forlogic-core 1.7.7 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +835 -684
- package/dist/README.md +835 -684
- package/dist/assets/index-2WBeKMgq.css +1 -0
- package/dist/assets/index-Dg0JuUel.js +696 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.html +19 -0
- package/dist/index.js +2 -2
- package/package.json +4 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as e from"react";import t,{createContext as n,useContext as r,useState as a,useCallback as s,useEffect as i,useMemo as o,memo as l,useRef as c,Component as u}from"react";import{Slot as d,createSlot as f}from"@radix-ui/react-slot";import{cva as m}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 k,ChevronUp as j,Check as C,Loader2 as S,AlertCircle as I,Search as
|
|
1
|
+
import*as e from"react";import t,{createContext as n,useContext as r,useState as a,useCallback as s,useEffect as i,useMemo as o,memo as l,useRef as c,Component as u}from"react";import{Slot as d,createSlot as f}from"@radix-ui/react-slot";import{cva as m}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 k,ChevronUp as j,Check as C,Loader2 as S,AlertCircle as I,Search as E,FileX as T,ChevronRight as P,Circle as A,Edit as R,PowerOff as _,Power as D,Trash2 as F,ArrowUpDown as z,ArrowUp as O,ArrowDown as L,Target as M,Trophy as U,Award as $,Sparkles as B,Flame as V,Zap as H,Key as q,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 ue,ArrowLeft as de,ChevronLeft as fe,Minus as me,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 ke,Phone as je,Mail as Ce,Settings as Se,User as Ie,Home as Ee,Heart as Te,Star as Pe,ChevronsUpDown as Ae,ChevronsLeft as Re,ChevronsRight as _e,RefreshCw as De,MoreHorizontal as Fe,PanelLeft as ze,ExternalLink as Oe,Building2 as Le,LogOut as Me,AlertTriangle as Ue,MessageCircle as $e,Send as Be,Users as Ve,Crown as He,UserPlus as qe}from"lucide-react";import*as We from"@radix-ui/react-label";import*as Qe from"@radix-ui/react-dialog";import{useFormContext as Ke,FormProvider as Ye,Controller as Je}from"react-hook-form";import*as Xe from"@radix-ui/react-select";import*as Ge from"@radix-ui/react-checkbox";import*as Ze from"@radix-ui/react-toast";import{createClient as et}from"@supabase/supabase-js";import{useQueryClient as tt,useQuery as nt,useMutation as rt,QueryClient as at}from"@tanstack/react-query";import{useSearchParams as st,useLocation as it,useNavigate as ot,Link as lt}from"react-router-dom";import*as ct from"@radix-ui/react-alert-dialog";import*as ut from"@radix-ui/react-dropdown-menu";import*as dt from"@radix-ui/react-popover";import*as ft from"@radix-ui/react-scroll-area";import*as mt from"@radix-ui/react-accordion";import*as pt from"@radix-ui/react-aspect-ratio";import*as ht from"@radix-ui/react-avatar";import{DayPicker as gt}from"react-day-picker";import*as xt from"@radix-ui/react-collapsible";import*as yt from"@radix-ui/react-progress";import*as bt from"@radix-ui/react-radio-group";import*as vt from"@radix-ui/react-separator";import*as wt 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 jt from"@radix-ui/react-tabs";import*as Ct from"@radix-ui/react-toggle";import*as St from"@radix-ui/react-toggle-group";function It(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Et,Tt={exports:{}},Pt={};var At,Rt,_t={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.development.js
|
|
@@ -7,4 +7,4 @@ import*as e from"react";import t,{createContext as n,useContext as r,useState as
|
|
|
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 Rt(){return Tt||(Tt=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"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=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 u:return"Suspense";case d: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 f:var t=e.displayName||null;return null!==t?t:v(e.type)||"Memo";case m: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,k,j,C,S,I,P=Object.assign,E=0;function T(){}T.__reactDisabledLog=!0;var A,_=g.ReactCurrentDispatcher;function R(e,t,n){if(void 0===A)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return"\n"+A+e}var F,D=!1,z="function"==typeof WeakMap?WeakMap:Map;function O(e,t){if(!e||D)return"";var n,r=F.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===E){w=console.log,N=console.info,k=console.warn,j=console.error,C=console.group,S=console.groupCollapsed,I=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})}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,u=l.length-1;c>=1&&u>=0&&o[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(o[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||o[c]!==l[u]){var d="\n"+o[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&F.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{D=!1,_.current=a,function(){if(0===--E){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},e,{value:w}),info:P({},e,{value:N}),warn:P({},e,{value:k}),error:P({},e,{value:j}),group:P({},e,{value:C}),groupCollapsed:P({},e,{value:S}),groupEnd:P({},e,{value:I})})}E<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=s}var f=e?e.displayName||e.name:"",m=f?R(f):"";return"function"==typeof e&&F.set(e,m),m}function L(e,t,n){if(null==e)return"";if("function"==typeof e)return O(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if("string"==typeof e)return R(e);switch(e){case u:return R("Suspense");case d:return R("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return O(e.render,!1);case f:return L(e.type,t,n);case m:var r=e,a=r._payload,s=r._init;try{return L(s(a),t,n)}catch(i){}}return""}F=new z;var M=Object.prototype.hasOwnProperty,U={},B=g.ReactDebugCurrentFrame;function $(e){if(e){var t=e._owner,n=L(e.type,e._source,t?t.type:null);B.setExtraStackFrame(n)}else B.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 u=e.defaultProps;for(i in u)void 0===o[i]&&(o[i]=u[i])}if(l||c){var d="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,d),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,d)}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=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!==f)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||($(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),$(null)),o instanceof Error&&!(o.message in U)&&(U[o.message]=!0,$(a),x("Failed %s type: %s",n,o.message),$(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===u||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||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 k;N+=re(),null===e?k="null":q(e)?k="array":void 0!==e&&e.$$typeof===n?(k="<"+(v(e.type)||"Unknown")+" />",N=" Did you accidentally export a JSX literal instead of a component?"):k=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",k,N)}var j=X(e,t,r,g,b);if(null==j)return j;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 I=v(e),P=Object.keys(t).filter(function(e){return"key"!==e}),E=P.length>0?"{key: someKey, "+P.join(": ..., ")+": ...}":"{key: someKey}";if(!le[I+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,P.length>0?"{"+P.join(": ..., ")+": ...}":"{}",I),le[I+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))}(j):oe(j),j}var ue=function(e,t,n){return ce(e,t,n,!1)},de=function(e,t,n){return ce(e,t,n,!0)};_t.Fragment=a,_t.jsx=ue,_t.jsxs=de}()),_t}var Ft=(At||(At=1,"production"===process.env.NODE_ENV?Pt.exports=function(){if(It)return Et;It=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,u=null;for(o in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=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:u,props:l,_owner:s.current}}return Et.Fragment=r,Et.jsx=o,Et.jsxs=o,Et}():Pt.exports=Rt()),Pt.exports);function Dt(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 zt(...e){return h(p(e))}const Ot=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Ot);if("object"==typeof e&&e.constructor===Object){const t={};for(const[n,r]of Object.entries(e))t[n]=Ot(r);return t}return e},Lt=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"})}`},Mt=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),Ut=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},Bt=m("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"}}),$t=e.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...a},s)=>{const i=r?d:"button";return Ft.jsx(i,{className:zt(Bt({variant:t,size:n,className:e})),ref:s,...a})});$t.displayName="Button";const Vt=t.forwardRef(({variant:e="default",className:t,children:n,...r},a)=>Ft.jsx($t,{ref:a,variant:"action",size:"sm",className:zt("h-7 px-2 text-xs",t),...r,children:n||Ft.jsx(w,{size:12})}));Vt.displayName="ActionButton";const qt=e.forwardRef(({className:e,type:t,...n},r)=>Ft.jsx("input",{type:t,className:zt("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}));qt.displayName="Input";const Ht=m("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Wt=e.forwardRef(({className:e,...t},n)=>Ft.jsx(He.Root,{ref:n,className:zt(Ht(),e),...t}));Wt.displayName=He.Root.displayName;const Qt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Qt.displayName="Card";const Kt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("flex flex-col space-y-1.5 p-6",e),...t}));Kt.displayName="CardHeader";const Yt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("h3",{ref:n,className:zt("text-2xl font-semibold leading-none tracking-tight",e),...t}));Yt.displayName="CardTitle";const Jt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("p",{ref:n,className:zt("text-sm text-muted-foreground",e),...t}));Jt.displayName="CardDescription";const Xt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("p-6 pt-0",e),...t}));Xt.displayName="CardContent";const Gt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("flex items-center p-6 pt-0",e),...t}));Gt.displayName="CardFooter";const Zt=We.Root,en=We.Trigger,tn=We.Portal,nn=We.Close,rn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(We.Overlay,{ref:n,className:zt("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}));rn.displayName=We.Overlay.displayName;const an=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(tn,{children:[Ft.jsx(rn,{}),Ft.jsxs(We.Content,{ref:r,className:zt("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 overflow-hidden",e),...n,children:[t,Ft.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:[Ft.jsx(N,{className:"h-4 w-4"}),Ft.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));an.displayName=We.Content.displayName;const sn=({className:e,...t})=>Ft.jsx("div",{className:zt("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});sn.displayName="DialogHeader";const on=({className:e,...t})=>Ft.jsx("div",{className:zt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});on.displayName="DialogFooter";const ln=e.forwardRef(({className:e,...t},n)=>Ft.jsx(We.Title,{ref:n,className:zt("text-lg font-semibold leading-none tracking-tight",e),...t}));ln.displayName=We.Title.displayName;const cn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(We.Description,{ref:n,className:zt("text-sm text-muted-foreground",e),...t}));cn.displayName=We.Description.displayName;const un=Ke,dn=e.createContext({}),fn=({...e})=>Ft.jsx(dn.Provider,{value:{name:e.name},children:Ft.jsx(Ye,{...e})}),mn=()=>{const t=e.useContext(dn),n=e.useContext(pn),{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}},pn=e.createContext({}),hn=e.forwardRef(({className:t,...n},r)=>{const a=e.useId();return Ft.jsx(pn.Provider,{value:{id:a},children:Ft.jsx("div",{ref:r,className:zt("space-y-2",t),...n})})});hn.displayName="FormItem";const gn=e.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:a}=mn();return Ft.jsx(Wt,{ref:n,className:zt(r&&"text-destructive",e),htmlFor:a,...t})});gn.displayName="FormLabel";const xn=e.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:a,formMessageId:s}=mn();return Ft.jsx(d,{ref:t,id:r,"aria-describedby":n?`${a} ${s}`:`${a}`,"aria-invalid":!!n,...e})});xn.displayName="FormControl";e.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=mn();return Ft.jsx("p",{ref:n,id:r,className:zt("text-sm text-muted-foreground",e),...t})}).displayName="FormDescription";const yn=e.forwardRef(({className:e,children:t,...n},r)=>{const{error:a,formMessageId:s}=mn(),i=a?String(a?.message):t;return i?Ft.jsx("p",{ref:r,id:s,className:zt("text-sm font-medium text-destructive",e),...n,children:i}):null});yn.displayName="FormMessage";const bn=Je.Root,vn=Je.Value,wn=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(Je.Trigger,{ref:r,className:zt("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,Ft.jsx(Je.Icon,{asChild:!0,children:Ft.jsx(k,{className:"h-4 w-4 opacity-50"})})]}));wn.displayName=Je.Trigger.displayName;const Nn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Je.ScrollUpButton,{ref:n,className:zt("flex cursor-default items-center justify-center py-1",e),...t,children:Ft.jsx(j,{className:"h-4 w-4"})}));Nn.displayName=Je.ScrollUpButton.displayName;const kn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Je.ScrollDownButton,{ref:n,className:zt("flex cursor-default items-center justify-center py-1",e),...t,children:Ft.jsx(k,{className:"h-4 w-4"})}));kn.displayName=Je.ScrollDownButton.displayName;const jn=e.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>Ft.jsx(Je.Portal,{children:Ft.jsxs(Je.Content,{ref:a,className:zt("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:[Ft.jsx(Nn,{}),Ft.jsx(Je.Viewport,{className:zt("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),Ft.jsx(kn,{})]})}));jn.displayName=Je.Content.displayName;e.forwardRef(({className:e,...t},n)=>Ft.jsx(Je.Label,{ref:n,className:zt("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=Je.Label.displayName;const Cn=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(Je.Item,{ref:r,className:zt("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:[Ft.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ft.jsx(Je.ItemIndicator,{children:Ft.jsx(C,{className:"h-4 w-4"})})}),Ft.jsx(Je.ItemText,{children:t})]}));Cn.displayName=Je.Item.displayName;e.forwardRef(({className:e,...t},n)=>Ft.jsx(Je.Separator,{ref:n,className:zt("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=Je.Separator.displayName;const Sn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Xe.Root,{ref:n,className:zt("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:Ft.jsx(Xe.Indicator,{className:zt("flex items-center justify-center text-current"),children:Ft.jsx(C,{className:"h-4 w-4"})})}));Sn.displayName=Xe.Root.displayName;const In=e.forwardRef(({className:e,...t},n)=>Ft.jsx("textarea",{className:zt("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}));In.displayName="Textarea";const Pn=m("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"}}),En=e.forwardRef(({className:e,variant:t,...n},r)=>Ft.jsx("div",{ref:r,className:zt(Pn({variant:t}),e),...n}));En.displayName="Badge";const Tn={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function An({size:e="md",className:t}){return Ft.jsx(S,{className:zt("animate-spin text-muted-foreground",Tn[e],t)})}function _n({isLoading:e,children:t,className:n,type:r="spinner",size:a="md"}){return e?"overlay"===r?Ft.jsxs("div",{className:zt("relative",n),children:[t,Ft.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:Ft.jsx(An,{size:a})})]}):"skeleton"===r?Ft.jsx("div",{className:zt("animate-pulse",n),children:Ft.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):Ft.jsx("div",{className:zt("flex items-center justify-center py-8",n),children:Ft.jsx(An,{size:a})}):Ft.jsx(Ft.Fragment,{children:t})}let Rn=0;const Fn=new Map,Dn=e=>{if(Fn.has(e))return;const t=setTimeout(()=>{Fn.delete(e),Mn({type:"REMOVE_TOAST",toastId:e})},1e6);Fn.set(e,t)},zn=(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?Dn(n):e.toasts.forEach(e=>{Dn(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)}}},On=[];let Ln={toasts:[]};function Mn(e){Ln=zn(Ln,e),On.forEach(e=>{e(Ln)})}function Un({...e}){const t=(Rn=(Rn+1)%Number.MAX_SAFE_INTEGER,Rn.toString()),n=()=>Mn({type:"DISMISS_TOAST",toastId:t});return Mn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||n()}}}),{id:t,dismiss:n,update:e=>Mn({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function Bn(){const[t,n]=e.useState(Ln);return e.useEffect(()=>(On.push(n),()=>{const e=On.indexOf(n);e>-1&&On.splice(e,1)}),[t]),{...t,toast:Un,dismiss:e=>Mn({type:"DISMISS_TOAST",toastId:e})}}const $n=Ge.Provider,Vn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ge.Viewport,{ref:n,className:zt("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}));Vn.displayName=Ge.Viewport.displayName;const qn=m("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"}}),Hn=e.forwardRef(({className:e,variant:t,...n},r)=>Ft.jsx(Ge.Root,{ref:r,className:zt(qn({variant:t}),e),...n}));Hn.displayName=Ge.Root.displayName;const Wn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ge.Action,{ref:n,className:zt("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}));Wn.displayName=Ge.Action.displayName;const Qn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ge.Close,{ref:n,className:zt("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:Ft.jsx(N,{className:"h-4 w-4"})}));Qn.displayName=Ge.Close.displayName;const Kn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ge.Title,{ref:n,className:zt("text-sm font-semibold",e),...t}));Kn.displayName=Ge.Title.displayName;const Yn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ge.Description,{ref:n,className:zt("text-sm opacity-90",e),...t}));function Jn(){const{toasts:e}=Bn();return Ft.jsxs($n,{children:[e.map(function({id:e,title:t,description:n,action:r,...a}){return Ft.jsxs(Hn,{...a,children:[Ft.jsxs("div",{className:"grid gap-1",children:[t&&Ft.jsx(Kn,{children:t}),n&&Ft.jsx(Yn,{children:n})]}),r,Ft.jsx(Qn,{})]},e)}),Ft.jsx(Vn,{})]})}Yn.displayName=Ge.Description.displayName;var Xn=Object.defineProperty;class Gn{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?Xn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(Gn,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Zn="qualiex_access_token",er="qualiex_id_token",tr="supabase_token",nr="oauth_state",rr="oauth_nonce",ar="selected_alias",sr="manual_logout",ir={setAccessToken:e=>localStorage.setItem(Zn,e),getAccessToken:()=>localStorage.getItem(Zn),setIdToken:e=>localStorage.setItem(er,e),getIdToken:()=>localStorage.getItem(er),getSupabaseToken:()=>localStorage.getItem(tr),setOAuthState:e=>sessionStorage.setItem(nr,e),getOAuthState:()=>sessionStorage.getItem(nr),clearOAuthState:()=>sessionStorage.removeItem(nr),setOAuthNonce:e=>sessionStorage.setItem(rr,e),getOAuthNonce:()=>sessionStorage.getItem(rr),clearOAuthNonce:()=>sessionStorage.removeItem(rr),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:()=>!(!ir.getAccessToken()||!ir.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(tr,e),ir._clearValidationCache()},areAllTokensValid:()=>{const e=ir.getAccessToken(),t=ir.getIdToken();if(!e||!t)return!1;try{const n=Gn.validateTokens(e,t);return!!n.idTokenValid&&(n.accessTokenValid,n.idTokenValid)}catch(n){return!1}},clearExpiredTokens:()=>{let e=!1;const t=ir.getAccessToken(),n=ir.getIdToken(),r=ir.getSupabaseToken();return t&&ir.isTokenExpired(t)&&(localStorage.removeItem(Zn),e=!0),n&&ir.isTokenExpired(n)&&(localStorage.removeItem(er),e=!0),r&&ir.isTokenExpired(r)&&(localStorage.removeItem(tr),e=!0),e},clearAll:()=>{localStorage.removeItem(Zn),localStorage.removeItem(er),localStorage.removeItem(tr),localStorage.removeItem(ar),localStorage.removeItem(sr),sessionStorage.removeItem(nr),sessionStorage.removeItem(rr)},setManualLogout:()=>localStorage.setItem(sr,"true"),isManualLogout:()=>"true"===localStorage.getItem(sr),clearManualLogout:()=>localStorage.removeItem(sr),isTokenExpired:e=>{try{return Gn.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{ir._validationCache.isValid=!1,ir._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=ir.getSupabaseToken();if(!e)return!1;if(ir.isTokenExpired(e))return ir._clearValidationCache(),ir._handleExpiredToken(),!1;const t=Date.now();return t-ir._validationCache.timestamp<ir._validationCache.cacheValidityMs?ir._validationCache.isValid:(ir._validationCache.isValid=!0,ir._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>ir.isSupabaseTokenValid()?ir.getSupabaseToken():null,_handleExpiredToken:()=>{ir.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!ir.isSupabaseTokenValid())return null;const e=ir.getSupabaseToken();if(!e)return null;try{const t=Gn.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 ir._handleExpiredToken(),null}},getCompanyId:e=>{const t=ir.getAccessToken();if(t)try{const n=Gn.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=ir.extractTokenData();if(n?.companyId)return n.companyId;const r=ir.getIdToken();if(r)try{const t=Gn.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=ir.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=ir.getIdToken();if(!e)return[];try{const t=Gn.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 or=Object.defineProperty,lr=(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 cr=new class{constructor(){lr(this,"errors",[]),lr(this,"toastCount",0),lr(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()){Un({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){Un({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 ur=Object.defineProperty,dr=(e,t,n)=>((e,t,n)=>t in e?ur(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const fr=import.meta.env.VITE_SUPABASE_URL,mr=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,pr=class e{constructor(){dr(this,"client"),dr(this,"currentToken",null),dr(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:mr};return e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`),Ze(fr,mr,{auth:{persistSession:!1,autoRefreshToken:!1,storage:void 0},global:{headers:t}})}static getInstance(){return e.instance||(e.instance=new e),e.instance}getClient(){const e=ir.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 cr.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};dr(pr,"instance");let hr=pr;const gr=()=>hr.getInstance().getClient();var xr=Object.freeze({__proto__:null,getSupabaseClient:gr});class yr{static async generateToken(e,t,n,r=!1){try{if(!r){const e=ir.getSupabaseToken();if(e&&ir.isSupabaseTokenValid())return e}const a=gr(),{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?(ir.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 br=Object.defineProperty,vr=(e,t,n)=>((e,t,n)=>t in e?br(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=ir.getAccessToken(),t=ir.getSelectedAlias();if(!e||!t)return null;const n=await yr.generateToken(e,t,this.onLogoutCallback||void 0,!1);return n?(ir.setSupabaseToken(n),n):null}catch(e){return null}finally{this.isRegenerating=!1}}}vr(wr,"isRegenerating",!1),vr(wr,"onLogoutCallback",null);class Nr{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(ir.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 kr=Object.defineProperty;class jr{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):(Nr.handleError(e),this.isRetrying=!1,!1)}catch(r){return Nr.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=ir.getAccessToken();return e?ir.isTokenExpired(e)?{valid:!1,message:"Sua sessão expirou. Você será redirecionado para fazer login."}:{valid:!0}:{valid:!1,message:"Token OAuth não encontrado. Faça login novamente."}}}((e,t,n)=>{((e,t,n)=>{t in e?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,t+"",n)})(jr,"isRetrying",!1);var Cr=Object.defineProperty,Sr=(e,t,n)=>((e,t,n)=>t in e?Cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const Ir=new class{constructor(){Sr(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=jr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=ir.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 cr.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=n}if(!Array.isArray(r))return cr.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(n){if(await jr.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 cr.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=n}return Array.isArray(r)?r.map(this.mapToQualiexUser):(cr.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return cr.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 cr.handleError(a,!0),[]}}async fetchUserById(e,t,n){try{return(await this.fetchUsers(t,n)).find(t=>t.userId===e)||null}catch(r){return cr.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=ir.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}};var Pr=Object.freeze({__proto__:null,qualiexApi:Ir});const Er={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"}},Tr={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Ar={debounceDelay:500},_r=()=>{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},Rr={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]};let Fr={enableUserEnrichment:!1,enableUsersApi:!1,userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"};const Dr=()=>Fr,zr=e=>{Fr={...Fr,...e}},Or={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 Lr(e,t){const n=Dr(),r=t||n.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Mr(e,t){const n=Dr(),r=t||n.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Ur(e,t){const n=Dr(),r=t||n.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Br(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||Lr(e.idField),emailField:e.emailField||Mr(e.idField),usernameField:e.usernameField||Ur(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Lr(e),emailField:Mr(e),usernameField:Ur(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const $r=new Map;class Vr{static async fetchQualiexUsers(e,t){const n=Dr(),r=`${t}_${e}`,a=$r.get(r);if(a&&Date.now()-a.timestamp<3e5)return a.users;let s;return s=n.fetchUsers?await n.fetchUsers(t,e):await Ir.fetchUsers(e,t),$r.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=Dr();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=ir.extractTokenData();if(!t)return e;r=r||t.alias,a=a||t.companyId}if(!r||!a)return e;const s=Br(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 cr.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 qr=["responsible_name"],Hr=e=>qr.includes(e);function Wr(e,t,n){const r="string"==typeof e?{tableName:e,searchFields:t||[],schemaName:n||"central"}:{searchFields:e.searchFields||[],schemaName:e.schemaName||"central",...e},{tableName:a,searchFields:s,selectFields:i,schemaName:o,entityName:l,enableQualiexEnrichment:c=!1}=r,u=()=>{if(!ir.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return gr().schema(o).from(a)};return{async getAll(e={}){const{search:t="",sortField:n="updated_at",sortDirection:o="desc",page:d=1,limit:f=25,...m}=e;let p=u().select(i||"*",{count:"exact"});p=p.eq("is_removed",!1),Object.entries(m).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(".")||Hr(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,d,f);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,d,f);const b=Dr();if(c&&b.enableUserEnrichment&&l&&y.data.length>0){const t=Br(r.userIdFields,r.userFieldsMapping);if(y.data.some(e=>t.some(t=>e[t.idField]))){const a=n&&n.includes("."),s=n&&Hr(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 Vr.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 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}}})(c,d,f);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}}const c=await Vr.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 u().select(i||"*").eq("id",e).maybeSingle();if(n)throw new Error(`Error fetching ${a}: ${n.message}`);return t},async create(e){const t=Ot(e),n=Object.entries(t).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),{data:r,error:s}=await u().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={...Ot(t),updated_at:(new Date).toISOString()},{data:r,error:s}=await u().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 u().update(t).eq("id",e);if(n)throw new Error(`Error soft deleting ${a}: ${n.message}`)}}}const Qr=()=>{ir.clearManualLogout()},Kr=class{static async initialize(){try{if(!ir.hasAllTokens()||!ir.areAllTokensValid())return ir.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=ir.getAccessToken(),n=ir.getIdToken();Qr();const r=this.extractUserFromIdToken(n),a=this.extractCompaniesFromIdToken(n),s=this.extractAliasFromAccessToken(t),i=ir.extractTokenData(),o=i?.alias;let l=null;if(o&&a.some(e=>e.alias===o))l=o;else{const e=ir.getSelectedAlias(),t=e&&a.some(t=>t.alias===e);l=t?e:s||a[0]?.alias||null}!ir.isSupabaseTokenValid()&&l&&await wr.attemptRegeneration();let c=null;if(l){const e=ir.getCompanyId(l),t=a.find(e=>e.alias===l);t&&(c={id:e||t.id,name:t.name,alias:t.alias})}let u=null,d=null;if(r?.id&&l){const t=ir.getCompanyId(l);if(t)try{const{qualiexApi:e}=await Promise.resolve().then(function(){return Pr}),{getUserPlaceData:n}=await Promise.resolve().then(function(){return Ih}),a=(await e.fetchActiveUsersMap(l,t)).get(r.id);if(a){const e=n(a);u=e.placeId,d=e.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:u,placeName:d,activePlaceId:u,activePlaceName:d}}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{getSupabaseClient:e}=await Promise.resolve().then(function(){return xr}),t=e(),{data:n,error:r}=await t.functions.invoke("dev-tokens",{body:{environment:"development"}});if(r)return!1;if(!n?.access_token||!n?.id_token)return!1;const a=new URL("/callback",window.location.origin);return a.hash=`access_token=${n.access_token}&id_token=${n.id_token}&token_type=bearer`,window.location.href=a.toString(),!0}catch(e){return!1}}static loginProd(){const e=ir.generateOAuthState();ir.setOAuthState(e);const t=ir.generateOAuthNonce();ir.setOAuthNonce(t);const n=`${window.location.origin}/callback`,r=new URL(Er.oauth.authUrl);r.searchParams.set("client_id",Er.oauth.clientId),r.searchParams.set("response_type",Er.oauth.responseType),r.searchParams.set("scope",Er.oauth.scope),r.searchParams.set("redirect_uri",n),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),_r(),window.location.href=r.toString()}static async processCallback(){try{if(ir.hasAllTokens()){if(!ir.getValidSupabaseToken()){ir.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");ir.setAccessToken(r),ir.setIdToken(a),Qr();const i=this.extractAliasFromAccessToken(r);if(i)ir.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(a);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");ir.setSelectedAlias(e[0].alias)}if(!await wr.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return ir.clearOAuthState(),ir.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){ir.setManualLogout(),ir.clearAll(),window.location.href="/login"}static decodeToken(e){return Gn.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(()=>{Kr.logout()});let Yr=Kr;const Jr=n(void 0),Xr=({children:e})=>{const[t,n]=a({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let r=null;try{r=et()}catch{}const[l,c]=a(!1),[u,d]=a(0),f=s(e=>{n(t=>({...t,...e}))},[]),m=s(e=>{n(t=>({...t,isLoading:e}))},[]),p=s(()=>{n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),h=s(async e=>{try{m(!0);const a=ir.getAccessToken();if(!a)return;const s=await yr.generateToken(a,e.alias,void 0,!0);if(!s)return;ir.setSupabaseToken(s),ir.setSelectedAlias(e.alias);const i=ir.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||ir.getCompanyId(e.alias),c={id:l||e.id,name:e.name,alias:o};let u=null,d=null;if(t.user?.id&&o&&l)try{const{qualiexApi:e}=await Promise.resolve().then(function(){return Pr}),{getUserPlaceData:n}=await Promise.resolve().then(function(){return Ih}),r=(await e.fetchActiveUsersMap(o,l)).get(t.user.id);if(r){const e=n(r);u=e.placeId,d=e.placeName}}catch(n){}f({alias:o,selectedUnit:c,placeId:u,placeName:d,activePlaceId:u,activePlaceName:d}),r&&(await r.clear(),await new Promise(e=>setTimeout(e,100)))}catch(n){}finally{m(!1)}},[f,r,m,t.user]),g=s(async()=>await Yr.processCallback(),[]),x=s(async()=>{Yr.logout(),p(),r&&await r.clear()},[p,r]),y=s(e=>{c(e)},[]),b=s(()=>{d(e=>e+1)},[]),v=s(()=>{d(e=>e+1)},[]);i(()=>{if(!t.isAuthenticated)return;let e=!0;const n=setInterval(()=>{e&&(ir.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(n)}},[t.isAuthenticated,x]),i(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await Yr.initialize();if(!e)return;t&&t.isAuthenticated?f({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&&m(!1)}catch(t){e&&(Nr.handleError(t),m(!1))}})(),()=>{e=!1}},[f,m,x]);const w=o(()=>({...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 Ft.jsx(Jr.Provider,{value:w,children:e})},Gr=()=>{const e=r(Jr);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Zr({queryKey:e,service:t,entityName:n,searchFields:r,additionalFilters:i={},onSuccess:l}){const[c,u]=at(),d=et(),{alias:f,userId:m}=Gr(),p=c.get("search")||"",h=c.get("sortField")||Tr.sorting.defaultField,g=c.get("sortDirection")||Tr.sorting.defaultDirection,x=parseInt(c.get("page")||"1"),y=parseInt(c.get("limit")||String(Tr.pagination.defaultPageSize)),v=p,w=o(()=>({search:v,sortField:h,sortDirection:g,page:x,limit:y,...i}),[v,h,g,x,y,i]),N=s(()=>t.getAll(w),[t,w]),k=tt({queryKey:[e,f,m,w],queryFn:N});if(!k)throw new Error(`useCrud: Query initialization failed for "${n}". Ensure QueryClientProvider is configured in your app root.`);const j=nt({mutationFn:t.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Or.success.created(n)),l?.()},onError:e=>{b.error(`${Or.error.create(n)}: ${e.message}`)}}),C=nt({mutationFn:({id:e,data:n})=>t.update(e,n),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Or.success.updated(n)),l?.()},onError:e=>{b.error(`${Or.error.update(n)}: ${e.message}`)}}),S=nt({mutationFn:t.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Or.success.deleted(n))},onError:e=>{b.error(`${Or.error.delete(n)}: ${e.message}`)}}),I=s(e=>{const t={...Object.fromEntries(c)};Object.entries(e).forEach(([e,n])=>{""===n||0===n?delete t[e]:t[e]=String(n)}),u(t)},[c,u]),P=s(e=>{I({search:e,page:1})},[I]),E=s(e=>{I({sortField:e,sortDirection:h===e&&"asc"===g?"desc":"asc",page:1})},[h,g,I]),T=s(e=>{I({page:e})},[I]),A=s(e=>{I({limit:e,page:1})},[I]),_=s(()=>{u({})},[u]),[R,F]=a([]),D=s(e=>{F(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),z=s(()=>{const e=k?.data?.data.map(e=>e.id)||[];F(t=>t.length===e.length?[]:e)},[k?.data?.data]),O=s(()=>{F([])},[]),L=o(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&R.length===e.length},[R,k?.data?.data]),M=nt({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,r)=>{d.invalidateQueries({queryKey:[e]}),b.success(`${r.length} ${n}(s) deletado(s) com sucesso`),O()},onError:e=>{b.error(`Erro ao deletar itens: ${e.message}`)}}),U=s((e,t)=>{const n=t?t(e):e;e.id?C.mutate({id:e.id,data:n}):j.mutate({...n,alias:f})},[f,j,C]);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||Tr.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:j?.isPending??!1,isUpdating:C?.isPending??!1,isDeleting:S?.isPending??!1,error:k?.error||null,searchTerm:p,sortField:h,sortDirection:g,currentPage:x,itemsPerPage:y,createEntity:j.mutate,updateEntity:(e,t)=>C.mutate({id:e,data:t}),deleteEntity:S.mutate,save:U,handleSearch:P,handleSort:E,handlePageChange:T,handleItemsPerPageChange:A,clearFilters:_,refetch:k.refetch,selectedIds:R,selectItem:D,selectAll:z,clearSelection:O,isAllSelected:L,bulkDelete:M.mutate,isBulkDeleting:M.isPending}}function ea(e){const t=Wr({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)=>Zr({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:n,onSuccess:r})}}const ta=lt.Root,na=lt.Trigger,ra=lt.Portal,aa=e.forwardRef(({className:e,...t},n)=>Ft.jsx(lt.Overlay,{className:zt("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}));aa.displayName=lt.Overlay.displayName;const sa=e.forwardRef(({className:e,...t},n)=>Ft.jsxs(ra,{children:[Ft.jsx(aa,{}),Ft.jsx(lt.Content,{ref:n,className:zt("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})]}));sa.displayName=lt.Content.displayName;const ia=({className:e,...t})=>Ft.jsx("div",{className:zt("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});ia.displayName="AlertDialogHeader";const oa=({className:e,...t})=>Ft.jsx("div",{className:zt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});oa.displayName="AlertDialogFooter";const la=e.forwardRef(({className:e,...t},n)=>Ft.jsx(lt.Title,{ref:n,className:zt("text-lg font-semibold",e),...t}));la.displayName=lt.Title.displayName;const ca=e.forwardRef(({className:e,...t},n)=>Ft.jsx(lt.Description,{ref:n,className:zt("text-sm text-muted-foreground",e),...t}));ca.displayName=lt.Description.displayName;const ua=e.forwardRef(({className:e,...t},n)=>Ft.jsx(lt.Action,{ref:n,className:zt(Bt(),e),...t}));ua.displayName=lt.Action.displayName;const da=e.forwardRef(({className:e,...t},n)=>Ft.jsx(lt.Cancel,{ref:n,className:zt(Bt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));da.displayName=lt.Cancel.displayName;const fa=({open:e,onOpenChange:t,item:n,onConfirm:r,entityName:s="item",isDeleting:o=!1,isBulk:l=!1,bulkCount:c})=>{const[u,d]=a("");i(()=>{e||d("")},[e]);const f=()=>{d(""),t(!1)},m=l?u===c?.toString():u===n?.title;return n?Ft.jsx(ta,{open:e,onOpenChange:f,children:Ft.jsxs(sa,{className:"sm:max-w-[500px]",children:[Ft.jsx(ia,{children:Ft.jsxs("div",{className:"flex items-center space-x-2",children:[Ft.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:Ft.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),Ft.jsx("div",{className:"flex-1",children:Ft.jsx(la,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),Ft.jsx(ca,{asChild:!0,children:Ft.jsxs("div",{className:"space-y-4",children:[Ft.jsxs("div",{className:"text-sm text-muted-foreground",children:[Ft.jsx("p",{className:"mb-2",children:l?Ft.jsx(Ft.Fragment,{children:"Você está prestes a excluir permanentemente:"}):Ft.jsxs(Ft.Fragment,{children:["Você está prestes a excluir permanentemente o ",s,":"]})}),Ft.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:Ft.jsx("p",{className:"font-medium text-foreground",children:l?`${n.title}`:n.title})})]}),Ft.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:Ft.jsxs("div",{className:"flex items-start space-x-2",children:[Ft.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:Ft.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),Ft.jsxs("div",{className:"text-sm text-orange-800",children:[Ft.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),Ft.jsx("p",{children:l?Ft.jsx(Ft.Fragment,{children:"Esta ação não pode ser desfeita. Os itens serão removidos permanentemente do sistema."}):Ft.jsxs(Ft.Fragment,{children:["Esta ação não pode ser desfeita. O ",s," será removido permanentemente do sistema."]})})]})]})}),Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(Wt,{htmlFor:"confirmation",className:"text-sm font-medium",children:l?Ft.jsxs(Ft.Fragment,{children:["Para confirmar, digite o número de itens que serão removidos: ",Ft.jsx("strong",{children:c})]}):Ft.jsxs(Ft.Fragment,{children:["Para confirmar, digite ",Ft.jsxs("strong",{children:['"',n.title,'"']})," abaixo:"]})}),Ft.jsx(qt,{id:"confirmation",type:l?"number":"text",value:u,onChange:e=>d(e.target.value),placeholder:l?`Digite: ${c}`:`Digite: ${n.title}`,className:"w-full"})]})]})}),Ft.jsxs(oa,{children:[Ft.jsx(da,{onClick:f,children:"Cancelar"}),Ft.jsx(ua,{onClick:()=>{if(!n)return;(l?u===c?.toString():u===n.title)&&(r(n),d(""),t(!1))},disabled:!m||o,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:o?"Removendo...":`Excluir ${s}`})]})]})}):null},ma=e.forwardRef(({className:e,...t},n)=>Ft.jsx("table",{ref:n,className:zt("w-full caption-bottom text-sm",e),...t}));ma.displayName="Table";const pa=e.forwardRef(({className:e,...t},n)=>Ft.jsx("thead",{ref:n,className:zt("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));pa.displayName="TableHeader";const ha=e.forwardRef(({className:e,...t},n)=>Ft.jsx("tbody",{ref:n,className:zt("[&_tr:last-child]:border-0",e),...t}));ha.displayName="TableBody";const ga=e.forwardRef(({className:e,...t},n)=>Ft.jsx("tfoot",{ref:n,className:zt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));ga.displayName="TableFooter";const xa=e.forwardRef(({className:e,...t},n)=>Ft.jsx("tr",{ref:n,className:zt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...t}));xa.displayName="TableRow";const ya=e.forwardRef(({className:e,...t},n)=>Ft.jsx("th",{ref:n,className:zt("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}));ya.displayName="TableHead";const ba=e.forwardRef(({className:e,...t},n)=>Ft.jsx("td",{ref:n,className:zt("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ba.displayName="TableCell";const va=e.forwardRef(({className:e,...t},n)=>Ft.jsx("caption",{ref:n,className:zt("mt-4 text-sm text-muted-foreground",e),...t}));function wa({className:e,...t}){return Ft.jsx("div",{className:zt("animate-pulse rounded-md bg-muted",e),...t})}function Na({rows:e=5,columns:t=4}){return Ft.jsx("div",{className:"w-full",children:Ft.jsxs("div",{className:"rounded-md border",children:[Ft.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:Ft.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Ft.jsx(wa,{className:"h-4 w-24"},t))})}),Ft.jsx("div",{children:Array.from({length:e}).map((e,n)=>Ft.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:Ft.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Ft.jsx(wa,{className:"h-4 w-20"},t))})},n))})]})})}function ka({count:e=3}){return Ft.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>Ft.jsxs(Qt,{children:[Ft.jsxs(Kt,{children:[Ft.jsx(wa,{className:"h-4 w-3/4"}),Ft.jsx(wa,{className:"h-3 w-1/2"})]}),Ft.jsx(Xt,{children:Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(wa,{className:"h-3 w-full"}),Ft.jsx(wa,{className:"h-3 w-2/3"})]})})]},t))})}function ja({fields:e=4}){return Ft.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(wa,{className:"h-4 w-24"}),Ft.jsx(wa,{className:"h-10 w-full"})]},t)),Ft.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Ft.jsx(wa,{className:"h-10 w-20"}),Ft.jsx(wa,{className:"h-10 w-20"})]})]})}function Ca(){return Ft.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[Ft.jsxs("div",{className:"flex items-center space-x-3",children:[Ft.jsx(wa,{className:"h-8 w-8 rounded-full"}),Ft.jsx(wa,{className:"h-6 w-32"})]}),Ft.jsxs("div",{className:"flex items-center space-x-2",children:[Ft.jsx(wa,{className:"h-8 w-8"}),Ft.jsx(wa,{className:"h-8 w-24"})]})]})}function Sa(){return Ft.jsx("div",{className:"w-64 border-r bg-muted/10",children:Ft.jsxs("div",{className:"p-4",children:[Ft.jsx(wa,{className:"h-8 w-32 mb-6"}),Ft.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>Ft.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[Ft.jsx(wa,{className:"h-4 w-4"}),Ft.jsx(wa,{className:"h-4 w-20"})]},t))})]})})}va.displayName="TableCaption";const Ia={default:E,search:P,error:I};function Pa({icon:e,title:t,description:n,action:r,className:a,variant:s="default"}){const i=e?()=>e:Ia[s];return Ft.jsxs("div",{className:zt("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[Ft.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:Ft.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),Ft.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),n&&Ft.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:n}),r&&Ft.jsx($t,{onClick:r.onClick,variant:"outline",children:r.label})]})}const Ea=ct.Root,Ta=ct.Trigger,Aa=ct.Group,_a=ct.Portal,Ra=ct.Sub,Fa=ct.RadioGroup,Da=e.forwardRef(({className:e,inset:t,children:n,...r},a)=>Ft.jsxs(ct.SubTrigger,{ref:a,className:zt("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,Ft.jsx(T,{className:"ml-auto h-4 w-4"})]}));Da.displayName=ct.SubTrigger.displayName;const za=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ct.SubContent,{ref:n,className:zt("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}));za.displayName=ct.SubContent.displayName;const Oa=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Ft.jsx(ct.Portal,{children:Ft.jsx(ct.Content,{ref:r,sideOffset:t,className:zt("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})}));Oa.displayName=ct.Content.displayName;const La=e.forwardRef(({className:e,inset:t,...n},r)=>Ft.jsx(ct.Item,{ref:r,className:zt("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}));La.displayName=ct.Item.displayName;const Ma=e.forwardRef(({className:e,children:t,checked:n,...r},a)=>Ft.jsxs(ct.CheckboxItem,{ref:a,className:zt("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:[Ft.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ft.jsx(ct.ItemIndicator,{children:Ft.jsx(C,{className:"h-4 w-4"})})}),t]}));Ma.displayName=ct.CheckboxItem.displayName;const Ua=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(ct.RadioItem,{ref:r,className:zt("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:[Ft.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ft.jsx(ct.ItemIndicator,{children:Ft.jsx(A,{className:"h-2 w-2 fill-current"})})}),t]}));Ua.displayName=ct.RadioItem.displayName;const Ba=e.forwardRef(({className:e,inset:t,...n},r)=>Ft.jsx(ct.Label,{ref:r,className:zt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ba.displayName=ct.Label.displayName;const $a=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ct.Separator,{ref:n,className:zt("-mx-1 my-1 h-px bg-muted",e),...t}));$a.displayName=ct.Separator.displayName;const Va=({className:e,...t})=>Ft.jsx("span",{className:zt("ml-auto text-xs tracking-widest opacity-60",e),...t});Va.displayName="DropdownMenuShortcut";const qa=({onEdit:e,onDelete:t,onToggleStatus:n,isActive:r=!0,canDelete:a=!0,renderAs:s})=>{const i=[];if(e){const t={icon:_,label:"Editar",onClick:e};i.push(t)}if(n){const e={icon:r?R:F,label:r?"Inativar":"Ativar",onClick:n};i.push(e)}if(a&&t){const e={icon:D,label:"Remover",onClick:t,destructive:!0};i.push(e)}return"dropdown"===s?Ft.jsx(Ft.Fragment,{children:i.map((e,t)=>Ft.jsxs(La,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[Ft.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):Ft.jsx(Ft.Fragment,{children:i.map((e,t)=>Ft.jsxs($t,{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:[Ft.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},Ha=({onEdit:e,onDelete:t,canDelete:n=!0,onToggleStatus:r,isActive:a=!0})=>Ft.jsxs(Ea,{children:[Ft.jsx(Ta,{asChild:!0,children:Ft.jsx($t,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:Ft.jsx(w,{size:12})})}),Ft.jsx(Oa,{align:"end",children:Ft.jsx(qa,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),r?.()},isActive:a,canDelete:n,renderAs:"dropdown"})})]}),Wa=l(({checked:e,onCheckedChange:t})=>Ft.jsx(Sn,{checked:e,onCheckedChange:t}),(e,t)=>e.checked===t.checked),Qa=({manager:e,columns:t,onEdit:n,onView:r,onToggleStatus:s,onDelete:o,renderActions:l,enableBulkActions:c=!1})=>{const[u,d]=a(!1),[f,m]=a(null);i(()=>{const e=()=>d(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),i(()=>{const e=()=>m(null);if(f)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[f]);const p=(()=>{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+=100,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?Ft.jsx(ka,{count:3}):0===e.entities.length?Ft.jsx(Pa,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):Ft.jsxs("div",{className:"space-y-4",children:[e.entities.map(a=>Ft.jsx(Qt,{className:zt("overflow-hidden cursor-pointer hover:bg-muted/50",c&&e.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),c||n?.(a)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),m({x:e.clientX,y:e.clientY,item:a})},children:Ft.jsx(Xt,{className:"p-4",children:Ft.jsxs("div",{className:"flex items-start gap-3",children:[c&&Ft.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:Ft.jsx(Wa,{checked:e.selectedIds.includes(a.id),onCheckedChange:()=>e.selectItem(a.id)})}),Ft.jsxs("div",{className:"flex-1",children:[t.map(e=>Ft.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[Ft.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[e.header,":"]}),Ft.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:e.render?e.render(a):a[e.key]})]},String(e.key))),(n||r||l)&&Ft.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):Ft.jsx(Ha,{onEdit:n?()=>{n(a)}:void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:s?()=>s(a):void 0,isActive:a.is_actived})})]})]})})},a.id)),f&&Ft.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:Ft.jsx(qa,{onEdit:n?()=>{n(f.item),m(null)}:void 0,onDelete:o?()=>{o(f.item),m(null)}:void 0,onToggleStatus:s?()=>{s(f.item),m(null)}:void 0,isActive:f.item.is_actived,canDelete:!!o,renderAs:"context"})})]}):Ft.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?Ft.jsx(Na,{rows:5,columns:t.length}):Ft.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:Ft.jsx("div",{className:"flex-1 overflow-auto",children:Ft.jsxs(ma,{className:"table-auto",children:[Ft.jsxs("colgroup",{children:[c&&Ft.jsx("col",{style:{width:"50px"}}),p.map((e,t)=>Ft.jsx("col",{style:e.style},t)),Ft.jsx("col",{style:{width:"100px"}})]}),Ft.jsx(pa,{children:Ft.jsxs(xa,{children:[c&&Ft.jsx(ya,{className:"w-[50px]",children:Ft.jsx(Wa,{checked:e.isAllSelected,onCheckedChange:e.selectAll})}),t.map(t=>{return Ft.jsx(ya,{className:`${t.className||""} ${t.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:t.sortable?()=>e.handleSort(String(t.key)):void 0,children:Ft.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?Ft.jsx(z,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?Ft.jsx(O,{size:14,className:"ml-1"}):Ft.jsx(L,{size:14,className:"ml-1"}))]})},String(t.key));var n}),Ft.jsx(ya,{className:"w-[100px] text-center",children:"Ações"})]})}),Ft.jsx(ha,{children:0===e.entities.length?Ft.jsx(xa,{children:Ft.jsx(ba,{colSpan:c?t.length+2:t.length+1,className:"h-32",children:Ft.jsx(Pa,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(r=>Ft.jsxs(xa,{className:zt("cursor-pointer hover:bg-muted/50",c&&e.selectedIds.includes(r.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),c||n?.(r)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),m({x:e.clientX,y:e.clientY,item:r})},children:[c&&Ft.jsx(ba,{onClick:e=>e.stopPropagation(),children:Ft.jsx(Wa,{checked:e.selectedIds.includes(r.id),onCheckedChange:()=>e.selectItem(r.id)})}),t.map(e=>Ft.jsx(ba,{className:e.className,children:e.render?e.render(r):r[e.key]},String(e.key))),Ft.jsx(ba,{className:"text-center",children:l?l(r):Ft.jsx(Ha,{onEdit:n?()=>n(r):void 0,onDelete:o?()=>o(r):void 0,onToggleStatus:s?()=>s(r):void 0,isActive:r.is_actived})})]},r.id))})]})})}),f&&Ft.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:Ft.jsx(qa,{onEdit:n?()=>{n(f.item),m(null)}:void 0,onDelete:o?()=>{o(f.item),m(null)}:void 0,onToggleStatus:s?()=>{s(f.item),m(null)}:void 0,isActive:f.item.is_actived,canDelete:!!o,renderAs:"context"})})]})};function Ka(e,t,n,r){const[s,l]=a({}),[c,u]=a({}),d=o(()=>e,[e]),f=e=>e instanceof Date&&!isNaN(e.getTime()),m=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 m(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){}}};i(()=>{if(!r)return;const e=t=>{const n=[];return t.forEach(t=>{n.push(t),t.fields&&n.push(...e(t.fields))}),n},a=e(d),s={};a.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);f(e)&&(n=e.toISOString().split("T")[0])}else f(n)&&(n=n.toISOString().split("T")[0])}else n=m(e);s[e.name]=n}),a.forEach(e=>{const t=p(e,s);void 0!==t&&(s[e.name]=t)}),t&&Object.keys(t).forEach(e=>{a.find(t=>t.name===e)||void 0===t[e]||(s[e]=t[e])}),l(s),u({}),n&&n(s)},[d,t,n,r]);const g=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...g(e.fields))}),t},x=()=>{const e=g(d),t={};return e.forEach(e=>{const n=h(e,s[e.name],s);n&&(t[e.name]=n)}),u(t),0===Object.keys(t).length};return{formData:s,errors:c,updateField:(e,t)=>{l(r=>{const a={...r,[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(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=p(e,n);void 0!==t&&(n={...n,[e.name]:t})}),n})(e,a);return n&&n(s),s}),c[e]&&u(t=>{const n={...t};return delete n[e],n});const r=g(d).find(t=>t.name===e);if(r){const n=h(r,t,s);n&&u(t=>({...t,[e]:n}))}},validateForm:x,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),x()&&e(s)}}}const Ya=ut.Root,Ja=ut.Trigger,Xa=e.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>Ft.jsx(ut.Portal,{children:Ft.jsx(ut.Content,{ref:a,align:t,sideOffset:n,className:zt("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),...r})}));Xa.displayName=ut.Content.displayName;const Ga=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Za=({value:e="#3b82f6",onChange:t,label:n})=>Ft.jsxs("div",{className:"space-y-2",children:[n&&Ft.jsx(Wt,{children:n}),Ft.jsxs(Ya,{children:[Ft.jsx(Ja,{asChild:!0,children:Ft.jsxs($t,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Ft.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),Ft.jsx(Xa,{className:"w-64",children:Ft.jsxs("div",{className:"space-y-3",children:[Ft.jsxs("div",{children:[Ft.jsx(Wt,{htmlFor:"color-input",children:"Cor personalizada"}),Ft.jsx(qt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),Ft.jsxs("div",{children:[Ft.jsx(Wt,{children:"Cores predefinidas"}),Ft.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Ga.map(e=>Ft.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))})]})]})})]})]}),es=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(dt.Root,{ref:r,className:zt("relative overflow-hidden",e),...n,children:[Ft.jsx(dt.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),Ft.jsx(ts,{}),Ft.jsx(dt.Corner,{})]}));es.displayName=dt.Root.displayName;const ts=e.forwardRef(({className:e,orientation:t="vertical",...n},r)=>Ft.jsx(dt.ScrollAreaScrollbar,{ref:r,orientation:t,className:zt("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:Ft.jsx(dt.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));ts.displayName=dt.ScrollAreaScrollbar.displayName;const ns={Star:Te,Heart:Ee,Home:Pe,User:Ie,Settings:Se,Mail:Ce,Phone:je,Calendar:ke,MapPin:Ne,Camera:we,Image:ve,Music:be,Video:ye,Book:xe,Bookmark:ge,Search:P,Filter:he,Edit:_,Trash2:D,Plus:pe,Minus:me,Check:C,X:N,ChevronDown:k,ChevronUp:j,ChevronLeft:fe,ChevronRight:T,ArrowUp:O,ArrowDown:L,ArrowLeft:de,ArrowRight:ue,Clock:ce,Bell:le,AlertCircle:I,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:$,Award:B,Trophy:U,Target:M},rs=({value:e="Star",onChange:t,label:n})=>{const[r,s]=a(""),i=Object.entries(ns).filter(([e])=>e.toLowerCase().includes(r.toLowerCase())),o=ns[e]||Te;return Ft.jsxs("div",{className:"space-y-2",children:[n&&Ft.jsx(Wt,{children:n}),Ft.jsxs(Ya,{children:[Ft.jsx(Ja,{asChild:!0,children:Ft.jsxs($t,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Ft.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),Ft.jsx(Xa,{className:"w-80",children:Ft.jsxs("div",{className:"space-y-3",children:[Ft.jsxs("div",{children:[Ft.jsx(Wt,{htmlFor:"icon-search",children:"Buscar ícone"}),Ft.jsx(qt,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:r,onChange:e=>s(e.target.value)})]}),Ft.jsx(es,{className:"h-48",children:Ft.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([n,r])=>Ft.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:Ft.jsx(r,{className:"h-4 w-4"})},n))})})]})})]})]})},as=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));as.displayName="Command";const ss=({children:e,...t})=>Ft.jsx("div",{...t,children:Ft.jsx(as,{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})}),is=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:Ft.jsx("input",{ref:n,className:zt("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})}));is.displayName="CommandInput";const os=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));os.displayName="CommandList";const ls=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("py-6 text-center text-sm text-muted-foreground",e),...t}));ls.displayName="CommandEmpty";const cs=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("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}));cs.displayName="CommandGroup";const us=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("-mx-1 h-px bg-border",e),...t}));us.displayName="CommandSeparator";const ds=e.forwardRef(({className:e,disabled:t,onSelect:n,value:r,...a},s)=>Ft.jsx("div",{ref:s,className:zt("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}));ds.displayName="CommandItem";const fs=({className:e,...t})=>Ft.jsx("span",{className:zt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});function ms({options:t,value:n,onChange:r,onCreate:a,placeholder:s="Selecionar...",searchPlaceholder:i="Buscar...",createLabel:o=e=>`Criar "${e}"`,emptyMessage:l="Nenhum item encontrado.",disabled:c=!1,error:u,isLoading:d=!1,className:f,mode:m="single"}){const[p,h]=e.useState(!1),[g,x]=e.useState(""),[y,b]=e.useState(!1),v=e.useMemo(()=>n?Array.isArray(n)?n:[n]:[],[n]),w=e.useMemo(()=>v.map(e=>t.find(t=>t.value===e)?.label).filter(Boolean),[v,t]),N=e.useMemo(()=>g?t.filter(e=>e.label.toLowerCase().includes(g.toLowerCase())):t,[t,g]),k=e.useMemo(()=>!(!g||!a)&&!t.some(e=>e.label.toLowerCase()===g.toLowerCase()),[g,t,a]),j=e.useMemo(()=>0===w.length?s:"single"===m?w[0]:null,[w,s,m]);return Ft.jsxs(Ya,{open:p,onOpenChange:h,children:[Ft.jsx(Ja,{asChild:!0,children:Ft.jsxs($t,{variant:"outline",role:"combobox","aria-expanded":p,disabled:c||d,className:zt("w-full justify-between",!n&&"text-muted-foreground",u&&"border-destructive",f),children:[Ft.jsx("div",{className:"flex flex-wrap gap-1 flex-1 overflow-hidden",children:"multiple"===m&&w.length>0?w.map((e,t)=>Ft.jsxs(En,{variant:"secondary",className:"mr-1",children:[e,Ft.jsx("button",{className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",onMouseDown:e=>((e,t)=>{t.stopPropagation();const n=v.filter(t=>t!==e);r("single"===m?"":n)})(v[t],e),children:"✕"})]},v[t])):Ft.jsx("span",{className:"truncate",children:j})}),Ft.jsx(Ae,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),Ft.jsx(Xa,{className:"w-full p-0",align:"start",children:Ft.jsxs(as,{children:[Ft.jsx("div",{className:"flex items-center border-b px-3",children:Ft.jsx("input",{placeholder:i,value:g,onChange:e=>x(e.target.value),className:"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"})}),Ft.jsxs(os,{children:[0===N.length&&!k&&Ft.jsx(ls,{children:l}),k&&Ft.jsx(cs,{children:Ft.jsxs(ds,{onSelect:async()=>{if(a&&g){b(!0);try{const e=await a(g);e&&("single"===m?(r(e),h(!1)):r([...v,e])),x("")}catch(e){}finally{b(!1)}}},className:"cursor-pointer",disabled:y,children:[Ft.jsx(pe,{className:"mr-2 h-4 w-4 text-primary"}),Ft.jsx("span",{className:"text-primary font-medium",children:o(g)})]})}),N.length>0&&Ft.jsx(cs,{children:N.map(e=>Ft.jsxs(ds,{value:e.value,onSelect:()=>(e=>{if("single"===m)r(e),h(!1),x("");else{const t=v.includes(e)?v.filter(t=>t!==e):[...v,e];r(t)}})(e.value),className:"cursor-pointer",children:[Ft.jsx(C,{className:zt("mr-2 h-4 w-4",v.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})]})]})})]})}function ps({value:e,onChange:t,items:n,isLoading:r=!1,error:s=null,getItemValue:i,getItemLabel:l,searchPlaceholder:c="Buscar...",emptyMessage:u="Nenhum item disponível",noResultsMessage:d="Nenhum resultado encontrado",sortItems:f,placeholder:m="Selecionar...",disabled:p=!1,className:h}){const[g,x]=a(""),y=o(()=>{const e=f?[...n].sort(f):[...n].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))},[n,g,f,l]);return r?Ft.jsx(wa,{className:zt("h-10 w-full",h)}):s?Ft.jsxs("div",{className:zt("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[Ft.jsx(I,{className:"h-4 w-4 text-destructive"}),Ft.jsx("span",{className:"text-sm text-destructive",children:s.message||"Erro ao carregar dados"})]}):Ft.jsxs(bn,{value:e,onValueChange:t,disabled:p||0===n.length,children:[Ft.jsx(wn,{className:h,children:Ft.jsx(vn,{placeholder:m})}),Ft.jsxs(jn,{children:[Ft.jsx("div",{className:"px-2 pb-2",children:Ft.jsxs("div",{className:"relative",children:[Ft.jsx(P,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),Ft.jsx(qt,{placeholder:c,value:g,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===y.length?Ft.jsx(Cn,{value:"no-items",disabled:!0,children:g?d:u}):y.map(e=>Ft.jsx(Cn,{value:i(e),children:l(e)},i(e)))]})]})}fs.displayName="CommandShortcut";const hs=(e={})=>{const{user:t,alias:n}=Gr(),r=Dr(),{enabled:a=r.enableUsersApi}=e;return tt({queryKey:["qualiex-users",n],queryFn:()=>Ir.getUsers(n),enabled:a&&!!n&&!!t,retry:2,retryDelay:1e3})},gs=({value:e="",onChange:t,placeholder:n="Selecionar usuário",disabled:r,className:a,enabled:s})=>{const{data:i=[],isLoading:o,error:l}=hs({enabled:s});return Ft.jsx(ps,{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 xs({title:e,sections:n,initialData:r,onSubmit:i,onCancel:l,open:c,submitButtonText:u="Salvar",isLoading:d=!1,usersData:f}){const[m,p]=a(n?.[0]?.id||""),h=o(()=>n&&Array.isArray(n)?n.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[n]),{formData:g,errors:x,updateField:y,handleSubmit:b}=Ka(h,r,void 0,c),v=o(()=>n&&Array.isArray(n)?n.map(e=>({...e,disabled:e.condition?!e.condition(g):e.disabled||!1})):[],[n,g]),w=o(()=>{const e=v.find(e=>e.id===m);if(e&&!e.disabled)return m;const t=v.find(e=>!e.disabled);return t?.id||m},[v,m]);t.useEffect(()=>{w!==m&&p(w)},[w,m]);const N=v.find(e=>e.id===w),k=e=>{const t=(e.computedValue,g[e.name]),n=void 0!==t?t:"",r=x[e.name];switch(e.type){case"group":return Ft.jsxs("div",{className:"space-y-2",children:[e.label,Ft.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>k(e))})]},e.name);case"user-select":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Wt,{htmlFor:e.name,children:e.label}),Ft.jsx(gs,{value:n||"",onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":""}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"textarea":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Wt,{htmlFor:e.name,children:e.label}),Ft.jsx(In,{id:e.name,value:n||"",onChange:t=>{y(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&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"select":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Wt,{htmlFor:e.name,children:e.label}),Ft.jsxs(bn,{value:String(n),onValueChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[Ft.jsx(wn,{className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:Ft.jsx(vn,{placeholder:e.placeholder})}),Ft.jsx(jn,{children:e.options?.map(e=>Ft.jsx(Cn,{value:e.value,children:e.label},e.value))})]}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"date":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Wt,{htmlFor:e.name,children:e.label}),Ft.jsx(qt,{id:e.name,type:"date",value:String(n),onChange:t=>y(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:zt("w-full",r?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"color":return Ft.jsxs("div",{children:[Ft.jsxs(Wt,{htmlFor:e.name,children:[e.label," ",e.required&&Ft.jsx("span",{className:"text-destructive",children:"*"})]}),Ft.jsx(qt,{id:e.name,type:"color",value:n||e.defaultValue||"#000000",onChange:t=>y(e.name,t.target.value),className:"h-10"}),r&&Ft.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return Ft.jsxs("div",{children:[Ft.jsx(Za,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"#3b82f6",onChange:t=>y(e.name,t)}),r&&Ft.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return Ft.jsxs("div",{children:[Ft.jsx(rs,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"Star",onChange:t=>y(e.name,t)}),r&&Ft.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 Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&Ft.jsx(Wt,{htmlFor:e.name,children:e.label}),Ft.jsx(t,{value:n,onChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,error:r,...e.componentProps||{}}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"creatable-select":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsxs(Wt,{htmlFor:e.name,children:[e.label,e.required&&Ft.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Ft.jsx(ms,{options:e.options||[],value:n,onChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},onCreate:e.onCreate,placeholder:e.placeholder,searchPlaceholder:e.searchPlaceholder,createLabel:e.createLabel,emptyMessage:e.emptyMessage,disabled:e.disabled,error:r,mode:e.mode||"single"}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"number":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Wt,{htmlFor:e.name,children:e.label}),Ft.jsx(qt,{id:e.name,type:"number",value:null!=n?String(n):"",onChange:t=>{const n=t.target.value,r=""===n?null:Number(n);y(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&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);default:return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Wt,{htmlFor:e.name,children:e.label}),Ft.jsx(qt,{id:e.name,type:"text",value:n||"",onChange:t=>{y(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&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name)}},j=s(()=>{if(!N)return null;if(N.disabled)return Ft.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Ft.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:Ft.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Ft.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),Ft.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),Ft.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(N.component){const e=N.component;return Ft.jsx(e,{formData:g,updateField:y,errors:x,users:f,disabled:N.disabled})}return Ft.jsx("div",{className:"space-y-3",children:N.fields.map(k)})},[N,g,y,x,f,k]),C=Ft.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[v.length>1&&Ft.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:Ft.jsx("div",{className:"flex space-x-2",children:v.map(e=>Ft.jsx($t,{variant:w===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=v.find(t=>t.id===e);t&&!t.disabled&&p(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),Ft.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:d?Ft.jsx("div",{className:"flex items-center justify-center py-12",children:Ft.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):Ft.jsxs("form",{onSubmit:b(i),className:"space-y-3 md:space-y-4",children:[j(),Ft.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Ft.jsx($t,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),Ft.jsx($t,{type:"submit",disabled:d,children:u})]})]})})]});return Ft.jsx(Zt,{open:c,onOpenChange:e=>{!1===e&&!0===c&&l()},children:Ft.jsxs(an,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[Ft.jsxs(sn,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[Ft.jsx(ln,{className:"text-white",children:e}),Ft.jsx(cn,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),C]})})}function ys({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 Ft.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[Ft.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&Ft.jsxs(Ft.Fragment,{children:[Ft.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),Ft.jsxs(bn,{value:String(r),onValueChange:e=>s(Number(e)),children:[Ft.jsx(wn,{className:"h-8 w-[70px]",children:Ft.jsx(vn,{})}),Ft.jsxs(jn,{children:[Ft.jsx(Cn,{value:"10",children:"10"}),Ft.jsx(Cn,{value:"25",children:"25"}),Ft.jsx(Cn,{value:"50",children:"50"}),Ft.jsx(Cn,{value:"100",children:"100"})]})]})]})}),Ft.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[o,"-",l," de ",n," itens"]}),Ft.jsxs("div",{className:"flex items-center gap-1",children:[Ft.jsx($t,{variant:"outline",size:"sm",onClick:()=>a(1),disabled:1===e,className:"h-8 w-8 p-0",children:Ft.jsx(_e,{size:16})}),Ft.jsx($t,{variant:"outline",size:"sm",onClick:()=>a(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:Ft.jsx(fe,{size:16})}),Ft.jsxs("div",{className:"flex items-center gap-1 px-2",children:[Ft.jsx("span",{className:"text-sm font-medium",children:e}),Ft.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),Ft.jsx("span",{className:"text-sm font-medium",children:t})]}),Ft.jsx($t,{variant:"outline",size:"sm",onClick:()=>a(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:Ft.jsx(T,{size:16})}),Ft.jsx($t,{variant:"outline",size:"sm",onClick:()=>a(t),disabled:e===t,className:"h-8 w-8 p-0",children:Ft.jsx(Re,{size:16})})]})]})}function bs({manager:e}){return Ft.jsx(ys,{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 vs=({selectedCount:e,onClearSelection:t,onBulkDelete:n,customActions:r=[],isLoading:a=!1})=>Ft.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[Ft.jsxs("div",{className:"flex items-center gap-3",children:[Ft.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),Ft.jsxs($t,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[Ft.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]}),Ft.jsxs("div",{className:"flex items-center gap-2",children:[r.map((e,t)=>{const n=e.icon;return Ft.jsxs($t,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:a,className:"h-7",children:[n&&Ft.jsx(n,{size:14,className:"mr-1"}),e.label]},t)}),n&&Ft.jsxs($t,{variant:"destructive",size:"sm",onClick:n,disabled:a,className:"h-7",children:[Ft.jsx(D,{size:14,className:"mr-1"}),"Remover"]})]})]}),ws={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},Ns={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},ks={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function js({children:e,direction:t="column",gap:n="md",align:r="stretch",justify:a="start",wrap:s=!1,className:i}){return Ft.jsx("div",{className:zt("flex","column"===t?"flex-col":"flex-row",ws[n],Ns[r],ks[a],s&&"flex-wrap",i),children:e})}function Cs({manager:e,filters:t,inline:n=!1}){const{isSearchVisible:r}=Gr(),a=e.searchTerm,s=Ft.jsxs(Ft.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&Ft.jsxs("div",{className:"relative flex-1",children:[Ft.jsx(P,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Ft.jsx(qt,{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)=>Ft.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&&Ft.jsx("option",{value:"",children:e.placeholder}),e.options.map(e=>Ft.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 Ft.jsx("div",{className:n?"":"w-full sm:w-auto",children:Ft.jsx(r,{...e.props})},`custom-${t}`)}),a&&Ft.jsxs($t,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[Ft.jsx(N,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return n?Ft.jsx("div",{className:"flex items-center gap-2",children:s}):Ft.jsx(js,{direction:"column",gap:"md",className:"mb-6",children:Ft.jsx(js,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:s})})}function Ss({manager:e,config:t,formSections:n,onSave:r,onToggleStatus:s,defaultSort:o}){const{setSearchVisible:l}=Gr(),[c,u]=at(),[d,f]=a(!1),[m,p]=a(null),[h,g]=a({isOpen:!1,entityId:null,entityName:""}),[x,y]=a({isOpen:!1,count:0});i(()=>(l(!0),()=>{l(!1)}),[l]),i(()=>{if(o&&!c.has("sortField")&&!c.has("sortDirection")){const e=new URLSearchParams(c);e.set("sortField",o.column),e.set("sortDirection",o.direction),u(e,{replace:!0})}},[]);return Ft.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[t.enableBulkActions&&e.selectedIds.length>0&&Ft.jsx(vs,{selectedCount:e.selectedIds.length,onClearSelection:e.clearSelection,onBulkDelete:()=>{y({isOpen:!0,count:e.selectedIds.length})},customActions:t.bulkActions,isLoading:e.isBulkDeleting}),Ft.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[Ft.jsxs("div",{className:"flex items-center gap-2",children:[Ft.jsxs($t,{onClick:()=>{t.onNew?t.onNew():(p(null),f(!0))},children:[Ft.jsx(pe,{size:16,className:"mr-2"}),"Novo"]}),t.customActions?.map((e,t)=>Ft.jsxs($t,{onClick:e.action,variant:e.variant||"outline",children:[e.icon&&Ft.jsx(e.icon,{size:16,className:"mr-2"}),e.label]},t))]}),t.filters&&t.filters.length>0&&Ft.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:Ft.jsx(Cs,{manager:e,filters:t.filters,inline:!0})})]}),Ft.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:t.customListView?Ft.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.customListView(e.entities,e)}):Ft.jsx(Qa,{manager:e,columns:t.columns,onEdit:e=>{t.onEdit?t.onEdit(e):(p(e),f(!0))},onDelete:e=>{g({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:s,enableBulkActions:t.enableBulkActions})}),Ft.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:Ft.jsx(bs,{manager:e})}),!t.useCustomRouting&&Ft.jsx(xs,{open:d,title:m?`Editar ${t.entityName}`:`Novo ${t.entityName}`,sections:n,initialData:m||void 0,onSubmit:e=>{r(e),f(!1),p(null)},onCancel:()=>{f(!1),p(null)},isLoading:e.isLoading,submitButtonText:m?"Atualizar":"Criar"}),Ft.jsx(fa,{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}),Ft.jsx(fa,{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 Is(e){return()=>{const{manager:t,config:n,onSave:r,onToggleStatus:a}=e,s={entityName:n.entityName,entityNamePlural:n.entityNamePlural,filters:n.filters||[],columns:n.columns,cardFields:n.cardFields||[],enableBulkActions:n.enableBulkActions??!1,customActions:n.customActions,customListView:n.customListView,onEdit:n.onEdit};return Ft.jsx(Ss,{manager:t,config:s,formSections:n.formSections,onSave:r,onToggleStatus:a,defaultSort:n.defaultSort})}}function Ps(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 Es(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:As(e),label:As(e),...Ts(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 Ts(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 As(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const _s={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 Rs(e,t,n={}){const r=_s[e];return Es(r.title,t,{...r,...n})}const Fs=({children:e})=>{const{isAuthenticated:n,isLoading:r}=Gr();if(t.useEffect(()=>{if(!n)return;const e=()=>{ir.areAllTokensValid()||Yr.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),t.useEffect(()=>{if(r)return;if(n)return;if(ir.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=_r();(async()=>{s?await Yr.loginDev():Yr.loginProd()})()},[n,r]),r)return Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Qt,{className:"w-full max-w-md",children:[Ft.jsx(Kt,{className:"text-center",children:Ft.jsx(Yt,{className:"text-xl font-semibold",children:"Carregando..."})}),Ft.jsxs(Xt,{className:"text-center",children:[Ft.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ft.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 Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Qt,{className:"w-full max-w-md",children:[Ft.jsx(Kt,{className:"text-center",children:Ft.jsx(Yt,{className:"text-xl font-semibold",children:"Processando..."})}),Ft.jsxs(Xt,{className:"text-center",children:[Ft.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ft.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(ir.areAllTokensValid())return Ft.jsx(Ft.Fragment,{children:e})}catch{}return Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Qt,{className:"w-full max-w-md",children:[Ft.jsx(Kt,{className:"text-center",children:Ft.jsx(Yt,{className:"text-xl font-semibold",children:"Iniciando..."})}),Ft.jsxs(Xt,{className:"text-center",children:[Ft.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ft.jsx("p",{className:"text-muted-foreground",children:_r()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return Ft.jsx(Ft.Fragment,{children:e})},Ds=m("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"}}),zs=e.forwardRef(({className:e,variant:t,...n},r)=>Ft.jsx("div",{ref:r,role:"alert",className:zt(Ds({variant:t}),e),...n}));zs.displayName="Alert";const Os=e.forwardRef(({className:e,...t},n)=>Ft.jsx("h5",{ref:n,className:zt("mb-1 font-medium leading-none tracking-tight",e),...t}));Os.displayName="AlertTitle";const Ls=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:zt("text-sm [&_p]:leading-relaxed",e),...t}));Ls.displayName="AlertDescription";const Ms=()=>{const{processCallback:e}=Gr(),[t,n]=a(null),[r,s]=a(!1);i(()=>{(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 n("Falha na autenticação. Tente novamente.")}catch(t){n(t?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e]);const o=async()=>{s(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(t){n(t?.message||"Erro ao tentar novamente.")}finally{s(!1)}},l=()=>{window.location.href="/"};return t?Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Qt,{className:"w-full max-w-md",children:[Ft.jsx(Kt,{className:"text-center",children:Ft.jsxs(Yt,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[Ft.jsx(I,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),Ft.jsxs(Xt,{className:"space-y-4",children:[Ft.jsx(zs,{variant:"destructive",children:Ft.jsx(Ls,{children:t})}),Ft.jsx("div",{className:"text-sm text-muted-foreground",children:Ft.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),Ft.jsxs("div",{className:"flex gap-2",children:[Ft.jsx($t,{onClick:o,disabled:r,className:"flex-1",children:r?Ft.jsxs(Ft.Fragment,{children:[Ft.jsx(An,{size:"sm",className:"mr-2"}),"Tentando..."]}):Ft.jsxs(Ft.Fragment,{children:[Ft.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),Ft.jsx($t,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Qt,{className:"w-full max-w-md",children:[Ft.jsx(Kt,{className:"text-center",children:Ft.jsx(Yt,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),Ft.jsxs(Xt,{className:"text-center",children:[Ft.jsx("div",{className:"flex justify-center mb-4",children:Ft.jsx(An,{size:"lg"})}),Ft.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},Us=()=>Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Qt,{className:"w-full max-w-md",children:[Ft.jsx(Kt,{className:"text-center",children:Ft.jsx(Yt,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),Ft.jsxs(Xt,{className:"text-center space-y-4",children:[Ft.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),Ft.jsx($t,{onClick:async()=>{_r()?await Yr.loginDev():Yr.loginProd()},className:"w-full",size:"lg",children:_r()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),Bs=n(void 0);function $s({children:e}){const[t,n]=a({});return Ft.jsx(Bs.Provider,{value:{metadata:t,setMetadata:n,clearMetadata:()=>n({})},children:e})}function Vs(){const e=r(Bs);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function qs(e){const{setMetadata:t,clearMetadata:n}=Vs();i(()=>(t(e),()=>n()),[e.title,e.subtitle,t,n])}function Hs(e){return{queryClient:e.queryClient||new rt({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const Ws=ft.Root,Qs=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ft.Item,{ref:n,className:zt("border-b",e),...t}));Qs.displayName="AccordionItem";const Ks=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsx(ft.Header,{className:"flex",children:Ft.jsxs(ft.Trigger,{ref:r,className:zt("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,Ft.jsx(k,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Ks.displayName=ft.Trigger.displayName;const Ys=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsx(ft.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:Ft.jsx("div",{className:zt("pb-4 pt-0",e),children:t})}));Ys.displayName=ft.Content.displayName;const Js=mt.Root,Xs=e.forwardRef(({className:e,...t},n)=>Ft.jsx(pt.Root,{ref:n,className:zt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Xs.displayName=pt.Root.displayName;const Gs=e.forwardRef(({className:e,...t},n)=>Ft.jsx(pt.Image,{ref:n,className:zt("aspect-square h-full w-full",e),...t}));Gs.displayName=pt.Image.displayName;const Zs=e.forwardRef(({className:e,...t},n)=>Ft.jsx(pt.Fallback,{ref:n,className:zt("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Zs.displayName=pt.Fallback.displayName;const ei=e.forwardRef(({...e},t)=>Ft.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));ei.displayName="Breadcrumb";const ti=e.forwardRef(({className:e,...t},n)=>Ft.jsx("ol",{ref:n,className:zt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));ti.displayName="BreadcrumbList";const ni=e.forwardRef(({className:e,...t},n)=>Ft.jsx("li",{ref:n,className:zt("inline-flex items-center gap-1.5",e),...t}));ni.displayName="BreadcrumbItem";const ri=e.forwardRef(({asChild:t,className:n,...r},a)=>{const s=t?e.Fragment:"a";return Ft.jsx(s,{ref:a,className:zt("transition-colors hover:text-foreground",n),...r})});ri.displayName="BreadcrumbLink";const ai=e.forwardRef(({className:e,...t},n)=>Ft.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:zt("font-normal text-foreground",e),...t}));ai.displayName="BreadcrumbPage";const si=({children:e,className:t,...n})=>Ft.jsx("li",{role:"presentation","aria-hidden":"true",className:zt("[&>svg]:size-3.5",t),...n,children:e??Ft.jsx(T,{})});si.displayName="BreadcrumbSeparator";const ii=({className:e,...t})=>Ft.jsxs("span",{role:"presentation","aria-hidden":"true",className:zt("flex h-9 w-9 items-center justify-center",e),...t,children:[Ft.jsx(De,{className:"h-4 w-4"}),Ft.jsx("span",{className:"sr-only",children:"More"})]});function oi(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function li(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 ci(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)}}}ii.displayName="BreadcrumbEllipsis";const ui={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"}},di={date:oi({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:oi({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:oi({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},fi={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"},mi={ordinalNumber:(e,t)=>{const n=Number(e);return"week"===t?.unit?n+"ª":n+"º"},era:li({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:li({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:li({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:li({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:li({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"})},pi={ordinalNumber:(hi={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(hi.matchPattern);if(!n)return null;const r=n[0],a=e.match(hi.parsePattern);if(!a)return null;let s=hi.valueCallback?hi.valueCallback(a[0]):a[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:ci({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:ci({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:ci({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:ci({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:ci({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 hi;const gi={code:"pt-BR",formatDistance:(e,t,n)=>{let r;const a=ui[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:di,formatRelative:(e,t,n,r)=>{const a=fi[e];return"function"==typeof a?a(t):a},localize:mi,match:pi,options:{weekStartsOn:0,firstWeekContainsDate:1}};function xi({className:e,classNames:t,showOutsideDays:n=!0,...r}){return Ft.jsx(ht,{showOutsideDays:n,className:zt("p-3",e),locale:gi,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:zt(Bt({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:zt(Bt({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})=>Ft.jsx(fe,{className:"h-4 w-4"}),IconRight:({...e})=>Ft.jsx(T,{className:"h-4 w-4"})},...r})}xi.displayName="Calendar";const yi=gt.Root,bi=gt.CollapsibleTrigger,vi=gt.CollapsibleContent;const wi={Root:function({children:e,className:t}){return Ft.jsx("div",{className:zt("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:n}){return Ft.jsx(Qt,{className:zt("transition-colors",t&&"cursor-pointer hover:bg-muted/50",n),onClick:t,children:Ft.jsx(Xt,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:n}){return Ft.jsxs("div",{className:zt("flex justify-between items-center text-sm",n),children:[Ft.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),Ft.jsx("span",{className:"text-foreground",children:t})]})}},Ni={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))]"},ki={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function ji({children:e,cols:t="auto-fit",gap:n="md",className:r}){return Ft.jsx("div",{className:zt("grid",Ni[t],ki[n],r),children:e})}function Ci({items:e,maxItems:t=3,className:n}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,Ft.jsx(ei,{className:n})}function Si(){const e=st();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 Ii=({className:e,...t})=>Ft.jsx("nav",{role:"navigation","aria-label":"pagination",className:zt("mx-auto flex w-full justify-center",e),...t});Ii.displayName="Pagination";const Pi=e.forwardRef(({className:e,...t},n)=>Ft.jsx("ul",{ref:n,className:zt("flex flex-row items-center gap-1",e),...t}));Pi.displayName="PaginationContent";const Ei=e.forwardRef(({className:e,...t},n)=>Ft.jsx("li",{ref:n,className:zt("",e),...t}));Ei.displayName="PaginationItem";const Ti=({className:e,isActive:t,size:n="icon",...r})=>Ft.jsx("a",{"aria-current":t?"page":void 0,className:zt(Bt({variant:t?"outline":"ghost",size:n}),e),...r});Ti.displayName="PaginationLink";const Ai=({className:e,...t})=>Ft.jsxs(Ti,{"aria-label":"Go to previous page",size:"default",className:zt("gap-1 pl-2.5",e),...t,children:[Ft.jsx(fe,{className:"h-4 w-4"}),Ft.jsx("span",{children:"Previous"})]});Ai.displayName="PaginationPrevious";const _i=({className:e,...t})=>Ft.jsxs(Ti,{"aria-label":"Go to next page",size:"default",className:zt("gap-1 pr-2.5",e),...t,children:[Ft.jsx("span",{children:"Next"}),Ft.jsx(T,{className:"h-4 w-4"})]});_i.displayName="PaginationNext";const Ri=({className:e,...t})=>Ft.jsxs("span",{"aria-hidden":!0,className:zt("flex h-9 w-9 items-center justify-center",e),...t,children:[Ft.jsx(De,{className:"h-4 w-4"}),Ft.jsx("span",{className:"sr-only",children:"More pages"})]});Ri.displayName="PaginationEllipsis";const Fi=e.forwardRef(({className:e,value:t,...n},r)=>Ft.jsx(xt.Root,{ref:r,className:zt("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:Ft.jsx(xt.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Fi.displayName=xt.Root.displayName;const Di=e.forwardRef(({className:e,...t},n)=>Ft.jsx(yt.Root,{className:zt("grid gap-2",e),...t,ref:n}));Di.displayName=yt.Root.displayName;const zi=e.forwardRef(({className:e,...t},n)=>Ft.jsx(yt.Item,{ref:n,className:zt("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:Ft.jsx(yt.Indicator,{className:"flex items-center justify-center",children:Ft.jsx(A,{className:"h-2.5 w-2.5 fill-current text-current"})})}));zi.displayName=yt.Item.displayName;const Oi=e.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>Ft.jsx(bt.Root,{ref:a,decorative:n,orientation:t,className:zt("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Oi.displayName=bt.Root.displayName;const Li=We.Root,Mi=We.Trigger,Ui=We.Close,Bi=We.Portal,$i=e.forwardRef(({className:e,...t},n)=>Ft.jsx(We.Overlay,{className:zt("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}));$i.displayName=We.Overlay.displayName;const Vi=m("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"}}),qi=e.forwardRef(({side:e="right",className:t,children:n,...r},a)=>Ft.jsxs(Bi,{children:[Ft.jsx($i,{}),Ft.jsxs(We.Content,{ref:a,className:zt(Vi({side:e}),t),...r,children:[n,Ft.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:[Ft.jsx(N,{className:"h-4 w-4"}),Ft.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));qi.displayName=We.Content.displayName;const Hi=({className:e,...t})=>Ft.jsx("div",{className:zt("flex flex-col space-y-2 text-center sm:text-left",e),...t});Hi.displayName="SheetHeader";const Wi=({className:e,...t})=>Ft.jsx("div",{className:zt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Wi.displayName="SheetFooter";const Qi=e.forwardRef(({className:e,...t},n)=>Ft.jsx(We.Title,{ref:n,className:zt("text-lg font-semibold text-foreground",e),...t}));Qi.displayName=We.Title.displayName;const Ki=e.forwardRef(({className:e,...t},n)=>Ft.jsx(We.Description,{ref:n,className:zt("text-sm text-muted-foreground",e),...t}));Ki.displayName=We.Description.displayName;const Yi=vt.Provider,Ji=vt.Root,Xi=vt.Trigger,Gi=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Ft.jsx(vt.Content,{ref:r,sideOffset:t,className:zt("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}));Gi.displayName=vt.Content.displayName;const Zi="sidebar:state",eo=e.createContext(null);function to(){const t=e.useContext(eo);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const no=e.forwardRef(({defaultOpen:t=!0,open:n,onOpenChange:r,className:a,style:s,children:i,...o},l)=>{const[c,u]=e.useState(!1);e.useEffect(()=>{const e=()=>u(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[d,f]=e.useState(!1),[m,p]=e.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(Zi);return null!==e?"true"===e:t}return t}),h=n??m,g=e.useCallback(e=>{const t="function"==typeof e?e(h):e;r?r(t):p(t),"undefined"!=typeof window&&localStorage.setItem(Zi,String(t))},[r,h]),x=e.useCallback(()=>c?f(e=>!e):g(e=>!e),[c,g,f]);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:d,setOpenMobile:f,toggleSidebar:x}),[y,h,g,c,d,f,x]);return Ft.jsx(eo.Provider,{value:b,children:Ft.jsx(Yi,{delayDuration:0,children:Ft.jsx("div",{className:zt("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})})})});no.displayName="SidebarProvider";const ro=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:u}=to();return"none"===n?Ft.jsx("div",{className:zt("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:a}):o?Ft.jsx(Li,{open:c,onOpenChange:u,...s,children:Ft.jsxs(qi,{"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:[Ft.jsx(Qi,{className:"sr-only",children:"Menu de Navegação"}),Ft.jsx("div",{className:"flex h-full w-full flex-col",children:a})]})}):Ft.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:[Ft.jsx("div",{className:zt("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]")}),Ft.jsx("div",{className:zt("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:Ft.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})})]})});ro.displayName="Sidebar";const ao=e.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:a}=to();return Ft.jsxs($t,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:zt("h-7 w-7",e),onClick:e=>{t?.(e),a()},...n,children:[Ft.jsx(ze,{}),Ft.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});ao.displayName="SidebarTrigger";const so=e.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=to();return Ft.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:zt("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})});so.displayName="SidebarRail";const io=e.forwardRef(({className:e,...t},n)=>Ft.jsx("main",{ref:n,className:zt("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}));io.displayName="SidebarInset";const oo=e.forwardRef(({className:e,...t},n)=>Ft.jsx(qt,{ref:n,"data-sidebar":"input",className:zt("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));oo.displayName="SidebarInput";const lo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"header",className:zt("flex flex-col gap-2 p-2",e),...t}));lo.displayName="SidebarHeader";const co=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"footer",className:zt("flex flex-col gap-2 p-2",e),...t}));co.displayName="SidebarFooter";const uo=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Oi,{ref:n,"data-sidebar":"separator",className:zt("mx-2 w-auto bg-sidebar-border",e),...t}));uo.displayName="SidebarSeparator";const fo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"content",className:zt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));fo.displayName="SidebarContent";const mo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"group",className:zt("relative flex w-full min-w-0 flex-col p-2",e),...t}));mo.displayName="SidebarGroup";const po=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?d:"div";return Ft.jsx(a,{ref:r,"data-sidebar":"group-label",className:zt("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})});po.displayName="SidebarGroupLabel";const ho=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?d:"button";return Ft.jsx(a,{ref:r,"data-sidebar":"group-action",className:zt("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})});ho.displayName="SidebarGroupAction";const go=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"group-content",className:zt("w-full text-sm",e),...t}));go.displayName="SidebarGroupContent";const xo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("ul",{ref:n,"data-sidebar":"menu",className:zt("flex w-full min-w-0 flex-col gap-1",e),...t}));xo.displayName="SidebarMenu";const yo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("li",{ref:n,"data-sidebar":"menu-item",className:zt("group/menu-item relative",e),...t}));yo.displayName="SidebarMenuItem";const bo=m("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"}}),vo=e.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:a,className:s,...i},o)=>{const l=e?d:"button",{isMobile:c,state:u}=to(),f=Ft.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:zt(bo({variant:n,size:r}),s),...i});return a?("string"==typeof a&&(a={children:a}),Ft.jsxs(Ji,{children:[Ft.jsx(Xi,{asChild:!0,children:f}),Ft.jsx(Gi,{side:"right",align:"center",hidden:"collapsed"!==u||c,...a})]})):f});vo.displayName="SidebarMenuButton";const wo=e.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},a)=>{const s=t?d:"button";return Ft.jsx(s,{ref:a,"data-sidebar":"menu-action",className:zt("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})});wo.displayName="SidebarMenuAction";const No=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:zt("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}));No.displayName="SidebarMenuBadge";const ko=e.forwardRef(({className:t,showIcon:n=!1,...r},a)=>{const s=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return Ft.jsxs("div",{ref:a,"data-sidebar":"menu-skeleton",className:zt("rounded-md h-8 flex gap-2 px-2 items-center",t),...r,children:[n&&Ft.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),Ft.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":s}})]})});ko.displayName="SidebarMenuSkeleton";const jo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:zt("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}));jo.displayName="SidebarMenuSub";const Co=e.forwardRef(({...e},t)=>Ft.jsx("li",{ref:t,...e}));Co.displayName="SidebarMenuSubItem";const So=e.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...a},s)=>{const i=e?d:"a";return Ft.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:zt("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})});So.displayName="SidebarMenuSubButton";const Io=e.forwardRef(({className:e,...t},n)=>Ft.jsxs(wt.Root,{ref:n,className:zt("relative flex w-full touch-none select-none items-center",e),...t,children:[Ft.jsx(wt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:Ft.jsx(wt.Range,{className:"absolute h-full bg-primary"})}),Ft.jsx(wt.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"})]}));Io.displayName=wt.Root.displayName;const Po=({...e})=>{const{theme:t="system"}=Nt();return Ft.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 Eo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function To(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ao(...t){return e.useCallback(function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=To(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():To(e[t],null)}}}}(...t),t)}function _o(...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 Ro=globalThis?.document?e.useLayoutEffect:()=>{},Fo=e[" useInsertionEffect ".trim().toString()]||Ro;function Do({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 Fo(()=>{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 u=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,u]}var zo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=f(`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),Ft.jsx(i,{...s,ref:t})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{}),Oo="Switch",[Lo]=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 Ft.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}\``)}]},_o(a,...n)]}(Oo),[Mo,Uo]=Lo(Oo),Bo=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:a,checked:s,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:u,form:d,...f}=t,[m,p]=e.useState(null),h=Ao(n,e=>p(e)),g=e.useRef(!1),x=!m||(d||!!m.closest("form")),[y,b]=Do({prop:s,defaultProp:i??!1,onChange:u,caller:Oo});return Ft.jsxs(Mo,{scope:r,checked:y,disabled:l,children:[Ft.jsx(zo.button,{type:"button",role:"switch","aria-checked":y,"aria-required":o,"data-state":Ho(y),"data-disabled":l?"":void 0,disabled:l,value:c,...f,ref:h,onClick:Eo(t.onClick,e=>{b(e=>!e),x&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),x&&Ft.jsx(qo,{control:m,bubbles:!g.current,name:a,value:c,checked:y,required:o,disabled:l,form:d,style:{transform:"translateX(-100%)"}})]})});Bo.displayName=Oo;var $o="SwitchThumb",Vo=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Uo($o,n);return Ft.jsx(zo.span,{"data-state":Ho(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});Vo.displayName=$o;var qo=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:a=!0,...s},i)=>{const o=e.useRef(null),l=Ao(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),u=function(t){const[n,r]=e.useState(void 0);return Ro(()=>{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]),Ft.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:l,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Ho(e){return e?"checked":"unchecked"}qo.displayName="SwitchBubbleInput";var Wo=Bo,Qo=Vo;const Ko=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Wo,{className:zt("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:Ft.jsx(Qo,{className:zt("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")})}));Ko.displayName=Wo.displayName;const Yo=kt.Root,Jo=e.forwardRef(({className:e,...t},n)=>Ft.jsx(kt.List,{ref:n,className:zt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Jo.displayName=kt.List.displayName;const Xo=e.forwardRef(({className:e,...t},n)=>Ft.jsx(kt.Trigger,{ref:n,className:zt("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}));Xo.displayName=kt.Trigger.displayName;const Go=e.forwardRef(({className:e,...t},n)=>Ft.jsx(kt.Content,{ref:n,className:zt("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 Zo({children:e,className:t}){return Ft.jsx("div",{className:zt("flex flex-col h-full",t),children:Ft.jsx(es,{className:"flex-1",children:Ft.jsx("div",{className:"space-y-6 p-6",children:e})})})}function el({title:e,description:t,actions:n,className:r}){return Ft.jsxs("div",{className:zt("space-y-4",r),children:[Ft.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[Ft.jsxs("div",{className:"space-y-1",children:[Ft.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&Ft.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),n&&Ft.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:n})]}),Ft.jsx(Oi,{})]})}function tl({children:e,className:t}){return Ft.jsx("div",{className:zt("space-y-6",t),children:e})}Go.displayName=kt.Content.displayName;const nl=m("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"}}),rl=e.forwardRef(({className:e,variant:t,size:n,...r},a)=>Ft.jsx(jt.Root,{ref:a,className:zt(nl({variant:t,size:n,className:e})),...r}));rl.displayName=jt.Root.displayName;const al=e.createContext({size:"default",variant:"default"}),sl=e.forwardRef(({className:e,variant:t,size:n,children:r,...a},s)=>Ft.jsx(Ct.Root,{ref:s,className:zt("flex items-center justify-center gap-1",e),...a,children:Ft.jsx(al.Provider,{value:{variant:t,size:n},children:r})}));sl.displayName=Ct.Root.displayName;const il=e.forwardRef(({className:t,children:n,variant:r,size:a,...s},i)=>{const o=e.useContext(al);return Ft.jsx(Ct.Item,{ref:i,className:zt(nl({variant:o.variant||r,size:o.size||a}),t),...s,children:n})});function ol({data:e,columns:t,sortField:n,sortDirection:r,onSort:a,onRowClick:s,renderActions:i,isLoading:l=!1,emptyMessage:c="Nenhum item encontrado",className:u,enableSelection:d=!1,selectedIds:f=[],onSelectItem:m,onSelectAll:p,isAllSelected:h=!1}){const g=o(()=>{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?Ft.jsx("div",{className:"flex-1 overflow-auto",children:Ft.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>Ft.jsx(wa,{className:"h-12 w-full"},t))})}):0===e.length?Ft.jsx("div",{className:"flex-1 flex items-center justify-center",children:Ft.jsx("div",{className:"text-center text-muted-foreground",children:Ft.jsx("p",{children:c})})}):Ft.jsx("div",{className:"flex-1 overflow-auto",children:Ft.jsxs(ma,{className:u,children:[Ft.jsx(pa,{className:"sticky top-0 bg-background z-10",children:Ft.jsxs(xa,{children:[d&&Ft.jsx(ya,{className:"w-12",children:Ft.jsx(Sn,{checked:h,onCheckedChange:p,"aria-label":"Selecionar todos"})}),t.map((e,t)=>{return Ft.jsx(ya,{className:e.className,style:{width:g[t]},children:e.sortable&&a?Ft.jsxs("button",{onClick:()=>a(String(e.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[e.header,(s=String(e.key),n!==s?Ft.jsx(z,{size:14,className:"ml-1 opacity-50"}):"asc"===r?Ft.jsx(O,{size:14,className:"ml-1"}):Ft.jsx(L,{size:14,className:"ml-1"}))]}):Ft.jsx("span",{className:"font-medium",children:e.header})},String(e.key));var s}),i&&Ft.jsx(ya,{className:"w-20 text-right",children:"Ações"})]})}),Ft.jsx(ha,{children:e.map(e=>Ft.jsxs(xa,{onClick:()=>s?.(e),className:s?"cursor-pointer":"",children:[d&&Ft.jsx(ba,{children:Ft.jsx(Sn,{checked:f.includes(e.id),onCheckedChange:()=>m?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${e.id}`})}),t.map(t=>Ft.jsx(ba,{className:t.className,children:t.render?t.render(e):String(e[t.key]??"-")},String(t.key))),i&&Ft.jsx(ba,{className:"text-right",onClick:e=>e.stopPropagation(),children:i(e)})]},e.id))})]})})}function ll({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?R:F,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?Ft.jsxs(Ea,{children:[Ft.jsx(Ta,{asChild:!0,children:Ft.jsx($t,{variant:"ghost",size:"compact"===l?"sm":"default",className:"compact"===l?"h-7 px-2":"",children:Ft.jsx(w,{size:"compact"===l?14:16})})}),Ft.jsx(Oa,{align:"end",className:"bg-background",children:c.map((e,t)=>Ft.jsxs(La,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&Ft.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))})]}):Ft.jsx("div",{className:"flex items-center gap-1",children:c.map((e,t)=>Ft.jsxs($t,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===l?"sm":"default",onClick:e.onClick,className:"compact"===l?"h-7 px-2":"",children:[e.icon&&Ft.jsx(e.icon,{size:"compact"===l?14:16}),"compact"!==l&&Ft.jsx("span",{className:"ml-1",children:e.label})]},t))})}function cl({searchValue:e="",onSearchChange:t,customFilters:n=[],onClearFilters:r,showClearButton:a=!0,layout:s="horizontal"}){const i=e||n.length>0;return Ft.jsxs("div",{className:`flex ${"vertical"===s?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&Ft.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[Ft.jsx(P,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Ft.jsx(qt,{type:"text",placeholder:"Buscar...",value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),n.map((e,t)=>Ft.jsx("div",{className:"vertical"===s?"w-full":"",children:e},t)),a&&i&&r&&Ft.jsxs($t,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[Ft.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]})}function ul({data:e,renderCard:t,isLoading:n=!1,emptyMessage:r="Nenhum item encontrado",columns:a,gap:s="md",className:i}){return n?Ft.jsx(ji,{cols:a?String(a):"auto-fit",gap:s,className:i,children:[...Array(6)].map((e,t)=>Ft.jsx(wa,{className:"h-48 w-full"},t))}):0===e.length?Ft.jsx("div",{className:"flex items-center justify-center p-8",children:Ft.jsx("div",{className:"text-center text-muted-foreground",children:Ft.jsx("p",{children:r})})}):Ft.jsx(ji,{cols:a?String(a):"auto-fit",gap:s,className:i,children:e.map(t)})}function dl({manager:e,config:t,onEdit:n,onDelete:r}){return e.isLoading?Ft.jsx(ji,{children:Array.from({length:3}).map((e,t)=>Ft.jsxs(Qt,{children:[Ft.jsxs(Kt,{children:[Ft.jsx(wa,{className:"h-4 w-3/4"}),Ft.jsx(wa,{className:"h-3 w-1/2"})]}),Ft.jsx(Xt,{children:Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(wa,{className:"h-3 w-full"}),Ft.jsx(wa,{className:"h-3 w-2/3"})]})})]},t))}):Ft.jsx(wi.Root,{children:e.entities.map(e=>Ft.jsxs(wi.Item,{onClick:()=>n(e),children:[Ft.jsx(Kt,{className:"pb-3",children:Ft.jsxs("div",{className:"flex items-start justify-between",children:[Ft.jsxs("div",{className:"flex-1 min-w-0",children:[Ft.jsx(Yt,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),Ft.jsx(Jt,{className:"text-sm",children:y(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:gi})})]}),Ft.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&Ft.jsx($t,{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:Ft.jsx(Oe,{className:"h-4 w-4"})}),Ft.jsx("div",{onClick:e=>e.stopPropagation(),children:Ft.jsx(Ha,{onEdit:()=>n(e),onDelete:r?()=>r(e):void 0,canDelete:!!r})})]})]})}),Ft.jsx(Xt,{className:"pt-0",children:Ft.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const n=e[t.key];return n?Ft.jsx(wi.Field,{label:t.label,value:t.render?t.render(n,e):String(n)},String(t.key)):null})})})]},e.id))})}function fl(e){const t=it();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 ml(e,t){const n=fl({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:n.onNew,onEdit:n.onEdit}}il.displayName=Ct.Item.displayName;var pl=Object.defineProperty,hl=(e,t,n)=>((e,t,n)=>t in e?pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const gl=new class{constructor(){hl(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}extractCompanyUserId(e){const t=ir.getAccessToken();if(!t)return null;try{const n=Gn.parseJwtPayload(t);if(!n)return null;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(t.length>8&&t[0]===e)return t[8]}}}catch(n){}return null}async fetchPlaceByCompanyUserId(e,t){const n=ir.getAccessToken();if(!n||!t)return null;try{const r=`${this.baseUrl}/api/common/v1/CompaniesUsers/${e}`,a=await fetch(r,{method:"GET",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!a.ok)return null;const s=await a.json();return{placeId:s.placeId||null,placeName:s.placeName||null}}catch(r){return null}}async fetchPlaceFromUsersList(e,t,n){const r=ir.getAccessToken();if(!r||!t||!n)return null;try{const a=new URL(`${this.baseUrl}/api/common/v1/companiesusers`);a.searchParams.append("companyId",n),a.searchParams.append("filterStatus","active");const s=await fetch(a.toString(),{method:"GET",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json",Accept:"application/json","un-alias":t}});if(!s.ok)return null;const i=await s.json(),o=i.data||i;if(!Array.isArray(o))return null;const l=o.find(t=>t.userId===e);return l?{placeId:l.placeId||null,placeName:l.placeName||null}:null}catch(a){return null}}async fetchUserPlace(e,t,n){if(!jr.validateToken().valid)return{placeId:null,placeName:null};try{const r=this.extractCompanyUserId(t);if(r){const e=await this.fetchPlaceByCompanyUserId(r,t);if(e&&e.placeId)return e}const a=await this.fetchPlaceFromUsersList(e,t,n);return a&&a.placeId?a:{placeId:null,placeName:null}}catch(r){if(await jr.handleApiError(r)){const e=this.extractCompanyUserId(t);if(e){const n=await this.fetchPlaceByCompanyUserId(e,t);if(n&&n.placeId)return n}}return{placeId:null,placeName:null}}}};var xl=Object.defineProperty,yl=(e,t,n)=>((e,t,n)=>t in e?xl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);class bl{constructor(){yl(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=jr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=ir.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} ${i.statusText}`);throw e.status=i.status,e}return await i.json()}mapToPlace(e){return{id:e.id||e.placeId,placeId:e.id||e.placeId,title:e.name||"Local sem nome",name:e.name||"Local sem nome",description:e.description||null,is_actived:!1!==e.isActive,companyId:e.companyId||"",usersIds:e.usersIds||[],parentId:e.parentId||null,subPlaces:[],id_user:"",responsible_name:"",alias:"",created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),is_removed:!1}}buildHierarchy(e){const t=new Map,n=[];return e.forEach(e=>{t.set(e.placeId,{...e,subPlaces:[]})}),e.forEach(e=>{const r=t.get(e.placeId);if(e.parentId&&t.has(e.parentId)){const n=t.get(e.parentId);n.subPlaces||(n.subPlaces=[]);const a={id:r.placeId,placeId:r.placeId,name:r.name,parentId:e.parentId,usersIds:r.usersIds,isActive:r.is_actived,subPlaces:r.subPlaces||[]};n.subPlaces.push(a)}else n.push(r)}),n}async fetchPlaces(e,t){try{const n=await this.makeApiCall("/api/common/v1/places",{companyId:t,filterStatus:"all"},e);let r=n;if(n.data?r=n.data:Array.isArray(n)||(r=[]),!Array.isArray(r))return cr.handleError("[PlaceService] Resposta não é um array",!1),[];const a=r.map(this.mapToPlace.bind(this));return this.buildHierarchy(a)}catch(n){if(await jr.handleApiError(n))try{const n=await this.makeApiCall("/api/common/v1/places",{companyId:t,filterStatus:"all"},e);let r=n;n.data?r=n.data:Array.isArray(n)||(r=[]);const a=(Array.isArray(r)?r:[]).map(this.mapToPlace.bind(this));return this.buildHierarchy(a)}catch(r){return cr.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}const a=n instanceof Error?n.message:"Erro ao buscar locais da API Qualiex";return cr.handleError(a,!0),[]}}async getPlaces(e){const t=ir.extractTokenData();return t&&t.companyId?this.fetchPlaces(e,t.companyId):(cr.handleError("[PlaceService] CompanyId não encontrado no token",!1),[])}}const vl=new bl;var wl=Object.defineProperty,Nl=(e,t,n)=>((e,t,n)=>t in e?wl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class kl{constructor(e={}){Nl(this,"tableName"),Nl(this,"schemaName"),this.tableName=e.tableName||"place_managers",this.schemaName=e.schemaName||"public"}async getPlaceManagers(e,t){const n=gr(),{data:r,error:a}=await n.schema(this.schemaName).from(this.tableName).select("*").eq("alias",e).eq("place_id",t).order("role",{ascending:!1}).order("user_name",{ascending:!0});if(a)throw a;return r||[]}async setManager(e,t,n){const r=gr();await r.schema(this.schemaName).from(this.tableName).delete().eq("alias",e).eq("place_id",t).eq("role","manager");const{error:a}=await r.schema(this.schemaName).from(this.tableName).insert({alias:e,place_id:t,user_id:n.userId,user_name:n.userName,user_email:n.userEmail,role:"manager"});if(a)throw a}async addMember(e,t,n){const r=gr(),{error:a}=await r.schema(this.schemaName).from(this.tableName).insert({alias:e,place_id:t,user_id:n.userId,user_name:n.userName,user_email:n.userEmail,role:"member"});if(a)throw a}async removePlaceUser(e,t,n){const r=gr(),{error:a}=await r.schema(this.schemaName).from(this.tableName).delete().eq("alias",e).eq("place_id",t).eq("user_id",n);if(a)throw a}}const jl=(e,t,n=!0)=>{const{alias:r}=Gr(),a=et(),{data:s=[],isLoading:i}=tt({queryKey:["place-managers",r,e],queryFn:()=>t.getPlaceManagers(r,e),enabled:n&&!!r&&!!e}),o=nt({mutationFn:n=>t.setManager(r,e,n),onSuccess:()=>{a.invalidateQueries({queryKey:["place-managers"]}),Un({title:"Gestor definido com sucesso"})},onError:e=>{Un({title:"Erro ao definir gestor",description:e.message,variant:"destructive"})}}),l=nt({mutationFn:n=>t.addMember(r,e,n),onSuccess:()=>{a.invalidateQueries({queryKey:["place-managers"]}),Un({title:"Membro adicionado com sucesso"})},onError:e=>{Un({title:"Erro ao adicionar membro",description:e.message,variant:"destructive"})}}),c=nt({mutationFn:n=>t.removePlaceUser(r,e,n),onSuccess:()=>{a.invalidateQueries({queryKey:["place-managers"]}),Un({title:"Removido com sucesso"})},onError:e=>{Un({title:"Erro ao remover",description:e.message,variant:"destructive"})}}),u=s.find(e=>"manager"===e.role),d=s.filter(e=>"member"===e.role);return{managers:s,manager:u,members:d,isLoading:i,setManager:o.mutate,addMember:l.mutate,remove:c.mutate,isSettingManager:o.isPending,isAddingMember:l.isPending,isRemoving:c.isPending}},Cl=({open:e,onOpenChange:t,onSelectManager:n,onSelectMember:r,currentManagerId:s,currentMemberIds:i=[],placeName:o,isLoading:l=!1})=>{const[c,u]=a(""),{data:d=[],isLoading:f}=hs(),m=d.filter(e=>e.userName.toLowerCase().includes(c.toLowerCase())||e.userEmail.toLowerCase().includes(c.toLowerCase())).sort((e,t)=>e.userName.localeCompare(t.userName)),p=f||l;return Ft.jsx(Zt,{open:e,onOpenChange:t,children:Ft.jsxs(an,{className:"max-w-4xl min-w-[800px]",children:[Ft.jsxs(sn,{children:[Ft.jsxs(ln,{children:["Gerenciar Acesso - ",o]}),Ft.jsx(cn,{children:"Selecione o gestor e os membros que terão acesso a este local"})]}),Ft.jsxs("div",{className:"space-y-4",children:[Ft.jsxs("div",{className:"relative",children:[Ft.jsx(P,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Ft.jsx(qt,{placeholder:"Buscar por nome ou email...",value:c,onChange:e=>u(e.target.value),className:"pl-9"})]}),Ft.jsx(es,{className:"h-[400px] pr-4",children:p?Ft.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Carregando usuários..."}):0===m.length?Ft.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum usuário encontrado"}):Ft.jsx("div",{className:"space-y-2",children:m.map(e=>{const t=e.userId===s,a=i.includes(e.userId),o=t||a;return Ft.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[Ft.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:Ft.jsxs("div",{className:"flex-1 min-w-0",children:[Ft.jsxs("div",{className:"flex items-center gap-2",children:[Ft.jsx("p",{className:"font-medium truncate",children:e.userName}),t&&Ft.jsxs(En,{variant:"default",className:"shrink-0",children:[Ft.jsx(Le,{className:"h-3 w-3 mr-1"}),"Gestor"]}),a&&Ft.jsxs(En,{variant:"secondary",className:"shrink-0",children:[Ft.jsx(Me,{className:"h-3 w-3 mr-1"}),"Membro"]})]}),Ft.jsx("p",{className:"text-sm text-muted-foreground truncate",children:e.userEmail})]})}),Ft.jsxs("div",{className:"flex gap-2 shrink-0 ml-4",children:[!t&&Ft.jsxs($t,{size:"sm",variant:"outline",onClick:()=>n(e),className:"whitespace-nowrap",children:[Ft.jsx(Le,{className:"h-3 w-3 mr-1"}),"Tornar Gestor"]}),!o&&Ft.jsxs($t,{size:"sm",variant:"secondary",onClick:()=>r(e),className:"whitespace-nowrap",children:[Ft.jsx(Me,{className:"h-3 w-3 mr-1"}),"Adicionar Membro"]})]})]},e.userId)})})})]})]})})},Sl=({placeId:e,placeName:t,service:n})=>{const[r,s]=a(!1),{manager:i,members:o,setManager:l,addMember:c,remove:u,isSettingManager:d,isAddingMember:f,isRemoving:m}=jl(e,n);return Ft.jsxs(Ft.Fragment,{children:[Ft.jsxs(Ea,{children:[Ft.jsx(Ta,{asChild:!0,children:Ft.jsx($t,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",children:Ft.jsx(w,{className:"h-4 w-4"})})}),Ft.jsxs(Oa,{align:"end",className:"w-56 bg-background z-50",children:[Ft.jsxs(La,{onClick:()=>s(!0),children:[Ft.jsx(Le,{className:"h-4 w-4 mr-2"}),"Gerenciar Acessos"]}),i&&Ft.jsx(La,{onClick:()=>u(i.user_id),className:"text-destructive",disabled:m,children:"Remover Gestor"})]})]}),Ft.jsx(Cl,{open:r,onOpenChange:s,onSelectManager:e=>{l(e),s(!1)},onSelectMember:c,currentManagerId:i?.user_id,currentMemberIds:o.map(e=>e.user_id),placeName:t,isLoading:d||f})]})};function Il({place:e,level:t=0,service:n}){const[r,s]=a(!1),i=e.subPlaces&&e.subPlaces.length>0,o="is_actived"in e?e.is_actived:e.isActive,l=e.placeId;return Ft.jsxs("div",{children:[Ft.jsxs(yi,{open:r,onOpenChange:s,children:[Ft.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:[i?Ft.jsxs(bi,{className:"flex items-center gap-2 flex-1",children:[Ft.jsx(T,{className:zt("h-4 w-4 transition-transform shrink-0",r&&"rotate-90")}),Ft.jsx(Ue,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Ft.jsx("span",{className:"font-medium",children:e.name}),Ft.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):Ft.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Ft.jsx("div",{className:"w-4 shrink-0"}),Ft.jsx(Ue,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Ft.jsx("span",{className:"font-medium",children:e.name})]}),Ft.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[Ft.jsxs("div",{className:"flex items-center gap-1.5",children:[Ft.jsx(Me,{className:"h-3.5 w-3.5 text-muted-foreground"}),Ft.jsx("span",{className:"text-sm text-muted-foreground",children:e.usersIds.length})]}),Ft.jsx(En,{variant:o?"default":"secondary",className:"text-xs",children:o?"Ativo":"Inativo"}),Ft.jsx(Sl,{placeId:l,placeName:e.name,service:n})]})]}),i&&Ft.jsx(vi,{children:e.subPlaces.map(e=>Ft.jsx(Il,{place:e,level:t+1,service:n},e.placeId))})]}),0===t&&Ft.jsx(Oi,{})]})}function Pl({placeManagerService:e}){const{alias:t}=Gr(),{data:n=[],isLoading:r}=tt({queryKey:["places",t],queryFn:()=>vl.getPlaces(t||""),enabled:!!t});return r?Ft.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(wa,{className:"h-8 w-64"}),Ft.jsx(wa,{className:"h-4 w-96"})]}),Ft.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[1,2,3].map(e=>Ft.jsx(wa,{className:"h-64 w-full"},e))})]}):Ft.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[Ft.jsxs("div",{children:[Ft.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Locais"}),Ft.jsx("p",{className:"text-muted-foreground",children:"Visualização hierárquica de locais e sublocais da organização"})]}),0===n.length?Ft.jsx(Qt,{children:Ft.jsxs(Xt,{className:"flex flex-col items-center justify-center py-12",children:[Ft.jsx(Ue,{className:"h-12 w-12 text-muted-foreground mb-4"}),Ft.jsx("p",{className:"text-muted-foreground",children:"Nenhum local encontrado"})]})}):Ft.jsxs(Qt,{children:[Ft.jsx(Kt,{children:Ft.jsx(Yt,{children:"Estrutura de Locais"})}),Ft.jsx(Xt,{className:"p-0",children:Ft.jsx("div",{children:n.map(t=>Ft.jsx(Il,{place:t,service:e},t.placeId))})})]})]})}const El=({placeId:e,userCount:t,service:n})=>{const{manager:r,isLoading:a}=jl(e,n);return Ft.jsxs("div",{className:"flex flex-col items-end gap-1",children:[Ft.jsx("span",{className:"text-xs text-muted-foreground",children:a?"Carregando...":r?"Gestor":"Gestores"}),Ft.jsxs("div",{className:"flex items-center gap-1.5",children:[Ft.jsx(Me,{className:"h-3.5 w-3.5 text-muted-foreground"}),Ft.jsx("span",{className:"text-sm text-muted-foreground",children:t})]})]})},Tl=t.memo(({variant:e="card",className:n="",selectedUnit:r,onUnitChange:a})=>{const{user:s,companies:i,alias:o,isAuthenticated:l,logout:c,switchUnit:u}=Gr(),d=i?.[0]||null,f=o?i?.find(e=>e.alias===o):d,m=i||[],p=r||f||d||d,h=t.useCallback(e=>{a?a(e):u(e)},[a,u]),g=t.useMemo(()=>{if(!m?.length)return[];const e=new Map;m.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},[m,p?.alias]);if(!l||!s)return null;const x=()=>Ft.jsxs(Ft.Fragment,{children:[Ft.jsxs("div",{className:"flex items-center space-x-3",children:[Ft.jsx("div",{className:"flex-shrink-0",children:Ft.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:Ft.jsx(Ie,{className:"h-5 w-5 text-primary-foreground"})})}),Ft.jsxs("div",{className:"flex-1 min-w-0",children:[Ft.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),Ft.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&Ft.jsx("div",{className:"mt-3",children:Ft.jsxs("div",{className:"flex items-center space-x-2",children:[Ft.jsx(Ue,{className:"h-4 w-4 text-muted-foreground"}),Ft.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),g.length>1&&Ft.jsxs("div",{className:"mt-2",children:[Ft.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",g.length]}),Ft.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,3).map(e=>Ft.jsx(En,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),g.length>3&&Ft.jsxs(En,{variant:"outline",className:"text-xs",children:["+",g.length-3]})]})]})]});return"dropdown"===e?Ft.jsxs(Ea,{children:[Ft.jsx(Ta,{asChild:!0,children:Ft.jsx($t,{variant:"ghost",className:`h-auto p-2 ${n}`,children:Ft.jsxs("div",{className:"flex items-center space-x-2",children:[Ft.jsxs("div",{className:"hidden md:block text-left",children:[Ft.jsx("p",{className:"text-sm font-medium",children:s.name}),Ft.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),Ft.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:Ft.jsx(Ie,{className:"h-4 w-4 text-primary-foreground"})}),Ft.jsx(k,{className:"h-4 w-4"})]})})}),Ft.jsxs(Oa,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[Ft.jsxs(Ra,{children:[Ft.jsxs(Da,{children:[Ft.jsx(Fe,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),Ft.jsx(za,{children:g.map(e=>Ft.jsxs(La,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[Ft.jsx(Ue,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&Ft.jsx(En,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Ft.jsx($a,{}),Ft.jsxs(La,{onClick:c,children:[Ft.jsx(Be,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):Ft.jsxs(Qt,{className:n,children:[Ft.jsx(Kt,{children:Ft.jsx(Yt,{className:"text-lg",children:"Informações do Usuário"})}),Ft.jsxs(Xt,{className:"space-y-4",children:[Ft.jsx(x,{}),Ft.jsx(Oi,{}),Ft.jsxs($t,{variant:"outline",onClick:c,size:"sm",className:"w-full",children:[Ft.jsx(Be,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Al=n({});function _l({children:e,config:t}){const n=o(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return Ft.jsx(Al.Provider,{value:n,children:e})}function Rl(){return r(Al)}function Fl(){const e=st(),{navigation:t}=Rl();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 Dl(e,t){const[n,r]=a(e),o=c(),l=s(()=>{o.current&&(clearTimeout(o.current),o.current=void 0)},[]);return i(()=>(l(),o.current=setTimeout(()=>{r(e)},t),l),[e,t,l]),[n,l]}const zl=l(function({actions:e}){const t=st(),n=Fl(),{navigation:r,appName:s}=Rl(),{metadata:o}=Vs(),{companies:l,alias:c,isSearchVisible:u,clearSearch:d,refreshData:f,switchUnit:m}=Gr(),p=c?l?.find(e=>e.alias===c)||l?.[0]||null:l?.[0]||null,[h,g]=at(),[x,y]=a(()=>h.get("search")||""),[b,v]=Dl(x,Ar.debounceDelay);i(()=>{if(!u)return;const e=new URLSearchParams(h);b?(e.set("search",b),e.set("page","1")):e.delete("search"),g(e)},[b,g,u]);const w=r?.find(e=>e.path===t.pathname)||r?.find(e=>t.pathname.startsWith(e.path+"/")),k=o.title||n,j=o.subtitle||w?.complementaryText||"Detalhes do item";return Ft.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:Ft.jsxs("div",{className:"flex items-center gap-4",children:[Ft.jsxs("div",{className:"flex-shrink-0",children:[Ft.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[Ft.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:k}),Ft.jsx(En,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:s||"Módulo"})]}),Ft.jsx("p",{className:"text-sm text-muted-foreground truncate",children:j})]}),u&&Ft.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[Ft.jsxs("div",{className:"relative flex-1",children:[Ft.jsx(P,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Ft.jsx(qt,{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&&Ft.jsx($t,{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:Ft.jsx(N,{size:14})})]}),Ft.jsx($t,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:Ft.jsx(Fe,{size:14})})]}),Ft.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[e&&Ft.jsx("div",{className:"flex items-center gap-2",children:e}),Ft.jsx("div",{className:"text-sm",children:Ft.jsx(Tl,{variant:"dropdown",selectedUnit:p,onUnitChange:m})})]})]})})}),Ol=(e={})=>{const{enabled:t=!0}=e,{alias:n}=Gr();return tt({queryKey:["active-modules",n],queryFn:async()=>{if(!n)return[];const e=gr(),{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(!Nr.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!n})},Ll=({key:e,enabled:t,checkFn:n,staleTime:r=3e5,gcTime:a=6e5})=>tt({queryKey:["permission",e],queryFn:n,enabled:t,staleTime:r,gcTime:a,retry:0,refetchOnWindowFocus:!1}),Ml=import.meta.env.VITE_SUPABASE_PROJECT_ID,Ul={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`},Bl=Ul.logo,$l=Ul.smallLogo,Vl="forlogic-sidebar-pinned",ql=()=>{try{const e=localStorage.getItem(Vl);return!!e&&JSON.parse(e)}catch{return!1}};function Hl({config:e}={}){const{state:t,open:n,setOpen:r}=to(),s=st(),{alias:o,user:l}=Gr(),[c,u]=a(!1),[d,f]=a(ql),[m,p]=a(!1);i(()=>{r(!!d||!(!m&&!c))},[d,m,c,r]);const{data:h,isLoading:g,error:x}=Ol({enabled:c}),y=e=>s.pathname===e||s.pathname.startsWith(e+"/"),b=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]};return Ft.jsxs(ro,{collapsible:"icon",onMouseEnter:()=>{d||p(!0)},onMouseLeave:()=>{d||p(!1)},className:"app-sidebar transition-all duration-300 ease-in-out bg-white border-r border-gray-200 py-6 px-3",children:[Ft.jsxs(lo,{className:"p-0 gap-0",children:[Ft.jsx("div",{className:"flex items-center justify-between h-[34px]",children:n?Ft.jsxs(Ft.Fragment,{children:[Ft.jsx("div",{className:"flex items-center pl-[12px]",children:Ft.jsx("img",{src:Ul.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),Ft.jsx("button",{onClick:()=>{const e=!d;f(e),(e=>{try{localStorage.setItem(Vl,JSON.stringify(e))}catch{}})(e)},className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(d?"bg-primary text-primary-foreground":"hover:bg-muted text-muted-foreground"),children:Ft.jsx(ze,{className:"h-4 w-4"})})]}):Ft.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:Ft.jsx("img",{src:Ul.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),Ft.jsx("div",{className:"mt-2 pt-0",children:Ft.jsxs(Ea,{onOpenChange:u,children:[Ft.jsx(Ta,{asChild:!0,children:n?Ft.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:[Ft.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Ft.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"}),Ft.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:e?.appName||"Título do módulo"})]}),Ft.jsx(k,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):Ft.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:Ft.jsx(k,{className:"h-6 w-6 text-muted-foreground"})})}),Ft.jsx(Oa,{className:n?"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:n?"start":"center",children:g?Ft.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[Ft.jsx(S,{className:"h-4 w-4 animate-spin"}),Ft.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):x?Ft.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[Ft.jsx(I,{className:"h-4 w-4"}),Ft.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):h&&0!==h.length?Ft.jsx("div",{className:"space-y-2",children:h.map((e,t)=>Ft.jsx("div",{onClick:()=>(e=>{const t=h?.find(t=>t.url===e);t?.url&&window.open(t.url,"_blank")})(e.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${b(t)} transition-colors duration-200\n `,children:Ft.jsxs("div",{className:"flex items-center justify-between",children:[Ft.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&Ft.jsx(Oe,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):Ft.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]}),Ft.jsx(fo,{children:Ft.jsx(mo,{className:"p-0 mt-6",children:Ft.jsx(go,{children:Ft.jsx(xo,{className:"space-y-2",children:Ft.jsx(Yi,{children:e?.navigation?.map((e,t)=>{const n=({item:e,index:t})=>{const n=`${e.path}-${t}-${o??"noalias"}-${l?.id??"nouser"}`,{data:r=!0,isLoading:a}=Ll({key:n,enabled:Boolean(e.permissionCheck&&o&&l?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),s=e.permissionCheck&&!r,i=a?S:s?J:e.icon;return s||e.complementaryText,Ft.jsx(yo,{children:s||a?Ft.jsxs(Ji,{children:[Ft.jsx(Xi,{asChild:!0,children:Ft.jsx(vo,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:Ft.jsxs("div",{className:"flex w-full items-center gap-3",children:[Ft.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Ft.jsx(i,{className:"h-4 w-4 "+(a?"animate-spin":"")})}),Ft.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),Ft.jsx(Gi,{children:Ft.jsx("p",{children:a?"Verificando acesso...":"Acesso restrito"})})]}):Ft.jsx(vo,{asChild:!0,isActive:y(e.path),size:"lg",className:"h-10",children:Ft.jsxs(ot,{to:e.path,className:"flex w-full items-center gap-3",children:[Ft.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Ft.jsx(i,{className:"h-5 w-4"})}),Ft.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path)};return Ft.jsx(n,{item:e,index:t},e.path)})})})})})})]})}const Wl=l(function({children:e,sidebar:t,sidebarConfig:n,showHeader:r=!0}){const a=o(()=>t||Ft.jsx(Hl,{config:n}),[t,n]),s=o(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return Ft.jsx(_l,{config:n,children:Ft.jsx($s,{children:Ft.jsx(no,{defaultOpen:!1,style:s,children:Ft.jsxs("div",{className:"min-h-screen flex w-full",children:[a,Ft.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[r&&Ft.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:Ft.jsx(zl,{})}),Ft.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:e})]})]})})})})});class Ql extends u{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){cr.handleError(e,!1)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:Ft.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:Ft.jsxs(Qt,{className:"w-full max-w-md",children:[Ft.jsxs(Kt,{className:"text-center",children:[Ft.jsx("div",{className:"flex justify-center mb-4",children:Ft.jsx($e,{className:"h-12 w-12 text-destructive"})}),Ft.jsx(Yt,{children:"Algo deu errado"})]}),Ft.jsxs(Xt,{className:"text-center space-y-4",children:[Ft.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),Ft.jsx($t,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function Kl(){const[e,t]=a([]),[n,r]=a(!1),[o,l]=a(null),[c,u]=a(null);i(()=>{d()},[]);const d=async()=>{try{const e=gr(),{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){u("Erro ao inicializar conversa"),b.error("Erro ao inicializar conversa")}},f=s(async e=>{if(!o||!e.trim())return;const n={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};t(e=>[...e,n]),r(!0),u(null);try{const n=gr(),{data:r,error:a}=await n.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:o,message:e}});if(a)throw a;const{runId:s}=r,i=await(async e=>{if(!o)return!1;for(let n=0;n<60;n++)try{const t=gr(),{data:n,error:r}=await t.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:o,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")})(s);i&&await(async()=>{if(o)try{const e=gr(),{data:n,error:r}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:o}});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(a){const e=a instanceof Error?a.message:"Erro ao enviar mensagem";u(e),b.error(e),t(e=>e.filter(e=>e.id!==n.id))}finally{r(!1)}},[o]);return{messages:e,isLoading:n,error:c,sendMessage:f,threadId:o}}function Yl(){}function Jl(){}const Xl=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Gl=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Zl={};function ec(e,t){return(Zl.jsx?Gl:Xl).test(e)}const tc=/[ \t\n\f\r]/g;function nc(e){return""===e.replace(tc,"")}class rc{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function ac(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new rc(n,r,t)}function sc(e){return e.toLowerCase()}rc.prototype.normal={},rc.prototype.property={},rc.prototype.space=void 0;class ic{constructor(e,t){this.attribute=t,this.property=e}}ic.prototype.attribute="",ic.prototype.booleanish=!1,ic.prototype.boolean=!1,ic.prototype.commaOrSpaceSeparated=!1,ic.prototype.commaSeparated=!1,ic.prototype.defined=!1,ic.prototype.mustUseProperty=!1,ic.prototype.number=!1,ic.prototype.overloadedBoolean=!1,ic.prototype.property="",ic.prototype.spaceSeparated=!1,ic.prototype.space=void 0;let oc=0;const lc=hc(),cc=hc(),uc=hc(),dc=hc(),fc=hc(),mc=hc(),pc=hc();function hc(){return 2**++oc}var gc=Object.freeze({__proto__:null,boolean:lc,booleanish:cc,commaOrSpaceSeparated:pc,commaSeparated:mc,number:dc,overloadedBoolean:uc,spaceSeparated:fc});const xc=Object.keys(gc);class yc extends ic{constructor(e,t,n,r){let a=-1;if(super(e,t),bc(this,"space",r),"number"==typeof n)for(;++a<xc.length;){const e=xc[a];bc(this,xc[a],(n&gc[e])===gc[e])}}}function bc(e,t,n){n&&(e[t]=n)}function vc(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new yc(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[sc(r)]=r,n[sc(s.attribute)]=r}return new rc(t,n,e.space)}yc.prototype.defined=!0;const wc=vc({properties:{ariaActiveDescendant:null,ariaAtomic:cc,ariaAutoComplete:null,ariaBusy:cc,ariaChecked:cc,ariaColCount:dc,ariaColIndex:dc,ariaColSpan:dc,ariaControls:fc,ariaCurrent:null,ariaDescribedBy:fc,ariaDetails:null,ariaDisabled:cc,ariaDropEffect:fc,ariaErrorMessage:null,ariaExpanded:cc,ariaFlowTo:fc,ariaGrabbed:cc,ariaHasPopup:null,ariaHidden:cc,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:fc,ariaLevel:dc,ariaLive:null,ariaModal:cc,ariaMultiLine:cc,ariaMultiSelectable:cc,ariaOrientation:null,ariaOwns:fc,ariaPlaceholder:null,ariaPosInSet:dc,ariaPressed:cc,ariaReadOnly:cc,ariaRelevant:null,ariaRequired:cc,ariaRoleDescription:fc,ariaRowCount:dc,ariaRowIndex:dc,ariaRowSpan:dc,ariaSelected:cc,ariaSetSize:dc,ariaSort:null,ariaValueMax:dc,ariaValueMin:dc,ariaValueNow:dc,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function Nc(e,t){return t in e?e[t]:t}function kc(e,t){return Nc(e,t.toLowerCase())}const jc=vc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:mc,acceptCharset:fc,accessKey:fc,action:null,allow:null,allowFullScreen:lc,allowPaymentRequest:lc,allowUserMedia:lc,alt:null,as:null,async:lc,autoCapitalize:null,autoComplete:fc,autoFocus:lc,autoPlay:lc,blocking:fc,capture:null,charSet:null,checked:lc,cite:null,className:fc,cols:dc,colSpan:null,content:null,contentEditable:cc,controls:lc,controlsList:fc,coords:dc|mc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:lc,defer:lc,dir:null,dirName:null,disabled:lc,download:uc,draggable:cc,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:lc,formTarget:null,headers:fc,height:dc,hidden:uc,high:dc,href:null,hrefLang:null,htmlFor:fc,httpEquiv:fc,id:null,imageSizes:null,imageSrcSet:null,inert:lc,inputMode:null,integrity:null,is:null,isMap:lc,itemId:null,itemProp:fc,itemRef:fc,itemScope:lc,itemType:fc,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:lc,low:dc,manifest:null,max:null,maxLength:dc,media:null,method:null,min:null,minLength:dc,multiple:lc,muted:lc,name:null,nonce:null,noModule:lc,noValidate:lc,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:lc,optimum:dc,pattern:null,ping:fc,placeholder:null,playsInline:lc,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:lc,referrerPolicy:null,rel:fc,required:lc,reversed:lc,rows:dc,rowSpan:dc,sandbox:fc,scope:null,scoped:lc,seamless:lc,selected:lc,shadowRootClonable:lc,shadowRootDelegatesFocus:lc,shadowRootMode:null,shape:null,size:dc,sizes:null,slot:null,span:dc,spellCheck:cc,src:null,srcDoc:null,srcLang:null,srcSet:null,start:dc,step:null,style:null,tabIndex:dc,target:null,title:null,translate:null,type:null,typeMustMatch:lc,useMap:null,value:cc,width:dc,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:fc,axis:null,background:null,bgColor:null,border:dc,borderColor:null,bottomMargin:dc,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:lc,declare:lc,event:null,face:null,frame:null,frameBorder:null,hSpace:dc,leftMargin:dc,link:null,longDesc:null,lowSrc:null,marginHeight:dc,marginWidth:dc,noResize:lc,noHref:lc,noShade:lc,noWrap:lc,object:null,profile:null,prompt:null,rev:null,rightMargin:dc,rules:null,scheme:null,scrolling:cc,standby:null,summary:null,text:null,topMargin:dc,valueType:null,version:null,vAlign:null,vLink:null,vSpace:dc,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:lc,disableRemotePlayback:lc,prefix:null,property:null,results:dc,security:null,unselectable:null},space:"html",transform:kc}),Cc=vc({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:pc,accentHeight:dc,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:dc,amplitude:dc,arabicForm:null,ascent:dc,attributeName:null,attributeType:null,azimuth:dc,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:dc,by:null,calcMode:null,capHeight:dc,className:fc,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:dc,diffuseConstant:dc,direction:null,display:null,dur:null,divisor:dc,dominantBaseline:null,download:lc,dx:null,dy:null,edgeMode:null,editable:null,elevation:dc,enableBackground:null,end:null,event:null,exponent:dc,externalResourcesRequired:null,fill:null,fillOpacity:dc,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:mc,g2:mc,glyphName:mc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:dc,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:dc,horizOriginX:dc,horizOriginY:dc,id:null,ideographic:dc,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:dc,k:dc,k1:dc,k2:dc,k3:dc,k4:dc,kernelMatrix:pc,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:dc,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:dc,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:dc,overlineThickness:dc,paintOrder:null,panose1:null,path:null,pathLength:dc,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:fc,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:dc,pointsAtY:dc,pointsAtZ:dc,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pc,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pc,rev:pc,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pc,requiredFeatures:pc,requiredFonts:pc,requiredFormats:pc,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:dc,specularExponent:dc,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:dc,strikethroughThickness:dc,string:null,stroke:null,strokeDashArray:pc,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:dc,strokeOpacity:dc,strokeWidth:null,style:null,surfaceScale:dc,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pc,tabIndex:dc,tableValues:null,target:null,targetX:dc,targetY:dc,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pc,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:dc,underlineThickness:dc,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:dc,values:null,vAlphabetic:dc,vMathematical:dc,vectorEffect:null,vHanging:dc,vIdeographic:dc,version:null,vertAdvY:dc,vertOriginX:dc,vertOriginY:dc,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:dc,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Nc}),Sc=vc({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()}),Ic=vc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:kc}),Pc=vc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),Ec={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"},Tc=/[A-Z]/g,Ac=/-[a-z]/g,_c=/^data[-\w.:]+$/i;function Rc(e){return"-"+e.toLowerCase()}function Fc(e){return e.charAt(1).toUpperCase()}const Dc=ac([wc,jc,Sc,Ic,Pc],"html"),zc=ac([wc,Cc,Sc,Ic,Pc],"svg");var Oc,Lc,Mc,Uc={};function Bc(){if(Mc)return Uc;Mc=1;var e=Uc&&Uc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Uc,"__esModule",{value:!0}),Uc.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(Lc)return Oc;Lc=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 Oc=function(o,u){if("string"!=typeof o)throw new TypeError("First argument must be a string");if(!o)return[];u=u||{};var d=1,f=1;function m(e){var n=e.match(t);n&&(d+=n.length);var r=e.lastIndexOf("\n");f=~r?e.length-r:f+e.length}function p(){var e={line:d,column:f};return function(t){return t.position=new h(e),y(),t}}function h(e){this.start=e,this.end={line:d,column:f},this.source=u.source}function g(e){var t=new Error(u.source+":"+d+":"+f+": "+e);if(t.reason=e,t.filename=u.source,t.line=d,t.column=f,t.source=o,!u.silent)throw t}function x(e){var t=e.exec(o);if(t){var n=t[0];return m(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 f+=2,m(n),o=o.slice(t),f+=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),u=t({type:"declaration",property:c(n[0].replace(e,l)),value:o?c(o[0].replace(e,l)):l});return x(i),u}}return h.prototype.content=o,y(),function(){var e,t=[];for(b(t);e=w();)!1!==e&&(t.push(e),b(t));return t}()},Oc}());return Uc}var $c,Vc,qc,Hc={};function Wc(){if($c)return Hc;$c=1,Object.defineProperty(Hc,"__esModule",{value:!0}),Hc.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 Hc.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))},Hc}var Qc=function(){if(qc)return Vc;qc=1;var e=(Vc&&Vc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Bc()),t=Wc();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,Vc=n}(),Kc=St(Qc);const Yc=Xc("end"),Jc=Xc("start");function Xc(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 Gc(e){return e&&"object"==typeof e?"position"in e||"type"in e?eu(e.position):"start"in e||"end"in e?eu(e):"line"in e||"column"in e?Zc(e):"":""}function Zc(e){return tu(e&&e.line)+":"+tu(e&&e.column)}function eu(e){return Zc(e&&e.start)+"-"+Zc(e&&e.end)}function tu(e){return e&&"number"==typeof e?e:1}class nu 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=Gc(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}}nu.prototype.file="",nu.prototype.name="",nu.prototype.reason="",nu.prototype.message="",nu.prototype.stack="",nu.prototype.column=void 0,nu.prototype.line=void 0,nu.prototype.ancestors=void 0,nu.prototype.cause=void 0,nu.prototype.fatal=void 0,nu.prototype.place=void 0,nu.prototype.ruleId=void 0,nu.prototype.source=void 0;const ru={}.hasOwnProperty,au=new Map,su=/[A-Z]/g,iu=new Set(["table","tbody","thead","tfoot","tr"]),ou=new Set(["td","th"]),lu="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function cu(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=Jc(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?zc:Dc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=uu(a,e,void 0);return s&&"string"!=typeof s?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function uu(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=zc,e.schema=a);e.ancestors.push(t);const s=hu(e,t.tagName,!1),i=function(e,t){const n={};let r,a;for(a in t.properties)if("children"!==a&&ru.call(t.properties,a)){const s=pu(e,a,t.properties[a]);if(s){const[a,i]=s;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof i&&ou.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=mu(e,t);iu.has(t.tagName)&&(o=o.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&nc(t.value):nc(t));var t}));return du(e,i,s,t),fu(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)}gu(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=zc,e.schema=a);e.ancestors.push(t);const s=null===t.name?e.Fragment:hu(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];Yl(t.type);const a=t.expression;Yl(a.type);const s=a.properties[0];Yl(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else gu(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];Yl(t.type),s=e.evaluater.evaluateExpression(t.expression)}else gu(e,t.position);else s=null===r.value||r.value;n[a]=s}return n}(e,t),o=mu(e,t);return du(e,i,s,t),fu(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);gu(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return fu(r,mu(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 du(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function fu(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function mu(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:au;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=uu(e,s,i);void 0!==o&&n.push(o)}return n}function pu(e,t,n){const r=function(e,t){const n=sc(t);let r=t,a=ic;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&_c.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(Ac,Fc);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!Ac.test(e)){let n=e.replace(Tc,Rc);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}a=yc}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 Kc(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new nu("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=lu+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)ru.call(e,n)&&(t[xu(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?Ec[r.property]||r.property:r.attribute,n]}}function hu(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,a=-1;for(;++a<e.length;){const t=ec(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=ec(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 ru.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);gu(e)}function gu(e,t){const n=new nu("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=lu+"#cannot-handle-mdx-estrees-without-createevaluater",n}function xu(e){let t=e.replace(su,yu);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function yu(e){return"-"+e.toLowerCase()}const bu={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"]},vu={};function wu(e,t){return Nu(e,"boolean"!=typeof vu.includeImageAlt||vu.includeImageAlt,"boolean"!=typeof vu.includeHtml||vu.includeHtml)}function Nu(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 ku(e.children,t,n)}return Array.isArray(e)?ku(e,t,n):""}function ku(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=Nu(e[a],t,n);return r.join("")}const ju=document.createElement("i");function Cu(e){const t="&"+e+";";ju.innerHTML=t;const n=ju.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function Su(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 Iu(e,t){return e.length>0?(Su(e,e.length,0,t),e):t}const Pu={}.hasOwnProperty;function Eu(e){const t={};let n=-1;for(;++n<e.length;)Tu(t,e[n]);return t}function Tu(e,t){let n;for(n in t){const r=(Pu.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){Pu.call(r,s)||(r[s]=[]);const e=a[s];Au(r[s],Array.isArray(e)?e:e?[e]:[])}}}function Au(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);Su(e,0,0,r)}function _u(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 Ru(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Fu=Wu(/[A-Za-z]/),Du=Wu(/[\dA-Za-z]/),zu=Wu(/[#-'*+\--9=?A-Z^-~]/);function Ou(e){return null!==e&&(e<32||127===e)}const Lu=Wu(/\d/),Mu=Wu(/[\dA-Fa-f]/),Uu=Wu(/[!-/:-@[-`{-~]/);function Bu(e){return null!==e&&e<-2}function $u(e){return null!==e&&(e<0||32===e)}function Vu(e){return-2===e||-1===e||32===e}const qu=Wu(/\p{P}|\p{S}/u),Hu=Wu(/\s/);function Wu(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Qu(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&Du(e.charCodeAt(n+1))&&Du(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 Ku(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(Vu(r))return e.enter(n),i(r);return t(r)};function i(r){return Vu(r)&&s++<a?(e.consume(r),i):(e.exit(n),t(r))}}const Yu={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"),Ku(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)):Bu(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),a)}}};const Ju={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 Su(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 f(a);if(r.currentConstruct&&r.currentConstruct.concrete)return p(a);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Xu,u,d)(a)}function u(e){return r&&y(),x(i),f(e)}function d(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,p(e)}function f(n){return t.containerState={},e.attempt(Xu,m,p)(n)}function m(e){return i++,n.push([t.currentConstruct,t.containerState]),f(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)):Bu(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++;Su(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}}},Xu={tokenize:function(e,t,n){return Ku(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function Gu(e){return null===e||$u(e)||Hu(e)?1:qu(e)?2:void 0}function Zu(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 ed={name:"attention",resolveAll:function(e,t){let n,r,a,s,i,o,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close)for(n=u;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[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;o=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const d={...e[n][1].end},f={...e[u][1].start};td(d,-o),td(f,o),s={type:o>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},i={type:o>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:f},a={type:o>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:o>1?"strong":"emphasis",start:{...s.start},end:{...i.end}},e[n][1].end={...s.start},e[u][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=Iu(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=Iu(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",a,t]]),l=Iu(l,Zu(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=Iu(l,[["exit",a,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=Iu(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,Su(e,n-1,u-n+3,l),u=n+l.length-c-2;break}u=-1;for(;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Gu(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=Gu(o),u=!c||2===c&&a||n.includes(o),d=!a||2===a&&c||n.includes(r);return l._open=Boolean(42===s?u:u&&(a||!d)),l._close=Boolean(42===s?d:d&&(c||!u)),t(o)}}};function td(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const nd={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 Fu(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||Du(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||Du(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||Ou(r)?n(r):(e.consume(r),o)}function l(t){return 64===t?(e.consume(t),c):zu(t)?(e.consume(t),l):n(t)}function c(e){return Du(e)?u(e):n(e)}function u(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):d(n)}function d(t){if((45===t||Du(t))&&r++<63){const n=45===t?d:u;return e.consume(t),n}return n(t)}}};const rd={partial:!0,tokenize:function(e,t,n){return function(t){return Vu(t)?Ku(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||Bu(e)?t(e):n(e)}}};const ad={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(Vu(t))return Ku(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return a(t)};function a(r){return e.attempt(ad,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 Vu(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const sd={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 Uu(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const id={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=Du,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=Mu,c):(e.enter("characterReferenceValue"),a=7,s=Lu,c(t))}function c(o){if(59===o&&i){const a=e.exit("characterReferenceValue");return s!==Du||Cu(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 od={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)}}},ld={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"),Vu(t)?Ku(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"),u(t)):n(t)}function u(t){return t===s?(a++,e.consume(t),u):a>=o?(e.exit("codeFencedFenceSequence"),Vu(t)?Ku(e,d,"whitespace")(t):d(t)):n(t)}function d(r){return null===r||Bu(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"),Vu(t)?Ku(e,c,"whitespace")(t):c(t))}function c(n){return null===n||Bu(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(od,m,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||Bu(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):Vu(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ku(e,d,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),u)}function d(t){return null===t||Bu(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(t))}function f(t){return null===t||Bu(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),f)}function m(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&&Vu(t)?Ku(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||Bu(t)?e.check(od,m,y)(t):(e.enter("codeFlowValue"),x(t))}function x(t){return null===t||Bu(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),x)}function y(n){return e.exit("codeFenced"),t(n)}}};const cd={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),Ku(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):Bu(t)?e.attempt(ud,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||Bu(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},ud={partial:!0,tokenize:function(e,t,n){const r=this;return a;function a(t){return r.parser.lazy[r.now().line]?n(t):Bu(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):Ku(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):Bu(e)?a(e):n(e)}}};const dd={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)):Bu(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||Bu(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 fd{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&&md(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),md(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),md(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);md(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);md(this.left,t.reverse())}}}function md(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 pd(e){const t={};let n,r,a,s,i,o,l,c=-1;const u=new fd(e);for(;++c<u.length;){for(;c in t;)c=t[c];if(n=u.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===u.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,hd(u,c)),c=t[c],l=!0);else if(n[1]._container){for(a=c,r=void 0;a--;)if(s=u.get(a),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(r&&(u.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={...u.get(r)[1].start},i=u.slice(r,c),i.unshift(n),u.splice(r,c-r+1,i))}}return Su(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function hd(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 u,d,f=-1,m=n,p=0,h=0;const g=[h];for(;m;){for(;e.get(++a)[1]!==m;);s.push(a),m._tokenizer||(u=r.sliceStream(m),m.next||u.push(null),d&&i.defineSkip(m.start),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(u),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),d=m,m=m.next}for(m=n;++f<o.length;)"exit"===o[f][0]&&"enter"===o[f-1][0]&&o[f][1].type===o[f-1][1].type&&o[f][1].start.line!==o[f][1].end.line&&(h=f+1,g.push(h),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(i.events=[],m?(m._tokenizer=void 0,m.previous=void 0):g.pop(),f=g.length;f--;){const t=o.slice(g[f],g[f+1]),n=s.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),f=-1;++f<l.length;)c[p+l[f][0]]=p+l[f][1],p+=l[f][1]-l[f][0]-1;return c}const gd={resolve:function(e){return pd(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):Bu(t)?e.check(xd,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}}},xd={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"),Ku(e,a,"linePrefix")};function a(a){if(null===a||Bu(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 yd(e,t,n,r,a,s,i,o,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return function(t){if(60===t)return e.enter(r),e.enter(a),e.enter(s),e.consume(t),e.exit(s),d;if(null===t||32===t||41===t||Ou(t))return n(t);return e.enter(r),e.enter(i),e.enter(o),e.enter("chunkString",{contentType:"string"}),p(t)};function d(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"}),f(n))}function f(t){return 62===t?(e.exit("chunkString"),e.exit(o),d(t)):null===t||60===t||Bu(t)?n(t):(e.consume(t),92===t?m:f)}function m(t){return 60===t||62===t||92===t?(e.consume(t),f):f(t)}function p(a){return u||null!==a&&41!==a&&!$u(a)?u<c&&40===a?(e.consume(a),u++,p):41===a?(e.consume(a),u--,p):null===a||32===a||40===a||Ou(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 bd(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(d){return l>999||null===d||91===d||93===d&&!o||94===d&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(d):93===d?(e.exit(s),e.enter(a),e.consume(d),e.exit(a),e.exit(r),t):Bu(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||Bu(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!Vu(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function vd(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):Bu(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Ku(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||Bu(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===i||92===t?(e.consume(t),c):c(t)}}function wd(e,t){let n;return function r(a){if(Bu(a))return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r;if(Vu(a))return Ku(e,r,n?"linePrefix":"lineSuffix")(a);return t(a)}}const Nd={name:"definition",tokenize:function(e,t,n){const r=this;let a;return function(t){return e.enter("definition"),function(t){return bd.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return a=Ru(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 $u(t)?wd(e,o)(t):o(t)}function o(t){return yd(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(kd,c,c)(t)}function c(t){return Vu(t)?Ku(e,u,"whitespace")(t):u(t)}function u(s){return null===s||Bu(s)?(e.exit("definition"),r.parser.defined.push(a),t(s)):n(s)}}},kd={partial:!0,tokenize:function(e,t,n){return function(t){return $u(t)?wd(e,r)(t):n(t)};function r(t){return vd(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return Vu(t)?Ku(e,s,"whitespace")(t):s(t)}function s(e){return null===e||Bu(e)?t(e):n(e)}}};const jd={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return Bu(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const Cd={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"},Su(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||$u(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||Bu(n)?(e.exit("atxHeading"),t(n)):Vu(n)?Ku(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||$u(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const Sd=["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"],Id=["pre","script","style","textarea"],Pd={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),u):47===o?(e.consume(o),s=!0,m):63===o?(e.consume(o),a=3,r.interrupt?t:F):Fu(o)?(e.consume(o),i=String.fromCharCode(o),p):n(o)}function u(s){return 45===s?(e.consume(s),a=2,d):91===s?(e.consume(s),a=5,o=0,f):Fu(s)?(e.consume(s),a=4,r.interrupt?t:F):n(s)}function d(a){return 45===a?(e.consume(a),r.interrupt?t:F):n(a)}function f(a){const s="CDATA[";return a===s.charCodeAt(o++)?(e.consume(a),6===o?r.interrupt?t:S:f):n(a)}function m(t){return Fu(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||$u(o)){const l=47===o,c=i.toLowerCase();return l||s||!Id.includes(c)?Sd.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||Du(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 Vu(t)?(e.consume(t),g):j(t)}function x(t){return 47===t?(e.consume(t),j):58===t||95===t||Fu(t)?(e.consume(t),y):Vu(t)?(e.consume(t),x):j(t)}function y(t){return 45===t||46===t||58===t||95===t||Du(t)?(e.consume(t),y):b(t)}function b(t){return 61===t?(e.consume(t),v):Vu(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):Vu(t)?(e.consume(t),v):N(t)}function w(t){return t===l?(e.consume(t),l=null,k):null===t||Bu(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||$u(t)?b(t):(e.consume(t),N)}function k(e){return 47===e||62===e||Vu(e)?x(e):n(e)}function j(t){return 62===t?(e.consume(t),C):n(t)}function C(t){return null===t||Bu(t)?S(t):Vu(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),A):62===t&&4===a?(e.consume(t),D):63===t&&3===a?(e.consume(t),F):93===t&&5===a?(e.consume(t),R):!Bu(t)||6!==a&&7!==a?null===t||Bu(t)?(e.exit("htmlFlowData"),I(t)):(e.consume(t),S):(e.exit("htmlFlowData"),e.check(Ed,z,I)(t))}function I(t){return e.check(Td,P,z)(t)}function P(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||Bu(t)?I(t):(e.enter("htmlFlowData"),S(t))}function T(t){return 45===t?(e.consume(t),F):S(t)}function A(t){return 47===t?(e.consume(t),i="",_):S(t)}function _(t){if(62===t){const n=i.toLowerCase();return Id.includes(n)?(e.consume(t),D):S(t)}return Fu(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),_):S(t)}function R(t){return 93===t?(e.consume(t),F):S(t)}function F(t){return 62===t?(e.consume(t),D):45===t&&2===a?(e.consume(t),F):S(t)}function D(t){return null===t||Bu(t)?(e.exit("htmlFlowData"),z(t)):(e.consume(t),D)}function z(n){return e.exit("htmlFlow"),t(n)}}},Ed={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(rd,t,n)}}},Td={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(Bu(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 Ad={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):Fu(t)?(e.consume(t),k):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,m):Fu(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),f):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):Bu(t)?(i=u,_(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),f):u(t)}function f(e){return 62===e?A(e):45===e?d(e):u(e)}function m(t){const r="CDATA[";return t===r.charCodeAt(s++)?(e.consume(t),6===s?p:m):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),h):Bu(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?A(t):93===t?(e.consume(t),g):p(t)}function x(t){return null===t||62===t?A(t):Bu(t)?(i=x,_(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):Bu(t)?(i=y,_(t)):(e.consume(t),y)}function b(e){return 62===e?A(e):y(e)}function v(t){return Fu(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||Du(t)?(e.consume(t),w):N(t)}function N(t){return Bu(t)?(i=N,_(t)):Vu(t)?(e.consume(t),N):A(t)}function k(t){return 45===t||Du(t)?(e.consume(t),k):47===t||62===t||$u(t)?j(t):n(t)}function j(t){return 47===t?(e.consume(t),A):58===t||95===t||Fu(t)?(e.consume(t),C):Bu(t)?(i=j,_(t)):Vu(t)?(e.consume(t),j):A(t)}function C(t){return 45===t||46===t||58===t||95===t||Du(t)?(e.consume(t),C):S(t)}function S(t){return 61===t?(e.consume(t),I):Bu(t)?(i=S,_(t)):Vu(t)?(e.consume(t),S):j(t)}function I(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,P):Bu(t)?(i=I,_(t)):Vu(t)?(e.consume(t),I):(e.consume(t),E)}function P(t){return t===a?(e.consume(t),a=void 0,T):null===t?n(t):Bu(t)?(i=P,_(t)):(e.consume(t),P)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||$u(t)?j(t):(e.consume(t),E)}function T(e){return 47===e||62===e||$u(e)?j(e):n(e)}function A(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"),R}function R(t){return Vu(t)?Ku(e,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):F(t)}function F(t){return e.enter("htmlTextData"),i(t)}}};const _d={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&&Su(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}},u={type:"labelText",start:{...e[r+o+2][1].end},end:{...e[a-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=Iu(s,e.slice(r+1,r+o+3)),s=Iu(s,[["enter",u,t]]),s=Iu(s,Zu(t.parser.constructs.insideSpan.null,e.slice(r+o+4,a-3),t)),s=Iu(s,[["exit",u,t],e[a-2],e[a-1],["exit",c,t]]),s=Iu(s,e.slice(a+1)),s=Iu(s,[["exit",l,t]]),Su(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 u(t);return s=r.parser.defined.includes(Ru(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(Rd,c,s?c:u)(t):91===t?e.attempt(Fd,c,s?l:u)(t):s?c(t):u(t)}function l(t){return e.attempt(Dd,c,u)(t)}function c(e){return t(e)}function u(e){return a._balanced=!0,n(e)}}},Rd={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 $u(t)?wd(e,a)(t):a(t)}function a(t){return 41===t?c(t):yd(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return $u(t)?wd(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?vd(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return $u(t)?wd(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)}}},Fd={tokenize:function(e,t,n){const r=this;return function(t){return bd.call(r,e,a,s,"reference","referenceMarker","referenceString")(t)};function a(e){return r.parser.defined.includes(Ru(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},Dd={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 zd={name:"labelStartImage",resolveAll:_d.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 Od={name:"labelStartLink",resolveAll:_d.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 Ld={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Ku(e,t,"linePrefix")}}};const Md={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||Bu(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),a++,i):(e.exit("thematicBreakSequence"),Vu(t)?Ku(e,s,"whitespace")(t):s(t))}}};const Ud={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(rd,a,s);function a(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ku(e,t,"listItemIndent",r.containerState.size+1)(n)}function s(n){return r.containerState.furtherBlankLines||!Vu(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($d,t,i)(n))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ku(e,e.attempt(Ud,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:Lu(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(Md,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 Lu(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(rd,r.interrupt?n:c,e.attempt(Bd,d,u))}function c(e){return r.containerState.initialBlankLine=!0,s++,d(e)}function u(t){return Vu(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Bd={partial:!0,tokenize:function(e,t,n){const r=this;return Ku(e,function(e){const a=r.events[r.events.length-1];return!Vu(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},$d={partial:!0,tokenize:function(e,t,n){const r=this;return Ku(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 Vd={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"),Vu(t)?Ku(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||Bu(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const qd={tokenize:function(e){const t=this,n=e.attempt(rd,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,Ku(e,e.attempt(this.parser.constructs.flow,r,e.attempt(gd,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 Hd={resolveAll:Yd()},Wd=Kd("string"),Qd=Kd("text");function Kd(e){return{resolveAll:Yd("text"===e?Jd: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 Yd(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 Jd(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 Xd={42:Ud,43:Ud,45:Ud,48:Ud,49:Ud,50:Ud,51:Ud,52:Ud,53:Ud,54:Ud,55:Ud,56:Ud,57:Ud,62:ad},Gd={91:Nd},Zd={[-2]:cd,[-1]:cd,32:cd},ef={35:Cd,42:Md,45:[Vd,Md],60:Pd,61:Vd,95:Md,96:ld,126:ld},tf={38:id,92:sd},nf={[-5]:Ld,[-4]:Ld,[-3]:Ld,33:zd,38:id,42:ed,60:[nd,Ad],91:Od,92:[jd,sd],93:_d,95:ed,96:dd},rf={null:[ed,Hd]};var af=Object.freeze({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:Gd,disable:{null:[]},document:Xd,flow:ef,flowInitial:Zd,insideSpan:rf,string:tf,text:nf});function sf(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){Bu(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=f(),c.events.push(["enter",n,c]),o.push(n),n},exit:function(e){const t=o.pop();return t.end=f(),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:f,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("")}(d(e),t)},sliceStream:d,write:function(e){if(i=Iu(i,e),m(),null!==i[i.length-1])return[];return x(t,0),c.events=Zu(s,c.events,c),c.events}};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(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 f(){const{_bufferIndex:e,_index:t,line:n,column:a,offset:s}=r;return{_bufferIndex:e,_index:t,line:n,column:a,offset:s}}function m(){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){u=u(e)}function h(e,t){t.restore()}function g(e,t){return function(n,a,s){let i,u,d,m;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,u=0,0===e.length?s:h(e[u])}function h(e){return function(n){m=function(){const e=f(),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()}}(),d=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(d,m),a}function x(e){return m.restore(),++u<i.length?h(i[u]):s}}}function x(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&Su(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 of=/[\0\t\n\r]/g;const lf=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function cf(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return _u(n.slice(t?2:1),t?16:10)}return Cu(n)||e}const uf={}.hasOwnProperty;function df(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:f,listOrdered:s(ne,d),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:B,characterReferenceMarkerNumeric:B,characterReferenceValue:$,characterReference:V,codeFenced:l(g),codeFencedFence:h,codeFencedFenceInfo:m,codeFencedFenceMeta:p,codeFlowValue:S,codeIndented:l(x),codeText:l(A),codeTextData:S,data:S,definition:l(),definitionDestinationString:v,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(P),hardBreakTrailing:l(P),htmlFlow:l(E),htmlFlowData:S,htmlText:l(T),htmlTextData:S,image:l(R),label:D,labelText:F,lineEnding:I,link:l(_),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:U,resourceDestinationString:z,resourceTitleString:O,resource:L,setextHeading:l(j),setextHeadingLineSequence:k,setextHeadingText:N,strong:l(),thematicBreak:l()}};mf(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:u,data:n},l=[];let d=-1;for(;++d<e.length;)if("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)if("enter"===e[d][0])l.push(d);else{d=a(e,l.pop(),d)}for(d=-1;++d<e.length;){const n=t[e[d][0]];uf.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},s),e[d][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||hf).call(s,void 0,e[0])}for(r.position={start:ff(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:ff(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](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:ff(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+"` ("+Gc({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]||hf).call(this,e,r[0])}n.position.end=ff(e.end)}function u(){return wu(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){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=Ru(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 k(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function j(){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:ff(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=ff(e.end)}function I(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=ff(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 P(){this.data.atHardBreak=!0}function E(){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 A(){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 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 F(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(lf,cf)}(t),n.identifier=Ru(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 z(){const e=this.resume();this.stack[this.stack.length-1].url=e}function O(){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=Ru(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function B(e){this.data.characterReferenceType=e.type}function $(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;if(n)r=_u(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=Cu(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=ff(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(;!pd(e););return e}(function(e){const t={constructs:Eu([af,...(e||{}).extensions||[]]),content:n(Yu),defined:[],document:n(Ju),flow:n(qd),lazy:{},string:n(Wd),text:n(Qd)};return t;function n(e){return function(n){return sf(t,e,n)}}}(n).document().write(function(){let e,t=1,n="",r=!0;return function(a,s,i){const o=[];let l,c,u,d,f;for(a=n+("string"==typeof a?a.toString():new TextDecoder(s||void 0).decode(a)),u=0,n="",r&&(65279===a.charCodeAt(0)&&u++,r=void 0);u<a.length;){if(of.lastIndex=u,l=of.exec(a),d=l&&void 0!==l.index?l.index:a.length,f=a.charCodeAt(d),!l){n=a.slice(u);break}if(10===f&&u===d&&e)o.push(-3),e=void 0;else switch(e&&(o.push(-5),e=void 0),u<d&&(o.push(a.slice(u,d)),t+=d-u),f){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}u=d+1}return i&&(e&&o.push(-5),n&&o.push(n),o.push(null)),o}}()(e,t,!0))))}function ff(e){return{line:e.line,column:e.column,offset:e.offset}}function mf(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?mf(e,r):pf(e,r)}}function pf(e,t){let n;for(n in t)if(uf.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 hf(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Gc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Gc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Gc({start:t.start,end:t.end})+") is still open")}function gf(e){const t=this;t.parser=function(n){return df(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function xf(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 yf(e){const t=e.spread;return null==t?e.children.length>1:t}function bf(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const s=[];for(;r;)s.push(vf(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return s.push(vf(t.slice(a),a>0,!1)),s.join("")}function vf(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 wf={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=Qu(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 xf(e,t);const a={src:Qu(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:Qu(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 xf(e,t);const a={href:Qu(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:Qu(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=yf(n[r])}return t}(n):yf(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=Jc(t.children[1]),i=Yc(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:bf(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:Nf,yaml:Nf,definition:Nf,footnoteDefinition:Nf};function Nf(){}const kf="object"==typeof self?self:globalThis,jf=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 kf[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 kf[s](i),a)};return r})(new Map,e)(0),Cf="",{toString:Sf}={},{keys:If}=Object,Pf=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=Sf.call(e).slice(8,-1);switch(n){case"Array":return[1,Cf];case"Object":return[2,Cf];case"Date":return[3,Cf];case"RegExp":return[4,Cf];case"Map":return[5,Cf];case"Set":return[6,Cf];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Ef=([e,t])=>0===e&&("function"===t||"symbol"===t),Tf=(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]=Pf(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 If(r))!e&&Ef(Pf(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||!Ef(Pf(a))&&!Ef(Pf(i)))&&t.push([s(a),s(i)]);return n}case 6:{const t=[],n=a([i,t],r);for(const a of r)!e&&Ef(Pf(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 Af="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?jf(Tf(e,t)):structuredClone(e):(e,t)=>jf(Tf(e,t));function _f(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 Rf(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Ff=function(e){if(null==e)return zf;if("function"==typeof e)return Df(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Ff(e[n]);return Df(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 Df(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 Df(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function Df(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 zf(){return!0}const Of=[],Lf=!0,Mf=!1;function Uf(e,t,n,r){let a;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):a=t;const s=Ff(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(u,"name",{value:"node ("+a.type+(e?"<"+e+">":"")+")"})}return u;function u(){let c,u,d,f=Of;if((!t||s(a,o,l[l.length-1]||void 0))&&(f=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[Lf,e];return null==e?Of:[e]}(n(a,l)),f[0]===Mf))return f;if("children"in a&&a.children){const t=a;if(t.children&&"skip"!==f[0])for(u=(r?t.children.length:-1)+i,d=l.concat(t);u>-1&&u<t.children.length;){const n=t.children[u];if(c=e(n,u,d)(),c[0]===Mf)return c;u="number"==typeof c[1]?c[1]:u+i}}return f}}(e,void 0,[])()}function Bf(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),Uf(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 $f={}.hasOwnProperty,Vf={};function qf(e,t){e.position&&(t.position=function(e){const t=Jc(e),n=Yc(e);if(t&&n)return{start:t,end:n}}(e))}function Hf(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,Af(a)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function Wf(e,t){const n=t.data||{},r=!("value"in t)||$f.call(n,"hProperties")||$f.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 Qf(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 Kf(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function Yf(e,t){const n=function(e,t){const n=t||Vf,r=new Map,a=new Map,s=new Map,i={...wf,...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=Kf(a.value)),!Array.isArray(a)&&"element"===a.type)){const e=a.children[0];e&&"text"===e.type&&(e.value=Kf(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:Hf,definitionById:r,footnoteById:a,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=o.handlers[n];if($f.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=Af(n);return r.children=o.all(e),r}return Af(e)}return(o.options.unknownHandler||Wf)(o,e,t)},options:n,patch:qf,wrap:Qf};return Bf(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||_f,r=e.options.footnoteBackLabel||Rf,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=Qu(i.toLowerCase());let u=0;const d=[],f=e.footnoteCounts.get(i);for(;void 0!==f&&++u<=f;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const m=s[s.length-1];if(m&&"element"===m.type&&"p"===m.tagName){const e=m.children[m.children.length-1];e&&"text"===e.type?e.value+=" ":m.children.push({type:"text",value:" "}),m.children.push(...d)}else s.push(...d);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:{...Af(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 Jf(e,t){return e&&"run"in e?async function(n,r){const a=Yf(n,{file:r,...t});await e.run(a,r)}:function(n,r){return Yf(n,{file:r,...e||t})}}function Xf(e){if(e)throw e}var Gf,Zf;var em=function(){if(Zf)return Gf;Zf=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 Gf=function e(){var t,n,r,l,c,u,d=arguments[0],f=1,m=arguments.length,p=!1;for("boolean"==typeof d&&(p=d,d=arguments[1]||{},f=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f<m;++f)if(null!=(t=arguments[f]))for(n in t)r=o(d,n),d!==(l=o(t,n))&&(p&&l&&(s(l)||(c=a(l)))?(c?(c=!1,u=r&&a(r)?r:[]):u=r&&s(r)?r:{},i(d,{name:n,newValue:e(p,u,l)})):void 0!==l&&i(d,{name:n,newValue:l}));return d},Gf}(),tm=St(em);function nm(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 rm(){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 am={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');sm(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(sm(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){sm(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;)sm(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){sm(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 sm(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const im={cwd:function(){return"/"}};function om(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function lm(e){if("string"==typeof e)e=new URL(e);else if(!om(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 cm=["history","path","basename","stem","extname","dirname"];class um{constructor(e){let t;t=e?om(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?"":im.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<cm.length;){const e=cm[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)cm.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?am.basename(this.path):void 0}set basename(e){fm(e,"basename"),dm(e,"basename"),this.path=am.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?am.dirname(this.path):void 0}set dirname(e){mm(this.basename,"dirname"),this.path=am.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?am.extname(this.path):void 0}set extname(e){if(dm(e,"extname"),mm(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=am.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){om(e)&&(e=lm(e)),fm(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?am.basename(this.path,this.extname):void 0}set stem(e){fm(e,"stem"),dm(e,"stem"),this.path=am.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 nu(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 dm(e,t){if(e&&e.includes(am.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+am.sep+"`")}function fm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function mm(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const pm=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},hm={}.hasOwnProperty;class gm extends pm{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=rm()}copy(){const e=new gm;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(tm(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(vm("data",this.frozen),this.namespace[e]=t,this):hm.call(this.namespace,e)&&this.namespace[e]||void 0:e?(vm("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=km(e),n=this.parser||this.Parser;return ym("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),ym("process",this.parser||this.Parser),bm("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,a){const s=km(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(),ym("processSync",this.parser||this.Parser),bm("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,Xf(e),t=r}),Nm("processSync","process",n),t}run(e,t,n){wm(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=km(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){Xf(e),n=t,r=!0}),Nm("runSync","run",r),n}stringify(e,t){this.freeze();const n=km(t),r=this.compiler||this.Compiler;return bm("stringify",r),wm(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(vm("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=tm(!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];nm(i)&&nm(r)&&(r=tm(!0,i,r)),n[a]=[e,r,...s]}}}}const xm=(new gm).freeze();function ym(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function bm(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function vm(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 wm(e){if(!nm(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function Nm(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function km(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new um(e)}const jm=[],Cm={allowDangerousHtml:!0},Sm=/^(https?|ircs?|mailto|xmpp)$/i,Im=[{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 Pm(e){const t=function(e){const t=e.rehypePlugins||jm,n=e.remarkPlugins||jm,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Cm}:Cm,a=xm().use(gf).use(n).use(Jf,r).use(t);return a}(e),n=function(e){const t=e.children||"",n=new um;"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||Em;for(const u of Im)Object.hasOwn(t,u.from)&&Jl((u.from,u.to&&u.to,u.id));return Bf(e,c),cu(e,{Fragment:Ft.Fragment,components:a,ignoreInvalidStyle:!0,jsx:Ft.jsx,jsxs:Ft.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 bu)if(Object.hasOwn(bu,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=bu[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 Em(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||Sm.test(e.slice(0,t))?e:""}function Tm(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 Am(e,t,n){const r=Ff((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([_m(e[0]),Rm(e[1])])}return t}(t);let s=-1;for(;++s<a.length;)Uf(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,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){const n=d.index,a={index:d.index,input:d.input,stack:[...t,e]};let s=i(...d,a);if("string"==typeof s&&(s=s.length>0?{type:"text",value:s}:void 0),!1===s?r.lastIndex=n+1:(o!==n&&u.push({type:"text",value:e.value.slice(o,n)}),Array.isArray(s)?u.push(...s):s&&u.push(s),o=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}c?(o<e.value.length&&u.push({type:"text",value:e.value.slice(o)}),n.children.splice(l,1,...u)):u=[e];return l+u.length}(e,t)}}function _m(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 Rm(e){return"function"==typeof e?e:function(){return e}}const Fm="phrasing",Dm=["autolink","link","image","label"];function zm(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Om(e){this.config.enter.autolinkProtocol.call(this,e)}function Lm(e){this.config.exit.autolinkProtocol.call(this,e)}function Mm(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 Um(e){this.config.exit.autolinkEmail.call(this,e)}function Bm(e){this.exit(e)}function $m(e){Am(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Vm],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,qm]],{ignore:["link","linkReference"]})}function Vm(e,t,n,r,a){let s="";if(!Hm(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=Tm(e,"(");let s=Tm(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 qm(e,t,n,r){return!(!Hm(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Hm(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||Hu(n)||qu(n))&&(!t||47!==n)}function Wm(){this.buffer()}function Qm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Km(){this.buffer()}function Ym(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Jm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ru(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Xm(e){this.exit(e)}function Gm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ru(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Zm(e){this.exit(e)}function ep(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 tp(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?rp:np)));return o(),i},footnoteReference:ep},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function np(e,t,n){return 0===t?e:rp(e,t,n)}function rp(e,t,n){return(n?"":" ")+e}ep.peek=function(){return"["};const ap=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function sp(e){this.enter({type:"delete",children:[]},e)}function ip(e){this.exit(e)}function op(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 lp(e){return e.length}function cp(e){return null==e?"":String(e)}function up(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 dp(e,t,n){return">"+(n?"":" ")+e}function fp(e,t){return mp(e,t.inConstruct,!0)&&!mp(e,t.notInConstruct,!1)}function mp(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 pp(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if("\n"===n.unsafe[a].character&&fp(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function hp(e,t,n){return(n?"":" ")+e}function gp(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 xp(e){return"&#x"+e.toString(16).toUpperCase()+";"}function yp(e,t,n){const r=Gu(e),a=Gu(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 bp(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),u=yp(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=xp(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=yp(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+xp(d));const m=i.move(a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}function vp(e){return e.value||""}function wp(e,t,n,r){const a=gp(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 Np(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 u=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=u,s(),"full"!==a&&c&&c===d?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(d+"]"),l}function kp(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 jp(e,t){const n=wu(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 Cp(e,t,n,r){const a=gp(n),s='"'===a?"Quote":"Apostrophe",i=n.createTracker(r);let o,l;if(jp(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 Sp(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 u=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=u,s(),"full"!==a&&c&&c===d?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(d+"]"),l}function Ip(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 Pp(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}op.peek=function(){return"~"},bp.peek=function(e,t,n){return n.options.emphasis||"*"},vp.peek=function(){return"<"},wp.peek=function(){return"!"},Np.peek=function(){return"!"},kp.peek=function(){return"`"},Cp.peek=function(e,t,n){return jp(e,n)?"<":"["},Sp.peek=function(){return"["};const Ep=Ff(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Tp(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),u=yp(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=xp(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=yp(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+xp(d));const m=i.move(a+a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}Tp.peek=function(e,t,n){return n.options.strong||"*"};const Ap={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()),dp);return a(),i},break:pp,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,hp);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 u=o.move(l);if(e.lang){const t=n.enter(`codeFencedLang${i}`);u+=o.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${i}`);u+=o.move(" "),u+=o.move(n.safe(e.meta,{before:u,after:"\n",encode:["`"],...o.current()})),t()}return u+=o.move("\n"),s&&(u+=o.move(s+"\n")),u+=o.move(l),c(),u},definition:function(e,t,n,r){const a=gp(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:bp,hardBreak:pp,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 Bf(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,Mf}),Boolean((!e.depth||e.depth<3)&&wu(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=xp(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),o(),c},html:vp,image:wp,imageReference:Np,inlineCode:kp,link:Cp,linkReference:Sp,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):Ip(n);const o=e.ordered?"."===i?")":".":function(e){const t=Ip(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),Pp(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||Ip(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 Ep(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:Tp,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(Pp(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 _p(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 Rp(e){this.exit(e),this.data.inTable=void 0}function Fp(e){this.enter({type:"tableRow",children:[]},e)}function Dp(e){this.exit(e)}function zp(e){this.enter({type:"tableCell",children:[]},e)}function Op(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Lp));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Lp(e,t){return"|"===t?t:e}function Mp(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=Ap.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||lp,s=[],i=[],o=[],l=[];let c=0,u=-1;for(;++u<e.length;){const t=[],r=[];let s=-1;for(e[u].length>c&&(c=e[u].length);++s<e[u].length;){const i=cp(e[u][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[u]=t,o[u]=r}let d=-1;if("object"==typeof r&&"length"in r)for(;++d<c;)s[d]=up(r[d]);else{const e=up(r);for(;++d<c;)s[d]=e}d=-1;const f=[],m=[];for(;++d<c;){const e=s[d];let t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let a=!1===n.alignDelimiters?1:Math.max(1,l[d]-t.length-r.length);const i=t+"-".repeat(a)+r;!1!==n.alignDelimiters&&(a=t.length+a+r.length,a>l[d]&&(l[d]=a),m[d]=a),f[d]=i}i.splice(1,0,f),o.splice(1,0,m),u=-1;const p=[];for(;++u<i.length;){const e=i[u],t=o[u];d=-1;const r=[];for(;++d<c;){const a=e[d]||"";let i="",o="";if(!1!==n.alignDelimiters){const e=l[d]-(t[d]||0),n=s[d];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||d||r.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===a||!1===n.delimiterStart&&!d||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&&d===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 Up(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function Bp(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 $p(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=Ap.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const Vp={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},qp={tokenize:function(e,t,n){let r,a,s;return i;function i(t){return 46===t||95===t?e.check(Wp,l,o)(t):null===t||$u(t)||Hu(t)||45!==t&&qu(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},Hp={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(Wp,t,s)(i):null===i||$u(i)||Hu(i)?t(i):(e.consume(i),a)}function s(t){return 41===t&&r++,e.consume(t),a}},partial:!0},Wp={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||$u(i)||Hu(i)?t(i):n(i)}function a(e){return null===e||40===e||91===e||$u(e)||Hu(e)?t(e):r(e)}function s(e){return Fu(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),r):Fu(t)?(e.consume(t),i):n(t)}},partial:!0},Qp={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return Du(e)?n(e):t(e)}},partial:!0},Kp={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){if(87!==t&&119!==t||!Zp.call(r,r.previous)||rh(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Vp,e.attempt(qp,e.attempt(Hp,a),n),n)(t)};function a(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:Zp},Yp={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let a="",s=!1;return function(t){if((72===t||104===t)&&eh.call(r,r.previous)&&!rh(r.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if(Fu(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||Ou(t)||$u(t)||Hu(t)||qu(t)?n(t):e.attempt(qp,e.attempt(Hp,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:eh},Jp={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let a,s;return function(t){if(!nh(t)||!th.call(r,r.previous)||rh(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return nh(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(Qp,c,l)(t):45===t||95===t||Du(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&&Fu(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:th},Xp={};let Gp=48;for(;Gp<123;)Xp[Gp]=Jp,Gp++,58===Gp?Gp=65:91===Gp&&(Gp=97);function Zp(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||$u(e)}function eh(e){return!Fu(e)}function th(e){return!(47===e||nh(e))}function nh(e){return 43===e||45===e||46===e||95===e||Du(e)}function rh(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}Xp[43]=Jp,Xp[45]=Jp,Xp[46]=Jp,Xp[95]=Jp,Xp[72]=[Jp,Yp],Xp[104]=[Jp,Yp],Xp[87]=[Jp,Kp],Xp[119]=[Jp,Kp];const ah={tokenize:function(e,t,n){const r=this;return Ku(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 sh(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=Ru(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 ih(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 oh(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||$u(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return a.includes(Ru(r.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return $u(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 lh(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||$u(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=Ru(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return $u(t)||(i=!0),o++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a.includes(s)||a.push(s),Ku(e,f,"gfmFootnoteDefinitionWhitespace")):n(t)}function f(e){return t(e)}}function ch(e,t,n){return e.check(rd,t,e.attempt(ah,t,n))}function uh(e){e.exit("gfmFootnoteDefinition")}function dh(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=Gu(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"),u=Gu(s);return c._open=!u||2===u&&Boolean(l),c._close=!l||2===l&&Boolean(u),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&&Su(i,i.length,0,Zu(o,e.slice(r+1,n),t)),Su(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",a,t]]),Su(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 fh{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 mh(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 ph(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):Bu(t)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):Vu(t)?Ku(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||$u(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter("tableDelimiterRow"),a=!1,Vu(t)?Ku(e,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):f(t))}function f(t){return 45===t||58===t?p(t):124===t?(a=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),m):b(t)}function m(t){return Vu(t)?Ku(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||Bu(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 Vu(t)?Ku(e,y,"whitespace")(t):y(t)}function y(n){return 124===n?f(n):(null===n||Bu(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||Bu(n)?(e.exit("tableRow"),t(n)):Vu(n)?Ku(e,w,"whitespace")(n):(e.enter("data"),N(n))}function N(t){return null===t||124===t||$u(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?k:N)}function k(t){return 92===t||124===t?(e.consume(t),N):N(t)}}function hh(e,t){let n,r,a,s=-1,i=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0;const f=new fh;for(;++s<e.length;){const m=e[s],p=m[1];"enter"===m[0]?"tableHead"===p.type?(u=!1,0!==d&&(xh(f,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},f.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],u&&(u=!1,r={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},f.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=gh(f,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=gh(f,t,l,o,void 0,a),l=[0,0,0,0]),c[2]=s)):"tableHead"===p.type?(u=!0,d=s):"tableRow"===p.type||"tableDelimiterRow"===p.type?(d=s,0!==l[1]?(c[0]=c[1],a=gh(f,t,l,o,s,a)):0!==c[1]&&(a=gh(f,t,c,o,s,a)),o=0):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type||(c[3]=s)}for(0!==d&&xh(f,t,d,n,r),f.consume(t.events),s=-1;++s<t.events.length;){const e=t.events[s];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=mh(t.events,s))}return e}function gh(e,t,n,r,a,s){const i=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},yh(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=yh(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=yh(t.events,n[2]),s=yh(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({},yh(t.events,a)),e.add(a,0,[["exit",s,t]]),s=void 0),s}function xh(e,t,n,r,a){const s=[],i=yh(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 yh(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const bh={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 $u(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 Bu(r)?t(r):Vu(r)?e.check({tokenize:vh},t,n)(r):n(r)}}};function vh(e,t,n){return Ku(e,function(e){return null===e?n(e):t(e)},"whitespace")}const wh={};function Nh(e){const t=e||wh,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return Eu([{text:Xp},{document:{91:{name:"gfmFootnoteDefinition",tokenize:lh,continuation:{tokenize:ch},exit:uh}},text:{91:{name:"gfmFootnoteCall",tokenize:oh},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:sh,resolveTo:ih}}},dh(e),{flow:{null:{name:"table",tokenize:ph,resolveAll:hh}}},{text:{91:bh}}])}(t)),a.push([{transforms:[$m],enter:{literalAutolink:zm,literalAutolinkEmail:Om,literalAutolinkHttp:Om,literalAutolinkWww:Om},exit:{literalAutolink:Bm,literalAutolinkEmail:Um,literalAutolinkHttp:Lm,literalAutolinkWww:Mm}},{enter:{gfmFootnoteCallString:Wm,gfmFootnoteCall:Qm,gfmFootnoteDefinitionLabelString:Km,gfmFootnoteDefinition:Ym},exit:{gfmFootnoteCallString:Jm,gfmFootnoteCall:Xm,gfmFootnoteDefinitionLabelString:Gm,gfmFootnoteDefinition:Zm}},{canContainEols:["delete"],enter:{strikethrough:sp},exit:{strikethrough:ip}},{enter:{table:_p,tableData:zp,tableHeader:zp,tableRow:Fp},exit:{codeText:Op,table:Rp,tableData:Dp,tableHeader:Dp,tableRow:Dp}},{exit:{taskListCheckValueChecked:Up,taskListCheckValueUnchecked:Up,paragraph:Bp}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Fm,notInConstruct:Dm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Fm,notInConstruct:Dm},{character:":",before:"[ps]",after:"\\/",inConstruct:Fm,notInConstruct:Dm}]},tp(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:ap}],handlers:{delete:op}},Mp(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:$p}}]}}(t))}function kh({content:e,className:t}){return Ft.jsx("div",{className:zt("prose prose-sm max-w-none",t),children:Ft.jsx(Pm,{remarkPlugins:[Nh],components:{h1:({children:e})=>Ft.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>Ft.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>Ft.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>Ft.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>Ft.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>Ft.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>Ft.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...n})=>e?Ft.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...n,children:t}):Ft.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})=>Ft.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>Ft.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>Ft.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>Ft.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>Ft.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}function jh(){const[e,t]=a(!1),[n,r]=a(""),{messages:s,isLoading:o,error:l,sendMessage:u}=Kl(),d=c(null),f=c(null);i(()=>{if(d.current){const e=d.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[s]),i(()=>{e&&f.current&&f.current.focus()},[e]),i(()=>{const n=n=>{"Escape"===n.key&&e&&t(!1)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e]);const m=()=>{n.trim()&&!o&&(u(n),r(""))};return Ft.jsxs(Ft.Fragment,{children:[Ft.jsx($t,{onClick:()=>t(!e),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e?Ft.jsx(N,{className:"h-6 w-6"}):Ft.jsx(Ve,{className:"h-6 w-6"})}),e&&Ft.jsxs(Qt,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[Ft.jsxs(Kt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[Ft.jsx(Yt,{className:"text-lg font-semibold",children:"Chat Assistant"}),Ft.jsx($t,{variant:"ghost",size:"icon",onClick:()=>t(!1),className:"h-8 w-8",children:Ft.jsx(N,{className:"h-4 w-4"})})]}),Ft.jsxs(Xt,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[Ft.jsx(es,{ref:d,className:"flex-1 px-4",children:Ft.jsxs("div",{className:"space-y-4 py-4",children:[s.map(e=>Ft.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:Ft.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?Ft.jsx(kh,{content:e.content}):Ft.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),o&&Ft.jsx("div",{className:"flex justify-start",children:Ft.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:Ft.jsxs("div",{className:"flex space-x-2",children:[Ft.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),Ft.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),Ft.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),l&&Ft.jsx("div",{className:"text-center text-sm text-destructive py-2",children:l})]})}),Ft.jsx("div",{className:"border-t p-4",children:Ft.jsxs("div",{className:"flex space-x-2",children:[Ft.jsx(qt,{ref:f,value:n,onChange:e=>r(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),m())},placeholder:"Digite sua mensagem...",disabled:o,className:"flex-1"}),Ft.jsx($t,{onClick:m,disabled:o||!n.trim(),size:"icon",children:Ft.jsx(qe,{className:"h-4 w-4"})})]})})]})]})]})}const Ch=e=>e?.placeId||null,Sh=e=>e?.placeName||null;var Ih=Object.freeze({__proto__:null,getUserPlaceData:e=>({placeId:Ch(e),placeName:Sh(e)}),getUserPlaceId:Ch,getUserPlaceName:Sh});export{Er as AUTH_CONFIG,Ws as Accordion,Ys as AccordionContent,Qs as AccordionItem,Ks as AccordionTrigger,Vt as ActionButton,qa as ActionMenuItems,ll as ActionMenuPrimitive,zs as Alert,Ls as AlertDescription,ta as AlertDialog,ua as AlertDialogAction,da as AlertDialogCancel,sa as AlertDialogContent,ca as AlertDialogDescription,oa as AlertDialogFooter,ia as AlertDialogHeader,aa as AlertDialogOverlay,ra as AlertDialogPortal,la as AlertDialogTitle,na as AlertDialogTrigger,Os as AlertTitle,zl as AppHeader,Wl as AppLayout,Hl as AppSidebar,Js as AspectRatio,Nr as AuthErrorInterceptor,Xr as AuthProvider,Yr as AuthService,Xs as Avatar,Zs as AvatarFallback,Gs as AvatarImage,En as Badge,xs as BaseForm,ei as Breadcrumb,ii as BreadcrumbEllipsis,ni as BreadcrumbItem,ri as BreadcrumbLink,ti as BreadcrumbList,ai as BreadcrumbPage,si as BreadcrumbSeparator,vs as BulkActionBar,$t as Button,Tr as CRUD_CONFIG,xi as Calendar,Ms as CallbackPage,Qt as Card,Xt as CardContent,Jt as CardDescription,Gt as CardFooter,Kt as CardHeader,ka as CardSkeleton,Yt as CardTitle,ul as CardsPrimitive,jh as ChatbotPage,Sn as Checkbox,yi as Collapsible,vi as CollapsibleContent,bi as CollapsibleTrigger,Za as ColorPicker,as as Command,ss as CommandDialog,ls as CommandEmpty,cs as CommandGroup,is as CommandInput,ds as CommandItem,os as CommandList,us as CommandSeparator,fs as CommandShortcut,dl as CrudCards,Ss as CrudPageInternal,bs as CrudPagination,Qa as CrudTable,wi as DataList,fa as DeleteConfirmationDialog,Zt as Dialog,nn as DialogClose,an as DialogContent,cn as DialogDescription,on as DialogFooter,sn as DialogHeader,rn as DialogOverlay,tn as DialogPortal,ln as DialogTitle,en as DialogTrigger,Ea as DropdownMenu,Ma as DropdownMenuCheckboxItem,Oa as DropdownMenuContent,Aa as DropdownMenuGroup,La as DropdownMenuItem,Ba as DropdownMenuLabel,_a as DropdownMenuPortal,Fa as DropdownMenuRadioGroup,Ua as DropdownMenuRadioItem,$a as DropdownMenuSeparator,Va as DropdownMenuShortcut,Ra as DropdownMenuSub,za as DropdownMenuSubContent,Da as DropdownMenuSubTrigger,Ta as DropdownMenuTrigger,Pa as EmptyState,ps as EntitySelect,Ql as ErrorBoundary,Cs as FilterBar,cl as FilterBarPrimitive,un as Form,xn as FormControl,fn as FormField,hn as FormItem,gn as FormLabel,yn as FormMessage,ja as FormSkeleton,ji as Grid,Ca as HeaderSkeleton,rs as IconPicker,qt as Input,Wt as Label,_n as LoadingState,Us as LoginPage,Or as MESSAGES,Cl as ManagerSelectionDialog,kh as MarkdownMessage,_l as NavigationProvider,Ci as PageBreadcrumb,Ii as Pagination,Pi as PaginationContent,Ri as PaginationEllipsis,Ei as PaginationItem,Ti as PaginationLink,_i as PaginationNext,Ai as PaginationPrevious,ys as PaginationPrimitive,El as PlaceManagerBadge,Sl as PlaceManagerButton,kl as PlaceManagerService,bl as PlaceService,Pl as PlacesPage,Ya as Popover,Xa as PopoverContent,Ja as PopoverTrigger,Fi as Progress,Fs as ProtectedRoute,Rr as QUERY_KEYS,Vr as QualiexEnrichmentService,jr as QualiexErrorInterceptor,gs as QualiexUserField,Di as RadioGroup,zi as RadioGroupItem,Ar as SEARCH_CONFIG,es as ScrollArea,ts as ScrollBar,bn as Select,jn as SelectContent,Cn as SelectItem,wn as SelectTrigger,vn as SelectValue,Oi as Separator,Li as Sheet,Ui as SheetClose,qi as SheetContent,Ki as SheetDescription,Wi as SheetFooter,Hi as SheetHeader,$i as SheetOverlay,Bi as SheetPortal,Qi as SheetTitle,Mi as SheetTrigger,ro as Sidebar,fo as SidebarContent,co as SidebarFooter,mo as SidebarGroup,ho as SidebarGroupAction,go as SidebarGroupContent,po as SidebarGroupLabel,lo as SidebarHeader,oo as SidebarInput,io as SidebarInset,xo as SidebarMenu,wo as SidebarMenuAction,No as SidebarMenuBadge,vo as SidebarMenuButton,yo as SidebarMenuItem,ko as SidebarMenuSkeleton,jo as SidebarMenuSub,So as SidebarMenuSubButton,Co as SidebarMenuSubItem,no as SidebarProvider,so as SidebarRail,uo as SidebarSeparator,Sa as SidebarSkeleton,ao as SidebarTrigger,wa as Skeleton,Io as Slider,Po as SonnerToaster,An as Spinner,js as Stack,Ko as Switch,tl as TabPageContent,el as TabPageHeader,Zo as TabPageLayout,ma as Table,ha as TableBody,va as TableCaption,ba as TableCell,ga as TableFooter,ya as TableHead,pa as TableHeader,ol as TablePrimitive,xa as TableRow,Ha as TableRowActions,Na as TableSkeleton,Yo as Tabs,Go as TabsContent,Jo as TabsList,Xo as TabsTrigger,In as Textarea,Hn as Toast,Wn as ToastAction,Qn as ToastClose,Yn as ToastDescription,$n as ToastProvider,Kn as ToastTitle,Vn as ToastViewport,Jn as Toaster,rl as Toggle,sl as ToggleGroup,il as ToggleGroupItem,ir as TokenManager,Gn as TokenService,Ji as Tooltip,Gi as TooltipContent,Yi as TooltipProvider,Xi as TooltipTrigger,Ul as assets,Pn as badgeVariants,Bt as buttonVariants,zt as cn,Is as createCrudPage,ml as createCrudRoutingConfig,fl as createRoutingHandlers,Wr as createService,Ps as createSimpleSaveHandler,ea as createSimpleService,_s as crudPresets,Ut as debounce,Mr as deriveEmailField,Lr as deriveNameField,Ur as deriveUsernameField,cr as errorService,Mt as formatCurrency,Lt as formatDatetime,Es as generateCrudConfig,Dr as getQualiexConfig,gr as getSupabaseClient,Dt as handleExternalLink,_r as isDevEnvironment,Bl as logoSrc,vl as placeService,Ir as qualiexApi,Br as resolveFieldMappings,zr as setQualiexConfig,Hs as setupQualiexCore,$l as smallLogoSrc,Un as toast,nl as toggleVariants,Ot as trimTextFields,Ol as useActiveModules,Gr as useAuth,Ka as useBaseForm,Zr as useCrud,Dl as useDebounce,Rl as useNavigation,Kl as useOpenAIChat,qs as usePageMetadata,Fl as usePageTitle,Ll as usePermissionQuery,jl as usePlaceManagers,hs as useQualiexUsers,Si as useRouteBreadcrumbs,to as useSidebar,Bn as useToast,gl as userPlaceService,Rs as withPreset};
|
|
10
|
+
*/function Dt(){return At||(At=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"),u=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),m=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 u:return"Suspense";case d: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 f:var t=e.displayName||null;return null!==t?t:v(e.type)||"Memo";case m: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,k,j,C,S,I,E=Object.assign,T=0;function P(){}P.__reactDisabledLog=!0;var A,R=g.ReactCurrentDispatcher;function _(e,t,n){if(void 0===A)try{throw Error()}catch(a){var r=a.stack.trim().match(/\n( *(at )?)/);A=r&&r[1]||""}return"\n"+A+e}var D,F=!1,z="function"==typeof WeakMap?WeakMap:Map;function O(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=R.current,R.current=null,function(){if(0===T){w=console.log,N=console.info,k=console.warn,j=console.error,C=console.group,S=console.groupCollapsed,I=console.groupEnd;var e={configurable:!0,enumerable:!0,value:P,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,u=l.length-1;c>=1&&u>=0&&o[c]!==l[u];)u--;for(;c>=1&&u>=0;c--,u--)if(o[c]!==l[u]){if(1!==c||1!==u)do{if(c--,--u<0||o[c]!==l[u]){var d="\n"+o[c].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{F=!1,R.current=a,function(){if(0===--T){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},e,{value:w}),info:E({},e,{value:N}),warn:E({},e,{value:k}),error:E({},e,{value:j}),group:E({},e,{value:C}),groupCollapsed:E({},e,{value:S}),groupEnd:E({},e,{value:I})})}T<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=s}var f=e?e.displayName||e.name:"",m=f?_(f):"";return"function"==typeof e&&D.set(e,m),m}function L(e,t,n){if(null==e)return"";if("function"==typeof e)return O(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if("string"==typeof e)return _(e);switch(e){case u:return _("Suspense");case d:return _("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return O(e.render,!1);case f:return L(e.type,t,n);case m:var r=e,a=r._payload,s=r._init;try{return L(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=L(e.type,e._source,t?t.type:null);$.setExtraStackFrame(n)}else $.setExtraStackFrame(null)}var V=Array.isArray;function H(e){return V(e)}function q(e){return""+e}function W(e){if(function(e){try{return q(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)),q(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 u=e.defaultProps;for(i in u)void 0===o[i]&&(o[i]=u[i])}if(l||c){var d="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,d),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,d)}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=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(H(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!==f)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 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?",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===u||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||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 k;N+=re(),null===e?k="null":H(e)?k="array":void 0!==e&&e.$$typeof===n?(k="<"+(v(e.type)||"Unknown")+" />",N=" Did you accidentally export a JSX literal instead of a component?"):k=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",k,N)}var j=X(e,t,r,g,b);if(null==j)return j;if(w){var C=t.children;if(void 0!==C)if(h)if(H(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 I=v(e),E=Object.keys(t).filter(function(e){return"key"!==e}),T=E.length>0?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}";if(!le[I+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,I,E.length>0?"{"+E.join(": ..., ")+": ...}":"{}",I),le[I+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))}(j):oe(j),j}var ue=function(e,t,n){return ce(e,t,n,!1)},de=function(e,t,n){return ce(e,t,n,!0)};_t.Fragment=a,_t.jsx=ue,_t.jsxs=de}()),_t}var Ft=(Rt||(Rt=1,"production"===process.env.NODE_ENV?Tt.exports=function(){if(Et)return Pt;Et=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,u=null;for(o in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=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:u,props:l,_owner:s.current}}return Pt.Fragment=r,Pt.jsx=o,Pt.jsxs=o,Pt}():Tt.exports=Dt()),Tt.exports);function zt(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 Ot(...e){return h(p(e))}const Lt=e=>{if(null==e)return e;if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(Lt);if("object"==typeof e&&e.constructor===Object){const t={};for(const[n,r]of Object.entries(e))t[n]=Lt(r);return t}return e},Mt=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"})}`},Ut=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),$t=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},Bt=m("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"}}),Vt=e.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...a},s)=>{const i=r?d:"button";return Ft.jsx(i,{className:Ot(Bt({variant:t,size:n,className:e})),ref:s,...a})});Vt.displayName="Button";const Ht=t.forwardRef(({variant:e="default",className:t,children:n,...r},a)=>Ft.jsx(Vt,{ref:a,variant:"action",size:"sm",className:Ot("h-7 px-2 text-xs",t),...r,children:n||Ft.jsx(w,{size:12})}));Ht.displayName="ActionButton";const qt=e.forwardRef(({className:e,type:t,...n},r)=>Ft.jsx("input",{type:t,className:Ot("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}));qt.displayName="Input";const Wt=m("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Qt=e.forwardRef(({className:e,...t},n)=>Ft.jsx(We.Root,{ref:n,className:Ot(Wt(),e),...t}));Qt.displayName=We.Root.displayName;const Kt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Kt.displayName="Card";const Yt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("flex flex-col space-y-1.5 p-6",e),...t}));Yt.displayName="CardHeader";const Jt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("h3",{ref:n,className:Ot("text-2xl font-semibold leading-none tracking-tight",e),...t}));Jt.displayName="CardTitle";const Xt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("p",{ref:n,className:Ot("text-sm text-muted-foreground",e),...t}));Xt.displayName="CardDescription";const Gt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("p-6 pt-0",e),...t}));Gt.displayName="CardContent";const Zt=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("flex items-center p-6 pt-0",e),...t}));Zt.displayName="CardFooter";const en=Qe.Root,tn=Qe.Trigger,nn=Qe.Portal,rn=Qe.Close,an=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Qe.Overlay,{ref:n,className:Ot("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}));an.displayName=Qe.Overlay.displayName;const sn=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(nn,{children:[Ft.jsx(an,{}),Ft.jsxs(Qe.Content,{ref:r,className:Ot("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 overflow-hidden",e),...n,children:[t,Ft.jsxs(Qe.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:[Ft.jsx(N,{className:"h-4 w-4"}),Ft.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));sn.displayName=Qe.Content.displayName;const on=({className:e,...t})=>Ft.jsx("div",{className:Ot("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});on.displayName="DialogHeader";const ln=({className:e,...t})=>Ft.jsx("div",{className:Ot("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});ln.displayName="DialogFooter";const cn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Qe.Title,{ref:n,className:Ot("text-lg font-semibold leading-none tracking-tight",e),...t}));cn.displayName=Qe.Title.displayName;const un=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Qe.Description,{ref:n,className:Ot("text-sm text-muted-foreground",e),...t}));un.displayName=Qe.Description.displayName;const dn=Ye,fn=e.createContext({}),mn=({...e})=>Ft.jsx(fn.Provider,{value:{name:e.name},children:Ft.jsx(Je,{...e})}),pn=()=>{const t=e.useContext(fn),n=e.useContext(hn),{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}},hn=e.createContext({}),gn=e.forwardRef(({className:t,...n},r)=>{const a=e.useId();return Ft.jsx(hn.Provider,{value:{id:a},children:Ft.jsx("div",{ref:r,className:Ot("space-y-2",t),...n})})});gn.displayName="FormItem";const xn=e.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:a}=pn();return Ft.jsx(Qt,{ref:n,className:Ot(r&&"text-destructive",e),htmlFor:a,...t})});xn.displayName="FormLabel";const yn=e.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:a,formMessageId:s}=pn();return Ft.jsx(d,{ref:t,id:r,"aria-describedby":n?`${a} ${s}`:`${a}`,"aria-invalid":!!n,...e})});yn.displayName="FormControl";e.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=pn();return Ft.jsx("p",{ref:n,id:r,className:Ot("text-sm text-muted-foreground",e),...t})}).displayName="FormDescription";const bn=e.forwardRef(({className:e,children:t,...n},r)=>{const{error:a,formMessageId:s}=pn(),i=a?String(a?.message):t;return i?Ft.jsx("p",{ref:r,id:s,className:Ot("text-sm font-medium text-destructive",e),...n,children:i}):null});bn.displayName="FormMessage";const vn=Xe.Root,wn=Xe.Value,Nn=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(Xe.Trigger,{ref:r,className:Ot("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,Ft.jsx(Xe.Icon,{asChild:!0,children:Ft.jsx(k,{className:"h-4 w-4 opacity-50"})})]}));Nn.displayName=Xe.Trigger.displayName;const kn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Xe.ScrollUpButton,{ref:n,className:Ot("flex cursor-default items-center justify-center py-1",e),...t,children:Ft.jsx(j,{className:"h-4 w-4"})}));kn.displayName=Xe.ScrollUpButton.displayName;const jn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Xe.ScrollDownButton,{ref:n,className:Ot("flex cursor-default items-center justify-center py-1",e),...t,children:Ft.jsx(k,{className:"h-4 w-4"})}));jn.displayName=Xe.ScrollDownButton.displayName;const Cn=e.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>Ft.jsx(Xe.Portal,{children:Ft.jsxs(Xe.Content,{ref:a,className:Ot("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:[Ft.jsx(kn,{}),Ft.jsx(Xe.Viewport,{className:Ot("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),Ft.jsx(jn,{})]})}));Cn.displayName=Xe.Content.displayName;e.forwardRef(({className:e,...t},n)=>Ft.jsx(Xe.Label,{ref:n,className:Ot("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=Xe.Label.displayName;const Sn=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(Xe.Item,{ref:r,className:Ot("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:[Ft.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ft.jsx(Xe.ItemIndicator,{children:Ft.jsx(C,{className:"h-4 w-4"})})}),Ft.jsx(Xe.ItemText,{children:t})]}));Sn.displayName=Xe.Item.displayName;e.forwardRef(({className:e,...t},n)=>Ft.jsx(Xe.Separator,{ref:n,className:Ot("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=Xe.Separator.displayName;const In=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ge.Root,{ref:n,className:Ot("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:Ft.jsx(Ge.Indicator,{className:Ot("flex items-center justify-center text-current"),children:Ft.jsx(C,{className:"h-4 w-4"})})}));In.displayName=Ge.Root.displayName;const En=e.forwardRef(({className:e,...t},n)=>Ft.jsx("textarea",{className:Ot("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}));En.displayName="Textarea";const Tn=m("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"}}),Pn=e.forwardRef(({className:e,variant:t,...n},r)=>Ft.jsx("div",{ref:r,className:Ot(Tn({variant:t}),e),...n}));Pn.displayName="Badge";const An={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Rn({size:e="md",className:t}){return Ft.jsx(S,{className:Ot("animate-spin text-muted-foreground",An[e],t)})}function _n({isLoading:e,children:t,className:n,type:r="spinner",size:a="md"}){return e?"overlay"===r?Ft.jsxs("div",{className:Ot("relative",n),children:[t,Ft.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:Ft.jsx(Rn,{size:a})})]}):"skeleton"===r?Ft.jsx("div",{className:Ot("animate-pulse",n),children:Ft.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):Ft.jsx("div",{className:Ot("flex items-center justify-center py-8",n),children:Ft.jsx(Rn,{size:a})}):Ft.jsx(Ft.Fragment,{children:t})}let Dn=0;const Fn=new Map,zn=e=>{if(Fn.has(e))return;const t=setTimeout(()=>{Fn.delete(e),Un({type:"REMOVE_TOAST",toastId:e})},1e6);Fn.set(e,t)},On=(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?zn(n):e.toasts.forEach(e=>{zn(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)}}},Ln=[];let Mn={toasts:[]};function Un(e){Mn=On(Mn,e),Ln.forEach(e=>{e(Mn)})}function $n({...e}){const t=(Dn=(Dn+1)%Number.MAX_SAFE_INTEGER,Dn.toString()),n=()=>Un({type:"DISMISS_TOAST",toastId:t});return Un({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||n()}}}),{id:t,dismiss:n,update:e=>Un({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function Bn(){const[t,n]=e.useState(Mn);return e.useEffect(()=>(Ln.push(n),()=>{const e=Ln.indexOf(n);e>-1&&Ln.splice(e,1)}),[t]),{...t,toast:$n,dismiss:e=>Un({type:"DISMISS_TOAST",toastId:e})}}const Vn=Ze.Provider,Hn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ze.Viewport,{ref:n,className:Ot("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}));Hn.displayName=Ze.Viewport.displayName;const qn=m("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"}}),Wn=e.forwardRef(({className:e,variant:t,...n},r)=>Ft.jsx(Ze.Root,{ref:r,className:Ot(qn({variant:t}),e),...n}));Wn.displayName=Ze.Root.displayName;const Qn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ze.Action,{ref:n,className:Ot("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}));Qn.displayName=Ze.Action.displayName;const Kn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ze.Close,{ref:n,className:Ot("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:Ft.jsx(N,{className:"h-4 w-4"})}));Kn.displayName=Ze.Close.displayName;const Yn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ze.Title,{ref:n,className:Ot("text-sm font-semibold",e),...t}));Yn.displayName=Ze.Title.displayName;const Jn=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ze.Description,{ref:n,className:Ot("text-sm opacity-90",e),...t}));function Xn(){const{toasts:e}=Bn();return Ft.jsxs(Vn,{children:[e.map(function({id:e,title:t,description:n,action:r,...a}){return Ft.jsxs(Wn,{...a,children:[Ft.jsxs("div",{className:"grid gap-1",children:[t&&Ft.jsx(Yn,{children:t}),n&&Ft.jsx(Jn,{children:n})]}),r,Ft.jsx(Kn,{})]},e)}),Ft.jsx(Hn,{})]})}Jn.displayName=Ze.Description.displayName;var Gn=Object.defineProperty;class Zn{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?Gn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(Zn,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const er="qualiex_access_token",tr="qualiex_id_token",nr="supabase_token",rr="oauth_state",ar="oauth_nonce",sr="selected_alias",ir="manual_logout",or={setAccessToken:e=>localStorage.setItem(er,e),getAccessToken:()=>localStorage.getItem(er),setIdToken:e=>localStorage.setItem(tr,e),getIdToken:()=>localStorage.getItem(tr),getSupabaseToken:()=>localStorage.getItem(nr),setOAuthState:e=>sessionStorage.setItem(rr,e),getOAuthState:()=>sessionStorage.getItem(rr),clearOAuthState:()=>sessionStorage.removeItem(rr),setOAuthNonce:e=>sessionStorage.setItem(ar,e),getOAuthNonce:()=>sessionStorage.getItem(ar),clearOAuthNonce:()=>sessionStorage.removeItem(ar),setSelectedAlias:e=>localStorage.setItem(sr,e),getSelectedAlias:()=>localStorage.getItem(sr),clearSelectedAlias:()=>localStorage.removeItem(sr),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!or.getAccessToken()||!or.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(nr,e),or._clearValidationCache()},areAllTokensValid:()=>{const e=or.getAccessToken(),t=or.getIdToken();if(!e||!t)return!1;try{const n=Zn.validateTokens(e,t);return!!n.idTokenValid&&n.idTokenValid}catch(n){return!1}},clearExpiredTokens:()=>{let e=!1;const t=or.getAccessToken(),n=or.getIdToken(),r=or.getSupabaseToken();return t&&or.isTokenExpired(t)&&(localStorage.removeItem(er),e=!0),n&&or.isTokenExpired(n)&&(localStorage.removeItem(tr),e=!0),r&&or.isTokenExpired(r)&&(localStorage.removeItem(nr),e=!0),e},clearAll:()=>{localStorage.removeItem(er),localStorage.removeItem(tr),localStorage.removeItem(nr),localStorage.removeItem(sr),localStorage.removeItem(ir),sessionStorage.removeItem(rr),sessionStorage.removeItem(ar)},setManualLogout:()=>localStorage.setItem(ir,"true"),isManualLogout:()=>"true"===localStorage.getItem(ir),clearManualLogout:()=>localStorage.removeItem(ir),isTokenExpired:e=>{try{return Zn.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{or._validationCache.isValid=!1,or._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=or.getSupabaseToken();if(!e)return!1;if(or.isTokenExpired(e))return or._clearValidationCache(),or._handleExpiredToken(),!1;const t=Date.now();return t-or._validationCache.timestamp<or._validationCache.cacheValidityMs?or._validationCache.isValid:(or._validationCache.isValid=!0,or._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>or.isSupabaseTokenValid()?or.getSupabaseToken():null,_handleExpiredToken:()=>{or.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!or.isSupabaseTokenValid())return null;const e=or.getSupabaseToken();if(!e)return null;try{const t=Zn.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 or._handleExpiredToken(),null}},getCompanyId:e=>{const t=or.getAccessToken();if(t)try{const n=Zn.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=or.extractTokenData();if(n?.companyId)return n.companyId;const r=or.getIdToken();if(r)try{const t=Zn.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=or.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=or.getIdToken();if(!e)return[];try{const t=Zn.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 lr=Object.defineProperty,cr=(e,t,n)=>((e,t,n)=>t in e?lr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const ur=new class{constructor(){cr(this,"errors",[]),cr(this,"toastCount",0),cr(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()){$n({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){$n({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 dr=Object.defineProperty,fr=(e,t,n)=>((e,t,n)=>t in e?dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const mr=import.meta.env.VITE_SUPABASE_URL,pr=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,hr=class e{constructor(){fr(this,"client"),fr(this,"currentToken",null),fr(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:pr};e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`);return et(mr,pr,{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=or.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 ur.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};fr(hr,"instance");let gr=hr;function xr(){return gr.getInstance().getClient()}class yr{static async generateToken(e,t,n,r=!1){try{if(!r){const e=or.getSupabaseToken();if(e&&or.isSupabaseTokenValid())return e}const a=xr(),{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?(or.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 br=Object.defineProperty,vr=(e,t,n)=>((e,t,n)=>t in e?br(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=or.getAccessToken(),t=or.getSelectedAlias();if(!e||!t)return null;const n=await yr.generateToken(e,t,this.onLogoutCallback||void 0,!1);return n?(or.setSupabaseToken(n),n):null}catch(e){return null}finally{this.isRegenerating=!1}}}vr(wr,"isRegenerating",!1),vr(wr,"onLogoutCallback",null);class Nr{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(or.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 kr=Object.defineProperty;class jr{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):(Nr.handleError(e),this.isRetrying=!1,!1)}catch(r){return Nr.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=or.getAccessToken();return e?or.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?kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,t+"",n)})(jr,"isRetrying",!1);var Cr=Object.defineProperty,Sr=(e,t,n)=>((e,t,n)=>t in e?Cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const Ir=new class{constructor(){Sr(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=jr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=or.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 ur.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=n}if(!Array.isArray(r))return ur.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(n){if(await jr.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 ur.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=n}return Array.isArray(r)?r.map(this.mapToQualiexUser):(ur.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return ur.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 ur.handleError(a,!0),[]}}async fetchUserById(e,t,n){try{return(await this.fetchUsers(t,n)).find(t=>t.userId===e)||null}catch(r){return ur.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=or.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}},Er={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"}},Tr={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Pr={debounceDelay:500},Ar=()=>{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},Rr={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]};let _r={enableUserEnrichment:!1,enableUsersApi:!1,userNameFieldSuffix:"_name",userEmailFieldSuffix:"_email",userUsernameFieldSuffix:"_username"};const Dr=()=>_r,Fr=e=>{_r={..._r,...e}},zr={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 Or(e,t){const n=Dr(),r=t||n.userNameFieldSuffix||"_name";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Lr(e,t){const n=Dr(),r=t||n.userEmailFieldSuffix||"_email";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Mr(e,t){const n=Dr(),r=t||n.userUsernameFieldSuffix||"_username";return e.endsWith("_id")?e.replace(/_id$/,r):`${e}${r}`}function Ur(e,t){return t&&t.length>0?t.map(e=>({idField:e.idField,nameField:e.nameField||Or(e.idField),emailField:e.emailField||Lr(e.idField),usernameField:e.usernameField||Mr(e.idField)})):e&&e.length>0?e.map(e=>({idField:e,nameField:Or(e),emailField:Lr(e),usernameField:Mr(e)})):[{idField:"id_user",nameField:"responsible_name"}]}const $r=new Map;class Br{static async fetchQualiexUsers(e,t){const n=Dr(),r=`${t}_${e}`,a=$r.get(r);if(a&&Date.now()-a.timestamp<3e5)return a.users;let s;return s=n.fetchUsers?await n.fetchUsers(t,e):await Ir.fetchUsers(e,t),$r.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=Dr();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=or.extractTokenData();if(!t)return e;r=r||t.alias,a=a||t.companyId}if(!r||!a)return e;const s=Ur(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 ur.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 Vr=["responsible_name"],Hr=e=>Vr.includes(e);function qr(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,u=()=>{if(!or.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return xr().schema(o).from(a)};return{async getAll(e={}){const{search:t="",sortField:n="updated_at",sortDirection:o="desc",page:d=1,limit:f=25,...m}=e;let p=u().select(i||"*",{count:"exact"});p=p.eq("is_removed",!1),Object.entries(m).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(".")||Hr(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,d,f);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,d,f);const b=Dr();if(c&&b.enableUserEnrichment&&l&&y.data.length>0){const t=Ur(r.userIdFields,r.userFieldsMapping);if(y.data.some(e=>t.some(t=>e[t.idField]))){const a=n&&n.includes("."),s=n&&Hr(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 Br.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 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}}})(c,d,f);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}}const c=await Br.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 u().select(i||"*").eq("id",e).maybeSingle();if(n)throw new Error(`Error fetching ${a}: ${n.message}`);return t},async create(e){const t=Lt(e),n=Object.entries(t).reduce((e,[t,n])=>(void 0!==n&&(e[t]=n),e),{}),{data:r,error:s}=await u().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={...Lt(t),updated_at:(new Date).toISOString()},{data:r,error:s}=await u().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 u().update(t).eq("id",e);if(n)throw new Error(`Error soft deleting ${a}: ${n.message}`)}}}const Wr=()=>{or.clearManualLogout()},Qr=e=>e?.placeId||null,Kr=e=>e?.placeName||null,Yr=e=>({placeId:Qr(e),placeName:Kr(e)}),Jr=class{static async initialize(){try{if(!or.hasAllTokens()||!or.areAllTokensValid())return or.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=or.getAccessToken(),n=or.getIdToken();Wr();const r=this.extractUserFromIdToken(n),a=this.extractCompaniesFromIdToken(n),s=this.extractAliasFromAccessToken(t),i=or.extractTokenData(),o=i?.alias;let l=null;if(o&&a.some(e=>e.alias===o))l=o;else{const e=or.getSelectedAlias(),t=e&&a.some(t=>t.alias===e);l=t?e:s||a[0]?.alias||null}!or.isSupabaseTokenValid()&&l&&await wr.attemptRegeneration();let c=null;if(l){const e=or.getCompanyId(l),t=a.find(e=>e.alias===l);t&&(c={id:e||t.id,name:t.name,alias:t.alias})}let u=null,d=null;if(r?.id&&l){const t=or.getCompanyId(l);if(t)try{const e=(await Ir.fetchActiveUsersMap(l,t)).get(r.id);if(e){const t=Yr(e);u=t.placeId,d=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:u,placeName:d,activePlaceId:u,activePlaceName:d}}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=xr(),{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=or.generateOAuthState();or.setOAuthState(e);const t=or.generateOAuthNonce();or.setOAuthNonce(t);const n=`${window.location.origin}/callback`,r=new URL(Er.oauth.authUrl);r.searchParams.set("client_id",Er.oauth.clientId),r.searchParams.set("response_type",Er.oauth.responseType),r.searchParams.set("scope",Er.oauth.scope),r.searchParams.set("redirect_uri",n),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),Ar(),window.location.href=r.toString()}static async processCallback(){try{if(or.hasAllTokens()){if(!or.getValidSupabaseToken()){or.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");or.setAccessToken(r),or.setIdToken(a),Wr();const i=this.extractAliasFromAccessToken(r);if(i)or.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(a);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");or.setSelectedAlias(e[0].alias)}if(!await wr.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return or.clearOAuthState(),or.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){or.setManualLogout(),or.clearAll(),window.location.href="/login"}static decodeToken(e){return Zn.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(()=>{Jr.logout()});let Xr=Jr;const Gr=n(void 0),Zr=({children:e})=>{const[t,n]=a({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null});let r=null;try{r=tt()}catch{}const[l,c]=a(!1),[u,d]=a(0),f=s(e=>{n(t=>({...t,...e}))},[]),m=s(e=>{n(t=>({...t,isLoading:e}))},[]),p=s(()=>{n({user:null,companies:[],alias:null,isAuthenticated:!1,isLoading:!0,selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null,activePlaceId:null,activePlaceName:null})},[]),h=s(async e=>{try{m(!0);const a=or.getAccessToken();if(!a)return;const s=await yr.generateToken(a,e.alias,void 0,!0);if(!s)return;or.setSupabaseToken(s),or.setSelectedAlias(e.alias);const i=or.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||or.getCompanyId(e.alias),c={id:l||e.id,name:e.name,alias:o};let u=null,d=null;if(t.user?.id&&o&&l)try{const e=(await Ir.fetchActiveUsersMap(o,l)).get(t.user.id);if(e){const t=Yr(e);u=t.placeId,d=t.placeName}}catch(n){}f({alias:o,selectedUnit:c,placeId:u,placeName:d,activePlaceId:u,activePlaceName:d}),r&&(await r.clear(),await new Promise(e=>setTimeout(e,100)))}catch(n){}finally{m(!1)}},[f,r,m,t.user]),g=s(async()=>await Xr.processCallback(),[]),x=s(async()=>{Xr.logout(),p(),r&&await r.clear()},[p,r]),y=s(e=>{c(e)},[]),b=s(()=>{d(e=>e+1)},[]),v=s(()=>{d(e=>e+1)},[]);i(()=>{if(!t.isAuthenticated)return;let e=!0;const n=setInterval(()=>{e&&(or.areAllTokensValid()||e&&x())},6e5);return()=>{e=!1,clearInterval(n)}},[t.isAuthenticated,x]),i(()=>{let e=!0;return(async()=>{try{if(await new Promise(e=>setTimeout(e,100)),!e)return;const t=await Xr.initialize();if(!e)return;t&&t.isAuthenticated?f({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&&m(!1)}catch(t){e&&(Nr.handleError(t),m(!1))}})(),()=>{e=!1}},[f,m,x]);const w=o(()=>({...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 Ft.jsx(Gr.Provider,{value:w,children:e})},ea=()=>{const e=r(Gr);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function ta({queryKey:e,service:t,entityName:n,searchFields:r,additionalFilters:i={},onSuccess:l}){const[c,u]=st(),d=tt(),{alias:f,userId:m}=ea(),p=c.get("search")||"",h=c.get("sortField")||Tr.sorting.defaultField,g=c.get("sortDirection")||Tr.sorting.defaultDirection,x=parseInt(c.get("page")||"1"),y=parseInt(c.get("limit")||String(Tr.pagination.defaultPageSize)),v=p,w=o(()=>({search:v,sortField:h,sortDirection:g,page:x,limit:y,...i}),[v,h,g,x,y,i]),N=s(()=>t.getAll(w),[t,w]),k=nt({queryKey:[e,f,m,w],queryFn:N});if(!k)throw new Error(`useCrud: Query initialization failed for "${n}". Ensure QueryClientProvider is configured in your app root.`);const j=rt({mutationFn:t.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(zr.success.created(n)),l?.()},onError:e=>{b.error(`${zr.error.create(n)}: ${e.message}`)}}),C=rt({mutationFn:({id:e,data:n})=>t.update(e,n),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(zr.success.updated(n)),l?.()},onError:e=>{b.error(`${zr.error.update(n)}: ${e.message}`)}}),S=rt({mutationFn:t.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(zr.success.deleted(n))},onError:e=>{b.error(`${zr.error.delete(n)}: ${e.message}`)}}),I=s(e=>{const t={...Object.fromEntries(c)};Object.entries(e).forEach(([e,n])=>{""===n||0===n?delete t[e]:t[e]=String(n)}),u(t)},[c,u]),E=s(e=>{I({search:e,page:1})},[I]),T=s(e=>{I({sortField:e,sortDirection:h===e&&"asc"===g?"desc":"asc",page:1})},[h,g,I]),P=s(e=>{I({page:e})},[I]),A=s(e=>{I({limit:e,page:1})},[I]),R=s(()=>{u({})},[u]),[_,D]=a([]),F=s(e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),z=s(()=>{const e=k?.data?.data.map(e=>e.id)||[];D(t=>t.length===e.length?[]:e)},[k?.data?.data]),O=s(()=>{D([])},[]),L=o(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&_.length===e.length},[_,k?.data?.data]),M=rt({mutationFn:async e=>{await Promise.all(e.map(e=>t.delete(e)))},onSuccess:(t,r)=>{d.invalidateQueries({queryKey:[e]}),b.success(`${r.length} ${n}(s) deletado(s) com sucesso`),O()},onError:e=>{b.error(`Erro ao deletar itens: ${e.message}`)}}),U=s((e,t)=>{const n=t?t(e):e;e.id?C.mutate({id:e.id,data:n}):j.mutate({...n,alias:f})},[f,j,C]);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||Tr.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:j?.isPending??!1,isUpdating:C?.isPending??!1,isDeleting:S?.isPending??!1,error:k?.error||null,searchTerm:p,sortField:h,sortDirection:g,currentPage:x,itemsPerPage:y,createEntity:j.mutate,updateEntity:(e,t)=>C.mutate({id:e,data:t}),deleteEntity:S.mutate,save:U,handleSearch:E,handleSort:T,handlePageChange:P,handleItemsPerPageChange:A,clearFilters:R,refetch:k.refetch,selectedIds:_,selectItem:F,selectAll:z,clearSelection:O,isAllSelected:L,bulkDelete:M.mutate,isBulkDeleting:M.isPending}}function na(e){const t=qr({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)=>ta({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:n,onSuccess:r})}}const ra=ct.Root,aa=ct.Trigger,sa=ct.Portal,ia=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ct.Overlay,{className:Ot("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}));ia.displayName=ct.Overlay.displayName;const oa=e.forwardRef(({className:e,...t},n)=>Ft.jsxs(sa,{children:[Ft.jsx(ia,{}),Ft.jsx(ct.Content,{ref:n,className:Ot("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})]}));oa.displayName=ct.Content.displayName;const la=({className:e,...t})=>Ft.jsx("div",{className:Ot("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});la.displayName="AlertDialogHeader";const ca=({className:e,...t})=>Ft.jsx("div",{className:Ot("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});ca.displayName="AlertDialogFooter";const ua=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ct.Title,{ref:n,className:Ot("text-lg font-semibold",e),...t}));ua.displayName=ct.Title.displayName;const da=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ct.Description,{ref:n,className:Ot("text-sm text-muted-foreground",e),...t}));da.displayName=ct.Description.displayName;const fa=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ct.Action,{ref:n,className:Ot(Bt(),e),...t}));fa.displayName=ct.Action.displayName;const ma=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ct.Cancel,{ref:n,className:Ot(Bt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));ma.displayName=ct.Cancel.displayName;const pa=({open:e,onOpenChange:t,item:n,onConfirm:r,entityName:s="item",isDeleting:o=!1,isBulk:l=!1,bulkCount:c})=>{const[u,d]=a("");i(()=>{e||d("")},[e]);const f=()=>{d(""),t(!1)},m=l?u===c?.toString():u===n?.title;return n?Ft.jsx(ra,{open:e,onOpenChange:f,children:Ft.jsxs(oa,{className:"sm:max-w-[500px]",children:[Ft.jsx(la,{children:Ft.jsxs("div",{className:"flex items-center space-x-2",children:[Ft.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:Ft.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),Ft.jsx("div",{className:"flex-1",children:Ft.jsx(ua,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),Ft.jsx(da,{asChild:!0,children:Ft.jsxs("div",{className:"space-y-4",children:[Ft.jsxs("div",{className:"text-sm text-muted-foreground",children:[Ft.jsx("p",{className:"mb-2",children:l?Ft.jsx(Ft.Fragment,{children:"Você está prestes a excluir permanentemente:"}):Ft.jsxs(Ft.Fragment,{children:["Você está prestes a excluir permanentemente o ",s,":"]})}),Ft.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:Ft.jsx("p",{className:"font-medium text-foreground",children:l?`${n.title}`:n.title})})]}),Ft.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:Ft.jsxs("div",{className:"flex items-start space-x-2",children:[Ft.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:Ft.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),Ft.jsxs("div",{className:"text-sm text-orange-800",children:[Ft.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),Ft.jsx("p",{children:l?Ft.jsx(Ft.Fragment,{children:"Esta ação não pode ser desfeita. Os itens serão removidos permanentemente do sistema."}):Ft.jsxs(Ft.Fragment,{children:["Esta ação não pode ser desfeita. O ",s," será removido permanentemente do sistema."]})})]})]})}),Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(Qt,{htmlFor:"confirmation",className:"text-sm font-medium",children:l?Ft.jsxs(Ft.Fragment,{children:["Para confirmar, digite o número de itens que serão removidos: ",Ft.jsx("strong",{children:c})]}):Ft.jsxs(Ft.Fragment,{children:["Para confirmar, digite ",Ft.jsxs("strong",{children:['"',n.title,'"']})," abaixo:"]})}),Ft.jsx(qt,{id:"confirmation",type:l?"number":"text",value:u,onChange:e=>d(e.target.value),placeholder:l?`Digite: ${c}`:`Digite: ${n.title}`,className:"w-full"})]})]})}),Ft.jsxs(ca,{children:[Ft.jsx(ma,{onClick:f,children:"Cancelar"}),Ft.jsx(fa,{onClick:()=>{if(!n)return;(l?u===c?.toString():u===n.title)&&(r(n),d(""),t(!1))},disabled:!m||o,className:"bg-destructive hover:bg-destructive/90 text-destructive-foreground",children:o?"Removendo...":`Excluir ${s}`})]})]})}):null},ha=e.forwardRef(({className:e,...t},n)=>Ft.jsx("table",{ref:n,className:Ot("w-full caption-bottom text-sm",e),...t}));ha.displayName="Table";const ga=e.forwardRef(({className:e,...t},n)=>Ft.jsx("thead",{ref:n,className:Ot("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));ga.displayName="TableHeader";const xa=e.forwardRef(({className:e,...t},n)=>Ft.jsx("tbody",{ref:n,className:Ot("[&_tr:last-child]:border-0",e),...t}));xa.displayName="TableBody";const ya=e.forwardRef(({className:e,...t},n)=>Ft.jsx("tfoot",{ref:n,className:Ot("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));ya.displayName="TableFooter";const ba=e.forwardRef(({className:e,...t},n)=>Ft.jsx("tr",{ref:n,className:Ot("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...t}));ba.displayName="TableRow";const va=e.forwardRef(({className:e,...t},n)=>Ft.jsx("th",{ref:n,className:Ot("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}));va.displayName="TableHead";const wa=e.forwardRef(({className:e,...t},n)=>Ft.jsx("td",{ref:n,className:Ot("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));wa.displayName="TableCell";const Na=e.forwardRef(({className:e,...t},n)=>Ft.jsx("caption",{ref:n,className:Ot("mt-4 text-sm text-muted-foreground",e),...t}));function ka({className:e,...t}){return Ft.jsx("div",{className:Ot("animate-pulse rounded-md bg-muted",e),...t})}function ja({rows:e=5,columns:t=4}){return Ft.jsx("div",{className:"w-full",children:Ft.jsxs("div",{className:"rounded-md border",children:[Ft.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:Ft.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Ft.jsx(ka,{className:"h-4 w-24"},t))})}),Ft.jsx("div",{children:Array.from({length:e}).map((e,n)=>Ft.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:Ft.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Ft.jsx(ka,{className:"h-4 w-20"},t))})},n))})]})})}function Ca({count:e=3}){return Ft.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>Ft.jsxs(Kt,{children:[Ft.jsxs(Yt,{children:[Ft.jsx(ka,{className:"h-4 w-3/4"}),Ft.jsx(ka,{className:"h-3 w-1/2"})]}),Ft.jsx(Gt,{children:Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(ka,{className:"h-3 w-full"}),Ft.jsx(ka,{className:"h-3 w-2/3"})]})})]},t))})}function Sa({fields:e=4}){return Ft.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(ka,{className:"h-4 w-24"}),Ft.jsx(ka,{className:"h-10 w-full"})]},t)),Ft.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Ft.jsx(ka,{className:"h-10 w-20"}),Ft.jsx(ka,{className:"h-10 w-20"})]})]})}function Ia(){return Ft.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[Ft.jsxs("div",{className:"flex items-center space-x-3",children:[Ft.jsx(ka,{className:"h-8 w-8 rounded-full"}),Ft.jsx(ka,{className:"h-6 w-32"})]}),Ft.jsxs("div",{className:"flex items-center space-x-2",children:[Ft.jsx(ka,{className:"h-8 w-8"}),Ft.jsx(ka,{className:"h-8 w-24"})]})]})}function Ea(){return Ft.jsx("div",{className:"w-64 border-r bg-muted/10",children:Ft.jsxs("div",{className:"p-4",children:[Ft.jsx(ka,{className:"h-8 w-32 mb-6"}),Ft.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>Ft.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[Ft.jsx(ka,{className:"h-4 w-4"}),Ft.jsx(ka,{className:"h-4 w-20"})]},t))})]})})}Na.displayName="TableCaption";const Ta={default:T,search:E,error:I};function Pa({icon:e,title:t,description:n,action:r,className:a,variant:s="default"}){const i=e?()=>e:Ta[s];return Ft.jsxs("div",{className:Ot("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[Ft.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:Ft.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),Ft.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),n&&Ft.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:n}),r&&Ft.jsx(Vt,{onClick:r.onClick,variant:"outline",children:r.label})]})}const Aa=ut.Root,Ra=ut.Trigger,_a=ut.Group,Da=ut.Portal,Fa=ut.Sub,za=ut.RadioGroup,Oa=e.forwardRef(({className:e,inset:t,children:n,...r},a)=>Ft.jsxs(ut.SubTrigger,{ref:a,className:Ot("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,Ft.jsx(P,{className:"ml-auto h-4 w-4"})]}));Oa.displayName=ut.SubTrigger.displayName;const La=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ut.SubContent,{ref:n,className:Ot("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}));La.displayName=ut.SubContent.displayName;const Ma=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Ft.jsx(ut.Portal,{children:Ft.jsx(ut.Content,{ref:r,sideOffset:t,className:Ot("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})}));Ma.displayName=ut.Content.displayName;const Ua=e.forwardRef(({className:e,inset:t,...n},r)=>Ft.jsx(ut.Item,{ref:r,className:Ot("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}));Ua.displayName=ut.Item.displayName;const $a=e.forwardRef(({className:e,children:t,checked:n,...r},a)=>Ft.jsxs(ut.CheckboxItem,{ref:a,className:Ot("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:[Ft.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ft.jsx(ut.ItemIndicator,{children:Ft.jsx(C,{className:"h-4 w-4"})})}),t]}));$a.displayName=ut.CheckboxItem.displayName;const Ba=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsxs(ut.RadioItem,{ref:r,className:Ot("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:[Ft.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Ft.jsx(ut.ItemIndicator,{children:Ft.jsx(A,{className:"h-2 w-2 fill-current"})})}),t]}));Ba.displayName=ut.RadioItem.displayName;const Va=e.forwardRef(({className:e,inset:t,...n},r)=>Ft.jsx(ut.Label,{ref:r,className:Ot("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Va.displayName=ut.Label.displayName;const Ha=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ut.Separator,{ref:n,className:Ot("-mx-1 my-1 h-px bg-muted",e),...t}));Ha.displayName=ut.Separator.displayName;const qa=({className:e,...t})=>Ft.jsx("span",{className:Ot("ml-auto text-xs tracking-widest opacity-60",e),...t});qa.displayName="DropdownMenuShortcut";const Wa=({onEdit:e,onDelete:t,onToggleStatus:n,isActive:r=!0,canDelete:a=!0,renderAs:s})=>{const i=[];if(e){const t={icon:R,label:"Editar",onClick:e};i.push(t)}if(n){const e={icon:r?_:D,label:r?"Inativar":"Ativar",onClick:n};i.push(e)}if(a&&t){const e={icon:F,label:"Remover",onClick:t,destructive:!0};i.push(e)}return"dropdown"===s?Ft.jsx(Ft.Fragment,{children:i.map((e,t)=>Ft.jsxs(Ua,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[Ft.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):Ft.jsx(Ft.Fragment,{children:i.map((e,t)=>Ft.jsxs(Vt,{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:[Ft.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},Qa=({onEdit:e,onDelete:t,canDelete:n=!0,onToggleStatus:r,isActive:a=!0})=>Ft.jsxs(Aa,{children:[Ft.jsx(Ra,{asChild:!0,children:Ft.jsx(Vt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:Ft.jsx(w,{size:12})})}),Ft.jsx(Ma,{align:"end",children:Ft.jsx(Wa,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),r?.()},isActive:a,canDelete:n,renderAs:"dropdown"})})]}),Ka=l(({checked:e,onCheckedChange:t})=>Ft.jsx(In,{checked:e,onCheckedChange:t}),(e,t)=>e.checked===t.checked),Ya=({manager:e,columns:t,onEdit:n,onView:r,onToggleStatus:s,onDelete:o,renderActions:l,enableBulkActions:c=!1})=>{const[u,d]=a(!1),[f,m]=a(null);i(()=>{const e=()=>d(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),i(()=>{const e=()=>m(null);if(f)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[f]);const p=(()=>{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+=100,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?Ft.jsx(Ca,{count:3}):0===e.entities.length?Ft.jsx(Pa,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):Ft.jsxs("div",{className:"space-y-4",children:[e.entities.map(a=>Ft.jsx(Kt,{className:Ot("overflow-hidden cursor-pointer hover:bg-muted/50",c&&e.selectedIds.includes(a.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),c||n?.(a)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),m({x:e.clientX,y:e.clientY,item:a})},children:Ft.jsx(Gt,{className:"p-4",children:Ft.jsxs("div",{className:"flex items-start gap-3",children:[c&&Ft.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:Ft.jsx(Ka,{checked:e.selectedIds.includes(a.id),onCheckedChange:()=>e.selectItem(a.id)})}),Ft.jsxs("div",{className:"flex-1",children:[t.map(e=>Ft.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[Ft.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[e.header,":"]}),Ft.jsx("div",{className:"text-sm text-foreground text-right min-w-0 flex-1",children:e.render?e.render(a):a[e.key]})]},String(e.key))),(n||r||l)&&Ft.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):Ft.jsx(Qa,{onEdit:n?()=>{n(a)}:void 0,onDelete:o?()=>o(a):void 0,onToggleStatus:s?()=>s(a):void 0,isActive:a.is_actived})})]})]})})},a.id)),f&&Ft.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:Ft.jsx(Wa,{onEdit:n?()=>{n(f.item),m(null)}:void 0,onDelete:o?()=>{o(f.item),m(null)}:void 0,onToggleStatus:s?()=>{s(f.item),m(null)}:void 0,isActive:f.item.is_actived,canDelete:!!o,renderAs:"context"})})]}):Ft.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?Ft.jsx(ja,{rows:5,columns:t.length}):Ft.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:Ft.jsx("div",{className:"flex-1 overflow-auto",children:Ft.jsxs(ha,{className:"table-auto",children:[Ft.jsxs("colgroup",{children:[c&&Ft.jsx("col",{style:{width:"50px"}}),p.map((e,t)=>Ft.jsx("col",{style:e.style},t)),Ft.jsx("col",{style:{width:"100px"}})]}),Ft.jsx(ga,{children:Ft.jsxs(ba,{children:[c&&Ft.jsx(va,{className:"w-[50px]",children:Ft.jsx(Ka,{checked:e.isAllSelected,onCheckedChange:e.selectAll})}),t.map(t=>{return Ft.jsx(va,{className:`${t.className||""} ${t.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:t.sortable?()=>e.handleSort(String(t.key)):void 0,children:Ft.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?Ft.jsx(z,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?Ft.jsx(O,{size:14,className:"ml-1"}):Ft.jsx(L,{size:14,className:"ml-1"}))]})},String(t.key));var n}),Ft.jsx(va,{className:"w-[100px] text-center",children:"Ações"})]})}),Ft.jsx(xa,{children:0===e.entities.length?Ft.jsx(ba,{children:Ft.jsx(wa,{colSpan:c?t.length+2:t.length+1,className:"h-32",children:Ft.jsx(Pa,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(r=>Ft.jsxs(ba,{className:Ot("cursor-pointer hover:bg-muted/50",c&&e.selectedIds.includes(r.id)&&"bg-muted"),onClick:e=>{e.stopPropagation(),c||n?.(r)},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),m({x:e.clientX,y:e.clientY,item:r})},children:[c&&Ft.jsx(wa,{onClick:e=>e.stopPropagation(),children:Ft.jsx(Ka,{checked:e.selectedIds.includes(r.id),onCheckedChange:()=>e.selectItem(r.id)})}),t.map(e=>Ft.jsx(wa,{className:e.className,children:e.render?e.render(r):r[e.key]},String(e.key))),Ft.jsx(wa,{className:"text-center",children:l?l(r):Ft.jsx(Qa,{onEdit:n?()=>n(r):void 0,onDelete:o?()=>o(r):void 0,onToggleStatus:s?()=>s(r):void 0,isActive:r.is_actived})})]},r.id))})]})})}),f&&Ft.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:Ft.jsx(Wa,{onEdit:n?()=>{n(f.item),m(null)}:void 0,onDelete:o?()=>{o(f.item),m(null)}:void 0,onToggleStatus:s?()=>{s(f.item),m(null)}:void 0,isActive:f.item.is_actived,canDelete:!!o,renderAs:"context"})})]})};function Ja(e,t,n,r){const[s,l]=a({}),[c,u]=a({}),d=o(()=>e,[e]),f=e=>e instanceof Date&&!isNaN(e.getTime()),m=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 m(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){}}};i(()=>{if(!r)return;const e=t=>{const n=[];return t.forEach(t=>{n.push(t),t.fields&&n.push(...e(t.fields))}),n},a=e(d),s={};a.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);f(e)&&(n=e.toISOString().split("T")[0])}else f(n)&&(n=n.toISOString().split("T")[0])}else n=m(e);s[e.name]=n}),a.forEach(e=>{const t=p(e,s);void 0!==t&&(s[e.name]=t)}),t&&Object.keys(t).forEach(e=>{a.find(t=>t.name===e)||void 0===t[e]||(s[e]=t[e])}),l(s),u({}),n&&n(s)},[d,t,n,r]);const g=e=>{const t=[];return e.forEach(e=>{t.push(e),e.fields&&t.push(...g(e.fields))}),t},x=()=>{const e=g(d),t={};return e.forEach(e=>{const n=h(e,s[e.name],s);n&&(t[e.name]=n)}),u(t),0===Object.keys(t).length};return{formData:s,errors:c,updateField:(e,t)=>{l(r=>{const a={...r,[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(d).filter(t=>t.dependsOn===e).forEach(e=>{const t=p(e,n);void 0!==t&&(n={...n,[e.name]:t})}),n})(e,a);return n&&n(s),s}),c[e]&&u(t=>{const n={...t};return delete n[e],n});const r=g(d).find(t=>t.name===e);if(r){const n=h(r,t,s);n&&u(t=>({...t,[e]:n}))}},validateForm:x,handleSubmit:e=>t=>{t&&(t.preventDefault(),t.stopPropagation()),x()&&e(s)}}}const Xa=dt.Root,Ga=dt.Trigger,Za=e.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>Ft.jsx(dt.Portal,{children:Ft.jsx(dt.Content,{ref:a,align:t,sideOffset:n,className:Ot("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),...r})}));Za.displayName=dt.Content.displayName;const es=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],ts=({value:e="#3b82f6",onChange:t,label:n})=>Ft.jsxs("div",{className:"space-y-2",children:[n&&Ft.jsx(Qt,{children:n}),Ft.jsxs(Xa,{children:[Ft.jsx(Ga,{asChild:!0,children:Ft.jsxs(Vt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Ft.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),Ft.jsx(Za,{className:"w-64",children:Ft.jsxs("div",{className:"space-y-3",children:[Ft.jsxs("div",{children:[Ft.jsx(Qt,{htmlFor:"color-input",children:"Cor personalizada"}),Ft.jsx(qt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),Ft.jsxs("div",{children:[Ft.jsx(Qt,{children:"Cores predefinidas"}),Ft.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:es.map(e=>Ft.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)=>Ft.jsxs(ft.Root,{ref:r,className:Ot("relative overflow-hidden",e),...n,children:[Ft.jsx(ft.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),Ft.jsx(rs,{}),Ft.jsx(ft.Corner,{})]}));ns.displayName=ft.Root.displayName;const rs=e.forwardRef(({className:e,orientation:t="vertical",...n},r)=>Ft.jsx(ft.ScrollAreaScrollbar,{ref:r,orientation:t,className:Ot("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:Ft.jsx(ft.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));rs.displayName=ft.ScrollAreaScrollbar.displayName;const as={Star:Pe,Heart:Te,Home:Ee,User:Ie,Settings:Se,Mail:Ce,Phone:je,Calendar:ke,MapPin:Ne,Camera:we,Image:ve,Music:be,Video:ye,Book:xe,Bookmark:ge,Search:E,Filter:he,Edit:R,Trash2:F,Plus:pe,Minus:me,Check:C,X:N,ChevronDown:k,ChevronUp:j,ChevronLeft:fe,ChevronRight:P,ArrowUp:O,ArrowDown:L,ArrowLeft:de,ArrowRight:ue,Clock:ce,Bell:le,AlertCircle:I,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:q,Zap:H,Flame:V,Sparkles:B,Award:$,Trophy:U,Target:M},ss=({value:e="Star",onChange:t,label:n})=>{const[r,s]=a(""),i=Object.entries(as).filter(([e])=>e.toLowerCase().includes(r.toLowerCase())),o=as[e]||Pe;return Ft.jsxs("div",{className:"space-y-2",children:[n&&Ft.jsx(Qt,{children:n}),Ft.jsxs(Xa,{children:[Ft.jsx(Ga,{asChild:!0,children:Ft.jsxs(Vt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Ft.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),Ft.jsx(Za,{className:"w-80",children:Ft.jsxs("div",{className:"space-y-3",children:[Ft.jsxs("div",{children:[Ft.jsx(Qt,{htmlFor:"icon-search",children:"Buscar ícone"}),Ft.jsx(qt,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:r,onChange:e=>s(e.target.value)})]}),Ft.jsx(ns,{className:"h-48",children:Ft.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([n,r])=>Ft.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:Ft.jsx(r,{className:"h-4 w-4"})},n))})})]})})]})]})},is=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));is.displayName="Command";const os=({children:e,...t})=>Ft.jsx("div",{...t,children:Ft.jsx(is,{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})}),ls=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:Ft.jsx("input",{ref:n,className:Ot("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})}));ls.displayName="CommandInput";const cs=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));cs.displayName="CommandList";const us=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("py-6 text-center text-sm text-muted-foreground",e),...t}));us.displayName="CommandEmpty";const ds=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("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}));ds.displayName="CommandGroup";const fs=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("-mx-1 h-px bg-border",e),...t}));fs.displayName="CommandSeparator";const ms=e.forwardRef(({className:e,disabled:t,onSelect:n,value:r,...a},s)=>Ft.jsx("div",{ref:s,className:Ot("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}));ms.displayName="CommandItem";const ps=({className:e,...t})=>Ft.jsx("span",{className:Ot("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});function hs({options:t,value:n,onChange:r,onCreate:a,placeholder:s="Selecionar...",searchPlaceholder:i="Buscar...",createLabel:o=e=>`Criar "${e}"`,emptyMessage:l="Nenhum item encontrado.",disabled:c=!1,error:u,isLoading:d=!1,className:f,mode:m="single"}){const[p,h]=e.useState(!1),[g,x]=e.useState(""),[y,b]=e.useState(!1),v=e.useMemo(()=>n?Array.isArray(n)?n:[n]:[],[n]),w=e.useMemo(()=>v.map(e=>t.find(t=>t.value===e)?.label).filter(Boolean),[v,t]),N=e.useMemo(()=>g?t.filter(e=>e.label.toLowerCase().includes(g.toLowerCase())):t,[t,g]),k=e.useMemo(()=>!(!g||!a)&&!t.some(e=>e.label.toLowerCase()===g.toLowerCase()),[g,t,a]),j=e.useMemo(()=>0===w.length?s:"single"===m?w[0]:null,[w,s,m]);return Ft.jsxs(Xa,{open:p,onOpenChange:h,children:[Ft.jsx(Ga,{asChild:!0,children:Ft.jsxs(Vt,{variant:"outline",role:"combobox","aria-expanded":p,disabled:c||d,className:Ot("w-full justify-between",!n&&"text-muted-foreground",u&&"border-destructive",f),children:[Ft.jsx("div",{className:"flex flex-wrap gap-1 flex-1 overflow-hidden",children:"multiple"===m&&w.length>0?w.map((e,t)=>Ft.jsxs(Pn,{variant:"secondary",className:"mr-1",children:[e,Ft.jsx("button",{className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",onMouseDown:e=>((e,t)=>{t.stopPropagation();const n=v.filter(t=>t!==e);r("single"===m?"":n)})(v[t],e),children:"✕"})]},v[t])):Ft.jsx("span",{className:"truncate",children:j})}),Ft.jsx(Ae,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),Ft.jsx(Za,{className:"w-full p-0",align:"start",children:Ft.jsxs(is,{children:[Ft.jsx("div",{className:"flex items-center border-b px-3",children:Ft.jsx("input",{placeholder:i,value:g,onChange:e=>x(e.target.value),className:"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"})}),Ft.jsxs(cs,{children:[0===N.length&&!k&&Ft.jsx(us,{children:l}),k&&Ft.jsx(ds,{children:Ft.jsxs(ms,{onSelect:async()=>{if(a&&g){b(!0);try{const e=await a(g);e&&("single"===m?(r(e),h(!1)):r([...v,e])),x("")}catch(e){}finally{b(!1)}}},className:"cursor-pointer",disabled:y,children:[Ft.jsx(pe,{className:"mr-2 h-4 w-4 text-primary"}),Ft.jsx("span",{className:"text-primary font-medium",children:o(g)})]})}),N.length>0&&Ft.jsx(ds,{children:N.map(e=>Ft.jsxs(ms,{value:e.value,onSelect:()=>(e=>{if("single"===m)r(e),h(!1),x("");else{const t=v.includes(e)?v.filter(t=>t!==e):[...v,e];r(t)}})(e.value),className:"cursor-pointer",children:[Ft.jsx(C,{className:Ot("mr-2 h-4 w-4",v.includes(e.value)?"opacity-100":"opacity-0")}),e.label]},e.value))})]})]})})]})}function gs({value:e,onChange:t,items:n,isLoading:r=!1,error:s=null,getItemValue:i,getItemLabel:l,searchPlaceholder:c="Buscar...",emptyMessage:u="Nenhum item disponível",noResultsMessage:d="Nenhum resultado encontrado",sortItems:f,placeholder:m="Selecionar...",disabled:p=!1,className:h}){const[g,x]=a(""),y=o(()=>{const e=f?[...n].sort(f):[...n].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))},[n,g,f,l]);return r?Ft.jsx(ka,{className:Ot("h-10 w-full",h)}):s?Ft.jsxs("div",{className:Ot("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[Ft.jsx(I,{className:"h-4 w-4 text-destructive"}),Ft.jsx("span",{className:"text-sm text-destructive",children:s.message||"Erro ao carregar dados"})]}):Ft.jsxs(vn,{value:e,onValueChange:t,disabled:p||0===n.length,children:[Ft.jsx(Nn,{className:h,children:Ft.jsx(wn,{placeholder:m})}),Ft.jsxs(Cn,{children:[Ft.jsx("div",{className:"px-2 pb-2",children:Ft.jsxs("div",{className:"relative",children:[Ft.jsx(E,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),Ft.jsx(qt,{placeholder:c,value:g,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===y.length?Ft.jsx(Sn,{value:"no-items",disabled:!0,children:g?d:u}):y.map(e=>Ft.jsx(Sn,{value:i(e),children:l(e)},i(e)))]})]})}ps.displayName="CommandShortcut";const xs=(e={})=>{const{user:t,alias:n}=ea(),r=Dr(),{enabled:a=r.enableUsersApi}=e;return nt({queryKey:["qualiex-users",n],queryFn:()=>Ir.getUsers(n),enabled:a&&!!n&&!!t,retry:2,retryDelay:1e3})},ys=({value:e="",onChange:t,placeholder:n="Selecionar usuário",disabled:r,className:a,enabled:s})=>{const{data:i=[],isLoading:o,error:l}=xs({enabled:s});return Ft.jsx(gs,{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 bs({title:e,sections:n,initialData:r,onSubmit:i,onCancel:l,open:c,submitButtonText:u="Salvar",isLoading:d=!1,usersData:f}){const[m,p]=a(n?.[0]?.id||""),h=o(()=>n&&Array.isArray(n)?n.flatMap(e=>e.fields.flatMap(e=>"group"===e.type?e.fields||[]:e)):[],[n]),{formData:g,errors:x,updateField:y,handleSubmit:b}=Ja(h,r,void 0,c),v=o(()=>n&&Array.isArray(n)?n.map(e=>({...e,disabled:e.condition?!e.condition(g):e.disabled||!1})):[],[n,g]),w=o(()=>{const e=v.find(e=>e.id===m);if(e&&!e.disabled)return m;const t=v.find(e=>!e.disabled);return t?.id||m},[v,m]);t.useEffect(()=>{w!==m&&p(w)},[w,m]);const N=v.find(e=>e.id===w),k=e=>{const t=(e.computedValue,g[e.name]),n=void 0!==t?t:"",r=x[e.name];switch(e.type){case"group":return Ft.jsxs("div",{className:"space-y-2",children:[e.label,Ft.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>k(e))})]},e.name);case"user-select":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Qt,{htmlFor:e.name,children:e.label}),Ft.jsx(ys,{value:n||"",onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":""}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"textarea":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Qt,{htmlFor:e.name,children:e.label}),Ft.jsx(En,{id:e.name,value:n||"",onChange:t=>{y(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&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"select":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Qt,{htmlFor:e.name,children:e.label}),Ft.jsxs(vn,{value:String(n),onValueChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[Ft.jsx(Nn,{className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:Ft.jsx(wn,{placeholder:e.placeholder})}),Ft.jsx(Cn,{children:e.options?.map(e=>Ft.jsx(Sn,{value:e.value,children:e.label},e.value))})]}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"date":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Qt,{htmlFor:e.name,children:e.label}),Ft.jsx(qt,{id:e.name,type:"date",value:String(n),onChange:t=>y(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:Ot("w-full",r?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"color":return Ft.jsxs("div",{children:[Ft.jsxs(Qt,{htmlFor:e.name,children:[e.label," ",e.required&&Ft.jsx("span",{className:"text-destructive",children:"*"})]}),Ft.jsx(qt,{id:e.name,type:"color",value:n||e.defaultValue||"#000000",onChange:t=>y(e.name,t.target.value),className:"h-10"}),r&&Ft.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return Ft.jsxs("div",{children:[Ft.jsx(ts,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"#3b82f6",onChange:t=>y(e.name,t)}),r&&Ft.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return Ft.jsxs("div",{children:[Ft.jsx(ss,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"Star",onChange:t=>y(e.name,t)}),r&&Ft.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 Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&Ft.jsx(Qt,{htmlFor:e.name,children:e.label}),Ft.jsx(t,{value:n,onChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,error:r,...e.componentProps||{}}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"creatable-select":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsxs(Qt,{htmlFor:e.name,children:[e.label,e.required&&Ft.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Ft.jsx(hs,{options:e.options||[],value:n,onChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},onCreate:e.onCreate,placeholder:e.placeholder,searchPlaceholder:e.searchPlaceholder,createLabel:e.createLabel,emptyMessage:e.emptyMessage,disabled:e.disabled,error:r,mode:e.mode||"single"}),r&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"number":return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Qt,{htmlFor:e.name,children:e.label}),Ft.jsx(qt,{id:e.name,type:"number",value:null!=n?String(n):"",onChange:t=>{const n=t.target.value,r=""===n?null:Number(n);y(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&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);default:return Ft.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Ft.jsx(Qt,{htmlFor:e.name,children:e.label}),Ft.jsx(qt,{id:e.name,type:"text",value:n||"",onChange:t=>{y(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&&Ft.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name)}},j=s(()=>{if(!N)return null;if(N.disabled)return Ft.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Ft.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:Ft.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Ft.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),Ft.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),Ft.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(N.component){const e=N.component;return Ft.jsx(e,{formData:g,updateField:y,errors:x,users:f,disabled:N.disabled})}return Ft.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:N.fields.map(k)})},[N,g,y,x,f,k]),C=Ft.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[v.length>1&&Ft.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:Ft.jsx("div",{className:"flex space-x-2",children:v.map(e=>Ft.jsx(Vt,{variant:w===e.id?"action-primary":"action-secondary",size:"sm",onClick:()=>(e=>{const t=v.find(t=>t.id===e);t&&!t.disabled&&p(e)})(e.id),disabled:e.disabled,className:e.disabled?"opacity-50 cursor-not-allowed":"",children:e.title},e.id))})}),Ft.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:d?Ft.jsx("div",{className:"flex items-center justify-center py-12",children:Ft.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):Ft.jsxs("form",{onSubmit:b(i),className:"space-y-3 md:space-y-4",children:[j(),Ft.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Ft.jsx(Vt,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),Ft.jsx(Vt,{type:"submit",disabled:d,children:u})]})]})})]});return Ft.jsx(en,{open:c,onOpenChange:e=>{!1===e&&!0===c&&l()},children:Ft.jsxs(sn,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[Ft.jsxs(on,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[Ft.jsx(cn,{className:"text-white",children:e}),Ft.jsx(un,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),C]})})}function vs({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 Ft.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[Ft.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&Ft.jsxs(Ft.Fragment,{children:[Ft.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),Ft.jsxs(vn,{value:String(r),onValueChange:e=>s(Number(e)),children:[Ft.jsx(Nn,{className:"h-8 w-[70px]",children:Ft.jsx(wn,{})}),Ft.jsxs(Cn,{children:[Ft.jsx(Sn,{value:"10",children:"10"}),Ft.jsx(Sn,{value:"25",children:"25"}),Ft.jsx(Sn,{value:"50",children:"50"}),Ft.jsx(Sn,{value:"100",children:"100"})]})]})]})}),Ft.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[o,"-",l," de ",n," itens"]}),Ft.jsxs("div",{className:"flex items-center gap-1",children:[Ft.jsx(Vt,{variant:"outline",size:"sm",onClick:()=>a(1),disabled:1===e,className:"h-8 w-8 p-0",children:Ft.jsx(Re,{size:16})}),Ft.jsx(Vt,{variant:"outline",size:"sm",onClick:()=>a(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:Ft.jsx(fe,{size:16})}),Ft.jsxs("div",{className:"flex items-center gap-1 px-2",children:[Ft.jsx("span",{className:"text-sm font-medium",children:e}),Ft.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),Ft.jsx("span",{className:"text-sm font-medium",children:t})]}),Ft.jsx(Vt,{variant:"outline",size:"sm",onClick:()=>a(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:Ft.jsx(P,{size:16})}),Ft.jsx(Vt,{variant:"outline",size:"sm",onClick:()=>a(t),disabled:e===t,className:"h-8 w-8 p-0",children:Ft.jsx(_e,{size:16})})]})]})}function ws({manager:e}){return Ft.jsx(vs,{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 Ns=({selectedCount:e,onClearSelection:t,onBulkDelete:n,customActions:r=[],isLoading:a=!1})=>Ft.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[Ft.jsxs("div",{className:"flex items-center gap-3",children:[Ft.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),Ft.jsxs(Vt,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[Ft.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]}),Ft.jsxs("div",{className:"flex items-center gap-2",children:[r.map((e,t)=>{const n=e.icon;return Ft.jsxs(Vt,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:a,className:"h-7",children:[n&&Ft.jsx(n,{size:14,className:"mr-1"}),e.label]},t)}),n&&Ft.jsxs(Vt,{variant:"destructive",size:"sm",onClick:n,disabled:a,className:"h-7",children:[Ft.jsx(F,{size:14,className:"mr-1"}),"Remover"]})]})]}),ks={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},js={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},Cs={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function Ss({children:e,direction:t="column",gap:n="md",align:r="stretch",justify:a="start",wrap:s=!1,className:i}){return Ft.jsx("div",{className:Ot("flex","column"===t?"flex-col":"flex-row",ks[n],js[r],Cs[a],s&&"flex-wrap",i),children:e})}function Is({manager:e,filters:t,inline:n=!1}){const{isSearchVisible:r}=ea(),a=e.searchTerm,s=Ft.jsxs(Ft.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&Ft.jsxs("div",{className:"relative flex-1",children:[Ft.jsx(E,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Ft.jsx(qt,{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)=>Ft.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&&Ft.jsx("option",{value:"",children:e.placeholder}),e.options.map(e=>Ft.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 Ft.jsx("div",{className:n?"":"w-full sm:w-auto",children:Ft.jsx(r,{...e.props})},`custom-${t}`)}),a&&Ft.jsxs(Vt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[Ft.jsx(N,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return n?Ft.jsx("div",{className:"flex items-center gap-2",children:s}):Ft.jsx(Ss,{direction:"column",gap:"md",className:"mb-6",children:Ft.jsx(Ss,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:s})})}function Es({manager:e,config:t,formSections:n,onSave:r,onToggleStatus:s,defaultSort:o}){const{setSearchVisible:l}=ea(),[c,u]=st(),[d,f]=a(!1),[m,p]=a(null),[h,g]=a({isOpen:!1,entityId:null,entityName:""}),[x,y]=a({isOpen:!1,count:0});i(()=>(l(!0),()=>{l(!1)}),[l]),i(()=>{if(o&&!c.has("sortField")&&!c.has("sortDirection")){const e=new URLSearchParams(c);e.set("sortField",o.column),e.set("sortDirection",o.direction),u(e,{replace:!0})}},[]);return Ft.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[t.enableBulkActions&&e.selectedIds.length>0&&Ft.jsx(Ns,{selectedCount:e.selectedIds.length,onClearSelection:e.clearSelection,onBulkDelete:()=>{y({isOpen:!0,count:e.selectedIds.length})},customActions:t.bulkActions,isLoading:e.isBulkDeleting}),Ft.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[Ft.jsxs("div",{className:"flex items-center gap-2",children:[Ft.jsxs(Vt,{onClick:()=>{t.onNew?t.onNew():(p(null),f(!0))},children:[Ft.jsx(pe,{size:16,className:"mr-2"}),"Novo"]}),t.customActions?.map((e,t)=>Ft.jsxs(Vt,{onClick:e.action,variant:e.variant||"outline",children:[e.icon&&Ft.jsx(e.icon,{size:16,className:"mr-2"}),e.label]},t))]}),t.filters&&t.filters.length>0&&Ft.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:Ft.jsx(Is,{manager:e,filters:t.filters,inline:!0})})]}),Ft.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:t.customListView?Ft.jsx("div",{className:"flex-1 overflow-auto p-4",children:t.customListView(e.entities,e)}):Ft.jsx(Ya,{manager:e,columns:t.columns,onEdit:e=>{t.onEdit?t.onEdit(e):(p(e),f(!0))},onDelete:e=>{g({isOpen:!0,entityId:e.id,entityName:e.title||e.name||"Item"})},onToggleStatus:s,enableBulkActions:t.enableBulkActions})}),Ft.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:Ft.jsx(ws,{manager:e})}),!t.useCustomRouting&&Ft.jsx(bs,{open:d,title:m?`Editar ${t.entityName}`:`Novo ${t.entityName}`,sections:n,initialData:m||void 0,onSubmit:e=>{r(e),f(!1),p(null)},onCancel:()=>{f(!1),p(null)},isLoading:e.isLoading,submitButtonText:m?"Atualizar":"Criar"}),Ft.jsx(pa,{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}),Ft.jsx(pa,{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 Ts(e){return()=>{const{manager:t,config:n,onSave:r,onEdit:a,onToggleStatus:s}=e,i={entityName:n.entityName,entityNamePlural:n.entityNamePlural,filters:n.filters||[],columns:n.columns,cardFields:n.cardFields||[],enableBulkActions:n.enableBulkActions??!1,bulkActions:n.bulkActions||[],customActions:n.customActions,customListView:n.customListView,onEdit:a||n.onEdit};return Ft.jsx(Es,{manager:t,config:i,formSections:n.formSections,onSave:r,onToggleStatus:s,defaultSort:n.defaultSort})}}function Ps(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 As(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:_s(e),label:_s(e),...Rs(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 Rs(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 _s(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const Ds={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 Fs(e,t,n={}){const r=Ds[e];return As(r.title,t,{...r,...n})}const zs=({children:e})=>{const{isAuthenticated:n,isLoading:r}=ea();if(t.useEffect(()=>{if(!n)return;const e=()=>{or.areAllTokensValid()||Xr.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),t.useEffect(()=>{if(r)return;if(n)return;if(or.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=Ar();(async()=>{s?await Xr.loginDev():Xr.loginProd()})()},[n,r]),r)return Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Kt,{className:"w-full max-w-md",children:[Ft.jsx(Yt,{className:"text-center",children:Ft.jsx(Jt,{className:"text-xl font-semibold",children:"Carregando..."})}),Ft.jsxs(Gt,{className:"text-center",children:[Ft.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ft.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 Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Kt,{className:"w-full max-w-md",children:[Ft.jsx(Yt,{className:"text-center",children:Ft.jsx(Jt,{className:"text-xl font-semibold",children:"Processando..."})}),Ft.jsxs(Gt,{className:"text-center",children:[Ft.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ft.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(or.areAllTokensValid())return Ft.jsx(Ft.Fragment,{children:e})}catch{}return Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Kt,{className:"w-full max-w-md",children:[Ft.jsx(Yt,{className:"text-center",children:Ft.jsx(Jt,{className:"text-xl font-semibold",children:"Iniciando..."})}),Ft.jsxs(Gt,{className:"text-center",children:[Ft.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Ft.jsx("p",{className:"text-muted-foreground",children:Ar()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return Ft.jsx(Ft.Fragment,{children:e})},Os=m("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"}}),Ls=e.forwardRef(({className:e,variant:t,...n},r)=>Ft.jsx("div",{ref:r,role:"alert",className:Ot(Os({variant:t}),e),...n}));Ls.displayName="Alert";const Ms=e.forwardRef(({className:e,...t},n)=>Ft.jsx("h5",{ref:n,className:Ot("mb-1 font-medium leading-none tracking-tight",e),...t}));Ms.displayName="AlertTitle";const Us=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,className:Ot("text-sm [&_p]:leading-relaxed",e),...t}));Us.displayName="AlertDescription";const $s=()=>{const{processCallback:e}=ea(),[t,n]=a(null),[r,s]=a(!1);i(()=>{(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 n("Falha na autenticação. Tente novamente.")}catch(t){n(t?.message||"Erro durante a autenticação. Tente novamente.")}})()},[e]);const o=async()=>{s(!0),n(null);try{await e()||n("Falha na autenticação. Tente novamente.")}catch(t){n(t?.message||"Erro ao tentar novamente.")}finally{s(!1)}},l=()=>{window.location.href="/"};return t?Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Kt,{className:"w-full max-w-md",children:[Ft.jsx(Yt,{className:"text-center",children:Ft.jsxs(Jt,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[Ft.jsx(I,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),Ft.jsxs(Gt,{className:"space-y-4",children:[Ft.jsx(Ls,{variant:"destructive",children:Ft.jsx(Us,{children:t})}),Ft.jsx("div",{className:"text-sm text-muted-foreground",children:Ft.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),Ft.jsxs("div",{className:"flex gap-2",children:[Ft.jsx(Vt,{onClick:o,disabled:r,className:"flex-1",children:r?Ft.jsxs(Ft.Fragment,{children:[Ft.jsx(Rn,{size:"sm",className:"mr-2"}),"Tentando..."]}):Ft.jsxs(Ft.Fragment,{children:[Ft.jsx(De,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),Ft.jsx(Vt,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Kt,{className:"w-full max-w-md",children:[Ft.jsx(Yt,{className:"text-center",children:Ft.jsx(Jt,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),Ft.jsxs(Gt,{className:"text-center",children:[Ft.jsx("div",{className:"flex justify-center mb-4",children:Ft.jsx(Rn,{size:"lg"})}),Ft.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},Bs=()=>Ft.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Ft.jsxs(Kt,{className:"w-full max-w-md",children:[Ft.jsx(Yt,{className:"text-center",children:Ft.jsx(Jt,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),Ft.jsxs(Gt,{className:"text-center space-y-4",children:[Ft.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),Ft.jsx(Vt,{onClick:async()=>{Ar()?await Xr.loginDev():Xr.loginProd()},className:"w-full",size:"lg",children:Ar()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),Vs=n(void 0);function Hs({children:e}){const[t,n]=a({});return Ft.jsx(Vs.Provider,{value:{metadata:t,setMetadata:n,clearMetadata:()=>n({})},children:e})}function qs(){const e=r(Vs);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function Ws(e){const{setMetadata:t,clearMetadata:n}=qs();i(()=>(t(e),()=>n()),[e.title,e.subtitle,t,n])}function Qs(e){return{queryClient:e.queryClient||new at({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const Ks=mt.Root,Ys=e.forwardRef(({className:e,...t},n)=>Ft.jsx(mt.Item,{ref:n,className:Ot("border-b",e),...t}));Ys.displayName="AccordionItem";const Js=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsx(mt.Header,{className:"flex",children:Ft.jsxs(mt.Trigger,{ref:r,className:Ot("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,Ft.jsx(k,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Js.displayName=mt.Trigger.displayName;const Xs=e.forwardRef(({className:e,children:t,...n},r)=>Ft.jsx(mt.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:Ft.jsx("div",{className:Ot("pb-4 pt-0",e),children:t})}));Xs.displayName=mt.Content.displayName;const Gs=pt.Root,Zs=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ht.Root,{ref:n,className:Ot("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));Zs.displayName=ht.Root.displayName;const ei=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ht.Image,{ref:n,className:Ot("aspect-square h-full w-full",e),...t}));ei.displayName=ht.Image.displayName;const ti=e.forwardRef(({className:e,...t},n)=>Ft.jsx(ht.Fallback,{ref:n,className:Ot("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));ti.displayName=ht.Fallback.displayName;const ni=e.forwardRef(({...e},t)=>Ft.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));ni.displayName="Breadcrumb";const ri=e.forwardRef(({className:e,...t},n)=>Ft.jsx("ol",{ref:n,className:Ot("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));ri.displayName="BreadcrumbList";const ai=e.forwardRef(({className:e,...t},n)=>Ft.jsx("li",{ref:n,className:Ot("inline-flex items-center gap-1.5",e),...t}));ai.displayName="BreadcrumbItem";const si=e.forwardRef(({asChild:t,className:n,...r},a)=>{const s=t?e.Fragment:"a";return Ft.jsx(s,{ref:a,className:Ot("transition-colors hover:text-foreground",n),...r})});si.displayName="BreadcrumbLink";const ii=e.forwardRef(({className:e,...t},n)=>Ft.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:Ot("font-normal text-foreground",e),...t}));ii.displayName="BreadcrumbPage";const oi=({children:e,className:t,...n})=>Ft.jsx("li",{role:"presentation","aria-hidden":"true",className:Ot("[&>svg]:size-3.5",t),...n,children:e??Ft.jsx(P,{})});oi.displayName="BreadcrumbSeparator";const li=({className:e,...t})=>Ft.jsxs("span",{role:"presentation","aria-hidden":"true",className:Ot("flex h-9 w-9 items-center justify-center",e),...t,children:[Ft.jsx(Fe,{className:"h-4 w-4"}),Ft.jsx("span",{className:"sr-only",children:"More"})]});function ci(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function ui(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 di(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)}}}li.displayName="BreadcrumbEllipsis";const fi={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"}},mi={date:ci({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:ci({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:ci({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},pi={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"},hi={ordinalNumber:(e,t)=>{const n=Number(e);return"week"===t?.unit?n+"ª":n+"º"},era:ui({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:ui({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:ui({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:ui({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:ui({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"})},gi={ordinalNumber:(xi={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(xi.matchPattern);if(!n)return null;const r=n[0],a=e.match(xi.parsePattern);if(!a)return null;let s=xi.valueCallback?xi.valueCallback(a[0]):a[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:di({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:di({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:di({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:di({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:di({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 xi;const yi={code:"pt-BR",formatDistance:(e,t,n)=>{let r;const a=fi[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:mi,formatRelative:(e,t,n,r)=>{const a=pi[e];return"function"==typeof a?a(t):a},localize:hi,match:gi,options:{weekStartsOn:0,firstWeekContainsDate:1}};function bi({className:e,classNames:t,showOutsideDays:n=!0,...r}){return Ft.jsx(gt,{showOutsideDays:n,className:Ot("p-3",e),locale:yi,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:Ot(Bt({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:Ot(Bt({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})=>Ft.jsx(fe,{className:"h-4 w-4"}),IconRight:({...e})=>Ft.jsx(P,{className:"h-4 w-4"})},...r})}bi.displayName="Calendar";const vi=xt.Root,wi=xt.CollapsibleTrigger,Ni=xt.CollapsibleContent;const ki={Root:function({children:e,className:t}){return Ft.jsx("div",{className:Ot("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:n}){return Ft.jsx(Kt,{className:Ot("transition-colors",t&&"cursor-pointer hover:bg-muted/50",n),onClick:t,children:Ft.jsx(Gt,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:n}){return Ft.jsxs("div",{className:Ot("flex justify-between items-center text-sm",n),children:[Ft.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),Ft.jsx("span",{className:"text-foreground",children:t})]})}},ji={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4",5:"grid-cols-5",6:"grid-cols-6","auto-fit":"grid-cols-[repeat(auto-fit,minmax(250px,1fr))]","auto-fill":"grid-cols-[repeat(auto-fill,minmax(250px,1fr))]"},Ci={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function Si({children:e,cols:t="auto-fit",gap:n="md",className:r}){return Ft.jsx("div",{className:Ot("grid",ji[t],Ci[n],r),children:e})}function Ii({items:e,maxItems:t=3,className:n}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,Ft.jsx(ni,{className:n})}function Ei(){const e=it();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 Ti=({className:e,...t})=>Ft.jsx("nav",{role:"navigation","aria-label":"pagination",className:Ot("mx-auto flex w-full justify-center",e),...t});Ti.displayName="Pagination";const Pi=e.forwardRef(({className:e,...t},n)=>Ft.jsx("ul",{ref:n,className:Ot("flex flex-row items-center gap-1",e),...t}));Pi.displayName="PaginationContent";const Ai=e.forwardRef(({className:e,...t},n)=>Ft.jsx("li",{ref:n,className:Ot("",e),...t}));Ai.displayName="PaginationItem";const Ri=({className:e,isActive:t,size:n="icon",...r})=>Ft.jsx("a",{"aria-current":t?"page":void 0,className:Ot(Bt({variant:t?"outline":"ghost",size:n}),e),...r});Ri.displayName="PaginationLink";const _i=({className:e,...t})=>Ft.jsxs(Ri,{"aria-label":"Go to previous page",size:"default",className:Ot("gap-1 pl-2.5",e),...t,children:[Ft.jsx(fe,{className:"h-4 w-4"}),Ft.jsx("span",{children:"Previous"})]});_i.displayName="PaginationPrevious";const Di=({className:e,...t})=>Ft.jsxs(Ri,{"aria-label":"Go to next page",size:"default",className:Ot("gap-1 pr-2.5",e),...t,children:[Ft.jsx("span",{children:"Next"}),Ft.jsx(P,{className:"h-4 w-4"})]});Di.displayName="PaginationNext";const Fi=({className:e,...t})=>Ft.jsxs("span",{"aria-hidden":!0,className:Ot("flex h-9 w-9 items-center justify-center",e),...t,children:[Ft.jsx(Fe,{className:"h-4 w-4"}),Ft.jsx("span",{className:"sr-only",children:"More pages"})]});Fi.displayName="PaginationEllipsis";const zi=e.forwardRef(({className:e,value:t,...n},r)=>Ft.jsx(yt.Root,{ref:r,className:Ot("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:Ft.jsx(yt.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));zi.displayName=yt.Root.displayName;const Oi=e.forwardRef(({className:e,...t},n)=>Ft.jsx(bt.Root,{className:Ot("grid gap-2",e),...t,ref:n}));Oi.displayName=bt.Root.displayName;const Li=e.forwardRef(({className:e,...t},n)=>Ft.jsx(bt.Item,{ref:n,className:Ot("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:Ft.jsx(bt.Indicator,{className:"flex items-center justify-center",children:Ft.jsx(A,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Li.displayName=bt.Item.displayName;const Mi=e.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>Ft.jsx(vt.Root,{ref:a,decorative:n,orientation:t,className:Ot("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Mi.displayName=vt.Root.displayName;const Ui=Qe.Root,$i=Qe.Trigger,Bi=Qe.Close,Vi=Qe.Portal,Hi=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Qe.Overlay,{className:Ot("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}));Hi.displayName=Qe.Overlay.displayName;const qi=m("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"}}),Wi=e.forwardRef(({side:e="right",className:t,children:n,...r},a)=>Ft.jsxs(Vi,{children:[Ft.jsx(Hi,{}),Ft.jsxs(Qe.Content,{ref:a,className:Ot(qi({side:e}),t),...r,children:[n,Ft.jsxs(Qe.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:[Ft.jsx(N,{className:"h-4 w-4"}),Ft.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Wi.displayName=Qe.Content.displayName;const Qi=({className:e,...t})=>Ft.jsx("div",{className:Ot("flex flex-col space-y-2 text-center sm:text-left",e),...t});Qi.displayName="SheetHeader";const Ki=({className:e,...t})=>Ft.jsx("div",{className:Ot("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ki.displayName="SheetFooter";const Yi=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Qe.Title,{ref:n,className:Ot("text-lg font-semibold text-foreground",e),...t}));Yi.displayName=Qe.Title.displayName;const Ji=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Qe.Description,{ref:n,className:Ot("text-sm text-muted-foreground",e),...t}));Ji.displayName=Qe.Description.displayName;const Xi=wt.Provider,Gi=wt.Root,Zi=wt.Trigger,eo=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Ft.jsx(wt.Content,{ref:r,sideOffset:t,className:Ot("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}));eo.displayName=wt.Content.displayName;const to="sidebar:state",no=e.createContext(null);function ro(){const t=e.useContext(no);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const ao=e.forwardRef(({defaultOpen:t=!0,open:n,onOpenChange:r,className:a,style:s,children:i,...o},l)=>{const[c,u]=e.useState(!1);e.useEffect(()=>{const e=()=>u(window.innerWidth<768);return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[d,f]=e.useState(!1),[m,p]=e.useState(()=>{if("undefined"!=typeof window){const e=localStorage.getItem(to);return null!==e?"true"===e:t}return t}),h=n??m,g=e.useCallback(e=>{const t="function"==typeof e?e(h):e;r?r(t):p(t),"undefined"!=typeof window&&localStorage.setItem(to,String(t))},[r,h]),x=e.useCallback(()=>c?f(e=>!e):g(e=>!e),[c,g,f]);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:d,setOpenMobile:f,toggleSidebar:x}),[y,h,g,c,d,f,x]);return Ft.jsx(no.Provider,{value:b,children:Ft.jsx(Xi,{delayDuration:0,children:Ft.jsx("div",{className:Ot("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})})})});ao.displayName="SidebarProvider";const so=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:u}=ro();return"none"===n?Ft.jsx("div",{className:Ot("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:a}):o?Ft.jsx(Ui,{open:c,onOpenChange:u,...s,children:Ft.jsxs(Wi,{"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:[Ft.jsx(Yi,{className:"sr-only",children:"Menu de Navegação"}),Ft.jsx("div",{className:"flex h-full w-full flex-col",children:a})]})}):Ft.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:[Ft.jsx("div",{className:Ot("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]")}),Ft.jsx("div",{className:Ot("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:Ft.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})})]})});so.displayName="Sidebar";const io=e.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:a}=ro();return Ft.jsxs(Vt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Ot("h-7 w-7",e),onClick:e=>{t?.(e),a()},...n,children:[Ft.jsx(ze,{}),Ft.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});io.displayName="SidebarTrigger";const oo=e.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=ro();return Ft.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Ot("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})});oo.displayName="SidebarRail";const lo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("main",{ref:n,className:Ot("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}));lo.displayName="SidebarInset";const co=e.forwardRef(({className:e,...t},n)=>Ft.jsx(qt,{ref:n,"data-sidebar":"input",className:Ot("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));co.displayName="SidebarInput";const uo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"header",className:Ot("flex flex-col gap-2 p-2",e),...t}));uo.displayName="SidebarHeader";const fo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"footer",className:Ot("flex flex-col gap-2 p-2",e),...t}));fo.displayName="SidebarFooter";const mo=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Mi,{ref:n,"data-sidebar":"separator",className:Ot("mx-2 w-auto bg-sidebar-border",e),...t}));mo.displayName="SidebarSeparator";const po=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"content",className:Ot("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));po.displayName="SidebarContent";const ho=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"group",className:Ot("relative flex w-full min-w-0 flex-col p-2",e),...t}));ho.displayName="SidebarGroup";const go=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?d:"div";return Ft.jsx(a,{ref:r,"data-sidebar":"group-label",className:Ot("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})});go.displayName="SidebarGroupLabel";const xo=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?d:"button";return Ft.jsx(a,{ref:r,"data-sidebar":"group-action",className:Ot("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})});xo.displayName="SidebarGroupAction";const yo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"group-content",className:Ot("w-full text-sm",e),...t}));yo.displayName="SidebarGroupContent";const bo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("ul",{ref:n,"data-sidebar":"menu",className:Ot("flex w-full min-w-0 flex-col gap-1",e),...t}));bo.displayName="SidebarMenu";const vo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("li",{ref:n,"data-sidebar":"menu-item",className:Ot("group/menu-item relative",e),...t}));vo.displayName="SidebarMenuItem";const wo=m("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-primary data-[active=true]:font-medium data-[active=true]:text-sidebar-primary-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 group-data-[collapsible=icon]:[&>*]:!mr-0 group-data-[collapsible=icon]:[&>*]:!ml-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-10 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),No=e.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:a,className:s,...i},o)=>{const l=e?d:"button",{isMobile:c,state:u}=ro(),f=Ft.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:Ot(wo({variant:n,size:r}),s),...i});return a?("string"==typeof a&&(a={children:a}),Ft.jsxs(Gi,{children:[Ft.jsx(Zi,{asChild:!0,children:f}),Ft.jsx(eo,{side:"right",align:"center",hidden:"collapsed"!==u||c,...a})]})):f});No.displayName="SidebarMenuButton";const ko=e.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},a)=>{const s=t?d:"button";return Ft.jsx(s,{ref:a,"data-sidebar":"menu-action",className:Ot("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})});ko.displayName="SidebarMenuAction";const jo=e.forwardRef(({className:e,...t},n)=>Ft.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:Ot("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}));jo.displayName="SidebarMenuBadge";const Co=e.forwardRef(({className:t,showIcon:n=!1,...r},a)=>{const s=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return Ft.jsxs("div",{ref:a,"data-sidebar":"menu-skeleton",className:Ot("rounded-md h-8 flex gap-2 px-2 items-center",t),...r,children:[n&&Ft.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),Ft.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":s}})]})});Co.displayName="SidebarMenuSkeleton";const So=e.forwardRef(({className:e,...t},n)=>Ft.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:Ot("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}));So.displayName="SidebarMenuSub";const Io=e.forwardRef(({...e},t)=>Ft.jsx("li",{ref:t,...e}));Io.displayName="SidebarMenuSubItem";const Eo=e.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...a},s)=>{const i=e?d:"a";return Ft.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:Ot("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})});Eo.displayName="SidebarMenuSubButton";const To=e.forwardRef(({className:e,...t},n)=>Ft.jsxs(Nt.Root,{ref:n,className:Ot("relative flex w-full touch-none select-none items-center",e),...t,children:[Ft.jsx(Nt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:Ft.jsx(Nt.Range,{className:"absolute h-full bg-primary"})}),Ft.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"})]}));To.displayName=Nt.Root.displayName;const Po=({...e})=>{const{theme:t="system"}=kt();return Ft.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 Ao(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function Ro(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function _o(...t){return e.useCallback(function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=Ro(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():Ro(e[t],null)}}}}(...t),t)}function Do(...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 Fo=globalThis?.document?e.useLayoutEffect:()=>{},zo=e[" useInsertionEffect ".trim().toString()]||Fo;function Oo({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 zo(()=>{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 u=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,u]}var Lo=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((t,n)=>{const r=f(`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),Ft.jsx(i,{...s,ref:t})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{}),Mo="Switch",[Uo]=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 Ft.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}\``)}]},Do(a,...n)]}(Mo),[$o,Bo]=Uo(Mo),Vo=e.forwardRef((t,n)=>{const{__scopeSwitch:r,name:a,checked:s,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:u,form:d,...f}=t,[m,p]=e.useState(null),h=_o(n,e=>p(e)),g=e.useRef(!1),x=!m||(d||!!m.closest("form")),[y,b]=Oo({prop:s,defaultProp:i??!1,onChange:u,caller:Mo});return Ft.jsxs($o,{scope:r,checked:y,disabled:l,children:[Ft.jsx(Lo.button,{type:"button",role:"switch","aria-checked":y,"aria-required":o,"data-state":Qo(y),"data-disabled":l?"":void 0,disabled:l,value:c,...f,ref:h,onClick:Ao(t.onClick,e=>{b(e=>!e),x&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),x&&Ft.jsx(Wo,{control:m,bubbles:!g.current,name:a,value:c,checked:y,required:o,disabled:l,form:d,style:{transform:"translateX(-100%)"}})]})});Vo.displayName=Mo;var Ho="SwitchThumb",qo=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Bo(Ho,n);return Ft.jsx(Lo.span,{"data-state":Qo(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});qo.displayName=Ho;var Wo=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:a=!0,...s},i)=>{const o=e.useRef(null),l=_o(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),u=function(t){const[n,r]=e.useState(void 0);return Fo(()=>{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]),Ft.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:l,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Qo(e){return e?"checked":"unchecked"}Wo.displayName="SwitchBubbleInput";var Ko=Vo,Yo=qo;const Jo=e.forwardRef(({className:e,...t},n)=>Ft.jsx(Ko,{className:Ot("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:Ft.jsx(Yo,{className:Ot("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")})}));Jo.displayName=Ko.displayName;const Xo=jt.Root,Go=e.forwardRef(({className:e,...t},n)=>Ft.jsx(jt.List,{ref:n,className:Ot("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Go.displayName=jt.List.displayName;const Zo=e.forwardRef(({className:e,...t},n)=>Ft.jsx(jt.Trigger,{ref:n,className:Ot("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}));Zo.displayName=jt.Trigger.displayName;const el=e.forwardRef(({className:e,...t},n)=>Ft.jsx(jt.Content,{ref:n,className:Ot("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 tl({children:e,className:t}){return Ft.jsx("div",{className:Ot("flex flex-col h-full",t),children:Ft.jsx(ns,{className:"flex-1",children:Ft.jsx("div",{className:"space-y-6 p-6",children:e})})})}function nl({title:e,description:t,actions:n,className:r}){return Ft.jsxs("div",{className:Ot("space-y-4",r),children:[Ft.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[Ft.jsxs("div",{className:"space-y-1",children:[Ft.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&Ft.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),n&&Ft.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:n})]}),Ft.jsx(Mi,{})]})}function rl({children:e,className:t}){return Ft.jsx("div",{className:Ot("space-y-6",t),children:e})}el.displayName=jt.Content.displayName;const al=m("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"}}),sl=e.forwardRef(({className:e,variant:t,size:n,...r},a)=>Ft.jsx(Ct.Root,{ref:a,className:Ot(al({variant:t,size:n,className:e})),...r}));sl.displayName=Ct.Root.displayName;const il=e.createContext({size:"default",variant:"default"}),ol=e.forwardRef(({className:e,variant:t,size:n,children:r,...a},s)=>Ft.jsx(St.Root,{ref:s,className:Ot("flex items-center justify-center gap-1",e),...a,children:Ft.jsx(il.Provider,{value:{variant:t,size:n},children:r})}));ol.displayName=St.Root.displayName;const ll=e.forwardRef(({className:t,children:n,variant:r,size:a,...s},i)=>{const o=e.useContext(il);return Ft.jsx(St.Item,{ref:i,className:Ot(al({variant:o.variant||r,size:o.size||a}),t),...s,children:n})});function cl({data:e,columns:t,sortField:n,sortDirection:r,onSort:a,onRowClick:s,renderActions:i,isLoading:l=!1,emptyMessage:c="Nenhum item encontrado",className:u,enableSelection:d=!1,selectedIds:f=[],onSelectItem:m,onSelectAll:p,isAllSelected:h=!1}){const g=o(()=>{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?Ft.jsx("div",{className:"flex-1 overflow-auto",children:Ft.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>Ft.jsx(ka,{className:"h-12 w-full"},t))})}):0===e.length?Ft.jsx("div",{className:"flex-1 flex items-center justify-center",children:Ft.jsx("div",{className:"text-center text-muted-foreground",children:Ft.jsx("p",{children:c})})}):Ft.jsx("div",{className:"flex-1 overflow-auto",children:Ft.jsxs(ha,{className:u,children:[Ft.jsx(ga,{className:"sticky top-0 bg-background z-10",children:Ft.jsxs(ba,{children:[d&&Ft.jsx(va,{className:"w-12",children:Ft.jsx(In,{checked:h,onCheckedChange:p,"aria-label":"Selecionar todos"})}),t.map((e,t)=>{return Ft.jsx(va,{className:e.className,style:{width:g[t]},children:e.sortable&&a?Ft.jsxs("button",{onClick:()=>a(String(e.key)),className:"flex items-center hover:text-foreground transition-colors font-medium",children:[e.header,(s=String(e.key),n!==s?Ft.jsx(z,{size:14,className:"ml-1 opacity-50"}):"asc"===r?Ft.jsx(O,{size:14,className:"ml-1"}):Ft.jsx(L,{size:14,className:"ml-1"}))]}):Ft.jsx("span",{className:"font-medium",children:e.header})},String(e.key));var s}),i&&Ft.jsx(va,{className:"w-20 text-right",children:"Ações"})]})}),Ft.jsx(xa,{children:e.map(e=>Ft.jsxs(ba,{onClick:()=>s?.(e),className:s?"cursor-pointer":"",children:[d&&Ft.jsx(wa,{children:Ft.jsx(In,{checked:f.includes(e.id),onCheckedChange:()=>m?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${e.id}`})}),t.map(t=>Ft.jsx(wa,{className:t.className,children:t.render?t.render(e):String(e[t.key]??"-")},String(t.key))),i&&Ft.jsx(wa,{className:"text-right",onClick:e=>e.stopPropagation(),children:i(e)})]},e.id))})]})})}function ul({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:R,label:"Editar",onClick:e,variant:"default"}),n&&c.push({icon: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?Ft.jsxs(Aa,{children:[Ft.jsx(Ra,{asChild:!0,children:Ft.jsx(Vt,{variant:"ghost",size:"compact"===l?"sm":"default",className:"compact"===l?"h-7 px-2":"",children:Ft.jsx(w,{size:"compact"===l?14:16})})}),Ft.jsx(Ma,{align:"end",className:"bg-background",children:c.map((e,t)=>Ft.jsxs(Ua,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&Ft.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))})]}):Ft.jsx("div",{className:"flex items-center gap-1",children:c.map((e,t)=>Ft.jsxs(Vt,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===l?"sm":"default",onClick:e.onClick,className:"compact"===l?"h-7 px-2":"",children:[e.icon&&Ft.jsx(e.icon,{size:"compact"===l?14:16}),"compact"!==l&&Ft.jsx("span",{className:"ml-1",children:e.label})]},t))})}function dl({searchValue:e="",onSearchChange:t,customFilters:n=[],onClearFilters:r,showClearButton:a=!0,layout:s="horizontal"}){const i=e||n.length>0;return Ft.jsxs("div",{className:`flex ${"vertical"===s?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&Ft.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[Ft.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Ft.jsx(qt,{type:"text",placeholder:"Buscar...",value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),n.map((e,t)=>Ft.jsx("div",{className:"vertical"===s?"w-full":"",children:e},t)),a&&i&&r&&Ft.jsxs(Vt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[Ft.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]})}function fl({data:e,renderCard:t,isLoading:n=!1,emptyMessage:r="Nenhum item encontrado",columns:a,gap:s="md",className:i}){return n?Ft.jsx(Si,{cols:a?String(a):"auto-fit",gap:s,className:i,children:[...Array(6)].map((e,t)=>Ft.jsx(ka,{className:"h-48 w-full"},t))}):0===e.length?Ft.jsx("div",{className:"flex items-center justify-center p-8",children:Ft.jsx("div",{className:"text-center text-muted-foreground",children:Ft.jsx("p",{children:r})})}):Ft.jsx(Si,{cols:a?String(a):"auto-fit",gap:s,className:i,children:e.map(t)})}function ml({manager:e,config:t,onEdit:n,onDelete:r}){return e.isLoading?Ft.jsx(Si,{children:Array.from({length:3}).map((e,t)=>Ft.jsxs(Kt,{children:[Ft.jsxs(Yt,{children:[Ft.jsx(ka,{className:"h-4 w-3/4"}),Ft.jsx(ka,{className:"h-3 w-1/2"})]}),Ft.jsx(Gt,{children:Ft.jsxs("div",{className:"space-y-2",children:[Ft.jsx(ka,{className:"h-3 w-full"}),Ft.jsx(ka,{className:"h-3 w-2/3"})]})})]},t))}):Ft.jsx(ki.Root,{children:e.entities.map(e=>Ft.jsxs(ki.Item,{onClick:()=>n(e),children:[Ft.jsx(Yt,{className:"pb-3",children:Ft.jsxs("div",{className:"flex items-start justify-between",children:[Ft.jsxs("div",{className:"flex-1 min-w-0",children:[Ft.jsx(Jt,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),Ft.jsx(Xt,{className:"text-sm",children:y(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:yi})})]}),Ft.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&Ft.jsx(Vt,{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:Ft.jsx(Oe,{className:"h-4 w-4"})}),Ft.jsx("div",{onClick:e=>e.stopPropagation(),children:Ft.jsx(Qa,{onEdit:()=>n(e),onDelete:r?()=>r(e):void 0,canDelete:!!r})})]})]})}),Ft.jsx(Gt,{className:"pt-0",children:Ft.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const n=e[t.key];return n?Ft.jsx(ki.Field,{label:t.label,value:t.render?t.render(n,e):String(n)},String(t.key)):null})})})]},e.id))})}function pl(e){const t=ot();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 hl(e,t){const n=pl({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:n.onNew,onEdit:n.onEdit}}ll.displayName=St.Item.displayName;const gl=t.memo(({variant:e="card",className:n="",selectedUnit:r,onUnitChange:a})=>{const{user:s,companies:i,alias:o,isAuthenticated:l,logout:c,switchUnit:u}=ea(),d=i?.[0]||null,f=o?i?.find(e=>e.alias===o):d,m=i||[],p=r||f||d||d,h=t.useCallback(e=>{a?a(e):u(e)},[a,u]),g=t.useMemo(()=>{if(!m?.length)return[];const e=new Map;m.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},[m,p?.alias]);if(!l||!s)return null;const x=()=>Ft.jsxs(Ft.Fragment,{children:[Ft.jsxs("div",{className:"flex items-center space-x-3",children:[Ft.jsx("div",{className:"flex-shrink-0",children:Ft.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:Ft.jsx(Ie,{className:"h-5 w-5 text-primary-foreground"})})}),Ft.jsxs("div",{className:"flex-1 min-w-0",children:[Ft.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),Ft.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&Ft.jsx("div",{className:"mt-3",children:Ft.jsxs("div",{className:"flex items-center space-x-2",children:[Ft.jsx(Le,{className:"h-4 w-4 text-muted-foreground"}),Ft.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),g.length>1&&Ft.jsxs("div",{className:"mt-2",children:[Ft.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",g.length]}),Ft.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,3).map(e=>Ft.jsx(Pn,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),g.length>3&&Ft.jsxs(Pn,{variant:"outline",className:"text-xs",children:["+",g.length-3]})]})]})]});return"dropdown"===e?Ft.jsxs(Aa,{children:[Ft.jsx(Ra,{asChild:!0,children:Ft.jsx(Vt,{variant:"ghost",className:`h-auto p-2 ${n}`,children:Ft.jsxs("div",{className:"flex items-center space-x-2",children:[Ft.jsxs("div",{className:"hidden md:block text-left",children:[Ft.jsx("p",{className:"text-sm font-medium",children:s.name}),Ft.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),Ft.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:Ft.jsx(Ie,{className:"h-4 w-4 text-primary-foreground"})}),Ft.jsx(k,{className:"h-4 w-4"})]})})}),Ft.jsxs(Ma,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[Ft.jsxs(Fa,{children:[Ft.jsxs(Oa,{children:[Ft.jsx(De,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),Ft.jsx(La,{children:g.map(e=>Ft.jsxs(Ua,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[Ft.jsx(Le,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&Ft.jsx(Pn,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Ft.jsx(Ha,{}),Ft.jsxs(Ua,{onClick:c,children:[Ft.jsx(Me,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):Ft.jsxs(Kt,{className:n,children:[Ft.jsx(Yt,{children:Ft.jsx(Jt,{className:"text-lg",children:"Informações do Usuário"})}),Ft.jsxs(Gt,{className:"space-y-4",children:[Ft.jsx(x,{}),Ft.jsx(Mi,{}),Ft.jsxs(Vt,{variant:"outline",onClick:c,size:"sm",className:"w-full",children:[Ft.jsx(Me,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),xl=n({});function yl({children:e,config:t}){const n=o(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return Ft.jsx(xl.Provider,{value:n,children:e})}function bl(){return r(xl)}function vl(){const e=it(),{navigation:t}=bl();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 wl(e,t){const[n,r]=a(e),o=c(),l=s(()=>{o.current&&(clearTimeout(o.current),o.current=void 0)},[]);return i(()=>(l(),o.current=setTimeout(()=>{r(e)},t),l),[e,t,l]),[n,l]}const Nl=l(function({actions:e}){const t=it(),n=vl(),{navigation:r,appName:s}=bl(),{metadata:o}=qs(),{companies:l,alias:c,isSearchVisible:u,clearSearch:d,refreshData:f,switchUnit:m}=ea(),p=c?l?.find(e=>e.alias===c)||l?.[0]||null:l?.[0]||null,[h,g]=st(),[x,y]=a(()=>h.get("search")||""),[b,v]=wl(x,Pr.debounceDelay);i(()=>{if(!u)return;const e=new URLSearchParams(h);b?(e.set("search",b),e.set("page","1")):e.delete("search"),g(e)},[b,g,u]);const w=r?.find(e=>e.path===t.pathname)||r?.find(e=>t.pathname.startsWith(e.path+"/")),k=o.title||n,j=o.subtitle||w?.complementaryText||"Detalhes do item";return Ft.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:Ft.jsxs("div",{className:"flex items-center gap-4",children:[Ft.jsxs("div",{className:"flex-shrink-0",children:[Ft.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[Ft.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:k}),Ft.jsx(Pn,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:s||"Módulo"})]}),Ft.jsx("p",{className:"text-sm text-muted-foreground truncate",children:j})]}),u&&Ft.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[Ft.jsxs("div",{className:"relative flex-1",children:[Ft.jsx(E,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Ft.jsx(qt,{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&&Ft.jsx(Vt,{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:Ft.jsx(N,{size:14})})]}),Ft.jsx(Vt,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:Ft.jsx(De,{size:14})})]}),Ft.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[e&&Ft.jsx("div",{className:"flex items-center gap-2",children:e}),Ft.jsx(Vt,{variant:"secondary",size:"sm",className:"h-8 px-3",children:"Wiki"}),Ft.jsx("div",{className:"text-sm",children:Ft.jsx(gl,{variant:"dropdown",selectedUnit:p,onUnitChange:m})})]})]})})}),kl=(e={})=>{const{enabled:t=!0}=e,{alias:n}=ea();return nt({queryKey:["active-modules",n],queryFn:async()=>{if(!n)return[];const e=xr(),{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(!Nr.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!n})},jl=({key:e,enabled:t,checkFn:n,staleTime:r=3e5,gcTime:a=6e5})=>nt({queryKey:["permission",e],queryFn:n,enabled:t,staleTime:r,gcTime:a,retry:0,refetchOnWindowFocus:!1}),Cl=import.meta.env.VITE_SUPABASE_PROJECT_ID,Sl={logo:`https://${Cl}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${Cl}.supabase.co/storage/v1/object/public/library-assets/small.svg`},Il=Sl.logo,El=Sl.smallLogo,Tl="forlogic-sidebar-pinned",Pl=()=>{try{const e=localStorage.getItem(Tl);return!!e&&JSON.parse(e)}catch{return!1}};function Al({config:e}={}){const{state:t,open:n,setOpen:r}=ro(),s=it(),{alias:o,user:l}=ea(),[c,u]=a(!1),[d,f]=a(Pl),[m,p]=a(!1);i(()=>{r(!!d||!(!m&&!c))},[d,m,c,r]);const{data:h,isLoading:g,error:x}=kl({enabled:c}),y=e=>s.pathname===e||s.pathname.startsWith(e+"/"),b=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]};return Ft.jsxs(so,{collapsible:"icon",onMouseEnter:()=>{d||p(!0)},onMouseLeave:()=>{d||p(!1)},className:"app-sidebar transition-all duration-300 ease-in-out bg-white border-r border-gray-200 py-6 px-3",children:[Ft.jsxs(uo,{className:"p-0 gap-0",children:[Ft.jsx("div",{className:"flex items-center justify-between h-[34px]",children:n?Ft.jsxs(Ft.Fragment,{children:[Ft.jsx("div",{className:"flex items-center pl-[12px]",children:Ft.jsx("img",{src:Sl.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),Ft.jsx("button",{onClick:()=>{const e=!d;f(e),(e=>{try{localStorage.setItem(Tl,JSON.stringify(e))}catch{}})(e)},className:"h-8 w-8 flex items-center justify-center rounded-md transition-colors duration-200 "+(d?"bg-primary text-primary-foreground":"hover:bg-muted text-muted-foreground"),children:Ft.jsx(ze,{className:"h-4 w-4"})})]}):Ft.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:Ft.jsx("img",{src:Sl.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),Ft.jsx("div",{className:"mt-2 pt-0",children:Ft.jsxs(Aa,{onOpenChange:u,children:[Ft.jsx(Ra,{asChild:!0,children:n?Ft.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:[Ft.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Ft.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"}),Ft.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:e?.appName||"Título do módulo"})]}),Ft.jsx(k,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):Ft.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:Ft.jsx(k,{className:"h-6 w-6 text-muted-foreground"})})}),Ft.jsx(Ma,{className:n?"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:n?"start":"center",children:g?Ft.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[Ft.jsx(S,{className:"h-4 w-4 animate-spin"}),Ft.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):x?Ft.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[Ft.jsx(I,{className:"h-4 w-4"}),Ft.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):h&&0!==h.length?Ft.jsx("div",{className:"space-y-2",children:h.map((e,t)=>Ft.jsx("div",{onClick:()=>(e=>{const t=h?.find(t=>t.url===e);t?.url&&window.open(t.url,"_blank")})(e.url||""),className:`\n bg-muted/50 hover:bg-muted rounded-md p-3 cursor-pointer \n border-l-4 ${b(t)} transition-colors duration-200\n `,children:Ft.jsxs("div",{className:"flex items-center justify-between",children:[Ft.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&Ft.jsx(Oe,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):Ft.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]}),Ft.jsx(po,{children:Ft.jsx(ho,{className:"p-0 mt-6",children:Ft.jsx(yo,{children:Ft.jsx(bo,{className:"space-y-2",children:Ft.jsx(Xi,{children:e?.navigation?.map((e,t)=>{const n=({item:e,index:t})=>{const n=`${e.path}-${t}-${o??"noalias"}-${l?.id??"nouser"}`,{data:r=!0,isLoading:a}=jl({key:n,enabled:Boolean(e.permissionCheck&&o&&l?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),s=e.permissionCheck&&!r,i=a?S:s?J:e.icon;return s||e.complementaryText,Ft.jsx(vo,{children:s||a?Ft.jsxs(Gi,{children:[Ft.jsx(Zi,{asChild:!0,children:Ft.jsx(No,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:Ft.jsxs("div",{className:"flex w-full items-center gap-3",children:[Ft.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Ft.jsx(i,{className:"h-4 w-4 "+(a?"animate-spin":"")})}),Ft.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),Ft.jsx(eo,{children:Ft.jsx("p",{children:a?"Verificando acesso...":"Acesso restrito"})})]}):Ft.jsx(No,{asChild:!0,isActive:y(e.path),size:"lg",className:"h-10",children:Ft.jsxs(lt,{to:e.path,className:"flex w-full items-center gap-3",children:[Ft.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Ft.jsx(i,{className:"h-5 w-4"})}),Ft.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path)};return Ft.jsx(n,{item:e,index:t},e.path)})})})})})})]})}const Rl=l(function({children:e,sidebar:t,sidebarConfig:n,showHeader:r=!0}){const a=o(()=>t||Ft.jsx(Al,{config:n}),[t,n]),s=o(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return Ft.jsx(yl,{config:n,children:Ft.jsx(Hs,{children:Ft.jsx(ao,{defaultOpen:!1,style:s,children:Ft.jsxs("div",{className:"min-h-screen flex w-full",children:[a,Ft.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[r&&Ft.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:Ft.jsx(Nl,{})}),Ft.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:e})]})]})})})})});var _l=Object.defineProperty,Dl=(e,t,n)=>((e,t,n)=>t in e?_l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);class Fl extends u{constructor(e){super(e),Dl(this,"copyErrorDetails",()=>{const e=ur.getErrors().slice(-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),$n({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){return{hasError:!0,error:e}}componentDidCatch(e,t){ur.handleError(e,!1),this.setState({errorInfo:t})}render(){if(this.state.hasError){if(this.props.fallback)return this.props.fallback;const e=ur.getErrors().slice(-2);return Ft.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:Ft.jsxs(Kt,{className:"w-full max-w-2xl",children:[Ft.jsxs(Yt,{className:"text-center",children:[Ft.jsx("div",{className:"flex justify-center mb-4",children:Ft.jsx(Ue,{className:"h-12 w-12 text-destructive"})}),Ft.jsx(Jt,{children:"Algo deu errado"})]}),Ft.jsxs(Gt,{className:"space-y-4",children:[Ft.jsx("p",{className:"text-center text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),Ft.jsxs(vi,{open:this.state.showDetails,onOpenChange:e=>this.setState({showDetails:e}),children:[Ft.jsx(wi,{asChild:!0,children:Ft.jsxs(Vt,{variant:"outline",className:"w-full flex items-center justify-center gap-2",children:[Ft.jsx(k,{className:"h-4 w-4 transition-transform "+(this.state.showDetails?"rotate-180":"")}),"Ver Detalhes Técnicos"]})}),Ft.jsxs(Ni,{className:"mt-4 space-y-4",children:[Ft.jsxs("div",{className:"rounded-lg border bg-card p-4 space-y-3",children:[Ft.jsxs("div",{children:[Ft.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📋 Erro Atual"}),Ft.jsxs("div",{className:"text-sm space-y-2",children:[Ft.jsx("p",{className:"font-medium text-destructive",children:this.state.error?.message||"Erro desconhecido"}),this.state.error?.stack&&Ft.jsx(ns,{className:"h-32 w-full rounded border bg-muted p-2",children:Ft.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:this.state.error.stack})})]})]}),e.length>0&&Ft.jsxs("div",{className:"pt-3 border-t",children:[Ft.jsx("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:"📜 Últimos Erros"}),Ft.jsx("div",{className:"space-y-2",children:e.map((t,n)=>Ft.jsx("div",{className:"text-sm p-2 rounded bg-muted/50",children:Ft.jsxs("div",{className:"flex items-start gap-2",children:[Ft.jsxs("span",{className:"font-medium text-muted-foreground shrink-0",children:[e.length-n,"."]}),Ft.jsxs("div",{className:"flex-1 min-w-0",children:[Ft.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:Ft.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",new Date(t.timestamp).toLocaleTimeString(),"]"]})}),Ft.jsx("p",{className:"text-sm break-words",children:t.message})]})]})},t.id))})]})]}),Ft.jsxs(Vt,{variant:"outline",onClick:this.copyErrorDetails,className:"w-full flex items-center justify-center gap-2",children:[Ft.jsx(ne,{className:"h-4 w-4"}),"Copiar Detalhes"]})]})]}),Ft.jsx(Vt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})})}return this.props.children}}class zl{static async sendEmail(e){const t=xr(),{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 Ol=zl;function Ll(){const[e,t]=a([]),[n,r]=a(!1),[o,l]=a(null),[c,u]=a(null);i(()=>{d()},[]);const d=async()=>{try{const e=xr(),{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){u("Erro ao inicializar conversa"),b.error("Erro ao inicializar conversa")}},f=s(async e=>{if(!o||!e.trim())return;const n={id:`user-${Date.now()}`,role:"user",content:e,timestamp:new Date};t(e=>[...e,n]),r(!0),u(null);try{const n=xr(),{data:r,error:a}=await n.functions.invoke("openai-chat",{body:{action:"sendMessage",threadId:o,message:e}});if(a)throw a;const{runId:s}=r,i=await(async e=>{if(!o)return!1;for(let n=0;n<60;n++)try{const t=xr(),{data:n,error:r}=await t.functions.invoke("openai-chat",{body:{action:"checkRunStatus",threadId:o,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")})(s);i&&await(async()=>{if(o)try{const e=xr(),{data:n,error:r}=await e.functions.invoke("openai-chat",{body:{action:"getMessages",threadId:o}});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(a){const e=a instanceof Error?a.message:"Erro ao enviar mensagem";u(e),b.error(e),t(e=>e.filter(e=>e.id!==n.id))}finally{r(!1)}},[o]);return{messages:e,isLoading:n,error:c,sendMessage:f,threadId:o}}function Ml(){}function Ul(){}const $l=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Bl=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Vl={};function Hl(e,t){return(Vl.jsx?Bl:$l).test(e)}const ql=/[ \t\n\f\r]/g;function Wl(e){return""===e.replace(ql,"")}class Ql{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function Kl(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Ql(n,r,t)}function Yl(e){return e.toLowerCase()}Ql.prototype.normal={},Ql.prototype.property={},Ql.prototype.space=void 0;class Jl{constructor(e,t){this.attribute=t,this.property=e}}Jl.prototype.attribute="",Jl.prototype.booleanish=!1,Jl.prototype.boolean=!1,Jl.prototype.commaOrSpaceSeparated=!1,Jl.prototype.commaSeparated=!1,Jl.prototype.defined=!1,Jl.prototype.mustUseProperty=!1,Jl.prototype.number=!1,Jl.prototype.overloadedBoolean=!1,Jl.prototype.property="",Jl.prototype.spaceSeparated=!1,Jl.prototype.space=void 0;let Xl=0;const Gl=sc(),Zl=sc(),ec=sc(),tc=sc(),nc=sc(),rc=sc(),ac=sc();function sc(){return 2**++Xl}var ic=Object.freeze({__proto__:null,boolean:Gl,booleanish:Zl,commaOrSpaceSeparated:ac,commaSeparated:rc,number:tc,overloadedBoolean:ec,spaceSeparated:nc});const oc=Object.keys(ic);class lc extends Jl{constructor(e,t,n,r){let a=-1;if(super(e,t),cc(this,"space",r),"number"==typeof n)for(;++a<oc.length;){const e=oc[a];cc(this,oc[a],(n&ic[e])===ic[e])}}}function cc(e,t,n){n&&(e[t]=n)}function uc(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new lc(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Yl(r)]=r,n[Yl(s.attribute)]=r}return new Ql(t,n,e.space)}lc.prototype.defined=!0;const dc=uc({properties:{ariaActiveDescendant:null,ariaAtomic:Zl,ariaAutoComplete:null,ariaBusy:Zl,ariaChecked:Zl,ariaColCount:tc,ariaColIndex:tc,ariaColSpan:tc,ariaControls:nc,ariaCurrent:null,ariaDescribedBy:nc,ariaDetails:null,ariaDisabled:Zl,ariaDropEffect:nc,ariaErrorMessage:null,ariaExpanded:Zl,ariaFlowTo:nc,ariaGrabbed:Zl,ariaHasPopup:null,ariaHidden:Zl,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:nc,ariaLevel:tc,ariaLive:null,ariaModal:Zl,ariaMultiLine:Zl,ariaMultiSelectable:Zl,ariaOrientation:null,ariaOwns:nc,ariaPlaceholder:null,ariaPosInSet:tc,ariaPressed:Zl,ariaReadOnly:Zl,ariaRelevant:null,ariaRequired:Zl,ariaRoleDescription:nc,ariaRowCount:tc,ariaRowIndex:tc,ariaRowSpan:tc,ariaSelected:Zl,ariaSetSize:tc,ariaSort:null,ariaValueMax:tc,ariaValueMin:tc,ariaValueNow:tc,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function fc(e,t){return t in e?e[t]:t}function mc(e,t){return fc(e,t.toLowerCase())}const pc=uc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:rc,acceptCharset:nc,accessKey:nc,action:null,allow:null,allowFullScreen:Gl,allowPaymentRequest:Gl,allowUserMedia:Gl,alt:null,as:null,async:Gl,autoCapitalize:null,autoComplete:nc,autoFocus:Gl,autoPlay:Gl,blocking:nc,capture:null,charSet:null,checked:Gl,cite:null,className:nc,cols:tc,colSpan:null,content:null,contentEditable:Zl,controls:Gl,controlsList:nc,coords:tc|rc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Gl,defer:Gl,dir:null,dirName:null,disabled:Gl,download:ec,draggable:Zl,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Gl,formTarget:null,headers:nc,height:tc,hidden:ec,high:tc,href:null,hrefLang:null,htmlFor:nc,httpEquiv:nc,id:null,imageSizes:null,imageSrcSet:null,inert:Gl,inputMode:null,integrity:null,is:null,isMap:Gl,itemId:null,itemProp:nc,itemRef:nc,itemScope:Gl,itemType:nc,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Gl,low:tc,manifest:null,max:null,maxLength:tc,media:null,method:null,min:null,minLength:tc,multiple:Gl,muted:Gl,name:null,nonce:null,noModule:Gl,noValidate:Gl,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:Gl,optimum:tc,pattern:null,ping:nc,placeholder:null,playsInline:Gl,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Gl,referrerPolicy:null,rel:nc,required:Gl,reversed:Gl,rows:tc,rowSpan:tc,sandbox:nc,scope:null,scoped:Gl,seamless:Gl,selected:Gl,shadowRootClonable:Gl,shadowRootDelegatesFocus:Gl,shadowRootMode:null,shape:null,size:tc,sizes:null,slot:null,span:tc,spellCheck:Zl,src:null,srcDoc:null,srcLang:null,srcSet:null,start:tc,step:null,style:null,tabIndex:tc,target:null,title:null,translate:null,type:null,typeMustMatch:Gl,useMap:null,value:Zl,width:tc,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:nc,axis:null,background:null,bgColor:null,border:tc,borderColor:null,bottomMargin:tc,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Gl,declare:Gl,event:null,face:null,frame:null,frameBorder:null,hSpace:tc,leftMargin:tc,link:null,longDesc:null,lowSrc:null,marginHeight:tc,marginWidth:tc,noResize:Gl,noHref:Gl,noShade:Gl,noWrap:Gl,object:null,profile:null,prompt:null,rev:null,rightMargin:tc,rules:null,scheme:null,scrolling:Zl,standby:null,summary:null,text:null,topMargin:tc,valueType:null,version:null,vAlign:null,vLink:null,vSpace:tc,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Gl,disableRemotePlayback:Gl,prefix:null,property:null,results:tc,security:null,unselectable:null},space:"html",transform:mc}),hc=uc({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:ac,accentHeight:tc,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:tc,amplitude:tc,arabicForm:null,ascent:tc,attributeName:null,attributeType:null,azimuth:tc,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:tc,by:null,calcMode:null,capHeight:tc,className:nc,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:tc,diffuseConstant:tc,direction:null,display:null,dur:null,divisor:tc,dominantBaseline:null,download:Gl,dx:null,dy:null,edgeMode:null,editable:null,elevation:tc,enableBackground:null,end:null,event:null,exponent:tc,externalResourcesRequired:null,fill:null,fillOpacity:tc,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:rc,g2:rc,glyphName:rc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:tc,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:tc,horizOriginX:tc,horizOriginY:tc,id:null,ideographic:tc,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:tc,k:tc,k1:tc,k2:tc,k3:tc,k4:tc,kernelMatrix:ac,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:tc,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:tc,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:tc,overlineThickness:tc,paintOrder:null,panose1:null,path:null,pathLength:tc,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:nc,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:tc,pointsAtY:tc,pointsAtZ:tc,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ac,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ac,rev:ac,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ac,requiredFeatures:ac,requiredFonts:ac,requiredFormats:ac,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:tc,specularExponent:tc,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:tc,strikethroughThickness:tc,string:null,stroke:null,strokeDashArray:ac,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:tc,strokeOpacity:tc,strokeWidth:null,style:null,surfaceScale:tc,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ac,tabIndex:tc,tableValues:null,target:null,targetX:tc,targetY:tc,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ac,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:tc,underlineThickness:tc,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:tc,values:null,vAlphabetic:tc,vMathematical:tc,vectorEffect:null,vHanging:tc,vIdeographic:tc,version:null,vertAdvY:tc,vertOriginX:tc,vertOriginY:tc,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:tc,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:fc}),gc=uc({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()}),xc=uc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:mc}),yc=uc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),bc={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"},vc=/[A-Z]/g,wc=/-[a-z]/g,Nc=/^data[-\w.:]+$/i;function kc(e){return"-"+e.toLowerCase()}function jc(e){return e.charAt(1).toUpperCase()}const Cc=Kl([dc,pc,gc,xc,yc],"html"),Sc=Kl([dc,hc,gc,xc,yc],"svg");var Ic,Ec,Tc,Pc={};function Ac(){if(Tc)return Pc;Tc=1;var e=Pc&&Pc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Pc,"__esModule",{value:!0}),Pc.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(Ec)return Ic;Ec=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 Ic=function(o,u){if("string"!=typeof o)throw new TypeError("First argument must be a string");if(!o)return[];u=u||{};var d=1,f=1;function m(e){var n=e.match(t);n&&(d+=n.length);var r=e.lastIndexOf("\n");f=~r?e.length-r:f+e.length}function p(){var e={line:d,column:f};return function(t){return t.position=new h(e),y(),t}}function h(e){this.start=e,this.end={line:d,column:f},this.source=u.source}function g(e){var t=new Error(u.source+":"+d+":"+f+": "+e);if(t.reason=e,t.filename=u.source,t.line=d,t.column=f,t.source=o,!u.silent)throw t}function x(e){var t=e.exec(o);if(t){var n=t[0];return m(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 f+=2,m(n),o=o.slice(t),f+=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),u=t({type:"declaration",property:c(n[0].replace(e,l)),value:o?c(o[0].replace(e,l)):l});return x(i),u}}return h.prototype.content=o,y(),function(){var e,t=[];for(b(t);e=w();)!1!==e&&(t.push(e),b(t));return t}()},Ic}());return Pc}var Rc,_c,Dc,Fc={};function zc(){if(Rc)return Fc;Rc=1,Object.defineProperty(Fc,"__esModule",{value:!0}),Fc.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 Fc.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))},Fc}var Oc=function(){if(Dc)return _c;Dc=1;var e=(_c&&_c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Ac()),t=zc();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,_c=n}(),Lc=It(Oc);const Mc=$c("end"),Uc=$c("start");function $c(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 Bc(e){return e&&"object"==typeof e?"position"in e||"type"in e?Hc(e.position):"start"in e||"end"in e?Hc(e):"line"in e||"column"in e?Vc(e):"":""}function Vc(e){return qc(e&&e.line)+":"+qc(e&&e.column)}function Hc(e){return Vc(e&&e.start)+"-"+Vc(e&&e.end)}function qc(e){return e&&"number"==typeof e?e:1}class Wc 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=Bc(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}}Wc.prototype.file="",Wc.prototype.name="",Wc.prototype.reason="",Wc.prototype.message="",Wc.prototype.stack="",Wc.prototype.column=void 0,Wc.prototype.line=void 0,Wc.prototype.ancestors=void 0,Wc.prototype.cause=void 0,Wc.prototype.fatal=void 0,Wc.prototype.place=void 0,Wc.prototype.ruleId=void 0,Wc.prototype.source=void 0;const Qc={}.hasOwnProperty,Kc=new Map,Yc=/[A-Z]/g,Jc=new Set(["table","tbody","thead","tfoot","tr"]),Xc=new Set(["td","th"]),Gc="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Zc(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=Uc(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?Sc:Cc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=eu(a,e,void 0);return s&&"string"!=typeof s?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function eu(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=Sc,e.schema=a);e.ancestors.push(t);const s=su(e,t.tagName,!1),i=function(e,t){const n={};let r,a;for(a in t.properties)if("children"!==a&&Qc.call(t.properties,a)){const s=au(e,a,t.properties[a]);if(s){const[a,i]=s;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof i&&Xc.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=ru(e,t);Jc.has(t.tagName)&&(o=o.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&Wl(t.value):Wl(t));var t}));return tu(e,i,s,t),nu(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)}iu(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=Sc,e.schema=a);e.ancestors.push(t);const s=null===t.name?e.Fragment:su(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];Ml(t.type);const a=t.expression;Ml(a.type);const s=a.properties[0];Ml(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else iu(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];Ml(t.type),s=e.evaluater.evaluateExpression(t.expression)}else iu(e,t.position);else s=null===r.value||r.value;n[a]=s}return n}(e,t),o=ru(e,t);return tu(e,i,s,t),nu(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);iu(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return nu(r,ru(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 tu(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function nu(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function ru(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:Kc;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=eu(e,s,i);void 0!==o&&n.push(o)}return n}function au(e,t,n){const r=function(e,t){const n=Yl(t);let r=t,a=Jl;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Nc.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(wc,jc);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!wc.test(e)){let n=e.replace(vc,kc);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}a=lc}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 Lc(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new Wc("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=Gc+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)Qc.call(e,n)&&(t[ou(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?bc[r.property]||r.property:r.attribute,n]}}function su(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,a=-1;for(;++a<e.length;){const t=Hl(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=Hl(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 Qc.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);iu(e)}function iu(e,t){const n=new Wc("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=Gc+"#cannot-handle-mdx-estrees-without-createevaluater",n}function ou(e){let t=e.replace(Yc,lu);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function lu(e){return"-"+e.toLowerCase()}const cu={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"]},uu={};function du(e,t){return fu(e,"boolean"!=typeof uu.includeImageAlt||uu.includeImageAlt,"boolean"!=typeof uu.includeHtml||uu.includeHtml)}function fu(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 mu(e.children,t,n)}return Array.isArray(e)?mu(e,t,n):""}function mu(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=fu(e[a],t,n);return r.join("")}const pu=document.createElement("i");function hu(e){const t="&"+e+";";pu.innerHTML=t;const n=pu.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function gu(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 xu(e,t){return e.length>0?(gu(e,e.length,0,t),e):t}const yu={}.hasOwnProperty;function bu(e){const t={};let n=-1;for(;++n<e.length;)vu(t,e[n]);return t}function vu(e,t){let n;for(n in t){const r=(yu.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){yu.call(r,s)||(r[s]=[]);const e=a[s];wu(r[s],Array.isArray(e)?e:e?[e]:[])}}}function wu(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);gu(e,0,0,r)}function Nu(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 ku(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ju=zu(/[A-Za-z]/),Cu=zu(/[\dA-Za-z]/),Su=zu(/[#-'*+\--9=?A-Z^-~]/);function Iu(e){return null!==e&&(e<32||127===e)}const Eu=zu(/\d/),Tu=zu(/[\dA-Fa-f]/),Pu=zu(/[!-/:-@[-`{-~]/);function Au(e){return null!==e&&e<-2}function Ru(e){return null!==e&&(e<0||32===e)}function _u(e){return-2===e||-1===e||32===e}const Du=zu(/\p{P}|\p{S}/u),Fu=zu(/\s/);function zu(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Ou(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&Cu(e.charCodeAt(n+1))&&Cu(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 Lu(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(_u(r))return e.enter(n),i(r);return t(r)};function i(r){return _u(r)&&s++<a?(e.consume(r),i):(e.exit(n),t(r))}}const Mu={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"),Lu(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)):Au(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),a)}}};const Uu={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 gu(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 f(a);if(r.currentConstruct&&r.currentConstruct.concrete)return p(a);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check($u,u,d)(a)}function u(e){return r&&y(),x(i),f(e)}function d(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,p(e)}function f(n){return t.containerState={},e.attempt($u,m,p)(n)}function m(e){return i++,n.push([t.currentConstruct,t.containerState]),f(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)):Au(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++;gu(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}}},$u={tokenize:function(e,t,n){return Lu(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function Bu(e){return null===e||Ru(e)||Fu(e)?1:Du(e)?2:void 0}function Vu(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 Hu={name:"attention",resolveAll:function(e,t){let n,r,a,s,i,o,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close)for(n=u;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[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;o=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const d={...e[n][1].end},f={...e[u][1].start};qu(d,-o),qu(f,o),s={type:o>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},i={type:o>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:f},a={type:o>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},r={type:o>1?"strong":"emphasis",start:{...s.start},end:{...i.end}},e[n][1].end={...s.start},e[u][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=xu(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=xu(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",a,t]]),l=xu(l,Vu(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=xu(l,[["exit",a,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=xu(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,gu(e,n-1,u-n+3,l),u=n+l.length-c-2;break}u=-1;for(;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Bu(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=Bu(o),u=!c||2===c&&a||n.includes(o),d=!a||2===a&&c||n.includes(r);return l._open=Boolean(42===s?u:u&&(a||!d)),l._close=Boolean(42===s?d:d&&(c||!u)),t(o)}}};function qu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Wu={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 ju(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||Cu(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||Cu(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||Iu(r)?n(r):(e.consume(r),o)}function l(t){return 64===t?(e.consume(t),c):Su(t)?(e.consume(t),l):n(t)}function c(e){return Cu(e)?u(e):n(e)}function u(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):d(n)}function d(t){if((45===t||Cu(t))&&r++<63){const n=45===t?d:u;return e.consume(t),n}return n(t)}}};const Qu={partial:!0,tokenize:function(e,t,n){return function(t){return _u(t)?Lu(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||Au(e)?t(e):n(e)}}};const Ku={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(_u(t))return Lu(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return a(t)};function a(r){return e.attempt(Ku,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 _u(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const Yu={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 Pu(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const Ju={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=Cu,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=Tu,c):(e.enter("characterReferenceValue"),a=7,s=Eu,c(t))}function c(o){if(59===o&&i){const a=e.exit("characterReferenceValue");return s!==Cu||hu(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)}}},Gu={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"),_u(t)?Lu(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"),u(t)):n(t)}function u(t){return t===s?(a++,e.consume(t),u):a>=o?(e.exit("codeFencedFenceSequence"),_u(t)?Lu(e,d,"whitespace")(t):d(t)):n(t)}function d(r){return null===r||Au(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"),_u(t)?Lu(e,c,"whitespace")(t):c(t))}function c(n){return null===n||Au(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(Xu,m,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||Au(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):_u(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Lu(e,d,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),u)}function d(t){return null===t||Au(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(t))}function f(t){return null===t||Au(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),f)}function m(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&&_u(t)?Lu(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||Au(t)?e.check(Xu,m,y)(t):(e.enter("codeFlowValue"),x(t))}function x(t){return null===t||Au(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),x)}function y(n){return e.exit("codeFenced"),t(n)}}};const Zu={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),Lu(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):Au(t)?e.attempt(ed,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||Au(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},ed={partial:!0,tokenize:function(e,t,n){const r=this;return a;function a(t){return r.parser.lazy[r.now().line]?n(t):Au(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):Lu(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):Au(e)?a(e):n(e)}}};const td={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)):Au(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||Au(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 nd{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&&rd(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),rd(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),rd(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);rd(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);rd(this.left,t.reverse())}}}function rd(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 ad(e){const t={};let n,r,a,s,i,o,l,c=-1;const u=new nd(e);for(;++c<u.length;){for(;c in t;)c=t[c];if(n=u.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===u.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,sd(u,c)),c=t[c],l=!0);else if(n[1]._container){for(a=c,r=void 0;a--;)if(s=u.get(a),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(r&&(u.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={...u.get(r)[1].start},i=u.slice(r,c),i.unshift(n),u.splice(r,c-r+1,i))}}return gu(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function sd(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 u,d,f=-1,m=n,p=0,h=0;const g=[h];for(;m;){for(;e.get(++a)[1]!==m;);s.push(a),m._tokenizer||(u=r.sliceStream(m),m.next||u.push(null),d&&i.defineSkip(m.start),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(u),m._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),d=m,m=m.next}for(m=n;++f<o.length;)"exit"===o[f][0]&&"enter"===o[f-1][0]&&o[f][1].type===o[f-1][1].type&&o[f][1].start.line!==o[f][1].end.line&&(h=f+1,g.push(h),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(i.events=[],m?(m._tokenizer=void 0,m.previous=void 0):g.pop(),f=g.length;f--;){const t=o.slice(g[f],g[f+1]),n=s.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),f=-1;++f<l.length;)c[p+l[f][0]]=p+l[f][1],p+=l[f][1]-l[f][0]-1;return c}const id={resolve:function(e){return ad(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):Au(t)?e.check(od,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}}},od={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"),Lu(e,a,"linePrefix")};function a(a){if(null===a||Au(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 ld(e,t,n,r,a,s,i,o,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return function(t){if(60===t)return e.enter(r),e.enter(a),e.enter(s),e.consume(t),e.exit(s),d;if(null===t||32===t||41===t||Iu(t))return n(t);return e.enter(r),e.enter(i),e.enter(o),e.enter("chunkString",{contentType:"string"}),p(t)};function d(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"}),f(n))}function f(t){return 62===t?(e.exit("chunkString"),e.exit(o),d(t)):null===t||60===t||Au(t)?n(t):(e.consume(t),92===t?m:f)}function m(t){return 60===t||62===t||92===t?(e.consume(t),f):f(t)}function p(a){return u||null!==a&&41!==a&&!Ru(a)?u<c&&40===a?(e.consume(a),u++,p):41===a?(e.consume(a),u--,p):null===a||32===a||40===a||Iu(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 cd(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(d){return l>999||null===d||91===d||93===d&&!o||94===d&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(d):93===d?(e.exit(s),e.enter(a),e.consume(d),e.exit(a),e.exit(r),t):Au(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||Au(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!_u(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function ud(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):Au(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Lu(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||Au(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===i||92===t?(e.consume(t),c):c(t)}}function dd(e,t){let n;return function r(a){if(Au(a))return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r;if(_u(a))return Lu(e,r,n?"linePrefix":"lineSuffix")(a);return t(a)}}const fd={name:"definition",tokenize:function(e,t,n){const r=this;let a;return function(t){return e.enter("definition"),function(t){return cd.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return a=ku(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 Ru(t)?dd(e,o)(t):o(t)}function o(t){return ld(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(md,c,c)(t)}function c(t){return _u(t)?Lu(e,u,"whitespace")(t):u(t)}function u(s){return null===s||Au(s)?(e.exit("definition"),r.parser.defined.push(a),t(s)):n(s)}}},md={partial:!0,tokenize:function(e,t,n){return function(t){return Ru(t)?dd(e,r)(t):n(t)};function r(t){return ud(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return _u(t)?Lu(e,s,"whitespace")(t):s(t)}function s(e){return null===e||Au(e)?t(e):n(e)}}};const pd={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return Au(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const hd={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"},gu(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||Ru(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||Au(n)?(e.exit("atxHeading"),t(n)):_u(n)?Lu(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||Ru(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const gd=["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"],xd=["pre","script","style","textarea"],yd={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),u):47===o?(e.consume(o),s=!0,m):63===o?(e.consume(o),a=3,r.interrupt?t:D):ju(o)?(e.consume(o),i=String.fromCharCode(o),p):n(o)}function u(s){return 45===s?(e.consume(s),a=2,d):91===s?(e.consume(s),a=5,o=0,f):ju(s)?(e.consume(s),a=4,r.interrupt?t:D):n(s)}function d(a){return 45===a?(e.consume(a),r.interrupt?t:D):n(a)}function f(a){const s="CDATA[";return a===s.charCodeAt(o++)?(e.consume(a),6===o?r.interrupt?t:S:f):n(a)}function m(t){return ju(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||Ru(o)){const l=47===o,c=i.toLowerCase();return l||s||!xd.includes(c)?gd.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||Cu(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 _u(t)?(e.consume(t),g):j(t)}function x(t){return 47===t?(e.consume(t),j):58===t||95===t||ju(t)?(e.consume(t),y):_u(t)?(e.consume(t),x):j(t)}function y(t){return 45===t||46===t||58===t||95===t||Cu(t)?(e.consume(t),y):b(t)}function b(t){return 61===t?(e.consume(t),v):_u(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):_u(t)?(e.consume(t),v):N(t)}function w(t){return t===l?(e.consume(t),l=null,k):null===t||Au(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||Ru(t)?b(t):(e.consume(t),N)}function k(e){return 47===e||62===e||_u(e)?x(e):n(e)}function j(t){return 62===t?(e.consume(t),C):n(t)}function C(t){return null===t||Au(t)?S(t):_u(t)?(e.consume(t),C):n(t)}function S(t){return 45===t&&2===a?(e.consume(t),P):60===t&&1===a?(e.consume(t),A):62===t&&4===a?(e.consume(t),F):63===t&&3===a?(e.consume(t),D):93===t&&5===a?(e.consume(t),_):!Au(t)||6!==a&&7!==a?null===t||Au(t)?(e.exit("htmlFlowData"),I(t)):(e.consume(t),S):(e.exit("htmlFlowData"),e.check(bd,z,I)(t))}function I(t){return e.check(vd,E,z)(t)}function E(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),T}function T(t){return null===t||Au(t)?I(t):(e.enter("htmlFlowData"),S(t))}function P(t){return 45===t?(e.consume(t),D):S(t)}function A(t){return 47===t?(e.consume(t),i="",R):S(t)}function R(t){if(62===t){const n=i.toLowerCase();return xd.includes(n)?(e.consume(t),F):S(t)}return ju(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),R):S(t)}function _(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||Au(t)?(e.exit("htmlFlowData"),z(t)):(e.consume(t),F)}function z(n){return e.exit("htmlFlow"),t(n)}}},bd={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(Qu,t,n)}}},vd={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(Au(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 wd={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):ju(t)?(e.consume(t),k):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,m):ju(t)?(e.consume(t),x):n(t)}function c(t){return 45===t?(e.consume(t),f):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):Au(t)?(i=u,R(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),f):u(t)}function f(e){return 62===e?A(e):45===e?d(e):u(e)}function m(t){const r="CDATA[";return t===r.charCodeAt(s++)?(e.consume(t),6===s?p:m):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),h):Au(t)?(i=p,R(t)):(e.consume(t),p)}function h(t){return 93===t?(e.consume(t),g):p(t)}function g(t){return 62===t?A(t):93===t?(e.consume(t),g):p(t)}function x(t){return null===t||62===t?A(t):Au(t)?(i=x,R(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):Au(t)?(i=y,R(t)):(e.consume(t),y)}function b(e){return 62===e?A(e):y(e)}function v(t){return ju(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||Cu(t)?(e.consume(t),w):N(t)}function N(t){return Au(t)?(i=N,R(t)):_u(t)?(e.consume(t),N):A(t)}function k(t){return 45===t||Cu(t)?(e.consume(t),k):47===t||62===t||Ru(t)?j(t):n(t)}function j(t){return 47===t?(e.consume(t),A):58===t||95===t||ju(t)?(e.consume(t),C):Au(t)?(i=j,R(t)):_u(t)?(e.consume(t),j):A(t)}function C(t){return 45===t||46===t||58===t||95===t||Cu(t)?(e.consume(t),C):S(t)}function S(t){return 61===t?(e.consume(t),I):Au(t)?(i=S,R(t)):_u(t)?(e.consume(t),S):j(t)}function I(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),a=t,E):Au(t)?(i=I,R(t)):_u(t)?(e.consume(t),I):(e.consume(t),T)}function E(t){return t===a?(e.consume(t),a=void 0,P):null===t?n(t):Au(t)?(i=E,R(t)):(e.consume(t),E)}function T(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Ru(t)?j(t):(e.consume(t),T)}function P(e){return 47===e||62===e||Ru(e)?j(e):n(e)}function A(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function R(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),_}function _(t){return _u(t)?Lu(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 Nd={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&&gu(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}},u={type:"labelText",start:{...e[r+o+2][1].end},end:{...e[a-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=xu(s,e.slice(r+1,r+o+3)),s=xu(s,[["enter",u,t]]),s=xu(s,Vu(t.parser.constructs.insideSpan.null,e.slice(r+o+4,a-3),t)),s=xu(s,[["exit",u,t],e[a-2],e[a-1],["exit",c,t]]),s=xu(s,e.slice(a+1)),s=xu(s,[["exit",l,t]]),gu(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 u(t);return s=r.parser.defined.includes(ku(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(kd,c,s?c:u)(t):91===t?e.attempt(jd,c,s?l:u)(t):s?c(t):u(t)}function l(t){return e.attempt(Cd,c,u)(t)}function c(e){return t(e)}function u(e){return a._balanced=!0,n(e)}}},kd={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 Ru(t)?dd(e,a)(t):a(t)}function a(t){return 41===t?c(t):ld(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return Ru(t)?dd(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?ud(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return Ru(t)?dd(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)}}},jd={tokenize:function(e,t,n){const r=this;return function(t){return cd.call(r,e,a,s,"reference","referenceMarker","referenceString")(t)};function a(e){return r.parser.defined.includes(ku(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},Cd={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 Sd={name:"labelStartImage",resolveAll:Nd.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 Id={name:"labelStartLink",resolveAll:Nd.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 Ed={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Lu(e,t,"linePrefix")}}};const Td={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||Au(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),a++,i):(e.exit("thematicBreakSequence"),_u(t)?Lu(e,s,"whitespace")(t):s(t))}}};const Pd={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Qu,a,s);function a(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Lu(e,t,"listItemIndent",r.containerState.size+1)(n)}function s(n){return r.containerState.furtherBlankLines||!_u(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(Rd,t,i)(n))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Lu(e,e.attempt(Pd,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:Eu(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(Td,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 Eu(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(Qu,r.interrupt?n:c,e.attempt(Ad,d,u))}function c(e){return r.containerState.initialBlankLine=!0,s++,d(e)}function u(t){return _u(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Ad={partial:!0,tokenize:function(e,t,n){const r=this;return Lu(e,function(e){const a=r.events[r.events.length-1];return!_u(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Rd={partial:!0,tokenize:function(e,t,n){const r=this;return Lu(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 _d={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"),_u(t)?Lu(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||Au(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const Dd={tokenize:function(e){const t=this,n=e.attempt(Qu,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,Lu(e,e.attempt(this.parser.constructs.flow,r,e.attempt(id,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 Fd={resolveAll:Md()},zd=Ld("string"),Od=Ld("text");function Ld(e){return{resolveAll:Md("text"===e?Ud: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 Md(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 Ud(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 $d={42:Pd,43:Pd,45:Pd,48:Pd,49:Pd,50:Pd,51:Pd,52:Pd,53:Pd,54:Pd,55:Pd,56:Pd,57:Pd,62:Ku},Bd={91:fd},Vd={[-2]:Zu,[-1]:Zu,32:Zu},Hd={35:hd,42:Td,45:[_d,Td],60:yd,61:_d,95:Td,96:Gu,126:Gu},qd={38:Ju,92:Yu},Wd={[-5]:Ed,[-4]:Ed,[-3]:Ed,33:Sd,38:Ju,42:Hu,60:[Wu,wd],91:Id,92:[pd,Yu],93:Nd,95:Hu,96:td},Qd={null:[Hu,Fd]};var Kd=Object.freeze({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:Bd,disable:{null:[]},document:$d,flow:Hd,flowInitial:Vd,insideSpan:Qd,string:qd,text:Wd});function Yd(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){Au(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=f(),c.events.push(["enter",n,c]),o.push(n),n},exit:function(e){const t=o.pop();return t.end=f(),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:f,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("")}(d(e),t)},sliceStream:d,write:function(e){if(i=xu(i,e),m(),null!==i[i.length-1])return[];return x(t,0),c.events=Vu(s,c.events,c),c.events}};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(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 f(){const{_bufferIndex:e,_index:t,line:n,column:a,offset:s}=r;return{_bufferIndex:e,_index:t,line:n,column:a,offset:s}}function m(){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){u=u(e)}function h(e,t){t.restore()}function g(e,t){return function(n,a,s){let i,u,d,m;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,u=0,0===e.length?s:h(e[u])}function h(e){return function(n){m=function(){const e=f(),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()}}(),d=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(d,m),a}function x(e){return m.restore(),++u<i.length?h(i[u]):s}}}function x(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&gu(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 Jd=/[\0\t\n\r]/g;const Xd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Gd(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Nu(n.slice(t?2:1),t?16:10)}return hu(n)||e}const Zd={}.hasOwnProperty;function ef(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:f,listOrdered:s(ne,d),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:q,autolinkProtocol:H,blockQuote:l(),characterEscapeValue:S,characterReferenceMarkerHexadecimal:$,characterReferenceMarkerNumeric:$,characterReferenceValue:B,characterReference:V,codeFenced:l(g),codeFencedFence:h,codeFencedFenceInfo:m,codeFencedFenceMeta:p,codeFlowValue:S,codeIndented:l(x),codeText:l(A),codeTextData:S,data:S,definition:l(),definitionDestinationString:v,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(E),hardBreakTrailing:l(E),htmlFlow:l(T),htmlFlowData:S,htmlText:l(P),htmlTextData:S,image:l(_),label:F,labelText:D,lineEnding:I,link:l(R),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:U,resourceDestinationString:z,resourceTitleString:O,resource:L,setextHeading:l(j),setextHeadingLineSequence:k,setextHeadingText:N,strong:l(),thematicBreak:l()}};nf(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:u,data:n},l=[];let d=-1;for(;++d<e.length;)if("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)if("enter"===e[d][0])l.push(d);else{d=a(e,l.pop(),d)}for(d=-1;++d<e.length;){const n=t[e[d][0]];Zd.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},s),e[d][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||af).call(s,void 0,e[0])}for(r.position={start:tf(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:tf(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](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:tf(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+"` ("+Bc({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]||af).call(this,e,r[0])}n.position.end=tf(e.end)}function u(){return du(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function m(){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=ku(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 k(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function j(){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:tf(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=tf(e.end)}function I(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=tf(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 E(){this.data.atHardBreak=!0}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.resume();this.stack[this.stack.length-1].value=e}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 _(){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(Xd,Gd)}(t),n.identifier=ku(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 O(){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=ku(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=Nu(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=hu(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=tf(e.end)}function H(e){S.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function q(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(;!ad(e););return e}(function(e){const t={constructs:bu([Kd,...(e||{}).extensions||[]]),content:n(Mu),defined:[],document:n(Uu),flow:n(Dd),lazy:{},string:n(zd),text:n(Od)};return t;function n(e){return function(n){return Yd(t,e,n)}}}(n).document().write(function(){let e,t=1,n="",r=!0;return function(a,s,i){const o=[];let l,c,u,d,f;for(a=n+("string"==typeof a?a.toString():new TextDecoder(s||void 0).decode(a)),u=0,n="",r&&(65279===a.charCodeAt(0)&&u++,r=void 0);u<a.length;){if(Jd.lastIndex=u,l=Jd.exec(a),d=l&&void 0!==l.index?l.index:a.length,f=a.charCodeAt(d),!l){n=a.slice(u);break}if(10===f&&u===d&&e)o.push(-3),e=void 0;else switch(e&&(o.push(-5),e=void 0),u<d&&(o.push(a.slice(u,d)),t+=d-u),f){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}u=d+1}return i&&(e&&o.push(-5),n&&o.push(n),o.push(null)),o}}()(e,t,!0))))}function tf(e){return{line:e.line,column:e.column,offset:e.offset}}function nf(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?nf(e,r):rf(e,r)}}function rf(e,t){let n;for(n in t)if(Zd.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 af(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Bc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Bc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Bc({start:t.start,end:t.end})+") is still open")}function sf(e){const t=this;t.parser=function(n){return ef(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function of(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 lf(e){const t=e.spread;return null==t?e.children.length>1:t}function cf(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const s=[];for(;r;)s.push(uf(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return s.push(uf(t.slice(a),a>0,!1)),s.join("")}function uf(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 df={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=Ou(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 of(e,t);const a={src:Ou(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:Ou(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 of(e,t);const a={href:Ou(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:Ou(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=lf(n[r])}return t}(n):lf(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=Uc(t.children[1]),i=Mc(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:cf(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:ff,yaml:ff,definition:ff,footnoteDefinition:ff};function ff(){}const mf="object"==typeof self?self:globalThis,pf=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 mf[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 mf[s](i),a)};return r})(new Map,e)(0),hf="",{toString:gf}={},{keys:xf}=Object,yf=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=gf.call(e).slice(8,-1);switch(n){case"Array":return[1,hf];case"Object":return[2,hf];case"Date":return[3,hf];case"RegExp":return[4,hf];case"Map":return[5,hf];case"Set":return[6,hf];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},bf=([e,t])=>0===e&&("function"===t||"symbol"===t),vf=(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]=yf(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 xf(r))!e&&bf(yf(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||!bf(yf(a))&&!bf(yf(i)))&&t.push([s(a),s(i)]);return n}case 6:{const t=[],n=a([i,t],r);for(const a of r)!e&&bf(yf(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 wf="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?pf(vf(e,t)):structuredClone(e):(e,t)=>pf(vf(e,t));function Nf(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 kf(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const jf=function(e){if(null==e)return Sf;if("function"==typeof e)return Cf(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=jf(e[n]);return Cf(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 Cf(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 Cf(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function Cf(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 Sf(){return!0}const If=[],Ef=!0,Tf=!1;function Pf(e,t,n,r){let a;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):a=t;const s=jf(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(u,"name",{value:"node ("+a.type+(e?"<"+e+">":"")+")"})}return u;function u(){let c,u,d,f=If;if((!t||s(a,o,l[l.length-1]||void 0))&&(f=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[Ef,e];return null==e?If:[e]}(n(a,l)),f[0]===Tf))return f;if("children"in a&&a.children){const t=a;if(t.children&&"skip"!==f[0])for(u=(r?t.children.length:-1)+i,d=l.concat(t);u>-1&&u<t.children.length;){const n=t.children[u];if(c=e(n,u,d)(),c[0]===Tf)return c;u="number"==typeof c[1]?c[1]:u+i}}return f}}(e,void 0,[])()}function Af(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),Pf(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 Rf={}.hasOwnProperty,_f={};function Df(e,t){e.position&&(t.position=function(e){const t=Uc(e),n=Mc(e);if(t&&n)return{start:t,end:n}}(e))}function Ff(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,wf(a)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function zf(e,t){const n=t.data||{},r=!("value"in t)||Rf.call(n,"hProperties")||Rf.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 Of(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 Lf(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function Mf(e,t){const n=function(e,t){const n=t||_f,r=new Map,a=new Map,s=new Map,i={...df,...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=Lf(a.value)),!Array.isArray(a)&&"element"===a.type)){const e=a.children[0];e&&"text"===e.type&&(e.value=Lf(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:Ff,definitionById:r,footnoteById:a,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=o.handlers[n];if(Rf.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=wf(n);return r.children=o.all(e),r}return wf(e)}return(o.options.unknownHandler||zf)(o,e,t)},options:n,patch:Df,wrap:Of};return Af(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||Nf,r=e.options.footnoteBackLabel||kf,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=Ou(i.toLowerCase());let u=0;const d=[],f=e.footnoteCounts.get(i);for(;void 0!==f&&++u<=f;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const m=s[s.length-1];if(m&&"element"===m.type&&"p"===m.tagName){const e=m.children[m.children.length-1];e&&"text"===e.type?e.value+=" ":m.children.push({type:"text",value:" "}),m.children.push(...d)}else s.push(...d);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:{...wf(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 Uf(e,t){return e&&"run"in e?async function(n,r){const a=Mf(n,{file:r,...t});await e.run(a,r)}:function(n,r){return Mf(n,{file:r,...e||t})}}function $f(e){if(e)throw e}var Bf,Vf;var Hf=function(){if(Vf)return Bf;Vf=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 Bf=function e(){var t,n,r,l,c,u,d=arguments[0],f=1,m=arguments.length,p=!1;for("boolean"==typeof d&&(p=d,d=arguments[1]||{},f=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f<m;++f)if(null!=(t=arguments[f]))for(n in t)r=o(d,n),d!==(l=o(t,n))&&(p&&l&&(s(l)||(c=a(l)))?(c?(c=!1,u=r&&a(r)?r:[]):u=r&&s(r)?r:{},i(d,{name:n,newValue:e(p,u,l)})):void 0!==l&&i(d,{name:n,newValue:l}));return d},Bf}(),qf=It(Hf);function Wf(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 Qf(){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 Kf={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');Yf(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(Yf(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){Yf(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;)Yf(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){Yf(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 Yf(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Jf={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 Gf(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 Zf=["history","path","basename","stem","extname","dirname"];class em{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?"":Jf.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<Zf.length;){const e=Zf[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)Zf.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?Kf.basename(this.path):void 0}set basename(e){nm(e,"basename"),tm(e,"basename"),this.path=Kf.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?Kf.dirname(this.path):void 0}set dirname(e){rm(this.basename,"dirname"),this.path=Kf.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?Kf.extname(this.path):void 0}set extname(e){if(tm(e,"extname"),rm(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=Kf.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Xf(e)&&(e=Gf(e)),nm(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?Kf.basename(this.path,this.extname):void 0}set stem(e){nm(e,"stem"),tm(e,"stem"),this.path=Kf.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 Wc(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 tm(e,t){if(e&&e.includes(Kf.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Kf.sep+"`")}function nm(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function rm(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const am=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},sm={}.hasOwnProperty;class im extends am{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=Qf()}copy(){const e=new im;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(qf(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(um("data",this.frozen),this.namespace[e]=t,this):sm.call(this.namespace,e)&&this.namespace[e]||void 0:e?(um("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=mm(e),n=this.parser||this.Parser;return lm("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),lm("process",this.parser||this.Parser),cm("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,a){const s=mm(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(),lm("processSync",this.parser||this.Parser),cm("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,$f(e),t=r}),fm("processSync","process",n),t}run(e,t,n){dm(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=mm(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){$f(e),n=t,r=!0}),fm("runSync","run",r),n}stringify(e,t){this.freeze();const n=mm(t),r=this.compiler||this.Compiler;return cm("stringify",r),dm(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(um("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=qf(!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];Wf(i)&&Wf(r)&&(r=qf(!0,i,r)),n[a]=[e,r,...s]}}}}const om=(new im).freeze();function lm(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function cm(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function um(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 dm(e){if(!Wf(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function fm(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function mm(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new em(e)}const pm=[],hm={allowDangerousHtml:!0},gm=/^(https?|ircs?|mailto|xmpp)$/i,xm=[{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 ym(e){const t=function(e){const t=e.rehypePlugins||pm,n=e.remarkPlugins||pm,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...hm}:hm,a=om().use(sf).use(n).use(Uf,r).use(t);return a}(e),n=function(e){const t=e.children||"",n=new em;"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||bm;for(const u of xm)Object.hasOwn(t,u.from)&&Ul((u.from,u.to&&u.to,u.id));return Af(e,c),Zc(e,{Fragment:Ft.Fragment,components:a,ignoreInvalidStyle:!0,jsx:Ft.jsx,jsxs:Ft.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 cu)if(Object.hasOwn(cu,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=cu[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 bm(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||gm.test(e.slice(0,t))?e:""}function vm(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 wm(e,t,n){const r=jf((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([Nm(e[0]),km(e[1])])}return t}(t);let s=-1;for(;++s<a.length;)Pf(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,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){const n=d.index,a={index:d.index,input:d.input,stack:[...t,e]};let s=i(...d,a);if("string"==typeof s&&(s=s.length>0?{type:"text",value:s}:void 0),!1===s?r.lastIndex=n+1:(o!==n&&u.push({type:"text",value:e.value.slice(o,n)}),Array.isArray(s)?u.push(...s):s&&u.push(s),o=n+d[0].length,c=!0),!r.global)break;d=r.exec(e.value)}c?(o<e.value.length&&u.push({type:"text",value:e.value.slice(o)}),n.children.splice(l,1,...u)):u=[e];return l+u.length}(e,t)}}function Nm(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 km(e){return"function"==typeof e?e:function(){return e}}const jm="phrasing",Cm=["autolink","link","image","label"];function Sm(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Im(e){this.config.enter.autolinkProtocol.call(this,e)}function Em(e){this.config.exit.autolinkProtocol.call(this,e)}function Tm(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 Pm(e){this.config.exit.autolinkEmail.call(this,e)}function Am(e){this.exit(e)}function Rm(e){wm(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,_m],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Dm]],{ignore:["link","linkReference"]})}function _m(e,t,n,r,a){let s="";if(!Fm(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=vm(e,"(");let s=vm(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 Dm(e,t,n,r){return!(!Fm(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Fm(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||Fu(n)||Du(n))&&(!t||47!==n)}function zm(){this.buffer()}function Om(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Lm(){this.buffer()}function Mm(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Um(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ku(this.sliceSerialize(e)).toLowerCase(),n.label=t}function $m(e){this.exit(e)}function Bm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ku(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Vm(e){this.exit(e)}function Hm(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 qm(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?Qm:Wm)));return o(),i},footnoteReference:Hm},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function Wm(e,t,n){return 0===t?e:Qm(e,t,n)}function Qm(e,t,n){return(n?"":" ")+e}Hm.peek=function(){return"["};const Km=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function Ym(e){this.enter({type:"delete",children:[]},e)}function Jm(e){this.exit(e)}function Xm(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 Gm(e){return e.length}function Zm(e){return null==e?"":String(e)}function ep(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 tp(e,t,n){return">"+(n?"":" ")+e}function np(e,t){return rp(e,t.inConstruct,!0)&&!rp(e,t.notInConstruct,!1)}function rp(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 ap(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if("\n"===n.unsafe[a].character&&np(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function sp(e,t,n){return(n?"":" ")+e}function ip(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 op(e){return"&#x"+e.toString(16).toUpperCase()+";"}function lp(e,t,n){const r=Bu(e),a=Bu(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 cp(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),u=lp(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=op(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=lp(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+op(d));const m=i.move(a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}function up(e){return e.value||""}function dp(e,t,n,r){const a=ip(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 fp(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 u=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=u,s(),"full"!==a&&c&&c===d?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(d+"]"),l}function mp(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 pp(e,t){const n=du(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 hp(e,t,n,r){const a=ip(n),s='"'===a?"Quote":"Apostrophe",i=n.createTracker(r);let o,l;if(pp(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 gp(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 u=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:l,after:"]",...o.current()});return i(),n.stack=u,s(),"full"!==a&&c&&c===d?"shortcut"===a?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(d+"]"),l}function xp(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 yp(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}Xm.peek=function(){return"~"},cp.peek=function(e,t,n){return n.options.emphasis||"*"},up.peek=function(){return"<"},dp.peek=function(){return"!"},fp.peek=function(){return"!"},mp.peek=function(){return"`"},hp.peek=function(e,t,n){return pp(e,n)?"<":"["},gp.peek=function(){return"["};const bp=jf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function vp(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),u=lp(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=op(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=lp(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+op(d));const m=i.move(a+a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}vp.peek=function(e,t,n){return n.options.strong||"*"};const wp={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()),tp);return a(),i},break:ap,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,sp);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 u=o.move(l);if(e.lang){const t=n.enter(`codeFencedLang${i}`);u+=o.move(n.safe(e.lang,{before:u,after:" ",encode:["`"],...o.current()})),t()}if(e.lang&&e.meta){const t=n.enter(`codeFencedMeta${i}`);u+=o.move(" "),u+=o.move(n.safe(e.meta,{before:u,after:"\n",encode:["`"],...o.current()})),t()}return u+=o.move("\n"),s&&(u+=o.move(s+"\n")),u+=o.move(l),c(),u},definition:function(e,t,n,r){const a=ip(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:cp,hardBreak:ap,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 Af(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,Tf}),Boolean((!e.depth||e.depth<3)&&du(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=op(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),o(),c},html:up,image:dp,imageReference:fp,inlineCode:mp,link:hp,linkReference:gp,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):xp(n);const o=e.ordered?"."===i?")":".":function(e){const t=xp(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),yp(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||xp(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 bp(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:vp,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(yp(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 Np(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 kp(e){this.exit(e),this.data.inTable=void 0}function jp(e){this.enter({type:"tableRow",children:[]},e)}function Cp(e){this.exit(e)}function Sp(e){this.enter({type:"tableCell",children:[]},e)}function Ip(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Ep));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Ep(e,t){return"|"===t?t:e}function Tp(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=wp.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||Gm,s=[],i=[],o=[],l=[];let c=0,u=-1;for(;++u<e.length;){const t=[],r=[];let s=-1;for(e[u].length>c&&(c=e[u].length);++s<e[u].length;){const i=Zm(e[u][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[u]=t,o[u]=r}let d=-1;if("object"==typeof r&&"length"in r)for(;++d<c;)s[d]=ep(r[d]);else{const e=ep(r);for(;++d<c;)s[d]=e}d=-1;const f=[],m=[];for(;++d<c;){const e=s[d];let t="",r="";99===e?(t=":",r=":"):108===e?t=":":114===e&&(r=":");let a=!1===n.alignDelimiters?1:Math.max(1,l[d]-t.length-r.length);const i=t+"-".repeat(a)+r;!1!==n.alignDelimiters&&(a=t.length+a+r.length,a>l[d]&&(l[d]=a),m[d]=a),f[d]=i}i.splice(1,0,f),o.splice(1,0,m),u=-1;const p=[];for(;++u<i.length;){const e=i[u],t=o[u];d=-1;const r=[];for(;++d<c;){const a=e[d]||"";let i="",o="";if(!1!==n.alignDelimiters){const e=l[d]-(t[d]||0),n=s[d];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||d||r.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===a||!1===n.delimiterStart&&!d||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&&d===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 Pp(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function Ap(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 Rp(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=wp.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const _p={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},Dp={tokenize:function(e,t,n){let r,a,s;return i;function i(t){return 46===t||95===t?e.check(zp,l,o)(t):null===t||Ru(t)||Fu(t)||45!==t&&Du(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},Fp={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(zp,t,s)(i):null===i||Ru(i)||Fu(i)?t(i):(e.consume(i),a)}function s(t){return 41===t&&r++,e.consume(t),a}},partial:!0},zp={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||Ru(i)||Fu(i)?t(i):n(i)}function a(e){return null===e||40===e||91===e||Ru(e)||Fu(e)?t(e):r(e)}function s(e){return ju(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),r):ju(t)?(e.consume(t),i):n(t)}},partial:!0},Op={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return Cu(e)?n(e):t(e)}},partial:!0},Lp={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){if(87!==t&&119!==t||!Vp.call(r,r.previous)||Qp(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(_p,e.attempt(Dp,e.attempt(Fp,a),n),n)(t)};function a(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:Vp},Mp={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let a="",s=!1;return function(t){if((72===t||104===t)&&Hp.call(r,r.previous)&&!Qp(r.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if(ju(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||Iu(t)||Ru(t)||Fu(t)||Du(t)?n(t):e.attempt(Dp,e.attempt(Fp,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:Hp},Up={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let a,s;return function(t){if(!Wp(t)||!qp.call(r,r.previous)||Qp(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return Wp(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(Op,c,l)(t):45===t||95===t||Cu(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&&ju(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:qp},$p={};let Bp=48;for(;Bp<123;)$p[Bp]=Up,Bp++,58===Bp?Bp=65:91===Bp&&(Bp=97);function Vp(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||Ru(e)}function Hp(e){return!ju(e)}function qp(e){return!(47===e||Wp(e))}function Wp(e){return 43===e||45===e||46===e||95===e||Cu(e)}function Qp(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}$p[43]=Up,$p[45]=Up,$p[46]=Up,$p[95]=Up,$p[72]=[Up,Mp],$p[104]=[Up,Mp],$p[87]=[Up,Lp],$p[119]=[Up,Lp];const Kp={tokenize:function(e,t,n){const r=this;return Lu(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 Yp(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=ku(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 Jp(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 Xp(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||Ru(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return a.includes(ku(r.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return Ru(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 Gp(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||Ru(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=ku(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return Ru(t)||(i=!0),o++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a.includes(s)||a.push(s),Lu(e,f,"gfmFootnoteDefinitionWhitespace")):n(t)}function f(e){return t(e)}}function Zp(e,t,n){return e.check(Qu,t,e.attempt(Kp,t,n))}function eh(e){e.exit("gfmFootnoteDefinition")}function th(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=Bu(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"),u=Bu(s);return c._open=!u||2===u&&Boolean(l),c._close=!l||2===l&&Boolean(u),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&&gu(i,i.length,0,Vu(o,e.slice(r+1,n),t)),gu(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",a,t]]),gu(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 nh{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 rh(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 ah(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):Au(t)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):_u(t)?Lu(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||Ru(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter("tableDelimiterRow"),a=!1,_u(t)?Lu(e,f,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):f(t))}function f(t){return 45===t||58===t?p(t):124===t?(a=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),m):b(t)}function m(t){return _u(t)?Lu(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||Au(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 _u(t)?Lu(e,y,"whitespace")(t):y(t)}function y(n){return 124===n?f(n):(null===n||Au(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||Au(n)?(e.exit("tableRow"),t(n)):_u(n)?Lu(e,w,"whitespace")(n):(e.enter("data"),N(n))}function N(t){return null===t||124===t||Ru(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?k:N)}function k(t){return 92===t||124===t?(e.consume(t),N):N(t)}}function sh(e,t){let n,r,a,s=-1,i=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0;const f=new nh;for(;++s<e.length;){const m=e[s],p=m[1];"enter"===m[0]?"tableHead"===p.type?(u=!1,0!==d&&(oh(f,t,d,n,r),r=void 0,d=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},f.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],u&&(u=!1,r={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},f.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=ih(f,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=ih(f,t,l,o,void 0,a),l=[0,0,0,0]),c[2]=s)):"tableHead"===p.type?(u=!0,d=s):"tableRow"===p.type||"tableDelimiterRow"===p.type?(d=s,0!==l[1]?(c[0]=c[1],a=ih(f,t,l,o,s,a)):0!==c[1]&&(a=ih(f,t,c,o,s,a)),o=0):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type||(c[3]=s)}for(0!==d&&oh(f,t,d,n,r),f.consume(t.events),s=-1;++s<t.events.length;){const e=t.events[s];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=rh(t.events,s))}return e}function ih(e,t,n,r,a,s){const i=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},lh(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=lh(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=lh(t.events,n[2]),s=lh(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({},lh(t.events,a)),e.add(a,0,[["exit",s,t]]),s=void 0),s}function oh(e,t,n,r,a){const s=[],i=lh(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 lh(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const ch={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 Ru(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 Au(r)?t(r):_u(r)?e.check({tokenize:uh},t,n)(r):n(r)}}};function uh(e,t,n){return Lu(e,function(e){return null===e?n(e):t(e)},"whitespace")}const dh={};function fh(e){const t=e||dh,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return bu([{text:$p},{document:{91:{name:"gfmFootnoteDefinition",tokenize:Gp,continuation:{tokenize:Zp},exit:eh}},text:{91:{name:"gfmFootnoteCall",tokenize:Xp},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Yp,resolveTo:Jp}}},th(e),{flow:{null:{name:"table",tokenize:ah,resolveAll:sh}}},{text:{91:ch}}])}(t)),a.push([{transforms:[Rm],enter:{literalAutolink:Sm,literalAutolinkEmail:Im,literalAutolinkHttp:Im,literalAutolinkWww:Im},exit:{literalAutolink:Am,literalAutolinkEmail:Pm,literalAutolinkHttp:Em,literalAutolinkWww:Tm}},{enter:{gfmFootnoteCallString:zm,gfmFootnoteCall:Om,gfmFootnoteDefinitionLabelString:Lm,gfmFootnoteDefinition:Mm},exit:{gfmFootnoteCallString:Um,gfmFootnoteCall:$m,gfmFootnoteDefinitionLabelString:Bm,gfmFootnoteDefinition:Vm}},{canContainEols:["delete"],enter:{strikethrough:Ym},exit:{strikethrough:Jm}},{enter:{table:Np,tableData:Sp,tableHeader:Sp,tableRow:jp},exit:{codeText:Ip,table:kp,tableData:Cp,tableHeader:Cp,tableRow:Cp}},{exit:{taskListCheckValueChecked:Pp,taskListCheckValueUnchecked:Pp,paragraph:Ap}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:jm,notInConstruct:Cm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:jm,notInConstruct:Cm},{character:":",before:"[ps]",after:"\\/",inConstruct:jm,notInConstruct:Cm}]},qm(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Km}],handlers:{delete:Xm}},Tp(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Rp}}]}}(t))}function mh({content:e,className:t}){return Ft.jsx("div",{className:Ot("prose prose-sm max-w-none",t),children:Ft.jsx(ym,{remarkPlugins:[fh],components:{h1:({children:e})=>Ft.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>Ft.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>Ft.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>Ft.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>Ft.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>Ft.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>Ft.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...n})=>e?Ft.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...n,children:t}):Ft.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})=>Ft.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>Ft.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>Ft.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>Ft.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>Ft.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}function ph(){const[e,t]=a(!1),[n,r]=a(""),{messages:s,isLoading:o,error:l,sendMessage:u}=Ll(),d=c(null),f=c(null);i(()=>{if(d.current){const e=d.current.querySelector("[data-radix-scroll-area-viewport]");e&&(e.scrollTop=e.scrollHeight)}},[s]),i(()=>{e&&f.current&&f.current.focus()},[e]),i(()=>{const n=n=>{"Escape"===n.key&&e&&t(!1)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e]);const m=()=>{n.trim()&&!o&&(u(n),r(""))};return Ft.jsxs(Ft.Fragment,{children:[Ft.jsx(Vt,{onClick:()=>t(!e),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e?Ft.jsx(N,{className:"h-6 w-6"}):Ft.jsx($e,{className:"h-6 w-6"})}),e&&Ft.jsxs(Kt,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[Ft.jsxs(Yt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[Ft.jsx(Jt,{className:"text-lg font-semibold",children:"Chat Assistant"}),Ft.jsx(Vt,{variant:"ghost",size:"icon",onClick:()=>t(!1),className:"h-8 w-8",children:Ft.jsx(N,{className:"h-4 w-4"})})]}),Ft.jsxs(Gt,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[Ft.jsx(ns,{ref:d,className:"flex-1 px-4",children:Ft.jsxs("div",{className:"space-y-4 py-4",children:[s.map(e=>Ft.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:Ft.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?Ft.jsx(mh,{content:e.content}):Ft.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),o&&Ft.jsx("div",{className:"flex justify-start",children:Ft.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:Ft.jsxs("div",{className:"flex space-x-2",children:[Ft.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),Ft.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),Ft.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),l&&Ft.jsx("div",{className:"text-center text-sm text-destructive py-2",children:l})]})}),Ft.jsx("div",{className:"border-t p-4",children:Ft.jsxs("div",{className:"flex space-x-2",children:[Ft.jsx(qt,{ref:f,value:n,onChange:e=>r(e.target.value),onKeyPress:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),m())},placeholder:"Digite sua mensagem...",disabled:o,className:"flex-1"}),Ft.jsx(Vt,{onClick:m,disabled:o||!n.trim(),size:"icon",children:Ft.jsx(Be,{className:"h-4 w-4"})})]})})]})]})]})}function hh({open:e,onOpenChange:t,placeId:n,placeName:r,onMakeManager:s,onMakeMembers:i,currentManagerId:l,currentMemberIds:c=[]}){const[u,d]=a([]),[f,m]=a(!1),[p,h]=a(""),{data:g=[],isLoading:x}=xs({enabled:e}),y=o(()=>{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=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},v=1===u.length,w=u.length>0;return Ft.jsx(en,{open:e,onOpenChange:t,children:Ft.jsxs(sn,{className:"max-w-2xl",children:[Ft.jsx(on,{children:Ft.jsxs(cn,{className:"flex items-center gap-2",children:[Ft.jsx(Ve,{className:"h-5 w-5"}),"Gerenciar Acessos - ",r]})}),Ft.jsxs("div",{className:"relative",children:[Ft.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Ft.jsx(qt,{placeholder:"Buscar por nome ou email...",value:p,onChange:e=>h(e.target.value),className:"pl-9"})]}),Ft.jsx(ns,{className:"h-[400px] pr-4",children:x?Ft.jsx("div",{className:"space-y-2",children:[...Array(5)].map((e,t)=>Ft.jsx(ka,{className:"h-16 w-full"},t))}):0===y.length?Ft.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Ft.jsx(Ve,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),Ft.jsx("p",{className:"text-sm text-muted-foreground",children:p?"Nenhum usuário encontrado":"Nenhum usuário disponível"})]}):Ft.jsx("div",{className:"space-y-2",children:y.map(e=>{const t=e.userId===l,n=c.includes(e.userId||""),r=u.includes(e.userId||"");return Ft.jsxs("div",{className:Ot("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:[Ft.jsx(In,{checked:r,onCheckedChange:()=>b(e.userId||""),onClick:e=>e.stopPropagation()}),Ft.jsxs("div",{className:"flex-1",children:[Ft.jsxs("div",{className:"flex items-center gap-2",children:[Ft.jsx("p",{className:"font-medium",children:e.userName}),t&&Ft.jsx(He,{className:"h-4 w-4 text-yellow-500"})]}),Ft.jsx("p",{className:"text-sm text-muted-foreground",children:e.userEmail})]}),(t||n)&&Ft.jsx("div",{className:"text-xs text-muted-foreground",children:t?"Gestor":"Membro"})]},e.userId)})})}),Ft.jsxs(ln,{className:"flex gap-2 sm:gap-2",children:[Ft.jsx("div",{className:"flex-1 text-sm text-muted-foreground",children:u.length>0&&Ft.jsxs("span",{children:[u.length," selecionado(s)"]})}),v&&s&&Ft.jsxs(Vt,{onClick:async()=>{if(s&&1===u.length){m(!0);try{await s(u[0],n),d([])}finally{m(!1)}}},disabled:f,variant:"outline",children:[Ft.jsx(He,{className:"h-4 w-4 mr-2"}),"Tornar Gestor"]}),w&&i&&Ft.jsxs(Vt,{onClick:async()=>{if(i&&0!==u.length){m(!0);try{await i(u,n),d([])}finally{m(!1)}}},disabled:f,children:[Ft.jsx(qe,{className:"h-4 w-4 mr-2"}),"Tornar ",u.length>1?"Membros":"Membro"]})]})]})})}function gh({place:e,level:t=0,manageAccessConfig:n}){const[r,s]=a(!1),[i,o]=a(!1),l=e.subPlaces&&e.subPlaces.length>0,c=e.isActive??!0,u=e.usersCount??0;return Ft.jsxs("div",{children:[Ft.jsxs(vi,{open:r,onOpenChange:s,children:[Ft.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?Ft.jsxs(wi,{className:"flex items-center gap-2 flex-1",children:[Ft.jsx(P,{className:Ot("h-4 w-4 transition-transform shrink-0",r&&"rotate-90")}),Ft.jsx(Le,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Ft.jsx("span",{className:"font-medium",children:e.name}),Ft.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):Ft.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Ft.jsx("div",{className:"w-4 shrink-0"}),Ft.jsx(Le,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Ft.jsx("span",{className:"font-medium",children:e.name})]}),Ft.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[Ft.jsxs("div",{className:"flex items-center gap-1.5",children:[Ft.jsx(Ve,{className:"h-3.5 w-3.5 text-muted-foreground"}),Ft.jsx("span",{className:"text-sm text-muted-foreground",children:u})]}),Ft.jsx(Pn,{variant:c?"default":"secondary",className:"text-xs",children:c?"Ativo":"Inativo"}),n&&Ft.jsx(ul,{customActions:[{label:"Gerenciar Acessos",icon:Se,onClick:()=>o(!0),variant:"default"}],renderAs:"dropdown",variant:"compact"})]})]}),l&&Ft.jsx(Ni,{children:e.subPlaces.map(e=>Ft.jsx(gh,{place:e,level:t+1,manageAccessConfig:n},e.id))})]}),0===t&&Ft.jsx(Mi,{}),n&&Ft.jsx(hh,{open:i,onOpenChange:o,placeId:e.id,placeName:e.name,onMakeManager:n.onMakeManager,onMakeMembers:n.onMakeMembers,currentManagerId:n.getCurrentManagerId?.(e.id),currentMemberIds:n.getCurrentMemberIds?.(e.id)})]})}function xh({places:e,isLoading:t,manageAccessConfig:n}){return t?Ft.jsx("div",{className:"flex items-center justify-center py-12",children:Ft.jsxs("div",{className:"text-center space-y-2",children:[Ft.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto"}),Ft.jsx("p",{className:"text-sm text-muted-foreground",children:"Carregando locais..."})]})}):e&&0!==e.length?Ft.jsxs("div",{className:"space-y-1",children:[Ft.jsx("h2",{className:"text-xl font-bold mb-4",children:"Estrutura de Locais"}),e.map(e=>Ft.jsx(gh,{place:e,manageAccessConfig:n},e.id))]}):Ft.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-3",children:[Ft.jsx(Le,{className:"h-12 w-12 text-muted-foreground/50"}),Ft.jsxs("div",{children:[Ft.jsx("h3",{className:"font-semibold text-lg",children:"Nenhum local encontrado"}),Ft.jsx("p",{className:"text-sm text-muted-foreground",children:"Não há locais cadastrados para esta unidade."})]})]})}var yh=Object.defineProperty,bh=(e,t,n)=>((e,t,n)=>t in e?yh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const vh=new class{constructor(){bh(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=jr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=or.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 jr.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 ur.handleError(r instanceof Error?r:"Erro ao buscar locais após renovação de token",!0),[]}return ur.handleError(n instanceof Error?n.message:"Erro ao buscar locais",!0),[]}}};export{Er as AUTH_CONFIG,Ks as Accordion,Xs as AccordionContent,Ys as AccordionItem,Js as AccordionTrigger,Ht as ActionButton,Wa as ActionMenuItems,ul as ActionMenuPrimitive,Ls as Alert,Us as AlertDescription,ra as AlertDialog,fa as AlertDialogAction,ma as AlertDialogCancel,oa as AlertDialogContent,da as AlertDialogDescription,ca as AlertDialogFooter,la as AlertDialogHeader,ia as AlertDialogOverlay,sa as AlertDialogPortal,ua as AlertDialogTitle,aa as AlertDialogTrigger,Ms as AlertTitle,Nl as AppHeader,Rl as AppLayout,Al as AppSidebar,Gs as AspectRatio,Nr as AuthErrorInterceptor,Zr as AuthProvider,Xr as AuthService,Zs as Avatar,ti as AvatarFallback,ei as AvatarImage,Pn as Badge,bs as BaseForm,ni as Breadcrumb,li as BreadcrumbEllipsis,ai as BreadcrumbItem,si as BreadcrumbLink,ri as BreadcrumbList,ii as BreadcrumbPage,oi as BreadcrumbSeparator,Ns as BulkActionBar,Vt as Button,Tr as CRUD_CONFIG,bi as Calendar,$s as CallbackPage,Kt as Card,Gt as CardContent,Xt as CardDescription,Zt as CardFooter,Yt as CardHeader,Ca as CardSkeleton,Jt as CardTitle,fl as CardsPrimitive,ph as ChatbotPage,In as Checkbox,vi as Collapsible,Ni as CollapsibleContent,wi as CollapsibleTrigger,ts as ColorPicker,is as Command,os as CommandDialog,us as CommandEmpty,ds as CommandGroup,ls as CommandInput,ms as CommandItem,cs as CommandList,fs as CommandSeparator,ps as CommandShortcut,ml as CrudCards,Es as CrudPageInternal,ws as CrudPagination,Ya as CrudTable,ki as DataList,pa as DeleteConfirmationDialog,en as Dialog,rn as DialogClose,sn as DialogContent,un as DialogDescription,ln as DialogFooter,on as DialogHeader,an as DialogOverlay,nn as DialogPortal,cn as DialogTitle,tn as DialogTrigger,Aa as DropdownMenu,$a as DropdownMenuCheckboxItem,Ma as DropdownMenuContent,_a as DropdownMenuGroup,Ua as DropdownMenuItem,Va as DropdownMenuLabel,Da as DropdownMenuPortal,za as DropdownMenuRadioGroup,Ba as DropdownMenuRadioItem,Ha as DropdownMenuSeparator,qa as DropdownMenuShortcut,Fa as DropdownMenuSub,La as DropdownMenuSubContent,Oa as DropdownMenuSubTrigger,Ra as DropdownMenuTrigger,zl as EmailService,Pa as EmptyState,gs as EntitySelect,Fl as ErrorBoundary,Is as FilterBar,dl as FilterBarPrimitive,dn as Form,yn as FormControl,mn as FormField,gn as FormItem,xn as FormLabel,bn as FormMessage,Sa as FormSkeleton,Si as Grid,Ia as HeaderSkeleton,ss as IconPicker,qt as Input,Qt as Label,_n as LoadingState,Bs as LoginPage,zr as MESSAGES,hh as ManageAccessModal,mh as MarkdownMessage,yl as NavigationProvider,Ii as PageBreadcrumb,Ti as Pagination,Pi as PaginationContent,Fi as PaginationEllipsis,Ai as PaginationItem,Ri as PaginationLink,Di as PaginationNext,_i as PaginationPrevious,vs as PaginationPrimitive,gh as PlaceCard,xh as PlacesList,Xa as Popover,Za as PopoverContent,Ga as PopoverTrigger,zi as Progress,zs as ProtectedRoute,Rr as QUERY_KEYS,Br as QualiexEnrichmentService,jr as QualiexErrorInterceptor,ys as QualiexUserField,Oi as RadioGroup,Li as RadioGroupItem,Pr as SEARCH_CONFIG,ns as ScrollArea,rs as ScrollBar,vn as Select,Cn as SelectContent,Sn as SelectItem,Nn as SelectTrigger,wn as SelectValue,Mi as Separator,Ui as Sheet,Bi as SheetClose,Wi as SheetContent,Ji as SheetDescription,Ki as SheetFooter,Qi as SheetHeader,Hi as SheetOverlay,Vi as SheetPortal,Yi as SheetTitle,$i as SheetTrigger,so as Sidebar,po as SidebarContent,fo as SidebarFooter,ho as SidebarGroup,xo as SidebarGroupAction,yo as SidebarGroupContent,go as SidebarGroupLabel,uo as SidebarHeader,co as SidebarInput,lo as SidebarInset,bo as SidebarMenu,ko as SidebarMenuAction,jo as SidebarMenuBadge,No as SidebarMenuButton,vo as SidebarMenuItem,Co as SidebarMenuSkeleton,So as SidebarMenuSub,Eo as SidebarMenuSubButton,Io as SidebarMenuSubItem,ao as SidebarProvider,oo as SidebarRail,mo as SidebarSeparator,Ea as SidebarSkeleton,io as SidebarTrigger,ka as Skeleton,To as Slider,Po as SonnerToaster,Rn as Spinner,Ss as Stack,Jo as Switch,rl as TabPageContent,nl as TabPageHeader,tl as TabPageLayout,ha as Table,xa as TableBody,Na as TableCaption,wa as TableCell,ya as TableFooter,va as TableHead,ga as TableHeader,cl as TablePrimitive,ba as TableRow,Qa as TableRowActions,ja as TableSkeleton,Xo as Tabs,el as TabsContent,Go as TabsList,Zo as TabsTrigger,En as Textarea,Wn as Toast,Qn as ToastAction,Kn as ToastClose,Jn as ToastDescription,Vn as ToastProvider,Yn as ToastTitle,Hn as ToastViewport,Xn as Toaster,sl as Toggle,ol as ToggleGroup,ll as ToggleGroupItem,or as TokenManager,Zn as TokenService,Gi as Tooltip,eo as TooltipContent,Xi as TooltipProvider,Zi as TooltipTrigger,Sl as assets,Tn as badgeVariants,Bt as buttonVariants,Ot as cn,Ts as createCrudPage,hl as createCrudRoutingConfig,pl as createRoutingHandlers,qr as createService,Ps as createSimpleSaveHandler,na as createSimpleService,Ds as crudPresets,$t as debounce,Lr as deriveEmailField,Or as deriveNameField,Mr as deriveUsernameField,Ol as emailService,ur as errorService,Ut as formatCurrency,Mt as formatDatetime,As as generateCrudConfig,Dr as getQualiexConfig,xr as getSupabaseClient,zt as handleExternalLink,Ar as isDevEnvironment,Il as logoSrc,vh as placeService,Ir as qualiexApi,Ur as resolveFieldMappings,Fr as setQualiexConfig,Qs as setupQualiexCore,El as smallLogoSrc,$n as toast,al as toggleVariants,Lt as trimTextFields,kl as useActiveModules,ea as useAuth,Ja as useBaseForm,ta as useCrud,wl as useDebounce,bl as useNavigation,Ll as useOpenAIChat,Ws as usePageMetadata,vl as usePageTitle,jl as usePermissionQuery,xs as useQualiexUsers,Ei as useRouteBreadcrumbs,ro as useSidebar,Bn as useToast,Fs as withPreset};
|