forlogic-core 1.7.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +857 -132
- package/dist/README.md +857 -132
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -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
|
|
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 S,Loader2 as C,AlertCircle as I,Search as P,FileX as T,ChevronRight as E,Circle as A,Edit as _,PowerOff as R,Power as D,Trash2 as z,ArrowUpDown as O,ArrowUp as L,ArrowDown as F,Target as M,Trophy as U,Award as B,Sparkles as $,Flame as V,Zap as q,Key as H,Shield as W,EyeOff as Q,Eye as K,Unlock as Y,Lock as J,Archive as X,FolderOpen as G,Folder as Z,FileText as ee,Save as te,Copy as ne,Share as re,Upload as ae,Download as se,HelpCircle as ie,Info as oe,Bell as le,Clock as ce,ArrowRight as 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 Se,Settings as Ce,User as Ie,Home as Pe,Heart as Te,Star as Ee,ChevronsLeft as Ae,ChevronsRight as _e,RefreshCw as Re,MoreHorizontal as De,PanelLeft as ze,ExternalLink as Oe,Building2 as Le,Users as Fe,Crown as Me,LogOut as Ue,AlertTriangle as Be,MessageCircle as $e,Send as Ve}from"lucide-react";import*as qe from"@radix-ui/react-label";import*as He from"@radix-ui/react-dialog";import{useFormContext as We,FormProvider as Qe,Controller as Ke}from"react-hook-form";import*as Ye from"@radix-ui/react-select";import*as Je from"@radix-ui/react-checkbox";import*as Xe from"@radix-ui/react-toast";import{createClient as Ge}from"@supabase/supabase-js";import{useQueryClient as Ze,useQuery as et,useMutation as tt,QueryClient as nt}from"@tanstack/react-query";import{useSearchParams as rt,useLocation as at,useNavigate as st,Link as it}from"react-router-dom";import*as ot from"@radix-ui/react-alert-dialog";import*as lt from"@radix-ui/react-dropdown-menu";import*as ct from"@radix-ui/react-popover";import*as ut from"@radix-ui/react-scroll-area";import*as dt from"@radix-ui/react-accordion";import*as ft from"@radix-ui/react-aspect-ratio";import*as mt from"@radix-ui/react-avatar";import{DayPicker as pt}from"react-day-picker";import*as ht from"@radix-ui/react-collapsible";import*as gt from"@radix-ui/react-progress";import*as xt from"@radix-ui/react-radio-group";import*as yt from"@radix-ui/react-separator";import*as bt from"@radix-ui/react-tooltip";import*as vt from"@radix-ui/react-slider";import{useTheme as wt}from"next-themes";import"react-dom";import*as Nt from"@radix-ui/react-tabs";import*as kt from"@radix-ui/react-toggle";import*as jt from"@radix-ui/react-toggle-group";function St(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ct,It={exports:{}},Pt={};var Tt,Et,At={};
|
|
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 At(){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,k,N,j,S,C,I,T=Object.assign,E=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,O=!1,z="function"==typeof WeakMap?WeakMap:Map;function L(e,t){if(!e||O)return"";var n,r=D.get(e);if(void 0!==r)return r;O=!0;var a,s=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=R.current,R.current=null,function(){if(0===E){w=console.log,k=console.info,N=console.warn,j=console.error,S=console.group,C=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})}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&&D.set(e,d),d}}while(c>=1&&u>=0);break}}}finally{O=!1,R.current=a,function(){if(0===--E){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:T({},e,{value:w}),info:T({},e,{value:k}),warn:T({},e,{value:N}),error:T({},e,{value:j}),group:T({},e,{value:S}),groupCollapsed:T({},e,{value:C}),groupEnd:T({},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?_(f):"";return"function"==typeof e&&D.set(e,m),m}function F(e,t,n){if(null==e)return"";if("function"==typeof e)return L(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if("string"==typeof e)return _(e);switch(e){case u:return _("Suspense");case d:return _("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return L(e.render,!1);case f:return F(e.type,t,n);case m:var r=e,a=r._payload,s=r._init;try{return F(s(a),t,n)}catch(i){}}return""}D=new z;var M=Object.prototype.hasOwnProperty,B={},$=g.ReactDebugCurrentFrame;function U(e){if(e){var t=e._owner,n=F(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,X={key:!0,ref:!0,__self:!0,__source:!0};function J(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)&&!X.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=F(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||(U(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),U(null)),o instanceof Error&&!(o.message in B)&&(B[o.message]=!0,U(a),x("Failed %s type: %s",n,o.message),U(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 k="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(k+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var N;k+=re(),null===e?N="null":H(e)?N="array":void 0!==e&&e.$$typeof===n?(N="<"+(v(e.type)||"Unknown")+" />",k=" Did you accidentally export a JSX literal instead of a component?"):N=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",N,k)}var j=J(e,t,r,g,b);if(null==j)return j;if(w){var S=t.children;if(void 0!==S)if(h)if(H(S)){for(var C=0;C<S.length;C++)ie(S[C],e);Object.freeze&&Object.freeze(S)}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(S,e)}if(M.call(t,"key")){var I=v(e),T=Object.keys(t).filter(function(e){return"key"!==e}),E=T.length>0?"{key: someKey, "+T.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,T.length>0?"{"+T.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)};Pt.Fragment=a,Pt.jsx=ue,Pt.jsxs=de}()),Pt}var Rt=(Et||(Et=1,"production"===process.env.NODE_ENV?Ct.exports=function(){if(St)return It;St=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 It.Fragment=r,It.jsx=o,It.jsxs=o,It}():Ct.exports=At()),Ct.exports);function _t(e,t){t?.stopPropagation();window.open(e,"_blank","noopener,noreferrer")||navigator.clipboard.writeText(e).then(()=>{b.info("Link copiado para a área de transferência")})}function Dt(...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},zt=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"})}`},Lt=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),Ft=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},Mt=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"}}),Bt=e.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...a},s)=>{const i=r?d:"button";return Rt.jsx(i,{className:Dt(Mt({variant:t,size:n,className:e})),ref:s,...a})});Bt.displayName="Button";const $t=e.forwardRef(({className:e,type:t,...n},r)=>Rt.jsx("input",{type:t,className:Dt("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}));$t.displayName="Input";const Ut=m("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Vt=e.forwardRef(({className:e,...t},n)=>Rt.jsx(w.Root,{ref:n,className:Dt(Ut(),e),...t}));Vt.displayName=w.Root.displayName;const Ht=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Ht.displayName="Card";const qt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("flex flex-col space-y-1.5 p-6",e),...t}));qt.displayName="CardHeader";const Wt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("h3",{ref:n,className:Dt("text-2xl font-semibold leading-none tracking-tight",e),...t}));Wt.displayName="CardTitle";const Qt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("p",{ref:n,className:Dt("text-sm text-muted-foreground",e),...t}));Qt.displayName="CardDescription";const Kt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("p-6 pt-0",e),...t}));Kt.displayName="CardContent";const Yt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("flex items-center p-6 pt-0",e),...t}));Yt.displayName="CardFooter";const Xt=k.Root,Jt=k.Trigger,Gt=k.Portal,Zt=k.Close,en=e.forwardRef(({className:e,...t},n)=>Rt.jsx(k.Overlay,{ref:n,className:Dt("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}));en.displayName=k.Overlay.displayName;const tn=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(Gt,{children:[Rt.jsx(en,{}),Rt.jsxs(k.Content,{ref:r,className:Dt("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,Rt.jsxs(k.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:[Rt.jsx(N,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));tn.displayName=k.Content.displayName;const nn=({className:e,...t})=>Rt.jsx("div",{className:Dt("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});nn.displayName="DialogHeader";const rn=({className:e,...t})=>Rt.jsx("div",{className:Dt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});rn.displayName="DialogFooter";const an=e.forwardRef(({className:e,...t},n)=>Rt.jsx(k.Title,{ref:n,className:Dt("text-lg font-semibold leading-none tracking-tight",e),...t}));an.displayName=k.Title.displayName;const sn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(k.Description,{ref:n,className:Dt("text-sm text-muted-foreground",e),...t}));sn.displayName=k.Description.displayName;const on=We,ln=e.createContext({}),cn=({...e})=>Rt.jsx(ln.Provider,{value:{name:e.name},children:Rt.jsx(Qe,{...e})}),un=()=>{const t=e.useContext(ln),n=e.useContext(dn),{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}},dn=e.createContext({}),fn=e.forwardRef(({className:t,...n},r)=>{const a=e.useId();return Rt.jsx(dn.Provider,{value:{id:a},children:Rt.jsx("div",{ref:r,className:Dt("space-y-2",t),...n})})});fn.displayName="FormItem";const mn=e.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:a}=un();return Rt.jsx(Vt,{ref:n,className:Dt(r&&"text-destructive",e),htmlFor:a,...t})});mn.displayName="FormLabel";const pn=e.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:a,formMessageId:s}=un();return Rt.jsx(d,{ref:t,id:r,"aria-describedby":n?`${a} ${s}`:`${a}`,"aria-invalid":!!n,...e})});pn.displayName="FormControl";e.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=un();return Rt.jsx("p",{ref:n,id:r,className:Dt("text-sm text-muted-foreground",e),...t})}).displayName="FormDescription";const hn=e.forwardRef(({className:e,children:t,...n},r)=>{const{error:a,formMessageId:s}=un(),i=a?String(a?.message):t;return i?Rt.jsx("p",{ref:r,id:s,className:Dt("text-sm font-medium text-destructive",e),...n,children:i}):null});hn.displayName="FormMessage";const gn=Ke.Root,xn=Ke.Value,yn=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(Ke.Trigger,{ref:r,className:Dt("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,Rt.jsx(Ke.Icon,{asChild:!0,children:Rt.jsx(j,{className:"h-4 w-4 opacity-50"})})]}));yn.displayName=Ke.Trigger.displayName;const bn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.ScrollUpButton,{ref:n,className:Dt("flex cursor-default items-center justify-center py-1",e),...t,children:Rt.jsx(S,{className:"h-4 w-4"})}));bn.displayName=Ke.ScrollUpButton.displayName;const vn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.ScrollDownButton,{ref:n,className:Dt("flex cursor-default items-center justify-center py-1",e),...t,children:Rt.jsx(j,{className:"h-4 w-4"})}));vn.displayName=Ke.ScrollDownButton.displayName;const wn=e.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>Rt.jsx(Ke.Portal,{children:Rt.jsxs(Ke.Content,{ref:a,className:Dt("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:[Rt.jsx(bn,{}),Rt.jsx(Ke.Viewport,{className:Dt("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),Rt.jsx(vn,{})]})}));wn.displayName=Ke.Content.displayName;e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.Label,{ref:n,className:Dt("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=Ke.Label.displayName;const kn=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(Ke.Item,{ref:r,className:Dt("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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(Ke.ItemIndicator,{children:Rt.jsx(C,{className:"h-4 w-4"})})}),Rt.jsx(Ke.ItemText,{children:t})]}));kn.displayName=Ke.Item.displayName;e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ke.Separator,{ref:n,className:Dt("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=Ke.Separator.displayName;const Nn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ye.Root,{ref:n,className:Dt("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:Rt.jsx(Ye.Indicator,{className:Dt("flex items-center justify-center text-current"),children:Rt.jsx(C,{className:"h-4 w-4"})})}));Nn.displayName=Ye.Root.displayName;const jn=e.forwardRef(({className:e,...t},n)=>Rt.jsx("textarea",{className:Dt("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}));jn.displayName="Textarea";const Sn=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"}}),Cn=e.forwardRef(({className:e,variant:t,...n},r)=>Rt.jsx("div",{ref:r,className:Dt(Sn({variant:t}),e),...n}));Cn.displayName="Badge";const In={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function Tn({size:e="md",className:t}){return Rt.jsx(I,{className:Dt("animate-spin text-muted-foreground",In[e],t)})}function En({isLoading:e,children:t,className:n,type:r="spinner",size:a="md"}){return e?"overlay"===r?Rt.jsxs("div",{className:Dt("relative",n),children:[t,Rt.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:Rt.jsx(Tn,{size:a})})]}):"skeleton"===r?Rt.jsx("div",{className:Dt("animate-pulse",n),children:Rt.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):Rt.jsx("div",{className:Dt("flex items-center justify-center py-8",n),children:Rt.jsx(Tn,{size:a})}):Rt.jsx(Rt.Fragment,{children:t})}let Pn=0;const An=new Map,Rn=e=>{if(An.has(e))return;const t=setTimeout(()=>{An.delete(e),zn({type:"REMOVE_TOAST",toastId:e})},1e6);An.set(e,t)},_n=(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?Rn(n):e.toasts.forEach(e=>{Rn(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)}}},Dn=[];let On={toasts:[]};function zn(e){On=_n(On,e),Dn.forEach(e=>{e(On)})}function Ln({...e}){const t=(Pn=(Pn+1)%Number.MAX_SAFE_INTEGER,Pn.toString()),n=()=>zn({type:"DISMISS_TOAST",toastId:t});return zn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||n()}}}),{id:t,dismiss:n,update:e=>zn({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function Fn(){const[t,n]=e.useState(On);return e.useEffect(()=>(Dn.push(n),()=>{const e=Dn.indexOf(n);e>-1&&Dn.splice(e,1)}),[t]),{...t,toast:Ln,dismiss:e=>zn({type:"DISMISS_TOAST",toastId:e})}}const Mn=Xe.Provider,Bn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.Viewport,{ref:n,className:Dt("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}));Bn.displayName=Xe.Viewport.displayName;const $n=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"}}),Un=e.forwardRef(({className:e,variant:t,...n},r)=>Rt.jsx(Xe.Root,{ref:r,className:Dt($n({variant:t}),e),...n}));Un.displayName=Xe.Root.displayName;const Vn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.Action,{ref:n,className:Dt("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}));Vn.displayName=Xe.Action.displayName;const Hn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.Close,{ref:n,className:Dt("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:Rt.jsx(N,{className:"h-4 w-4"})}));Hn.displayName=Xe.Close.displayName;const qn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.Title,{ref:n,className:Dt("text-sm font-semibold",e),...t}));qn.displayName=Xe.Title.displayName;const Wn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.Description,{ref:n,className:Dt("text-sm opacity-90",e),...t}));function Qn(){const{toasts:e}=Fn();return Rt.jsxs(Mn,{children:[e.map(function({id:e,title:t,description:n,action:r,...a}){return Rt.jsxs(Un,{...a,children:[Rt.jsxs("div",{className:"grid gap-1",children:[t&&Rt.jsx(qn,{children:t}),n&&Rt.jsx(Wn,{children:n})]}),r,Rt.jsx(Hn,{})]},e)}),Rt.jsx(Bn,{})]})}Wn.displayName=Xe.Description.displayName;var Kn=Object.defineProperty;class Yn{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?Kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(Yn,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Xn="qualiex_access_token",Jn="qualiex_id_token",Gn="supabase_token",Zn="oauth_state",er="oauth_nonce",tr="selected_alias",nr="manual_logout",rr={setAccessToken:e=>localStorage.setItem(Xn,e),getAccessToken:()=>localStorage.getItem(Xn),setIdToken:e=>localStorage.setItem(Jn,e),getIdToken:()=>localStorage.getItem(Jn),getSupabaseToken:()=>localStorage.getItem(Gn),setOAuthState:e=>sessionStorage.setItem(Zn,e),getOAuthState:()=>sessionStorage.getItem(Zn),clearOAuthState:()=>sessionStorage.removeItem(Zn),setOAuthNonce:e=>sessionStorage.setItem(er,e),getOAuthNonce:()=>sessionStorage.getItem(er),clearOAuthNonce:()=>sessionStorage.removeItem(er),setSelectedAlias:e=>localStorage.setItem(tr,e),getSelectedAlias:()=>localStorage.getItem(tr),clearSelectedAlias:()=>localStorage.removeItem(tr),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!rr.getAccessToken()||!rr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(Gn,e),rr._clearValidationCache()},areAllTokensValid:()=>{const e=rr.getAccessToken(),t=rr.getIdToken();if(!e||!t)return!1;try{const n=Yn.validateTokens(e,t);return!!n.idTokenValid&&(n.accessTokenValid,n.idTokenValid)}catch(n){return!1}},clearExpiredTokens:()=>{let e=!1;const t=rr.getAccessToken(),n=rr.getIdToken(),r=rr.getSupabaseToken();return t&&rr.isTokenExpired(t)&&(localStorage.removeItem(Xn),e=!0),n&&rr.isTokenExpired(n)&&(localStorage.removeItem(Jn),e=!0),r&&rr.isTokenExpired(r)&&(localStorage.removeItem(Gn),e=!0),e},clearAll:()=>{localStorage.removeItem(Xn),localStorage.removeItem(Jn),localStorage.removeItem(Gn),localStorage.removeItem(tr),localStorage.removeItem(nr),sessionStorage.removeItem(Zn),sessionStorage.removeItem(er)},setManualLogout:()=>localStorage.setItem(nr,"true"),isManualLogout:()=>"true"===localStorage.getItem(nr),clearManualLogout:()=>localStorage.removeItem(nr),isTokenExpired:e=>{try{return Yn.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{rr._validationCache.isValid=!1,rr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=rr.getSupabaseToken();if(!e)return!1;if(rr.isTokenExpired(e))return rr._clearValidationCache(),rr._handleExpiredToken(),!1;const t=Date.now();return t-rr._validationCache.timestamp<rr._validationCache.cacheValidityMs?rr._validationCache.isValid:(rr._validationCache.isValid=!0,rr._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>rr.isSupabaseTokenValid()?rr.getSupabaseToken():null,_handleExpiredToken:()=>{rr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!rr.isSupabaseTokenValid())return null;const e=rr.getSupabaseToken();if(!e)return null;try{const t=Yn.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 rr._handleExpiredToken(),null}},getCompanyId:e=>{const t=rr.extractTokenData();if(!t)return null;if(!e)return t.companyId;const n=rr.getIdToken();if(!n)return null;try{const t=Yn.parseJwtPayload(n);if(!t)return null;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(t.length>7&&t[0]===e)return t[7]}}}catch{return null}return null},getCurrentCompanyId:()=>{const e=rr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=rr.getIdToken();if(!e)return[];try{const t=Yn.parseJwtPayload(e);if(!t)return[];const n=[];for(const e in t)if(e.startsWith("co")&&/^co\d+$/.test(e)){const r=t[e];if(r&&"string"==typeof r){const e=r.split(";");e.length>=4&&n.push({id:e.length>7?e[7]:"",alias:e[0].trim(),name:e[3].trim(),payload:t})}}return n}catch{return[]}}};var ar=Object.defineProperty,sr=(e,t,n)=>((e,t,n)=>t in e?ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const ir=new class{constructor(){sr(this,"errors",[]),sr(this,"toastCount",0),sr(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()){Ln({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){Ln({title:e,description:t,variant:"default"})}shouldShowToast(){const e=Date.now();return e-this.lastToastTime>6e4&&(this.toastCount=0),this.toastCount<3&&(this.toastCount++,this.lastToastTime=e,!0)}getErrors(){return this.errors.slice(-50)}clearErrors(){this.errors=[]}};var or=Object.defineProperty,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=import.meta.env.VITE_SUPABASE_URL,ur=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,dr=class e{constructor(){lr(this,"client"),lr(this,"currentToken",null),lr(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:ur};return e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`),Je(cr,ur,{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=rr.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 ir.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};lr(dr,"instance");let fr=dr;const mr=()=>fr.getInstance().getClient();var pr=Object.freeze({__proto__:null,getSupabaseClient:mr});class hr{static async generateToken(e,t,n,r=!1){try{if(!r){const e=rr.getSupabaseToken();if(e&&rr.isSupabaseTokenValid())return e}const a=mr(),{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?(rr.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 gr=Object.defineProperty,xr=(e,t,n)=>((e,t,n)=>t in e?gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class yr{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=rr.getAccessToken(),t=rr.getSelectedAlias();if(!e||!t)return null;const n=await hr.generateToken(e,t,this.onLogoutCallback||void 0,!1);return n?(rr.setSupabaseToken(n),n):null}catch(e){return null}finally{this.isRegenerating=!1}}}xr(yr,"isRegenerating",!1),xr(yr,"onLogoutCallback",null);class br{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(rr.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 vr=Object.defineProperty;class wr{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 yr.attemptRegeneration()?(this.isRetrying=!1,!0):(br.handleError(e),this.isRetrying=!1,!1)}catch(r){return br.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=rr.getAccessToken();return e?rr.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?vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,t+"",n)})(wr,"isRetrying",!1);var kr=Object.defineProperty,Nr=(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);const jr=new class{constructor(){Nr(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=wr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=rr.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{userId:e.userId||String(e.ID),userName:e.userName||"Nome não disponível",userEmail:e.userEmail||"Email não disponível"}}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 ir.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=n}if(!Array.isArray(r))return ir.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(n){if(await wr.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 ir.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=n}return Array.isArray(r)?r.map(this.mapToQualiexUser):(ir.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return ir.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 ir.handleError(a,!0),[]}}async fetchUserById(e,t,n){try{return(await this.fetchUsers(t,n)).find(t=>t.userId===e)||null}catch(r){return ir.handleError(r instanceof Error?r:"[QualiexApi] Error fetching user by ID"),null}}async getUsers(e){const t=rr.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):(ir.handleError("[QualiexApi] CompanyId não encontrado no token Supabase",!1),[])}};class Sr{static async extractTokenData(){const e=rr.extractTokenData();return e||(ir.handleError("[QualiexEnrichment] ❌ Token Supabase não encontrado",!1),null)}static async enrichWithResponsibleNames(e,t){if(!e||0===e.length)return ir.handleError(`[QualiexEnrichment.${t.entityName}] Nenhuma entidade encontrada`,!1),e;try{const n=await this.extractTokenData();if(!n)return e.map(e=>({...e,responsible_name:e.id_user?"Token não encontrado":null}));const{alias:r,companyId:a}=n;if(!r||!a)return ir.handleError(`[QualiexEnrichment.${t.entityName}] DADOS OBRIGATÓRIOS FALTANDO - alias: ${!!r}, companyId: ${!!a}`,!1),e.map(e=>({...e,responsible_name:e.id_user?`Configuração incompleta (alias: ${!!r}, companyId: ${!!a})`:null}));const s=await jr.getUsers(r),i=e.map(e=>{if(e.id_user){const t=s.find(t=>t.userId===e.id_user);return{...e,responsible_name:t?.userName||`ID não encontrado: ${e.id_user}`}}return{...e,responsible_name:null}});i.filter(e=>e.responsible_name&&!e.responsible_name.includes("ID não encontrado")&&!e.responsible_name.includes("Erro:")&&!e.responsible_name.includes("Token não encontrado")&&!e.responsible_name.includes("Configuração incompleta")).length;return i}catch(n){return ir.handleError(n instanceof Error?n:`[QualiexEnrichment.${t.entityName}] 💥 ERRO CRÍTICO`),e.map(e=>({...e,responsible_name:e.id_user?`Erro: ${n.message}`:null}))}}}const Cr={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"}},Ir={pagination:{defaultPageSize:25,pageSizeOptions:[10,25,50,100]},sorting:{defaultField:"updated_at",defaultDirection:"desc"}},Tr={debounceDelay:500},Er=()=>{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},Pr={crud:e=>[e],list:(e,t)=>[e,"list",t],detail:(e,t)=>[e,"detail",t]};let Ar={enableUserEnrichment:!1,enableUsersApi:!1};const Rr=()=>Ar,_r=e=>{Ar={...Ar,...e}},Dr={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}`}},Or=["responsible_name"],zr=e=>Or.includes(e);function Lr(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(!rr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return mr().schema(o).from(a)};return{async getAll(e={}){const{search:t="",sortField:n="updated_at",sortDirection:r="desc",page:o=1,limit:d=25,...f}=e;let m=u().select(i||"*",{count:"exact"});m=m.eq("is_removed",!1),Object.entries(f).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?m=m.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?m=m.not(e,"is",null):"is_null"===t.operator&&(m=m.is(e,null)):null!==t&&(m=m.eq(e,t)))}),m=((e,t)=>{if(t&&s.length>0){const n=s.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(n)}return e})(m,t);n.includes(".")||zr(n)||(m=m.order(n,{ascending:"asc"===r})),m=((e,t,n)=>{const r=(t-1)*n,a=r+n-1;return e.range(r,a)})(m,o,d);const{data:p,error:h,count:g}=await m;if(h)throw new Error(`Error fetching ${a}: ${h.message}`);let x=((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}})(p||[],g,o,d);const y=Rr();if(c&&y.enableUserEnrichment&&l&&x.data.length>0){if(x.data.some(e=>e.id_user)){const t=n&&n.includes(".");if(n&&(zr(n)||t)){const a={...e,page:1,limit:500,sortField:void 0,sortDirection:void 0},s=await this.getAll(a);if(!s?.data?.length)return s;const i=await Sr.enrichWithResponsibleNames(s.data,{entityName:l});let c;c=t?i.sort((e,t)=>{const a=n.split(".").reduce((e,t)=>e?.[t],e)||"",s=n.split(".").reduce((e,t)=>e?.[t],t)||"",i=String(a).localeCompare(String(s),"pt-BR");return"asc"===r?i:-i}):((e,t,n)=>[...e].sort((e,r)=>{const a=e[t]||"",s=r[t]||"",i=a.localeCompare(s,"pt-BR",{sensitivity:"base"});return"asc"===n?i:-i}))(i,n,r);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,o,d);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 a=await Sr.enrichWithResponsibleNames(x.data,{entityName:l});x={...x,data:a}}}return x},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 Fr=()=>{rr.clearManualLogout()},Mr=class{static async initialize(){try{if(!rr.hasAllTokens()||!rr.areAllTokensValid())return rr.clearExpiredTokens(),{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null};const e=rr.getAccessToken(),t=rr.getIdToken();Fr();const n=this.extractUserFromIdToken(t),r=this.extractCompaniesFromIdToken(t),a=this.extractAliasFromAccessToken(e),s=rr.extractTokenData(),i=s?.alias;let o=null;if(i&&r.some(e=>e.alias===i))o=i;else{const e=rr.getSelectedAlias(),t=e&&r.some(t=>t.alias===e);o=t?e:a||r[0]?.alias||null}!rr.isSupabaseTokenValid()&&o&&await yr.attemptRegeneration();let l=null;if(o){const e=rr.getCompanyId(o),t=r.find(e=>e.alias===o);t&&(l={id:e||t.id,name:t.name,alias:t.alias})}const c=rr.extractTokenData();return{isAuthenticated:!0,isLoading:!1,user:n,alias:o,companies:r,selectedUnit:l,userId:n?.id||null,userAlias:n?.id||null,placeId:c?.placeId||null,placeName:c?.placeName||null}}catch(e){return{isAuthenticated:!1,isLoading:!1,user:null,alias:null,companies:[],selectedUnit:null,userId:null,userAlias:null,placeId:null,placeName:null}}}static async loginDev(){try{const{getSupabaseClient:e}=await Promise.resolve().then(function(){return pr}),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=rr.generateOAuthState();rr.setOAuthState(e);const t=rr.generateOAuthNonce();rr.setOAuthNonce(t);const n=`${window.location.origin}/callback`,r=new URL(Cr.oauth.authUrl);r.searchParams.set("client_id",Cr.oauth.clientId),r.searchParams.set("response_type",Cr.oauth.responseType),r.searchParams.set("scope",Cr.oauth.scope),r.searchParams.set("redirect_uri",n),r.searchParams.set("state",e),r.searchParams.set("nonce",t),r.searchParams.set("response_mode","fragment"),Er(),window.location.href=r.toString()}static async processCallback(){try{if(rr.hasAllTokens()){if(!rr.getValidSupabaseToken()){rr.getAccessToken();await yr.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");rr.setAccessToken(r),rr.setIdToken(a),Fr();const i=this.extractAliasFromAccessToken(r);if(i)rr.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(a);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");rr.setSelectedAlias(e[0].alias)}if(!await yr.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return rr.clearOAuthState(),rr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){rr.setManualLogout(),rr.clearAll(),window.location.href="/login"}static decodeToken(e){return Yn.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}};yr.setLogoutCallback(()=>{Mr.logout()});let Br=Mr;const $r=n(void 0),Ur=({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});let r=null;try{r=Ge()}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})},[]),h=s(async e=>{try{m(!0);const t=rr.getAccessToken();if(!t)return;const n=await hr.generateToken(t,e.alias,void 0,!0);if(!n)return;rr.setSupabaseToken(n),rr.setSelectedAlias(e.alias);const a=rr.extractTokenData(),s=a?.alias||e.alias,i={id:a?.companyId||rr.getCompanyId(e.alias)||e.id,name:e.name,alias:s};f({alias:s,selectedUnit:i}),r&&(await r.clear(),await new Promise(e=>setTimeout(e,100)))}catch(t){}finally{m(!1)}},[f,r,m]),g=s(async()=>await Br.processCallback(),[]),x=s(async()=>{Br.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&&(rr.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 Br.initialize();if(!e)return;if(t&&t.isAuthenticated){const e=rr.extractTokenData();f({user:t.user,companies:t.companies,alias:t.alias,isAuthenticated:!0,isLoading:!1,selectedUnit:t.selectedUnit,userId:t.userId,userAlias:t.userAlias,placeId:e?.placeId||null,placeName:e?.placeName||null})}else e&&m(!1)}catch(t){e&&(br.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,x,g,h,l,y,b,v]);return Rt.jsx($r.Provider,{value:w,children:e})},Vr=()=>{const e=r($r);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Hr({queryKey:e,service:t,entityName:n,searchFields:r,additionalFilters:i={},onSuccess:l}){const[c,u]=nt(),d=Ge(),{alias:f,userId:m}=Vr(),p=c.get("search")||"",h=c.get("sortField")||Ir.sorting.defaultField,g=c.get("sortDirection")||Ir.sorting.defaultDirection,x=parseInt(c.get("page")||"1"),y=parseInt(c.get("limit")||String(Ir.pagination.defaultPageSize)),v=p,w=o(()=>({search:v,sortField:h,sortDirection:g,page:x,limit:y,...i}),[v,h,g,x,y,i]),k=s(()=>t.getAll(w),[t,w]),N=Ze({queryKey:[e,f,m,w],queryFn:k});if(!N)throw new Error(`useCrud: Query initialization failed for "${n}". Ensure QueryClientProvider is configured in your app root.`);const j=et({mutationFn:t.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Dr.success.created(n)),l?.()},onError:e=>{b.error(`${Dr.error.create(n)}: ${e.message}`)}}),S=et({mutationFn:({id:e,data:n})=>t.update(e,n),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Dr.success.updated(n)),l?.()},onError:e=>{b.error(`${Dr.error.update(n)}: ${e.message}`)}}),C=et({mutationFn:t.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Dr.success.deleted(n))},onError:e=>{b.error(`${Dr.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]),T=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]),P=s(e=>{I({page:e})},[I]),A=s(e=>{I({limit:e,page:1})},[I]),R=s(()=>{u({})},[u]),[_,D]=a([]),O=s(e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),z=s(()=>{const e=N?.data?.data.map(e=>e.id)||[];D(t=>t.length===e.length?[]:e)},[N?.data?.data]),L=s(()=>{D([])},[]),F=o(()=>{const e=N?.data?.data.map(e=>e.id)||[];return e.length>0&&_.length===e.length},[_,N?.data?.data]),M=et({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`),L()},onError:e=>{b.error(`Erro ao deletar itens: ${e.message}`)}}),B=s((e,t)=>{const n=t?t(e):e;e.id?S.mutate({id:e.id,data:n}):j.mutate({...n,alias:f})},[f,j,S]);return{entities:N?.data?.data||[],pagination:{currentPage:N?.data?.currentPage||1,totalPages:N?.data?.totalPages||1,totalItems:N?.data?.totalItems||0,itemsPerPage:N?.data?.itemsPerPage||Ir.pagination.defaultPageSize,hasNextPage:N?.data?.hasNextPage||!1,hasPreviousPage:N?.data?.hasPreviousPage||!1},isLoading:N?.isLoading??!0,isCreating:j?.isPending??!1,isUpdating:S?.isPending??!1,isDeleting:C?.isPending??!1,error:N?.error||null,searchTerm:p,sortField:h,sortDirection:g,currentPage:x,itemsPerPage:y,createEntity:j.mutate,updateEntity:(e,t)=>S.mutate({id:e,data:t}),deleteEntity:C.mutate,save:B,handleSearch:T,handleSort:E,handlePageChange:P,handleItemsPerPageChange:A,clearFilters:R,refetch:N.refetch,selectedIds:_,selectItem:O,selectAll:z,clearSelection:L,isAllSelected:F,bulkDelete:M.mutate,isBulkDeleting:M.isPending}}function qr(e){const t=Lr({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0});return{service:t,useCrudHook:(n,r)=>Hr({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:n,onSuccess:r})}}const Wr=it.Root,Qr=it.Trigger,Kr=it.Portal,Yr=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Overlay,{className:Dt("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}));Yr.displayName=it.Overlay.displayName;const Xr=e.forwardRef(({className:e,...t},n)=>Rt.jsxs(Kr,{children:[Rt.jsx(Yr,{}),Rt.jsx(it.Content,{ref:n,className:Dt("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})]}));Xr.displayName=it.Content.displayName;const Jr=({className:e,...t})=>Rt.jsx("div",{className:Dt("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});Jr.displayName="AlertDialogHeader";const Gr=({className:e,...t})=>Rt.jsx("div",{className:Dt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Gr.displayName="AlertDialogFooter";const Zr=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Title,{ref:n,className:Dt("text-lg font-semibold",e),...t}));Zr.displayName=it.Title.displayName;const ea=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Description,{ref:n,className:Dt("text-sm text-muted-foreground",e),...t}));ea.displayName=it.Description.displayName;const ta=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Action,{ref:n,className:Dt(Mt(),e),...t}));ta.displayName=it.Action.displayName;const na=e.forwardRef(({className:e,...t},n)=>Rt.jsx(it.Cancel,{ref:n,className:Dt(Mt({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));na.displayName=it.Cancel.displayName;const ra=({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?Rt.jsx(Wr,{open:e,onOpenChange:f,children:Rt.jsxs(Xr,{className:"sm:max-w-[500px]",children:[Rt.jsx(Jr,{children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:Rt.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),Rt.jsx("div",{className:"flex-1",children:Rt.jsx(Zr,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),Rt.jsx(ea,{asChild:!0,children:Rt.jsxs("div",{className:"space-y-4",children:[Rt.jsxs("div",{className:"text-sm text-muted-foreground",children:[Rt.jsx("p",{className:"mb-2",children:l?Rt.jsx(Rt.Fragment,{children:"Você está prestes a excluir permanentemente:"}):Rt.jsxs(Rt.Fragment,{children:["Você está prestes a excluir permanentemente o ",s,":"]})}),Rt.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:Rt.jsx("p",{className:"font-medium text-foreground",children:l?`${n.title}`:n.title})})]}),Rt.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:Rt.jsxs("div",{className:"flex items-start space-x-2",children:[Rt.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:Rt.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),Rt.jsxs("div",{className:"text-sm text-orange-800",children:[Rt.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),Rt.jsx("p",{children:l?Rt.jsx(Rt.Fragment,{children:"Esta ação não pode ser desfeita. Os itens serão removidos permanentemente do sistema."}):Rt.jsxs(Rt.Fragment,{children:["Esta ação não pode ser desfeita. O ",s," será removido permanentemente do sistema."]})})]})]})}),Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(Vt,{htmlFor:"confirmation",className:"text-sm font-medium",children:l?Rt.jsxs(Rt.Fragment,{children:["Para confirmar, digite o número de itens que serão removidos: ",Rt.jsx("strong",{children:c})]}):Rt.jsxs(Rt.Fragment,{children:["Para confirmar, digite ",Rt.jsxs("strong",{children:['"',n.title,'"']})," abaixo:"]})}),Rt.jsx($t,{id:"confirmation",type:l?"number":"text",value:u,onChange:e=>d(e.target.value),placeholder:l?`Digite: ${c}`:`Digite: ${n.title}`,className:"w-full"})]})]})}),Rt.jsxs(Gr,{children:[Rt.jsx(na,{onClick:f,children:"Cancelar"}),Rt.jsx(ta,{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},aa=e.forwardRef(({className:e,...t},n)=>Rt.jsx("table",{ref:n,className:Dt("w-full caption-bottom text-sm",e),...t}));aa.displayName="Table";const sa=e.forwardRef(({className:e,...t},n)=>Rt.jsx("thead",{ref:n,className:Dt("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));sa.displayName="TableHeader";const ia=e.forwardRef(({className:e,...t},n)=>Rt.jsx("tbody",{ref:n,className:Dt("[&_tr:last-child]:border-0",e),...t}));ia.displayName="TableBody";const oa=e.forwardRef(({className:e,...t},n)=>Rt.jsx("tfoot",{ref:n,className:Dt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));oa.displayName="TableFooter";const la=e.forwardRef(({className:e,...t},n)=>Rt.jsx("tr",{ref:n,className:Dt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted odd:bg-muted/50",e),...t}));la.displayName="TableRow";const ca=e.forwardRef(({className:e,...t},n)=>Rt.jsx("th",{ref:n,className:Dt("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}));ca.displayName="TableHead";const ua=e.forwardRef(({className:e,...t},n)=>Rt.jsx("td",{ref:n,className:Dt("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ua.displayName="TableCell";const da=e.forwardRef(({className:e,...t},n)=>Rt.jsx("caption",{ref:n,className:Dt("mt-4 text-sm text-muted-foreground",e),...t}));function fa({className:e,...t}){return Rt.jsx("div",{className:Dt("animate-pulse rounded-md bg-muted",e),...t})}function ma({rows:e=5,columns:t=4}){return Rt.jsx("div",{className:"w-full",children:Rt.jsxs("div",{className:"rounded-md border",children:[Rt.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:Rt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Rt.jsx(fa,{className:"h-4 w-24"},t))})}),Rt.jsx("div",{children:Array.from({length:e}).map((e,n)=>Rt.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:Rt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Rt.jsx(fa,{className:"h-4 w-20"},t))})},n))})]})})}function pa({count:e=3}){return Rt.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>Rt.jsxs(Ht,{children:[Rt.jsxs(qt,{children:[Rt.jsx(fa,{className:"h-4 w-3/4"}),Rt.jsx(fa,{className:"h-3 w-1/2"})]}),Rt.jsx(Kt,{children:Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(fa,{className:"h-3 w-full"}),Rt.jsx(fa,{className:"h-3 w-2/3"})]})})]},t))})}function ha({fields:e=4}){return Rt.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(fa,{className:"h-4 w-24"}),Rt.jsx(fa,{className:"h-10 w-full"})]},t)),Rt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Rt.jsx(fa,{className:"h-10 w-20"}),Rt.jsx(fa,{className:"h-10 w-20"})]})]})}function ga(){return Rt.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[Rt.jsxs("div",{className:"flex items-center space-x-3",children:[Rt.jsx(fa,{className:"h-8 w-8 rounded-full"}),Rt.jsx(fa,{className:"h-6 w-32"})]}),Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx(fa,{className:"h-8 w-8"}),Rt.jsx(fa,{className:"h-8 w-24"})]})]})}function xa(){return Rt.jsx("div",{className:"w-64 border-r bg-muted/10",children:Rt.jsxs("div",{className:"p-4",children:[Rt.jsx(fa,{className:"h-8 w-32 mb-6"}),Rt.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>Rt.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[Rt.jsx(fa,{className:"h-4 w-4"}),Rt.jsx(fa,{className:"h-4 w-20"})]},t))})]})})}da.displayName="TableCaption";const ya={default:P,search:E,error:T};function ba({icon:e,title:t,description:n,action:r,className:a,variant:s="default"}){const i=e?()=>e:ya[s];return Rt.jsxs("div",{className:Dt("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[Rt.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:Rt.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),Rt.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),n&&Rt.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:n}),r&&Rt.jsx(Bt,{onClick:r.onClick,variant:"outline",children:r.label})]})}const va=ot.Root,wa=ot.Trigger,ka=ot.Group,Na=ot.Portal,ja=ot.Sub,Sa=ot.RadioGroup,Ca=e.forwardRef(({className:e,inset:t,children:n,...r},a)=>Rt.jsxs(ot.SubTrigger,{ref:a,className:Dt("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,Rt.jsx(A,{className:"ml-auto h-4 w-4"})]}));Ca.displayName=ot.SubTrigger.displayName;const Ia=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.SubContent,{ref:n,className:Dt("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}));Ia.displayName=ot.SubContent.displayName;const Ta=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Rt.jsx(ot.Portal,{children:Rt.jsx(ot.Content,{ref:r,sideOffset:t,className:Dt("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})}));Ta.displayName=ot.Content.displayName;const Ea=e.forwardRef(({className:e,inset:t,...n},r)=>Rt.jsx(ot.Item,{ref:r,className:Dt("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}));Ea.displayName=ot.Item.displayName;const Pa=e.forwardRef(({className:e,children:t,checked:n,...r},a)=>Rt.jsxs(ot.CheckboxItem,{ref:a,className:Dt("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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(ot.ItemIndicator,{children:Rt.jsx(C,{className:"h-4 w-4"})})}),t]}));Pa.displayName=ot.CheckboxItem.displayName;const Aa=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(ot.RadioItem,{ref:r,className:Dt("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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(ot.ItemIndicator,{children:Rt.jsx(R,{className:"h-2 w-2 fill-current"})})}),t]}));Aa.displayName=ot.RadioItem.displayName;const Ra=e.forwardRef(({className:e,inset:t,...n},r)=>Rt.jsx(ot.Label,{ref:r,className:Dt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ra.displayName=ot.Label.displayName;const _a=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.Separator,{ref:n,className:Dt("-mx-1 my-1 h-px bg-muted",e),...t}));_a.displayName=ot.Separator.displayName;const Da=({className:e,...t})=>Rt.jsx("span",{className:Dt("ml-auto text-xs tracking-widest opacity-60",e),...t});Da.displayName="DropdownMenuShortcut";const Oa=({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?D:O,label:r?"Inativar":"Ativar",onClick:n};i.push(e)}if(a&&t){const e={icon:z,label:"Remover",onClick:t,destructive:!0};i.push(e)}return"dropdown"===s?Rt.jsx(Rt.Fragment,{children:i.map((e,t)=>Rt.jsxs(Ea,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[Rt.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):Rt.jsx(Rt.Fragment,{children:i.map((e,t)=>Rt.jsxs(Bt,{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:[Rt.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},za=({onEdit:e,onDelete:t,canDelete:n=!0,onToggleStatus:r,isActive:a=!0})=>Rt.jsxs(va,{children:[Rt.jsx(wa,{asChild:!0,children:Rt.jsx(Bt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:Rt.jsx(L,{size:12})})}),Rt.jsx(Ta,{align:"end",children:Rt.jsx(Oa,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),r?.()},isActive:a,canDelete:n,renderAs:"dropdown"})})]}),La=l(({checked:e,onCheckedChange:t})=>Rt.jsx(Nn,{checked:e,onCheckedChange:t}),(e,t)=>e.checked===t.checked),Fa=({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?Rt.jsx(pa,{count:3}):0===e.entities.length?Rt.jsx(ba,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):Rt.jsxs("div",{className:"space-y-4",children:[e.entities.map(a=>Rt.jsx(Ht,{className:Dt("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:Rt.jsx(Kt,{className:"p-4",children:Rt.jsxs("div",{className:"flex items-start gap-3",children:[c&&Rt.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:Rt.jsx(La,{checked:e.selectedIds.includes(a.id),onCheckedChange:()=>e.selectItem(a.id)})}),Rt.jsxs("div",{className:"flex-1",children:[t.map(e=>Rt.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[Rt.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[e.header,":"]}),Rt.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)&&Rt.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):Rt.jsx(za,{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&&Rt.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:Rt.jsx(Oa,{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"})})]}):Rt.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?Rt.jsx(ma,{rows:5,columns:t.length}):Rt.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:Rt.jsx("div",{className:"flex-1 overflow-auto",children:Rt.jsxs(aa,{className:"table-auto",children:[Rt.jsxs("colgroup",{children:[c&&Rt.jsx("col",{style:{width:"50px"}}),p.map((e,t)=>Rt.jsx("col",{style:e.style},t)),Rt.jsx("col",{style:{width:"100px"}})]}),Rt.jsx(sa,{children:Rt.jsxs(la,{children:[c&&Rt.jsx(ca,{className:"w-[50px]",children:Rt.jsx(La,{checked:e.isAllSelected,onCheckedChange:e.selectAll})}),t.map(t=>{return Rt.jsx(ca,{className:`${t.className||""} ${t.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:t.sortable?()=>e.handleSort(String(t.key)):void 0,children:Rt.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?Rt.jsx(F,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?Rt.jsx(M,{size:14,className:"ml-1"}):Rt.jsx(B,{size:14,className:"ml-1"}))]})},String(t.key));var n}),Rt.jsx(ca,{className:"w-[100px] text-center",children:"Ações"})]})}),Rt.jsx(ia,{children:0===e.entities.length?Rt.jsx(la,{children:Rt.jsx(ua,{colSpan:c?t.length+2:t.length+1,className:"h-32",children:Rt.jsx(ba,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(r=>Rt.jsxs(la,{className:Dt("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&&Rt.jsx(ua,{onClick:e=>e.stopPropagation(),children:Rt.jsx(La,{checked:e.selectedIds.includes(r.id),onCheckedChange:()=>e.selectItem(r.id)})}),t.map(e=>Rt.jsx(ua,{className:e.className,children:e.render?e.render(r):r[e.key]},String(e.key))),Rt.jsx(ua,{className:"text-center",children:l?l(r):Rt.jsx(za,{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&&Rt.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:Rt.jsx(Oa,{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 Ma(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 Ba=lt.Root,$a=lt.Trigger,Ua=e.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>Rt.jsx(lt.Portal,{children:Rt.jsx(lt.Content,{ref:a,align:t,sideOffset:n,className:Dt("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})}));Ua.displayName=lt.Content.displayName;const Va=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Ha=({value:e="#3b82f6",onChange:t,label:n})=>Rt.jsxs("div",{className:"space-y-2",children:[n&&Rt.jsx(Vt,{children:n}),Rt.jsxs(Ba,{children:[Rt.jsx($a,{asChild:!0,children:Rt.jsxs(Bt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Rt.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),Rt.jsx(Ua,{className:"w-64",children:Rt.jsxs("div",{className:"space-y-3",children:[Rt.jsxs("div",{children:[Rt.jsx(Vt,{htmlFor:"color-input",children:"Cor personalizada"}),Rt.jsx($t,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),Rt.jsxs("div",{children:[Rt.jsx(Vt,{children:"Cores predefinidas"}),Rt.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Va.map(e=>Rt.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))})]})]})})]})]}),qa=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(ct.Root,{ref:r,className:Dt("relative overflow-hidden",e),...n,children:[Rt.jsx(ct.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),Rt.jsx(Wa,{}),Rt.jsx(ct.Corner,{})]}));qa.displayName=ct.Root.displayName;const Wa=e.forwardRef(({className:e,orientation:t="vertical",...n},r)=>Rt.jsx(ct.ScrollAreaScrollbar,{ref:r,orientation:t,className:Dt("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:Rt.jsx(ct.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Wa.displayName=ct.ScrollAreaScrollbar.displayName;const Qa={Star:Re,Heart:Ae,Home:Pe,User:Ee,Settings:Te,Mail:Ie,Phone:Ce,Calendar:Se,MapPin:je,Camera:Ne,Image:ke,Music:we,Video:ve,Book:be,Bookmark:ye,Search:E,Filter:xe,Edit:_,Trash2:z,Plus:ge,Minus:he,Check:C,X:N,ChevronDown:j,ChevronUp:S,ChevronLeft:pe,ChevronRight:A,ArrowUp:M,ArrowDown:B,ArrowLeft:me,ArrowRight:fe,Clock:de,Bell:ue,AlertCircle:T,Info:ce,HelpCircle:le,Download:oe,Upload:ie,Share:se,Copy:ae,Save:re,FileText:ne,Folder:te,FolderOpen:ee,Archive:Z,Lock:G,Unlock:J,Eye:X,EyeOff:Y,Shield:K,Key:Q,Zap:W,Flame:q,Sparkles:H,Award:V,Trophy:U,Target:$},Ka=({value:e="Star",onChange:t,label:n})=>{const[r,s]=a(""),i=Object.entries(Qa).filter(([e])=>e.toLowerCase().includes(r.toLowerCase())),o=Qa[e]||Re;return Rt.jsxs("div",{className:"space-y-2",children:[n&&Rt.jsx(Vt,{children:n}),Rt.jsxs(Ba,{children:[Rt.jsx($a,{asChild:!0,children:Rt.jsxs(Bt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Rt.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),Rt.jsx(Ua,{className:"w-80",children:Rt.jsxs("div",{className:"space-y-3",children:[Rt.jsxs("div",{children:[Rt.jsx(Vt,{htmlFor:"icon-search",children:"Buscar ícone"}),Rt.jsx($t,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:r,onChange:e=>s(e.target.value)})]}),Rt.jsx(qa,{className:"h-48",children:Rt.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([n,r])=>Rt.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:Rt.jsx(r,{className:"h-4 w-4"})},n))})})]})})]})]})};function Ya({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?Rt.jsx(fa,{className:Dt("h-10 w-full",h)}):s?Rt.jsxs("div",{className:Dt("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[Rt.jsx(T,{className:"h-4 w-4 text-destructive"}),Rt.jsx("span",{className:"text-sm text-destructive",children:s.message||"Erro ao carregar dados"})]}):Rt.jsxs(gn,{value:e,onValueChange:t,disabled:p||0===n.length,children:[Rt.jsx(yn,{className:h,children:Rt.jsx(xn,{placeholder:m})}),Rt.jsxs(wn,{children:[Rt.jsx("div",{className:"px-2 pb-2",children:Rt.jsxs("div",{className:"relative",children:[Rt.jsx(E,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),Rt.jsx($t,{placeholder:c,value:g,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===y.length?Rt.jsx(kn,{value:"no-items",disabled:!0,children:g?d:u}):y.map(e=>Rt.jsx(kn,{value:i(e),children:l(e)},i(e)))]})]})}const Xa=(e={})=>{const{user:t,alias:n}=Vr(),r=Rr(),{enabled:a=r.enableUsersApi}=e;return Ze({queryKey:["qualiex-users",n],queryFn:()=>jr.getUsers(n),enabled:a&&!!n&&!!t,retry:2,retryDelay:1e3})},Ja=({value:e="",onChange:t,placeholder:n="Selecionar usuário",disabled:r,className:a,enabled:s})=>{const{data:i=[],isLoading:o,error:l}=Xa({enabled:s});return Rt.jsx(Ya,{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 Ga({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}=Ma(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 k=v.find(e=>e.id===w),N=e=>{const t=(e.computedValue,g[e.name]),n=void 0!==t?t:"",r=x[e.name];switch(e.type){case"group":return Rt.jsxs("div",{className:"space-y-2",children:[e.label,Rt.jsx("div",{className:e.className||("horizontal"===e.layout?"flex gap-3":"space-y-3"),children:e.fields?.map(e=>N(e))})]},e.name);case"user-select":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Vt,{htmlFor:e.name,children:e.label}),Rt.jsx(Ja,{value:n||"",onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":""}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"textarea":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Vt,{htmlFor:e.name,children:e.label}),Rt.jsx(jn,{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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"select":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Vt,{htmlFor:e.name,children:e.label}),Rt.jsxs(gn,{value:String(n),onValueChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[Rt.jsx(yn,{className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:Rt.jsx(xn,{placeholder:e.placeholder})}),Rt.jsx(wn,{children:e.options?.map(e=>Rt.jsx(kn,{value:e.value,children:e.label},e.value))})]}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"date":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Vt,{htmlFor:e.name,children:e.label}),Rt.jsx($t,{id:e.name,type:"date",value:String(n),onChange:t=>y(e.name,t.target.value),placeholder:e.placeholder,disabled:e.disabled,className:Dt("w-full",r?"border-red-500":"",e.disabled?"bg-gray-100 cursor-not-allowed":"")}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"color":return Rt.jsxs("div",{children:[Rt.jsxs(Vt,{htmlFor:e.name,children:[e.label," ",e.required&&Rt.jsx("span",{className:"text-destructive",children:"*"})]}),Rt.jsx($t,{id:e.name,type:"color",value:n||e.defaultValue||"#000000",onChange:t=>y(e.name,t.target.value),className:"h-10"}),r&&Rt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return Rt.jsxs("div",{children:[Rt.jsx(Ha,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"#3b82f6",onChange:t=>y(e.name,t)}),r&&Rt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return Rt.jsxs("div",{children:[Rt.jsx(Ka,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"Star",onChange:t=>y(e.name,t)}),r&&Rt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"number":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Vt,{htmlFor:e.name,children:e.label}),Rt.jsx($t,{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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);default:return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Vt,{htmlFor:e.name,children:e.label}),Rt.jsx($t,{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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name)}},j=s(()=>{if(!k)return null;if(k.disabled)return Rt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Rt.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:Rt.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Rt.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),Rt.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),Rt.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(k.component){const e=k.component;return Rt.jsx(e,{formData:g,updateField:y,errors:x,users:f,disabled:k.disabled})}return Rt.jsx("div",{className:"space-y-3",children:k.fields.map(N)})},[k,g,y,x,f,N]),S=Rt.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[v.length>1&&Rt.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:Rt.jsx("div",{className:"flex space-x-2",children:v.map(e=>Rt.jsx(Bt,{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))})}),Rt.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:d?Rt.jsx("div",{className:"flex items-center justify-center py-12",children:Rt.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):Rt.jsxs("form",{onSubmit:b(i),className:"space-y-3 md:space-y-4",children:[j(),Rt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Rt.jsx(Bt,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),Rt.jsx(Bt,{type:"submit",disabled:d,children:u})]})]})})]});return Rt.jsx(Xt,{open:c,onOpenChange:e=>{!1===e&&!0===c&&l()},children:Rt.jsxs(tn,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[Rt.jsxs(nn,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[Rt.jsx(an,{className:"text-white",children:e}),Rt.jsx(sn,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}const Za=({manager:e})=>{const{pagination:t={totalItems:0,totalPages:1},currentPage:n=1,itemsPerPage:r=10,handlePageChange:a=()=>{},handleItemsPerPageChange:s=()=>{}}=e,{totalItems:i=0,totalPages:o=1}=t,l=i>0?(n-1)*r+1:0,c=Math.min(n*r,i);return Rt.jsxs("div",{className:"px-4 h-12 flex items-center justify-between text-sm text-muted-foreground bg-muted/50 border-t border-border flex-shrink-0 mt-auto",children:[Rt.jsxs("div",{className:"flex items-center space-x-3",children:[Rt.jsx("span",{children:"Itens por página"}),Rt.jsxs(gn,{value:r.toString(),onValueChange:e=>s(Number(e)),children:[Rt.jsx(yn,{className:"w-20 h-8 border-border",children:Rt.jsx(xn,{})}),Rt.jsxs(wn,{children:[Rt.jsx(kn,{value:"10",children:"10"}),Rt.jsx(kn,{value:"25",children:"25"}),Rt.jsx(kn,{value:"50",children:"50"}),Rt.jsx(kn,{value:"100",children:"100"})]})]})]}),Rt.jsx("div",{className:"flex-1 flex justify-center",children:Rt.jsx("span",{children:i>0?`${l}-${c} de ${i} itens (página ${n} de ${o})`:"0 itens"})}),Rt.jsxs("div",{className:"flex items-center space-x-1",children:[Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:()=>a(1),disabled:1===n,children:Rt.jsx(_e,{className:"h-4 w-4"})}),Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:()=>a(Math.max(1,n-1)),disabled:1===n,children:Rt.jsx(pe,{className:"h-4 w-4"})}),Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:()=>a(Math.min(o,n+1)),disabled:n===o,children:Rt.jsx(A,{className:"h-4 w-4"})}),Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:()=>a(o),disabled:n===o,children:Rt.jsx(De,{className:"h-4 w-4"})})]})]})},es=({selectedCount:e,onClearSelection:t,onBulkDelete:n,customActions:r=[],isLoading:a=!1})=>Rt.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[Rt.jsxs("div",{className:"flex items-center gap-3",children:[Rt.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),Rt.jsxs(Bt,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[Rt.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]}),Rt.jsxs("div",{className:"flex items-center gap-2",children:[r.map((e,t)=>{const n=e.icon;return Rt.jsxs(Bt,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:a,className:"h-7",children:[n&&Rt.jsx(n,{size:14,className:"mr-1"}),e.label]},t)}),n&&Rt.jsxs(Bt,{variant:"destructive",size:"sm",onClick:n,disabled:a,className:"h-7",children:[Rt.jsx(z,{size:14,className:"mr-1"}),"Remover"]})]})]}),ts={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"},rs={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function as({children:e,direction:t="column",gap:n="md",align:r="stretch",justify:a="start",wrap:s=!1,className:i}){return Rt.jsx("div",{className:Dt("flex","column"===t?"flex-col":"flex-row",ts[n],ns[r],rs[a],s&&"flex-wrap",i),children:e})}function ss({manager:e,filters:t,inline:n=!1}){const{isSearchVisible:r}=Vr(),a=e.searchTerm,s=Rt.jsxs(Rt.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&Rt.jsxs("div",{className:"relative flex-1",children:[Rt.jsx(E,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Rt.jsx($t,{placeholder:"Buscar...",value:e.searchTerm,onChange:t=>e.handleSearch(t.target.value),className:"pl-10"})]}),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return Rt.jsx("div",{className:n?"":"w-full sm:w-auto",children:Rt.jsx(r,{...e.props})},t)}),a&&Rt.jsxs(Bt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[Rt.jsx(N,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return n?Rt.jsx("div",{className:"flex items-center gap-2",children:s}):Rt.jsx(as,{direction:"column",gap:"md",className:"mb-6",children:Rt.jsx(as,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:s})})}function is({manager:e,config:t,formSections:n,onSave:r,onToggleStatus:s,defaultSort:o}){const{setSearchVisible:l}=Vr(),[c,u]=nt(),[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 Rt.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[t.enableBulkActions&&e.selectedIds.length>0&&Rt.jsx(es,{selectedCount:e.selectedIds.length,onClearSelection:e.clearSelection,onBulkDelete:()=>{y({isOpen:!0,count:e.selectedIds.length})},customActions:t.bulkActions,isLoading:e.isBulkDeleting}),Rt.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[Rt.jsx("div",{className:"flex items-center gap-4",children:Rt.jsxs(Bt,{onClick:()=>{t.onNew?t.onNew():(p(null),f(!0))},children:[Rt.jsx(ge,{size:16,className:"mr-2"}),"Novo"]})}),t.filters&&t.filters.length>0&&Rt.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:Rt.jsx(ss,{manager:e,filters:t.filters,inline:!0})})]}),Rt.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:Rt.jsx(Fa,{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})}),Rt.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:Rt.jsx(Za,{manager:e})}),!t.useCustomRouting&&Rt.jsx(Ga,{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"}),Rt.jsx(ra,{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}),Rt.jsx(ra,{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 os(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};return Rt.jsx(is,{manager:t,config:s,formSections:n.formSections,onSave:r,onToggleStatus:a,defaultSort:n.defaultSort})}}function ls(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 cs(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:ds(e),label:ds(e),...us(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 us(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 ds(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const fs={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 ms(e,t,n={}){const r=fs[e];return cs(r.title,t,{...r,...n})}const ps=({children:e})=>{const{isAuthenticated:n,isLoading:r}=Vr();if(t.useEffect(()=>{if(!n)return;const e=()=>{rr.areAllTokensValid()||Br.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),t.useEffect(()=>{if(r)return;if(n)return;if(rr.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=Er();(async()=>{s?await Br.loginDev():Br.loginProd()})()},[n,r]),r)return Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Ht,{className:"w-full max-w-md",children:[Rt.jsx(qt,{className:"text-center",children:Rt.jsx(Wt,{className:"text-xl font-semibold",children:"Carregando..."})}),Rt.jsxs(Kt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.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 Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Ht,{className:"w-full max-w-md",children:[Rt.jsx(qt,{className:"text-center",children:Rt.jsx(Wt,{className:"text-xl font-semibold",children:"Processando..."})}),Rt.jsxs(Kt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(rr.areAllTokensValid())return Rt.jsx(Rt.Fragment,{children:e})}catch{}return Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Ht,{className:"w-full max-w-md",children:[Rt.jsx(qt,{className:"text-center",children:Rt.jsx(Wt,{className:"text-xl font-semibold",children:"Iniciando..."})}),Rt.jsxs(Kt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.jsx("p",{className:"text-muted-foreground",children:Er()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return Rt.jsx(Rt.Fragment,{children:e})},hs=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"}}),gs=e.forwardRef(({className:e,variant:t,...n},r)=>Rt.jsx("div",{ref:r,role:"alert",className:Dt(hs({variant:t}),e),...n}));gs.displayName="Alert";const xs=e.forwardRef(({className:e,...t},n)=>Rt.jsx("h5",{ref:n,className:Dt("mb-1 font-medium leading-none tracking-tight",e),...t}));xs.displayName="AlertTitle";const ys=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("text-sm [&_p]:leading-relaxed",e),...t}));ys.displayName="AlertDescription";const bs=()=>{const{processCallback:e}=Vr(),[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?Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Ht,{className:"w-full max-w-md",children:[Rt.jsx(qt,{className:"text-center",children:Rt.jsxs(Wt,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[Rt.jsx(T,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),Rt.jsxs(Kt,{className:"space-y-4",children:[Rt.jsx(gs,{variant:"destructive",children:Rt.jsx(ys,{children:t})}),Rt.jsx("div",{className:"text-sm text-muted-foreground",children:Rt.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),Rt.jsxs("div",{className:"flex gap-2",children:[Rt.jsx(Bt,{onClick:o,disabled:r,className:"flex-1",children:r?Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(Tn,{size:"sm",className:"mr-2"}),"Tentando..."]}):Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(Oe,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),Rt.jsx(Bt,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Ht,{className:"w-full max-w-md",children:[Rt.jsx(qt,{className:"text-center",children:Rt.jsx(Wt,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),Rt.jsxs(Kt,{className:"text-center",children:[Rt.jsx("div",{className:"flex justify-center mb-4",children:Rt.jsx(Tn,{size:"lg"})}),Rt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},vs=()=>Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Ht,{className:"w-full max-w-md",children:[Rt.jsx(qt,{className:"text-center",children:Rt.jsx(Wt,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),Rt.jsxs(Kt,{className:"text-center space-y-4",children:[Rt.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),Rt.jsx(Bt,{onClick:async()=>{Er()?await Br.loginDev():Br.loginProd()},className:"w-full",size:"lg",children:Er()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),ws=n(void 0);function ks({children:e}){const[t,n]=a({});return Rt.jsx(ws.Provider,{value:{metadata:t,setMetadata:n,clearMetadata:()=>n({})},children:e})}function Ns(){const e=r(ws);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function js(e){const{setMetadata:t,clearMetadata:n}=Ns();i(()=>(t(e),()=>n()),[e.title,e.subtitle,t,n])}function Ss(e){return{queryClient:e.queryClient||new tt({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const Cs=ut.Root,Is=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ut.Item,{ref:n,className:Dt("border-b",e),...t}));Is.displayName="AccordionItem";const Ts=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsx(ut.Header,{className:"flex",children:Rt.jsxs(ut.Trigger,{ref:r,className:Dt("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,Rt.jsx(j,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));Ts.displayName=ut.Trigger.displayName;const Es=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsx(ut.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:Rt.jsx("div",{className:Dt("pb-4 pt-0",e),children:t})}));Es.displayName=ut.Content.displayName;const Ps=dt.Root,As=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ft.Root,{ref:n,className:Dt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));As.displayName=ft.Root.displayName;const Rs=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ft.Image,{ref:n,className:Dt("aspect-square h-full w-full",e),...t}));Rs.displayName=ft.Image.displayName;const _s=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ft.Fallback,{ref:n,className:Dt("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));_s.displayName=ft.Fallback.displayName;const Ds=e.forwardRef(({...e},t)=>Rt.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));Ds.displayName="Breadcrumb";const Os=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ol",{ref:n,className:Dt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));Os.displayName="BreadcrumbList";const zs=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,className:Dt("inline-flex items-center gap-1.5",e),...t}));zs.displayName="BreadcrumbItem";const Ls=e.forwardRef(({asChild:t,className:n,...r},a)=>{const s=t?e.Fragment:"a";return Rt.jsx(s,{ref:a,className:Dt("transition-colors hover:text-foreground",n),...r})});Ls.displayName="BreadcrumbLink";const Fs=e.forwardRef(({className:e,...t},n)=>Rt.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:Dt("font-normal text-foreground",e),...t}));Fs.displayName="BreadcrumbPage";const Ms=({children:e,className:t,...n})=>Rt.jsx("li",{role:"presentation","aria-hidden":"true",className:Dt("[&>svg]:size-3.5",t),...n,children:e??Rt.jsx(A,{})});Ms.displayName="BreadcrumbSeparator";const Bs=({className:e,...t})=>Rt.jsxs("span",{role:"presentation","aria-hidden":"true",className:Dt("flex h-9 w-9 items-center justify-center",e),...t,children:[Rt.jsx(ze,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"More"})]});function $s(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function Us(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 Vs(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)}}}Bs.displayName="BreadcrumbEllipsis";const Hs={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"}},qs={date:$s({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:$s({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:$s({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Ws={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"},Qs={ordinalNumber:(e,t)=>{const n=Number(e);return"week"===t?.unit?n+"ª":n+"º"},era:Us({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Us({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:Us({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:Us({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:Us({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"})},Ks={ordinalNumber:(Ys={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(Ys.matchPattern);if(!n)return null;const r=n[0],a=e.match(Ys.parsePattern);if(!a)return null;let s=Ys.valueCallback?Ys.valueCallback(a[0]):a[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:Vs({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:Vs({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:Vs({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:Vs({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:Vs({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 Ys;const Xs={code:"pt-BR",formatDistance:(e,t,n)=>{let r;const a=Hs[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:qs,formatRelative:(e,t,n,r)=>{const a=Ws[e];return"function"==typeof a?a(t):a},localize:Qs,match:Ks,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Js({className:e,classNames:t,showOutsideDays:n=!0,...r}){return Rt.jsx(mt,{showOutsideDays:n,className:Dt("p-3",e),locale:Xs,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:Dt(Mt({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:Dt(Mt({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})=>Rt.jsx(pe,{className:"h-4 w-4"}),IconRight:({...e})=>Rt.jsx(A,{className:"h-4 w-4"})},...r})}Js.displayName="Calendar";const Gs=pt.Root,Zs=pt.CollapsibleTrigger,ei=pt.CollapsibleContent,ti=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));ti.displayName="Command";const ni=({children:e,...t})=>Rt.jsx("div",{...t,children:Rt.jsx(ti,{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})}),ri=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:Rt.jsx("input",{ref:n,className:Dt("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})}));ri.displayName="CommandInput";const ai=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));ai.displayName="CommandList";const si=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("py-6 text-center text-sm text-muted-foreground",e),...t}));si.displayName="CommandEmpty";const ii=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("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}));ii.displayName="CommandGroup";const oi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:Dt("-mx-1 h-px bg-border",e),...t}));oi.displayName="CommandSeparator";const li=e.forwardRef(({className:e,disabled:t,onSelect:n,value:r,...a},s)=>Rt.jsx("div",{ref:s,className:Dt("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}));li.displayName="CommandItem";const ci=({className:e,...t})=>Rt.jsx("span",{className:Dt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});ci.displayName="CommandShortcut";const ui={Root:function({children:e,className:t}){return Rt.jsx("div",{className:Dt("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:n}){return Rt.jsx(Ht,{className:Dt("transition-colors",t&&"cursor-pointer hover:bg-muted/50",n),onClick:t,children:Rt.jsx(Kt,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:n}){return Rt.jsxs("div",{className:Dt("flex justify-between items-center text-sm",n),children:[Rt.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),Rt.jsx("span",{className:"text-foreground",children:t})]})}},di={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))]"},fi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function mi({children:e,cols:t="auto-fit",gap:n="md",className:r}){return Rt.jsx("div",{className:Dt("grid",di[t],fi[n],r),children:e})}function pi({items:e,maxItems:t=3,className:n}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,Rt.jsx(Ds,{className:n})}function hi(){const e=rt();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 gi=({className:e,...t})=>Rt.jsx("nav",{role:"navigation","aria-label":"pagination",className:Dt("mx-auto flex w-full justify-center",e),...t});gi.displayName="Pagination";const xi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ul",{ref:n,className:Dt("flex flex-row items-center gap-1",e),...t}));xi.displayName="PaginationContent";const yi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,className:Dt("",e),...t}));yi.displayName="PaginationItem";const bi=({className:e,isActive:t,size:n="icon",...r})=>Rt.jsx("a",{"aria-current":t?"page":void 0,className:Dt(Mt({variant:t?"outline":"ghost",size:n}),e),...r});bi.displayName="PaginationLink";const vi=({className:e,...t})=>Rt.jsxs(bi,{"aria-label":"Go to previous page",size:"default",className:Dt("gap-1 pl-2.5",e),...t,children:[Rt.jsx(pe,{className:"h-4 w-4"}),Rt.jsx("span",{children:"Previous"})]});vi.displayName="PaginationPrevious";const wi=({className:e,...t})=>Rt.jsxs(bi,{"aria-label":"Go to next page",size:"default",className:Dt("gap-1 pr-2.5",e),...t,children:[Rt.jsx("span",{children:"Next"}),Rt.jsx(A,{className:"h-4 w-4"})]});wi.displayName="PaginationNext";const ki=({className:e,...t})=>Rt.jsxs("span",{"aria-hidden":!0,className:Dt("flex h-9 w-9 items-center justify-center",e),...t,children:[Rt.jsx(ze,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"More pages"})]});ki.displayName="PaginationEllipsis";const Ni=e.forwardRef(({className:e,value:t,...n},r)=>Rt.jsx(ht.Root,{ref:r,className:Dt("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:Rt.jsx(ht.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Ni.displayName=ht.Root.displayName;const ji=e.forwardRef(({className:e,...t},n)=>Rt.jsx(gt.Root,{className:Dt("grid gap-2",e),...t,ref:n}));ji.displayName=gt.Root.displayName;const Si=e.forwardRef(({className:e,...t},n)=>Rt.jsx(gt.Item,{ref:n,className:Dt("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:Rt.jsx(gt.Indicator,{className:"flex items-center justify-center",children:Rt.jsx(R,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Si.displayName=gt.Item.displayName;const Ci=e.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>Rt.jsx(xt.Root,{ref:a,decorative:n,orientation:t,className:Dt("shrink-0 bg-border","horizontal"===t?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Ci.displayName=xt.Root.displayName;const Ii=k.Root,Ti=k.Trigger,Ei=k.Close,Pi=k.Portal,Ai=e.forwardRef(({className:e,...t},n)=>Rt.jsx(k.Overlay,{className:Dt("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}));Ai.displayName=k.Overlay.displayName;const Ri=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"}}),_i=e.forwardRef(({side:e="right",className:t,children:n,...r},a)=>Rt.jsxs(Pi,{children:[Rt.jsx(Ai,{}),Rt.jsxs(k.Content,{ref:a,className:Dt(Ri({side:e}),t),...r,children:[n,Rt.jsxs(k.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:[Rt.jsx(N,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_i.displayName=k.Content.displayName;const Di=({className:e,...t})=>Rt.jsx("div",{className:Dt("flex flex-col space-y-2 text-center sm:text-left",e),...t});Di.displayName="SheetHeader";const Oi=({className:e,...t})=>Rt.jsx("div",{className:Dt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Oi.displayName="SheetFooter";const zi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(k.Title,{ref:n,className:Dt("text-lg font-semibold text-foreground",e),...t}));zi.displayName=k.Title.displayName;const Li=e.forwardRef(({className:e,...t},n)=>Rt.jsx(k.Description,{ref:n,className:Dt("text-sm text-muted-foreground",e),...t}));Li.displayName=k.Description.displayName;const Fi=yt.Provider,Mi=yt.Root,Bi=yt.Trigger,$i=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Rt.jsx(yt.Content,{ref:r,sideOffset:t,className:Dt("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}));$i.displayName=yt.Content.displayName;const Ui="sidebar:state",Vi=e.createContext(null);function Hi(){const t=e.useContext(Vi);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const qi=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(Ui);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(Ui,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 Rt.jsx(Vi.Provider,{value:b,children:Rt.jsx(Fi,{delayDuration:0,children:Rt.jsx("div",{className:Dt("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})})})});qi.displayName="SidebarProvider";const Wi=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}=Hi();return"none"===n?Rt.jsx("div",{className:Dt("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:a}):o?Rt.jsx(Ii,{open:c,onOpenChange:u,...s,children:Rt.jsxs(_i,{"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:[Rt.jsx(zi,{className:"sr-only",children:"Menu de Navegação"}),Rt.jsx("div",{className:"flex h-full w-full flex-col",children:a})]})}):Rt.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:[Rt.jsx("div",{className:Dt("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]")}),Rt.jsx("div",{className:Dt("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:Rt.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})})]})});Wi.displayName="Sidebar";const Qi=e.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:a}=Hi();return Rt.jsxs(Bt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:Dt("h-7 w-7",e),onClick:e=>{t?.(e),a()},...n,children:[Rt.jsx(Le,{}),Rt.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Qi.displayName="SidebarTrigger";const Ki=e.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Hi();return Rt.jsx("button",{ref:n,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:r,title:"Toggle Sidebar",className:Dt("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})});Ki.displayName="SidebarRail";const Yi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("main",{ref:n,className:Dt("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}));Yi.displayName="SidebarInset";const Xi=e.forwardRef(({className:e,...t},n)=>Rt.jsx($t,{ref:n,"data-sidebar":"input",className:Dt("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));Xi.displayName="SidebarInput";const Ji=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"header",className:Dt("flex flex-col gap-2 p-2",e),...t}));Ji.displayName="SidebarHeader";const Gi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"footer",className:Dt("flex flex-col gap-2 p-2",e),...t}));Gi.displayName="SidebarFooter";const Zi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ci,{ref:n,"data-sidebar":"separator",className:Dt("mx-2 w-auto bg-sidebar-border",e),...t}));Zi.displayName="SidebarSeparator";const eo=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"content",className:Dt("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));eo.displayName="SidebarContent";const to=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"group",className:Dt("relative flex w-full min-w-0 flex-col p-2",e),...t}));to.displayName="SidebarGroup";const no=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?d:"div";return Rt.jsx(a,{ref:r,"data-sidebar":"group-label",className:Dt("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})});no.displayName="SidebarGroupLabel";const ro=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?d:"button";return Rt.jsx(a,{ref:r,"data-sidebar":"group-action",className:Dt("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})});ro.displayName="SidebarGroupAction";const ao=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"group-content",className:Dt("w-full text-sm",e),...t}));ao.displayName="SidebarGroupContent";const so=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ul",{ref:n,"data-sidebar":"menu",className:Dt("flex w-full min-w-0 flex-col gap-1",e),...t}));so.displayName="SidebarMenu";const io=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,"data-sidebar":"menu-item",className:Dt("group/menu-item relative",e),...t}));io.displayName="SidebarMenuItem";const oo=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"}}),lo=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}=Hi(),f=Rt.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:Dt(oo({variant:n,size:r}),s),...i});return a?("string"==typeof a&&(a={children:a}),Rt.jsxs(Mi,{children:[Rt.jsx(Bi,{asChild:!0,children:f}),Rt.jsx($i,{side:"right",align:"center",hidden:"collapsed"!==u||c,...a})]})):f});lo.displayName="SidebarMenuButton";const co=e.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},a)=>{const s=t?d:"button";return Rt.jsx(s,{ref:a,"data-sidebar":"menu-action",className:Dt("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})});co.displayName="SidebarMenuAction";const uo=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"menu-badge",className:Dt("absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));uo.displayName="SidebarMenuBadge";const fo=e.forwardRef(({className:t,showIcon:n=!1,...r},a)=>{const s=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return Rt.jsxs("div",{ref:a,"data-sidebar":"menu-skeleton",className:Dt("rounded-md h-8 flex gap-2 px-2 items-center",t),...r,children:[n&&Rt.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),Rt.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":s}})]})});fo.displayName="SidebarMenuSkeleton";const mo=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ul",{ref:n,"data-sidebar":"menu-sub",className:Dt("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}));mo.displayName="SidebarMenuSub";const po=e.forwardRef(({...e},t)=>Rt.jsx("li",{ref:t,...e}));po.displayName="SidebarMenuSubItem";const ho=e.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...a},s)=>{const i=e?d:"a";return Rt.jsx(i,{ref:s,"data-sidebar":"menu-sub-button","data-size":t,"data-active":n,className:Dt("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})});ho.displayName="SidebarMenuSubButton";const go=e.forwardRef(({className:e,...t},n)=>Rt.jsxs(bt.Root,{ref:n,className:Dt("relative flex w-full touch-none select-none items-center",e),...t,children:[Rt.jsx(bt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:Rt.jsx(bt.Range,{className:"absolute h-full bg-primary"})}),Rt.jsx(bt.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"})]}));go.displayName=bt.Root.displayName;const xo=({...e})=>{const{theme:t="system"}=vt();return Rt.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 yo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function bo(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function vo(...t){return e.useCallback(function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=bo(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():bo(e[t],null)}}}}(...t),t)}function wo(...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 ko=globalThis?.document?e.useLayoutEffect:()=>{},No=e[" useInsertionEffect ".trim().toString()]||ko;function jo({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 No(()=>{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 So=["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),Rt.jsx(i,{...s,ref:t})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{}),Co="Switch",[Io]=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 Rt.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}\``)}]},wo(a,...n)]}(Co),[To,Eo]=Io(Co),Po=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=vo(n,e=>p(e)),g=e.useRef(!1),x=!m||(d||!!m.closest("form")),[y,b]=jo({prop:s,defaultProp:i??!1,onChange:u,caller:Co});return Rt.jsxs(To,{scope:r,checked:y,disabled:l,children:[Rt.jsx(So.button,{type:"button",role:"switch","aria-checked":y,"aria-required":o,"data-state":Do(y),"data-disabled":l?"":void 0,disabled:l,value:c,...f,ref:h,onClick:yo(t.onClick,e=>{b(e=>!e),x&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),x&&Rt.jsx(_o,{control:m,bubbles:!g.current,name:a,value:c,checked:y,required:o,disabled:l,form:d,style:{transform:"translateX(-100%)"}})]})});Po.displayName=Co;var Ao="SwitchThumb",Ro=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Eo(Ao,n);return Rt.jsx(So.span,{"data-state":Do(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});Ro.displayName=Ao;var _o=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:a=!0,...s},i)=>{const o=e.useRef(null),l=vo(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 ko(()=>{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]),Rt.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 Do(e){return e?"checked":"unchecked"}_o.displayName="SwitchBubbleInput";var Oo=Po,zo=Ro;const Lo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Oo,{className:Dt("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:Rt.jsx(zo,{className:Dt("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")})}));Lo.displayName=Oo.displayName;const Fo=wt.Root,Mo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(wt.List,{ref:n,className:Dt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Mo.displayName=wt.List.displayName;const Bo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(wt.Trigger,{ref:n,className:Dt("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}));Bo.displayName=wt.Trigger.displayName;const $o=e.forwardRef(({className:e,...t},n)=>Rt.jsx(wt.Content,{ref:n,className:Dt("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 Uo({children:e,className:t}){return Rt.jsx("div",{className:Dt("flex flex-col h-full",t),children:Rt.jsx(qa,{className:"flex-1",children:Rt.jsx("div",{className:"space-y-6 p-6",children:e})})})}function Vo({title:e,description:t,actions:n,className:r}){return Rt.jsxs("div",{className:Dt("space-y-4",r),children:[Rt.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[Rt.jsxs("div",{className:"space-y-1",children:[Rt.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&Rt.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),n&&Rt.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:n})]}),Rt.jsx(Ci,{})]})}function Ho({children:e,className:t}){return Rt.jsx("div",{className:Dt("space-y-6",t),children:e})}$o.displayName=wt.Content.displayName;const qo=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"}}),Wo=e.forwardRef(({className:e,variant:t,size:n,...r},a)=>Rt.jsx(kt.Root,{ref:a,className:Dt(qo({variant:t,size:n,className:e})),...r}));Wo.displayName=kt.Root.displayName;const Qo=e.createContext({size:"default",variant:"default"}),Ko=e.forwardRef(({className:e,variant:t,size:n,children:r,...a},s)=>Rt.jsx(Nt.Root,{ref:s,className:Dt("flex items-center justify-center gap-1",e),...a,children:Rt.jsx(Qo.Provider,{value:{variant:t,size:n},children:r})}));Ko.displayName=Nt.Root.displayName;const Yo=e.forwardRef(({className:t,children:n,variant:r,size:a,...s},i)=>{const o=e.useContext(Qo);return Rt.jsx(Nt.Item,{ref:i,className:Dt(qo({variant:o.variant||r,size:o.size||a}),t),...s,children:n})});Yo.displayName=Nt.Item.displayName;const Xo=t.forwardRef(({variant:e="default",className:t,children:n,...r},a)=>Rt.jsx(Bt,{ref:a,variant:"outline",size:"sm",className:Dt("h-7 px-2 text-xs","border-primary/20 text-primary hover:bg-primary/5",t),...r,children:n||Rt.jsx(L,{size:12})}));function Jo({manager:e,config:t,onEdit:n,onDelete:r}){return e.isLoading?Rt.jsx(mi,{children:Array.from({length:3}).map((e,t)=>Rt.jsxs(Ht,{children:[Rt.jsxs(qt,{children:[Rt.jsx(fa,{className:"h-4 w-3/4"}),Rt.jsx(fa,{className:"h-3 w-1/2"})]}),Rt.jsx(Kt,{children:Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(fa,{className:"h-3 w-full"}),Rt.jsx(fa,{className:"h-3 w-2/3"})]})})]},t))}):Rt.jsx(ui.Root,{children:e.entities.map(e=>Rt.jsxs(ui.Item,{onClick:()=>n(e),children:[Rt.jsx(qt,{className:"pb-3",children:Rt.jsxs("div",{className:"flex items-start justify-between",children:[Rt.jsxs("div",{className:"flex-1 min-w-0",children:[Rt.jsx(Wt,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),Rt.jsx(Qt,{className:"text-sm",children:y(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:Xs})})]}),Rt.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&Rt.jsx(Bt,{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:Rt.jsx(Fe,{className:"h-4 w-4"})}),Rt.jsx("div",{onClick:e=>e.stopPropagation(),children:Rt.jsx(za,{onEdit:()=>n(e),onDelete:r?()=>r(e):void 0,canDelete:!!r})})]})]})}),Rt.jsx(Kt,{className:"pt-0",children:Rt.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const n=e[t.key];return n?Rt.jsx(ui.Field,{label:t.label,value:t.render?t.render(n,e):String(n)},String(t.key)):null})})})]},e.id))})}function Go(e){const t=at();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 Zo(e,t){const n=Go({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:n.onNew,onEdit:n.onEdit}}Xo.displayName="ActionButton";var el=Object.defineProperty,tl=(e,t,n)=>((e,t,n)=>t in e?el(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);class nl{constructor(){tl(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=wr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=rr.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 ir.handleError("[PlaceService] Resposta não é um array",!1),[];const a=r.map(this.mapToPlace.bind(this));return this.buildHierarchy(a)}catch(n){if(await wr.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 ir.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 ir.handleError(a,!0),[]}}async getPlaces(e){const t=rr.extractTokenData();return t&&t.companyId?this.fetchPlaces(e,t.companyId):(ir.handleError("[PlaceService] CompanyId não encontrado no token",!1),[])}}const rl=new nl;function al({place:e,level:t=0}){const[n,r]=a(!1),s=e.subPlaces&&e.subPlaces.length>0,i="is_actived"in e?e.is_actived:e.isActive;return Rt.jsxs("div",{children:[Rt.jsxs(Gs,{open:n,onOpenChange:r,children:[Rt.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:[s?Rt.jsxs(Zs,{className:"flex items-center gap-2 flex-1",children:[Rt.jsx(A,{className:Dt("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),Rt.jsx(Me,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Rt.jsx("span",{className:"font-medium",children:e.name}),Rt.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):Rt.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Rt.jsx("div",{className:"w-4 shrink-0"}),Rt.jsx(Me,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Rt.jsx("span",{className:"font-medium",children:e.name})]}),Rt.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[Rt.jsxs("div",{className:"flex items-center gap-1.5",children:[Rt.jsx(Be,{className:"h-3.5 w-3.5 text-muted-foreground"}),Rt.jsx("span",{className:"text-sm text-muted-foreground",children:e.usersIds.length})]}),Rt.jsx(Cn,{variant:i?"default":"secondary",className:"text-xs",children:i?"Ativo":"Inativo"})]})]}),s&&Rt.jsx(ei,{children:e.subPlaces.map(e=>Rt.jsx(al,{place:e,level:t+1},e.placeId))})]}),0===t&&Rt.jsx(Ci,{})]})}function sl(){const{alias:e}=Vr(),{data:t=[],isLoading:n}=Ze({queryKey:["places",e],queryFn:()=>rl.getPlaces(e||""),enabled:!!e});return n?Rt.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(fa,{className:"h-8 w-64"}),Rt.jsx(fa,{className:"h-4 w-96"})]}),Rt.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[1,2,3].map(e=>Rt.jsx(fa,{className:"h-64 w-full"},e))})]}):Rt.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[Rt.jsxs("div",{children:[Rt.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Locais"}),Rt.jsx("p",{className:"text-muted-foreground",children:"Visualização hierárquica de locais e sublocais da organização"})]}),0===t.length?Rt.jsx(Ht,{children:Rt.jsxs(Kt,{className:"flex flex-col items-center justify-center py-12",children:[Rt.jsx(Me,{className:"h-12 w-12 text-muted-foreground mb-4"}),Rt.jsx("p",{className:"text-muted-foreground",children:"Nenhum local encontrado"})]})}):Rt.jsxs(Ht,{children:[Rt.jsx(qt,{children:Rt.jsx(Wt,{children:"Estrutura de Locais"})}),Rt.jsx(Kt,{className:"p-0",children:Rt.jsx("div",{children:t.map(e=>Rt.jsx(al,{place:e},e.placeId))})})]})]})}const il=t.memo(({variant:e="card",className:n="",selectedUnit:r,onUnitChange:a})=>{const{user:s,companies:i,alias:o,isAuthenticated:l,logout:c,switchUnit:u}=Vr(),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=()=>Rt.jsxs(Rt.Fragment,{children:[Rt.jsxs("div",{className:"flex items-center space-x-3",children:[Rt.jsx("div",{className:"flex-shrink-0",children:Rt.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:Rt.jsx(Ee,{className:"h-5 w-5 text-primary-foreground"})})}),Rt.jsxs("div",{className:"flex-1 min-w-0",children:[Rt.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),Rt.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&Rt.jsx("div",{className:"mt-3",children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx(Me,{className:"h-4 w-4 text-muted-foreground"}),Rt.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),g.length>1&&Rt.jsxs("div",{className:"mt-2",children:[Rt.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",g.length]}),Rt.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,3).map(e=>Rt.jsx(Cn,{variant:e.alias===p?.alias?"default":"secondary",className:"text-xs cursor-pointer",onClick:()=>h(e),children:e.name},e.alias)),g.length>3&&Rt.jsxs(Cn,{variant:"outline",className:"text-xs",children:["+",g.length-3]})]})]})]});return"dropdown"===e?Rt.jsxs(va,{children:[Rt.jsx(wa,{asChild:!0,children:Rt.jsx(Bt,{variant:"ghost",className:`h-auto p-2 ${n}`,children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsxs("div",{className:"hidden md:block text-left",children:[Rt.jsx("p",{className:"text-sm font-medium",children:s.name}),Rt.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),Rt.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:Rt.jsx(Ee,{className:"h-4 w-4 text-primary-foreground"})}),Rt.jsx(j,{className:"h-4 w-4"})]})})}),Rt.jsxs(Ta,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[Rt.jsxs(ja,{children:[Rt.jsxs(Ca,{children:[Rt.jsx(Oe,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),Rt.jsx(Ia,{children:g.map(e=>Rt.jsxs(Ea,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[Rt.jsx(Me,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&Rt.jsx(Cn,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Rt.jsx(_a,{}),Rt.jsxs(Ea,{onClick:c,children:[Rt.jsx($e,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):Rt.jsxs(Ht,{className:n,children:[Rt.jsx(qt,{children:Rt.jsx(Wt,{className:"text-lg",children:"Informações do Usuário"})}),Rt.jsxs(Kt,{className:"space-y-4",children:[Rt.jsx(x,{}),Rt.jsx(Ci,{}),Rt.jsxs(Bt,{variant:"outline",onClick:c,size:"sm",className:"w-full",children:[Rt.jsx($e,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),ol=n({});function ll({children:e,config:t}){const n=o(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return Rt.jsx(ol.Provider,{value:n,children:e})}function cl(){return r(ol)}function ul(){const e=rt(),{navigation:t}=cl();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 fl=l(function({actions:e}){const t=rt(),n=ul(),{navigation:r,appName:s}=cl(),{metadata:o}=Ns(),{companies:l,alias:c,isSearchVisible:u,clearSearch:d,refreshData:f,switchUnit:m}=Vr(),p=c?l?.find(e=>e.alias===c)||l?.[0]||null:l?.[0]||null,[h,g]=nt(),[x,y]=a(()=>h.get("search")||""),[b,v]=dl(x,Tr.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 Rt.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:Rt.jsxs("div",{className:"flex items-center gap-4",children:[Rt.jsxs("div",{className:"flex-shrink-0",children:[Rt.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[Rt.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:k}),Rt.jsx(Cn,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:s||"Módulo"})]}),Rt.jsx("p",{className:"text-sm text-muted-foreground truncate",children:j})]}),u&&Rt.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[Rt.jsxs("div",{className:"relative flex-1",children:[Rt.jsx(E,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Rt.jsx($t,{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&&Rt.jsx(Bt,{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:Rt.jsx(N,{size:14})})]}),Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:Rt.jsx(Oe,{size:14})})]}),Rt.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[e&&Rt.jsx("div",{className:"flex items-center gap-2",children:e}),Rt.jsx("div",{className:"text-sm",children:Rt.jsx(il,{variant:"dropdown",selectedUnit:p,onUnitChange:m})})]})]})})}),ml=(e={})=>{const{enabled:t=!0}=e,{alias:n}=Vr();return Ze({queryKey:["active-modules",n],queryFn:async()=>{if(!n)return[];const e=mr(),{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(!br.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!n})},pl=({key:e,enabled:t,checkFn:n,staleTime:r=3e5,gcTime:a=6e5})=>Ze({queryKey:["permission",e],queryFn:n,enabled:t,staleTime:r,gcTime:a,retry:0,refetchOnWindowFocus:!1}),hl=import.meta.env.VITE_SUPABASE_PROJECT_ID,gl={logo:`https://${hl}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${hl}.supabase.co/storage/v1/object/public/library-assets/small.svg`},xl=gl.logo,yl=gl.smallLogo,bl="forlogic-sidebar-pinned",vl=()=>{try{const e=localStorage.getItem(bl);return!!e&&JSON.parse(e)}catch{return!1}};function wl({config:e}={}){const{state:t,open:n,setOpen:r}=Hi(),s=rt(),{alias:o,user:l}=Vr(),[c,u]=a(!1),[d,f]=a(vl),[m,p]=a(!1);i(()=>{r(!!d||!(!m&&!c))},[d,m,c,r]);const{data:h,isLoading:g,error:x}=ml({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 Rt.jsxs(Wi,{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:[Rt.jsxs(Ji,{className:"p-0 gap-0",children:[Rt.jsx("div",{className:"flex items-center justify-between h-[34px]",children:n?Rt.jsxs(Rt.Fragment,{children:[Rt.jsx("div",{className:"flex items-center pl-[12px]",children:Rt.jsx("img",{src:gl.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),Rt.jsx("button",{onClick:()=>{const e=!d;f(e),(e=>{try{localStorage.setItem(bl,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:Rt.jsx(Le,{className:"h-4 w-4"})})]}):Rt.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:Rt.jsx("img",{src:gl.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),Rt.jsx("div",{className:"mt-2 pt-0",children:Rt.jsxs(va,{onOpenChange:u,children:[Rt.jsx(wa,{asChild:!0,children:n?Rt.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:[Rt.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Rt.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"}),Rt.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:e?.appName||"Título do módulo"})]}),Rt.jsx(j,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):Rt.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:Rt.jsx(j,{className:"h-6 w-6 text-muted-foreground"})})}),Rt.jsx(Ta,{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?Rt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[Rt.jsx(I,{className:"h-4 w-4 animate-spin"}),Rt.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):x?Rt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[Rt.jsx(T,{className:"h-4 w-4"}),Rt.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):h&&0!==h.length?Rt.jsx("div",{className:"space-y-2",children:h.map((e,t)=>Rt.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:Rt.jsxs("div",{className:"flex items-center justify-between",children:[Rt.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&Rt.jsx(Fe,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):Rt.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]}),Rt.jsx(eo,{children:Rt.jsx(to,{className:"p-0 mt-6",children:Rt.jsx(ao,{children:Rt.jsx(so,{className:"space-y-2",children:Rt.jsx(Fi,{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}=pl({key:n,enabled:Boolean(e.permissionCheck&&o&&l?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),s=e.permissionCheck&&!r,i=a?I:s?G:e.icon;return s||e.complementaryText,Rt.jsx(io,{children:s||a?Rt.jsxs(Mi,{children:[Rt.jsx(Bi,{asChild:!0,children:Rt.jsx(lo,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:Rt.jsxs("div",{className:"flex w-full items-center gap-3",children:[Rt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Rt.jsx(i,{className:"h-4 w-4 "+(a?"animate-spin":"")})}),Rt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),Rt.jsx($i,{children:Rt.jsx("p",{children:a?"Verificando acesso...":"Acesso restrito"})})]}):Rt.jsx(lo,{asChild:!0,isActive:y(e.path),size:"lg",className:"h-10",children:Rt.jsxs(st,{to:e.path,className:"flex w-full items-center gap-3",children:[Rt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Rt.jsx(i,{className:"h-5 w-4"})}),Rt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path)};return Rt.jsx(n,{item:e,index:t},e.path)})})})})})})]})}const kl=l(function({children:e,sidebar:t,sidebarConfig:n,showHeader:r=!0}){const a=o(()=>t||Rt.jsx(wl,{config:n}),[t,n]),s=o(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return Rt.jsx(ll,{config:n,children:Rt.jsx(ks,{children:Rt.jsx(qi,{defaultOpen:!1,style:s,children:Rt.jsxs("div",{className:"min-h-screen flex w-full",children:[a,Rt.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[r&&Rt.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:Rt.jsx(fl,{})}),Rt.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:e})]})]})})})})});class Nl extends u{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){ir.handleError(e,!1)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:Rt.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:Rt.jsxs(Ht,{className:"w-full max-w-md",children:[Rt.jsxs(qt,{className:"text-center",children:[Rt.jsx("div",{className:"flex justify-center mb-4",children:Rt.jsx(Ue,{className:"h-12 w-12 text-destructive"})}),Rt.jsx(Wt,{children:"Algo deu errado"})]}),Rt.jsxs(Kt,{className:"text-center space-y-4",children:[Rt.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),Rt.jsx(Bt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function jl(){const[e,t]=a([]),[n,r]=a(!1),[o,l]=a(null),[c,u]=a(null);i(()=>{d()},[]);const d=async()=>{try{const e=mr(),{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=mr(),{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=mr(),{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=mr(),{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 Sl(){}function Cl(){}const Il=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Tl=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,El={};function Pl(e,t){return(El.jsx?Tl:Il).test(e)}const Al=/[ \t\n\f\r]/g;function Rl(e){return""===e.replace(Al,"")}class _l{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function Dl(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new _l(n,r,t)}function Ol(e){return e.toLowerCase()}_l.prototype.normal={},_l.prototype.property={},_l.prototype.space=void 0;class zl{constructor(e,t){this.attribute=t,this.property=e}}zl.prototype.attribute="",zl.prototype.booleanish=!1,zl.prototype.boolean=!1,zl.prototype.commaOrSpaceSeparated=!1,zl.prototype.commaSeparated=!1,zl.prototype.defined=!1,zl.prototype.mustUseProperty=!1,zl.prototype.number=!1,zl.prototype.overloadedBoolean=!1,zl.prototype.property="",zl.prototype.spaceSeparated=!1,zl.prototype.space=void 0;let Ll=0;const Fl=ql(),Ml=ql(),Bl=ql(),$l=ql(),Ul=ql(),Vl=ql(),Hl=ql();function ql(){return 2**++Ll}var Wl=Object.freeze({__proto__:null,boolean:Fl,booleanish:Ml,commaOrSpaceSeparated:Hl,commaSeparated:Vl,number:$l,overloadedBoolean:Bl,spaceSeparated:Ul});const Ql=Object.keys(Wl);class Kl extends zl{constructor(e,t,n,r){let a=-1;if(super(e,t),Yl(this,"space",r),"number"==typeof n)for(;++a<Ql.length;){const e=Ql[a];Yl(this,Ql[a],(n&Wl[e])===Wl[e])}}}function Yl(e,t,n){n&&(e[t]=n)}function Xl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new Kl(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Ol(r)]=r,n[Ol(s.attribute)]=r}return new _l(t,n,e.space)}Kl.prototype.defined=!0;const Jl=Xl({properties:{ariaActiveDescendant:null,ariaAtomic:Ml,ariaAutoComplete:null,ariaBusy:Ml,ariaChecked:Ml,ariaColCount:$l,ariaColIndex:$l,ariaColSpan:$l,ariaControls:Ul,ariaCurrent:null,ariaDescribedBy:Ul,ariaDetails:null,ariaDisabled:Ml,ariaDropEffect:Ul,ariaErrorMessage:null,ariaExpanded:Ml,ariaFlowTo:Ul,ariaGrabbed:Ml,ariaHasPopup:null,ariaHidden:Ml,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ul,ariaLevel:$l,ariaLive:null,ariaModal:Ml,ariaMultiLine:Ml,ariaMultiSelectable:Ml,ariaOrientation:null,ariaOwns:Ul,ariaPlaceholder:null,ariaPosInSet:$l,ariaPressed:Ml,ariaReadOnly:Ml,ariaRelevant:null,ariaRequired:Ml,ariaRoleDescription:Ul,ariaRowCount:$l,ariaRowIndex:$l,ariaRowSpan:$l,ariaSelected:Ml,ariaSetSize:$l,ariaSort:null,ariaValueMax:$l,ariaValueMin:$l,ariaValueNow:$l,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function Gl(e,t){return t in e?e[t]:t}function Zl(e,t){return Gl(e,t.toLowerCase())}const ec=Xl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Vl,acceptCharset:Ul,accessKey:Ul,action:null,allow:null,allowFullScreen:Fl,allowPaymentRequest:Fl,allowUserMedia:Fl,alt:null,as:null,async:Fl,autoCapitalize:null,autoComplete:Ul,autoFocus:Fl,autoPlay:Fl,blocking:Ul,capture:null,charSet:null,checked:Fl,cite:null,className:Ul,cols:$l,colSpan:null,content:null,contentEditable:Ml,controls:Fl,controlsList:Ul,coords:$l|Vl,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Fl,defer:Fl,dir:null,dirName:null,disabled:Fl,download:Bl,draggable:Ml,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Fl,formTarget:null,headers:Ul,height:$l,hidden:Bl,high:$l,href:null,hrefLang:null,htmlFor:Ul,httpEquiv:Ul,id:null,imageSizes:null,imageSrcSet:null,inert:Fl,inputMode:null,integrity:null,is:null,isMap:Fl,itemId:null,itemProp:Ul,itemRef:Ul,itemScope:Fl,itemType:Ul,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Fl,low:$l,manifest:null,max:null,maxLength:$l,media:null,method:null,min:null,minLength:$l,multiple:Fl,muted:Fl,name:null,nonce:null,noModule:Fl,noValidate:Fl,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:Fl,optimum:$l,pattern:null,ping:Ul,placeholder:null,playsInline:Fl,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Fl,referrerPolicy:null,rel:Ul,required:Fl,reversed:Fl,rows:$l,rowSpan:$l,sandbox:Ul,scope:null,scoped:Fl,seamless:Fl,selected:Fl,shadowRootClonable:Fl,shadowRootDelegatesFocus:Fl,shadowRootMode:null,shape:null,size:$l,sizes:null,slot:null,span:$l,spellCheck:Ml,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$l,step:null,style:null,tabIndex:$l,target:null,title:null,translate:null,type:null,typeMustMatch:Fl,useMap:null,value:Ml,width:$l,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ul,axis:null,background:null,bgColor:null,border:$l,borderColor:null,bottomMargin:$l,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Fl,declare:Fl,event:null,face:null,frame:null,frameBorder:null,hSpace:$l,leftMargin:$l,link:null,longDesc:null,lowSrc:null,marginHeight:$l,marginWidth:$l,noResize:Fl,noHref:Fl,noShade:Fl,noWrap:Fl,object:null,profile:null,prompt:null,rev:null,rightMargin:$l,rules:null,scheme:null,scrolling:Ml,standby:null,summary:null,text:null,topMargin:$l,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$l,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Fl,disableRemotePlayback:Fl,prefix:null,property:null,results:$l,security:null,unselectable:null},space:"html",transform:Zl}),tc=Xl({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:Hl,accentHeight:$l,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$l,amplitude:$l,arabicForm:null,ascent:$l,attributeName:null,attributeType:null,azimuth:$l,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$l,by:null,calcMode:null,capHeight:$l,className:Ul,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:$l,diffuseConstant:$l,direction:null,display:null,dur:null,divisor:$l,dominantBaseline:null,download:Fl,dx:null,dy:null,edgeMode:null,editable:null,elevation:$l,enableBackground:null,end:null,event:null,exponent:$l,externalResourcesRequired:null,fill:null,fillOpacity:$l,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:Vl,g2:Vl,glyphName:Vl,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$l,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$l,horizOriginX:$l,horizOriginY:$l,id:null,ideographic:$l,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$l,k:$l,k1:$l,k2:$l,k3:$l,k4:$l,kernelMatrix:Hl,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$l,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:$l,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:$l,overlineThickness:$l,paintOrder:null,panose1:null,path:null,pathLength:$l,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ul,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$l,pointsAtY:$l,pointsAtZ:$l,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Hl,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Hl,rev:Hl,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Hl,requiredFeatures:Hl,requiredFonts:Hl,requiredFormats:Hl,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:$l,specularExponent:$l,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$l,strikethroughThickness:$l,string:null,stroke:null,strokeDashArray:Hl,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$l,strokeOpacity:$l,strokeWidth:null,style:null,surfaceScale:$l,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Hl,tabIndex:$l,tableValues:null,target:null,targetX:$l,targetY:$l,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Hl,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$l,underlineThickness:$l,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$l,values:null,vAlphabetic:$l,vMathematical:$l,vectorEffect:null,vHanging:$l,vIdeographic:$l,version:null,vertAdvY:$l,vertOriginX:$l,vertOriginY:$l,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$l,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Gl}),nc=Xl({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()}),rc=Xl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Zl}),ac=Xl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),sc={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"},ic=/[A-Z]/g,oc=/-[a-z]/g,lc=/^data[-\w.:]+$/i;function cc(e){return"-"+e.toLowerCase()}function uc(e){return e.charAt(1).toUpperCase()}const dc=Dl([Jl,ec,nc,rc,ac],"html"),fc=Dl([Jl,tc,nc,rc,ac],"svg");var mc,pc,hc,gc={};function xc(){if(hc)return gc;hc=1;var e=gc&&gc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(gc,"__esModule",{value:!0}),gc.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(pc)return mc;pc=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 mc=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}()},mc}());return gc}var yc,bc,vc,wc={};function kc(){if(yc)return wc;yc=1,Object.defineProperty(wc,"__esModule",{value:!0}),wc.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 wc.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))},wc}var Nc=function(){if(vc)return bc;vc=1;var e=(bc&&bc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(xc()),t=kc();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,bc=n}(),jc=jt(Nc);const Sc=Ic("end"),Cc=Ic("start");function Ic(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 Tc(e){return e&&"object"==typeof e?"position"in e||"type"in e?Pc(e.position):"start"in e||"end"in e?Pc(e):"line"in e||"column"in e?Ec(e):"":""}function Ec(e){return Ac(e&&e.line)+":"+Ac(e&&e.column)}function Pc(e){return Ec(e&&e.start)+"-"+Ec(e&&e.end)}function Ac(e){return e&&"number"==typeof e?e:1}class Rc 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=Tc(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}}Rc.prototype.file="",Rc.prototype.name="",Rc.prototype.reason="",Rc.prototype.message="",Rc.prototype.stack="",Rc.prototype.column=void 0,Rc.prototype.line=void 0,Rc.prototype.ancestors=void 0,Rc.prototype.cause=void 0,Rc.prototype.fatal=void 0,Rc.prototype.place=void 0,Rc.prototype.ruleId=void 0,Rc.prototype.source=void 0;const _c={}.hasOwnProperty,Dc=new Map,Oc=/[A-Z]/g,zc=new Set(["table","tbody","thead","tfoot","tr"]),Lc=new Set(["td","th"]),Fc="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Mc(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=Cc(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?fc:dc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=Bc(a,e,void 0);return s&&"string"!=typeof s?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function Bc(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=fc,e.schema=a);e.ancestors.push(t);const s=qc(e,t.tagName,!1),i=function(e,t){const n={};let r,a;for(a in t.properties)if("children"!==a&&_c.call(t.properties,a)){const s=Hc(e,a,t.properties[a]);if(s){const[a,i]=s;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof i&&Lc.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=Vc(e,t);zc.has(t.tagName)&&(o=o.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&Rl(t.value):Rl(t));var t}));return $c(e,i,s,t),Uc(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)}Wc(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=fc,e.schema=a);e.ancestors.push(t);const s=null===t.name?e.Fragment:qc(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];Sl(t.type);const a=t.expression;Sl(a.type);const s=a.properties[0];Sl(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else Wc(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];Sl(t.type),s=e.evaluater.evaluateExpression(t.expression)}else Wc(e,t.position);else s=null===r.value||r.value;n[a]=s}return n}(e,t),o=Vc(e,t);return $c(e,i,s,t),Uc(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);Wc(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return Uc(r,Vc(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 $c(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Uc(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Vc(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:Dc;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=Bc(e,s,i);void 0!==o&&n.push(o)}return n}function Hc(e,t,n){const r=function(e,t){const n=Ol(t);let r=t,a=zl;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&lc.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(oc,uc);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!oc.test(e)){let n=e.replace(ic,cc);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}a=Kl}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 jc(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new Rc("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=Fc+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)_c.call(e,n)&&(t[Qc(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?sc[r.property]||r.property:r.attribute,n]}}function qc(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,a=-1;for(;++a<e.length;){const t=Pl(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=Pl(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 _c.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Wc(e)}function Wc(e,t){const n=new Rc("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=Fc+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Qc(e){let t=e.replace(Oc,Kc);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function Kc(e){return"-"+e.toLowerCase()}const Yc={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"]},Xc={};function Jc(e,t){return Gc(e,"boolean"!=typeof Xc.includeImageAlt||Xc.includeImageAlt,"boolean"!=typeof Xc.includeHtml||Xc.includeHtml)}function Gc(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 Zc(e.children,t,n)}return Array.isArray(e)?Zc(e,t,n):""}function Zc(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=Gc(e[a],t,n);return r.join("")}const eu=document.createElement("i");function tu(e){const t="&"+e+";";eu.innerHTML=t;const n=eu.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function nu(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 ru(e,t){return e.length>0?(nu(e,e.length,0,t),e):t}const au={}.hasOwnProperty;function su(e){const t={};let n=-1;for(;++n<e.length;)iu(t,e[n]);return t}function iu(e,t){let n;for(n in t){const r=(au.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){au.call(r,s)||(r[s]=[]);const e=a[s];ou(r[s],Array.isArray(e)?e:e?[e]:[])}}}function ou(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);nu(e,0,0,r)}function lu(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 cu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const uu=ku(/[A-Za-z]/),du=ku(/[\dA-Za-z]/),fu=ku(/[#-'*+\--9=?A-Z^-~]/);function mu(e){return null!==e&&(e<32||127===e)}const pu=ku(/\d/),hu=ku(/[\dA-Fa-f]/),gu=ku(/[!-/:-@[-`{-~]/);function xu(e){return null!==e&&e<-2}function yu(e){return null!==e&&(e<0||32===e)}function bu(e){return-2===e||-1===e||32===e}const vu=ku(/\p{P}|\p{S}/u),wu=ku(/\s/);function ku(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Nu(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 ju(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(bu(r))return e.enter(n),i(r);return t(r)};function i(r){return bu(r)&&s++<a?(e.consume(r),i):(e.exit(n),t(r))}}const Su={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),ju(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)):xu(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),a)}}};const Cu={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 nu(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(Iu,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(Iu,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)):xu(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++;nu(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}}},Iu={tokenize:function(e,t,n){return ju(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function Tu(e){return null===e||yu(e)||wu(e)?1:vu(e)?2:void 0}function Eu(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 Pu={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};Au(d,-o),Au(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=ru(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=ru(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",a,t]]),l=ru(l,Eu(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=ru(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=ru(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,nu(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=Tu(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=Tu(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 Au(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ru={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 uu(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||mu(r)?n(r):(e.consume(r),o)}function l(t){return 64===t?(e.consume(t),c):fu(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 _u={partial:!0,tokenize:function(e,t,n){return function(t){return bu(t)?ju(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||xu(e)?t(e):n(e)}}};const Du={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(bu(t))return ju(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return a(t)};function a(r){return e.attempt(Du,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 bu(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const Ou={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 gu(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const zu={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=hu,c):(e.enter("characterReferenceValue"),a=7,s=pu,c(t))}function c(o){if(59===o&&i){const a=e.exit("characterReferenceValue");return s!==du||tu(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 Lu={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a};function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},Fu={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,a={partial:!0,tokenize:function(e,t,n){let a=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),bu(t)?ju(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"),bu(t)?ju(e,d,"whitespace")(t):d(t)):n(t)}function d(r){return null===r||xu(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"),bu(t)?ju(e,c,"whitespace")(t):c(t))}function c(n){return null===n||xu(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(Lu,m,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||xu(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):bu(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ju(e,d,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),u)}function d(t){return null===t||xu(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(t))}function f(t){return null===t||xu(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&&bu(t)?ju(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||xu(t)?e.check(Lu,m,y)(t):(e.enter("codeFlowValue"),x(t))}function x(t){return null===t||xu(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),x)}function y(n){return e.exit("codeFenced"),t(n)}}};const Mu={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),ju(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):xu(t)?e.attempt(Bu,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||xu(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},Bu={partial:!0,tokenize:function(e,t,n){const r=this;return a;function a(t){return r.parser.lazy[r.now().line]?n(t):xu(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):ju(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):xu(e)?a(e):n(e)}}};const $u={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)):xu(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||xu(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 Uu{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&&Vu(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),Vu(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Vu(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);Vu(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);Vu(this.left,t.reverse())}}}function Vu(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 Hu(e){const t={};let n,r,a,s,i,o,l,c=-1;const u=new Uu(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,qu(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 nu(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function qu(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 Wu={resolve:function(e){return Hu(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):xu(t)?e.check(Qu,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}}},Qu={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"),ju(e,a,"linePrefix")};function a(a){if(null===a||xu(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 Ku(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||mu(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||xu(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&&!yu(a)?u<c&&40===a?(e.consume(a),u++,p):41===a?(e.consume(a),u--,p):null===a||32===a||40===a||mu(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 Yu(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):xu(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||xu(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!bu(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function Xu(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):xu(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ju(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||xu(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 Ju(e,t){let n;return function r(a){if(xu(a))return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r;if(bu(a))return ju(e,r,n?"linePrefix":"lineSuffix")(a);return t(a)}}const Gu={name:"definition",tokenize:function(e,t,n){const r=this;let a;return function(t){return e.enter("definition"),function(t){return Yu.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return a=cu(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 yu(t)?Ju(e,o)(t):o(t)}function o(t){return Ku(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(Zu,c,c)(t)}function c(t){return bu(t)?ju(e,u,"whitespace")(t):u(t)}function u(s){return null===s||xu(s)?(e.exit("definition"),r.parser.defined.push(a),t(s)):n(s)}}},Zu={partial:!0,tokenize:function(e,t,n){return function(t){return yu(t)?Ju(e,r)(t):n(t)};function r(t){return Xu(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return bu(t)?ju(e,s,"whitespace")(t):s(t)}function s(e){return null===e||xu(e)?t(e):n(e)}}};const ed={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return xu(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const td={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"},nu(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||yu(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||xu(n)?(e.exit("atxHeading"),t(n)):bu(n)?ju(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||yu(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const nd=["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"],rd=["pre","script","style","textarea"],ad={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):uu(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):uu(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:C:f):n(a)}function m(t){return uu(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||yu(o)){const l=47===o,c=i.toLowerCase();return l||s||!rd.includes(c)?nd.includes(i.toLowerCase())?(a=6,l?(e.consume(o),h):r.interrupt?t(o):C(o)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(o):s?g(o):x(o)):(a=1,r.interrupt?t(o):C(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:C):n(a)}function g(t){return bu(t)?(e.consume(t),g):j(t)}function x(t){return 47===t?(e.consume(t),j):58===t||95===t||uu(t)?(e.consume(t),y):bu(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):bu(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):bu(t)?(e.consume(t),v):k(t)}function w(t){return t===l?(e.consume(t),l=null,N):null===t||xu(t)?n(t):(e.consume(t),w)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||yu(t)?b(t):(e.consume(t),k)}function N(e){return 47===e||62===e||bu(e)?x(e):n(e)}function j(t){return 62===t?(e.consume(t),S):n(t)}function S(t){return null===t||xu(t)?C(t):bu(t)?(e.consume(t),S):n(t)}function C(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),O):63===t&&3===a?(e.consume(t),D):93===t&&5===a?(e.consume(t),_):!xu(t)||6!==a&&7!==a?null===t||xu(t)?(e.exit("htmlFlowData"),I(t)):(e.consume(t),C):(e.exit("htmlFlowData"),e.check(sd,z,I)(t))}function I(t){return e.check(id,T,z)(t)}function T(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||xu(t)?I(t):(e.enter("htmlFlowData"),C(t))}function P(t){return 45===t?(e.consume(t),D):C(t)}function A(t){return 47===t?(e.consume(t),i="",R):C(t)}function R(t){if(62===t){const n=i.toLowerCase();return rd.includes(n)?(e.consume(t),O):C(t)}return uu(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),R):C(t)}function _(t){return 93===t?(e.consume(t),D):C(t)}function D(t){return 62===t?(e.consume(t),O):45===t&&2===a?(e.consume(t),D):C(t)}function O(t){return null===t||xu(t)?(e.exit("htmlFlowData"),z(t)):(e.consume(t),O)}function z(n){return e.exit("htmlFlow"),t(n)}}},sd={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(_u,t,n)}}},id={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(xu(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 od={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):uu(t)?(e.consume(t),N):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,m):uu(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):xu(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):xu(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):xu(t)?(i=x,R(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):xu(t)?(i=y,R(t)):(e.consume(t),y)}function b(e){return 62===e?A(e):y(e)}function v(t){return uu(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||du(t)?(e.consume(t),w):k(t)}function k(t){return xu(t)?(i=k,R(t)):bu(t)?(e.consume(t),k):A(t)}function N(t){return 45===t||du(t)?(e.consume(t),N):47===t||62===t||yu(t)?j(t):n(t)}function j(t){return 47===t?(e.consume(t),A):58===t||95===t||uu(t)?(e.consume(t),S):xu(t)?(i=j,R(t)):bu(t)?(e.consume(t),j):A(t)}function S(t){return 45===t||46===t||58===t||95===t||du(t)?(e.consume(t),S):C(t)}function C(t){return 61===t?(e.consume(t),I):xu(t)?(i=C,R(t)):bu(t)?(e.consume(t),C):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,T):xu(t)?(i=I,R(t)):bu(t)?(e.consume(t),I):(e.consume(t),E)}function T(t){return t===a?(e.consume(t),a=void 0,P):null===t?n(t):xu(t)?(i=T,R(t)):(e.consume(t),T)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||yu(t)?j(t):(e.consume(t),E)}function P(e){return 47===e||62===e||yu(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 bu(t)?ju(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 ld={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&&nu(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=ru(s,e.slice(r+1,r+o+3)),s=ru(s,[["enter",u,t]]),s=ru(s,Eu(t.parser.constructs.insideSpan.null,e.slice(r+o+4,a-3),t)),s=ru(s,[["exit",u,t],e[a-2],e[a-1],["exit",c,t]]),s=ru(s,e.slice(a+1)),s=ru(s,[["exit",l,t]]),nu(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(cu(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(cd,c,s?c:u)(t):91===t?e.attempt(ud,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)}}},cd={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 yu(t)?Ju(e,a)(t):a(t)}function a(t){return 41===t?c(t):Ku(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return yu(t)?Ju(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?Xu(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return yu(t)?Ju(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)}}},ud={tokenize:function(e,t,n){const r=this;return function(t){return Yu.call(r,e,a,s,"reference","referenceMarker","referenceString")(t)};function a(e){return r.parser.defined.includes(cu(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 fd={name:"labelStartImage",resolveAll:ld.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 md={name:"labelStartLink",resolveAll:ld.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 pd={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),ju(e,t,"linePrefix")}}};const hd={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||xu(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),a++,i):(e.exit("thematicBreakSequence"),bu(t)?ju(e,s,"whitespace")(t):s(t))}}};const gd={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(_u,a,s);function a(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ju(e,t,"listItemIndent",r.containerState.size+1)(n)}function s(n){return r.containerState.furtherBlankLines||!bu(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(yd,t,i)(n))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,ju(e,e.attempt(gd,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:pu(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(hd,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 pu(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(_u,r.interrupt?n:c,e.attempt(xd,d,u))}function c(e){return r.containerState.initialBlankLine=!0,s++,d(e)}function u(t){return bu(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)}}},xd={partial:!0,tokenize:function(e,t,n){const r=this;return ju(e,function(e){const a=r.events[r.events.length-1];return!bu(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},yd={partial:!0,tokenize:function(e,t,n){const r=this;return ju(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 bd={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"),bu(t)?ju(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||xu(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const vd={tokenize:function(e){const t=this,n=e.attempt(_u,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,ju(e,e.attempt(this.parser.constructs.flow,r,e.attempt(Wu,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}};const wd={resolveAll:Sd()},kd=jd("string"),Nd=jd("text");function jd(e){return{resolveAll:Sd("text"===e?Cd: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 Sd(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 Cd(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 Id={42:gd,43:gd,45:gd,48:gd,49:gd,50:gd,51:gd,52:gd,53:gd,54:gd,55:gd,56:gd,57:gd,62:Du},Td={91:Gu},Ed={[-2]:Mu,[-1]:Mu,32:Mu},Pd={35:td,42:hd,45:[bd,hd],60:ad,61:bd,95:hd,96:Fu,126:Fu},Ad={38:zu,92:Ou},Rd={[-5]:pd,[-4]:pd,[-3]:pd,33:fd,38:zu,42:Pu,60:[Ru,od],91:md,92:[ed,Ou],93:ld,95:Pu,96:$u},_d={null:[Pu,wd]};var Dd=Object.freeze({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:Td,disable:{null:[]},document:Id,flow:Pd,flowInitial:Ed,insideSpan:_d,string:Ad,text:Rd});function Od(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){xu(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=ru(i,e),m(),null!==i[i.length-1])return[];return x(t,0),c.events=Eu(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&&nu(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 zd=/[\0\t\n\r]/g;const Ld=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Fd(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return lu(n.slice(t?2:1),t?16:10)}return tu(n)||e}const Md={}.hasOwnProperty;function Bd(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:S,autolinkEmail:S,atxHeading:s(J),blockQuote:s(W),characterEscape:S,characterReference:S,codeFenced:s(Q),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(Q,i),codeText:s(K,i),codeTextData:S,data:S,codeFlowValue:S,definition:s(Y),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(X),hardBreakEscape:s(G),hardBreakTrailing:s(G),htmlFlow:s(Z,i),htmlFlowData:S,htmlText:s(Z,i),htmlTextData:S,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(J),strong:s(se),thematicBreak:s(oe)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:q,autolinkProtocol:H,blockQuote:l(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:$,characterReferenceMarkerNumeric:$,characterReferenceValue:U,characterReference:V,codeFenced:l(g),codeFencedFence:h,codeFencedFenceInfo:m,codeFencedFenceMeta:p,codeFlowValue:C,codeIndented:l(x),codeText:l(A),codeTextData:C,data:C,definition:l(),definitionDestinationString:v,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(T),hardBreakTrailing:l(T),htmlFlow:l(E),htmlFlowData:C,htmlText:l(P),htmlTextData:C,image:l(_),label:O,labelText:D,lineEnding:I,link:l(R),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:z,resourceTitleString:L,resource:F,setextHeading:l(j),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};Ud(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]];Md.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]||Hd).call(s,void 0,e[0])}for(r.position={start:$d(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:$d(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:$d(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+"` ("+Tc({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]||Hd).call(this,e,r[0])}n.position.end=$d(e.end)}function u(){return Jc(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=cu(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 k(){this.data.setextHeadingSlurpLineEnding=!0}function N(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function j(){this.data.setextHeadingSlurpLineEnding=void 0}function S(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:$d(e.start),end:void 0},t.push(n)),this.stack.push(n)}function C(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=$d(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=$d(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(S.call(this,e),C.call(this,e))}function T(){this.data.atHardBreak=!0}function E(){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(Ld,Fd)}(t),n.identifier=cu(t).toLowerCase()}function O(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function z(){const e=this.resume();this.stack[this.stack.length-1].url=e}function L(){const e=this.resume();this.stack[this.stack.length-1].title=e}function F(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function B(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=cu(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function $(e){this.data.characterReferenceType=e.type}function U(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;if(n)r=lu(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=tu(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=$d(e.end)}function H(e){C.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function q(e){C.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 X(){return{type:"emphasis",children:[]}}function J(){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(;!Hu(e););return e}(function(e){const t={constructs:su([Dd,...(e||{}).extensions||[]]),content:n(Su),defined:[],document:n(Cu),flow:n(vd),lazy:{},string:n(kd),text:n(Nd)};return t;function n(e){return function(n){return Od(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(zd.lastIndex=u,l=zd.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 $d(e){return{line:e.line,column:e.column,offset:e.offset}}function Ud(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Ud(e,r):Vd(e,r)}}function Vd(e,t){let n;for(n in t)if(Md.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 Hd(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Tc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Tc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Tc({start:t.start,end:t.end})+") is still open")}function qd(e){const t=this;t.parser=function(n){return Bd(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Wd(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 Qd(e){const t=e.spread;return null==t?e.children.length>1:t}function Kd(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const s=[];for(;r;)s.push(Yd(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return s.push(Yd(t.slice(a),a>0,!1)),s.join("")}function Yd(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 Xd={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=Nu(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 Wd(e,t);const a={src:Nu(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:Nu(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 Wd(e,t);const a={href:Nu(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:Nu(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=Qd(n[r])}return t}(n):Qd(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=Cc(t.children[1]),i=Sc(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:Kd(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:Jd,yaml:Jd,definition:Jd,footnoteDefinition:Jd};function Jd(){}const Gd="object"==typeof self?self:globalThis,Zd=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 Gd[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 Gd[s](i),a)};return r})(new Map,e)(0),ef="",{toString:tf}={},{keys:nf}=Object,rf=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=tf.call(e).slice(8,-1);switch(n){case"Array":return[1,ef];case"Object":return[2,ef];case"Date":return[3,ef];case"RegExp":return[4,ef];case"Map":return[5,ef];case"Set":return[6,ef];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},af=([e,t])=>0===e&&("function"===t||"symbol"===t),sf=(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]=rf(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 nf(r))!e&&af(rf(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||!af(rf(a))&&!af(rf(i)))&&t.push([s(a),s(i)]);return n}case 6:{const t=[],n=a([i,t],r);for(const a of r)!e&&af(rf(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 of="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Zd(sf(e,t)):structuredClone(e):(e,t)=>Zd(sf(e,t));function lf(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 cf(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const uf=function(e){if(null==e)return ff;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]=uf(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 ff(){return!0}const mf=[],pf=!0,hf=!1;function gf(e,t,n,r){let a;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):a=t;const s=uf(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=mf;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[pf,e];return null==e?mf:[e]}(n(a,l)),f[0]===hf))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]===hf)return c;u="number"==typeof c[1]?c[1]:u+i}}return f}}(e,void 0,[])()}function xf(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),gf(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 yf={}.hasOwnProperty,bf={};function vf(e,t){e.position&&(t.position=function(e){const t=Cc(e),n=Sc(e);if(t&&n)return{start:t,end:n}}(e))}function wf(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,of(a)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function kf(e,t){const n=t.data||{},r=!("value"in t)||yf.call(n,"hProperties")||yf.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,r),e.applyData(t,r)}function Nf(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function jf(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function Sf(e,t){const n=function(e,t){const n=t||bf,r=new Map,a=new Map,s=new Map,i={...Xd,...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=jf(a.value)),!Array.isArray(a)&&"element"===a.type)){const e=a.children[0];e&&"text"===e.type&&(e.value=jf(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:wf,definitionById:r,footnoteById:a,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=o.handlers[n];if(yf.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=of(n);return r.children=o.all(e),r}return of(e)}return(o.options.unknownHandler||kf)(o,e,t)},options:n,patch:vf,wrap:Nf};return xf(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||lf,r=e.options.footnoteBackLabel||cf,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=Nu(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:{...of(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 Cf(e,t){return e&&"run"in e?async function(n,r){const a=Sf(n,{file:r,...t});await e.run(a,r)}:function(n,r){return Sf(n,{file:r,...e||t})}}function If(e){if(e)throw e}var Tf,Ef;var Pf=function(){if(Ef)return Tf;Ef=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 Tf=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},Tf}(),Af=jt(Pf);function Rf(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 _f(){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 Df={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');Of(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(Of(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){Of(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;)Of(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){Of(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 Of(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const zf={cwd:function(){return"/"}};function Lf(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function Ff(e){if("string"==typeof e)e=new URL(e);else if(!Lf(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 Mf=["history","path","basename","stem","extname","dirname"];class Bf{constructor(e){let t;t=e?Lf(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?"":zf.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<Mf.length;){const e=Mf[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)Mf.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?Df.basename(this.path):void 0}set basename(e){Uf(e,"basename"),$f(e,"basename"),this.path=Df.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?Df.dirname(this.path):void 0}set dirname(e){Vf(this.basename,"dirname"),this.path=Df.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?Df.extname(this.path):void 0}set extname(e){if($f(e,"extname"),Vf(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=Df.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Lf(e)&&(e=Ff(e)),Uf(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?Df.basename(this.path,this.extname):void 0}set stem(e){Uf(e,"stem"),$f(e,"stem"),this.path=Df.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 Rc(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 $f(e,t){if(e&&e.includes(Df.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Df.sep+"`")}function Uf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Vf(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const Hf=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},qf={}.hasOwnProperty;class Wf extends Hf{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=_f()}copy(){const e=new Wf;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(Af(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(Xf("data",this.frozen),this.namespace[e]=t,this):qf.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Xf("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=Zf(e),n=this.parser||this.Parser;return Kf("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),Kf("process",this.parser||this.Parser),Yf("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,a){const s=Zf(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(),Kf("processSync",this.parser||this.Parser),Yf("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,If(e),t=r}),Gf("processSync","process",n),t}run(e,t,n){Jf(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=Zf(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){If(e),n=t,r=!0}),Gf("runSync","run",r),n}stringify(e,t){this.freeze();const n=Zf(t),r=this.compiler||this.Compiler;return Yf("stringify",r),Jf(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(Xf("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=Af(!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];Rf(i)&&Rf(r)&&(r=Af(!0,i,r)),n[a]=[e,r,...s]}}}}const Qf=(new Wf).freeze();function Kf(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Yf(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function Xf(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 Jf(e){if(!Rf(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function Gf(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Zf(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new Bf(e)}const em=[],tm={allowDangerousHtml:!0},nm=/^(https?|ircs?|mailto|xmpp)$/i,rm=[{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 am(e){const t=function(e){const t=e.rehypePlugins||em,n=e.remarkPlugins||em,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...tm}:tm,a=Qf().use(qd).use(n).use(Cf,r).use(t);return a}(e),n=function(e){const t=e.children||"",n=new Bf;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,s=t.disallowedElements,i=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||sm;for(const u of rm)Object.hasOwn(t,u.from)&&Cl((u.from,u.to&&u.to,u.id));return xf(e,c),Mc(e,{Fragment:Rt.Fragment,components:a,ignoreInvalidStyle:!0,jsx:Rt.jsx,jsxs:Rt.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 Yc)if(Object.hasOwn(Yc,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=Yc[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 sm(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||nm.test(e.slice(0,t))?e:""}function im(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 om(e,t,n){const r=uf((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([lm(e[0]),cm(e[1])])}return t}(t);let s=-1;for(;++s<a.length;)gf(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 lm(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 cm(e){return"function"==typeof e?e:function(){return e}}const um="phrasing",dm=["autolink","link","image","label"];function fm(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function mm(e){this.config.enter.autolinkProtocol.call(this,e)}function pm(e){this.config.exit.autolinkProtocol.call(this,e)}function hm(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 gm(e){this.config.exit.autolinkEmail.call(this,e)}function xm(e){this.exit(e)}function ym(e){om(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,bm],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,vm]],{ignore:["link","linkReference"]})}function bm(e,t,n,r,a){let s="";if(!wm(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=im(e,"(");let s=im(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 vm(e,t,n,r){return!(!wm(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function wm(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||wu(n)||vu(n))&&(!t||47!==n)}function km(){this.buffer()}function Nm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function jm(){this.buffer()}function Sm(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Cm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=cu(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Im(e){this.exit(e)}function Tm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=cu(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Em(e){this.exit(e)}function Pm(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 Am(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?_m:Rm)));return o(),i},footnoteReference:Pm},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function Rm(e,t,n){return 0===t?e:_m(e,t,n)}function _m(e,t,n){return(n?"":" ")+e}Pm.peek=function(){return"["};const Dm=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function Om(e){this.enter({type:"delete",children:[]},e)}function zm(e){this.exit(e)}function Lm(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 Fm(e){return e.length}function Mm(e){return null==e?"":String(e)}function Bm(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 $m(e,t,n){return">"+(n?"":" ")+e}function Um(e,t){return Vm(e,t.inConstruct,!0)&&!Vm(e,t.notInConstruct,!1)}function Vm(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 Hm(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if("\n"===n.unsafe[a].character&&Um(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function qm(e,t,n){return(n?"":" ")+e}function Wm(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 Qm(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Km(e,t,n){const r=Tu(e),a=Tu(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 Ym(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=Km(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=Qm(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=Km(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+Qm(d));const m=i.move(a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}function Xm(e){return e.value||""}function Jm(e,t,n,r){const a=Wm(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 Gm(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 Zm(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 ep(e,t){const n=Jc(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function tp(e,t,n,r){const a=Wm(n),s='"'===a?"Quote":"Apostrophe",i=n.createTracker(r);let o,l;if(ep(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 np(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 rp(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 ap(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}Lm.peek=function(){return"~"},Ym.peek=function(e,t,n){return n.options.emphasis||"*"},Xm.peek=function(){return"<"},Jm.peek=function(){return"!"},Gm.peek=function(){return"!"},Zm.peek=function(){return"`"},tp.peek=function(e,t,n){return ep(e,n)?"<":"["},np.peek=function(){return"["};const sp=uf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function ip(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=Km(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=Qm(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=Km(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+Qm(d));const m=i.move(a+a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}ip.peek=function(e,t,n){return n.options.strong||"*"};const op={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()),$m);return a(),i},break:Hm,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,qm);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=Wm(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:Ym,hardBreak:Hm,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 xf(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,hf}),Boolean((!e.depth||e.depth<3)&&Jc(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=Qm(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),o(),c},html:Xm,image:Jm,imageReference:Gm,inlineCode:Zm,link:tp,linkReference:np,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):rp(n);const o=e.ordered?"."===i?")":".":function(e){const t=rp(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),ap(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||rp(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 sp(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:ip,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(ap(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?r.slice(0,-1):r}};function lp(e){const t=e._align;this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function cp(e){this.exit(e),this.data.inTable=void 0}function up(e){this.enter({type:"tableRow",children:[]},e)}function dp(e){this.exit(e)}function fp(e){this.enter({type:"tableCell",children:[]},e)}function mp(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,pp));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function pp(e,t){return"|"===t?t:e}function hp(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=op.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||Fm,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=Mm(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]=Bm(r[d]);else{const e=Bm(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 gp(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function xp(e){const t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"==typeof t.checked){const e=this.stack[this.stack.length-1];e.type;const n=e.children[0];if(n&&"text"===n.type){const r=t.children;let a,s=-1;for(;++s<r.length;){const e=r[s];if("paragraph"===e.type){a=e;break}}a===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"==typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function yp(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=op.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const bp={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},vp={tokenize:function(e,t,n){let r,a,s;return i;function i(t){return 46===t||95===t?e.check(kp,l,o)(t):null===t||yu(t)||wu(t)||45!==t&&vu(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},wp={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(kp,t,s)(i):null===i||yu(i)||wu(i)?t(i):(e.consume(i),a)}function s(t){return 41===t&&r++,e.consume(t),a}},partial:!0},kp={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||yu(i)||wu(i)?t(i):n(i)}function a(e){return null===e||40===e||91===e||yu(e)||wu(e)?t(e):r(e)}function s(e){return uu(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),r):uu(t)?(e.consume(t),i):n(t)}},partial:!0},Np={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},jp={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){if(87!==t&&119!==t||!Ep.call(r,r.previous)||_p(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(bp,e.attempt(vp,e.attempt(wp,a),n),n)(t)};function a(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:Ep},Sp={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let a="",s=!1;return function(t){if((72===t||104===t)&&Pp.call(r,r.previous)&&!_p(r.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if(uu(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||mu(t)||yu(t)||wu(t)||vu(t)?n(t):e.attempt(vp,e.attempt(wp,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:Pp},Cp={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let a,s;return function(t){if(!Rp(t)||!Ap.call(r,r.previous)||_p(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return Rp(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(Np,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&&uu(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:Ap},Ip={};let Tp=48;for(;Tp<123;)Ip[Tp]=Cp,Tp++,58===Tp?Tp=65:91===Tp&&(Tp=97);function Ep(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||yu(e)}function Pp(e){return!uu(e)}function Ap(e){return!(47===e||Rp(e))}function Rp(e){return 43===e||45===e||46===e||95===e||du(e)}function _p(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}Ip[43]=Cp,Ip[45]=Cp,Ip[46]=Cp,Ip[95]=Cp,Ip[72]=[Cp,Sp],Ip[104]=[Cp,Sp],Ip[87]=[Cp,jp],Ip[119]=[Cp,jp];const Dp={tokenize:function(e,t,n){const r=this;return ju(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 Op(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=cu(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 zp(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 Lp(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||yu(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return a.includes(cu(r.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return yu(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 Fp(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||yu(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=cu(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return yu(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),ju(e,f,"gfmFootnoteDefinitionWhitespace")):n(t)}function f(e){return t(e)}}function Mp(e,t,n){return e.check(_u,t,e.attempt(Dp,t,n))}function Bp(e){e.exit("gfmFootnoteDefinition")}function $p(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=Tu(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=Tu(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&&nu(i,i.length,0,Eu(o,e.slice(r+1,n),t)),nu(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",a,t]]),nu(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 Up{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 Vp(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 Hp(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):xu(t)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):bu(t)?ju(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||yu(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,bu(t)?ju(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 bu(t)?ju(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||xu(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 bu(t)?ju(e,y,"whitespace")(t):y(t)}function y(n){return 124===n?f(n):(null===n||xu(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||xu(n)?(e.exit("tableRow"),t(n)):bu(n)?ju(e,w,"whitespace")(n):(e.enter("data"),k(n))}function k(t){return null===t||124===t||yu(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?N:k)}function N(t){return 92===t||124===t?(e.consume(t),k):k(t)}}function qp(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 Up;for(;++s<e.length;){const m=e[s],p=m[1];"enter"===m[0]?"tableHead"===p.type?(u=!1,0!==d&&(Qp(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=Wp(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=Wp(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=Wp(f,t,l,o,s,a)):0!==c[1]&&(a=Wp(f,t,c,o,s,a)),o=0):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type||(c[3]=s)}for(0!==d&&Qp(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=Vp(t.events,s))}return e}function Wp(e,t,n,r,a,s){const i=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},Kp(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=Kp(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=Kp(t.events,n[2]),s=Kp(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({},Kp(t.events,a)),e.add(a,0,[["exit",s,t]]),s=void 0),s}function Qp(e,t,n,r,a){const s=[],i=Kp(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 Kp(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const Yp={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 yu(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 xu(r)?t(r):bu(r)?e.check({tokenize:Xp},t,n)(r):n(r)}}};function Xp(e,t,n){return ju(e,function(e){return null===e?n(e):t(e)},"whitespace")}const Jp={};function Gp(e){const t=e||Jp,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return su([{text:Ip},{document:{91:{name:"gfmFootnoteDefinition",tokenize:Fp,continuation:{tokenize:Mp},exit:Bp}},text:{91:{name:"gfmFootnoteCall",tokenize:Lp},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Op,resolveTo:zp}}},$p(e),{flow:{null:{name:"table",tokenize:Hp,resolveAll:qp}}},{text:{91:Yp}}])}(t)),a.push([{transforms:[ym],enter:{literalAutolink:fm,literalAutolinkEmail:mm,literalAutolinkHttp:mm,literalAutolinkWww:mm},exit:{literalAutolink:xm,literalAutolinkEmail:gm,literalAutolinkHttp:pm,literalAutolinkWww:hm}},{enter:{gfmFootnoteCallString:km,gfmFootnoteCall:Nm,gfmFootnoteDefinitionLabelString:jm,gfmFootnoteDefinition:Sm},exit:{gfmFootnoteCallString:Cm,gfmFootnoteCall:Im,gfmFootnoteDefinitionLabelString:Tm,gfmFootnoteDefinition:Em}},{canContainEols:["delete"],enter:{strikethrough:Om},exit:{strikethrough:zm}},{enter:{table:lp,tableData:fp,tableHeader:fp,tableRow:up},exit:{codeText:mp,table:cp,tableData:dp,tableHeader:dp,tableRow:dp}},{exit:{taskListCheckValueChecked:gp,taskListCheckValueUnchecked:gp,paragraph:xp}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:um,notInConstruct:dm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:um,notInConstruct:dm},{character:":",before:"[ps]",after:"\\/",inConstruct:um,notInConstruct:dm}]},Am(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Dm}],handlers:{delete:Lm}},hp(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:yp}}]}}(t))}function Zp({content:e,className:t}){return Rt.jsx("div",{className:Dt("prose prose-sm max-w-none",t),children:Rt.jsx(am,{remarkPlugins:[Gp],components:{h1:({children:e})=>Rt.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>Rt.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>Rt.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>Rt.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>Rt.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>Rt.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>Rt.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...n})=>e?Rt.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...n,children:t}):Rt.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})=>Rt.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>Rt.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>Rt.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>Rt.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>Rt.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}function eh(){const[e,t]=a(!1),[n,r]=a(""),{messages:s,isLoading:o,error:l,sendMessage:u}=jl(),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 Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(Bt,{onClick:()=>t(!e),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e?Rt.jsx(N,{className:"h-6 w-6"}):Rt.jsx(Ve,{className:"h-6 w-6"})}),e&&Rt.jsxs(Ht,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[Rt.jsxs(qt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[Rt.jsx(Wt,{className:"text-lg font-semibold",children:"Chat Assistant"}),Rt.jsx(Bt,{variant:"ghost",size:"icon",onClick:()=>t(!1),className:"h-8 w-8",children:Rt.jsx(N,{className:"h-4 w-4"})})]}),Rt.jsxs(Kt,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[Rt.jsx(qa,{ref:d,className:"flex-1 px-4",children:Rt.jsxs("div",{className:"space-y-4 py-4",children:[s.map(e=>Rt.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:Rt.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?Rt.jsx(Zp,{content:e.content}):Rt.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),o&&Rt.jsx("div",{className:"flex justify-start",children:Rt.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:Rt.jsxs("div",{className:"flex space-x-2",children:[Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),l&&Rt.jsx("div",{className:"text-center text-sm text-destructive py-2",children:l})]})}),Rt.jsx("div",{className:"border-t p-4",children:Rt.jsxs("div",{className:"flex space-x-2",children:[Rt.jsx($t,{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"}),Rt.jsx(Bt,{onClick:m,disabled:o||!n.trim(),size:"icon",children:Rt.jsx(He,{className:"h-4 w-4"})})]})})]})]})]})}export{Cr as AUTH_CONFIG,Cs as Accordion,Es as AccordionContent,Is as AccordionItem,Ts as AccordionTrigger,Xo as ActionButton,Oa as ActionMenuItems,gs as Alert,ys as AlertDescription,Wr as AlertDialog,ta as AlertDialogAction,na as AlertDialogCancel,Xr as AlertDialogContent,ea as AlertDialogDescription,Gr as AlertDialogFooter,Jr as AlertDialogHeader,Yr as AlertDialogOverlay,Kr as AlertDialogPortal,Zr as AlertDialogTitle,Qr as AlertDialogTrigger,xs as AlertTitle,fl as AppHeader,kl as AppLayout,wl as AppSidebar,Ps as AspectRatio,br as AuthErrorInterceptor,Ur as AuthProvider,Br as AuthService,As as Avatar,_s as AvatarFallback,Rs as AvatarImage,Cn as Badge,Ga as BaseForm,Ds as Breadcrumb,Bs as BreadcrumbEllipsis,zs as BreadcrumbItem,Ls as BreadcrumbLink,Os as BreadcrumbList,Fs as BreadcrumbPage,Ms as BreadcrumbSeparator,es as BulkActionBar,Bt as Button,Ir as CRUD_CONFIG,Js as Calendar,bs as CallbackPage,Ht as Card,Kt as CardContent,Qt as CardDescription,Yt as CardFooter,qt as CardHeader,pa as CardSkeleton,Wt as CardTitle,eh as ChatbotPage,Nn as Checkbox,Gs as Collapsible,ei as CollapsibleContent,Zs as CollapsibleTrigger,Ha as ColorPicker,ti as Command,ni as CommandDialog,si as CommandEmpty,ii as CommandGroup,ri as CommandInput,li as CommandItem,ai as CommandList,oi as CommandSeparator,ci as CommandShortcut,Jo as CrudCards,is as CrudPageInternal,Fa as CrudTable,ui as DataList,ra as DeleteConfirmationDialog,Xt as Dialog,Zt as DialogClose,tn as DialogContent,sn as DialogDescription,rn as DialogFooter,nn as DialogHeader,en as DialogOverlay,Gt as DialogPortal,an as DialogTitle,Jt as DialogTrigger,va as DropdownMenu,Pa as DropdownMenuCheckboxItem,Ta as DropdownMenuContent,ka as DropdownMenuGroup,Ea as DropdownMenuItem,Ra as DropdownMenuLabel,Na as DropdownMenuPortal,Sa as DropdownMenuRadioGroup,Aa as DropdownMenuRadioItem,_a as DropdownMenuSeparator,Da as DropdownMenuShortcut,ja as DropdownMenuSub,Ia as DropdownMenuSubContent,Ca as DropdownMenuSubTrigger,wa as DropdownMenuTrigger,ba as EmptyState,Ya as EntitySelect,Nl as ErrorBoundary,ss as FilterBar,on as Form,pn as FormControl,cn as FormField,fn as FormItem,mn as FormLabel,hn as FormMessage,ha as FormSkeleton,mi as Grid,ga as HeaderSkeleton,Ka as IconPicker,$t as Input,Vt as Label,En as LoadingState,vs as LoginPage,Dr as MESSAGES,Zp as MarkdownMessage,ll as NavigationProvider,pi as PageBreadcrumb,gi as Pagination,xi as PaginationContent,ki as PaginationEllipsis,yi as PaginationItem,bi as PaginationLink,wi as PaginationNext,vi as PaginationPrevious,nl as PlaceService,sl as PlacesPage,Ba as Popover,Ua as PopoverContent,$a as PopoverTrigger,Ni as Progress,ps as ProtectedRoute,Pr as QUERY_KEYS,Sr as QualiexEnrichmentService,wr as QualiexErrorInterceptor,Ja as QualiexUserField,ji as RadioGroup,Si as RadioGroupItem,Tr as SEARCH_CONFIG,qa as ScrollArea,Wa as ScrollBar,gn as Select,wn as SelectContent,kn as SelectItem,yn as SelectTrigger,xn as SelectValue,Ci as Separator,Ii as Sheet,Ei as SheetClose,_i as SheetContent,Li as SheetDescription,Oi as SheetFooter,Di as SheetHeader,Ai as SheetOverlay,Pi as SheetPortal,zi as SheetTitle,Ti as SheetTrigger,Wi as Sidebar,eo as SidebarContent,Gi as SidebarFooter,to as SidebarGroup,ro as SidebarGroupAction,ao as SidebarGroupContent,no as SidebarGroupLabel,Ji as SidebarHeader,Xi as SidebarInput,Yi as SidebarInset,so as SidebarMenu,co as SidebarMenuAction,uo as SidebarMenuBadge,lo as SidebarMenuButton,io as SidebarMenuItem,fo as SidebarMenuSkeleton,mo as SidebarMenuSub,ho as SidebarMenuSubButton,po as SidebarMenuSubItem,qi as SidebarProvider,Ki as SidebarRail,Zi as SidebarSeparator,xa as SidebarSkeleton,Qi as SidebarTrigger,fa as Skeleton,go as Slider,xo as SonnerToaster,Tn as Spinner,as as Stack,Lo as Switch,Ho as TabPageContent,Vo as TabPageHeader,Uo as TabPageLayout,aa as Table,ia as TableBody,da as TableCaption,ua as TableCell,oa as TableFooter,ca as TableHead,sa as TableHeader,la as TableRow,za as TableRowActions,ma as TableSkeleton,Fo as Tabs,$o as TabsContent,Mo as TabsList,Bo as TabsTrigger,jn as Textarea,Un as Toast,Vn as ToastAction,Hn as ToastClose,Wn as ToastDescription,Mn as ToastProvider,qn as ToastTitle,Bn as ToastViewport,Qn as Toaster,Wo as Toggle,Ko as ToggleGroup,Yo as ToggleGroupItem,rr as TokenManager,Yn as TokenService,Mi as Tooltip,$i as TooltipContent,Fi as TooltipProvider,Bi as TooltipTrigger,gl as assets,Sn as badgeVariants,Mt as buttonVariants,Dt as cn,os as createCrudPage,Zo as createCrudRoutingConfig,Go as createRoutingHandlers,Lr as createService,ls as createSimpleSaveHandler,qr as createSimpleService,fs as crudPresets,Ft as debounce,ir as errorService,Lt as formatCurrency,zt as formatDatetime,cs as generateCrudConfig,Rr as getQualiexConfig,mr as getSupabaseClient,_t as handleExternalLink,Er as isDevEnvironment,xl as logoSrc,rl as placeService,jr as qualiexApi,_r as setQualiexConfig,Ss as setupQualiexCore,yl as smallLogoSrc,Ln as toast,qo as toggleVariants,Ot as trimTextFields,ml as useActiveModules,Vr as useAuth,Ma as useBaseForm,Hr as useCrud,dl as useDebounce,cl as useNavigation,jl as useOpenAIChat,js as usePageMetadata,ul as usePageTitle,pl as usePermissionQuery,Xa as useQualiexUsers,hi as useRouteBreadcrumbs,Hi as useSidebar,Fn as useToast,ms as withPreset};
|
|
10
|
+
*/function _t(){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,S,C,I,P=Object.assign,T=0;function E(){}E.__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 D,z=!1,O="function"==typeof WeakMap?WeakMap:Map;function L(e,t){if(!e||z)return"";var n,r=D.get(e);if(void 0!==r)return r;z=!0;var a,s=Error.prepareStackTrace;Error.prepareStackTrace=void 0,a=_.current,_.current=null,function(){if(0===T){w=console.log,N=console.info,k=console.warn,j=console.error,S=console.group,C=console.groupCollapsed,I=console.groupEnd;var e={configurable:!0,enumerable:!0,value:E,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{z=!1,_.current=a,function(){if(0===--T){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:S}),groupCollapsed:P({},e,{value:C}),groupEnd:P({},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?R(f):"";return"function"==typeof e&&D.set(e,m),m}function F(e,t,n){if(null==e)return"";if("function"==typeof e)return L(e,function(e){var t=e.prototype;return!(!t||!t.isReactComponent)}(e));if("string"==typeof e)return R(e);switch(e){case u:return R("Suspense");case d:return R("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case c:return L(e.render,!1);case f:return F(e.type,t,n);case m:var r=e,a=r._payload,s=r._init;try{return F(s(a),t,n)}catch(i){}}return""}D=new O;var M=Object.prototype.hasOwnProperty,U={},B=g.ReactDebugCurrentFrame;function $(e){if(e){var t=e._owner,n=F(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=F(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 S=t.children;if(void 0!==S)if(h)if(q(S)){for(var C=0;C<S.length;C++)ie(S[C],e);Object.freeze&&Object.freeze(S)}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(S,e)}if(M.call(t,"key")){var I=v(e),P=Object.keys(t).filter(function(e){return"key"!==e}),T=P.length>0?"{key: someKey, "+P.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,P.length>0?"{"+P.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)};At.Fragment=a,At.jsx=ue,At.jsxs=de}()),At}var Rt=(Et||(Et=1,"production"===process.env.NODE_ENV?It.exports=function(){if(Ct)return Pt;Ct=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}():It.exports=_t()),It.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"})}`},Ft=e=>null==e?"R$ 0,00":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(e),Mt=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}},Ut=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"}}),Bt=e.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...a},s)=>{const i=r?d:"button";return Rt.jsx(i,{className:zt(Ut({variant:t,size:n,className:e})),ref:s,...a})});Bt.displayName="Button";const $t=t.forwardRef(({variant:e="default",className:t,children:n,...r},a)=>Rt.jsx(Bt,{ref:a,variant:"action",size:"sm",className:zt("h-7 px-2 text-xs",t),...r,children:n||Rt.jsx(w,{size:12})}));$t.displayName="ActionButton";const Vt=e.forwardRef(({className:e,type:t,...n},r)=>Rt.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}));Vt.displayName="Input";const qt=m("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ht=e.forwardRef(({className:e,...t},n)=>Rt.jsx(qe.Root,{ref:n,className:zt(qt(),e),...t}));Ht.displayName=qe.Root.displayName;const Wt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));Wt.displayName="Card";const Qt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("flex flex-col space-y-1.5 p-6",e),...t}));Qt.displayName="CardHeader";const Kt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("h3",{ref:n,className:zt("text-2xl font-semibold leading-none tracking-tight",e),...t}));Kt.displayName="CardTitle";const Yt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("p",{ref:n,className:zt("text-sm text-muted-foreground",e),...t}));Yt.displayName="CardDescription";const Jt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("p-6 pt-0",e),...t}));Jt.displayName="CardContent";const Xt=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("flex items-center p-6 pt-0",e),...t}));Xt.displayName="CardFooter";const Gt=He.Root,Zt=He.Trigger,en=He.Portal,tn=He.Close,nn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(He.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}));nn.displayName=He.Overlay.displayName;const rn=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(en,{children:[Rt.jsx(nn,{}),Rt.jsxs(He.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,Rt.jsxs(He.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:[Rt.jsx(N,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));rn.displayName=He.Content.displayName;const an=({className:e,...t})=>Rt.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});an.displayName="DialogHeader";const sn=({className:e,...t})=>Rt.jsx("div",{className:zt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});sn.displayName="DialogFooter";const on=e.forwardRef(({className:e,...t},n)=>Rt.jsx(He.Title,{ref:n,className:zt("text-lg font-semibold leading-none tracking-tight",e),...t}));on.displayName=He.Title.displayName;const ln=e.forwardRef(({className:e,...t},n)=>Rt.jsx(He.Description,{ref:n,className:zt("text-sm text-muted-foreground",e),...t}));ln.displayName=He.Description.displayName;const cn=Qe,un=e.createContext({}),dn=({...e})=>Rt.jsx(un.Provider,{value:{name:e.name},children:Rt.jsx(Ke,{...e})}),fn=()=>{const t=e.useContext(un),n=e.useContext(mn),{getFieldState:r,formState:a}=We(),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}},mn=e.createContext({}),pn=e.forwardRef(({className:t,...n},r)=>{const a=e.useId();return Rt.jsx(mn.Provider,{value:{id:a},children:Rt.jsx("div",{ref:r,className:zt("space-y-2",t),...n})})});pn.displayName="FormItem";const hn=e.forwardRef(({className:e,...t},n)=>{const{error:r,formItemId:a}=fn();return Rt.jsx(Ht,{ref:n,className:zt(r&&"text-destructive",e),htmlFor:a,...t})});hn.displayName="FormLabel";const gn=e.forwardRef(({...e},t)=>{const{error:n,formItemId:r,formDescriptionId:a,formMessageId:s}=fn();return Rt.jsx(d,{ref:t,id:r,"aria-describedby":n?`${a} ${s}`:`${a}`,"aria-invalid":!!n,...e})});gn.displayName="FormControl";e.forwardRef(({className:e,...t},n)=>{const{formDescriptionId:r}=fn();return Rt.jsx("p",{ref:n,id:r,className:zt("text-sm text-muted-foreground",e),...t})}).displayName="FormDescription";const xn=e.forwardRef(({className:e,children:t,...n},r)=>{const{error:a,formMessageId:s}=fn(),i=a?String(a?.message):t;return i?Rt.jsx("p",{ref:r,id:s,className:zt("text-sm font-medium text-destructive",e),...n,children:i}):null});xn.displayName="FormMessage";const yn=Ye.Root,bn=Ye.Value,vn=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(Ye.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,Rt.jsx(Ye.Icon,{asChild:!0,children:Rt.jsx(k,{className:"h-4 w-4 opacity-50"})})]}));vn.displayName=Ye.Trigger.displayName;const wn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ye.ScrollUpButton,{ref:n,className:zt("flex cursor-default items-center justify-center py-1",e),...t,children:Rt.jsx(j,{className:"h-4 w-4"})}));wn.displayName=Ye.ScrollUpButton.displayName;const Nn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ye.ScrollDownButton,{ref:n,className:zt("flex cursor-default items-center justify-center py-1",e),...t,children:Rt.jsx(k,{className:"h-4 w-4"})}));Nn.displayName=Ye.ScrollDownButton.displayName;const kn=e.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>Rt.jsx(Ye.Portal,{children:Rt.jsxs(Ye.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:[Rt.jsx(wn,{}),Rt.jsx(Ye.Viewport,{className:zt("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),Rt.jsx(Nn,{})]})}));kn.displayName=Ye.Content.displayName;e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ye.Label,{ref:n,className:zt("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t})).displayName=Ye.Label.displayName;const jn=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(Ye.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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(Ye.ItemIndicator,{children:Rt.jsx(S,{className:"h-4 w-4"})})}),Rt.jsx(Ye.ItemText,{children:t})]}));jn.displayName=Ye.Item.displayName;e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ye.Separator,{ref:n,className:zt("-mx-1 my-1 h-px bg-muted",e),...t})).displayName=Ye.Separator.displayName;const Sn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Je.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:Rt.jsx(Je.Indicator,{className:zt("flex items-center justify-center text-current"),children:Rt.jsx(S,{className:"h-4 w-4"})})}));Sn.displayName=Je.Root.displayName;const Cn=e.forwardRef(({className:e,...t},n)=>Rt.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}));Cn.displayName="Textarea";const In=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)=>Rt.jsx("div",{ref:r,className:zt(In({variant:t}),e),...n}));Pn.displayName="Badge";const Tn={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"};function En({size:e="md",className:t}){return Rt.jsx(C,{className:zt("animate-spin text-muted-foreground",Tn[e],t)})}function An({isLoading:e,children:t,className:n,type:r="spinner",size:a="md"}){return e?"overlay"===r?Rt.jsxs("div",{className:zt("relative",n),children:[t,Rt.jsx("div",{className:"absolute inset-0 bg-background/50 backdrop-blur-sm flex items-center justify-center z-10",children:Rt.jsx(En,{size:a})})]}):"skeleton"===r?Rt.jsx("div",{className:zt("animate-pulse",n),children:Rt.jsx("div",{className:"bg-muted rounded-md h-full w-full"})}):Rt.jsx("div",{className:zt("flex items-center justify-center py-8",n),children:Rt.jsx(En,{size:a})}):Rt.jsx(Rt.Fragment,{children:t})}let _n=0;const Rn=new Map,Dn=e=>{if(Rn.has(e))return;const t=setTimeout(()=>{Rn.delete(e),Fn({type:"REMOVE_TOAST",toastId:e})},1e6);Rn.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 Fn(e){Ln=zn(Ln,e),On.forEach(e=>{e(Ln)})}function Mn({...e}){const t=(_n=(_n+1)%Number.MAX_SAFE_INTEGER,_n.toString()),n=()=>Fn({type:"DISMISS_TOAST",toastId:t});return Fn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:e=>{e||n()}}}),{id:t,dismiss:n,update:e=>Fn({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function Un(){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:Mn,dismiss:e=>Fn({type:"DISMISS_TOAST",toastId:e})}}const Bn=Xe.Provider,$n=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.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}));$n.displayName=Xe.Viewport.displayName;const Vn=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"}}),qn=e.forwardRef(({className:e,variant:t,...n},r)=>Rt.jsx(Xe.Root,{ref:r,className:zt(Vn({variant:t}),e),...n}));qn.displayName=Xe.Root.displayName;const Hn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.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}));Hn.displayName=Xe.Action.displayName;const Wn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.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:Rt.jsx(N,{className:"h-4 w-4"})}));Wn.displayName=Xe.Close.displayName;const Qn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.Title,{ref:n,className:zt("text-sm font-semibold",e),...t}));Qn.displayName=Xe.Title.displayName;const Kn=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Xe.Description,{ref:n,className:zt("text-sm opacity-90",e),...t}));function Yn(){const{toasts:e}=Un();return Rt.jsxs(Bn,{children:[e.map(function({id:e,title:t,description:n,action:r,...a}){return Rt.jsxs(qn,{...a,children:[Rt.jsxs("div",{className:"grid gap-1",children:[t&&Rt.jsx(Qn,{children:t}),n&&Rt.jsx(Kn,{children:n})]}),r,Rt.jsx(Wn,{})]},e)}),Rt.jsx($n,{})]})}Kn.displayName=Xe.Description.displayName;var Jn=Object.defineProperty;class Xn{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?Jn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(Xn,"LARGE_PAYLOAD_THRESHOLD"+"",1e3);const Gn="qualiex_access_token",Zn="qualiex_id_token",er="supabase_token",tr="oauth_state",nr="oauth_nonce",rr="selected_alias",ar="manual_logout",sr={setAccessToken:e=>localStorage.setItem(Gn,e),getAccessToken:()=>localStorage.getItem(Gn),setIdToken:e=>localStorage.setItem(Zn,e),getIdToken:()=>localStorage.getItem(Zn),getSupabaseToken:()=>localStorage.getItem(er),setOAuthState:e=>sessionStorage.setItem(tr,e),getOAuthState:()=>sessionStorage.getItem(tr),clearOAuthState:()=>sessionStorage.removeItem(tr),setOAuthNonce:e=>sessionStorage.setItem(nr,e),getOAuthNonce:()=>sessionStorage.getItem(nr),clearOAuthNonce:()=>sessionStorage.removeItem(nr),setSelectedAlias:e=>localStorage.setItem(rr,e),getSelectedAlias:()=>localStorage.getItem(rr),clearSelectedAlias:()=>localStorage.removeItem(rr),generateOAuthState:()=>"Lw==",generateOAuthNonce:()=>{const e=new Uint8Array(32);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e)).replace(/[+/=]/g,"")},hasAllTokens:()=>!(!sr.getAccessToken()||!sr.getIdToken()),setSupabaseToken:e=>{localStorage.setItem(er,e),sr._clearValidationCache()},areAllTokensValid:()=>{const e=sr.getAccessToken(),t=sr.getIdToken();if(!e||!t)return!1;try{const n=Xn.validateTokens(e,t);return!!n.idTokenValid&&(n.accessTokenValid,n.idTokenValid)}catch(n){return!1}},clearExpiredTokens:()=>{let e=!1;const t=sr.getAccessToken(),n=sr.getIdToken(),r=sr.getSupabaseToken();return t&&sr.isTokenExpired(t)&&(localStorage.removeItem(Gn),e=!0),n&&sr.isTokenExpired(n)&&(localStorage.removeItem(Zn),e=!0),r&&sr.isTokenExpired(r)&&(localStorage.removeItem(er),e=!0),e},clearAll:()=>{localStorage.removeItem(Gn),localStorage.removeItem(Zn),localStorage.removeItem(er),localStorage.removeItem(rr),localStorage.removeItem(ar),sessionStorage.removeItem(tr),sessionStorage.removeItem(nr)},setManualLogout:()=>localStorage.setItem(ar,"true"),isManualLogout:()=>"true"===localStorage.getItem(ar),clearManualLogout:()=>localStorage.removeItem(ar),isTokenExpired:e=>{try{return Xn.isTokenExpired(e)}catch{return!0}},_validationCache:{isValid:!1,timestamp:0,cacheValidityMs:3e5},_clearValidationCache:()=>{sr._validationCache.isValid=!1,sr._validationCache.timestamp=0},isSupabaseTokenValid:()=>{const e=sr.getSupabaseToken();if(!e)return!1;if(sr.isTokenExpired(e))return sr._clearValidationCache(),sr._handleExpiredToken(),!1;const t=Date.now();return t-sr._validationCache.timestamp<sr._validationCache.cacheValidityMs?sr._validationCache.isValid:(sr._validationCache.isValid=!0,sr._validationCache.timestamp=t,!0)},getValidSupabaseToken:()=>sr.isSupabaseTokenValid()?sr.getSupabaseToken():null,_handleExpiredToken:()=>{sr.clearAll(),"undefined"!=typeof window&&(window.location.href="/")},extractTokenData:()=>{if(!sr.isSupabaseTokenValid())return null;const e=sr.getSupabaseToken();if(!e)return null;try{const t=Xn.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 sr._handleExpiredToken(),null}},getCompanyId:e=>{const t=sr.getAccessToken();if(t)try{const n=Xn.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=sr.extractTokenData();if(n?.companyId)return n.companyId;const r=sr.getIdToken();if(r)try{const t=Xn.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=sr.extractTokenData();return e?.companyId||null},getAllCompaniesData:()=>{const e=sr.getIdToken();if(!e)return[];try{const t=Xn.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 ir=Object.defineProperty,or=(e,t,n)=>((e,t,n)=>t in e?ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const lr=new class{constructor(){or(this,"errors",[]),or(this,"toastCount",0),or(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()){Mn({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){Mn({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 cr=Object.defineProperty,ur=(e,t,n)=>((e,t,n)=>t in e?cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);const dr=import.meta.env.VITE_SUPABASE_URL,fr=import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY,mr=class e{constructor(){ur(this,"client"),ur(this,"currentToken",null),ur(this,"instanceCount",0),this.instanceCount++,this.client=this.createClientWithToken(null)}createClientWithToken(e){const t={apikey:fr};return e&&this.isTokenValid(e)&&(t.Authorization=`Bearer ${e}`),Ge(dr,fr,{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=sr.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 lr.handleError(t instanceof Error?t:"❌ Supabase - Error validating token",!1),!1}}};ur(mr,"instance");let pr=mr;const hr=()=>pr.getInstance().getClient();var gr=Object.freeze({__proto__:null,getSupabaseClient:hr});class xr{static async generateToken(e,t,n,r=!1){try{if(!r){const e=sr.getSupabaseToken();if(e&&sr.isSupabaseTokenValid())return e}const a=hr(),{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?(sr.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 yr=Object.defineProperty,br=(e,t,n)=>((e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class vr{static setLogoutCallback(e){this.onLogoutCallback=e}static async attemptRegeneration(){if(this.isRegenerating)return null;this.isRegenerating=!0;try{const e=sr.getAccessToken(),t=sr.getSelectedAlias();if(!e||!t)return null;const n=await xr.generateToken(e,t,this.onLogoutCallback||void 0,!1);return n?(sr.setSupabaseToken(n),n):null}catch(e){return null}finally{this.isRegenerating=!1}}}br(vr,"isRegenerating",!1),br(vr,"onLogoutCallback",null);class wr{static handleError(e){if(!e)return!1;const t=e.message||e.toString();return!!this.isAuthenticationError(e,t)&&(sr.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 Nr=Object.defineProperty;class kr{static async handleApiError(e){if(!e||this.isRetrying)return!1;const t=e.status||e.statusCode,n=e.message||e.toString();if(401===t||n.includes("401")||n.includes("Unauthorized")){this.isRetrying=!0;try{return await vr.attemptRegeneration()?(this.isRetrying=!1,!0):(wr.handleError(e),this.isRetrying=!1,!1)}catch(r){return wr.handleError(e),this.isRetrying=!1,!1}}return!1}static validateToken(){const e=sr.getAccessToken();return e?sr.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?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,t+"",n)})(kr,"isRetrying",!1);var jr=Object.defineProperty,Sr=(e,t,n)=>((e,t,n)=>t in e?jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const Cr=new class{constructor(){Sr(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=kr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=sr.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 lr.handleError("[QualiexApi] Formato de resposta inesperado",!1),[];r=n}if(!Array.isArray(r))return lr.handleError("[QualiexApi] Resposta não é um array",!1),[];return r.map(this.mapToQualiexUser)}catch(n){if(await kr.handleApiError(n))try{const n=await this.makeApiCall("/api/common/v1/companiesusers",{companyId:t,search:"",filterStatus:"active"},e);let r=n;if(n.data)r=n.data;else{if(!Array.isArray(n))return lr.handleError("[QualiexApi] Formato de resposta inesperado após retry",!1),[];r=n}return Array.isArray(r)?r.map(this.mapToQualiexUser):(lr.handleError("[QualiexApi] Resposta não é um array após retry",!1),[])}catch(r){return lr.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 lr.handleError(a,!0),[]}}async fetchUserById(e,t,n){try{return(await this.fetchUsers(t,n)).find(t=>t.userId===e)||null}catch(r){return lr.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=sr.extractTokenData();return t&&t.companyId?this.fetchUsers(e,t.companyId):[]}};var Ir=Object.freeze({__proto__:null,qualiexApi:Cr});class Pr{static async extractTokenData(){const e=sr.extractTokenData();return e||(lr.handleError("[QualiexEnrichment] ❌ Token Supabase não encontrado",!1),null)}static async enrichWithResponsibleNames(e,t){if(!e||0===e.length)return lr.handleError(`[QualiexEnrichment.${t.entityName}] Nenhuma entidade encontrada`,!1),e;try{const n=await this.extractTokenData();if(!n)return e.map(e=>({...e,responsible_name:e.id_user?"Token não encontrado":null}));const{alias:r,companyId:a}=n;if(!r||!a)return lr.handleError(`[QualiexEnrichment.${t.entityName}] DADOS OBRIGATÓRIOS FALTANDO - alias: ${!!r}, companyId: ${!!a}`,!1),e.map(e=>({...e,responsible_name:e.id_user?`Configuração incompleta (alias: ${!!r}, companyId: ${!!a})`:null}));const s=await Cr.getUsers(r),i=e.map(e=>{if(e.id_user){const t=s.find(t=>t.userId===e.id_user);return{...e,responsible_name:t?.userName||`ID não encontrado: ${e.id_user}`}}return{...e,responsible_name:null}});i.filter(e=>e.responsible_name&&!e.responsible_name.includes("ID não encontrado")&&!e.responsible_name.includes("Erro:")&&!e.responsible_name.includes("Token não encontrado")&&!e.responsible_name.includes("Configuração incompleta")).length;return i}catch(n){return lr.handleError(n instanceof Error?n:`[QualiexEnrichment.${t.entityName}] 💥 ERRO CRÍTICO`),e.map(e=>({...e,responsible_name:e.id_user?`Erro: ${n.message}`:null}))}}}const Tr={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"}},Er={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 Dr={enableUserEnrichment:!1,enableUsersApi:!1};const zr=()=>Dr,Or=e=>{Dr={...Dr,...e}},Lr={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}`}},Fr=["responsible_name"],Mr=e=>Fr.includes(e);function Ur(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(!sr.getValidSupabaseToken())throw new Error("Token de autenticação expirado. Faça login novamente.");return hr().schema(o).from(a)};return{async getAll(e={}){const{search:t="",sortField:n="updated_at",sortDirection:r="desc",page:o=1,limit:d=25,...f}=e;let m=u().select(i||"*",{count:"exact"});m=m.eq("is_removed",!1),Object.entries(f).forEach(([e,t])=>{void 0!==t&&""!==t&&(Array.isArray(t)?m=m.in(e,t):"object"==typeof t&&t&&"operator"in t?"not_null"===t.operator?m=m.not(e,"is",null):"is_null"===t.operator&&(m=m.is(e,null)):null!==t&&(m=m.eq(e,t)))}),m=((e,t)=>{if(t&&s.length>0){const n=s.map(e=>`${e}.ilike.%${t}%`).join(",");return e.or(n)}return e})(m,t);n.includes(".")||Mr(n)||(m=m.order(n,{ascending:"asc"===r})),m=((e,t,n)=>{const r=(t-1)*n,a=r+n-1;return e.range(r,a)})(m,o,d);const{data:p,error:h,count:g}=await m;if(h)throw new Error(`Error fetching ${a}: ${h.message}`);let x=((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}})(p||[],g,o,d);const y=zr();if(c&&y.enableUserEnrichment&&l&&x.data.length>0){if(x.data.some(e=>e.id_user)){const t=n&&n.includes(".");if(n&&(Mr(n)||t)){const a={...e,page:1,limit:500,sortField:void 0,sortDirection:void 0},s=await this.getAll(a);if(!s?.data?.length)return s;const i=await Pr.enrichWithResponsibleNames(s.data,{entityName:l});let c;c=t?i.sort((e,t)=>{const a=n.split(".").reduce((e,t)=>e?.[t],e)||"",s=n.split(".").reduce((e,t)=>e?.[t],t)||"",i=String(a).localeCompare(String(s),"pt-BR");return"asc"===r?i:-i}):((e,t,n)=>[...e].sort((e,r)=>{const a=e[t]||"",s=r[t]||"",i=a.localeCompare(s,"pt-BR",{sensitivity:"base"});return"asc"===n?i:-i}))(i,n,r);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,o,d);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 a=await Pr.enrichWithResponsibleNames(x.data,{entityName:l});x={...x,data:a}}}return x},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 Br=()=>{sr.clearManualLogout()},$r=class{static async initialize(){try{if(!sr.hasAllTokens()||!sr.areAllTokensValid())return sr.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=sr.getAccessToken(),n=sr.getIdToken();Br();const r=this.extractUserFromIdToken(n),a=this.extractCompaniesFromIdToken(n),s=this.extractAliasFromAccessToken(t),i=sr.extractTokenData(),o=i?.alias;let l=null;if(o&&a.some(e=>e.alias===o))l=o;else{const e=sr.getSelectedAlias(),t=e&&a.some(t=>t.alias===e);l=t?e:s||a[0]?.alias||null}!sr.isSupabaseTokenValid()&&l&&await vr.attemptRegeneration();let c=null;if(l){const e=sr.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=sr.getCompanyId(l);if(t)try{const{qualiexApi:e}=await Promise.resolve().then(function(){return Ir}),{getUserPlaceData:n}=await Promise.resolve().then(function(){return wh}),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 gr}),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=sr.generateOAuthState();sr.setOAuthState(e);const t=sr.generateOAuthNonce();sr.setOAuthNonce(t);const n=`${window.location.origin}/callback`,r=new URL(Tr.oauth.authUrl);r.searchParams.set("client_id",Tr.oauth.clientId),r.searchParams.set("response_type",Tr.oauth.responseType),r.searchParams.set("scope",Tr.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(sr.hasAllTokens()){if(!sr.getValidSupabaseToken()){sr.getAccessToken();await vr.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");sr.setAccessToken(r),sr.setIdToken(a),Br();const i=this.extractAliasFromAccessToken(r);if(i)sr.setSelectedAlias(i);else{const e=this.extractCompaniesFromIdToken(a);if(0===e.length)throw new Error("Nenhuma empresa encontrada nos tokens");sr.setSelectedAlias(e[0].alias)}if(!await vr.attemptRegeneration())throw new Error("Falha ao gerar token Supabase");return sr.clearOAuthState(),sr.clearOAuthNonce(),!0}catch(e){throw e}}static logout(){sr.setManualLogout(),sr.clearAll(),window.location.href="/login"}static decodeToken(e){return Xn.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}};vr.setLogoutCallback(()=>{$r.logout()});let Vr=$r;const qr=n(void 0),Hr=({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=Ze()}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=sr.getAccessToken();if(!a)return;const s=await xr.generateToken(a,e.alias,void 0,!0);if(!s)return;sr.setSupabaseToken(s),sr.setSelectedAlias(e.alias);const i=sr.extractTokenData(),o=i?.alias||e.alias,l=i?.companyId||sr.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 Ir}),{getUserPlaceData:n}=await Promise.resolve().then(function(){return wh}),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 Vr.processCallback(),[]),x=s(async()=>{Vr.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&&(sr.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 Vr.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&&(wr.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 Rt.jsx(qr.Provider,{value:w,children:e})},Wr=()=>{const e=r(qr);if(void 0===e)throw new Error("useAuth deve ser usado dentro de um AuthProvider");return e};function Qr({queryKey:e,service:t,entityName:n,searchFields:r,additionalFilters:i={},onSuccess:l}){const[c,u]=rt(),d=Ze(),{alias:f,userId:m}=Wr(),p=c.get("search")||"",h=c.get("sortField")||Er.sorting.defaultField,g=c.get("sortDirection")||Er.sorting.defaultDirection,x=parseInt(c.get("page")||"1"),y=parseInt(c.get("limit")||String(Er.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=et({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=tt({mutationFn:t.create,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Lr.success.created(n)),l?.()},onError:e=>{b.error(`${Lr.error.create(n)}: ${e.message}`)}}),S=tt({mutationFn:({id:e,data:n})=>t.update(e,n),onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Lr.success.updated(n)),l?.()},onError:e=>{b.error(`${Lr.error.update(n)}: ${e.message}`)}}),C=tt({mutationFn:t.delete,onSuccess:()=>{d.invalidateQueries({queryKey:[e]}),b.success(Lr.success.deleted(n))},onError:e=>{b.error(`${Lr.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]),T=s(e=>{I({sortField:e,sortDirection:h===e&&"asc"===g?"desc":"asc",page:1})},[h,g,I]),E=s(e=>{I({page:e})},[I]),A=s(e=>{I({limit:e,page:1})},[I]),_=s(()=>{u({})},[u]),[R,D]=a([]),z=s(e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),O=s(()=>{const e=k?.data?.data.map(e=>e.id)||[];D(t=>t.length===e.length?[]:e)},[k?.data?.data]),L=s(()=>{D([])},[]),F=o(()=>{const e=k?.data?.data.map(e=>e.id)||[];return e.length>0&&R.length===e.length},[R,k?.data?.data]),M=tt({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`),L()},onError:e=>{b.error(`Erro ao deletar itens: ${e.message}`)}}),U=s((e,t)=>{const n=t?t(e):e;e.id?S.mutate({id:e.id,data:n}):j.mutate({...n,alias:f})},[f,j,S]);return{entities:k?.data?.data||[],pagination:{currentPage:k?.data?.currentPage||1,totalPages:k?.data?.totalPages||1,totalItems:k?.data?.totalItems||0,itemsPerPage:k?.data?.itemsPerPage||Er.pagination.defaultPageSize,hasNextPage:k?.data?.hasNextPage||!1,hasPreviousPage:k?.data?.hasPreviousPage||!1},isLoading:k?.isLoading??!0,isCreating:j?.isPending??!1,isUpdating:S?.isPending??!1,isDeleting:C?.isPending??!1,error:k?.error||null,searchTerm:p,sortField:h,sortDirection:g,currentPage:x,itemsPerPage:y,createEntity:j.mutate,updateEntity:(e,t)=>S.mutate({id:e,data:t}),deleteEntity:C.mutate,save:U,handleSearch:P,handleSort:T,handlePageChange:E,handleItemsPerPageChange:A,clearFilters:_,refetch:k.refetch,selectedIds:R,selectItem:z,selectAll:O,clearSelection:L,isAllSelected:F,bulkDelete:M.mutate,isBulkDeleting:M.isPending}}function Kr(e){const t=Ur({tableName:e.tableName,searchFields:e.searchFields||["title"],selectFields:e.selectFields,schemaName:e.schemaName||"central",entityName:e.entityName,enableQualiexEnrichment:e.enableQualiexEnrichment||!0});return{service:t,useCrudHook:(n,r)=>Qr({queryKey:e.tableName,service:{...t,getAll:async(e={})=>await t.getAll({...e})},entityName:e.entityName,additionalFilters:n,onSuccess:r})}}const Yr=ot.Root,Jr=ot.Trigger,Xr=ot.Portal,Gr=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.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}));Gr.displayName=ot.Overlay.displayName;const Zr=e.forwardRef(({className:e,...t},n)=>Rt.jsxs(Xr,{children:[Rt.jsx(Gr,{}),Rt.jsx(ot.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})]}));Zr.displayName=ot.Content.displayName;const ea=({className:e,...t})=>Rt.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});ea.displayName="AlertDialogHeader";const ta=({className:e,...t})=>Rt.jsx("div",{className:zt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});ta.displayName="AlertDialogFooter";const na=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.Title,{ref:n,className:zt("text-lg font-semibold",e),...t}));na.displayName=ot.Title.displayName;const ra=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.Description,{ref:n,className:zt("text-sm text-muted-foreground",e),...t}));ra.displayName=ot.Description.displayName;const aa=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.Action,{ref:n,className:zt(Ut(),e),...t}));aa.displayName=ot.Action.displayName;const sa=e.forwardRef(({className:e,...t},n)=>Rt.jsx(ot.Cancel,{ref:n,className:zt(Ut({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));sa.displayName=ot.Cancel.displayName;const ia=({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?Rt.jsx(Yr,{open:e,onOpenChange:f,children:Rt.jsxs(Zr,{className:"sm:max-w-[500px]",children:[Rt.jsx(ea,{children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-destructive/10 flex items-center justify-center",children:Rt.jsx("span",{className:"text-destructive font-semibold text-sm",children:"!"})}),Rt.jsx("div",{className:"flex-1",children:Rt.jsx(na,{className:"text-lg font-semibold",children:"Confirmar Exclusão"})})]})}),Rt.jsx(ra,{asChild:!0,children:Rt.jsxs("div",{className:"space-y-4",children:[Rt.jsxs("div",{className:"text-sm text-muted-foreground",children:[Rt.jsx("p",{className:"mb-2",children:l?Rt.jsx(Rt.Fragment,{children:"Você está prestes a excluir permanentemente:"}):Rt.jsxs(Rt.Fragment,{children:["Você está prestes a excluir permanentemente o ",s,":"]})}),Rt.jsx("div",{className:"p-3 bg-muted rounded-md border-l-4 border-l-destructive",children:Rt.jsx("p",{className:"font-medium text-foreground",children:l?`${n.title}`:n.title})})]}),Rt.jsx("div",{className:"bg-orange-50 border border-orange-200 rounded-md p-3",children:Rt.jsxs("div",{className:"flex items-start space-x-2",children:[Rt.jsx("div",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-orange-500 flex items-center justify-center mt-0.5",children:Rt.jsx("span",{className:"text-white font-bold text-xs",children:"!"})}),Rt.jsxs("div",{className:"text-sm text-orange-800",children:[Rt.jsx("p",{className:"font-medium mb-1",children:"Atenção!"}),Rt.jsx("p",{children:l?Rt.jsx(Rt.Fragment,{children:"Esta ação não pode ser desfeita. Os itens serão removidos permanentemente do sistema."}):Rt.jsxs(Rt.Fragment,{children:["Esta ação não pode ser desfeita. O ",s," será removido permanentemente do sistema."]})})]})]})}),Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(Ht,{htmlFor:"confirmation",className:"text-sm font-medium",children:l?Rt.jsxs(Rt.Fragment,{children:["Para confirmar, digite o número de itens que serão removidos: ",Rt.jsx("strong",{children:c})]}):Rt.jsxs(Rt.Fragment,{children:["Para confirmar, digite ",Rt.jsxs("strong",{children:['"',n.title,'"']})," abaixo:"]})}),Rt.jsx(Vt,{id:"confirmation",type:l?"number":"text",value:u,onChange:e=>d(e.target.value),placeholder:l?`Digite: ${c}`:`Digite: ${n.title}`,className:"w-full"})]})]})}),Rt.jsxs(ta,{children:[Rt.jsx(sa,{onClick:f,children:"Cancelar"}),Rt.jsx(aa,{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},oa=e.forwardRef(({className:e,...t},n)=>Rt.jsx("table",{ref:n,className:zt("w-full caption-bottom text-sm",e),...t}));oa.displayName="Table";const la=e.forwardRef(({className:e,...t},n)=>Rt.jsx("thead",{ref:n,className:zt("[&_tr]:border-b sticky top-0 z-[1] bg-background",e),...t}));la.displayName="TableHeader";const ca=e.forwardRef(({className:e,...t},n)=>Rt.jsx("tbody",{ref:n,className:zt("[&_tr:last-child]:border-0",e),...t}));ca.displayName="TableBody";const ua=e.forwardRef(({className:e,...t},n)=>Rt.jsx("tfoot",{ref:n,className:zt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));ua.displayName="TableFooter";const da=e.forwardRef(({className:e,...t},n)=>Rt.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}));da.displayName="TableRow";const fa=e.forwardRef(({className:e,...t},n)=>Rt.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}));fa.displayName="TableHead";const ma=e.forwardRef(({className:e,...t},n)=>Rt.jsx("td",{ref:n,className:zt("px-4 py-3 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));ma.displayName="TableCell";const pa=e.forwardRef(({className:e,...t},n)=>Rt.jsx("caption",{ref:n,className:zt("mt-4 text-sm text-muted-foreground",e),...t}));function ha({className:e,...t}){return Rt.jsx("div",{className:zt("animate-pulse rounded-md bg-muted",e),...t})}function ga({rows:e=5,columns:t=4}){return Rt.jsx("div",{className:"w-full",children:Rt.jsxs("div",{className:"rounded-md border",children:[Rt.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:Rt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Rt.jsx(ha,{className:"h-4 w-24"},t))})}),Rt.jsx("div",{children:Array.from({length:e}).map((e,n)=>Rt.jsx("div",{className:"border-b px-4 py-3 last:border-0",children:Rt.jsx("div",{className:"flex space-x-4",children:Array.from({length:t}).map((e,t)=>Rt.jsx(ha,{className:"h-4 w-20"},t))})},n))})]})})}function xa({count:e=3}){return Rt.jsx("div",{className:"space-y-4",children:Array.from({length:e}).map((e,t)=>Rt.jsxs(Wt,{children:[Rt.jsxs(Qt,{children:[Rt.jsx(ha,{className:"h-4 w-3/4"}),Rt.jsx(ha,{className:"h-3 w-1/2"})]}),Rt.jsx(Jt,{children:Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(ha,{className:"h-3 w-full"}),Rt.jsx(ha,{className:"h-3 w-2/3"})]})})]},t))})}function ya({fields:e=4}){return Rt.jsxs("div",{className:"space-y-4",children:[Array.from({length:e}).map((e,t)=>Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(ha,{className:"h-4 w-24"}),Rt.jsx(ha,{className:"h-10 w-full"})]},t)),Rt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Rt.jsx(ha,{className:"h-10 w-20"}),Rt.jsx(ha,{className:"h-10 w-20"})]})]})}function ba(){return Rt.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[Rt.jsxs("div",{className:"flex items-center space-x-3",children:[Rt.jsx(ha,{className:"h-8 w-8 rounded-full"}),Rt.jsx(ha,{className:"h-6 w-32"})]}),Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx(ha,{className:"h-8 w-8"}),Rt.jsx(ha,{className:"h-8 w-24"})]})]})}function va(){return Rt.jsx("div",{className:"w-64 border-r bg-muted/10",children:Rt.jsxs("div",{className:"p-4",children:[Rt.jsx(ha,{className:"h-8 w-32 mb-6"}),Rt.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((e,t)=>Rt.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[Rt.jsx(ha,{className:"h-4 w-4"}),Rt.jsx(ha,{className:"h-4 w-20"})]},t))})]})})}pa.displayName="TableCaption";const wa={default:T,search:P,error:I};function Na({icon:e,title:t,description:n,action:r,className:a,variant:s="default"}){const i=e?()=>e:wa[s];return Rt.jsxs("div",{className:zt("flex flex-col items-center justify-center py-12 px-4 text-center",a),children:[Rt.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4",children:Rt.jsx(i,{className:"h-8 w-8 text-muted-foreground"})}),Rt.jsx("h3",{className:"text-lg font-semibold mb-2",children:t}),n&&Rt.jsx("p",{className:"text-muted-foreground mb-6 max-w-sm",children:n}),r&&Rt.jsx(Bt,{onClick:r.onClick,variant:"outline",children:r.label})]})}const ka=lt.Root,ja=lt.Trigger,Sa=lt.Group,Ca=lt.Portal,Ia=lt.Sub,Pa=lt.RadioGroup,Ta=e.forwardRef(({className:e,inset:t,children:n,...r},a)=>Rt.jsxs(lt.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,Rt.jsx(E,{className:"ml-auto h-4 w-4"})]}));Ta.displayName=lt.SubTrigger.displayName;const Ea=e.forwardRef(({className:e,...t},n)=>Rt.jsx(lt.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}));Ea.displayName=lt.SubContent.displayName;const Aa=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Rt.jsx(lt.Portal,{children:Rt.jsx(lt.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})}));Aa.displayName=lt.Content.displayName;const _a=e.forwardRef(({className:e,inset:t,...n},r)=>Rt.jsx(lt.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}));_a.displayName=lt.Item.displayName;const Ra=e.forwardRef(({className:e,children:t,checked:n,...r},a)=>Rt.jsxs(lt.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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(lt.ItemIndicator,{children:Rt.jsx(S,{className:"h-4 w-4"})})}),t]}));Ra.displayName=lt.CheckboxItem.displayName;const Da=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(lt.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:[Rt.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:Rt.jsx(lt.ItemIndicator,{children:Rt.jsx(A,{className:"h-2 w-2 fill-current"})})}),t]}));Da.displayName=lt.RadioItem.displayName;const za=e.forwardRef(({className:e,inset:t,...n},r)=>Rt.jsx(lt.Label,{ref:r,className:zt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));za.displayName=lt.Label.displayName;const Oa=e.forwardRef(({className:e,...t},n)=>Rt.jsx(lt.Separator,{ref:n,className:zt("-mx-1 my-1 h-px bg-muted",e),...t}));Oa.displayName=lt.Separator.displayName;const La=({className:e,...t})=>Rt.jsx("span",{className:zt("ml-auto text-xs tracking-widest opacity-60",e),...t});La.displayName="DropdownMenuShortcut";const Fa=({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:D,label:r?"Inativar":"Ativar",onClick:n};i.push(e)}if(a&&t){const e={icon:z,label:"Remover",onClick:t,destructive:!0};i.push(e)}return"dropdown"===s?Rt.jsx(Rt.Fragment,{children:i.map((e,t)=>Rt.jsxs(_a,{onClick:e.onClick,className:e.destructive?"text-destructive":"",children:[Rt.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))}):Rt.jsx(Rt.Fragment,{children:i.map((e,t)=>Rt.jsxs(Bt,{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:[Rt.jsx(e.icon,{className:"h-4 w-4 mr-2"}),e.label]},t))})},Ma=({onEdit:e,onDelete:t,canDelete:n=!0,onToggleStatus:r,isActive:a=!0})=>Rt.jsxs(ka,{children:[Rt.jsx(ja,{asChild:!0,children:Rt.jsx(Bt,{variant:"action",size:"sm",className:"h-7 px-2 text-xs",children:Rt.jsx(w,{size:12})})}),Rt.jsx(Aa,{align:"end",children:Rt.jsx(Fa,{onEdit:t=>{t?.stopPropagation(),e?.()},onDelete:e=>{e?.stopPropagation(),t?.()},onToggleStatus:e=>{e?.stopPropagation(),r?.()},isActive:a,canDelete:n,renderAs:"dropdown"})})]}),Ua=l(({checked:e,onCheckedChange:t})=>Rt.jsx(Sn,{checked:e,onCheckedChange:t}),(e,t)=>e.checked===t.checked),Ba=({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?Rt.jsx(xa,{count:3}):0===e.entities.length?Rt.jsx(Na,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"}):Rt.jsxs("div",{className:"space-y-4",children:[e.entities.map(a=>Rt.jsx(Wt,{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:Rt.jsx(Jt,{className:"p-4",children:Rt.jsxs("div",{className:"flex items-start gap-3",children:[c&&Rt.jsx("div",{className:"pt-0.5",onClick:e=>e.stopPropagation(),children:Rt.jsx(Ua,{checked:e.selectedIds.includes(a.id),onCheckedChange:()=>e.selectItem(a.id)})}),Rt.jsxs("div",{className:"flex-1",children:[t.map(e=>Rt.jsxs("div",{className:"flex justify-between items-start mb-2 last:mb-0",children:[Rt.jsxs("span",{className:"text-sm font-medium text-muted-foreground min-w-0 mr-2",children:[e.header,":"]}),Rt.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)&&Rt.jsx("div",{className:"mt-3 pt-3 border-t flex justify-end",onClick:e=>e.stopPropagation(),children:l?l(a):Rt.jsx(Ma,{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&&Rt.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:Rt.jsx(Fa,{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"})})]}):Rt.jsxs("div",{className:"flex flex-col h-full",children:[e.isLoading?Rt.jsx(ga,{rows:5,columns:t.length}):Rt.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:Rt.jsx("div",{className:"flex-1 overflow-auto",children:Rt.jsxs(oa,{className:"table-auto",children:[Rt.jsxs("colgroup",{children:[c&&Rt.jsx("col",{style:{width:"50px"}}),p.map((e,t)=>Rt.jsx("col",{style:e.style},t)),Rt.jsx("col",{style:{width:"100px"}})]}),Rt.jsx(la,{children:Rt.jsxs(da,{children:[c&&Rt.jsx(fa,{className:"w-[50px]",children:Rt.jsx(Ua,{checked:e.isAllSelected,onCheckedChange:e.selectAll})}),t.map(t=>{return Rt.jsx(fa,{className:`${t.className||""} ${t.sortable?"cursor-pointer hover:bg-muted/50":""}`,onClick:t.sortable?()=>e.handleSort(String(t.key)):void 0,children:Rt.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?Rt.jsx(O,{size:14,className:"ml-1 opacity-50"}):"asc"===e.sortDirection?Rt.jsx(L,{size:14,className:"ml-1"}):Rt.jsx(F,{size:14,className:"ml-1"}))]})},String(t.key));var n}),Rt.jsx(fa,{className:"w-[100px] text-center",children:"Ações"})]})}),Rt.jsx(ca,{children:0===e.entities.length?Rt.jsx(da,{children:Rt.jsx(ma,{colSpan:c?t.length+2:t.length+1,className:"h-32",children:Rt.jsx(Na,{title:"Nenhum item encontrado",description:"Não há dados para exibir no momento.",variant:"search"})})}):e.entities.map(r=>Rt.jsxs(da,{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&&Rt.jsx(ma,{onClick:e=>e.stopPropagation(),children:Rt.jsx(Ua,{checked:e.selectedIds.includes(r.id),onCheckedChange:()=>e.selectItem(r.id)})}),t.map(e=>Rt.jsx(ma,{className:e.className,children:e.render?e.render(r):r[e.key]},String(e.key))),Rt.jsx(ma,{className:"text-center",children:l?l(r):Rt.jsx(Ma,{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&&Rt.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:Rt.jsx(Fa,{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 $a(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 Va=ct.Root,qa=ct.Trigger,Ha=e.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>Rt.jsx(ct.Portal,{children:Rt.jsx(ct.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})}));Ha.displayName=ct.Content.displayName;const Wa=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#06b6d4","#84cc16","#f97316","#ec4899","#6b7280"],Qa=({value:e="#3b82f6",onChange:t,label:n})=>Rt.jsxs("div",{className:"space-y-2",children:[n&&Rt.jsx(Ht,{children:n}),Rt.jsxs(Va,{children:[Rt.jsx(qa,{asChild:!0,children:Rt.jsxs(Bt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Rt.jsx("div",{className:"h-4 w-4 rounded border mr-2",style:{backgroundColor:e}}),e]})}),Rt.jsx(Ha,{className:"w-64",children:Rt.jsxs("div",{className:"space-y-3",children:[Rt.jsxs("div",{children:[Rt.jsx(Ht,{htmlFor:"color-input",children:"Cor personalizada"}),Rt.jsx(Vt,{id:"color-input",type:"color",value:e,onChange:e=>t?.(e.target.value),className:"h-10 w-full"})]}),Rt.jsxs("div",{children:[Rt.jsx(Ht,{children:"Cores predefinidas"}),Rt.jsx("div",{className:"grid grid-cols-5 gap-2 mt-2",children:Wa.map(e=>Rt.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))})]})]})})]})]}),Ka=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsxs(ut.Root,{ref:r,className:zt("relative overflow-hidden",e),...n,children:[Rt.jsx(ut.Viewport,{className:"h-full w-full rounded-[inherit]",children:t}),Rt.jsx(Ya,{}),Rt.jsx(ut.Corner,{})]}));Ka.displayName=ut.Root.displayName;const Ya=e.forwardRef(({className:e,orientation:t="vertical",...n},r)=>Rt.jsx(ut.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:Rt.jsx(ut.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}));Ya.displayName=ut.ScrollAreaScrollbar.displayName;const Ja={Star:Ee,Heart:Te,Home:Pe,User:Ie,Settings:Ce,Mail:Se,Phone:je,Calendar:ke,MapPin:Ne,Camera:we,Image:ve,Music:be,Video:ye,Book:xe,Bookmark:ge,Search:P,Filter:he,Edit:_,Trash2:z,Plus:pe,Minus:me,Check:S,X:N,ChevronDown:k,ChevronUp:j,ChevronLeft:fe,ChevronRight:E,ArrowUp:L,ArrowDown:F,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},Xa=({value:e="Star",onChange:t,label:n})=>{const[r,s]=a(""),i=Object.entries(Ja).filter(([e])=>e.toLowerCase().includes(r.toLowerCase())),o=Ja[e]||Ee;return Rt.jsxs("div",{className:"space-y-2",children:[n&&Rt.jsx(Ht,{children:n}),Rt.jsxs(Va,{children:[Rt.jsx(qa,{asChild:!0,children:Rt.jsxs(Bt,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[Rt.jsx(o,{className:"h-4 w-4 mr-2"}),e]})}),Rt.jsx(Ha,{className:"w-80",children:Rt.jsxs("div",{className:"space-y-3",children:[Rt.jsxs("div",{children:[Rt.jsx(Ht,{htmlFor:"icon-search",children:"Buscar ícone"}),Rt.jsx(Vt,{id:"icon-search",placeholder:"Digite o nome do ícone...",value:r,onChange:e=>s(e.target.value)})]}),Rt.jsx(Ka,{className:"h-48",children:Rt.jsx("div",{className:"grid grid-cols-6 gap-2",children:i.map(([n,r])=>Rt.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:Rt.jsx(r,{className:"h-4 w-4"})},n))})})]})})]})]})};function Ga({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?Rt.jsx(ha,{className:zt("h-10 w-full",h)}):s?Rt.jsxs("div",{className:zt("flex items-center gap-2 p-2 border border-destructive/20 rounded-md",h),children:[Rt.jsx(I,{className:"h-4 w-4 text-destructive"}),Rt.jsx("span",{className:"text-sm text-destructive",children:s.message||"Erro ao carregar dados"})]}):Rt.jsxs(yn,{value:e,onValueChange:t,disabled:p||0===n.length,children:[Rt.jsx(vn,{className:h,children:Rt.jsx(bn,{placeholder:m})}),Rt.jsxs(kn,{children:[Rt.jsx("div",{className:"px-2 pb-2",children:Rt.jsxs("div",{className:"relative",children:[Rt.jsx(P,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),Rt.jsx(Vt,{placeholder:c,value:g,onChange:e=>x(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"pl-8 h-9"})]})}),0===y.length?Rt.jsx(jn,{value:"no-items",disabled:!0,children:g?d:u}):y.map(e=>Rt.jsx(jn,{value:i(e),children:l(e)},i(e)))]})]})}const Za=(e={})=>{const{user:t,alias:n}=Wr(),r=zr(),{enabled:a=r.enableUsersApi}=e;return et({queryKey:["qualiex-users",n],queryFn:()=>Cr.getUsers(n),enabled:a&&!!n&&!!t,retry:2,retryDelay:1e3})},es=({value:e="",onChange:t,placeholder:n="Selecionar usuário",disabled:r,className:a,enabled:s})=>{const{data:i=[],isLoading:o,error:l}=Za({enabled:s});return Rt.jsx(Ga,{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 ts({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}=$a(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 Rt.jsxs("div",{className:"space-y-2",children:[e.label,Rt.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 Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Ht,{htmlFor:e.name,children:e.label}),Rt.jsx(es,{value:n||"",onChange:t=>y(e.name,t),placeholder:e.placeholder,disabled:e.disabled,className:r?"border-red-500":""}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"textarea":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Ht,{htmlFor:e.name,children:e.label}),Rt.jsx(Cn,{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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"select":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Ht,{htmlFor:e.name,children:e.label}),Rt.jsxs(yn,{value:String(n),onValueChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,children:[Rt.jsx(vn,{className:`${r?"border-red-500":""} ${e.disabled?"bg-gray-100 cursor-not-allowed":""}`,children:Rt.jsx(bn,{placeholder:e.placeholder})}),Rt.jsx(kn,{children:e.options?.map(e=>Rt.jsx(jn,{value:e.value,children:e.label},e.value))})]}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"date":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Ht,{htmlFor:e.name,children:e.label}),Rt.jsx(Vt,{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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"color":return Rt.jsxs("div",{children:[Rt.jsxs(Ht,{htmlFor:e.name,children:[e.label," ",e.required&&Rt.jsx("span",{className:"text-destructive",children:"*"})]}),Rt.jsx(Vt,{id:e.name,type:"color",value:n||e.defaultValue||"#000000",onChange:t=>y(e.name,t.target.value),className:"h-10"}),r&&Rt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"color-picker":return Rt.jsxs("div",{children:[Rt.jsx(Qa,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"#3b82f6",onChange:t=>y(e.name,t)}),r&&Rt.jsx("p",{className:"text-sm text-destructive mt-1",children:r})]},e.name);case"icon-picker":return Rt.jsxs("div",{children:[Rt.jsx(Xa,{label:`${e.label} ${e.required?"*":""}`,value:n||e.defaultValue||"Star",onChange:t=>y(e.name,t)}),r&&Rt.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 Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[e.label&&Rt.jsx(Ht,{htmlFor:e.name,children:e.label}),Rt.jsx(t,{value:n,onChange:t=>{y(e.name,t),e.onValueChange&&e.onValueChange(t)},disabled:e.disabled,error:r,...e.componentProps||{}}),r&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);case"number":return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Ht,{htmlFor:e.name,children:e.label}),Rt.jsx(Vt,{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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name);default:return Rt.jsxs("div",{className:`space-y-2 ${e.className||""}`,children:[Rt.jsx(Ht,{htmlFor:e.name,children:e.label}),Rt.jsx(Vt,{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&&Rt.jsx("p",{className:"text-sm text-red-500",children:r})]},e.name)}},j=s(()=>{if(!N)return null;if(N.disabled)return Rt.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[Rt.jsx("div",{className:"rounded-full bg-muted p-3 mb-4",children:Rt.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:Rt.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m0 0v2m0-2h2m-2 0H9m3-8V9m0-4V3"})})}),Rt.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Seção não disponível"}),Rt.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 Rt.jsx(e,{formData:g,updateField:y,errors:x,users:f,disabled:N.disabled})}return Rt.jsx("div",{className:"space-y-3",children:N.fields.map(k)})},[N,g,y,x,f,k]),S=Rt.jsxs("div",{className:"flex flex-col max-h-[80vh]",children:[v.length>1&&Rt.jsx("div",{className:"flex-shrink-0 p-4 border-b",children:Rt.jsx("div",{className:"flex space-x-2",children:v.map(e=>Rt.jsx(Bt,{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))})}),Rt.jsx("div",{className:"flex-1 overflow-y-auto px-2 md:px-4 pt-0 pb-2 md:pb-4",children:d?Rt.jsx("div",{className:"flex items-center justify-center py-12",children:Rt.jsx("div",{className:"text-muted-foreground",children:"Carregando dados..."})}):Rt.jsxs("form",{onSubmit:b(i),className:"space-y-3 md:space-y-4",children:[j(),Rt.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[Rt.jsx(Bt,{type:"button",variant:"outline",onClick:l,children:"Cancelar"}),Rt.jsx(Bt,{type:"submit",disabled:d,children:u})]})]})})]});return Rt.jsx(Gt,{open:c,onOpenChange:e=>{!1===e&&!0===c&&l()},children:Rt.jsxs(rn,{className:"max-w-4xl max-h-[90vh] overflow-hidden",children:[Rt.jsxs(an,{className:"bg-primary text-primary-foreground px-6 py-4 -mx-6 -mt-6 mb-4",children:[Rt.jsx(on,{className:"text-white",children:e}),Rt.jsx(ln,{className:"sr-only",children:"Formulário para preenchimento de dados"})]}),S]})})}function ns({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 Rt.jsxs("div",{className:"flex items-center justify-between px-4 py-3 gap-4",children:[Rt.jsx("div",{className:"flex items-center gap-2",children:"full"===i&&Rt.jsxs(Rt.Fragment,{children:[Rt.jsx("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Itens por página"}),Rt.jsxs(yn,{value:String(r),onValueChange:e=>s(Number(e)),children:[Rt.jsx(vn,{className:"h-8 w-[70px]",children:Rt.jsx(bn,{})}),Rt.jsxs(kn,{children:[Rt.jsx(jn,{value:"10",children:"10"}),Rt.jsx(jn,{value:"25",children:"25"}),Rt.jsx(jn,{value:"50",children:"50"}),Rt.jsx(jn,{value:"100",children:"100"})]})]})]})}),Rt.jsxs("div",{className:"text-sm text-muted-foreground text-center hidden sm:block",children:[o,"-",l," de ",n," itens (página ",e," de ",t,")"]}),Rt.jsxs("div",{className:"flex items-center gap-1",children:[Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:()=>a(1),disabled:1===e,className:"h-8 w-8 p-0",children:Rt.jsx(Ae,{size:16})}),Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:()=>a(e-1),disabled:1===e,className:"h-8 w-8 p-0",children:Rt.jsx(fe,{size:16})}),Rt.jsxs("div",{className:"flex items-center gap-1 px-2",children:[Rt.jsx("span",{className:"text-sm font-medium",children:e}),Rt.jsx("span",{className:"text-sm text-muted-foreground",children:"de"}),Rt.jsx("span",{className:"text-sm font-medium",children:t})]}),Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:()=>a(e+1),disabled:e===t,className:"h-8 w-8 p-0",children:Rt.jsx(E,{size:16})}),Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:()=>a(t),disabled:e===t,className:"h-8 w-8 p-0",children:Rt.jsx(_e,{size:16})})]})]})}function rs({manager:e}){return Rt.jsx(ns,{currentPage:e.pagination.currentPage,totalPages:e.pagination.totalPages,totalItems:e.pagination.totalItems,itemsPerPage:e.pagination.itemsPerPage,onPageChange:e.handlePageChange,onItemsPerPageChange:e.handleItemsPerPageChange,variant:"full"})}const as=({selectedCount:e,onClearSelection:t,onBulkDelete:n,customActions:r=[],isLoading:a=!1})=>Rt.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-4 py-2 bg-primary/10 border-b border-primary/20",children:[Rt.jsxs("div",{className:"flex items-center gap-3",children:[Rt.jsxs("span",{className:"text-sm font-medium",children:[e," ",1===e?"item selecionado":"itens selecionados"]}),Rt.jsxs(Bt,{variant:"ghost",size:"sm",onClick:t,className:"h-7 px-2",children:[Rt.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]}),Rt.jsxs("div",{className:"flex items-center gap-2",children:[r.map((e,t)=>{const n=e.icon;return Rt.jsxs(Bt,{variant:e.variant||"outline",size:"sm",onClick:()=>e.action([]),disabled:a,className:"h-7",children:[n&&Rt.jsx(n,{size:14,className:"mr-1"}),e.label]},t)}),n&&Rt.jsxs(Bt,{variant:"destructive",size:"sm",onClick:n,disabled:a,className:"h-7",children:[Rt.jsx(z,{size:14,className:"mr-1"}),"Remover"]})]})]}),ss={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"},is={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"},os={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};function ls({children:e,direction:t="column",gap:n="md",align:r="stretch",justify:a="start",wrap:s=!1,className:i}){return Rt.jsx("div",{className:zt("flex","column"===t?"flex-col":"flex-row",ss[n],is[r],os[a],s&&"flex-wrap",i),children:e})}function cs({manager:e,filters:t,inline:n=!1}){const{isSearchVisible:r}=Wr(),a=e.searchTerm,s=Rt.jsxs(Rt.Fragment,{children:[t.some(e=>"search"===e.type)&&!r&&Rt.jsxs("div",{className:"relative flex-1",children:[Rt.jsx(P,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Rt.jsx(Vt,{placeholder:"Buscar...",value:e.searchTerm,onChange:t=>e.handleSearch(t.target.value),className:"pl-10"})]}),t.filter(e=>"custom"===e.type&&e.component).map((e,t)=>{const r=e.component;return Rt.jsx("div",{className:n?"":"w-full sm:w-auto",children:Rt.jsx(r,{...e.props})},t)}),a&&Rt.jsxs(Bt,{variant:"outline",onClick:e.clearFilters,className:"whitespace-nowrap",children:[Rt.jsx(N,{className:"h-4 w-4 mr-2"}),"Limpar Filtros"]})]});return n?Rt.jsx("div",{className:"flex items-center gap-2",children:s}):Rt.jsx(ls,{direction:"column",gap:"md",className:"mb-6",children:Rt.jsx(ls,{direction:"row",gap:"md",wrap:!0,className:"flex-col sm:flex-row",children:s})})}function us({manager:e,config:t,formSections:n,onSave:r,onToggleStatus:s,defaultSort:o}){const{setSearchVisible:l}=Wr(),[c,u]=rt(),[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 Rt.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[t.enableBulkActions&&e.selectedIds.length>0&&Rt.jsx(as,{selectedCount:e.selectedIds.length,onClearSelection:e.clearSelection,onBulkDelete:()=>{y({isOpen:!0,count:e.selectedIds.length})},customActions:t.bulkActions,isLoading:e.isBulkDeleting}),Rt.jsxs("div",{className:"flex-shrink-0 flex justify-between items-center px-4 py-1.5 bg-muted/50 border-b gap-4",children:[Rt.jsx("div",{className:"flex items-center gap-4",children:Rt.jsxs(Bt,{onClick:()=>{t.onNew?t.onNew():(p(null),f(!0))},children:[Rt.jsx(pe,{size:16,className:"mr-2"}),"Novo"]})}),t.filters&&t.filters.length>0&&Rt.jsx("div",{className:"flex items-center gap-2 flex-1 justify-end",children:Rt.jsx(cs,{manager:e,filters:t.filters,inline:!0})})]}),Rt.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:Rt.jsx(Ba,{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})}),Rt.jsx("div",{className:"flex-shrink-0 border-t bg-background",children:Rt.jsx(rs,{manager:e})}),!t.useCustomRouting&&Rt.jsx(ts,{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"}),Rt.jsx(ia,{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}),Rt.jsx(ia,{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 ds(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};return Rt.jsx(us,{manager:t,config:s,formSections:n.formSections,onSave:r,onToggleStatus:a,defaultSort:n.defaultSort})}}function fs(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 ms(e,t,n={}){const r=[];return Object.keys(t).forEach(e=>{if("id"!==e&&!e.endsWith("_at")){const n=t[e],a={key:e,header:hs(e),label:hs(e),...ps(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 ps(e,t){const n=e.toLowerCase();return n.includes("email")?{type:"email",required:!0}:n.includes("phone")||n.includes("tel")?{type:"tel"}:n.includes("description")||n.includes("content")||n.includes("notes")?{type:"textarea"}:n.includes("status")||n.includes("type")||n.includes("category")?{type:"select",options:[]}:"boolean"==typeof t?{type:"boolean"}:"number"==typeof t?{type:"number"}:t instanceof Date?{type:"date"}:{type:"text"}}function hs(e){return e.replace(/([A-Z])/g," $1").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()).trim()}const gs={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 xs(e,t,n={}){const r=gs[e];return ms(r.title,t,{...r,...n})}const ys=({children:e})=>{const{isAuthenticated:n,isLoading:r}=Wr();if(t.useEffect(()=>{if(!n)return;const e=()=>{sr.areAllTokensValid()||Vr.logout()};e();const t=setInterval(e,3e5);return()=>clearInterval(t)},[n]),t.useEffect(()=>{if(r)return;if(n)return;if(sr.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 Vr.loginDev():Vr.loginProd()})()},[n,r]),r)return Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Wt,{className:"w-full max-w-md",children:[Rt.jsx(Qt,{className:"text-center",children:Rt.jsx(Kt,{className:"text-xl font-semibold",children:"Carregando..."})}),Rt.jsxs(Jt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.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 Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Wt,{className:"w-full max-w-md",children:[Rt.jsx(Qt,{className:"text-center",children:Rt.jsx(Kt,{className:"text-xl font-semibold",children:"Processando..."})}),Rt.jsxs(Jt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens..."})]})]})});try{if(sr.areAllTokensValid())return Rt.jsx(Rt.Fragment,{children:e})}catch{}return Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Wt,{className:"w-full max-w-md",children:[Rt.jsx(Qt,{className:"text-center",children:Rt.jsx(Kt,{className:"text-xl font-semibold",children:"Iniciando..."})}),Rt.jsxs(Jt,{className:"text-center",children:[Rt.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),Rt.jsx("p",{className:"text-muted-foreground",children:_r()?"Fazendo login automático...":"Redirecionando para autenticação..."})]})]})})}return Rt.jsx(Rt.Fragment,{children:e})},bs=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"}}),vs=e.forwardRef(({className:e,variant:t,...n},r)=>Rt.jsx("div",{ref:r,role:"alert",className:zt(bs({variant:t}),e),...n}));vs.displayName="Alert";const ws=e.forwardRef(({className:e,...t},n)=>Rt.jsx("h5",{ref:n,className:zt("mb-1 font-medium leading-none tracking-tight",e),...t}));ws.displayName="AlertTitle";const Ns=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("text-sm [&_p]:leading-relaxed",e),...t}));Ns.displayName="AlertDescription";const ks=()=>{const{processCallback:e}=Wr(),[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?Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Wt,{className:"w-full max-w-md",children:[Rt.jsx(Qt,{className:"text-center",children:Rt.jsxs(Kt,{className:"text-xl font-semibold text-destructive flex items-center justify-center gap-2",children:[Rt.jsx(I,{className:"h-5 w-5"}),"Erro na Autenticação"]})}),Rt.jsxs(Jt,{className:"space-y-4",children:[Rt.jsx(vs,{variant:"destructive",children:Rt.jsx(Ns,{children:t})}),Rt.jsx("div",{className:"text-sm text-muted-foreground",children:Rt.jsx("p",{children:"Se o problema persistir, verifique se a URL de callback está configurada corretamente no provedor OAuth."})}),Rt.jsxs("div",{className:"flex gap-2",children:[Rt.jsx(Bt,{onClick:o,disabled:r,className:"flex-1",children:r?Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(En,{size:"sm",className:"mr-2"}),"Tentando..."]}):Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(Re,{className:"h-4 w-4 mr-2"}),"Tentar Novamente"]})}),Rt.jsx(Bt,{onClick:l,variant:"outline",className:"flex-1",children:"Voltar ao Início"})]})]})]})}):Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Wt,{className:"w-full max-w-md",children:[Rt.jsx(Qt,{className:"text-center",children:Rt.jsx(Kt,{className:"text-xl font-semibold",children:"Processando Autenticação"})}),Rt.jsxs(Jt,{className:"text-center",children:[Rt.jsx("div",{className:"flex justify-center mb-4",children:Rt.jsx(En,{size:"lg"})}),Rt.jsx("p",{className:"text-muted-foreground",children:"Processando tokens e redirecionando..."})]})]})})},js=()=>Rt.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:Rt.jsxs(Wt,{className:"w-full max-w-md",children:[Rt.jsx(Qt,{className:"text-center",children:Rt.jsx(Kt,{className:"text-2xl font-bold",children:"Acesso ao Sistema"})}),Rt.jsxs(Jt,{className:"text-center space-y-4",children:[Rt.jsx("p",{className:"text-muted-foreground",children:"Faça login para acessar o sistema"}),Rt.jsx(Bt,{onClick:async()=>{_r()?await Vr.loginDev():Vr.loginProd()},className:"w-full",size:"lg",children:_r()?"Login Desenvolvimento":"Entrar com Qualiex"})]})]})}),Ss=n(void 0);function Cs({children:e}){const[t,n]=a({});return Rt.jsx(Ss.Provider,{value:{metadata:t,setMetadata:n,clearMetadata:()=>n({})},children:e})}function Is(){const e=r(Ss);if(!e)throw new Error("usePageMetadataContext must be used within PageMetadataProvider");return e}function Ps(e){const{setMetadata:t,clearMetadata:n}=Is();i(()=>(t(e),()=>n()),[e.title,e.subtitle,t,n])}function Ts(e){return{queryClient:e.queryClient||new nt({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}),config:e}}const Es=dt.Root,As=e.forwardRef(({className:e,...t},n)=>Rt.jsx(dt.Item,{ref:n,className:zt("border-b",e),...t}));As.displayName="AccordionItem";const _s=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsx(dt.Header,{className:"flex",children:Rt.jsxs(dt.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,Rt.jsx(k,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));_s.displayName=dt.Trigger.displayName;const Rs=e.forwardRef(({className:e,children:t,...n},r)=>Rt.jsx(dt.Content,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:Rt.jsx("div",{className:zt("pb-4 pt-0",e),children:t})}));Rs.displayName=dt.Content.displayName;const Ds=ft.Root,zs=e.forwardRef(({className:e,...t},n)=>Rt.jsx(mt.Root,{ref:n,className:zt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));zs.displayName=mt.Root.displayName;const Os=e.forwardRef(({className:e,...t},n)=>Rt.jsx(mt.Image,{ref:n,className:zt("aspect-square h-full w-full",e),...t}));Os.displayName=mt.Image.displayName;const Ls=e.forwardRef(({className:e,...t},n)=>Rt.jsx(mt.Fallback,{ref:n,className:zt("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));Ls.displayName=mt.Fallback.displayName;const Fs=e.forwardRef(({...e},t)=>Rt.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));Fs.displayName="Breadcrumb";const Ms=e.forwardRef(({className:e,...t},n)=>Rt.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}));Ms.displayName="BreadcrumbList";const Us=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,className:zt("inline-flex items-center gap-1.5",e),...t}));Us.displayName="BreadcrumbItem";const Bs=e.forwardRef(({asChild:t,className:n,...r},a)=>{const s=t?e.Fragment:"a";return Rt.jsx(s,{ref:a,className:zt("transition-colors hover:text-foreground",n),...r})});Bs.displayName="BreadcrumbLink";const $s=e.forwardRef(({className:e,...t},n)=>Rt.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:zt("font-normal text-foreground",e),...t}));$s.displayName="BreadcrumbPage";const Vs=({children:e,className:t,...n})=>Rt.jsx("li",{role:"presentation","aria-hidden":"true",className:zt("[&>svg]:size-3.5",t),...n,children:e??Rt.jsx(E,{})});Vs.displayName="BreadcrumbSeparator";const qs=({className:e,...t})=>Rt.jsxs("span",{role:"presentation","aria-hidden":"true",className:zt("flex h-9 w-9 items-center justify-center",e),...t,children:[Rt.jsx(De,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"More"})]});function Hs(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}function Ws(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 Qs(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)}}}qs.displayName="BreadcrumbEllipsis";const Ks={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"}},Ys={date:Hs({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:Hs({formats:{full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},defaultWidth:"full"}),dateTime:Hs({formats:{full:"{{date}} 'às' {{time}}",long:"{{date}} 'às' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},Js={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"},Xs={ordinalNumber:(e,t)=>{const n=Number(e);return"week"===t?.unit?n+"ª":n+"º"},era:Ws({values:{narrow:["AC","DC"],abbreviated:["AC","DC"],wide:["antes de cristo","depois de cristo"]},defaultWidth:"wide"}),quarter:Ws({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:Ws({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:Ws({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:Ws({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"})},Gs={ordinalNumber:(Zs={matchPattern:/^(\d+)[ºªo]?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,t={})=>{const n=e.match(Zs.matchPattern);if(!n)return null;const r=n[0],a=e.match(Zs.parsePattern);if(!a)return null;let s=Zs.valueCallback?Zs.valueCallback(a[0]):a[0];return s=t.valueCallback?t.valueCallback(s):s,{value:s,rest:e.slice(r.length)}}),era:Qs({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:Qs({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:Qs({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:Qs({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:Qs({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 Zs;const ei={code:"pt-BR",formatDistance:(e,t,n)=>{let r;const a=Ks[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:Ys,formatRelative:(e,t,n,r)=>{const a=Js[e];return"function"==typeof a?a(t):a},localize:Xs,match:Gs,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ti({className:e,classNames:t,showOutsideDays:n=!0,...r}){return Rt.jsx(pt,{showOutsideDays:n,className:zt("p-3",e),locale:ei,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(Ut({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(Ut({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})=>Rt.jsx(fe,{className:"h-4 w-4"}),IconRight:({...e})=>Rt.jsx(E,{className:"h-4 w-4"})},...r})}ti.displayName="Calendar";const ni=ht.Root,ri=ht.CollapsibleTrigger,ai=ht.CollapsibleContent,si=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));si.displayName="Command";const ii=({children:e,...t})=>Rt.jsx("div",{...t,children:Rt.jsx(si,{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})}),oi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:Rt.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})}));oi.displayName="CommandInput";const li=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));li.displayName="CommandList";const ci=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("py-6 text-center text-sm text-muted-foreground",e),...t}));ci.displayName="CommandEmpty";const ui=e.forwardRef(({className:e,...t},n)=>Rt.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}));ui.displayName="CommandGroup";const di=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,className:zt("-mx-1 h-px bg-border",e),...t}));di.displayName="CommandSeparator";const fi=e.forwardRef(({className:e,disabled:t,onSelect:n,value:r,...a},s)=>Rt.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}));fi.displayName="CommandItem";const mi=({className:e,...t})=>Rt.jsx("span",{className:zt("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});mi.displayName="CommandShortcut";const pi={Root:function({children:e,className:t}){return Rt.jsx("div",{className:zt("space-y-4",t),children:e})},Item:function({children:e,onClick:t,className:n}){return Rt.jsx(Wt,{className:zt("transition-colors",t&&"cursor-pointer hover:bg-muted/50",n),onClick:t,children:Rt.jsx(Jt,{className:"p-4",children:e})})},Field:function({label:e,value:t,className:n}){return Rt.jsxs("div",{className:zt("flex justify-between items-center text-sm",n),children:[Rt.jsxs("span",{className:"text-muted-foreground font-medium",children:[e,":"]}),Rt.jsx("span",{className:"text-foreground",children:t})]})}},hi={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))]"},gi={xs:"gap-1",sm:"gap-2",md:"gap-4",lg:"gap-6",xl:"gap-8"};function xi({children:e,cols:t="auto-fit",gap:n="md",className:r}){return Rt.jsx("div",{className:zt("grid",hi[t],gi[n],r),children:e})}function yi({items:e,maxItems:t=3,className:n}){return e.length>t&&(e[0],e.slice(-(t-1))),e.length,Rt.jsx(Fs,{className:n})}function bi(){const e=at();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 vi=({className:e,...t})=>Rt.jsx("nav",{role:"navigation","aria-label":"pagination",className:zt("mx-auto flex w-full justify-center",e),...t});vi.displayName="Pagination";const wi=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ul",{ref:n,className:zt("flex flex-row items-center gap-1",e),...t}));wi.displayName="PaginationContent";const Ni=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,className:zt("",e),...t}));Ni.displayName="PaginationItem";const ki=({className:e,isActive:t,size:n="icon",...r})=>Rt.jsx("a",{"aria-current":t?"page":void 0,className:zt(Ut({variant:t?"outline":"ghost",size:n}),e),...r});ki.displayName="PaginationLink";const ji=({className:e,...t})=>Rt.jsxs(ki,{"aria-label":"Go to previous page",size:"default",className:zt("gap-1 pl-2.5",e),...t,children:[Rt.jsx(fe,{className:"h-4 w-4"}),Rt.jsx("span",{children:"Previous"})]});ji.displayName="PaginationPrevious";const Si=({className:e,...t})=>Rt.jsxs(ki,{"aria-label":"Go to next page",size:"default",className:zt("gap-1 pr-2.5",e),...t,children:[Rt.jsx("span",{children:"Next"}),Rt.jsx(E,{className:"h-4 w-4"})]});Si.displayName="PaginationNext";const Ci=({className:e,...t})=>Rt.jsxs("span",{"aria-hidden":!0,className:zt("flex h-9 w-9 items-center justify-center",e),...t,children:[Rt.jsx(De,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"More pages"})]});Ci.displayName="PaginationEllipsis";const Ii=e.forwardRef(({className:e,value:t,...n},r)=>Rt.jsx(gt.Root,{ref:r,className:zt("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...n,children:Rt.jsx(gt.Indicator,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Ii.displayName=gt.Root.displayName;const Pi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(xt.Root,{className:zt("grid gap-2",e),...t,ref:n}));Pi.displayName=xt.Root.displayName;const Ti=e.forwardRef(({className:e,...t},n)=>Rt.jsx(xt.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:Rt.jsx(xt.Indicator,{className:"flex items-center justify-center",children:Rt.jsx(A,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Ti.displayName=xt.Item.displayName;const Ei=e.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},a)=>Rt.jsx(yt.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}));Ei.displayName=yt.Root.displayName;const Ai=He.Root,_i=He.Trigger,Ri=He.Close,Di=He.Portal,zi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(He.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}));zi.displayName=He.Overlay.displayName;const Oi=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"}}),Li=e.forwardRef(({side:e="right",className:t,children:n,...r},a)=>Rt.jsxs(Di,{children:[Rt.jsx(zi,{}),Rt.jsxs(He.Content,{ref:a,className:zt(Oi({side:e}),t),...r,children:[n,Rt.jsxs(He.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:[Rt.jsx(N,{className:"h-4 w-4"}),Rt.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Li.displayName=He.Content.displayName;const Fi=({className:e,...t})=>Rt.jsx("div",{className:zt("flex flex-col space-y-2 text-center sm:text-left",e),...t});Fi.displayName="SheetHeader";const Mi=({className:e,...t})=>Rt.jsx("div",{className:zt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Mi.displayName="SheetFooter";const Ui=e.forwardRef(({className:e,...t},n)=>Rt.jsx(He.Title,{ref:n,className:zt("text-lg font-semibold text-foreground",e),...t}));Ui.displayName=He.Title.displayName;const Bi=e.forwardRef(({className:e,...t},n)=>Rt.jsx(He.Description,{ref:n,className:zt("text-sm text-muted-foreground",e),...t}));Bi.displayName=He.Description.displayName;const $i=bt.Provider,Vi=bt.Root,qi=bt.Trigger,Hi=e.forwardRef(({className:e,sideOffset:t=4,...n},r)=>Rt.jsx(bt.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}));Hi.displayName=bt.Content.displayName;const Wi="sidebar:state",Qi=e.createContext(null);function Ki(){const t=e.useContext(Qi);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}const Yi=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(Wi);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(Wi,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 Rt.jsx(Qi.Provider,{value:b,children:Rt.jsx($i,{delayDuration:0,children:Rt.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})})})});Yi.displayName="SidebarProvider";const Ji=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}=Ki();return"none"===n?Rt.jsx("div",{className:zt("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",r),ref:i,...s,children:a}):o?Rt.jsx(Ai,{open:c,onOpenChange:u,...s,children:Rt.jsxs(Li,{"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:[Rt.jsx(Ui,{className:"sr-only",children:"Menu de Navegação"}),Rt.jsx("div",{className:"flex h-full w-full flex-col",children:a})]})}):Rt.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:[Rt.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]")}),Rt.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:Rt.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})})]})});Ji.displayName="Sidebar";const Xi=e.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:a}=Ki();return Rt.jsxs(Bt,{ref:r,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:zt("h-7 w-7",e),onClick:e=>{t?.(e),a()},...n,children:[Rt.jsx(ze,{}),Rt.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});Xi.displayName="SidebarTrigger";const Gi=e.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=Ki();return Rt.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})});Gi.displayName="SidebarRail";const Zi=e.forwardRef(({className:e,...t},n)=>Rt.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}));Zi.displayName="SidebarInset";const eo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Vt,{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}));eo.displayName="SidebarInput";const to=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"header",className:zt("flex flex-col gap-2 p-2",e),...t}));to.displayName="SidebarHeader";const no=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"footer",className:zt("flex flex-col gap-2 p-2",e),...t}));no.displayName="SidebarFooter";const ro=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Ei,{ref:n,"data-sidebar":"separator",className:zt("mx-2 w-auto bg-sidebar-border",e),...t}));ro.displayName="SidebarSeparator";const ao=e.forwardRef(({className:e,...t},n)=>Rt.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}));ao.displayName="SidebarContent";const so=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"group",className:zt("relative flex w-full min-w-0 flex-col p-2",e),...t}));so.displayName="SidebarGroup";const io=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?d:"div";return Rt.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})});io.displayName="SidebarGroupLabel";const oo=e.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const a=t?d:"button";return Rt.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})});oo.displayName="SidebarGroupAction";const lo=e.forwardRef(({className:e,...t},n)=>Rt.jsx("div",{ref:n,"data-sidebar":"group-content",className:zt("w-full text-sm",e),...t}));lo.displayName="SidebarGroupContent";const co=e.forwardRef(({className:e,...t},n)=>Rt.jsx("ul",{ref:n,"data-sidebar":"menu",className:zt("flex w-full min-w-0 flex-col gap-1",e),...t}));co.displayName="SidebarMenu";const uo=e.forwardRef(({className:e,...t},n)=>Rt.jsx("li",{ref:n,"data-sidebar":"menu-item",className:zt("group/menu-item relative",e),...t}));uo.displayName="SidebarMenuItem";const fo=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"}}),mo=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}=Ki(),f=Rt.jsx(l,{ref:o,"data-sidebar":"menu-button","data-size":r,"data-active":t,className:zt(fo({variant:n,size:r}),s),...i});return a?("string"==typeof a&&(a={children:a}),Rt.jsxs(Vi,{children:[Rt.jsx(qi,{asChild:!0,children:f}),Rt.jsx(Hi,{side:"right",align:"center",hidden:"collapsed"!==u||c,...a})]})):f});mo.displayName="SidebarMenuButton";const po=e.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},a)=>{const s=t?d:"button";return Rt.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})});po.displayName="SidebarMenuAction";const ho=e.forwardRef(({className:e,...t},n)=>Rt.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}));ho.displayName="SidebarMenuBadge";const go=e.forwardRef(({className:t,showIcon:n=!1,...r},a)=>{const s=e.useMemo(()=>`${Math.floor(40*Math.random())+50}%`,[]);return Rt.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&&Rt.jsx("div",{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),Rt.jsx("div",{className:"h-4 flex-1 max-w-[--skeleton-width] skeleton-width","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":s}})]})});go.displayName="SidebarMenuSkeleton";const xo=e.forwardRef(({className:e,...t},n)=>Rt.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}));xo.displayName="SidebarMenuSub";const yo=e.forwardRef(({...e},t)=>Rt.jsx("li",{ref:t,...e}));yo.displayName="SidebarMenuSubItem";const bo=e.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...a},s)=>{const i=e?d:"a";return Rt.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})});bo.displayName="SidebarMenuSubButton";const vo=e.forwardRef(({className:e,...t},n)=>Rt.jsxs(vt.Root,{ref:n,className:zt("relative flex w-full touch-none select-none items-center",e),...t,children:[Rt.jsx(vt.Track,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:Rt.jsx(vt.Range,{className:"absolute h-full bg-primary"})}),Rt.jsx(vt.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"})]}));vo.displayName=vt.Root.displayName;const wo=({...e})=>{const{theme:t="system"}=wt();return Rt.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 No(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),!1===n||!r.defaultPrevented)return t?.(r)}}function ko(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function jo(...t){return e.useCallback(function(...e){return t=>{let n=!1;const r=e.map(e=>{const r=ko(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():ko(e[t],null)}}}}(...t),t)}function So(...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 Co=globalThis?.document?e.useLayoutEffect:()=>{},Io=e[" useInsertionEffect ".trim().toString()]||Co;function Po({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 Io(()=>{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 To=["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),Rt.jsx(i,{...s,ref:t})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{}),Eo="Switch",[Ao]=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 Rt.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}\``)}]},So(a,...n)]}(Eo),[_o,Ro]=Ao(Eo),Do=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=jo(n,e=>p(e)),g=e.useRef(!1),x=!m||(d||!!m.closest("form")),[y,b]=Po({prop:s,defaultProp:i??!1,onChange:u,caller:Eo});return Rt.jsxs(_o,{scope:r,checked:y,disabled:l,children:[Rt.jsx(To.button,{type:"button",role:"switch","aria-checked":y,"aria-required":o,"data-state":Fo(y),"data-disabled":l?"":void 0,disabled:l,value:c,...f,ref:h,onClick:No(t.onClick,e=>{b(e=>!e),x&&(g.current=e.isPropagationStopped(),g.current||e.stopPropagation())})}),x&&Rt.jsx(Lo,{control:m,bubbles:!g.current,name:a,value:c,checked:y,required:o,disabled:l,form:d,style:{transform:"translateX(-100%)"}})]})});Do.displayName=Eo;var zo="SwitchThumb",Oo=e.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Ro(zo,n);return Rt.jsx(To.span,{"data-state":Fo(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});Oo.displayName=zo;var Lo=e.forwardRef(({__scopeSwitch:t,control:n,checked:r,bubbles:a=!0,...s},i)=>{const o=e.useRef(null),l=jo(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 Co(()=>{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]),Rt.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 Fo(e){return e?"checked":"unchecked"}Lo.displayName="SwitchBubbleInput";var Mo=Do,Uo=Oo;const Bo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Mo,{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:Rt.jsx(Uo,{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")})}));Bo.displayName=Mo.displayName;const $o=Nt.Root,Vo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Nt.List,{ref:n,className:zt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));Vo.displayName=Nt.List.displayName;const qo=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Nt.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}));qo.displayName=Nt.Trigger.displayName;const Ho=e.forwardRef(({className:e,...t},n)=>Rt.jsx(Nt.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 Wo({children:e,className:t}){return Rt.jsx("div",{className:zt("flex flex-col h-full",t),children:Rt.jsx(Ka,{className:"flex-1",children:Rt.jsx("div",{className:"space-y-6 p-6",children:e})})})}function Qo({title:e,description:t,actions:n,className:r}){return Rt.jsxs("div",{className:zt("space-y-4",r),children:[Rt.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[Rt.jsxs("div",{className:"space-y-1",children:[Rt.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:e}),t&&Rt.jsx("p",{className:"text-muted-foreground text-sm",children:t})]}),n&&Rt.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:n})]}),Rt.jsx(Ei,{})]})}function Ko({children:e,className:t}){return Rt.jsx("div",{className:zt("space-y-6",t),children:e})}Ho.displayName=Nt.Content.displayName;const Yo=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"}}),Jo=e.forwardRef(({className:e,variant:t,size:n,...r},a)=>Rt.jsx(kt.Root,{ref:a,className:zt(Yo({variant:t,size:n,className:e})),...r}));Jo.displayName=kt.Root.displayName;const Xo=e.createContext({size:"default",variant:"default"}),Go=e.forwardRef(({className:e,variant:t,size:n,children:r,...a},s)=>Rt.jsx(jt.Root,{ref:s,className:zt("flex items-center justify-center gap-1",e),...a,children:Rt.jsx(Xo.Provider,{value:{variant:t,size:n},children:r})}));Go.displayName=jt.Root.displayName;const Zo=e.forwardRef(({className:t,children:n,variant:r,size:a,...s},i)=>{const o=e.useContext(Xo);return Rt.jsx(jt.Item,{ref:i,className:zt(Yo({variant:o.variant||r,size:o.size||a}),t),...s,children:n})});function el({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?Rt.jsx("div",{className:"flex-1 overflow-auto",children:Rt.jsx("div",{className:"p-4 space-y-3",children:[...Array(5)].map((e,t)=>Rt.jsx(ha,{className:"h-12 w-full"},t))})}):0===e.length?Rt.jsx("div",{className:"flex-1 flex items-center justify-center",children:Rt.jsx("div",{className:"text-center text-muted-foreground",children:Rt.jsx("p",{children:c})})}):Rt.jsx("div",{className:"flex-1 overflow-auto",children:Rt.jsxs(oa,{className:u,children:[Rt.jsx(la,{className:"sticky top-0 bg-background z-10",children:Rt.jsxs(da,{children:[d&&Rt.jsx(fa,{className:"w-12",children:Rt.jsx(Sn,{checked:h,onCheckedChange:p,"aria-label":"Selecionar todos"})}),t.map((e,t)=>{return Rt.jsx(fa,{className:e.className,style:{width:g[t]},children:e.sortable&&a?Rt.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?Rt.jsx(O,{size:14,className:"ml-1 opacity-50"}):"asc"===r?Rt.jsx(L,{size:14,className:"ml-1"}):Rt.jsx(F,{size:14,className:"ml-1"}))]}):Rt.jsx("span",{className:"font-medium",children:e.header})},String(e.key));var s}),i&&Rt.jsx(fa,{className:"w-20 text-right",children:"Ações"})]})}),Rt.jsx(ca,{children:e.map(e=>Rt.jsxs(da,{onClick:()=>s?.(e),className:s?"cursor-pointer":"",children:[d&&Rt.jsx(ma,{children:Rt.jsx(Sn,{checked:f.includes(e.id),onCheckedChange:()=>m?.(e.id),onClick:e=>e.stopPropagation(),"aria-label":`Selecionar item ${e.id}`})}),t.map(t=>Rt.jsx(ma,{className:t.className,children:t.render?t.render(e):String(e[t.key]??"-")},String(t.key))),i&&Rt.jsx(ma,{className:"text-right",onClick:e=>e.stopPropagation(),children:i(e)})]},e.id))})]})})}function tl({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: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:z,label:"Remover",onClick:t,variant:"destructive"}),0===c.length?null:"dropdown"===o?Rt.jsxs(ka,{children:[Rt.jsx(ja,{asChild:!0,children:Rt.jsx(Bt,{variant:"ghost",size:"compact"===l?"sm":"default",className:"compact"===l?"h-7 px-2":"",children:Rt.jsx(w,{size:"compact"===l?14:16})})}),Rt.jsx(Aa,{align:"end",className:"bg-background",children:c.map((e,t)=>Rt.jsxs(_a,{onClick:e.onClick,className:"destructive"===e.variant?"text-destructive":"",children:[e.icon&&Rt.jsx(e.icon,{className:"mr-2 h-4 w-4"}),e.label]},t))})]}):Rt.jsx("div",{className:"flex items-center gap-1",children:c.map((e,t)=>Rt.jsxs(Bt,{variant:"destructive"===e.variant?"destructive":"ghost",size:"compact"===l?"sm":"default",onClick:e.onClick,className:"compact"===l?"h-7 px-2":"",children:[e.icon&&Rt.jsx(e.icon,{size:"compact"===l?14:16}),"compact"!==l&&Rt.jsx("span",{className:"ml-1",children:e.label})]},t))})}function nl({searchValue:e="",onSearchChange:t,customFilters:n=[],onClearFilters:r,showClearButton:a=!0,layout:s="horizontal"}){const i=e||n.length>0;return Rt.jsxs("div",{className:`flex ${"vertical"===s?"flex-col":"flex-row items-center"} gap-2 w-full`,children:[t&&Rt.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[Rt.jsx(P,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Rt.jsx(Vt,{type:"text",placeholder:"Buscar...",value:e,onChange:e=>t(e.target.value),className:"pl-9 h-9"})]}),n.map((e,t)=>Rt.jsx("div",{className:"vertical"===s?"w-full":"",children:e},t)),a&&i&&r&&Rt.jsxs(Bt,{variant:"ghost",size:"sm",onClick:r,className:"h-9 px-3 whitespace-nowrap",children:[Rt.jsx(N,{size:14,className:"mr-1"}),"Limpar"]})]})}function rl({data:e,renderCard:t,isLoading:n=!1,emptyMessage:r="Nenhum item encontrado",columns:a,gap:s="md",className:i}){return n?Rt.jsx(xi,{cols:a?String(a):"auto-fit",gap:s,className:i,children:[...Array(6)].map((e,t)=>Rt.jsx(ha,{className:"h-48 w-full"},t))}):0===e.length?Rt.jsx("div",{className:"flex items-center justify-center p-8",children:Rt.jsx("div",{className:"text-center text-muted-foreground",children:Rt.jsx("p",{children:r})})}):Rt.jsx(xi,{cols:a?String(a):"auto-fit",gap:s,className:i,children:e.map(t)})}function al({manager:e,config:t,onEdit:n,onDelete:r}){return e.isLoading?Rt.jsx(xi,{children:Array.from({length:3}).map((e,t)=>Rt.jsxs(Wt,{children:[Rt.jsxs(Qt,{children:[Rt.jsx(ha,{className:"h-4 w-3/4"}),Rt.jsx(ha,{className:"h-3 w-1/2"})]}),Rt.jsx(Jt,{children:Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(ha,{className:"h-3 w-full"}),Rt.jsx(ha,{className:"h-3 w-2/3"})]})})]},t))}):Rt.jsx(pi.Root,{children:e.entities.map(e=>Rt.jsxs(pi.Item,{onClick:()=>n(e),children:[Rt.jsx(Qt,{className:"pb-3",children:Rt.jsxs("div",{className:"flex items-start justify-between",children:[Rt.jsxs("div",{className:"flex-1 min-w-0",children:[Rt.jsx(Kt,{className:"text-base leading-6 truncate",children:e.title||e.name||"Sem título"}),Rt.jsx(Yt,{className:"text-sm",children:y(new Date(e.created_at),"dd/MM/yyyy HH:mm",{locale:ei})})]}),Rt.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.link&&Rt.jsx(Bt,{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:Rt.jsx(Oe,{className:"h-4 w-4"})}),Rt.jsx("div",{onClick:e=>e.stopPropagation(),children:Rt.jsx(Ma,{onEdit:()=>n(e),onDelete:r?()=>r(e):void 0,canDelete:!!r})})]})]})}),Rt.jsx(Jt,{className:"pt-0",children:Rt.jsx("div",{className:"space-y-2",children:t.cardFields?.map(t=>{const n=e[t.key];return n?Rt.jsx(pi.Field,{label:t.label,value:t.render?t.render(n,e):String(n)},String(t.key)):null})})})]},e.id))})}function sl(e){const t=st();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 il(e,t){const n=sl({basePath:e,newPath:t.newPath,editPath:t.editPath});return{useCustomRouting:!0,onNew:n.onNew,onEdit:n.onEdit}}Zo.displayName=jt.Item.displayName;var ol=Object.defineProperty,ll=(e,t,n)=>((e,t,n)=>t in e?ol(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);const cl=new class{constructor(){ll(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}extractCompanyUserId(e){const t=sr.getAccessToken();if(!t)return null;try{const n=Xn.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=sr.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=sr.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(!kr.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 kr.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 ul=Object.defineProperty,dl=(e,t,n)=>((e,t,n)=>t in e?ul(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,t+"",n);class fl{constructor(){dl(this,"baseUrl",import.meta.env.VITE_QUALIEX_API_URL)}async makeApiCall(e,t,n){const r=kr.validateToken();if(!r.valid)throw new Error(r.message||"Token inválido");const a=sr.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 lr.handleError("[PlaceService] Resposta não é um array",!1),[];const a=r.map(this.mapToPlace.bind(this));return this.buildHierarchy(a)}catch(n){if(await kr.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 lr.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 lr.handleError(a,!0),[]}}async getPlaces(e){const t=sr.extractTokenData();return t&&t.companyId?this.fetchPlaces(e,t.companyId):(lr.handleError("[PlaceService] CompanyId não encontrado no token",!1),[])}}const ml=new fl;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,"symbol"!=typeof t?t+"":t,n);class gl{constructor(e={}){hl(this,"tableName"),hl(this,"schemaName"),this.tableName=e.tableName||"place_managers",this.schemaName=e.schemaName||"public"}async getPlaceManagers(e,t){const n=hr(),{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=hr();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=hr(),{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=hr(),{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 xl=new gl,yl=(e,t=!0)=>{const{alias:n}=Wr(),r=Ze(),{data:a=[],isLoading:s}=et({queryKey:["place-managers",n,e],queryFn:()=>xl.getPlaceManagers(n,e),enabled:t&&!!n&&!!e}),i=tt({mutationFn:t=>xl.setManager(n,e,t),onSuccess:()=>{r.invalidateQueries({queryKey:["place-managers"]}),Mn({title:"Gestor definido com sucesso"})},onError:e=>{Mn({title:"Erro ao definir gestor",description:e.message,variant:"destructive"})}}),o=tt({mutationFn:t=>xl.addMember(n,e,t),onSuccess:()=>{r.invalidateQueries({queryKey:["place-managers"]}),Mn({title:"Membro adicionado com sucesso"})},onError:e=>{Mn({title:"Erro ao adicionar membro",description:e.message,variant:"destructive"})}}),l=tt({mutationFn:t=>xl.removePlaceUser(n,e,t),onSuccess:()=>{r.invalidateQueries({queryKey:["place-managers"]}),Mn({title:"Removido com sucesso"})},onError:e=>{Mn({title:"Erro ao remover",description:e.message,variant:"destructive"})}}),c=a.find(e=>"manager"===e.role),u=a.filter(e=>"member"===e.role);return{managers:a,manager:c,members:u,isLoading:s,setManager:i.mutate,addMember:o.mutate,remove:l.mutate,isSettingManager:i.isPending,isAddingMember:o.isPending,isRemoving:l.isPending}};function bl({place:e,level:t=0}){const[n,r]=a(!1),s=e.subPlaces&&e.subPlaces.length>0,i="is_actived"in e?e.is_actived:e.isActive;return Rt.jsxs("div",{children:[Rt.jsxs(ni,{open:n,onOpenChange:r,children:[Rt.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:[s?Rt.jsxs(ri,{className:"flex items-center gap-2 flex-1",children:[Rt.jsx(E,{className:zt("h-4 w-4 transition-transform shrink-0",n&&"rotate-90")}),Rt.jsx(Le,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Rt.jsx("span",{className:"font-medium",children:e.name}),Rt.jsxs("span",{className:"text-sm text-muted-foreground",children:["(",e.subPlaces.length,")"]})]}):Rt.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Rt.jsx("div",{className:"w-4 shrink-0"}),Rt.jsx(Le,{className:"h-4 w-4 text-muted-foreground shrink-0"}),Rt.jsx("span",{className:"font-medium",children:e.name})]}),Rt.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[Rt.jsxs("div",{className:"flex items-center gap-1.5",children:[Rt.jsx(Fe,{className:"h-3.5 w-3.5 text-muted-foreground"}),Rt.jsx("span",{className:"text-sm text-muted-foreground",children:e.usersIds.length})]}),Rt.jsx(Pn,{variant:i?"default":"secondary",className:"text-xs",children:i?"Ativo":"Inativo"})]})]}),s&&Rt.jsx(ai,{children:e.subPlaces.map(e=>Rt.jsx(bl,{place:e,level:t+1},e.placeId))})]}),0===t&&Rt.jsx(Ei,{})]})}function vl(){const{alias:e}=Wr(),{data:t=[],isLoading:n}=et({queryKey:["places",e],queryFn:()=>ml.getPlaces(e||""),enabled:!!e});return n?Rt.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[Rt.jsxs("div",{className:"space-y-2",children:[Rt.jsx(ha,{className:"h-8 w-64"}),Rt.jsx(ha,{className:"h-4 w-96"})]}),Rt.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[1,2,3].map(e=>Rt.jsx(ha,{className:"h-64 w-full"},e))})]}):Rt.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[Rt.jsxs("div",{children:[Rt.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Locais"}),Rt.jsx("p",{className:"text-muted-foreground",children:"Visualização hierárquica de locais e sublocais da organização"})]}),0===t.length?Rt.jsx(Wt,{children:Rt.jsxs(Jt,{className:"flex flex-col items-center justify-center py-12",children:[Rt.jsx(Le,{className:"h-12 w-12 text-muted-foreground mb-4"}),Rt.jsx("p",{className:"text-muted-foreground",children:"Nenhum local encontrado"})]})}):Rt.jsxs(Wt,{children:[Rt.jsx(Qt,{children:Rt.jsx(Kt,{children:"Estrutura de Locais"})}),Rt.jsx(Jt,{className:"p-0",children:Rt.jsx("div",{children:t.map(e=>Rt.jsx(bl,{place:e},e.placeId))})})]})]})}const wl=({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}=Za(),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 Rt.jsx(Gt,{open:e,onOpenChange:t,children:Rt.jsxs(rn,{className:"max-w-4xl min-w-[800px]",children:[Rt.jsxs(an,{children:[Rt.jsxs(on,{children:["Gerenciar Acesso - ",o]}),Rt.jsx(ln,{children:"Selecione o gestor e os membros que terão acesso a este local"})]}),Rt.jsxs("div",{className:"space-y-4",children:[Rt.jsxs("div",{className:"relative",children:[Rt.jsx(P,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),Rt.jsx(Vt,{placeholder:"Buscar por nome ou email...",value:c,onChange:e=>u(e.target.value),className:"pl-9"})]}),Rt.jsx(Ka,{className:"h-[400px] pr-4",children:p?Rt.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Carregando usuários..."}):0===m.length?Rt.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Nenhum usuário encontrado"}):Rt.jsx("div",{className:"space-y-2",children:m.map(e=>{const t=e.userId===s,a=i.includes(e.userId),o=t||a;return Rt.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card hover:bg-accent/50 transition-colors",children:[Rt.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:Rt.jsxs("div",{className:"flex-1 min-w-0",children:[Rt.jsxs("div",{className:"flex items-center gap-2",children:[Rt.jsx("p",{className:"font-medium truncate",children:e.userName}),t&&Rt.jsxs(Pn,{variant:"default",className:"shrink-0",children:[Rt.jsx(Me,{className:"h-3 w-3 mr-1"}),"Gestor"]}),a&&Rt.jsxs(Pn,{variant:"secondary",className:"shrink-0",children:[Rt.jsx(Fe,{className:"h-3 w-3 mr-1"}),"Membro"]})]}),Rt.jsx("p",{className:"text-sm text-muted-foreground truncate",children:e.userEmail})]})}),Rt.jsxs("div",{className:"flex gap-2 shrink-0 ml-4",children:[!t&&Rt.jsxs(Bt,{size:"sm",variant:"outline",onClick:()=>n(e),className:"whitespace-nowrap",children:[Rt.jsx(Me,{className:"h-3 w-3 mr-1"}),"Tornar Gestor"]}),!o&&Rt.jsxs(Bt,{size:"sm",variant:"secondary",onClick:()=>r(e),className:"whitespace-nowrap",children:[Rt.jsx(Fe,{className:"h-3 w-3 mr-1"}),"Adicionar Membro"]})]})]},e.userId)})})})]})]})})},Nl=({placeId:e,placeName:t})=>{const[n,r]=a(!1),{manager:s,members:i,setManager:o,addMember:l,remove:c,isSettingManager:u,isAddingMember:d,isRemoving:f}=yl(e);return Rt.jsxs(Rt.Fragment,{children:[Rt.jsxs(ka,{children:[Rt.jsx(ja,{asChild:!0,children:Rt.jsx(Bt,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",children:Rt.jsx(w,{className:"h-4 w-4"})})}),Rt.jsxs(Aa,{align:"end",className:"w-56 bg-background z-50",children:[Rt.jsxs(_a,{onClick:()=>r(!0),children:[Rt.jsx(Me,{className:"h-4 w-4 mr-2"}),"Gerenciar Acessos"]}),s&&Rt.jsx(_a,{onClick:()=>c(s.user_id),className:"text-destructive",disabled:f,children:"Remover Gestor"})]})]}),Rt.jsx(wl,{open:n,onOpenChange:r,onSelectManager:e=>{o(e),r(!1)},onSelectMember:l,currentManagerId:s?.user_id,currentMemberIds:i.map(e=>e.user_id),placeName:t,isLoading:u||d})]})},kl=({placeId:e,userCount:t})=>{const{manager:n,isLoading:r}=yl(e);return Rt.jsxs("div",{className:"flex flex-col items-end gap-1",children:[Rt.jsx("span",{className:"text-xs text-muted-foreground",children:r?"Carregando...":n?"Gestor":"Gestores"}),Rt.jsxs("div",{className:"flex items-center gap-1.5",children:[Rt.jsx(Fe,{className:"h-3.5 w-3.5 text-muted-foreground"}),Rt.jsx("span",{className:"text-sm text-muted-foreground",children:t})]})]})},jl=t.memo(({variant:e="card",className:n="",selectedUnit:r,onUnitChange:a})=>{const{user:s,companies:i,alias:o,isAuthenticated:l,logout:c,switchUnit:u}=Wr(),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=()=>Rt.jsxs(Rt.Fragment,{children:[Rt.jsxs("div",{className:"flex items-center space-x-3",children:[Rt.jsx("div",{className:"flex-shrink-0",children:Rt.jsx("div",{className:"w-10 h-10 bg-primary rounded-full flex items-center justify-center",children:Rt.jsx(Ie,{className:"h-5 w-5 text-primary-foreground"})})}),Rt.jsxs("div",{className:"flex-1 min-w-0",children:[Rt.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),Rt.jsxs("p",{className:"text-xs text-muted-foreground",children:["Unidade: ",p?.name||"N/A"]})]})]}),p&&Rt.jsx("div",{className:"mt-3",children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsx(Le,{className:"h-4 w-4 text-muted-foreground"}),Rt.jsx("span",{className:"text-sm font-medium",children:p.name})]})}),g.length>1&&Rt.jsxs("div",{className:"mt-2",children:[Rt.jsxs("p",{className:"text-xs text-muted-foreground mb-1",children:["Unidades disponíveis: ",g.length]}),Rt.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,3).map(e=>Rt.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&&Rt.jsxs(Pn,{variant:"outline",className:"text-xs",children:["+",g.length-3]})]})]})]});return"dropdown"===e?Rt.jsxs(ka,{children:[Rt.jsx(ja,{asChild:!0,children:Rt.jsx(Bt,{variant:"ghost",className:`h-auto p-2 ${n}`,children:Rt.jsxs("div",{className:"flex items-center space-x-2",children:[Rt.jsxs("div",{className:"hidden md:block text-left",children:[Rt.jsx("p",{className:"text-sm font-medium",children:s.name}),Rt.jsx("p",{className:"text-xs text-muted-foreground",children:p?.name||"N/A"})]}),Rt.jsx("div",{className:"w-8 h-8 bg-primary rounded-full flex items-center justify-center",children:Rt.jsx(Ie,{className:"h-4 w-4 text-primary-foreground"})}),Rt.jsx(k,{className:"h-4 w-4"})]})})}),Rt.jsxs(Aa,{className:"w-56 bg-background border border-border shadow-lg z-50",align:"end",children:[Rt.jsxs(Ia,{children:[Rt.jsxs(Ta,{children:[Rt.jsx(Re,{className:"mr-2 h-4 w-4"}),"Alterar Unidade"]}),Rt.jsx(Ea,{children:g.map(e=>Rt.jsxs(_a,{onClick:()=>h(e),className:e.alias===p?.alias?"bg-muted":"",children:[Rt.jsx(Le,{className:"mr-2 h-4 w-4"}),e.name,e.alias===p?.alias&&Rt.jsx(Pn,{variant:"outline",className:"ml-2 text-xs",children:"Atual"})]},e.alias))})]}),Rt.jsx(Oa,{}),Rt.jsxs(_a,{onClick:c,children:[Rt.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]}):Rt.jsxs(Wt,{className:n,children:[Rt.jsx(Qt,{children:Rt.jsx(Kt,{className:"text-lg",children:"Informações do Usuário"})}),Rt.jsxs(Jt,{className:"space-y-4",children:[Rt.jsx(x,{}),Rt.jsx(Ei,{}),Rt.jsxs(Bt,{variant:"outline",onClick:c,size:"sm",className:"w-full",children:[Rt.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Sair"]})]})]})}),Sl=n({});function Cl({children:e,config:t}){const n=o(()=>({navigation:t?.navigation,appName:t?.appName}),[t?.navigation,t?.appName]);return Rt.jsx(Sl.Provider,{value:n,children:e})}function Il(){return r(Sl)}function Pl(){const e=at(),{navigation:t}=Il();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 Tl(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 El=l(function({actions:e}){const t=at(),n=Pl(),{navigation:r,appName:s}=Il(),{metadata:o}=Is(),{companies:l,alias:c,isSearchVisible:u,clearSearch:d,refreshData:f,switchUnit:m}=Wr(),p=c?l?.find(e=>e.alias===c)||l?.[0]||null:l?.[0]||null,[h,g]=rt(),[x,y]=a(()=>h.get("search")||""),[b,v]=Tl(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 Rt.jsx("header",{className:"bg-white border-b border-gray-200 px-2 md:px-4 py-2",children:Rt.jsxs("div",{className:"flex items-center gap-4",children:[Rt.jsxs("div",{className:"flex-shrink-0",children:[Rt.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[Rt.jsx("h1",{className:"text-lg font-semibold text-foreground truncate",children:k}),Rt.jsx(Pn,{variant:"default",className:"bg-primary hover:bg-primary/90 text-primary-foreground text-xs px-2 py-1",children:s||"Módulo"})]}),Rt.jsx("p",{className:"text-sm text-muted-foreground truncate",children:j})]}),u&&Rt.jsxs("div",{className:"flex items-center gap-2 flex-1 max-w-2xl",children:[Rt.jsxs("div",{className:"relative flex-1",children:[Rt.jsx(P,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),Rt.jsx(Vt,{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&&Rt.jsx(Bt,{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:Rt.jsx(N,{size:14})})]}),Rt.jsx(Bt,{variant:"outline",size:"sm",onClick:f,className:"flex-shrink-0 h-10 w-10 p-0",title:"Atualizar dados",children:Rt.jsx(Re,{size:14})})]}),Rt.jsxs("div",{className:"flex-shrink-0 ml-auto flex items-center gap-3",children:[e&&Rt.jsx("div",{className:"flex items-center gap-2",children:e}),Rt.jsx("div",{className:"text-sm",children:Rt.jsx(jl,{variant:"dropdown",selectedUnit:p,onUnitChange:m})})]})]})})}),Al=(e={})=>{const{enabled:t=!0}=e,{alias:n}=Wr();return et({queryKey:["active-modules",n],queryFn:async()=>{if(!n)return[];const e=hr(),{data:t,error:r}=await e.schema("central").from("modules").select("\n id, name, url,\n modules_alias!inner(alias)\n ").eq("modules_alias.alias",n).eq("status","active").order("name");if(r){if(!wr.handleError(r))throw r;return[]}return t||[]},enabled:t&&!!n})},_l=({key:e,enabled:t,checkFn:n,staleTime:r=3e5,gcTime:a=6e5})=>et({queryKey:["permission",e],queryFn:n,enabled:t,staleTime:r,gcTime:a,retry:0,refetchOnWindowFocus:!1}),Rl=import.meta.env.VITE_SUPABASE_PROJECT_ID,Dl={logo:`https://${Rl}.supabase.co/storage/v1/object/public/library-assets/logo.svg`,smallLogo:`https://${Rl}.supabase.co/storage/v1/object/public/library-assets/small.svg`},zl=Dl.logo,Ol=Dl.smallLogo,Ll="forlogic-sidebar-pinned",Fl=()=>{try{const e=localStorage.getItem(Ll);return!!e&&JSON.parse(e)}catch{return!1}};function Ml({config:e}={}){const{state:t,open:n,setOpen:r}=Ki(),s=at(),{alias:o,user:l}=Wr(),[c,u]=a(!1),[d,f]=a(Fl),[m,p]=a(!1);i(()=>{r(!!d||!(!m&&!c))},[d,m,c,r]);const{data:h,isLoading:g,error:x}=Al({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 Rt.jsxs(Ji,{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:[Rt.jsxs(to,{className:"p-0 gap-0",children:[Rt.jsx("div",{className:"flex items-center justify-between h-[34px]",children:n?Rt.jsxs(Rt.Fragment,{children:[Rt.jsx("div",{className:"flex items-center pl-[12px]",children:Rt.jsx("img",{src:Dl.logo,alt:"Logo",className:"h-6 max-w-full object-contain"})}),Rt.jsx("button",{onClick:()=>{const e=!d;f(e),(e=>{try{localStorage.setItem(Ll,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:Rt.jsx(ze,{className:"h-4 w-4"})})]}):Rt.jsx("div",{className:"flex items-center justify-center w-full h-[34px]",children:Rt.jsx("img",{src:Dl.smallLogo,alt:"Logo",className:"h-[34px] w-[34px] object-contain"})})}),Rt.jsx("div",{className:"mt-2 pt-0",children:Rt.jsxs(ka,{onOpenChange:u,children:[Rt.jsx(ja,{asChild:!0,children:n?Rt.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:[Rt.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[Rt.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"}),Rt.jsx("span",{className:"truncate group-data-[collapsible=icon]:hidden",children:e?.appName||"Título do módulo"})]}),Rt.jsx(k,{className:"h-6 w-6 flex-shrink-0 text-muted-foreground"})]}):Rt.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:Rt.jsx(k,{className:"h-6 w-6 text-muted-foreground"})})}),Rt.jsx(Aa,{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?Rt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-muted-foreground",children:[Rt.jsx(C,{className:"h-4 w-4 animate-spin"}),Rt.jsx("span",{className:"text-sm",children:"Carregando módulos..."})]}):x?Rt.jsxs("div",{className:"flex items-center space-x-2 py-3 px-3 text-destructive",children:[Rt.jsx(I,{className:"h-4 w-4"}),Rt.jsx("span",{className:"text-sm",children:"Erro ao carregar módulos"})]}):h&&0!==h.length?Rt.jsx("div",{className:"space-y-2",children:h.map((e,t)=>Rt.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:Rt.jsxs("div",{className:"flex items-center justify-between",children:[Rt.jsx("span",{className:"font-medium text-foreground text-sm",children:e.name}),e.url&&Rt.jsx(Oe,{className:"h-4 w-4 text-muted-foreground"})]})},e.id))}):Rt.jsx("div",{className:"py-3 px-3 text-muted-foreground text-sm",children:"Nenhum módulo disponível"})})]})})]}),Rt.jsx(ao,{children:Rt.jsx(so,{className:"p-0 mt-6",children:Rt.jsx(lo,{children:Rt.jsx(co,{className:"space-y-2",children:Rt.jsx($i,{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}=_l({key:n,enabled:Boolean(e.permissionCheck&&o&&l?.id),checkFn:e.permissionCheck||(()=>Promise.resolve(!0))}),s=e.permissionCheck&&!r,i=a?C:s?J:e.icon;return s||e.complementaryText,Rt.jsx(uo,{children:s||a?Rt.jsxs(Vi,{children:[Rt.jsx(qi,{asChild:!0,children:Rt.jsx(mo,{size:"lg",className:"h-10 opacity-50 cursor-not-allowed",onClick:e=>e.preventDefault(),children:Rt.jsxs("div",{className:"flex w-full items-center gap-3",children:[Rt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Rt.jsx(i,{className:"h-4 w-4 "+(a?"animate-spin":"")})}),Rt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})}),Rt.jsx(Hi,{children:Rt.jsx("p",{children:a?"Verificando acesso...":"Acesso restrito"})})]}):Rt.jsx(mo,{asChild:!0,isActive:y(e.path),size:"lg",className:"h-10",children:Rt.jsxs(it,{to:e.path,className:"flex w-full items-center gap-3",children:[Rt.jsx("span",{className:"grid place-items-center h-[34px] w-[34px] p-[5px]",children:Rt.jsx(i,{className:"h-5 w-4"})}),Rt.jsx("span",{className:"font-medium sidebar-text group-data-[collapsible=icon]:hidden",children:e.label})]})})},e.path)};return Rt.jsx(n,{item:e,index:t},e.path)})})})})})})]})}const Ul=l(function({children:e,sidebar:t,sidebarConfig:n,showHeader:r=!0}){const a=o(()=>t||Rt.jsx(Ml,{config:n}),[t,n]),s=o(()=>({"--sidebar-width":"240px","--sidebar-width-icon":"58px"}),[]);return Rt.jsx(Cl,{config:n,children:Rt.jsx(Cs,{children:Rt.jsx(Yi,{defaultOpen:!1,style:s,children:Rt.jsxs("div",{className:"min-h-screen flex w-full",children:[a,Rt.jsxs("main",{className:"flex-1 flex flex-col h-screen overflow-hidden",children:[r&&Rt.jsx("div",{className:"flex-shrink-0 sticky top-0 z-10 bg-background",children:Rt.jsx(El,{})}),Rt.jsx("div",{className:"flex-1 overflow-y-auto bg-gray-50",children:e})]})]})})})})});class Bl extends u{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){lr.handleError(e,!1)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:Rt.jsx("div",{className:"flex items-center justify-center min-h-screen p-4",children:Rt.jsxs(Wt,{className:"w-full max-w-md",children:[Rt.jsxs(Qt,{className:"text-center",children:[Rt.jsx("div",{className:"flex justify-center mb-4",children:Rt.jsx(Be,{className:"h-12 w-12 text-destructive"})}),Rt.jsx(Kt,{children:"Algo deu errado"})]}),Rt.jsxs(Jt,{className:"text-center space-y-4",children:[Rt.jsx("p",{className:"text-muted-foreground",children:"Ocorreu um erro inesperado. Tente recarregar a página."}),Rt.jsx(Bt,{onClick:()=>window.location.reload(),className:"w-full",children:"Recarregar Página"})]})]})}):this.props.children}}function $l(){const[e,t]=a([]),[n,r]=a(!1),[o,l]=a(null),[c,u]=a(null);i(()=>{d()},[]);const d=async()=>{try{const e=hr(),{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=hr(),{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=hr(),{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=hr(),{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 Vl(){}function ql(){}const Hl=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Wl=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ql={};function Kl(e,t){return(Ql.jsx?Wl:Hl).test(e)}const Yl=/[ \t\n\f\r]/g;function Jl(e){return""===e.replace(Yl,"")}class Xl{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function Gl(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Xl(n,r,t)}function Zl(e){return e.toLowerCase()}Xl.prototype.normal={},Xl.prototype.property={},Xl.prototype.space=void 0;class ec{constructor(e,t){this.attribute=t,this.property=e}}ec.prototype.attribute="",ec.prototype.booleanish=!1,ec.prototype.boolean=!1,ec.prototype.commaOrSpaceSeparated=!1,ec.prototype.commaSeparated=!1,ec.prototype.defined=!1,ec.prototype.mustUseProperty=!1,ec.prototype.number=!1,ec.prototype.overloadedBoolean=!1,ec.prototype.property="",ec.prototype.spaceSeparated=!1,ec.prototype.space=void 0;let tc=0;const nc=cc(),rc=cc(),ac=cc(),sc=cc(),ic=cc(),oc=cc(),lc=cc();function cc(){return 2**++tc}var uc=Object.freeze({__proto__:null,boolean:nc,booleanish:rc,commaOrSpaceSeparated:lc,commaSeparated:oc,number:sc,overloadedBoolean:ac,spaceSeparated:ic});const dc=Object.keys(uc);class fc extends ec{constructor(e,t,n,r){let a=-1;if(super(e,t),mc(this,"space",r),"number"==typeof n)for(;++a<dc.length;){const e=dc[a];mc(this,dc[a],(n&uc[e])===uc[e])}}}function mc(e,t,n){n&&(e[t]=n)}function pc(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new fc(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Zl(r)]=r,n[Zl(s.attribute)]=r}return new Xl(t,n,e.space)}fc.prototype.defined=!0;const hc=pc({properties:{ariaActiveDescendant:null,ariaAtomic:rc,ariaAutoComplete:null,ariaBusy:rc,ariaChecked:rc,ariaColCount:sc,ariaColIndex:sc,ariaColSpan:sc,ariaControls:ic,ariaCurrent:null,ariaDescribedBy:ic,ariaDetails:null,ariaDisabled:rc,ariaDropEffect:ic,ariaErrorMessage:null,ariaExpanded:rc,ariaFlowTo:ic,ariaGrabbed:rc,ariaHasPopup:null,ariaHidden:rc,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ic,ariaLevel:sc,ariaLive:null,ariaModal:rc,ariaMultiLine:rc,ariaMultiSelectable:rc,ariaOrientation:null,ariaOwns:ic,ariaPlaceholder:null,ariaPosInSet:sc,ariaPressed:rc,ariaReadOnly:rc,ariaRelevant:null,ariaRequired:rc,ariaRoleDescription:ic,ariaRowCount:sc,ariaRowIndex:sc,ariaRowSpan:sc,ariaSelected:rc,ariaSetSize:sc,ariaSort:null,ariaValueMax:sc,ariaValueMin:sc,ariaValueNow:sc,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function gc(e,t){return t in e?e[t]:t}function xc(e,t){return gc(e,t.toLowerCase())}const yc=pc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:oc,acceptCharset:ic,accessKey:ic,action:null,allow:null,allowFullScreen:nc,allowPaymentRequest:nc,allowUserMedia:nc,alt:null,as:null,async:nc,autoCapitalize:null,autoComplete:ic,autoFocus:nc,autoPlay:nc,blocking:ic,capture:null,charSet:null,checked:nc,cite:null,className:ic,cols:sc,colSpan:null,content:null,contentEditable:rc,controls:nc,controlsList:ic,coords:sc|oc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:nc,defer:nc,dir:null,dirName:null,disabled:nc,download:ac,draggable:rc,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:nc,formTarget:null,headers:ic,height:sc,hidden:ac,high:sc,href:null,hrefLang:null,htmlFor:ic,httpEquiv:ic,id:null,imageSizes:null,imageSrcSet:null,inert:nc,inputMode:null,integrity:null,is:null,isMap:nc,itemId:null,itemProp:ic,itemRef:ic,itemScope:nc,itemType:ic,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:nc,low:sc,manifest:null,max:null,maxLength:sc,media:null,method:null,min:null,minLength:sc,multiple:nc,muted:nc,name:null,nonce:null,noModule:nc,noValidate:nc,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:nc,optimum:sc,pattern:null,ping:ic,placeholder:null,playsInline:nc,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:nc,referrerPolicy:null,rel:ic,required:nc,reversed:nc,rows:sc,rowSpan:sc,sandbox:ic,scope:null,scoped:nc,seamless:nc,selected:nc,shadowRootClonable:nc,shadowRootDelegatesFocus:nc,shadowRootMode:null,shape:null,size:sc,sizes:null,slot:null,span:sc,spellCheck:rc,src:null,srcDoc:null,srcLang:null,srcSet:null,start:sc,step:null,style:null,tabIndex:sc,target:null,title:null,translate:null,type:null,typeMustMatch:nc,useMap:null,value:rc,width:sc,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ic,axis:null,background:null,bgColor:null,border:sc,borderColor:null,bottomMargin:sc,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:nc,declare:nc,event:null,face:null,frame:null,frameBorder:null,hSpace:sc,leftMargin:sc,link:null,longDesc:null,lowSrc:null,marginHeight:sc,marginWidth:sc,noResize:nc,noHref:nc,noShade:nc,noWrap:nc,object:null,profile:null,prompt:null,rev:null,rightMargin:sc,rules:null,scheme:null,scrolling:rc,standby:null,summary:null,text:null,topMargin:sc,valueType:null,version:null,vAlign:null,vLink:null,vSpace:sc,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:nc,disableRemotePlayback:nc,prefix:null,property:null,results:sc,security:null,unselectable:null},space:"html",transform:xc}),bc=pc({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:lc,accentHeight:sc,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:sc,amplitude:sc,arabicForm:null,ascent:sc,attributeName:null,attributeType:null,azimuth:sc,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:sc,by:null,calcMode:null,capHeight:sc,className:ic,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:sc,diffuseConstant:sc,direction:null,display:null,dur:null,divisor:sc,dominantBaseline:null,download:nc,dx:null,dy:null,edgeMode:null,editable:null,elevation:sc,enableBackground:null,end:null,event:null,exponent:sc,externalResourcesRequired:null,fill:null,fillOpacity:sc,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:oc,g2:oc,glyphName:oc,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:sc,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:sc,horizOriginX:sc,horizOriginY:sc,id:null,ideographic:sc,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:sc,k:sc,k1:sc,k2:sc,k3:sc,k4:sc,kernelMatrix:lc,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:sc,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:sc,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:sc,overlineThickness:sc,paintOrder:null,panose1:null,path:null,pathLength:sc,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ic,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:sc,pointsAtY:sc,pointsAtZ:sc,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:lc,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:lc,rev:lc,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:lc,requiredFeatures:lc,requiredFonts:lc,requiredFormats:lc,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:sc,specularExponent:sc,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:sc,strikethroughThickness:sc,string:null,stroke:null,strokeDashArray:lc,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:sc,strokeOpacity:sc,strokeWidth:null,style:null,surfaceScale:sc,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:lc,tabIndex:sc,tableValues:null,target:null,targetX:sc,targetY:sc,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:lc,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:sc,underlineThickness:sc,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:sc,values:null,vAlphabetic:sc,vMathematical:sc,vectorEffect:null,vHanging:sc,vIdeographic:sc,version:null,vertAdvY:sc,vertOriginX:sc,vertOriginY:sc,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:sc,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:gc}),vc=pc({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()}),wc=pc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:xc}),Nc=pc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),kc={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"},jc=/[A-Z]/g,Sc=/-[a-z]/g,Cc=/^data[-\w.:]+$/i;function Ic(e){return"-"+e.toLowerCase()}function Pc(e){return e.charAt(1).toUpperCase()}const Tc=Gl([hc,yc,vc,wc,Nc],"html"),Ec=Gl([hc,bc,vc,wc,Nc],"svg");var Ac,_c,Rc,Dc={};function zc(){if(Rc)return Dc;Rc=1;var e=Dc&&Dc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Dc,"__esModule",{value:!0}),Dc.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(_c)return Ac;_c=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 Ac=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}()},Ac}());return Dc}var Oc,Lc,Fc,Mc={};function Uc(){if(Oc)return Mc;Oc=1,Object.defineProperty(Mc,"__esModule",{value:!0}),Mc.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 Mc.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))},Mc}var Bc=function(){if(Fc)return Lc;Fc=1;var e=(Lc&&Lc.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(zc()),t=Uc();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,Lc=n}(),$c=St(Bc);const Vc=Hc("end"),qc=Hc("start");function Hc(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 Wc(e){return e&&"object"==typeof e?"position"in e||"type"in e?Kc(e.position):"start"in e||"end"in e?Kc(e):"line"in e||"column"in e?Qc(e):"":""}function Qc(e){return Yc(e&&e.line)+":"+Yc(e&&e.column)}function Kc(e){return Qc(e&&e.start)+"-"+Qc(e&&e.end)}function Yc(e){return e&&"number"==typeof e?e:1}class Jc 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=Wc(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}}Jc.prototype.file="",Jc.prototype.name="",Jc.prototype.reason="",Jc.prototype.message="",Jc.prototype.stack="",Jc.prototype.column=void 0,Jc.prototype.line=void 0,Jc.prototype.ancestors=void 0,Jc.prototype.cause=void 0,Jc.prototype.fatal=void 0,Jc.prototype.place=void 0,Jc.prototype.ruleId=void 0,Jc.prototype.source=void 0;const Xc={}.hasOwnProperty,Gc=new Map,Zc=/[A-Z]/g,eu=new Set(["table","tbody","thead","tfoot","tr"]),tu=new Set(["td","th"]),nu="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ru(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=qc(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?Ec:Tc,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=au(a,e,void 0);return s&&"string"!=typeof s?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function au(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=Ec,e.schema=a);e.ancestors.push(t);const s=cu(e,t.tagName,!1),i=function(e,t){const n={};let r,a;for(a in t.properties)if("children"!==a&&Xc.call(t.properties,a)){const s=lu(e,a,t.properties[a]);if(s){const[a,i]=s;e.tableCellAlignToStyle&&"align"===a&&"string"==typeof i&&tu.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=ou(e,t);eu.has(t.tagName)&&(o=o.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&Jl(t.value):Jl(t));var t}));return su(e,i,s,t),iu(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)}uu(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=Ec,e.schema=a);e.ancestors.push(t);const s=null===t.name?e.Fragment:cu(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];Vl(t.type);const a=t.expression;Vl(a.type);const s=a.properties[0];Vl(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else uu(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];Vl(t.type),s=e.evaluater.evaluateExpression(t.expression)}else uu(e,t.position);else s=null===r.value||r.value;n[a]=s}return n}(e,t),o=ou(e,t);return su(e,i,s,t),iu(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);uu(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return iu(r,ou(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 su(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function iu(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function ou(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:Gc;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=au(e,s,i);void 0!==o&&n.push(o)}return n}function lu(e,t,n){const r=function(e,t){const n=Zl(t);let r=t,a=ec;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Cc.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(Sc,Pc);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!Sc.test(e)){let n=e.replace(jc,Ic);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}a=fc}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 $c(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new Jc("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=nu+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)Xc.call(e,n)&&(t[du(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?kc[r.property]||r.property:r.attribute,n]}}function cu(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,a=-1;for(;++a<e.length;){const t=Kl(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=Kl(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 Xc.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);uu(e)}function uu(e,t){const n=new Jc("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=nu+"#cannot-handle-mdx-estrees-without-createevaluater",n}function du(e){let t=e.replace(Zc,fu);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function fu(e){return"-"+e.toLowerCase()}const mu={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"]},pu={};function hu(e,t){return gu(e,"boolean"!=typeof pu.includeImageAlt||pu.includeImageAlt,"boolean"!=typeof pu.includeHtml||pu.includeHtml)}function gu(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 xu(e.children,t,n)}return Array.isArray(e)?xu(e,t,n):""}function xu(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=gu(e[a],t,n);return r.join("")}const yu=document.createElement("i");function bu(e){const t="&"+e+";";yu.innerHTML=t;const n=yu.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function vu(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 wu(e,t){return e.length>0?(vu(e,e.length,0,t),e):t}const Nu={}.hasOwnProperty;function ku(e){const t={};let n=-1;for(;++n<e.length;)ju(t,e[n]);return t}function ju(e,t){let n;for(n in t){const r=(Nu.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let s;if(a)for(s in a){Nu.call(r,s)||(r[s]=[]);const e=a[s];Su(r[s],Array.isArray(e)?e:e?[e]:[])}}}function Su(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);vu(e,0,0,r)}function Cu(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 Iu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Pu=Uu(/[A-Za-z]/),Tu=Uu(/[\dA-Za-z]/),Eu=Uu(/[#-'*+\--9=?A-Z^-~]/);function Au(e){return null!==e&&(e<32||127===e)}const _u=Uu(/\d/),Ru=Uu(/[\dA-Fa-f]/),Du=Uu(/[!-/:-@[-`{-~]/);function zu(e){return null!==e&&e<-2}function Ou(e){return null!==e&&(e<0||32===e)}function Lu(e){return-2===e||-1===e||32===e}const Fu=Uu(/\p{P}|\p{S}/u),Mu=Uu(/\s/);function Uu(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Bu(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&Tu(e.charCodeAt(n+1))&&Tu(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 $u(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(Lu(r))return e.enter(n),i(r);return t(r)};function i(r){return Lu(r)&&s++<a?(e.consume(r),i):(e.exit(n),t(r))}}const Vu={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"),$u(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)):zu(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),a)}}};const qu={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 vu(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(Hu,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(Hu,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)):zu(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++;vu(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}}},Hu={tokenize:function(e,t,n){return $u(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function Wu(e){return null===e||Ou(e)||Mu(e)?1:Fu(e)?2:void 0}function Qu(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 Ku={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};Yu(d,-o),Yu(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=wu(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=wu(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",a,t]]),l=wu(l,Qu(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=wu(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=wu(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,vu(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=Wu(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=Wu(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 Yu(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ju={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 Pu(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||Tu(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||Tu(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||Au(r)?n(r):(e.consume(r),o)}function l(t){return 64===t?(e.consume(t),c):Eu(t)?(e.consume(t),l):n(t)}function c(e){return Tu(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||Tu(t))&&r++<63){const n=45===t?d:u;return e.consume(t),n}return n(t)}}};const Xu={partial:!0,tokenize:function(e,t,n){return function(t){return Lu(t)?$u(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||zu(e)?t(e):n(e)}}};const Gu={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(Lu(t))return $u(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return a(t)};function a(r){return e.attempt(Gu,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 Lu(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const Zu={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 Du(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const ed={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=Tu,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=Ru,c):(e.enter("characterReferenceValue"),a=7,s=_u,c(t))}function c(o){if(59===o&&i){const a=e.exit("characterReferenceValue");return s!==Tu||bu(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 td={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)}}},nd={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"),Lu(t)?$u(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"),Lu(t)?$u(e,d,"whitespace")(t):d(t)):n(t)}function d(r){return null===r||zu(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"),Lu(t)?$u(e,c,"whitespace")(t):c(t))}function c(n){return null===n||zu(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(td,m,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||zu(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):Lu(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),$u(e,d,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),u)}function d(t){return null===t||zu(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),f(t))}function f(t){return null===t||zu(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&&Lu(t)?$u(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||zu(t)?e.check(td,m,y)(t):(e.enter("codeFlowValue"),x(t))}function x(t){return null===t||zu(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),x)}function y(n){return e.exit("codeFenced"),t(n)}}};const rd={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),$u(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):zu(t)?e.attempt(ad,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||zu(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},ad={partial:!0,tokenize:function(e,t,n){const r=this;return a;function a(t){return r.parser.lazy[r.now().line]?n(t):zu(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):$u(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):zu(e)?a(e):n(e)}}};const sd={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)):zu(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||zu(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 id{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&&od(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),od(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),od(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);od(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);od(this.left,t.reverse())}}}function od(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 ld(e){const t={};let n,r,a,s,i,o,l,c=-1;const u=new id(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,cd(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 vu(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function cd(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 ud={resolve:function(e){return ld(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):zu(t)?e.check(dd,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}}},dd={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"),$u(e,a,"linePrefix")};function a(a){if(null===a||zu(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 fd(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||Au(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||zu(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&&!Ou(a)?u<c&&40===a?(e.consume(a),u++,p):41===a?(e.consume(a),u--,p):null===a||32===a||40===a||Au(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 md(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):zu(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||zu(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!Lu(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function pd(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):zu(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),$u(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||zu(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 hd(e,t){let n;return function r(a){if(zu(a))return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r;if(Lu(a))return $u(e,r,n?"linePrefix":"lineSuffix")(a);return t(a)}}const gd={name:"definition",tokenize:function(e,t,n){const r=this;let a;return function(t){return e.enter("definition"),function(t){return md.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return a=Iu(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 Ou(t)?hd(e,o)(t):o(t)}function o(t){return fd(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(xd,c,c)(t)}function c(t){return Lu(t)?$u(e,u,"whitespace")(t):u(t)}function u(s){return null===s||zu(s)?(e.exit("definition"),r.parser.defined.push(a),t(s)):n(s)}}},xd={partial:!0,tokenize:function(e,t,n){return function(t){return Ou(t)?hd(e,r)(t):n(t)};function r(t){return pd(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function a(t){return Lu(t)?$u(e,s,"whitespace")(t):s(t)}function s(e){return null===e||zu(e)?t(e):n(e)}}};const yd={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return zu(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const bd={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"},vu(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||Ou(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||zu(n)?(e.exit("atxHeading"),t(n)):Lu(n)?$u(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||Ou(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const vd=["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"],wd=["pre","script","style","textarea"],Nd={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):Pu(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):Pu(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:C:f):n(a)}function m(t){return Pu(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}function p(o){if(null===o||47===o||62===o||Ou(o)){const l=47===o,c=i.toLowerCase();return l||s||!wd.includes(c)?vd.includes(i.toLowerCase())?(a=6,l?(e.consume(o),h):r.interrupt?t(o):C(o)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(o):s?g(o):x(o)):(a=1,r.interrupt?t(o):C(o))}return 45===o||Tu(o)?(e.consume(o),i+=String.fromCharCode(o),p):n(o)}function h(a){return 62===a?(e.consume(a),r.interrupt?t:C):n(a)}function g(t){return Lu(t)?(e.consume(t),g):j(t)}function x(t){return 47===t?(e.consume(t),j):58===t||95===t||Pu(t)?(e.consume(t),y):Lu(t)?(e.consume(t),x):j(t)}function y(t){return 45===t||46===t||58===t||95===t||Tu(t)?(e.consume(t),y):b(t)}function b(t){return 61===t?(e.consume(t),v):Lu(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):Lu(t)?(e.consume(t),v):N(t)}function w(t){return t===l?(e.consume(t),l=null,k):null===t||zu(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||Ou(t)?b(t):(e.consume(t),N)}function k(e){return 47===e||62===e||Lu(e)?x(e):n(e)}function j(t){return 62===t?(e.consume(t),S):n(t)}function S(t){return null===t||zu(t)?C(t):Lu(t)?(e.consume(t),S):n(t)}function C(t){return 45===t&&2===a?(e.consume(t),E):60===t&&1===a?(e.consume(t),A):62===t&&4===a?(e.consume(t),z):63===t&&3===a?(e.consume(t),D):93===t&&5===a?(e.consume(t),R):!zu(t)||6!==a&&7!==a?null===t||zu(t)?(e.exit("htmlFlowData"),I(t)):(e.consume(t),C):(e.exit("htmlFlowData"),e.check(kd,O,I)(t))}function I(t){return e.check(jd,P,O)(t)}function P(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),T}function T(t){return null===t||zu(t)?I(t):(e.enter("htmlFlowData"),C(t))}function E(t){return 45===t?(e.consume(t),D):C(t)}function A(t){return 47===t?(e.consume(t),i="",_):C(t)}function _(t){if(62===t){const n=i.toLowerCase();return wd.includes(n)?(e.consume(t),z):C(t)}return Pu(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),_):C(t)}function R(t){return 93===t?(e.consume(t),D):C(t)}function D(t){return 62===t?(e.consume(t),z):45===t&&2===a?(e.consume(t),D):C(t)}function z(t){return null===t||zu(t)?(e.exit("htmlFlowData"),O(t)):(e.consume(t),z)}function O(n){return e.exit("htmlFlow"),t(n)}}},kd={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(Xu,t,n)}}},jd={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(zu(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 Sd={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):Pu(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):Pu(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):zu(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):zu(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):zu(t)?(i=x,_(t)):(e.consume(t),x)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):zu(t)?(i=y,_(t)):(e.consume(t),y)}function b(e){return 62===e?A(e):y(e)}function v(t){return Pu(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||Tu(t)?(e.consume(t),w):N(t)}function N(t){return zu(t)?(i=N,_(t)):Lu(t)?(e.consume(t),N):A(t)}function k(t){return 45===t||Tu(t)?(e.consume(t),k):47===t||62===t||Ou(t)?j(t):n(t)}function j(t){return 47===t?(e.consume(t),A):58===t||95===t||Pu(t)?(e.consume(t),S):zu(t)?(i=j,_(t)):Lu(t)?(e.consume(t),j):A(t)}function S(t){return 45===t||46===t||58===t||95===t||Tu(t)?(e.consume(t),S):C(t)}function C(t){return 61===t?(e.consume(t),I):zu(t)?(i=C,_(t)):Lu(t)?(e.consume(t),C):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):zu(t)?(i=I,_(t)):Lu(t)?(e.consume(t),I):(e.consume(t),T)}function P(t){return t===a?(e.consume(t),a=void 0,E):null===t?n(t):zu(t)?(i=P,_(t)):(e.consume(t),P)}function T(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Ou(t)?j(t):(e.consume(t),T)}function E(e){return 47===e||62===e||Ou(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 Lu(t)?$u(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 Cd={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&&vu(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=wu(s,e.slice(r+1,r+o+3)),s=wu(s,[["enter",u,t]]),s=wu(s,Qu(t.parser.constructs.insideSpan.null,e.slice(r+o+4,a-3),t)),s=wu(s,[["exit",u,t],e[a-2],e[a-1],["exit",c,t]]),s=wu(s,e.slice(a+1)),s=wu(s,[["exit",l,t]]),vu(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(Iu(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(Id,c,s?c:u)(t):91===t?e.attempt(Pd,c,s?l:u)(t):s?c(t):u(t)}function l(t){return e.attempt(Td,c,u)(t)}function c(e){return t(e)}function u(e){return a._balanced=!0,n(e)}}},Id={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 Ou(t)?hd(e,a)(t):a(t)}function a(t){return 41===t?c(t):fd(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return Ou(t)?hd(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?pd(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return Ou(t)?hd(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)}}},Pd={tokenize:function(e,t,n){const r=this;return function(t){return md.call(r,e,a,s,"reference","referenceMarker","referenceString")(t)};function a(e){return r.parser.defined.includes(Iu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},Td={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 Ed={name:"labelStartImage",resolveAll:Cd.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 Ad={name:"labelStartLink",resolveAll:Cd.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 _d={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),$u(e,t,"linePrefix")}}};const Rd={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||zu(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),a++,i):(e.exit("thematicBreakSequence"),Lu(t)?$u(e,s,"whitespace")(t):s(t))}}};const Dd={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Xu,a,s);function a(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,$u(e,t,"listItemIndent",r.containerState.size+1)(n)}function s(n){return r.containerState.furtherBlankLines||!Lu(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(Od,t,i)(n))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,$u(e,e.attempt(Dd,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:_u(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(Rd,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 _u(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(Xu,r.interrupt?n:c,e.attempt(zd,d,u))}function c(e){return r.containerState.initialBlankLine=!0,s++,d(e)}function u(t){return Lu(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)}}},zd={partial:!0,tokenize:function(e,t,n){const r=this;return $u(e,function(e){const a=r.events[r.events.length-1];return!Lu(e)&&a&&"listItemPrefixWhitespace"===a[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Od={partial:!0,tokenize:function(e,t,n){const r=this;return $u(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 Ld={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"),Lu(t)?$u(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||zu(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const Fd={tokenize:function(e){const t=this,n=e.attempt(Xu,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,$u(e,e.attempt(this.parser.constructs.flow,r,e.attempt(ud,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 Md={resolveAll:Vd()},Ud=$d("string"),Bd=$d("text");function $d(e){return{resolveAll:Vd("text"===e?qd: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 Vd(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 qd(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 Hd={42:Dd,43:Dd,45:Dd,48:Dd,49:Dd,50:Dd,51:Dd,52:Dd,53:Dd,54:Dd,55:Dd,56:Dd,57:Dd,62:Gu},Wd={91:gd},Qd={[-2]:rd,[-1]:rd,32:rd},Kd={35:bd,42:Rd,45:[Ld,Rd],60:Nd,61:Ld,95:Rd,96:nd,126:nd},Yd={38:ed,92:Zu},Jd={[-5]:_d,[-4]:_d,[-3]:_d,33:Ed,38:ed,42:Ku,60:[Ju,Sd],91:Ad,92:[yd,Zu],93:Cd,95:Ku,96:sd},Xd={null:[Ku,Md]};var Gd=Object.freeze({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:Wd,disable:{null:[]},document:Hd,flow:Kd,flowInitial:Qd,insideSpan:Xd,string:Yd,text:Jd});function Zd(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){zu(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=wu(i,e),m(),null!==i[i.length-1])return[];return x(t,0),c.events=Qu(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&&vu(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 ef=/[\0\t\n\r]/g;const tf=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function nf(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Cu(n.slice(t?2:1),t?16:10)}return bu(n)||e}const rf={}.hasOwnProperty;function af(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:S,autolinkEmail:S,atxHeading:s(X),blockQuote:s(W),characterEscape:S,characterReference:S,codeFenced:s(Q),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(Q,i),codeText:s(K,i),codeTextData:S,data:S,codeFlowValue:S,definition:s(Y),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(J),hardBreakEscape:s(G),hardBreakTrailing:s(G),htmlFlow:s(Z,i),htmlFlowData:S,htmlText:s(Z,i),htmlTextData:S,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:C,characterReferenceMarkerHexadecimal:B,characterReferenceMarkerNumeric:B,characterReferenceValue:$,characterReference:V,codeFenced:l(g),codeFencedFence:h,codeFencedFenceInfo:m,codeFencedFenceMeta:p,codeFlowValue:C,codeIndented:l(x),codeText:l(A),codeTextData:C,data:C,definition:l(),definitionDestinationString:v,definitionLabelString:y,definitionTitleString:b,emphasis:l(),hardBreakEscape:l(P),hardBreakTrailing:l(P),htmlFlow:l(T),htmlFlowData:C,htmlText:l(E),htmlTextData:C,image:l(R),label:z,labelText:D,lineEnding:I,link:l(_),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:U,resourceDestinationString:O,resourceTitleString:L,resource:F,setextHeading:l(j),setextHeadingLineSequence:k,setextHeadingText:N,strong:l(),thematicBreak:l()}};of(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]];rf.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]||cf).call(s,void 0,e[0])}for(r.position={start:sf(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:sf(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:sf(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+"` ("+Wc({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]||cf).call(this,e,r[0])}n.position.end=sf(e.end)}function u(){return hu(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=Iu(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 S(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:sf(e.start),end:void 0},t.push(n)),this.stack.push(n)}function C(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=sf(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=sf(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(S.call(this,e),C.call(this,e))}function P(){this.data.atHardBreak=!0}function T(){const e=this.resume();this.stack[this.stack.length-1].value=e}function E(){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 D(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(tf,nf)}(t),n.identifier=Iu(t).toLowerCase()}function z(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function O(){const e=this.resume();this.stack[this.stack.length-1].url=e}function L(){const e=this.resume();this.stack[this.stack.length-1].title=e}function F(){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=Iu(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=Cu(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=bu(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=sf(e.end)}function q(e){C.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function H(e){C.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(;!ld(e););return e}(function(e){const t={constructs:ku([Gd,...(e||{}).extensions||[]]),content:n(Vu),defined:[],document:n(qu),flow:n(Fd),lazy:{},string:n(Ud),text:n(Bd)};return t;function n(e){return function(n){return Zd(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(ef.lastIndex=u,l=ef.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 sf(e){return{line:e.line,column:e.column,offset:e.offset}}function of(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?of(e,r):lf(e,r)}}function lf(e,t){let n;for(n in t)if(rf.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 cf(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Wc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Wc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Wc({start:t.start,end:t.end})+") is still open")}function uf(e){const t=this;t.parser=function(n){return af(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function df(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 ff(e){const t=e.spread;return null==t?e.children.length>1:t}function mf(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const s=[];for(;r;)s.push(pf(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return s.push(pf(t.slice(a),a>0,!1)),s.join("")}function pf(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 hf={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=Bu(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 df(e,t);const a={src:Bu(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:Bu(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 df(e,t);const a={href:Bu(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:Bu(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=ff(n[r])}return t}(n):ff(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=qc(t.children[1]),i=Vc(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:mf(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:gf,yaml:gf,definition:gf,footnoteDefinition:gf};function gf(){}const xf="object"==typeof self?self:globalThis,yf=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 xf[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 xf[s](i),a)};return r})(new Map,e)(0),bf="",{toString:vf}={},{keys:wf}=Object,Nf=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=vf.call(e).slice(8,-1);switch(n){case"Array":return[1,bf];case"Object":return[2,bf];case"Date":return[3,bf];case"RegExp":return[4,bf];case"Map":return[5,bf];case"Set":return[6,bf];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},kf=([e,t])=>0===e&&("function"===t||"symbol"===t),jf=(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]=Nf(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 wf(r))!e&&kf(Nf(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||!kf(Nf(a))&&!kf(Nf(i)))&&t.push([s(a),s(i)]);return n}case 6:{const t=[],n=a([i,t],r);for(const a of r)!e&&kf(Nf(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 Sf="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?yf(jf(e,t)):structuredClone(e):(e,t)=>yf(jf(e,t));function Cf(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 If(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Pf=function(e){if(null==e)return Ef;if("function"==typeof e)return Tf(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Pf(e[n]);return Tf(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 Tf(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 Tf(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function Tf(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 Ef(){return!0}const Af=[],_f=!0,Rf=!1;function Df(e,t,n,r){let a;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):a=t;const s=Pf(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=Af;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[_f,e];return null==e?Af:[e]}(n(a,l)),f[0]===Rf))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]===Rf)return c;u="number"==typeof c[1]?c[1]:u+i}}return f}}(e,void 0,[])()}function zf(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),Df(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 Of={}.hasOwnProperty,Lf={};function Ff(e,t){e.position&&(t.position=function(e){const t=qc(e),n=Vc(e);if(t&&n)return{start:t,end:n}}(e))}function Mf(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,Sf(a)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function Uf(e,t){const n=t.data||{},r=!("value"in t)||Of.call(n,"hProperties")||Of.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 Bf(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 $f(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function Vf(e,t){const n=function(e,t){const n=t||Lf,r=new Map,a=new Map,s=new Map,i={...hf,...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=$f(a.value)),!Array.isArray(a)&&"element"===a.type)){const e=a.children[0];e&&"text"===e.type&&(e.value=$f(e.value))}Array.isArray(a)?t.push(...a):t.push(a)}}}return t},applyData:Mf,definitionById:r,footnoteById:a,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=o.handlers[n];if(Of.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=Sf(n);return r.children=o.all(e),r}return Sf(e)}return(o.options.unknownHandler||Uf)(o,e,t)},options:n,patch:Ff,wrap:Bf};return zf(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||Cf,r=e.options.footnoteBackLabel||If,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=Bu(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:{...Sf(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 qf(e,t){return e&&"run"in e?async function(n,r){const a=Vf(n,{file:r,...t});await e.run(a,r)}:function(n,r){return Vf(n,{file:r,...e||t})}}function Hf(e){if(e)throw e}var Wf,Qf;var Kf=function(){if(Qf)return Wf;Qf=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 Wf=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},Wf}(),Yf=St(Kf);function Jf(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 Xf(){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 Gf={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');Zf(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(Zf(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){Zf(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;)Zf(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){Zf(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 Zf(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const em={cwd:function(){return"/"}};function tm(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function nm(e){if("string"==typeof e)e=new URL(e);else if(!tm(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 rm=["history","path","basename","stem","extname","dirname"];class am{constructor(e){let t;t=e?tm(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?"":em.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<rm.length;){const e=rm[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)rm.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?Gf.basename(this.path):void 0}set basename(e){im(e,"basename"),sm(e,"basename"),this.path=Gf.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?Gf.dirname(this.path):void 0}set dirname(e){om(this.basename,"dirname"),this.path=Gf.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?Gf.extname(this.path):void 0}set extname(e){if(sm(e,"extname"),om(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=Gf.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){tm(e)&&(e=nm(e)),im(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?Gf.basename(this.path,this.extname):void 0}set stem(e){im(e,"stem"),sm(e,"stem"),this.path=Gf.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 Jc(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 sm(e,t){if(e&&e.includes(Gf.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Gf.sep+"`")}function im(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function om(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const lm=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},cm={}.hasOwnProperty;class um extends lm{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=Xf()}copy(){const e=new um;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(Yf(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(pm("data",this.frozen),this.namespace[e]=t,this):cm.call(this.namespace,e)&&this.namespace[e]||void 0:e?(pm("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=xm(e),n=this.parser||this.Parser;return fm("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),fm("process",this.parser||this.Parser),mm("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,a){const s=xm(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(),fm("processSync",this.parser||this.Parser),mm("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,Hf(e),t=r}),gm("processSync","process",n),t}run(e,t,n){hm(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=xm(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){Hf(e),n=t,r=!0}),gm("runSync","run",r),n}stringify(e,t){this.freeze();const n=xm(t),r=this.compiler||this.Compiler;return mm("stringify",r),hm(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(pm("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=Yf(!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];Jf(i)&&Jf(r)&&(r=Yf(!0,i,r)),n[a]=[e,r,...s]}}}}const dm=(new um).freeze();function fm(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function mm(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function pm(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 hm(e){if(!Jf(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function gm(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function xm(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new am(e)}const ym=[],bm={allowDangerousHtml:!0},vm=/^(https?|ircs?|mailto|xmpp)$/i,wm=[{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 Nm(e){const t=function(e){const t=e.rehypePlugins||ym,n=e.remarkPlugins||ym,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...bm}:bm,a=dm().use(uf).use(n).use(qf,r).use(t);return a}(e),n=function(e){const t=e.children||"",n=new am;"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||km;for(const u of wm)Object.hasOwn(t,u.from)&&ql((u.from,u.to&&u.to,u.id));return zf(e,c),ru(e,{Fragment:Rt.Fragment,components:a,ignoreInvalidStyle:!0,jsx:Rt.jsx,jsxs:Rt.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 mu)if(Object.hasOwn(mu,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=mu[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 km(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||vm.test(e.slice(0,t))?e:""}function jm(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 Sm(e,t,n){const r=Pf((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([Cm(e[0]),Im(e[1])])}return t}(t);let s=-1;for(;++s<a.length;)Df(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 Cm(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 Im(e){return"function"==typeof e?e:function(){return e}}const Pm="phrasing",Tm=["autolink","link","image","label"];function Em(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Am(e){this.config.enter.autolinkProtocol.call(this,e)}function _m(e){this.config.exit.autolinkProtocol.call(this,e)}function Rm(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 Dm(e){this.config.exit.autolinkEmail.call(this,e)}function zm(e){this.exit(e)}function Om(e){Sm(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Lm],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Fm]],{ignore:["link","linkReference"]})}function Lm(e,t,n,r,a){let s="";if(!Mm(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=jm(e,"(");let s=jm(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 Fm(e,t,n,r){return!(!Mm(r,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Mm(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||Mu(n)||Fu(n))&&(!t||47!==n)}function Um(){this.buffer()}function Bm(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function $m(){this.buffer()}function Vm(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function qm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Iu(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Hm(e){this.exit(e)}function Wm(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Iu(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Qm(e){this.exit(e)}function Km(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 Ym(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?Xm:Jm)));return o(),i},footnoteReference:Km},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function Jm(e,t,n){return 0===t?e:Xm(e,t,n)}function Xm(e,t,n){return(n?"":" ")+e}Km.peek=function(){return"["};const Gm=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function Zm(e){this.enter({type:"delete",children:[]},e)}function ep(e){this.exit(e)}function tp(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 np(e){return e.length}function rp(e){return null==e?"":String(e)}function ap(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 sp(e,t,n){return">"+(n?"":" ")+e}function ip(e,t){return op(e,t.inConstruct,!0)&&!op(e,t.notInConstruct,!1)}function op(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 lp(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if("\n"===n.unsafe[a].character&&ip(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return"\\\n"}function cp(e,t,n){return(n?"":" ")+e}function up(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 dp(e){return"&#x"+e.toString(16).toUpperCase()+";"}function fp(e,t,n){const r=Wu(e),a=Wu(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 mp(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=fp(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=dp(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=fp(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+dp(d));const m=i.move(a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}function pp(e){return e.value||""}function hp(e,t,n,r){const a=up(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 gp(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 xp(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 yp(e,t){const n=hu(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 bp(e,t,n,r){const a=up(n),s='"'===a?"Quote":"Apostrophe",i=n.createTracker(r);let o,l;if(yp(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 vp(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 wp(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 Np(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}tp.peek=function(){return"~"},mp.peek=function(e,t,n){return n.options.emphasis||"*"},pp.peek=function(){return"<"},hp.peek=function(){return"!"},gp.peek=function(){return"!"},xp.peek=function(){return"`"},bp.peek=function(e,t,n){return yp(e,n)?"<":"["},vp.peek=function(){return"["};const kp=Pf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function jp(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=fp(r.before.charCodeAt(r.before.length-1),c,a);u.inside&&(l=dp(c)+l.slice(1));const d=l.charCodeAt(l.length-1),f=fp(r.after.charCodeAt(0),d,a);f.inside&&(l=l.slice(0,-1)+dp(d));const m=i.move(a+a);return s(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},o+l+m}jp.peek=function(e,t,n){return n.options.strong||"*"};const Sp={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()),sp);return a(),i},break:lp,code:function(e,t,n,r){const a=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),s=e.value||"",i="`"===a?"GraveAccent":"Tilde";if(function(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(s,cp);return e(),t}const o=n.createTracker(r),l=a.repeat(Math.max(function(e,t){const n=String(e);let r=n.indexOf(t),a=r,s=0,i=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==r;)r===a?++s>i&&(i=s):s=1,a=r+t.length,r=n.indexOf(t,a);return i}(s,a)+1,3)),c=n.enter("codeFenced");let 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=up(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:mp,hardBreak:lp,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 zf(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,Rf}),Boolean((!e.depth||e.depth<3)&&hu(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=dp(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),o(),c},html:pp,image:hp,imageReference:gp,inlineCode:xp,link:bp,linkReference:vp,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):wp(n);const o=e.ordered?"."===i?")":".":function(e){const t=wp(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),Np(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||wp(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 kp(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)},strong:jp,text:function(e,t,n,r){return n.safe(e.value,r)},thematicBreak:function(e,t,n){const r=(Np(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 Cp(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 Ip(e){this.exit(e),this.data.inTable=void 0}function Pp(e){this.enter({type:"tableRow",children:[]},e)}function Tp(e){this.exit(e)}function Ep(e){this.enter({type:"tableCell",children:[]},e)}function Ap(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,_p));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function _p(e,t){return"|"===t?t:e}function Rp(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=Sp.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||np,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=rp(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]=ap(r[d]);else{const e=ap(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 Dp(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function zp(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 Op(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=Sp.listItem(e,t,n,{...r,...o.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const Lp={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},Fp={tokenize:function(e,t,n){let r,a,s;return i;function i(t){return 46===t||95===t?e.check(Up,l,o)(t):null===t||Ou(t)||Mu(t)||45!==t&&Fu(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},Mp={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(Up,t,s)(i):null===i||Ou(i)||Mu(i)?t(i):(e.consume(i),a)}function s(t){return 41===t&&r++,e.consume(t),a}},partial:!0},Up={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||Ou(i)||Mu(i)?t(i):n(i)}function a(e){return null===e||40===e||91===e||Ou(e)||Mu(e)?t(e):r(e)}function s(e){return Pu(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),r):Pu(t)?(e.consume(t),i):n(t)}},partial:!0},Bp={tokenize:function(e,t,n){return function(t){return e.consume(t),r};function r(e){return Tu(e)?n(e):t(e)}},partial:!0},$p={name:"wwwAutolink",tokenize:function(e,t,n){const r=this;return function(t){if(87!==t&&119!==t||!Qp.call(r,r.previous)||Xp(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Lp,e.attempt(Fp,e.attempt(Mp,a),n),n)(t)};function a(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:Qp},Vp={name:"protocolAutolink",tokenize:function(e,t,n){const r=this;let a="",s=!1;return function(t){if((72===t||104===t)&&Kp.call(r,r.previous)&&!Xp(r.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if(Pu(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||Au(t)||Ou(t)||Mu(t)||Fu(t)?n(t):e.attempt(Fp,e.attempt(Mp,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:Kp},qp={name:"emailAutolink",tokenize:function(e,t,n){const r=this;let a,s;return function(t){if(!Jp(t)||!Yp.call(r,r.previous)||Xp(r.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return Jp(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(Bp,c,l)(t):45===t||95===t||Tu(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&&Pu(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:Yp},Hp={};let Wp=48;for(;Wp<123;)Hp[Wp]=qp,Wp++,58===Wp?Wp=65:91===Wp&&(Wp=97);function Qp(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||Ou(e)}function Kp(e){return!Pu(e)}function Yp(e){return!(47===e||Jp(e))}function Jp(e){return 43===e||45===e||46===e||95===e||Tu(e)}function Xp(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}Hp[43]=qp,Hp[45]=qp,Hp[46]=qp,Hp[95]=qp,Hp[72]=[qp,Vp],Hp[104]=[qp,Vp],Hp[87]=[qp,$p],Hp[119]=[qp,$p];const Gp={tokenize:function(e,t,n){const r=this;return $u(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 Zp(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=Iu(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 eh(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 th(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||Ou(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return a.includes(Iu(r.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return Ou(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 nh(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||Ou(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=Iu(r.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return Ou(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),$u(e,f,"gfmFootnoteDefinitionWhitespace")):n(t)}function f(e){return t(e)}}function rh(e,t,n){return e.check(Xu,t,e.attempt(Gp,t,n))}function ah(e){e.exit("gfmFootnoteDefinition")}function sh(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=Wu(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=Wu(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&&vu(i,i.length,0,Qu(o,e.slice(r+1,n),t)),vu(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",a,t]]),vu(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 ih{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 oh(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 lh(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):zu(t)?i>1?(i=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):n(t):Lu(t)?$u(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||Ou(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,Lu(t)?$u(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 Lu(t)?$u(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||zu(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 Lu(t)?$u(e,y,"whitespace")(t):y(t)}function y(n){return 124===n?f(n):(null===n||zu(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||zu(n)?(e.exit("tableRow"),t(n)):Lu(n)?$u(e,w,"whitespace")(n):(e.enter("data"),N(n))}function N(t){return null===t||124===t||Ou(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 ch(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 ih;for(;++s<e.length;){const m=e[s],p=m[1];"enter"===m[0]?"tableHead"===p.type?(u=!1,0!==d&&(dh(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=uh(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=uh(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=uh(f,t,l,o,s,a)):0!==c[1]&&(a=uh(f,t,c,o,s,a)),o=0):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type||(c[3]=s)}for(0!==d&&dh(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=oh(t.events,s))}return e}function uh(e,t,n,r,a,s){const i=1===r?"tableHeader":2===r?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},fh(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=fh(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=fh(t.events,n[2]),s=fh(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({},fh(t.events,a)),e.add(a,0,[["exit",s,t]]),s=void 0),s}function dh(e,t,n,r,a){const s=[],i=fh(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 fh(e,t){const n=e[t],r="enter"===n[0]?"start":"end";return n[1][r]}const mh={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 Ou(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 zu(r)?t(r):Lu(r)?e.check({tokenize:ph},t,n)(r):n(r)}}};function ph(e,t,n){return $u(e,function(e){return null===e?n(e):t(e)},"whitespace")}const hh={};function gh(e){const t=e||hh,n=this.data(),r=n.micromarkExtensions||(n.micromarkExtensions=[]),a=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);r.push(function(e){return ku([{text:Hp},{document:{91:{name:"gfmFootnoteDefinition",tokenize:nh,continuation:{tokenize:rh},exit:ah}},text:{91:{name:"gfmFootnoteCall",tokenize:th},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Zp,resolveTo:eh}}},sh(e),{flow:{null:{name:"table",tokenize:lh,resolveAll:ch}}},{text:{91:mh}}])}(t)),a.push([{transforms:[Om],enter:{literalAutolink:Em,literalAutolinkEmail:Am,literalAutolinkHttp:Am,literalAutolinkWww:Am},exit:{literalAutolink:zm,literalAutolinkEmail:Dm,literalAutolinkHttp:_m,literalAutolinkWww:Rm}},{enter:{gfmFootnoteCallString:Um,gfmFootnoteCall:Bm,gfmFootnoteDefinitionLabelString:$m,gfmFootnoteDefinition:Vm},exit:{gfmFootnoteCallString:qm,gfmFootnoteCall:Hm,gfmFootnoteDefinitionLabelString:Wm,gfmFootnoteDefinition:Qm}},{canContainEols:["delete"],enter:{strikethrough:Zm},exit:{strikethrough:ep}},{enter:{table:Cp,tableData:Ep,tableHeader:Ep,tableRow:Pp},exit:{codeText:Ap,table:Ip,tableData:Tp,tableHeader:Tp,tableRow:Tp}},{exit:{taskListCheckValueChecked:Dp,taskListCheckValueUnchecked:Dp,paragraph:zp}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Pm,notInConstruct:Tm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Pm,notInConstruct:Tm},{character:":",before:"[ps]",after:"\\/",inConstruct:Pm,notInConstruct:Tm}]},Ym(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Gm}],handlers:{delete:tp}},Rp(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Op}}]}}(t))}function xh({content:e,className:t}){return Rt.jsx("div",{className:zt("prose prose-sm max-w-none",t),children:Rt.jsx(Nm,{remarkPlugins:[gh],components:{h1:({children:e})=>Rt.jsx("h1",{className:"text-lg font-bold mt-4 mb-2 text-foreground",children:e}),h2:({children:e})=>Rt.jsx("h2",{className:"text-base font-bold mt-3 mb-2 text-foreground",children:e}),h3:({children:e})=>Rt.jsx("h3",{className:"text-sm font-semibold mt-2 mb-1 text-foreground",children:e}),p:({children:e})=>Rt.jsx("p",{className:"text-sm mb-2 last:mb-0 text-foreground",children:e}),ul:({children:e})=>Rt.jsx("ul",{className:"list-disc list-inside mb-2 space-y-1",children:e}),ol:({children:e})=>Rt.jsx("ol",{className:"list-decimal list-inside mb-2 space-y-1",children:e}),li:({children:e})=>Rt.jsx("li",{className:"text-sm text-foreground",children:e}),code:({inline:e,children:t,...n})=>e?Rt.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs font-mono text-foreground",...n,children:t}):Rt.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})=>Rt.jsx("pre",{className:"bg-muted p-2 rounded overflow-x-auto mb-2",children:e}),a:({children:e,href:t})=>Rt.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:text-primary/80",children:e}),blockquote:({children:e})=>Rt.jsx("blockquote",{className:"border-l-4 border-primary pl-3 italic my-2 text-muted-foreground",children:e}),strong:({children:e})=>Rt.jsx("strong",{className:"font-bold text-foreground",children:e}),em:({children:e})=>Rt.jsx("em",{className:"italic text-foreground",children:e})},children:e})})}function yh(){const[e,t]=a(!1),[n,r]=a(""),{messages:s,isLoading:o,error:l,sendMessage:u}=$l(),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 Rt.jsxs(Rt.Fragment,{children:[Rt.jsx(Bt,{onClick:()=>t(!e),className:"fixed bottom-6 right-6 h-14 w-14 rounded-full shadow-lg z-50",size:"icon",children:e?Rt.jsx(N,{className:"h-6 w-6"}):Rt.jsx($e,{className:"h-6 w-6"})}),e&&Rt.jsxs(Wt,{className:"fixed bottom-24 right-6 w-96 h-[600px] shadow-xl z-50 flex flex-col",children:[Rt.jsxs(Qt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[Rt.jsx(Kt,{className:"text-lg font-semibold",children:"Chat Assistant"}),Rt.jsx(Bt,{variant:"ghost",size:"icon",onClick:()=>t(!1),className:"h-8 w-8",children:Rt.jsx(N,{className:"h-4 w-4"})})]}),Rt.jsxs(Jt,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[Rt.jsx(Ka,{ref:d,className:"flex-1 px-4",children:Rt.jsxs("div",{className:"space-y-4 py-4",children:[s.map(e=>Rt.jsx("div",{className:"flex "+("user"===e.role?"justify-end":"justify-start"),children:Rt.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?Rt.jsx(xh,{content:e.content}):Rt.jsx("p",{className:"text-sm whitespace-pre-wrap",children:e.content})})},e.id)),o&&Rt.jsx("div",{className:"flex justify-start",children:Rt.jsx("div",{className:"bg-muted rounded-lg px-4 py-2",children:Rt.jsxs("div",{className:"flex space-x-2",children:[Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce"}),Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.2s]"}),Rt.jsx("div",{className:"w-2 h-2 bg-foreground/40 rounded-full animate-bounce [animation-delay:0.4s]"})]})})}),l&&Rt.jsx("div",{className:"text-center text-sm text-destructive py-2",children:l})]})}),Rt.jsx("div",{className:"border-t p-4",children:Rt.jsxs("div",{className:"flex space-x-2",children:[Rt.jsx(Vt,{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"}),Rt.jsx(Bt,{onClick:m,disabled:o||!n.trim(),size:"icon",children:Rt.jsx(Ve,{className:"h-4 w-4"})})]})})]})]})]})}const bh=e=>e?.placeId||null,vh=e=>e?.placeName||null;var wh=Object.freeze({__proto__:null,getUserPlaceData:e=>({placeId:bh(e),placeName:vh(e)}),getUserPlaceId:bh,getUserPlaceName:vh});export{Tr as AUTH_CONFIG,Es as Accordion,Rs as AccordionContent,As as AccordionItem,_s as AccordionTrigger,$t as ActionButton,Fa as ActionMenuItems,tl as ActionMenuPrimitive,vs as Alert,Ns as AlertDescription,Yr as AlertDialog,aa as AlertDialogAction,sa as AlertDialogCancel,Zr as AlertDialogContent,ra as AlertDialogDescription,ta as AlertDialogFooter,ea as AlertDialogHeader,Gr as AlertDialogOverlay,Xr as AlertDialogPortal,na as AlertDialogTitle,Jr as AlertDialogTrigger,ws as AlertTitle,El as AppHeader,Ul as AppLayout,Ml as AppSidebar,Ds as AspectRatio,wr as AuthErrorInterceptor,Hr as AuthProvider,Vr as AuthService,zs as Avatar,Ls as AvatarFallback,Os as AvatarImage,Pn as Badge,ts as BaseForm,Fs as Breadcrumb,qs as BreadcrumbEllipsis,Us as BreadcrumbItem,Bs as BreadcrumbLink,Ms as BreadcrumbList,$s as BreadcrumbPage,Vs as BreadcrumbSeparator,as as BulkActionBar,Bt as Button,Er as CRUD_CONFIG,ti as Calendar,ks as CallbackPage,Wt as Card,Jt as CardContent,Yt as CardDescription,Xt as CardFooter,Qt as CardHeader,xa as CardSkeleton,Kt as CardTitle,rl as CardsPrimitive,yh as ChatbotPage,Sn as Checkbox,ni as Collapsible,ai as CollapsibleContent,ri as CollapsibleTrigger,Qa as ColorPicker,si as Command,ii as CommandDialog,ci as CommandEmpty,ui as CommandGroup,oi as CommandInput,fi as CommandItem,li as CommandList,di as CommandSeparator,mi as CommandShortcut,al as CrudCards,us as CrudPageInternal,rs as CrudPagination,Ba as CrudTable,pi as DataList,ia as DeleteConfirmationDialog,Gt as Dialog,tn as DialogClose,rn as DialogContent,ln as DialogDescription,sn as DialogFooter,an as DialogHeader,nn as DialogOverlay,en as DialogPortal,on as DialogTitle,Zt as DialogTrigger,ka as DropdownMenu,Ra as DropdownMenuCheckboxItem,Aa as DropdownMenuContent,Sa as DropdownMenuGroup,_a as DropdownMenuItem,za as DropdownMenuLabel,Ca as DropdownMenuPortal,Pa as DropdownMenuRadioGroup,Da as DropdownMenuRadioItem,Oa as DropdownMenuSeparator,La as DropdownMenuShortcut,Ia as DropdownMenuSub,Ea as DropdownMenuSubContent,Ta as DropdownMenuSubTrigger,ja as DropdownMenuTrigger,Na as EmptyState,Ga as EntitySelect,Bl as ErrorBoundary,cs as FilterBar,nl as FilterBarPrimitive,cn as Form,gn as FormControl,dn as FormField,pn as FormItem,hn as FormLabel,xn as FormMessage,ya as FormSkeleton,xi as Grid,ba as HeaderSkeleton,Xa as IconPicker,Vt as Input,Ht as Label,An as LoadingState,js as LoginPage,Lr as MESSAGES,wl as ManagerSelectionDialog,xh as MarkdownMessage,Cl as NavigationProvider,yi as PageBreadcrumb,vi as Pagination,wi as PaginationContent,Ci as PaginationEllipsis,Ni as PaginationItem,ki as PaginationLink,Si as PaginationNext,ji as PaginationPrevious,ns as PaginationPrimitive,kl as PlaceManagerBadge,Nl as PlaceManagerButton,gl as PlaceManagerService,fl as PlaceService,vl as PlacesPage,Va as Popover,Ha as PopoverContent,qa as PopoverTrigger,Ii as Progress,ys as ProtectedRoute,Rr as QUERY_KEYS,Pr as QualiexEnrichmentService,kr as QualiexErrorInterceptor,es as QualiexUserField,Pi as RadioGroup,Ti as RadioGroupItem,Ar as SEARCH_CONFIG,Ka as ScrollArea,Ya as ScrollBar,yn as Select,kn as SelectContent,jn as SelectItem,vn as SelectTrigger,bn as SelectValue,Ei as Separator,Ai as Sheet,Ri as SheetClose,Li as SheetContent,Bi as SheetDescription,Mi as SheetFooter,Fi as SheetHeader,zi as SheetOverlay,Di as SheetPortal,Ui as SheetTitle,_i as SheetTrigger,Ji as Sidebar,ao as SidebarContent,no as SidebarFooter,so as SidebarGroup,oo as SidebarGroupAction,lo as SidebarGroupContent,io as SidebarGroupLabel,to as SidebarHeader,eo as SidebarInput,Zi as SidebarInset,co as SidebarMenu,po as SidebarMenuAction,ho as SidebarMenuBadge,mo as SidebarMenuButton,uo as SidebarMenuItem,go as SidebarMenuSkeleton,xo as SidebarMenuSub,bo as SidebarMenuSubButton,yo as SidebarMenuSubItem,Yi as SidebarProvider,Gi as SidebarRail,ro as SidebarSeparator,va as SidebarSkeleton,Xi as SidebarTrigger,ha as Skeleton,vo as Slider,wo as SonnerToaster,En as Spinner,ls as Stack,Bo as Switch,Ko as TabPageContent,Qo as TabPageHeader,Wo as TabPageLayout,oa as Table,ca as TableBody,pa as TableCaption,ma as TableCell,ua as TableFooter,fa as TableHead,la as TableHeader,el as TablePrimitive,da as TableRow,Ma as TableRowActions,ga as TableSkeleton,$o as Tabs,Ho as TabsContent,Vo as TabsList,qo as TabsTrigger,Cn as Textarea,qn as Toast,Hn as ToastAction,Wn as ToastClose,Kn as ToastDescription,Bn as ToastProvider,Qn as ToastTitle,$n as ToastViewport,Yn as Toaster,Jo as Toggle,Go as ToggleGroup,Zo as ToggleGroupItem,sr as TokenManager,Xn as TokenService,Vi as Tooltip,Hi as TooltipContent,$i as TooltipProvider,qi as TooltipTrigger,Dl as assets,In as badgeVariants,Ut as buttonVariants,zt as cn,ds as createCrudPage,il as createCrudRoutingConfig,sl as createRoutingHandlers,Ur as createService,fs as createSimpleSaveHandler,Kr as createSimpleService,gs as crudPresets,Mt as debounce,lr as errorService,Ft as formatCurrency,Lt as formatDatetime,ms as generateCrudConfig,zr as getQualiexConfig,hr as getSupabaseClient,Dt as handleExternalLink,_r as isDevEnvironment,zl as logoSrc,xl as placeManagerService,ml as placeService,Cr as qualiexApi,Or as setQualiexConfig,Ts as setupQualiexCore,Ol as smallLogoSrc,Mn as toast,Yo as toggleVariants,Ot as trimTextFields,Al as useActiveModules,Wr as useAuth,$a as useBaseForm,Qr as useCrud,Tl as useDebounce,Il as useNavigation,$l as useOpenAIChat,Ps as usePageMetadata,Pl as usePageTitle,_l as usePermissionQuery,yl as usePlaceManagers,Za as useQualiexUsers,bi as useRouteBreadcrumbs,Ki as useSidebar,Un as useToast,cl as userPlaceService,xs as withPreset};
|