forlogic-core 1.8.13 → 1.8.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import*as e from"react";import t,{useState as n,useMemo as r,createContext as a,useContext as s,useCallback as i,useEffect as o,memo as l,useRef as c,Component as d}from"react";import{Slot as u,createSlot as m}from"@radix-ui/react-slot";import{cva as f}from"class-variance-authority";import{clsx as p}from"clsx";import{twMerge as h}from"tailwind-merge";import{parseISO as g,isValid as x,format as y}from"date-fns";import{toast as b,Toaster as v}from"sonner";export{toast as sonnerToast}from"sonner";import{EllipsisVertical as w,X as N,ChevronDown as j,ChevronUp as k,Check as C,Loader2 as S,AlertCircle as E,Search as I,FileX as _,ChevronRight as T,Circle as P,Edit as A,PowerOff as R,Power as D,Trash2 as F,ArrowUpDown as z,ArrowUp as L,ArrowDown as O,Target as M,Trophy as $,Award as U,Sparkles as B,Flame as V,Zap as q,Key as H,Shield as W,EyeOff as Q,Eye as K,Unlock as Y,Lock as J,Archive as X,FolderOpen as G,Folder as Z,FileText as ee,Save as te,Copy as ne,Share as re,Upload as ae,Download as se,HelpCircle as ie,Info as oe,Bell as le,Clock as ce,ArrowRight as de,ArrowLeft as ue,ChevronLeft as me,Minus as fe,Plus as pe,Filter as he,Bookmark as ge,Book as xe,Video as ye,Music as be,Image as ve,Camera as we,MapPin as Ne,Calendar as je,Phone as ke,Mail as Ce,Settings as Se,User as Ee,Home as Ie,Heart as _e,Star as Te,ChevronsLeft as Pe,ChevronsRight as Ae,RefreshCw as Re,MoreHorizontal as De,PanelLeft as Fe,ExternalLink as ze,Building2 as Le,LogOut as Oe,AlertTriangle as Me,MessageCircle as $e,Send as Ue,Users as Be,Crown as Ve,UserPlus as qe}from"lucide-react";import*as He from"@radix-ui/react-label";import*as We from"@radix-ui/react-dialog";import{useFormContext as Qe,FormProvider as Ke,Controller as Ye,appendErrors as Je,useForm as Xe}from"react-hook-form";import*as Ge from"@radix-ui/react-select";import*as Ze from"@radix-ui/react-checkbox";import*as et from"@radix-ui/react-toast";import*as tt from"@radix-ui/react-popover";import{createClient as nt}from"@supabase/supabase-js";import{useQueryClient as rt,useQuery as at,useMutation as st,QueryClient as it}from"@tanstack/react-query";import{useSearchParams as ot,useLocation as lt,useNavigate as ct,Link as dt}from"react-router-dom";import*as ut from"@radix-ui/react-alert-dialog";import*as mt from"@radix-ui/react-dropdown-menu";import*as ft from"@radix-ui/react-scroll-area";import*as pt from"@radix-ui/react-accordion";import*as ht from"@radix-ui/react-aspect-ratio";import*as gt from"@radix-ui/react-avatar";import{DayPicker as xt}from"react-day-picker";import*as yt from"@radix-ui/react-collapsible";import*as bt from"@radix-ui/react-progress";import*as vt from"@radix-ui/react-radio-group";import*as wt from"@radix-ui/react-separator";import*as Nt from"@radix-ui/react-tooltip";import*as jt from"@radix-ui/react-slider";import{useTheme as kt}from"next-themes";import"react-dom";import*as Ct from"@radix-ui/react-tabs";import*as St from"@radix-ui/react-toggle";import*as Et from"@radix-ui/react-toggle-group";import{z as It}from"zod";import{validateFieldsNatively as _t,toNestErrors as Tt}from"@hookform/resolvers";function Pt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var At,Rt={exports:{}},Dt={};var Ft,zt,Lt={};
1
+ import*as e from"react";import t,{useState as n,useMemo as r,createContext as a,useContext as s,useCallback as i,useEffect as o,memo as l,useRef as c,Component as d}from"react";import{Slot as u,createSlot as m}from"@radix-ui/react-slot";import{cva as f}from"class-variance-authority";import{clsx as p}from"clsx";import{twMerge as h}from"tailwind-merge";import{parseISO as g,isValid as x,format as y}from"date-fns";import{toast as v,Toaster as b}from"sonner";export{toast as sonnerToast}from"sonner";import{EllipsisVertical as w,X as j,ChevronDown as N,ChevronUp as k,Check as C,Loader2 as S,AlertCircle as E,Search as I,FileX as T,ChevronRight as A,Circle as P,Edit as _,PowerOff as F,Power as R,Trash2 as D,ArrowUpDown as O,ArrowUp as z,ArrowDown as L,Target as M,Trophy as U,Award as $,Sparkles as B,Flame as V,Zap as q,Key as H,Shield as W,EyeOff as K,Eye as Q,Unlock as Y,Lock as J,Archive as X,FolderOpen as G,Folder as Z,FileText as ee,Save as te,Copy as ne,Share as re,Upload as ae,Download as se,HelpCircle as ie,Info as oe,Bell as le,Clock as ce,ArrowRight as de,ArrowLeft as ue,ChevronLeft as me,Minus as fe,Plus as pe,Filter as he,Bookmark as ge,Book as xe,Video as ye,Music as ve,Image as be,Camera as we,MapPin as je,Calendar as Ne,Phone as ke,Mail as Ce,Settings as Se,User as Ee,Home as Ie,Heart as Te,Star as Ae,ChevronsLeft as Pe,ChevronsRight as _e,RefreshCw as Fe,MoreHorizontal as Re,PanelLeft as De,ExternalLink as Oe,Building2 as ze,LogOut as Le,AlertTriangle as Me,MessageCircle as Ue,Send as $e,Users as Be,Crown as Ve,UserPlus as qe}from"lucide-react";import*as He from"@radix-ui/react-label";import*as We from"@radix-ui/react-dialog";import{useFormContext as Ke,FormProvider as Qe,Controller as Ye,appendErrors as Je,useForm as Xe}from"react-hook-form";import*as Ge from"@radix-ui/react-select";import*as Ze from"@radix-ui/react-checkbox";import*as et from"@radix-ui/react-toast";import*as tt from"@radix-ui/react-popover";import{createClient as nt}from"@supabase/supabase-js";import{useQueryClient as rt,useQuery as at,useMutation as st,QueryClient as it}from"@tanstack/react-query";import{useSearchParams as ot,useLocation as lt,useNavigate as ct,Link as dt}from"react-router-dom";import*as ut from"@radix-ui/react-alert-dialog";import*as mt from"@radix-ui/react-dropdown-menu";import*as ft from"@radix-ui/react-scroll-area";import*as pt from"@radix-ui/react-accordion";import*as ht from"@radix-ui/react-aspect-ratio";import*as gt from"@radix-ui/react-avatar";import{DayPicker as xt}from"react-day-picker";import*as yt from"@radix-ui/react-collapsible";import*as vt from"@radix-ui/react-progress";import*as bt from"@radix-ui/react-radio-group";import*as wt from"@radix-ui/react-separator";import*as jt from"@radix-ui/react-tooltip";import*as Nt from"@radix-ui/react-slider";import{useTheme as kt}from"next-themes";import"react-dom";import*as Ct from"@radix-ui/react-tabs";import*as St from"@radix-ui/react-toggle";import*as Et from"@radix-ui/react-toggle-group";import{z as It}from"zod";import{validateFieldsNatively as Tt,toNestErrors as At}from"@hookform/resolvers";function Pt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _t,Ft={exports:{}},Rt={};var Dt,Ot,zt={};
2
2
  /**
3
3
  * @license React
4
4
  * react-jsx-runtime.development.js
@@ -7,4 +7,4 @@ import*as e from"react";import t,{useState as n,useMemo as r,createContext as a,
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */function Ot(){return Ft||(Ft=1,"production"!==process.env.NODE_ENV&&function(){var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),h=Symbol.iterator;var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];!function(e,t,n){var r=g.ReactDebugCurrentFrame,a=r.getStackAddendum();""!==a&&(t+="%s",n=n.concat([a]));var s=n.map(function(e){return String(e)});s.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,s)}("error",e,n)}var y;function b(e){return e.displayName||"Context"}function v(e){if(null==e)return null;if("number"==typeof e.tag&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case r:return"Portal";case i:return"Profiler";case s:return"StrictMode";case d:return"Suspense";case u:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return b(e)+".Consumer";case o:return b(e._context)+".Provider";case c:return function(e,t,n){var r=e.displayName;if(r)return r;var a=t.displayName||t.name||"";return""!==a?n+"("+a+")":n}(e,e.render,"ForwardRef");case m:var t=e.displayName||null;return null!==t?t:v(e.type)||"Memo";case f:var n=e,p=n._payload,h=n._init;try{return v(h(p))}catch(g){return null}}return null}y=Symbol.for("react.module.reference");var w,N,j,k,C,S,E,I=Object.assign,_=0;function T(){}T.__reactDisabledLog=!0;var P,A=g.ReactCurrentDispatcher;function R(e,t,n){if(void 0===P)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);P=r&&r[1]||""}return"\n"+P+e}var D,F=!1,z="function"==typeof WeakMap?WeakMap:Map;function L(e,t){if(!e||F)return"";var n,r=D.get(e);if(void 0!==r)return r;F=!0;var a,s=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=A.current,A.current=null,function(){if(0===_){w=console.log,N=console.info,j=console.warn,k=console.error,C=console.group,S=console.groupCollapsed,E=console.groupEnd;var e={configurable:!0,enumerable:!0,value:T,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}_++}();try{if(t){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(p){n=p}Reflect.construct(e,[],i)}else{try{i.call()}catch(p){n=p}e.call(i.prototype)}}else{try{throw Error()}catch(p){n=p}e()}}catch(h){if(h&&n&&"string"==typeof h.stack){for(var o=h.stack.split("\n"),l=n.stack.split("\n"),c=o.length-1,d=l.length-1;c>=1&&d>=0&&o[c]!==l[d];)d--;for(;c>=1&&d>=0;c--,d--)if(o[c]!==l[d]){if(1!==c||1!==d)do{if(c--,--d<0||o[c]!==l[d]){var u="\n"+o[c].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,u),u}}while(c>=1&&d>=0);break}}}finally{F=!1,A.current=a,function(){if(0===--_){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},e,{value:w}),info:I({},e,{value:N}),warn:I({},e,{value:j}),error:I({},e,{value:k}),group:I({},e,{value:C}),groupCollapsed:I({},e,{value:S}),groupEnd:I({},e,{value:E})})}_<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=s}var m=e?e.displayName||e.name:"",f=m?R(m):"";return"function"==typeof e&&D.set(e,f),f}function O(e,t,n){if(null==e)return"";if("function"==typeof e)return L(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if("string"==typeof e)return R(e);switch(e){case d:return R("Suspense");case u:return R("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return L(e.render,!1);case m:return O(e.type,t,n);case f:var r=e,a=r._payload,s=r._init;try{return O(s(a),t,n)}catch(i){}}return""}D=new z;var M=Object.prototype.hasOwnProperty,$={},U=g.ReactDebugCurrentFrame;function B(e){if(e){var t=e._owner,n=O(e.type,e._source,t?t.type:null);U.setExtraStackFrame(n)}else U.setExtraStackFrame(null)}var V=Array.isArray;function q(e){return V(e)}function H(e){return""+e}function W(e){if(function(e){try{return H(e),!1}catch(t){return!0}}(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),H(e)}var Q,K,Y=g.ReactCurrentOwner,J={key:!0,ref:!0,__self:!0,__source:!0};function X(e,t,r,a,s){var i,o={},l=null,c=null;for(i in void 0!==r&&(W(r),l=""+r),function(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(W(t.key),l=""+t.key),function(e){if(M.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e){"string"==typeof e.ref&&Y.current}(t)),t)M.call(t,i)&&!J.hasOwnProperty(i)&&(o[i]=t[i]);if(e&&e.defaultProps){var d=e.defaultProps;for(i in d)void 0===o[i]&&(o[i]=d[i])}if(l||c){var u="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var n=function(){Q||(Q=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(o,u),c&&function(e,t){var n=function(){K||(K=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}(o,u)}return function(e,t,r,a,s,i,o){var l={$$typeof:n,type:e,key:t,ref:r,props:o,_owner:i,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,s,a,Y.current,o)}var G,Z=g.ReactCurrentOwner,ee=g.ReactDebugCurrentFrame;function te(e){if(e){var t=e._owner,n=O(e.type,e._source,t?t.type:null);ee.setExtraStackFrame(n)}else ee.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}function re(){if(Z.current){var e=v(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}G=!1;var ae={};function se(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var n=function(e){var t=re();if(!t){var n="string"==typeof e?e:e.displayName||e.name;n&&(t="\n\nCheck the top-level render call using <"+n+">.")}return t}(t);if(!ae[n]){ae[n]=!0;var r="";e&&e._owner&&e._owner!==Z.current&&(r=" It was passed a child from "+v(e._owner.type)+"."),te(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),te(null)}}}function ie(e,t){if("object"==typeof e)if(q(e))for(var n=0;n<e.length;n++){var r=e[n];ne(r)&&se(r,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var a=function(e){if(null===e||"object"!=typeof e)return null;var t=h&&e[h]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof a&&a!==e.entries)for(var s,i=a.call(e);!(s=i.next()).done;)ne(s.value)&&se(s.value,t)}}function oe(e){var t,n=e.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)t=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==c&&n.$$typeof!==m)return;t=n.propTypes}if(t){var r=v(n);!function(e,t,n,r,a){var s=Function.call.bind(M);for(var i in e)if(s(e,i)){var o=void 0;try{if("function"!=typeof e[i]){var l=Error((r||"React class")+": "+n+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}o=e[i](t,i,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){o=c}!o||o instanceof Error||(B(a),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",n,i,typeof o),B(null)),o instanceof Error&&!(o.message in $)&&($[o.message]=!0,B(a),x("Failed %s type: %s",n,o.message),B(null))}}(t,e.props,"prop",r,e)}else if(void 0!==n.PropTypes&&!G){G=!0,x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",v(n)||"Unknown")}"function"!=typeof n.getDefaultProps||n.getDefaultProps.isReactClassApproved||x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var le={};function ce(e,t,r,h,g,b){var w=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===i||e===s||e===d||e===u||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===m||e.$$typeof===o||e.$$typeof===l||e.$$typeof===c||e.$$typeof===y||void 0!==e.getModuleId)}(e);if(!w){var N="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(N+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var j;N+=re(),null===e?j="null":q(e)?j="array":void 0!==e&&e.$$typeof===n?(j="<"+(v(e.type)||"Unknown")+" />",N=" Did you accidentally export a JSX literal instead of a component?"):j=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",j,N)}var k=X(e,t,r,g,b);if(null==k)return k;if(w){var C=t.children;if(void 0!==C)if(h)if(q(C)){for(var S=0;S<C.length;S++)ie(C[S],e);Object.freeze&&Object.freeze(C)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ie(C,e)}if(M.call(t,"key")){var E=v(e),I=Object.keys(t).filter(function(e){return"key"!==e}),_=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!le[E+_])x('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',_,E,I.length>0?"{"+I.join(": ..., ")+": ...}":"{}",E),le[E+_]=!0}return e===a?function(e){for(var t=Object.keys(e.props),n=0;n<t.length;n++){var r=t[n];if("children"!==r&&"key"!==r){te(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),te(null);break}}null!==e.ref&&(te(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}(k):oe(k),k}var de=function(e,t,n){return ce(e,t,n,!1)},ue=function(e,t,n){return ce(e,t,n,!0)};Lt.Fragment=a,Lt.jsx=de,Lt.jsxs=ue}()),Lt}var Mt=(zt||(zt=1,"production"===process.env.NODE_ENV?Rt.exports=function(){if(At)return Dt;At=1;var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(e,t,r){var o,l={},c=null,d=null;for(o in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(d=t.ref),t)a.call(t,o)&&!i.hasOwnProperty(o)&&(l[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===l[o]&&(l[o]=t[o]);return{$$typeof:n,type:e,key:c,ref:d,props:l,_owner:s.current}}return Dt.Fragment=r,Dt.jsx=o,Dt.jsxs=o,Dt}():Rt.exports=Ot()),Rt.exports);function $t(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{b.info("Link copiado para a área de transferência")})}function Ut(...e){return h(p(e))}const Bt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Bt);if("object"==typeof e&&e.constructor===Object){const t={};for(const[n,r]of Object.entries(e))t[n]=Bt(r);return t}return e},Vt=e=>{if(!e)return"";const t=g(e);if(!x(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`},qt=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),Ht=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},Wt=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),Qt=f("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium 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 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",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:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6"}},defaultVariants:{variant:"default",size:"default"}}),Kt=e.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...a},s)=>{const i=r?u:"button";return Mt.jsx(i,{className:Ut(Qt({variant:t,size:n,className:e})),ref:s,...a})});Kt.displayName="Button";const Yt=t.forwardRef(({variant:e="default",className:t,children:n,...r},a)=>Mt.jsx(Kt,{ref:a,variant:"action",size:"sm",className:Ut("h-7 px-2 text-xs",t),...r,children:n||Mt.jsx(w,{size:12})}));Yt.displayName="ActionButton";const Jt=e.forwardRef(({className:e,type:t,...n},r)=>Mt.jsx("input",{type:t,className:Ut("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Jt.displayName="Input";const Xt=f("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Gt=e.forwardRef(({className:e,...t},n)=>Mt.jsx(He.Root,{ref:n,className:Ut(Xt(),e),...t}));Gt.displayName=He.Root.displayName;const Zt=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Zt.displayName="Card";const en=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("flex flex-col space-y-1.5 p-6",e),...t}));en.displayName="CardHeader";const tn=e.forwardRef(({className:e,...t},n)=>Mt.jsx("h3",{ref:n,className:Ut("text-2xl font-semibold leading-none tracking-tight",e),...t}));tn.displayName="CardTitle";const nn=e.forwardRef(({className:e,...t},n)=>Mt.jsx("p",{ref:n,className:Ut("text-sm text-muted-foreground",e),...t}));nn.displayName="CardDescription";const rn=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("p-6 pt-0",e),...t}));rn.displayName="CardContent";const an=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("flex items-center p-6 pt-0",e),...t}));an.displayName="CardFooter";const sn=We.Root,on=We.Trigger,ln=We.Portal,cn=We.Close,dn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Overlay,{ref:n,className:Ut("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));dn.displayName=We.Overlay.displayName;const un=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(ln,{children:[Mt.jsx(dn,{}),Mt.jsxs(We.Content,{ref:r,className:Ut("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 bg-background p-6 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-h-[90vh] overflow-auto",e),...n,children:[t,Mt.jsxs(We.Close,{className:"absolute right-4 top-4 z-10 rounded-sm text-white opacity-70 ring-offset-background transition-opacity hover:opacity-100 hover:text-white focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[Mt.jsx(N,{className:"h-4 w-4"}),Mt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));un.displayName=We.Content.displayName;const mn=({className:e,...t})=>Mt.jsx("div",{className:Ut("flex flex-col space-y-1.5 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-3 rounded-t-lg",e),...t});mn.displayName="DialogHeader";const fn=({className:e,...t})=>Mt.jsx("div",{className:Ut("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});fn.displayName="DialogFooter";const pn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Title,{ref:n,className:Ut("text-lg font-semibold leading-none tracking-tight",e),...t}));pn.displayName=We.Title.displayName;const hn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Description,{ref:n,className:Ut("text-sm text-muted-foreground",e),...t}));hn.displayName=We.Description.displayName;const gn=Ke,xn=e.createContext({}),yn=({...e})=>Mt.jsx(xn.Provider,{value:{name:e.name},children:Mt.jsx(Ye,{...e})}),bn=()=>{const t=e.useContext(xn),n=e.useContext(vn),{getFieldState:r,formState:a}=Qe(),s=r(t.name,a);if(!t)throw new Error("useFormField should be used within <FormField>");const{id:i}=n;return{id:i,name:t.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...s}},vn=e.createContext({}),wn=e.forwardRef(({className:t,...n},r)=>{const a=e.useId();return Mt.jsx(vn.Provider,{value:{id:a},children:Mt.jsx("div",{ref:r,className:Ut("space-y-2",t),...n})})});wn.displayName="FormItem";const Nn=e.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:a}=bn();return Mt.jsx(Gt,{ref:n,className:Ut(r&&"text-destructive",e),htmlFor:a,...t})});Nn.displayName="FormLabel";const jn=e.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:a,formMessageId:s}=bn();return Mt.jsx(u,{ref:t,id:r,"aria-describedby":n?`${a} ${s}`:`${a}`,"aria-invalid":!!n,...e})});jn.displayName="FormControl";const kn=e.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=bn();return Mt.jsx("p",{ref:n,id:r,className:Ut("text-sm text-muted-foreground",e),...t})});kn.displayName="FormDescription";const Cn=e.forwardRef(({className:e,children:t,...n},r)=>{const{error:a,formMessageId:s}=bn(),i=a?String(a?.message):t;return i?Mt.jsx("p",{ref:r,id:s,className:Ut("text-sm font-medium text-destructive",e),...n,children:i}):null});Cn.displayName="FormMessage";const Sn=Ge.Root,En=Ge.Group,In=Ge.Value,_n=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(Ge.Trigger,{ref:r,className:Ut("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,Mt.jsx(Ge.Icon,{asChild:!0,children:Mt.jsx(j,{className:"h-4 w-4 opacity-50"})})]}));_n.displayName=Ge.Trigger.displayName;const Tn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ge.ScrollUpButton,{ref:n,className:Ut("flex cursor-default items-center justify-center py-1",e),...t,children:Mt.jsx(k,{className:"h-4 w-4"})}));Tn.displayName=Ge.ScrollUpButton.displayName;const Pn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ge.ScrollDownButton,{ref:n,className:Ut("flex cursor-default items-center justify-center py-1",e),...t,children:Mt.jsx(j,{className:"h-4 w-4"})}));Pn.displayName=Ge.ScrollDownButton.displayName;const An=e.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>Mt.jsx(Ge.Portal,{children:Mt.jsxs(Ge.Content,{ref:a,className:Ut("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"===n&&"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:n,...r,children:[Mt.jsx(Tn,{}),Mt.jsx(Ge.Viewport,{className:Ut("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),Mt.jsx(Pn,{})]})}));An.displayName=Ge.Content.displayName;const Rn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ge.Label,{ref:n,className:Ut("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Rn.displayName=Ge.Label.displayName;const Dn=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(Ge.Item,{ref:r,className:Ut("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[Mt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Mt.jsx(Ge.ItemIndicator,{children:Mt.jsx(C,{className:"h-4 w-4"})})}),Mt.jsx(Ge.ItemText,{children:t})]}));Dn.displayName=Ge.Item.displayName;const Fn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ge.Separator,{ref:n,className:Ut("-mx-1 my-1 h-px bg-muted",e),...t}));Fn.displayName=Ge.Separator.displayName;const zn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ze.Root,{ref:n,className:Ut("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:Mt.jsx(Ze.Indicator,{className:Ut("flex items-center justify-center text-current"),children:Mt.jsx(C,{className:"h-4 w-4"})})}));zn.displayName=Ze.Root.displayName;const Ln=e.forwardRef(({className:e,...t},n)=>Mt.jsx("textarea",{className:Ut("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ln.displayName="Textarea";const On=f("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500 text-white hover:bg-green-600",warning:"border-transparent bg-yellow-500 text-white hover:bg-yellow-600",info:"border-transparent bg-blue-500 text-white hover:bg-blue-600"}},defaultVariants:{variant:"default"}}),Mn=e.forwardRef(({className:e,variant:t,...n},r)=>Mt.jsx("div",{ref:r,className:Ut(On({variant:t}),e),...n}));Mn.displayName="Badge";const $n={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Un({size:e="md",className:t}){return Mt.jsx(S,{className:Ut("animate-spin text-muted-foreground",$n[e],t)})}function Bn({isLoading:e,children:t,className:n,type:r="spinner",size:a="md"}){return e?"overlay"===r?Mt.jsxs("div",{className:Ut("relative",n),children:[t,Mt.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:Mt.jsx(Un,{size:a})})]}):"skeleton"===r?Mt.jsx("div",{className:Ut("animate-pulse",n),children:Mt.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):Mt.jsx("div",{className:Ut("flex items-center justify-center py-8",n),children:Mt.jsx(Un,{size:a})}):Mt.jsx(Mt.Fragment,{children:t})}let Vn=0;const qn=new Map,Hn=e=>{if(qn.has(e))return;const t=setTimeout(()=>{qn.delete(e),Yn({type:"REMOVE_TOAST",toastId:e})},1e6);qn.set(e,t)},Wn=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Hn(n):e.toasts.forEach(e=>{Hn(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===n||void 0===n?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},Qn=[];let Kn={toasts:[]};function Yn(e){Kn=Wn(Kn,e),Qn.forEach(e=>{e(Kn)})}function Jn({...e}){const t=(Vn=(Vn+1)%Number.MAX_SAFE_INTEGER,Vn.toString()),n=()=>Yn({type:"DISMISS_TOAST",toastId:t});return Yn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||n()}}}),{id:t,dismiss:n,update:e=>Yn({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function Xn(){const[t,n]=e.useState(Kn);return e.useEffect(()=>(Qn.push(n),()=>{const e=Qn.indexOf(n);e>-1&&Qn.splice(e,1)}),[t]),{...t,toast:Jn,dismiss:e=>Yn({type:"DISMISS_TOAST",toastId:e})}}const Gn=et.Provider,Zn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Viewport,{ref:n,className:Ut("fixed top-4 left-1/2 transform -translate-x-1/2 z-[100] flex max-h-screen w-full max-w-[420px] flex-col p-4",e),...t}));Zn.displayName=et.Viewport.displayName;const er=f("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),tr=e.forwardRef(({className:e,variant:t,...n},r)=>Mt.jsx(et.Root,{ref:r,className:Ut(er({variant:t}),e),...n}));tr.displayName=et.Root.displayName;const nr=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Action,{ref:n,className:Ut("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));nr.displayName=et.Action.displayName;const rr=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Close,{ref:n,className:Ut("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:Mt.jsx(N,{className:"h-4 w-4"})}));rr.displayName=et.Close.displayName;const ar=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Title,{ref:n,className:Ut("text-sm font-semibold",e),...t}));ar.displayName=et.Title.displayName;const sr=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Description,{ref:n,className:Ut("text-sm opacity-90",e),...t}));function ir(){const{toasts:e}=Xn();return Mt.jsxs(Gn,{children:[e.map(function({id:e,title:t,description:n,action:r,...a}){return Mt.jsxs(tr,{...a,children:[Mt.jsxs("div",{className:"grid gap-1",children:[t&&Mt.jsx(ar,{children:t}),n&&Mt.jsx(sr,{children:n})]}),r,Mt.jsx(rr,{})]},e)}),Mt.jsx(Zn,{})]})}sr.displayName=et.Description.displayName;const or=tt.Root,lr=tt.Trigger,cr=e.forwardRef(({className:e,align:t="center",sideOffset:n=4,container:r,...a},s)=>Mt.jsx(tt.Portal,{container:r,children:Mt.jsx(tt.Content,{ref:s,align:t,sideOffset:n,className:Ut("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),...a})}));cr.displayName=tt.Content.displayName;const dr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));dr.displayName="Command";const ur=({children:e,...t})=>Mt.jsx("div",{...t,children:Mt.jsx(dr,{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})}),mr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:Mt.jsx("input",{ref:n,className:Ut("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})}));mr.displayName="CommandInput";const fr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));fr.displayName="CommandList";const pr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("py-6 text-center text-sm text-muted-foreground",e),...t}));pr.displayName="CommandEmpty";const hr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));hr.displayName="CommandGroup";const gr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("-mx-1 h-px bg-border",e),...t}));gr.displayName="CommandSeparator";const xr=e.forwardRef(({className:e,disabled:t,onSelect:n,value:r,...a},s)=>Mt.jsx("div",{ref:s,className:Ut("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),"data-disabled":t,onClick:()=>!t&&n?.(r||""),...a}));xr.displayName="CommandItem";const yr=({className:e,...t})=>Mt.jsx("span",{className:Ut("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});function br({className:e,...t}){return Mt.jsx("div",{className:Ut("animate-pulse rounded-md bg-muted",e),...t})}yr.displayName="CommandShortcut";const vr=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function wr({options:e=[],value:t=[],onChange:a,getOptionValue:s=e=>e.value,getOptionLabel:i=e=>e.label,placeholder:o="Selecione itens...",label:l,icon:c,emptyMessage:d="Nenhum item disponível.",searchPlaceholder:u="Buscar...",disabled:m=!1,required:f=!1,isLoading:p=!1,error:h,className:g,sortOptions:x=!0,maxDisplayedBadges:y,popoverContainer:b,onOpen:v,onClose:w}){const[k,S]=n(!1),[I,_]=n(""),T=r(()=>{if(!b)return;let e=b,t=0;try{for(;e&&t<3;){const n=window.getComputedStyle(e),r=n.overflowY||n.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[b]),P=r(()=>{const t=e.map(e=>({original:e,value:s(e),label:i(e)}));return x?t.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):t},[e,s,i,x]),A=r(()=>{if(!I)return P;const e=vr(I);return P.filter(t=>vr(t.label).includes(e))},[P,I]),R=r(()=>P.filter(e=>t.includes(e.value)),[P,t]),D=(e,n)=>{n.preventDefault(),n.stopPropagation(),a&&a(t.filter(t=>t!==e))};if(p)return Mt.jsxs("div",{className:Ut("space-y-2",g),children:[l&&Mt.jsxs(Gt,{children:[l,f&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsx(br,{className:"h-10 w-full"})]});const F="string"==typeof h?h:h?"Erro ao carregar dados":void 0;if(F)return Mt.jsxs("div",{className:Ut("space-y-2",g),children:[l&&Mt.jsxs(Gt,{children:[l,f&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[Mt.jsx(E,{className:"h-4 w-4"}),Mt.jsx("span",{className:"text-sm",children:F})]})]});const z=y?R.slice(0,y):R,L=y&&R.length>y?R.length-y:0;return Mt.jsxs("div",{className:Ut("space-y-2",g),children:[l&&Mt.jsxs(Gt,{children:[l,f&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsxs(or,{open:k,onOpenChange:e=>{S(e),e?v?.():(_(""),w?.())},modal:!1,children:[Mt.jsx(lr,{asChild:!0,children:Mt.jsxs(Kt,{variant:"outline",role:"combobox","aria-expanded":k,disabled:m,className:Ut("w-full justify-between min-h-10 h-auto",0===R.length&&"text-muted-foreground"),children:[0===R.length?Mt.jsxs("span",{className:"flex items-center gap-2",children:[c&&Mt.jsx(c,{className:"h-4 w-4"}),o]}):Mt.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[z.map(e=>Mt.jsxs(Mn,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,Mt.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&&D(e.value,t)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>D(e.value,t),children:Mt.jsx(N,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),L>0&&Mt.jsxs(Mn,{variant:"outline",className:"gap-1",children:["+",L]})]}),Mt.jsx(j,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),Mt.jsx(cr,{className:"w-full p-0 z-[60]",align:"start",container:T,collisionBoundary:T,children:Mt.jsxs(dr,{children:[Mt.jsx(mr,{placeholder:u,value:I,onChange:e=>_(e.target.value)}),Mt.jsx(fr,{children:0===e.length?Mt.jsx(pr,{children:d}):0===A.length?Mt.jsx(pr,{children:"Nenhum item encontrado."}):Mt.jsx(hr,{children:A.map(e=>Mt.jsxs(xr,{value:e.value,onSelect:()=>(e=>{if(!a)return;const n=t.includes(e)?t.filter(t=>t!==e):[...t,e];a(n)})(e.value),className:"cursor-pointer",children:[Mt.jsx(C,{className:Ut("mr-2 h-4 w-4",t.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})})]})})]}),F&&Mt.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1",children:[Mt.jsx(E,{className:"h-3 w-3"}),F]})]})}var Nr=Object.defineProperty;class jr{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const n=(4-t.length%4)%4;return t+="=".repeat(n),t}static parseJwtPayload(e){try{const a=e.split(".");if(3!==a.length)return null;const s=a[1];s.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(s),t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);const r=new TextDecoder("utf-8").decode(n);return JSON.parse(r)}catch(t){try{const e=this.normalizeBase64Url(s),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(n){try{const e=this.normalizeBase64Url(s),t=atob(e);return JSON.parse(t)}catch(r){throw r}}}}catch(a){return null}}static validateTokens(e,t){const n=[],r=[];try{t.split(".")[1],e.split(".")[1];const a=this.parseJwtPayload(t),s=this.parseJwtPayload(e);if(!a){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:n,errors:r}}let i=!0;if(!s){const e="Access token decode falhou - será tentado novamente nas chamadas de API";n.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(s?.exp&&s.exp<o){const e="Access token expirado - pode precisar de refresh";n.push(e),i=!1}if(a.exp&&a.exp<o){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:n,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:n,errors:r}}catch(a){const e=`Erro na validação de tokens: ${a}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:n,errors:r}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,t,n)=>{t in e?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(jr,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const kr="qualiex_access_token",Cr="qualiex_id_token",Sr="supabase_token",Er="oauth_state",Ir="oauth_nonce",_r="selected_alias",Tr="manual_logout",Pr={setAccessToken:e=>localStorage.setItem(kr,e),getAccessToken:()=>localStorage.getItem(kr),setIdToken:e=>localStorage.setItem(Cr,e),getIdToken:()=>localStorage.getItem(Cr),getSupabaseToken:()=>localStorage.getItem(Sr),setOAuthState:e=>sessionStorage.setItem(Er,e),getOAuthState:()=>sessionStorage.getItem(Er),clearOAuthState:()=>sessionStorage.removeItem(Er),setOAuthNonce:e=>sessionStorage.setItem(Ir,e),getOAuthNonce:()=>sessionStorage.getItem(Ir),clearOAuthNonce:()=>sessionStorage.removeItem(Ir),setSelectedAlias:e=>localStorage.setItem(_r,e),getSelectedAlias:()=>localStorage.getItem(_r),clearSelectedAlias:()=>localStorage.removeItem(_r),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!Pr.getAccessToken()||!Pr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Sr,e),Pr._clearValidationCache()},areAllTokensValid:()=>{const e=Pr.getAccessToken(),t=Pr.getIdToken();if(!e||!t)return!1;try{const n=jr.validateTokens(e,t);return!!n.idTokenValid&&n.idTokenValid}catch(n){return!1}},clearExpiredTokens:()=>{let e=!1;const t=Pr.getAccessToken(),n=Pr.getIdToken(),r=Pr.getSupabaseToken();return t&&Pr.isTokenExpired(t)&&(localStorage.removeItem(kr),e=!0),n&&Pr.isTokenExpired(n)&&(localStorage.removeItem(Cr),e=!0),r&&Pr.isTokenExpired(r)&&(localStorage.removeItem(Sr),e=!0),e},clearAll:()=>{localStorage.removeItem(kr),localStorage.removeItem(Cr),localStorage.removeItem(Sr),localStorage.removeItem(_r),localStorage.removeItem(Tr),sessionStorage.removeItem(Er),sessionStorage.removeItem(Ir)},setManualLogout:()=>localStorage.setItem(Tr,"true"),isManualLogout:()=>"true"===localStorage.getItem(Tr),clearManualLogout:()=>localStorage.removeItem(Tr),isTokenExpired:e=>{try{return jr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{Pr._validationCache.isValid=!1,Pr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=Pr.getSupabaseToken();if(!e)return!1;if(Pr.isTokenExpired(e))return Pr._clearValidationCache(),Pr._handleExpiredToken(),!1;const t=Date.now();return t-Pr._validationCache.timestamp<Pr._validationCache.cacheValidityMs?Pr._validationCache.isValid:(Pr._validationCache.isValid=!0,Pr._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>Pr.isSupabaseTokenValid()?Pr.getSupabaseToken():null,_handleExpiredToken:()=>{Pr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!Pr.isSupabaseTokenValid())return null;const e=Pr.getSupabaseToken();if(!e)return null;try{const t=jr.parseJwtPayload(e);if(!t)return null;const n=t.alias||t.default||t.user_alias,r=t.place_id||null,a=t.place_name||null;let s=t.company_id;if(!s&&n)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]===n){s=e[7];break}}}return{alias:n,companyId:s,placeId:r,placeName:a,payload:t}}catch(t){return Pr._handleExpiredToken(),null}},getCompanyId:e=>{const t=Pr.getAccessToken();if(t)try{const n=jr.parseJwtPayload(t);if(n)for(const t in n)if(t.startsWith("co")&&/^co\d+$/.test(t)){const r=n[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(a){}const n=Pr.extractTokenData();if(n?.companyId)return n.companyId;const r=Pr.getIdToken();if(r)try{const t=jr.parseJwtPayload(r);if(t)for(const n in t)if(n.startsWith("co")&&/^co\d+$/.test(n)){const r=t[n];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(a){}return null},getCurrentCompanyId:()=>{const e=Pr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=Pr.getIdToken();if(!e)return[];try{const t=jr.parseJwtPayload(e);if(!t)return[];const n=[];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&&n.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return n}catch{return[]}}};var Ar=Object.defineProperty,Rr=(e,t,n)=>((e,t,n)=>t in e?Ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const Dr=new class{constructor(){Rr(this,"errors",[]),Rr(this,"toastCount",0),Rr(this,"lastToastTime",0)}handleError(e,t=!0){const n="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:n,timestamp:Date.now(),count:1}),t&&this.shouldShowToast()){Jn({title:this.getErrorTitle(n),description:n,variant:"destructive"})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){Jn({title:e,description:t,variant:"default"})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var Fr=Object.defineProperty,zr=(e,t,n)=>((e,t,n)=>t in e?Fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const Lr=import.meta.env.VITE_SUPABASE_URL,Or=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,Mr=class e{constructor(){zr(this,"client"),zr(this,"currentToken",null),zr(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:Or};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return nt(Lr,Or,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,t)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=Pr.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const t=JSON.parse(atob(e.split(".")[1])),n=Math.floor(Date.now()/1e3);return t.exp>n}catch(t){return Dr.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};zr(Mr,"instance");let $r=Mr;function Ur(){return $r.getInstance().getClient()}class Br{static async generateToken(e,t,n,r=!1){try{if(!r){const e=Pr.getSupabaseToken();if(e&&Pr.isSupabaseTokenValid())return e}const a=Ur(),{data:s,error:i}=await a.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(n?.(),null):s?.access_token&&s.access_token?(Pr.setSupabaseToken(s.access_token),s.access_token):null}catch(a){return a instanceof Error&&(a.message.includes("401")||a.message.includes("Unauthorized"))&&n?.(),null}}}var Vr=Object.defineProperty,qr=(e,t,n)=>((e,t,n)=>t in e?Vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class Hr{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=Pr.getAccessToken(),t=Pr.getSelectedAlias();if(!e||!t)return null;const n=await Br.generateToken(e,t,this.onLogoutCallback||void 0,!1);return n?(Pr.setSupabaseToken(n),n):null}catch(e){return null}finally{this.isRegenerating=!1}}}qr(Hr,"isRegenerating",!1),qr(Hr,"onLogoutCallback",null);class Wr{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(Pr.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const n=t.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>n.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 Qr=Object.defineProperty;class Kr{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,n=e.message||e.toString();if(401===t||n.includes("401")||n.includes("Unauthorized")){this.isRetrying=!0;try{return await Hr.attemptRegeneration()?(this.isRetrying=!1,!0):(Wr.handleError(e),this.isRetrying=!1,!1)}catch(r){return Wr.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=Pr.getAccessToken();return e?Pr.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,n)=>{((e,t,n)=>{t in e?Qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,t+"",n)})(Kr,"isRetrying",!1);var Yr=Object.defineProperty,Jr=(e,t,n)=>((e,t,n)=>t in e?Yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const Xr=new class{constructor(){Jr(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=Kr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=Pr.getAccessToken();if(!a)throw new Error("Token Qualiex não encontrado");if(!n||""===n.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const s=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{s.searchParams.append(e,t)});const i=await fetch(s.toString(),{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json",Accept:"application/json","un-alias":n}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}mapToQualiexUser(e){return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0}}async fetchUsers(e,t){try{const n=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=n;if(n.data)r=n.data;else{if(!Array.isArray(n))return Dr.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=n}if(!Array.isArray(r))return Dr.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(n){if(await Kr.handleApiError(n))try{const n=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=n;if(n.data)r=n.data;else{if(!Array.isArray(n))return Dr.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=n}return Array.isArray(r)?r.map(this.mapToQualiexUser):(Dr.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return Dr.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}const a=n instanceof Error?n.message:"Erro ao buscar usuários da API Qualiex";return Dr.handleError(a,!0),[]}}async fetchUserById(e,t,n){try{return(await this.fetchUsers(t,n)).find(t=>t.userId===e)||null}catch(r){return Dr.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const n=await this.fetchUsers(e,t),r=new Map;return n.forEach(e=>{r.set(e.userId,e)}),r}async getUsers(e){const t=Pr.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}},Gr={oauth:{authUrl:import.meta.env.VITE_OAUTH_AUTH_URL,clientId:import.meta.env.VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},Zr={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},ea={debounceDelay:500},ta=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||import.meta.env.DEV},na={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]};let ra={enableUserEnrichment:!1,enableUsersApi:!1,userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"};const aa=()=>ra,sa=e=>{ra={...ra,...e}},ia={success:{created:e=>`${e} criado com sucesso`,updated:e=>`${e} atualizado com sucesso`,deleted:e=>`${e} removido com sucesso`},error:{create:e=>`Erro ao criar ${e}`,update:e=>`Erro ao atualizar ${e}`,delete:e=>`Erro ao remover ${e}`,load:e=>`Erro ao carregar ${e}`}};function oa(e,t){const n=aa(),r=t||n.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function la(e,t){const n=aa(),r=t||n.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function ca(e,t){const n=aa(),r=t||n.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function da(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||oa(e.idField),emailField:e.emailField||la(e.idField),usernameField:e.usernameField||ca(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:oa(e),emailField:la(e),usernameField:ca(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const ua=new Map;class ma{static async fetchQualiexUsers(e,t){const n=aa(),r=`${t}_${e}`,a=ua.get(r);if(a&&Date.now()-a.timestamp<3e5)return a.users;let s;return s=n.fetchUsers?await n.fetchUsers(t,e):await Xr.fetchUsers(e,t),ua.set(r,{users:s,timestamp:Date.now()}),s}static extractUserIds(e,t){const n=new Set;for(const r of e)for(const e of t){const t=r[e.idField];t&&"string"==typeof t&&""!==t.trim()&&n.add(t)}return n}static indexUsers(e){const t=new Map;for(const n of e)n.id&&t.set(n.id,n),n.userId&&t.set(n.userId,n);return t}static enrichEntity(e,t,n){const r={...e};for(const a of t){const t=e[a.idField];if(!t)continue;const s=n.get(t);if(s){if(a.nameField){r[a.nameField]||(r[a.nameField]=s.userName||s.displayName||null)}if(a.emailField){r[a.emailField]||(r[a.emailField]=s.userEmail||null)}if(a.usernameField){r[a.usernameField]||(r[a.usernameField]=s.userName||null)}}}return r}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{const n=aa();let r=null,a=null;if(n.getCompanyId){const e=n.getCompanyId();a=e instanceof Promise?await e:e}if(n.getAccessToken){const t=n.getAccessToken();if(!(t instanceof Promise?await t:t))return e}if(!r||!a){const t=Pr.extractTokenData();if(!t)return e;r=r||t.alias,a=a||t.companyId}if(!r||!a)return e;const s=da(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,s).size)return e;const i=await this.fetchQualiexUsers(r,a),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,s,o))}catch(n){return Dr.handleError(n instanceof Error?n:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,t){return this.enrichWithUserData(e,{entityName:t.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const fa=["responsible_name"],pa=e=>fa.includes(e);function ha(e,t,n){const r="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:n||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:a,searchFields:s,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:c=!1}=r,d=()=>{if(!Pr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Ur().schema(o).from(a)};return{async getAll(e={}){const{search:t="",sortField:n="updated_at",sortDirection:o="desc",page:u=1,limit:m=25,...f}=e;let p=d().select(i||"*",{count:"exact"});p=p.eq("is_removed",!1),Object.entries(f).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?p=p.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?p=p.not(e,"is",null):"is_null"===t.operator&&(p=p.is(e,null)):null!==t&&(p=p.eq(e,t)))}),p=((e,t)=>{if(t&&s.length>0){const n=s.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(n)}return e})(p,t);n.includes(".")||pa(n)||(p=p.order(n,{ascending:"asc"===o})),p=((e,t,n)=>{const r=(t-1)*n,a=r+n-1;return e.range(r,a)})(p,u,m);const{data:h,error:g,count:x}=await p;if(g)throw new Error(`Error fetching ${a}: ${g.message}`);let y=((e,t,n,r)=>{const a=Math.ceil((t||0)/r);return{data:e,currentPage:n,totalPages:a,totalItems:t||0,itemsPerPage:r,hasNextPage:n<a,hasPreviousPage:n>1}})(h||[],x,u,m);const b=aa();if(c&&b.enableUserEnrichment&&l&&y.data.length>0){const t=da(r.userIdFields,r.userFieldsMapping);if(y.data.some(e=>t.some(t=>e[t.idField]))){const a=n&&n.includes("."),s=n&&pa(n),i=n&&t.some(e=>e.nameField===n||e.emailField===n||e.usernameField===n);if(n&&(s||a||i)){const t={...e,page:1,limit:500,sortField:void 0,sortDirection:void 0},s=await this.getAll(t);if(!s?.data?.length)return s;const i=await ma.enrichWithUserData(s.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let c;c=a?i.sort((e,t)=>{const r=n.split(".").reduce((e,t)=>e?.[t],e)||"",a=n.split(".").reduce((e,t)=>e?.[t],t)||"",s=String(r).localeCompare(String(a),"pt-BR");return"asc"===o?s:-s}):((e,t,n)=>[...e].sort((e,r)=>{const a=e[t]||"",s=r[t]||"",i=a.localeCompare(s,"pt-BR",{sensitivity:"base"});return"asc"===n?i:-i}))(i,n,o);const d=((e,t=1,n=25)=>{const r=(t-1)*n,a=r+n,s=e.slice(r,a);return{data:s,pagination:{currentPage:t,totalPages:Math.ceil(e.length/n),totalItems:s.length,totalCount:e.length,itemsPerPage:n,hasNextPage:a<e.length,hasPreviousPage:t>1}}})(c,u,m);return{data:d.data,currentPage:d.pagination.currentPage,totalPages:d.pagination.totalPages,totalItems:d.pagination.totalCount,itemsPerPage:d.pagination.itemsPerPage,hasNextPage:d.pagination.hasNextPage,hasPreviousPage:d.pagination.hasPreviousPage}}const c=await ma.enrichWithUserData(y.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});y={...y,data:c}}}return y},async getById(e){const{data:t,error:n}=await d().select(i||"*").eq("id",e).maybeSingle();if(n)throw new Error(`Error fetching ${a}: ${n.message}`);return t},async create(e){const t=Bt(e),n=Object.entries(t).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),{data:r,error:s}=await d().insert(n).select().single();if(s)throw new Error(`Error creating ${a}: ${s.message}`);if(!r)throw new Error(`No data returned from create ${a} operation`);return r},async update(e,t){const n={...Bt(t),updated_at:(new Date).toISOString()},{data:r,error:s}=await d().update(n).eq("id",e).select().single();if(s)throw new Error(`Error updating ${a}: ${s.message}`);if(!r)throw new Error(`No data returned from update ${a} operation`);return r},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:n}=await d().update(t).eq("id",e);if(n)throw new Error(`Error soft deleting ${a}: ${n.message}`)}}}const ga=()=>{Pr.clearManualLogout()},xa=e=>e?.placeId||null,ya=e=>e?.placeName||null,ba=e=>({placeId:xa(e),placeName:ya(e)}),va=class{static async initialize(){try{if(!Pr.hasAllTokens()||!Pr.areAllTokensValid())return Pr.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};const t=Pr.getAccessToken(),n=Pr.getIdToken();ga();const r=this.extractUserFromIdToken(n),a=this.extractCompaniesFromIdToken(n),s=this.extractAliasFromAccessToken(t),i=Pr.extractTokenData(),o=i?.alias;let l=null;if(o&&a.some(e=>e.alias===o))l=o;else{const e=Pr.getSelectedAlias(),t=e&&a.some(t=>t.alias===e);l=t?e:s||a[0]?.alias||null}!Pr.isSupabaseTokenValid()&&l&&await Hr.attemptRegeneration();let c=null;if(l){const e=Pr.getCompanyId(l),t=a.find(e=>e.alias===l);t&&(c={id:e||t.id,name:t.name,alias:t.alias})}let d=null,u=null;if(r?.id&&l){const t=Pr.getCompanyId(l);if(t)try{const e=(await Xr.fetchActiveUsersMap(l,t)).get(r.id);if(e){const t=ba(e);d=t.placeId,u=t.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:r,alias:l,companies:a,selectedUnit:c,userId:r?.id||null,userAlias:r?.id||null,placeId:d,placeName:u,activePlaceId:d,activePlaceName:u}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null}}}static async loginDev(){try{const e=Ur(),{data:t,error:n}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(n)return!1;if(!t?.access_token||!t?.id_token)return!1;const r=new URL("/callback",window.location.origin);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=Pr.generateOAuthState();Pr.setOAuthState(e);const t=Pr.generateOAuthNonce();Pr.setOAuthNonce(t);const n=`${window.location.origin}/callback`,r=new URL(Gr.oauth.authUrl);r.searchParams.set("client_id",Gr.oauth.clientId),r.searchParams.set("response_type",Gr.oauth.responseType),r.searchParams.set("scope",Gr.oauth.scope),r.searchParams.set("redirect_uri",n),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),ta(),window.location.href=r.toString()}static async processCallback(){try{if(Pr.hasAllTokens()){if(!Pr.getValidSupabaseToken()){Pr.getAccessToken();await Hr.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),n=n=>e.get(n)||t.get(n),r=n("access_token"),a=n("id_token"),s=n("error");if(s)throw new Error(`Erro OAuth: ${s}`);if(!r||!a)throw new Error("Tokens não encontrados na URL de callback");Pr.setAccessToken(r),Pr.setIdToken(a),ga();const i=this.extractAliasFromAccessToken(r);if(i)Pr.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(a);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");Pr.setSelectedAlias(e[0].alias)}if(!await Hr.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return Pr.clearOAuthState(),Pr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){Pr.setManualLogout(),Pr.clearAll(),window.location.href="/login"}static decodeToken(e){return jr.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const n=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const r=t[e].split(";");if(r.length>=4)n.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,a]=t[e].split("|");r&&a&&n.push({id:"",alias:r.trim(),name:a.trim()})}}}),n}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}};Hr.setLogoutCallback(()=>{va.logout()});let wa=va;const Na=a(void 0),ja=({children:e})=>{const[t,a]=n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let s=null;try{s=rt()}catch{}const[l,c]=n(!1),[d,u]=n(0),m=i(e=>{a(t=>({...t,...e}))},[]),f=i(e=>{a(t=>({...t,isLoading:e}))},[]),p=i(()=>{a({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),h=i(async e=>{try{f(!0);const r=Pr.getAccessToken();if(!r)return;const a=await Br.generateToken(r,e.alias,void 0,!0);if(!a)return;Pr.setSupabaseToken(a),Pr.setSelectedAlias(e.alias);const i=Pr.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||Pr.getCompanyId(e.alias),c={id:l||e.id,name:e.name,alias:o};let d=null,u=null;if(t.user?.id&&o&&l)try{const e=(await Xr.fetchActiveUsersMap(o,l)).get(t.user.id);if(e){const t=ba(e);d=t.placeId,u=t.placeName}}catch(n){}m({alias:o,selectedUnit:c,placeId:d,placeName:u,activePlaceId:d,activePlaceName:u}),s&&(await s.clear(),await new Promise(e=>setTimeout(e,100)))}catch(n){}finally{f(!1)}},[m,s,f,t.user]),g=i(async()=>await wa.processCallback(),[]),x=i(async()=>{wa.logout(),p(),s&&await s.clear()},[p,s]),y=i(e=>{c(e)},[]),b=i(()=>{u(e=>e+1)},[]),v=i(()=>{u(e=>e+1)},[]);o(()=>{if(!t.isAuthenticated)return;let e=!0;const n=setInterval(()=>{e&&(Pr.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(n)}},[t.isAuthenticated,x]),o(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await wa.initialize();if(!e)return;t&&t.isAuthenticated?m({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&&f(!1)}catch(t){e&&(Wr.handleError(t),f(!1))}})(),()=>{e=!1}},[m,f,x]);const w=r(()=>({...t,logout:x,processCallback:g,switchUnit:h,availableUnits:t.companies,isSearchVisible:l,setSearchVisible:y,clearSearch:b,refreshData:v}),[t.user,t.companies,t.alias,t.isAuthenticated,t.isLoading,t.selectedUnit,t.userId,t.userAlias,t.placeId,t.placeName,t.activePlaceId,t.activePlaceName,x,g,h,l,y,b,v]);return Mt.jsx(Na.Provider,{value:w,children:e})},ka=()=>{const e=s(Na);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Ca({queryKey:e,service:t,entityName:a,searchFields:s,additionalFilters:o={},onSuccess:l}){const[c,d]=ot(),u=rt(),{alias:m,userId:f}=ka(),p=i(t=>{const n=`${e}_${t}`,r=c.get(n);return r||(c.get(t)||"")},[c,e]),h=p("search"),g=p("sortField")||Zr.sorting.defaultField,x=p("sortDirection")||Zr.sorting.defaultDirection,y=parseInt(p("page")||"1"),v=parseInt(p("limit")||String(Zr.pagination.defaultPageSize)),w=h,N=r(()=>({search:w,sortField:g,sortDirection:x,page:y,limit:v,...o}),[w,g,x,y,v,o]),j=i(()=>t.getAll(N),[t,N]),k=at({queryKey:[e,m,f,N],queryFn:j});if(!k)throw new Error(`useCrud: Query initialization failed for "${a}". Ensure QueryClientProvider is configured in your app root.`);const C=st({mutationFn:t.create,onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),b.success(ia.success.created(a)),l?.()},onError:e=>{b.error(`${ia.error.create(a)}: ${e.message}`)}}),S=st({mutationFn:({id:e,data:n})=>t.update(e,n),onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),b.success(ia.success.updated(a)),l?.()},onError:e=>{b.error(`${ia.error.update(a)}: ${e.message}`)}}),E=st({mutationFn:t.delete,onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),b.success(ia.success.deleted(a))},onError:e=>{b.error(`${ia.error.delete(a)}: ${e.message}`)}}),I=i(t=>{const n={...Object.fromEntries(c)};Object.entries(t).forEach(([t,r])=>{const a=`${e}_${t}`;""===r||0===r?delete n[a]:n[a]=String(r)}),delete n.sortField,delete n.sortDirection,d(n)},[c,d,e]),_=i(e=>{I({search:e,page:1})},[I]),T=i(e=>{I({sortField:e,sortDirection:g===e&&"asc"===x?"desc":"asc",page:1})},[g,x,I]),P=i(e=>{I({page:e})},[I]),A=i(e=>{I({limit:e,page:1})},[I]),R=i(()=>{const t=Object.fromEntries(c),n=`${e}_`,r=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(n)));d(r)},[d,c,e]),[D,F]=n([]),z=i(e=>{F(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),L=i(()=>{const e=k?.data?.data.map(e=>e.id)||[];F(t=>t.length===e.length?[]:e)},[k?.data?.data]),O=i(()=>{F([])},[]),M=r(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&D.length===e.length},[D,k?.data?.data]),$=st({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,n)=>{u.invalidateQueries({queryKey:[e]}),b.success(`${n.length} ${a}(s) deletado(s) com sucesso`),O()},onError:e=>{b.error(`Erro ao deletar itens: ${e.message}`)}}),U=i((e,t)=>{const n=t?t(e):e;e.id?S.mutate({id:e.id,data:n}):C.mutate({...n,alias:m})},[m,C,S]);return{entities:k?.data?.data||[],pagination:{currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||Zr.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:C?.isPending??!1,isUpdating:S?.isPending??!1,isDeleting:E?.isPending??!1,error:k?.error||null,searchTerm:h,sortField:g,sortDirection:x,currentPage:y,itemsPerPage:v,queryKey:e,createEntity:C.mutate,updateEntity:(e,t)=>S.mutate({id:e,data:t}),deleteEntity:E.mutate,save:U,handleSearch:_,handleSort:T,handlePageChange:P,handleItemsPerPageChange:A,clearFilters:R,refetch:k.refetch,selectedIds:D,selectItem:z,selectAll:L,clearSelection:O,isAllSelected:M,bulkDelete:$.mutate,isBulkDeleting:$.isPending}}function Sa(e){const t=ha({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:(n,r)=>Ca({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:n,onSuccess:r})}}const Ea=ut.Root,Ia=ut.Trigger,_a=ut.Portal,Ta=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Overlay,{className:Ut("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Ta.displayName=ut.Overlay.displayName;const Pa=e.forwardRef(({className:e,...t},n)=>Mt.jsxs(_a,{children:[Mt.jsx(Ta,{}),Mt.jsx(ut.Content,{ref:n,className:Ut("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Pa.displayName=ut.Content.displayName;const Aa=({className:e,...t})=>Mt.jsx("div",{className:Ut("flex flex-col space-y-2 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-6 rounded-t-lg",e),...t});Aa.displayName="AlertDialogHeader";const Ra=({className:e,...t})=>Mt.jsx("div",{className:Ut("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ra.displayName="AlertDialogFooter";const Da=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Title,{ref:n,className:Ut("text-lg font-semibold",e),...t}));Da.displayName=ut.Title.displayName;const Fa=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Description,{ref:n,className:Ut("text-sm text-muted-foreground",e),...t}));Fa.displayName=ut.Description.displayName;const za=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Action,{ref:n,className:Ut(Qt(),e),...t}));za.displayName=ut.Action.displayName;const La=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Cancel,{ref:n,className:Ut(Qt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));La.displayName=ut.Cancel.displayName;const Oa=({open:e,onOpenChange:t,item:r,onConfirm:a,entityName:s="item",isDeleting:i=!1,isBulk:l=!1,bulkCount:c})=>{const[d,u]=n("");o(()=>{e||u("")},[e]);const m=()=>{u(""),t(!1)},f=l?d===c?.toString():d===r?.title;return r?Mt.jsx(Ea,{open:e,onOpenChange:m,children:Mt.jsxs(Pa,{className:"sm:max-w-[500px]",children:[Mt.jsx(Aa,{children:Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:Mt.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),Mt.jsx("div",{className:"flex-1",children:Mt.jsx(Da,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),Mt.jsx(Fa,{asChild:!0,children:Mt.jsxs("div",{className:"space-y-4",children:[Mt.jsxs("div",{className:"text-sm text-muted-foreground",children:[Mt.jsx("p",{className:"mb-2",children:l?Mt.jsx(Mt.Fragment,{children:"Você está prestes a excluir permanentemente:"}):Mt.jsxs(Mt.Fragment,{children:["Você está prestes a excluir permanentemente o ",s,":"]})}),Mt.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:Mt.jsx("p",{className:"font-medium text-foreground",children:l?`${r.title}`:r.title})})]}),Mt.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:Mt.jsxs("div",{className:"flex items-start space-x-2",children:[Mt.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:Mt.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),Mt.jsxs("div",{className:"text-sm text-orange-800",children:[Mt.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),Mt.jsx("p",{children:l?Mt.jsx(Mt.Fragment,{children:"Esta ação não pode ser desfeita. Os itens serão removidos permanentemente do sistema."}):Mt.jsxs(Mt.Fragment,{children:["Esta ação não pode ser desfeita. O ",s," será removido permanentemente do sistema."]})})]})]})}),Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{htmlFor:"confirmation",className:"text-sm font-medium",children:l?Mt.jsxs(Mt.Fragment,{children:["Para confirmar, digite o número de itens que serão removidos: ",Mt.jsx("strong",{children:c})]}):Mt.jsxs(Mt.Fragment,{children:["Para confirmar, digite ",Mt.jsxs("strong",{children:['"',r.title,'"']})," abaixo:"]})}),Mt.jsx(Jt,{id:"confirmation",type:l?"number":"text",value:d,onChange:e=>u(e.target.value),placeholder:l?`Digite: ${c}`:`Digite: ${r.title}`,className:"w-full"})]})]})}),Mt.jsxs(Ra,{children:[Mt.jsx(La,{onClick:m,children:"Cancelar"}),Mt.jsx(za,{onClick:()=>{if(!r)return;(l?d===c?.toString():d===r.title)&&(a(r),u(""),t(!1))},disabled:!f||i,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:i?"Removendo...":`Excluir ${s}`})]})]})}):null},Ma=e.forwardRef(({className:e,...t},n)=>Mt.jsx("table",{ref:n,className:Ut("w-full caption-bottom text-sm",e),...t}));Ma.displayName="Table";const $a=e.forwardRef(({className:e,...t},n)=>Mt.jsx("thead",{ref:n,className:Ut("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));$a.displayName="TableHeader";const Ua=e.forwardRef(({className:e,...t},n)=>Mt.jsx("tbody",{ref:n,className:Ut("[&_tr:last-child]:border-0",e),...t}));Ua.displayName="TableBody";const Ba=e.forwardRef(({className:e,...t},n)=>Mt.jsx("tfoot",{ref:n,className:Ut("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Ba.displayName="TableFooter";const Va=e.forwardRef(({className:e,...t},n)=>Mt.jsx("tr",{ref:n,className:Ut("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...t}));Va.displayName="TableRow";const qa=e.forwardRef(({className:e,...t},n)=>Mt.jsx("th",{ref:n,className:Ut("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",e),...t}));qa.displayName="TableHead";const Ha=e.forwardRef(({className:e,...t},n)=>Mt.jsx("td",{ref:n,className:Ut("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));Ha.displayName="TableCell";const Wa=e.forwardRef(({className:e,...t},n)=>Mt.jsx("caption",{ref:n,className:Ut("mt-4 text-sm text-muted-foreground",e),...t}));function Qa({rows:e=5,columns:t=4}){return Mt.jsx("div",{className:"w-full",children:Mt.jsxs("div",{className:"rounded-md border",children:[Mt.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:Mt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Mt.jsx(br,{className:"h-4 w-24"},t))})}),Mt.jsx("div",{children:Array.from({length:e}).map((e,n)=>Mt.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:Mt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Mt.jsx(br,{className:"h-4 w-20"},t))})},n))})]})})}function Ka({count:e=3}){return Mt.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>Mt.jsxs(Zt,{children:[Mt.jsxs(en,{children:[Mt.jsx(br,{className:"h-4 w-3/4"}),Mt.jsx(br,{className:"h-3 w-1/2"})]}),Mt.jsx(rn,{children:Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(br,{className:"h-3 w-full"}),Mt.jsx(br,{className:"h-3 w-2/3"})]})})]},t))})}function Ya({fields:e=4}){return Mt.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(br,{className:"h-4 w-24"}),Mt.jsx(br,{className:"h-10 w-full"})]},t)),Mt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Mt.jsx(br,{className:"h-10 w-20"}),Mt.jsx(br,{className:"h-10 w-20"})]})]})}function Ja(){return Mt.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[Mt.jsxs("div",{className:"flex items-center space-x-3",children:[Mt.jsx(br,{className:"h-8 w-8 rounded-full"}),Mt.jsx(br,{className:"h-6 w-32"})]}),Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsx(br,{className:"h-8 w-8"}),Mt.jsx(br,{className:"h-8 w-24"})]})]})}function Xa(){return Mt.jsx("div",{className:"w-64 border-r bg-muted/10",children:Mt.jsxs("div",{className:"p-4",children:[Mt.jsx(br,{className:"h-8 w-32 mb-6"}),Mt.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>Mt.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[Mt.jsx(br,{className:"h-4 w-4"}),Mt.jsx(br,{className:"h-4 w-20"})]},t))})]})})}Wa.displayName="TableCaption";const Ga={default:_,search:I,error:E};function Za({icon:e,title:t,description:n,action:r,className:a,variant:s="default"}){const i=e?()=>e:Ga[s];return Mt.jsxs("div",{className:Ut("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[Mt.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:Mt.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),Mt.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),n&&Mt.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:n}),r&&Mt.jsx(Kt,{onClick:r.onClick,variant:"outline",children:r.label})]})}const es=mt.Root,ts=mt.Trigger,ns=mt.Group,rs=mt.Portal,as=mt.Sub,ss=mt.RadioGroup,is=e.forwardRef(({className:e,inset:t,children:n,...r},a)=>Mt.jsxs(mt.SubTrigger,{ref:a,className:Ut("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,Mt.jsx(T,{className:"ml-auto h-4 w-4"})]}));is.displayName=mt.SubTrigger.displayName;const os=e.forwardRef(({className:e,...t},n)=>Mt.jsx(mt.SubContent,{ref:n,className:Ut("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));os.displayName=mt.SubContent.displayName;const ls=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Mt.jsx(mt.Portal,{children:Mt.jsx(mt.Content,{ref:r,sideOffset:t,className:Ut("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-white 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 dark:bg-gray-800 dark:border-gray-700",e),...n})}));ls.displayName=mt.Content.displayName;const cs=e.forwardRef(({className:e,inset:t,...n},r)=>Mt.jsx(mt.Item,{ref:r,className:Ut("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));cs.displayName=mt.Item.displayName;const ds=e.forwardRef(({className:e,children:t,checked:n,...r},a)=>Mt.jsxs(mt.CheckboxItem,{ref:a,className:Ut("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:n,...r,children:[Mt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Mt.jsx(mt.ItemIndicator,{children:Mt.jsx(C,{className:"h-4 w-4"})})}),t]}));ds.displayName=mt.CheckboxItem.displayName;const us=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(mt.RadioItem,{ref:r,className:Ut("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),...n,children:[Mt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Mt.jsx(mt.ItemIndicator,{children:Mt.jsx(P,{className:"h-2 w-2 fill-current"})})}),t]}));us.displayName=mt.RadioItem.displayName;const ms=e.forwardRef(({className:e,inset:t,...n},r)=>Mt.jsx(mt.Label,{ref:r,className:Ut("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));ms.displayName=mt.Label.displayName;const fs=e.forwardRef(({className:e,...t},n)=>Mt.jsx(mt.Separator,{ref:n,className:Ut("-mx-1 my-1 h-px bg-muted",e),...t}));fs.displayName=mt.Separator.displayName;const ps=({className:e,...t})=>Mt.jsx("span",{className:Ut("ml-auto text-xs tracking-widest opacity-60",e),...t});ps.displayName="DropdownMenuShortcut";const hs=({onEdit:e,onDelete:t,onToggleStatus:n,isActive:r=!0,canDelete:a=!0,customActions:s=[],renderAs:i})=>{const o=[];if(e){const t={icon:A,label:"Editar",onClick:e};o.push(t)}if(s.forEach(e=>{o.push(e)}),n){const e={icon:r?R:D,label:r?"Inativar":"Ativar",onClick:n};o.push(e)}if(a&&t){const e={icon:F,label:"Remover",onClick:t,destructive:!0};o.push(e)}return"dropdown"===i?Mt.jsx(Mt.Fragment,{children:o.map((e,t)=>Mt.jsxs(cs,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[Mt.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):Mt.jsx(Mt.Fragment,{children:o.map((e,t)=>Mt.jsxs(Kt,{variant:"ghost",size:"sm",onClick:e.onClick,className:"w-full justify-start h-auto py-2 px-3 text-sm font-normal "+(e.destructive?"text-destructive hover:text-destructive":""),children:[Mt.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},gs=({onEdit:e,onDelete:t,canDelete:n=!0,onToggleStatus:r,isActive:a=!0,customActions:s=[]})=>Mt.jsxs(es,{children:[Mt.jsx(ts,{asChild:!0,children:Mt.jsx(Kt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:Mt.jsx(w,{size:12})})}),Mt.jsx(ls,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:Mt.jsx(hs,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),r?.()},isActive:a,canDelete:n,customActions:s,renderAs:"dropdown"})})]}),xs=l(({checked:e,onCheckedChange:t})=>Mt.jsx(zn,{checked:e,onCheckedChange:t}),(e,t)=>e.checked===t.checked),ys=({manager:e,columns:t,onEdit:r,onView:a,onToggleStatus:s,onDelete:i,renderActions:l,customRowActions:c,enableBulkActions:d=!1})=>{const[u,m]=n(!1),[f,p]=n(null);o(()=>{const e=()=>m(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),o(()=>{const e=()=>p(null);if(f)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[f]);const h=(()=>{t.length;let e=0;const n=t.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const n=t.minWidth||120,r=t.weight||1;return e+=n,{...t,calculatedWidth:n,weight:r,isFixed:!1}}});return e+=50,n.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})();return u?e.isLoading?Mt.jsx(Ka,{count:3}):0===e.entities.length?Mt.jsx(Za,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):Mt.jsxs("div",{className:"space-y-4",children:[e.entities.map(n=>Mt.jsx(Zt,{className:Ut("overflow-hidden cursor-pointer hover:bg-muted/50",d&&e.selectedIds.includes(n.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),d?e.selectItem(n.id):r?.(n)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),p({x:e.clientX,y:e.clientY,item:n})},children:Mt.jsx(rn,{className:"p-4",children:Mt.jsxs("div",{className:"flex items-start gap-3",children:[d&&Mt.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:Mt.jsx(xs,{checked:e.selectedIds.includes(n.id),onCheckedChange:()=>e.selectItem(n.id)})}),Mt.jsxs("div",{className:"flex-1",children:[t.map(e=>Mt.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[Mt.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[e.header,":"]}),Mt.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:e.render?e.render(n):n[e.key]})]},String(e.key))),(r||a||l)&&Mt.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(n):Mt.jsx(gs,{onEdit:r?()=>{r(n)}:void 0,onDelete:i?()=>i(n):void 0,onToggleStatus:s?()=>s(n):void 0,isActive:n.is_actived,customActions:c?c(n):[]})})]})]})})},n.id)),f&&Mt.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:f.x,top:f.y},onClick:e=>e.stopPropagation(),children:Mt.jsx(hs,{onEdit:r?()=>{r(f.item),p(null)}:void 0,onDelete:i?()=>{i(f.item),p(null)}:void 0,onToggleStatus:s?()=>{s(f.item),p(null)}:void 0,isActive:f.item.is_actived,canDelete:!!i,customActions:c?c(f.item):[],renderAs:"context"})})]}):Mt.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?Mt.jsx(Qa,{rows:5,columns:t.length}):Mt.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:Mt.jsx("div",{className:"flex-1 overflow-auto",children:Mt.jsxs(Ma,{className:"table-auto",children:[Mt.jsxs("colgroup",{children:[d&&Mt.jsx("col",{style:{width:"50px"}}),h.map((e,t)=>Mt.jsx("col",{style:e.style},t)),Mt.jsx("col",{style:{width:"50px"}})]}),Mt.jsx($a,{children:Mt.jsxs(Va,{children:[d&&Mt.jsx(qa,{className:"w-[50px]",children:Mt.jsx(xs,{checked:e.isAllSelected,onCheckedChange:e.selectAll})}),t.map(t=>{return Mt.jsx(qa,{className:`${t.className||""} ${t.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:t.sortable?()=>e.handleSort(String(t.key)):void 0,children:Mt.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),e.sortField!==n?Mt.jsx(z,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?Mt.jsx(L,{size:14,className:"ml-1"}):Mt.jsx(O,{size:14,className:"ml-1"}))]})},String(t.key));var n}),Mt.jsx(qa,{className:"w-[50px] text-center",children:"Ações"})]})}),Mt.jsx(Ua,{children:0===e.entities.length?Mt.jsx(Va,{children:Mt.jsx(Ha,{colSpan:d?t.length+2:t.length+1,className:"h-32",children:Mt.jsx(Za,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(n=>Mt.jsxs(Va,{className:Ut("cursor-pointer hover:bg-muted/50",d&&e.selectedIds.includes(n.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),d?e.selectItem(n.id):r?.(n)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),p({x:e.clientX,y:e.clientY,item:n})},children:[d&&Mt.jsx(Ha,{onClick:e=>e.stopPropagation(),children:Mt.jsx(xs,{checked:e.selectedIds.includes(n.id),onCheckedChange:()=>e.selectItem(n.id)})}),t.map(e=>Mt.jsx(Ha,{className:e.className,children:e.render?e.render(n):n[e.key]},String(e.key))),Mt.jsx(Ha,{className:"text-center",children:l?l(n):Mt.jsx(gs,{onEdit:r?()=>r(n):void 0,onDelete:i?()=>i(n):void 0,onToggleStatus:s?()=>s(n):void 0,isActive:n.is_actived,customActions:c?c(n):[]})})]},n.id))})]})})}),f&&Mt.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:f.x,top:f.y},onClick:e=>e.stopPropagation(),children:Mt.jsx(hs,{onEdit:r?()=>{r(f.item),p(null)}:void 0,onDelete:i?()=>{i(f.item),p(null)}:void 0,onToggleStatus:s?()=>{s(f.item),p(null)}:void 0,isActive:f.item.is_actived,canDelete:!!i,customActions:c?c(f.item):[],renderAs:"context"})})]})};function bs(e,t,a,s){const[i,l]=n({}),[c,d]=n({}),u=r(()=>e,[e]),m=e=>e instanceof Date&&!isNaN(e.getTime()),f=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},p=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(n){return f(e)}},h=(e,t,n)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let a;if("function"==typeof e.validation?a=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(a=e.validation.custom),a)try{const e=a(t,n);if(e)return e}catch(r){}}};o(()=>{if(!s)return;const e=t=>{const n=[];return t.forEach(t=>{n.push(t),t.fields&&n.push(...e(t.fields))}),n},n=e(u),r={};n.forEach(e=>{let n;if(t&&void 0!==t[e.name]){if(n=t[e.name],null==n&&(n=""),"date"===e.type&&n)if("string"==typeof n){const e=new Date(n);m(e)&&(n=e.toISOString().split("T")[0])}else m(n)&&(n=n.toISOString().split("T")[0])}else n=f(e);r[e.name]=n}),n.forEach(e=>{const t=p(e,r);void 0!==t&&(r[e.name]=t)}),t&&Object.keys(t).forEach(e=>{n.find(t=>t.name===e)||void 0===t[e]||(r[e]=t[e])}),l(r),d({}),a&&a(r)},[u,t,a,s]);const g=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...g(e.fields))}),t},x=()=>{const e=g(u),t={};return e.forEach(e=>{const n=h(e,i[e.name],i);n&&(t[e.name]=n)}),d(t),0===Object.keys(t).length};return{formData:i,errors:c,updateField:(e,t)=>{l(n=>{const r={...n,[e]:t},s=((e,t)=>{let n={...t};const r=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...r(e.fields))}),t};return r(u).filter(t=>t.dependsOn===e).forEach(e=>{const t=p(e,n);void 0!==t&&(n={...n,[e.name]:t})}),n})(e,r);return a&&a(s),s}),c[e]&&d(t=>{const n={...t};return delete n[e],n});const n=g(u).find(t=>t.name===e);if(n){const r=h(n,t,i);r&&d(t=>({...t,[e]:r}))}},validateForm:x,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),x()&&e(i)}}}const vs=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],ws=({value:e="#3b82f6",onChange:t,label:n})=>Mt.jsxs("div",{className:"space-y-2",children:[n&&Mt.jsx(Gt,{children:n}),Mt.jsxs(or,{children:[Mt.jsx(lr,{asChild:!0,children:Mt.jsxs(Kt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Mt.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),Mt.jsx(cr,{className:"w-64",children:Mt.jsxs("div",{className:"space-y-3",children:[Mt.jsxs("div",{children:[Mt.jsx(Gt,{htmlFor:"color-input",children:"Cor personalizada"}),Mt.jsx(Jt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),Mt.jsxs("div",{children:[Mt.jsx(Gt,{children:"Cores predefinidas"}),Mt.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:vs.map(e=>Mt.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>t?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]}),Ns=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(ft.Root,{ref:r,className:Ut("relative overflow-hidden",e),...n,children:[Mt.jsx(ft.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),Mt.jsx(js,{}),Mt.jsx(ft.Corner,{})]}));Ns.displayName=ft.Root.displayName;const js=e.forwardRef(({className:e,orientation:t="vertical",...n},r)=>Mt.jsx(ft.ScrollAreaScrollbar,{ref:r,orientation:t,className:Ut("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:Mt.jsx(ft.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));js.displayName=ft.ScrollAreaScrollbar.displayName;const ks={Star:Te,Heart:_e,Home:Ie,User:Ee,Settings:Se,Mail:Ce,Phone:ke,Calendar:je,MapPin:Ne,Camera:we,Image:ve,Music:be,Video:ye,Book:xe,Bookmark:ge,Search:I,Filter:he,Edit:A,Trash2:F,Plus:pe,Minus:fe,Check:C,X:N,ChevronDown:j,ChevronUp:k,ChevronLeft:me,ChevronRight:T,ArrowUp:L,ArrowDown:O,ArrowLeft:ue,ArrowRight:de,Clock:ce,Bell:le,AlertCircle:E,Info:oe,HelpCircle:ie,Download:se,Upload:ae,Share:re,Copy:ne,Save:te,FileText:ee,Folder:Z,FolderOpen:G,Archive:X,Lock:J,Unlock:Y,Eye:K,EyeOff:Q,Shield:W,Key:H,Zap:q,Flame:V,Sparkles:B,Award:U,Trophy:$,Target:M},Cs=({value:e="Star",onChange:t,label:r})=>{const[a,s]=n(""),i=Object.entries(ks).filter(([e])=>e.toLowerCase().includes(a.toLowerCase())),o=ks[e]||Te;return Mt.jsxs("div",{className:"space-y-2",children:[r&&Mt.jsx(Gt,{children:r}),Mt.jsxs(or,{children:[Mt.jsx(lr,{asChild:!0,children:Mt.jsxs(Kt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Mt.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),Mt.jsx(cr,{className:"w-80",children:Mt.jsxs("div",{className:"space-y-3",children:[Mt.jsxs("div",{children:[Mt.jsx(Gt,{htmlFor:"icon-search",children:"Buscar ícone"}),Mt.jsx(Jt,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:a,onChange:e=>s(e.target.value)})]}),Mt.jsx(Ns,{className:"h-48",children:Mt.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([n,r])=>Mt.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(e===n?"border-primary bg-primary/10":"border-border"),onClick:()=>t?.(n),title:n,children:Mt.jsx(r,{className:"h-4 w-4"})},n))})})]})})]})]})};function Ss({value:e,onChange:t,items:a,isLoading:s=!1,error:i=null,getItemValue:o,getItemLabel:l,searchPlaceholder:c="Buscar...",emptyMessage:d="Nenhum item disponível",noResultsMessage:u="Nenhum resultado encontrado",sortItems:m,placeholder:f="Selecionar...",disabled:p=!1,className:h}){const[g,x]=n(""),y=r(()=>{const e=m?[...a].sort(m):[...a].sort((e,t)=>l(e).localeCompare(l(t),"pt-BR"));if(!g.trim())return e;const t=g.toLowerCase();return e.filter(e=>l(e).toLowerCase().includes(t))},[a,g,m,l]);return s?Mt.jsx(br,{className:Ut("h-10 w-full",h)}):i?Mt.jsxs("div",{className:Ut("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[Mt.jsx(E,{className:"h-4 w-4 text-destructive"}),Mt.jsx("span",{className:"text-sm text-destructive",children:i.message||"Erro ao carregar dados"})]}):Mt.jsxs(Sn,{value:e,onValueChange:t,disabled:p||0===a.length,children:[Mt.jsx(_n,{className:h,children:Mt.jsx(In,{placeholder:f})}),Mt.jsxs(An,{children:[Mt.jsx("div",{className:"px-2 pb-2",children:Mt.jsxs("div",{className:"relative",children:[Mt.jsx(I,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),Mt.jsx(Jt,{placeholder:c,value:g,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===y.length?Mt.jsx(Dn,{value:"no-items",disabled:!0,children:g?u:d}):y.map(e=>Mt.jsx(Dn,{value:o(e),children:l(e)},o(e)))]})]})}const Es=(e={})=>{const{user:t,alias:n}=ka(),r=aa(),{enabled:a=r.enableUsersApi}=e;return at({queryKey:["qualiex-users",n],queryFn:()=>Xr.getUsers(n),enabled:a&&!!n&&!!t,retry:2,retryDelay:1e3})},Is=({value:e="",onChange:t,placeholder:n="Selecionar usuário",disabled:r,className:a,enabled:s})=>{const{data:i=[],isLoading:o,error:l}=Es({enabled:s});return Mt.jsx(Ss,{value:e,onChange:t,items:i,isLoading:o,error:l,getItemValue:e=>e.userId,getItemLabel:e=>e.userName,placeholder:n,searchPlaceholder:"Buscar usuário...",emptyMessage:"Nenhum usuário disponível",noResultsMessage:"Nenhum usuário encontrado",disabled:r,className:a})};function _s({title:e,sections:a,initialData:s,onSubmit:o,onCancel:l,open:d,submitButtonText:u="Salvar",isLoading:m=!1,usersData:f}){const[p,h]=n(a?.[0]?.id||""),g=c(null),[x,y]=n(null),b=i(e=>{g.current=e,y(e)},[]),v=r(()=>a&&Array.isArray(a)?a.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[a]),{formData:w,errors:N,updateField:j,handleSubmit:k}=bs(v,s,void 0,d),C=r(()=>a&&Array.isArray(a)?a.map(e=>({...e,disabled:e.condition?!e.condition(w):e.disabled||!1})):[],[a,w]),S=r(()=>{const e=C.find(e=>e.id===p);if(e&&!e.disabled)return p;const t=C.find(e=>!e.disabled);return t?.id||p},[C,p]);t.useEffect(()=>{S!==p&&h(S)},[S,p]);const E=C.find(e=>e.id===S),I=e=>{const t=(e.computedValue,w[e.name]),n=void 0!==t?t:"",r=N[e.name];switch(e.type){case"group":return Mt.jsxs("div",{className:"space-y-2",children:[e.label,Mt.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>I(e))})]},e.name);case"user-select":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(Is,{value:n||"",onChange:t=>j(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":""}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"textarea":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(Ln,{id:e.name,value:n||"",onChange:t=>{j(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"select":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsxs(Sn,{value:String(n),onValueChange:t=>{j(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[Mt.jsx(_n,{className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:Mt.jsx(In,{placeholder:e.placeholder})}),Mt.jsx(An,{children:e.options?.map(e=>Mt.jsx(Dn,{value:e.value,children:e.label},e.value))})]}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"multiselect":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsxs(Gt,{htmlFor:e.name,children:[e.label,e.required&&Mt.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Mt.jsx(wr,{options:e.options||[],value:Array.isArray(n)?n:[],onChange:t=>j(e.name,t),placeholder:e.placeholder,disabled:e.disabled,error:r,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"date":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(Jt,{id:e.name,type:"date",value:String(n),onChange:t=>j(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:Ut("w-full",r?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"color":return Mt.jsxs("div",{children:[Mt.jsxs(Gt,{htmlFor:e.name,children:[e.label," ",e.required&&Mt.jsx("span",{className:"text-destructive",children:"*"})]}),Mt.jsx(Jt,{id:e.name,type:"color",value:n||e.defaultValue||"#000000",onChange:t=>j(e.name,t.target.value),className:"h-10"}),r&&Mt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return Mt.jsxs("div",{children:[Mt.jsx(ws,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"#3b82f6",onChange:t=>j(e.name,t)}),r&&Mt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return Mt.jsxs("div",{children:[Mt.jsx(Cs,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"Star",onChange:t=>j(e.name,t)}),r&&Mt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"custom":if(!e.component)return null;const t=e.component;return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(t,{value:n,onChange:t=>{j(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,error:r,popoverContainer:x,...e.componentProps||{}}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"number":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(Jt,{id:e.name,type:"number",value:null!=n?String(n):"",onChange:t=>{const n=t.target.value,r=""===n?null:Number(n);j(e.name,r)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);default:return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(Jt,{id:e.name,type:"text",value:n||"",onChange:t=>{j(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,readOnly:e.disabled}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name)}},_=i(()=>{if(!E)return null;if(E.disabled)return Mt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Mt.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:Mt.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Mt.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),Mt.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),Mt.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(E.component){const e=E.component;return Mt.jsx(e,{formData:w,updateField:j,errors:N,users:f,disabled:E.disabled})}return Mt.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:E.fields.map(I)})},[E,w,j,N,f,I]),T=Mt.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[C.length>1&&Mt.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:Mt.jsx("div",{className:"flex space-x-2",children:C.map(e=>Mt.jsx(Kt,{variant:S===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=C.find(t=>t.id===e);t&&!t.disabled&&h(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),Mt.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:m?Mt.jsx("div",{className:"flex items-center justify-center py-12",children:Mt.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):Mt.jsxs("form",{onSubmit:k(o),className:"space-y-3 md:space-y-4",children:[_(),Mt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Mt.jsx(Kt,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),Mt.jsx(Kt,{type:"submit",disabled:m,children:u})]})]})})]});return Mt.jsx(sn,{open:d,onOpenChange:e=>{!1===e&&!0===d&&l()},children:Mt.jsxs(un,{ref:b,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[Mt.jsxs(mn,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[Mt.jsx(pn,{className:"text-white",children:e}),Mt.jsx(hn,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),T]})})}function Ts({currentPage:e,totalPages:t,totalItems:n,itemsPerPage:r,onPageChange:a,onItemsPerPageChange:s,variant:i="full"}){const o=(e-1)*r+1,l=Math.min(e*r,n);return Mt.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[Mt.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&Mt.jsxs(Mt.Fragment,{children:[Mt.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),Mt.jsxs(Sn,{value:String(r),onValueChange:e=>s(Number(e)),children:[Mt.jsx(_n,{className:"h-8 w-[70px]",children:Mt.jsx(In,{})}),Mt.jsxs(An,{children:[Mt.jsx(Dn,{value:"10",children:"10"}),Mt.jsx(Dn,{value:"25",children:"25"}),Mt.jsx(Dn,{value:"50",children:"50"}),Mt.jsx(Dn,{value:"100",children:"100"})]})]})]})}),Mt.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[o,"-",l," de ",n," itens"]}),Mt.jsxs("div",{className:"flex items-center gap-1",children:[Mt.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>a(1),disabled:1===e,className:"h-8 w-8 p-0",children:Mt.jsx(Pe,{size:16})}),Mt.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>a(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:Mt.jsx(me,{size:16})}),Mt.jsxs("div",{className:"flex items-center gap-1 px-2",children:[Mt.jsx("span",{className:"text-sm font-medium",children:e}),Mt.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),Mt.jsx("span",{className:"text-sm font-medium",children:t})]}),Mt.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>a(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:Mt.jsx(T,{size:16})}),Mt.jsx(Kt,{variant:"outline",size:"sm",onClick:()=>a(t),disabled:e===t,className:"h-8 w-8 p-0",children:Mt.jsx(Ae,{size:16})})]})]})}function Ps({manager:e}){return Mt.jsx(Ts,{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 As=({selectedCount:e,onClearSelection:t,onBulkDelete:n,customActions:r=[],isLoading:a=!1})=>Mt.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[Mt.jsxs("div",{className:"flex items-center gap-3",children:[Mt.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),Mt.jsxs(Kt,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[Mt.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]}),Mt.jsxs("div",{className:"flex items-center gap-2",children:[r.map((e,t)=>{const n=e.icon;return Mt.jsxs(Kt,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:a,className:"h-7",children:[n&&Mt.jsx(n,{size:14,className:"mr-1"}),e.label]},t)}),n&&Mt.jsxs(Kt,{variant:"destructive",size:"sm",onClick:n,disabled:a,className:"h-7",children:[Mt.jsx(F,{size:14,className:"mr-1"}),"Remover"]})]})]}),Rs={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Ds={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},Fs={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function zs({children:e,direction:t="column",gap:n="md",align:r="stretch",justify:a="start",wrap:s=!1,className:i}){return Mt.jsx("div",{className:Ut("flex","column"===t?"flex-col":"flex-row",Rs[n],Ds[r],Fs[a],s&&"flex-wrap",i),children:e})}function Ls({manager:e,filters:t,inline:n=!1}){const{isSearchVisible:r}=ka(),a=e.searchTerm,s=Mt.jsxs(Mt.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&Mt.jsxs("div",{className:"relative flex-1",children:[Mt.jsx(I,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Mt.jsx(Jt,{placeholder:"Buscar...",value:e.searchTerm,onChange:t=>e.handleSearch(t.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((e,t)=>Mt.jsxs("select",{value:e.value||"",onChange:t=>e.onChange?.(t.target.value),className:"h-10 px-3 rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[e.placeholder&&Mt.jsx("option",{value:"",children:e.placeholder}),e.options.map(e=>Mt.jsx("option",{value:e.value,children:e.label},e.value))]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return Mt.jsx("div",{className:n?"":"w-full sm:w-auto",children:Mt.jsx(r,{...e.props})},`custom-${t}`)}),a&&Mt.jsxs(Kt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[Mt.jsx(N,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return n?Mt.jsx("div",{className:"flex items-center gap-2",children:s}):Mt.jsx(zs,{direction:"column",gap:"md",className:"mb-6",children:Mt.jsx(zs,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:s})})}function Os({manager:e,config:t,formSections:r,onSave:a,onToggleStatus:s,defaultSort:i}){e&&e.queryKey;const{setSearchVisible:l}=ka(),[c,d]=ot(),[u,m]=n(!1),[f,p]=n(null),[h,g]=n({isOpen:!1,entityId:null,entityName:""}),[x,y]=n({isOpen:!1,count:0});o(()=>(l(!0),()=>{l(!1)}),[l]),o(()=>{if(i&&e){const t=`${e.queryKey}_sortField`,n=`${e.queryKey}_sortDirection`;if(!c.has(t)&&!c.has(n)){const e=Object.fromEntries(c);e[t]=i.column,e[n]=i.direction,d(e)}}},[]);return Mt.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[t.enableBulkActions&&e.selectedIds.length>0&&Mt.jsx(As,{selectedCount:e.selectedIds.length,onClearSelection:e.clearSelection,onBulkDelete:t.bulkActions&&t.bulkActions.length>0?void 0:()=>{y({isOpen:!0,count:e.selectedIds.length})},customActions:t.bulkActions,isLoading:e.isBulkDeleting}),Mt.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[Mt.jsxs("div",{className:"flex items-center gap-2",children:[Mt.jsxs(Kt,{onClick:()=>{t.onNew?t.onNew():(p(null),m(!0))},children:[Mt.jsx(pe,{size:16,className:"mr-2"}),"Novo"]}),t.customActions?.map((e,t)=>Mt.jsxs(Kt,{onClick:e.action,variant:e.variant||"outline",children:[e.icon&&Mt.jsx(e.icon,{size:16,className:"mr-2"}),e.label]},t))]}),t.filters&&t.filters.length>0&&Mt.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:Mt.jsx(Ls,{manager:e,filters:t.filters,inline:!0})})]}),Mt.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:t.customListView?Mt.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.customListView(e.entities,e)}):Mt.jsx(ys,{manager:e,columns:t.columns,onEdit:e=>{t.onEdit?t.onEdit(e):(p(e),m(!0))},onDelete:e=>{g({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:s,enableBulkActions:t.enableBulkActions,customRowActions:t.customRowActions})}),Mt.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:Mt.jsx(Ps,{manager:e})}),!t.useCustomRouting&&Mt.jsx(_s,{open:u,title:f?`Editar ${t.entityName}`:`Novo ${t.entityName}`,sections:r,initialData:f||void 0,onSubmit:e=>{a(e),m(!1),p(null)},onCancel:()=>{m(!1),p(null)},isLoading:e.isLoading,submitButtonText:f?"Atualizar":"Criar"}),Mt.jsx(Oa,{open:h.isOpen,onOpenChange:()=>{g({isOpen:!1,entityId:null,entityName:""})},onConfirm:t=>{h.entityId&&(e.deleteEntity(h.entityId),g({isOpen:!1,entityId:null,entityName:""}))},item:h.entityId?{id:h.entityId,title:h.entityName}:void 0,entityName:t.entityName,isDeleting:e.isDeleting}),Mt.jsx(Oa,{open:x.isOpen,onOpenChange:()=>y({isOpen:!1,count:0}),onConfirm:()=>(e.bulkDelete?.(e.selectedIds),void y({isOpen:!1,count:0})),item:{id:"bulk",title:`${x.count} ${1===x.count?t.entityName:t.entityNamePlural}`},entityName:t.entityNamePlural,isDeleting:e.isBulkDeleting,isBulk:!0,bulkCount:x.count})]})}function Ms(e){return({manager:t})=>{const{manager:n,config:r,onSave:a,onEdit:s,onToggleStatus:i}=e,o=t??n,l={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:s||r.onEdit};return Mt.jsx(Os,{manager:o,config:l,formSections:r.formSections,onSave:a,onToggleStatus:i,defaultSort:r.defaultSort})}}function $s(e,t,n){return r=>{if(r.id){const t=n(r);e.updateEntity(r.id,t)}else{const n=t(r);e.createEntity(n)}}}function Us(e,t,n={}){const r=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const n=t[e],a={key:e,header:Vs(e),label:Vs(e),...Bs(e,n),sortable:!0,searchable:"string"==typeof n};r.push(a)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...n}}function Bs(e,t){const n=e.toLowerCase();return n.includes("email")?{type:"email",required:!0}:n.includes("phone")||n.includes("tel")?{type:"tel"}:n.includes("description")||n.includes("content")||n.includes("notes")?{type:"textarea"}:n.includes("status")||n.includes("type")||n.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function Vs(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const qs={user:{title:"Usuários",searchPlaceholder:"Buscar usuários...",enableDelete:!1},product:{title:"Produtos",searchPlaceholder:"Buscar produtos...",enableFilters:!0},order:{title:"Pedidos",searchPlaceholder:"Buscar pedidos...",enableCreate:!1},category:{title:"Categorias",searchPlaceholder:"Buscar categorias...",itemsPerPage:20}};function Hs(e,t,n={}){const r=qs[e];return Us(r.title,t,{...r,...n})}const Ws=({children:e})=>{const{isAuthenticated:n,isLoading:r}=ka();if(t.useEffect(()=>{if(!n)return;const e=()=>{Pr.areAllTokensValid()||wa.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),t.useEffect(()=>{if(r)return;if(n)return;if(Pr.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const s=ta();(async()=>{s?await wa.loginDev():wa.loginProd()})()},[n,r]),r)return Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-xl font-semibold",children:"Carregando..."})}),Mt.jsxs(rn,{className:"text-center",children:[Mt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Mt.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!n){if(new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token"))return Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-xl font-semibold",children:"Processando..."})}),Mt.jsxs(rn,{className:"text-center",children:[Mt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Mt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(Pr.areAllTokensValid())return Mt.jsx(Mt.Fragment,{children:e})}catch{}return Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-xl font-semibold",children:"Iniciando..."})}),Mt.jsxs(rn,{className:"text-center",children:[Mt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Mt.jsx("p",{className:"text-muted-foreground",children:ta()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return Mt.jsx(Mt.Fragment,{children:e})},Qs=f("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Ks=e.forwardRef(({className:e,variant:t,...n},r)=>Mt.jsx("div",{ref:r,role:"alert",className:Ut(Qs({variant:t}),e),...n}));Ks.displayName="Alert";const Ys=e.forwardRef(({className:e,...t},n)=>Mt.jsx("h5",{ref:n,className:Ut("mb-1 font-medium leading-none tracking-tight",e),...t}));Ys.displayName="AlertTitle";const Js=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:Ut("text-sm [&_p]:leading-relaxed",e),...t}));Js.displayName="AlertDescription";const Xs=()=>{const{processCallback:e}=ka(),[t,r]=n(null),[a,s]=n(!1);o(()=>{(async()=>{try{if(await e()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else r("Falha na autenticação. Tente novamente.")}catch(t){r(t?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e]);const i=async()=>{s(!0),r(null);try{await e()||r("Falha na autenticação. Tente novamente.")}catch(t){r(t?.message||"Erro ao tentar novamente.")}finally{s(!1)}},l=()=>{window.location.href="/"};return t?Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsxs(tn,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[Mt.jsx(E,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),Mt.jsxs(rn,{className:"space-y-4",children:[Mt.jsx(Ks,{variant:"destructive",children:Mt.jsx(Js,{children:t})}),Mt.jsx("div",{className:"text-sm text-muted-foreground",children:Mt.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),Mt.jsxs("div",{className:"flex gap-2",children:[Mt.jsx(Kt,{onClick:i,disabled:a,className:"flex-1",children:a?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(Un,{size:"sm",className:"mr-2"}),"Tentando..."]}):Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(Re,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),Mt.jsx(Kt,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),Mt.jsxs(rn,{className:"text-center",children:[Mt.jsx("div",{className:"flex justify-center mb-4",children:Mt.jsx(Un,{size:"lg"})}),Mt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},Gs=()=>Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),Mt.jsxs(rn,{className:"text-center space-y-4",children:[Mt.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),Mt.jsx(Kt,{onClick:async()=>{ta()?await wa.loginDev():wa.loginProd()},className:"w-full",size:"lg",children:ta()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),Zs=a(void 0);function ei({children:e}){const[t,r]=n({});return Mt.jsx(Zs.Provider,{value:{metadata:t,setMetadata:r,clearMetadata:()=>r({})},children:e})}function ti(){const e=s(Zs);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function ni(e){const{setMetadata:t,clearMetadata:n}=ti();o(()=>(t(e),()=>n()),[e.title,e.subtitle,t,n])}function ri(e){return{queryClient:e.queryClient||new it({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const ai=pt.Root,si=e.forwardRef(({className:e,...t},n)=>Mt.jsx(pt.Item,{ref:n,className:Ut("border-b",e),...t}));si.displayName="AccordionItem";const ii=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsx(pt.Header,{className:"flex",children:Mt.jsxs(pt.Trigger,{ref:r,className:Ut("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,Mt.jsx(j,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));ii.displayName=pt.Trigger.displayName;const oi=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsx(pt.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:Mt.jsx("div",{className:Ut("pb-4 pt-0",e),children:t})}));oi.displayName=pt.Content.displayName;const li=ht.Root,ci=e.forwardRef(({className:e,...t},n)=>Mt.jsx(gt.Root,{ref:n,className:Ut("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));ci.displayName=gt.Root.displayName;const di=e.forwardRef(({className:e,...t},n)=>Mt.jsx(gt.Image,{ref:n,className:Ut("aspect-square h-full w-full",e),...t}));di.displayName=gt.Image.displayName;const ui=e.forwardRef(({className:e,...t},n)=>Mt.jsx(gt.Fallback,{ref:n,className:Ut("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));ui.displayName=gt.Fallback.displayName;const mi=e.forwardRef(({...e},t)=>Mt.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));mi.displayName="Breadcrumb";const fi=e.forwardRef(({className:e,...t},n)=>Mt.jsx("ol",{ref:n,className:Ut("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));fi.displayName="BreadcrumbList";const pi=e.forwardRef(({className:e,...t},n)=>Mt.jsx("li",{ref:n,className:Ut("inline-flex items-center gap-1.5",e),...t}));pi.displayName="BreadcrumbItem";const hi=e.forwardRef(({asChild:t,className:n,...r},a)=>{const s=t?e.Fragment:"a";return Mt.jsx(s,{ref:a,className:Ut("transition-colors hover:text-foreground",n),...r})});hi.displayName="BreadcrumbLink";const gi=e.forwardRef(({className:e,...t},n)=>Mt.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:Ut("font-normal text-foreground",e),...t}));gi.displayName="BreadcrumbPage";const xi=({children:e,className:t,...n})=>Mt.jsx("li",{role:"presentation","aria-hidden":"true",className:Ut("[&>svg]:size-3.5",t),...n,children:e??Mt.jsx(T,{})});xi.displayName="BreadcrumbSeparator";const yi=({className:e,...t})=>Mt.jsxs("span",{role:"presentation","aria-hidden":"true",className:Ut("flex h-9 w-9 items-center justify-center",e),...t,children:[Mt.jsx(De,{className:"h-4 w-4"}),Mt.jsx("span",{className:"sr-only",children:"More"})]});function bi(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function vi(e){return(t,n)=>{let r;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,a=n?.width?String(n.width):t;r=e.formattingValues[a]||e.formattingValues[t]}else{const t=e.defaultWidth,a=n?.width?String(n.width):e.defaultWidth;r=e.values[a]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}function wi(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;return}(o,e=>e.test(i)):function(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;return}(o,e=>e.test(i));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;return{value:c,rest:t.slice(i.length)}}}yi.displayName="BreadcrumbEllipsis";const Ni={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"}},ji={date:bi({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:bi({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:bi({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},ki={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"},Ci={ordinalNumber:(e,t)=>{const n=Number(e);return"week"===t?.unit?n+"ª":n+"º"},era:vi({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:vi({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:vi({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:vi({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:vi({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"})},Si={ordinalNumber:(Ei={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(Ei.matchPattern);if(!n)return null;const r=n[0],a=e.match(Ei.parsePattern);if(!a)return null;let s=Ei.valueCallback?Ei.valueCallback(a[0]):a[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:wi({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:wi({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:wi({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:wi({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:wi({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"})};var Ei;const Ii={code:"pt-BR",formatDistance:(e,t,n)=>{let r;const a=Ni[e];return r="string"==typeof a?a:1===t?a.one:a.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?"em "+r:"há "+r:r},formatLong:ji,formatRelative:(e,t,n,r)=>{const a=ki[e];return"function"==typeof a?a(t):a},localize:Ci,match:Si,options:{weekStartsOn:0,firstWeekContainsDate:1}};function _i({className:e,classNames:t,showOutsideDays:n=!0,...r}){return Mt.jsx(xt,{showOutsideDays:n,className:Ut("p-3",e),locale:Ii,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:Ut(Qt({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:Ut(Qt({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({...e})=>Mt.jsx(me,{className:"h-4 w-4"}),IconRight:({...e})=>Mt.jsx(T,{className:"h-4 w-4"})},...r})}_i.displayName="Calendar";const Ti=yt.Root,Pi=yt.CollapsibleTrigger,Ai=yt.CollapsibleContent;const Ri={Root:function({children:e,className:t}){return Mt.jsx("div",{className:Ut("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:n}){return Mt.jsx(Zt,{className:Ut("transition-colors",t&&"cursor-pointer hover:bg-muted/50",n),onClick:t,children:Mt.jsx(rn,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:n}){return Mt.jsxs("div",{className:Ut("flex justify-between items-center text-sm",n),children:[Mt.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),Mt.jsx("span",{className:"text-foreground",children:t})]})}};function Di({value:e,onChange:t,activeLabel:n="Ativo",inactiveLabel:r="Inativo",allLabel:a="[Todos]",placeholder:s="Status",className:i="w-full sm:w-[180px]"}){return Mt.jsx(Ss,{value:String(e),onChange:e=>t(e),items:[{id:"active",name:n},{id:"inactive",name:r},{id:"all",name:a}],getItemValue:e=>e.id,getItemLabel:e=>e.name,placeholder:s,className:i})}const Fi={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))]"},zi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Li({children:e,cols:t="auto-fit",gap:n="md",className:r}){return Mt.jsx("div",{className:Ut("grid",Fi[t],zi[n],r),children:e})}function Oi({items:e,maxItems:t=3,className:n}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,Mt.jsx(mi,{className:n})}function Mi(){const e=lt();return(()=>{const t=e.pathname.split("/").filter(Boolean),n=[{label:"Exemplos",href:"/"}];let r="";return t.forEach((e,a)=>{r+=`/${e}`;const s=a===t.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");n.push({label:i,href:s?void 0:r,isCurrentPage:s})}),n})()}const $i=({className:e,...t})=>Mt.jsx("nav",{role:"navigation","aria-label":"pagination",className:Ut("mx-auto flex w-full justify-center",e),...t});$i.displayName="Pagination";const Ui=e.forwardRef(({className:e,...t},n)=>Mt.jsx("ul",{ref:n,className:Ut("flex flex-row items-center gap-1",e),...t}));Ui.displayName="PaginationContent";const Bi=e.forwardRef(({className:e,...t},n)=>Mt.jsx("li",{ref:n,className:Ut("",e),...t}));Bi.displayName="PaginationItem";const Vi=({className:e,isActive:t,size:n="icon",...r})=>Mt.jsx("a",{"aria-current":t?"page":void 0,className:Ut(Qt({variant:t?"outline":"ghost",size:n}),e),...r});Vi.displayName="PaginationLink";const qi=({className:e,...t})=>Mt.jsxs(Vi,{"aria-label":"Go to previous page",size:"default",className:Ut("gap-1 pl-2.5",e),...t,children:[Mt.jsx(me,{className:"h-4 w-4"}),Mt.jsx("span",{children:"Previous"})]});qi.displayName="PaginationPrevious";const Hi=({className:e,...t})=>Mt.jsxs(Vi,{"aria-label":"Go to next page",size:"default",className:Ut("gap-1 pr-2.5",e),...t,children:[Mt.jsx("span",{children:"Next"}),Mt.jsx(T,{className:"h-4 w-4"})]});Hi.displayName="PaginationNext";const Wi=({className:e,...t})=>Mt.jsxs("span",{"aria-hidden":!0,className:Ut("flex h-9 w-9 items-center justify-center",e),...t,children:[Mt.jsx(De,{className:"h-4 w-4"}),Mt.jsx("span",{className:"sr-only",children:"More pages"})]});Wi.displayName="PaginationEllipsis";const Qi=e.forwardRef(({className:e,value:t,...n},r)=>Mt.jsx(bt.Root,{ref:r,className:Ut("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:Mt.jsx(bt.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Qi.displayName=bt.Root.displayName;const Ki=e.forwardRef(({className:e,...t},n)=>Mt.jsx(vt.Root,{className:Ut("grid gap-2",e),...t,ref:n}));Ki.displayName=vt.Root.displayName;const Yi=e.forwardRef(({className:e,...t},n)=>Mt.jsx(vt.Item,{ref:n,className:Ut("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:Mt.jsx(vt.Indicator,{className:"flex items-center justify-center",children:Mt.jsx(P,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Yi.displayName=vt.Item.displayName;const Ji=e.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>Mt.jsx(wt.Root,{ref:a,decorative:n,orientation:t,className:Ut("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ji.displayName=wt.Root.displayName;const Xi=We.Root,Gi=We.Trigger,Zi=We.Close,eo=We.Portal,to=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Overlay,{className:Ut("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));to.displayName=We.Overlay.displayName;const no=f("fixed z-50 gap-4 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 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t 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"}}),ro=e.forwardRef(({side:e="right",className:t,children:n,...r},a)=>Mt.jsxs(eo,{children:[Mt.jsx(to,{}),Mt.jsxs(We.Content,{ref:a,className:Ut(no({side:e}),t),...r,children:[n,Mt.jsxs(We.Close,{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-secondary",children:[Mt.jsx(N,{className:"h-4 w-4"}),Mt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ro.displayName=We.Content.displayName;const ao=({className:e,...t})=>Mt.jsx("div",{className:Ut("flex flex-col space-y-2 text-center sm:text-left",e),...t});ao.displayName="SheetHeader";const so=({className:e,...t})=>Mt.jsx("div",{className:Ut("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});so.displayName="SheetFooter";const io=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Title,{ref:n,className:Ut("text-lg font-semibold text-foreground",e),...t}));io.displayName=We.Title.displayName;const oo=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Description,{ref:n,className:Ut("text-sm text-muted-foreground",e),...t}));oo.displayName=We.Description.displayName;const lo=Nt.Provider,co=Nt.Root,uo=Nt.Trigger,mo=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Mt.jsx(Nt.Content,{ref:r,sideOffset:t,className:Ut("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),...n}));mo.displayName=Nt.Content.displayName;const fo="sidebar:state",po=e.createContext(null);function ho(){const t=e.useContext(po);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const go=e.forwardRef(({defaultOpen:t=!0,open:n,onOpenChange:r,className:a,style:s,children:i,...o},l)=>{const[c,d]=e.useState(!1);e.useEffect(()=>{const e=()=>d(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=e.useState(!1),[f,p]=e.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(fo);return null!==e?"true"===e:t}return t}),h=n??f,g=e.useCallback(e=>{const t="function"==typeof e?e(h):e;r?r(t):p(t),"undefined"!=typeof window&&localStorage.setItem(fo,String(t))},[r,h]),x=e.useCallback(()=>c?m(e=>!e):g(e=>!e),[c,g,m]);e.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const y=h?"expanded":"collapsed",b=e.useMemo(()=>({state:y,open:h,setOpen:g,isMobile:c,openMobile:u,setOpenMobile:m,toggleSidebar:x}),[y,h,g,c,u,m,x]);return Mt.jsx(po.Provider,{value:b,children:Mt.jsx(lo,{delayDuration:0,children:Mt.jsx("div",{className:Ut("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",a),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...s},ref:l,...o,children:i})})})});go.displayName="SidebarProvider";const xo=e.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:a,...s},i)=>{const{isMobile:o,state:l,openMobile:c,setOpenMobile:d}=ho();return"none"===n?Mt.jsx("div",{className:Ut("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:a}):o?Mt.jsx(Xi,{open:c,onOpenChange:d,...s,children:Mt.jsxs(ro,{"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:[Mt.jsx(io,{className:"sr-only",children:"Menu de Navegação"}),Mt.jsx("div",{className:"flex h-full w-full flex-col",children:a})]})}):Mt.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":l,"data-collapsible":"collapsed"===l?n:"","data-variant":t,"data-side":e,children:[Mt.jsx("div",{className:Ut("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),Mt.jsx("div",{className:Ut("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===e?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:Mt.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:a})})]})});xo.displayName="Sidebar";const yo=e.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:a}=ho();return Mt.jsxs(Kt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Ut("h-7 w-7",e),onClick:e=>{t?.(e),a()},...n,children:[Mt.jsx(Fe,{}),Mt.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});yo.displayName="SidebarTrigger";const bo=e.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=ho();return Mt.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Ut("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});bo.displayName="SidebarRail";const vo=e.forwardRef(({className:e,...t},n)=>Mt.jsx("main",{ref:n,className:Ut("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));vo.displayName="SidebarInset";const wo=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Jt,{ref:n,"data-sidebar":"input",className:Ut("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));wo.displayName="SidebarInput";const No=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"header",className:Ut("flex flex-col gap-2 p-2",e),...t}));No.displayName="SidebarHeader";const jo=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"footer",className:Ut("flex flex-col gap-2 p-2",e),...t}));jo.displayName="SidebarFooter";const ko=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ji,{ref:n,"data-sidebar":"separator",className:Ut("mx-2 w-auto bg-sidebar-border",e),...t}));ko.displayName="SidebarSeparator";const Co=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"content",className:Ut("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Co.displayName="SidebarContent";const So=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"group",className:Ut("relative flex w-full min-w-0 flex-col p-2",e),...t}));So.displayName="SidebarGroup";const Eo=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?u:"div";return Mt.jsx(a,{ref:r,"data-sidebar":"group-label",className:Ut("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),...n})});Eo.displayName="SidebarGroupLabel";const Io=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?u:"button";return Mt.jsx(a,{ref:r,"data-sidebar":"group-action",className:Ut("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),...n})});Io.displayName="SidebarGroupAction";const _o=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"group-content",className:Ut("w-full text-sm",e),...t}));_o.displayName="SidebarGroupContent";const To=e.forwardRef(({className:e,...t},n)=>Mt.jsx("ul",{ref:n,"data-sidebar":"menu",className:Ut("flex w-full min-w-0 flex-col gap-1",e),...t}));To.displayName="SidebarMenu";const Po=e.forwardRef(({className:e,...t},n)=>Mt.jsx("li",{ref:n,"data-sidebar":"menu-item",className:Ut("group/menu-item relative",e),...t}));Po.displayName="SidebarMenuItem";const Ao=f("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Ro=e.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:a,className:s,...i},o)=>{const l=e?u:"button",{isMobile:c,state:d}=ho(),m=Mt.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:Ut(Ao({variant:n,size:r}),s),...i});return a?("string"==typeof a&&(a={children:a}),Mt.jsxs(co,{children:[Mt.jsx(uo,{asChild:!0,children:m}),Mt.jsx(mo,{side:"right",align:"center",hidden:"collapsed"!==d||c,...a})]})):m});Ro.displayName="SidebarMenuButton";const Do=e.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},a)=>{const s=t?u:"button";return Mt.jsx(s,{ref:a,"data-sidebar":"menu-action",className:Ut("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",n&&"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),...r})});Do.displayName="SidebarMenuAction";const Fo=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:Ut("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));Fo.displayName="SidebarMenuBadge";const zo=e.forwardRef(({className:t,showIcon:n=!1,...r},a)=>{const s=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return Mt.jsxs("div",{ref:a,"data-sidebar":"menu-skeleton",className:Ut("rounded-md h-8 flex gap-2 px-2 items-center",t),...r,children:[n&&Mt.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),Mt.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":s}})]})});zo.displayName="SidebarMenuSkeleton";const Lo=e.forwardRef(({className:e,...t},n)=>Mt.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:Ut("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Lo.displayName="SidebarMenuSub";const Oo=e.forwardRef(({...e},t)=>Mt.jsx("li",{ref:t,...e}));Oo.displayName="SidebarMenuSubItem";const Mo=e.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...a},s)=>{const i=e?u:"a";return Mt.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:Ut("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",r),...a})});Mo.displayName="SidebarMenuSubButton";const $o=e.forwardRef(({className:e,...t},n)=>Mt.jsxs(jt.Root,{ref:n,className:Ut("relative flex w-full touch-none select-none items-center",e),...t,children:[Mt.jsx(jt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:Mt.jsx(jt.Range,{className:"absolute h-full bg-primary"})}),Mt.jsx(jt.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"})]}));$o.displayName=jt.Root.displayName;const Uo=({...e})=>{const{theme:t="system"}=kt();return Mt.jsx(v,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",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"}},...e})};function Bo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Vo(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function qo(...t){return e.useCallback(function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=Vo(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():Vo(e[t],null)}}}}(...t),t)}function Ho(...t){const n=t[0];if(1===t.length)return n;const r=()=>{const r=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const a=r.reduce((e,{useScope:n,scopeName:r})=>({...e,...n(t)[`__scope${r}`]}),{});return e.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}var Wo=globalThis?.document?e.useLayoutEffect:()=>{},Qo=e[" useInsertionEffect ".trim().toString()]||Wo;function Ko({prop:t,defaultProp:n,onChange:r=()=>{},caller:a}){const[s,i,o]=function({defaultProp:t,onChange:n}){const[r,a]=e.useState(t),s=e.useRef(r),i=e.useRef(n);return Qo(()=>{i.current=n},[n]),e.useEffect(()=>{s.current!==r&&(i.current?.(r),s.current=r)},[r,s]),[r,a,i]}({defaultProp:n,onChange:r}),l=void 0!==t,c=l?t:s;{const n=e.useRef(void 0!==t);e.useEffect(()=>{const e=n.current;if(e!==l){}n.current=l},[l,a])}const d=e.useCallback(e=>{if(l){const n=function(e){return"function"==typeof e}(e)?e(t):e;n!==t&&o.current?.(n)}else i(e)},[l,t,i,o]);return[c,d]}var Yo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=m(`Primitive.${n}`),a=e.forwardRef((e,t)=>{const{asChild:a,...s}=e,i=a?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),Mt.jsx(i,{...s,ref:t})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{}),Jo="Switch",[Xo]=function(t,n=[]){let r=[];const a=()=>{const n=r.map(t=>e.createContext(t));return function(r){const a=r?.[t]||n;return e.useMemo(()=>({[`__scope${t}`]:{...r,[t]:a}}),[r,a])}};return a.scopeName=t,[function(n,a){const s=e.createContext(a),i=r.length;r=[...r,a];const o=n=>{const{scope:r,children:a,...o}=n,l=r?.[t]?.[i]||s,c=e.useMemo(()=>o,Object.values(o));return Mt.jsx(l.Provider,{value:c,children:a})};return o.displayName=n+"Provider",[o,function(r,o){const l=o?.[t]?.[i]||s,c=e.useContext(l);if(c)return c;if(void 0!==a)return a;throw new Error(`\`${r}\` must be used within \`${n}\``)}]},Ho(a,...n)]}(Jo),[Go,Zo]=Xo(Jo),el=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:a,checked:s,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:d,form:u,...m}=t,[f,p]=e.useState(null),h=qo(n,e=>p(e)),g=e.useRef(!1),x=!f||(u||!!f.closest("form")),[y,b]=Ko({prop:s,defaultProp:i??!1,onChange:d,caller:Jo});return Mt.jsxs(Go,{scope:r,checked:y,disabled:l,children:[Mt.jsx(Yo.button,{type:"button",role:"switch","aria-checked":y,"aria-required":o,"data-state":al(y),"data-disabled":l?"":void 0,disabled:l,value:c,...m,ref:h,onClick:Bo(t.onClick,e=>{b(e=>!e),x&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),x&&Mt.jsx(rl,{control:f,bubbles:!g.current,name:a,value:c,checked:y,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});el.displayName=Jo;var tl="SwitchThumb",nl=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Zo(tl,n);return Mt.jsx(Yo.span,{"data-state":al(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});nl.displayName=tl;var rl=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:a=!0,...s},i)=>{const o=e.useRef(null),l=qo(o,i),c=function(t){const n=e.useRef({value:t,previous:t});return e.useMemo(()=>(n.current.value!==t&&(n.current.previous=n.current.value,n.current.value=t),n.current.previous),[t])}(r),d=function(t){const[n,r]=e.useState(void 0);return Wo(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const e=new ResizeObserver(e=>{if(!Array.isArray(e))return;if(!e.length)return;const n=e[0];let a,s;if("borderBoxSize"in n){const e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;a=t.inlineSize,s=t.blockSize}else a=t.offsetWidth,s=t.offsetHeight;r({width:a,height:s})});return e.observe(t,{box:"border-box"}),()=>e.unobserve(t)}r(void 0)},[t]),n}(n);return e.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(c!==r&&n){const t=new Event("click",{bubbles:a});n.call(e,r),e.dispatchEvent(t)}},[c,r,a]),Mt.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:l,style:{...s.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function al(e){return e?"checked":"unchecked"}rl.displayName="SwitchBubbleInput";var sl=el,il=nl;const ol=e.forwardRef(({className:e,...t},n)=>Mt.jsx(sl,{className:Ut("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:Mt.jsx(il,{className:Ut("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")})}));ol.displayName=sl.displayName;const ll=Ct.Root,cl=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ct.List,{ref:n,className:Ut("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));cl.displayName=Ct.List.displayName;const dl=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ct.Trigger,{ref:n,className:Ut("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));dl.displayName=Ct.Trigger.displayName;const ul=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ct.Content,{ref:n,className:Ut("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));function ml({children:e,className:t}){return Mt.jsx("div",{className:Ut("flex flex-col h-full",t),children:Mt.jsx(Ns,{className:"flex-1",children:Mt.jsx("div",{className:"space-y-6 p-6",children:e})})})}function fl({title:e,description:t,actions:n,className:r}){return Mt.jsxs("div",{className:Ut("space-y-4",r),children:[Mt.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[Mt.jsxs("div",{className:"space-y-1",children:[Mt.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&Mt.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),n&&Mt.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:n})]}),Mt.jsx(Ji,{})]})}function pl({children:e,className:t}){return Mt.jsx("div",{className:Ut("space-y-6",t),children:e})}ul.displayName=Ct.Content.displayName;const hl=f("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),gl=e.forwardRef(({className:e,variant:t,size:n,...r},a)=>Mt.jsx(St.Root,{ref:a,className:Ut(hl({variant:t,size:n,className:e})),...r}));gl.displayName=St.Root.displayName;const xl=e.createContext({size:"default",variant:"default"}),yl=e.forwardRef(({className:e,variant:t,size:n,children:r,...a},s)=>Mt.jsx(Et.Root,{ref:s,className:Ut("flex items-center justify-center gap-1",e),...a,children:Mt.jsx(xl.Provider,{value:{variant:t,size:n},children:r})}));yl.displayName=Et.Root.displayName;const bl=e.forwardRef(({className:t,children:n,variant:r,size:a,...s},i)=>{const o=e.useContext(xl);return Mt.jsx(Et.Item,{ref:i,className:Ut(hl({variant:o.variant||r,size:o.size||a}),t),...s,children:n})});function vl({manager:e,config:t,onEdit:n,onDelete:r}){return e.isLoading?Mt.jsx(Li,{children:Array.from({length:3}).map((e,t)=>Mt.jsxs(Zt,{children:[Mt.jsxs(en,{children:[Mt.jsx(br,{className:"h-4 w-3/4"}),Mt.jsx(br,{className:"h-3 w-1/2"})]}),Mt.jsx(rn,{children:Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(br,{className:"h-3 w-full"}),Mt.jsx(br,{className:"h-3 w-2/3"})]})})]},t))}):Mt.jsx(Ri.Root,{children:e.entities.map(e=>Mt.jsxs(Ri.Item,{onClick:()=>n(e),children:[Mt.jsx(en,{className:"pb-3",children:Mt.jsxs("div",{className:"flex items-start justify-between",children:[Mt.jsxs("div",{className:"flex-1 min-w-0",children:[Mt.jsx(tn,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),Mt.jsx(nn,{className:"text-sm",children:y(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:Ii})})]}),Mt.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&Mt.jsx(Kt,{variant:"external-link",size:"icon-xs",onClick:t=>{t.stopPropagation(),(e=>{try{const t=window.open(e,"_blank");t&&!t.closed&&void 0!==t.closed||(navigator.clipboard.writeText(e),b.info("Link copiado para a área de transferência"))}catch(t){window.location.href=e}})(e.link)},title:"Abrir link externo",children:Mt.jsx(ze,{className:"h-4 w-4"})}),Mt.jsx("div",{onClick:e=>e.stopPropagation(),children:Mt.jsx(gs,{onEdit:()=>n(e),onDelete:r?()=>r(e):void 0,canDelete:!!r})})]})]})}),Mt.jsx(rn,{className:"pt-0",children:Mt.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const n=e[t.key];return n?Mt.jsx(Ri.Field,{label:t.label,value:t.render?t.render(n,e):String(n)},String(t.key)):null})})})]},e.id))})}function wl({data:e,columns:t,sortField:n,sortDirection:a,onSort:s,onRowClick:i,renderActions:o,isLoading:l=!1,emptyMessage:c="Nenhum item encontrado",className:d,enableSelection:u=!1,selectedIds:m=[],onSelectItem:f,onSelectAll:p,isAllSelected:h=!1}){const g=r(()=>{const e=t.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return t.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const n=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${n}%)`:`${n}%`})},[t]);return l?Mt.jsx("div",{className:"flex-1 overflow-auto",children:Mt.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>Mt.jsx(br,{className:"h-12 w-full"},t))})}):0===e.length?Mt.jsx("div",{className:"flex-1 flex items-center justify-center",children:Mt.jsx("div",{className:"text-center text-muted-foreground",children:Mt.jsx("p",{children:c})})}):Mt.jsx("div",{className:"flex-1 overflow-auto",children:Mt.jsxs(Ma,{className:d,children:[Mt.jsx($a,{className:"sticky top-0 bg-background z-10",children:Mt.jsxs(Va,{children:[u&&Mt.jsx(qa,{className:"w-[40px]",children:Mt.jsx(zn,{checked:h,onCheckedChange:p,"aria-label":"Selecionar todos"})}),t.map((e,t)=>{return Mt.jsx(qa,{className:e.className,style:{width:g[t]},children:e.sortable&&s?Mt.jsxs("button",{onClick:()=>s(String(e.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[e.header,(r=String(e.key),n!==r?Mt.jsx(z,{size:14,className:"ml-1 opacity-50"}):"asc"===a?Mt.jsx(L,{size:14,className:"ml-1"}):Mt.jsx(O,{size:14,className:"ml-1"}))]}):Mt.jsx("span",{className:"font-medium",children:e.header})},String(e.key));var r}),o&&Mt.jsx(qa,{className:"w-[80px] text-right",children:"Ações"})]})}),Mt.jsx(Ua,{children:e.map(e=>Mt.jsxs(Va,{onClick:()=>i?.(e),className:i?"cursor-pointer":"",children:[u&&Mt.jsx(Ha,{children:Mt.jsx(zn,{checked:m.includes(e.id),onCheckedChange:()=>f?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${e.id}`})}),t.map(t=>Mt.jsx(Ha,{className:t.className,children:t.render?t.render(e):String(e[t.key]??"-")},String(t.key))),o&&Mt.jsx(Ha,{className:"text-right",onClick:e=>e.stopPropagation(),children:o(e)})]},e.id))})]})})}function Nl({onEdit:e,onDelete:t,onToggleStatus:n,isActive:r=!0,canEdit:a=!0,canDelete:s=!0,customActions:i=[],renderAs:o="dropdown",variant:l="default"}){const c=[];return e&&a&&c.push({icon:A,label:"Editar",onClick:e,variant:"default"}),n&&c.push({icon:r?R:D,label:r?"Inativar":"Ativar",onClick:n,variant:"default"}),i.forEach(e=>{!1!==e.show&&c.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),t&&s&&c.push({icon:F,label:"Remover",onClick:t,variant:"destructive"}),0===c.length?null:"dropdown"===o?Mt.jsxs(es,{children:[Mt.jsx(ts,{asChild:!0,children:Mt.jsx(Kt,{variant:"ghost",size:"compact"===l?"sm":"default",className:"compact"===l?"h-7 px-2":"",children:Mt.jsx(w,{size:"compact"===l?14:16})})}),Mt.jsx(ls,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:c.map((e,t)=>Mt.jsxs(cs,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&Mt.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))})]}):Mt.jsx("div",{className:"flex items-center gap-1",children:c.map((e,t)=>Mt.jsxs(Kt,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===l?"sm":"default",onClick:e.onClick,className:"compact"===l?"h-7 px-2":"",children:[e.icon&&Mt.jsx(e.icon,{size:"compact"===l?14:16}),"compact"!==l&&Mt.jsx("span",{className:"ml-1",children:e.label})]},t))})}function jl({searchValue:e="",onSearchChange:t,customFilters:n=[],onClearFilters:r,showClearButton:a=!0,layout:s="horizontal"}){const i=e||n.length>0;return Mt.jsxs("div",{className:`flex ${"vertical"===s?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&Mt.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[Mt.jsx(I,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Mt.jsx(Jt,{type:"text",placeholder:"Buscar...",value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),n.map((e,t)=>Mt.jsx("div",{className:"vertical"===s?"w-full":"",children:e},t)),a&&i&&r&&Mt.jsxs(Kt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[Mt.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]})}function kl({data:e,renderCard:t,isLoading:n=!1,emptyMessage:r="Nenhum item encontrado",columns:a,gap:s="md",className:i}){return n?Mt.jsx(Li,{cols:a?String(a):"auto-fit",gap:s,className:i,children:[...Array(6)].map((e,t)=>Mt.jsx(br,{className:"h-48 w-full"},t))}):0===e.length?Mt.jsx("div",{className:"flex items-center justify-center p-8",children:Mt.jsx("div",{className:"text-center text-muted-foreground",children:Mt.jsx("p",{children:r})})}):Mt.jsx(Li,{cols:a?String(a):"auto-fit",gap:s,className:i,children:e.map(t)})}function Cl(e){const t=ct();return{onNew:()=>{const n=e.newPath||`${e.basePath}/new`;t(n)},onEdit:n=>{const r=e.editPath?e.editPath.replace(":id",n.id):`${e.basePath}/${n.id}/edit`;t(r)}}}function Sl(e,t){const n=Cl({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:n.onNew,onEdit:n.onEdit}}bl.displayName=Et.Item.displayName;const El=t.memo(({variant:e="card",className:n="",selectedUnit:r,onUnitChange:a})=>{const{user:s,companies:i,alias:o,isAuthenticated:l,logout:c,switchUnit:d}=ka(),u=i?.[0]||null,m=o?i?.find(e=>e.alias===o):u,f=i||[],p=r||m||u||u,h=t.useCallback(e=>{a?a(e):d(e)},[a,d]),g=t.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),n=t.find(e=>e.alias===p?.alias),r=t.filter(e=>e.alias!==p?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),n?[n,...r]:r},[f,p?.alias]);if(!l||!s)return null;const x=()=>Mt.jsxs(Mt.Fragment,{children:[Mt.jsxs("div",{className:"flex items-center space-x-3",children:[Mt.jsx("div",{className:"flex-shrink-0",children:Mt.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:Mt.jsx(Ee,{className:"h-5 w-5 text-primary-foreground"})})}),Mt.jsxs("div",{className:"flex-1 min-w-0",children:[Mt.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),Mt.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&Mt.jsx("div",{className:"mt-3",children:Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsx(Le,{className:"h-4 w-4 text-muted-foreground"}),Mt.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),g.length>1&&Mt.jsxs("div",{className:"mt-2",children:[Mt.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",g.length]}),Mt.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,3).map(e=>Mt.jsx(Mn,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),g.length>3&&Mt.jsxs(Mn,{variant:"outline",className:"text-xs",children:["+",g.length-3]})]})]})]});return"dropdown"===e?Mt.jsxs(es,{children:[Mt.jsx(ts,{asChild:!0,children:Mt.jsx(Kt,{variant:"ghost",className:`h-auto p-2 ${n}`,children:Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsxs("div",{className:"hidden md:block text-left",children:[Mt.jsx("p",{className:"text-sm font-medium",children:s.name}),Mt.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),Mt.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:Mt.jsx(Ee,{className:"h-4 w-4 text-primary-foreground"})}),Mt.jsx(j,{className:"h-4 w-4"})]})})}),Mt.jsxs(ls,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[Mt.jsxs(as,{children:[Mt.jsxs(is,{children:[Mt.jsx(Re,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),Mt.jsx(os,{children:g.map(e=>Mt.jsxs(cs,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[Mt.jsx(Le,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&Mt.jsx(Mn,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Mt.jsx(fs,{}),Mt.jsxs(cs,{onClick:c,children:[Mt.jsx(Oe,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):Mt.jsxs(Zt,{className:n,children:[Mt.jsx(en,{children:Mt.jsx(tn,{className:"text-lg",children:"Informações do Usuário"})}),Mt.jsxs(rn,{className:"space-y-4",children:[Mt.jsx(x,{}),Mt.jsx(Ji,{}),Mt.jsxs(Kt,{variant:"outline",onClick:c,size:"sm",className:"w-full",children:[Mt.jsx(Oe,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Il=a({});function _l({children:e,config:t}){const n=r(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return Mt.jsx(Il.Provider,{value:n,children:e})}function Tl(){return s(Il)}function Pl(){const e=lt(),{navigation:t}=Tl();if(!t)return"Página";const n=t.find(t=>t.path===e.pathname);if(n)return n.label;const r=t.find(t=>e.pathname.startsWith(t.path+"/"));return r?.label||"Página"}function Al(e,t){const[r,a]=n(e),s=c(),l=i(()=>{s.current&&(clearTimeout(s.current),s.current=void 0)},[]);return o(()=>(l(),s.current=setTimeout(()=>{a(e)},t),l),[e,t,l]),[r,l]}const Rl=l(function({actions:e}){const t=lt(),r=Pl(),{navigation:a,appName:s}=Tl(),{metadata:i}=ti(),{companies:l,alias:c,isSearchVisible:d,clearSearch:u,refreshData:m,switchUnit:f}=ka(),p=c?l?.find(e=>e.alias===c)||l?.[0]||null:l?.[0]||null,[h,g]=ot(),[x,y]=n(()=>h.get("search")||""),[b,v]=Al(x,ea.debounceDelay);o(()=>{if(!d)return;const e=new URLSearchParams(h);b?(e.set("search",b),e.set("page","1")):e.delete("search"),g(e)},[b,g,d]);const w=a?.find(e=>e.path===t.pathname)||a?.find(e=>t.pathname.startsWith(e.path+"/")),j=i.title||r,k=i.subtitle||w?.complementaryText||"Detalhes do item";return Mt.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:Mt.jsxs("div",{className:"flex items-center gap-4",children:[Mt.jsxs("div",{className:"flex-shrink-0",children:[Mt.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[Mt.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:j}),Mt.jsx(Mn,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:s||"Módulo"})]}),Mt.jsx("p",{className:"text-sm text-muted-foreground truncate",children:k})]}),d&&Mt.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[Mt.jsxs("div",{className:"relative flex-1",children:[Mt.jsx(I,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Mt.jsx(Jt,{placeholder:"/wiki"===t.pathname?"Buscar artigos...":"Buscar...",value:x,onChange:e=>(e=>{y(e)})(e.target.value),className:"w-full pl-10 pr-8"}),x&&Mt.jsx(Kt,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-gray-100",onClick:()=>{v(),y("");const e=new URLSearchParams(h);e.delete("search"),e.delete("page"),g(e)},title:"Limpar busca",children:Mt.jsx(N,{size:14})})]}),Mt.jsx(Kt,{variant:"outline",size:"sm",onClick:m,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:Mt.jsx(Re,{size:14})})]}),Mt.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[e&&Mt.jsx("div",{className:"flex items-center gap-2",children:e}),import.meta.env.VITE_WIKI_URL&&Mt.jsx(Kt,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>$t(import.meta.env.VITE_WIKI_URL,e),title:"Abrir Wiki",children:"Wiki"}),Mt.jsx("div",{className:"text-sm",children:Mt.jsx(El,{variant:"dropdown",selectedUnit:p,onUnitChange:f})})]})]})})}),Dl=({key:e,enabled:t,checkFn:n,staleTime:r=3e5,gcTime:a=6e5})=>at({queryKey:["permission",e],queryFn:n,enabled:t,staleTime:r,gcTime:a,retry:0,refetchOnWindowFocus:!1}),Fl=(e={})=>{const{enabled:t=!0}=e,{alias:n}=ka();return at({queryKey:["active-modules",n],queryFn:async()=>{if(!n)return[];const e=Ur(),{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",n).eq("status","active").order("name");if(r){if(!Wr.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!n})},zl="forlogic-sidebar-pinned",Ll=()=>{try{const e=localStorage.getItem(zl);return!!e&&JSON.parse(e)}catch{return!1}},Ol=e=>{const t=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return t[e%t.length]},Ml=import.meta.env.VITE_SUPABASE_PROJECT_ID,$l={logo:`https://${Ml}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${Ml}.supabase.co/storage/v1/object/public/library-assets/small.svg`},Ul=$l.logo,Bl=$l.smallLogo;function Vl({appName:e,isPinned:t,onPinToggle:n,open:r,dropdownOpen:a,onDropdownChange:s}){const{data:i,isLoading:o,error:l}=Fl({enabled:a}),c=e=>{((e,t)=>{const n=e?.find(e=>e.url===t);n?.url&&window.open(n.url,"_blank")})(i,e)};return Mt.jsxs(No,{className:"p-0 gap-0",children:[Mt.jsx("div",{className:"flex items-center justify-between h-[34px]",children:r?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx("div",{className:"flex items-center pl-[12px]",children:Mt.jsx("img",{src:$l.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),Mt.jsx("button",{onClick:n,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(t?"bg-primary text-primary-foreground":"hover:bg-muted text-muted-foreground"),children:Mt.jsx(Fe,{className:"h-4 w-4"})})]}):Mt.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:Mt.jsx("img",{src:$l.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),Mt.jsx("div",{className:"mt-2 pt-0",children:Mt.jsxs(es,{onOpenChange:s,children:[Mt.jsx(ts,{asChild:!0,children:r?Mt.jsxs("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[Mt.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Mt.jsx("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),Mt.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:e})]}),Mt.jsx(j,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):Mt.jsx("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:Mt.jsx(j,{className:"h-6 w-6 text-muted-foreground"})})}),Mt.jsx(ls,{className:r?"w-80 bg-white rounded-lg shadow-lg border border-gray-200 p-4 z-50":"w-[58px] bg-white rounded-lg shadow-lg border border-gray-200 p-2 z-50",align:r?"start":"center",children:o?Mt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[Mt.jsx(S,{className:"h-4 w-4 animate-spin"}),Mt.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):l?Mt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[Mt.jsx(E,{className:"h-4 w-4"}),Mt.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):i&&0!==i.length?Mt.jsx("div",{className:"space-y-2",children:i.map((e,t)=>Mt.jsx("div",{onClick:()=>c(e.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${Ol(t)} transition-colors duration-200\n `,children:Mt.jsxs("div",{className:"flex items-center justify-between",children:[Mt.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&Mt.jsx(ze,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):Mt.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]})}function ql({direction:e="right",minWidth:t=224,maxWidth:r=384,defaultWidth:a=240,storageKey:s="sidebar-width",onResize:l,isOpen:d=!0}={}){const[u,m]=n(()=>{if("undefined"==typeof window)return a;const e=localStorage.getItem(s);return e?parseInt(e):a}),[f,p]=n(!1),h=c(null);o(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(d?e.style.setProperty("--sidebar-width",`${u}px`):e.style.setProperty("--sidebar-width","240px"))},[u,d]);const g=i(e=>{e.preventDefault(),p(!0)},[]);return o(()=>{if(!f)return;const n=n=>{let a;a="left"===e?window.innerWidth-n.clientX:n.clientX,a=Math.max(t,Math.min(r,a)),m(a),l?.(a)},a=()=>{p(!1),localStorage.setItem(s,u.toString())};return document.addEventListener("mousemove",n),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",a)}},[f,e,t,r,u,s,l]),o(()=>{f?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[f,e]),{width:u,isDragging:f,dragRef:h,handleMouseDown:g}}const Hl=t.forwardRef(({className:e,onMouseDown:t,isDragging:n,...r},a)=>Mt.jsx("div",{ref:a,onMouseDown:t,className:Ut("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",n&&"bg-primary/40",e),...r}));function Wl({config:e,customContent:t,resizable:r=!1,minWidth:a=224,maxWidth:s=384}={}){const{open:i,setOpen:l}=ho(),c=lt(),{alias:d,user:u}=ka(),[m,f]=n(!1),[p,h]=n(Ll),[g,x]=n(!1),y=r?ql({minWidth:a,maxWidth:s,storageKey:"app-sidebar-width",isOpen:i}):null;o(()=>{l(!!p||!(!g&&!m))},[p,g,m,l]);const b=e=>c.pathname===e||c.pathname.startsWith(e+"/");return Mt.jsxs(xo,{collapsible:"icon",onMouseEnter:()=>{p||x(!0)},onMouseLeave:()=>{p||x(!1)},className:"app-sidebar bg-white border-r border-gray-200 py-6 px-3",style:y&&i?{width:`${y.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[Mt.jsx(Vl,{appName:e?.appName||"Título do módulo",isPinned:p,onPinToggle:()=>{const e=!p;h(e),(e=>{try{localStorage.setItem(zl,JSON.stringify(e))}catch{}})(e)},open:i,dropdownOpen:m,onDropdownChange:f}),Mt.jsx(Co,{children:t||Mt.jsx(So,{className:"p-0 mt-6",children:Mt.jsx(_o,{children:Mt.jsx(To,{className:"space-y-2",children:Mt.jsx(lo,{children:e?.navigation?.map((e,t)=>{const n=({item:e,index:t})=>{const r=`${e.path}-${t}-${d??"noalias"}-${u?.id??"nouser"}`,{data:a=!0,isLoading:s}=Dl({key:r,enabled:Boolean(e.permissionCheck&&d&&u?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),i=e.permissionCheck&&!a,o=s?S:i?J:e.icon;i||e.complementaryText;return e.children&&e.children.length>0?Mt.jsx(Ti,{defaultOpen:!0,className:"group/collapsible",children:Mt.jsxs(Po,{children:[Mt.jsx(Pi,{asChild:!0,children:Mt.jsx(Ro,{size:"lg",className:"h-10",children:Mt.jsxs("div",{className:"flex w-full items-center gap-3",children:[Mt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Mt.jsx(o,{className:"h-5 w-4"})}),Mt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label}),Mt.jsx(T,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),Mt.jsx(Ai,{children:Mt.jsx(Lo,{children:e.children.map((e,t)=>Mt.jsx(n,{item:e,index:t},e.path))})})]})},e.path):Mt.jsx(Po,{children:i||s?Mt.jsxs(co,{children:[Mt.jsx(uo,{asChild:!0,children:Mt.jsx(Ro,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:Mt.jsxs("div",{className:"flex w-full items-center gap-3",children:[Mt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Mt.jsx(o,{className:"h-4 w-4 "+(s?"animate-spin":"")})}),Mt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),Mt.jsx(mo,{children:Mt.jsx("p",{children:s?"Verificando acesso...":"Acesso restrito"})})]}):Mt.jsx(Ro,{asChild:!0,isActive:b(e.path),size:"lg",className:"h-10",children:Mt.jsxs(dt,{to:e.path,className:"flex w-full items-center gap-3",children:[Mt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Mt.jsx(o,{className:"h-5 w-4"})}),Mt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path)};return Mt.jsx(n,{item:e,index:t},e.path)})})})})})}),r&&y&&i&&Mt.jsx(Hl,{ref:y.dragRef,onMouseDown:y.handleMouseDown,isDragging:y.isDragging})]})}Hl.displayName="ResizableRail";const Ql=l(function({children:e,sidebar:t,sidebarConfig:n,showHeader:a=!0}){const s=r(()=>t||Mt.jsx(Wl,{config:n}),[t,n]),i=r(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return Mt.jsx(_l,{config:n,children:Mt.jsx(ei,{children:Mt.jsx(go,{defaultOpen:!1,style:i,children:Mt.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[s,Mt.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[a&&Mt.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:Mt.jsx(Rl,{})}),Mt.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:e})]})]})})})})});var Kl=Object.defineProperty,Yl=(e,t,n)=>((e,t,n)=>t in e?Kl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);class Jl extends d{constructor(e){super(e),Yl(this,"copyErrorDetails",()=>{const e=Dr.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),Jn({title:"Detalhes copiados!",description:"Os detalhes do erro foram copiados para a área de transferência."})}),this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if(import.meta.env.DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if(import.meta.env.DEV)throw e;Dr.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const e=Dr.getErrors().slice(0,2);return Mt.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:Mt.jsxs(Zt,{className:"w-full max-w-2xl",children:[Mt.jsxs(en,{className:"text-center",children:[Mt.jsx("div",{className:"flex justify-center mb-4",children:Mt.jsx(Me,{className:"h-12 w-12 text-destructive"})}),Mt.jsx(tn,{children:"Algo deu errado"})]}),Mt.jsxs(rn,{className:"space-y-4",children:[Mt.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),Mt.jsxs(Ti,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[Mt.jsx(Pi,{asChild:!0,children:Mt.jsxs(Kt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[Mt.jsx(j,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),Mt.jsxs(Ai,{className:"mt-4 space-y-4",children:[Mt.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[Mt.jsxs("div",{children:[Mt.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),Mt.jsxs("div",{className:"text-sm space-y-2",children:[Mt.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&Mt.jsx(Ns,{className:"h-32 w-full rounded border bg-muted p-2",children:Mt.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),e.length>0&&Mt.jsxs("div",{className:"pt-3 border-t",children:[Mt.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),Mt.jsx("div",{className:"space-y-2",children:e.map((e,t)=>Mt.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:Mt.jsxs("div",{className:"flex items-start gap-2",children:[Mt.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),Mt.jsxs("div",{className:"flex-1 min-w-0",children:[Mt.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Mt.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(e.timestamp).toLocaleTimeString(),"]"]})}),Mt.jsx("p",{className:"text-sm break-words",children:e.message})]})]})},e.id))})]})]}),Mt.jsxs(Kt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[Mt.jsx(ne,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),Mt.jsx(Kt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}class Xl{static async sendEmail(e){const t=Ur(),{data:n,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 n}}const Gl=Xl;function Zl(){const[e,t]=n([]),[r,a]=n(!1),[s,l]=n(null),[c,d]=n(null);o(()=>{u()},[]);const u=async()=>{try{const e=Ur(),{data:n,error:r}=await e.functions.invoke("openai-chat",{body:{action:"createThread"}});if(r)throw r;l(n.threadId),t([{id:"initial",role:"assistant",content:"Olá! Como posso ajudá-lo hoje?",timestamp:new Date}])}catch(e){d("Erro ao inicializar conversa"),b.error("Erro ao inicializar conversa")}},m=i(async e=>{if(!s||!e.trim())return;const n={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};t(e=>[...e,n]),a(!0),d(null);try{const n=Ur(),{data:r,error:a}=await n.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:s,message:e}});if(a)throw a;const{runId:i}=r,o=await(async e=>{if(!s)return!1;for(let n=0;n<60;n++)try{const t=Ur(),{data:n,error:r}=await t.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:s,runId:e}});if(r)throw r;const{status:a}=n;if("completed"===a)return!0;if("failed"===a||"cancelled"===a)throw new Error("O assistente encontrou um erro");await new Promise(e=>setTimeout(e,1e3))}catch(t){throw t}throw new Error("Tempo limite excedido")})(i);o&&await(async()=>{if(s)try{const e=Ur(),{data:n,error:r}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:s}});if(r)throw r;const a=n.messages.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(1e3*e.created_at)}));t(a)}catch(e){throw e}})()}catch(r){const e=r instanceof Error?r.message:"Erro ao enviar mensagem";d(e),b.error(e),t(e=>e.filter(e=>e.id!==n.id))}finally{a(!1)}},[s]);return{messages:e,isLoading:r,error:c,sendMessage:m,threadId:s}}function ec(){}function tc(){}const nc=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rc=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ac={};function sc(e,t){return(ac.jsx?rc:nc).test(e)}const ic=/[ \t\n\f\r]/g;function oc(e){return""===e.replace(ic,"")}class lc{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function cc(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new lc(n,r,t)}function dc(e){return e.toLowerCase()}lc.prototype.normal={},lc.prototype.property={},lc.prototype.space=void 0;class uc{constructor(e,t){this.attribute=t,this.property=e}}uc.prototype.attribute="",uc.prototype.booleanish=!1,uc.prototype.boolean=!1,uc.prototype.commaOrSpaceSeparated=!1,uc.prototype.commaSeparated=!1,uc.prototype.defined=!1,uc.prototype.mustUseProperty=!1,uc.prototype.number=!1,uc.prototype.overloadedBoolean=!1,uc.prototype.property="",uc.prototype.spaceSeparated=!1,uc.prototype.space=void 0;let mc=0;const fc=vc(),pc=vc(),hc=vc(),gc=vc(),xc=vc(),yc=vc(),bc=vc();function vc(){return 2**++mc}var wc=Object.freeze({__proto__:null,boolean:fc,booleanish:pc,commaOrSpaceSeparated:bc,commaSeparated:yc,number:gc,overloadedBoolean:hc,spaceSeparated:xc});const Nc=Object.keys(wc);class jc extends uc{constructor(e,t,n,r){let a=-1;if(super(e,t),kc(this,"space",r),"number"==typeof n)for(;++a<Nc.length;){const e=Nc[a];kc(this,Nc[a],(n&wc[e])===wc[e])}}}function kc(e,t,n){n&&(e[t]=n)}function Cc(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new jc(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[dc(r)]=r,n[dc(s.attribute)]=r}return new lc(t,n,e.space)}jc.prototype.defined=!0;const Sc=Cc({properties:{ariaActiveDescendant:null,ariaAtomic:pc,ariaAutoComplete:null,ariaBusy:pc,ariaChecked:pc,ariaColCount:gc,ariaColIndex:gc,ariaColSpan:gc,ariaControls:xc,ariaCurrent:null,ariaDescribedBy:xc,ariaDetails:null,ariaDisabled:pc,ariaDropEffect:xc,ariaErrorMessage:null,ariaExpanded:pc,ariaFlowTo:xc,ariaGrabbed:pc,ariaHasPopup:null,ariaHidden:pc,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:xc,ariaLevel:gc,ariaLive:null,ariaModal:pc,ariaMultiLine:pc,ariaMultiSelectable:pc,ariaOrientation:null,ariaOwns:xc,ariaPlaceholder:null,ariaPosInSet:gc,ariaPressed:pc,ariaReadOnly:pc,ariaRelevant:null,ariaRequired:pc,ariaRoleDescription:xc,ariaRowCount:gc,ariaRowIndex:gc,ariaRowSpan:gc,ariaSelected:pc,ariaSetSize:gc,ariaSort:null,ariaValueMax:gc,ariaValueMin:gc,ariaValueNow:gc,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function Ec(e,t){return t in e?e[t]:t}function Ic(e,t){return Ec(e,t.toLowerCase())}const _c=Cc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:yc,acceptCharset:xc,accessKey:xc,action:null,allow:null,allowFullScreen:fc,allowPaymentRequest:fc,allowUserMedia:fc,alt:null,as:null,async:fc,autoCapitalize:null,autoComplete:xc,autoFocus:fc,autoPlay:fc,blocking:xc,capture:null,charSet:null,checked:fc,cite:null,className:xc,cols:gc,colSpan:null,content:null,contentEditable:pc,controls:fc,controlsList:xc,coords:gc|yc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:fc,defer:fc,dir:null,dirName:null,disabled:fc,download:hc,draggable:pc,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:fc,formTarget:null,headers:xc,height:gc,hidden:hc,high:gc,href:null,hrefLang:null,htmlFor:xc,httpEquiv:xc,id:null,imageSizes:null,imageSrcSet:null,inert:fc,inputMode:null,integrity:null,is:null,isMap:fc,itemId:null,itemProp:xc,itemRef:xc,itemScope:fc,itemType:xc,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:fc,low:gc,manifest:null,max:null,maxLength:gc,media:null,method:null,min:null,minLength:gc,multiple:fc,muted:fc,name:null,nonce:null,noModule:fc,noValidate:fc,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:fc,optimum:gc,pattern:null,ping:xc,placeholder:null,playsInline:fc,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:fc,referrerPolicy:null,rel:xc,required:fc,reversed:fc,rows:gc,rowSpan:gc,sandbox:xc,scope:null,scoped:fc,seamless:fc,selected:fc,shadowRootClonable:fc,shadowRootDelegatesFocus:fc,shadowRootMode:null,shape:null,size:gc,sizes:null,slot:null,span:gc,spellCheck:pc,src:null,srcDoc:null,srcLang:null,srcSet:null,start:gc,step:null,style:null,tabIndex:gc,target:null,title:null,translate:null,type:null,typeMustMatch:fc,useMap:null,value:pc,width:gc,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:xc,axis:null,background:null,bgColor:null,border:gc,borderColor:null,bottomMargin:gc,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:fc,declare:fc,event:null,face:null,frame:null,frameBorder:null,hSpace:gc,leftMargin:gc,link:null,longDesc:null,lowSrc:null,marginHeight:gc,marginWidth:gc,noResize:fc,noHref:fc,noShade:fc,noWrap:fc,object:null,profile:null,prompt:null,rev:null,rightMargin:gc,rules:null,scheme:null,scrolling:pc,standby:null,summary:null,text:null,topMargin:gc,valueType:null,version:null,vAlign:null,vLink:null,vSpace:gc,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:fc,disableRemotePlayback:fc,prefix:null,property:null,results:gc,security:null,unselectable:null},space:"html",transform:Ic}),Tc=Cc({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:bc,accentHeight:gc,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:gc,amplitude:gc,arabicForm:null,ascent:gc,attributeName:null,attributeType:null,azimuth:gc,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:gc,by:null,calcMode:null,capHeight:gc,className:xc,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:gc,diffuseConstant:gc,direction:null,display:null,dur:null,divisor:gc,dominantBaseline:null,download:fc,dx:null,dy:null,edgeMode:null,editable:null,elevation:gc,enableBackground:null,end:null,event:null,exponent:gc,externalResourcesRequired:null,fill:null,fillOpacity:gc,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:yc,g2:yc,glyphName:yc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:gc,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:gc,horizOriginX:gc,horizOriginY:gc,id:null,ideographic:gc,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:gc,k:gc,k1:gc,k2:gc,k3:gc,k4:gc,kernelMatrix:bc,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:gc,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:gc,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:gc,overlineThickness:gc,paintOrder:null,panose1:null,path:null,pathLength:gc,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:xc,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:gc,pointsAtY:gc,pointsAtZ:gc,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bc,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bc,rev:bc,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bc,requiredFeatures:bc,requiredFonts:bc,requiredFormats:bc,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:gc,specularExponent:gc,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:gc,strikethroughThickness:gc,string:null,stroke:null,strokeDashArray:bc,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:gc,strokeOpacity:gc,strokeWidth:null,style:null,surfaceScale:gc,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bc,tabIndex:gc,tableValues:null,target:null,targetX:gc,targetY:gc,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bc,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:gc,underlineThickness:gc,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:gc,values:null,vAlphabetic:gc,vMathematical:gc,vectorEffect:null,vHanging:gc,vIdeographic:gc,version:null,vertAdvY:gc,vertOriginX:gc,vertOriginY:gc,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:gc,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ec}),Pc=Cc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),Ac=Cc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ic}),Rc=Cc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),Dc={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Fc=/[A-Z]/g,zc=/-[a-z]/g,Lc=/^data[-\w.:]+$/i;function Oc(e){return"-"+e.toLowerCase()}function Mc(e){return e.charAt(1).toUpperCase()}const $c=cc([Sc,_c,Pc,Ac,Rc],"html"),Uc=cc([Sc,Tc,Pc,Ac,Rc],"svg");var Bc,Vc,qc,Hc={};function Wc(){if(qc)return Hc;qc=1;var e=Hc&&Hc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.default=function(e,n){var r=null;if(!e||"string"!=typeof e)return r;var a=(0,t.default)(e),s="function"==typeof n;return a.forEach(function(e){if("declaration"===e.type){var t=e.property,a=e.value;s?n(t,a,e):a&&((r=r||{})[t]=a)}}),r};var t=e(function(){if(Vc)return Bc;Vc=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,o=/^\s+|\s+$/g,l="";function c(e){return e?e.replace(o,l):l}return Bc=function(o,d){if("string"!=typeof o)throw new TypeError("First argument must be a string");if(!o)return[];d=d||{};var u=1,m=1;function f(e){var n=e.match(t);n&&(u+=n.length);var r=e.lastIndexOf("\n");m=~r?e.length-r:m+e.length}function p(){var e={line:u,column:m};return function(t){return t.position=new h(e),y(),t}}function h(e){this.start=e,this.end={line:u,column:m},this.source=d.source}function g(e){var t=new Error(d.source+":"+u+":"+m+": "+e);if(t.reason=e,t.filename=d.source,t.line=u,t.column=m,t.source=o,!d.silent)throw t}function x(e){var t=e.exec(o);if(t){var n=t[0];return f(n),o=o.slice(n.length),t}}function y(){x(n)}function b(e){var t;for(e=e||[];t=v();)!1!==t&&e.push(t);return e}function v(){var e=p();if("/"==o.charAt(0)&&"*"==o.charAt(1)){for(var t=2;l!=o.charAt(t)&&("*"!=o.charAt(t)||"/"!=o.charAt(t+1));)++t;if(t+=2,l===o.charAt(t-1))return g("End of comment missing");var n=o.slice(2,t-2);return m+=2,f(n),o=o.slice(t),m+=2,e({type:"comment",comment:n})}}function w(){var t=p(),n=x(r);if(n){if(v(),!x(a))return g("property missing ':'");var o=x(s),d=t({type:"declaration",property:c(n[0].replace(e,l)),value:o?c(o[0].replace(e,l)):l});return x(i),d}}return h.prototype.content=o,y(),function(){var e,t=[];for(b(t);e=w();)!1!==e&&(t.push(e),b(t));return t}()},Bc}());return Hc}var Qc,Kc,Yc,Jc={};function Xc(){if(Qc)return Jc;Qc=1,Object.defineProperty(Jc,"__esModule",{value:!0}),Jc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,s=function(e,t){return t.toUpperCase()},i=function(e,t){return"".concat(t,"-")};return Jc.camelCase=function(o,l){return void 0===l&&(l={}),function(t){return!t||n.test(t)||e.test(t)}(o)?o:(o=o.toLowerCase(),(o=l.reactCompat?o.replace(a,i):o.replace(r,i)).replace(t,s))},Jc}var Gc=function(){if(Yc)return Kc;Yc=1;var e=(Kc&&Kc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Wc()),t=Xc();function n(n,r){var a={};return n&&"string"==typeof n?((0,e.default)(n,function(e,n){e&&n&&(a[(0,t.camelCase)(e,r)]=n)}),a):a}return n.default=n,Kc=n}(),Zc=Pt(Gc);const ed=nd("end"),td=nd("start");function nd(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function rd(e){return e&&"object"==typeof e?"position"in e||"type"in e?sd(e.position):"start"in e||"end"in e?sd(e):"line"in e||"column"in e?ad(e):"":""}function ad(e){return id(e&&e.line)+":"+id(e&&e.column)}function sd(e){return ad(e&&e.start)+"-"+ad(e&&e.end)}function id(e){return e&&"number"==typeof e?e:1}class od extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",a={},s=!1;if(t&&(a="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!a.cause&&e&&(s=!0,r=e.message,a.cause=e),!a.ruleId&&!a.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?a.ruleId=n:(a.source=n.slice(0,e),a.ruleId=n.slice(e+1))}if(!a.place&&a.ancestors&&a.ancestors){const e=a.ancestors[a.ancestors.length-1];e&&(a.place=e.position)}const i=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=rd(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=s&&a.cause&&"string"==typeof a.cause.stack?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}od.prototype.file="",od.prototype.name="",od.prototype.reason="",od.prototype.message="",od.prototype.stack="",od.prototype.column=void 0,od.prototype.line=void 0,od.prototype.ancestors=void 0,od.prototype.cause=void 0,od.prototype.fatal=void 0,od.prototype.place=void 0,od.prototype.ruleId=void 0,od.prototype.source=void 0;const ld={}.hasOwnProperty,cd=new Map,dd=/[A-Z]/g,ud=new Set(["table","tbody","thead","tfoot","tr"]),md=new Set(["td","th"]),fd="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function pd(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=function(e,t){return n;function n(n,r,a,s){const i=Array.isArray(a.children),o=td(n);return t(r,a,s,i,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");r=function(e,t,n){return r;function r(e,r,a,s){const i=Array.isArray(a.children)?n:t;return s?i(r,a,s):i(r,a)}}(0,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?Uc:$c,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=hd(a,e,void 0);return s&&"string"!=typeof s?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function hd(e,t,n){return"element"===t.type?function(e,t,n){const r=e.schema;let a=r;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(a=Uc,e.schema=a);e.ancestors.push(t);const s=vd(e,t.tagName,!1),i=function(e,t){const n={};let r,a;for(a in t.properties)if("children"!==a&&ld.call(t.properties,a)){const s=bd(e,a,t.properties[a]);if(s){const[a,i]=s;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof i&&md.has(t.tagName)?r=i:n[a]=i}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let o=yd(e,t);ud.has(t.tagName)&&(o=o.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&oc(t.value):oc(t));var t}));return gd(e,i,s,t),xd(i,o),e.ancestors.pop(),e.schema=r,e.create(t,s,i,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}wd(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const r=e.schema;let a=r;"svg"===t.name&&"html"===r.space&&(a=Uc,e.schema=a);e.ancestors.push(t);const s=null===t.name?e.Fragment:vd(e,t.name,!0),i=function(e,t){const n={};for(const r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){const t=r.data.estree.body[0];ec(t.type);const a=t.expression;ec(a.type);const s=a.properties[0];ec(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else wd(e,t.position);else{const a=r.name;let s;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){const t=r.value.data.estree.body[0];ec(t.type),s=e.evaluater.evaluateExpression(t.expression)}else wd(e,t.position);else s=null===r.value||r.value;n[a]=s}return n}(e,t),o=yd(e,t);return gd(e,i,s,t),xd(i,o),e.ancestors.pop(),e.schema=r,e.create(t,s,i,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);wd(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return xd(r,yd(e,t)),e.create(t,e.Fragment,r,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function gd(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function xd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function yd(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:cd;for(;++r<t.children.length;){const s=t.children[r];let i;if(e.passKeys){const e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){const t=a.get(e)||0;i=e+"-"+t,a.set(e,t+1)}}const o=hd(e,s,i);void 0!==o&&n.push(o)}return n}function bd(e,t,n){const r=function(e,t){const n=dc(t);let r=t,a=uc;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Lc.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(zc,Mc);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!zc.test(e)){let n=e.replace(Fc,Oc);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}a=jc}return new a(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return Zc(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new od("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=fd+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)ld.call(e,n)&&(t[Nd(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?Dc[r.property]||r.property:r.attribute,n]}}function vd(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,a=-1;for(;++a<e.length;){const t=sc(e[a])?{type:"Identifier",name:e[a]}:{type:"Literal",value:e[a]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(a&&"Literal"===t.type),optional:!1}:t}r=n}else r=sc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){const t=r.value;return ld.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);wd(e)}function wd(e,t){const n=new od("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=fd+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Nd(e){let t=e.replace(dd,jd);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function jd(e){return"-"+e.toLowerCase()}const kd={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Cd={};function Sd(e,t){return Ed(e,"boolean"!=typeof Cd.includeImageAlt||Cd.includeImageAlt,"boolean"!=typeof Cd.includeHtml||Cd.includeHtml)}function Ed(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Id(e.children,t,n)}return Array.isArray(e)?Id(e,t,n):""}function Id(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=Ed(e[a],t,n);return r.join("")}const _d=document.createElement("i");function Td(e){const t="&"+e+";";_d.innerHTML=t;const n=_d.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function Pd(e,t,n,r){const a=e.length;let s,i=0;if(t=t<0?-t>a?0:a+t:t>a?a:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function Ad(e,t){return e.length>0?(Pd(e,e.length,0,t),e):t}const Rd={}.hasOwnProperty;function Dd(e){const t={};let n=-1;for(;++n<e.length;)Fd(t,e[n]);return t}function Fd(e,t){let n;for(n in t){const r=(Rd.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){Rd.call(r,s)||(r[s]=[]);const e=a[s];zd(r[s],Array.isArray(e)?e:e?[e]:[])}}}function zd(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);Pd(e,0,0,r)}function Ld(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function Od(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Md=Xd(/[A-Za-z]/),$d=Xd(/[\dA-Za-z]/),Ud=Xd(/[#-'*+\--9=?A-Z^-~]/);function Bd(e){return null!==e&&(e<32||127===e)}const Vd=Xd(/\d/),qd=Xd(/[\dA-Fa-f]/),Hd=Xd(/[!-/:-@[-`{-~]/);function Wd(e){return null!==e&&e<-2}function Qd(e){return null!==e&&(e<0||32===e)}function Kd(e){return-2===e||-1===e||32===e}const Yd=Xd(/\p{P}|\p{S}/u),Jd=Xd(/\s/);function Xd(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Gd(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&$d(e.charCodeAt(n+1))&&$d(e.charCodeAt(n+2)))a=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const t=e.charCodeAt(n+1);s<56320&&t>56319&&t<57344?(i=String.fromCharCode(s,t),a=1):i="�"}else i=String.fromCharCode(s);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+a+1,i=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Zd(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(Kd(r))return e.enter(n),i(r);return t(r)};function i(r){return Kd(r)&&s++<a?(e.consume(r),i):(e.exit(n),t(r))}}const eu={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Zd(e,t,"linePrefix")},function(t){return e.enter("paragraph"),r(t)});let n;return t;function r(t){const r=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=r),n=r,a(t)}function a(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):Wd(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),a)}}};const tu={tokenize:function(e){const t=this,n=[];let r,a,s,i=0;return o;function o(r){if(i<n.length){const a=n[i];return t.containerState=a[1],e.attempt(a[0].continuation,l,c)(r)}return c(r)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&y();const n=t.events.length;let a,s=n;for(;s--;)if("exit"===t.events[s][0]&&"chunkFlow"===t.events[s][1].type){a=t.events[s][1].end;break}x(i);let o=n;for(;o<t.events.length;)t.events[o][1].end={...a},o++;return Pd(t.events,s+1,0,t.events.slice(n)),t.events.length=o,c(e)}return o(e)}function c(a){if(i===n.length){if(!r)return m(a);if(r.currentConstruct&&r.currentConstruct.concrete)return p(a);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(nu,d,u)(a)}function d(e){return r&&y(),x(i),m(e)}function u(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,p(e)}function m(n){return t.containerState={},e.attempt(nu,f,p)(n)}function f(e){return i++,n.push([t.currentConstruct,t.containerState]),m(e)}function p(n){return null===n?(r&&y(),x(0),void e.consume(n)):(r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:a}),h(n))}function h(n){return null===n?(g(e.exit("chunkFlow"),!0),x(0),void e.consume(n)):Wd(n)?(e.consume(n),g(e.exit("chunkFlow")),i=0,t.interrupt=void 0,o):(e.consume(n),h)}function g(e,n){const o=t.sliceStream(e);if(n&&o.push(null),e.previous=a,a&&(a.next=e),a=e,r.defineSkip(e.start),r.write(o),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<s&&(!r.events[e][1].end||r.events[e][1].end.offset>s))return;const n=t.events.length;let a,o,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(a){o=t.events[l][1].end;break}a=!0}for(x(i),e=n;e<t.events.length;)t.events[e][1].end={...o},e++;Pd(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function x(r){let a=n.length;for(;a-- >r;){const r=n[a];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function y(){r.write([null]),a=void 0,r=void 0,t.containerState._closeFlow=void 0}}},nu={tokenize:function(e,t,n){return Zd(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function ru(e){return null===e||Qd(e)||Jd(e)?1:Yd(e)?2:void 0}function au(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const s=e[a].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const su={name:"attention",resolveAll:function(e,t){let n,r,a,s,i,o,l,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close)for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;o=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;const u={...e[n][1].end},m={...e[d][1].start};iu(u,-o),iu(m,o),s={type:o>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},i={type:o>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:m},a={type:o>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},r={type:o>1?"strong":"emphasis",start:{...s.start},end:{...i.end}},e[n][1].end={...s.start},e[d][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=Ad(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=Ad(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",a,t]]),l=Ad(l,au(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=Ad(l,[["exit",a,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=Ad(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,Pd(e,n-1,d-n+3,l),d=n+l.length-c-2;break}d=-1;for(;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=ru(r);let s;return function(t){return s=t,e.enter("attentionSequence"),i(t)};function i(o){if(o===s)return e.consume(o),i;const l=e.exit("attentionSequence"),c=ru(o),d=!c||2===c&&a||n.includes(o),u=!a||2===a&&c||n.includes(r);return l._open=Boolean(42===s?d:d&&(a||!u)),l._close=Boolean(42===s?u:u&&(c||!d)),t(o)}}};function iu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ou={name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a};function a(t){return Md(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||$d(e)?(r=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),r=0,o):(43===t||45===t||46===t||$d(t))&&r++<32?(e.consume(t),i):(r=0,l(t))}function o(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||Bd(r)?n(r):(e.consume(r),o)}function l(t){return 64===t?(e.consume(t),c):Ud(t)?(e.consume(t),l):n(t)}function c(e){return $d(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),r=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):u(n)}function u(t){if((45===t||$d(t))&&r++<63){const n=45===t?u:d;return e.consume(t),n}return n(t)}}};const lu={partial:!0,tokenize:function(e,t,n){return function(t){return Kd(t)?Zd(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||Wd(e)?t(e):n(e)}}};const cu={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(Kd(t))return Zd(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return a(t)};function a(r){return e.attempt(cu,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),a}return n(t)};function a(n){return Kd(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const du={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return Hd(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const uu={name:"characterReference",tokenize:function(e,t,n){const r=this;let a,s,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),o};function o(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),a=31,s=$d,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,s=qd,c):(e.enter("characterReferenceValue"),a=7,s=Vd,c(t))}function c(o){if(59===o&&i){const a=e.exit("characterReferenceValue");return s!==$d||Td(r.sliceSerialize(a))?(e.enter("characterReferenceMarker"),e.consume(o),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(o)}return s(o)&&i++<a?(e.consume(o),c):n(o)}}};const mu={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a};function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},fu={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),Kd(t)?Zd(e,c,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===s?(e.enter("codeFencedFenceSequence"),d(t)):n(t)}function d(t){return t===s?(a++,e.consume(t),d):a>=o?(e.exit("codeFencedFenceSequence"),Kd(t)?Zd(e,u,"whitespace")(t):u(t)):n(t)}function u(r){return null===r||Wd(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let s,i=0,o=0;return function(t){return function(t){const n=r.events[r.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===s?(o++,e.consume(t),l):o<3?n(t):(e.exit("codeFencedFenceSequence"),Kd(t)?Zd(e,c,"whitespace")(t):c(t))}function c(n){return null===n||Wd(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(mu,f,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||Wd(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):Kd(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Zd(e,u,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),d)}function u(t){return null===t||Wd(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(t))}function m(t){return null===t||Wd(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),m)}function f(t){return e.attempt(a,y,p)(t)}function p(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return i>0&&Kd(t)?Zd(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||Wd(t)?e.check(mu,f,y)(t):(e.enter("codeFlowValue"),x(t))}function x(t){return null===t||Wd(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),x)}function y(n){return e.exit("codeFenced"),t(n)}}};const pu={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),Zd(e,a,"linePrefix",5)(t)};function a(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?s(e):n(e)}function s(t){return null===t?o(t):Wd(t)?e.attempt(hu,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||Wd(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},hu={partial:!0,tokenize:function(e,t,n){const r=this;return a;function a(t){return r.parser.lazy[r.now().line]?n(t):Wd(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):Zd(e,s,"linePrefix",5)(t)}function s(e){const s=r.events[r.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):Wd(e)?a(e):n(e)}}};const gu={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,a=3;if(!("lineEnding"!==e[a][1].type&&"space"!==e[a][1].type||"lineEnding"!==e[r][1].type&&"space"!==e[r][1].type))for(t=a;++t<r;)if("codeTextData"===e[t][1].type){e[a][1].type="codeTextPadding",e[r][1].type="codeTextPadding",a+=2,r-=2;break}t=a-1,r++;for(;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):t!==r&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,a,s=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),s++,i):(e.exit("codeTextSequence"),o(t))}function o(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),o):96===t?(a=e.enter("codeTextSequence"),r=0,c(t)):Wd(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||Wd(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),r++,c):r===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(a.type="codeTextData",l(n))}}};class xu{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const r=t||0;this.setCursor(Math.trunc(e));const a=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&yu(this.left,n),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),yu(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),yu(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);yu(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);yu(this.left,t.reverse())}}}function yu(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function bu(e){const t={};let n,r,a,s,i,o,l,c=-1;const d=new xu(e);for(;++c<d.length;){for(;c in t;)c=t[c];if(n=d.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&(o=n[1]._tokenizer.events,a=0,a<o.length&&"lineEndingBlank"===o[a][1].type&&(a+=2),a<o.length&&"content"===o[a][1].type))for(;++a<o.length&&"content"!==o[a][1].type;)"chunkText"===o[a][1].type&&(o[a][1]._isInFirstContentOfListItem=!0,a++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,vu(d,c)),c=t[c],l=!0);else if(n[1]._container){for(a=c,r=void 0;a--;)if(s=d.get(a),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(r&&(d.get(r)[1].type="lineEndingBlank"),s[1].type="lineEnding",r=a);else if("linePrefix"!==s[1].type&&"listItemIndent"!==s[1].type)break;r&&(n[1].end={...d.get(r)[1].start},i=d.slice(r,c),i.unshift(n),d.splice(r,c-r+1,i))}}return Pd(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function vu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const s=[];let i=n._tokenizer;i||(i=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const o=i.events,l=[],c={};let d,u,m=-1,f=n,p=0,h=0;const g=[h];for(;f;){for(;e.get(++a)[1]!==f;);s.push(a),f._tokenizer||(d=r.sliceStream(f),f.next||d.push(null),u&&i.defineSkip(f.start),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),u=f,f=f.next}for(f=n;++m<o.length;)"exit"===o[m][0]&&"enter"===o[m-1][0]&&o[m][1].type===o[m-1][1].type&&o[m][1].start.line!==o[m][1].end.line&&(h=m+1,g.push(h),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(i.events=[],f?(f._tokenizer=void 0,f.previous=void 0):g.pop(),m=g.length;m--;){const t=o.slice(g[m],g[m+1]),n=s.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),m=-1;++m<l.length;)c[p+l[m][0]]=p+l[m][1],p+=l[m][1]-l[m][0]-1;return c}const wu={resolve:function(e){return bu(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?a(t):Wd(t)?e.check(Nu,s,a)(t):(e.consume(t),r)}function a(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function s(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},Nu={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Zd(e,a,"linePrefix")};function a(a){if(null===a||Wd(a))return n(a);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}};function ju(e,t,n,r,a,s,i,o,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(r),e.enter(a),e.enter(s),e.consume(t),e.exit(s),u;if(null===t||32===t||41===t||Bd(t))return n(t);return e.enter(r),e.enter(i),e.enter(o),e.enter("chunkString",{contentType:"string"}),p(t)};function u(n){return 62===n?(e.enter(s),e.consume(n),e.exit(s),e.exit(a),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),m(n))}function m(t){return 62===t?(e.exit("chunkString"),e.exit(o),u(t)):null===t||60===t||Wd(t)?n(t):(e.consume(t),92===t?f:m)}function f(t){return 60===t||62===t||92===t?(e.consume(t),m):m(t)}function p(a){return d||null!==a&&41!==a&&!Qd(a)?d<c&&40===a?(e.consume(a),d++,p):41===a?(e.consume(a),d--,p):null===a||32===a||40===a||Bd(a)?n(a):(e.consume(a),92===a?h:p):(e.exit("chunkString"),e.exit(o),e.exit(i),e.exit(r),t(a))}function h(t){return 40===t||41===t||92===t?(e.consume(t),p):p(t)}}function ku(e,t,n,r,a,s){const i=this;let o,l=0;return function(t){return e.enter(r),e.enter(a),e.consume(t),e.exit(a),e.enter(s),c};function c(u){return l>999||null===u||91===u||93===u&&!o||94===u&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(u):93===u?(e.exit(s),e.enter(a),e.consume(u),e.exit(a),e.exit(r),t):Wd(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||Wd(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!Kd(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function Cu(e,t,n,r,a,s){let i;return function(t){if(34===t||39===t||40===t)return e.enter(r),e.enter(a),e.consume(t),e.exit(a),i=40===t?41:t,o;return n(t)};function o(n){return n===i?(e.enter(a),e.consume(n),e.exit(a),e.exit(r),t):(e.enter(s),l(n))}function l(t){return t===i?(e.exit(s),o(i)):null===t?n(t):Wd(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Zd(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||Wd(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===i||92===t?(e.consume(t),c):c(t)}}function Su(e,t){let n;return function r(a){if(Wd(a))return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r;if(Kd(a))return Zd(e,r,n?"linePrefix":"lineSuffix")(a);return t(a)}}const Eu={name:"definition",tokenize:function(e,t,n){const r=this;let a;return function(t){return e.enter("definition"),function(t){return ku.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return a=Od(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i):n(t)}function i(t){return Qd(t)?Su(e,o)(t):o(t)}function o(t){return ju(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(Iu,c,c)(t)}function c(t){return Kd(t)?Zd(e,d,"whitespace")(t):d(t)}function d(s){return null===s||Wd(s)?(e.exit("definition"),r.parser.defined.push(a),t(s)):n(s)}}},Iu={partial:!0,tokenize:function(e,t,n){return function(t){return Qd(t)?Su(e,r)(t):n(t)};function r(t){return Cu(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return Kd(t)?Zd(e,s,"whitespace")(t):s(t)}function s(e){return null===e||Wd(e)?t(e):n(e)}}};const _u={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return Wd(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const Tu={name:"headingAtx",resolve:function(e,t){let n,r,a=e.length-2,s=3;"whitespace"===e[s][1].type&&(s+=2);a-2>s&&"whitespace"===e[a][1].type&&(a-=2);"atxHeadingSequence"===e[a][1].type&&(s===a-1||a-4>s&&"whitespace"===e[a-2][1].type)&&(a-=s+1===a?2:4);a>s&&(n={type:"atxHeadingText",start:e[s][1].start,end:e[a][1].end},r={type:"chunkText",start:e[s][1].start,end:e[a][1].end,contentType:"text"},Pd(e,s,a-s+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),a(t)}(t)};function a(t){return 35===t&&r++<6?(e.consume(t),a):null===t||Qd(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||Wd(n)?(e.exit("atxHeading"),t(n)):Kd(n)?Zd(e,s,"whitespace")(n):(e.enter("atxHeadingText"),o(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),s(t))}function o(t){return null===t||35===t||Qd(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const Pu=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Au=["pre","script","style","textarea"],Ru={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const r=this;let a,s,i,o,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(o){return 33===o?(e.consume(o),d):47===o?(e.consume(o),s=!0,f):63===o?(e.consume(o),a=3,r.interrupt?t:D):Md(o)?(e.consume(o),i=String.fromCharCode(o),p):n(o)}function d(s){return 45===s?(e.consume(s),a=2,u):91===s?(e.consume(s),a=5,o=0,m):Md(s)?(e.consume(s),a=4,r.interrupt?t:D):n(s)}function u(a){return 45===a?(e.consume(a),r.interrupt?t:D):n(a)}function m(a){const s="CDATA[";return a===s.charCodeAt(o++)?(e.consume(a),6===o?r.interrupt?t:S:m):n(a)}function f(t){return Md(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||Qd(o)){const l=47===o,c=i.toLowerCase();return l||s||!Au.includes(c)?Pu.includes(i.toLowerCase())?(a=6,l?(e.consume(o),h):r.interrupt?t(o):S(o)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(o):s?g(o):x(o)):(a=1,r.interrupt?t(o):S(o))}return 45===o||$d(o)?(e.consume(o),i+=String.fromCharCode(o),p):n(o)}function h(a){return 62===a?(e.consume(a),r.interrupt?t:S):n(a)}function g(t){return Kd(t)?(e.consume(t),g):k(t)}function x(t){return 47===t?(e.consume(t),k):58===t||95===t||Md(t)?(e.consume(t),y):Kd(t)?(e.consume(t),x):k(t)}function y(t){return 45===t||46===t||58===t||95===t||$d(t)?(e.consume(t),y):b(t)}function b(t){return 61===t?(e.consume(t),v):Kd(t)?(e.consume(t),b):x(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):Kd(t)?(e.consume(t),v):N(t)}function w(t){return t===l?(e.consume(t),l=null,j):null===t||Wd(t)?n(t):(e.consume(t),w)}function N(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||Qd(t)?b(t):(e.consume(t),N)}function j(e){return 47===e||62===e||Kd(e)?x(e):n(e)}function k(t){return 62===t?(e.consume(t),C):n(t)}function C(t){return null===t||Wd(t)?S(t):Kd(t)?(e.consume(t),C):n(t)}function S(t){return 45===t&&2===a?(e.consume(t),T):60===t&&1===a?(e.consume(t),P):62===t&&4===a?(e.consume(t),F):63===t&&3===a?(e.consume(t),D):93===t&&5===a?(e.consume(t),R):!Wd(t)||6!==a&&7!==a?null===t||Wd(t)?(e.exit("htmlFlowData"),E(t)):(e.consume(t),S):(e.exit("htmlFlowData"),e.check(Du,z,E)(t))}function E(t){return e.check(Fu,I,z)(t)}function I(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),_}function _(t){return null===t||Wd(t)?E(t):(e.enter("htmlFlowData"),S(t))}function T(t){return 45===t?(e.consume(t),D):S(t)}function P(t){return 47===t?(e.consume(t),i="",A):S(t)}function A(t){if(62===t){const n=i.toLowerCase();return Au.includes(n)?(e.consume(t),F):S(t)}return Md(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),A):S(t)}function R(t){return 93===t?(e.consume(t),D):S(t)}function D(t){return 62===t?(e.consume(t),F):45===t&&2===a?(e.consume(t),D):S(t)}function F(t){return null===t||Wd(t)?(e.exit("htmlFlowData"),z(t)):(e.consume(t),F)}function z(n){return e.exit("htmlFlow"),t(n)}}},Du={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(lu,t,n)}}},Fu={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(Wd(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a;return n(t)};function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}};const zu={name:"htmlText",tokenize:function(e,t,n){const r=this;let a,s,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),o};function o(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),v):63===t?(e.consume(t),y):Md(t)?(e.consume(t),j):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,f):Md(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),m):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):Wd(t)?(i=d,A(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),m):d(t)}function m(e){return 62===e?P(e):45===e?u(e):d(e)}function f(t){const r="CDATA[";return t===r.charCodeAt(s++)?(e.consume(t),6===s?p:f):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),h):Wd(t)?(i=p,A(t)):(e.consume(t),p)}function h(t){return 93===t?(e.consume(t),g):p(t)}function g(t){return 62===t?P(t):93===t?(e.consume(t),g):p(t)}function x(t){return null===t||62===t?P(t):Wd(t)?(i=x,A(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):Wd(t)?(i=y,A(t)):(e.consume(t),y)}function b(e){return 62===e?P(e):y(e)}function v(t){return Md(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||$d(t)?(e.consume(t),w):N(t)}function N(t){return Wd(t)?(i=N,A(t)):Kd(t)?(e.consume(t),N):P(t)}function j(t){return 45===t||$d(t)?(e.consume(t),j):47===t||62===t||Qd(t)?k(t):n(t)}function k(t){return 47===t?(e.consume(t),P):58===t||95===t||Md(t)?(e.consume(t),C):Wd(t)?(i=k,A(t)):Kd(t)?(e.consume(t),k):P(t)}function C(t){return 45===t||46===t||58===t||95===t||$d(t)?(e.consume(t),C):S(t)}function S(t){return 61===t?(e.consume(t),E):Wd(t)?(i=S,A(t)):Kd(t)?(e.consume(t),S):k(t)}function E(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,I):Wd(t)?(i=E,A(t)):Kd(t)?(e.consume(t),E):(e.consume(t),_)}function I(t){return t===a?(e.consume(t),a=void 0,T):null===t?n(t):Wd(t)?(i=I,A(t)):(e.consume(t),I)}function _(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Qd(t)?k(t):(e.consume(t),_)}function T(e){return 47===e||62===e||Qd(e)?k(e):n(e)}function P(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function A(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),R}function R(t){return Kd(t)?Zd(e,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):D(t)}function D(t){return e.enter("htmlTextData"),i(t)}}};const Lu={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){const e="labelImage"===r.type?4:2;r.type="data",t+=e}}e.length!==n.length&&Pd(e,0,e.length,n);return e},resolveTo:function(e,t){let n,r,a,s,i=e.length,o=0;for(;i--;)if(n=e[i][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(a){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=i,"labelLink"!==n.type)){o=2;break}}else"labelEnd"===n.type&&(a=i);const l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[a][1].end}},d={type:"labelText",start:{...e[r+o+2][1].end},end:{...e[a-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=Ad(s,e.slice(r+1,r+o+3)),s=Ad(s,[["enter",d,t]]),s=Ad(s,au(t.parser.constructs.insideSpan.null,e.slice(r+o+4,a-3),t)),s=Ad(s,[["exit",d,t],e[a-2],e[a-1],["exit",c,t]]),s=Ad(s,e.slice(a+1)),s=Ad(s,[["exit",l,t]]),Pd(e,r,e.length,s),e},tokenize:function(e,t,n){const r=this;let a,s,i=r.events.length;for(;i--;)if(("labelImage"===r.events[i][1].type||"labelLink"===r.events[i][1].type)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return function(t){if(!a)return n(t);if(a._inactive)return d(t);return s=r.parser.defined.includes(Od(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),o};function o(t){return 40===t?e.attempt(Ou,c,s?c:d)(t):91===t?e.attempt(Mu,c,s?l:d)(t):s?c(t):d(t)}function l(t){return e.attempt($u,c,d)(t)}function c(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}},Ou={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return Qd(t)?Su(e,a)(t):a(t)}function a(t){return 41===t?c(t):ju(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return Qd(t)?Su(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?Cu(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return Qd(t)?Su(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},Mu={tokenize:function(e,t,n){const r=this;return function(t){return ku.call(r,e,a,s,"reference","referenceMarker","referenceString")(t)};function a(e){return r.parser.defined.includes(Od(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},$u={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}};const Uu={name:"labelStartImage",resolveAll:Lu.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),a};function a(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),s):n(t)}function s(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const Bu={name:"labelStartLink",resolveAll:Lu.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),a};function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const Vu={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Zd(e,t,"linePrefix")}}};const qu={name:"thematicBreak",tokenize:function(e,t,n){let r,a=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,s(e)}(t)};function s(s){return s===r?(e.enter("thematicBreakSequence"),i(s)):a>=3&&(null===s||Wd(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),a++,i):(e.exit("thematicBreakSequence"),Kd(t)?Zd(e,s,"whitespace")(t):s(t))}}};const Hu={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(lu,a,s);function a(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Zd(e,t,"listItemIndent",r.containerState.size+1)(n)}function s(n){return r.containerState.furtherBlankLines||!Kd(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Qu,t,i)(n))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Zd(e,e.attempt(Hu,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const r=this,a=r.events[r.events.length-1];let s=a&&"linePrefix"===a[1].type?a[2].sliceSerialize(a[1],!0).length:0,i=0;return function(t){const a=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===a?!r.containerState.marker||t===r.containerState.marker:Vd(t)){if(r.containerState.type||(r.containerState.type=a,e.enter(a,{_container:!0})),"listUnordered"===a)return e.enter("listItemPrefix"),42===t||45===t?e.check(qu,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),o(t)}return n(t)};function o(t){return Vd(t)&&++i<10?(e.consume(t),o):(!r.interrupt||i<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(lu,r.interrupt?n:c,e.attempt(Wu,u,d))}function c(e){return r.containerState.initialBlankLine=!0,s++,u(e)}function d(t){return Kd(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Wu={partial:!0,tokenize:function(e,t,n){const r=this;return Zd(e,function(e){const a=r.events[r.events.length-1];return!Kd(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Qu={partial:!0,tokenize:function(e,t,n){const r=this;return Zd(e,function(e){const a=r.events[r.events.length-1];return a&&"listItemIndent"===a[1].type&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}};const Ku={name:"setextUnderline",resolveTo:function(e,t){let n,r,a,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){n=s;break}"paragraph"===e[s][1].type&&(r=s)}else"content"===e[s][1].type&&e.splice(s,1),a||"definition"!==e[s][1].type||(a=s);const i={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};e[r][1].type="setextHeadingText",a?(e.splice(r,0,["enter",i,t]),e.splice(a+1,0,["exit",e[n][1],t]),e[n][1].end={...e[a][1].end}):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const r=this;let a;return function(t){let i,o=r.events.length;for(;o--;)if("lineEnding"!==r.events[o][1].type&&"linePrefix"!==r.events[o][1].type&&"content"!==r.events[o][1].type){i="paragraph"===r.events[o][1].type;break}if(!r.parser.lazy[r.now().line]&&(r.interrupt||i))return e.enter("setextHeadingLine"),a=t,function(t){return e.enter("setextHeadingLineSequence"),s(t)}(t);return n(t)};function s(t){return t===a?(e.consume(t),s):(e.exit("setextHeadingLineSequence"),Kd(t)?Zd(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||Wd(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const Yu={tokenize:function(e){const t=this,n=e.attempt(lu,function(r){if(null===r)return void e.consume(r);return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n},e.attempt(this.parser.constructs.flowInitial,r,Zd(e,e.attempt(this.parser.constructs.flow,r,e.attempt(wu,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}};const Ju={resolveAll:em()},Xu=Zu("string"),Gu=Zu("text");function Zu(e){return{resolveAll:em("text"===e?tm:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],a=t.attempt(r,s,i);return s;function s(e){return l(e)?a(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),o;t.consume(e)}function o(e){return l(e)?(t.exit("data"),a(e)):(t.consume(e),o)}function l(e){if(null===e)return!0;const t=r[e];let a=-1;if(t)for(;++a<t.length;){const e=t[a];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function em(e){return function(t,n){let r,a=-1;for(;++a<=t.length;)void 0===r?t[a]&&"data"===t[a][1].type&&(r=a,a++):t[a]&&"data"===t[a][1].type||(a!==r+2&&(t[r][1].end=t[a-1][1].end,t.splice(r+2,a-r-2),a=r+2),r=void 0);return e?e(t,n):t}}function tm(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const r=e[n-1][1],a=t.sliceStream(r);let s,i=a.length,o=-1,l=0;for(;i--;){const e=a[i];if("string"==typeof e){for(o=e.length;32===e.charCodeAt(o-1);)l++,o--;if(o)break;o=-1}else if(-2===e)s=!0,l++;else if(-1!==e){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const a={type:n===e.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:r.start._bufferIndex+o,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...a.start},r.start.offset===r.end.offset?Object.assign(r,a):(e.splice(n,0,["enter",a,t],["exit",a,t]),n+=2)}n++}return e}const nm={42:Hu,43:Hu,45:Hu,48:Hu,49:Hu,50:Hu,51:Hu,52:Hu,53:Hu,54:Hu,55:Hu,56:Hu,57:Hu,62:cu},rm={91:Eu},am={[-2]:pu,[-1]:pu,32:pu},sm={35:Tu,42:qu,45:[Ku,qu],60:Ru,61:Ku,95:qu,96:fu,126:fu},im={38:uu,92:du},om={[-5]:Vu,[-4]:Vu,[-3]:Vu,33:Uu,38:uu,42:su,60:[ou,zu],91:Bu,92:[_u,du],93:Lu,95:su,96:gu},lm={null:[su,Ju]};var cm=Object.freeze({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:rm,disable:{null:[]},document:nm,flow:sm,flowInitial:am,insideSpan:lm,string:im,text:om});function dm(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},s=[];let i=[],o=[];const l={attempt:g(function(e,t){x(e,t.from)}),check:g(h),consume:function(e){Wd(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,y()):-1!==e&&(r.column++,r.offset++);r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++));c.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=m(),c.events.push(["enter",n,c]),o.push(n),n},exit:function(e){const t=o.pop();return t.end=m(),c.events.push(["exit",t,c]),t},interrupt:g(h,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){a[e.line]=e.column,y()},events:[],now:m,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const s=e[n];let i;if("string"==typeof s)i=s;else switch(s){case-5:i="\r";break;case-4:i="\n";break;case-3:i="\r\n";break;case-2:i=t?" ":"\t";break;case-1:if(!t&&a)continue;i=" ";break;default:i=String.fromCharCode(s)}a=-2===s,r.push(i)}return r.join("")}(u(e),t)},sliceStream:u,write:function(e){if(i=Ad(i,e),f(),null!==i[i.length-1])return[];return x(t,0),c.events=au(s,c.events,c),c.events}};let d=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function u(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,s=t.end._bufferIndex;let i;if(n===a)i=[e[n].slice(r,s)];else{if(i=e.slice(n,a),r>-1){const e=i[0];"string"==typeof e?i[0]=e.slice(r):i.shift()}s>0&&i.push(e[a].slice(0,s))}return i}(i,e)}function m(){const{_bufferIndex:e,_index:t,line:n,column:a,offset:s}=r;return{_bufferIndex:e,_index:t,line:n,column:a,offset:s}}function f(){let e;for(;r._index<i.length;){const t=i[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)p(t.charCodeAt(r._bufferIndex));else p(t)}}function p(e){d=d(e)}function h(e,t){t.restore()}function g(e,t){return function(n,a,s){let i,d,u,f;return Array.isArray(n)?p(n):"tokenize"in n?p([n]):function(e){return t;function t(t){const n=null!==t&&e[t],r=null!==t&&e.null;return p([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function p(e){return i=e,d=0,0===e.length?s:h(e[d])}function h(e){return function(n){f=function(){const e=m(),t=c.previous,n=c.currentConstruct,a=c.events.length,s=Array.from(o);return{from:a,restore:i};function i(){r=e,c.previous=t,c.currentConstruct=n,c.events.length=a,o=s,y()}}(),u=e,e.partial||(c.currentConstruct=e);if(e.name&&c.parser.constructs.disable.null.includes(e.name))return x();return e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,g,x)(n)}}function g(t){return e(u,f),a}function x(e){return f.restore(),++d<i.length?h(i[d]):s}}}function x(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&Pd(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function y(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}const um=/[\0\t\n\r]/g;const mm=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function fm(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Ld(n.slice(t?2:1),t?16:10)}return Td(n)||e}const pm={}.hasOwnProperty;function hm(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(te),autolinkProtocol:C,autolinkEmail:C,atxHeading:s(X),blockQuote:s(W),characterEscape:C,characterReference:C,codeFenced:s(Q),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(Q,i),codeText:s(K,i),codeTextData:C,data:C,codeFlowValue:C,definition:s(Y),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(J),hardBreakEscape:s(G),hardBreakTrailing:s(G),htmlFlow:s(Z,i),htmlFlowData:C,htmlText:s(Z,i),htmlTextData:C,image:s(ee),label:i,link:s(te),listItem:s(re),listItemValue:m,listOrdered:s(ne,u),listUnordered:s(ne),paragraph:s(ae),reference:M,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:s(X),strong:s(se),thematicBreak:s(oe)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:H,autolinkProtocol:q,blockQuote:l(),characterEscapeValue:S,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:B,characterReference:V,codeFenced:l(g),codeFencedFence:h,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:S,codeIndented:l(x),codeText:l(P),codeTextData:S,data:S,definition:l(),definitionDestinationString:v,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(I),hardBreakTrailing:l(I),htmlFlow:l(_),htmlFlowData:S,htmlText:l(T),htmlTextData:S,image:l(R),label:F,labelText:D,lineEnding:E,link:l(A),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:$,resourceDestinationString:z,resourceTitleString:L,resource:O,setextHeading:l(k),setextHeadingLineSequence:j,setextHeadingText:N,strong:l(),thematicBreak:l()}};xm(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(e){let r={type:"root",children:[]};const s={stack:[r],tokenStack:[],config:t,enter:o,exit:c,buffer:i,resume:d,data:n},l=[];let u=-1;for(;++u<e.length;)if("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)if("enter"===e[u][0])l.push(u);else{u=a(e,l.pop(),u)}for(u=-1;++u<e.length;){const n=t[e[u][0]];pm.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},s),e[u][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||bm).call(s,void 0,e[0])}for(r.position={start:gm(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:gm(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r}function a(e,t,n){let r,a,s,i,o=t-1,l=-1,c=!1;for(;++o<=n;){const t=e[o];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||i||l||s||(s=o),i=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:i=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let i=o;for(a=void 0;i--;){const t=e[i];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;a&&(e[a][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",a=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}s&&(!a||s<a)&&(r._spread=!0),r.end=Object.assign({},a?e[a][1].start:t[1].end),e.splice(a||o,0,["exit",r,t[2]]),o++,n++}if("listItemPrefix"===t[1].type){const a={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=a,e.splice(o,0,["enter",a,t[2]]),o++,n++,s=void 0,i=!0}}}return e[t][1]._spread=c,n}function s(e,t){return n;function n(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:gm(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){const n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw new Error("Cannot close `"+e.type+"` ("+rd({start:e.start,end:e.end})+"): it’s not open");if(r[0].type!==e.type)if(t)t.call(this,e,r[0]);else{(r[1]||bm).call(this,e,r[0])}n.position.end=gm(e.end)}function d(){return Sd(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function m(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function f(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function p(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function y(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Od(this.sliceSerialize(e)).toLowerCase()}function b(){const e=this.resume();this.stack[this.stack.length-1].title=e}function v(){const e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function j(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function k(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ie(),n.position={start:gm(e.start),end:void 0},t.push(n)),this.stack.push(n)}function S(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=gm(e.end)}function E(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=gm(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(C.call(this,e),S.call(this,e))}function I(){this.data.atHardBreak=!0}function _(){const e=this.resume();this.stack[this.stack.length-1].value=e}function T(){const e=this.resume();this.stack[this.stack.length-1].value=e}function P(){const e=this.resume();this.stack[this.stack.length-1].value=e}function A(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function R(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function D(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(mm,fm)}(t),n.identifier=Od(t).toLowerCase()}function F(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function z(){const e=this.resume();this.stack[this.stack.length-1].url=e}function L(){const e=this.resume();this.stack[this.stack.length-1].title=e}function O(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function $(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Od(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function U(e){this.data.characterReferenceType=e.type}function B(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;if(n)r=Ld(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=Td(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=gm(e.end)}function q(e){S.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function H(e){S.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function W(){return{type:"blockquote",children:[]}}function Q(){return{type:"code",lang:null,meta:null,value:""}}function K(){return{type:"inlineCode",value:""}}function Y(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function J(){return{type:"emphasis",children:[]}}function X(){return{type:"heading",depth:0,children:[]}}function G(){return{type:"break"}}function Z(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function re(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function ae(){return{type:"paragraph",children:[]}}function se(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function oe(){return{type:"thematicBreak"}}}(n)(function(e){for(;!bu(e););return e}(function(e){const t={constructs:Dd([cm,...(e||{}).extensions||[]]),content:n(eu),defined:[],document:n(tu),flow:n(Yu),lazy:{},string:n(Xu),text:n(Gu)};return t;function n(e){return function(n){return dm(t,e,n)}}}(n).document().write(function(){let e,t=1,n="",r=!0;return function(a,s,i){const o=[];let l,c,d,u,m;for(a=n+("string"==typeof a?a.toString():new TextDecoder(s||void 0).decode(a)),d=0,n="",r&&(65279===a.charCodeAt(0)&&d++,r=void 0);d<a.length;){if(um.lastIndex=d,l=um.exec(a),u=l&&void 0!==l.index?l.index:a.length,m=a.charCodeAt(u),!l){n=a.slice(d);break}if(10===m&&d===u&&e)o.push(-3),e=void 0;else switch(e&&(o.push(-5),e=void 0),d<u&&(o.push(a.slice(d,u)),t+=u-d),m){case 0:o.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),o.push(-2);t++<c;)o.push(-1);break;case 10:o.push(-4),t=1;break;default:e=!0,t=1}d=u+1}return i&&(e&&o.push(-5),n&&o.push(n),o.push(null)),o}}()(e,t,!0))))}function gm(e){return{line:e.line,column:e.column,offset:e.offset}}function xm(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?xm(e,r):ym(e,r)}}function ym(e,t){let n;for(n in t)if(pm.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function bm(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+rd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+rd({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+rd({start:t.start,end:t.end})+") is still open")}function vm(e){const t=this;t.parser=function(n){return hm(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function wm(e,t){const n=t.referenceType;let r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),s=a[0];s&&"text"===s.type?s.value="["+s.value:a.unshift({type:"text",value:"["});const i=a[a.length-1];return i&&"text"===i.type?i.value+=r:a.push({type:"text",value:r}),a}function Nm(e){const t=e.spread;return null==t?e.children.length>1:t}function jm(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const s=[];for(;r;)s.push(km(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return s.push(km(t.slice(a),a>0,!1)),s.join("")}function km(e,t,n){let r=0,a=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(a-1);for(;9===t||32===t;)a--,t=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}const Cm={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",r={};t.lang&&(r.className=["language-"+t.lang]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=Gd(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let i,o=e.footnoteCounts.get(r);void 0===o?(o=0,e.footnoteOrder.push(r),i=e.footnoteOrder.length):i=s+1,o+=1,e.footnoteCounts.set(r,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return wm(e,t);const a={src:Gd(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(a.title=r.title);const s={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){const n={src:Gd(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return wm(e,t);const a={href:Gd(r.url||"")};null!==r.title&&void 0!==r.title&&(a.title=r.title);const s={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){const n={href:Gd(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){const r=e.all(t),a=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Nm(n[r])}return t}(n):Nm(t),s={},i=[];if("boolean"==typeof t.checked){const e=r[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const e=r[o];(a||0!==o||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||a?i.push(e):i.push(...e.children)}const l=r[r.length-1];l&&(a||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:s,children:i};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},r=e.all(t);let a=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++a<r.length;){const e=r[a];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),a.push(n)}if(n.length>0){const r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},s=td(t.children[1]),i=ed(t.children[t.children.length-1]);s&&i&&(r.position={start:s,end:i}),a.push(r)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,s),e.applyData(t,s)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const r=n?n.children:void 0,a=0===(r?r.indexOf(t):1)?"th":"td",s=n&&"table"===n.type?n.align:void 0,i=s?s.length:t.children.length;let o=-1;const l=[];for(;++o<i;){const n=t.children[o],r={},i=s?s[o]:void 0;i&&(r.align=i);let c={type:"element",tagName:a,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){const n={type:"text",value:jm(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:Sm,yaml:Sm,definition:Sm,footnoteDefinition:Sm};function Sm(){}const Em="object"==typeof self?self:globalThis,Im=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),r=a=>{if(e.has(a))return e.get(a);const[s,i]=t[a];switch(s){case 0:case-1:return n(i,a);case 1:{const e=n([],a);for(const t of i)e.push(r(t));return e}case 2:{const e=n({},a);for(const[t,n]of i)e[r(t)]=r(n);return e}case 3:return n(new Date(i),a);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),a)}case 5:{const e=n(new Map,a);for(const[t,n]of i)e.set(r(t),r(n));return e}case 6:{const e=n(new Set,a);for(const t of i)e.add(r(t));return e}case 7:{const{name:e,message:t}=i;return n(new Em[e](t),a)}case 8:return n(BigInt(i),a);case"BigInt":return n(Object(BigInt(i)),a);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:e}=new Uint8Array(i);return n(new DataView(e),i)}}return n(new Em[s](i),a)};return r})(new Map,e)(0),_m="",{toString:Tm}={},{keys:Pm}=Object,Am=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=Tm.call(e).slice(8,-1);switch(n){case"Array":return[1,_m];case"Object":return[2,_m];case"Date":return[3,_m];case"RegExp":return[4,_m];case"Map":return[5,_m];case"Set":return[6,_m];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Rm=([e,t])=>0===e&&("function"===t||"symbol"===t),Dm=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const a=(e,t)=>{const a=r.push(e)-1;return n.set(t,a),a},s=r=>{if(n.has(r))return n.get(r);let[i,o]=Am(r);switch(i){case 0:{let t=r;switch(o){case"bigint":i=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);t=null;break;case"undefined":return a([-1],r)}return a([i,t],r)}case 1:{if(o){let e=r;return"DataView"===o?e=new Uint8Array(r.buffer):"ArrayBuffer"===o&&(e=new Uint8Array(r)),a([o,[...e]],r)}const e=[],t=a([i,e],r);for(const n of r)e.push(s(n));return t}case 2:{if(o)switch(o){case"BigInt":return a([o,r.toString()],r);case"Boolean":case"Number":case"String":return a([o,r.valueOf()],r)}if(t&&"toJSON"in r)return s(r.toJSON());const n=[],l=a([i,n],r);for(const t of Pm(r))!e&&Rm(Am(r[t]))||n.push([s(t),s(r[t])]);return l}case 3:return a([i,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return a([i,{source:e,flags:t}],r)}case 5:{const t=[],n=a([i,t],r);for(const[a,i]of r)(e||!Rm(Am(a))&&!Rm(Am(i)))&&t.push([s(a),s(i)]);return n}case 6:{const t=[],n=a([i,t],r);for(const a of r)!e&&Rm(Am(a))||t.push(s(a));return n}}const{message:l}=r;return a([i,{name:o,message:l}],r)};return s})(!(t||n),!!t,new Map,r)(e),r};var Fm="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Im(Dm(e,t)):structuredClone(e):(e,t)=>Im(Dm(e,t));function zm(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Lm(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Om=function(e){if(null==e)return $m;if("function"==typeof e)return Mm(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Om(e[n]);return Mm(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}(e):function(e){const t=e;return Mm(n);function n(n){const r=n;let a;for(a in e)if(r[a]!==t[a])return!1;return!0}}(e);if("string"==typeof e)return function(e){return Mm(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function Mm(e){return function(t,n,r){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function $m(){return!0}const Um=[],Bm=!0,Vm=!1;function qm(e,t,n,r){let a;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):a=t;const s=Om(a),i=r?-1:1;!function e(a,o,l){const c=a&&"object"==typeof a?a:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+a.type+(e?"<"+e+">":"")+")"})}return d;function d(){let c,d,u,m=Um;if((!t||s(a,o,l[l.length-1]||void 0))&&(m=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[Bm,e];return null==e?Um:[e]}(n(a,l)),m[0]===Vm))return m;if("children"in a&&a.children){const t=a;if(t.children&&"skip"!==m[0])for(d=(r?t.children.length:-1)+i,u=l.concat(t);d>-1&&d<t.children.length;){const n=t.children[d];if(c=e(n,d,u)(),c[0]===Vm)return c;d="number"==typeof c[1]?c[1]:d+i}}return m}}(e,void 0,[])()}function Hm(e,t,n,r){let a,s,i;"function"==typeof t&&"function"!=typeof n?(s=void 0,i=t,a=n):(s=t,i=n,a=r),qm(e,s,function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return i(e,r,n)},a)}const Wm={}.hasOwnProperty,Qm={};function Km(e,t){e.position&&(t.position=function(e){const t=td(e),n=ed(e);if(t&&n)return{start:t,end:n}}(e))}function Ym(e,t){let n=t;if(e&&e.data){const t=e.data.hName,r=e.data.hChildren,a=e.data.hProperties;if("string"==typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&a&&Object.assign(n.properties,Fm(a)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function Jm(e,t){const n=t.data||{},r=!("value"in t)||Wm.call(n,"hProperties")||Wm.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,r),e.applyData(t,r)}function Xm(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function Gm(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function Zm(e,t){const n=function(e,t){const n=t||Qm,r=new Map,a=new Map,s=new Map,i={...Cm,...n.handlers},o={all:function(e){const t=[];if("children"in e){const n=e.children;let r=-1;for(;++r<n.length;){const a=o.one(n[r],e);if(a){if(r&&"break"===n[r-1].type&&(Array.isArray(a)||"text"!==a.type||(a.value=Gm(a.value)),!Array.isArray(a)&&"element"===a.type)){const e=a.children[0];e&&"text"===e.type&&(e.value=Gm(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:Ym,definitionById:r,footnoteById:a,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=o.handlers[n];if(Wm.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,r=Fm(n);return r.children=o.all(e),r}return Fm(e)}return(o.options.unknownHandler||Jm)(o,e,t)},options:n,patch:Km,wrap:Xm};return Hm(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?r:a,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o}(e,t),r=n.one(e,void 0),a=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||zm,r=e.options.footnoteBackLabel||Lm,a=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const a=e.footnoteById.get(e.footnoteOrder[l]);if(!a)continue;const s=e.all(a),i=String(a.identifier).toUpperCase(),c=Gd(i.toLowerCase());let d=0;const u=[],m=e.footnoteCounts.get(i);for(;void 0!==m&&++d<=m;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const f=s[s.length-1];if(f&&"element"===f.type&&"p"===f.tagName){const e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...u)}else s.push(...u);const p={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(a,p),o.push(p)}if(0!==o.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Fm(i),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:"\n"}]}}(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&s.children.push({type:"text",value:"\n"},a),s}function ef(e,t){return e&&"run"in e?async function(n,r){const a=Zm(n,{file:r,...t});await e.run(a,r)}:function(n,r){return Zm(n,{file:r,...e||t})}}function tf(e){if(e)throw e}var nf,rf;var af=function(){if(rf)return nf;rf=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===t.call(e)},s=function(n){if(!n||"[object Object]"!==t.call(n))return!1;var r,a=e.call(n,"constructor"),s=n.constructor&&n.constructor.prototype&&e.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!a&&!s)return!1;for(r in n);return void 0===r||e.call(n,r)},i=function(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},o=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(r)return r(t,n).value}return t[n]};return nf=function e(){var t,n,r,l,c,d,u=arguments[0],m=1,f=arguments.length,p=!1;for("boolean"==typeof u&&(p=u,u=arguments[1]||{},m=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});m<f;++m)if(null!=(t=arguments[m]))for(n in t)r=o(u,n),u!==(l=o(t,n))&&(p&&l&&(s(l)||(c=a(l)))?(c?(c=!1,d=r&&a(r)?r:[]):d=r&&s(r)?r:{},i(u,{name:n,newValue:e(p,d,l)})):void 0!==l&&i(u,{name:n,newValue:l}));return u},nf}(),sf=Pt(af);function of(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function lf(){const e=[],t={run:function(...t){let n=-1;const r=t.pop();if("function"!=typeof r)throw new TypeError("Expected function as last argument, not "+r);!function a(s,...i){const o=e[++n];let l=-1;if(s)r(s);else{for(;++l<t.length;)null!==i[l]&&void 0!==i[l]||(i[l]=t[l]);t=i,o?function(e,t){let n;return r;function r(...t){const r=e.length>t.length;let o;r&&t.push(a);try{o=e.apply(this,t)}catch(s){if(r&&n)throw s;return a(s)}r||(o&&o.then&&"function"==typeof o.then?o.then(i,a):o instanceof Error?a(o):i(o))}function a(e,...r){n||(n=!0,t(e,...r))}function i(e){a(null,e)}}(o,a)(...i):r(null,...i)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const cf={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');df(e);let n,r=0,a=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else a<0&&(n=!0,a=s+1);return a<0?"":e.slice(r,a)}if(t===e)return"";let i=-1,o=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else i<0&&(n=!0,i=s+1),o>-1&&(e.codePointAt(s)===t.codePointAt(o--)?o<0&&(a=s):(o=-1,a=i));r===a?a=i:a<0&&(a=e.length);return e.slice(r,a)},dirname:function(e){if(df(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){df(e);let t,n=e.length,r=-1,a=0,s=-1,i=0;for(;n--;){const o=e.codePointAt(n);if(47!==o)r<0&&(t=!0,r=n+1),46===o?s<0?s=n:1!==i&&(i=1):s>-1&&(i=-1);else if(t){a=n+1;break}}if(s<0||r<0||0===i||1===i&&s===r-1&&s===a+1)return"";return e.slice(s,r)},join:function(...e){let t,n=-1;for(;++n<e.length;)df(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){df(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,a="",s=0,i=-1,o=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else{if(47===n)break;n=47}if(47===n){if(i===l-1||1===o);else if(i!==l-1&&2===o){if(a.length<2||2!==s||46!==a.codePointAt(a.length-1)||46!==a.codePointAt(a.length-2))if(a.length>2){if(r=a.lastIndexOf("/"),r!==a.length-1){r<0?(a="",s=0):(a=a.slice(0,r),s=a.length-1-a.lastIndexOf("/")),i=l,o=0;continue}}else if(a.length>0){a="",s=0,i=l,o=0;continue}t&&(a=a.length>0?a+"/..":"..",s=2)}else a.length>0?a+="/"+e.slice(i+1,l):a=e.slice(i+1,l),s=l-i-1;i=l,o=0}else 46===n&&o>-1?o++:o=-1}return a}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function df(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const uf={cwd:function(){return"/"}};function mf(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function ff(e){if("string"==typeof e)e=new URL(e);else if(!mf(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const pf=["history","path","basename","stem","extname","dirname"];class hf{constructor(e){let t;t=e?mf(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":uf.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<pf.length;){const e=pf[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)pf.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?cf.basename(this.path):void 0}set basename(e){xf(e,"basename"),gf(e,"basename"),this.path=cf.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?cf.dirname(this.path):void 0}set dirname(e){yf(this.basename,"dirname"),this.path=cf.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?cf.extname(this.path):void 0}set extname(e){if(gf(e,"extname"),yf(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=cf.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){mf(e)&&(e=ff(e)),xf(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?cf.basename(this.path,this.extname):void 0}set stem(e){xf(e,"stem"),gf(e,"stem"),this.path=cf.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){const r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){const r=new od(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function gf(e,t){if(e&&e.includes(cf.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+cf.sep+"`")}function xf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function yf(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const bf=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},vf={}.hasOwnProperty;class wf extends bf{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=lf()}copy(){const e=new wf;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(sf(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(Cf("data",this.frozen),this.namespace[e]=t,this):vf.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Cf("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=If(e),n=this.parser||this.Parser;return jf("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),jf("process",this.parser||this.Parser),kf("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,a){const s=If(e),i=n.parse(s);function o(e,n){e||!n?a(e):r?r(n):t(void 0,n)}n.run(i,s,function(e,t,r){if(e||!t||!r)return o(e);const a=t,s=n.stringify(a,r);!function(e){return"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)}(s)?r.result=s:r.value=s,o(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),jf("processSync",this.parser||this.Parser),kf("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,tf(e),t=r}),Ef("processSync","process",n),t}run(e,t,n){Sf(e),this.freeze();const r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?a(void 0,n):new Promise(a);function a(a,s){const i=If(t);r.run(e,i,function(t,r,i){const o=r||e;t?s(t):a?a(o):n(void 0,o,i)})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){tf(e),n=t,r=!0}),Ef("runSync","run",r),n}stringify(e,t){this.freeze();const n=If(t),r=this.compiler||this.Compiler;return kf("stringify",r),Sf(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(Cf("use",this.frozen),null==e);else if("function"==typeof e)o(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?i(e):s(e)}return this;function a(e){if("function"==typeof e)o(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;o(t,n)}else s(e)}}function s(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(r.settings=sf(!0,r.settings,e.settings))}function i(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){a(e[t])}}}function o(e,t){let r=-1,a=-1;for(;++r<n.length;)if(n[r][0]===e){a=r;break}if(-1===a)n.push([e,...t]);else if(t.length>0){let[r,...s]=t;const i=n[a][1];of(i)&&of(r)&&(r=sf(!0,i,r)),n[a]=[e,r,...s]}}}}const Nf=(new wf).freeze();function jf(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function kf(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function Cf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Sf(e){if(!of(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function Ef(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function If(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new hf(e)}const _f=[],Tf={allowDangerousHtml:!0},Pf=/^(https?|ircs?|mailto|xmpp)$/i,Af=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Rf(e){const t=function(e){const t=e.rehypePlugins||_f,n=e.remarkPlugins||_f,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Tf}:Tf,a=Nf().use(vm).use(n).use(ef,r).use(t);return a}(e),n=function(e){const t=e.children||"",n=new hf;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,s=t.disallowedElements,i=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||Df;for(const d of Af)Object.hasOwn(t,d.from)&&tc((d.from,d.to&&d.to,d.id));return Hm(e,c),pd(e,{Fragment:Mt.Fragment,components:a,ignoreInvalidStyle:!0,jsx:Mt.jsx,jsxs:Mt.jsxs,passKeys:!0,passNode:!0});function c(e,t,a){if("raw"===e.type&&a&&"number"==typeof t)return i?a.children.splice(t,1):a.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in kd)if(Object.hasOwn(kd,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=kd[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let i=n?!n.includes(e.tagName):!!s&&s.includes(e.tagName);if(!i&&r&&"number"==typeof t&&(i=!r(e,t,a)),i&&a&&"number"==typeof t)return o&&e.children?a.children.splice(t,1,...e.children):a.children.splice(t,1),t}}}(t.runSync(t.parse(n),n),e)}function Df(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return-1===t||-1!==a&&t>a||-1!==n&&t>n||-1!==r&&t>r||Pf.test(e.slice(0,t))?e:""}function Ff(e,t){const n=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;-1!==a;)r++,a=n.indexOf(t,a+t.length);return r}function zf(e,t,n){const r=Om((n||{}).ignore||[]),a=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const e=n[r];t.push([Lf(e[0]),Of(e[1])])}return t}(t);let s=-1;for(;++s<a.length;)qm(e,"text",i);function i(e,t){let n,i=-1;for(;++i<t.length;){const e=t[i],a=n?n.children:void 0;if(r(e,a?a.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){const n=t[t.length-1],r=a[s][0],i=a[s][1];let o=0;const l=n.children.indexOf(e);let c=!1,d=[];r.lastIndex=0;let u=r.exec(e.value);for(;u;){const n=u.index,a={index:u.index,input:u.input,stack:[...t,e]};let s=i(...u,a);if("string"==typeof s&&(s=s.length>0?{type:"text",value:s}:void 0),!1===s?r.lastIndex=n+1:(o!==n&&d.push({type:"text",value:e.value.slice(o,n)}),Array.isArray(s)?d.push(...s):s&&d.push(s),o=n+u[0].length,c=!0),!r.global)break;u=r.exec(e.value)}c?(o<e.value.length&&d.push({type:"text",value:e.value.slice(o)}),n.children.splice(l,1,...d)):d=[e];return l+d.length}(e,t)}}function Lf(e){return"string"==typeof e?new RegExp(function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e),"g"):e}function Of(e){return"function"==typeof e?e:function(){return e}}const Mf="phrasing",$f=["autolink","link","image","label"];function Uf(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Bf(e){this.config.enter.autolinkProtocol.call(this,e)}function Vf(e){this.config.exit.autolinkProtocol.call(this,e)}function qf(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Hf(e){this.config.exit.autolinkEmail.call(this,e)}function Wf(e){this.exit(e)}function Qf(e){zf(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Kf],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Yf]],{ignore:["link","linkReference"]})}function Kf(e,t,n,r,a){let s="";if(!Jf(a))return!1;if(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!function(e){const t=e.split(".");if(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))return!1;return!0}(n))return!1;const i=function(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=Ff(e,"(");let s=Ff(e,")");for(;-1!==r&&a>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}(n+r);if(!i[0])return!1;const o={type:"link",title:null,url:s+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[o,{type:"text",value:i[1]}]:o}function Yf(e,t,n,r){return!(!Jf(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Jf(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||Jd(n)||Yd(n))&&(!t||47!==n)}function Xf(){this.buffer()}function Gf(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Zf(){this.buffer()}function ep(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function tp(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Od(this.sliceSerialize(e)).toLowerCase(),n.label=t}function np(e){this.exit(e)}function rp(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Od(this.sliceSerialize(e)).toLowerCase(),n.label=t}function ap(e){this.exit(e)}function sp(e,t,n,r){const a=n.createTracker(r);let s=a.move("[^");const i=n.enter("footnoteReference"),o=n.enter("reference");return s+=a.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),i(),s+=a.move("]"),s}function ip(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,n,r,a){const s=r.createTracker(a);let i=s.move("[^");const o=r.enter("footnoteDefinition"),l=r.enter("label");i+=s.move(r.safe(r.associationId(e),{before:i,after:"]"})),l(),i+=s.move("]:"),e.children&&e.children.length>0&&(s.shift(4),i+=s.move((t?"\n":" ")+r.indentLines(r.containerFlow(e,s.current()),t?lp:op)));return o(),i},footnoteReference:sp},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function op(e,t,n){return 0===t?e:lp(e,t,n)}function lp(e,t,n){return(n?"":" ")+e}sp.peek=function(){return"["};const cp=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function dp(e){this.enter({type:"delete",children:[]},e)}function up(e){this.exit(e)}function mp(e,t,n,r){const a=n.createTracker(r),s=n.enter("strikethrough");let i=a.move("~~");return i+=n.containerPhrasing(e,{...a.current(),before:i,after:"~"}),i+=a.move("~~"),s(),i}function fp(e){return e.length}function pp(e){return null==e?"":String(e)}function hp(e){const t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function gp(e,t,n){return">"+(n?"":" ")+e}function xp(e,t){return yp(e,t.inConstruct,!0)&&!yp(e,t.notInConstruct,!1)}function yp(e,t,n){if("string"==typeof t&&(t=[t]),!t||0===t.length)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function bp(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if("\n"===n.unsafe[a].character&&xp(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function vp(e,t,n){return(n?"":" ")+e}function wp(e){const t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Np(e){return"&#x"+e.toString(16).toUpperCase()+";"}function jp(e,t,n){const r=ru(e),a=ru(t);return void 0===r?void 0===a?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===a?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===r?void 0===a?{inside:!1,outside:!1}:1===a?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===a?{inside:!1,outside:!1}:1===a?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function kp(e,t,n,r){const a=function(e){const t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),s=n.enter("emphasis"),i=n.createTracker(r),o=i.move(a);let l=i.move(n.containerPhrasing(e,{after:a,before:o,...i.current()}));const c=l.charCodeAt(0),d=jp(r.before.charCodeAt(r.before.length-1),c,a);d.inside&&(l=Np(c)+l.slice(1));const u=l.charCodeAt(l.length-1),m=jp(r.after.charCodeAt(0),u,a);m.inside&&(l=l.slice(0,-1)+Np(u));const f=i.move(a);return s(),n.attentionEncodeSurroundingInfo={after:m.outside,before:d.outside},o+l+f}function Cp(e){return e.value||""}function Sp(e,t,n,r){const a=wp(n),s='"'===a?"Quote":"Apostrophe",i=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+a),c+=l.move(n.safe(e.title,{before:c,after:a,...l.current()})),c+=l.move(a),o()),c+=l.move(")"),i(),c}function Ep(e,t,n,r){const a=e.referenceType,s=n.enter("imageReference");let i=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const c=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=d,s(),"full"!==a&&c&&c===u?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(u+"]"),l}function Ip(e,t,n){let r=e.value||"",a="`",s=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const e=n.unsafe[s],t=n.compilePattern(e);let a;if(e.atBreak)for(;a=t.exec(r);){let e=a.index;10===r.charCodeAt(e)&&13===r.charCodeAt(e-1)&&e--,r=r.slice(0,e)+" "+r.slice(a.index+1)}}return a+r+a}function _p(e,t){const n=Sd(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function Tp(e,t,n,r){const a=wp(n),s='"'===a?"Quote":"Apostrophe",i=n.createTracker(r);let o,l;if(_p(e,n)){const t=n.stack;n.stack=[],o=n.enter("autolink");let r=i.move("<");return r+=i.move(n.containerPhrasing(e,{before:r,after:">",...i.current()})),r+=i.move(">"),o(),n.stack=t,r}o=n.enter("link"),l=n.enter("label");let c=i.move("[");return c+=i.move(n.containerPhrasing(e,{before:c,after:"](",...i.current()})),c+=i.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=i.move("<"),c+=i.move(n.safe(e.url,{before:c,after:">",...i.current()})),c+=i.move(">")):(l=n.enter("destinationRaw"),c+=i.move(n.safe(e.url,{before:c,after:e.title?" ":")",...i.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=i.move(" "+a),c+=i.move(n.safe(e.title,{before:c,after:a,...i.current()})),c+=i.move(a),l()),c+=i.move(")"),o(),c}function Pp(e,t,n,r){const a=e.referenceType,s=n.enter("linkReference");let i=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=d,s(),"full"!==a&&c&&c===u?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(u+"]"),l}function Ap(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Rp(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}mp.peek=function(){return"~"},kp.peek=function(e,t,n){return n.options.emphasis||"*"},Cp.peek=function(){return"<"},Sp.peek=function(){return"!"},Ep.peek=function(){return"!"},Ip.peek=function(){return"`"},Tp.peek=function(e,t,n){return _p(e,n)?"<":"["},Pp.peek=function(){return"["};const Dp=Om(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Fp(e,t,n,r){const a=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),s=n.enter("strong"),i=n.createTracker(r),o=i.move(a+a);let l=i.move(n.containerPhrasing(e,{after:a,before:o,...i.current()}));const c=l.charCodeAt(0),d=jp(r.before.charCodeAt(r.before.length-1),c,a);d.inside&&(l=Np(c)+l.slice(1));const u=l.charCodeAt(l.length-1),m=jp(r.after.charCodeAt(0),u,a);m.inside&&(l=l.slice(0,-1)+Np(u));const f=i.move(a+a);return s(),n.attentionEncodeSurroundingInfo={after:m.outside,before:d.outside},o+l+f}Fp.peek=function(e,t,n){return n.options.strong||"*"};const zp={blockquote:function(e,t,n,r){const a=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const i=n.indentLines(n.containerFlow(e,s.current()),gp);return a(),i},break:bp,code:function(e,t,n,r){const a=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),s=e.value||"",i="`"===a?"GraveAccent":"Tilde";if(function(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(s,vp);return e(),t}const o=n.createTracker(r),l=a.repeat(Math.max(function(e,t){const n=String(e);let r=n.indexOf(t),a=r,s=0,i=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==r;)r===a?++s>i&&(i=s):s=1,a=r+t.length,r=n.indexOf(t,a);return i}(s,a)+1,3)),c=n.enter("codeFenced");let d=o.move(l);if(e.lang){const t=n.enter(`codeFencedLang${i}`);d+=o.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${i}`);d+=o.move(" "),d+=o.move(n.safe(e.meta,{before:d,after:"\n",encode:["`"],...o.current()})),t()}return d+=o.move("\n"),s&&(d+=o.move(s+"\n")),d+=o.move(l),c(),d},definition:function(e,t,n,r){const a=wp(n),s='"'===a?"Quote":"Apostrophe",i=n.enter("definition");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+a),c+=l.move(n.safe(e.title,{before:c,after:a,...l.current()})),c+=l.move(a),o()),i(),c},emphasis:kp,hardBreak:bp,heading:function(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(function(e,t){let n=!1;return Hm(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,Vm}),Boolean((!e.depth||e.depth<3)&&Sd(e)&&(t.options.setext||n))}(e,n)){const t=n.enter("headingSetext"),r=n.enter("phrasing"),i=n.containerPhrasing(e,{...s.current(),before:"\n",after:"\n"});return r(),t(),i+"\n"+(1===a?"=":"-").repeat(i.length-(Math.max(i.lastIndexOf("\r"),i.lastIndexOf("\n"))+1))}const i="#".repeat(a),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(i+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...s.current()});return/^[\t ]/.test(c)&&(c=Np(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),o(),c},html:Cp,image:Sp,imageReference:Ep,inlineCode:Ip,link:Tp,linkReference:Pp,list:function(e,t,n,r){const a=n.enter("list"),s=n.bulletCurrent;let i=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):Ap(n);const o=e.ordered?"."===i?")":".":function(e){const t=Ap(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let l=!(!t||!n.bulletLastUsed)&&i===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==i&&"-"!==i||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(l=!0),Rp(n)===i&&t){let t=-1;for(;++t<e.children.length;){const n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){l=!0;break}}}}l&&(i=o),n.bulletCurrent=i;const c=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=s,a(),c},listItem:function(e,t,n,r){const a=function(e){const t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n);let s=n.bulletCurrent||Ap(n);t&&"list"===t.type&&t.ordered&&(s=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+s);let i=s.length+1;("tab"===a||"mixed"===a&&(t&&"list"===t.type&&t.spread||e.spread))&&(i=4*Math.ceil(i/4));const o=n.createTracker(r);o.move(s+" ".repeat(i-s.length)),o.shift(i);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),function(e,t,n){if(t)return(n?"":" ".repeat(i))+e;return(n?s:s+" ".repeat(i-s.length))+e});return l(),c},paragraph:function(e,t,n,r){const a=n.enter("paragraph"),s=n.enter("phrasing"),i=n.containerPhrasing(e,r);return s(),a(),i},root:function(e,t,n,r){return(e.children.some(function(e){return Dp(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:Fp,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(Rp(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}};function Lp(e){const t=e._align;this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function Op(e){this.exit(e),this.data.inTable=void 0}function Mp(e){this.enter({type:"tableRow",children:[]},e)}function $p(e){this.exit(e)}function Up(e){this.enter({type:"tableCell",children:[]},e)}function Bp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Vp));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Vp(e,t){return"|"===t?t:e}function qp(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let r=zp.inlineCode(e,t,n);n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&"));return r},table:function(e,t,n,r){return o(function(e,t,n){const r=e.children;let a=-1;const s=[],i=t.enter("table");for(;++a<r.length;)s[a]=l(r[a],t,n);return i(),s}(e,n,r),e.align)},tableCell:i,tableRow:function(e,t,n,r){const a=l(e,n,r),s=o([a]);return s.slice(0,s.indexOf("\n"))}}};function i(e,t,n,r){const a=n.enter("tableCell"),i=n.enter("phrasing"),o=n.containerPhrasing(e,{...r,before:s,after:s});return i(),a(),o}function o(e,t){return function(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||fp,s=[],i=[],o=[],l=[];let c=0,d=-1;for(;++d<e.length;){const t=[],r=[];let s=-1;for(e[d].length>c&&(c=e[d].length);++s<e[d].length;){const i=pp(e[d][s]);if(!1!==n.alignDelimiters){const e=a(i);r[s]=e,(void 0===l[s]||e>l[s])&&(l[s]=e)}t.push(i)}i[d]=t,o[d]=r}let u=-1;if("object"==typeof r&&"length"in r)for(;++u<c;)s[u]=hp(r[u]);else{const e=hp(r);for(;++u<c;)s[u]=e}u=-1;const m=[],f=[];for(;++u<c;){const e=s[u];let t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let a=!1===n.alignDelimiters?1:Math.max(1,l[u]-t.length-r.length);const i=t+"-".repeat(a)+r;!1!==n.alignDelimiters&&(a=t.length+a+r.length,a>l[u]&&(l[u]=a),f[u]=a),m[u]=i}i.splice(1,0,m),o.splice(1,0,f),d=-1;const p=[];for(;++d<i.length;){const e=i[d],t=o[d];u=-1;const r=[];for(;++u<c;){const a=e[u]||"";let i="",o="";if(!1!==n.alignDelimiters){const e=l[u]-(t[u]||0),n=s[u];114===n?i=" ".repeat(e):99===n?e%2?(i=" ".repeat(e/2+.5),o=" ".repeat(e/2-.5)):(i=" ".repeat(e/2),o=i):o=" ".repeat(e)}!1===n.delimiterStart||u||r.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===a||!1===n.delimiterStart&&!u||r.push(" "),!1!==n.alignDelimiters&&r.push(i),r.push(a),!1!==n.alignDelimiters&&r.push(o),!1!==n.padding&&r.push(" "),!1===n.delimiterEnd&&u===c-1||r.push("|")}p.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return p.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:a})}function l(e,t,n){const r=e.children;let a=-1;const s=[],o=t.enter("tableRow");for(;++a<r.length;)s[a]=i(r[a],0,t,n);return o(),s}}function Hp(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function Wp(e){const t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){const e=this.stack[this.stack.length-1];e.type;const n=e.children[0];if(n&&"text"===n.type){const r=t.children;let a,s=-1;for(;++s<r.length;){const e=r[s];if("paragraph"===e.type){a=e;break}}a===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Qp(e,t,n,r){const a=e.children[0],s="boolean"==typeof e.checked&&a&&"paragraph"===a.type,i="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(i);let l=zp.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const Kp={tokenize:function(e,t,n){let r=0;return function t(s){if((87===s||119===s)&&r<3)return r++,e.consume(s),t;if(46===s&&3===r)return e.consume(s),a;return n(s)};function a(e){return null===e?n(e):t(e)}},partial:!0},Yp={tokenize:function(e,t,n){let r,a,s;return i;function i(t){return 46===t||95===t?e.check(Xp,l,o)(t):null===t||Qd(t)||Jd(t)||45!==t&&Yd(t)?l(t):(s=!0,e.consume(t),i)}function o(t){return 95===t?r=!0:(a=r,r=void 0),e.consume(t),i}function l(e){return a||r||!s?n(e):t(e)}},partial:!0},Jp={tokenize:function(e,t){let n=0,r=0;return a;function a(i){return 40===i?(n++,e.consume(i),a):41===i&&r<n?s(i):33===i||34===i||38===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||60===i||63===i||93===i||95===i||126===i?e.check(Xp,t,s)(i):null===i||Qd(i)||Jd(i)?t(i):(e.consume(i),a)}function s(t){return 41===t&&r++,e.consume(t),a}},partial:!0},Xp={tokenize:function(e,t,n){return r;function r(i){return 33===i||34===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||63===i||95===i||126===i?(e.consume(i),r):38===i?(e.consume(i),s):93===i?(e.consume(i),a):60===i||null===i||Qd(i)||Jd(i)?t(i):n(i)}function a(e){return null===e||40===e||91===e||Qd(e)||Jd(e)?t(e):r(e)}function s(e){return Md(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),r):Md(t)?(e.consume(t),i):n(t)}},partial:!0},Gp={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return $d(e)?n(e):t(e)}},partial:!0},Zp={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){if(87!==t&&119!==t||!ah.call(r,r.previous)||lh(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Kp,e.attempt(Yp,e.attempt(Jp,a),n),n)(t)};function a(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:ah},eh={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let a="",s=!1;return function(t){if((72===t||104===t)&&sh.call(r,r.previous)&&!lh(r.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if(Md(t)&&a.length<5)return a+=String.fromCodePoint(t),e.consume(t),i;if(58===t){const n=a.toLowerCase();if("http"===n||"https"===n)return e.consume(t),o}return n(t)}function o(t){return 47===t?(e.consume(t),s?l:(s=!0,o)):n(t)}function l(t){return null===t||Bd(t)||Qd(t)||Jd(t)||Yd(t)?n(t):e.attempt(Yp,e.attempt(Jp,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:sh},th={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let a,s;return function(t){if(!oh(t)||!ih.call(r,r.previous)||lh(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return oh(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(Gp,c,l)(t):45===t||95===t||$d(t)?(s=!0,e.consume(t),o):c(t)}function l(t){return e.consume(t),a=!0,o}function c(i){return s&&a&&Md(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:ih},nh={};let rh=48;for(;rh<123;)nh[rh]=th,rh++,58===rh?rh=65:91===rh&&(rh=97);function ah(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||Qd(e)}function sh(e){return!Md(e)}function ih(e){return!(47===e||oh(e))}function oh(e){return 43===e||45===e||46===e||95===e||$d(e)}function lh(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}nh[43]=th,nh[45]=th,nh[46]=th,nh[95]=th,nh[72]=[th,eh],nh[104]=[th,eh],nh[87]=[th,Zp],nh[119]=[th,Zp];const ch={tokenize:function(e,t,n){const r=this;return Zd(e,function(e){const a=r.events[r.events.length-1];return a&&"gfmFootnoteDefinitionIndent"===a[1].type&&4===a[2].sliceSerialize(a[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function dh(e,t,n){const r=this;let a=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;a--;){const e=r.events[a][1];if("labelImage"===e.type){i=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(a){if(!i||!i._balanced)return n(a);const o=Od(r.sliceSerialize({start:i.end,end:r.now()}));if(94!==o.codePointAt(0)||!s.includes(o.slice(1)))return n(a);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a)}}function uh(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function mh(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),o};function o(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(o){if(i>999||93===o&&!s||null===o||91===o||Qd(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return a.includes(Od(r.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return Qd(o)||(s=!0),i++,e.consume(o),92===o?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),i++,l):l(t)}}function fh(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i,o=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(o>999||93===t&&!i||null===t||91===t||Qd(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=Od(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return Qd(t)||(i=!0),o++,e.consume(t),92===t?d:c}function d(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function u(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a.includes(s)||a.push(s),Zd(e,m,"gfmFootnoteDefinitionWhitespace")):n(t)}function m(e){return t(e)}}function ph(e,t,n){return e.check(lu,t,e.attempt(ch,t,n))}function hh(e){e.exit("gfmFootnoteDefinition")}function gh(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,r){const a=this.previous,s=this.events;let i=0;return function(t){if(126===a&&"characterEscape"!==s[s.length-1][1].type)return r(t);return e.enter("strikethroughSequenceTemporary"),o(t)};function o(s){const l=ru(a);if(126===s)return i>1?r(s):(e.consume(s),i++,o);if(i<2&&!t)return r(s);const c=e.exit("strikethroughSequenceTemporary"),d=ru(s);return c._open=!d||2===d&&Boolean(l),c._close=!l||2===l&&Boolean(d),n(s)}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";const a={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},s={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},i=[["enter",a,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",s,t]],o=t.parser.constructs.insideSpan.null;o&&Pd(i,i.length,0,au(o,e.slice(r+1,n),t)),Pd(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",a,t]]),Pd(e,r-1,n-r+3,i),n=r+i.length-2;break}}n=-1;for(;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}};return null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}}class xh{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let a=0;if(0===n&&0===r.length)return;for(;a<e.map.length;){if(e.map[a][0]===t)return e.map[a][1]+=n,void e.map[a][2].push(...r);a+=1}e.map.push([t,n,r])}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length;const n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(const t of r)e.push(t);r=n.pop()}this.map.length=0}}function yh(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if("enter"===a[0])"tableContent"===a[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===a[1].type){if("tableDelimiterMarker"===e[t-1][1].type){const e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===a[1].type)break}else"enter"===a[0]&&"tableDelimiterRow"===a[1].type&&(n=!0);t+=1}return r}function bh(e,t,n){const r=this;let a,s=0,i=0;return function(e){let t=r.events.length-1;for(;t>-1;){const e=r.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const a=t>-1?r.events[t][1].type:null,s="tableHead"===a||"tableRow"===a?v:o;if(s===v&&r.parser.lazy[r.now().line])return n(e);return s(e)};function o(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return l(e);return a=!0,i+=1,l(e)}(t)}function l(t){return null===t?n(t):Wd(t)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u):n(t):Kd(t)?Zd(e,l,"whitespace")(t):(i+=1,a&&(a=!1,s+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),a=!0,l):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||Qd(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return 92===t||124===t?(e.consume(t),c):c(t)}function u(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter("tableDelimiterRow"),a=!1,Kd(t)?Zd(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):m(t))}function m(t){return 45===t||58===t?p(t):124===t?(a=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),f):b(t)}function f(t){return Kd(t)?Zd(e,p,"whitespace")(t):p(t)}function p(t){return 58===t?(i+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),h):45===t?(i+=1,h(t)):null===t||Wd(t)?y(t):b(t)}function h(t){return 45===t?(e.enter("tableDelimiterFiller"),g(t)):b(t)}function g(t){return 45===t?(e.consume(t),g):58===t?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(t))}function x(t){return Kd(t)?Zd(e,y,"whitespace")(t):y(t)}function y(n){return 124===n?m(n):(null===n||Wd(n))&&a&&s===i?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):b(n)}function b(e){return n(e)}function v(t){return e.enter("tableRow"),w(t)}function w(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),w):null===n||Wd(n)?(e.exit("tableRow"),t(n)):Kd(n)?Zd(e,w,"whitespace")(n):(e.enter("data"),N(n))}function N(t){return null===t||124===t||Qd(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?j:N)}function j(t){return 92===t||124===t?(e.consume(t),N):N(t)}}function vh(e,t){let n,r,a,s=-1,i=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],d=!1,u=0;const m=new xh;for(;++s<e.length;){const f=e[s],p=f[1];"enter"===f[0]?"tableHead"===p.type?(d=!1,0!==u&&(Nh(m,t,u,n,r),r=void 0,u=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},m.add(s,0,[["enter",n,t]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(i=!0,a=void 0,l=[0,0,0,0],c=[0,s+1,0,0],d&&(d=!1,r={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},m.add(s,0,[["enter",r,t]])),o="tableDelimiterRow"===p.type?2:r?3:1):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type?"tableCellDivider"===p.type&&(i?i=!1:(0!==l[1]&&(c[0]=c[1],a=wh(m,t,l,o,void 0,a)),l=c,c=[l[1],s,0,0])):(i=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],a=wh(m,t,l,o,void 0,a),l=[0,0,0,0]),c[2]=s)):"tableHead"===p.type?(d=!0,u=s):"tableRow"===p.type||"tableDelimiterRow"===p.type?(u=s,0!==l[1]?(c[0]=c[1],a=wh(m,t,l,o,s,a)):0!==c[1]&&(a=wh(m,t,c,o,s,a)),o=0):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type||(c[3]=s)}for(0!==u&&Nh(m,t,u,n,r),m.consume(t.events),s=-1;++s<t.events.length;){const e=t.events[s];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=yh(t.events,s))}return e}function wh(e,t,n,r,a,s){const i=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},jh(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=jh(t.events,n[1]);if(s={type:i,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),0!==n[2]){const a=jh(t.events,n[2]),s=jh(t.events,n[3]),i={type:"tableContent",start:Object.assign({},a),end:Object.assign({},s)};if(e.add(n[2],0,[["enter",i,t]]),2!==r){const r=t.events[n[2]],a=t.events[n[3]];if(r[1].end=Object.assign({},a[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){const t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",i,t]])}return void 0!==a&&(s.end=Object.assign({},jh(t.events,a)),e.add(a,0,[["exit",s,t]]),s=void 0),s}function Nh(e,t,n,r,a){const s=[],i=jh(t.events,n);a&&(a.end=Object.assign({},i),s.push(["exit",a,t])),r.end=Object.assign({},i),s.push(["exit",r,t]),e.add(n+1,0,s)}function jh(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const kh={name:"tasklistCheck",tokenize:function(e,t,n){const r=this;return function(t){if(null!==r.previous||!r._gfmTasklistFirstContentOfListItem)return n(t);return e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),a};function a(t){return Qd(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),s):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),s):n(t)}function s(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),i):n(t)}function i(r){return Wd(r)?t(r):Kd(r)?e.check({tokenize:Ch},t,n)(r):n(r)}}};function Ch(e,t,n){return Zd(e,function(e){return null===e?n(e):t(e)},"whitespace")}const Sh={};function Eh(e){const t=e||Sh,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return Dd([{text:nh},{document:{91:{name:"gfmFootnoteDefinition",tokenize:fh,continuation:{tokenize:ph},exit:hh}},text:{91:{name:"gfmFootnoteCall",tokenize:mh},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:dh,resolveTo:uh}}},gh(e),{flow:{null:{name:"table",tokenize:bh,resolveAll:vh}}},{text:{91:kh}}])}(t)),a.push([{transforms:[Qf],enter:{literalAutolink:Uf,literalAutolinkEmail:Bf,literalAutolinkHttp:Bf,literalAutolinkWww:Bf},exit:{literalAutolink:Wf,literalAutolinkEmail:Hf,literalAutolinkHttp:Vf,literalAutolinkWww:qf}},{enter:{gfmFootnoteCallString:Xf,gfmFootnoteCall:Gf,gfmFootnoteDefinitionLabelString:Zf,gfmFootnoteDefinition:ep},exit:{gfmFootnoteCallString:tp,gfmFootnoteCall:np,gfmFootnoteDefinitionLabelString:rp,gfmFootnoteDefinition:ap}},{canContainEols:["delete"],enter:{strikethrough:dp},exit:{strikethrough:up}},{enter:{table:Lp,tableData:Up,tableHeader:Up,tableRow:Mp},exit:{codeText:Bp,table:Op,tableData:$p,tableHeader:$p,tableRow:$p}},{exit:{taskListCheckValueChecked:Hp,taskListCheckValueUnchecked:Hp,paragraph:Wp}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Mf,notInConstruct:$f},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Mf,notInConstruct:$f},{character:":",before:"[ps]",after:"\\/",inConstruct:Mf,notInConstruct:$f}]},ip(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:cp}],handlers:{delete:mp}},qp(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Qp}}]}}(t))}function Ih({content:e,className:t}){return Mt.jsx("div",{className:Ut("prose prose-sm max-w-none",t),children:Mt.jsx(Rf,{remarkPlugins:[Eh],components:{h1:({children:e})=>Mt.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>Mt.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>Mt.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>Mt.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>Mt.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>Mt.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>Mt.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...n})=>e?Mt.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...n,children:t}):Mt.jsx("code",{className:"block bg-muted p-2 rounded text-xs font-mono overflow-x-auto mb-2 text-foreground",...n,children:t}),pre:({children:e})=>Mt.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>Mt.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>Mt.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>Mt.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>Mt.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}function _h(){const[e,t]=n(!1),[r,a]=n(""),{messages:s,isLoading:i,error:l,sendMessage:d}=Zl(),u=c(null),m=c(null);o(()=>{if(u.current){const e=u.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[s]),o(()=>{e&&m.current&&m.current.focus()},[e]),o(()=>{const n=n=>{"Escape"===n.key&&e&&t(!1)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e]);const f=()=>{r.trim()&&!i&&(d(r),a(""))};return Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(Kt,{onClick:()=>t(!e),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e?Mt.jsx(N,{className:"h-6 w-6"}):Mt.jsx($e,{className:"h-6 w-6"})}),e&&Mt.jsxs(Zt,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[Mt.jsxs(en,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[Mt.jsx(tn,{className:"text-lg font-semibold",children:"Chat Assistant"}),Mt.jsx(Kt,{variant:"ghost",size:"icon",onClick:()=>t(!1),className:"h-8 w-8",children:Mt.jsx(N,{className:"h-4 w-4"})})]}),Mt.jsxs(rn,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[Mt.jsx(Ns,{ref:u,className:"flex-1 px-4",children:Mt.jsxs("div",{className:"space-y-4 py-4",children:[s.map(e=>Mt.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:Mt.jsx("div",{className:"max-w-[80%] rounded-lg px-4 py-2 "+("user"===e.role?"bg-primary text-primary-foreground":"bg-muted"),children:"assistant"===e.role?Mt.jsx(Ih,{content:e.content}):Mt.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),i&&Mt.jsx("div",{className:"flex justify-start",children:Mt.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:Mt.jsxs("div",{className:"flex space-x-2",children:[Mt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),Mt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),Mt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),l&&Mt.jsx("div",{className:"text-center text-sm text-destructive py-2",children:l})]})}),Mt.jsx("div",{className:"border-t p-4",children:Mt.jsxs("div",{className:"flex space-x-2",children:[Mt.jsx(Jt,{ref:m,value:r,onChange:e=>a(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),f())},placeholder:"Digite sua mensagem...",disabled:i,className:"flex-1"}),Mt.jsx(Kt,{onClick:f,disabled:i||!r.trim(),size:"icon",children:Mt.jsx(Ue,{className:"h-4 w-4"})})]})})]})]})]})}function Th({open:e,onOpenChange:t,placeId:a,placeName:s,onMakeManager:i,onMakeMembers:o,currentManagerId:l,currentMemberIds:c=[]}){const[d,u]=n([]),[m,f]=n(!1),[p,h]=n(""),{data:g=[],isLoading:x}=Es({enabled:e}),y=r(()=>{let e=[...g];if(e.sort((e,t)=>{const n=e.userName?.toLowerCase()||"",r=t.userName?.toLowerCase()||"";return n.localeCompare(r)}),p){const t=p.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[g,p]),b=e=>{u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},v=1===d.length,w=d.length>0;return Mt.jsx(sn,{open:e,onOpenChange:t,children:Mt.jsxs(un,{className:"max-w-2xl",children:[Mt.jsx(mn,{children:Mt.jsxs(pn,{className:"flex items-center gap-2",children:[Mt.jsx(Be,{className:"h-5 w-5"}),"Gerenciar Acessos - ",s]})}),Mt.jsxs("div",{className:"relative",children:[Mt.jsx(I,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Mt.jsx(Jt,{placeholder:"Buscar por nome ou email...",value:p,onChange:e=>h(e.target.value),className:"pl-9"})]}),Mt.jsx(Ns,{className:"h-[400px] pr-4",children:x?Mt.jsx("div",{className:"space-y-2",children:[...Array(5)].map((e,t)=>Mt.jsx(br,{className:"h-16 w-full"},t))}):0===y.length?Mt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Mt.jsx(Be,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:p?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):Mt.jsx("div",{className:"space-y-2",children:y.map(e=>{const t=e.userId===l,n=c.includes(e.userId||""),r=d.includes(e.userId||"");return Mt.jsxs("div",{className:Ut("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>b(e.userId||""),children:[Mt.jsx(zn,{checked:r,onCheckedChange:()=>b(e.userId||""),onClick:e=>e.stopPropagation()}),Mt.jsxs("div",{className:"flex-1",children:[Mt.jsxs("div",{className:"flex items-center gap-2",children:[Mt.jsx("p",{className:"font-medium",children:e.userName}),t&&Mt.jsx(Ve,{className:"h-4 w-4 text-yellow-500"})]}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:e.userEmail})]}),(t||n)&&Mt.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},e.userId)})})}),Mt.jsxs(fn,{className:"flex gap-2 sm:gap-2",children:[Mt.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:d.length>0&&Mt.jsxs("span",{children:[d.length," selecionado(s)"]})}),v&&i&&Mt.jsxs(Kt,{onClick:async()=>{if(i&&1===d.length){f(!0);try{await i(d[0],a),u([])}finally{f(!1)}}},disabled:m,variant:"outline",children:[Mt.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),w&&o&&Mt.jsxs(Kt,{onClick:async()=>{if(o&&0!==d.length){f(!0);try{await o(d,a),u([])}finally{f(!1)}}},disabled:m,children:[Mt.jsx(qe,{className:"h-4 w-4 mr-2"}),"Tornar ",d.length>1?"Membros":"Membro"]})]})]})})}function Ph({place:e,level:t=0,manageAccessConfig:r}){const[a,s]=n(!1),[i,o]=n(!1),l=e.subPlaces&&e.subPlaces.length>0,c=e.isActive??!0,d=e.usersCount??0;return Mt.jsxs("div",{children:[Mt.jsxs(Ti,{open:a,onOpenChange:s,children:[Mt.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*t+1+"rem"},children:[l?Mt.jsxs(Pi,{className:"flex items-center gap-2 flex-1",children:[Mt.jsx(T,{className:Ut("h-4 w-4 transition-transform shrink-0",a&&"rotate-90")}),Mt.jsx(Le,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Mt.jsx("span",{className:"font-medium",children:e.name}),Mt.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):Mt.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Mt.jsx("div",{className:"w-4 shrink-0"}),Mt.jsx(Le,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Mt.jsx("span",{className:"font-medium",children:e.name})]}),Mt.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[Mt.jsxs("div",{className:"flex items-center gap-1.5",children:[Mt.jsx(Be,{className:"h-3.5 w-3.5 text-muted-foreground"}),Mt.jsx("span",{className:"text-sm text-muted-foreground",children:d})]}),Mt.jsx(Mn,{variant:c?"default":"secondary",className:"text-xs",children:c?"Ativo":"Inativo"}),r&&Mt.jsx(Nl,{customActions:[{label:"Gerenciar Acessos",icon:Se,onClick:()=>o(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),l&&Mt.jsx(Ai,{children:e.subPlaces.map(e=>Mt.jsx(Ph,{place:e,level:t+1,manageAccessConfig:r},e.id))})]}),0===t&&Mt.jsx(Ji,{}),r&&Mt.jsx(Th,{open:i,onOpenChange:o,placeId:e.id,placeName:e.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(e.id),currentMemberIds:r.getCurrentMemberIds?.(e.id)})]})}function Ah({places:e,isLoading:t,manageAccessConfig:n}){return t?Mt.jsx("div",{className:"flex items-center justify-center py-12",children:Mt.jsxs("div",{className:"text-center space-y-2",children:[Mt.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando locais..."})]})}):e&&0!==e.length?Mt.jsxs("div",{className:"space-y-1",children:[Mt.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),e.map(e=>Mt.jsx(Ph,{place:e,manageAccessConfig:n},e.id))]}):Mt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[Mt.jsx(Le,{className:"h-12 w-12 text-muted-foreground/50"}),Mt.jsxs("div",{children:[Mt.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})}var Rh=Object.defineProperty,Dh=(e,t,n)=>((e,t,n)=>t in e?Rh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const Fh=new class{constructor(){Dh(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=Kr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=Pr.getAccessToken();if(!a)throw new Error("Token Qualiex não encontrado");if(!n||""===n.trim())throw new Error("Alias da unidade é obrigatório");const s=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{s.searchParams.append(e,t)});const i=await fetch(s.toString(),{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json",Accept:"application/json","un-alias":n}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const t=new Map,n=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const r=t.get(e.id);if(e.parentId){const a=t.get(e.parentId);a?(a.subPlaces=a.subPlaces||[],a.subPlaces.push(r)):n.push(r)}else n.push(r)}),n}async getPlaces(e,t){try{const n=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),r=n.data||n||[];return this.buildHierarchy(r)}catch(n){if(await Kr.handleApiError(n))try{const n=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),r=n.data||n||[];return this.buildHierarchy(r)}catch(r){return Dr.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}return Dr.handleError(n instanceof Error?n.message:"Erro ao buscar locais",!0),[]}}};function zh(e){const t=new Map,n=new Map,r=[];e.forEach(e=>{const r={...e,children:[],level:0};t.set(e.id,r),n.set(e.id_user,r)}),e.forEach(e=>{const a=t.get(e.id);if(e.id_leader){const t=n.get(e.id_leader);if(t)return void t.children.push(a)}r.push(a)});const a=(e,t)=>{e.level=t,e.children.forEach(e=>a(e,t+1))};r.forEach(e=>a(e,0));const s=e=>{e.sort((e,t)=>{const n=e.name||e.id_user||e.email||"",r=t.name||t.id_user||t.email||"";return n.localeCompare(r)}),e.forEach(e=>e.children.length>0&&s(e.children))};return s(r),r}function Lh(e){const t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}function Oh(){const{alias:e,isAuthenticated:t}=ka(),n=Pr.getAccessToken(),{data:r=[]}=Es();return at({queryKey:["leadership",e,r.length],queryFn:async()=>{if(!n||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=Ur(),{data:a,error:s}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(s)throw new Error("Erro ao buscar hierarquia de liderança");if(!a||0===a.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=a.map(e=>({...e,name:i[e.id_user]?.name||e.id_user,email:i[e.id_user]?.email||"",subordinatesCount:a.filter(t=>t.id_leader===e.id_user).length})),l=new Set(a.map(e=>e.id_user));return new Set(a.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const t=i[e];o.push({id:`virtual-${e}`,alias:a[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:t?.name||e,email:t?.email||"",subordinatesCount:a.filter(t=>t.id_leader===e).length})}),zh(o)},enabled:!!n&&!!e&&t&&r.length>0})}function Mh(){const e="common",{alias:t}=ka(),n=rt(),r=Ur();return st({mutationFn:async n=>{if(!t)throw new Error("Unidade não selecionada");if(n.id_user===n.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await r.schema(e).from("leaders").select("id").eq("alias",t).eq("id_user",n.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");n.id_leader&&await Hh(r,t,e,n.id_user,n.id_leader);const{data:a,error:s}=await r.schema(e).from("leaders").insert({alias:t,id_user:n.id_user,id_leader:n.id_leader,is_active:!0,is_removed:!1}).select().single();if(s)throw s;return a},onSuccess:()=>{n.invalidateQueries({queryKey:["leadership",t]}),b.success("Líder adicionado com sucesso")},onError:e=>{b.error(e.message||"Erro ao adicionar líder")}})}function $h(){const e="common",{alias:t}=ka(),n=rt(),r=Ur();return st({mutationFn:async n=>{if(!t)throw new Error("Unidade não selecionada");if(n.id_user===n.id_leader)throw new Error("Usuário não pode ser seu próprio líder");n.id_leader&&await Hh(r,t,e,n.id_user,n.id_leader);const{data:a,error:s}=await r.schema(e).from("leaders").insert({alias:t,id_user:n.id_user,id_leader:n.id_leader,is_active:!0,is_removed:!1}).select().single();if(s)throw s;return a},onSuccess:()=>{n.invalidateQueries({queryKey:["leadership",t]}),b.success("Líder virtual promovido com sucesso")},onError:e=>{b.error(e.message||"Erro ao criar líder")}})}function Uh(){const e="common",{alias:t}=ka(),n=rt(),r=Ur();return st({mutationFn:async n=>{if(!t)throw new Error("Unidade não selecionada");if(!n.users.length)throw new Error("Selecione pelo menos um liderado");const a=n.users.map(e=>e.id_user),{data:s}=await r.schema(e).from("leaders").select("id_user").eq("alias",t).in("id_user",a).eq("is_removed",!1);if(s&&s.length>0){const e=s.map(e=>e.id_user);throw new Error(`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`)}for(const c of n.users){if(c.id_user===n.id_leader)throw new Error("Usuário não pode ser seu próprio líder");await Hh(r,t,e,c.id_user,n.id_leader)}const i=n.users.map(e=>({alias:t,id_user:e.id_user,id_leader:n.id_leader,is_active:!0,is_removed:!1})),{data:o,error:l}=await r.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{n.invalidateQueries({queryKey:["leadership",t]}),b.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{b.error(e.message||"Erro ao adicionar liderados")}})}function Bh(){const e="common",{alias:t}=ka(),n=rt(),r=Ur();return st({mutationFn:async n=>{if(!t)throw new Error("Unidade não selecionada");const{data:a}=await r.schema(e).from("leaders").select("id_user").eq("id",n.id).eq("alias",t).single();if(!a)throw new Error("Líder não encontrado");if(a.id_user===n.id_leader)throw new Error("Usuário não pode ser seu próprio líder");n.id_leader&&await Hh(r,t,e,a.id_user,n.id_leader,n.id);const{data:s,error:i}=await r.schema(e).from("leaders").update({id_leader:n.id_leader}).eq("id",n.id).eq("alias",t).select().single();if(i)throw i;return s},onSuccess:()=>{n.invalidateQueries({queryKey:["leadership",t]}),b.success("Líder atualizado com sucesso")},onError:e=>{b.error(e.message||"Erro ao atualizar líder")}})}function Vh(){const{alias:e}=ka(),t=rt(),n=Ur();return st({mutationFn:async t=>{if(!e)throw new Error("Unidade não selecionada");const{error:r}=await n.schema("common").from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),b.success("Líder removido com sucesso")},onError:e=>{b.error(e.message||"Erro ao remover líder")}})}function qh(){const e="common",{alias:t}=ka(),n=rt(),r=Ur();return st({mutationFn:async({leaderUserId:n,selectedUsers:a})=>{if(!t)throw new Error("Unidade não selecionada");const s=a.map(e=>e.id_user),i=await Promise.all([r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).eq("id_leader",n),r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).in("id_user",s.length?s:["__none__"])]),[{data:o,error:l},{data:c,error:d}]=i;if(l)throw l;if(d)throw d;const u=o||[],m=c||[],f=new Set(s),p=u.filter(e=>!f.has(e.id_user)),h=m.filter(e=>e.id_leader!==n),g=new Set(m.map(e=>e.id_user)),x=a.filter(e=>!g.has(e.id_user));for(const v of h)await Hh(r,t,e,v.id_user,n,v.id);for(const v of x){if(v.id_user===n)throw new Error("Usuário não pode ser seu próprio líder");await Hh(r,t,e,v.id_user,n)}const y=[];if(p.length){const n=p.map(e=>e.id);y.push(r.schema(e).from("leaders").update({id_leader:null}).in("id",n).eq("alias",t))}if(h.length){const a=h.map(e=>e.id);y.push(r.schema(e).from("leaders").update({id_leader:n}).in("id",a).eq("alias",t))}if(x.length){const a=x.map(e=>({alias:t,id_user:e.id_user,id_leader:n,is_active:!0,is_removed:!1}));y.push(r.schema(e).from("leaders").insert(a))}const b=(await Promise.all(y)).find(e=>e?.error);if(b?.error)throw b.error;return{unlinked:p.length,updated:h.length,created:x.length}},onSuccess:e=>{n.invalidateQueries({queryKey:["leadership",t]}),b.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{b.error(e.message||"Erro ao sincronizar subordinados")}})}async function Hh(e,t,n,r,a,s){const{data:i,error:o}=await e.schema(n).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(o)throw o;const l=s?i.filter(e=>e.id!==s):i,c=new Set;let d=a;for(;d;){if(c.has(d))throw new Error("Esta associação criaria um ciclo na hierarquia");if(d===r)throw new Error("Esta associação criaria um ciclo na hierarquia");c.add(d);const e=l.find(e=>e.id_user===d);d=e?.id_leader||null}}function Wh({leader:e,expandedIds:t,onToggleExpand:n,onEdit:r}){const a=t.has(e.id),s=e.children.length>0,i=32*e.level;return Mt.jsxs(Mt.Fragment,{children:[Mt.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[Mt.jsx("td",{className:"py-3 px-4",children:Mt.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${i}px`},children:[s?Mt.jsx("button",{onClick:()=>n(e.id),className:"p-1 hover:bg-accent rounded",children:a?Mt.jsx(j,{className:"h-4 w-4"}):Mt.jsx(T,{className:"h-4 w-4"})}):Mt.jsx("div",{className:"w-6"}),Mt.jsx(Ee,{className:"h-4 w-4 text-muted-foreground"}),Mt.jsx("button",{onClick:()=>{r(e)},className:"font-medium hover:text-primary hover:underline text-left",children:e.name||e.id_user||e.email})]})}),Mt.jsx("td",{className:"py-3 px-4 text-center",children:Mt.jsx("span",{className:"text-sm",children:e.subordinatesCount||0})})]}),s&&a&&e.children.map(e=>Mt.jsx(Wh,{leader:e,expandedIds:t,onToggleExpand:n,onEdit:r},e.id))]})}var Qh=function(e,t){for(var n={};e.length;){var r=e[0],a=r.code,s=r.message,i=r.path.join(".");if(!n[i])if("unionErrors"in r){var o=r.unionErrors[0].errors[0];n[i]={message:o.message,type:o.code}}else n[i]={message:s,type:a};if("unionErrors"in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=n[i].types,c=l&&l[r.code];n[i]=Je(i,t,n,a,c?[].concat(c,r.message):r.message)}e.shift()}return n},Kh=function(e,t,n){return void 0===n&&(n={}),function(r,a,s){try{return Promise.resolve(function(a,i){try{var o=Promise.resolve(e["sync"===n.mode?"parse":"parseAsync"](r,t)).then(function(e){return s.shouldUseNativeValidation&&_t({},s),{errors:{},values:n.raw?r:e}})}catch(l){return i(l)}return o&&o.then?o.then(void 0,i):o}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:Tt(Qh(e.errors,!s.shouldUseNativeValidation&&"all"===s.criteriaMode),s)};throw e}))}catch(i){return Promise.reject(i)}}};const Yh=It.object({id_leader:It.string().nullable(),id_users:It.array(It.string()).min(1,"Selecione pelo menos um liderado")}),Jh=It.object({id_leader:It.string().nullable(),id_users:It.array(It.string())});function Xh({value:e,onChange:t,excludeUserIds:r=[],error:a}){const{data:s=[],isLoading:i}=Es(),[l,d]=n(""),u=c(null),m=c(0),f=s.filter(e=>!r.includes(e.userId||"")).filter(e=>{const t=l.toLowerCase(),n=e.userName?.toLowerCase().includes(t);return n}).sort((t,n)=>{const r=e.includes(t.userId),a=e.includes(n.userId);if(r&&!a)return-1;if(!r&&a)return 1;const s=t.userName||t.userEmail||"",i=n.userName||n.userEmail||"";return s.localeCompare(i)});return o(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[f]),i?Mt.jsxs("div",{className:"flex items-center justify-center p-4",children:[Mt.jsx(S,{className:"h-6 w-6 animate-spin"}),Mt.jsx("span",{className:"ml-2",children:"Carregando usuários..."})]}):Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Jt,{placeholder:"Buscar usuário...",value:l,onChange:e=>d(e.target.value)}),Mt.jsx("div",{ref:u,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===f.length?Mt.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum usuário encontrado"}):Mt.jsx("div",{className:"space-y-2",children:f.map(n=>Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsx(zn,{id:n.userId,checked:e.includes(n.userId),onCheckedChange:()=>{return r=n.userId,u.current&&(m.current=u.current.scrollTop),void(e.includes(r)?t(e.filter(e=>e!==r)):t([...e,r]));var r}}),Mt.jsx(Gt,{htmlFor:n.userId,className:"flex-1 cursor-pointer",children:n.userName||n.userEmail})]},n.userId))})}),e.length>0&&Mt.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," usuário(s) selecionado(s)"]}),a&&Mt.jsx("p",{className:"text-sm text-destructive",children:a})]})}function Gh({leader:e,prefilledLeaderId:t,onSuccess:r}){const{alias:a}=ka(),s=!!e,i=e?.id.startsWith("virtual-"),l=Uh(),c=$h(),d=Bh(),u=qh(),m=Vh(),{data:f=[]}=Oh(),{data:p=[]}=Es(),[h,g]=n(""),x=Lh(f).map(e=>e.id_user),y=s?Lh(f).filter(t=>t.id_leader===e.id_user).map(e=>e.id_user):[],b=Xe({resolver:Kh(s?Jh:Yh),defaultValues:{id_leader:t||(s?e?.id_leader:null)||null,id_users:s?y:[]}});o(()=>{if(e){const t=Lh(f).filter(t=>t.id_leader===e.id_user).map(e=>e.id_user);b.reset({id_leader:e.id_leader||null,id_users:t})}else t?b.reset({id_leader:t,id_users:[]}):b.reset({id_leader:null,id_users:[]})},[a,e?.id,e?.id_user,e?.id_leader,t,f]);const v=l.isPending||c.isPending||d.isPending||u.isPending||m.isPending,w=b.watch("id_leader"),N=b.watch("id_users"),j=s?[e.id_user,...x.filter(t=>t!==e.id_user&&!N.includes(t)&&!y.includes(t))]:[w,...x.filter(e=>!N.includes(e))].filter(Boolean);return Mt.jsxs("form",{onSubmit:b.handleSubmit(async t=>{try{if(s)if(i){await c.mutateAsync({id_user:e.id_user,id_leader:t.id_leader});const n=p.filter(e=>t.id_users.includes(e.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({leaderUserId:e.id_user,selectedUsers:n})}else{await d.mutateAsync({id:e.id,id_leader:t.id_leader});const n=p.filter(e=>t.id_users.includes(e.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({leaderUserId:e.id_user,selectedUsers:n})}else{const e=p.filter(e=>t.id_users.includes(e.userId)).map(e=>({id_user:e.userId}));await l.mutateAsync({id_leader:t.id_leader,users:e})}r?.()}catch(n){}}),className:"space-y-4",children:[s&&Mt.jsxs("div",{children:[Mt.jsx(Gt,{children:"Líder"}),Mt.jsx(Jt,{value:p.find(t=>t.userId===e.id_user)?.userName||e.name||e.id_user,disabled:!0,className:"bg-muted"})]}),Mt.jsxs("div",{children:[Mt.jsx(Gt,{children:"Líder Superior"}),Mt.jsxs(Sn,{value:w||"none",onValueChange:e=>b.setValue("id_leader","none"===e?null:e),children:[Mt.jsx(_n,{children:Mt.jsx(In,{placeholder:"Nenhum (líder raiz)"})}),Mt.jsxs(An,{children:[Mt.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:Mt.jsx(Jt,{placeholder:"Buscar líder...",value:h,onChange:e=>g(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),Mt.jsxs(Ns,{className:"h-[200px]",children:[Mt.jsx(Dn,{value:"none",children:"Nenhum (líder raiz)"}),p.filter(t=>{const n=s?t.userId!==e.id_user:!N.includes(t.userId),r=!h||t.userName?.toLowerCase().includes(h.toLowerCase());return n&&r}).sort((e,t)=>{const n=e.userName||e.userEmail||"",r=t.userName||t.userEmail||"";return n.localeCompare(r)}).map(e=>Mt.jsx(Dn,{value:e.userId,children:e.userName},e.userId))]})]})]},`superior-select-${a}`),b.formState.errors.id_leader&&Mt.jsx("p",{className:"text-sm text-destructive mt-1",children:b.formState.errors.id_leader.message})]}),Mt.jsxs("div",{children:[Mt.jsx(Gt,{children:"Liderados *"}),Mt.jsx(Xh,{value:N,onChange:e=>b.setValue("id_users",e),excludeUserIds:j,error:b.formState.errors.id_users?.message},`users-multiselect-${a}`)]}),Mt.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Mt.jsx(Kt,{type:"submit",disabled:v||!s&&0===N.length,children:v&&!m.isPending?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Atualizando...":"Salvando..."]}):s?N.length>0?`Atualizar (${N.length})`:"Atualizar":`Adicionar (${N.length})`}),s&&!w&&0===N.length&&Mt.jsx(Kt,{type:"button",variant:"destructive",disabled:v,onClick:async()=>{if(e&&window.confirm("Tem certeza que deseja remover esta liderança?"))try{await m.mutateAsync(e.id),r?.()}catch(t){}},className:"ml-auto",children:m.isPending?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(F,{className:"mr-2 h-4 w-4"}),"Remover"]})})]})]})}function Zh({open:e,onOpenChange:t,leader:n,prefilledLeaderId:r,title:a}){return Mt.jsx(sn,{open:e,onOpenChange:t,children:Mt.jsxs(un,{className:"sm:max-w-[500px]",children:[Mt.jsx(mn,{children:Mt.jsx(pn,{children:a})}),Mt.jsx(Gh,{leader:n,prefilledLeaderId:r,onSuccess:()=>t(!1)})]})})}const eg="leadership-expanded-nodes",tg=(e,t)=>{try{localStorage.setItem(`${eg}-${e}`,JSON.stringify(Array.from(t)))}catch(n){}};function ng(){const{alias:e}=ka(),{data:t,isLoading:r,error:a,refetch:s}=Oh(),{data:i=[]}=Es(),[l,c]=n(()=>e?(e=>{try{const t=localStorage.getItem(`${eg}-${e}`);if(t)return new Set(JSON.parse(t))}catch(a){}return new Set})(e):new Set),[d,u]=n(!1),[m,f]=n(),[p,h]=n(null),g=i.length-(t?new Set(Lh(t).map(e=>e.id_user)).size:0);o(()=>{if(t&&t.length>0&&e){if(!localStorage.getItem(`${eg}-${e}`)){const n=t.map(e=>e.id),r=new Set(n);c(r),tg(e,r)}}},[t,e]);const x=t=>{c(n=>{const r=new Set(n);return r.has(t)?r.delete(t):r.add(t),e&&tg(e,r),r})},y=e=>{f(e),h(null),u(!0)};return r?Mt.jsx("div",{className:"flex items-center justify-center h-full",children:Mt.jsxs("div",{className:"text-center",children:[Mt.jsx(Re,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),Mt.jsx("p",{className:"text-muted-foreground",children:"Carregando hierarquia de liderança..."})]})}):a?Mt.jsx("div",{className:"flex items-center justify-center h-full",children:Mt.jsxs("div",{className:"text-center",children:[Mt.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),Mt.jsx(Kt,{onClick:()=>s(),children:"Tentar novamente"})]})}):Mt.jsxs("div",{className:"flex flex-col h-full",children:[Mt.jsx("div",{className:"flex items-center justify-between p-4 border-b",children:Mt.jsxs("div",{className:"flex gap-2 items-center",children:[Mt.jsxs(Kt,{size:"sm",onClick:()=>{f(void 0),h(null),u(!0)},children:[Mt.jsx(pe,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),Mt.jsxs(Kt,{variant:"outline",size:"sm",onClick:()=>{if(!t)return;const n=Lh(t).filter(e=>e.children.length>0).map(e=>e.id),r=new Set(n);c(r),e&&tg(e,r)},disabled:!t||0===t.length,children:[Mt.jsx(j,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),Mt.jsxs(Kt,{variant:"outline",size:"sm",onClick:()=>{const t=new Set;c(t),e&&tg(e,t)},disabled:!t||0===t.length,children:[Mt.jsx(T,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),Mt.jsx("div",{className:"flex items-center gap-2 ml-4",children:Mt.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[Mt.jsx(Be,{className:"h-4 w-4 text-muted-foreground"}),Mt.jsxs("span",{className:"text-sm font-medium",children:[g," usuário",1!==g?"s":""," não associado",1!==g?"s":""]})]})})]})}),t&&0!==t.length?Mt.jsx(Ns,{className:"flex-1",children:Mt.jsx("div",{children:Mt.jsxs("table",{className:"w-full",children:[Mt.jsx("thead",{children:Mt.jsxs("tr",{className:"border-b bg-muted/50",children:[Mt.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),Mt.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),Mt.jsx("tbody",{children:t.map(e=>Mt.jsx(Wh,{leader:e,expandedIds:l,onToggleExpand:x,onEdit:y},e.id))})]})})}):Mt.jsx("div",{className:"flex items-center justify-center flex-1",children:Mt.jsxs("div",{className:"text-center space-y-4",children:[Mt.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),Mt.jsx(Zh,{open:d,onOpenChange:()=>{u(!1),f(void 0),h(null)},leader:m,prefilledLeaderId:p,title:m?"Editar Líder":p?"Adicionar Liderado":"Adicionar Líder Raiz"},`leadership-dialog-${e}`)]})}export{Gr as AUTH_CONFIG,ai as Accordion,oi as AccordionContent,si as AccordionItem,ii as AccordionTrigger,Yt as ActionButton,Nl as ActionMenu,hs as ActionMenuItems,Ks as Alert,Js as AlertDescription,Ea as AlertDialog,za as AlertDialogAction,La as AlertDialogCancel,Pa as AlertDialogContent,Fa as AlertDialogDescription,Ra as AlertDialogFooter,Aa as AlertDialogHeader,Ta as AlertDialogOverlay,_a as AlertDialogPortal,Da as AlertDialogTitle,Ia as AlertDialogTrigger,Ys as AlertTitle,Rl as AppHeader,Ql as AppLayout,Wl as AppSidebar,li as AspectRatio,Wr as AuthErrorInterceptor,ja as AuthProvider,wa as AuthService,ci as Avatar,ui as AvatarFallback,di as AvatarImage,Mn as Badge,_s as BaseForm,mi as Breadcrumb,yi as BreadcrumbEllipsis,pi as BreadcrumbItem,hi as BreadcrumbLink,fi as BreadcrumbList,gi as BreadcrumbPage,xi as BreadcrumbSeparator,As as BulkActionBar,Kt as Button,Zr as CRUD_CONFIG,_i as Calendar,Xs as CallbackPage,Zt as Card,rn as CardContent,nn as CardDescription,an as CardFooter,en as CardHeader,Ka as CardSkeleton,tn as CardTitle,kl as Cards,_h as ChatbotPage,zn as Checkbox,Ti as Collapsible,Ai as CollapsibleContent,Pi as CollapsibleTrigger,ws as ColorPicker,dr as Command,ur as CommandDialog,pr as CommandEmpty,hr as CommandGroup,mr as CommandInput,xr as CommandItem,fr as CommandList,gr as CommandSeparator,yr as CommandShortcut,vl as CrudCards,Os as CrudPageInternal,Ps as CrudPagination,jl as CrudPrimitiveFilterBar,Ts as CrudPrimitivePagination,wl as CrudPrimitiveTable,ys as CrudTable,Ri as DataList,Oa as DeleteConfirmationDialog,sn as Dialog,cn as DialogClose,un as DialogContent,hn as DialogDescription,fn as DialogFooter,mn as DialogHeader,dn as DialogOverlay,ln as DialogPortal,pn as DialogTitle,on as DialogTrigger,es as DropdownMenu,ds as DropdownMenuCheckboxItem,ls as DropdownMenuContent,ns as DropdownMenuGroup,cs as DropdownMenuItem,ms as DropdownMenuLabel,rs as DropdownMenuPortal,ss as DropdownMenuRadioGroup,us as DropdownMenuRadioItem,fs as DropdownMenuSeparator,ps as DropdownMenuShortcut,as as DropdownMenuSub,os as DropdownMenuSubContent,is as DropdownMenuSubTrigger,ts as DropdownMenuTrigger,Xl as EmailService,Za as EmptyState,Ss as EntitySelect,Jl as ErrorBoundary,Ls as FilterBar,gn as Form,jn as FormControl,kn as FormDescription,yn as FormField,wn as FormItem,Nn as FormLabel,Cn as FormMessage,Ya as FormSkeleton,Li as Grid,Ja as HeaderSkeleton,Cs as IconPicker,Jt as Input,Gt as Label,Wh as LeaderRow,Zh as LeadershipDialog,Gh as LeadershipForm,ng as LeadershipPage,Bn as LoadingState,Gs as LoginPage,ia as MESSAGES,Th as ManageAccessModal,Ih as MarkdownMessage,wr as MultiSelect,_l as NavigationProvider,Oi as PageBreadcrumb,ei as PageMetadataProvider,$i as Pagination,Ui as PaginationContent,Wi as PaginationEllipsis,Bi as PaginationItem,Vi as PaginationLink,Hi as PaginationNext,qi as PaginationPrevious,Ph as PlaceCard,Ah as PlacesList,or as Popover,cr as PopoverContent,lr as PopoverTrigger,Qi as Progress,Ws as ProtectedRoute,na as QUERY_KEYS,ma as QualiexEnrichmentService,Kr as QualiexErrorInterceptor,Is as QualiexUserField,Ki as RadioGroup,Yi as RadioGroupItem,Hl as ResizableRail,ea as SEARCH_CONFIG,Ns as ScrollArea,js as ScrollBar,Sn as Select,An as SelectContent,En as SelectGroup,Dn as SelectItem,Rn as SelectLabel,Pn as SelectScrollDownButton,Tn as SelectScrollUpButton,Fn as SelectSeparator,_n as SelectTrigger,In as SelectValue,Ji as Separator,Xi as Sheet,Zi as SheetClose,ro as SheetContent,oo as SheetDescription,so as SheetFooter,ao as SheetHeader,to as SheetOverlay,eo as SheetPortal,io as SheetTitle,Gi as SheetTrigger,xo as Sidebar,Co as SidebarContent,jo as SidebarFooter,So as SidebarGroup,Io as SidebarGroupAction,_o as SidebarGroupContent,Eo as SidebarGroupLabel,Vl as SidebarHeader,wo as SidebarInput,vo as SidebarInset,To as SidebarMenu,Do as SidebarMenuAction,Fo as SidebarMenuBadge,Ro as SidebarMenuButton,Po as SidebarMenuItem,zo as SidebarMenuSkeleton,Lo as SidebarMenuSub,Mo as SidebarMenuSubButton,Oo as SidebarMenuSubItem,go as SidebarProvider,bo as SidebarRail,ko as SidebarSeparator,Xa as SidebarSkeleton,yo as SidebarTrigger,br as Skeleton,$o as Slider,Uo as SonnerToaster,Un as Spinner,zs as Stack,Di as StatusSelect,ol as Switch,pl as TabPageContent,fl as TabPageHeader,ml as TabPageLayout,Ma as Table,Ua as TableBody,Wa as TableCaption,Ha as TableCell,Ba as TableFooter,qa as TableHead,$a as TableHeader,Va as TableRow,gs as TableRowActions,Qa as TableSkeleton,ll as Tabs,ul as TabsContent,cl as TabsList,dl as TabsTrigger,Ln as Textarea,tr as Toast,nr as ToastAction,rr as ToastClose,sr as ToastDescription,Gn as ToastProvider,ar as ToastTitle,Zn as ToastViewport,ir as Toaster,gl as Toggle,yl as ToggleGroup,bl as ToggleGroupItem,Pr as TokenManager,jr as TokenService,co as Tooltip,mo as TooltipContent,lo as TooltipProvider,uo as TooltipTrigger,$l as assets,On as badgeVariants,zh as buildHierarchy,Qt as buttonVariants,Ut as cn,Ms as createCrudPage,Sl as createCrudRoutingConfig,Cl as createRoutingHandlers,ha as createService,$s as createSimpleSaveHandler,Sa as createSimpleService,qs as crudPresets,Ht as debounce,la as deriveEmailField,oa as deriveNameField,ca as deriveUsernameField,Gl as emailService,Dr as errorService,Lh as flattenTree,qt as formatCurrency,Vt as formatDatetime,Us as generateCrudConfig,aa as getQualiexConfig,Ur as getSupabaseClient,$t as handleExternalLink,ta as isDevEnvironment,Ul as logoSrc,Fh as placeService,Xr as qualiexApi,da as resolveFieldMappings,sa as setQualiexConfig,ri as setupQualiexCore,Wt as slugify,Bl as smallLogoSrc,Jn as toast,hl as toggleVariants,Bt as trimTextFields,Fl as useActiveModules,ka as useAuth,bs as useBaseForm,Mh as useCreateLeaderMutation,Uh as useCreateMultipleLeadersMutation,$h as useCreateSingleLeaderMutation,Ca as useCrud,Al as useDebounce,bn as useFormField,Oh as useLeadershipApi,Tl as useNavigation,Zl as useOpenAIChat,ni as usePageMetadata,Pl as usePageTitle,Dl as usePermissionQuery,Es as useQualiexUsers,Vh as useRemoveLeaderMutation,Mi as useRouteBreadcrumbs,ho as useSidebar,ql as useSidebarResize,qh as useSyncSubordinatesMutation,Xn as useToast,Bh as useUpdateLeaderMutation,Hs as withPreset};
10
+ */function Lt(){return Dt||(Dt=1,"production"!==process.env.NODE_ENV&&function(){var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),h=Symbol.iterator;var g=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];!function(e,t,n){var r=g.ReactDebugCurrentFrame,a=r.getStackAddendum();""!==a&&(t+="%s",n=n.concat([a]));var s=n.map(function(e){return String(e)});s.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,s)}("error",e,n)}var y;function v(e){return e.displayName||"Context"}function b(e){if(null==e)return null;if("number"==typeof e.tag&&x("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case r:return"Portal";case i:return"Profiler";case s:return"StrictMode";case d:return"Suspense";case u:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return v(e)+".Consumer";case o:return v(e._context)+".Provider";case c:return function(e,t,n){var r=e.displayName;if(r)return r;var a=t.displayName||t.name||"";return""!==a?n+"("+a+")":n}(e,e.render,"ForwardRef");case m:var t=e.displayName||null;return null!==t?t:b(e.type)||"Memo";case f:var n=e,p=n._payload,h=n._init;try{return b(h(p))}catch(g){return null}}return null}y=Symbol.for("react.module.reference");var w,j,N,k,C,S,E,I=Object.assign,T=0;function A(){}A.__reactDisabledLog=!0;var P,_=g.ReactCurrentDispatcher;function F(e,t,n){if(void 0===P)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);P=r&&r[1]||""}return"\n"+P+e}var R,D=!1,O="function"==typeof WeakMap?WeakMap:Map;function z(e,t){if(!e||D)return"";var n,r=R.get(e);if(void 0!==r)return r;D=!0;var a,s=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=_.current,_.current=null,function(){if(0===T){w=console.log,j=console.info,N=console.warn,k=console.error,C=console.group,S=console.groupCollapsed,E=console.groupEnd;var e={configurable:!0,enumerable:!0,value:A,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}T++}();try{if(t){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(i,[])}catch(p){n=p}Reflect.construct(e,[],i)}else{try{i.call()}catch(p){n=p}e.call(i.prototype)}}else{try{throw Error()}catch(p){n=p}e()}}catch(h){if(h&&n&&"string"==typeof h.stack){for(var o=h.stack.split("\n"),l=n.stack.split("\n"),c=o.length-1,d=l.length-1;c>=1&&d>=0&&o[c]!==l[d];)d--;for(;c>=1&&d>=0;c--,d--)if(o[c]!==l[d]){if(1!==c||1!==d)do{if(c--,--d<0||o[c]!==l[d]){var u="\n"+o[c].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),"function"==typeof e&&R.set(e,u),u}}while(c>=1&&d>=0);break}}}finally{D=!1,_.current=a,function(){if(0===--T){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},e,{value:w}),info:I({},e,{value:j}),warn:I({},e,{value:N}),error:I({},e,{value:k}),group:I({},e,{value:C}),groupCollapsed:I({},e,{value:S}),groupEnd:I({},e,{value:E})})}T<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=s}var m=e?e.displayName||e.name:"",f=m?F(m):"";return"function"==typeof e&&R.set(e,f),f}function L(e,t,n){if(null==e)return"";if("function"==typeof e)return z(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if("string"==typeof e)return F(e);switch(e){case d:return F("Suspense");case u:return F("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return z(e.render,!1);case m:return L(e.type,t,n);case f:var r=e,a=r._payload,s=r._init;try{return L(s(a),t,n)}catch(i){}}return""}R=new O;var M=Object.prototype.hasOwnProperty,U={},$=g.ReactDebugCurrentFrame;function B(e){if(e){var t=e._owner,n=L(e.type,e._source,t?t.type:null);$.setExtraStackFrame(n)}else $.setExtraStackFrame(null)}var V=Array.isArray;function q(e){return V(e)}function H(e){return""+e}function W(e){if(function(e){try{return H(e),!1}catch(t){return!0}}(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),H(e)}var K,Q,Y=g.ReactCurrentOwner,J={key:!0,ref:!0,__self:!0,__source:!0};function X(e,t,r,a,s){var i,o={},l=null,c=null;for(i in void 0!==r&&(W(r),l=""+r),function(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(W(t.key),l=""+t.key),function(e){if(M.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(c=t.ref,function(e){"string"==typeof e.ref&&Y.current}(t)),t)M.call(t,i)&&!J.hasOwnProperty(i)&&(o[i]=t[i]);if(e&&e.defaultProps){var d=e.defaultProps;for(i in d)void 0===o[i]&&(o[i]=d[i])}if(l||c){var u="function"==typeof e?e.displayName||e.name||"Unknown":e;l&&function(e,t){var n=function(){K||(K=!0,x("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(o,u),c&&function(e,t){var n=function(){Q||(Q=!0,x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}(o,u)}return function(e,t,r,a,s,i,o){var l={$$typeof:n,type:e,key:t,ref:r,props:o,_owner:i,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}(e,l,c,s,a,Y.current,o)}var G,Z=g.ReactCurrentOwner,ee=g.ReactDebugCurrentFrame;function te(e){if(e){var t=e._owner,n=L(e.type,e._source,t?t.type:null);ee.setExtraStackFrame(n)}else ee.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}function re(){if(Z.current){var e=b(Z.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}G=!1;var ae={};function se(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var n=function(e){var t=re();if(!t){var n="string"==typeof e?e:e.displayName||e.name;n&&(t="\n\nCheck the top-level render call using <"+n+">.")}return t}(t);if(!ae[n]){ae[n]=!0;var r="";e&&e._owner&&e._owner!==Z.current&&(r=" It was passed a child from "+b(e._owner.type)+"."),te(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),te(null)}}}function ie(e,t){if("object"==typeof e)if(q(e))for(var n=0;n<e.length;n++){var r=e[n];ne(r)&&se(r,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var a=function(e){if(null===e||"object"!=typeof e)return null;var t=h&&e[h]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof a&&a!==e.entries)for(var s,i=a.call(e);!(s=i.next()).done;)ne(s.value)&&se(s.value,t)}}function oe(e){var t,n=e.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)t=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==c&&n.$$typeof!==m)return;t=n.propTypes}if(t){var r=b(n);!function(e,t,n,r,a){var s=Function.call.bind(M);for(var i in e)if(s(e,i)){var o=void 0;try{if("function"!=typeof e[i]){var l=Error((r||"React class")+": "+n+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}o=e[i](t,i,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){o=c}!o||o instanceof Error||(B(a),x("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",n,i,typeof o),B(null)),o instanceof Error&&!(o.message in U)&&(U[o.message]=!0,B(a),x("Failed %s type: %s",n,o.message),B(null))}}(t,e.props,"prop",r,e)}else if(void 0!==n.PropTypes&&!G){G=!0,x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b(n)||"Unknown")}"function"!=typeof n.getDefaultProps||n.getDefaultProps.isReactClassApproved||x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var le={};function ce(e,t,r,h,g,v){var w=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===i||e===s||e===d||e===u||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===f||e.$$typeof===m||e.$$typeof===o||e.$$typeof===l||e.$$typeof===c||e.$$typeof===y||void 0!==e.getModuleId)}(e);if(!w){var j="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(j+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var N;j+=re(),null===e?N="null":q(e)?N="array":void 0!==e&&e.$$typeof===n?(N="<"+(b(e.type)||"Unknown")+" />",j=" Did you accidentally export a JSX literal instead of a component?"):N=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",N,j)}var k=X(e,t,r,g,v);if(null==k)return k;if(w){var C=t.children;if(void 0!==C)if(h)if(q(C)){for(var S=0;S<C.length;S++)ie(C[S],e);Object.freeze&&Object.freeze(C)}else x("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ie(C,e)}if(M.call(t,"key")){var E=b(e),I=Object.keys(t).filter(function(e){return"key"!==e}),T=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!le[E+T])x('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',T,E,I.length>0?"{"+I.join(": ..., ")+": ...}":"{}",E),le[E+T]=!0}return e===a?function(e){for(var t=Object.keys(e.props),n=0;n<t.length;n++){var r=t[n];if("children"!==r&&"key"!==r){te(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),te(null);break}}null!==e.ref&&(te(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),te(null))}(k):oe(k),k}var de=function(e,t,n){return ce(e,t,n,!1)},ue=function(e,t,n){return ce(e,t,n,!0)};zt.Fragment=a,zt.jsx=de,zt.jsxs=ue}()),zt}var Mt=(Ot||(Ot=1,"production"===process.env.NODE_ENV?Ft.exports=function(){if(_t)return Rt;_t=1;var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(e,t,r){var o,l={},c=null,d=null;for(o in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(d=t.ref),t)a.call(t,o)&&!i.hasOwnProperty(o)&&(l[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===l[o]&&(l[o]=t[o]);return{$$typeof:n,type:e,key:c,ref:d,props:l,_owner:s.current}}return Rt.Fragment=r,Rt.jsx=o,Rt.jsxs=o,Rt}():Ft.exports=Lt()),Ft.exports);function Ut(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{v.info("Link copiado para a área de transferência")})}function $t(...e){return h(p(e))}const Bt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Bt);if("object"==typeof e&&e.constructor===Object){const t={};for(const[n,r]of Object.entries(e))t[n]=Bt(r);return t}return e},Vt=e=>{if(!e)return"";const t=g(e);if(!x(t))return"Data inválida";return`${t.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"})} ${t.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}`},qt=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),Ht=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},Wt=e=>e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"),Kt=f("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium 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 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",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:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-xs":"h-6 w-6"}},defaultVariants:{variant:"default",size:"default"}}),Qt=e.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...a},s)=>{const i=r?u:"button";return Mt.jsx(i,{className:$t(Kt({variant:t,size:n,className:e})),ref:s,...a})});Qt.displayName="Button";const Yt=t.forwardRef(({variant:e="default",className:t,children:n,...r},a)=>Mt.jsx(Qt,{ref:a,variant:"action",size:"sm",className:$t("h-7 px-2 text-xs",t),...r,children:n||Mt.jsx(w,{size:12})}));Yt.displayName="ActionButton";const Jt=e.forwardRef(({className:e,type:t,...n},r)=>Mt.jsx("input",{type:t,className:$t("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Jt.displayName="Input";const Xt=f("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Gt=e.forwardRef(({className:e,...t},n)=>Mt.jsx(He.Root,{ref:n,className:$t(Xt(),e),...t}));Gt.displayName=He.Root.displayName;const Zt=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Zt.displayName="Card";const en=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("flex flex-col space-y-1.5 p-6",e),...t}));en.displayName="CardHeader";const tn=e.forwardRef(({className:e,...t},n)=>Mt.jsx("h3",{ref:n,className:$t("text-2xl font-semibold leading-none tracking-tight",e),...t}));tn.displayName="CardTitle";const nn=e.forwardRef(({className:e,...t},n)=>Mt.jsx("p",{ref:n,className:$t("text-sm text-muted-foreground",e),...t}));nn.displayName="CardDescription";const rn=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("p-6 pt-0",e),...t}));rn.displayName="CardContent";const an=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("flex items-center p-6 pt-0",e),...t}));an.displayName="CardFooter";const sn=We.Root,on=We.Trigger,ln=We.Portal,cn=We.Close,dn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Overlay,{ref:n,className:$t("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));dn.displayName=We.Overlay.displayName;const un=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(ln,{children:[Mt.jsx(dn,{}),Mt.jsxs(We.Content,{ref:r,className:$t("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 bg-background p-6 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-h-[90vh] overflow-auto",e),...n,children:[t,Mt.jsxs(We.Close,{className:"absolute right-4 top-4 z-10 rounded-sm text-white opacity-70 ring-offset-background transition-opacity hover:opacity-100 hover:text-white focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[Mt.jsx(j,{className:"h-4 w-4"}),Mt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));un.displayName=We.Content.displayName;const mn=({className:e,...t})=>Mt.jsx("div",{className:$t("flex flex-col space-y-1.5 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-3 rounded-t-lg",e),...t});mn.displayName="DialogHeader";const fn=({className:e,...t})=>Mt.jsx("div",{className:$t("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});fn.displayName="DialogFooter";const pn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Title,{ref:n,className:$t("text-lg font-semibold leading-none tracking-tight",e),...t}));pn.displayName=We.Title.displayName;const hn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Description,{ref:n,className:$t("text-sm text-white",e),...t}));hn.displayName=We.Description.displayName;const gn=Qe,xn=e.createContext({}),yn=({...e})=>Mt.jsx(xn.Provider,{value:{name:e.name},children:Mt.jsx(Ye,{...e})}),vn=()=>{const t=e.useContext(xn),n=e.useContext(bn),{getFieldState:r,formState:a}=Ke(),s=r(t.name,a);if(!t)throw new Error("useFormField should be used within <FormField>");const{id:i}=n;return{id:i,name:t.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...s}},bn=e.createContext({}),wn=e.forwardRef(({className:t,...n},r)=>{const a=e.useId();return Mt.jsx(bn.Provider,{value:{id:a},children:Mt.jsx("div",{ref:r,className:$t("space-y-2",t),...n})})});wn.displayName="FormItem";const jn=e.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:a}=vn();return Mt.jsx(Gt,{ref:n,className:$t(r&&"text-destructive",e),htmlFor:a,...t})});jn.displayName="FormLabel";const Nn=e.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:a,formMessageId:s}=vn();return Mt.jsx(u,{ref:t,id:r,"aria-describedby":n?`${a} ${s}`:`${a}`,"aria-invalid":!!n,...e})});Nn.displayName="FormControl";const kn=e.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=vn();return Mt.jsx("p",{ref:n,id:r,className:$t("text-sm text-muted-foreground",e),...t})});kn.displayName="FormDescription";const Cn=e.forwardRef(({className:e,children:t,...n},r)=>{const{error:a,formMessageId:s}=vn(),i=a?String(a?.message):t;return i?Mt.jsx("p",{ref:r,id:s,className:$t("text-sm font-medium text-destructive",e),...n,children:i}):null});Cn.displayName="FormMessage";const Sn=Ge.Root,En=Ge.Group,In=Ge.Value,Tn=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(Ge.Trigger,{ref:r,className:$t("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,Mt.jsx(Ge.Icon,{asChild:!0,children:Mt.jsx(N,{className:"h-4 w-4 opacity-50"})})]}));Tn.displayName=Ge.Trigger.displayName;const An=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ge.ScrollUpButton,{ref:n,className:$t("flex cursor-default items-center justify-center py-1",e),...t,children:Mt.jsx(k,{className:"h-4 w-4"})}));An.displayName=Ge.ScrollUpButton.displayName;const Pn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ge.ScrollDownButton,{ref:n,className:$t("flex cursor-default items-center justify-center py-1",e),...t,children:Mt.jsx(N,{className:"h-4 w-4"})}));Pn.displayName=Ge.ScrollDownButton.displayName;const _n=e.forwardRef(({className:e,children:t,position:n="popper",container:r,collisionBoundary:a,...s},i)=>Mt.jsx(Ge.Portal,{container:r,children:Mt.jsxs(Ge.Content,{ref:i,className:$t("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"===n&&"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:n,collisionBoundary:a,...s,children:[Mt.jsx(An,{}),Mt.jsx(Ge.Viewport,{className:$t("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),Mt.jsx(Pn,{})]})}));_n.displayName=Ge.Content.displayName;const Fn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ge.Label,{ref:n,className:$t("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Fn.displayName=Ge.Label.displayName;const Rn=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(Ge.Item,{ref:r,className:$t("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[Mt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Mt.jsx(Ge.ItemIndicator,{children:Mt.jsx(C,{className:"h-4 w-4"})})}),Mt.jsx(Ge.ItemText,{children:t})]}));Rn.displayName=Ge.Item.displayName;const Dn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ge.Separator,{ref:n,className:$t("-mx-1 my-1 h-px bg-muted",e),...t}));Dn.displayName=Ge.Separator.displayName;const On=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ze.Root,{ref:n,className:$t("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:Mt.jsx(Ze.Indicator,{className:$t("flex items-center justify-center text-current"),children:Mt.jsx(C,{className:"h-4 w-4"})})}));On.displayName=Ze.Root.displayName;const zn=e.forwardRef(({className:e,...t},n)=>Mt.jsx("textarea",{className:$t("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));zn.displayName="Textarea";const Ln=f("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500 text-white hover:bg-green-600",warning:"border-transparent bg-yellow-500 text-white hover:bg-yellow-600",info:"border-transparent bg-blue-500 text-white hover:bg-blue-600"}},defaultVariants:{variant:"default"}}),Mn=e.forwardRef(({className:e,variant:t,...n},r)=>Mt.jsx("div",{ref:r,className:$t(Ln({variant:t}),e),...n}));Mn.displayName="Badge";const Un={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function $n({size:e="md",className:t}){return Mt.jsx(S,{className:$t("animate-spin text-muted-foreground",Un[e],t)})}function Bn({isLoading:e,children:t,className:n,type:r="spinner",size:a="md"}){return e?"overlay"===r?Mt.jsxs("div",{className:$t("relative",n),children:[t,Mt.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:Mt.jsx($n,{size:a})})]}):"skeleton"===r?Mt.jsx("div",{className:$t("animate-pulse",n),children:Mt.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):Mt.jsx("div",{className:$t("flex items-center justify-center py-8",n),children:Mt.jsx($n,{size:a})}):Mt.jsx(Mt.Fragment,{children:t})}let Vn=0;const qn=new Map,Hn=e=>{if(qn.has(e))return;const t=setTimeout(()=>{qn.delete(e),Yn({type:"REMOVE_TOAST",toastId:e})},1e6);qn.set(e,t)},Wn=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?Hn(n):e.toasts.forEach(e=>{Hn(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===n||void 0===n?{...e,open:!1}:e)}}case"REMOVE_TOAST":return void 0===t.toastId?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}},Kn=[];let Qn={toasts:[]};function Yn(e){Qn=Wn(Qn,e),Kn.forEach(e=>{e(Qn)})}function Jn({...e}){const t=(Vn=(Vn+1)%Number.MAX_SAFE_INTEGER,Vn.toString()),n=()=>Yn({type:"DISMISS_TOAST",toastId:t});return Yn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||n()}}}),{id:t,dismiss:n,update:e=>Yn({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function Xn(){const[t,n]=e.useState(Qn);return e.useEffect(()=>(Kn.push(n),()=>{const e=Kn.indexOf(n);e>-1&&Kn.splice(e,1)}),[t]),{...t,toast:Jn,dismiss:e=>Yn({type:"DISMISS_TOAST",toastId:e})}}const Gn=et.Provider,Zn=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Viewport,{ref:n,className:$t("fixed top-4 left-1/2 transform -translate-x-1/2 z-[100] flex max-h-screen w-full max-w-[420px] flex-col p-4",e),...t}));Zn.displayName=et.Viewport.displayName;const er=f("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),tr=e.forwardRef(({className:e,variant:t,...n},r)=>Mt.jsx(et.Root,{ref:r,className:$t(er({variant:t}),e),...n}));tr.displayName=et.Root.displayName;const nr=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Action,{ref:n,className:$t("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));nr.displayName=et.Action.displayName;const rr=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Close,{ref:n,className:$t("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:Mt.jsx(j,{className:"h-4 w-4"})}));rr.displayName=et.Close.displayName;const ar=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Title,{ref:n,className:$t("text-sm font-semibold",e),...t}));ar.displayName=et.Title.displayName;const sr=e.forwardRef(({className:e,...t},n)=>Mt.jsx(et.Description,{ref:n,className:$t("text-sm opacity-90",e),...t}));function ir(){const{toasts:e}=Xn();return Mt.jsxs(Gn,{children:[e.map(function({id:e,title:t,description:n,action:r,...a}){return Mt.jsxs(tr,{...a,children:[Mt.jsxs("div",{className:"grid gap-1",children:[t&&Mt.jsx(ar,{children:t}),n&&Mt.jsx(sr,{children:n})]}),r,Mt.jsx(rr,{})]},e)}),Mt.jsx(Zn,{})]})}sr.displayName=et.Description.displayName;const or=tt.Root,lr=tt.Trigger,cr=e.forwardRef(({className:e,align:t="center",sideOffset:n=4,container:r,...a},s)=>Mt.jsx(tt.Portal,{container:r,children:Mt.jsx(tt.Content,{ref:s,align:t,sideOffset:n,className:$t("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),...a})}));cr.displayName=tt.Content.displayName;const dr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));dr.displayName="Command";const ur=({children:e,...t})=>Mt.jsx("div",{...t,children:Mt.jsx(dr,{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})}),mr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:Mt.jsx("input",{ref:n,className:$t("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})}));mr.displayName="CommandInput";const fr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));fr.displayName="CommandList";const pr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("py-6 text-center text-sm text-muted-foreground",e),...t}));pr.displayName="CommandEmpty";const hr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));hr.displayName="CommandGroup";const gr=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("-mx-1 h-px bg-border",e),...t}));gr.displayName="CommandSeparator";const xr=e.forwardRef(({className:e,disabled:t,onSelect:n,value:r,...a},s)=>Mt.jsx("div",{ref:s,className:$t("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),"data-disabled":t,onClick:()=>!t&&n?.(r||""),...a}));xr.displayName="CommandItem";const yr=({className:e,...t})=>Mt.jsx("span",{className:$t("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});function vr({className:e,...t}){return Mt.jsx("div",{className:$t("animate-pulse rounded-md bg-muted",e),...t})}yr.displayName="CommandShortcut";const br=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function wr({multiple:e,options:t,value:a,onChange:s,getOptionValue:i,getOptionLabel:o,placeholder:l,label:c,icon:d,emptyMessage:u,searchPlaceholder:m,disabled:f,required:p,className:h,sortOptions:g,maxDisplayedBadges:x,popoverContainer:y,onOpen:v,onClose:b}){const[w,k]=n(!1),[S,E]=n(""),I=r(()=>a?Array.isArray(a)?a:[a]:[],[a]),T=r(()=>{if(!y)return;let e=y,t=0;try{for(;e&&t<3;){const n=window.getComputedStyle(e),r=n.overflowY||n.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[y]),A=r(()=>{const e=t.map(e=>({original:e,value:i(e),label:o(e)}));return g?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[t,i,o,g]),P=r(()=>{if(!S)return A;const e=br(S);return A.filter(t=>br(t.label).includes(e))},[A,S]),_=r(()=>A.filter(e=>I.includes(e.value)),[A,I]),F=(t,n)=>{n.preventDefault(),n.stopPropagation(),s&&s(e?I.filter(e=>e!==t):"")},R=x?_.slice(0,x):_,D=x&&_.length>x?_.length-x:0;return Mt.jsxs("div",{className:$t("space-y-2",h),children:[c&&Mt.jsxs(Gt,{children:[c,p&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsxs(or,{open:w,onOpenChange:e=>{k(e),e?v?.():(E(""),b?.())},modal:!1,children:[Mt.jsx(lr,{asChild:!0,children:Mt.jsxs(Qt,{variant:"outline",role:"combobox","aria-expanded":w,disabled:f,className:$t("w-full justify-between min-h-10 h-auto",0===_.length&&"text-muted-foreground"),children:[0===_.length?Mt.jsxs("span",{className:"flex items-center gap-2",children:[d&&Mt.jsx(d,{className:"h-4 w-4"}),l]}):e?Mt.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[R.map(e=>Mt.jsxs(Mn,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,Mt.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&&F(e.value,t)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>F(e.value,t),children:Mt.jsx(j,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),D>0&&Mt.jsxs(Mn,{variant:"outline",className:"gap-1",children:["+",D]})]}):Mt.jsxs("span",{className:"flex items-center gap-2",children:[d&&Mt.jsx(d,{className:"h-4 w-4"}),_[0]?.label]}),Mt.jsx(N,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),Mt.jsx(cr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:T,collisionBoundary:T,children:Mt.jsxs(dr,{children:[Mt.jsx(mr,{placeholder:m,value:S,onChange:e=>E(e.target.value)}),Mt.jsx(fr,{children:0===t.length?Mt.jsx(pr,{children:u}):0===P.length?Mt.jsx(pr,{children:"Nenhum item encontrado."}):Mt.jsx(hr,{children:P.map(t=>Mt.jsxs(xr,{value:t.value,onSelect:()=>(t=>{if(s)if(e){const e=I.includes(t)?I.filter(e=>e!==t):[...I,t];s(e)}else s(t),k(!1)})(t.value),className:"cursor-pointer",children:[Mt.jsx(C,{className:$t("mr-2 h-4 w-4",I.includes(t.value)?"opacity-100":"opacity-0")}),t.label]},t.value))})})]})})]})]})}function jr({multiple:e=!0,options:t=[],value:n,onChange:r,getOptionValue:a=e=>e.value,getOptionLabel:s=e=>e.label,placeholder:i="Selecione itens...",label:o,icon:l,emptyMessage:c="Nenhum item disponível.",searchPlaceholder:d="Buscar...",disabled:u=!1,required:m=!1,isLoading:f=!1,error:p,className:h,sortOptions:g=!0,maxDisplayedBadges:x,popoverContainer:y,onOpen:v,onClose:b}){if(f)return Mt.jsxs("div",{className:$t("space-y-2",h),children:[o&&Mt.jsxs(Gt,{children:[o,m&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsx(vr,{className:"h-10 w-full"})]});const w="string"==typeof p?p:p?"Erro ao carregar dados":void 0;return w?Mt.jsxs("div",{className:$t("space-y-2",h),children:[o&&Mt.jsxs(Gt,{children:[o,m&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[Mt.jsx(E,{className:"h-4 w-4"}),Mt.jsx("span",{className:"text-sm",children:w})]})]}):Mt.jsx(wr,{multiple:e,options:t,value:n||(e?[]:""),onChange:r,getOptionValue:a,getOptionLabel:s,placeholder:i,label:o,icon:l,emptyMessage:c,searchPlaceholder:d,disabled:u,required:m,className:h,sortOptions:g,maxDisplayedBadges:x,popoverContainer:y,onOpen:v,onClose:b})}var Nr=Object.defineProperty;class kr{static normalizeBase64Url(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const n=(4-t.length%4)%4;return t+="=".repeat(n),t}static parseJwtPayload(e){try{const a=e.split(".");if(3!==a.length)return null;const s=a[1];s.length,this.LARGE_PAYLOAD_THRESHOLD;try{const e=this.normalizeBase64Url(s),t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);const r=new TextDecoder("utf-8").decode(n);return JSON.parse(r)}catch(t){try{const e=this.normalizeBase64Url(s),t=decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(t)}catch(n){try{const e=this.normalizeBase64Url(s),t=atob(e);return JSON.parse(t)}catch(r){throw r}}}}catch(a){return null}}static validateTokens(e,t){const n=[],r=[];try{t.split(".")[1],e.split(".")[1];const a=this.parseJwtPayload(t),s=this.parseJwtPayload(e);if(!a){const e="ID token decode falhou - possível problema com base64url encoding";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:n,errors:r}}let i=!0;if(!s){const e="Access token decode falhou - será tentado novamente nas chamadas de API";n.push(e),i=!1}const o=Math.floor(Date.now()/1e3);if(s?.exp&&s.exp<o){const e="Access token expirado - pode precisar de refresh";n.push(e),i=!1}if(a.exp&&a.exp<o){const e="ID token expirado - autenticação inválida";return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:i,warnings:n,errors:r}}return{isValid:!0,idTokenValid:!0,accessTokenValid:i,warnings:n,errors:r}}catch(a){const e=`Erro na validação de tokens: ${a}`;return r.push(e),{isValid:!1,idTokenValid:!1,accessTokenValid:!1,warnings:n,errors:r}}}static isTokenExpired(e){const t=this.parseJwtPayload(e);return!t||!t.exp||1e3*t.exp<Date.now()}static extractTokenData(e){return this.parseJwtPayload(e)}}((e,t,n)=>{t in e?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(kr,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Cr="qualiex_access_token",Sr="qualiex_id_token",Er="supabase_token",Ir="oauth_state",Tr="oauth_nonce",Ar="selected_alias",Pr="manual_logout",_r={setAccessToken:e=>localStorage.setItem(Cr,e),getAccessToken:()=>localStorage.getItem(Cr),setIdToken:e=>localStorage.setItem(Sr,e),getIdToken:()=>localStorage.getItem(Sr),getSupabaseToken:()=>localStorage.getItem(Er),setOAuthState:e=>sessionStorage.setItem(Ir,e),getOAuthState:()=>sessionStorage.getItem(Ir),clearOAuthState:()=>sessionStorage.removeItem(Ir),setOAuthNonce:e=>sessionStorage.setItem(Tr,e),getOAuthNonce:()=>sessionStorage.getItem(Tr),clearOAuthNonce:()=>sessionStorage.removeItem(Tr),setSelectedAlias:e=>localStorage.setItem(Ar,e),getSelectedAlias:()=>localStorage.getItem(Ar),clearSelectedAlias:()=>localStorage.removeItem(Ar),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!_r.getAccessToken()||!_r.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Er,e),_r._clearValidationCache()},areAllTokensValid:()=>{const e=_r.getAccessToken(),t=_r.getIdToken();if(!e||!t)return!1;try{const n=kr.validateTokens(e,t);return!!n.idTokenValid&&n.idTokenValid}catch(n){return!1}},clearExpiredTokens:()=>{let e=!1;const t=_r.getAccessToken(),n=_r.getIdToken(),r=_r.getSupabaseToken();return t&&_r.isTokenExpired(t)&&(localStorage.removeItem(Cr),e=!0),n&&_r.isTokenExpired(n)&&(localStorage.removeItem(Sr),e=!0),r&&_r.isTokenExpired(r)&&(localStorage.removeItem(Er),e=!0),e},clearAll:()=>{localStorage.removeItem(Cr),localStorage.removeItem(Sr),localStorage.removeItem(Er),localStorage.removeItem(Ar),localStorage.removeItem(Pr),sessionStorage.removeItem(Ir),sessionStorage.removeItem(Tr)},setManualLogout:()=>localStorage.setItem(Pr,"true"),isManualLogout:()=>"true"===localStorage.getItem(Pr),clearManualLogout:()=>localStorage.removeItem(Pr),isTokenExpired:e=>{try{return kr.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{_r._validationCache.isValid=!1,_r._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=_r.getSupabaseToken();if(!e)return!1;if(_r.isTokenExpired(e))return _r._clearValidationCache(),_r._handleExpiredToken(),!1;const t=Date.now();return t-_r._validationCache.timestamp<_r._validationCache.cacheValidityMs?_r._validationCache.isValid:(_r._validationCache.isValid=!0,_r._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>_r.isSupabaseTokenValid()?_r.getSupabaseToken():null,_handleExpiredToken:()=>{_r.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!_r.isSupabaseTokenValid())return null;const e=_r.getSupabaseToken();if(!e)return null;try{const t=kr.parseJwtPayload(e);if(!t)return null;const n=t.alias||t.default||t.user_alias,r=t.place_id||null,a=t.place_name||null;let s=t.company_id;if(!s&&n)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]===n){s=e[7];break}}}return{alias:n,companyId:s,placeId:r,placeName:a,payload:t}}catch(t){return _r._handleExpiredToken(),null}},getCompanyId:e=>{const t=_r.getAccessToken();if(t)try{const n=kr.parseJwtPayload(t);if(n)for(const t in n)if(t.startsWith("co")&&/^co\d+$/.test(t)){const r=n[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(a){}const n=_r.extractTokenData();if(n?.companyId)return n.companyId;const r=_r.getIdToken();if(r)try{const t=kr.parseJwtPayload(r);if(t)for(const n in t)if(n.startsWith("co")&&/^co\d+$/.test(n)){const r=t[n];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(a){}return null},getCurrentCompanyId:()=>{const e=_r.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=_r.getIdToken();if(!e)return[];try{const t=kr.parseJwtPayload(e);if(!t)return[];const n=[];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&&n.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return n}catch{return[]}}};var Fr=Object.defineProperty,Rr=(e,t,n)=>((e,t,n)=>t in e?Fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const Dr=new class{constructor(){Rr(this,"errors",[]),Rr(this,"toastCount",0),Rr(this,"lastToastTime",0)}handleError(e,t=!0){const n="string"==typeof e?e:e.message;if(this.errors.push({id:Date.now().toString(),message:n,timestamp:Date.now(),count:1}),t&&this.shouldShowToast()){Jn({title:this.getErrorTitle(n),description:n,variant:"destructive"})}}getErrorTitle(e){const t=e.toLowerCase();return t.includes("401")||t.includes("unauthorized")||t.includes("expirou")?"Sessão Expirada":t.includes("token")||t.includes("autenticação")?"Erro de Autenticação":t.includes("api")||t.includes("network")?"Erro de Conexão":"Erro"}success(e,t){Jn({title:e,description:t,variant:"default"})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var Or=Object.defineProperty,zr=(e,t,n)=>((e,t,n)=>t in e?Or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const Lr=import.meta.env.VITE_SUPABASE_URL,Mr=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,Ur=class e{constructor(){zr(this,"client"),zr(this,"currentToken",null),zr(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:Mr};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return nt(Lr,Mr,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1,storage:void 0},global:{headers:t,fetch:async(e,t)=>("string"==typeof e?e:e.url).includes("/auth/v1/user")?new Response(JSON.stringify({error:"blocked"}),{status:401,headers:{"Content-Type":"application/json"}}):fetch(e,t)}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=_r.getValidSupabaseToken();return e!==this.currentToken&&(this.client=this.createClientWithToken(e),this.currentToken=e),this.client}isTokenValid(e){try{const t=JSON.parse(atob(e.split(".")[1])),n=Math.floor(Date.now()/1e3);return t.exp>n}catch(t){return Dr.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};zr(Ur,"instance");let $r=Ur;function Br(){return $r.getInstance().getClient()}class Vr{static async generateToken(e,t,n,r=!1){try{if(!r){const e=_r.getSupabaseToken();if(e&&_r.isSupabaseTokenValid())return e}const a=Br(),{data:s,error:i}=await a.functions.invoke("validate-token",{body:{access_token:e,alias:t}});return i&&(i.message?.includes("401")||i.message?.includes("Unauthorized"))?(n?.(),null):s?.access_token&&s.access_token?(_r.setSupabaseToken(s.access_token),s.access_token):null}catch(a){return a instanceof Error&&(a.message.includes("401")||a.message.includes("Unauthorized"))&&n?.(),null}}}var qr=Object.defineProperty,Hr=(e,t,n)=>((e,t,n)=>t in e?qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class Wr{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=_r.getAccessToken(),t=_r.getSelectedAlias();if(!e||!t)return null;const n=await Vr.generateToken(e,t,this.onLogoutCallback||void 0,!1);return n?(_r.setSupabaseToken(n),n):null}catch(e){return null}finally{this.isRegenerating=!1}}}Hr(Wr,"isRegenerating",!1),Hr(Wr,"onLogoutCallback",null);class Kr{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(_r.clearAll(),window.location.href="/",!0)}static isAuthenticationError(e,t){if(401===e.status||401===e.statusCode)return!0;const n=t.toLowerCase();return["401","unauthorized","token","expired","invalid","authentication","login","session"].some(e=>n.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 Qr=Object.defineProperty;class Yr{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,n=e.message||e.toString();if(401===t||n.includes("401")||n.includes("Unauthorized")){this.isRetrying=!0;try{return await Wr.attemptRegeneration()?(this.isRetrying=!1,!0):(Kr.handleError(e),this.isRetrying=!1,!1)}catch(r){return Kr.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=_r.getAccessToken();return e?_r.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,n)=>{((e,t,n)=>{t in e?Qr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,t+"",n)})(Yr,"isRetrying",!1);var Jr=Object.defineProperty,Xr=(e,t,n)=>((e,t,n)=>t in e?Jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const Gr=new class{constructor(){Xr(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=Yr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=_r.getAccessToken();if(!a)throw new Error("Token Qualiex não encontrado");if(!n||""===n.trim())throw new Error("Alias da unidade é obrigatório para chamadas à API do Qualiex");const s=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{s.searchParams.append(e,t)});const i=await fetch(s.toString(),{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json",Accept:"application/json","un-alias":n}});if(!i.ok){const e=new Error(`API call failed: ${i.status} ${i.statusText}`);throw e.status=i.status,e.statusCode=i.status,e}return await i.json()}mapToQualiexUser(e){return{id:e.id||e.ID||"",userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível",placeId:null,placeName:e.placeName||null,roleId:e.roleId||void 0,roleName:e.roleName||void 0,companyId:e.companyId||void 0,companyName:e.companyName||void 0}}async fetchUsers(e,t){try{const n=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=n;if(n.data)r=n.data;else{if(!Array.isArray(n))return Dr.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=n}if(!Array.isArray(r))return Dr.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(n){if(await Yr.handleApiError(n))try{const n=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=n;if(n.data)r=n.data;else{if(!Array.isArray(n))return Dr.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=n}return Array.isArray(r)?r.map(this.mapToQualiexUser):(Dr.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return Dr.handleError(r instanceof Error?r:"Erro ao buscar usuários após renovação de token",!0),[]}const a=n instanceof Error?n.message:"Erro ao buscar usuários da API Qualiex";return Dr.handleError(a,!0),[]}}async fetchUserById(e,t,n){try{return(await this.fetchUsers(t,n)).find(t=>t.userId===e)||null}catch(r){return Dr.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async fetchActiveUsersMap(e,t){const n=await this.fetchUsers(e,t),r=new Map;return n.forEach(e=>{r.set(e.userId,e)}),r}async getUsers(e){const t=_r.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}},Zr={oauth:{authUrl:import.meta.env.VITE_OAUTH_AUTH_URL,clientId:import.meta.env.VITE_OAUTH_CLIENT_ID,responseType:"id_token token",scope:"openid profile email"}},ea={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},ta={debounceDelay:500},na=()=>{const e=window.location.origin;return e.includes("localhost")||e.includes("127.0.0.1")||e.includes("id-preview")||e.includes("lovable.dev")||import.meta.env.DEV},ra={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]};let aa={enableUserEnrichment:!1,enableUsersApi:!1,userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"};const sa=()=>aa,ia=e=>{aa={...aa,...e}},oa={success:{created:e=>`${e} criado com sucesso`,updated:e=>`${e} atualizado com sucesso`,deleted:e=>`${e} removido com sucesso`},error:{create:e=>`Erro ao criar ${e}`,update:e=>`Erro ao atualizar ${e}`,delete:e=>`Erro ao remover ${e}`,load:e=>`Erro ao carregar ${e}`}};function la(e,t){const n=sa(),r=t||n.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function ca(e,t){const n=sa(),r=t||n.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function da(e,t){const n=sa(),r=t||n.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function ua(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||la(e.idField),emailField:e.emailField||ca(e.idField),usernameField:e.usernameField||da(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:la(e),emailField:ca(e),usernameField:da(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const ma=new Map;class fa{static async fetchQualiexUsers(e,t){const n=sa(),r=`${t}_${e}`,a=ma.get(r);if(a&&Date.now()-a.timestamp<3e5)return a.users;let s;return s=n.fetchUsers?await n.fetchUsers(t,e):await Gr.fetchUsers(e,t),ma.set(r,{users:s,timestamp:Date.now()}),s}static extractUserIds(e,t){const n=new Set;for(const r of e)for(const e of t){const t=r[e.idField];t&&"string"==typeof t&&""!==t.trim()&&n.add(t)}return n}static indexUsers(e){const t=new Map;for(const n of e)n.id&&t.set(n.id,n),n.userId&&t.set(n.userId,n);return t}static enrichEntity(e,t,n){const r={...e};for(const a of t){const t=e[a.idField];if(!t)continue;const s=n.get(t);if(s){if(a.nameField){r[a.nameField]||(r[a.nameField]=s.userName||s.displayName||null)}if(a.emailField){r[a.emailField]||(r[a.emailField]=s.userEmail||null)}if(a.usernameField){r[a.usernameField]||(r[a.usernameField]=s.userName||null)}}}return r}static async enrichWithUserData(e,t){if(!Array.isArray(e)||0===e.length)return e;try{const n=sa();let r=null,a=null;if(n.getCompanyId){const e=n.getCompanyId();a=e instanceof Promise?await e:e}if(n.getAccessToken){const t=n.getAccessToken();if(!(t instanceof Promise?await t:t))return e}if(!r||!a){const t=_r.extractTokenData();if(!t)return e;r=r||t.alias,a=a||t.companyId}if(!r||!a)return e;const s=ua(t.userIdFields,t.userFieldsMapping);if(0===this.extractUserIds(e,s).size)return e;const i=await this.fetchQualiexUsers(r,a),o=this.indexUsers(i);return e.map(e=>this.enrichEntity(e,s,o))}catch(n){return Dr.handleError(n instanceof Error?n:new Error(`[QualiexEnrichment.${t.entityName}] Erro crítico`),!1),e}}static async enrichWithResponsibleNames(e,t){return this.enrichWithUserData(e,{entityName:t.entityName,userIdFields:["id_user"],userFieldsMapping:[{idField:"id_user",nameField:"responsible_name"}]})}}const pa=["responsible_name"],ha=e=>pa.includes(e);function ga(e,t,n){const r="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:n||"common"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"common",...e},{tableName:a,searchFields:s,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:c=!1}=r,d=()=>{if(!_r.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return Br().schema(o).from(a)},u=(e,t,n,r)=>{let a=d().select(i||"*",{count:"exact"});a=a.eq("is_removed",!1),Object.entries(r).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?a=a.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?a=a.not(e,"is",null):"is_null"===t.operator&&(a=a.is(e,null)):null!==t&&(a=a.eq(e,t)))}),a=((e,t)=>{if(t&&s.length>0){const n=s.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(n)}return e})(a,e);const o=t.includes(".");return o||ha(t)||(a=a.order(t,{ascending:"asc"===n})),{query:a,isForeignKey:o}},m=async(e,t,n,a,s)=>{const i=ua(r.userIdFields,r.userFieldsMapping).some(e=>e.nameField===t||e.emailField===t||e.usernameField===t),o=t.includes(".");if(ha(t)||o||i){const e={search:"",sortField:void 0,sortDirection:void 0,page:1,limit:500},i=await this.getAll(e);if(!i?.data?.length)return i;const c=await fa.enrichWithUserData(i.data,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping});let d;d=o?c.sort((e,r)=>{const a=t.split(".").reduce((e,t)=>e?.[t],e)||"",s=t.split(".").reduce((e,t)=>e?.[t],r)||"",i=String(a).localeCompare(String(s),"pt-BR");return"asc"===n?i:-i}):((e,t,n)=>[...e].sort((e,r)=>{const a=e[t]||"",s=r[t]||"",i=a.localeCompare(s,"pt-BR",{sensitivity:"base"});return"asc"===n?i:-i}))(c,t,n);const u=((e,t=1,n=25)=>{const r=(t-1)*n,a=r+n,s=e.slice(r,a);return{data:s,pagination:{currentPage:t,totalPages:Math.ceil(e.length/n),totalItems:s.length,totalCount:e.length,itemsPerPage:n,hasNextPage:a<e.length,hasPreviousPage:t>1}}})(d,a,s);return{data:u.data,currentPage:u.pagination.currentPage,totalPages:u.pagination.totalPages,totalItems:u.pagination.totalCount,itemsPerPage:u.pagination.itemsPerPage,hasNextPage:u.pagination.hasNextPage,hasPreviousPage:u.pagination.hasPreviousPage}}return await fa.enrichWithUserData(e,{entityName:l,userIdFields:r.userIdFields,userFieldsMapping:r.userFieldsMapping})};return{async getAll(e={}){const{search:t,sortField:n,sortDirection:s,page:i,limit:o,additionalFilters:d}=(e=>{const{search:t="",sortField:n="updated_at",sortDirection:r="desc",page:a=1,limit:s=25,...i}=e;return{search:t,sortField:n,sortDirection:r,page:a,limit:s,additionalFilters:i}})(e),{query:f}=u(t,n,s,d),p=((e,t,n)=>{const r=(t-1)*n,a=r+n-1;return e.range(r,a)})(f,i,o),{data:h,error:g,count:x}=await p;if(g)throw new Error(`Error fetching ${a}: ${g.message}`);let y=((e,t,n,r)=>{const a=Math.ceil((t||0)/r);return{data:e,currentPage:n,totalPages:a,totalItems:t||0,itemsPerPage:r,hasNextPage:n<a,hasPreviousPage:n>1}})(h||[],x,i,o);if((e=>{const t=sa();if(!c||!t.enableUserEnrichment||!l||0===e.length)return!1;const n=ua(r.userIdFields,r.userFieldsMapping);return e.some(e=>n.some(t=>e[t.idField]))})(y.data)){const e=await m(y.data,n,s,i,o);if(!Array.isArray(e))return e;y={...y,data:e}}return y},async getById(e){const{data:t,error:n}=await d().select(i||"*").eq("id",e).maybeSingle();if(n)throw new Error(`Error fetching ${a}: ${n.message}`);return t},async create(e){const t=Bt(e),n=Object.entries(t).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),{data:r,error:s}=await d().insert(n).select().single();if(s)throw new Error(`Error creating ${a}: ${s.message}`);if(!r)throw new Error(`No data returned from create ${a} operation`);return r},async update(e,t){const n={...Bt(t),updated_at:(new Date).toISOString()},{data:r,error:s}=await d().update(n).eq("id",e).select().single();if(s)throw new Error(`Error updating ${a}: ${s.message}`);if(!r)throw new Error(`No data returned from update ${a} operation`);return r},async delete(e){const t={is_removed:!0,updated_at:(new Date).toISOString()},{error:n}=await d().update(t).eq("id",e);if(n)throw new Error(`Error soft deleting ${a}: ${n.message}`)}}}const xa=()=>{_r.clearManualLogout()},ya=e=>e?.placeId||null,va=e=>e?.placeName||null,ba=e=>({placeId:ya(e),placeName:va(e)}),wa=class{static async initialize(){try{if(!_r.hasAllTokens()||!_r.areAllTokensValid())return _r.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null};const t=_r.getAccessToken(),n=_r.getIdToken();xa();const r=this.extractUserFromIdToken(n),a=this.extractCompaniesFromIdToken(n),s=this.extractAliasFromAccessToken(t),i=_r.extractTokenData(),o=i?.alias;let l=null;if(o&&a.some(e=>e.alias===o))l=o;else{const e=_r.getSelectedAlias(),t=e&&a.some(t=>t.alias===e);l=t?e:s||a[0]?.alias||null}!_r.isSupabaseTokenValid()&&l&&await Wr.attemptRegeneration();let c=null;if(l){const e=_r.getCompanyId(l),t=a.find(e=>e.alias===l);t&&(c={id:e||t.id,name:t.name,alias:t.alias})}let d=null,u=null;if(r?.id&&l){const t=_r.getCompanyId(l);if(t)try{const e=(await Gr.fetchActiveUsersMap(l,t)).get(r.id);if(e){const t=ba(e);d=t.placeId,u=t.placeName}}catch(e){}}return{isAuthenticated:!0,isLoading:!1,user:r,alias:l,companies:a,selectedUnit:c,userId:r?.id||null,userAlias:r?.id||null,placeId:d,placeName:u,activePlaceId:d,activePlaceName:u}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null}}}static async loginDev(){try{const e=Br(),{data:t,error:n}=await e.functions.invoke("dev-tokens",{body:{environment:"development"}});if(n)return!1;if(!t?.access_token||!t?.id_token)return!1;const r=new URL("/callback",window.location.origin);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=_r.generateOAuthState();_r.setOAuthState(e);const t=_r.generateOAuthNonce();_r.setOAuthNonce(t);const n=`${window.location.origin}/callback`,r=new URL(Zr.oauth.authUrl);r.searchParams.set("client_id",Zr.oauth.clientId),r.searchParams.set("response_type",Zr.oauth.responseType),r.searchParams.set("scope",Zr.oauth.scope),r.searchParams.set("redirect_uri",n),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),na(),window.location.href=r.toString()}static async processCallback(){try{if(_r.hasAllTokens()){if(!_r.getValidSupabaseToken()){_r.getAccessToken();await Wr.attemptRegeneration()}return!0}const e=new URLSearchParams(window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash),t=new URLSearchParams(window.location.search),n=n=>e.get(n)||t.get(n),r=n("access_token"),a=n("id_token"),s=n("error");if(s)throw new Error(`Erro OAuth: ${s}`);if(!r||!a)throw new Error("Tokens não encontrados na URL de callback");_r.setAccessToken(r),_r.setIdToken(a),xa();const i=this.extractAliasFromAccessToken(r);if(i)_r.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(a);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");_r.setSelectedAlias(e[0].alias)}if(!await Wr.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return _r.clearOAuthState(),_r.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){_r.setManualLogout(),_r.clearAll(),window.location.href="/login"}static decodeToken(e){return kr.parseJwtPayload(e)}static extractUserFromIdToken(e){const t=this.decodeToken(e);return t?{id:t.subNewId,email:t.email,name:t.name,identifier:t.identifier}:null}static extractCompaniesFromIdToken(e){const t=this.decodeToken(e);if(!t)return[];const n=[];return Object.keys(t).forEach(e=>{if(e.match(/^co(\d+)$/)&&"string"==typeof t[e]){const r=t[e].split(";");if(r.length>=4)n.push({id:r.length>7?r[7].trim():"",alias:r[0].trim(),name:r[3].trim()});else{const[r,a]=t[e].split("|");r&&a&&n.push({id:"",alias:r.trim(),name:a.trim()})}}}),n}static extractAliasFromAccessToken(e){const t=this.decodeToken(e);return t?.default||null}};Wr.setLogoutCallback(()=>{wa.logout()});let ja=wa;const Na=a(void 0),ka=({children:e})=>{const[t,a]=n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let s=null;try{s=rt()}catch{}const[l,c]=n(!1),[d,u]=n(0),m=i(e=>{a(t=>({...t,...e}))},[]),f=i(e=>{a(t=>({...t,isLoading:e}))},[]),p=i(()=>{a({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),h=i(async e=>{try{f(!0);const r=_r.getAccessToken();if(!r)return;const a=await Vr.generateToken(r,e.alias,void 0,!0);if(!a)return;_r.setSupabaseToken(a),_r.setSelectedAlias(e.alias);const i=_r.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||_r.getCompanyId(e.alias),c={id:l||e.id,name:e.name,alias:o};let d=null,u=null;if(t.user?.id&&o&&l)try{const e=(await Gr.fetchActiveUsersMap(o,l)).get(t.user.id);if(e){const t=ba(e);d=t.placeId,u=t.placeName}}catch(n){}m({alias:o,selectedUnit:c,placeId:d,placeName:u,activePlaceId:d,activePlaceName:u}),s&&(await s.clear(),await new Promise(e=>setTimeout(e,100)))}catch(n){}finally{f(!1)}},[m,s,f,t.user]),g=i(async()=>await ja.processCallback(),[]),x=i(async()=>{ja.logout(),p(),s&&await s.clear()},[p,s]),y=i(e=>{c(e)},[]),v=i(()=>{u(e=>e+1)},[]),b=i(()=>{u(e=>e+1)},[]);o(()=>{if(!t.isAuthenticated)return;let e=!0;const n=setInterval(()=>{e&&(_r.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(n)}},[t.isAuthenticated,x]),o(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await ja.initialize();if(!e)return;t&&t.isAuthenticated?m({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&&f(!1)}catch(t){e&&(Kr.handleError(t),f(!1))}})(),()=>{e=!1}},[m,f,x]);const w=r(()=>({...t,logout:x,processCallback:g,switchUnit:h,availableUnits:t.companies,isSearchVisible:l,setSearchVisible:y,clearSearch:v,refreshData:b}),[t.user,t.companies,t.alias,t.isAuthenticated,t.isLoading,t.selectedUnit,t.userId,t.userAlias,t.placeId,t.placeName,t.activePlaceId,t.activePlaceName,x,g,h,l,y,v,b]);return Mt.jsx(Na.Provider,{value:w,children:e})},Ca=()=>{const e=s(Na);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Sa({queryKey:e,service:t,entityName:a,searchFields:s,additionalFilters:o={},onSuccess:l}){const[c,d]=ot(),u=rt(),{alias:m,userId:f}=Ca(),p=i(t=>{const n=`${e}_${t}`,r=c.get(n);return r||(c.get(t)||"")},[c,e]),h=p("search"),g=p("sortField")||ea.sorting.defaultField,x=p("sortDirection")||ea.sorting.defaultDirection,y=parseInt(p("page")||"1"),b=parseInt(p("limit")||String(ea.pagination.defaultPageSize)),w=h,j=r(()=>({search:w,sortField:g,sortDirection:x,page:y,limit:b,...o}),[w,g,x,y,b,o]),N=i(()=>t.getAll(j),[t,j]),k=at({queryKey:[e,m,f,j],queryFn:N});if(!k)throw new Error(`useCrud: Query initialization failed for "${a}". Ensure QueryClientProvider is configured in your app root.`);const C=st({mutationFn:t.create,onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),v.success(oa.success.created(a)),l?.()},onError:e=>{v.error(`${oa.error.create(a)}: ${e.message}`)}}),S=st({mutationFn:({id:e,data:n})=>t.update(e,n),onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),v.success(oa.success.updated(a)),l?.()},onError:e=>{v.error(`${oa.error.update(a)}: ${e.message}`)}}),E=st({mutationFn:t.delete,onSuccess:()=>{u.invalidateQueries({queryKey:[e]}),v.success(oa.success.deleted(a))},onError:e=>{v.error(`${oa.error.delete(a)}: ${e.message}`)}}),I=i(t=>{const n={...Object.fromEntries(c)};Object.entries(t).forEach(([t,r])=>{const a=`${e}_${t}`;""===r||0===r?delete n[a]:n[a]=String(r)}),delete n.sortField,delete n.sortDirection,d(n)},[c,d,e]),T=i(e=>{I({search:e,page:1})},[I]),A=i(e=>{I({sortField:e,sortDirection:g===e&&"asc"===x?"desc":"asc",page:1})},[g,x,I]),P=i(e=>{I({page:e})},[I]),_=i(e=>{I({limit:e,page:1})},[I]),F=i(()=>{const t=Object.fromEntries(c),n=`${e}_`,r=Object.fromEntries(Object.entries(t).filter(([e])=>!e.startsWith(n)));d(r)},[d,c,e]),[R,D]=n([]),O=i(e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),z=i(()=>{const e=k?.data?.data.map(e=>e.id)||[];D(t=>t.length===e.length?[]:e)},[k?.data?.data]),L=i(()=>{D([])},[]),M=r(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&R.length===e.length},[R,k?.data?.data]),U=st({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,n)=>{u.invalidateQueries({queryKey:[e]}),v.success(`${n.length} ${a}(s) deletado(s) com sucesso`),L()},onError:e=>{v.error(`Erro ao deletar itens: ${e.message}`)}}),$=i((e,t)=>{const n=t?t(e):e;e.id?S.mutate({id:e.id,data:n}):C.mutate({...n,alias:m})},[m,C,S]);return{entities:k?.data?.data||[],pagination:{currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||ea.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:C?.isPending??!1,isUpdating:S?.isPending??!1,isDeleting:E?.isPending??!1,error:k?.error||null,searchTerm:h,sortField:g,sortDirection:x,currentPage:y,itemsPerPage:b,queryKey:e,createEntity:C.mutate,updateEntity:(e,t)=>S.mutate({id:e,data:t}),deleteEntity:E.mutate,save:$,handleSearch:T,handleSort:A,handlePageChange:P,handleItemsPerPageChange:_,clearFilters:F,refetch:k.refetch,selectedIds:R,selectItem:O,selectAll:z,clearSelection:L,isAllSelected:M,bulkDelete:U.mutate,isBulkDeleting:U.isPending}}function Ea(e){const t=ga({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:(n,r)=>Sa({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:n,onSuccess:r})}}const Ia=ut.Root,Ta=ut.Trigger,Aa=ut.Portal,Pa=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Overlay,{className:$t("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));Pa.displayName=ut.Overlay.displayName;const _a=e.forwardRef(({className:e,...t},n)=>Mt.jsxs(Aa,{children:[Mt.jsx(Pa,{}),Mt.jsx(ut.Content,{ref:n,className:$t("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));_a.displayName=ut.Content.displayName;const Fa=({className:e,...t})=>Mt.jsx("div",{className:$t("flex flex-col space-y-2 text-center sm:text-left bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-6 rounded-t-lg",e),...t});Fa.displayName="AlertDialogHeader";const Ra=({className:e,...t})=>Mt.jsx("div",{className:$t("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ra.displayName="AlertDialogFooter";const Da=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Title,{ref:n,className:$t("text-lg font-semibold",e),...t}));Da.displayName=ut.Title.displayName;const Oa=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Description,{ref:n,className:$t("text-sm text-muted-foreground",e),...t}));Oa.displayName=ut.Description.displayName;const za=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Action,{ref:n,className:$t(Kt(),e),...t}));za.displayName=ut.Action.displayName;const La=e.forwardRef(({className:e,...t},n)=>Mt.jsx(ut.Cancel,{ref:n,className:$t(Kt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));La.displayName=ut.Cancel.displayName;const Ma=({open:e,onOpenChange:t,item:r,onConfirm:a,entityName:s="item",isDeleting:i=!1,isBulk:l=!1,bulkCount:c})=>{const[d,u]=n("");o(()=>{e||u("")},[e]);const m=()=>{u(""),t(!1)},f=l?d===c?.toString():d===r?.title;return r?Mt.jsx(Ia,{open:e,onOpenChange:m,children:Mt.jsxs(_a,{className:"sm:max-w-[500px]",children:[Mt.jsx(Fa,{children:Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:Mt.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),Mt.jsx("div",{className:"flex-1",children:Mt.jsx(Da,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),Mt.jsx(Oa,{asChild:!0,children:Mt.jsxs("div",{className:"space-y-4",children:[Mt.jsxs("div",{className:"text-sm text-muted-foreground",children:[Mt.jsx("p",{className:"mb-2",children:l?Mt.jsx(Mt.Fragment,{children:"Você está prestes a excluir permanentemente:"}):Mt.jsxs(Mt.Fragment,{children:["Você está prestes a excluir permanentemente o ",s,":"]})}),Mt.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:Mt.jsx("p",{className:"font-medium text-foreground",children:l?`${r.title}`:r.title})})]}),Mt.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:Mt.jsxs("div",{className:"flex items-start space-x-2",children:[Mt.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:Mt.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),Mt.jsxs("div",{className:"text-sm text-orange-800",children:[Mt.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),Mt.jsx("p",{children:l?Mt.jsx(Mt.Fragment,{children:"Esta ação não pode ser desfeita. Os itens serão removidos permanentemente do sistema."}):Mt.jsxs(Mt.Fragment,{children:["Esta ação não pode ser desfeita. O ",s," será removido permanentemente do sistema."]})})]})]})}),Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{htmlFor:"confirmation",className:"text-sm font-medium",children:l?Mt.jsxs(Mt.Fragment,{children:["Para confirmar, digite o número de itens que serão removidos: ",Mt.jsx("strong",{children:c})]}):Mt.jsxs(Mt.Fragment,{children:["Para confirmar, digite ",Mt.jsxs("strong",{children:['"',r.title,'"']})," abaixo:"]})}),Mt.jsx(Jt,{id:"confirmation",type:l?"number":"text",value:d,onChange:e=>u(e.target.value),placeholder:l?`Digite: ${c}`:`Digite: ${r.title}`,className:"w-full"})]})]})}),Mt.jsxs(Ra,{children:[Mt.jsx(La,{onClick:m,children:"Cancelar"}),Mt.jsx(za,{onClick:()=>{if(!r)return;(l?d===c?.toString():d===r.title)&&(a(r),u(""),t(!1))},disabled:!f||i,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:i?"Removendo...":`Excluir ${s}`})]})]})}):null},Ua=e.forwardRef(({className:e,...t},n)=>Mt.jsx("table",{ref:n,className:$t("w-full caption-bottom text-sm",e),...t}));Ua.displayName="Table";const $a=e.forwardRef(({className:e,...t},n)=>Mt.jsx("thead",{ref:n,className:$t("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));$a.displayName="TableHeader";const Ba=e.forwardRef(({className:e,...t},n)=>Mt.jsx("tbody",{ref:n,className:$t("[&_tr:last-child]:border-0",e),...t}));Ba.displayName="TableBody";const Va=e.forwardRef(({className:e,...t},n)=>Mt.jsx("tfoot",{ref:n,className:$t("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));Va.displayName="TableFooter";const qa=e.forwardRef(({className:e,...t},n)=>Mt.jsx("tr",{ref:n,className:$t("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...t}));qa.displayName="TableRow";const Ha=e.forwardRef(({className:e,...t},n)=>Mt.jsx("th",{ref:n,className:$t("h-12 px-4 py-3 text-left align-middle font-medium text-muted-foreground bg-background border-b [&:has([role=checkbox])]:pr-0",e),...t}));Ha.displayName="TableHead";const Wa=e.forwardRef(({className:e,...t},n)=>Mt.jsx("td",{ref:n,className:$t("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));Wa.displayName="TableCell";const Ka=e.forwardRef(({className:e,...t},n)=>Mt.jsx("caption",{ref:n,className:$t("mt-4 text-sm text-muted-foreground",e),...t}));function Qa({rows:e=5,columns:t=4}){return Mt.jsx("div",{className:"w-full",children:Mt.jsxs("div",{className:"rounded-md border",children:[Mt.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:Mt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Mt.jsx(vr,{className:"h-4 w-24"},t))})}),Mt.jsx("div",{children:Array.from({length:e}).map((e,n)=>Mt.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:Mt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Mt.jsx(vr,{className:"h-4 w-20"},t))})},n))})]})})}function Ya({count:e=3}){return Mt.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>Mt.jsxs(Zt,{children:[Mt.jsxs(en,{children:[Mt.jsx(vr,{className:"h-4 w-3/4"}),Mt.jsx(vr,{className:"h-3 w-1/2"})]}),Mt.jsx(rn,{children:Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(vr,{className:"h-3 w-full"}),Mt.jsx(vr,{className:"h-3 w-2/3"})]})})]},t))})}function Ja({fields:e=4}){return Mt.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(vr,{className:"h-4 w-24"}),Mt.jsx(vr,{className:"h-10 w-full"})]},t)),Mt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Mt.jsx(vr,{className:"h-10 w-20"}),Mt.jsx(vr,{className:"h-10 w-20"})]})]})}function Xa(){return Mt.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[Mt.jsxs("div",{className:"flex items-center space-x-3",children:[Mt.jsx(vr,{className:"h-8 w-8 rounded-full"}),Mt.jsx(vr,{className:"h-6 w-32"})]}),Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsx(vr,{className:"h-8 w-8"}),Mt.jsx(vr,{className:"h-8 w-24"})]})]})}function Ga(){return Mt.jsx("div",{className:"w-64 border-r bg-muted/10",children:Mt.jsxs("div",{className:"p-4",children:[Mt.jsx(vr,{className:"h-8 w-32 mb-6"}),Mt.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>Mt.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[Mt.jsx(vr,{className:"h-4 w-4"}),Mt.jsx(vr,{className:"h-4 w-20"})]},t))})]})})}Ka.displayName="TableCaption";const Za={default:T,search:I,error:E};function es({icon:e,title:t,description:n,action:r,className:a,variant:s="default"}){const i=e?()=>e:Za[s];return Mt.jsxs("div",{className:$t("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[Mt.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:Mt.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),Mt.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),n&&Mt.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:n}),r&&Mt.jsx(Qt,{onClick:r.onClick,variant:"outline",children:r.label})]})}const ts=mt.Root,ns=mt.Trigger,rs=mt.Group,as=mt.Portal,ss=mt.Sub,is=mt.RadioGroup,os=e.forwardRef(({className:e,inset:t,children:n,...r},a)=>Mt.jsxs(mt.SubTrigger,{ref:a,className:$t("flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,Mt.jsx(A,{className:"ml-auto h-4 w-4"})]}));os.displayName=mt.SubTrigger.displayName;const ls=e.forwardRef(({className:e,...t},n)=>Mt.jsx(mt.SubContent,{ref:n,className:$t("z-50 min-w-[8rem] overflow-hidden border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));ls.displayName=mt.SubContent.displayName;const cs=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Mt.jsx(mt.Portal,{children:Mt.jsx(mt.Content,{ref:r,sideOffset:t,className:$t("z-[100] min-w-[8rem] overflow-hidden rounded-md border bg-white 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 dark:bg-gray-800 dark:border-gray-700",e),...n})}));cs.displayName=mt.Content.displayName;const ds=e.forwardRef(({className:e,inset:t,...n},r)=>Mt.jsx(mt.Item,{ref:r,className:$t("relative flex cursor-default select-none items-center px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));ds.displayName=mt.Item.displayName;const us=e.forwardRef(({className:e,children:t,checked:n,...r},a)=>Mt.jsxs(mt.CheckboxItem,{ref:a,className:$t("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:n,...r,children:[Mt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Mt.jsx(mt.ItemIndicator,{children:Mt.jsx(C,{className:"h-4 w-4"})})}),t]}));us.displayName=mt.CheckboxItem.displayName;const ms=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(mt.RadioItem,{ref:r,className:$t("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),...n,children:[Mt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Mt.jsx(mt.ItemIndicator,{children:Mt.jsx(P,{className:"h-2 w-2 fill-current"})})}),t]}));ms.displayName=mt.RadioItem.displayName;const fs=e.forwardRef(({className:e,inset:t,...n},r)=>Mt.jsx(mt.Label,{ref:r,className:$t("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));fs.displayName=mt.Label.displayName;const ps=e.forwardRef(({className:e,...t},n)=>Mt.jsx(mt.Separator,{ref:n,className:$t("-mx-1 my-1 h-px bg-muted",e),...t}));ps.displayName=mt.Separator.displayName;const hs=({className:e,...t})=>Mt.jsx("span",{className:$t("ml-auto text-xs tracking-widest opacity-60",e),...t});hs.displayName="DropdownMenuShortcut";const gs=({onEdit:e,onDelete:t,onToggleStatus:n,isActive:r=!0,canDelete:a=!0,customActions:s=[],renderAs:i})=>{const o=[];if(e){const t={icon:_,label:"Editar",onClick:e};o.push(t)}if(s.forEach(e=>{o.push(e)}),n){const e={icon:r?F:R,label:r?"Inativar":"Ativar",onClick:n};o.push(e)}if(a&&t){const e={icon:D,label:"Remover",onClick:t,destructive:!0};o.push(e)}return"dropdown"===i?Mt.jsx(Mt.Fragment,{children:o.map((e,t)=>Mt.jsxs(ds,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[Mt.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):Mt.jsx(Mt.Fragment,{children:o.map((e,t)=>Mt.jsxs(Qt,{variant:"ghost",size:"sm",onClick:e.onClick,className:"w-full justify-start px-2 py-1.5 text-sm font-normal h-7 "+(e.destructive?"text-destructive hover:text-destructive":""),children:[Mt.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},xs=({onEdit:e,onDelete:t,canDelete:n=!0,onToggleStatus:r,isActive:a=!0,customActions:s=[]})=>Mt.jsxs(ts,{children:[Mt.jsx(ns,{asChild:!0,children:Mt.jsx(Qt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:Mt.jsx(w,{size:12})})}),Mt.jsx(cs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:Mt.jsx(gs,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),r?.()},isActive:a,canDelete:n,customActions:s,renderAs:"dropdown"})})]}),ys=({contextMenu:e,onClose:t,onEdit:n,onDelete:r,onToggleStatus:a,customActions:s})=>(o(()=>{const n=()=>t();if(e)return document.addEventListener("click",n),()=>document.removeEventListener("click",n)},[e,t]),e?Mt.jsx("div",{className:"fixed bg-background border border-border rounded-md shadow-lg py-1 z-50 min-w-[120px]",style:{left:e.x,top:e.y},onClick:e=>e.stopPropagation(),children:Mt.jsx(gs,{onEdit:n?()=>{n(e.item),t()}:void 0,onDelete:r?()=>{r(e.item),t()}:void 0,onToggleStatus:a?()=>{a(e.item),t()}:void 0,isActive:e.item.is_actived,canDelete:!!r,customActions:s?s(e.item):[],renderAs:"context"})}):null),vs=l(({checked:e,onCheckedChange:t})=>Mt.jsx(On,{checked:e,onCheckedChange:t}),(e,t)=>e.checked===t.checked),bs=({manager:e,columns:t,onEdit:a,onView:s,onToggleStatus:i,onDelete:l,renderActions:c,customRowActions:d,enableBulkActions:u=!1})=>{const[m,f]=n(!1),[p,h]=n(null);o(()=>{const e=()=>f(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),o(()=>{const e=()=>h(null);if(p)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[p]);const g=r(()=>(()=>{t.length;let e=0;const n=t.map(t=>{if(t.width)return e+=t.width,{...t,calculatedWidth:t.width,isFixed:!0};{const n=t.minWidth||120,r=t.weight||1;return e+=n,{...t,calculatedWidth:n,weight:r,isFixed:!1}}});return e+=50,n.map(e=>e.isFixed?{...e,style:{width:`${e.calculatedWidth}px`}}:{...e,style:{minWidth:`${e.calculatedWidth}px`,width:`${e.calculatedWidth}px`}})})(),[t]);return m?e.isLoading?Mt.jsx(Ya,{count:3}):0===e.entities.length?Mt.jsx(es,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):Mt.jsxs("div",{className:"space-y-4",children:[e.entities.map(n=>Mt.jsx(Zt,{className:$t("overflow-hidden cursor-pointer hover:bg-muted/50",u&&e.selectedIds.includes(n.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),u?e.selectItem(n.id):a?.(n)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),h({x:e.clientX,y:e.clientY,item:n})},children:Mt.jsx(rn,{className:"p-4",children:Mt.jsxs("div",{className:"flex items-start gap-3",children:[u&&Mt.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:Mt.jsx(vs,{checked:e.selectedIds.includes(n.id),onCheckedChange:()=>e.selectItem(n.id)})}),Mt.jsxs("div",{className:"flex-1",children:[t.map(e=>Mt.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[Mt.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[e.header,":"]}),Mt.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:e.render?e.render(n):String(n[e.key]??"")})]},String(e.key))),(a||s||c)&&Mt.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:c?c(n):Mt.jsx(xs,{onEdit:a?()=>{a(n)}:void 0,onDelete:l?()=>l(n):void 0,onToggleStatus:i?()=>i(n):void 0,isActive:n.is_actived,customActions:d?d(n):[]})})]})]})})},n.id)),Mt.jsx(ys,{contextMenu:p,onClose:()=>h(null),onEdit:a,onDelete:l,onToggleStatus:i,customActions:d})]}):Mt.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?Mt.jsx(Qa,{rows:5,columns:t.length}):Mt.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:Mt.jsx("div",{className:"flex-1 overflow-auto",children:Mt.jsxs(Ua,{className:"table-auto",children:[Mt.jsxs("colgroup",{children:[u&&Mt.jsx("col",{style:{width:"50px"}}),g.map((e,t)=>Mt.jsx("col",{style:e.style},t)),Mt.jsx("col",{style:{width:"50px"}})]}),Mt.jsx($a,{children:Mt.jsxs(qa,{children:[u&&Mt.jsx(Ha,{className:"w-[50px]",children:Mt.jsx(vs,{checked:e.isAllSelected,onCheckedChange:e.selectAll})}),t.map(t=>{return Mt.jsx(Ha,{className:`${t.className||""} ${t.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:t.sortable?()=>e.handleSort(String(t.key)):void 0,children:Mt.jsxs("div",{className:"flex items-center "+(t.className?.includes("text-center")?"justify-center":""),children:[t.header,t.sortable&&(n=String(t.key),e.sortField!==n?Mt.jsx(O,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?Mt.jsx(z,{size:14,className:"ml-1"}):Mt.jsx(L,{size:14,className:"ml-1"}))]})},String(t.key));var n}),Mt.jsx(Ha,{className:"w-[50px] text-center",children:"Ações"})]})}),Mt.jsx(Ba,{children:0===e.entities.length?Mt.jsx(qa,{children:Mt.jsx(Wa,{colSpan:u?t.length+2:t.length+1,className:"h-32",children:Mt.jsx(es,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(n=>Mt.jsxs(qa,{className:$t("cursor-pointer hover:bg-muted/50",u&&e.selectedIds.includes(n.id)&&"bg-muted"),onClick:t=>{t.stopPropagation(),u?e.selectItem(n.id):a?.(n)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),h({x:e.clientX,y:e.clientY,item:n})},children:[u&&Mt.jsx(Wa,{onClick:e=>e.stopPropagation(),children:Mt.jsx(vs,{checked:e.selectedIds.includes(n.id),onCheckedChange:()=>e.selectItem(n.id)})}),t.map(e=>Mt.jsx(Wa,{className:e.className,children:e.render?e.render(n):String(n[e.key]??"")},String(e.key))),Mt.jsx(Wa,{className:"text-center",children:c?c(n):Mt.jsx(xs,{onEdit:a?()=>a(n):void 0,onDelete:l?()=>l(n):void 0,onToggleStatus:i?()=>i(n):void 0,isActive:n.is_actived,customActions:d?d(n):[]})})]},n.id))})]})})}),Mt.jsx(ys,{contextMenu:p,onClose:()=>h(null),onEdit:a,onDelete:l,onToggleStatus:i,customActions:d})]})};function ws(e,t,a,s){const[i,l]=n({}),[c,d]=n({}),u=r(()=>e,[e]),m=e=>e instanceof Date&&!isNaN(e.getTime()),f=e=>{if(void 0!==e.defaultValue)return e.defaultValue;switch(e.type){case"multiselect":return[];case"checkbox":return!1;case"number":return 0;case"date":default:return"";case"group":return{}}},p=(e,t)=>{if(e.computedValue&&"function"==typeof e.computedValue)try{return e.computedValue(t)}catch(n){return f(e)}},h=(e,t,n)=>{if(e.required&&(""===t||null==t||Array.isArray(t)&&0===t.length))return`${e.label} é obrigatório`;if(e.validation){let a;if("function"==typeof e.validation?a=e.validation:e.validation.custom&&"function"==typeof e.validation.custom&&(a=e.validation.custom),a)try{const e=a(t,n);if(e)return e}catch(r){}}};o(()=>{if(!s)return;const e=t=>{const n=[];return t.forEach(t=>{n.push(t),t.fields&&n.push(...e(t.fields))}),n},n=e(u),r={};n.forEach(e=>{let n;if(t&&void 0!==t[e.name]){if(n=t[e.name],null==n&&(n=""),"date"===e.type&&n)if("string"==typeof n){const e=new Date(n);m(e)&&(n=e.toISOString().split("T")[0])}else m(n)&&(n=n.toISOString().split("T")[0])}else n=f(e);r[e.name]=n}),n.forEach(e=>{const t=p(e,r);void 0!==t&&(r[e.name]=t)}),t&&Object.keys(t).forEach(e=>{n.find(t=>t.name===e)||void 0===t[e]||(r[e]=t[e])}),l(r),d({}),a&&a(r)},[u,t,a,s]);const g=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...g(e.fields))}),t},x=()=>{const e=g(u),t={};return e.forEach(e=>{const n=h(e,i[e.name],i);n&&(t[e.name]=n)}),d(t),0===Object.keys(t).length};return{formData:i,errors:c,updateField:(e,t)=>{l(n=>{const r={...n,[e]:t},s=((e,t)=>{let n={...t};const r=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...r(e.fields))}),t};return r(u).filter(t=>t.dependsOn===e).forEach(e=>{const t=p(e,n);void 0!==t&&(n={...n,[e.name]:t})}),n})(e,r);return a&&a(s),s}),c[e]&&d(t=>{const n={...t};return delete n[e],n});const n=g(u).find(t=>t.name===e);if(n){const r=h(n,t,i);r&&d(t=>({...t,[e]:r}))}},validateForm:x,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),x()&&e(i)}}}const js=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Ns=({value:e="#3b82f6",onChange:t,label:n})=>Mt.jsxs("div",{className:"space-y-2",children:[n&&Mt.jsx(Gt,{children:n}),Mt.jsxs(or,{children:[Mt.jsx(lr,{asChild:!0,children:Mt.jsxs(Qt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Mt.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),Mt.jsx(cr,{className:"w-64",children:Mt.jsxs("div",{className:"space-y-3",children:[Mt.jsxs("div",{children:[Mt.jsx(Gt,{htmlFor:"color-input",children:"Cor personalizada"}),Mt.jsx(Jt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),Mt.jsxs("div",{children:[Mt.jsx(Gt,{children:"Cores predefinidas"}),Mt.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:js.map(e=>Mt.jsx("button",{className:"h-8 w-8 rounded border-2 border-border hover:border-primary",style:{backgroundColor:e},onClick:()=>t?.(e),"aria-label":`Selecionar cor ${e}`},e))})]})]})})]})]}),ks=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsxs(ft.Root,{ref:r,className:$t("relative overflow-hidden",e),...n,children:[Mt.jsx(ft.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),Mt.jsx(Cs,{}),Mt.jsx(ft.Corner,{})]}));ks.displayName=ft.Root.displayName;const Cs=e.forwardRef(({className:e,orientation:t="vertical",...n},r)=>Mt.jsx(ft.ScrollAreaScrollbar,{ref:r,orientation:t,className:$t("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:Mt.jsx(ft.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Cs.displayName=ft.ScrollAreaScrollbar.displayName;const Ss={Star:Ae,Heart:Te,Home:Ie,User:Ee,Settings:Se,Mail:Ce,Phone:ke,Calendar:Ne,MapPin:je,Camera:we,Image:be,Music:ve,Video:ye,Book:xe,Bookmark:ge,Search:I,Filter:he,Edit:_,Trash2:D,Plus:pe,Minus:fe,Check:C,X:j,ChevronDown:N,ChevronUp:k,ChevronLeft:me,ChevronRight:A,ArrowUp:z,ArrowDown:L,ArrowLeft:ue,ArrowRight:de,Clock:ce,Bell:le,AlertCircle:E,Info:oe,HelpCircle:ie,Download:se,Upload:ae,Share:re,Copy:ne,Save:te,FileText:ee,Folder:Z,FolderOpen:G,Archive:X,Lock:J,Unlock:Y,Eye:Q,EyeOff:K,Shield:W,Key:H,Zap:q,Flame:V,Sparkles:B,Award:$,Trophy:U,Target:M},Es=({value:e="Star",onChange:t,label:r})=>{const[a,s]=n(""),i=Object.entries(Ss).filter(([e])=>e.toLowerCase().includes(a.toLowerCase())),o=Ss[e]||Ae;return Mt.jsxs("div",{className:"space-y-2",children:[r&&Mt.jsx(Gt,{children:r}),Mt.jsxs(or,{children:[Mt.jsx(lr,{asChild:!0,children:Mt.jsxs(Qt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Mt.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),Mt.jsx(cr,{className:"w-80",children:Mt.jsxs("div",{className:"space-y-3",children:[Mt.jsxs("div",{children:[Mt.jsx(Gt,{htmlFor:"icon-search",children:"Buscar ícone"}),Mt.jsx(Jt,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:a,onChange:e=>s(e.target.value)})]}),Mt.jsx(ks,{className:"h-48",children:Mt.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([n,r])=>Mt.jsx("button",{className:"p-2 rounded border-2 hover:border-primary "+(e===n?"border-primary bg-primary/10":"border-border"),onClick:()=>t?.(n),title:n,children:Mt.jsx(r,{className:"h-4 w-4"})},n))})})]})})]})]})};function Is({items:e,getItemValue:t,getItemLabel:n,...r}){const a=r.error?"string"==typeof r.error?r.error:!(r.error instanceof Error)||r.error.message:void 0,s={...r,multiple:!1,options:e,getOptionValue:t,getOptionLabel:n,error:a};return Mt.jsx(jr,{...s})}const Ts=(e={})=>{const{user:t,alias:n}=Ca(),r=sa(),{enabled:a=r.enableUsersApi}=e;return at({queryKey:["qualiex-users",n],queryFn:()=>Gr.getUsers(n),enabled:a&&!!n&&!!t,retry:2,retryDelay:1e3})},As=({value:e="",onChange:t,placeholder:n="Selecionar usuário",disabled:r,className:a,enabled:s})=>{const{data:i=[],isLoading:o,error:l}=Ts({enabled:s});return Mt.jsx(Is,{value:e,onChange:t,items:i,isLoading:o,error:l,getItemValue:e=>e.userId,getItemLabel:e=>e.userName,placeholder:n,searchPlaceholder:"Buscar usuário...",emptyMessage:"Nenhum usuário disponível",disabled:r,className:a})};function Ps({title:e,sections:a,initialData:s,onSubmit:o,onCancel:l,open:d,submitButtonText:u="Salvar",isLoading:m=!1,usersData:f}){const[p,h]=n(a?.[0]?.id||""),g=c(null),[x,y]=n(null),v=i(e=>{g.current=e,y(e)},[]),b=r(()=>a&&Array.isArray(a)?a.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[a]),{formData:w,errors:j,updateField:N,handleSubmit:k}=ws(b,s,void 0,d),C=r(()=>a&&Array.isArray(a)?a.map(e=>({...e,disabled:e.condition?!e.condition(w):e.disabled||!1})):[],[a,w]),S=r(()=>{const e=C.find(e=>e.id===p);if(e&&!e.disabled)return p;const t=C.find(e=>!e.disabled);return t?.id||p},[C,p]);t.useEffect(()=>{S!==p&&h(S)},[S,p]);const E=C.find(e=>e.id===S),I=e=>{const t=(e.computedValue,w[e.name]),n=void 0!==t?t:"",r=j[e.name];switch(e.type){case"group":return Mt.jsxs("div",{className:"space-y-2",children:[e.label,Mt.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>I(e))})]},e.name);case"user-select":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(As,{value:n||"",onChange:t=>N(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":""}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"textarea":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(zn,{id:e.name,value:n||"",onChange:t=>{N(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"select":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsxs(Sn,{value:String(n),onValueChange:t=>{N(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[Mt.jsx(Tn,{className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:Mt.jsx(In,{placeholder:e.placeholder})}),Mt.jsx(_n,{children:e.options?.map(e=>Mt.jsx(Rn,{value:e.value,children:e.label},e.value))})]}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"multiselect":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsxs(Gt,{htmlFor:e.name,children:[e.label,e.required&&Mt.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Mt.jsx(jr,{options:e.options||[],value:Array.isArray(n)?n:[],onChange:t=>N(e.name,t),placeholder:e.placeholder,disabled:e.disabled,error:r,popoverContainer:x,getOptionValue:e=>String(e.value),getOptionLabel:e=>e.label}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"date":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(Jt,{id:e.name,type:"date",value:String(n),onChange:t=>N(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:$t("w-full",r?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"color":return Mt.jsxs("div",{children:[Mt.jsxs(Gt,{htmlFor:e.name,children:[e.label," ",e.required&&Mt.jsx("span",{className:"text-destructive",children:"*"})]}),Mt.jsx(Jt,{id:e.name,type:"color",value:n||e.defaultValue||"#000000",onChange:t=>N(e.name,t.target.value),className:"h-10"}),r&&Mt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return Mt.jsxs("div",{children:[Mt.jsx(Ns,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"#3b82f6",onChange:t=>N(e.name,t)}),r&&Mt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return Mt.jsxs("div",{children:[Mt.jsx(Es,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"Star",onChange:t=>N(e.name,t)}),r&&Mt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"custom":if(!e.component)return null;const t=e.component;return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(t,{value:n,onChange:t=>{N(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,error:r,popoverContainer:x,...e.componentProps||{}}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"number":return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(Jt,{id:e.name,type:"number",value:null!=n?String(n):"",onChange:t=>{const n=t.target.value,r=""===n?null:Number(n);N(e.name,r)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,min:e.min,step:e.step||"1"}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);default:return Mt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Mt.jsx(Gt,{htmlFor:e.name,children:e.label}),Mt.jsx(Jt,{id:e.name,type:"text",value:n||"",onChange:t=>{N(e.name,t.target.value)},placeholder:e.placeholder,disabled:e.disabled,className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,readOnly:e.disabled}),r&&Mt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name)}},T=i(()=>{if(!E)return null;if(E.disabled)return Mt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Mt.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:Mt.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Mt.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),Mt.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),Mt.jsx("p",{className:"text-muted-foreground max-w-sm",children:'Complete as informações obrigatórias na seção "Informações Gerais" para acessar esta seção.'})]});if(E.component){const e=E.component;return Mt.jsx(e,{formData:w,updateField:N,errors:j,users:f,disabled:E.disabled})}return Mt.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:E.fields.map(I)})},[E,w,N,j,f,I]),A=Mt.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[C.length>1&&Mt.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:Mt.jsx("div",{className:"flex space-x-2",children:C.map(e=>Mt.jsx(Qt,{variant:S===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=C.find(t=>t.id===e);t&&!t.disabled&&h(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),Mt.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:m?Mt.jsx("div",{className:"flex items-center justify-center py-12",children:Mt.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):Mt.jsxs("form",{onSubmit:k(o),className:"space-y-3 md:space-y-4",children:[T(),Mt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Mt.jsx(Qt,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),Mt.jsx(Qt,{type:"submit",disabled:m,children:u})]})]})})]});return Mt.jsx(sn,{open:d,onOpenChange:e=>{!1===e&&!0===d&&l()},children:Mt.jsxs(un,{ref:v,className:"max-w-4xl max-h-[90vh] overflow-visible",children:[Mt.jsxs(mn,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[Mt.jsx(pn,{className:"text-white",children:e}),Mt.jsx(hn,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),A]})})}function _s({currentPage:e,totalPages:t,totalItems:n,itemsPerPage:r,onPageChange:a,onItemsPerPageChange:s,variant:i="full"}){const o=(e-1)*r+1,l=Math.min(e*r,n);return Mt.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[Mt.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&Mt.jsxs(Mt.Fragment,{children:[Mt.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),Mt.jsxs(Sn,{value:String(r),onValueChange:e=>s(Number(e)),children:[Mt.jsx(Tn,{className:"h-8 w-[70px]",children:Mt.jsx(In,{})}),Mt.jsxs(_n,{children:[Mt.jsx(Rn,{value:"10",children:"10"}),Mt.jsx(Rn,{value:"25",children:"25"}),Mt.jsx(Rn,{value:"50",children:"50"}),Mt.jsx(Rn,{value:"100",children:"100"})]})]})]})}),Mt.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[o,"-",l," de ",n," itens"]}),Mt.jsxs("div",{className:"flex items-center gap-1",children:[Mt.jsx(Qt,{variant:"outline",size:"sm",onClick:()=>a(1),disabled:1===e,className:"h-8 w-8 p-0",children:Mt.jsx(Pe,{size:16})}),Mt.jsx(Qt,{variant:"outline",size:"sm",onClick:()=>a(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:Mt.jsx(me,{size:16})}),Mt.jsxs("div",{className:"flex items-center gap-1 px-2",children:[Mt.jsx("span",{className:"text-sm font-medium",children:e}),Mt.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),Mt.jsx("span",{className:"text-sm font-medium",children:t})]}),Mt.jsx(Qt,{variant:"outline",size:"sm",onClick:()=>a(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:Mt.jsx(A,{size:16})}),Mt.jsx(Qt,{variant:"outline",size:"sm",onClick:()=>a(t),disabled:e===t,className:"h-8 w-8 p-0",children:Mt.jsx(_e,{size:16})})]})]})}function Fs({manager:e}){return Mt.jsx(_s,{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 Rs=({selectedCount:e,onClearSelection:t,onBulkDelete:n,customActions:r=[],isLoading:a=!1})=>Mt.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[Mt.jsxs("div",{className:"flex items-center gap-3",children:[Mt.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),Mt.jsxs(Qt,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[Mt.jsx(j,{size:14,className:"mr-1"}),"Limpar"]})]}),Mt.jsxs("div",{className:"flex items-center gap-2",children:[r.map((e,t)=>{const n=e.icon;return Mt.jsxs(Qt,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:a,className:"h-7",children:[n&&Mt.jsx(n,{size:14,className:"mr-1"}),e.label]},t)}),n&&Mt.jsxs(Qt,{variant:"destructive",size:"sm",onClick:n,disabled:a,className:"h-7",children:[Mt.jsx(D,{size:14,className:"mr-1"}),"Remover"]})]})]}),Ds={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Os={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},zs={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function Ls({children:e,direction:t="column",gap:n="md",align:r="stretch",justify:a="start",wrap:s=!1,className:i}){return Mt.jsx("div",{className:$t("flex","column"===t?"flex-col":"flex-row",Ds[n],Os[r],zs[a],s&&"flex-wrap",i),children:e})}function Ms({manager:e,filters:t,inline:n=!1}){const{isSearchVisible:r}=Ca(),a=e.searchTerm,s=Mt.jsxs(Mt.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&Mt.jsxs("div",{className:"relative flex-1",children:[Mt.jsx(I,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Mt.jsx(Jt,{placeholder:"Buscar...",value:e.searchTerm,onChange:t=>e.handleSearch(t.target.value),className:"pl-10"})]}),t.filter(e=>"select"===e.type&&e.options).map((e,t)=>Mt.jsxs("select",{value:e.value||"",onChange:t=>e.onChange?.(t.target.value),className:"h-10 px-3 rounded-md border border-input bg-background text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[e.placeholder&&Mt.jsx("option",{value:"",children:e.placeholder}),e.options.map(e=>Mt.jsx("option",{value:e.value,children:e.label},e.value))]},`select-${t}`)),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return Mt.jsx("div",{className:n?"":"w-full sm:w-auto",children:Mt.jsx(r,{...e.props})},`custom-${t}`)}),a&&Mt.jsxs(Qt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[Mt.jsx(j,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return n?Mt.jsx("div",{className:"flex items-center gap-2",children:s}):Mt.jsx(Ls,{direction:"column",gap:"md",className:"mb-6",children:Mt.jsx(Ls,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:s})})}function Us({manager:e,config:t,formSections:r,onSave:a,onToggleStatus:s,defaultSort:i}){e&&e.queryKey;const{setSearchVisible:l}=Ca(),[c,d]=ot(),[u,m]=n(!1),[f,p]=n(null),[h,g]=n({isOpen:!1,entityId:null,entityName:""}),[x,y]=n({isOpen:!1,count:0});o(()=>(l(!0),()=>{l(!1)}),[l]),o(()=>{if(i&&e){const t=`${e.queryKey}_sortField`,n=`${e.queryKey}_sortDirection`;if(!c.has(t)&&!c.has(n)){const e=Object.fromEntries(c);e[t]=i.column,e[n]=i.direction,d(e)}}},[]);return Mt.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[t.enableBulkActions&&e.selectedIds.length>0&&Mt.jsx(Rs,{selectedCount:e.selectedIds.length,onClearSelection:e.clearSelection,onBulkDelete:t.bulkActions&&t.bulkActions.length>0?void 0:()=>{y({isOpen:!0,count:e.selectedIds.length})},customActions:t.bulkActions,isLoading:e.isBulkDeleting}),Mt.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[Mt.jsxs("div",{className:"flex items-center gap-2",children:[Mt.jsxs(Qt,{onClick:()=>{t.onNew?t.onNew():(p(null),m(!0))},children:[Mt.jsx(pe,{size:16,className:"mr-2"}),"Novo"]}),t.customActions?.map((e,t)=>Mt.jsxs(Qt,{onClick:e.action,variant:e.variant||"outline",children:[e.icon&&Mt.jsx(e.icon,{size:16,className:"mr-2"}),e.label]},t))]}),t.filters&&t.filters.length>0&&Mt.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:Mt.jsx(Ms,{manager:e,filters:t.filters,inline:!0})})]}),Mt.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:t.customListView?Mt.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.customListView(e.entities,e)}):Mt.jsx(bs,{manager:e,columns:t.columns,onEdit:e=>{t.onEdit?t.onEdit(e):(p(e),m(!0))},onDelete:e=>{g({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:s,enableBulkActions:t.enableBulkActions,customRowActions:t.customRowActions})}),Mt.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:Mt.jsx(Fs,{manager:e})}),!t.useCustomRouting&&Mt.jsx(Ps,{open:u,title:f?`Editar ${t.entityName}`:`Novo ${t.entityName}`,sections:r,initialData:f||void 0,onSubmit:e=>{a(e),m(!1),p(null)},onCancel:()=>{m(!1),p(null)},isLoading:e.isLoading,submitButtonText:f?"Atualizar":"Criar"}),Mt.jsx(Ma,{open:h.isOpen,onOpenChange:()=>{g({isOpen:!1,entityId:null,entityName:""})},onConfirm:t=>{h.entityId&&(e.deleteEntity(h.entityId),g({isOpen:!1,entityId:null,entityName:""}))},item:h.entityId?{id:h.entityId,title:h.entityName}:void 0,entityName:t.entityName,isDeleting:e.isDeleting}),Mt.jsx(Ma,{open:x.isOpen,onOpenChange:()=>y({isOpen:!1,count:0}),onConfirm:()=>(e.bulkDelete?.(e.selectedIds),void y({isOpen:!1,count:0})),item:{id:"bulk",title:`${x.count} ${1===x.count?t.entityName:t.entityNamePlural}`},entityName:t.entityNamePlural,isDeleting:e.isBulkDeleting,isBulk:!0,bulkCount:x.count})]})}function $s(e){return({manager:t})=>{const{manager:n,config:r,onSave:a,onEdit:s,onToggleStatus:i}=e,o=t??n,l={entityName:r.entityName,entityNamePlural:r.entityNamePlural,filters:r.filters||[],columns:r.columns,cardFields:r.cardFields||[],enableBulkActions:r.enableBulkActions??!1,bulkActions:r.bulkActions||[],customActions:r.customActions,customRowActions:r.customRowActions,customListView:r.customListView,onEdit:s||r.onEdit};return Mt.jsx(Us,{manager:o,config:l,formSections:r.formSections,onSave:a,onToggleStatus:i,defaultSort:r.defaultSort})}}function Bs(e,t,n){return r=>{if(r.id){const t=n(r);e.updateEntity(r.id,t)}else{const n=t(r);e.createEntity(n)}}}function Vs(e,t,n={}){const r=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const n=t[e],a={key:e,header:Hs(e),label:Hs(e),...qs(e,n),sortable:!0,searchable:"string"==typeof n};r.push(a)}}),{title:e,columns:r,searchPlaceholder:`Buscar ${e.toLowerCase()}...`,itemsPerPage:10,enableCreate:!0,enableEdit:!0,enableDelete:!0,enableSearch:!0,enableFilters:!1,...n}}function qs(e,t){const n=e.toLowerCase();return n.includes("email")?{type:"email",required:!0}:n.includes("phone")||n.includes("tel")?{type:"tel"}:n.includes("description")||n.includes("content")||n.includes("notes")?{type:"textarea"}:n.includes("status")||n.includes("type")||n.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function Hs(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Ws={user:{title:"Usuários",searchPlaceholder:"Buscar usuários...",enableDelete:!1},product:{title:"Produtos",searchPlaceholder:"Buscar produtos...",enableFilters:!0},order:{title:"Pedidos",searchPlaceholder:"Buscar pedidos...",enableCreate:!1},category:{title:"Categorias",searchPlaceholder:"Buscar categorias...",itemsPerPage:20}};function Ks(e,t,n={}){const r=Ws[e];return Vs(r.title,t,{...r,...n})}const Qs=({children:e})=>{const{isAuthenticated:n,isLoading:r}=Ca();if(t.useEffect(()=>{if(!n)return;const e=()=>{_r.areAllTokensValid()||ja.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),t.useEffect(()=>{if(r)return;if(n)return;if(_r.isManualLogout())return void(window.location.href="/login");const e=new URLSearchParams(window.location.search),t=window.location.hash.startsWith("#")?window.location.hash.substring(1):window.location.hash,a=new URLSearchParams(t);if(e.has("access_token")||a.has("access_token"))return;const s=na();(async()=>{s?await ja.loginDev():ja.loginProd()})()},[n,r]),r)return Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-xl font-semibold",children:"Carregando..."})}),Mt.jsxs(rn,{className:"text-center",children:[Mt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Mt.jsx("p",{className:"text-muted-foreground",children:"Verificando autenticação..."})]})]})});if(!n){if(new URLSearchParams(window.location.search).has("access_token")||new URLSearchParams(window.location.hash.substring(1)).has("access_token"))return Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-xl font-semibold",children:"Processando..."})}),Mt.jsxs(rn,{className:"text-center",children:[Mt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Mt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(_r.areAllTokensValid())return Mt.jsx(Mt.Fragment,{children:e})}catch{}return Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-xl font-semibold",children:"Iniciando..."})}),Mt.jsxs(rn,{className:"text-center",children:[Mt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Mt.jsx("p",{className:"text-muted-foreground",children:na()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return Mt.jsx(Mt.Fragment,{children:e})},Ys=f("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Js=e.forwardRef(({className:e,variant:t,...n},r)=>Mt.jsx("div",{ref:r,role:"alert",className:$t(Ys({variant:t}),e),...n}));Js.displayName="Alert";const Xs=e.forwardRef(({className:e,...t},n)=>Mt.jsx("h5",{ref:n,className:$t("mb-1 font-medium leading-none tracking-tight",e),...t}));Xs.displayName="AlertTitle";const Gs=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,className:$t("text-sm [&_p]:leading-relaxed",e),...t}));Gs.displayName="AlertDescription";const Zs=()=>{const{processCallback:e}=Ca(),[t,r]=n(null),[a,s]=n(!1);o(()=>{(async()=>{try{if(await e()){window.history.replaceState({},document.title,"/");const e=localStorage.getItem("auth_return_url");e?(localStorage.removeItem("auth_return_url"),window.location.href=e):window.location.href="/"}else r("Falha na autenticação. Tente novamente.")}catch(t){r(t?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e]);const i=async()=>{s(!0),r(null);try{await e()||r("Falha na autenticação. Tente novamente.")}catch(t){r(t?.message||"Erro ao tentar novamente.")}finally{s(!1)}},l=()=>{window.location.href="/"};return t?Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsxs(tn,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[Mt.jsx(E,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),Mt.jsxs(rn,{className:"space-y-4",children:[Mt.jsx(Js,{variant:"destructive",children:Mt.jsx(Gs,{children:t})}),Mt.jsx("div",{className:"text-sm text-muted-foreground",children:Mt.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),Mt.jsxs("div",{className:"flex gap-2",children:[Mt.jsx(Qt,{onClick:i,disabled:a,className:"flex-1",children:a?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx($n,{size:"sm",className:"mr-2"}),"Tentando..."]}):Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),Mt.jsx(Qt,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),Mt.jsxs(rn,{className:"text-center",children:[Mt.jsx("div",{className:"flex justify-center mb-4",children:Mt.jsx($n,{size:"lg"})}),Mt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},ei=()=>Mt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Mt.jsxs(Zt,{className:"w-full max-w-md",children:[Mt.jsx(en,{className:"text-center",children:Mt.jsx(tn,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),Mt.jsxs(rn,{className:"text-center space-y-4",children:[Mt.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),Mt.jsx(Qt,{onClick:async()=>{na()?await ja.loginDev():ja.loginProd()},className:"w-full",size:"lg",children:na()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),ti=a(void 0);function ni({children:e}){const[t,r]=n({});return Mt.jsx(ti.Provider,{value:{metadata:t,setMetadata:r,clearMetadata:()=>r({})},children:e})}function ri(){const e=s(ti);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function ai(e){const{setMetadata:t,clearMetadata:n}=ri();o(()=>(t(e),()=>n()),[e.title,e.subtitle,t,n])}function si(e){return{queryClient:e.queryClient||new it({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const ii=pt.Root,oi=e.forwardRef(({className:e,...t},n)=>Mt.jsx(pt.Item,{ref:n,className:$t("border-b",e),...t}));oi.displayName="AccordionItem";const li=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsx(pt.Header,{className:"flex",children:Mt.jsxs(pt.Trigger,{ref:r,className:$t("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,Mt.jsx(N,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));li.displayName=pt.Trigger.displayName;const ci=e.forwardRef(({className:e,children:t,...n},r)=>Mt.jsx(pt.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:Mt.jsx("div",{className:$t("pb-4 pt-0",e),children:t})}));ci.displayName=pt.Content.displayName;const di=ht.Root,ui=e.forwardRef(({className:e,...t},n)=>Mt.jsx(gt.Root,{ref:n,className:$t("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));ui.displayName=gt.Root.displayName;const mi=e.forwardRef(({className:e,...t},n)=>Mt.jsx(gt.Image,{ref:n,className:$t("aspect-square h-full w-full",e),...t}));mi.displayName=gt.Image.displayName;const fi=e.forwardRef(({className:e,...t},n)=>Mt.jsx(gt.Fallback,{ref:n,className:$t("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));fi.displayName=gt.Fallback.displayName;const pi=e.forwardRef(({...e},t)=>Mt.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));pi.displayName="Breadcrumb";const hi=e.forwardRef(({className:e,...t},n)=>Mt.jsx("ol",{ref:n,className:$t("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));hi.displayName="BreadcrumbList";const gi=e.forwardRef(({className:e,...t},n)=>Mt.jsx("li",{ref:n,className:$t("inline-flex items-center gap-1.5",e),...t}));gi.displayName="BreadcrumbItem";const xi=e.forwardRef(({asChild:t,className:n,...r},a)=>{const s=t?e.Fragment:"a";return Mt.jsx(s,{ref:a,className:$t("transition-colors hover:text-foreground",n),...r})});xi.displayName="BreadcrumbLink";const yi=e.forwardRef(({className:e,...t},n)=>Mt.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:$t("font-normal text-foreground",e),...t}));yi.displayName="BreadcrumbPage";const vi=({children:e,className:t,...n})=>Mt.jsx("li",{role:"presentation","aria-hidden":"true",className:$t("[&>svg]:size-3.5",t),...n,children:e??Mt.jsx(A,{})});vi.displayName="BreadcrumbSeparator";const bi=({className:e,...t})=>Mt.jsxs("span",{role:"presentation","aria-hidden":"true",className:$t("flex h-9 w-9 items-center justify-center",e),...t,children:[Mt.jsx(Re,{className:"h-4 w-4"}),Mt.jsx("span",{className:"sr-only",children:"More"})]});function wi(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function ji(e){return(t,n)=>{let r;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){const t=e.defaultFormattingWidth||e.defaultWidth,a=n?.width?String(n.width):t;r=e.formattingValues[a]||e.formattingValues[t]}else{const t=e.defaultWidth,a=n?.width?String(n.width):e.defaultWidth;r=e.values[a]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}function Ni(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(o)?function(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n;return}(o,e=>e.test(i)):function(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n;return}(o,e=>e.test(i));let c;c=e.valueCallback?e.valueCallback(l):l,c=n.valueCallback?n.valueCallback(c):c;return{value:c,rest:t.slice(i.length)}}}bi.displayName="BreadcrumbEllipsis";const ki={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"}},Ci={date:wi({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:wi({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:wi({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Si={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"},Ei={ordinalNumber:(e,t)=>{const n=Number(e);return"week"===t?.unit?n+"ª":n+"º"},era:ji({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:ji({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:ji({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:ji({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:ji({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"})},Ii={ordinalNumber:(Ti={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(Ti.matchPattern);if(!n)return null;const r=n[0],a=e.match(Ti.parsePattern);if(!a)return null;let s=Ti.valueCallback?Ti.valueCallback(a[0]):a[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:Ni({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:Ni({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:Ni({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:Ni({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:Ni({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"})};var Ti;const Ai={code:"pt-BR",formatDistance:(e,t,n)=>{let r;const a=ki[e];return r="string"==typeof a?a:1===t?a.one:a.other.replace("{{count}}",String(t)),n?.addSuffix?n.comparison&&n.comparison>0?"em "+r:"há "+r:r},formatLong:Ci,formatRelative:(e,t,n,r)=>{const a=Si[e];return"function"==typeof a?a(t):a},localize:Ei,match:Ii,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Pi({className:e,classNames:t,showOutsideDays:n=!0,...r}){return Mt.jsx(xt,{showOutsideDays:n,className:$t("p-3",e),locale:Ai,classNames:{months:"flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",month:"space-y-4",caption:"flex justify-center pt-1 relative items-center",caption_label:"text-sm font-medium",nav:"space-x-1 flex items-center",nav_button:$t(Kt({variant:"outline"}),"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-y-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:"h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",day:$t(Kt({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_end:"day-range-end",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({...e})=>Mt.jsx(me,{className:"h-4 w-4"}),IconRight:({...e})=>Mt.jsx(A,{className:"h-4 w-4"})},...r})}Pi.displayName="Calendar";const _i=yt.Root,Fi=yt.CollapsibleTrigger,Ri=yt.CollapsibleContent;const Di={Root:function({children:e,className:t}){return Mt.jsx("div",{className:$t("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:n}){return Mt.jsx(Zt,{className:$t("transition-colors",t&&"cursor-pointer hover:bg-muted/50",n),onClick:t,children:Mt.jsx(rn,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:n}){return Mt.jsxs("div",{className:$t("flex justify-between items-center text-sm",n),children:[Mt.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),Mt.jsx("span",{className:"text-foreground",children:t})]})}};function Oi({value:e,onChange:t,activeLabel:n="Ativo",inactiveLabel:r="Inativo",allLabel:a="[Todos]",placeholder:s="Status",className:i="w-full sm:w-[180px]"}){const o=[{id:"active",name:n},{id:"inactive",name:r},{id:"all",name:a}];return Mt.jsx(Is,{value:e,onChange:e=>t(e),items:o,getItemValue:e=>e.id,getItemLabel:e=>e.name,placeholder:s,className:i})}const zi={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))]"},Li={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Mi({children:e,cols:t="auto-fit",gap:n="md",className:r}){return Mt.jsx("div",{className:$t("grid",zi[t],Li[n],r),children:e})}const Ui=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase();function $i({multiple:e,options:t,value:a,onChange:s,getOptionValue:i,getOptionLabel:o,placeholder:l,label:c,icon:d,emptyMessage:u,searchPlaceholder:m,disabled:f,required:p,className:h,sortOptions:g,maxDisplayedBadges:x,popoverContainer:y,onOpen:v,onClose:b}){const[w,k]=n(!1),[S,E]=n(""),I=r(()=>a?Array.isArray(a)?a:[a]:[],[a]),T=r(()=>{if(!y)return;let e=y,t=0;try{for(;e&&t<3;){const n=window.getComputedStyle(e),r=n.overflowY||n.overflow;if(!r||"visible"===r||"unset"===r)break;e=e.parentElement,t++}}catch{}return e??void 0},[y]),A=r(()=>{const e=t.map(e=>({original:e,value:i(e),label:o(e)}));return g?e.sort((e,t)=>e.label.localeCompare(t.label,"pt-BR",{sensitivity:"base"})):e},[t,i,o,g]),P=r(()=>{if(!S)return A;const e=Ui(S);return A.filter(t=>Ui(t.label).includes(e))},[A,S]),_=r(()=>A.filter(e=>I.includes(e.value)),[A,I]),F=(t,n)=>{n.preventDefault(),n.stopPropagation(),s&&s(e?I.filter(e=>e!==t):"")},R=x?_.slice(0,x):_,D=x&&_.length>x?_.length-x:0;return Mt.jsxs("div",{className:$t("space-y-2",h),children:[c&&Mt.jsxs(Gt,{children:[c,p&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsxs(or,{open:w,onOpenChange:e=>{k(e),e?v?.():(E(""),b?.())},modal:!1,children:[Mt.jsx(lr,{asChild:!0,children:Mt.jsxs(Qt,{variant:"outline",role:"combobox","aria-expanded":w,disabled:f,className:$t("w-full justify-between min-h-10 h-auto",0===_.length&&"text-muted-foreground"),children:[0===_.length?Mt.jsxs("span",{className:"flex items-center gap-2",children:[d&&Mt.jsx(d,{className:"h-4 w-4"}),l]}):e?Mt.jsxs("div",{className:"flex flex-wrap gap-1.5 flex-1 mr-2",children:[R.map(e=>Mt.jsxs(Mn,{variant:"secondary",className:"gap-1 pr-1",children:[e.label,Mt.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&&F(e.value,t)},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>F(e.value,t),children:Mt.jsx(j,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},e.value)),D>0&&Mt.jsxs(Mn,{variant:"outline",className:"gap-1",children:["+",D]})]}):Mt.jsxs("span",{className:"flex items-center gap-2",children:[d&&Mt.jsx(d,{className:"h-4 w-4"}),_[0]?.label]}),Mt.jsx(N,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),Mt.jsx(cr,{className:"w-full p-0 bg-popover z-[60]",align:"start",container:T,collisionBoundary:T,children:Mt.jsxs(dr,{children:[Mt.jsx(mr,{placeholder:m,value:S,onChange:e=>E(e.target.value)}),Mt.jsx(fr,{children:0===t.length?Mt.jsx(pr,{children:u}):0===P.length?Mt.jsx(pr,{children:"Nenhum item encontrado."}):Mt.jsx(hr,{children:P.map(t=>Mt.jsxs(xr,{value:t.value,onSelect:()=>(t=>{if(s)if(e){const e=I.includes(t)?I.filter(e=>e!==t):[...I,t];s(e)}else s(t),k(!1)})(t.value),className:"cursor-pointer",children:[Mt.jsx(C,{className:$t("mr-2 h-4 w-4",I.includes(t.value)?"opacity-100":"opacity-0")}),t.label]},t.value))})})]})})]})]})}function Bi({multiple:e=!1,options:t=[],value:n,onChange:r,getOptionValue:a=e=>e.value,getOptionLabel:s=e=>e.label,placeholder:i="Selecione...",label:o,icon:l,emptyMessage:c="Nenhum item disponível.",searchPlaceholder:d="Buscar...",disabled:u=!1,required:m=!1,isLoading:f=!1,error:p,className:h,sortOptions:g=!0,maxDisplayedBadges:x,popoverContainer:y,onOpen:v,onClose:b}){if(f)return Mt.jsxs("div",{className:$t("space-y-2",h),children:[o&&Mt.jsxs(Gt,{children:[o,m&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsx(vr,{className:"h-10 w-full"})]});const w="string"==typeof p?p:p?"Erro ao carregar dados":void 0;return w?Mt.jsxs("div",{className:$t("space-y-2",h),children:[o&&Mt.jsxs(Gt,{children:[o,m&&Mt.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),Mt.jsxs("div",{className:"flex items-center gap-2 p-3 border border-destructive rounded-md bg-destructive/10 text-destructive",children:[Mt.jsx(E,{className:"h-4 w-4"}),Mt.jsx("span",{className:"text-sm",children:w})]})]}):Mt.jsx($i,{multiple:e,options:t,value:n||(e?[]:""),onChange:r,getOptionValue:a,getOptionLabel:s,placeholder:i,label:o,icon:l,emptyMessage:c,searchPlaceholder:d,disabled:u,required:m,className:h,sortOptions:g,maxDisplayedBadges:x,popoverContainer:y,onOpen:v,onClose:b})}function Vi({items:e,maxItems:t=3,className:n}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,Mt.jsx(pi,{className:n})}function qi(){const e=lt();return(()=>{const t=e.pathname.split("/").filter(Boolean),n=[{label:"Exemplos",href:"/"}];let r="";return t.forEach((e,a)=>{r+=`/${e}`;const s=a===t.length-1,i=e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ");n.push({label:i,href:s?void 0:r,isCurrentPage:s})}),n})()}const Hi=({className:e,...t})=>Mt.jsx("nav",{role:"navigation","aria-label":"pagination",className:$t("mx-auto flex w-full justify-center",e),...t});Hi.displayName="Pagination";const Wi=e.forwardRef(({className:e,...t},n)=>Mt.jsx("ul",{ref:n,className:$t("flex flex-row items-center gap-1",e),...t}));Wi.displayName="PaginationContent";const Ki=e.forwardRef(({className:e,...t},n)=>Mt.jsx("li",{ref:n,className:$t("",e),...t}));Ki.displayName="PaginationItem";const Qi=({className:e,isActive:t,size:n="icon",...r})=>Mt.jsx("a",{"aria-current":t?"page":void 0,className:$t(Kt({variant:t?"outline":"ghost",size:n}),e),...r});Qi.displayName="PaginationLink";const Yi=({className:e,...t})=>Mt.jsxs(Qi,{"aria-label":"Go to previous page",size:"default",className:$t("gap-1 pl-2.5",e),...t,children:[Mt.jsx(me,{className:"h-4 w-4"}),Mt.jsx("span",{children:"Previous"})]});Yi.displayName="PaginationPrevious";const Ji=({className:e,...t})=>Mt.jsxs(Qi,{"aria-label":"Go to next page",size:"default",className:$t("gap-1 pr-2.5",e),...t,children:[Mt.jsx("span",{children:"Next"}),Mt.jsx(A,{className:"h-4 w-4"})]});Ji.displayName="PaginationNext";const Xi=({className:e,...t})=>Mt.jsxs("span",{"aria-hidden":!0,className:$t("flex h-9 w-9 items-center justify-center",e),...t,children:[Mt.jsx(Re,{className:"h-4 w-4"}),Mt.jsx("span",{className:"sr-only",children:"More pages"})]});Xi.displayName="PaginationEllipsis";const Gi=e.forwardRef(({className:e,value:t,...n},r)=>Mt.jsx(vt.Root,{ref:r,className:$t("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:Mt.jsx(vt.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Gi.displayName=vt.Root.displayName;const Zi=e.forwardRef(({className:e,...t},n)=>Mt.jsx(bt.Root,{className:$t("grid gap-2",e),...t,ref:n}));Zi.displayName=bt.Root.displayName;const eo=e.forwardRef(({className:e,...t},n)=>Mt.jsx(bt.Item,{ref:n,className:$t("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:Mt.jsx(bt.Indicator,{className:"flex items-center justify-center",children:Mt.jsx(P,{className:"h-2.5 w-2.5 fill-current text-current"})})}));eo.displayName=bt.Item.displayName;const to=e.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>Mt.jsx(wt.Root,{ref:a,decorative:n,orientation:t,className:$t("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));to.displayName=wt.Root.displayName;const no=We.Root,ro=We.Trigger,ao=We.Close,so=We.Portal,io=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Overlay,{className:$t("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));io.displayName=We.Overlay.displayName;const oo=f("fixed z-50 gap-4 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 data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t 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"}}),lo=e.forwardRef(({side:e="right",className:t,children:n,...r},a)=>Mt.jsxs(so,{children:[Mt.jsx(io,{}),Mt.jsxs(We.Content,{ref:a,className:$t(oo({side:e}),t),...r,children:[n,Mt.jsxs(We.Close,{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-secondary",children:[Mt.jsx(j,{className:"h-4 w-4"}),Mt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));lo.displayName=We.Content.displayName;const co=({className:e,...t})=>Mt.jsx("div",{className:$t("flex flex-col space-y-2 text-center sm:text-left",e),...t});co.displayName="SheetHeader";const uo=({className:e,...t})=>Mt.jsx("div",{className:$t("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});uo.displayName="SheetFooter";const mo=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Title,{ref:n,className:$t("text-lg font-semibold text-foreground",e),...t}));mo.displayName=We.Title.displayName;const fo=e.forwardRef(({className:e,...t},n)=>Mt.jsx(We.Description,{ref:n,className:$t("text-sm text-muted-foreground",e),...t}));fo.displayName=We.Description.displayName;const po=jt.Provider,ho=jt.Root,go=jt.Trigger,xo=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Mt.jsx(jt.Content,{ref:r,sideOffset:t,className:$t("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),...n}));xo.displayName=jt.Content.displayName;const yo="sidebar:state",vo=e.createContext(null);function bo(){const t=e.useContext(vo);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const wo=e.forwardRef(({defaultOpen:t=!0,open:n,onOpenChange:r,className:a,style:s,children:i,...o},l)=>{const[c,d]=e.useState(!1);e.useEffect(()=>{const e=()=>d(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[u,m]=e.useState(!1),[f,p]=e.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(yo);return null!==e?"true"===e:t}return t}),h=n??f,g=e.useCallback(e=>{const t="function"==typeof e?e(h):e;r?r(t):p(t),"undefined"!=typeof window&&localStorage.setItem(yo,String(t))},[r,h]),x=e.useCallback(()=>c?m(e=>!e):g(e=>!e),[c,g,m]);e.useEffect(()=>{const e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),x())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[x]);const y=h?"expanded":"collapsed",v=e.useMemo(()=>({state:y,open:h,setOpen:g,isMobile:c,openMobile:u,setOpenMobile:m,toggleSidebar:x}),[y,h,g,c,u,m,x]);return Mt.jsx(vo.Provider,{value:v,children:Mt.jsx(po,{delayDuration:0,children:Mt.jsx("div",{className:$t("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar sidebar-container",a),style:{"--sidebar-width":"16rem","--sidebar-width-icon":"4.5rem",...s},ref:l,...o,children:i})})})});wo.displayName="SidebarProvider";const jo=e.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:a,...s},i)=>{const{isMobile:o,state:l,openMobile:c,setOpenMobile:d}=bo();return"none"===n?Mt.jsx("div",{className:$t("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:a}):o?Mt.jsx(no,{open:c,onOpenChange:d,...s,children:Mt.jsxs(lo,{"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:[Mt.jsx(mo,{className:"sr-only",children:"Menu de Navegação"}),Mt.jsx("div",{className:"flex h-full w-full flex-col",children:a})]})}):Mt.jsxs("div",{ref:i,className:"group peer hidden md:block text-sidebar-foreground","data-state":l,"data-collapsible":"collapsed"===l?n:"","data-variant":t,"data-side":e,children:[Mt.jsx("div",{className:$t("duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===t||"inset"===t?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),Mt.jsx("div",{className:$t("duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex","left"===e?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===t||"inset"===t?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:Mt.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow bg-white",children:a})})]})});jo.displayName="Sidebar";const No=e.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:a}=bo();return Mt.jsxs(Qt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:$t("h-7 w-7",e),onClick:e=>{t?.(e),a()},...n,children:[Mt.jsx(De,{}),Mt.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});No.displayName="SidebarTrigger";const ko=e.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=bo();return Mt.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:$t("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});ko.displayName="SidebarRail";const Co=e.forwardRef(({className:e,...t},n)=>Mt.jsx("main",{ref:n,className:$t("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));Co.displayName="SidebarInset";const So=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Jt,{ref:n,"data-sidebar":"input",className:$t("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));So.displayName="SidebarInput";const Eo=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"header",className:$t("flex flex-col gap-2 p-2",e),...t}));Eo.displayName="SidebarHeader";const Io=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"footer",className:$t("flex flex-col gap-2 p-2",e),...t}));Io.displayName="SidebarFooter";const To=e.forwardRef(({className:e,...t},n)=>Mt.jsx(to,{ref:n,"data-sidebar":"separator",className:$t("mx-2 w-auto bg-sidebar-border",e),...t}));To.displayName="SidebarSeparator";const Ao=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"content",className:$t("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));Ao.displayName="SidebarContent";const Po=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"group",className:$t("relative flex w-full min-w-0 flex-col p-2",e),...t}));Po.displayName="SidebarGroup";const _o=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?u:"div";return Mt.jsx(a,{ref:r,"data-sidebar":"group-label",className:$t("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),...n})});_o.displayName="SidebarGroupLabel";const Fo=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?u:"button";return Mt.jsx(a,{ref:r,"data-sidebar":"group-action",className:$t("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),...n})});Fo.displayName="SidebarGroupAction";const Ro=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"group-content",className:$t("w-full text-sm",e),...t}));Ro.displayName="SidebarGroupContent";const Do=e.forwardRef(({className:e,...t},n)=>Mt.jsx("ul",{ref:n,"data-sidebar":"menu",className:$t("flex w-full min-w-0 flex-col gap-1",e),...t}));Do.displayName="SidebarMenu";const Oo=e.forwardRef(({className:e,...t},n)=>Mt.jsx("li",{ref:n,"data-sidebar":"menu-item",className:$t("group/menu-item relative",e),...t}));Oo.displayName="SidebarMenuItem";const zo=f("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),Lo=e.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:a,className:s,...i},o)=>{const l=e?u:"button",{isMobile:c,state:d}=bo(),m=Mt.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:$t(zo({variant:n,size:r}),s),...i});return a?("string"==typeof a&&(a={children:a}),Mt.jsxs(ho,{children:[Mt.jsx(go,{asChild:!0,children:m}),Mt.jsx(xo,{side:"right",align:"center",hidden:"collapsed"!==d||c,...a})]})):m});Lo.displayName="SidebarMenuButton";const Mo=e.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},a)=>{const s=t?u:"button";return Mt.jsx(s,{ref:a,"data-sidebar":"menu-action",className:$t("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",n&&"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),...r})});Mo.displayName="SidebarMenuAction";const Uo=e.forwardRef(({className:e,...t},n)=>Mt.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:$t("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));Uo.displayName="SidebarMenuBadge";const $o=e.forwardRef(({className:t,showIcon:n=!1,...r},a)=>{const s=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return Mt.jsxs("div",{ref:a,"data-sidebar":"menu-skeleton",className:$t("rounded-md h-8 flex gap-2 px-2 items-center",t),...r,children:[n&&Mt.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),Mt.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":s}})]})});$o.displayName="SidebarMenuSkeleton";const Bo=e.forwardRef(({className:e,...t},n)=>Mt.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:$t("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));Bo.displayName="SidebarMenuSub";const Vo=e.forwardRef(({...e},t)=>Mt.jsx("li",{ref:t,...e}));Vo.displayName="SidebarMenuSubItem";const qo=e.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...a},s)=>{const i=e?u:"a";return Mt.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:$t("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground","sm"===t&&"text-xs","md"===t&&"text-sm","group-data-[collapsible=icon]:hidden",r),...a})});qo.displayName="SidebarMenuSubButton";const Ho=e.forwardRef(({className:e,...t},n)=>Mt.jsxs(Nt.Root,{ref:n,className:$t("relative flex w-full touch-none select-none items-center",e),...t,children:[Mt.jsx(Nt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:Mt.jsx(Nt.Range,{className:"absolute h-full bg-primary"})}),Mt.jsx(Nt.Thumb,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));Ho.displayName=Nt.Root.displayName;const Wo=({...e})=>{const{theme:t="system"}=kt();return Mt.jsx(b,{theme:t,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",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"}},...e})};function Ko(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Qo(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Yo(...t){return e.useCallback(function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=Qo(e,t);return n||"function"!=typeof r||(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){const n=r[t];"function"==typeof n?n():Qo(e[t],null)}}}}(...t),t)}function Jo(...t){const n=t[0];if(1===t.length)return n;const r=()=>{const r=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){const a=r.reduce((e,{useScope:n,scopeName:r})=>({...e,...n(t)[`__scope${r}`]}),{});return e.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}var Xo=globalThis?.document?e.useLayoutEffect:()=>{},Go=e[" useInsertionEffect ".trim().toString()]||Xo;function Zo({prop:t,defaultProp:n,onChange:r=()=>{},caller:a}){const[s,i,o]=function({defaultProp:t,onChange:n}){const[r,a]=e.useState(t),s=e.useRef(r),i=e.useRef(n);return Go(()=>{i.current=n},[n]),e.useEffect(()=>{s.current!==r&&(i.current?.(r),s.current=r)},[r,s]),[r,a,i]}({defaultProp:n,onChange:r}),l=void 0!==t,c=l?t:s;{const n=e.useRef(void 0!==t);e.useEffect(()=>{const e=n.current;if(e!==l){}n.current=l},[l,a])}const d=e.useCallback(e=>{if(l){const n=function(e){return"function"==typeof e}(e)?e(t):e;n!==t&&o.current?.(n)}else i(e)},[l,t,i,o]);return[c,d]}var el=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=m(`Primitive.${n}`),a=e.forwardRef((e,t)=>{const{asChild:a,...s}=e,i=a?r:n;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),Mt.jsx(i,{...s,ref:t})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{}),tl="Switch",[nl]=function(t,n=[]){let r=[];const a=()=>{const n=r.map(t=>e.createContext(t));return function(r){const a=r?.[t]||n;return e.useMemo(()=>({[`__scope${t}`]:{...r,[t]:a}}),[r,a])}};return a.scopeName=t,[function(n,a){const s=e.createContext(a),i=r.length;r=[...r,a];const o=n=>{const{scope:r,children:a,...o}=n,l=r?.[t]?.[i]||s,c=e.useMemo(()=>o,Object.values(o));return Mt.jsx(l.Provider,{value:c,children:a})};return o.displayName=n+"Provider",[o,function(r,o){const l=o?.[t]?.[i]||s,c=e.useContext(l);if(c)return c;if(void 0!==a)return a;throw new Error(`\`${r}\` must be used within \`${n}\``)}]},Jo(a,...n)]}(tl),[rl,al]=nl(tl),sl=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:a,checked:s,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:d,form:u,...m}=t,[f,p]=e.useState(null),h=Yo(n,e=>p(e)),g=e.useRef(!1),x=!f||(u||!!f.closest("form")),[y,v]=Zo({prop:s,defaultProp:i??!1,onChange:d,caller:tl});return Mt.jsxs(rl,{scope:r,checked:y,disabled:l,children:[Mt.jsx(el.button,{type:"button",role:"switch","aria-checked":y,"aria-required":o,"data-state":cl(y),"data-disabled":l?"":void 0,disabled:l,value:c,...m,ref:h,onClick:Ko(t.onClick,e=>{v(e=>!e),x&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),x&&Mt.jsx(ll,{control:f,bubbles:!g.current,name:a,value:c,checked:y,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});sl.displayName=tl;var il="SwitchThumb",ol=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=al(il,n);return Mt.jsx(el.span,{"data-state":cl(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});ol.displayName=il;var ll=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:a=!0,...s},i)=>{const o=e.useRef(null),l=Yo(o,i),c=function(t){const n=e.useRef({value:t,previous:t});return e.useMemo(()=>(n.current.value!==t&&(n.current.previous=n.current.value,n.current.value=t),n.current.previous),[t])}(r),d=function(t){const[n,r]=e.useState(void 0);return Xo(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const e=new ResizeObserver(e=>{if(!Array.isArray(e))return;if(!e.length)return;const n=e[0];let a,s;if("borderBoxSize"in n){const e=n.borderBoxSize,t=Array.isArray(e)?e[0]:e;a=t.inlineSize,s=t.blockSize}else a=t.offsetWidth,s=t.offsetHeight;r({width:a,height:s})});return e.observe(t,{box:"border-box"}),()=>e.unobserve(t)}r(void 0)},[t]),n}(n);return e.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,"checked").set;if(c!==r&&n){const t=new Event("click",{bubbles:a});n.call(e,r),e.dispatchEvent(t)}},[c,r,a]),Mt.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:l,style:{...s.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function cl(e){return e?"checked":"unchecked"}ll.displayName="SwitchBubbleInput";var dl=sl,ul=ol;const ml=e.forwardRef(({className:e,...t},n)=>Mt.jsx(dl,{className:$t("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:Mt.jsx(ul,{className:$t("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")})}));ml.displayName=dl.displayName;const fl=Ct.Root,pl=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ct.List,{ref:n,className:$t("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));pl.displayName=Ct.List.displayName;const hl=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ct.Trigger,{ref:n,className:$t("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));hl.displayName=Ct.Trigger.displayName;const gl=e.forwardRef(({className:e,...t},n)=>Mt.jsx(Ct.Content,{ref:n,className:$t("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));function xl({children:e,className:t}){return Mt.jsx("div",{className:$t("flex flex-col h-full",t),children:Mt.jsx(ks,{className:"flex-1",children:Mt.jsx("div",{className:"space-y-6 p-6",children:e})})})}function yl({title:e,description:t,actions:n,className:r}){return Mt.jsxs("div",{className:$t("space-y-4",r),children:[Mt.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[Mt.jsxs("div",{className:"space-y-1",children:[Mt.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&Mt.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),n&&Mt.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:n})]}),Mt.jsx(to,{})]})}function vl({children:e,className:t}){return Mt.jsx("div",{className:$t("space-y-6",t),children:e})}gl.displayName=Ct.Content.displayName;const bl=f("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),wl=e.forwardRef(({className:e,variant:t,size:n,...r},a)=>Mt.jsx(St.Root,{ref:a,className:$t(bl({variant:t,size:n,className:e})),...r}));wl.displayName=St.Root.displayName;const jl=e.createContext({size:"default",variant:"default"}),Nl=e.forwardRef(({className:e,variant:t,size:n,children:r,...a},s)=>Mt.jsx(Et.Root,{ref:s,className:$t("flex items-center justify-center gap-1",e),...a,children:Mt.jsx(jl.Provider,{value:{variant:t,size:n},children:r})}));Nl.displayName=Et.Root.displayName;const kl=e.forwardRef(({className:t,children:n,variant:r,size:a,...s},i)=>{const o=e.useContext(jl);return Mt.jsx(Et.Item,{ref:i,className:$t(bl({variant:o.variant||r,size:o.size||a}),t),...s,children:n})});function Cl({manager:e,config:t,onEdit:n,onDelete:r}){return e.isLoading?Mt.jsx(Mi,{children:Array.from({length:3}).map((e,t)=>Mt.jsxs(Zt,{children:[Mt.jsxs(en,{children:[Mt.jsx(vr,{className:"h-4 w-3/4"}),Mt.jsx(vr,{className:"h-3 w-1/2"})]}),Mt.jsx(rn,{children:Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(vr,{className:"h-3 w-full"}),Mt.jsx(vr,{className:"h-3 w-2/3"})]})})]},t))}):Mt.jsx(Di.Root,{children:e.entities.map(e=>Mt.jsxs(Di.Item,{onClick:()=>n(e),children:[Mt.jsx(en,{className:"pb-3",children:Mt.jsxs("div",{className:"flex items-start justify-between",children:[Mt.jsxs("div",{className:"flex-1 min-w-0",children:[Mt.jsx(tn,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),Mt.jsx(nn,{className:"text-sm",children:y(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:Ai})})]}),Mt.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&Mt.jsx(Qt,{variant:"external-link",size:"icon-xs",onClick:t=>{t.stopPropagation(),(e=>{try{const t=window.open(e,"_blank");t&&!t.closed&&void 0!==t.closed||(navigator.clipboard.writeText(e),v.info("Link copiado para a área de transferência"))}catch(t){window.location.href=e}})(e.link)},title:"Abrir link externo",children:Mt.jsx(Oe,{className:"h-4 w-4"})}),Mt.jsx("div",{onClick:e=>e.stopPropagation(),children:Mt.jsx(xs,{onEdit:()=>n(e),onDelete:r?()=>r(e):void 0,canDelete:!!r})})]})]})}),Mt.jsx(rn,{className:"pt-0",children:Mt.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const n=e[t.key];return n?Mt.jsx(Di.Field,{label:t.label,value:t.render?t.render(n,e):String(n)},String(t.key)):null})})})]},e.id))})}function Sl({data:e,columns:t,sortField:n,sortDirection:a,onSort:s,onRowClick:i,renderActions:o,isLoading:l=!1,emptyMessage:c="Nenhum item encontrado",className:d,enableSelection:u=!1,selectedIds:m=[],onSelectItem:f,onSelectAll:p,isAllSelected:h=!1}){const g=r(()=>{const e=t.reduce((e,t)=>t.width?e:e+(t.weight??1),0);return t.map(t=>{if(t.width)return`${t.width}px`;if(t.minWidth&&!t.weight)return`${t.minWidth}px`;const n=(t.weight??1)/e*100;return t.minWidth?`minmax(${t.minWidth}px, ${n}%)`:`${n}%`})},[t]);return l?Mt.jsx("div",{className:"flex-1 overflow-auto",children:Mt.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>Mt.jsx(vr,{className:"h-12 w-full"},t))})}):0===e.length?Mt.jsx("div",{className:"flex-1 flex items-center justify-center",children:Mt.jsx("div",{className:"text-center text-muted-foreground",children:Mt.jsx("p",{children:c})})}):Mt.jsx("div",{className:"flex-1 overflow-auto",children:Mt.jsxs(Ua,{className:d,children:[Mt.jsx($a,{className:"sticky top-0 bg-background z-10",children:Mt.jsxs(qa,{children:[u&&Mt.jsx(Ha,{className:"w-[40px]",children:Mt.jsx(On,{checked:h,onCheckedChange:p,"aria-label":"Selecionar todos"})}),t.map((e,t)=>{return Mt.jsx(Ha,{className:e.className,style:{width:g[t]},children:e.sortable&&s?Mt.jsxs("button",{onClick:()=>s(String(e.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[e.header,(r=String(e.key),n!==r?Mt.jsx(O,{size:14,className:"ml-1 opacity-50"}):"asc"===a?Mt.jsx(z,{size:14,className:"ml-1"}):Mt.jsx(L,{size:14,className:"ml-1"}))]}):Mt.jsx("span",{className:"font-medium",children:e.header})},String(e.key));var r}),o&&Mt.jsx(Ha,{className:"w-[80px] text-right",children:"Ações"})]})}),Mt.jsx(Ba,{children:e.map(e=>Mt.jsxs(qa,{onClick:()=>i?.(e),className:i?"cursor-pointer":"",children:[u&&Mt.jsx(Wa,{children:Mt.jsx(On,{checked:m.includes(e.id),onCheckedChange:()=>f?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${e.id}`})}),t.map(t=>Mt.jsx(Wa,{className:t.className,children:t.render?t.render(e):String(e[t.key]??"-")},String(t.key))),o&&Mt.jsx(Wa,{className:"text-right",onClick:e=>e.stopPropagation(),children:o(e)})]},e.id))})]})})}function El({onEdit:e,onDelete:t,onToggleStatus:n,isActive:r=!0,canEdit:a=!0,canDelete:s=!0,customActions:i=[],renderAs:o="dropdown",variant:l="default"}){const c=[];return e&&a&&c.push({icon:_,label:"Editar",onClick:e,variant:"default"}),n&&c.push({icon:r?F:R,label:r?"Inativar":"Ativar",onClick:n,variant:"default"}),i.forEach(e=>{!1!==e.show&&c.push({icon:e.icon,label:e.label,onClick:e.onClick,variant:e.variant||"default"})}),t&&s&&c.push({icon:D,label:"Remover",onClick:t,variant:"destructive"}),0===c.length?null:"dropdown"===o?Mt.jsxs(ts,{children:[Mt.jsx(ns,{asChild:!0,children:Mt.jsx(Qt,{variant:"ghost",size:"compact"===l?"sm":"default",className:"compact"===l?"h-7 px-2":"",children:Mt.jsx(w,{size:"compact"===l?14:16})})}),Mt.jsx(cs,{align:"end",className:"bg-background border border-border shadow-lg min-w-[120px]",children:c.map((e,t)=>Mt.jsxs(ds,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&Mt.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))})]}):Mt.jsx("div",{className:"flex items-center gap-1",children:c.map((e,t)=>Mt.jsxs(Qt,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===l?"sm":"default",onClick:e.onClick,className:"compact"===l?"h-7 px-2":"",children:[e.icon&&Mt.jsx(e.icon,{size:"compact"===l?14:16}),"compact"!==l&&Mt.jsx("span",{className:"ml-1",children:e.label})]},t))})}function Il({searchValue:e="",onSearchChange:t,customFilters:n=[],onClearFilters:r,showClearButton:a=!0,layout:s="horizontal"}){const i=e||n.length>0;return Mt.jsxs("div",{className:`flex ${"vertical"===s?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&Mt.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[Mt.jsx(I,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Mt.jsx(Jt,{type:"text",placeholder:"Buscar...",value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),n.map((e,t)=>Mt.jsx("div",{className:"vertical"===s?"w-full":"",children:e},t)),a&&i&&r&&Mt.jsxs(Qt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[Mt.jsx(j,{size:14,className:"mr-1"}),"Limpar"]})]})}function Tl({data:e,renderCard:t,isLoading:n=!1,emptyMessage:r="Nenhum item encontrado",columns:a,gap:s="md",className:i}){return n?Mt.jsx(Mi,{cols:a?String(a):"auto-fit",gap:s,className:i,children:[...Array(6)].map((e,t)=>Mt.jsx(vr,{className:"h-48 w-full"},t))}):0===e.length?Mt.jsx("div",{className:"flex items-center justify-center p-8",children:Mt.jsx("div",{className:"text-center text-muted-foreground",children:Mt.jsx("p",{children:r})})}):Mt.jsx(Mi,{cols:a?String(a):"auto-fit",gap:s,className:i,children:e.map(t)})}function Al(e){const t=ct();return{onNew:()=>{const n=e.newPath||`${e.basePath}/new`;t(n)},onEdit:n=>{const r=e.editPath?e.editPath.replace(":id",n.id):`${e.basePath}/${n.id}/edit`;t(r)}}}function Pl(e,t){const n=Al({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:n.onNew,onEdit:n.onEdit}}kl.displayName=Et.Item.displayName;const _l=t.memo(({variant:e="card",className:n="",selectedUnit:r,onUnitChange:a})=>{const{user:s,companies:i,alias:o,isAuthenticated:l,logout:c,switchUnit:d}=Ca(),u=i?.[0]||null,m=o?i?.find(e=>e.alias===o):u,f=i||[],p=r||m||u||u,h=t.useCallback(e=>{a?a(e):d(e)},[a,d]),g=t.useMemo(()=>{if(!f?.length)return[];const e=new Map;f.forEach(t=>{e.set(t.alias,t)});const t=Array.from(e.values()),n=t.find(e=>e.alias===p?.alias),r=t.filter(e=>e.alias!==p?.alias);return r.sort((e,t)=>(e.name||"").localeCompare(t.name||"","pt-BR",{sensitivity:"base"})),n?[n,...r]:r},[f,p?.alias]);if(!l||!s)return null;const x=()=>Mt.jsxs(Mt.Fragment,{children:[Mt.jsxs("div",{className:"flex items-center space-x-3",children:[Mt.jsx("div",{className:"flex-shrink-0",children:Mt.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:Mt.jsx(Ee,{className:"h-5 w-5 text-primary-foreground"})})}),Mt.jsxs("div",{className:"flex-1 min-w-0",children:[Mt.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),Mt.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&Mt.jsx("div",{className:"mt-3",children:Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsx(ze,{className:"h-4 w-4 text-muted-foreground"}),Mt.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),g.length>1&&Mt.jsxs("div",{className:"mt-2",children:[Mt.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",g.length]}),Mt.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,3).map(e=>Mt.jsx(Mn,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),g.length>3&&Mt.jsxs(Mn,{variant:"outline",className:"text-xs",children:["+",g.length-3]})]})]})]});return"dropdown"===e?Mt.jsxs(ts,{children:[Mt.jsx(ns,{asChild:!0,children:Mt.jsx(Qt,{variant:"ghost",className:`h-auto p-2 ${n}`,children:Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsxs("div",{className:"hidden md:block text-left",children:[Mt.jsx("p",{className:"text-sm font-medium",children:s.name}),Mt.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),Mt.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:Mt.jsx(Ee,{className:"h-4 w-4 text-primary-foreground"})}),Mt.jsx(N,{className:"h-4 w-4"})]})})}),Mt.jsxs(cs,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[Mt.jsxs(ss,{children:[Mt.jsxs(os,{children:[Mt.jsx(Fe,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),Mt.jsx(ls,{children:g.map(e=>Mt.jsxs(ds,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[Mt.jsx(ze,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&Mt.jsx(Mn,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Mt.jsx(ps,{}),Mt.jsxs(ds,{onClick:c,children:[Mt.jsx(Le,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):Mt.jsxs(Zt,{className:n,children:[Mt.jsx(en,{children:Mt.jsx(tn,{className:"text-lg",children:"Informações do Usuário"})}),Mt.jsxs(rn,{className:"space-y-4",children:[Mt.jsx(x,{}),Mt.jsx(to,{}),Mt.jsxs(Qt,{variant:"outline",onClick:c,size:"sm",className:"w-full",children:[Mt.jsx(Le,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Fl=a({});function Rl({children:e,config:t}){const n=r(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return Mt.jsx(Fl.Provider,{value:n,children:e})}function Dl(){return s(Fl)}function Ol(){const e=lt(),{navigation:t}=Dl();if(!t)return"Página";const n=t.find(t=>t.path===e.pathname);if(n)return n.label;const r=t.find(t=>e.pathname.startsWith(t.path+"/"));return r?.label||"Página"}function zl(e,t){const[r,a]=n(e),s=c(),l=i(()=>{s.current&&(clearTimeout(s.current),s.current=void 0)},[]);return o(()=>(l(),s.current=setTimeout(()=>{a(e)},t),l),[e,t,l]),[r,l]}const Ll=l(function({actions:e}){const t=lt(),r=Ol(),{navigation:a,appName:s}=Dl(),{metadata:i}=ri(),{companies:l,alias:c,isSearchVisible:d,clearSearch:u,refreshData:m,switchUnit:f}=Ca(),p=c?l?.find(e=>e.alias===c)||l?.[0]||null:l?.[0]||null,[h,g]=ot(),[x,y]=n(()=>h.get("search")||""),[v,b]=zl(x,ta.debounceDelay);o(()=>{if(!d)return;const e=new URLSearchParams(h);v?(e.set("search",v),e.set("page","1")):e.delete("search"),g(e)},[v,g,d]);const w=a?.find(e=>e.path===t.pathname)||a?.find(e=>t.pathname.startsWith(e.path+"/")),N=i.title||r,k=i.subtitle||w?.complementaryText||"Detalhes do item";return Mt.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:Mt.jsxs("div",{className:"flex items-center gap-4",children:[Mt.jsxs("div",{className:"flex-shrink-0",children:[Mt.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[Mt.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:N}),Mt.jsx(Mn,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:s||"Módulo"})]}),Mt.jsx("p",{className:"text-sm text-muted-foreground truncate",children:k})]}),d&&Mt.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[Mt.jsxs("div",{className:"relative flex-1",children:[Mt.jsx(I,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Mt.jsx(Jt,{placeholder:"/wiki"===t.pathname?"Buscar artigos...":"Buscar...",value:x,onChange:e=>(e=>{y(e)})(e.target.value),className:"w-full pl-10 pr-8"}),x&&Mt.jsx(Qt,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-gray-100",onClick:()=>{b(),y("");const e=new URLSearchParams(h);e.delete("search"),e.delete("page"),g(e)},title:"Limpar busca",children:Mt.jsx(j,{size:14})})]}),Mt.jsx(Qt,{variant:"outline",size:"sm",onClick:m,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:Mt.jsx(Fe,{size:14})})]}),Mt.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[e&&Mt.jsx("div",{className:"flex items-center gap-2",children:e}),import.meta.env.VITE_WIKI_URL&&Mt.jsx(Qt,{variant:"secondary",size:"sm",className:"h-8 px-3",onClick:e=>Ut(import.meta.env.VITE_WIKI_URL,e),title:"Abrir Wiki",children:"Wiki"}),Mt.jsx("div",{className:"text-sm",children:Mt.jsx(_l,{variant:"dropdown",selectedUnit:p,onUnitChange:f})})]})]})})}),Ml=({key:e,enabled:t,checkFn:n,staleTime:r=3e5,gcTime:a=6e5})=>at({queryKey:["permission",e],queryFn:n,enabled:t,staleTime:r,gcTime:a,retry:0,refetchOnWindowFocus:!1}),Ul=(e={})=>{const{enabled:t=!0}=e,{alias:n}=Ca();return at({queryKey:["active-modules",n],queryFn:async()=>{if(!n)return[];const e=Br(),{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",n).eq("status","active").order("name");if(r){if(!Kr.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!n})},$l="forlogic-sidebar-pinned",Bl=()=>{try{const e=localStorage.getItem($l);return!!e&&JSON.parse(e)}catch{return!1}},Vl=e=>{const t=["border-l-yellow-400","border-l-green-400","border-l-blue-400","border-l-red-400","border-l-purple-400","border-l-pink-400"];return t[e%t.length]},ql=import.meta.env.VITE_SUPABASE_PROJECT_ID,Hl={logo:`https://${ql}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${ql}.supabase.co/storage/v1/object/public/library-assets/small.svg`},Wl=Hl.logo,Kl=Hl.smallLogo;function Ql({appName:e,isPinned:t,onPinToggle:n,open:r,dropdownOpen:a,onDropdownChange:s}){const{data:i,isLoading:o,error:l}=Ul({enabled:a}),c=e=>{((e,t)=>{const n=e?.find(e=>e.url===t);n?.url&&window.open(n.url,"_blank")})(i,e)};return Mt.jsxs(Eo,{className:"p-0 gap-0",children:[Mt.jsx("div",{className:"flex items-center justify-between h-[34px]",children:r?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx("div",{className:"flex items-center pl-[12px]",children:Mt.jsx("img",{src:Hl.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),Mt.jsx("button",{onClick:n,className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(t?"bg-primary text-primary-foreground":"hover:bg-muted text-muted-foreground"),children:Mt.jsx(De,{className:"h-4 w-4"})})]}):Mt.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:Mt.jsx("img",{src:Hl.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),Mt.jsx("div",{className:"mt-2 pt-0",children:Mt.jsxs(ts,{onOpenChange:s,children:[Mt.jsx(ns,{asChild:!0,children:r?Mt.jsxs("div",{className:"bg-muted hover:bg-muted/80 text-foreground font-medium text-sm flex items-center justify-between cursor-pointer transition-all duration-200 h-8 px-3 gap-3 rounded-md w-full",children:[Mt.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Mt.jsx("img",{src:"https://ccjfvpnndclajkleyqkc.supabase.co/storage/v1/object/public/library-assets/composit.svg",alt:"Menu",className:"h-6 w-6 text-muted-foreground flex-shrink-0"}),Mt.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:e})]}),Mt.jsx(N,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):Mt.jsx("div",{className:"flex items-center justify-center w-full h-8 bg-muted hover:bg-muted/80 rounded-md cursor-pointer transition-all duration-200 p-[5px]",children:Mt.jsx(N,{className:"h-6 w-6 text-muted-foreground"})})}),Mt.jsx(cs,{className:r?"w-80 bg-white rounded-lg shadow-lg border border-gray-200 p-4 z-50":"w-[58px] bg-white rounded-lg shadow-lg border border-gray-200 p-2 z-50",align:r?"start":"center",children:o?Mt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[Mt.jsx(S,{className:"h-4 w-4 animate-spin"}),Mt.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):l?Mt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[Mt.jsx(E,{className:"h-4 w-4"}),Mt.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):i&&0!==i.length?Mt.jsx("div",{className:"space-y-2",children:i.map((e,t)=>Mt.jsx("div",{onClick:()=>c(e.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${Vl(t)} transition-colors duration-200\n `,children:Mt.jsxs("div",{className:"flex items-center justify-between",children:[Mt.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&Mt.jsx(Oe,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):Mt.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]})}function Yl({direction:e="right",minWidth:t=224,maxWidth:r=384,defaultWidth:a=240,storageKey:s="sidebar-width",onResize:l,isOpen:d=!0}={}){const[u,m]=n(()=>{if("undefined"==typeof window)return a;const e=localStorage.getItem(s);return e?parseInt(e):a}),[f,p]=n(!1),h=c(null);o(()=>{const e=document.querySelector(".sidebar-container");e&&e instanceof HTMLElement&&(d?e.style.setProperty("--sidebar-width",`${u}px`):e.style.setProperty("--sidebar-width","240px"))},[u,d]);const g=i(e=>{e.preventDefault(),p(!0)},[]);return o(()=>{if(!f)return;const n=n=>{let a;a="left"===e?window.innerWidth-n.clientX:n.clientX,a=Math.max(t,Math.min(r,a)),m(a),l?.(a)},a=()=>{p(!1),localStorage.setItem(s,u.toString())};return document.addEventListener("mousemove",n),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",a)}},[f,e,t,r,u,s,l]),o(()=>{f?(document.body.style.cursor="ew-resize",document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")},[f,e]),{width:u,isDragging:f,dragRef:h,handleMouseDown:g}}const Jl=t.forwardRef(({className:e,onMouseDown:t,isDragging:n,...r},a)=>Mt.jsx("div",{ref:a,onMouseDown:t,className:$t("absolute inset-y-0 right-0 w-1 cursor-ew-resize","hover:bg-primary/20 transition-colors","after:absolute after:inset-y-0 after:-left-1 after:-right-1 after:content-['']",n&&"bg-primary/40",e),...r}));function Xl({config:e,customContent:t,resizable:r=!1,minWidth:a=224,maxWidth:s=384}={}){const{open:i,setOpen:l}=bo(),c=lt(),{alias:d,user:u}=Ca(),[m,f]=n(!1),[p,h]=n(Bl),[g,x]=n(!1),y=r?Yl({minWidth:a,maxWidth:s,storageKey:"app-sidebar-width",isOpen:i}):null;o(()=>{l(!!p||!(!g&&!m))},[p,g,m,l]);const v=e=>c.pathname===e||c.pathname.startsWith(e+"/");return Mt.jsxs(jo,{collapsible:"icon",onMouseEnter:()=>{p||x(!0)},onMouseLeave:()=>{p||x(!1)},className:"app-sidebar bg-white border-r border-gray-200 py-6 px-3",style:y&&i?{width:`${y.width}px`,transition:"none"}:{transition:"all 300ms ease-in-out"},children:[Mt.jsx(Ql,{appName:e?.appName||"Título do módulo",isPinned:p,onPinToggle:()=>{const e=!p;h(e),(e=>{try{localStorage.setItem($l,JSON.stringify(e))}catch{}})(e)},open:i,dropdownOpen:m,onDropdownChange:f}),Mt.jsx(Ao,{children:t||Mt.jsx(Po,{className:"p-0 mt-6",children:Mt.jsx(Ro,{children:Mt.jsx(Do,{className:"space-y-2",children:Mt.jsx(po,{children:e?.navigation?.map((e,t)=>{const n=({item:e,index:t})=>{const r=`${e.path}-${t}-${d??"noalias"}-${u?.id??"nouser"}`,{data:a=!0,isLoading:s}=Ml({key:r,enabled:Boolean(e.permissionCheck&&d&&u?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),i=e.permissionCheck&&!a,o=s?S:i?J:e.icon;i||e.complementaryText;return e.children&&e.children.length>0?Mt.jsx(_i,{defaultOpen:!0,className:"group/collapsible",children:Mt.jsxs(Oo,{children:[Mt.jsx(Fi,{asChild:!0,children:Mt.jsx(Lo,{size:"lg",className:"h-10",children:Mt.jsxs("div",{className:"flex w-full items-center gap-3",children:[Mt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Mt.jsx(o,{className:"h-5 w-4"})}),Mt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label}),Mt.jsx(A,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-90 group-data-[collapsible=icon]:hidden"})]})})}),Mt.jsx(Ri,{children:Mt.jsx(Bo,{children:e.children.map((e,t)=>Mt.jsx(n,{item:e,index:t},e.path))})})]})},e.path):Mt.jsx(Oo,{children:i||s?Mt.jsxs(ho,{children:[Mt.jsx(go,{asChild:!0,children:Mt.jsx(Lo,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:Mt.jsxs("div",{className:"flex w-full items-center gap-3",children:[Mt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Mt.jsx(o,{className:"h-4 w-4 "+(s?"animate-spin":"")})}),Mt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),Mt.jsx(xo,{children:Mt.jsx("p",{children:s?"Verificando acesso...":"Acesso restrito"})})]}):Mt.jsx(Lo,{asChild:!0,isActive:v(e.path),size:"lg",className:"h-10",children:Mt.jsxs(dt,{to:e.path,className:"flex w-full items-center gap-3",children:[Mt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Mt.jsx(o,{className:"h-5 w-4"})}),Mt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path)};return Mt.jsx(n,{item:e,index:t},e.path)})})})})})}),r&&y&&i&&Mt.jsx(Jl,{ref:y.dragRef,onMouseDown:y.handleMouseDown,isDragging:y.isDragging})]})}Jl.displayName="ResizableRail";const Gl=l(function({children:e,sidebar:t,sidebarConfig:n,showHeader:a=!0}){const s=r(()=>t||Mt.jsx(Xl,{config:n}),[t,n]),i=r(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return Mt.jsx(Rl,{config:n,children:Mt.jsx(ni,{children:Mt.jsx(wo,{defaultOpen:!1,style:i,children:Mt.jsxs("div",{className:"sidebar-container min-h-screen flex w-full",children:[s,Mt.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[a&&Mt.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:Mt.jsx(Ll,{})}),Mt.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:e})]})]})})})})});var Zl=Object.defineProperty,ec=(e,t,n)=>((e,t,n)=>t in e?Zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);class tc extends d{constructor(e){super(e),ec(this,"copyErrorDetails",()=>{const e=Dr.getErrors().slice(0,2),t=`\n=== ERRO ATUAL ===\n${this.state.error?.message||"Erro desconhecido"}\n\nStack Trace:\n${this.state.error?.stack||"Não disponível"}\n\n=== ÚLTIMOS ERROS ===\n${e.map((e,t)=>`${t+1}. [${new Date(e.timestamp).toLocaleTimeString()}] ${e.message}`).join("\n")||"Nenhum erro registrado"}\n `.trim();navigator.clipboard.writeText(t),Jn({title:"Detalhes copiados!",description:"Os detalhes do erro foram copiados para a área de transferência."})}),this.state={hasError:!1,showDetails:!1}}static getDerivedStateFromError(e){if(import.meta.env.DEV)throw e;return{hasError:!0,error:e}}componentDidCatch(e,t){if(import.meta.env.DEV)throw e;Dr.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const e=Dr.getErrors().slice(0,2);return Mt.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:Mt.jsxs(Zt,{className:"w-full max-w-2xl",children:[Mt.jsxs(en,{className:"text-center",children:[Mt.jsx("div",{className:"flex justify-center mb-4",children:Mt.jsx(Me,{className:"h-12 w-12 text-destructive"})}),Mt.jsx(tn,{children:"Algo deu errado"})]}),Mt.jsxs(rn,{className:"space-y-4",children:[Mt.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),Mt.jsxs(_i,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[Mt.jsx(Fi,{asChild:!0,children:Mt.jsxs(Qt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[Mt.jsx(N,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),Mt.jsxs(Ri,{className:"mt-4 space-y-4",children:[Mt.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[Mt.jsxs("div",{children:[Mt.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),Mt.jsxs("div",{className:"text-sm space-y-2",children:[Mt.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&Mt.jsx(ks,{className:"h-32 w-full rounded border bg-muted p-2",children:Mt.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),e.length>0&&Mt.jsxs("div",{className:"pt-3 border-t",children:[Mt.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),Mt.jsx("div",{className:"space-y-2",children:e.map((e,t)=>Mt.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:Mt.jsxs("div",{className:"flex items-start gap-2",children:[Mt.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[t+1,"."]}),Mt.jsxs("div",{className:"flex-1 min-w-0",children:[Mt.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Mt.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(e.timestamp).toLocaleTimeString(),"]"]})}),Mt.jsx("p",{className:"text-sm break-words",children:e.message})]})]})},e.id))})]})]}),Mt.jsxs(Qt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[Mt.jsx(ne,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),Mt.jsx(Qt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}class nc{static async sendEmail(e){const t=Br(),{data:n,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 n}}const rc=nc;function ac(){const[e,t]=n([]),[r,a]=n(!1),[s,l]=n(null),[c,d]=n(null);o(()=>{u()},[]);const u=async()=>{try{const e=Br(),{data:n,error:r}=await e.functions.invoke("openai-chat",{body:{action:"createThread"}});if(r)throw r;l(n.threadId),t([{id:"initial",role:"assistant",content:"Olá! Como posso ajudá-lo hoje?",timestamp:new Date}])}catch(e){d("Erro ao inicializar conversa"),v.error("Erro ao inicializar conversa")}},m=i(async e=>{if(!s||!e.trim())return;const n={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};t(e=>[...e,n]),a(!0),d(null);try{const n=Br(),{data:r,error:a}=await n.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:s,message:e}});if(a)throw a;const{runId:i}=r,o=await(async e=>{if(!s)return!1;for(let n=0;n<60;n++)try{const t=Br(),{data:n,error:r}=await t.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:s,runId:e}});if(r)throw r;const{status:a}=n;if("completed"===a)return!0;if("failed"===a||"cancelled"===a)throw new Error("O assistente encontrou um erro");await new Promise(e=>setTimeout(e,1e3))}catch(t){throw t}throw new Error("Tempo limite excedido")})(i);o&&await(async()=>{if(s)try{const e=Br(),{data:n,error:r}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:s}});if(r)throw r;const a=n.messages.map(e=>({id:e.id,role:e.role,content:e.content,timestamp:new Date(1e3*e.created_at)}));t(a)}catch(e){throw e}})()}catch(r){const e=r instanceof Error?r.message:"Erro ao enviar mensagem";d(e),v.error(e),t(e=>e.filter(e=>e.id!==n.id))}finally{a(!1)}},[s]);return{messages:e,isLoading:r,error:c,sendMessage:m,threadId:s}}function sc(){}function ic(){}const oc=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lc=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cc={};function dc(e,t){return(cc.jsx?lc:oc).test(e)}const uc=/[ \t\n\f\r]/g;function mc(e){return""===e.replace(uc,"")}class fc{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function pc(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new fc(n,r,t)}function hc(e){return e.toLowerCase()}fc.prototype.normal={},fc.prototype.property={},fc.prototype.space=void 0;class gc{constructor(e,t){this.attribute=t,this.property=e}}gc.prototype.attribute="",gc.prototype.booleanish=!1,gc.prototype.boolean=!1,gc.prototype.commaOrSpaceSeparated=!1,gc.prototype.commaSeparated=!1,gc.prototype.defined=!1,gc.prototype.mustUseProperty=!1,gc.prototype.number=!1,gc.prototype.overloadedBoolean=!1,gc.prototype.property="",gc.prototype.spaceSeparated=!1,gc.prototype.space=void 0;let xc=0;const yc=Cc(),vc=Cc(),bc=Cc(),wc=Cc(),jc=Cc(),Nc=Cc(),kc=Cc();function Cc(){return 2**++xc}var Sc=Object.freeze({__proto__:null,boolean:yc,booleanish:vc,commaOrSpaceSeparated:kc,commaSeparated:Nc,number:wc,overloadedBoolean:bc,spaceSeparated:jc});const Ec=Object.keys(Sc);class Ic extends gc{constructor(e,t,n,r){let a=-1;if(super(e,t),Tc(this,"space",r),"number"==typeof n)for(;++a<Ec.length;){const e=Ec[a];Tc(this,Ec[a],(n&Sc[e])===Sc[e])}}}function Tc(e,t,n){n&&(e[t]=n)}function Ac(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new Ic(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[hc(r)]=r,n[hc(s.attribute)]=r}return new fc(t,n,e.space)}Ic.prototype.defined=!0;const Pc=Ac({properties:{ariaActiveDescendant:null,ariaAtomic:vc,ariaAutoComplete:null,ariaBusy:vc,ariaChecked:vc,ariaColCount:wc,ariaColIndex:wc,ariaColSpan:wc,ariaControls:jc,ariaCurrent:null,ariaDescribedBy:jc,ariaDetails:null,ariaDisabled:vc,ariaDropEffect:jc,ariaErrorMessage:null,ariaExpanded:vc,ariaFlowTo:jc,ariaGrabbed:vc,ariaHasPopup:null,ariaHidden:vc,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:jc,ariaLevel:wc,ariaLive:null,ariaModal:vc,ariaMultiLine:vc,ariaMultiSelectable:vc,ariaOrientation:null,ariaOwns:jc,ariaPlaceholder:null,ariaPosInSet:wc,ariaPressed:vc,ariaReadOnly:vc,ariaRelevant:null,ariaRequired:vc,ariaRoleDescription:jc,ariaRowCount:wc,ariaRowIndex:wc,ariaRowSpan:wc,ariaSelected:vc,ariaSetSize:wc,ariaSort:null,ariaValueMax:wc,ariaValueMin:wc,ariaValueNow:wc,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function _c(e,t){return t in e?e[t]:t}function Fc(e,t){return _c(e,t.toLowerCase())}const Rc=Ac({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Nc,acceptCharset:jc,accessKey:jc,action:null,allow:null,allowFullScreen:yc,allowPaymentRequest:yc,allowUserMedia:yc,alt:null,as:null,async:yc,autoCapitalize:null,autoComplete:jc,autoFocus:yc,autoPlay:yc,blocking:jc,capture:null,charSet:null,checked:yc,cite:null,className:jc,cols:wc,colSpan:null,content:null,contentEditable:vc,controls:yc,controlsList:jc,coords:wc|Nc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:yc,defer:yc,dir:null,dirName:null,disabled:yc,download:bc,draggable:vc,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:yc,formTarget:null,headers:jc,height:wc,hidden:bc,high:wc,href:null,hrefLang:null,htmlFor:jc,httpEquiv:jc,id:null,imageSizes:null,imageSrcSet:null,inert:yc,inputMode:null,integrity:null,is:null,isMap:yc,itemId:null,itemProp:jc,itemRef:jc,itemScope:yc,itemType:jc,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:yc,low:wc,manifest:null,max:null,maxLength:wc,media:null,method:null,min:null,minLength:wc,multiple:yc,muted:yc,name:null,nonce:null,noModule:yc,noValidate:yc,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:yc,optimum:wc,pattern:null,ping:jc,placeholder:null,playsInline:yc,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:yc,referrerPolicy:null,rel:jc,required:yc,reversed:yc,rows:wc,rowSpan:wc,sandbox:jc,scope:null,scoped:yc,seamless:yc,selected:yc,shadowRootClonable:yc,shadowRootDelegatesFocus:yc,shadowRootMode:null,shape:null,size:wc,sizes:null,slot:null,span:wc,spellCheck:vc,src:null,srcDoc:null,srcLang:null,srcSet:null,start:wc,step:null,style:null,tabIndex:wc,target:null,title:null,translate:null,type:null,typeMustMatch:yc,useMap:null,value:vc,width:wc,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:jc,axis:null,background:null,bgColor:null,border:wc,borderColor:null,bottomMargin:wc,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:yc,declare:yc,event:null,face:null,frame:null,frameBorder:null,hSpace:wc,leftMargin:wc,link:null,longDesc:null,lowSrc:null,marginHeight:wc,marginWidth:wc,noResize:yc,noHref:yc,noShade:yc,noWrap:yc,object:null,profile:null,prompt:null,rev:null,rightMargin:wc,rules:null,scheme:null,scrolling:vc,standby:null,summary:null,text:null,topMargin:wc,valueType:null,version:null,vAlign:null,vLink:null,vSpace:wc,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:yc,disableRemotePlayback:yc,prefix:null,property:null,results:wc,security:null,unselectable:null},space:"html",transform:Fc}),Dc=Ac({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:kc,accentHeight:wc,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:wc,amplitude:wc,arabicForm:null,ascent:wc,attributeName:null,attributeType:null,azimuth:wc,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:wc,by:null,calcMode:null,capHeight:wc,className:jc,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:wc,diffuseConstant:wc,direction:null,display:null,dur:null,divisor:wc,dominantBaseline:null,download:yc,dx:null,dy:null,edgeMode:null,editable:null,elevation:wc,enableBackground:null,end:null,event:null,exponent:wc,externalResourcesRequired:null,fill:null,fillOpacity:wc,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Nc,g2:Nc,glyphName:Nc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:wc,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:wc,horizOriginX:wc,horizOriginY:wc,id:null,ideographic:wc,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:wc,k:wc,k1:wc,k2:wc,k3:wc,k4:wc,kernelMatrix:kc,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:wc,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:wc,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:wc,overlineThickness:wc,paintOrder:null,panose1:null,path:null,pathLength:wc,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:jc,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:wc,pointsAtY:wc,pointsAtZ:wc,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:kc,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:kc,rev:kc,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:kc,requiredFeatures:kc,requiredFonts:kc,requiredFormats:kc,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:wc,specularExponent:wc,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:wc,strikethroughThickness:wc,string:null,stroke:null,strokeDashArray:kc,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:wc,strokeOpacity:wc,strokeWidth:null,style:null,surfaceScale:wc,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:kc,tabIndex:wc,tableValues:null,target:null,targetX:wc,targetY:wc,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:kc,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:wc,underlineThickness:wc,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:wc,values:null,vAlphabetic:wc,vMathematical:wc,vectorEffect:null,vHanging:wc,vIdeographic:wc,version:null,vertAdvY:wc,vertOriginX:wc,vertOriginY:wc,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:wc,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:_c}),Oc=Ac({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),zc=Ac({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Fc}),Lc=Ac({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),Mc={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Uc=/[A-Z]/g,$c=/-[a-z]/g,Bc=/^data[-\w.:]+$/i;function Vc(e){return"-"+e.toLowerCase()}function qc(e){return e.charAt(1).toUpperCase()}const Hc=pc([Pc,Rc,Oc,zc,Lc],"html"),Wc=pc([Pc,Dc,Oc,zc,Lc],"svg");var Kc,Qc,Yc,Jc={};function Xc(){if(Yc)return Jc;Yc=1;var e=Jc&&Jc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Jc,"__esModule",{value:!0}),Jc.default=function(e,n){var r=null;if(!e||"string"!=typeof e)return r;var a=(0,t.default)(e),s="function"==typeof n;return a.forEach(function(e){if("declaration"===e.type){var t=e.property,a=e.value;s?n(t,a,e):a&&((r=r||{})[t]=a)}}),r};var t=e(function(){if(Qc)return Kc;Qc=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,o=/^\s+|\s+$/g,l="";function c(e){return e?e.replace(o,l):l}return Kc=function(o,d){if("string"!=typeof o)throw new TypeError("First argument must be a string");if(!o)return[];d=d||{};var u=1,m=1;function f(e){var n=e.match(t);n&&(u+=n.length);var r=e.lastIndexOf("\n");m=~r?e.length-r:m+e.length}function p(){var e={line:u,column:m};return function(t){return t.position=new h(e),y(),t}}function h(e){this.start=e,this.end={line:u,column:m},this.source=d.source}function g(e){var t=new Error(d.source+":"+u+":"+m+": "+e);if(t.reason=e,t.filename=d.source,t.line=u,t.column=m,t.source=o,!d.silent)throw t}function x(e){var t=e.exec(o);if(t){var n=t[0];return f(n),o=o.slice(n.length),t}}function y(){x(n)}function v(e){var t;for(e=e||[];t=b();)!1!==t&&e.push(t);return e}function b(){var e=p();if("/"==o.charAt(0)&&"*"==o.charAt(1)){for(var t=2;l!=o.charAt(t)&&("*"!=o.charAt(t)||"/"!=o.charAt(t+1));)++t;if(t+=2,l===o.charAt(t-1))return g("End of comment missing");var n=o.slice(2,t-2);return m+=2,f(n),o=o.slice(t),m+=2,e({type:"comment",comment:n})}}function w(){var t=p(),n=x(r);if(n){if(b(),!x(a))return g("property missing ':'");var o=x(s),d=t({type:"declaration",property:c(n[0].replace(e,l)),value:o?c(o[0].replace(e,l)):l});return x(i),d}}return h.prototype.content=o,y(),function(){var e,t=[];for(v(t);e=w();)!1!==e&&(t.push(e),v(t));return t}()},Kc}());return Jc}var Gc,Zc,ed,td={};function nd(){if(Gc)return td;Gc=1,Object.defineProperty(td,"__esModule",{value:!0}),td.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,s=function(e,t){return t.toUpperCase()},i=function(e,t){return"".concat(t,"-")};return td.camelCase=function(o,l){return void 0===l&&(l={}),function(t){return!t||n.test(t)||e.test(t)}(o)?o:(o=o.toLowerCase(),(o=l.reactCompat?o.replace(a,i):o.replace(r,i)).replace(t,s))},td}var rd=function(){if(ed)return Zc;ed=1;var e=(Zc&&Zc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Xc()),t=nd();function n(n,r){var a={};return n&&"string"==typeof n?((0,e.default)(n,function(e,n){e&&n&&(a[(0,t.camelCase)(e,r)]=n)}),a):a}return n.default=n,Zc=n}(),ad=Pt(rd);const sd=od("end"),id=od("start");function od(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function ld(e){return e&&"object"==typeof e?"position"in e||"type"in e?dd(e.position):"start"in e||"end"in e?dd(e):"line"in e||"column"in e?cd(e):"":""}function cd(e){return ud(e&&e.line)+":"+ud(e&&e.column)}function dd(e){return cd(e&&e.start)+"-"+cd(e&&e.end)}function ud(e){return e&&"number"==typeof e?e:1}class md extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",a={},s=!1;if(t&&(a="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!a.cause&&e&&(s=!0,r=e.message,a.cause=e),!a.ruleId&&!a.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?a.ruleId=n:(a.source=n.slice(0,e),a.ruleId=n.slice(e+1))}if(!a.place&&a.ancestors&&a.ancestors){const e=a.ancestors[a.ancestors.length-1];e&&(a.place=e.position)}const i=a.place&&"start"in a.place?a.place.start:a.place;this.ancestors=a.ancestors||void 0,this.cause=a.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=i?i.line:void 0,this.name=ld(a.place)||"1:1",this.place=a.place||void 0,this.reason=this.message,this.ruleId=a.ruleId||void 0,this.source=a.source||void 0,this.stack=s&&a.cause&&"string"==typeof a.cause.stack?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}md.prototype.file="",md.prototype.name="",md.prototype.reason="",md.prototype.message="",md.prototype.stack="",md.prototype.column=void 0,md.prototype.line=void 0,md.prototype.ancestors=void 0,md.prototype.cause=void 0,md.prototype.fatal=void 0,md.prototype.place=void 0,md.prototype.ruleId=void 0,md.prototype.source=void 0;const fd={}.hasOwnProperty,pd=new Map,hd=/[A-Z]/g,gd=new Set(["table","tbody","thead","tfoot","tr"]),xd=new Set(["td","th"]),yd="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function vd(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=function(e,t){return n;function n(n,r,a,s){const i=Array.isArray(a.children),o=id(n);return t(r,a,s,i,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");r=function(e,t,n){return r;function r(e,r,a,s){const i=Array.isArray(a.children)?n:t;return s?i(r,a,s):i(r,a)}}(0,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?Wc:Hc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=bd(a,e,void 0);return s&&"string"!=typeof s?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function bd(e,t,n){return"element"===t.type?function(e,t,n){const r=e.schema;let a=r;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(a=Wc,e.schema=a);e.ancestors.push(t);const s=Cd(e,t.tagName,!1),i=function(e,t){const n={};let r,a;for(a in t.properties)if("children"!==a&&fd.call(t.properties,a)){const s=kd(e,a,t.properties[a]);if(s){const[a,i]=s;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof i&&xd.has(t.tagName)?r=i:n[a]=i}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let o=Nd(e,t);gd.has(t.tagName)&&(o=o.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&mc(t.value):mc(t));var t}));return wd(e,i,s,t),jd(i,o),e.ancestors.pop(),e.schema=r,e.create(t,s,i,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Sd(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const r=e.schema;let a=r;"svg"===t.name&&"html"===r.space&&(a=Wc,e.schema=a);e.ancestors.push(t);const s=null===t.name?e.Fragment:Cd(e,t.name,!0),i=function(e,t){const n={};for(const r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){const t=r.data.estree.body[0];sc(t.type);const a=t.expression;sc(a.type);const s=a.properties[0];sc(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else Sd(e,t.position);else{const a=r.name;let s;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){const t=r.value.data.estree.body[0];sc(t.type),s=e.evaluater.evaluateExpression(t.expression)}else Sd(e,t.position);else s=null===r.value||r.value;n[a]=s}return n}(e,t),o=Nd(e,t);return wd(e,i,s,t),jd(i,o),e.ancestors.pop(),e.schema=r,e.create(t,s,i,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Sd(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return jd(r,Nd(e,t)),e.create(t,e.Fragment,r,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function wd(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function jd(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Nd(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:pd;for(;++r<t.children.length;){const s=t.children[r];let i;if(e.passKeys){const e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){const t=a.get(e)||0;i=e+"-"+t,a.set(e,t+1)}}const o=bd(e,s,i);void 0!==o&&n.push(o)}return n}function kd(e,t,n){const r=function(e,t){const n=hc(t);let r=t,a=gc;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Bc.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace($c,qc);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!$c.test(e)){let n=e.replace(Uc,Vc);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}a=Ic}return new a(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return ad(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new md("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=yd+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)fd.call(e,n)&&(t[Ed(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?Mc[r.property]||r.property:r.attribute,n]}}function Cd(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,a=-1;for(;++a<e.length;){const t=dc(e[a])?{type:"Identifier",name:e[a]}:{type:"Literal",value:e[a]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(a&&"Literal"===t.type),optional:!1}:t}r=n}else r=dc(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){const t=r.value;return fd.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Sd(e)}function Sd(e,t){const n=new md("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=yd+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Ed(e){let t=e.replace(hd,Id);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function Id(e){return"-"+e.toLowerCase()}const Td={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Ad={};function Pd(e,t){return _d(e,"boolean"!=typeof Ad.includeImageAlt||Ad.includeImageAlt,"boolean"!=typeof Ad.includeHtml||Ad.includeHtml)}function _d(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Fd(e.children,t,n)}return Array.isArray(e)?Fd(e,t,n):""}function Fd(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=_d(e[a],t,n);return r.join("")}const Rd=document.createElement("i");function Dd(e){const t="&"+e+";";Rd.innerHTML=t;const n=Rd.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function Od(e,t,n,r){const a=e.length;let s,i=0;if(t=t<0?-t>a?0:a+t:t>a?a:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function zd(e,t){return e.length>0?(Od(e,e.length,0,t),e):t}const Ld={}.hasOwnProperty;function Md(e){const t={};let n=-1;for(;++n<e.length;)Ud(t,e[n]);return t}function Ud(e,t){let n;for(n in t){const r=(Ld.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){Ld.call(r,s)||(r[s]=[]);const e=a[s];$d(r[s],Array.isArray(e)?e:e?[e]:[])}}}function $d(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);Od(e,0,0,r)}function Bd(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function Vd(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const qd=nu(/[A-Za-z]/),Hd=nu(/[\dA-Za-z]/),Wd=nu(/[#-'*+\--9=?A-Z^-~]/);function Kd(e){return null!==e&&(e<32||127===e)}const Qd=nu(/\d/),Yd=nu(/[\dA-Fa-f]/),Jd=nu(/[!-/:-@[-`{-~]/);function Xd(e){return null!==e&&e<-2}function Gd(e){return null!==e&&(e<0||32===e)}function Zd(e){return-2===e||-1===e||32===e}const eu=nu(/\p{P}|\p{S}/u),tu=nu(/\s/);function nu(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function ru(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&Hd(e.charCodeAt(n+1))&&Hd(e.charCodeAt(n+2)))a=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const t=e.charCodeAt(n+1);s<56320&&t>56319&&t<57344?(i=String.fromCharCode(s,t),a=1):i="�"}else i=String.fromCharCode(s);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+a+1,i=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function au(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(Zd(r))return e.enter(n),i(r);return t(r)};function i(r){return Zd(r)&&s++<a?(e.consume(r),i):(e.exit(n),t(r))}}const su={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),au(e,t,"linePrefix")},function(t){return e.enter("paragraph"),r(t)});let n;return t;function r(t){const r=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=r),n=r,a(t)}function a(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):Xd(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),a)}}};const iu={tokenize:function(e){const t=this,n=[];let r,a,s,i=0;return o;function o(r){if(i<n.length){const a=n[i];return t.containerState=a[1],e.attempt(a[0].continuation,l,c)(r)}return c(r)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&y();const n=t.events.length;let a,s=n;for(;s--;)if("exit"===t.events[s][0]&&"chunkFlow"===t.events[s][1].type){a=t.events[s][1].end;break}x(i);let o=n;for(;o<t.events.length;)t.events[o][1].end={...a},o++;return Od(t.events,s+1,0,t.events.slice(n)),t.events.length=o,c(e)}return o(e)}function c(a){if(i===n.length){if(!r)return m(a);if(r.currentConstruct&&r.currentConstruct.concrete)return p(a);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ou,d,u)(a)}function d(e){return r&&y(),x(i),m(e)}function u(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,p(e)}function m(n){return t.containerState={},e.attempt(ou,f,p)(n)}function f(e){return i++,n.push([t.currentConstruct,t.containerState]),m(e)}function p(n){return null===n?(r&&y(),x(0),void e.consume(n)):(r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:a}),h(n))}function h(n){return null===n?(g(e.exit("chunkFlow"),!0),x(0),void e.consume(n)):Xd(n)?(e.consume(n),g(e.exit("chunkFlow")),i=0,t.interrupt=void 0,o):(e.consume(n),h)}function g(e,n){const o=t.sliceStream(e);if(n&&o.push(null),e.previous=a,a&&(a.next=e),a=e,r.defineSkip(e.start),r.write(o),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<s&&(!r.events[e][1].end||r.events[e][1].end.offset>s))return;const n=t.events.length;let a,o,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(a){o=t.events[l][1].end;break}a=!0}for(x(i),e=n;e<t.events.length;)t.events[e][1].end={...o},e++;Od(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function x(r){let a=n.length;for(;a-- >r;){const r=n[a];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function y(){r.write([null]),a=void 0,r=void 0,t.containerState._closeFlow=void 0}}},ou={tokenize:function(e,t,n){return au(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function lu(e){return null===e||Gd(e)||tu(e)?1:eu(e)?2:void 0}function cu(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const s=e[a].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const du={name:"attention",resolveAll:function(e,t){let n,r,a,s,i,o,l,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close)for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;o=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;const u={...e[n][1].end},m={...e[d][1].start};uu(u,-o),uu(m,o),s={type:o>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},i={type:o>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:m},a={type:o>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},r={type:o>1?"strong":"emphasis",start:{...s.start},end:{...i.end}},e[n][1].end={...s.start},e[d][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=zd(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=zd(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",a,t]]),l=zd(l,cu(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=zd(l,[["exit",a,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=zd(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,Od(e,n-1,d-n+3,l),d=n+l.length-c-2;break}d=-1;for(;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=lu(r);let s;return function(t){return s=t,e.enter("attentionSequence"),i(t)};function i(o){if(o===s)return e.consume(o),i;const l=e.exit("attentionSequence"),c=lu(o),d=!c||2===c&&a||n.includes(o),u=!a||2===a&&c||n.includes(r);return l._open=Boolean(42===s?d:d&&(a||!u)),l._close=Boolean(42===s?u:u&&(c||!d)),t(o)}}};function uu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const mu={name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a};function a(t){return qd(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||Hd(e)?(r=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),r=0,o):(43===t||45===t||46===t||Hd(t))&&r++<32?(e.consume(t),i):(r=0,l(t))}function o(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||Kd(r)?n(r):(e.consume(r),o)}function l(t){return 64===t?(e.consume(t),c):Wd(t)?(e.consume(t),l):n(t)}function c(e){return Hd(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),r=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):u(n)}function u(t){if((45===t||Hd(t))&&r++<63){const n=45===t?u:d;return e.consume(t),n}return n(t)}}};const fu={partial:!0,tokenize:function(e,t,n){return function(t){return Zd(t)?au(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||Xd(e)?t(e):n(e)}}};const pu={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(Zd(t))return au(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return a(t)};function a(r){return e.attempt(pu,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),a}return n(t)};function a(n){return Zd(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const hu={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return Jd(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const gu={name:"characterReference",tokenize:function(e,t,n){const r=this;let a,s,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),o};function o(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),a=31,s=Hd,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,s=Yd,c):(e.enter("characterReferenceValue"),a=7,s=Qd,c(t))}function c(o){if(59===o&&i){const a=e.exit("characterReferenceValue");return s!==Hd||Dd(r.sliceSerialize(a))?(e.enter("characterReferenceMarker"),e.consume(o),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(o)}return s(o)&&i++<a?(e.consume(o),c):n(o)}}};const xu={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a};function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},yu={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),Zd(t)?au(e,c,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===s?(e.enter("codeFencedFenceSequence"),d(t)):n(t)}function d(t){return t===s?(a++,e.consume(t),d):a>=o?(e.exit("codeFencedFenceSequence"),Zd(t)?au(e,u,"whitespace")(t):u(t)):n(t)}function u(r){return null===r||Xd(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let s,i=0,o=0;return function(t){return function(t){const n=r.events[r.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===s?(o++,e.consume(t),l):o<3?n(t):(e.exit("codeFencedFenceSequence"),Zd(t)?au(e,c,"whitespace")(t):c(t))}function c(n){return null===n||Xd(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(xu,f,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||Xd(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):Zd(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),au(e,u,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),d)}function u(t){return null===t||Xd(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(t))}function m(t){return null===t||Xd(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),m)}function f(t){return e.attempt(a,y,p)(t)}function p(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),h}function h(t){return i>0&&Zd(t)?au(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||Xd(t)?e.check(xu,f,y)(t):(e.enter("codeFlowValue"),x(t))}function x(t){return null===t||Xd(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),x)}function y(n){return e.exit("codeFenced"),t(n)}}};const vu={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),au(e,a,"linePrefix",5)(t)};function a(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?s(e):n(e)}function s(t){return null===t?o(t):Xd(t)?e.attempt(bu,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||Xd(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},bu={partial:!0,tokenize:function(e,t,n){const r=this;return a;function a(t){return r.parser.lazy[r.now().line]?n(t):Xd(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):au(e,s,"linePrefix",5)(t)}function s(e){const s=r.events[r.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):Xd(e)?a(e):n(e)}}};const wu={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,a=3;if(!("lineEnding"!==e[a][1].type&&"space"!==e[a][1].type||"lineEnding"!==e[r][1].type&&"space"!==e[r][1].type))for(t=a;++t<r;)if("codeTextData"===e[t][1].type){e[a][1].type="codeTextPadding",e[r][1].type="codeTextPadding",a+=2,r-=2;break}t=a-1,r++;for(;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):t!==r&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,a,s=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),s++,i):(e.exit("codeTextSequence"),o(t))}function o(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),o):96===t?(a=e.enter("codeTextSequence"),r=0,c(t)):Xd(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||Xd(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),r++,c):r===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(a.type="codeTextData",l(n))}}};class ju{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const r=t||0;this.setCursor(Math.trunc(e));const a=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&Nu(this.left,n),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Nu(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Nu(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);Nu(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Nu(this.left,t.reverse())}}}function Nu(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ku(e){const t={};let n,r,a,s,i,o,l,c=-1;const d=new ju(e);for(;++c<d.length;){for(;c in t;)c=t[c];if(n=d.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&(o=n[1]._tokenizer.events,a=0,a<o.length&&"lineEndingBlank"===o[a][1].type&&(a+=2),a<o.length&&"content"===o[a][1].type))for(;++a<o.length&&"content"!==o[a][1].type;)"chunkText"===o[a][1].type&&(o[a][1]._isInFirstContentOfListItem=!0,a++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,Cu(d,c)),c=t[c],l=!0);else if(n[1]._container){for(a=c,r=void 0;a--;)if(s=d.get(a),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(r&&(d.get(r)[1].type="lineEndingBlank"),s[1].type="lineEnding",r=a);else if("linePrefix"!==s[1].type&&"listItemIndent"!==s[1].type)break;r&&(n[1].end={...d.get(r)[1].start},i=d.slice(r,c),i.unshift(n),d.splice(r,c-r+1,i))}}return Od(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function Cu(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const s=[];let i=n._tokenizer;i||(i=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const o=i.events,l=[],c={};let d,u,m=-1,f=n,p=0,h=0;const g=[h];for(;f;){for(;e.get(++a)[1]!==f;);s.push(a),f._tokenizer||(d=r.sliceStream(f),f.next||d.push(null),u&&i.defineSkip(f.start),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),u=f,f=f.next}for(f=n;++m<o.length;)"exit"===o[m][0]&&"enter"===o[m-1][0]&&o[m][1].type===o[m-1][1].type&&o[m][1].start.line!==o[m][1].end.line&&(h=m+1,g.push(h),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(i.events=[],f?(f._tokenizer=void 0,f.previous=void 0):g.pop(),m=g.length;m--;){const t=o.slice(g[m],g[m+1]),n=s.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),m=-1;++m<l.length;)c[p+l[m][0]]=p+l[m][1],p+=l[m][1]-l[m][0]-1;return c}const Su={resolve:function(e){return ku(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?a(t):Xd(t)?e.check(Eu,s,a)(t):(e.consume(t),r)}function a(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function s(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},Eu={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),au(e,a,"linePrefix")};function a(a){if(null===a||Xd(a))return n(a);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}};function Iu(e,t,n,r,a,s,i,o,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(r),e.enter(a),e.enter(s),e.consume(t),e.exit(s),u;if(null===t||32===t||41===t||Kd(t))return n(t);return e.enter(r),e.enter(i),e.enter(o),e.enter("chunkString",{contentType:"string"}),p(t)};function u(n){return 62===n?(e.enter(s),e.consume(n),e.exit(s),e.exit(a),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),m(n))}function m(t){return 62===t?(e.exit("chunkString"),e.exit(o),u(t)):null===t||60===t||Xd(t)?n(t):(e.consume(t),92===t?f:m)}function f(t){return 60===t||62===t||92===t?(e.consume(t),m):m(t)}function p(a){return d||null!==a&&41!==a&&!Gd(a)?d<c&&40===a?(e.consume(a),d++,p):41===a?(e.consume(a),d--,p):null===a||32===a||40===a||Kd(a)?n(a):(e.consume(a),92===a?h:p):(e.exit("chunkString"),e.exit(o),e.exit(i),e.exit(r),t(a))}function h(t){return 40===t||41===t||92===t?(e.consume(t),p):p(t)}}function Tu(e,t,n,r,a,s){const i=this;let o,l=0;return function(t){return e.enter(r),e.enter(a),e.consume(t),e.exit(a),e.enter(s),c};function c(u){return l>999||null===u||91===u||93===u&&!o||94===u&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(u):93===u?(e.exit(s),e.enter(a),e.consume(u),e.exit(a),e.exit(r),t):Xd(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||Xd(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!Zd(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function Au(e,t,n,r,a,s){let i;return function(t){if(34===t||39===t||40===t)return e.enter(r),e.enter(a),e.consume(t),e.exit(a),i=40===t?41:t,o;return n(t)};function o(n){return n===i?(e.enter(a),e.consume(n),e.exit(a),e.exit(r),t):(e.enter(s),l(n))}function l(t){return t===i?(e.exit(s),o(i)):null===t?n(t):Xd(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),au(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||Xd(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===i||92===t?(e.consume(t),c):c(t)}}function Pu(e,t){let n;return function r(a){if(Xd(a))return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r;if(Zd(a))return au(e,r,n?"linePrefix":"lineSuffix")(a);return t(a)}}const _u={name:"definition",tokenize:function(e,t,n){const r=this;let a;return function(t){return e.enter("definition"),function(t){return Tu.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return a=Vd(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i):n(t)}function i(t){return Gd(t)?Pu(e,o)(t):o(t)}function o(t){return Iu(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(Fu,c,c)(t)}function c(t){return Zd(t)?au(e,d,"whitespace")(t):d(t)}function d(s){return null===s||Xd(s)?(e.exit("definition"),r.parser.defined.push(a),t(s)):n(s)}}},Fu={partial:!0,tokenize:function(e,t,n){return function(t){return Gd(t)?Pu(e,r)(t):n(t)};function r(t){return Au(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return Zd(t)?au(e,s,"whitespace")(t):s(t)}function s(e){return null===e||Xd(e)?t(e):n(e)}}};const Ru={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return Xd(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const Du={name:"headingAtx",resolve:function(e,t){let n,r,a=e.length-2,s=3;"whitespace"===e[s][1].type&&(s+=2);a-2>s&&"whitespace"===e[a][1].type&&(a-=2);"atxHeadingSequence"===e[a][1].type&&(s===a-1||a-4>s&&"whitespace"===e[a-2][1].type)&&(a-=s+1===a?2:4);a>s&&(n={type:"atxHeadingText",start:e[s][1].start,end:e[a][1].end},r={type:"chunkText",start:e[s][1].start,end:e[a][1].end,contentType:"text"},Od(e,s,a-s+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),a(t)}(t)};function a(t){return 35===t&&r++<6?(e.consume(t),a):null===t||Gd(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||Xd(n)?(e.exit("atxHeading"),t(n)):Zd(n)?au(e,s,"whitespace")(n):(e.enter("atxHeadingText"),o(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),s(t))}function o(t){return null===t||35===t||Gd(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const Ou=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],zu=["pre","script","style","textarea"],Lu={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const r=this;let a,s,i,o,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(o){return 33===o?(e.consume(o),d):47===o?(e.consume(o),s=!0,f):63===o?(e.consume(o),a=3,r.interrupt?t:R):qd(o)?(e.consume(o),i=String.fromCharCode(o),p):n(o)}function d(s){return 45===s?(e.consume(s),a=2,u):91===s?(e.consume(s),a=5,o=0,m):qd(s)?(e.consume(s),a=4,r.interrupt?t:R):n(s)}function u(a){return 45===a?(e.consume(a),r.interrupt?t:R):n(a)}function m(a){const s="CDATA[";return a===s.charCodeAt(o++)?(e.consume(a),6===o?r.interrupt?t:S:m):n(a)}function f(t){return qd(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||Gd(o)){const l=47===o,c=i.toLowerCase();return l||s||!zu.includes(c)?Ou.includes(i.toLowerCase())?(a=6,l?(e.consume(o),h):r.interrupt?t(o):S(o)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(o):s?g(o):x(o)):(a=1,r.interrupt?t(o):S(o))}return 45===o||Hd(o)?(e.consume(o),i+=String.fromCharCode(o),p):n(o)}function h(a){return 62===a?(e.consume(a),r.interrupt?t:S):n(a)}function g(t){return Zd(t)?(e.consume(t),g):k(t)}function x(t){return 47===t?(e.consume(t),k):58===t||95===t||qd(t)?(e.consume(t),y):Zd(t)?(e.consume(t),x):k(t)}function y(t){return 45===t||46===t||58===t||95===t||Hd(t)?(e.consume(t),y):v(t)}function v(t){return 61===t?(e.consume(t),b):Zd(t)?(e.consume(t),v):x(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):Zd(t)?(e.consume(t),b):j(t)}function w(t){return t===l?(e.consume(t),l=null,N):null===t||Xd(t)?n(t):(e.consume(t),w)}function j(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||Gd(t)?v(t):(e.consume(t),j)}function N(e){return 47===e||62===e||Zd(e)?x(e):n(e)}function k(t){return 62===t?(e.consume(t),C):n(t)}function C(t){return null===t||Xd(t)?S(t):Zd(t)?(e.consume(t),C):n(t)}function S(t){return 45===t&&2===a?(e.consume(t),A):60===t&&1===a?(e.consume(t),P):62===t&&4===a?(e.consume(t),D):63===t&&3===a?(e.consume(t),R):93===t&&5===a?(e.consume(t),F):!Xd(t)||6!==a&&7!==a?null===t||Xd(t)?(e.exit("htmlFlowData"),E(t)):(e.consume(t),S):(e.exit("htmlFlowData"),e.check(Mu,O,E)(t))}function E(t){return e.check(Uu,I,O)(t)}function I(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),T}function T(t){return null===t||Xd(t)?E(t):(e.enter("htmlFlowData"),S(t))}function A(t){return 45===t?(e.consume(t),R):S(t)}function P(t){return 47===t?(e.consume(t),i="",_):S(t)}function _(t){if(62===t){const n=i.toLowerCase();return zu.includes(n)?(e.consume(t),D):S(t)}return qd(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),_):S(t)}function F(t){return 93===t?(e.consume(t),R):S(t)}function R(t){return 62===t?(e.consume(t),D):45===t&&2===a?(e.consume(t),R):S(t)}function D(t){return null===t||Xd(t)?(e.exit("htmlFlowData"),O(t)):(e.consume(t),D)}function O(n){return e.exit("htmlFlow"),t(n)}}},Mu={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(fu,t,n)}}},Uu={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(Xd(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a;return n(t)};function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}};const $u={name:"htmlText",tokenize:function(e,t,n){const r=this;let a,s,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),o};function o(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),b):63===t?(e.consume(t),y):qd(t)?(e.consume(t),N):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,f):qd(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),m):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):Xd(t)?(i=d,_(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),m):d(t)}function m(e){return 62===e?P(e):45===e?u(e):d(e)}function f(t){const r="CDATA[";return t===r.charCodeAt(s++)?(e.consume(t),6===s?p:f):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),h):Xd(t)?(i=p,_(t)):(e.consume(t),p)}function h(t){return 93===t?(e.consume(t),g):p(t)}function g(t){return 62===t?P(t):93===t?(e.consume(t),g):p(t)}function x(t){return null===t||62===t?P(t):Xd(t)?(i=x,_(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),v):Xd(t)?(i=y,_(t)):(e.consume(t),y)}function v(e){return 62===e?P(e):y(e)}function b(t){return qd(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||Hd(t)?(e.consume(t),w):j(t)}function j(t){return Xd(t)?(i=j,_(t)):Zd(t)?(e.consume(t),j):P(t)}function N(t){return 45===t||Hd(t)?(e.consume(t),N):47===t||62===t||Gd(t)?k(t):n(t)}function k(t){return 47===t?(e.consume(t),P):58===t||95===t||qd(t)?(e.consume(t),C):Xd(t)?(i=k,_(t)):Zd(t)?(e.consume(t),k):P(t)}function C(t){return 45===t||46===t||58===t||95===t||Hd(t)?(e.consume(t),C):S(t)}function S(t){return 61===t?(e.consume(t),E):Xd(t)?(i=S,_(t)):Zd(t)?(e.consume(t),S):k(t)}function E(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,I):Xd(t)?(i=E,_(t)):Zd(t)?(e.consume(t),E):(e.consume(t),T)}function I(t){return t===a?(e.consume(t),a=void 0,A):null===t?n(t):Xd(t)?(i=I,_(t)):(e.consume(t),I)}function T(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Gd(t)?k(t):(e.consume(t),T)}function A(e){return 47===e||62===e||Gd(e)?k(e):n(e)}function P(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function _(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),F}function F(t){return Zd(t)?au(e,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):R(t)}function R(t){return e.enter("htmlTextData"),i(t)}}};const Bu={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){const e="labelImage"===r.type?4:2;r.type="data",t+=e}}e.length!==n.length&&Od(e,0,e.length,n);return e},resolveTo:function(e,t){let n,r,a,s,i=e.length,o=0;for(;i--;)if(n=e[i][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(a){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=i,"labelLink"!==n.type)){o=2;break}}else"labelEnd"===n.type&&(a=i);const l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[a][1].end}},d={type:"labelText",start:{...e[r+o+2][1].end},end:{...e[a-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=zd(s,e.slice(r+1,r+o+3)),s=zd(s,[["enter",d,t]]),s=zd(s,cu(t.parser.constructs.insideSpan.null,e.slice(r+o+4,a-3),t)),s=zd(s,[["exit",d,t],e[a-2],e[a-1],["exit",c,t]]),s=zd(s,e.slice(a+1)),s=zd(s,[["exit",l,t]]),Od(e,r,e.length,s),e},tokenize:function(e,t,n){const r=this;let a,s,i=r.events.length;for(;i--;)if(("labelImage"===r.events[i][1].type||"labelLink"===r.events[i][1].type)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return function(t){if(!a)return n(t);if(a._inactive)return d(t);return s=r.parser.defined.includes(Vd(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),o};function o(t){return 40===t?e.attempt(Vu,c,s?c:d)(t):91===t?e.attempt(qu,c,s?l:d)(t):s?c(t):d(t)}function l(t){return e.attempt(Hu,c,d)(t)}function c(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}},Vu={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return Gd(t)?Pu(e,a)(t):a(t)}function a(t){return 41===t?c(t):Iu(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return Gd(t)?Pu(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?Au(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return Gd(t)?Pu(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},qu={tokenize:function(e,t,n){const r=this;return function(t){return Tu.call(r,e,a,s,"reference","referenceMarker","referenceString")(t)};function a(e){return r.parser.defined.includes(Vd(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},Hu={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}};const Wu={name:"labelStartImage",resolveAll:Bu.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),a};function a(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),s):n(t)}function s(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const Ku={name:"labelStartLink",resolveAll:Bu.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),a};function a(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const Qu={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),au(e,t,"linePrefix")}}};const Yu={name:"thematicBreak",tokenize:function(e,t,n){let r,a=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,s(e)}(t)};function s(s){return s===r?(e.enter("thematicBreakSequence"),i(s)):a>=3&&(null===s||Xd(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),a++,i):(e.exit("thematicBreakSequence"),Zd(t)?au(e,s,"whitespace")(t):s(t))}}};const Ju={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(fu,a,s);function a(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,au(e,t,"listItemIndent",r.containerState.size+1)(n)}function s(n){return r.containerState.furtherBlankLines||!Zd(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Gu,t,i)(n))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,au(e,e.attempt(Ju,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const r=this,a=r.events[r.events.length-1];let s=a&&"linePrefix"===a[1].type?a[2].sliceSerialize(a[1],!0).length:0,i=0;return function(t){const a=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===a?!r.containerState.marker||t===r.containerState.marker:Qd(t)){if(r.containerState.type||(r.containerState.type=a,e.enter(a,{_container:!0})),"listUnordered"===a)return e.enter("listItemPrefix"),42===t||45===t?e.check(Yu,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),o(t)}return n(t)};function o(t){return Qd(t)&&++i<10?(e.consume(t),o):(!r.interrupt||i<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(fu,r.interrupt?n:c,e.attempt(Xu,u,d))}function c(e){return r.containerState.initialBlankLine=!0,s++,u(e)}function d(t){return Zd(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Xu={partial:!0,tokenize:function(e,t,n){const r=this;return au(e,function(e){const a=r.events[r.events.length-1];return!Zd(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Gu={partial:!0,tokenize:function(e,t,n){const r=this;return au(e,function(e){const a=r.events[r.events.length-1];return a&&"listItemIndent"===a[1].type&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}};const Zu={name:"setextUnderline",resolveTo:function(e,t){let n,r,a,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){n=s;break}"paragraph"===e[s][1].type&&(r=s)}else"content"===e[s][1].type&&e.splice(s,1),a||"definition"!==e[s][1].type||(a=s);const i={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};e[r][1].type="setextHeadingText",a?(e.splice(r,0,["enter",i,t]),e.splice(a+1,0,["exit",e[n][1],t]),e[n][1].end={...e[a][1].end}):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const r=this;let a;return function(t){let i,o=r.events.length;for(;o--;)if("lineEnding"!==r.events[o][1].type&&"linePrefix"!==r.events[o][1].type&&"content"!==r.events[o][1].type){i="paragraph"===r.events[o][1].type;break}if(!r.parser.lazy[r.now().line]&&(r.interrupt||i))return e.enter("setextHeadingLine"),a=t,function(t){return e.enter("setextHeadingLineSequence"),s(t)}(t);return n(t)};function s(t){return t===a?(e.consume(t),s):(e.exit("setextHeadingLineSequence"),Zd(t)?au(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||Xd(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const em={tokenize:function(e){const t=this,n=e.attempt(fu,function(r){if(null===r)return void e.consume(r);return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n},e.attempt(this.parser.constructs.flowInitial,r,au(e,e.attempt(this.parser.constructs.flow,r,e.attempt(Su,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}};const tm={resolveAll:sm()},nm=am("string"),rm=am("text");function am(e){return{resolveAll:sm("text"===e?im:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],a=t.attempt(r,s,i);return s;function s(e){return l(e)?a(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),o;t.consume(e)}function o(e){return l(e)?(t.exit("data"),a(e)):(t.consume(e),o)}function l(e){if(null===e)return!0;const t=r[e];let a=-1;if(t)for(;++a<t.length;){const e=t[a];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function sm(e){return function(t,n){let r,a=-1;for(;++a<=t.length;)void 0===r?t[a]&&"data"===t[a][1].type&&(r=a,a++):t[a]&&"data"===t[a][1].type||(a!==r+2&&(t[r][1].end=t[a-1][1].end,t.splice(r+2,a-r-2),a=r+2),r=void 0);return e?e(t,n):t}}function im(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const r=e[n-1][1],a=t.sliceStream(r);let s,i=a.length,o=-1,l=0;for(;i--;){const e=a[i];if("string"==typeof e){for(o=e.length;32===e.charCodeAt(o-1);)l++,o--;if(o)break;o=-1}else if(-2===e)s=!0,l++;else if(-1!==e){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const a={type:n===e.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:r.start._bufferIndex+o,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...a.start},r.start.offset===r.end.offset?Object.assign(r,a):(e.splice(n,0,["enter",a,t],["exit",a,t]),n+=2)}n++}return e}const om={42:Ju,43:Ju,45:Ju,48:Ju,49:Ju,50:Ju,51:Ju,52:Ju,53:Ju,54:Ju,55:Ju,56:Ju,57:Ju,62:pu},lm={91:_u},cm={[-2]:vu,[-1]:vu,32:vu},dm={35:Du,42:Yu,45:[Zu,Yu],60:Lu,61:Zu,95:Yu,96:yu,126:yu},um={38:gu,92:hu},mm={[-5]:Qu,[-4]:Qu,[-3]:Qu,33:Wu,38:gu,42:du,60:[mu,$u],91:Ku,92:[Ru,hu],93:Bu,95:du,96:wu},fm={null:[du,tm]};var pm=Object.freeze({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:lm,disable:{null:[]},document:om,flow:dm,flowInitial:cm,insideSpan:fm,string:um,text:mm});function hm(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},s=[];let i=[],o=[];const l={attempt:g(function(e,t){x(e,t.from)}),check:g(h),consume:function(e){Xd(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,y()):-1!==e&&(r.column++,r.offset++);r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++));c.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=m(),c.events.push(["enter",n,c]),o.push(n),n},exit:function(e){const t=o.pop();return t.end=m(),c.events.push(["exit",t,c]),t},interrupt:g(h,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){a[e.line]=e.column,y()},events:[],now:m,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const s=e[n];let i;if("string"==typeof s)i=s;else switch(s){case-5:i="\r";break;case-4:i="\n";break;case-3:i="\r\n";break;case-2:i=t?" ":"\t";break;case-1:if(!t&&a)continue;i=" ";break;default:i=String.fromCharCode(s)}a=-2===s,r.push(i)}return r.join("")}(u(e),t)},sliceStream:u,write:function(e){if(i=zd(i,e),f(),null!==i[i.length-1])return[];return x(t,0),c.events=cu(s,c.events,c),c.events}};let d=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function u(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,s=t.end._bufferIndex;let i;if(n===a)i=[e[n].slice(r,s)];else{if(i=e.slice(n,a),r>-1){const e=i[0];"string"==typeof e?i[0]=e.slice(r):i.shift()}s>0&&i.push(e[a].slice(0,s))}return i}(i,e)}function m(){const{_bufferIndex:e,_index:t,line:n,column:a,offset:s}=r;return{_bufferIndex:e,_index:t,line:n,column:a,offset:s}}function f(){let e;for(;r._index<i.length;){const t=i[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)p(t.charCodeAt(r._bufferIndex));else p(t)}}function p(e){d=d(e)}function h(e,t){t.restore()}function g(e,t){return function(n,a,s){let i,d,u,f;return Array.isArray(n)?p(n):"tokenize"in n?p([n]):function(e){return t;function t(t){const n=null!==t&&e[t],r=null!==t&&e.null;return p([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function p(e){return i=e,d=0,0===e.length?s:h(e[d])}function h(e){return function(n){f=function(){const e=m(),t=c.previous,n=c.currentConstruct,a=c.events.length,s=Array.from(o);return{from:a,restore:i};function i(){r=e,c.previous=t,c.currentConstruct=n,c.events.length=a,o=s,y()}}(),u=e,e.partial||(c.currentConstruct=e);if(e.name&&c.parser.constructs.disable.null.includes(e.name))return x();return e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,g,x)(n)}}function g(t){return e(u,f),a}function x(e){return f.restore(),++d<i.length?h(i[d]):s}}}function x(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&Od(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function y(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}const gm=/[\0\t\n\r]/g;const xm=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ym(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Bd(n.slice(t?2:1),t?16:10)}return Dd(n)||e}const vm={}.hasOwnProperty;function bm(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(te),autolinkProtocol:C,autolinkEmail:C,atxHeading:s(X),blockQuote:s(W),characterEscape:C,characterReference:C,codeFenced:s(K),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(K,i),codeText:s(Q,i),codeTextData:C,data:C,codeFlowValue:C,definition:s(Y),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(J),hardBreakEscape:s(G),hardBreakTrailing:s(G),htmlFlow:s(Z,i),htmlFlowData:C,htmlText:s(Z,i),htmlTextData:C,image:s(ee),label:i,link:s(te),listItem:s(re),listItemValue:m,listOrdered:s(ne,u),listUnordered:s(ne),paragraph:s(ae),reference:M,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:s(X),strong:s(se),thematicBreak:s(oe)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:H,autolinkProtocol:q,blockQuote:l(),characterEscapeValue:S,characterReferenceMarkerHexadecimal:$,characterReferenceMarkerNumeric:$,characterReferenceValue:B,characterReference:V,codeFenced:l(g),codeFencedFence:h,codeFencedFenceInfo:f,codeFencedFenceMeta:p,codeFlowValue:S,codeIndented:l(x),codeText:l(P),codeTextData:S,data:S,definition:l(),definitionDestinationString:b,definitionLabelString:y,definitionTitleString:v,emphasis:l(),hardBreakEscape:l(I),hardBreakTrailing:l(I),htmlFlow:l(T),htmlFlowData:S,htmlText:l(A),htmlTextData:S,image:l(F),label:D,labelText:R,lineEnding:E,link:l(_),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:U,resourceDestinationString:O,resourceTitleString:z,resource:L,setextHeading:l(k),setextHeadingLineSequence:N,setextHeadingText:j,strong:l(),thematicBreak:l()}};jm(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(e){let r={type:"root",children:[]};const s={stack:[r],tokenStack:[],config:t,enter:o,exit:c,buffer:i,resume:d,data:n},l=[];let u=-1;for(;++u<e.length;)if("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)if("enter"===e[u][0])l.push(u);else{u=a(e,l.pop(),u)}for(u=-1;++u<e.length;){const n=t[e[u][0]];vm.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},s),e[u][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||km).call(s,void 0,e[0])}for(r.position={start:wm(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:wm(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r}function a(e,t,n){let r,a,s,i,o=t-1,l=-1,c=!1;for(;++o<=n;){const t=e[o];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||i||l||s||(s=o),i=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:i=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let i=o;for(a=void 0;i--;){const t=e[i];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;a&&(e[a][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",a=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}s&&(!a||s<a)&&(r._spread=!0),r.end=Object.assign({},a?e[a][1].start:t[1].end),e.splice(a||o,0,["exit",r,t[2]]),o++,n++}if("listItemPrefix"===t[1].type){const a={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=a,e.splice(o,0,["enter",a,t[2]]),o++,n++,s=void 0,i=!0}}}return e[t][1]._spread=c,n}function s(e,t){return n;function n(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:wm(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){const n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw new Error("Cannot close `"+e.type+"` ("+ld({start:e.start,end:e.end})+"): it’s not open");if(r[0].type!==e.type)if(t)t.call(this,e,r[0]);else{(r[1]||km).call(this,e,r[0])}n.position.end=wm(e.end)}function d(){return Pd(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function m(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function f(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function p(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function y(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Vd(this.sliceSerialize(e)).toLowerCase()}function v(){const e=this.resume();this.stack[this.stack.length-1].title=e}function b(){const e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function j(){this.data.setextHeadingSlurpLineEnding=!0}function N(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function k(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ie(),n.position={start:wm(e.start),end:void 0},t.push(n)),this.stack.push(n)}function S(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=wm(e.end)}function E(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=wm(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(C.call(this,e),S.call(this,e))}function I(){this.data.atHardBreak=!0}function T(){const e=this.resume();this.stack[this.stack.length-1].value=e}function A(){const e=this.resume();this.stack[this.stack.length-1].value=e}function P(){const e=this.resume();this.stack[this.stack.length-1].value=e}function _(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function F(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function R(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(xm,ym)}(t),n.identifier=Vd(t).toLowerCase()}function D(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function O(){const e=this.resume();this.stack[this.stack.length-1].url=e}function z(){const e=this.resume();this.stack[this.stack.length-1].title=e}function L(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function U(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Vd(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function $(e){this.data.characterReferenceType=e.type}function B(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;if(n)r=Bd(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=Dd(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=wm(e.end)}function q(e){S.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function H(e){S.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function W(){return{type:"blockquote",children:[]}}function K(){return{type:"code",lang:null,meta:null,value:""}}function Q(){return{type:"inlineCode",value:""}}function Y(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function J(){return{type:"emphasis",children:[]}}function X(){return{type:"heading",depth:0,children:[]}}function G(){return{type:"break"}}function Z(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function re(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function ae(){return{type:"paragraph",children:[]}}function se(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function oe(){return{type:"thematicBreak"}}}(n)(function(e){for(;!ku(e););return e}(function(e){const t={constructs:Md([pm,...(e||{}).extensions||[]]),content:n(su),defined:[],document:n(iu),flow:n(em),lazy:{},string:n(nm),text:n(rm)};return t;function n(e){return function(n){return hm(t,e,n)}}}(n).document().write(function(){let e,t=1,n="",r=!0;return function(a,s,i){const o=[];let l,c,d,u,m;for(a=n+("string"==typeof a?a.toString():new TextDecoder(s||void 0).decode(a)),d=0,n="",r&&(65279===a.charCodeAt(0)&&d++,r=void 0);d<a.length;){if(gm.lastIndex=d,l=gm.exec(a),u=l&&void 0!==l.index?l.index:a.length,m=a.charCodeAt(u),!l){n=a.slice(d);break}if(10===m&&d===u&&e)o.push(-3),e=void 0;else switch(e&&(o.push(-5),e=void 0),d<u&&(o.push(a.slice(d,u)),t+=u-d),m){case 0:o.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),o.push(-2);t++<c;)o.push(-1);break;case 10:o.push(-4),t=1;break;default:e=!0,t=1}d=u+1}return i&&(e&&o.push(-5),n&&o.push(n),o.push(null)),o}}()(e,t,!0))))}function wm(e){return{line:e.line,column:e.column,offset:e.offset}}function jm(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?jm(e,r):Nm(e,r)}}function Nm(e,t){let n;for(n in t)if(vm.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function km(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ld({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ld({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ld({start:t.start,end:t.end})+") is still open")}function Cm(e){const t=this;t.parser=function(n){return bm(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Sm(e,t){const n=t.referenceType;let r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),s=a[0];s&&"text"===s.type?s.value="["+s.value:a.unshift({type:"text",value:"["});const i=a[a.length-1];return i&&"text"===i.type?i.value+=r:a.push({type:"text",value:r}),a}function Em(e){const t=e.spread;return null==t?e.children.length>1:t}function Im(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const s=[];for(;r;)s.push(Tm(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return s.push(Tm(t.slice(a),a>0,!1)),s.join("")}function Tm(e,t,n){let r=0,a=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(a-1);for(;9===t||32===t;)a--,t=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}const Am={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",r={};t.lang&&(r.className=["language-"+t.lang]);let a={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:"element",tagName:"pre",properties:{},children:[a]},e.patch(t,a),a},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=ru(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let i,o=e.footnoteCounts.get(r);void 0===o?(o=0,e.footnoteOrder.push(r),i=e.footnoteOrder.length):i=s+1,o+=1,e.footnoteCounts.set(r,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Sm(e,t);const a={src:ru(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(a.title=r.title);const s={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){const n={src:ru(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Sm(e,t);const a={href:ru(r.url||"")};null!==r.title&&void 0!==r.title&&(a.title=r.title);const s={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){const n={href:ru(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){const r=e.all(t),a=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Em(n[r])}return t}(n):Em(t),s={},i=[];if("boolean"==typeof t.checked){const e=r[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<r.length;){const e=r[o];(a||0!==o||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||a?i.push(e):i.push(...e.children)}const l=r[r.length-1];l&&(a||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:s,children:i};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},r=e.all(t);let a=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++a<r.length;){const e=r[a];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),a.push(n)}if(n.length>0){const r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},s=id(t.children[1]),i=sd(t.children[t.children.length-1]);s&&i&&(r.position={start:s,end:i}),a.push(r)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,s),e.applyData(t,s)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const r=n?n.children:void 0,a=0===(r?r.indexOf(t):1)?"th":"td",s=n&&"table"===n.type?n.align:void 0,i=s?s.length:t.children.length;let o=-1;const l=[];for(;++o<i;){const n=t.children[o],r={},i=s?s[o]:void 0;i&&(r.align=i);let c={type:"element",tagName:a,properties:r,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){const n={type:"text",value:Im(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:Pm,yaml:Pm,definition:Pm,footnoteDefinition:Pm};function Pm(){}const _m="object"==typeof self?self:globalThis,Fm=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),r=a=>{if(e.has(a))return e.get(a);const[s,i]=t[a];switch(s){case 0:case-1:return n(i,a);case 1:{const e=n([],a);for(const t of i)e.push(r(t));return e}case 2:{const e=n({},a);for(const[t,n]of i)e[r(t)]=r(n);return e}case 3:return n(new Date(i),a);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),a)}case 5:{const e=n(new Map,a);for(const[t,n]of i)e.set(r(t),r(n));return e}case 6:{const e=n(new Set,a);for(const t of i)e.add(r(t));return e}case 7:{const{name:e,message:t}=i;return n(new _m[e](t),a)}case 8:return n(BigInt(i),a);case"BigInt":return n(Object(BigInt(i)),a);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:e}=new Uint8Array(i);return n(new DataView(e),i)}}return n(new _m[s](i),a)};return r})(new Map,e)(0),Rm="",{toString:Dm}={},{keys:Om}=Object,zm=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=Dm.call(e).slice(8,-1);switch(n){case"Array":return[1,Rm];case"Object":return[2,Rm];case"Date":return[3,Rm];case"RegExp":return[4,Rm];case"Map":return[5,Rm];case"Set":return[6,Rm];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Lm=([e,t])=>0===e&&("function"===t||"symbol"===t),Mm=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const a=(e,t)=>{const a=r.push(e)-1;return n.set(t,a),a},s=r=>{if(n.has(r))return n.get(r);let[i,o]=zm(r);switch(i){case 0:{let t=r;switch(o){case"bigint":i=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);t=null;break;case"undefined":return a([-1],r)}return a([i,t],r)}case 1:{if(o){let e=r;return"DataView"===o?e=new Uint8Array(r.buffer):"ArrayBuffer"===o&&(e=new Uint8Array(r)),a([o,[...e]],r)}const e=[],t=a([i,e],r);for(const n of r)e.push(s(n));return t}case 2:{if(o)switch(o){case"BigInt":return a([o,r.toString()],r);case"Boolean":case"Number":case"String":return a([o,r.valueOf()],r)}if(t&&"toJSON"in r)return s(r.toJSON());const n=[],l=a([i,n],r);for(const t of Om(r))!e&&Lm(zm(r[t]))||n.push([s(t),s(r[t])]);return l}case 3:return a([i,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return a([i,{source:e,flags:t}],r)}case 5:{const t=[],n=a([i,t],r);for(const[a,i]of r)(e||!Lm(zm(a))&&!Lm(zm(i)))&&t.push([s(a),s(i)]);return n}case 6:{const t=[],n=a([i,t],r);for(const a of r)!e&&Lm(zm(a))||t.push(s(a));return n}}const{message:l}=r;return a([i,{name:o,message:l}],r)};return s})(!(t||n),!!t,new Map,r)(e),r};var Um="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Fm(Mm(e,t)):structuredClone(e):(e,t)=>Fm(Mm(e,t));function $m(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Bm(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Vm=function(e){if(null==e)return Hm;if("function"==typeof e)return qm(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Vm(e[n]);return qm(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}(e):function(e){const t=e;return qm(n);function n(n){const r=n;let a;for(a in e)if(r[a]!==t[a])return!1;return!0}}(e);if("string"==typeof e)return function(e){return qm(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function qm(e){return function(t,n,r){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function Hm(){return!0}const Wm=[],Km=!0,Qm=!1;function Ym(e,t,n,r){let a;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):a=t;const s=Vm(a),i=r?-1:1;!function e(a,o,l){const c=a&&"object"==typeof a?a:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+a.type+(e?"<"+e+">":"")+")"})}return d;function d(){let c,d,u,m=Wm;if((!t||s(a,o,l[l.length-1]||void 0))&&(m=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[Km,e];return null==e?Wm:[e]}(n(a,l)),m[0]===Qm))return m;if("children"in a&&a.children){const t=a;if(t.children&&"skip"!==m[0])for(d=(r?t.children.length:-1)+i,u=l.concat(t);d>-1&&d<t.children.length;){const n=t.children[d];if(c=e(n,d,u)(),c[0]===Qm)return c;d="number"==typeof c[1]?c[1]:d+i}}return m}}(e,void 0,[])()}function Jm(e,t,n,r){let a,s,i;"function"==typeof t&&"function"!=typeof n?(s=void 0,i=t,a=n):(s=t,i=n,a=r),Ym(e,s,function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return i(e,r,n)},a)}const Xm={}.hasOwnProperty,Gm={};function Zm(e,t){e.position&&(t.position=function(e){const t=id(e),n=sd(e);if(t&&n)return{start:t,end:n}}(e))}function ef(e,t){let n=t;if(e&&e.data){const t=e.data.hName,r=e.data.hChildren,a=e.data.hProperties;if("string"==typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&a&&Object.assign(n.properties,Um(a)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function tf(e,t){const n=t.data||{},r=!("value"in t)||Xm.call(n,"hProperties")||Xm.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,r),e.applyData(t,r)}function nf(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function rf(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function af(e,t){const n=function(e,t){const n=t||Gm,r=new Map,a=new Map,s=new Map,i={...Am,...n.handlers},o={all:function(e){const t=[];if("children"in e){const n=e.children;let r=-1;for(;++r<n.length;){const a=o.one(n[r],e);if(a){if(r&&"break"===n[r-1].type&&(Array.isArray(a)||"text"!==a.type||(a.value=rf(a.value)),!Array.isArray(a)&&"element"===a.type)){const e=a.children[0];e&&"text"===e.type&&(e.value=rf(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:ef,definitionById:r,footnoteById:a,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=o.handlers[n];if(Xm.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,r=Um(n);return r.children=o.all(e),r}return Um(e)}return(o.options.unknownHandler||tf)(o,e,t)},options:n,patch:Zm,wrap:nf};return Jm(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?r:a,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o}(e,t),r=n.one(e,void 0),a=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||$m,r=e.options.footnoteBackLabel||Bm,a=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const a=e.footnoteById.get(e.footnoteOrder[l]);if(!a)continue;const s=e.all(a),i=String(a.identifier).toUpperCase(),c=ru(i.toLowerCase());let d=0;const u=[],m=e.footnoteCounts.get(i);for(;void 0!==m&&++d<=m;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const f=s[s.length-1];if(f&&"element"===f.type&&"p"===f.tagName){const e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...u)}else s.push(...u);const p={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(a,p),o.push(p)}if(0!==o.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Um(i),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:"\n"}]}}(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&s.children.push({type:"text",value:"\n"},a),s}function sf(e,t){return e&&"run"in e?async function(n,r){const a=af(n,{file:r,...t});await e.run(a,r)}:function(n,r){return af(n,{file:r,...e||t})}}function of(e){if(e)throw e}var lf,cf;var df=function(){if(cf)return lf;cf=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===t.call(e)},s=function(n){if(!n||"[object Object]"!==t.call(n))return!1;var r,a=e.call(n,"constructor"),s=n.constructor&&n.constructor.prototype&&e.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!a&&!s)return!1;for(r in n);return void 0===r||e.call(n,r)},i=function(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},o=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(r)return r(t,n).value}return t[n]};return lf=function e(){var t,n,r,l,c,d,u=arguments[0],m=1,f=arguments.length,p=!1;for("boolean"==typeof u&&(p=u,u=arguments[1]||{},m=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});m<f;++m)if(null!=(t=arguments[m]))for(n in t)r=o(u,n),u!==(l=o(t,n))&&(p&&l&&(s(l)||(c=a(l)))?(c?(c=!1,d=r&&a(r)?r:[]):d=r&&s(r)?r:{},i(u,{name:n,newValue:e(p,d,l)})):void 0!==l&&i(u,{name:n,newValue:l}));return u},lf}(),uf=Pt(df);function mf(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function ff(){const e=[],t={run:function(...t){let n=-1;const r=t.pop();if("function"!=typeof r)throw new TypeError("Expected function as last argument, not "+r);!function a(s,...i){const o=e[++n];let l=-1;if(s)r(s);else{for(;++l<t.length;)null!==i[l]&&void 0!==i[l]||(i[l]=t[l]);t=i,o?function(e,t){let n;return r;function r(...t){const r=e.length>t.length;let o;r&&t.push(a);try{o=e.apply(this,t)}catch(s){if(r&&n)throw s;return a(s)}r||(o&&o.then&&"function"==typeof o.then?o.then(i,a):o instanceof Error?a(o):i(o))}function a(e,...r){n||(n=!0,t(e,...r))}function i(e){a(null,e)}}(o,a)(...i):r(null,...i)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const pf={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');hf(e);let n,r=0,a=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else a<0&&(n=!0,a=s+1);return a<0?"":e.slice(r,a)}if(t===e)return"";let i=-1,o=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else i<0&&(n=!0,i=s+1),o>-1&&(e.codePointAt(s)===t.codePointAt(o--)?o<0&&(a=s):(o=-1,a=i));r===a?a=i:a<0&&(a=e.length);return e.slice(r,a)},dirname:function(e){if(hf(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){hf(e);let t,n=e.length,r=-1,a=0,s=-1,i=0;for(;n--;){const o=e.codePointAt(n);if(47!==o)r<0&&(t=!0,r=n+1),46===o?s<0?s=n:1!==i&&(i=1):s>-1&&(i=-1);else if(t){a=n+1;break}}if(s<0||r<0||0===i||1===i&&s===r-1&&s===a+1)return"";return e.slice(s,r)},join:function(...e){let t,n=-1;for(;++n<e.length;)hf(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){hf(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,a="",s=0,i=-1,o=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else{if(47===n)break;n=47}if(47===n){if(i===l-1||1===o);else if(i!==l-1&&2===o){if(a.length<2||2!==s||46!==a.codePointAt(a.length-1)||46!==a.codePointAt(a.length-2))if(a.length>2){if(r=a.lastIndexOf("/"),r!==a.length-1){r<0?(a="",s=0):(a=a.slice(0,r),s=a.length-1-a.lastIndexOf("/")),i=l,o=0;continue}}else if(a.length>0){a="",s=0,i=l,o=0;continue}t&&(a=a.length>0?a+"/..":"..",s=2)}else a.length>0?a+="/"+e.slice(i+1,l):a=e.slice(i+1,l),s=l-i-1;i=l,o=0}else 46===n&&o>-1?o++:o=-1}return a}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function hf(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const gf={cwd:function(){return"/"}};function xf(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function yf(e){if("string"==typeof e)e=new URL(e);else if(!xf(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const vf=["history","path","basename","stem","extname","dirname"];class bf{constructor(e){let t;t=e?xf(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":gf.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<vf.length;){const e=vf[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)vf.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?pf.basename(this.path):void 0}set basename(e){jf(e,"basename"),wf(e,"basename"),this.path=pf.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?pf.dirname(this.path):void 0}set dirname(e){Nf(this.basename,"dirname"),this.path=pf.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?pf.extname(this.path):void 0}set extname(e){if(wf(e,"extname"),Nf(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=pf.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){xf(e)&&(e=yf(e)),jf(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?pf.basename(this.path,this.extname):void 0}set stem(e){jf(e,"stem"),wf(e,"stem"),this.path=pf.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){const r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){const r=new md(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function wf(e,t){if(e&&e.includes(pf.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+pf.sep+"`")}function jf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Nf(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const kf=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},Cf={}.hasOwnProperty;class Sf extends kf{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=ff()}copy(){const e=new Sf;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(uf(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(Af("data",this.frozen),this.namespace[e]=t,this):Cf.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Af("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=Ff(e),n=this.parser||this.Parser;return If("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),If("process",this.parser||this.Parser),Tf("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,a){const s=Ff(e),i=n.parse(s);function o(e,n){e||!n?a(e):r?r(n):t(void 0,n)}n.run(i,s,function(e,t,r){if(e||!t||!r)return o(e);const a=t,s=n.stringify(a,r);!function(e){return"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)}(s)?r.result=s:r.value=s,o(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),If("processSync",this.parser||this.Parser),Tf("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,of(e),t=r}),_f("processSync","process",n),t}run(e,t,n){Pf(e),this.freeze();const r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?a(void 0,n):new Promise(a);function a(a,s){const i=Ff(t);r.run(e,i,function(t,r,i){const o=r||e;t?s(t):a?a(o):n(void 0,o,i)})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){of(e),n=t,r=!0}),_f("runSync","run",r),n}stringify(e,t){this.freeze();const n=Ff(t),r=this.compiler||this.Compiler;return Tf("stringify",r),Pf(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(Af("use",this.frozen),null==e);else if("function"==typeof e)o(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?i(e):s(e)}return this;function a(e){if("function"==typeof e)o(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;o(t,n)}else s(e)}}function s(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(r.settings=uf(!0,r.settings,e.settings))}function i(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){a(e[t])}}}function o(e,t){let r=-1,a=-1;for(;++r<n.length;)if(n[r][0]===e){a=r;break}if(-1===a)n.push([e,...t]);else if(t.length>0){let[r,...s]=t;const i=n[a][1];mf(i)&&mf(r)&&(r=uf(!0,i,r)),n[a]=[e,r,...s]}}}}const Ef=(new Sf).freeze();function If(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Tf(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function Af(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Pf(e){if(!mf(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function _f(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ff(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new bf(e)}const Rf=[],Df={allowDangerousHtml:!0},Of=/^(https?|ircs?|mailto|xmpp)$/i,zf=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Lf(e){const t=function(e){const t=e.rehypePlugins||Rf,n=e.remarkPlugins||Rf,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Df}:Df,a=Ef().use(Cm).use(n).use(sf,r).use(t);return a}(e),n=function(e){const t=e.children||"",n=new bf;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,s=t.disallowedElements,i=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||Mf;for(const d of zf)Object.hasOwn(t,d.from)&&ic((d.from,d.to&&d.to,d.id));return Jm(e,c),vd(e,{Fragment:Mt.Fragment,components:a,ignoreInvalidStyle:!0,jsx:Mt.jsx,jsxs:Mt.jsxs,passKeys:!0,passNode:!0});function c(e,t,a){if("raw"===e.type&&a&&"number"==typeof t)return i?a.children.splice(t,1):a.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in Td)if(Object.hasOwn(Td,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=Td[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let i=n?!n.includes(e.tagName):!!s&&s.includes(e.tagName);if(!i&&r&&"number"==typeof t&&(i=!r(e,t,a)),i&&a&&"number"==typeof t)return o&&e.children?a.children.splice(t,1,...e.children):a.children.splice(t,1),t}}}(t.runSync(t.parse(n),n),e)}function Mf(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return-1===t||-1!==a&&t>a||-1!==n&&t>n||-1!==r&&t>r||Of.test(e.slice(0,t))?e:""}function Uf(e,t){const n=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;-1!==a;)r++,a=n.indexOf(t,a+t.length);return r}function $f(e,t,n){const r=Vm((n||{}).ignore||[]),a=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const e=n[r];t.push([Bf(e[0]),Vf(e[1])])}return t}(t);let s=-1;for(;++s<a.length;)Ym(e,"text",i);function i(e,t){let n,i=-1;for(;++i<t.length;){const e=t[i],a=n?n.children:void 0;if(r(e,a?a.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){const n=t[t.length-1],r=a[s][0],i=a[s][1];let o=0;const l=n.children.indexOf(e);let c=!1,d=[];r.lastIndex=0;let u=r.exec(e.value);for(;u;){const n=u.index,a={index:u.index,input:u.input,stack:[...t,e]};let s=i(...u,a);if("string"==typeof s&&(s=s.length>0?{type:"text",value:s}:void 0),!1===s?r.lastIndex=n+1:(o!==n&&d.push({type:"text",value:e.value.slice(o,n)}),Array.isArray(s)?d.push(...s):s&&d.push(s),o=n+u[0].length,c=!0),!r.global)break;u=r.exec(e.value)}c?(o<e.value.length&&d.push({type:"text",value:e.value.slice(o)}),n.children.splice(l,1,...d)):d=[e];return l+d.length}(e,t)}}function Bf(e){return"string"==typeof e?new RegExp(function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e),"g"):e}function Vf(e){return"function"==typeof e?e:function(){return e}}const qf="phrasing",Hf=["autolink","link","image","label"];function Wf(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Kf(e){this.config.enter.autolinkProtocol.call(this,e)}function Qf(e){this.config.exit.autolinkProtocol.call(this,e)}function Yf(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Jf(e){this.config.exit.autolinkEmail.call(this,e)}function Xf(e){this.exit(e)}function Gf(e){$f(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Zf],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,ep]],{ignore:["link","linkReference"]})}function Zf(e,t,n,r,a){let s="";if(!tp(a))return!1;if(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!function(e){const t=e.split(".");if(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))return!1;return!0}(n))return!1;const i=function(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=Uf(e,"(");let s=Uf(e,")");for(;-1!==r&&a>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}(n+r);if(!i[0])return!1;const o={type:"link",title:null,url:s+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[o,{type:"text",value:i[1]}]:o}function ep(e,t,n,r){return!(!tp(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function tp(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||tu(n)||eu(n))&&(!t||47!==n)}function np(){this.buffer()}function rp(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function ap(){this.buffer()}function sp(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ip(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Vd(this.sliceSerialize(e)).toLowerCase(),n.label=t}function op(e){this.exit(e)}function lp(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Vd(this.sliceSerialize(e)).toLowerCase(),n.label=t}function cp(e){this.exit(e)}function dp(e,t,n,r){const a=n.createTracker(r);let s=a.move("[^");const i=n.enter("footnoteReference"),o=n.enter("reference");return s+=a.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),i(),s+=a.move("]"),s}function up(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,n,r,a){const s=r.createTracker(a);let i=s.move("[^");const o=r.enter("footnoteDefinition"),l=r.enter("label");i+=s.move(r.safe(r.associationId(e),{before:i,after:"]"})),l(),i+=s.move("]:"),e.children&&e.children.length>0&&(s.shift(4),i+=s.move((t?"\n":" ")+r.indentLines(r.containerFlow(e,s.current()),t?fp:mp)));return o(),i},footnoteReference:dp},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function mp(e,t,n){return 0===t?e:fp(e,t,n)}function fp(e,t,n){return(n?"":" ")+e}dp.peek=function(){return"["};const pp=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function hp(e){this.enter({type:"delete",children:[]},e)}function gp(e){this.exit(e)}function xp(e,t,n,r){const a=n.createTracker(r),s=n.enter("strikethrough");let i=a.move("~~");return i+=n.containerPhrasing(e,{...a.current(),before:i,after:"~"}),i+=a.move("~~"),s(),i}function yp(e){return e.length}function vp(e){return null==e?"":String(e)}function bp(e){const t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function wp(e,t,n){return">"+(n?"":" ")+e}function jp(e,t){return Np(e,t.inConstruct,!0)&&!Np(e,t.notInConstruct,!1)}function Np(e,t,n){if("string"==typeof t&&(t=[t]),!t||0===t.length)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function kp(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if("\n"===n.unsafe[a].character&&jp(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function Cp(e,t,n){return(n?"":" ")+e}function Sp(e){const t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Ep(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ip(e,t,n){const r=lu(e),a=lu(t);return void 0===r?void 0===a?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===a?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===r?void 0===a?{inside:!1,outside:!1}:1===a?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===a?{inside:!1,outside:!1}:1===a?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function Tp(e,t,n,r){const a=function(e){const t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),s=n.enter("emphasis"),i=n.createTracker(r),o=i.move(a);let l=i.move(n.containerPhrasing(e,{after:a,before:o,...i.current()}));const c=l.charCodeAt(0),d=Ip(r.before.charCodeAt(r.before.length-1),c,a);d.inside&&(l=Ep(c)+l.slice(1));const u=l.charCodeAt(l.length-1),m=Ip(r.after.charCodeAt(0),u,a);m.inside&&(l=l.slice(0,-1)+Ep(u));const f=i.move(a);return s(),n.attentionEncodeSurroundingInfo={after:m.outside,before:d.outside},o+l+f}function Ap(e){return e.value||""}function Pp(e,t,n,r){const a=Sp(n),s='"'===a?"Quote":"Apostrophe",i=n.enter("image");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(e.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+a),c+=l.move(n.safe(e.title,{before:c,after:a,...l.current()})),c+=l.move(a),o()),c+=l.move(")"),i(),c}function _p(e,t,n,r){const a=e.referenceType,s=n.enter("imageReference");let i=n.enter("label");const o=n.createTracker(r);let l=o.move("![");const c=n.safe(e.alt,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=d,s(),"full"!==a&&c&&c===u?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(u+"]"),l}function Fp(e,t,n){let r=e.value||"",a="`",s=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const e=n.unsafe[s],t=n.compilePattern(e);let a;if(e.atBreak)for(;a=t.exec(r);){let e=a.index;10===r.charCodeAt(e)&&13===r.charCodeAt(e-1)&&e--,r=r.slice(0,e)+" "+r.slice(a.index+1)}}return a+r+a}function Rp(e,t){const n=Pd(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function Dp(e,t,n,r){const a=Sp(n),s='"'===a?"Quote":"Apostrophe",i=n.createTracker(r);let o,l;if(Rp(e,n)){const t=n.stack;n.stack=[],o=n.enter("autolink");let r=i.move("<");return r+=i.move(n.containerPhrasing(e,{before:r,after:">",...i.current()})),r+=i.move(">"),o(),n.stack=t,r}o=n.enter("link"),l=n.enter("label");let c=i.move("[");return c+=i.move(n.containerPhrasing(e,{before:c,after:"](",...i.current()})),c+=i.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=i.move("<"),c+=i.move(n.safe(e.url,{before:c,after:">",...i.current()})),c+=i.move(">")):(l=n.enter("destinationRaw"),c+=i.move(n.safe(e.url,{before:c,after:e.title?" ":")",...i.current()}))),l(),e.title&&(l=n.enter(`title${s}`),c+=i.move(" "+a),c+=i.move(n.safe(e.title,{before:c,after:a,...i.current()})),c+=i.move(a),l()),c+=i.move(")"),o(),c}function Op(e,t,n,r){const a=e.referenceType,s=n.enter("linkReference");let i=n.enter("label");const o=n.createTracker(r);let l=o.move("[");const c=n.containerPhrasing(e,{before:l,after:"]",...o.current()});l+=o.move(c+"]["),i();const d=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=d,s(),"full"!==a&&c&&c===u?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(u+"]"),l}function zp(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Lp(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}xp.peek=function(){return"~"},Tp.peek=function(e,t,n){return n.options.emphasis||"*"},Ap.peek=function(){return"<"},Pp.peek=function(){return"!"},_p.peek=function(){return"!"},Fp.peek=function(){return"`"},Dp.peek=function(e,t,n){return Rp(e,n)?"<":"["},Op.peek=function(){return"["};const Mp=Vm(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Up(e,t,n,r){const a=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),s=n.enter("strong"),i=n.createTracker(r),o=i.move(a+a);let l=i.move(n.containerPhrasing(e,{after:a,before:o,...i.current()}));const c=l.charCodeAt(0),d=Ip(r.before.charCodeAt(r.before.length-1),c,a);d.inside&&(l=Ep(c)+l.slice(1));const u=l.charCodeAt(l.length-1),m=Ip(r.after.charCodeAt(0),u,a);m.inside&&(l=l.slice(0,-1)+Ep(u));const f=i.move(a+a);return s(),n.attentionEncodeSurroundingInfo={after:m.outside,before:d.outside},o+l+f}Up.peek=function(e,t,n){return n.options.strong||"*"};const $p={blockquote:function(e,t,n,r){const a=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const i=n.indentLines(n.containerFlow(e,s.current()),wp);return a(),i},break:kp,code:function(e,t,n,r){const a=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),s=e.value||"",i="`"===a?"GraveAccent":"Tilde";if(function(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(s,Cp);return e(),t}const o=n.createTracker(r),l=a.repeat(Math.max(function(e,t){const n=String(e);let r=n.indexOf(t),a=r,s=0,i=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==r;)r===a?++s>i&&(i=s):s=1,a=r+t.length,r=n.indexOf(t,a);return i}(s,a)+1,3)),c=n.enter("codeFenced");let d=o.move(l);if(e.lang){const t=n.enter(`codeFencedLang${i}`);d+=o.move(n.safe(e.lang,{before:d,after:" ",encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${i}`);d+=o.move(" "),d+=o.move(n.safe(e.meta,{before:d,after:"\n",encode:["`"],...o.current()})),t()}return d+=o.move("\n"),s&&(d+=o.move(s+"\n")),d+=o.move(l),c(),d},definition:function(e,t,n,r){const a=Sp(n),s='"'===a?"Quote":"Apostrophe",i=n.enter("definition");let o=n.enter("label");const l=n.createTracker(r);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),o(),e.title&&(o=n.enter(`title${s}`),c+=l.move(" "+a),c+=l.move(n.safe(e.title,{before:c,after:a,...l.current()})),c+=l.move(a),o()),i(),c},emphasis:Tp,hardBreak:kp,heading:function(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(function(e,t){let n=!1;return Jm(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,Qm}),Boolean((!e.depth||e.depth<3)&&Pd(e)&&(t.options.setext||n))}(e,n)){const t=n.enter("headingSetext"),r=n.enter("phrasing"),i=n.containerPhrasing(e,{...s.current(),before:"\n",after:"\n"});return r(),t(),i+"\n"+(1===a?"=":"-").repeat(i.length-(Math.max(i.lastIndexOf("\r"),i.lastIndexOf("\n"))+1))}const i="#".repeat(a),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(i+" ");let c=n.containerPhrasing(e,{before:"# ",after:"\n",...s.current()});return/^[\t ]/.test(c)&&(c=Ep(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),o(),c},html:Ap,image:Pp,imageReference:_p,inlineCode:Fp,link:Dp,linkReference:Op,list:function(e,t,n,r){const a=n.enter("list"),s=n.bulletCurrent;let i=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):zp(n);const o=e.ordered?"."===i?")":".":function(e){const t=zp(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let l=!(!t||!n.bulletLastUsed)&&i===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==i&&"-"!==i||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(l=!0),Lp(n)===i&&t){let t=-1;for(;++t<e.children.length;){const n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){l=!0;break}}}}l&&(i=o),n.bulletCurrent=i;const c=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=s,a(),c},listItem:function(e,t,n,r){const a=function(e){const t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n);let s=n.bulletCurrent||zp(n);t&&"list"===t.type&&t.ordered&&(s=("number"==typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+s);let i=s.length+1;("tab"===a||"mixed"===a&&(t&&"list"===t.type&&t.spread||e.spread))&&(i=4*Math.ceil(i/4));const o=n.createTracker(r);o.move(s+" ".repeat(i-s.length)),o.shift(i);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),function(e,t,n){if(t)return(n?"":" ".repeat(i))+e;return(n?s:s+" ".repeat(i-s.length))+e});return l(),c},paragraph:function(e,t,n,r){const a=n.enter("paragraph"),s=n.enter("phrasing"),i=n.containerPhrasing(e,r);return s(),a(),i},root:function(e,t,n,r){return(e.children.some(function(e){return Mp(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:Up,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(Lp(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}};function Bp(e){const t=e._align;this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function Vp(e){this.exit(e),this.data.inTable=void 0}function qp(e){this.enter({type:"tableRow",children:[]},e)}function Hp(e){this.exit(e)}function Wp(e){this.enter({type:"tableCell",children:[]},e)}function Kp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Qp));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Qp(e,t){return"|"===t?t:e}function Yp(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let r=$p.inlineCode(e,t,n);n.stack.includes("tableCell")&&(r=r.replace(/\|/g,"\\$&"));return r},table:function(e,t,n,r){return o(function(e,t,n){const r=e.children;let a=-1;const s=[],i=t.enter("table");for(;++a<r.length;)s[a]=l(r[a],t,n);return i(),s}(e,n,r),e.align)},tableCell:i,tableRow:function(e,t,n,r){const a=l(e,n,r),s=o([a]);return s.slice(0,s.indexOf("\n"))}}};function i(e,t,n,r){const a=n.enter("tableCell"),i=n.enter("phrasing"),o=n.containerPhrasing(e,{...r,before:s,after:s});return i(),a(),o}function o(e,t){return function(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||yp,s=[],i=[],o=[],l=[];let c=0,d=-1;for(;++d<e.length;){const t=[],r=[];let s=-1;for(e[d].length>c&&(c=e[d].length);++s<e[d].length;){const i=vp(e[d][s]);if(!1!==n.alignDelimiters){const e=a(i);r[s]=e,(void 0===l[s]||e>l[s])&&(l[s]=e)}t.push(i)}i[d]=t,o[d]=r}let u=-1;if("object"==typeof r&&"length"in r)for(;++u<c;)s[u]=bp(r[u]);else{const e=bp(r);for(;++u<c;)s[u]=e}u=-1;const m=[],f=[];for(;++u<c;){const e=s[u];let t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let a=!1===n.alignDelimiters?1:Math.max(1,l[u]-t.length-r.length);const i=t+"-".repeat(a)+r;!1!==n.alignDelimiters&&(a=t.length+a+r.length,a>l[u]&&(l[u]=a),f[u]=a),m[u]=i}i.splice(1,0,m),o.splice(1,0,f),d=-1;const p=[];for(;++d<i.length;){const e=i[d],t=o[d];u=-1;const r=[];for(;++u<c;){const a=e[u]||"";let i="",o="";if(!1!==n.alignDelimiters){const e=l[u]-(t[u]||0),n=s[u];114===n?i=" ".repeat(e):99===n?e%2?(i=" ".repeat(e/2+.5),o=" ".repeat(e/2-.5)):(i=" ".repeat(e/2),o=i):o=" ".repeat(e)}!1===n.delimiterStart||u||r.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===a||!1===n.delimiterStart&&!u||r.push(" "),!1!==n.alignDelimiters&&r.push(i),r.push(a),!1!==n.alignDelimiters&&r.push(o),!1!==n.padding&&r.push(" "),!1===n.delimiterEnd&&u===c-1||r.push("|")}p.push(!1===n.delimiterEnd?r.join("").replace(/ +$/,""):r.join(""))}return p.join("\n")}(e,{align:t,alignDelimiters:r,padding:n,stringLength:a})}function l(e,t,n){const r=e.children;let a=-1;const s=[],o=t.enter("tableRow");for(;++a<r.length;)s[a]=i(r[a],0,t,n);return o(),s}}function Jp(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function Xp(e){const t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){const e=this.stack[this.stack.length-1];e.type;const n=e.children[0];if(n&&"text"===n.type){const r=t.children;let a,s=-1;for(;++s<r.length;){const e=r[s];if("paragraph"===e.type){a=e;break}}a===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Gp(e,t,n,r){const a=e.children[0],s="boolean"==typeof e.checked&&a&&"paragraph"===a.type,i="["+(e.checked?"x":" ")+"] ",o=n.createTracker(r);s&&o.move(i);let l=$p.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const Zp={tokenize:function(e,t,n){let r=0;return function t(s){if((87===s||119===s)&&r<3)return r++,e.consume(s),t;if(46===s&&3===r)return e.consume(s),a;return n(s)};function a(e){return null===e?n(e):t(e)}},partial:!0},eh={tokenize:function(e,t,n){let r,a,s;return i;function i(t){return 46===t||95===t?e.check(nh,l,o)(t):null===t||Gd(t)||tu(t)||45!==t&&eu(t)?l(t):(s=!0,e.consume(t),i)}function o(t){return 95===t?r=!0:(a=r,r=void 0),e.consume(t),i}function l(e){return a||r||!s?n(e):t(e)}},partial:!0},th={tokenize:function(e,t){let n=0,r=0;return a;function a(i){return 40===i?(n++,e.consume(i),a):41===i&&r<n?s(i):33===i||34===i||38===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||60===i||63===i||93===i||95===i||126===i?e.check(nh,t,s)(i):null===i||Gd(i)||tu(i)?t(i):(e.consume(i),a)}function s(t){return 41===t&&r++,e.consume(t),a}},partial:!0},nh={tokenize:function(e,t,n){return r;function r(i){return 33===i||34===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||63===i||95===i||126===i?(e.consume(i),r):38===i?(e.consume(i),s):93===i?(e.consume(i),a):60===i||null===i||Gd(i)||tu(i)?t(i):n(i)}function a(e){return null===e||40===e||91===e||Gd(e)||tu(e)?t(e):r(e)}function s(e){return qd(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),r):qd(t)?(e.consume(t),i):n(t)}},partial:!0},rh={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return Hd(e)?n(e):t(e)}},partial:!0},ah={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){if(87!==t&&119!==t||!ch.call(r,r.previous)||fh(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Zp,e.attempt(eh,e.attempt(th,a),n),n)(t)};function a(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:ch},sh={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let a="",s=!1;return function(t){if((72===t||104===t)&&dh.call(r,r.previous)&&!fh(r.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if(qd(t)&&a.length<5)return a+=String.fromCodePoint(t),e.consume(t),i;if(58===t){const n=a.toLowerCase();if("http"===n||"https"===n)return e.consume(t),o}return n(t)}function o(t){return 47===t?(e.consume(t),s?l:(s=!0,o)):n(t)}function l(t){return null===t||Kd(t)||Gd(t)||tu(t)||eu(t)?n(t):e.attempt(eh,e.attempt(th,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:dh},ih={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let a,s;return function(t){if(!mh(t)||!uh.call(r,r.previous)||fh(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return mh(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(rh,c,l)(t):45===t||95===t||Hd(t)?(s=!0,e.consume(t),o):c(t)}function l(t){return e.consume(t),a=!0,o}function c(i){return s&&a&&qd(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:uh},oh={};let lh=48;for(;lh<123;)oh[lh]=ih,lh++,58===lh?lh=65:91===lh&&(lh=97);function ch(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||Gd(e)}function dh(e){return!qd(e)}function uh(e){return!(47===e||mh(e))}function mh(e){return 43===e||45===e||46===e||95===e||Hd(e)}function fh(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if(("labelLink"===r.type||"labelImage"===r.type)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}oh[43]=ih,oh[45]=ih,oh[46]=ih,oh[95]=ih,oh[72]=[ih,sh],oh[104]=[ih,sh],oh[87]=[ih,ah],oh[119]=[ih,ah];const ph={tokenize:function(e,t,n){const r=this;return au(e,function(e){const a=r.events[r.events.length-1];return a&&"gfmFootnoteDefinitionIndent"===a[1].type&&4===a[2].sliceSerialize(a[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function hh(e,t,n){const r=this;let a=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;a--;){const e=r.events[a][1];if("labelImage"===e.type){i=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(a){if(!i||!i._balanced)return n(a);const o=Vd(r.sliceSerialize({start:i.end,end:r.now()}));if(94!==o.codePointAt(0)||!s.includes(o.slice(1)))return n(a);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),t(a)}}function gh(e,t){let n=e.length;for(;n--;)if("labelImage"===e[n][1].type&&"enter"===e[n][0]){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...o),e}function xh(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),o};function o(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(o){if(i>999||93===o&&!s||null===o||91===o||Gd(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return a.includes(Vd(r.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return Gd(o)||(s=!0),i++,e.consume(o),92===o?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),i++,l):l(t)}}function yh(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,i,o=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(o>999||93===t&&!i||null===t||91===t||Gd(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=Vd(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return Gd(t)||(i=!0),o++,e.consume(t),92===t?d:c}function d(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function u(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a.includes(s)||a.push(s),au(e,m,"gfmFootnoteDefinitionWhitespace")):n(t)}function m(e){return t(e)}}function vh(e,t,n){return e.check(fu,t,e.attempt(ph,t,n))}function bh(e){e.exit("gfmFootnoteDefinition")}function wh(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,r){const a=this.previous,s=this.events;let i=0;return function(t){if(126===a&&"characterEscape"!==s[s.length-1][1].type)return r(t);return e.enter("strikethroughSequenceTemporary"),o(t)};function o(s){const l=lu(a);if(126===s)return i>1?r(s):(e.consume(s),i++,o);if(i<2&&!t)return r(s);const c=e.exit("strikethroughSequenceTemporary"),d=lu(s);return c._open=!d||2===d&&Boolean(l),c._close=!l||2===l&&Boolean(d),n(s)}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let r=n;for(;r--;)if("exit"===e[r][0]&&"strikethroughSequenceTemporary"===e[r][1].type&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type="strikethroughSequence",e[r][1].type="strikethroughSequence";const a={type:"strikethrough",start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},s={type:"strikethroughText",start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},i=[["enter",a,t],["enter",e[r][1],t],["exit",e[r][1],t],["enter",s,t]],o=t.parser.constructs.insideSpan.null;o&&Od(i,i.length,0,cu(o,e.slice(r+1,n),t)),Od(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",a,t]]),Od(e,r-1,n-r+3,i),n=r+i.length-2;break}}n=-1;for(;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}};return null==t&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}}class jh{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,r){let a=0;if(0===n&&0===r.length)return;for(;a<e.map.length;){if(e.map[a][0]===t)return e.map[a][1]+=n,void e.map[a][2].push(...r);a+=1}e.map.push([t,n,r])}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length;const n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(const t of r)e.push(t);r=n.pop()}this.map.length=0}}function Nh(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if("enter"===a[0])"tableContent"===a[1].type&&r.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===a[1].type){if("tableDelimiterMarker"===e[t-1][1].type){const e=r.length-1;r[e]="left"===r[e]?"center":"right"}}else if("tableDelimiterRow"===a[1].type)break}else"enter"===a[0]&&"tableDelimiterRow"===a[1].type&&(n=!0);t+=1}return r}function kh(e,t,n){const r=this;let a,s=0,i=0;return function(e){let t=r.events.length-1;for(;t>-1;){const e=r.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const a=t>-1?r.events[t][1].type:null,s="tableHead"===a||"tableRow"===a?b:o;if(s===b&&r.parser.lazy[r.now().line])return n(e);return s(e)};function o(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return l(e);return a=!0,i+=1,l(e)}(t)}function l(t){return null===t?n(t):Xd(t)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u):n(t):Zd(t)?au(e,l,"whitespace")(t):(i+=1,a&&(a=!1,s+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),a=!0,l):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||Gd(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return 92===t||124===t?(e.consume(t),c):c(t)}function u(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter("tableDelimiterRow"),a=!1,Zd(t)?au(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):m(t))}function m(t){return 45===t||58===t?p(t):124===t?(a=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),f):v(t)}function f(t){return Zd(t)?au(e,p,"whitespace")(t):p(t)}function p(t){return 58===t?(i+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),h):45===t?(i+=1,h(t)):null===t||Xd(t)?y(t):v(t)}function h(t){return 45===t?(e.enter("tableDelimiterFiller"),g(t)):v(t)}function g(t){return 45===t?(e.consume(t),g):58===t?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(t))}function x(t){return Zd(t)?au(e,y,"whitespace")(t):y(t)}function y(n){return 124===n?m(n):(null===n||Xd(n))&&a&&s===i?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):v(n)}function v(e){return n(e)}function b(t){return e.enter("tableRow"),w(t)}function w(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),w):null===n||Xd(n)?(e.exit("tableRow"),t(n)):Zd(n)?au(e,w,"whitespace")(n):(e.enter("data"),j(n))}function j(t){return null===t||124===t||Gd(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?N:j)}function N(t){return 92===t||124===t?(e.consume(t),j):j(t)}}function Ch(e,t){let n,r,a,s=-1,i=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],d=!1,u=0;const m=new jh;for(;++s<e.length;){const f=e[s],p=f[1];"enter"===f[0]?"tableHead"===p.type?(d=!1,0!==u&&(Eh(m,t,u,n,r),r=void 0,u=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},m.add(s,0,[["enter",n,t]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(i=!0,a=void 0,l=[0,0,0,0],c=[0,s+1,0,0],d&&(d=!1,r={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},m.add(s,0,[["enter",r,t]])),o="tableDelimiterRow"===p.type?2:r?3:1):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type?"tableCellDivider"===p.type&&(i?i=!1:(0!==l[1]&&(c[0]=c[1],a=Sh(m,t,l,o,void 0,a)),l=c,c=[l[1],s,0,0])):(i=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],a=Sh(m,t,l,o,void 0,a),l=[0,0,0,0]),c[2]=s)):"tableHead"===p.type?(d=!0,u=s):"tableRow"===p.type||"tableDelimiterRow"===p.type?(u=s,0!==l[1]?(c[0]=c[1],a=Sh(m,t,l,o,s,a)):0!==c[1]&&(a=Sh(m,t,c,o,s,a)),o=0):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type||(c[3]=s)}for(0!==u&&Eh(m,t,u,n,r),m.consume(t.events),s=-1;++s<t.events.length;){const e=t.events[s];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=Nh(t.events,s))}return e}function Sh(e,t,n,r,a,s){const i=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},Ih(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=Ih(t.events,n[1]);if(s={type:i,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),0!==n[2]){const a=Ih(t.events,n[2]),s=Ih(t.events,n[3]),i={type:"tableContent",start:Object.assign({},a),end:Object.assign({},s)};if(e.add(n[2],0,[["enter",i,t]]),2!==r){const r=t.events[n[2]],a=t.events[n[3]];if(r[1].end=Object.assign({},a[1].end),r[1].type="chunkText",r[1].contentType="text",n[3]>n[2]+1){const t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[["exit",i,t]])}return void 0!==a&&(s.end=Object.assign({},Ih(t.events,a)),e.add(a,0,[["exit",s,t]]),s=void 0),s}function Eh(e,t,n,r,a){const s=[],i=Ih(t.events,n);a&&(a.end=Object.assign({},i),s.push(["exit",a,t])),r.end=Object.assign({},i),s.push(["exit",r,t]),e.add(n+1,0,s)}function Ih(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const Th={name:"tasklistCheck",tokenize:function(e,t,n){const r=this;return function(t){if(null!==r.previous||!r._gfmTasklistFirstContentOfListItem)return n(t);return e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),a};function a(t){return Gd(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),s):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),s):n(t)}function s(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),i):n(t)}function i(r){return Xd(r)?t(r):Zd(r)?e.check({tokenize:Ah},t,n)(r):n(r)}}};function Ah(e,t,n){return au(e,function(e){return null===e?n(e):t(e)},"whitespace")}const Ph={};function _h(e){const t=e||Ph,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return Md([{text:oh},{document:{91:{name:"gfmFootnoteDefinition",tokenize:yh,continuation:{tokenize:vh},exit:bh}},text:{91:{name:"gfmFootnoteCall",tokenize:xh},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:hh,resolveTo:gh}}},wh(e),{flow:{null:{name:"table",tokenize:kh,resolveAll:Ch}}},{text:{91:Th}}])}(t)),a.push([{transforms:[Gf],enter:{literalAutolink:Wf,literalAutolinkEmail:Kf,literalAutolinkHttp:Kf,literalAutolinkWww:Kf},exit:{literalAutolink:Xf,literalAutolinkEmail:Jf,literalAutolinkHttp:Qf,literalAutolinkWww:Yf}},{enter:{gfmFootnoteCallString:np,gfmFootnoteCall:rp,gfmFootnoteDefinitionLabelString:ap,gfmFootnoteDefinition:sp},exit:{gfmFootnoteCallString:ip,gfmFootnoteCall:op,gfmFootnoteDefinitionLabelString:lp,gfmFootnoteDefinition:cp}},{canContainEols:["delete"],enter:{strikethrough:hp},exit:{strikethrough:gp}},{enter:{table:Bp,tableData:Wp,tableHeader:Wp,tableRow:qp},exit:{codeText:Kp,table:Vp,tableData:Hp,tableHeader:Hp,tableRow:Hp}},{exit:{taskListCheckValueChecked:Jp,taskListCheckValueUnchecked:Jp,paragraph:Xp}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:qf,notInConstruct:Hf},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:qf,notInConstruct:Hf},{character:":",before:"[ps]",after:"\\/",inConstruct:qf,notInConstruct:Hf}]},up(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:pp}],handlers:{delete:xp}},Yp(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Gp}}]}}(t))}function Fh({content:e,className:t}){return Mt.jsx("div",{className:$t("prose prose-sm max-w-none",t),children:Mt.jsx(Lf,{remarkPlugins:[_h],components:{h1:({children:e})=>Mt.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>Mt.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>Mt.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>Mt.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>Mt.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>Mt.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>Mt.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...n})=>e?Mt.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...n,children:t}):Mt.jsx("code",{className:"block bg-muted p-2 rounded text-xs font-mono overflow-x-auto mb-2 text-foreground",...n,children:t}),pre:({children:e})=>Mt.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>Mt.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>Mt.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>Mt.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>Mt.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}function Rh(){const[e,t]=n(!1),[r,a]=n(""),{messages:s,isLoading:i,error:l,sendMessage:d}=ac(),u=c(null),m=c(null);o(()=>{if(u.current){const e=u.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[s]),o(()=>{e&&m.current&&m.current.focus()},[e]),o(()=>{const n=n=>{"Escape"===n.key&&e&&t(!1)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e]);const f=()=>{r.trim()&&!i&&(d(r),a(""))};return Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(Qt,{onClick:()=>t(!e),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e?Mt.jsx(j,{className:"h-6 w-6"}):Mt.jsx(Ue,{className:"h-6 w-6"})}),e&&Mt.jsxs(Zt,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[Mt.jsxs(en,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[Mt.jsx(tn,{className:"text-lg font-semibold",children:"Chat Assistant"}),Mt.jsx(Qt,{variant:"ghost",size:"icon",onClick:()=>t(!1),className:"h-8 w-8",children:Mt.jsx(j,{className:"h-4 w-4"})})]}),Mt.jsxs(rn,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[Mt.jsx(ks,{ref:u,className:"flex-1 px-4",children:Mt.jsxs("div",{className:"space-y-4 py-4",children:[s.map(e=>Mt.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:Mt.jsx("div",{className:"max-w-[80%] rounded-lg px-4 py-2 "+("user"===e.role?"bg-primary text-primary-foreground":"bg-muted"),children:"assistant"===e.role?Mt.jsx(Fh,{content:e.content}):Mt.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),i&&Mt.jsx("div",{className:"flex justify-start",children:Mt.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:Mt.jsxs("div",{className:"flex space-x-2",children:[Mt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),Mt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),Mt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),l&&Mt.jsx("div",{className:"text-center text-sm text-destructive py-2",children:l})]})}),Mt.jsx("div",{className:"border-t p-4",children:Mt.jsxs("div",{className:"flex space-x-2",children:[Mt.jsx(Jt,{ref:m,value:r,onChange:e=>a(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),f())},placeholder:"Digite sua mensagem...",disabled:i,className:"flex-1"}),Mt.jsx(Qt,{onClick:f,disabled:i||!r.trim(),size:"icon",children:Mt.jsx($e,{className:"h-4 w-4"})})]})})]})]})]})}function Dh({open:e,onOpenChange:t,placeId:a,placeName:s,onMakeManager:i,onMakeMembers:o,currentManagerId:l,currentMemberIds:c=[]}){const[d,u]=n([]),[m,f]=n(!1),[p,h]=n(""),{data:g=[],isLoading:x}=Ts({enabled:e}),y=r(()=>{let e=[...g];if(e.sort((e,t)=>{const n=e.userName?.toLowerCase()||"",r=t.userName?.toLowerCase()||"";return n.localeCompare(r)}),p){const t=p.toLowerCase();e=e.filter(e=>e.userName?.toLowerCase().includes(t)||e.userEmail?.toLowerCase().includes(t))}return e},[g,p]),v=e=>{u(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},b=1===d.length,w=d.length>0;return Mt.jsx(sn,{open:e,onOpenChange:t,children:Mt.jsxs(un,{className:"max-w-2xl",children:[Mt.jsx(mn,{children:Mt.jsxs(pn,{className:"flex items-center gap-2",children:[Mt.jsx(Be,{className:"h-5 w-5"}),"Gerenciar Acessos - ",s]})}),Mt.jsxs("div",{className:"relative",children:[Mt.jsx(I,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Mt.jsx(Jt,{placeholder:"Buscar por nome ou email...",value:p,onChange:e=>h(e.target.value),className:"pl-9"})]}),Mt.jsx(ks,{className:"h-[400px] pr-4",children:x?Mt.jsx("div",{className:"space-y-2",children:[...Array(5)].map((e,t)=>Mt.jsx(vr,{className:"h-16 w-full"},t))}):0===y.length?Mt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Mt.jsx(Be,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:p?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):Mt.jsx("div",{className:"space-y-2",children:y.map(e=>{const t=e.userId===l,n=c.includes(e.userId||""),r=d.includes(e.userId||"");return Mt.jsxs("div",{className:$t("flex items-center gap-3 p-3 rounded-lg border transition-colors",r&&"bg-accent border-primary","hover:bg-accent/50 cursor-pointer"),onClick:()=>v(e.userId||""),children:[Mt.jsx(On,{checked:r,onCheckedChange:()=>v(e.userId||""),onClick:e=>e.stopPropagation()}),Mt.jsxs("div",{className:"flex-1",children:[Mt.jsxs("div",{className:"flex items-center gap-2",children:[Mt.jsx("p",{className:"font-medium",children:e.userName}),t&&Mt.jsx(Ve,{className:"h-4 w-4 text-yellow-500"})]}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:e.userEmail})]}),(t||n)&&Mt.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},e.userId)})})}),Mt.jsxs(fn,{className:"flex gap-2 sm:gap-2",children:[Mt.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:d.length>0&&Mt.jsxs("span",{children:[d.length," selecionado(s)"]})}),b&&i&&Mt.jsxs(Qt,{onClick:async()=>{if(i&&1===d.length){f(!0);try{await i(d[0],a),u([])}finally{f(!1)}}},disabled:m,variant:"outline",children:[Mt.jsx(Ve,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),w&&o&&Mt.jsxs(Qt,{onClick:async()=>{if(o&&0!==d.length){f(!0);try{await o(d,a),u([])}finally{f(!1)}}},disabled:m,children:[Mt.jsx(qe,{className:"h-4 w-4 mr-2"}),"Tornar ",d.length>1?"Membros":"Membro"]})]})]})})}function Oh({place:e,level:t=0,manageAccessConfig:r}){const[a,s]=n(!1),[i,o]=n(!1),l=e.subPlaces&&e.subPlaces.length>0,c=e.isActive??!0,d=e.usersCount??0;return Mt.jsxs("div",{children:[Mt.jsxs(_i,{open:a,onOpenChange:s,children:[Mt.jsxs("div",{className:"flex items-center gap-2 py-3 px-4 hover:bg-accent/50 transition-colors",style:{paddingLeft:2*t+1+"rem"},children:[l?Mt.jsxs(Fi,{className:"flex items-center gap-2 flex-1",children:[Mt.jsx(A,{className:$t("h-4 w-4 transition-transform shrink-0",a&&"rotate-90")}),Mt.jsx(ze,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Mt.jsx("span",{className:"font-medium",children:e.name}),Mt.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):Mt.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Mt.jsx("div",{className:"w-4 shrink-0"}),Mt.jsx(ze,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Mt.jsx("span",{className:"font-medium",children:e.name})]}),Mt.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[Mt.jsxs("div",{className:"flex items-center gap-1.5",children:[Mt.jsx(Be,{className:"h-3.5 w-3.5 text-muted-foreground"}),Mt.jsx("span",{className:"text-sm text-muted-foreground",children:d})]}),Mt.jsx(Mn,{variant:c?"default":"secondary",className:"text-xs",children:c?"Ativo":"Inativo"}),r&&Mt.jsx(El,{customActions:[{label:"Gerenciar Acessos",icon:Se,onClick:()=>o(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),l&&Mt.jsx(Ri,{children:e.subPlaces.map(e=>Mt.jsx(Oh,{place:e,level:t+1,manageAccessConfig:r},e.id))})]}),0===t&&Mt.jsx(to,{}),r&&Mt.jsx(Dh,{open:i,onOpenChange:o,placeId:e.id,placeName:e.name,onMakeManager:r.onMakeManager,onMakeMembers:r.onMakeMembers,currentManagerId:r.getCurrentManagerId?.(e.id),currentMemberIds:r.getCurrentMemberIds?.(e.id)})]})}function zh({places:e,isLoading:t,manageAccessConfig:n}){return t?Mt.jsx("div",{className:"flex items-center justify-center py-12",children:Mt.jsxs("div",{className:"text-center space-y-2",children:[Mt.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando locais..."})]})}):e&&0!==e.length?Mt.jsxs("div",{className:"space-y-1",children:[Mt.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),e.map(e=>Mt.jsx(Oh,{place:e,manageAccessConfig:n},e.id))]}):Mt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[Mt.jsx(ze,{className:"h-12 w-12 text-muted-foreground/50"}),Mt.jsxs("div",{children:[Mt.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})}var Lh=Object.defineProperty,Mh=(e,t,n)=>((e,t,n)=>t in e?Lh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const Uh=new class{constructor(){Mh(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=Yr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=_r.getAccessToken();if(!a)throw new Error("Token Qualiex não encontrado");if(!n||""===n.trim())throw new Error("Alias da unidade é obrigatório");const s=new URL(e,this.baseUrl);Object.entries(t).forEach(([e,t])=>{s.searchParams.append(e,t)});const i=await fetch(s.toString(),{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json",Accept:"application/json","un-alias":n}});if(!i.ok){const e=new Error(`API call failed: ${i.status}`);throw e.status=i.status,e}return i.json()}buildHierarchy(e){const t=new Map,n=[];return e.forEach(e=>{t.set(e.id,{...e,subPlaces:[]})}),e.forEach(e=>{const r=t.get(e.id);if(e.parentId){const a=t.get(e.parentId);a?(a.subPlaces=a.subPlaces||[],a.subPlaces.push(r)):n.push(r)}else n.push(r)}),n}async getPlaces(e,t){try{const n=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),r=n.data||n||[];return this.buildHierarchy(r)}catch(n){if(await Yr.handleApiError(n))try{const n=await this.makeApiCall("/api/common/v1/places",{companyId:t},e),r=n.data||n||[];return this.buildHierarchy(r)}catch(r){return Dr.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}return Dr.handleError(n instanceof Error?n.message:"Erro ao buscar locais",!0),[]}}};function $h(e){const t=new Map,n=new Map,r=[];e.forEach(e=>{const r={...e,children:[],level:0};t.set(e.id,r),n.set(e.id_user,r)}),e.forEach(e=>{const a=t.get(e.id);if(e.id_leader){const t=n.get(e.id_leader);if(t)return void t.children.push(a)}r.push(a)});const a=(e,t)=>{e.level=t,e.children.forEach(e=>a(e,t+1))};r.forEach(e=>a(e,0));const s=e=>{e.sort((e,t)=>{const n=e.name||e.id_user||e.email||"",r=t.name||t.id_user||t.email||"";return n.localeCompare(r)}),e.forEach(e=>e.children.length>0&&s(e.children))};return s(r),r}function Bh(e){const t=[],n=e=>{t.push(e),e.children.forEach(n)};return e.forEach(n),t}function Vh(){const{alias:e,isAuthenticated:t}=Ca(),n=_r.getAccessToken(),{data:r=[]}=Ts();return at({queryKey:["leadership",e,r.length],queryFn:async()=>{if(!n||!e)throw new Error("Usuário não autenticado ou unidade não selecionada");const t=Br(),{data:a,error:s}=await t.schema("common").from("leaders").select("*").eq("is_removed",!1).eq("alias",e);if(s)throw new Error("Erro ao buscar hierarquia de liderança");if(!a||0===a.length)return[];const i={};r.forEach(e=>{i[e.userId]={name:e.userName||e.userEmail,email:e.userEmail||""}});const o=a.map(e=>({...e,name:i[e.id_user]?.name||e.id_user,email:i[e.id_user]?.email||"",subordinatesCount:a.filter(t=>t.id_leader===e.id_user).length})),l=new Set(a.map(e=>e.id_user));return new Set(a.filter(e=>e.id_leader&&!l.has(e.id_leader)).map(e=>e.id_leader)).forEach(e=>{const t=i[e];o.push({id:`virtual-${e}`,alias:a[0]?.alias||"",id_user:e,id_leader:null,is_removed:!1,is_active:!0,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),name:t?.name||e,email:t?.email||"",subordinatesCount:a.filter(t=>t.id_leader===e).length})}),$h(o)},enabled:!!n&&!!e&&t&&r.length>0})}function qh(){const e="common",{alias:t}=Ca(),n=rt(),r=Br();return st({mutationFn:async n=>{if(!t)throw new Error("Unidade não selecionada");if(n.id_user===n.id_leader)throw new Error("Usuário não pode ser seu próprio líder");if((await r.schema(e).from("leaders").select("id").eq("alias",t).eq("id_user",n.id_user).eq("is_removed",!1).maybeSingle()).data)throw new Error("Este usuário já está cadastrado como líder");n.id_leader&&await Jh(r,t,e,n.id_user,n.id_leader);const{data:a,error:s}=await r.schema(e).from("leaders").insert({alias:t,id_user:n.id_user,id_leader:n.id_leader,is_active:!0,is_removed:!1}).select().single();if(s)throw s;return a},onSuccess:()=>{n.invalidateQueries({queryKey:["leadership",t]}),v.success("Líder adicionado com sucesso")},onError:e=>{v.error(e.message||"Erro ao adicionar líder")}})}function Hh(){const e="common",{alias:t}=Ca(),n=rt(),r=Br();return st({mutationFn:async n=>{if(!t)throw new Error("Unidade não selecionada");if(n.id_user===n.id_leader)throw new Error("Usuário não pode ser seu próprio líder");n.id_leader&&await Jh(r,t,e,n.id_user,n.id_leader);const{data:a,error:s}=await r.schema(e).from("leaders").insert({alias:t,id_user:n.id_user,id_leader:n.id_leader,is_active:!0,is_removed:!1}).select().single();if(s)throw s;return a},onSuccess:()=>{n.invalidateQueries({queryKey:["leadership",t]}),v.success("Líder virtual promovido com sucesso")},onError:e=>{v.error(e.message||"Erro ao criar líder")}})}function Wh(){const e="common",{alias:t}=Ca(),n=rt(),r=Br();return st({mutationFn:async n=>{if(!t)throw new Error("Unidade não selecionada");if(!n.users.length)throw new Error("Selecione pelo menos um liderado");const a=n.users.map(e=>e.id_user),{data:s}=await r.schema(e).from("leaders").select("id_user").eq("alias",t).in("id_user",a).eq("is_removed",!1);if(s&&s.length>0){const e=s.map(e=>e.id_user);throw new Error(`Alguns usuários já estão cadastrados como líderes: ${e.join(", ")}`)}for(const c of n.users){if(c.id_user===n.id_leader)throw new Error("Usuário não pode ser seu próprio líder");await Jh(r,t,e,c.id_user,n.id_leader)}const i=n.users.map(e=>({alias:t,id_user:e.id_user,id_leader:n.id_leader,is_active:!0,is_removed:!1})),{data:o,error:l}=await r.schema(e).from("leaders").insert(i).select();if(l)throw l;return o},onSuccess:e=>{n.invalidateQueries({queryKey:["leadership",t]}),v.success(`${e?.length||0} liderado(s) adicionado(s) com sucesso`)},onError:e=>{v.error(e.message||"Erro ao adicionar liderados")}})}function Kh(){const e="common",{alias:t}=Ca(),n=rt(),r=Br();return st({mutationFn:async n=>{if(!t)throw new Error("Unidade não selecionada");const{data:a}=await r.schema(e).from("leaders").select("id_user").eq("id",n.id).eq("alias",t).single();if(!a)throw new Error("Líder não encontrado");if(a.id_user===n.id_leader)throw new Error("Usuário não pode ser seu próprio líder");n.id_leader&&await Jh(r,t,e,a.id_user,n.id_leader,n.id);const{data:s,error:i}=await r.schema(e).from("leaders").update({id_leader:n.id_leader}).eq("id",n.id).eq("alias",t).select().single();if(i)throw i;return s},onSuccess:()=>{n.invalidateQueries({queryKey:["leadership",t]}),v.success("Líder atualizado com sucesso")},onError:e=>{v.error(e.message||"Erro ao atualizar líder")}})}function Qh(){const{alias:e}=Ca(),t=rt(),n=Br();return st({mutationFn:async t=>{if(!e)throw new Error("Unidade não selecionada");const{error:r}=await n.schema("common").from("leaders").update({is_removed:!0}).eq("id",t).eq("alias",e);if(r)throw r},onSuccess:()=>{t.invalidateQueries({queryKey:["leadership",e]}),v.success("Líder removido com sucesso")},onError:e=>{v.error(e.message||"Erro ao remover líder")}})}function Yh(){const e="common",{alias:t}=Ca(),n=rt(),r=Br();return st({mutationFn:async({leaderUserId:n,selectedUsers:a})=>{if(!t)throw new Error("Unidade não selecionada");const s=a.map(e=>e.id_user),i=await Promise.all([r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).eq("id_leader",n),r.schema(e).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1).in("id_user",s.length?s:["__none__"])]),[{data:o,error:l},{data:c,error:d}]=i;if(l)throw l;if(d)throw d;const u=o||[],m=c||[],f=new Set(s),p=u.filter(e=>!f.has(e.id_user)),h=m.filter(e=>e.id_leader!==n),g=new Set(m.map(e=>e.id_user)),x=a.filter(e=>!g.has(e.id_user));for(const b of h)await Jh(r,t,e,b.id_user,n,b.id);for(const b of x){if(b.id_user===n)throw new Error("Usuário não pode ser seu próprio líder");await Jh(r,t,e,b.id_user,n)}const y=[];if(p.length){const n=p.map(e=>e.id);y.push(r.schema(e).from("leaders").update({id_leader:null}).in("id",n).eq("alias",t))}if(h.length){const a=h.map(e=>e.id);y.push(r.schema(e).from("leaders").update({id_leader:n}).in("id",a).eq("alias",t))}if(x.length){const a=x.map(e=>({alias:t,id_user:e.id_user,id_leader:n,is_active:!0,is_removed:!1}));y.push(r.schema(e).from("leaders").insert(a))}const v=(await Promise.all(y)).find(e=>e?.error);if(v?.error)throw v.error;return{unlinked:p.length,updated:h.length,created:x.length}},onSuccess:e=>{n.invalidateQueries({queryKey:["leadership",t]}),v.success(`Subordinados sincronizados (${e.created} adicionados, ${e.updated} atualizados, ${e.unlinked} removidos)`)},onError:e=>{v.error(e.message||"Erro ao sincronizar subordinados")}})}async function Jh(e,t,n,r,a,s){const{data:i,error:o}=await e.schema(n).from("leaders").select("id, id_user, id_leader").eq("alias",t).eq("is_removed",!1);if(o)throw o;const l=s?i.filter(e=>e.id!==s):i,c=new Set;let d=a;for(;d;){if(c.has(d))throw new Error("Esta associação criaria um ciclo na hierarquia");if(d===r)throw new Error("Esta associação criaria um ciclo na hierarquia");c.add(d);const e=l.find(e=>e.id_user===d);d=e?.id_leader||null}}function Xh({leader:e,expandedIds:t,onToggleExpand:n,onEdit:r}){const a=t.has(e.id),s=e.children.length>0,i=32*e.level;return Mt.jsxs(Mt.Fragment,{children:[Mt.jsxs("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:[Mt.jsx("td",{className:"py-3 px-4",children:Mt.jsxs("div",{className:"flex items-center gap-2",style:{paddingLeft:`${i}px`},children:[s?Mt.jsx("button",{onClick:()=>n(e.id),className:"p-1 hover:bg-accent rounded",children:a?Mt.jsx(N,{className:"h-4 w-4"}):Mt.jsx(A,{className:"h-4 w-4"})}):Mt.jsx("div",{className:"w-6"}),Mt.jsx(Ee,{className:"h-4 w-4 text-muted-foreground"}),Mt.jsx("button",{onClick:()=>{r(e)},className:"font-medium hover:text-primary hover:underline text-left",children:e.name||e.id_user||e.email})]})}),Mt.jsx("td",{className:"py-3 px-4 text-center",children:Mt.jsx("span",{className:"text-sm",children:e.subordinatesCount||0})})]}),s&&a&&e.children.map(e=>Mt.jsx(Xh,{leader:e,expandedIds:t,onToggleExpand:n,onEdit:r},e.id))]})}var Gh=function(e,t){for(var n={};e.length;){var r=e[0],a=r.code,s=r.message,i=r.path.join(".");if(!n[i])if("unionErrors"in r){var o=r.unionErrors[0].errors[0];n[i]={message:o.message,type:o.code}}else n[i]={message:s,type:a};if("unionErrors"in r&&r.unionErrors.forEach(function(t){return t.errors.forEach(function(t){return e.push(t)})}),t){var l=n[i].types,c=l&&l[r.code];n[i]=Je(i,t,n,a,c?[].concat(c,r.message):r.message)}e.shift()}return n},Zh=function(e,t,n){return void 0===n&&(n={}),function(r,a,s){try{return Promise.resolve(function(a,i){try{var o=Promise.resolve(e["sync"===n.mode?"parse":"parseAsync"](r,t)).then(function(e){return s.shouldUseNativeValidation&&Tt({},s),{errors:{},values:n.raw?r:e}})}catch(l){return i(l)}return o&&o.then?o.then(void 0,i):o}(0,function(e){if(function(e){return Array.isArray(null==e?void 0:e.errors)}(e))return{values:{},errors:At(Gh(e.errors,!s.shouldUseNativeValidation&&"all"===s.criteriaMode),s)};throw e}))}catch(i){return Promise.reject(i)}}};const eg=It.object({id_leader:It.string().nullable(),id_users:It.array(It.string()).min(1,"Selecione pelo menos um liderado")}),tg=It.object({id_leader:It.string().nullable(),id_users:It.array(It.string())});function ng({value:e,onChange:t,excludeUserIds:r=[],error:a}){const{data:s=[],isLoading:i}=Ts(),[l,d]=n(""),u=c(null),m=c(0),f=s.filter(e=>!r.includes(e.userId||"")).filter(e=>{const t=l.toLowerCase(),n=e.userName?.toLowerCase().includes(t);return n}).sort((t,n)=>{const r=e.includes(t.userId),a=e.includes(n.userId);if(r&&!a)return-1;if(!r&&a)return 1;const s=t.userName||t.userEmail||"",i=n.userName||n.userEmail||"";return s.localeCompare(i)});return o(()=>{u.current&&m.current>0&&(u.current.scrollTop=m.current)},[f]),i?Mt.jsxs("div",{className:"flex items-center justify-center p-4",children:[Mt.jsx(S,{className:"h-6 w-6 animate-spin"}),Mt.jsx("span",{className:"ml-2",children:"Carregando usuários..."})]}):Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Jt,{placeholder:"Buscar usuário...",value:l,onChange:e=>d(e.target.value)}),Mt.jsx("div",{ref:u,className:"border rounded-md p-4 h-[300px] overflow-y-auto",children:0===f.length?Mt.jsx("p",{className:"text-sm text-muted-foreground",children:"Nenhum usuário encontrado"}):Mt.jsx("div",{className:"space-y-2",children:f.map(n=>Mt.jsxs("div",{className:"flex items-center space-x-2",children:[Mt.jsx(On,{id:n.userId,checked:e.includes(n.userId),onCheckedChange:()=>{return r=n.userId,u.current&&(m.current=u.current.scrollTop),void(e.includes(r)?t(e.filter(e=>e!==r)):t([...e,r]));var r}}),Mt.jsx(Gt,{htmlFor:n.userId,className:"flex-1 cursor-pointer",children:n.userName||n.userEmail})]},n.userId))})}),e.length>0&&Mt.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," usuário(s) selecionado(s)"]}),a&&Mt.jsx("p",{className:"text-sm text-destructive",children:a})]})}function rg({leader:e,prefilledLeaderId:t,onSuccess:r}){const{alias:a}=Ca(),s=!!e,i=e?.id.startsWith("virtual-"),l=Wh(),c=Hh(),d=Kh(),u=Yh(),m=Qh(),{data:f=[]}=Vh(),{data:p=[]}=Ts(),[h,g]=n(""),x=Bh(f).map(e=>e.id_user),y=s?Bh(f).filter(t=>t.id_leader===e.id_user).map(e=>e.id_user):[],v=Xe({resolver:Zh(s?tg:eg),defaultValues:{id_leader:t||(s?e?.id_leader:null)||null,id_users:s?y:[]}});o(()=>{if(e){const t=Bh(f).filter(t=>t.id_leader===e.id_user).map(e=>e.id_user);v.reset({id_leader:e.id_leader||null,id_users:t})}else t?v.reset({id_leader:t,id_users:[]}):v.reset({id_leader:null,id_users:[]})},[a,e?.id,e?.id_user,e?.id_leader,t,f]);const b=l.isPending||c.isPending||d.isPending||u.isPending||m.isPending,w=v.watch("id_leader"),j=v.watch("id_users"),N=s?[e.id_user,...x.filter(t=>t!==e.id_user&&!j.includes(t)&&!y.includes(t))]:[w,...x.filter(e=>!j.includes(e))].filter(Boolean);return Mt.jsxs("form",{onSubmit:v.handleSubmit(async t=>{try{if(s)if(i){await c.mutateAsync({id_user:e.id_user,id_leader:t.id_leader});const n=p.filter(e=>t.id_users.includes(e.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({leaderUserId:e.id_user,selectedUsers:n})}else{await d.mutateAsync({id:e.id,id_leader:t.id_leader});const n=p.filter(e=>t.id_users.includes(e.userId)).map(e=>({id_user:e.userId}));await u.mutateAsync({leaderUserId:e.id_user,selectedUsers:n})}else{const e=p.filter(e=>t.id_users.includes(e.userId)).map(e=>({id_user:e.userId}));await l.mutateAsync({id_leader:t.id_leader,users:e})}r?.()}catch(n){}}),className:"space-y-4",children:[s&&Mt.jsxs("div",{children:[Mt.jsx(Gt,{children:"Líder"}),Mt.jsx(Jt,{value:p.find(t=>t.userId===e.id_user)?.userName||e.name||e.id_user,disabled:!0,className:"bg-muted"})]}),Mt.jsxs("div",{children:[Mt.jsx(Gt,{children:"Líder Superior"}),Mt.jsxs(Sn,{value:w||"none",onValueChange:e=>v.setValue("id_leader","none"===e?null:e),children:[Mt.jsx(Tn,{children:Mt.jsx(In,{placeholder:"Nenhum (líder raiz)"})}),Mt.jsxs(_n,{children:[Mt.jsx("div",{className:"sticky top-0 z-10 bg-background p-2 border-b",children:Mt.jsx(Jt,{placeholder:"Buscar líder...",value:h,onChange:e=>g(e.target.value),onKeyDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),className:"h-8"})}),Mt.jsxs(ks,{className:"h-[200px]",children:[Mt.jsx(Rn,{value:"none",children:"Nenhum (líder raiz)"}),p.filter(t=>{const n=s?t.userId!==e.id_user:!j.includes(t.userId),r=!h||t.userName?.toLowerCase().includes(h.toLowerCase());return n&&r}).sort((e,t)=>{const n=e.userName||e.userEmail||"",r=t.userName||t.userEmail||"";return n.localeCompare(r)}).map(e=>Mt.jsx(Rn,{value:e.userId,children:e.userName},e.userId))]})]})]},`superior-select-${a}`),v.formState.errors.id_leader&&Mt.jsx("p",{className:"text-sm text-destructive mt-1",children:v.formState.errors.id_leader.message})]}),Mt.jsxs("div",{children:[Mt.jsx(Gt,{children:"Liderados *"}),Mt.jsx(ng,{value:j,onChange:e=>v.setValue("id_users",e),excludeUserIds:N,error:v.formState.errors.id_users?.message},`users-multiselect-${a}`)]}),Mt.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Mt.jsx(Qt,{type:"submit",disabled:b||!s&&0===j.length,children:b&&!m.isPending?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),s?"Atualizando...":"Salvando..."]}):s?j.length>0?`Atualizar (${j.length})`:"Atualizar":`Adicionar (${j.length})`}),s&&!w&&0===j.length&&Mt.jsx(Qt,{type:"button",variant:"destructive",disabled:b,onClick:async()=>{if(e&&window.confirm("Tem certeza que deseja remover esta liderança?"))try{await m.mutateAsync(e.id),r?.()}catch(t){}},className:"ml-auto",children:m.isPending?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Removendo..."]}):Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(D,{className:"mr-2 h-4 w-4"}),"Remover"]})})]})]})}function ag({open:e,onOpenChange:t,leader:n,prefilledLeaderId:r,title:a}){return Mt.jsx(sn,{open:e,onOpenChange:t,children:Mt.jsxs(un,{className:"sm:max-w-[500px]",children:[Mt.jsx(mn,{children:Mt.jsx(pn,{children:a})}),Mt.jsx(rg,{leader:n,prefilledLeaderId:r,onSuccess:()=>t(!1)})]})})}const sg="leadership-expanded-nodes",ig=(e,t)=>{try{localStorage.setItem(`${sg}-${e}`,JSON.stringify(Array.from(t)))}catch(n){}};function og(){const{alias:e}=Ca(),{data:t,isLoading:r,error:a,refetch:s}=Vh(),{data:i=[]}=Ts(),[l,c]=n(()=>e?(e=>{try{const t=localStorage.getItem(`${sg}-${e}`);if(t)return new Set(JSON.parse(t))}catch(a){}return new Set})(e):new Set),[d,u]=n(!1),[m,f]=n(),[p,h]=n(null),g=i.length-(t?new Set(Bh(t).map(e=>e.id_user)).size:0);o(()=>{if(t&&t.length>0&&e){if(!localStorage.getItem(`${sg}-${e}`)){const n=t.map(e=>e.id),r=new Set(n);c(r),ig(e,r)}}},[t,e]);const x=t=>{c(n=>{const r=new Set(n);return r.has(t)?r.delete(t):r.add(t),e&&ig(e,r),r})},y=e=>{f(e),h(null),u(!0)};return r?Mt.jsx("div",{className:"flex items-center justify-center h-full",children:Mt.jsxs("div",{className:"text-center",children:[Mt.jsx(Fe,{className:"h-8 w-8 animate-spin mx-auto mb-4 text-muted-foreground"}),Mt.jsx("p",{className:"text-muted-foreground",children:"Carregando hierarquia de liderança..."})]})}):a?Mt.jsx("div",{className:"flex items-center justify-center h-full",children:Mt.jsxs("div",{className:"text-center",children:[Mt.jsx("p",{className:"text-destructive mb-4",children:"Erro ao carregar hierarquia de liderança"}),Mt.jsx(Qt,{onClick:()=>s(),children:"Tentar novamente"})]})}):Mt.jsxs("div",{className:"flex flex-col h-full",children:[Mt.jsx("div",{className:"flex items-center justify-between p-4 border-b",children:Mt.jsxs("div",{className:"flex gap-2 items-center",children:[Mt.jsxs(Qt,{size:"sm",onClick:()=>{f(void 0),h(null),u(!0)},children:[Mt.jsx(pe,{className:"h-4 w-4 mr-2"}),"Definir Líder"]}),Mt.jsxs(Qt,{variant:"outline",size:"sm",onClick:()=>{if(!t)return;const n=Bh(t).filter(e=>e.children.length>0).map(e=>e.id),r=new Set(n);c(r),e&&ig(e,r)},disabled:!t||0===t.length,children:[Mt.jsx(N,{className:"h-4 w-4 mr-2"}),"Expandir todos"]}),Mt.jsxs(Qt,{variant:"outline",size:"sm",onClick:()=>{const t=new Set;c(t),e&&ig(e,t)},disabled:!t||0===t.length,children:[Mt.jsx(A,{className:"h-4 w-4 mr-2"}),"Recolher todos"]}),Mt.jsx("div",{className:"flex items-center gap-2 ml-4",children:Mt.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-md",children:[Mt.jsx(Be,{className:"h-4 w-4 text-muted-foreground"}),Mt.jsxs("span",{className:"text-sm font-medium",children:[g," usuário",1!==g?"s":""," não associado",1!==g?"s":""]})]})})]})}),t&&0!==t.length?Mt.jsx(ks,{className:"flex-1",children:Mt.jsx("div",{children:Mt.jsxs("table",{className:"w-full",children:[Mt.jsx("thead",{children:Mt.jsxs("tr",{className:"border-b bg-muted/50",children:[Mt.jsx("th",{className:"py-3 px-4 text-left font-semibold",children:"Nome"}),Mt.jsx("th",{className:"py-3 px-4 text-center font-semibold",children:"Liderados"})]})}),Mt.jsx("tbody",{children:t.map(e=>Mt.jsx(Xh,{leader:e,expandedIds:l,onToggleExpand:x,onEdit:y},e.id))})]})})}):Mt.jsx("div",{className:"flex items-center justify-center flex-1",children:Mt.jsxs("div",{className:"text-center space-y-4",children:[Mt.jsx("p",{className:"text-muted-foreground",children:"Nenhuma hierarquia de liderança encontrada"}),Mt.jsx("p",{className:"text-sm text-muted-foreground",children:'Clique em "Definir Líder" para começar'})]})}),Mt.jsx(ag,{open:d,onOpenChange:()=>{u(!1),f(void 0),h(null)},leader:m,prefilledLeaderId:p,title:m?"Editar Líder":p?"Adicionar Liderado":"Adicionar Líder Raiz"},`leadership-dialog-${e}`)]})}function lg(e){const[t,r]=n(!1),[a,s]=n(0),{uploadFunction:i,deleteFunction:o,defaultOptions:l,onSuccess:c,onError:d}=e||{};return{upload:async(e,t)=>{if(!i){const e=new Error("uploadFunction não fornecida");throw Jn({title:"Erro de configuração",description:"Função de upload não configurada. Verifique a documentação.",variant:"destructive"}),e}r(!0),s(0);try{const n={...l,...t};if(n.maxSize&&e.size>n.maxSize)throw new Error(`Arquivo muito grande. Tamanho máximo: ${Math.round(n.maxSize/1024/1024)}MB`);if(n.allowedTypes){if(!n.allowedTypes.some(t=>t.endsWith("/*")?e.type.startsWith(t.replace("/*","")):e.type===t))throw new Error(`Tipo de arquivo não permitido. Tipos aceitos: ${n.allowedTypes.join(", ")}`)}const r=await i(e,n);return s(100),Jn({title:"Sucesso",description:"Arquivo enviado com sucesso"}),c?.(r),r}catch(n){const e=n instanceof Error?n:new Error("Erro ao fazer upload");throw Jn({title:"Erro",description:e.message,variant:"destructive"}),d?.(e),e}finally{r(!1)}},deleteMedia:async(e,t)=>{if(!o){const e=new Error("deleteFunction não fornecida");throw Jn({title:"Erro de configuração",description:"Função de delete não configurada.",variant:"destructive"}),e}try{await o(e,t),Jn({title:"Sucesso",description:"Arquivo removido com sucesso"})}catch(n){throw Jn({title:"Erro",description:"Erro ao remover o arquivo",variant:"destructive"}),n}},uploading:t,progress:a}}function cg(e){const t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/^([a-zA-Z0-9_-]{11})$/];for(const n of t){const t=e.match(n);if(t)return t[1]}return null}function dg(e,t){const n=cg(e);if(!n)return e;return`https://www.youtube.com/embed/${n}${t?"?autoplay=1&mute=1":""}`}function ug(e){const t=e.match(/vimeo\.com\/(?:video\/)?(\d+)/);return t?t[1]:null}function mg(e,t){const n=ug(e);if(!n)return e;return`https://player.vimeo.com/video/${n}${t?"?autoplay=1&muted=1":""}`}function fg(e){if(!e)return;const t=e.match(/src="([^"]+)"/);return t?t[1]:void 0}function pg(e){return e?/youtube|youtu\.be/.test(e)?"youtube":/vimeo/.test(e)?"vimeo":"file":"file"}function hg(e,t,n){switch(t||pg(e)){case"youtube":return dg(e,n);case"vimeo":return mg(e,n);default:return e}}function gg({value:e,onChange:t,onSubmit:a,onCancel:s,uploadFunction:i,deleteFunction:o,uploadOptions:l}){const[d,u]=n(e||{inputType:"url",controls:!0}),m=c(null),f=c(null),{upload:p,uploading:h}=lg({uploadFunction:i,deleteFunction:o,defaultOptions:{...l,allowedTypes:["video/*"],maxSize:104857600}}),{upload:g,uploading:x}=lg({uploadFunction:i,deleteFunction:o,defaultOptions:{...l,allowedTypes:["image/*"],maxSize:5242880}}),y=r(()=>pg(d.videoUrl||fg(d.embedCode)||""),[d.videoUrl,d.embedCode]),v=(e,n)=>{const r={...d,[e]:n};u(r),t(r)};return Mt.jsxs("div",{className:"space-y-6",children:[Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"Tipo de entrada"}),Mt.jsxs(Sn,{value:d.inputType||"url",onValueChange:e=>v("inputType",e),children:[Mt.jsx(Tn,{children:Mt.jsx(In,{})}),Mt.jsxs(_n,{children:[Mt.jsx(Rn,{value:"url",children:"URL (YouTube/Vimeo/arquivo)"}),Mt.jsx(Rn,{value:"upload",children:"Upload de arquivo"}),Mt.jsx(Rn,{value:"embed",children:"Código de incorporação (iframe)"})]})]})]}),"embed"!==d.inputType&&Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"URL do vídeo"}),Mt.jsx(Jt,{type:"url",placeholder:"https://www.youtube.com/watch?v=... ou arquivo direto",value:d.videoUrl||"",onChange:e=>v("videoUrl",e.target.value)})]}),"upload"===d.inputType&&i&&Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"Arquivo de vídeo"}),Mt.jsxs("div",{className:"flex gap-2",children:[Mt.jsx("input",{ref:m,type:"file",accept:"video/*",onChange:async e=>{const n=e.target.files?.[0];if(n)try{const e=await p(n),r={...d,videoUrl:e.url,videoFile:e.name,videoPath:e.path,videoSize:e.size,title:d.title||n.name.replace(/\.[^/.]+$/,"")};u(r),t(r)}catch(r){}finally{m.current&&(m.current.value="")}},className:"hidden"}),Mt.jsx(Qt,{type:"button",variant:"outline",onClick:()=>m.current?.click(),disabled:h,children:h?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(ae,{className:"mr-2 h-4 w-4"}),"Selecionar vídeo"]})}),d.videoFile&&Mt.jsxs("span",{className:"text-xs text-muted-foreground truncate self-center",children:[d.videoFile," (",Math.round((d.videoSize||0)/1024/1024)," MB)"]})]})]}),"embed"===d.inputType&&Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"Código embed (iframe)"}),Mt.jsx(zn,{placeholder:'<iframe src="https://www.youtube.com/embed/..." ...></iframe>',value:d.embedCode||"",onChange:e=>v("embedCode",e.target.value),rows:4,className:"font-mono text-sm"})]}),i&&Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"Thumbnail/Poster (opcional)"}),Mt.jsxs("div",{className:"flex gap-2",children:[Mt.jsx(Jt,{type:"url",placeholder:"https://exemplo.com/thumbnail.jpg",value:d.thumbnail||"",onChange:e=>v("thumbnail",e.target.value),className:"flex-1"}),Mt.jsx("input",{ref:f,type:"file",accept:"image/*",onChange:async e=>{const n=e.target.files?.[0];if(n)try{const e=await g(n),r={...d,thumbnail:e.url,thumbnailFile:e.name,thumbnailPath:e.path};u(r),t(r)}catch(r){}finally{f.current&&(f.current.value="")}},className:"hidden"}),Mt.jsx(Qt,{type:"button",variant:"outline",onClick:()=>f.current?.click(),disabled:x,children:x?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(ae,{className:"mr-2 h-4 w-4"}),"Upload"]})})]}),d.thumbnailFile&&Mt.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",d.thumbnailFile]})]}),Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{htmlFor:"title",children:"Título (opcional)"}),Mt.jsx(Jt,{id:"title",placeholder:"Título do vídeo",value:d.title||"",onChange:e=>v("title",e.target.value)})]}),Mt.jsxs("div",{className:"flex gap-6",children:[Mt.jsxs("div",{className:"flex items-center gap-2",children:[Mt.jsx("input",{id:"autoplay",type:"checkbox",checked:d.autoplay||!1,onChange:e=>v("autoplay",e.target.checked),className:"h-4 w-4"}),Mt.jsx(Gt,{htmlFor:"autoplay",className:"cursor-pointer",children:"Autoplay (mudo em embeds)"})]}),Mt.jsxs("div",{className:"flex items-center gap-2",children:[Mt.jsx("input",{id:"controls",type:"checkbox",checked:!1!==d.controls,onChange:e=>v("controls",e.target.checked),className:"h-4 w-4"}),Mt.jsx(Gt,{htmlFor:"controls",className:"cursor-pointer",children:"Mostrar controles"})]})]}),Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"Preview"}),Mt.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:(()=>{const e=d.videoUrl||fg(d.embedCode)||"";if(!e)return Mt.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Adicione uma URL, faça upload ou insira um código embed para visualizar"});if("file"===y)return Mt.jsxs("video",{controls:!1!==d.controls,autoPlay:d.autoplay,poster:d.thumbnail,className:"w-full h-auto rounded-md",playsInline:!0,children:[Mt.jsx("source",{src:e}),"Seu navegador não suporta vídeos HTML5."]});const t="youtube"===y?dg(e,d.autoplay):mg(e,d.autoplay);return Mt.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:Mt.jsx("iframe",{title:d.title||"Vídeo",src:t,className:"absolute inset-0 w-full h-full rounded-md",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})})()})]}),Mt.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[Mt.jsx(Qt,{variant:"outline",onClick:s,children:"Cancelar"}),Mt.jsx(Qt,{onClick:()=>{d.videoUrl||d.embedCode?a(d):Jn({title:"Erro",description:"Adicione uma URL, faça upload de um vídeo ou insira um código embed",variant:"destructive"})},disabled:!(d.videoUrl||d.embedCode),children:"Salvar"})]})]})}function xg({content:e,className:t="",style:n}){const r=e.videoUrl||fg(e.embedCode)||"";if(!r)return null;const a=pg(r);return Mt.jsx(Zt,{className:`overflow-hidden my-4 ${t}`,style:n,children:Mt.jsxs(rn,{className:"p-0",children:["file"===a?Mt.jsxs("video",{controls:!1!==e.controls,autoPlay:e.autoplay,poster:e.thumbnail,className:"w-full h-auto",playsInline:!0,muted:e.autoplay,children:[Mt.jsx("source",{src:r}),"Seu navegador não suporta vídeos HTML5."]}):Mt.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:Mt.jsx("iframe",{title:e.title||"Vídeo",src:"youtube"===a?dg(r,e.autoplay):mg(r,e.autoplay),className:"absolute inset-0 w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})}),e.title&&Mt.jsx("div",{className:"p-4",children:Mt.jsx("p",{className:"text-sm font-medium",children:e.title})})]})})}function yg({value:e,onChange:t,onSubmit:r,onCancel:a,uploadFunction:s,deleteFunction:i,uploadOptions:o}){const[l,d]=n(e||{alignment:"center",allowDownload:!1}),u=c(null),{upload:m,uploading:f}=lg({uploadFunction:s,deleteFunction:i,defaultOptions:{...o,allowedTypes:["image/*"],maxSize:5242880}}),p=(e,n)=>{const r={...l,[e]:n};d(r),t(r)};return Mt.jsxs("div",{className:"space-y-6",children:[Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"URL da imagem"}),Mt.jsxs("div",{className:"flex gap-2",children:[Mt.jsx(Jt,{type:"url",placeholder:"https://exemplo.com/imagem.jpg",value:l.imageUrl||"",onChange:e=>p("imageUrl",e.target.value),className:"flex-1"}),s&&Mt.jsxs(Mt.Fragment,{children:[Mt.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:async e=>{const n=e.target.files?.[0];if(n)try{const e=await m(n),r={...l,imageUrl:e.url,imageFile:e.name,imagePath:e.path,imageSize:e.size};d(r),t(r)}catch(r){}finally{u.current&&(u.current.value="")}},className:"hidden"}),Mt.jsx(Qt,{type:"button",variant:"outline",onClick:()=>u.current?.click(),disabled:f,children:f?Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(S,{className:"mr-2 h-4 w-4 animate-spin"}),"Enviando..."]}):Mt.jsxs(Mt.Fragment,{children:[Mt.jsx(ae,{className:"mr-2 h-4 w-4"}),"Upload"]})})]})]}),l.imageFile&&Mt.jsxs("p",{className:"text-xs text-muted-foreground",children:["Arquivo: ",l.imageFile," (",Math.round((l.imageSize||0)/1024)," KB)"]})]}),l.imageUrl&&Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"Preview"}),Mt.jsx("div",{className:"border rounded-lg p-4 bg-muted/30",children:Mt.jsx("div",{className:"flex "+("left"===l.alignment?"justify-start":"right"===l.alignment?"justify-end":"justify-center"),children:Mt.jsx("img",{src:l.imageUrl,alt:l.alt||"Preview",style:{width:l.width?`${l.width}px`:"auto",height:l.height?`${l.height}px`:"auto",maxWidth:"100%"},className:"rounded-lg shadow-md"})})})]}),Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{htmlFor:"caption",children:"Legenda (opcional)"}),Mt.jsx(zn,{id:"caption",placeholder:"Descrição da imagem",value:l.caption||"",onChange:e=>p("caption",e.target.value),rows:2})]}),Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{htmlFor:"alt",children:"Texto alternativo (acessibilidade)"}),Mt.jsx(Jt,{id:"alt",placeholder:"Descrição para leitores de tela",value:l.alt||"",onChange:e=>p("alt",e.target.value)})]}),Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{children:"Alinhamento"}),Mt.jsxs(Sn,{value:l.alignment||"center",onValueChange:e=>p("alignment",e),children:[Mt.jsx(Tn,{children:Mt.jsx(In,{})}),Mt.jsxs(_n,{children:[Mt.jsx(Rn,{value:"left",children:"Esquerda"}),Mt.jsx(Rn,{value:"center",children:"Centro"}),Mt.jsx(Rn,{value:"right",children:"Direita"})]})]})]}),Mt.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{htmlFor:"width",children:"Largura (px, opcional)"}),Mt.jsx(Jt,{id:"width",type:"number",placeholder:"Auto",value:l.width||"",onChange:e=>p("width",e.target.value?Number(e.target.value):void 0)})]}),Mt.jsxs("div",{className:"space-y-2",children:[Mt.jsx(Gt,{htmlFor:"height",children:"Altura (px, opcional)"}),Mt.jsx(Jt,{id:"height",type:"number",placeholder:"Auto",value:l.height||"",onChange:e=>p("height",e.target.value?Number(e.target.value):void 0)})]})]}),Mt.jsxs("div",{className:"flex items-center gap-2",children:[Mt.jsx("input",{id:"allowDownload",type:"checkbox",checked:l.allowDownload||!1,onChange:e=>p("allowDownload",e.target.checked),className:"h-4 w-4"}),Mt.jsx(Gt,{htmlFor:"allowDownload",className:"cursor-pointer",children:"Permitir download da imagem"})]}),Mt.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[Mt.jsx(Qt,{variant:"outline",onClick:a,children:"Cancelar"}),Mt.jsx(Qt,{onClick:()=>{l.imageUrl?r(l):Jn({title:"Erro",description:"Adicione uma URL ou faça upload de uma imagem",variant:"destructive"})},disabled:!l.imageUrl,children:"Salvar"})]})]})}function vg({content:e,className:t="",style:n}){if(!e.imageUrl)return null;const r={left:"justify-start",center:"justify-center",right:"justify-end"}[e.alignment||"center"];return Mt.jsx("div",{className:`flex ${r} my-4 ${t}`,style:n,children:Mt.jsxs("div",{className:"space-y-2 max-w-full",children:[Mt.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&&Mt.jsx("p",{className:"text-sm text-muted-foreground text-center italic",children:e.caption}),e.allowDownload&&e.imageUrl&&Mt.jsxs("a",{href:e.imageUrl,download:!0,className:"flex items-center gap-2 text-sm text-primary hover:underline justify-center",children:[Mt.jsx(se,{className:"h-4 w-4"}),"Baixar imagem"]})]})})}function bg(e,t){return e/t}function wg(e,t,n,r){const a=bg(e,t);return n&&!r?{width:n,height:Math.round(n/a)}:r&&!n?{width:Math.round(r*a),height:r}:{width:e,height:t}}function jg(e){const t=e.toLowerCase();return[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp",".ico"].some(e=>t.includes(e))}function Ng(e){try{const t=new URL(e),n=t.pathname.split("/");return n[n.length-1]||"image"}catch{const t=e.split("/");return t[t.length-1]||"image"}}function kg(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(2)} MB`}export{Zr as AUTH_CONFIG,ii as Accordion,ci as AccordionContent,oi as AccordionItem,li as AccordionTrigger,Yt as ActionButton,El as ActionMenu,gs as ActionMenuItems,Js as Alert,Gs as AlertDescription,Ia as AlertDialog,za as AlertDialogAction,La as AlertDialogCancel,_a as AlertDialogContent,Oa as AlertDialogDescription,Ra as AlertDialogFooter,Fa as AlertDialogHeader,Pa as AlertDialogOverlay,Aa as AlertDialogPortal,Da as AlertDialogTitle,Ta as AlertDialogTrigger,Xs as AlertTitle,Ll as AppHeader,Gl as AppLayout,Xl as AppSidebar,di as AspectRatio,Kr as AuthErrorInterceptor,ka as AuthProvider,ja as AuthService,ui as Avatar,fi as AvatarFallback,mi as AvatarImage,Mn as Badge,Ps as BaseForm,pi as Breadcrumb,bi as BreadcrumbEllipsis,gi as BreadcrumbItem,xi as BreadcrumbLink,hi as BreadcrumbList,yi as BreadcrumbPage,vi as BreadcrumbSeparator,Rs as BulkActionBar,Qt as Button,ea as CRUD_CONFIG,Pi as Calendar,Zs as CallbackPage,Zt as Card,rn as CardContent,nn as CardDescription,an as CardFooter,en as CardHeader,Ya as CardSkeleton,tn as CardTitle,Tl as Cards,Rh as ChatbotPage,On as Checkbox,_i as Collapsible,Ri as CollapsibleContent,Fi as CollapsibleTrigger,Ns as ColorPicker,dr as Command,ur as CommandDialog,pr as CommandEmpty,hr as CommandGroup,mr as CommandInput,xr as CommandItem,fr as CommandList,gr as CommandSeparator,yr as CommandShortcut,Cl as CrudCards,Us as CrudPageInternal,Fs as CrudPagination,Il as CrudPrimitiveFilterBar,_s as CrudPrimitivePagination,Sl as CrudPrimitiveTable,bs as CrudTable,Di as DataList,Ma as DeleteConfirmationDialog,sn as Dialog,cn as DialogClose,un as DialogContent,hn as DialogDescription,fn as DialogFooter,mn as DialogHeader,dn as DialogOverlay,ln as DialogPortal,pn as DialogTitle,on as DialogTrigger,ts as DropdownMenu,us as DropdownMenuCheckboxItem,cs as DropdownMenuContent,rs as DropdownMenuGroup,ds as DropdownMenuItem,fs as DropdownMenuLabel,as as DropdownMenuPortal,is as DropdownMenuRadioGroup,ms as DropdownMenuRadioItem,ps as DropdownMenuSeparator,hs as DropdownMenuShortcut,ss as DropdownMenuSub,ls as DropdownMenuSubContent,os as DropdownMenuSubTrigger,ns as DropdownMenuTrigger,nc as EmailService,es as EmptyState,Is as EntitySelect,tc as ErrorBoundary,Ms as FilterBar,gn as Form,Nn as FormControl,kn as FormDescription,yn as FormField,wn as FormItem,jn as FormLabel,Cn as FormMessage,Ja as FormSkeleton,Mi as Grid,Xa as HeaderSkeleton,Es as IconPicker,yg as ImageEditor,vg as ImageRenderer,Jt as Input,Gt as Label,Xh as LeaderRow,ag as LeadershipDialog,rg as LeadershipForm,og as LeadershipPage,Bn as LoadingState,ei as LoginPage,oa as MESSAGES,Dh as ManageAccessModal,Fh as MarkdownMessage,jr as MultiSelect,Rl as NavigationProvider,Vi as PageBreadcrumb,ni as PageMetadataProvider,Hi as Pagination,Wi as PaginationContent,Xi as PaginationEllipsis,Ki as PaginationItem,Qi as PaginationLink,Ji as PaginationNext,Yi as PaginationPrevious,Oh as PlaceCard,zh as PlacesList,or as Popover,cr as PopoverContent,lr as PopoverTrigger,Gi as Progress,Qs as ProtectedRoute,ra as QUERY_KEYS,fa as QualiexEnrichmentService,Yr as QualiexErrorInterceptor,As as QualiexUserField,Zi as RadioGroup,eo as RadioGroupItem,Jl as ResizableRail,ta as SEARCH_CONFIG,ks as ScrollArea,Cs as ScrollBar,Sn as Select,_n as SelectContent,En as SelectGroup,Rn as SelectItem,Fn as SelectLabel,Pn as SelectScrollDownButton,An as SelectScrollUpButton,Bi as SelectSearch,Dn as SelectSeparator,Tn as SelectTrigger,In as SelectValue,to as Separator,no as Sheet,ao as SheetClose,lo as SheetContent,fo as SheetDescription,uo as SheetFooter,co as SheetHeader,io as SheetOverlay,so as SheetPortal,mo as SheetTitle,ro as SheetTrigger,jo as Sidebar,Ao as SidebarContent,Io as SidebarFooter,Po as SidebarGroup,Fo as SidebarGroupAction,Ro as SidebarGroupContent,_o as SidebarGroupLabel,Ql as SidebarHeader,So as SidebarInput,Co as SidebarInset,Do as SidebarMenu,Mo as SidebarMenuAction,Uo as SidebarMenuBadge,Lo as SidebarMenuButton,Oo as SidebarMenuItem,$o as SidebarMenuSkeleton,Bo as SidebarMenuSub,qo as SidebarMenuSubButton,Vo as SidebarMenuSubItem,wo as SidebarProvider,ko as SidebarRail,To as SidebarSeparator,Ga as SidebarSkeleton,No as SidebarTrigger,vr as Skeleton,Ho as Slider,Wo as SonnerToaster,$n as Spinner,Ls as Stack,Oi as StatusSelect,ml as Switch,vl as TabPageContent,yl as TabPageHeader,xl as TabPageLayout,Ua as Table,Ba as TableBody,Ka as TableCaption,Wa as TableCell,Va as TableFooter,Ha as TableHead,$a as TableHeader,qa as TableRow,xs as TableRowActions,Qa as TableSkeleton,fl as Tabs,gl as TabsContent,pl as TabsList,hl as TabsTrigger,zn as Textarea,tr as Toast,nr as ToastAction,rr as ToastClose,sr as ToastDescription,Gn as ToastProvider,ar as ToastTitle,Zn as ToastViewport,ir as Toaster,wl as Toggle,Nl as ToggleGroup,kl as ToggleGroupItem,_r as TokenManager,kr as TokenService,ho as Tooltip,xo as TooltipContent,po as TooltipProvider,go as TooltipTrigger,gg as VideoEditor,xg as VideoRenderer,Hl as assets,Ln as badgeVariants,$h as buildHierarchy,Kt as buttonVariants,bg as calculateAspectRatio,$t as cn,$s as createCrudPage,Pl as createCrudRoutingConfig,Al as createRoutingHandlers,ga as createService,Bs as createSimpleSaveHandler,Ea as createSimpleService,Ws as crudPresets,Ht as debounce,ca as deriveEmailField,la as deriveNameField,da as deriveUsernameField,pg as detectVideoProvider,rc as emailService,Dr as errorService,Ng as extractImageFileName,ug as extractVimeoId,cg as extractYouTubeId,Bh as flattenTree,qt as formatCurrency,Vt as formatDatetime,kg as formatFileSize,Vs as generateCrudConfig,sa as getQualiexConfig,Br as getSupabaseClient,Ut as handleExternalLink,na as isDevEnvironment,jg as isImageUrl,Wl as logoSrc,hg as normalizeVideoUrl,mg as normalizeVimeoUrl,dg as normalizeYouTubeUrl,fg as parseIframeSrc,Uh as placeService,Gr as qualiexApi,wg as resizeKeepingAspect,ua as resolveFieldMappings,ia as setQualiexConfig,si as setupQualiexCore,Wt as slugify,Kl as smallLogoSrc,Jn as toast,bl as toggleVariants,Bt as trimTextFields,Ul as useActiveModules,Ca as useAuth,ws as useBaseForm,qh as useCreateLeaderMutation,Wh as useCreateMultipleLeadersMutation,Hh as useCreateSingleLeaderMutation,Sa as useCrud,zl as useDebounce,vn as useFormField,Vh as useLeadershipApi,lg as useMediaUpload,Dl as useNavigation,ac as useOpenAIChat,ai as usePageMetadata,Ol as usePageTitle,Ml as usePermissionQuery,Ts as useQualiexUsers,Qh as useRemoveLeaderMutation,qi as useRouteBreadcrumbs,bo as useSidebar,Yl as useSidebarResize,Yh as useSyncSubordinatesMutation,Xn as useToast,Kh as useUpdateLeaderMutation,Ks as withPreset};