PageSourceSearch

https://hublog-tienda.netlify.app/assets/AnalisisDashboard-OqajXoAc.js

js hublog-tienda.netlify.app collected 2026-10-03 10:54:10 UTC 319,237 bytes, 47 lines download raw bytes

vendor: 5,308 bytes, line 1
1import{j as l,n as Tl,m as gt,l as In}from"./index-CVJbFka_.js";import{g as wa,r as Le,u as Ll}from"./vendor-ZhunjhWo.js";import{bs as Ol,J as _l,w as yo,R as Vl,bb as Xr,S as Ir,I as Bl,B as Fe,az as Nl,t as Da,T as ja,s as dt,L as Ca,c as Ft,aK as $l,bi as Ul,bD as Hl,ax as tt,N as ft,O as Re,b as So,i as ko,ab as bo,o as Ce,ah as Kl,b6 as Wl,al as nr,d as Cn,E as wt,A as rr,m as it,p as ql,bE as Yl,bF as Gl,aB as Ql,aT as Xl}from"./antd-D1_ToyMj.js";import{a as wo,b as Zl,c as Jl,l as Do}from"./lazyLibs-BS9HZeJ4.js";import{h as es,b as hr,c as Hn,q as Rr,w as vn,o as Jr,B as jo,z as ei,T as ts,y as Ea,d as ns,e as rs}from"./firebase_db-C04hyDle.js";import{a as is,q as os,f as as,g as ls}from"./inventariosLayeredFirestore-SDF_aIl8.js";import{R as en,P as $r,e as Ur,f as _n,T as tn,z as pi,C as Vn,X as Bn,Y as Nn,b as wr,a as ir,c as Dr,B as Co,L as Eo}from"./charts-yOOhL4bs.js";import"./export_pdf-BViiA-Lo.js";import"./firebase_core-BU7P0LkR.js";function ss(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const cs=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,us=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ds={};function vo(e,t){return(ds.jsx?us:cs).test(e)}const fs=/[ \t\n\f\r]/g;function hs(e){return typeof e=="object"?e.type==="text"?Io(e.value):!1:Io(e)}function Io(e){return e.replace(fs,"")===""}class Tr{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Tr.prototype.normal={};Tr.prototype.property={};Tr.prototype.space=void 0;function va(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Tr(n,r,t)}function Ri(e){return e.toLowerCase()}class Pt{constructor(t,n){this.attribute=n,this.property=t}}Pt.prototype.attribute="";Pt.prototype.booleanish=!1;Pt.prototype.boolean=!1;Pt.prototype.commaOrSpaceSeparated=!1;Pt.prototype.commaSeparated=!1;Pt.prototype.defined=!1;Pt.prototype.mustUseProperty=!1;Pt.prototype.number=!1;Pt.prototype.overloadedBoolean=!1;Pt.prototype.property="";Pt.prototype.spaceSeparated=!1;Pt.prototype.space=void 0;let ps=0;const ye=Kn(),at=Kn(),Ti=Kn(),W=Kn(),Be=Kn(),ur=Kn(),Nt=Kn();function Kn(){return 2**++ps}const Li=Object.freeze(Object.defineProperty({__proto__:null,boolean:ye,booleanish:at,commaOrSpaceSeparated:Nt,commaSeparated:ur,number:W,overloadedBoolean:Ti,spaceSeparated:Be},Symbol.toStringTag,{value:"Module"})),mi=Object.keys(Li);class Yi extends Pt{constructor(t,n,r,i){let a=-1;if(super(t,n),zo(this,"space",i),typeof r=="number")for(;++a<mi.length;){const o=mi[a];zo(this,mi[a],(r&Li[o])===Li[o])}}}Yi.prototype.defined=!0;function zo(e,t,n){n&&(e[t]=n)}function pr(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const a=new Yi(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[Ri(r)]=r,n[Ri(a.attribute)]=r}return new Tr(t,n,e.space)}const Ia=pr({properties:{ariaActiveDescendant:null,ariaAtomic:at,ariaAutoComplete:null,ariaBusy:at,ariaChecked:at,ariaColCount:W,ariaColIndex:W,ariaColSpan:W,ariaControls:Be,ariaCurrent:null,ariaDescribedBy:Be,ariaDetails:null,ariaDisabled:at,ariaDropEffect:Be,ariaErrorMessage:null,ariaExpanded:at,ariaFlowTo:Be,ariaGrabbed:at,ariaHasPopup:null,ariaHidden:at,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Be,ariaLevel:W,ariaLive:null,ariaModal:at,ariaMultiLine:at,ariaMultiSelectable:at,ariaOrientation:null,ariaOwns:Be,ariaPlaceholder:null,ariaPosInSet:W,ariaPressed:at,ariaReadOnly:at,ariaRelevant:null,ariaRequired:at,ariaRoleDescription:Be,ariaRowCount:W,ariaRowIndex:W,ariaRowSpan:W,ariaSelected:at,ariaSetSize:W,ariaSort:null,ariaValueMax:W,ariaValueMin:W,ariaValueNow:W,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function za(e,t){return t in e?e[t]:t}function Ma(e,t){return za(e,t.toLowerCase())}const ms=pr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ur,acceptCharset:Be,accessKey:Be,action:null,allow:null,allowFullScreen:ye,allowPaymentRequest:ye,allowUserMedia:ye,alt:null,as:null,async:ye,autoCapitalize:null,autoComplete:Be,autoFocus:ye,autoPlay:ye,blocking:Be,capture:null,charSet:null,checked:ye,cite:null,className:Be,cols:W,colSpan:null,content:null,contentEditable:at,controls:ye,controlsList:Be,coords:W|ur,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ye,defer:ye,dir:null,dirName:null,disabled:ye,download:Ti,draggable:at,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ye,formTarget:null,headers:Be,height:W,hidden:Ti,high:W,href:null,hrefLang:null,htmlFor:Be,httpEquiv:Be,id:null,imageSizes:null,imageSrcSet:null,inert:ye,inputMode:null,integrity:null,is:null,isMap:ye,itemId:null,itemProp:Be,itemRef:Be,itemScope:ye,itemType:Be,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ye,low:W,manifest:null,max:null,maxLength:W,media:null,method:null,min:null,minLength:W,multiple:ye,muted:ye,name:null,nonce:null,noModule:ye,noValidate:ye,onAbort:null,onAfterPrint:null,onAuxCl
1ick: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:ye,optimum:W,pattern:null,ping:Be,placeholder:null,playsInline:ye,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ye,referrerPolicy:null,rel:Be,required:ye,reversed:ye,rows:W,rowSpan:W,sandbox:Be,scope:null,scoped:ye,seamless:ye,selected:ye,shadowRootClonable:ye,shadowRootDelegatesFocus:ye,shadowRootMode:null,shape:null,size:W,sizes:null,slot:null,span:W,spellCheck:at,src:null,srcDoc:null,srcLang:null,srcSet:null,start:W,step:null,style:null,tabIndex:W,target:null,title:null,translate:null,type:null,typeMustMatch:ye,useMap:null,value:at,width:W,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Be,axis:null,background:null,bgColor:null,border:W,borderColor:null,bottomMargin:W,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ye,declare:ye,event:null,face:null,frame:null,frameBorder:null,hSpace:W,leftMargin:W,link:null,longDesc:null,lowSrc:null,marginHeight:W,marginWidth:W,noResize:ye,noHref:ye,noShade:ye,noWrap:ye,object:null,profile:null,prompt:null,rev:null,rightMargin:W,rules:null,scheme:null,scrolling:at,standby:null,summary:null,text:null,topMargin:W,valueType:null,version:null,vAlign:null,vLink:null,vSpace:W,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ye,disableRemotePlayback:ye,prefix:null,property:null,results:W,security:null,unselectable:null},space:"html",transform:Ma}),gs=pr({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
1-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:Nt,accentHeight:W,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:W,amplitude:W,arabicForm:null,ascent:W,attributeName:null,attributeType:null,azimuth:W,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:W,by:null,calcMode:null,capHeight:W,className:Be,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:W,diffuseConstant:W,direction:null,display:null,dur:null,divisor:W,dominantBaseline:null,download:ye,dx:null,dy:null,edgeMode:null,editable:null,elevation:W,enableBackground:null,end:null,event:null,exponent:W,externalResourcesRequired:null,fill:null,fillOpacity:W,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:ur,g2:ur,glyphName:ur,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:W,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:W,horizOriginX:W,horizOriginY:W,id:null,ideographic:W,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:W,k:W,k1:W,k2:W,k3:W,k4:W,kernelMatrix:Nt,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:W,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:W,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,on
vendor: 5,398 bytes, lines 1-2
1Zoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:W,overlineThickness:W,paintOrder:null,panose1:null,path:null,pathLength:W,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Be,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:W,pointsAtY:W,pointsAtZ:W,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Nt,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Nt,rev:Nt,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Nt,requiredFeatures:Nt,requiredFonts:Nt,requiredFormats:Nt,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:W,specularExponent:W,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:W,strikethroughThickness:W,string:null,stroke:null,strokeDashArray:Nt,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:W,strokeOpacity:W,strokeWidth:null,style:null,surfaceScale:W,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Nt,tabIndex:W,tableValues:null,target:null,targetX:W,targetY:W,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Nt,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:W,underlineThickness:W,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:W,values:null,vAlphabetic:W,vMathematical:W,vectorEffect:null,vHanging:W,vIdeographic:W,version:null,vertAdvY:W,vertOriginX:W,vertOriginY:W,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:W,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:za}),Fa=pr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Aa=pr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ma}),Pa=pr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),xs={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"},ys=/[A-Z]/g,Mo=/-[a-z]/g,Ss=/^data[-\w.:]+$/i;function ks(e,t){const n=Ri(t);let r=t,i=Pt;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Ss.test(t)){if(t.charAt(4)==="-"){const a=t.slice(5).replace(Mo,ws);r="data"+a.charAt(0).toUpperCase()+a.slice(1)}else{const a=t.slice(4);if(!Mo.test(a)){let o=a.replace(ys,bs);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Yi}return new i(r,t)}function bs(e){return"-"+e.toLowerCase()}function ws(e){return e.charAt(1).toUpperCase()}const Ds=va([Ia,ms,Fa,Aa,Pa],"html"),Gi=va([Ia,gs,Fa,Aa,Pa],"svg");function js(e){return e.join(" ").trim()}var or={},gi,Fo;function Cs(){if(Fo)return gi;Fo=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,s=/^\s+|\s+$/g,d=`
2`,u="/",p="*",h="",x="comment",y="declaration";function C(O,M){if(typeof O!="string")throw new TypeError("First argument must be a string");if(!O)return[];M=M||{};var $=1,N=1;function ae(le){var Z=le.match(t);Z&&($+=Z.length);var we=le.lastIndexOf(d);N=~we?le.length-we:N+le.length}function X(){var le={line:$,column:N};return function(Z){return Z.position=new _(le),J(),Z}}function _(le){this.start=le,this.end={line:$,column:N},this.source=M.source}_.prototype.content=O;function F(le){var Z=new Error(M.source+":"+$+":"+N+": "+le);if(Z.reason=le,Z.filename=M.source,Z.line=$,Z.column=N,Z.source=O,!M.silent)throw Z}function V(le){var Z=le.exec(O);if(Z){var we=Z[0];return ae(we),O=O.slice(we.length),Z}}function J(){V(n)}function z(le){var Z;for(le=le||[];Z=G();)Z!==!1&&le.push(Z);return le}function G(){var le=X();if(!(u!=O.charAt(0)||p!=O.charAt(1))){for(var Z=2;h!=O.charAt(Z)&&(p!=O.charAt(Z)||u!=O.charAt(Z+1));)++Z;if(Z+=2,h===O.charAt(Z-1))return F("End of comment missing");var we=O.slice(2,Z-2);return N+=2,ae(we),O=O.slice(Z),N+=2,le({type:x,comment:we})}}function ee(){var le=X(),Z=V(r);if(Z){if(G(),!V(i))return F("property missing ':'");var we=V(a),Ae=le({type:y,property:L(Z[0].replace(e,h)),value:we?L(we[0].replace(e,h)):h});return V(o),Ae}}function he(){var le=[];z(le);for(var Z;Z=ee();)Z!==!1&&(le.push(Z),z(le));return le}return J(),he()}function L(O){return O?O.replace(s,h):h}return gi=C,gi}var Ao;function Es(){if(Ao)return or;Ao=1;var e=or&&or.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};
vendor: 3,714 bytes, line 2
2Object.defineProperty(or,"__esModule",{value:!0}),or.default=n;const t=e(Cs());function n(r,i){let a=null;if(!r||typeof r!="string")return a;const o=(0,t.default)(r),s=typeof i=="function";return o.forEach(d=>{if(d.type!=="declaration")return;const{property:u,value:p}=d;s?i(u,p,d):p&&(a=a||{},a[u]=p)}),a}return or}var jr={},Po;function vs(){if(Po)return jr;Po=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,a=function(u){return!u||n.test(u)||e.test(u)},o=function(u,p){return p.toUpperCase()},s=function(u,p){return"".concat(p,"-")},d=function(u,p){return p===void 0&&(p={}),a(u)?u:(u=u.toLowerCase(),p.reactCompat?u=u.replace(i,s):u=u.replace(r,s),u.replace(t,o))};return jr.camelCase=d,jr}var Cr,Ro;function Is(){if(Ro)return Cr;Ro=1;var e=Cr&&Cr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Es()),n=vs();function r(i,a){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(s,d){s&&d&&(o[(0,n.camelCase)(s,a)]=d)}),o}return r.default=r,Cr=r,Cr}var zs=Is();const Ms=wa(zs),Ra=Ta("end"),Qi=Ta("start");function Ta(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Fs(e){const t=Qi(e),n=Ra(e);if(t&&n)return{start:t,end:n}}function zr(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?To(e.position):"start"in e||"end"in e?To(e):"line"in e||"column"in e?Oi(e):""}function Oi(e){return Lo(e&&e.line)+":"+Lo(e&&e.column)}function To(e){return Oi(e&&e.start)+"-"+Oi(e&&e.end)}function Lo(e){return e&&typeof e=="number"?e:1}class jt extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",a={},o=!1;if(n&&("line"in n&&"column"in n?a={place:n}:"start"in n&&"end"in n?a={place:n}:"type"in n?a={ancestors:[n],place:n.position}:a={...n}),typeof t=="string"?i=t:!a.cause&&t&&(o=!0,i=t.message,a.cause=t),!a.ruleId&&!a.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?a.ruleId=r:(a.source=r.slice(0,d),a.ruleId=r.slice(d+1))}if(!a.place&&a.ancestors&&a.ancestors){const d=a.ancestors[a.ancestors.length-1];d&&(a.place=d.position)}const s=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=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=s?s.line:void 0,this.name=zr(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=o&&a.cause&&typeof a.cause.stack=="string"?a.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}jt.prototype.file="";jt.prototype.name="";jt.prototype.reason="";jt.prototype.message="";jt.prototype.stack="";jt.prototype.column=void 0;jt.prototype.line=void 0;jt.prototype.ancestors=void 0;jt.prototype.cause=void 0;jt.prototype.fatal=void 0;jt.prototype.place=void 0;jt.prototype.ruleId=void 0;jt.prototype.source=void 0;const Xi={}.hasOwnProperty,As=new Map,Ps=/[A-Z]/g,Rs=new Set(["table","tbody","thead","tfoot","tr"]),Ts=new Set(["td","th"]),La="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Ls(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Hs(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");
vendor: 5,854 bytes, line 2
2if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Us(n,t.jsx,t.jsxs)}const i={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:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Gi:Ds,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=Oa(i,e,void 0);return a&&typeof a!="string"?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function Oa(e,t,n){if(t.type==="element")return Os(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return _s(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Bs(e,t,n);if(t.type==="mdxjsEsm")return Vs(e,t);if(t.type==="root")return Ns(e,t,n);if(t.type==="text")return $s(e,t)}function Os(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Gi,e.schema=i),e.ancestors.push(t);const a=Va(e,t.tagName,!1),o=Ks(e,t);let s=Ji(e,t);return Rs.has(t.tagName)&&(s=s.filter(function(d){return typeof d=="string"?!hs(d):!0})),_a(e,o,a,t),Zi(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function _s(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Ar(e,t.position)}function Vs(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Ar(e,t.position)}function Bs(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Gi,e.schema=i),e.ancestors.push(t);const a=t.name===null?e.Fragment:Va(e,t.name,!0),o=Ws(e,t),s=Ji(e,t);return _a(e,o,a,t),Zi(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Ns(e,t,n){const r={};return Zi(r,Ji(e,t)),e.create(t,e.Fragment,r,n)}function $s(e,t){return t.value}function _a(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Zi(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Us(e,t,n){return r;function r(i,a,o,s){const u=Array.isArray(o.children)?n:t;return s?u(a,o,s):u(a,o)}}function Hs(e,t){return n;function n(r,i,a,o){const s=Array.isArray(a.children),d=Qi(r);return t(i,a,o,s,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function Ks(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Xi.call(t.properties,i)){const a=qs(e,i,t.properties[i]);if(a){const[o,s]=a;e.tableCellAlignToStyle&&o==="align"&&typeof s=="string"&&Ts.has(t.tagName)?r=s:n[o]=s}}if(r){const a=n.style||(n.style={});a[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ws(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const a=r.data.estree.body[0];a.type;const o=a.expression;o.type;const s=o.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else Ar(e,t.position);else{const i=r.name;let a;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,a=e.evaluater.evaluateExpression(s.expression)}else Ar(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function Ji(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:As;for(;++r<t.children.length;){const a=t.children[r];let o;if(e.passKeys){const d=a.type==="element"?a.tagName:a.type==="mdxJsxFlowElement"||a.type==="mdxJsxTextElement"?a.name:void 0;if(d){const u=i.get(d)||0;o=d+"-"+u,i.set(d,u+1)}}const s=Oa(e,a,o);s!==void 0&&n.push(s)}return n}function qs(e,t,n){const r=ks(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ss(n):js(n)),r.property==="style"){let i=typeof n=="object"?n:Ys(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Gs(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?xs[r.property]||r.property:r.attribute,n]}}function Ys(e,t){try{return Ms(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new jt("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=La+"#cannot-parse-style-attribute",i}}function Va(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let a=-1,o;for(;++a<i.length;){const s=vo(i[a])?{type:"Identifier",name:i[a]}:{type:"Literal",value:i[a]};o=o?{type:"MemberExpression",object:o,property:s,computed:!!(a&&s.type==="Literal"),optional:!1}:s}r=o}else r=vo(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Xi.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Ar(e)}function Ar(e,t){const n=new jt("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=La+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Gs(e){const t={};let n;for(n in e)Xi.call(e,n)&&(t[Qs(n)]=e[n]);return t}function Qs(e){let t=e.replace(Ps,Xs);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Xs(e){return"-"+e.toLowerCase()}const xi={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"]},Zs={};function eo(e,t){const n=Zs,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Ba(e,r,i)}
vendor: 13,167 bytes, line 2
2function Ba(e,t,n){if(Js(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Oo(e.children,t,n)}return Array.isArray(e)?Oo(e,t,n):""}function Oo(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Ba(e[i],t,n);return r.join("")}function Js(e){return!!(e&&typeof e=="object")}const _o=document.createElement("i");function to(e){const t="&"+e+";";_o.innerHTML=t;const n=_o.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function $t(e,t,n,r){const i=e.length;let a=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function qt(e,t){return e.length>0?($t(e,e.length,0,t),e):t}const Vo={}.hasOwnProperty;function Na(e){const t={};let n=-1;for(;++n<e.length;)ec(t,e[n]);return t}function ec(e,t){let n;for(n in t){const i=(Vo.call(e,n)?e[n]:void 0)||(e[n]={}),a=t[n];let o;if(a)for(o in a){Vo.call(i,o)||(i[o]=[]);const s=a[o];tc(i[o],Array.isArray(s)?s:s?[s]:[])}}}function tc(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);$t(e,0,0,r)}function $a(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function nn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const vt=zn(/[A-Za-z]/),Dt=zn(/[\dA-Za-z]/),nc=zn(/[#-'*+\--9=?A-Z^-~]/);function ti(e){return e!==null&&(e<32||e===127)}const _i=zn(/\d/),rc=zn(/[\dA-Fa-f]/),ic=zn(/[!-/:-@[-`{-~]/);function ue(e){return e!==null&&e<-2}function _e(e){return e!==null&&(e<0||e===32)}function be(e){return e===-2||e===-1||e===32}const ai=zn(new RegExp("\\p{P}|\\p{S}","u")),Un=zn(/\s/);function zn(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function mr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const a=e.charCodeAt(n);let o="";if(a===37&&Dt(e.charCodeAt(n+1))&&Dt(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){const s=e.charCodeAt(n+1);a<56320&&s>56319&&s<57344?(o=String.fromCharCode(a,s),i=1):o="�"}else o=String.fromCharCode(a);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ee(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let a=0;return o;function o(d){return be(d)?(e.enter(n),s(d)):t(d)}function s(d){return be(d)&&a++<i?(e.consume(d),s):(e.exit(n),t(d))}}const oc={tokenize:ac};function ac(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Ee(e,t,"linePrefix")}function i(s){return e.enter("paragraph"),a(s)}function a(s){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,o(s)}function o(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return ue(s)?(e.consume(s),e.exit("chunkText"),a):(e.consume(s),o)}}const lc={tokenize:sc},Bo={tokenize:cc};function sc(e){const t=this,n=[];let r=0,i,a,o;return s;function s(N){if(r<n.length){const ae=n[r];return t.containerState=ae[1],e.attempt(ae[0].continuation,d,u)(N)}return u(N)}function d(N){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&$();const ae=t.events.length;let X=ae,_;for(;X--;)if(t.events[X][0]==="exit"&&t.events[X][1].type==="chunkFlow"){_=t.events[X][1].end;break}M(r);let F=ae;for(;F<t.events.length;)t.events[F][1].end={..._},F++;return $t(t.events,X+1,0,t.events.slice(ae)),t.events.length=F,u(N)}return s(N)}function u(N){if(r===n.length){if(!i)return x(N);if(i.currentConstruct&&i.currentConstruct.concrete)return C(N);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Bo,p,h)(N)}function p(N){return i&&$(),M(r),x(N)}function h(N){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,C(N)}function x(N){return t.containerState={},e.attempt(Bo,y,C)(N)}function y(N){return r++,n.push([t.currentConstruct,t.containerState]),x(N)}function C(N){if(N===null){i&&$(),M(0),e.consume(N);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:a}),L(N)}function L(N){if(N===null){O(e.exit("chunkFlow"),!0),M(0),e.consume(N);return}return ue(N)?(e.consume(N),O(e.exit("chunkFlow")),r=0,t.interrupt=void 0,s):(e.consume(N),L)}function O(N,ae){const X=t.sliceStream(N);if(ae&&X.push(null),N.previous=a,a&&(a.next=N),a=N,i.defineSkip(N.start),i.write(X),t.parser.lazy[N.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<o&&(!i.events[_][1].end||i.events[_][1].end.offset>o))return;const F=t.events.length;let V=F,J,z;for(;V--;)if(t.events[V][0]==="exit"&&t.events[V][1].type==="chunkFlow"){if(J){z=t.events[V][1].end;break}J=!0}for(M(r),_=F;_<t.events.length;)t.events[_][1].end={...z},_++;$t(t.events,V+1,0,t.events.slice(F)),t.events.length=_}}function M(N){let ae=n.length;for(;ae-- >N;){const X=n[ae];t.containerState=X[1],X[0].exit.call(t,e)}n.length=N}function $(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function cc(e,t,n){return Ee(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function dr(e){if(e===null||_e(e)||Un(e))return 1;if(ai(e))return 2}function li(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}const Vi={name:"attention",resolveAll:uc,tokenize:dc};function uc(e,t){let n=-1,r,i,a,o,s,d,u,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},x={...e[n][1].start};No(h,-d),No(x,d),o={type:d>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},s={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},a={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:d>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=qt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=qt(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",a,t]]),u=qt(u,li(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=qt(u,[["exit",a,t],["enter",s,t],["exit",s,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,u=qt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,$t(e,r-1,n-r+3,u),n=r+u.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function dc(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=dr(r);let a;return o;function o(d){return a=d,e.enter("attentionSequence"),s(d)}function s(d){if(d===a)return e.consume(d),s;const u=e.exit("attentionSequence"),p=dr(d),h=!p||p===2&&i||n.includes(d),x=!i||i===2&&p||n.includes(r);return u._open=!!(a===42?h:h&&(i||!x)),u._close=!!(a===42?x:x&&(p||!h)),t(d)}}function No(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const fc={name:"autolink",tokenize:hc};function hc(e,t,n){let r=0;return i;function i(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),a}function a(y){return vt(y)?(e.consume(y),o):y===64?n(y):u(y)}function o(y){return y===43||y===45||y===46||Dt(y)?(r=1,s(y)):u(y)}function s(y){return y===58?(e.consume(y),r=0,d):(y===43||y===45||y===46||Dt(y))&&r++<32?(e.consume(y),s):(r=0,u(y))}function d(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||ti(y)?n(y):(e.consume(y),d)}function u(y){return y===64?(e.consume(y),p):nc(y)?(e.consume(y),u):n(y)}function p(y){return Dt(y)?h(y):n(y)}function h(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):x(y)}function x(y){if((y===45||Dt(y))&&r++<63){const C=y===45?x:h;return e.consume(y),C}return n(y)}}const Lr={partial:!0,tokenize:pc};function pc(e,t,n){return r;function r(a){return be(a)?Ee(e,i,"linePrefix")(a):i(a)}function i(a){return a===null||ue(a)?t(a):n(a)}}const Ua={continuation:{tokenize:gc},exit:xc,name:"blockQuote",tokenize:mc};function mc(e,t,n){const r=this;return i;function i(o){if(o===62){const s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),a}return n(o)}function a(o){return be(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function gc(e,t,n){const r=this;return i;function i(o){return be(o)?Ee(e,a,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):a(o)}function a(o){return e.attempt(Ua,t,n)(o)}}function xc(e){e.exit("blockQuote")}const Ha={name:"characterEscape",tokenize:yc};function yc(e,t,n){return r;function r(a){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(a),e.exit("escapeMarker"),i}function i(a){return ic(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}const Ka={name:"characterReference",tokenize:Sc};function Sc(e,t,n){const r=this;let i=0,a,o;return s;function s(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),d}function d(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),a=31,o=Dt,p(h))}function u(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),a=6,o=rc,p):(e.enter("characterReferenceValue"),a=7,o=_i,p(h))}function p(h){if(h===59&&i){const x=e.exit("characterReferenceValue");return o===Dt&&!to(r.sliceSerialize(x))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(h)&&i++<a?(e.consume(h),p):n(h)}}const $o={partial:!0,tokenize:bc},Uo={concrete:!0,name:"codeFenced",tokenize:kc};function kc(e,t,n){const r=this,i={partial:!0,tokenize:X};let a=0,o=0,s;return d;function d(_){return u(_)}function u(_){const F=r.events[r.events.length-1];return a=F&&F[1].type==="linePrefix"?F[2].sliceSerialize(F[1],!0).length:0,s=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(_)}function p(_){return _===s?(o++,e.consume(_),p):o<3?n(_):(e.exit("codeFencedFenceSequence"),be(_)?Ee(e,h,"whitespace")(_):h(_))}function h(_){return _===null||ue(_)?(e.exit("codeFencedFence"),r.interrupt?t(_):e.check($o,L,ae)(_)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(_))}function x(_){return _===null||ue(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(_)):be(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ee(e,y,"whitespace")(_)):_===96&&_===s?n(_):(e.consume(_),x)}function y(_){return _===null||ue(_)?h(_):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),C(_))}function C(_){return _===null||ue(_)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(_)):_===96&&_===s?n(_):(e.consume(_),C)}function L(_){return e.attempt(i,ae,O)(_)}function O(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),M}function M(_){return a>0&&be(_)?Ee(e,$,"linePrefix",a+1)(_):$(_)}function $(_){return _===null||ue(_)?e.check($o,L,ae)(_):(e.enter("codeFlowValue"),N(_))}function N(_){return _===null||ue(_)?(e.exit("codeFlowValue"),$(_)):(e.consume(_),N)}function ae(_){return e.exit("codeFenced"),t(_)}function X(_,F,V){let J=0;return z;function z(Z){return _.enter("lineEnding"),_.consume(Z),_.exit("lineEnding"),G}function G(Z){return _.enter("codeFencedFence"),be(Z)?Ee(_,ee,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Z):ee(Z)}function ee(Z){return Z===s?(_.enter("codeFencedFenceSequence"),he(Z)):V(Z)}function he(Z){return Z===s?(J++,_.consume(Z),he):J>=o?(_.exit("codeFencedFenceSequence"),be(Z)?Ee(_,le,"whitespace")(Z):le(Z)):V(Z)}function le(Z){return Z===null||ue(Z)?(_.exit("codeFencedFence"),F(Z)):V(Z)}}}
vendor: 5,365 bytes, line 2
2function bc(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const yi={name:"codeIndented",tokenize:Dc},wc={partial:!0,tokenize:jc};function Dc(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),Ee(e,a,"linePrefix",5)(u)}function a(u){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?d(u):ue(u)?e.attempt(wc,o,d)(u):(e.enter("codeFlowValue"),s(u))}function s(u){return u===null||ue(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),s)}function d(u){return e.exit("codeIndented"),t(u)}}function jc(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):ue(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ee(e,a,"linePrefix",5)(o)}function a(o){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):ue(o)?i(o):n(o)}}const Cc={name:"codeText",previous:vc,resolve:Ec,tokenize:Ic};function Ec(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function vc(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Ic(e,t,n){let r=0,i,a;return o;function o(h){return e.enter("codeText"),e.enter("codeTextSequence"),s(h)}function s(h){return h===96?(e.consume(h),r++,s):(e.exit("codeTextSequence"),d(h))}function d(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),d):h===96?(a=e.enter("codeTextSequence"),i=0,p(h)):ue(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("codeTextData"),u(h))}function u(h){return h===null||h===32||h===96||ue(h)?(e.exit("codeTextData"),d(h)):(e.consume(h),u)}function p(h){return h===96?(e.consume(h),i++,p):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(a.type="codeTextData",u(h))}}class zc{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const a=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Er(this.left,r),a.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Er(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Er(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Er(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Er(this.left,n.reverse())}}}function Er(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 Wa(e){const t={};let n=-1,r,i,a,o,s,d,u;const p=new zc(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,a=0,a<d.length&&d[a][1].type==="lineEndingBlank"&&(a+=2),a<d.length&&d[a][1].type==="content"))for(;++a<d.length&&d[a][1].type!=="content";)d[a][1].type==="chunkText"&&(d[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Mc(p,n)),n=t[n],u=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=p.get(a),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(p.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=a);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...p.get(i)[1].start},s=p.slice(i,n),s.unshift(r),p.splice(i,n-i+1,s))}}return $t(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!u}function Mc(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const a=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,d=[],u={};let p,h,x=-1,y=n,C=0,L=0;const O=[L];for(;y;){for(;e.get(++i)[1]!==y;);a.push(i),y._tokenizer||(p=r.sliceStream(y),y.next||p.push(null),h&&o.defineSki
vendor: 21,850 bytes, line 2
2p(y.start),y._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(p),y._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),h=y,y=y.next}for(y=n;++x<s.length;)s[x][0]==="exit"&&s[x-1][0]==="enter"&&s[x][1].type===s[x-1][1].type&&s[x][1].start.line!==s[x][1].end.line&&(L=x+1,O.push(L),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(o.events=[],y?(y._tokenizer=void 0,y.previous=void 0):O.pop(),x=O.length;x--;){const M=s.slice(O[x],O[x+1]),$=a.pop();d.push([$,$+M.length-1]),e.splice($,2,M)}for(d.reverse(),x=-1;++x<d.length;)u[C+d[x][0]]=C+d[x][1],C+=d[x][1]-d[x][0]-1;return u}const Fc={resolve:Pc,tokenize:Rc},Ac={partial:!0,tokenize:Tc};function Pc(e){return Wa(e),e}function Rc(e,t){let n;return r;function r(s){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(s)}function i(s){return s===null?a(s):ue(s)?e.check(Ac,o,a)(s):(e.consume(s),i)}function a(s){return e.exit("chunkContent"),e.exit("content"),t(s)}function o(s){return e.consume(s),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Tc(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ee(e,a,"linePrefix")}function a(o){if(o===null||ue(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function qa(e,t,n,r,i,a,o,s,d){const u=d||Number.POSITIVE_INFINITY;let p=0;return h;function h(M){return M===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(M),e.exit(a),x):M===null||M===32||M===41||ti(M)?n(M):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),L(M))}function x(M){return M===62?(e.enter(a),e.consume(M),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),y(M))}function y(M){return M===62?(e.exit("chunkString"),e.exit(s),x(M)):M===null||M===60||ue(M)?n(M):(e.consume(M),M===92?C:y)}function C(M){return M===60||M===62||M===92?(e.consume(M),y):y(M)}function L(M){return!p&&(M===null||M===41||_e(M))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(M)):p<u&&M===40?(e.consume(M),p++,L):M===41?(e.consume(M),p--,L):M===null||M===32||M===40||ti(M)?n(M):(e.consume(M),M===92?O:L)}function O(M){return M===40||M===41||M===92?(e.consume(M),L):L(M)}}function Ya(e,t,n,r,i,a){const o=this;let s=0,d;return u;function u(y){return e.enter(r),e.enter(i),e.consume(y),e.exit(i),e.enter(a),p}function p(y){return s>999||y===null||y===91||y===93&&!d||y===94&&!s&&"_hiddenFootnoteSupport"in o.parser.constructs?n(y):y===93?(e.exit(a),e.enter(i),e.consume(y),e.exit(i),e.exit(r),t):ue(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===null||y===91||y===93||ue(y)||s++>999?(e.exit("chunkString"),p(y)):(e.consume(y),d||(d=!be(y)),y===92?x:h)}function x(y){return y===91||y===92||y===93?(e.consume(y),s++,h):h(y)}}function Ga(e,t,n,r,i,a){let o;return s;function s(x){return x===34||x===39||x===40?(e.enter(r),e.enter(i),e.consume(x),e.exit(i),o=x===40?41:x,d):n(x)}function d(x){return x===o?(e.enter(i),e.consume(x),e.exit(i),e.exit(r),t):(e.enter(a),u(x))}function u(x){return x===o?(e.exit(a),d(o)):x===null?n(x):ue(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),Ee(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===o||x===null||ue(x)?(e.exit("chunkString"),u(x)):(e.consume(x),x===92?h:p)}function h(x){return x===o||x===92?(e.consume(x),p):p(x)}}function Mr(e,t){let n;return r;function r(i){return ue(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):be(i)?Ee(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Lc={name:"definition",tokenize:_c},Oc={partial:!0,tokenize:Vc};function _c(e,t,n){const r=this;let i;return a;function a(y){return e.enter("definition"),o(y)}function o(y){return Ya.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function s(y){return i=nn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),d):n(y)}function d(y){return _e(y)?Mr(e,u)(y):u(y)}function u(y){return qa(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(Oc,h,h)(y)}function h(y){return be(y)?Ee(e,x,"whitespace")(y):x(y)}function x(y){return y===null||ue(y)?(e.exit("definition"),r.parser.defined.push(i),t(y)):n(y)}}function Vc(e,t,n){return r;function r(s){return _e(s)?Mr(e,i)(s):n(s)}function i(s){return Ga(e,a,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function a(s){return be(s)?Ee(e,o,"whitespace")(s):o(s)}function o(s){return s===null||ue(s)?t(s):n(s)}}const Bc={name:"hardBreakEscape",tokenize:Nc};function Nc(e,t,n){return r;function r(a){return e.enter("hardBreakEscape"),e.consume(a),i}function i(a){return ue(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}const $c={name:"headingAtx",resolve:Uc,tokenize:Hc};function Uc(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},a={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},$t(e,r,n-r+1,[["enter",i,t],["enter",a,t],["exit",a,t],["exit",i,t]])),e}function Hc(e,t,n){let r=0;return i;function i(p){return e.enter("atxHeading"),a(p)}function a(p){return e.enter("atxHeadingSequence"),o(p)}function o(p){return p===35&&r++<6?(e.consume(p),o):p===null||_e(p)?(e.exit("atxHeadingSequence"),s(p)):n(p)}function s(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||ue(p)?(e.exit("atxHeading"),t(p)):be(p)?Ee(e,s,"whitespace")(p):(e.enter("atxHeadingText"),u(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),s(p))}function u(p){return p===null||p===35||_e(p)?(e.exit("atxHeadingText"),s(p)):(e.consume(p),u)}}const Kc=["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"],Ho=["pre","script","style","textarea"],Wc={concrete:!0,name:"htmlFlow",resolveTo:Gc,tokenize:Qc},qc={partial:!0,tokenize:Zc},Yc={partial:!0,tokenize:Xc};function Gc(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Qc(e,t,n){const r=this;let i,a,o,s,d;return u;function u(v){return p(v)}function p(v){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(v),h}function h(v){return v===33?(e.consume(v),x):v===47?(e.consume(v),a=!0,L):v===63?(e.consume(v),i=3,r.interrupt?t:E):vt(v)?(e.consume(v),o=String.fromCharCode(v),O):n(v)}function x(v){return v===45?(e.consume(v),i=2,y):v===91?(e.consume(v),i=5,s=0,C):vt(v)?(e.consume(v),i=4,r.interrupt?t:E):n(v)}function y(v){return v===45?(e.consume(v),r.interrupt?t:E):n(v)}function C(v){const Ze="CDATA[";return v===Ze.charCodeAt(s++)?(e.consume(v),s===Ze.length?r.interrupt?t:ee:C):n(v)}function L(v){return vt(v)?(e.consume(v),o=String.fromCharCode(v),O):n(v)}function O(v){if(v===null||v===47||v===62||_e(v)){const Ze=v===47,Rt=o.toLowerCase();return!Ze&&!a&&Ho.includes(Rt)?(i=1,r.interrupt?t(v):ee(v)):Kc.includes(o.toLowerCase())?(i=6,Ze?(e.consume(v),M):r.interrupt?t(v):ee(v)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(v):a?$(v):N(v))}return v===45||Dt(v)?(e.consume(v),o+=String.fromCharCode(v),O):n(v)}function M(v){return v===62?(e.consume(v),r.interrupt?t:ee):n(v)}function $(v){return be(v)?(e.consume(v),$):z(v)}function N(v){return v===47?(e.consume(v),z):v===58||v===95||vt(v)?(e.consume(v),ae):be(v)?(e.consume(v),N):z(v)}function ae(v){return v===45||v===46||v===58||v===95||Dt(v)?(e.consume(v),ae):X(v)}function X(v){return v===61?(e.consume(v),_):be(v)?(e.consume(v),X):N(v)}function _(v){return v===null||v===60||v===61||v===62||v===96?n(v):v===34||v===39?(e.consume(v),d=v,F):be(v)?(e.consume(v),_):V(v)}function F(v){return v===d?(e.consume(v),d=null,J):v===null||ue(v)?n(v):(e.consume(v),F)}function V(v){return v===null||v===34||v===39||v===47||v===60||v===61||v===62||v===96||_e(v)?X(v):(e.consume(v),V)}function J(v){return v===47||v===62||be(v)?N(v):n(v)}function z(v){return v===62?(e.consume(v),G):n(v)}function G(v){return v===null||ue(v)?ee(v):be(v)?(e.consume(v),G):n(v)}function ee(v){return v===45&&i===2?(e.consume(v),we):v===60&&i===1?(e.consume(v),Ae):v===62&&i===4?(e.consume(v),nt):v===63&&i===3?(e.consume(v),E):v===93&&i===5?(e.consume(v),xt):ue(v)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(qc,ht,he)(v)):v===null||ue(v)?(e.exit("htmlFlowData"),he(v)):(e.consume(v),ee)}function he(v){return e.check(Yc,le,ht)(v)}function le(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),Z}function Z(v){return v===null||ue(v)?he(v):(e.enter("htmlFlowData"),ee(v))}function we(v){return v===45?(e.consume(v),E):ee(v)}function Ae(v){return v===47?(e.consume(v),o="",ze):ee(v)}function ze(v){if(v===62){const Ze=o.toLowerCase();return Ho.includes(Ze)?(e.consume(v),nt):ee(v)}return vt(v)&&o.length<8?(e.consume(v),o+=String.fromCharCode(v),ze):ee(v)}function xt(v){return v===93?(e.consume(v),E):ee(v)}function E(v){return v===62?(e.consume(v),nt):v===45&&i===2?(e.consume(v),E):ee(v)}function nt(v){return v===null||ue(v)?(e.exit("htmlFlowData"),ht(v)):(e.consume(v),nt)}function ht(v){return e.exit("htmlFlow"),t(v)}}function Xc(e,t,n){const r=this;return i;function i(o){return ue(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):n(o)}function a(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Zc(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Lr,t,n)}}const Jc={name:"htmlText",tokenize:eu};function eu(e,t,n){const r=this;let i,a,o;return s;function s(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),d}function d(E){return E===33?(e.consume(E),u):E===47?(e.consume(E),X):E===63?(e.consume(E),N):vt(E)?(e.consume(E),V):n(E)}function u(E){return E===45?(e.consume(E),p):E===91?(e.consume(E),a=0,C):vt(E)?(e.consume(E),$):n(E)}function p(E){return E===45?(e.consume(E),y):n(E)}function h(E){return E===null?n(E):E===45?(e.consume(E),x):ue(E)?(o=h,Ae(E)):(e.consume(E),h)}function x(E){return E===45?(e.consume(E),y):h(E)}function y(E){return E===62?we(E):E===45?x(E):h(E)}function C(E){const nt="CDATA[";return E===nt.charCodeAt(a++)?(e.consume(E),a===nt.length?L:C):n(E)}function L(E){return E===null?n(E):E===93?(e.consume(E),O):ue(E)?(o=L,Ae(E)):(e.consume(E),L)}function O(E){return E===93?(e.consume(E),M):L(E)}function M(E){return E===62?we(E):E===93?(e.consume(E),M):L(E)}function $(E){return E===null||E===62?we(E):ue(E)?(o=$,Ae(E)):(e.consume(E),$)}function N(E){return E===null?n(E):E===63?(e.consume(E),ae):ue(E)?(o=N,Ae(E)):(e.consume(E),N)}function ae(E){return E===62?we(E):N(E)}function X(E){return vt(E)?(e.consume(E),_):n(E)}function _(E){return E===45||Dt(E)?(e.consume(E),_):F(E)}function F(E){return ue(E)?(o=F,Ae(E)):be(E)?(e.consume(E),F):we(E)}function V(E){return E===45||Dt(E)?(e.consume(E),V):E===47||E===62||_e(E)?J(E):n(E)}function J(E){return E===47?(e.consume(E),we):E===58||E===95||vt(E)?(e.consume(E),z):ue(E)?(o=J,Ae(E)):be(E)?(e.consume(E),J):we(E)}function z(E){return E===45||E===46||E===58||E===95||Dt(E)?(e.consume(E),z):G(E)}function G(E){return E===61?(e.consume(E),ee):ue(E)?(o=G,Ae(E)):be(E)?(e.consume(E),G):J(E)}function ee(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,he):ue(E)?(o=ee,Ae(E)):be(E)?(e.consume(E),ee):(e.consume(E),le)}function he(E){return E===i?(e.consume(E),i=void 0,Z):E===null?n(E):ue(E)?(o=he,Ae(E)):(e.consume(E),he)}function le(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||_e(E)?J(E):(e.consume(E),le)}function Z(E){return E===47||E===62||_e(E)?J(E):n(E)}function we(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function Ae(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),ze}function ze(E){return be(E)?Ee(e,xt,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):xt(E)}function xt(E){return e.enter("htmlTextData"),o(E)}}const no={name:"labelEnd",resolveAll:iu,resolveTo:ou,tokenize:au},tu={tokenize:lu},nu={tokenize:su},ru={tokenize:cu};function iu(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&$t(e,0,e.length,n),e}function ou(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(a=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const d={type:e[a][1].type==="labelLink"?"link":"image",start:{...e[a][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[a][1].start},end:{...e[o][1].end}},p={type:"labelText",start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[["enter",d,t],["enter",u,t]],s=qt(s,e.slice(a+1,a+r+3)),s=qt(s,[["enter",p,t]]),s=qt(s,li(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=qt(s,[["exit",p,t],e[o-2],e[o-1],["exit",u,t]]),s=qt(s,e.slice(o+1)),s=qt(s,[["exit",d,t]]),$t(e,a,e.length,s),e}function au(e,t,n){const r=this;let i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(x){return a?a._inactive?h(x):(o=r.parser.defined.includes(nn(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),d):n(x)}function d(x){return x===40?e.attempt(tu,p,o?p:h)(x):x===91?e.attempt(nu,p,o?u:h)(x):o?p(x):h(x)}function u(x){return e.attempt(ru,p,h)(x)}function p(x){return t(x)}function h(x){return a._balanced=!0,n(x)}}function lu(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return _e(h)?Mr(e,a)(h):a(h)}function a(h){return h===41?p(h):qa(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return _e(h)?Mr(e,d)(h):p(h)}function s(h){return n(h)}function d(h){return h===34||h===39||h===40?Ga(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):p(h)}function u(h){return _e(h)?Mr(e,p)(h):p(h)}function p(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function su(e,t,n){const r=this;return i;function i(s){return Ya.call(r,e,a,o,"reference","referenceMarker","referenceString")(s)}function a(s){return r.parser.defined.includes(nn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function cu(e,t,n){return r;function r(a){return e.enter("reference"),e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),i}function i(a){return a===93?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}const uu={name:"labelStartImage",resolveAll:no.resolveAll,tokenize:du};function du(e,t,n){const r=this;return i;function i(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),a}function a(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),o):n(s)}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}const fu={name:"labelStartLink",resolveAll:no.resolveAll,tokenize:hu};function hu(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),a}function a(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Si={name:"lineEnding",tokenize:pu};function pu(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ee(e,t,"linePrefix")}}const Zr={name:"thematicBreak",tokenize:mu};function mu(e,t,n){let r=0,i;return a;function a(u){return e.enter("thematicBreak"),o(u)}function o(u){return i=u,s(u)}function s(u){return u===i?(e.enter("thematicBreakSequence"),d(u)):r>=3&&(u===null||ue(u))?(e.exit("thematicBreak"),t(u)):n(u)}function d(u){return u===i?(e.consume(u),r++,d):(e.exit("thematicBreakSequence"),be(u)?Ee(e,s,"whitespace")(u):s(u))}}const At={continuation:{tokenize:Su},exit:bu,name:"list",tokenize:yu},gu={partial:!0,tokenize:wu},xu={partial:!0,tokenize:ku};function yu(e,t,n){const r=this,i=r.events[r.events.length-1];let a=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(y){const C=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(C==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:_i(y)){if(r.containerState.type||(r.containerState.type=C,e.enter(C,{_container:!0})),C==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(Zr,n,u)(y):u(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(y)}return n(y)}function d(y){return _i(y)&&++o<10?(e.consume(y),d):(!r.interrupt||o<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),u(y)):n(y)}function u(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(Lr,r.interrupt?n:p,e.attempt(gu,x,h))}function p(y){return r.containerState.initialBlankLine=!0,a++,x(y)}function h(y){return be(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),x):n(y)}function x(y){return r.containerState.size=a+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function Su(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Lr,i,a);function i(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ee(e,t,"listItemIndent",r.containerState.size+1)(s)}function a(s){return r.containerState.furtherBlankLines||!be(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(xu,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ee(e,e.attempt(At,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function ku(e,t,n){const r=this;return Ee(e,i,"listItemIndent",r.containerState.size+1);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(a):n(a)}}function bu(e){e.exit(this.containerState.type)}function wu(e,t,n){const r=this;return Ee(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(a){const o=r.events[r.events.length-1];return!be(a)&&o&&o[1].type==="listItemPrefixWhitespace"?t(a):n(a)}}const Ko={name:"setextUnderline",resolveTo:Du,tokenize:ju};function Du(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!a&&e[n][1].type==="definition"&&(a=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",a?(e.splice(i,0,["enter",o,t]),e.splice(a+1,0,["exit",e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function ju(e,t,n){const r=this;let i;return a;function a(u){let p=r.events.length,h;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){h=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),s(u)}function s(u){return u===i?(e.consume(u),s):(e.exit("setextHeadingLineSequence"),be(u)?Ee(e,d,"lineSuffix")(u):d(u))}function d(u){return u===null||ue(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Cu={tokenize:Eu};function Eu(e){const t=this,n=e.attempt(Lr,r,e.attempt(this.parser.constructs.flowInitial,i,Ee(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Fc,i)),"linePrefix")));return n;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const vu={resolveAll:Xa()}
vendor: 4,195 bytes, line 2
2,Iu=Qa("string"),zu=Qa("text");function Qa(e){return{resolveAll:Xa(e==="text"?Mu:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],a=n.attempt(i,o,s);return o;function o(p){return u(p)?a(p):s(p)}function s(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),d}function d(p){return u(p)?(n.exit("data"),a(p)):(n.consume(p),d)}function u(p){if(p===null)return!0;const h=i[p];let x=-1;if(h)for(;++x<h.length;){const y=h[x];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function Xa(e){return t;function t(n,r){let i=-1,a;for(;++i<=n.length;)a===void 0?n[i]&&n[i][1].type==="data"&&(a=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==a+2&&(n[a][1].end=n[i-1][1].end,n.splice(a+2,i-a-2),i=a+2),a=void 0);return e?e(n,r):n}}function Mu(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let a=i.length,o=-1,s=0,d;for(;a--;){const u=i[a];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(u===-2)d=!0,s++;else if(u!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const u={type:n===e.length||d||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Fu={42:At,43:At,45:At,48:At,49:At,50:At,51:At,52:At,53:At,54:At,55:At,56:At,57:At,62:Ua},Au={91:Lc},Pu={[-2]:yi,[-1]:yi,32:yi},Ru={35:$c,42:Zr,45:[Ko,Zr],60:Wc,61:Ko,95:Zr,96:Uo,126:Uo},Tu={38:Ka,92:Ha},Lu={[-5]:Si,[-4]:Si,[-3]:Si,33:uu,38:Ka,42:Vi,60:[fc,Jc],91:fu,92:[Bc,Ha],93:no,95:Vi,96:Cc},Ou={null:[Vi,vu]},_u={null:[42,95]},Vu={null:[]},Bu=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:_u,contentInitial:Au,disable:Vu,document:Fu,flow:Ru,flowInitial:Pu,insideSpan:Ou,string:Tu,text:Lu},Symbol.toStringTag,{value:"Module"}));function Nu(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 i={},a=[];let o=[],s=[];const d={attempt:F(X),check:F(_),consume:$,enter:N,exit:ae,interrupt:F(_,{interrupt:!0})},u={code:null,containerState:{},defineSkip:L,events:[],now:C,parser:e,previous:null,sliceSerialize:x,sliceStream:y,write:h};let p=t.tokenize.call(u,d);return t.resolveAll&&a.push(t),u;function h(G){return o=qt(o,G),O(),o[o.length-1]!==null?[]:(V(t,0),u.events=li(a,u.events,u),u.events)}function x(G,ee){return Uu(y(G),ee)}function y(G){return $u(o,G)}function C(){const{_bufferIndex:G,_index:ee,line:he,column:le,offset:Z}=r;return{_bufferIndex:G,_index:ee,line:he,column:le,offset:Z}}function L(G){i[G.line]=G.column,z()}function O(){let G;for(;r._index<o.length;){const ee=o[r._index];if(typeof ee=="string")for(G=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===G&&r._bufferIndex<ee.length;)M(ee.charCodeAt(r._bufferIndex));else M(ee)}}function M(G){p=p(G)}function $(G){ue(G)?(r.line++,r.column=1,r.offset+=G===-3?2:1,z()):G!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=G}function N(G,ee){const he=ee||{};return he.type=G,he.start=C(),u.events.push(["enter",he,u]),s.push(he),he}function ae(G){const ee=s.pop();return ee.end=C(),u.events.push(["exit",ee,u]),ee}function X(G,ee){V(G,ee.from)}function _(G,ee){ee.restore()}function F(G,ee){return he;function he(le,Z,we){let Ae,ze,xt,E;return Array.isArray(le)?ht(le):"tokenize"in le?ht([le]):nt(le);function nt(pe){return Ct;function Ct(Ve){const He=Ve!==null&&pe[Ve],yt=Ve!==null&&pe.null,Tt=[...Array.isArray(He)?He:He?[He]:[],...Array.isArray(yt)?yt:yt?[yt]:[]];return ht(Tt)(Ve)}}function ht(pe){return Ae=pe,ze=0,pe.length===0?we:v(pe[ze])}function v(pe){return Ct;function Ct(Ve){return E=J(),xt=pe,pe.partial||(u.currentConstruct=pe),pe.name&&u.parser.constructs.disable.null.includes(pe.name)?Rt():pe.tokenize.call(ee?Object.assign(Object.create(u),ee):u,d,Ze,Rt)(Ve)}}function Ze(pe){return G(xt,E),Z}
vendor: 12,622 bytes, lines 2-4
2function Rt(pe){return E.restore(),++ze<Ae.length?v(Ae[ze]):we}}}function V(G,ee){G.resolveAll&&!a.includes(G)&&a.push(G),G.resolve&&$t(u.events,ee,u.events.length-ee,G.resolve(u.events.slice(ee),u)),G.resolveTo&&(u.events=G.resolveTo(u.events,u))}function J(){const G=C(),ee=u.previous,he=u.currentConstruct,le=u.events.length,Z=Array.from(s);return{from:le,restore:we};function we(){r=G,u.previous=ee,u.currentConstruct=he,u.events.length=le,s=Z,z()}}function z(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function $u(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){const s=o[0];typeof s=="string"?o[0]=s.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Uu(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const a=e[n];let o;if(typeof a=="string")o=a;else switch(a){case-5:{o="\r";break}case-4:{o=`
3`;break}case-3:{o=`\r
4`;break}case-2:{o=t?" ":"	";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join("")}function Hu(e){const r={constructs:Na([Bu,...(e||{}).extensions||[]]),content:i(oc),defined:[],document:i(lc),flow:i(Cu),lazy:{},string:i(Iu),text:i(zu)};return r;function i(a){return o;function o(s){return Nu(r,a,s)}}}function Ku(e){for(;!Wa(e););return e}const Wo=/[\0\t\n\r]/g;function Wu(){let e=1,t="",n=!0,r;return i;function i(a,o,s){const d=[];let u,p,h,x,y;for(a=t+(typeof a=="string"?a.toString():new TextDecoder(o||void 0).decode(a)),h=0,t="",n&&(a.charCodeAt(0)===65279&&h++,n=void 0);h<a.length;){if(Wo.lastIndex=h,u=Wo.exec(a),x=u&&u.index!==void 0?u.index:a.length,y=a.charCodeAt(x),!u){t=a.slice(h);break}if(y===10&&h===x&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),h<x&&(d.push(a.slice(h,x)),e+=x-h),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:r=!0,e=1}h=x+1}return s&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const qu=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Yu(e){return e.replace(qu,Gu)}function Gu(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),a=i===120||i===88;return $a(n.slice(a?2:1),a?16:10)}return to(n)||e}const Za={}.hasOwnProperty;function Qu(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),Xu(n)(Ku(Hu(n).document().write(Wu()(e,t,!0))))}function Xu(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Lt),autolinkProtocol:J,autolinkEmail:J,atxHeading:a(me),blockQuote:a(yt),characterEscape:J,characterReference:J,codeFenced:a(Tt),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(Tt,o),codeText:a(Me,o),codeTextData:J,data:J,codeFlowValue:J,definition:a(un),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(dn),hardBreakEscape:a(de),hardBreakTrailing:a(de),htmlFlow:a(Oe,o),htmlFlowData:J,htmlText:a(Oe,o),htmlTextData:J,image:a(rt),label:o,link:a(Lt),listItem:a(lt),listItemValue:x,listOrdered:a(It,h),listUnordered:a(It),paragraph:a(rn),reference:v,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(me),strong:a(yn),thematicBreak:a(zt)},exit:{atxHeading:d(),atxHeadingSequence:X,autolink:d(),autolinkEmail:He,autolinkProtocol:Ve,blockQuote:d(),characterEscapeValue:z,characterReferenceMarkerHexadecimal:Rt,characterReferenceMarkerNumeric:Rt,characterReferenceValue:pe,characterReference:Ct,codeFenced:d(O),codeFencedFence:L,codeFencedFenceInfo:y,codeFencedFenceMeta:C,codeFlowValue:z,codeIndented:d(M),codeText:d(Z),codeTextData:z,data:z,definition:d(),definitionDestinationString:ae,definitionLabelString:$,definitionTitleString:N,emphasis:d(),hardBreakEscape:d(ee),hardBreakTrailing:d(ee),htmlFlow:d(he),htmlFlowData:z,htmlText:d(le),htmlTextData:z,image:d(Ae),label:xt,labelText:ze,lineEnding:G,link:d(we),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:Ze,resourceDestinationString:E,resourceTitleString:nt,resource:ht,setextHeading:d(V),setextHeadingLineSequence:F,setextHeadingText:_,strong:d(),thematicBreak:d()}};Ja(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(B){let Y={type:"root",children:[]};const Q={stack:[Y],tokenStack:[],config:t,enter:s,exit:u,buffer:o,resume:p,data:n},xe=[];let Se=-1;for(;++Se<B.length;)if(B[Se][1].type==="listOrdered"||B[Se][1].type==="listUnordered")if(B[Se][0]==="enter")xe.push(Se);else{const st=xe.pop();Se=i(B,st,Se)}for(Se=-1;++Se<B.length;){const st=t[B[Se][0]];Za.call(st,B[Se][1].type)&&st[B[Se][1].type].call(Object.assign({sliceSerialize:B[Se][2].sliceSerialize},Q),B[Se][1])}if(Q.tokenStack.length>0){const st=Q.tokenStack[Q.tokenStack.length-1];(st[1]||qo).call(Q,void 0,st[0])}for(Y.position={start:En(B.length>0?B[0][1].start:{line:1,column:1,offset:0}),end:En(B.length>0?B[B.length-2][1].end:{line:1,column:1,offset:0})},Se=-1;++Se<t.transforms.length;)Y=t.transforms[Se](Y)||Y;return Y}function i(B,Y,Q){let xe=Y-1,Se=-1,st=!1,bt,pt,Yt,Ut;for(;++xe<=Q;){const Je=B[xe];switch(Je[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Je[0]==="enter"?Se++:Se--,Ut=void 0;break}case"lineEndingBlank":{Je[0]==="enter"&&(bt&&!Ut&&!Se&&!Yt&&(Yt=xe),Ut=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ut=void 0}if(!Se&&Je[0]==="enter"&&Je[1].type==="listItemPrefix"||Se===-1&&Je[0]==="exit"&&(Je[1].type==="listUnordered"||Je[1].type==="listOrdered")){if(bt){let Mt=xe;for(pt=void 0;Mt--;){const et=B[Mt];if(et[1].type==="lineEnding"||et[1].type==="lineEndingBlank"){if(et[0]==="exit")continue;pt&&(B[pt][1].type="lineEndingBlank",st=!0),et[1].type="lineEnding",pt=Mt}else if(!(et[1].type==="linePrefix"||et[1].type==="blockQuotePrefix"||et[1].type==="blockQuotePrefixWhitespace"||et[1].type==="blockQuoteMarker"||et[1].type==="listItemIndent"))break}Yt&&(!pt||Yt<pt)&&(bt._spread=!0),bt.end=Object.assign({},pt?B[pt][1].start:Je[1].end),B.splice(pt||xe,0,["exit",bt,Je[2]]),xe++,Q++}if(Je[1].type==="listItemPrefix"){const Mt={type:"listItem",_spread:!1,start:Object.assign({},Je[1].start),end:void 0};bt=Mt,B.splice(xe,0,["enter",Mt,Je[2]]),xe++,Q++,Yt=void 0,Ut=!0}}}return B[Y][1]._spread=st,Q}function a(B,Y){return Q;function Q(xe){s.call(this,B(xe),xe),Y&&Y.call(this,xe)}}function o(){this.stack.push({type:"fragment",children:[]})}function s(B,Y,Q){this.stack[this.stack.length-1].children.push(B),this.stack.push(B),this.tokenStack.push([Y,Q||void 0]),B.position={start:En(Y.start),end:void 0}}function d(B){return Y;function Y(Q){B&&B.call(this,Q),u.call(this,Q)}}function u(B,Y){const Q=this.stack.pop(),xe=this.tokenStack.pop();if(xe)xe[0].type!==B.type&&(Y?Y.call(this,B,xe[0]):(xe[1]||qo).call(this,B,xe[0]));else throw new Error("Cannot close `"+B.type+"` ("+zr({start:B.start,end:B.end})+"): it’s not open");Q.position.end=En(B.end)}function p(){return eo(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function x(B){if(this.data.expectingFirstListItemValue){const Y=this.stack[this.stack.length-2];Y.start=Number.parseInt(this.sliceSerialize(B),10),this.data.expectingFirstListItemValue=void 0}}function y(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.lang=B}function C(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.meta=B}function L(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function O(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function M(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B.replace(/(\r?\n|\r)$/g,"")}function $(B){const Y=this.resume(),Q=this.stack[this.stack.length-1];Q.label=Y,Q.identifier=nn(this.sliceSerialize(B)).toLowerCase()}function N(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.title=B}function ae(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.url=B}function X(B){const Y=this.stack[this.stack.length-1];if(!Y.depth){const Q=this.sliceSerialize(B).length;Y.depth=Q}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function F(B){const Y=this.stack[this.stack.length-1];Y.depth=this.sliceSerialize(B).codePointAt(0)===61?1:2}function V(){this.data.setextHeadingSlurpLineEnding=void 0}function J(B){const Q=this.stack[this.stack.length-1].children;let xe=Q[Q.length-1];(!xe||xe.type!=="text")&&(xe=Ot(),xe.position={start:En(B.start),end:void 0},Q.push(xe)),this.stack.push(xe)}function z(B){const Y=this.stack.pop();Y.value+=this.sliceSerialize(B),Y.position.end=En(B.end)}function G(B){const Y=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Q=Y.children[Y.children.length-1];Q.position.end=En(B.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Y.type)&&(J.call(this,B),z.call(this,B))}function ee(){this.data.atHardBreak=!0}function he(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B}function le(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B}function Z(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.value=B}function we(){const B=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";B.type+="Reference",B.referenceType=Y,delete B.url,delete B.title}else delete B.identifier,delete B.label;this.data.referenceType=void 0}function Ae(){const B=this.stack[this.stack.length-1];if(this.data.inReference){const Y=this.data.referenceType||"shortcut";B.type+="Reference",B.referenceType=Y,delete B.url,delete B.title}else delete B.identifier,delete B.label;this.data.referenceType=void 0}function ze(B){const Y=this.sliceSerialize(B),Q=this.stack[this.stack.length-2];Q.label=Yu(Y),Q.identifier=nn(Y).toLowerCase()}function xt(){const B=this.stack[this.stack.length-1],Y=this.resume(),Q=this.stack[this.stack.length-1];if(this.data.inReference=!0,Q.type==="link"){const xe=B.children;Q.children=xe}else Q.alt=Y}function E(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.url=B}function nt(){const B=this.resume(),Y=this.stack[this.stack.length-1];Y.title=B}function ht(){this.data.inReference=void 0}function v(){this.data.referenceType="collapsed"}function Ze(B){const Y=this.resume(),Q=this.stack[this.stack.length-1];Q.label=Y,Q.identifier=nn(this.sliceSerialize(B)).toLowerCase(),this.data.referenceType="full"}function Rt(B){this.data.characterReferenceType=B.type}function pe(B){const Y=this.sliceSerialize(B),Q=this.data.characterReferenceType;let xe;Q?(xe=$a(Y,Q==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):xe=to(Y);const Se=this.stack[this.stack.length-1];Se.value+=xe}function Ct(B){const Y=this.stack.pop();Y.position.end=En(B.end)}function Ve(B){z.call(this,B);const Y=this.stack[this.stack.length-1];Y.url=this.sliceSerialize(B)}function He(B){z.call(this,B);const Y=this.stack[this.stack.length-1];Y.url="mailto:"+this.sliceSerialize(B)}function yt(){return{type:"blockquote",children:[]}}function Tt(){return{type:"code",lang:null,meta:null,value:""}}function Me(){return{type:"inlineCode",value:""}}function un(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function dn(){return{type:"emphasis",children:[]}}function me(){return{type:"heading",depth:0,children:[]}}function de(){return{type:"break"}}function Oe(){return{type:"html",value:""}}function rt(){return{type:"image",title:null,url:"",alt:null}}function Lt(){return{type:"link",title:null,url:"",children:[]}}function It(B){return{type:"list",ordered:B.type==="listOrdered",start:null,spread:B._spread,children:[]}}function lt(B){return{type:"listItem",spread:B._spread,checked:null,children:[]}}function rn(){return{type:"paragraph",children:[]}}function yn(){return{type:"strong",children:[]}}function Ot(){return{type:"text",value:""}}function zt(){return{type:"thematicBreak"}}}function En(e){return{line:e.line,column:e.column,offset:e.offset}}function Ja(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Ja(e,r):Zu(e,r)}}function Zu(e,t){let n;for(n in t)if(Za.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 qo(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+zr({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+zr({start:t.start,end:t.end}
vendor: 10,608 bytes, lines 4-8
4)+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+zr({start:t.start,end:t.end})+") is still open")}function Ju(e){const t=this;t.parser=n;function n(r){return Qu(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function ed(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)}function td(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
5`}]}function nd(e,t){const n=t.value?t.value+`
6`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);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}function rd(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function id(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function od(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=mr(r.toLowerCase()),a=e.footnoteOrder.indexOf(r);let o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);const d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,d);const u={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,u),e.applyData(t,u)}function ad(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ld(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function el(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),a=i[0];a&&a.type==="text"?a.value="["+a.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function sd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return el(e,t);const i={src:mr(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function cd(e,t){const n={src:mr(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function ud(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)}function dd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return el(e,t);const i={href:mr(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const a={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function fd(e,t){const n={href:mr(t.url)};t.title!==null&&t.title!==void 0&&(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)}function hd(e,t,n){const r=e.all(t),i=n?pd(n):tl(t),a={},o=[];if(typeof t.checked=="boolean"){const p=r[0];let h;p&&p.type==="element"&&p.tagName==="p"?h=p:(h={type:"element",tagName:"p",properties:{},children:[]},r.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let s=-1;for(;++s<r.length;){const p=r[s];(i||s!==0||p.type!=="element"||p.tagName!=="p")&&o.push({type:"text",value:`
7`}),p.type==="element"&&p.tagName==="p"&&!i?o.push(...p.children):o.push(p)}const d=r[r.length-1];d&&(i||d.type!=="element"||d.tagName!=="p")&&o.push({type:"text",value:`
8`});const u={type:"element",tagName:"li",properties:a,children:o};return e.patch(t,u),e.applyData(t,u)}function pd(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=tl(n[r])}return t}function tl(e){const t=e.spread;return t??e.children.length>1}function md(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function gd(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xd(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function yd(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Sd(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},s=Qi(t.children[1]),d=Ra(t.children[t.children.length-1]);s&&d&&(o.position={start:s,end:d}),i.push(o)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function kd(e,t,n){const r=n?n.children:void 0,a=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,s=o?o.length:t.children.length;let d=-1;const u=[];for(;++d<s;){const h=t.children[d],x={},y=o?o[d]:void 0;y&&(x.align=y);let C={type:"element",tagName:a,properties:x,children:[]};h&&(C.children=e.all(h),e.patch(h,C),C=e.applyData(h,C)),u.push(C)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,p),e.applyData(t,p)}function bd(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Yo=9,Go=32;function wd(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const a=[];for(;r;)a.push(Qo(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Qo(t.slice(i),i>0,!1)),a.join("")}function Qo(e,t,n){let r=0,i=e.length;if(t){let a=e.codePointAt(r);for(;a===Yo||a===Go;)r++,a=e.codePointAt(r)}if(n){let a=e.codePointAt(i-1);for(;a===Yo||a===Go;)i--,a=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function Dd(e,t){const n={type:"text",value:wd(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function jd(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const Cd={blockquote:ed,break:td,code:nd,delete:rd,emphasis:id,footnoteReference:od,heading:ad,html:ld,imageReference:sd,image:cd,inlineCode:ud,linkReference:dd,link:fd,listItem:hd,list:md,paragraph:gd,root:xd,strong:yd,table:Sd,tableCell:bd,tableRow:kd,text:Dd,thematicBreak:jd,toml:Hr,yaml:Hr,definition:Hr,footnoteDefinition:Hr};function Hr(){}const nl=-1,si=0,Fr=1,ni=2,ro=3,io=4,oo=5,ao=6,rl=7,il=8,Xo=typeof self=="object"?self:globalThis,Ed=(e,t)=>{const n=(i,a)=>(e.set(a,i),i),r=i=>{if(e.has(i))return e.get(i);const[a,o]=t[i];switch(a){case si:case nl:return n(o,i);case Fr:{const s=n([],i);for(const d of o)s.push(r(d));return s}case ni:{const s=n({},i);for(const[d,u]of o)s[r(d)]=r(u);return s}case ro:return n(new Date(o),i);case io:{const{source:s,flags:d}=o;return n(new RegExp(s,d),i)}case oo:{const s=n(new Map,i);for(const[d,u]of o)s.set(r(d),r(u));return s}case ao:{const s=n(new Set,i);for(const d of o)s.add(r(d));return s}case rl:{const{name:s,message:d}=o;return n(new Xo[s](d),i)}case il:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:s}=new Uint8Array(o);return n(new DataView(s),o)}}return n(new Xo[a](o),i)};return r},Zo=e=>Ed(new Map,e)(0),ar="",{toString:vd}={},{keys:Id}=Object,vr=e=>{const t=typeof e;if(t!=="object"||!e)return[si,t];const n=vd.call(e).slice(8,-1);switch(n){case"Array":return[Fr,ar];case"Object":return[ni,ar];case"Date":return[ro,ar];case"RegExp":return[io,ar];case"Map":return[oo,ar];case"Set":return[ao,ar];case"DataView":return[Fr,n]}return n.includes("Array")?[Fr,n]:n.includes("Error")?[rl,n]:[ni,n]},Kr=([e,t])=>e===si&&(t==="function"||t==="symbol"),zd=(e,t,n,r)=>{const i=(o,s)=>{const d=r.push(o)-1;return n.set(s,d),d},a=o=>{if(n.has(o))return n.get(o);let[s,d]=vr(o);switch(s){case si:{let p=o;switch(d){case"bigint":s=il,p=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return i([nl],o)}return i([s,p],o)}case Fr:{if(d){let x=o;return d==="DataView"?x=new Uint8Array(o.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(o)),i([d,[...x]],o)}const p=[],h=i([s,p],o);for(const x of o)p.push(a(x));return h}case ni:{if(d)switch(d){case"BigInt":return i([d,o.toString()],o);case"Boolean":case"Number":case"String":return i([d,o.valueOf()],o)}if(t&&"toJSON"in o)return a(o.toJSON());const p=[],h=i([s,p],o);for(const x of Id(o))(e||!Kr(vr(o[x])))&&p.push([a(x),a(o[x])]);return h}case ro:return i([s,o.toISOString()],o);case io:{const{source:p,flags:h}=o;return i([s,{source:p,flags:h}],o)}case oo:{const p=[],h=i([s,p],o);for(const[x,y]of o)(e||!(Kr(vr(x))||Kr(vr(y))))&&p.push([a(x),a(y)]);return h}case ao:{const p=[],h=i([s,p],o);for(const x of o)(e||!Kr(vr(x)))&&p.push(a(x));return h}}const{message:u}=o;return i([s,{name:d,message:u}],o)};return a},Jo=(e,{json:t,lossy:n}={})=>{const r=[];return zd(!(t||n),!!t,new Map,r)(e),r},ri=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Zo(Jo(e,t)):structuredClone(e):(e,t)=>Zo(Jo(e,t));function Md(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 Fd(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}
vendor: 7,109 bytes, lines 8-14
8function Ad(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Md,r=e.options.footnoteBackLabel||Fd,i=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[];let d=-1;for(;++d<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[d]);if(!u)continue;const p=e.all(u),h=String(u.identifier).toUpperCase(),x=mr(h.toLowerCase());let y=0;const C=[],L=e.footnoteCounts.get(h);for(;L!==void 0&&++y<=L;){C.length>0&&C.push({type:"text",value:" "});let $=typeof n=="string"?n:n(d,y);typeof $=="string"&&($={type:"text",value:$}),C.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(d,y),className:["data-footnote-backref"]},children:Array.isArray($)?$:[$]})}const O=p[p.length-1];if(O&&O.type==="element"&&O.tagName==="p"){const $=O.children[O.children.length-1];$&&$.type==="text"?$.value+=" ":O.children.push({type:"text",value:" "}),O.children.push(...C)}else p.push(...C);const M={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(p,!0)};e.patch(u,M),s.push(M)}if(s.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...ri(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
9`},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:`
10`}]}}const ci=(function(e){if(e==null)return Ld;if(typeof e=="function")return ui(e);if(typeof e=="object")return Array.isArray(e)?Pd(e):Rd(e);if(typeof e=="string")return Td(e);throw new Error("Expected function, string, or object as test")});function Pd(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=ci(e[n]);return ui(r);function r(...i){let a=-1;for(;++a<t.length;)if(t[a].apply(this,i))return!0;return!1}}function Rd(e){const t=e;return ui(n);function n(r){const i=r;let a;for(a in e)if(i[a]!==t[a])return!1;return!0}}function Td(e){return ui(t);function t(n){return n&&n.type===e}}function ui(e){return t;function t(n,r,i){return!!(Od(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Ld(){return!0}function Od(e){return e!==null&&typeof e=="object"&&"type"in e}const ol=[],_d=!0,Bi=!1,Vd="skip";function al(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const a=ci(i),o=r?-1:1;s(e,void 0,[])();function s(d,u,p){const h=d&&typeof d=="object"?d:{};if(typeof h.type=="string"){const y=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return x;function x(){let y=ol,C,L,O;if((!t||a(d,u,p[p.length-1]||void 0))&&(y=Bd(n(d,p)),y[0]===Bi))return y;if("children"in d&&d.children){const M=d;if(M.children&&y[0]!==Vd)for(L=(r?M.children.length:-1)+o,O=p.concat(M);L>-1&&L<M.children.length;){const $=M.children[L];if(C=s($,L,O)(),C[0]===Bi)return C;L=typeof C[1]=="number"?C[1]:L+o}}return y}}}function Bd(e){return Array.isArray(e)?e:typeof e=="number"?[_d,e]:e==null?ol:[e]}function lo(e,t,n,r){let i,a,o;typeof t=="function"&&typeof n!="function"?(a=void 0,o=t,i=n):(a=t,o=n,i=r),al(e,a,s,i);function s(d,u){const p=u[u.length-1],h=p?p.children.indexOf(d):void 0;return o(d,h,p)}}const Ni={}.hasOwnProperty,Nd={};function $d(e,t){const n=t||Nd,r=new Map,i=new Map,a=new Map,o={...Cd,...n.handlers},s={all:u,applyData:Hd,definitionById:r,footnoteById:i,footnoteCounts:a,footnoteOrder:[],handlers:o,one:d,options:n,patch:Ud,wrap:Wd};return lo(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const h=p.type==="definition"?r:i,x=String(p.identifier).toUpperCase();h.has(x)||h.set(x,p)}}),s;function d(p,h){const x=p.type,y=s.handlers[x];if(Ni.call(s.handlers,x)&&y)return y(s,p,h);if(s.options.passThrough&&s.options.passThrough.includes(x)){if("children"in p){const{children:L,...O}=p,M=ri(O);return M.children=s.all(p),M}return ri(p)}return(s.options.unknownHandler||Kd)(s,p,h)}function u(p){const h=[];if("children"in p){const x=p.children;let y=-1;for(;++y<x.length;){const C=s.one(x[y],p);if(C){if(y&&x[y-1].type==="break"&&(!Array.isArray(C)&&C.type==="text"&&(C.value=ea(C.value)),!Array.isArray(C)&&C.type==="element")){const L=C.children[0];L&&L.type==="text"&&(L.value=ea(L.value))}Array.isArray(C)?h.push(...C):h.push(C)}}}return h}}function Ud(e,t){e.position&&(t.position=Fs(e))}function Hd(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,a=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&a&&Object.assign(n.properties,ri(a)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Kd(e,t){const n=t.data||{},r="value"in t&&!(Ni.call(n,"hProperties")||Ni.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Wd(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
11`});++r<e.length;)r&&n.push({type:"text",value:`
12`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
13`}),n}function ea(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ta(e,t){const n=$d(e,t),r=n.one(e,void 0),i=Ad(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&a.children.push({type:"text",value:`
14`},i),a}function qd(e,t){return e&&"run"in e?async function(n,r){const i=ta(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ta(n,{file:r,...e||t})}}function na(e){if(e)throw e}var ki,ra;function Yd(){if(ra)return ki;ra=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},a=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var p=e.call(u,"constructor"),h=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!p&&!h)return!1;var x;for(x in u);return typeof x>"u"||e.call(u,x)},o=function(u,p){n&&p.name==="__proto__"?n(u,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):u[p.name]=p.newValue},s=function(u,p){if(p==="__proto__")if(e.call(u,p)){if(r)return r(u,p).value}else return;return u[p]};return ki=function d(){var u,p,h,x,y,C,L=arguments[0],O=1,M=arguments.length,$=!1;for(typeof L=="boolean"&&($=L,L=arguments[1]||{},O=2),(L==null||typeof L!="object"&&typeof L!="function")&&(L={});O<M;++O)if(u=arguments[O],u!=null)for(p in u)h=s(L,p),x=s(u,p),L!==x&&($&&x&&(a(x)||(y=i(x)))?(y?(y=!1,C=h&&i(h)?h:[]):C=h&&a(h)?h:{},o(L,{name:p,newValue:d($,C,x)})):typeof x<"u"&&o(L,{name:p,newValue:x}));return L},ki}var Gd=Yd();const bi=wa(Gd);function $i(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);
vendor: 4,372 bytes, line 14
14return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Qd(){const e=[],t={run:n,use:r};return t;function n(...i){let a=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);s(null,...i);function s(d,...u){const p=e[++a];let h=-1;if(d){o(d);return}for(;++h<i.length;)(u[h]===null||u[h]===void 0)&&(u[h]=i[h]);i=u,p?Xd(p,s)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Xd(e,t){let n;return r;function r(...o){const s=e.length>o.length;let d;s&&o.push(i);try{d=e.apply(this,o)}catch(u){const p=u;if(s&&n)throw p;return i(p)}s||(d&&d.then&&typeof d.then=="function"?d.then(a,i):d instanceof Error?i(d):a(d))}function i(o,...s){n||(n=!0,t(o,...s))}function a(o){i(null,o)}}const sn={basename:Zd,dirname:Jd,extname:ef,join:tf,sep:"/"};function Zd(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Or(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Jd(e){if(Or(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function ef(e){Or(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){const s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function tf(...e){let t=-1,n;for(;++t<e.length;)Or(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":nf(n)}function nf(e){Or(e);const t=e.codePointAt(0)===47;let n=rf(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function rf(e,t){let n="",r=0,i=-1,a=0,o=-1,s,d;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else{if(s===47)break;s=47}if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length>0){n="",r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function Or(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const of={cwd:af};function af(){return"/"}function Ui(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function lf(e){if(typeof e=="string")e=new URL(e);else if(!Ui(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(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return sf(e)}function sf(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const wi=["history","path","basename","stem","extname","dirname"];class ll{constructor(t){let n;t?Ui(t)?n={path:t}:typeof t=="string"||cf(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":of.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<wi.length;){const a=wi[r];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let i;for(i in n)wi.includes(i)||(this[i]=n[i])}
vendor: 5,548 bytes, line 14
14get basename(){return typeof this.path=="string"?sn.basename(this.path):void 0}set basename(t){ji(t,"basename"),Di(t,"basename"),this.path=sn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?sn.dirname(this.path):void 0}set dirname(t){ia(this.basename,"dirname"),this.path=sn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?sn.extname(this.path):void 0}set extname(t){if(Di(t,"extname"),ia(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=sn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Ui(t)&&(t=lf(t)),ji(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?sn.basename(this.path,this.extname):void 0}set stem(t){ji(t,"stem"),Di(t,"stem"),this.path=sn.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new jt(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Di(e,t){if(e&&e.includes(sn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+sn.sep+"`")}function ji(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function ia(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function cf(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const uf=(function(e){const r=this.constructor.prototype,i=r[e],a=function(){return i.apply(a,arguments)};return Object.setPrototypeOf(a,r),a}),df={}.hasOwnProperty;class so extends uf{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=Qd()}copy(){const t=new so;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(bi(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(vi("data",this.frozen),this.namespace[t]=n,this):df.call(this.namespace,t)&&this.namespace[t]||void 0:t?(vi("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Wr(t),r=this.parser||this.Parser;return Ci("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Ci("process",this.parser||this.Parser),Ei("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(a,o){const s=Wr(t),d=r.parse(s);r.run(d,s,function(p,h,x){if(p||!h||!x)return u(p);const y=h,C=r.stringify(y,x);pf(C)?x.value=C:x.result=C,u(p,x)});function u(p,h){p||!h?o(p):a?a(h):n(void 0,h)}}}processSync(t){let n=!1,r;return this.freeze(),Ci("processSync",this.parser||this.Parser),Ei("processSync",this.compiler||this.Compiler),this.process(t,i),aa("processSync","process",n),r;function i(a,o){n=!0,na(a),r=o}}run(t,n,r){oa(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?a(void 0,r):new Promise(a);function a(o,s){const d=Wr(n);i.run(t,d,u);function u(p,h,x){const y=h||t;p?s(p):o?o(y):r(void 0,y,x)}}}runSync(t,n){let r=!1,i;return this.run(t,n,a),aa("runSync","run",r),i;function a(o,s){na(o),i=s,r=!0}}stringify(t,n){this.freeze();const r=Wr(n),i=this.compiler||this.Compiler;return Ei("stringify",i),oa(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(vi("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?s(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(u){if(typeof u=="function")d(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[p,...h]=u;d(p,h)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))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");s(u.plugins),u.settings&&(i.settings=bi(!0,i.settings,u.settings))}function s(u){let p=-1;if(u!=null)if(Array.isArray(u))for(;++p<u.length;){const h=u[p];a(h)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function d(u,p){let h=-1,x=-1;for(;++h<r.length;)if(r[h][0]===u){x=h;break}if(x===-1)r.push([u,...p]);else if(p.length>0){let[y,...C]=p;const L=r[x][1];$i(L)&&$i(y)&&(y=bi(!0,L,y)),r[x]=[u,y,...C]}}}}const ff=new so().freeze();function Ci(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Ei(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function vi(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 oa(e){if(!$i(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}
vendor: 5,732 bytes, line 14
14function aa(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Wr(e){return hf(e)?e:new ll(e)}function hf(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function pf(e){return typeof e=="string"||mf(e)}function mf(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const gf="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",la=[],sa={allowDangerousHtml:!0},xf=/^(https?|ircs?|mailto|xmpp)$/i,yf=[{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 Sf(e){const t=kf(e),n=bf(e);return wf(t.runSync(t.parse(n),n),e)}function kf(e){const t=e.rehypePlugins||la,n=e.remarkPlugins||la,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...sa}:sa;return ff().use(Ju).use(n).use(qd,r).use(t)}function bf(e){const t=e.children||"",n=new ll;return typeof t=="string"&&(n.value=t),n}function wf(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,d=t.urlTransform||Df;for(const p of yf)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+gf+p.id,void 0);return lo(e,u),Ls(e,{Fragment:l.Fragment,components:i,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function u(p,h,x){if(p.type==="raw"&&x&&typeof h=="number")return o?x.children.splice(h,1):x.children[h]={type:"text",value:p.value},h;if(p.type==="element"){let y;for(y in xi)if(Object.hasOwn(xi,y)&&Object.hasOwn(p.properties,y)){const C=p.properties[y],L=xi[y];(L===null||L.includes(p.tagName))&&(p.properties[y]=d(String(C||""),y,p))}}if(p.type==="element"){let y=n?!n.includes(p.tagName):a?a.includes(p.tagName):!1;if(!y&&r&&typeof h=="number"&&(y=!r(p,h,x)),y&&x&&typeof h=="number")return s&&p.children?x.children.splice(h,1,...p.children):x.children.splice(h,1),h}}}function Df(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||xf.test(e.slice(0,t))?e:""}function ca(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function jf(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Cf(e,t,n){const i=ci((n||{}).ignore||[]),a=Ef(t);let o=-1;for(;++o<a.length;)al(e,"text",s);function s(u,p){let h=-1,x;for(;++h<p.length;){const y=p[h],C=x?x.children:void 0;if(i(y,C?C.indexOf(y):void 0,x))return;x=y}if(x)return d(u,p)}function d(u,p){const h=p[p.length-1],x=a[o][0],y=a[o][1];let C=0;const O=h.children.indexOf(u);let M=!1,$=[];x.lastIndex=0;let N=x.exec(u.value);for(;N;){const ae=N.index,X={index:N.index,input:N.input,stack:[...p,u]};let _=y(...N,X);if(typeof _=="string"&&(_=_.length>0?{type:"text",value:_}:void 0),_===!1?x.lastIndex=ae+1:(C!==ae&&$.push({type:"text",value:u.value.slice(C,ae)}),Array.isArray(_)?$.push(..._):_&&$.push(_),C=ae+N[0].length,M=!0),!x.global)break;N=x.exec(u.value)}return M?(C<u.value.length&&$.push({type:"text",value:u.value.slice(C)}),h.children.splice(O,1,...$)):$=[u],O+$.length}}function Ef(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 i=n[r];t.push([vf(i[0]),If(i[1])])}return t}function vf(e){return typeof e=="string"?new RegExp(jf(e),"g"):e}function If(e){return typeof e=="function"?e:function(){return e}}const Ii="phrasing",zi=["autolink","link","image","label"];function zf(){return{transforms:[Lf],enter:{literalAutolink:Ff,literalAutolinkEmail:Mi,literalAutolinkHttp:Mi,literalAutolinkWww:Mi},exit:{literalAutolink:Tf,literalAutolinkEmail:Rf,literalAutolinkHttp:Af,literalAutolinkWww:Pf}}}function Mf(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Ii,notInConstruct:zi},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Ii,notInConstruct:zi},{character:":",before:"[ps]",after:"\\/",inConstruct:Ii,notInConstruct:zi}]}}function Ff(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Mi(e){this.config.enter.autolinkProtocol.call(this,e)}function Af(e){this.config.exit.autolinkProtocol.call(this,e)}function Pf(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 Rf(e){this.config.exit.autolinkEmail.call(this,e)}function Tf(e){this.exit(e)}function Lf(e){Cf(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Of],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S}
14)([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),_f]],{ignore:["link","linkReference"]})}function Of(e,t,n,r,i){let a="";if(!sl(i)||(/^w/i.test(t)&&(n=t+n,t="",a="http://"),!Vf(n)))return!1;const o=Bf(n+r);if(!o[0])return!1;const s={type:"link",title:null,url:a+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[s,{type:"text",value:o[1]}]:s}function _f(e,t,n,r){return!sl(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Vf(e){const t=e.split(".");return!(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])))}function Bf(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 i=ca(e,"(");let a=ca(e,")");for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),a++;return[e,n]}function sl(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Un(n)||ai(n))&&(!t||n!==47)}cl.peek=Gf;function Nf(){this.buffer()}function $f(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Uf(){this.buffer()}function Hf(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Kf(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Wf(e){this.exit(e)}function qf(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nn(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Yf(e){this.exit(e)}function Gf(){return"["}function cl(e,t,n,r){const i=n.createTracker(r);let a=i.move("[^");const o=n.enter("footnoteReference"),s=n.enter("reference");return a+=i.move(n.safe(n.associationId(e),{after:"]",before:a})),s(),o(),a+=i.move("]"),a}function Qf(){return{enter:{gfmFootnoteCallString:Nf,gfmFootnoteCall:$f,gfmFootnoteDefinitionLabelString:Uf,gfmFootnoteDefinition:Hf},exit:{gfmFootnoteCallString:Kf,gfmFootnoteCall:Wf,gfmFootnoteDefinitionLabelString:qf,gfmFootnoteDefinition:Yf}}}function Xf(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:cl},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,a,o){const s=a.createTracker(o);let d=s.move("[^");const u=a.enter("footnoteDefinition"),p=a.enter("label");return d+=s.move(a.safe(a.associationId(r),{before:d,after:"]"})),p(),d+=s.move("]:"),r.children&&r.children.length>0&&(s.shift(4),d+=s.move((t?`
15`:" ")+a.indentLines(a.containerFlow(r,s.current()),t?ul:Zf))),u(),d}}function Zf(e,t,n){return t===0?e:ul(e,t,n)}function ul(e,t,n){return(n?"":"    ")+e}const Jf=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];dl.peek=ih;function eh(){return{canContainEols:["delete"],enter:{strikethrough:nh},exit:{strikethrough:rh}}}function th(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Jf}],handlers:{delete:dl}}}function nh(e){this.enter({type:"delete",children:[]},e)}function rh(e){this.exit(e)}function dl(e,t,n,r){const i=n.createTracker(r),a=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),a(),o}function ih(){return"~"}function oh(e){return e.length}function ah(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||oh,a=[],o=[],s=[],d=[];let u=0,p=-1;for(;++p<e.length;){const L=[],O=[];let M=-1;for(e[p].length>u&&(u=e[p].length);++M<e[p].length;){const $=lh(e[p][M]);if(n.alignDelimiters!==!1){const N=i($);O[M]=N,(d[M]===void 0||N>d[M])&&(d[M]=N)}L.push($)}o[p]=L,s[p]=O}let h=-1;if(typeof r=="object"&&"length"in r)for(;++h<u;)a[h]=ua(r[h]);else{const L=ua(r);for(;++h<u;)a[h]=L}h=-1;const x=[],y=[];for(;++h<u;){const L=a[h];let O="",M="";L===99?(O=":",M=":"):L===108?O=":":L===114&&(M=":");let $=n.alignDelimiters===!1?1:Math.max(1,d[h]-O.length-M.length);const N=O+"-".repeat($)+M;n.alignDelimiters!==!1&&($=O.length+$+M.length,$>d[h]&&(d[h]=$),y[h]=$),x[h]=N}o.splice(1,0,x),s.splice(1,0,y),p=-1;const C=[];for(;++p<o.length;){const L=o[p],O=s[p];h=-1;const M=[];for(;++h<u;){const $=L[h]||"";let N="",ae="";if(n.alignDelimiters!==!1){const X=d[h]-(O[h]||0),_=a[h];_===114?N=" ".repeat(X):_===99?X%2?(N=" ".repeat(X/2+.5),ae=" ".repeat(X/2-.5)):(N=" ".repeat(X/2),ae=N):ae=" ".repeat(X)}n.delimiterStart!==!1&&!h&&M.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&$==="")&&(n.delimiterStart!==!1||h)&&M.push(" "),n.alignDelimiters!==!1&&M.push(N),M.push($),n.alignDelimiters!==!1&&M.push(ae),n.padding!==!1&&M.push(" "),(n.delimiterEnd!==!1||h!==u-1)&&M.push("|")}C.push(n.delimiterEnd===!1?M.join("").replace(/ +$/,""):M.join(""))}return C.join(`
16`)}function lh(e){return e==null?"":String(e)}function ua(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function sh(e,t,n,r){const i=n.enter("blockquote"),a=n.createTracker(r);a.move("> "),a.shift(2);const o=n.indentLines(n.containerFlow(e,a.current()),ch);return i(),o}
vendor: 13,854 bytes, lines 16-29
16function ch(e,t,n){return">"+(n?"":" ")+e}function uh(e,t){return da(e,t.inConstruct,!0)&&!da(e,t.notInConstruct,!1)}function da(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function fa(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
17`&&uh(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
18`}function dh(e,t){const n=String(e);let r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function fh(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function hh(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function ph(e,t,n,r){const i=hh(n),a=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(fh(e,n)){const h=n.enter("codeIndented"),x=n.indentLines(a,mh);return h(),x}const s=n.createTracker(r),d=i.repeat(Math.max(dh(a,i)+1,3)),u=n.enter("codeFenced");let p=s.move(d);if(e.lang){const h=n.enter(`codeFencedLang${o}`);p+=s.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...s.current()})),h()}if(e.lang&&e.meta){const h=n.enter(`codeFencedMeta${o}`);p+=s.move(" "),p+=s.move(n.safe(e.meta,{before:p,after:`
19`,encode:["`"],...s.current()})),h()}return p+=s.move(`
20`),a&&(p+=s.move(a+`
21`)),p+=s.move(d),u(),p}function mh(e,t,n){return(n?"":"    ")+e}function co(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 gh(e,t,n,r){const i=co(n),a=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let s=n.enter("label");const d=n.createTracker(r);let u=d.move("[");return u+=d.move(n.safe(n.associationId(e),{before:u,after:"]",...d.current()})),u+=d.move("]: "),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),u+=d.move("<"),u+=d.move(n.safe(e.url,{before:u,after:">",...d.current()})),u+=d.move(">")):(s=n.enter("destinationRaw"),u+=d.move(n.safe(e.url,{before:u,after:e.title?" ":`
22`,...d.current()}))),s(),e.title&&(s=n.enter(`title${a}`),u+=d.move(" "+i),u+=d.move(n.safe(e.title,{before:u,after:i,...d.current()})),u+=d.move(i),s()),o(),u}function xh(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Pr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function ii(e,t,n){const r=dr(e),i=dr(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}fl.peek=yh;function fl(e,t,n,r){const i=xh(n),a=n.enter("emphasis"),o=n.createTracker(r),s=o.move(i);let d=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()}));const u=d.charCodeAt(0),p=ii(r.before.charCodeAt(r.before.length-1),u,i);p.inside&&(d=Pr(u)+d.slice(1));const h=d.charCodeAt(d.length-1),x=ii(r.after.charCodeAt(0),h,i);x.inside&&(d=d.slice(0,-1)+Pr(h));const y=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},s+d+y}function yh(e,t,n){return n.options.emphasis||"*"}function Sh(e,t){let n=!1;return lo(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Bi}),!!((!e.depth||e.depth<3)&&eo(e)&&(t.options.setext||n))}function kh(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Sh(e,n)){const p=n.enter("headingSetext"),h=n.enter("phrasing"),x=n.containerPhrasing(e,{...a.current(),before:`
23`,after:`
24`});return h(),p(),x+`
25`+(i===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
26`))+1))}const o="#".repeat(i),s=n.enter("headingAtx"),d=n.enter("phrasing");a.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
27`,...a.current()});return/^[\t ]/.test(u)&&(u=Pr(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),d(),s(),u}hl.peek=bh;function hl(e){return e.value||""}function bh(){return"<"}pl.peek=wh;function pl(e,t,n,r){const i=co(n),a=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let s=n.enter("label");const d=n.createTracker(r);let u=d.move("![");return u+=d.move(n.safe(e.alt,{before:u,after:"]",...d.current()})),u+=d.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),u+=d.move("<"),u+=d.move(n.safe(e.url,{before:u,after:">",...d.current()})),u+=d.move(">")):(s=n.enter("destinationRaw"),u+=d.move(n.safe(e.url,{before:u,after:e.title?" ":")",...d.current()}))),s(),e.title&&(s=n.enter(`title${a}`),u+=d.move(" "+i),u+=d.move(n.safe(e.title,{before:u,after:i,...d.current()})),u+=d.move(i),s()),u+=d.move(")"),o(),u}function wh(){return"!"}ml.peek=Dh;function ml(e,t,n,r){const i=e.referenceType,a=n.enter("imageReference");let o=n.enter("label");const s=n.createTracker(r);let d=s.move("![");const u=n.safe(e.alt,{before:d,after:"]",...s.current()});d+=s.move(u+"]["),o();const p=n.stack;n.stack=[],o=n.enter("reference");const h=n.safe(n.associationId(e),{before:d,after:"]",...s.current()});return o(),n.stack=p,a(),i==="full"||!u||u!==h?d+=s.move(h+"]"):i==="shortcut"?d=d.slice(0,-1):d+=s.move("]"),d}function Dh(){return"!"}gl.peek=jh;function gl(e,t,n){let r=e.value||"",i="`",a=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const o=n.unsafe[a],s=n.compilePattern(o);let d;if(o.atBreak)for(;d=s.exec(r);){let u=d.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(d.index+1)}}return i+r+i}function jh(){return"`"}function xl(e,t){const n=eo(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}yl.peek=Ch;function yl(e,t,n,r){const i=co(n),a=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let s,d;if(xl(e,n)){const p=n.stack;n.stack=[],s=n.enter("autolink");let h=o.move("<");return h+=o.move(n.containerPhrasing(e,{before:h,after:">",...o.current()})),h+=o.move(">"),s(),n.stack=p,h}s=n.enter("link"),d=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(d=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),d(),e.title&&(d=n.enter(`title${a}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),d()),u+=o.move(")"),s(),u}function Ch(e,t,n){return xl(e,n)?"<":"["}Sl.peek=Eh;function Sl(e,t,n,r){const i=e.referenceType,a=n.enter("linkReference");let o=n.enter("label");const s=n.createTracker(r);let d=s.move("[");const u=n.containerPhrasing(e,{before:d,after:"]",...s.current()});d+=s.move(u+"]["),o();const p=n.stack;n.stack=[],o=n.enter("reference");const h=n.safe(n.associationId(e),{before:d,after:"]",...s.current()});return o(),n.stack=p,a(),i==="full"||!u||u!==h?d+=s.move(h+"]"):i==="shortcut"?d=d.slice(0,-1):d+=s.move("]"),d}function Eh(){return"["}function uo(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 vh(e){const t=uo(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}function Ih(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function kl(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}function zh(e,t,n,r){const i=n.enter("list"),a=n.bulletCurrent;let o=e.ordered?Ih(n):uo(n);const s=e.ordered?o==="."?")":".":vh(n);let d=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),kl(n)===o&&p){let h=-1;for(;++h<e.children.length;){const x=e.children[h];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(o=s),n.bulletCurrent=o;const u=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),u}function Mh(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Fh(e,t,n,r){const i=Mh(n);let a=n.bulletCurrent||uo(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const s=n.createTracker(r);s.move(a+" ".repeat(o-a.length)),s.shift(o);const d=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,s.current()),p);return d(),u;function p(h,x,y){return x?(y?"":" ".repeat(o))+h:(y?a:a+" ".repeat(o-a.length))+h}}function Ah(e,t,n,r){const i=n.enter("paragraph"),a=n.enter("phrasing"),o=n.containerPhrasing(e,r);return a(),i(),o}const Ph=ci(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Rh(e,t,n,r){return(e.children.some(function(o){return Ph(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Th(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}bl.peek=Lh;function bl(e,t,n,r){const i=Th(n),a=n.enter("strong"),o=n.createTracker(r),s=o.move(i+i);let d=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()}));const u=d.charCodeAt(0),p=ii(r.before.charCodeAt(r.before.length-1),u,i);p.inside&&(d=Pr(u)+d.slice(1));const h=d.charCodeAt(d.length-1),x=ii(r.after.charCodeAt(0),h,i);x.inside&&(d=d.slice(0,-1)+Pr(h));const y=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},s+d+y}function Lh(e,t,n){return n.options.strong||"*"}function Oh(e,t,n,r){return n.safe(e.value,r)}function _h(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}function Vh(e,t,n){const r=(kl(n)+(n.options.ruleSpaces?" ":"")).repeat(_h(n));return n.options.ruleSpaces?r.slice(0,-1):r}const wl={blockquote:sh,break:fa,code:ph,definition:gh,emphasis:fl,hardBreak:fa,heading:kh,html:hl,image:pl,imageReference:ml,inlineCode:gl,link:yl,linkReference:Sl,list:zh,listItem:Fh,paragraph:Ah,root:Rh,strong:bl,text:Oh,thematicBreak:Vh};function Bh(){return{enter:{table:Nh,tableData:ha,tableHeader:ha,tableRow:Uh},exit:{codeText:Hh,table:$h,tableData:Fi,tableHeader:Fi,tableRow:Fi}}}function Nh(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function $h(e){this.exit(e),this.data.inTable=void 0}function Uh(e){this.enter({type:"tableRow",children:[]},e)}function Fi(e){this.exit(e)}function ha(e){this.enter({type:"tableCell",children:[]},e)}function Hh(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Kh));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Kh(e,t){return t==="|"?t:e}function Wh(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
28`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[	 :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:o,tableCell:d,tableRow:s}};function o(y,C,L,O){return u(p(y,L,O),y.align)}function s(y,C,L,O){const M=h(y,L,O),$=u([M]);return $.slice(0,$.indexOf(`
29`))}function d(y,C,L,O){const M=L.enter("tableCell"),$=L.enter("phrasing"),N=L.containerPhrasing(y,{...O,before:a,after:a});return $(),M(),N}function u(y,C){return ah(y,{align:C,alignDelimiters:r,padding:n,stringLength:i})}function p(y,C,L){const O=y.children;let M=-1;const $=[],N=C.enter("table");for(;++M<O.length;)$[M]=h(O[M],C,L);return N(),$}function h(y,C,L){const O=y.children;let M=-1;const $=[],N=C.enter("tableRow");for(;++M<O.length;)$[M]=d(O[M],y,C,L);return N(),$}function x(y,C,L){let O=wl.inlineCode(y,C,L);return L.stack.includes("tableCell")&&(O=O.replace(/\|/g,"\\$&")),O}}function qh(){return{exit:{taskListCheckValueChecked:pa,taskListCheckValueUnchecked:
vendor: 1,695 bytes, line 29
29pa,paragraph:Gh}}}function Yh(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Qh}}}function pa(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Gh(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let a=-1,o;for(;++a<i.length;){const s=i[a];if(s.type==="paragraph"){o=s;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function Qh(e,t,n,r){const i=e.children[0],a=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(o);let d=wl.listItem(e,t,n,{...r,...s.current()});return a&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),d;function u(p){return p+o}}function Xh(){return[zf(),Qf(),eh(),Bh(),qh()]}function Zh(e){return{extensions:[Mf(),Xf(e),th(),Wh(e),Yh()]}}const Jh={tokenize:op,partial:!0},Dl={tokenize:ap,partial:!0},jl={tokenize:lp,partial:!0},Cl={tokenize:sp,partial:!0},ep={tokenize:cp,partial:!0},El={name:"wwwAutolink",tokenize:rp,previous:Il},vl={name:"protocolAutolink",tokenize:ip,previous:zl},xn={name:"emailAutolink",tokenize:np,previous:Ml},cn={};function tp(){return{text:cn}}let $n=48;for(;$n<123;)cn[$n]=xn,$n++,$n===58?$n=65:$n===91&&($n=97);cn[43]=xn;cn[45]=xn;cn[46]=xn;cn[95]=xn;cn[72]=[xn,vl];cn[104]=[xn,vl];cn[87]=[xn,El];cn[119]=[xn,El];
vendor: 7,110 bytes, line 29
29function np(e,t,n){const r=this;let i,a;return o;function o(h){return!Hi(h)||!Ml.call(r,r.previous)||fo(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(h))}function s(h){return Hi(h)?(e.consume(h),s):h===64?(e.consume(h),d):n(h)}function d(h){return h===46?e.check(ep,p,u)(h):h===45||h===95||Dt(h)?(a=!0,e.consume(h),d):p(h)}function u(h){return e.consume(h),i=!0,d}function p(h){return a&&i&&vt(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function rp(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!Il.call(r,r.previous)||fo(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Jh,e.attempt(Dl,e.attempt(jl,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function ip(e,t,n){const r=this;let i="",a=!1;return o;function o(h){return(h===72||h===104)&&zl.call(r,r.previous)&&!fo(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),e.consume(h),s):n(h)}function s(h){if(vt(h)&&i.length<5)return i+=String.fromCodePoint(h),e.consume(h),s;if(h===58){const x=i.toLowerCase();if(x==="http"||x==="https")return e.consume(h),d}return n(h)}function d(h){return h===47?(e.consume(h),a?u:(a=!0,d)):n(h)}function u(h){return h===null||ti(h)||_e(h)||Un(h)||ai(h)?n(h):e.attempt(Dl,e.attempt(jl,p),n)(h)}function p(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function op(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function ap(e,t,n){let r,i,a;return o;function o(u){return u===46||u===95?e.check(Cl,d,s)(u):u===null||_e(u)||Un(u)||u!==45&&ai(u)?d(u):(a=!0,e.consume(u),o)}function s(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),o}function d(u){return i||r||!a?n(u):t(u)}}function lp(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Cl,t,a)(o):o===null||_e(o)||Un(o)?t(o):(e.consume(o),i)}function a(o){return o===41&&r++,e.consume(o),i}}function sp(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),a):s===93?(e.consume(s),i):s===60||s===null||_e(s)||Un(s)?t(s):n(s)}function i(s){return s===null||s===40||s===91||_e(s)||Un(s)?t(s):r(s)}function a(s){return vt(s)?o(s):n(s)}function o(s){return s===59?(e.consume(s),r):vt(s)?(e.consume(s),o):n(s)}}function cp(e,t,n){return r;function r(a){return e.consume(a),i}function i(a){return Dt(a)?n(a):t(a)}}function Il(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||_e(e)}function zl(e){return!vt(e)}function Ml(e){return!(e===47||Hi(e))}function Hi(e){return e===43||e===45||e===46||e===95||Dt(e)}function fo(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const up={tokenize:yp,partial:!0};function dp(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:mp,continuation:{tokenize:gp},exit:xp}},text:{91:{name:"gfmFootnoteCall",tokenize:pp},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:fp,resolveTo:hp}}}}function fp(e,t,n){const r=this;let i=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const d=r.events[i][1];if(d.type==="labelImage"){o=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return s;function s(d){if(!o||!o._balanced)return n(d);const u=nn(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!a.includes(u.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function hp(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){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)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function pp(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,o;return s;function s(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),d}function d(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(h){if(a>999||h===93&&!o||h===null||h===91||_e(h))return n(h);if(h===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return i.includes(nn(r.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return _e(h)||(o=!0),a++,e.consume(h),h===92?p:u}function p(h){return h===91||h===92||h===93?(e.consume(h),a++,u):u(h)}}function mp(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,o=0,s;return d;function d(C){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(C){return C===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(C)}function p(C){if(o>999||C===93&&!s||C===null||C===91||_e(C))return n(C);if(C===93){e.exit("chunkString");const L=e.exit("gfmFootnoteDefinitionLabelString");return a=nn(r.sliceSerialize(L)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(C),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return _e(C)||(s=!0),o++,e.consume(C),C===92?h:p}function h(C){return C===91||C===92||C===93?(e.consume(C),o++,p):p(C)}function x(C){return C===58?(e.enter("definitionMarker"),e.consume(C),e.exit("definitionMarker"),i.includes(a)||i.push(a),Ee(e,y,"gfmFootnoteDefinitionWhitespace")):n(C)}function y(C){return t(C)}}function gp(e,t,n){return e.check(Lr,t,e.attempt(up,t,n))}function xp(e){e.exit("gfmFootnoteDefinition")}
vendor: 2,881 bytes, line 29
29function yp(e,t,n){const r=this;return Ee(e,i,"gfmFootnoteDefinitionIndent",5);function i(a){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function Sp(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,s){let d=-1;for(;++d<o.length;)if(o[d][0]==="enter"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._close){let u=d;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[d][1].end.offset-o[d][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[d][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[d][1].end)},h={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[d][1].start)},x=[["enter",p,s],["enter",o[u][1],s],["exit",o[u][1],s],["enter",h,s]],y=s.parser.constructs.insideSpan.null;y&&$t(x,x.length,0,li(y,o.slice(u+1,d),s)),$t(x,x.length,0,[["exit",h,s],["enter",o[d][1],s],["exit",o[d][1],s],["exit",p,s]]),$t(o,u-1,d-u+3,x),d=u+x.length-2;break}}for(d=-1;++d<o.length;)o[d][1].type==="strikethroughSequenceTemporary"&&(o[d][1].type="data");return o}function a(o,s,d){const u=this.previous,p=this.events;let h=0;return x;function x(C){return u===126&&p[p.length-1][1].type!=="characterEscape"?d(C):(o.enter("strikethroughSequenceTemporary"),y(C))}function y(C){const L=dr(u);if(C===126)return h>1?d(C):(o.consume(C),h++,y);if(h<2&&!n)return d(C);const O=o.exit("strikethroughSequenceTemporary"),M=dr(C);return O._open=!M||M===2&&!!L,O._close=!L||L===2&&!!M,s(C)}}}class kp{constructor(){this.map=[]}add(t,n,r){bp(this,t,n,r)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const a of i)t.push(a);i=r.pop()}this.map.length=0}}function bp(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function wp(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Dp(){return{flow:{null:{name:"table",tokenize:jp,resolveAll:Cp}}}}
vendor: 4,320 bytes, line 29
29function jp(e,t,n){const r=this;let i=0,a=0,o;return s;function s(z){let G=r.events.length-1;for(;G>-1;){const le=r.events[G][1].type;if(le==="lineEnding"||le==="linePrefix")G--;else break}const ee=G>-1?r.events[G][1].type:null,he=ee==="tableHead"||ee==="tableRow"?_:d;return he===_&&r.parser.lazy[r.now().line]?n(z):he(z)}function d(z){return e.enter("tableHead"),e.enter("tableRow"),u(z)}function u(z){return z===124||(o=!0,a+=1),p(z)}function p(z){return z===null?n(z):ue(z)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(z),e.exit("lineEnding"),y):n(z):be(z)?Ee(e,p,"whitespace")(z):(a+=1,o&&(o=!1,i+=1),z===124?(e.enter("tableCellDivider"),e.consume(z),e.exit("tableCellDivider"),o=!0,p):(e.enter("data"),h(z)))}function h(z){return z===null||z===124||_e(z)?(e.exit("data"),p(z)):(e.consume(z),z===92?x:h)}function x(z){return z===92||z===124?(e.consume(z),h):h(z)}function y(z){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(z):(e.enter("tableDelimiterRow"),o=!1,be(z)?Ee(e,C,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):C(z))}function C(z){return z===45||z===58?O(z):z===124?(o=!0,e.enter("tableCellDivider"),e.consume(z),e.exit("tableCellDivider"),L):X(z)}function L(z){return be(z)?Ee(e,O,"whitespace")(z):O(z)}function O(z){return z===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(z),e.exit("tableDelimiterMarker"),M):z===45?(a+=1,M(z)):z===null||ue(z)?ae(z):X(z)}function M(z){return z===45?(e.enter("tableDelimiterFiller"),$(z)):X(z)}function $(z){return z===45?(e.consume(z),$):z===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(z),e.exit("tableDelimiterMarker"),N):(e.exit("tableDelimiterFiller"),N(z))}function N(z){return be(z)?Ee(e,ae,"whitespace")(z):ae(z)}function ae(z){return z===124?C(z):z===null||ue(z)?!o||i!==a?X(z):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(z)):X(z)}function X(z){return n(z)}function _(z){return e.enter("tableRow"),F(z)}function F(z){return z===124?(e.enter("tableCellDivider"),e.consume(z),e.exit("tableCellDivider"),F):z===null||ue(z)?(e.exit("tableRow"),t(z)):be(z)?Ee(e,F,"whitespace")(z):(e.enter("data"),V(z))}function V(z){return z===null||z===124||_e(z)?(e.exit("data"),F(z)):(e.consume(z),z===92?J:V)}function J(z){return z===92||z===124?(e.consume(z),V):V(z)}}function Cp(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,d=0,u,p,h;const x=new kp;for(;++n<e.length;){const y=e[n],C=y[1];y[0]==="enter"?C.type==="tableHead"?(s=!1,d!==0&&(ma(x,t,d,u,p),p=void 0,d=0),u={type:"table",start:Object.assign({},C.start),end:Object.assign({},C.end)},x.add(n,0,[["enter",u,t]])):C.type==="tableRow"||C.type==="tableDelimiterRow"?(r=!0,h=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,p={type:"tableBody",start:Object.assign({},C.start),end:Object.assign({},C.end)},x.add(n,0,[["enter",p,t]])),i=C.type==="tableDelimiterRow"?2:p?3:1):i&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],h=qr(x,t,a,i,void 0,h),a=[0,0,0,0]),o[2]=n)):C.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],h=qr(x,t,a,i,void 0,h)),a=o,o=[a[1],n,0,0])):C.type==="tableHead"?(s=!0,d=n):C.type==="tableRow"||C.type==="tableDelimiterRow"?(d=n,a[1]!==0?(o[0]=o[1],h=qr(x,t,a,i,n,h)):o[1]!==0&&(h=qr(x,t,o,i,n,h)),i=0):i&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(o[3]=n)}for(d!==0&&ma(x,t,d,u,p),x.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=wp(t.events,n))}return e}function qr(e,t,n,r,i,a){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},cr(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const d=cr(t.events,n[1]);if(a={type:o,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const u=cr(t.events,n[2]),p=cr(t.events,n[3]),h={type:s,start:Object.assign({},u),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",h,t]]),r!==2){const x=t.events[n[2]],y=t.events[n[3]];if(x[1].end=Object.assign({},y[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const C=n[2]+1,L=n[3]-n[2]-1;e.add(C,L,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return i!==void 0&&(a.end=Object.assign({}
29,cr(t.events,i)),e.add(i,0,[["exit",a,t]]),a=void 0),a}function ma(e,t,n,r,i){const a=[],o=cr(t.events,n);i&&(i.end=Object.assign({},o),a.push(["exit",i,t])),r.end=Object.assign({},o),a.push(["exit",r,t]),e.add(n+1,0,a)}function cr(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Ep={name:"tasklistCheck",tokenize:Ip};function vp(){return{text:{91:Ep}}}function Ip(e,t,n){const r=this;return i;function i(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),a)}function a(d){return _e(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),o):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),o):n(d)}function o(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(d)}function s(d){return ue(d)?t(d):be(d)?e.check({tokenize:zp},t,n)(d):n(d)}}function zp(e,t,n){return Ee(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Mp(e){return Na([tp(),dp(),Sp(e),Dp(),vp()])}const Fp={};function Ap(e){const t=this,n=e||Fp,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Mp(n)),a.push(Xh()),o.push(Zh(n))}const Pp=async(e,t=[])=>{try{return(await es(Tl,"aiAssistant")({message:e,conversationHistory:t})).data}catch(n){throw console.error("Error communicating with AI agent:",n),n}},{Text:fm}=ja,Xe={bg:"#000000",card:"#111111",border:"#333333",text:"#ffffff",accent:"#177ddc",red:"#dc3545"},Rp=({visible:e,onClose:t})=>{const[n,r]=Le.useState([{role:"assistant",content:"¡Hola! Soy tu asistente de IA para análisis de abastecimiento. ¿En qué puedo ayudarte hoy? Puedes preguntarme sobre stock, movimientos o información de productos."}]),[i,a]=Le.useState(""),[o,s]=Le.useState(!1),d=Le.useRef(null),u=()=>{d.current?.scrollIntoView({behavior:"smooth"})};Le.useEffect(()=>{u()},[n,o]);const p=async()=>{if(!i.trim())return;const x=i.trim();a("");const y=[...n,{role:"user",content:x}];r(y),s(!0);try{const C=n.filter(O=>O.role!=="system").map(O=>({role:O.role,content:O.content})),L=await Pp(x,C);r([...y,{role:"assistant",content:L.reply}])}catch(C){console.error("Chat error:",C),r([...y,{role:"assistant",content:"Lo siento, ha ocurrido un error al procesar tu solicitud. Por favor, inténtalo de nuevo más tarde.",isError:!0}])}finally{s(!1)}},h=x=>
29{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),p())};return l.jsxs(Ol,{title:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",color:Xe.text},children:[l.jsx(Xr,{style:{color:Xe.accent}}),l.jsx("span",{children:"Asistente IA - Hublog"})]}),placement:"right",onClose:t,open:e,width:400,closeIcon:l.jsx(Da,{style:{color:Xe.text}}),headerStyle:{background:Xe.card,borderBottom:`1px solid ${Xe.border}`},bodyStyle:{background:Xe.bg,padding:0,display:"flex",flexDirection:"column"},children:[l.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px"},children:[l.jsx(_l,{dataSource:n,renderItem:(x,y)=>l.jsx("div",{style:{display:"flex",justifyContent:x.role==="user"?"flex-end":"flex-start",marginBottom:"16px"},children:l.jsxs("div",{style:{display:"flex",flexDirection:x.role==="user"?"row-reverse":"row",alignItems:"flex-start",maxWidth:"85%"},children:[l.jsx(yo,{icon:x.role==="user"?l.jsx(Vl,{}):l.jsx(Xr,{}),style:{backgroundColor:x.role==="user"?Xe.accent:"#555",marginLeft:x.role==="user"?"8px":0,marginRight:x.role==="assistant"?"8px":0}}),l.jsx("div",{style:{background:x.role==="user"?Xe.accent:Xe.card,color:x.isError?Xe.red:Xe.text,padding:"10px 14px",borderRadius:"12px",borderTopRightRadius:x.role==="user"?0:"12px",borderTopLeftRadius:x.role==="assistant"?0:"12px",border:x.role==="assistant"?`1px solid ${Xe.border}`:"none",fontSize:"14px",lineHeight:"1.5",overflowWrap:"break-word",wordBreak:"break-word"},children:x.role==="assistant"?l.jsx("div",{className:"markdown-body",style:{color:x.isError?Xe.red:Xe.text},children:l.jsx(Sf,{remarkPlugins:[Ap],children:x.content})}):x.content})]})},y)}),o&&l.jsx("div",{style:{display:"flex",justifyContent:"flex-start",marginBottom:"16px"},children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[l.jsx(yo,{icon:l.jsx(Xr,{}),style:{backgroundColor:"#555"}}),l.jsx("div",{style:{background:Xe.card,padding:"12px",borderRadius:"12px",borderTopLeftRadius:0,border:`1px solid ${Xe.border}`},children:l.jsx(Ir,{size:"small"})})]})}),l.jsx("div",{ref:d})]}),l.jsx("div",{style:{padding:"16px",background:Xe.card,borderTop:`1px solid ${Xe.border}`},children:l.jsxs("div",{style:{display:"flex",gap:"8px"},children:[l.jsx(Bl.TextArea,{value:i,onChange:x=>a(x.target.value),onKeyPress:h,placeholder:"Pregúntale algo al asistente...",autoSize:{minRows:1,maxRows:4},disabled:o,style:{background:Xe.bg,color:Xe.text,borderColor:Xe.border,borderRadius:"8px"}}),l.jsx(Fe,{type:"primary",icon:l.jsx(Nl,{}),onClick:p,disabled:!i.trim()||o,style:{height:"auto",borderRadius:"8px",background:Xe.accent}})]})})]})},Wn=600*1e3,Tp=2700*1e3,Lp=1800*1e3,fr=e=>ts.fromDate(e),ho=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},po=e=>{const t=new Date(e);return t.setHours(23,59,59,999),t},Op=e=>{const t=e.data(),n={id:e.id,...t};for(const r of Object.keys(n))n[r]&&typeof n[r].toDate=="function"&&(n[r]=n[r].toDate());return n},qn=e=>{const t=[];return e.forEach(n=>t.push(Op(n))),t},_p=e=>{if(e==null)return null;if(e instanceof Date&&!isNaN(e.getTime()))return e;if(typeof e=="number"){const t=new Date(e);return isNaN(t.getTime())?null:t}if(typeof e=="string"){const t=new Date(e);return isNaN(t.getTime())?null:t}return null};let Yr=null,Gr=null;const Ai=async()=>{const e="analisis_maestro",t=gt.get(e);return t||(Yr||(Yr=(async()=>{try{const n=await hr(Hn(In,"maestroProductosChileAbastecimiento")),r=qn(n).map(i=>({...i,item:i.item||i.ITEM||"",descripcion:i.descripcionArticuloOracle||i["Descripcion Art Oracle"]||i.descripcionUnificada||"",marca:i.marca||"",familia:i.familia||"",subfamilia:i.subfamilia||"",precioAlsea:parseFloat(String(i.precioAlsea||"0").replace(/[^0-9.,-]/g,"").replace(",","."))||0,diasVidaUtil:parseInt(i.diasVidaUtil)||0,temperatura:i.categoriaOracleCloud||i.tipo||"",pickPack:parseInt(i.pickPack)||1}));return gt.set(e,r,Tp,!1),r}finally{Yr=null}})()),Yr)},Vp=async()=>{const e="analisis_latest_stock_date",t=gt.get(e),n=_p(t);return n||(Gr||(Gr=(async()=>{try{const r=await as("stockCH","stockCH_agg");return r&&gt.set(e,r.getTime(),Lp,!1),r}catch(r){return console.error("Error fetching latest stock date:",r),null}finally{Gr=null}})()),Gr)},Ki=async(e,t)=>{const n=`analisis_stock_${e.getTime()}_${t.getTime()}`,r=gt.get(n);if(r)return r;const a=(await is("Chile",ho(e),po(t),{})).map(o=>{const s={id:o.id,...o.data};for(const d of Object.keys(s))s[d]&&typeof s[d].toDate=="function"&&(s[d]=s[d].toDate());return s});return gt.set(n,a,Wn,!0),a},Wi=async(e,t)=>{const n=`analisis_mov_${e.getTime()}_${t.getTime()}`,r=gt.get(n);if(r)return r;const a=(await os("Chile",ho(e),po(t))).map(o=>{const s={id:o.id,...o.data};for(const d of Object.keys(s))s[d]&&typeof s[d].toDate=="function"&&(s[d]=s[d].toDate());return s});return gt.set(n,a,Wn,!0),a},Bp=7,Np=10,qi=async(e,t)=>{const n=`analisis_inv_${e.getTime()}_${t.getTime()}`,r=gt.get(n);if(r)return r;const i=ho(e),a=po(t),o=Math.max(1,Math.ceil((a-i)/864e5)+1),s=async(u,p)=>{const h=Rr(Hn(In,"InventariosChile"),vn("fechaInventario",">=",fr(u)),vn("fechaInventario","<=",fr(p))),x=await ls(h);return qn(x)};let d;if(o<=Np)d=await s(i,a);else{const u=[];let p=new Date(i);p.setHours(0,0,0,0);const h=new Date(a);for(;p.getTime()<=h.getTime();){const x=new Date(p);x.setDate(x.getDate()+Bp-1),x.setHours(23,59,59,999),x.getTime()>h.getTime()&&x.setTime(h.getTime()),u.push(...await s(p,x)),p=new Date(x),p.setDate(p.getDate()+1),p.setHours(0,0,0,0)}d=u}return gt.set(n,d,Wn,!0),d},$p=async(e=900)=>
29{const t=Hn(In,"ForecastCL"),n=[];let r=null;for(;;){const i=r?[Jr(jo()),Ea(r),ei(e)]:[Jr(jo()),ei(e)],a=await hr(Rr(t,...i));if(a.empty||(n.push(...qn(a)),r=a.docs[a.docs.length-1],a.size<e))break}return n},ga=async()=>{const e="analisis_forecast",t=gt.get(e);if(t&&t.length>0)return t;const n=async(a,o)=>{const s=Rr(Hn(In,"ForecastCL"),vn(a,"==",o)),d=await hr(s);return qn(d)};let r=[];const i=[["Tipo","V"],["Tipo","v"],["tipo","V"],["tipo","v"]];for(const[a,o]of i)try{const s=await n(a,o);if(s.length>0){r=s,console.log(`📦 Forecast (server-filtered ${a}=${o}): ${r.length} records`);break}}catch(s){console.warn(`📦 Forecast filter ${a}=${o} failed:`,s.message)}return r.length===0&&(console.warn("📦 Forecast: sin coincidencia por Tipo/tipo; lectura paginada por documento (evita timeout)..."),r=await $p(900),console.log(`📦 Forecast (paged): ${r.length} total records`)),r.length>0&&(console.log("📦 Forecast sample fields:",Object.keys(r[0]).join(", ")),gt.set(e,r,Wn,!0)),r},xa=async()=>{const e="analisis_politicas",t=gt.get(e);if(t)return t;const n=await hr(Hn(In,"politicas")),r=qn(n);return gt.set(e,r,Wn,!0),r},Pi=800,Fl=async(e,t)=>{const n=Hn(In,e),r=[];let i=null;for(;;){const a=i?[...t,Ea(i),ei(Pi)]:[...t,ei(Pi)],o=await hr(Rr(n,...a));if(o.empty||(r.push(...qn(o)),i=o.docs[o.docs.length-1],o.size<Pi))break}return r},Up=e=>{const t=new Map;for(const n of e||[])for(const r of n||[])r?.id&&!t.has(r.id)&&t.set(r.id,r);return[...t.values()]},Al=()=>{const e=new Date,t=new Date(e.getTime()-2160*60*60*1e3);return t.setHours(0,0,0,0),e.setHours(23,59,59,999),{from:t,to:e}},ya=async()=>{const e="analisis_ingreso_pedido",t=gt.get(e);if(t)return t;const{from:n,to:r}=Al();let i=[];try{const s=await hr(Rr(Hn(In,"AIngresarCL"),vn("estadoIngreso","in",["pendiente","parcial"])));i=qn(s)}catch(s){console.warn("AIngresarCL abiertos:",s?.message||s)}const a=await Fl("AIngresarCL",[vn("fechaImportacion",">=",fr(n)),vn("fechaImportacion","<=",fr(r)),Jr("fechaImportacion")]).catch(s=>(console.warn("AIngresarCL rango:",s?.message||s),[])),o=Up([i,a]);return gt.set(e,o,Wn,!0),console.log(`📥 Ingreso Pedido CL (rango+abiertos): ${o.length} registros`),o},Sa=async()=>{const e="analisis_ingreso_confirmado",t=gt.get(e);if(t)return t;const{from:n,to:r}=Al(),i=await Fl("IngresoConfirmadoCL",[vn("fechaRecepcion",">=",fr(n)),vn("fechaRecepcion","<=",fr(r)),Jr("fechaRecepcion")]).catch(a=>(console.warn("IngresoConfirmadoCL rango:",a?.message||a),[]));return gt.set(e,i,Wn,!0),console.log(`✅ Ingreso Confirmado CL (rango): ${i.length} registros`),i},Hp=(e,t,n,r,i,a,o,s,d,u=[],p=[],h=[])=>{const x=new Date,y=s&&d?Math.max(1,Math.ceil((d-s)/864e5)+1):30,C={};i.forEach(f=>{f.item&&(C[String(f.item)]=f)});const L={},O={};let M=!1;(n||[]).forEach(f=>{const k=String(f.item||f.ITEM||f.codigoSKU||""),T=f.temperatura||f.Temperatura||"";k&&T&&!L[k]&&(L[k]=T),!M&&k&&(M=!0,console.log("📋 Inventario sample fields:",Object.keys(f).join(", ")),["precioAlsea","precio","costoUnitario","valorUnitario","costo","costoUnit","precioUnitario","precioUnit","costoTotal","valorTotal","monto","importe"].forEach(se=>{f[se]!==void 0&&console.log(`📋 Inventario price field "${se}":`,f[se])}));const R=parseFloat(String(f.precioAlsea||f.precio||f.costoUnitario||f.valorUnitario||f.costo||f.costoUnit||f.precioUnitario||f.precioUnit||f.costoAlsea||f.valorUnidad||f.precioCompra||"0").replace(/[^0-9.]/g,""))||0,q=f.fechaInventario instanceof Date?f.fechaInventario.getTime():0;k&&R>0&&(!O[k]||q>O[k].fecha)&&(O[k]={price:R,fecha:q})}),console.log(`📋 Inventario: ${(n||[]).length} registros, ${Object.keys(O).length} SKUs con precio`);let $=e,N=t;if(a){const f=a.toLowerCase(),k=new Set;i.forEach(T=>{const R=String(T.marca||T.cadena||T.cliente||"").toLowerCase();(R.includes(f)||f.includes(R))&&T.item&&k.add(String(T.item))}),console.log(`🔗 Cadena "${a}": ${k.size} SKUs encontrados en maestro`),k.size>0?($=e.filter(T=>{const R=String(T.codigoSKU||T.codigo||"");return k.has(R)}),N=t.filter(T=>{const R=String(T.item||T.codigoSKU||"");return k.has(R)})):($=e.filter(T=>String(T.cadena||T.marca||T.cliente||T.cuenta||"").toLowerCase().includes(f)),N=t.filter(T=>String(T.cadena||T.marca||T.cliente||T.cuenta||"").toLowerCase().includes(f)))}if(o&&o.length>0){const f=new Set(o.map(String));if($.length>0){const R=$[0];console.log("🔎 Product filter debug - Stock sample fields:",Object.keys(R).join(", ")),console.log("🔎 Stock sample values: codigoSKU=",R.codigoSKU,"codigo=",R.codigo,"item=",R.item,"sku=",R.sku,"ITEM=",R.ITEM)}if(N.length>0){const R=N[0];console.log("🔎 Mov sample fields:",Object.keys(R).join(", ")),console.log("🔎 Mov sample values: item=",R.item,"codigoSKU=",R.codigoSKU,"sku=",R.sku,"ITEM=",R.ITEM)}console.log("🔎 Product filter: looking for",[...f].join(", "));const k=$.length,T=N.length;$=$.filter(R=>f.has(String(R.codigoSKU||R.codigo||R.item||R.sku||R.ITEM||""))),N=N.filter(R=>f.has(String(R.item||R.codigoSKU||R.sku||""))),console.log(`🔎 Product filter: stock ${k} → ${$.length}, mov ${T} → ${N.length}`)}let ae=null;$.forEach(f=>{const k=f.fechaStock instanceof Date?f.fechaStock:null;k&&(!ae||k>ae)&&(ae=k)});const X=ae?`${ae.getFullYear()}
29-${String(ae.getMonth()+1).padStart(2,"0")}-${String(ae.getDate()).padStart(2,"0")}`:null,_=X?$.filter(f=>{const k=f.fechaStock instanceof Date?f.fechaStock:null;return k?`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}-${String(k.getDate()).padStart(2,"0")}`===X:!1}):$,F={};_.forEach(f=>{const k=String(f.codigoSKU||f.codigo||"");k&&(F[k]||(F[k]={sku:k,descripcionSKU:f.descripcionSKU||"",familia:f.familia||"",subFamilia:f.subFamilia||"",tipoAlmacenamiento:f.tipoAlmacenamiento||"",estado:f.estado||"",cantidadFisica:0,cantidadDisponible:0,cantidadBloqueada:0,fechaElabor:f.fechaElabor||null,fechaVenci:f.fechaVenci||null,lotes:[]}),F[k].cantidadFisica+=Number(f.cantidadFisica||0),F[k].cantidadDisponible+=Number(f.cantidadDisponible||0),F[k].cantidadBloqueada+=Number(f.cantidadBloqueada||0),(f.fechaVenci||f.fechaElabor)&&F[k].lotes.push({lote:f.loteCliente||"",cantidad:Number(f.cantidadFisica||0),fechaElabor:f.fechaElabor||null,fechaVenci:f.fechaVenci||null}))});const V={},J={};let z=1/0,G=-1/0;N.forEach(f=>{const k=f.fecha instanceof Date?f.fecha.getTime():0;k>0&&(k<z&&(z=k),k>G&&(G=k))});const ee=z<1/0?Math.max(1,Math.ceil((G-z)/864e5)+1):1,he={};N.forEach(f=>{const k=String(f.item||"");if(k&&(V[k]||(V[k]={solicitado:0,despachado:0,entregado:0,devuelto:0,ingresado:0}),V[k].solicitado+=Number(f.solicitado||0),V[k].despachado+=Number(f.despachado||0),V[k].entregado+=Number(f.entregado||0),V[k].devuelto+=Number(f.devuelto||0),(f.ingresado||f.recibido)&&(V[k].ingresado+=Number(f.ingresado||f.recibido||0)),f.fecha instanceof Date)){const T=`${f.fecha.getFullYear()}-${String(f.fecha.getMonth()+1).padStart(2,"0")}-${String(f.fecha.getDate()).padStart(2,"0")}`;he[T]||(he[T]={fecha:T,despachado:0,solicitado:0,faltante:0});const R=Number(f.solicitado||0),q=Number(f.despachado||0);he[T].despachado+=q,he[T].solicitado+=R,he[T].faltante+=Math.max(0,R-q),J[k]||(J[k]={}),J[k][T]=(J[k][T]||0)+q}});const le=Object.values(he).sort((f,k)=>f.fecha.localeCompare(k.fecha)),Z={};Object.keys(J).forEach(f=>{const k=Object.keys(J[f]),T=k.reduce((R,q)=>R+J[f][q],0);Z[f]={promedioDiario:ee>0?T/ee:0,diasConDatos:k.length,totalDespachado:T}});const we=le.map(f=>({fecha:f.fecha,fechaLabel:f.fecha.substring(5),consumo:f.despachado})),Ae={};N.forEach(f=>{const k=String(f.ordenERP||f.ordenErp||"");if(!k)return;Ae[k]||(Ae[k]={orden:k,lineas:0,lineasConFaltante:0,totalSolicitado:0,totalFaltante:0}),Ae[k].lineas++;const T=Number(f.solicitado||0),R=Number(f.despachado||0);Ae[k].totalSolicitado+=T;const q=Math.max(0,T-R);Ae[k].totalFaltante+=q,q>0&&Ae[k].lineasConFaltante++});const ze=Object.values(Ae),xt=ze.length,E=ze.reduce((f,k)=>f+k.lineas,0),nt=ze.reduce((f,k)=>f+k.lineasConFaltante,0),ht=E>0?(E-nt)/E*100:100,v=ze.reduce((f,k)=>f+k.totalSolicitado,0),Ze=ze.reduce((f,k)=>f+k.totalFaltante,0),Rt=v>0?(v-Ze)/v*100:100,pe={},Ct=x.getFullYear(),Ve=x.getMonth()+1,He=`${Ct}-${String(Ve).padStart(2,"0")}`,yt=[];for(let f=0;f<3;f++){let k=Ve-f,T=Ct;k<=0&&(k+=12,T-=1),yt.push(`${T}-${String(k).padStart(2,"0")}`)}const Tt={enero:1,febrero:2,marzo:3,abril:4,mayo:5,junio:6,julio:7,agosto:8,septiembre:9,octubre:10,noviembre:11,diciembre:12,ene:1,feb:2,mar:3,abr:4,may:5,jun:6,jul:7,ago:8,sep:9,oct:10,nov:11,dic:12,january:1,february:2,march:3,april:4,june:6,july:7,august:8,september:9,october:10,november:11,december:12};let Me=0,un=0,dn=0;r.forEach(f=>{Me++;const k=String(f.Tipo||f.tipo||"").toUpperCase().trim();if(k&&k!=="V"){un++;return}const T=String(f.SKU||f.sku||f.Sku||f.codigo||f.Codigo||"");if(!T)return;const R=f.periodo||f.Periodo||f.mes||f.Mes||f.period||"";let q=null,oe=null;if(R instanceof Date)q=R.getFullYear(),oe=R.getMonth()+1;else if(R&&typeof R.toDate=="function"){const ke=R.toDate();q=ke.getFullYear(),oe=ke.getMonth()+1}else if(R){const ke=String(R).trim(),Te=ke.match(/^(\d{4})[-/](\d{1,2})$/),Ge=ke.match(/^(\d{1,2})[-/](\d{4})$/),St=ke.match(/^([a-zA-ZáéíóúñÑ]+)\s*[-/]?\s*(\d{4})$/i),Qe=ke.match(/^(\d{4})\s*[-/]?\s*([a-zA-ZáéíóúñÑ]+)$/i),Wt=ke.match(/^(\d{4})(\d{2})$/),Bt=ke.match(/^(\d{2})(\d{4})$/);Te?(q=parseInt(Te[1]),oe=parseInt(Te[2])):Ge?(oe=parseInt(Ge[1]),q=parseInt(Ge[2])):St?(oe=Tt[St[1].toLowerCase()]||null,q=parseInt(St[2])):Qe?(q=parseInt(Qe[1]),oe=Tt[Qe[2].toLowerCase()]||null):Wt?(q=parseInt(Wt[1]),oe=parseInt(Wt[2])):Bt&&(oe=parseInt(Bt[1]),q=parseInt(Bt[2]))}if(q||(q=parseInt(f.anio||f.año||f.year||f.Year||f.Anio||f.Año||0)||null),!oe){const ke=f.mes||f.Mes||f.month||f.Month||"";typeof ke=="number"?oe=ke:ke&&(oe=parseInt(ke)||Tt[String(ke).toLowerCase().trim()]||null)}if(!q||!oe||oe<1||oe>12)return;dn++;const se=`${q}-${String(oe).padStart(2,"0")}`,We=Number(f.cantidad||f.Cantidad||f.qty||f.Qty||f.unidades||f.
29Unidades||0);pe[T]||(pe[T]={}),pe[T][se]||(pe[T][se]=0),pe[T][se]+=We}),console.log(`📊 Forecast: ${Me} total, ${un} skipped (not V), ${dn} parsed. Relevant months: ${yt.join(", ")}. SKUs con forecast: ${Object.keys(pe).length}`),Me>0&&dn===0&&console.warn("⚠️ Forecast: ningún registro pudo ser parseado. Ejemplo del primer registro:",JSON.stringify(r[0]).substring(0,300));const me={};Object.keys(pe).forEach(f=>{if(pe[f][He])me[f]=pe[f][He];else{let k=0;yt.forEach(T=>{k+=pe[f][T]||0}),k>0&&(me[f]=Math.round(k/yt.filter(T=>pe[f][T]).length))}});const de=(f,k)=>{const T=`${k.getFullYear()}-${String(k.getMonth()+1).padStart(2,"0")}`,R=pe[f]?.[T];if(!R)return 0;const q=new Date(k.getFullYear(),k.getMonth()+1,0).getDate();return R/q},Oe={};$.forEach(f=>{const k=String(f.codigoSKU||f.codigo||"");if(!k)return;const T=f.fechaStock instanceof Date?f.fechaStock:null;if(!T)return;const R=`${T.getFullYear()}-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`;Oe[R]||(Oe[R]={}),Oe[R][k]=(Oe[R][k]||0)+Number(f.cantidadFisica||0)});const rt={};(p||[]).forEach(f=>{const k=String(f.articulo||"");if(!k)return;rt[k]||(rt[k]={totalPedido:0,totalRecibida:0,pendiente:0,fechaEntregaMasCercana:null,lineas:[]});const T=Number(f.cantidad||0),R=Number(f.cantidadRecibida||0),q=Number(f.cantidadCancelada||0),oe=Math.max(0,T-R-q);rt[k].totalPedido+=T,rt[k].totalRecibida+=R,rt[k].pendiente+=oe;const se=f.fechaEntregaSolicitada||f.fechaEntrega;se instanceof Date&&!isNaN(se.getTime())&&(!rt[k].fechaEntregaMasCercana||se<rt[k].fechaEntregaMasCercana)&&(rt[k].fechaEntregaMasCercana=se),rt[k].lineas.push({nroOC:f.nroOC||"",linea:f.linea||"",descripcion:f.descripcionArticulo||"",cantidad:T,recibida:R,cancelada:q,pendiente:oe,proveedor:f.proveedor||"",estadoOC:f.estadoOC||"",estadoLinea:f.estadoLineaOC||"",fechaEntrega:se instanceof Date?se:null})});const Lt={},It=Object.keys(Oe).sort();if(It.length>=2){const f=It[It.length-1],k=It[It.length-2];new Set([...Object.keys(Oe[f]||{}),...Object.keys(Oe[k]||{})]).forEach(R=>{const q=(Oe[f]||{})[R]||0,oe=(Oe[k]||{})[R]||0,se=(J[R]||{})[f]||0,We=q-oe+se;We>0&&(Lt[R]={cantidad:Math.round(We),stockAyer:oe,stockHoy:q,salidas:se,fechaDeteccion:f})})}const lt={},rn={};(h||[]).forEach(f=>{const k=String(f.sku||"");if(!k)return;lt[k]||(lt[k]={totalRecibida:0,totalKg:0,fechaMaxRecepcion:null,lineas:[]});const T=Number(f.cantidadRecibida||0),R=Number(f.kgRecibido||0);lt[k].totalRecibida+=T,lt[k].totalKg+=R;const q=f.fechaRecepcion,oe=q instanceof Date&&!isNaN(q.getTime())?q:null;if(oe){(!lt[k].fechaMaxRecepcion||oe>lt[k].fechaMaxRecepcion)&&(lt[k].fechaMaxRecepcion=oe);const se=parseFloat(String(f.precioAlsea||f.precio||f.costoUnitario||f.valorUnitario||f.costo||f.costoUnit||f.precioUnitario||f.precioUnit||f.costoAlsea||f.valorUnidad||f.precioCompra||"0").replace(/[^0-9.]/g,""))||0;se>0&&(!rn[k]||oe>rn[k].date)&&(rn[k]={price:se,date:oe})}lt[k].lineas.push({oc:f.oc||"",documento:f.documento||"",lpn:f.lpn||"",lote:f.loteCliente||"",descripcion:f.descripcionSKU||"",cantidadRecibida:T,kgRecibido:R,estadoRecepcion:f.estadoRecepcion||"",site:f.site||"",fechaRecepcion:oe,fechaVencimiento:f.fechaVencimiento instanceof Date?f.fechaVencimiento:null})});const yn=7,Ot={},zt=Object.keys(Oe).sort();if(zt.length>=2){const f=zt[zt.length-1],k=new Date(f).getTime();Object.entries(lt).forEach(([T,R])=>{if(!R.fechaMaxRecepcion||(k-R.fechaMaxRecepcion.getTime())/864e5>yn)return;const oe=R.fechaMaxRecepcion.toISOString().slice(0,10),se=zt.findIndex(Qt=>Qt>=oe),We=se>0?se-1:0,ke=zt[We],Te=(Oe[ke]||{})[T]||0,Ge=(Oe[f]||{})[T]||0;let St=0;for(let Qt=We+1;Qt<zt.length;Qt++)St+=(J[T]||{})[zt[Qt]]||0;const Qe=Te-St+R.totalRecibida,Wt=Ge-Qe,Bt=Math.max(5,R.totalRecibida*.05);Wt<-Bt&&(Ot[T]={sku:T,totalConfirmado:R.totalRecibida,fechaRecepcion:R.fechaMaxRecepcion,stockAntes:Te,stockActual:Ge,salidasPeriodo:St,stockEsperado:Math.round(Qe),diferencia:Math.round(Wt),descripcion:lt[T].lineas[0]?.descripcion||""})})}console.log(`📥 Ingreso Pedido: ${Object.keys(rt).length} SKUs con pedido, ${Object.keys(Lt).length} SKUs con ingreso detectado, ✅ Confirmado: ${Object.keys(lt).length} SKUs, ⚠️ Anomalías: ${Object.keys(Ot).length}`);
29const B=15,Y=new Set([...Object.keys(F),...Object.keys(V)]),Q=[];Y.forEach(f=>{const k=F[f]||{},T=V[f]||{},R=C[f]||{},q=Z[f]||{promedioDiario:0},oe=k.cantidadFisica||0,se=q.promedioDiario,We=ee>0?(V[f]?.ingresado||0)/ee:0,ke=rn[f]?.price||O[f]?.price||R.precioAlsea||0,Te=oe*ke,Ge=L[f]||k.tipoAlmacenamiento||R.temperatura||"",St=R.diasVidaUtil||0;let Qe=null,Wt=null,Bt="none",Qt=0,An=0,bn=0,qe=oe,mn=!1;const Gn=[],xr=(k.lotes||[]).filter(kt=>kt.fechaElabor||kt.fechaVenci);if(xr.length>0){let kt=1/0,br=0,jn=0;xr.forEach(ut=>{let On=ut.fechaVenci instanceof Date?ut.fechaVenci:ut.fechaVenci?new Date(ut.fechaVenci):null;const er=ut.fechaElabor instanceof Date?ut.fechaElabor:ut.fechaElabor?new Date(ut.fechaElabor):null;if(!On&&er&&St>0&&(On=new Date(er.getTime()+St*864e5)),!On||isNaN(On.getTime()))return;const mo=er&&!isNaN(er.getTime()),tr=Math.ceil((On-x)/864e5),Vr=tr-B,go=mo?Math.ceil((On-er)/864e5):St||0,Rl=mo?Math.ceil((x-er)/864e5):0,xo=go>0?Rl/go*100:100;tr<kt&&(kt=tr),br+=xo,jn++;const Br={lote:ut.lote,cantidad:ut.cantidad,fechaVenci:On,diasHastaVencReal:tr,diasHastaVencEfectivo:Vr,pctVida:Math.round(xo)};if(tr<0)An+=ut.cantidad*ke,bn+=ut.cantidad,qe-=ut.cantidad,Br.estado="vencido";else if(Vr<=0){const hi=se*Math.max(0,tr),Nr=Math.max(0,ut.cantidad-hi);Qt+=Nr*ke,Br.estado="riesgo_alto"}else{const hi=se*Vr,Nr=Math.max(0,ut.cantidad-hi);Qt+=Nr*ke,Br.estado=Nr>0?Vr<=30?"riesgo_medio":"riesgo_bajo":"ok"}Gn.push(Br)}),Qe=kt===1/0?null:kt,Wt=jn>0?br/jn:null,mn=bn>0,Qe!==null&&(Qe<0?Bt="merma":Qe<=B?Bt="alto":Qe<=45?Bt="medio":Qe<=90&&(Bt="bajo"))}qe=Math.max(0,qe);const Pn=se>0?qe/se:qe>0?1/0:0;let Qn="normal";oe>0&&se===0?Qn="nula":oe>0&&Pn>90&&(Qn="baja");const Xt=(T.solicitado||0)>0?(T.despachado||0)/(T.solicitado||1)*100:null,on=me[f]||0,yr=on>0?on/30:0,di=ee>0?(T.despachado||0)/ee:0,Xn=on>0?Math.round((T.despachado||0)/on*100):null,fi=R.categoriaOracleCloud||R.subfamilia||k.subFamilia||"";let wn="ok",Zn="";const Zt=se>0?se:yr,ct=Zt>0&&qe>0?Math.round(qe/Zt):null,Dn=ct!==null&&ct<=30&&qe>0,Jt=Gn.filter(kt=>kt.estado!=="vencido");let Ye=!1;if(Jt.length>0&&qe>0){let kt=0;for(const br of Jt.sort((jn,ut)=>jn.diasHastaVencReal-ut.diasHastaVencReal)){kt+=br.cantidad;const jn=br.diasHastaVencEfectivo,ut=Zt*Math.max(0,jn);if(kt>ut&&jn>0){Ye=!0;break}}}const an=Qe!==null&&Qe>0&&Qe<=30&&qe>0&&Zt===0;Dn&&(Ye||an)?(wn="ambos",Zn=`Agotamiento en ~${ct}d, vencimiento en ${Qe}d`):Dn?(wn="faltante",Zn=`Stock no vencido se agota en ~${ct}d (consumo ${Math.round(Zt)}/día)`):(Ye||an)&&(wn="mermaVencimiento",Zn=`Vence en ${Qe}d, stock ${Math.round(qe)} uds, consumo ${Math.round(Zt)}/día`);const Et=rt[f]||null,Rn=Lt[f]||null,gn=Et?Et.pendiente:0,Jn=Et?Et.fechaEntregaMasCercana:null;let Tn="sin_pedido";Et&&(Et.pendiente<=0?Tn="completado":Rn&&Rn.cantidad>=Et.pendiente*.5?Tn="ingresado":Tn="pendiente");const Sr=lt[f]||null,_r=Sr?Sr.totalRecibida:0,Ln=Ot[f]||null,kr=Zt>0&&qe>0?Math.round((qe+gn)/Zt):ct;Q.push({sku:f,descripcion:k.descripcionSKU||R.descripcion||R.descripcionArticuloOracle||Sr?.lineas?.[0]?.descripcion||Et?.lineas?.[0]?.descripcion||"",familia:k.familia||R.familia||"",subFamilia:k.subFamilia||R.subfamilia||"",tipoAlmacenamiento:Ge,subCatComercial:fi,marca:R.marca||"",cadena:String(R.cadena||R.marca||R.cliente||"").trim(),cantidadFisica:oe,cantidadNoVencida:qe,cantidadDisponible:k.cantidadDisponible||0,cantidadBloqueada:k.cantidadBloqueada||0,precio:ke,valorStock:Te,consumoDiario:Math.round(se*100)/100,despachoDiario:Math.round(di*100)/100,ingresoDiario:Math.round(We*100)/100,diasStockFinanciero:Pn===1/0?null:Math.round(Pn),solicitado:T.solicitado||0,despachado:T.despachado||0,entregado:T.entregado||0,devuelto:T.devuelto||0,forecastMensual:on,forecastDiario:Math.round(yr*100)/100,pctCumplimientoForecast:Xn,diasParaVencer:Qe,pctVidaUtil:Wt!==null?Math.round(Wt*10)/10:null,riesgoVencimiento:Bt,valorEnRiesgo:Math.round(Qt),esMerma:mn,valorMerma:Math.round(An),cantidadMerma:bn,prediccion:wn,prediccionDetalle:Zn,diasHastaAgotamiento:ct,rotacion:Qn,fillRate:Xt!==null?Math.round(Xt*10)/10:null,lotesDetalle:Gn,pendienteIngreso:gn,ingresoDetectado:Rn?Rn.cantidad:0,ingresoEstado:Tn,fechaIngresoEsperada:Jn,diasStockConIngreso:kr,cantConfirmada:_r,tieneAnomaliaIngreso:!!Ln,anomaliaIngreso:Ln})});const xe=Object.entries(rt).map(([f,k])=>{const T=C[f]||{},R=Lt[f],q=F[f]||{},oe=Q.find(se=>se.sku===f);return{key:f,sku:f,descripcion:T.descripcion||k.lineas[0]?.descripcion||"",familia:T.familia||"",totalPedido:k.totalPedido,totalRecibida:k.totalRecibida,pendiente:k.pendiente,ingresoDetectado:R?.cantidad||0,stockActual:q.cantidadFisica||0,consumoDiario:oe?.consumoDiario||0,diasStockSinIngreso:oe?.diasHastaAgotamiento||null,diasStockConIngreso:oe?.diasStockConIngreso||null,fechaEntrega:k.fechaEntregaMasCercana,estado:k.pendiente<=0?"completado":R&&R.cantidad>=k.pendiente*.5?"ingresado":"pendiente",deteccion:R||null,lineas:k.lineas}}).sort((f,k)=>{const T={pendiente:0,ingresado:1,completado:2};return(T[f.estado]??9)-(T[k.estado]??9)}),Se=Q.reduce((f,k)=>f+k.valorStock,0),st=Q.filter(f=>f.riesgoVencimiento==="alto").reduce((f,k)=>f+k.valorEnRiesgo,0),bt=Q.filter(f=>f.riesgoVencimiento==="medio").reduce((f,k)=>f+k.valorEnRiesgo,0),pt=Q.filter(f=>f.riesgoVencimiento==="bajo").reduce((f,k)=>f+k.valorEnRiesgo,0),Yt=Q.reduce((f,k)=>f+k.valorMerma,0),Ut=Q.reduce((f,k)=>f+k.cantidadMerma,0),Je=Q.filter(f=>f.esMerma).sort((f,k)=>k.valorMerma-f.valorMerma),Mt=Q.filter(f=>f.riesgoVencimiento==="alto").length,et=Q.filter(f=>f.riesgoVencimiento==="medio").length,Mn=Q.filter(f=>f.riesgoVencimiento==="bajo").length,Sn=[{name:"Alto (≤15d)",value:Mt,fill:"#ef5350",valorRiesgo:Math.round(st)},{name:"Medio (≤45d)",value:et,fill:"#ffa726",valorRiesgo:Math.round(bt)},{name:"Bajo (≤90d)",value:Mn,fill:"#ffee58",valorRiesgo:Math.round(pt)}],fn=Q.filter(f=>f.riesgoVencimiento==="none"||f.riesgoVencimiento==="bajo"),gr=Q.filter(f=>f.riesgoVencimiento==="medio"||f.riesgoVencimiento==="alto"),kn=Q.filter(f=>f.riesgoVencimiento==="merma"),Yn=[{name:"OK",productos:fn.length,valor:Math.round(fn.reduce((f,k)=>f+k.valorStock,0))}
29,{name:"Posible Vencimiento",productos:gr.length,valor:Math.round(gr.reduce((f,k)=>f+k.valorStock,0))},{name:"Merma",productos:kn.length,valor:Math.round(kn.reduce((f,k)=>f+k.valorMerma,0))}],w=Q.filter(f=>(f.prediccion==="faltante"||f.prediccion==="ambos")&&f.cantidadNoVencida>0).map(f=>({...f,diasStockSinIngreso:f.consumoDiario>0?Math.round(f.cantidadNoVencida/f.consumoDiario):null})).sort((f,k)=>(f.diasStockSinIngreso||9999)-(k.diasStockSinIngreso||9999)),j=Q.filter(f=>(f.prediccion==="mermaVencimiento"||f.prediccion==="ambos")&&f.cantidadNoVencida>0).map(f=>({...f,lotesEnRiesgo:f.lotesDetalle.filter(k=>k.estado!=="vencido"&&k.estado!=="ok")})).sort((f,k)=>(f.diasParaVencer||9999)-(k.diasParaVencer||9999)),m=Q.filter(f=>f.prediccion!=="ok").sort((f,k)=>{const T={ambos:0,faltante:1,mermaVencimiento:2};return(T[f.prediccion]||3)-(T[k.prediccion]||3)}),S=Q.filter(f=>f.rotacion==="baja"),b=Q.filter(f=>f.rotacion==="nula"),D=Q.filter(f=>f.diasParaVencer!==null&&f.diasParaVencer>0&&f.diasParaVencer<=30),te={};Q.forEach(f=>{const k=C[f.sku]?.familia||f.familia||"Sin Familia";te[k]||(te[k]={familia:k,cantidad:0,valorStock:0,productos:0}),te[k].cantidad+=f.cantidadFisica,te[k].valorStock+=f.cantidadFisica*f.precio,te[k].productos++});const A=Object.values(te).filter(f=>f.valorStock>0).sort((f,k)=>k.valorStock-f.valorStock),K={};(u||[]).forEach(f=>{const k=f.familia;if(!k)return;const T=Number(f.politiFam||f["Politi Fam"]||0);T!==0&&(!K[k]||K[k].politiFam<T)&&(K[k]={familia:k,politiFam:T,marca:f.marca||"",pais:f.pais||""})});const ge=Object.values(K).map(f=>{const{familia:k,politiFam:T}=f,R=Q.filter(ke=>(C[ke.sku]?.familia||ke.familia)===k),q=R.reduce((ke,Te)=>ke+Te.cantidadNoVencida,0),oe=R.reduce((ke,Te)=>ke+Te.consumoDiario,0),se=oe>0?q/oe:null;let We;return se===null?We="sin_movimiento":se<T*.85?We="bajo":se<=T*1.2?We="cercano":We="excedido",{familia:k,politiFam:T,marca:f.marca,pais:f.pais,diasStock:se!==null?Math.round(se):null,totalQty:Math.round(q),avgDailyConsumo:Math.round(oe*10)/10,estado:We,productos:R.length,brecha:se!==null?Math.round(se-T):null}}).sort((f,k)=>{const T={bajo:0,cercano:1,excedido:2,sin_movimiento:3};return(T[f.estado]??9)-(T[k.estado]??9)}),Ie=[...[...Q].filter(f=>f.cantidadFisica>0).sort((f,k)=>k.valorStock-f.valorStock).slice(0,16).map(f=>({sku:f.sku,descripcion:f.descripcion,qty:f.cantidadFisica}))].sort((f,k)=>k.qty-f.qty),Ne=Math.ceil(Ie.length/2),mt=Ie.slice(0,Ne),De=Ie.slice(Ne),_t=Object.keys(Oe).sort(),Ht=f=>_t.map(k=>{const T={fecha:k,fechaLabel:k.substring(5)};return f.forEach(({sku:R})=>{const q=Oe[k]?.[R];q!=null&&(T[R]=q);const[oe,se,We]=k.split("-").map(Number),ke=de(R,new Date(oe,se-1,We));ke>0&&(T[`fc_${R}`]=Math.round(ke))}),T}),hn=Ht(mt),Vt=Ht(De),Gt=Q.filter(f=>f.forecastMensual>0&&f.despachado>0).map(f=>({sku:f.sku,descripcion:f.descripcion,despachado:f.despachado,forecastMensual:f.forecastMensual,pctCumplimiento:f.pctCumplimientoForecast,diferencia:f.despachado-f.forecastMensual})).sort((f,k)=>Math.abs(k.diferencia)-Math.abs(f.diferencia)),pn=Gt.filter(f=>f.pctCumplimiento>=70&&f.pctCumplimiento<=130).slice(0,15),Fn=Gt.filter(f=>f.pctCumplimiento<70||f.pctCumplimiento>130).slice(0,15),g=Q.reduce((f,k)=>f+k.solicitado,0),I=Q.reduce((f,k)=>f+k.despachado,0),U=g>0?I/g*100:0,H={};Q.forEach(f=>{const k=f.familia||"Sin Familia";H[k]||(H[k]={familia:k,valorStock:0,despachoTotal:0,productos:0}),H[k].valorStock+=f.valorStock,H[k].despachoTotal+=f.consumoDiario*(f.precio||0),H[k].productos++});const ie=Object.values(H).map(f=>({...f,diasStockFinanciero:f.despachoTotal>0?Math.round(f.valorStock/f.despachoTotal):null})).filter(f=>f.diasStockFinanciero!=null&&f.diasStockFinanciero>0).sort((f,k)=>(k.diasStockFinanciero||0)-(f.diasStockFinanciero||0)),re={};Q.forEach(f=>{const k=f.subCatComercial||"Sin categoría";re[k]||(re[k]={categoria:k,productos:0,valorStock:0,despachado:0,valorEnRiesgo:0}),re[k].productos++,re[k].valorStock+=f.valorStock,re[k].despachado+=f.despachado,re[k].valorEnRiesgo+=f.valorEnRiesgo});const ce=Object.values(re).filter(f=>f.valorStock>0||f.despachado>0).sort((f,k)=>k.valorStock-f.valorStock),$e=Q.filter(f=>f.solicitado>0&&f.despachado<f.solicitado).map(f=>({sku:f.sku,descripcion:f.descripcion,solicitado:f.solicitado,despachado:f.despachado,noEnviado:f.solicitado-f.despachado,fillRate:f.fillRate})).sort((f,k)=>k.noEnviado-f.noEnviado),fe={};$.forEach(f=>{const k=String(f.codigoSKU||f.codigo||"");if(!k)return;const T=f.fechaStock instanceof Date?f.fechaStock:null;if(!T)return;const R=`${T.getFullYear()}
29-${String(T.getMonth()+1).padStart(2,"0")}-${String(T.getDate()).padStart(2,"0")}`;let q=Number(f.cantidadFisica||0);const oe=f.fechaVenci instanceof Date?f.fechaVenci:null;oe&&Math.ceil((oe-T)/864e5)<=15&&(q=0),fe[R]||(fe[R]={}),fe[R][k]=(fe[R][k]||0)+q});const Pe=Object.keys(fe).sort(),je={};N.forEach(f=>{const k=String(f.item||"");if(!k||!(f.fecha instanceof Date))return;const T=Number(f.solicitado||0);if(T<=0)return;const R=`${f.fecha.getFullYear()}-${String(f.fecha.getMonth()+1).padStart(2,"0")}-${String(f.fecha.getDate()).padStart(2,"0")}`,q=String(f.puntoEntrega||f.PuntoEntrega||f.local||f.Local||f.sucursal||f.cuenta||f.cliente||"Sin local"),oe=Number(f.despachado||0);je[R]||(je[R]={}),je[R][k]||(je[R][k]={}),je[R][k][q]||(je[R][k][q]={solicitado:0,despachado:0}),je[R][k][q].solicitado+=T,je[R][k][q].despachado+=oe});const Ke={};Object.keys(je).sort().forEach(f=>{const k=je[f];Object.keys(k).forEach(T=>{const R=k[T],q=Object.values(R).reduce((Te,Ge)=>Te+Ge.solicitado,0),oe=Object.values(R).reduce((Te,Ge)=>Te+Ge.despachado,0);if(oe>=q)return;let se=null;for(const Te of Pe)if(Te<=f)se=Te;else break;const We=se&&fe[se]?.[T]||0;if(We<=0)return;const ke=Object.entries(R).filter(([,Te])=>Te.solicitado>Te.despachado).map(([Te,Ge])=>({local:Te,solicitado:Ge.solicitado,despachado:Ge.despachado,faltante:Ge.solicitado-Ge.despachado})).sort((Te,Ge)=>Ge.faltante-Te.faltante);Ke[T]||(Ke[T]=[]),Ke[T].push({key:`${f}_${T}`,fecha:f,totalPedido:q,totalEnviado:oe,faltante:q-oe,stockDisponible:Math.round(We),locales:ke,cantLocales:ke.length})})});const Ue=Object.keys(Ke).map(f=>{const k=Ke[f].sort((R,q)=>R.fecha.localeCompare(q.fecha)),T=C[f]||{};return{key:f,sku:f,descripcion:T.descripcion||F[f]?.descripcionSKU||"",totalPedido:k.reduce((R,q)=>R+q.totalPedido,0),totalEnviado:k.reduce((R,q)=>R+q.totalEnviado,0),faltante:k.reduce((R,q)=>R+q.faltante,0),cantFechas:k.length,fechas:k}}).sort((f,k)=>k.faltante-f.faltante),Kt=Q.filter(f=>{const k=(f.consumoDiario||0)*30;return Math.max(0,k-(f.cantidadNoVencida||0)-(f.pendienteIngreso||0))>0}).map(f=>{const k=C[f.sku]||{},T=Math.round((f.consumoDiario||0)*30),R=f.cantidadNoVencida||0,q=f.pendienteIngreso||0,oe=Math.max(0,T-R-q);return{key:f.sku,codigoProveedor:k.codigoProveedor||"",nombreProveedor:k.proveedorOrigen||k.nombreFantasiaUnificado||"",sku:f.sku,descripcion:f.descripcion||k.descripcion||"",stockExistente:Math.round(R),consumo30Dias:T,pendienteIngreso:Math.round(q),cantidadNecesaria:Math.round(oe),consumoDiario:f.consumoDiario||0,diasStock:f.diasHastaAgotamiento,familia:f.familia||k.familia||""}}).sort((f,k)=>{const T=f.codigoProveedor||f.nombreProveedor||"ZZZ",R=k.codigoProveedor||k.nombreProveedor||"ZZZ";return T!==R?T.localeCompare(R):k.cantidadNecesaria-f.cantidadNecesaria});return{products:Q,newestStockDate:X,kpis:{totalProductos:Q.length,totalValorStock:Math.round(Se),totalValorRiesgoAlto:Math.round(st),totalValorRiesgoMedio:Math.round(bt),totalValorRiesgoBajo:Math.round(pt),pctRiesgoAlto:Se>0?Math.round(st/Se*1e3)/10:0,pctRiesgoMedio:Se>0?Math.round(bt/Se*1e3)/10:0,pctRiesgoBajo:Se>0?Math.round(pt/Se*1e3)/10:0,riesgoAltoCount:Mt,riesgoMedioCount:et,riesgoBajoCount:Mn,productosBajaRotacion:S.length,productosNulaRotacion:b.length,productosVencimientoCorto:D.length,totalSolicitado:Math.round(g),totalDespachado:Math.round(I),totalNoEnviado:Math.round(g-I),fillRateGlobal:Math.round(U*10)/10,fillRateLineas:Math.round(ht*10)/10,fillRateUnidades:Math.round(Rt*10)/10,totalOrdenes:xt,totalLineas:E,lineasConFaltante:nt,totalUnidadesSolOrd:v,totalUnidadesFaltOrd:Ze,totalValorMerma:Math.round(Yt),totalCantidadMerma:Ut,totalProductosMerma:Je.length,totalProductosPrediccionFaltante:w.length,totalProductosPrediccionMerma:j.length,totalStockFamilia:Math.round(A.reduce((f,k)=>f+k.valorStock,0)),totalPoliticasBajo:ge.filter(f=>f.estado==="bajo").length,totalPoliticasCercano:ge.filter(f=>f.estado==="cercano").length,totalPoliticasExcedido:ge.filter(f=>f.estado==="excedido").length},productosBajaRotacion:S,productosNulaRotacion:b,productosVencimientoCorto:D,productosMerma:Je,riesgoProportionData:Sn,statusChartData:Yn,predictivoData:m,posibleFaltante:w,posibleMermaVenc:j,familiaData:ie,subCatData:ce,forecastCercanos:pn,forecastLejanos:Fn,forecastComparison:Gt,noEnviados:$e,dailyData:le,consumoTrendData:we,totalDays:ee,periodDays:y,stockFamiliaData:A,stockEvolutionHigh:hn,stockEvolutionLow:Vt,evolutionGroupHigh:mt,evolutionGroupLow:De,politicasCumplimiento:ge,faltantesConStock:Ue,ingresoPedidoD
29ata:xe,ingresoConfirmadoData:Object.entries(lt).map(([f,k])=>{const T=C[f]||{},R=F[f]||{},q=Q.find(oe=>oe.sku===f);return{key:f,sku:f,descripcion:T.descripcion||k.lineas[0]?.descripcion||"",familia:T.familia||"",totalRecibida:k.totalRecibida,totalKg:k.totalKg,stockActual:R.cantidadFisica||0,consumoDiario:q?.consumoDiario||0,diasStockActual:q?.diasHastaAgotamiento||null,fechaUltimaRecepcion:k.fechaMaxRecepcion,tieneAnomaliaIngreso:!!Ot[f],anomalia:Ot[f]||null,lineas:k.lineas}}).sort((f,k)=>(k.tieneAnomaliaIngreso?1:0)-(f.tieneAnomaliaIngreso?1:0)),anomaliasIngresoData:Object.values(Ot),aPedirData:Kt}},Kp=(e,t,n,r,i,a,o,s=[],d=[],u=[])=>{const p=new Date,h=e.periodDays||(a&&o?Math.max(1,Math.ceil((o-a)/864e5)+1):30),x=e.totalDays||h,y={};n.forEach(g=>{g.item&&(y[String(g.item)]=g)});let{stockBySku:C,movBySku:L,dailyExitsBySku:O,dailyData:M,orderMap:$,invTempMap:N,lastInvPriceBySku:ae,stockByDaySku:X,stockDispByDaySku:_,movByDateSkuLocal:F}=e;if(r){const g=r.toLowerCase(),I=new Set;if(n.forEach(U=>{const H=String(U.marca||U.cadena||U.cliente||"").toLowerCase();(H.includes(g)||g.includes(H))&&U.item&&I.add(String(U.item))}),I.size>0){const U=H=>{const ie={};return Object.entries(H).forEach(([re,ce])=>{I.has(re)&&(ie[re]=ce)}),ie};C=U(C||{}),L=U(L||{}),O=U(O||{})}}if(i&&i.length>0){const g=new Set(i.map(String)),I=U=>{const H={};
29return Object.entries(U).forEach(([ie,re])=>{g.has(ie)&&(H[ie]=re)}),H};C=I(C||{}),L=I(L||{}),O=I(O||{})}const V={};Object.keys(O||{}).forEach(g=>{const I=Object.keys(O[g]),U=I.reduce((H,ie)=>H+O[g][ie],0);V[g]={promedioDiario:x>0?U/x:0,diasConDatos:I.length,totalDespachado:U}});const J=(M||[]).map(g=>({fecha:g.fecha,fechaLabel:g.fecha.substring(5),consumo:g.despachado})),z=Object.values($||{}),G=z.length,ee=z.reduce((g,I)=>g+(I.lineas||0),0),he=z.reduce((g,I)=>g+(I.lineasConFaltante||0),0),le=ee>0?(ee-he)/ee*100:100,Z=z.reduce((g,I)=>g+(I.totalSolicitado||0),0),we=z.reduce((g,I)=>g+(I.totalFaltante||0),0),Ae=Z>0?(Z-we)/Z*100:100,ze={},xt=p.getFullYear(),E=p.getMonth()+1,nt=`${xt}-${String(E).padStart(2,"0")}`,ht=[];for(let g=0;g<3;g++){let I=E-g,U=xt;I<=0&&(I+=12,U-=1),ht.push(`${U}-${String(I).padStart(2,"0")}`)}const v={enero:1,febrero:2,marzo:3,abril:4,mayo:5,junio:6,julio:7,agosto:8,septiembre:9,octubre:10,noviembre:11,diciembre:12,ene:1,feb:2,mar:3,abr:4,may:5,jun:6,jul:7,ago:8,sep:9,oct:10,nov:11,dic:12,january:1,february:2,march:3,april:4,june:6,july:7,august:8,september:9,october:10,november:11,december:12};t.forEach(g=>{const I=String(g.Tipo||g.tipo||"").toUpperCase().trim();if(I&&I!=="V")return;const U=String(g.SKU||g.sku||g.Sku||g.codigo||g.Codigo||"");if(!U)return;const H=g.periodo||g.Periodo||g.mes||g.Mes||g.period||"";let ie=null,re=null;if(H instanceof Date)ie=H.getFullYear(),re=H.getMonth()+1;else if(H&&typeof H.toDate=="function"){const fe=H.toDate();ie=fe.getFullYear(),re=fe.getMonth()+1}else if(H){const fe=String(H).trim(),Pe=fe.match(/^(\d{4})[-/](\d{1,2})$/),je=fe.match(/^(\d{1,2})[-/](\d{4})$/),Ke=fe.match(/^([a-zA-ZáéíóúñÑ]+)\s*[-/]?\s*(\d{4})$/i),Ue=fe.match(/^(\d{4})\s*[-/]?\s*([a-zA-ZáéíóúñÑ]+)$/i),Kt=fe.match(/^(\d{4})(\d{2})$/),f=fe.match(/^(\d{2})(\d{4})$/);Pe?(ie=parseInt(Pe[1]),re=parseInt(Pe[2])):je?(re=parseInt(je[1]),ie=parseInt(je[2])):Ke?(re=v[Ke[1].toLowerCase()]||null,ie=parseInt(Ke[2])):Ue?(ie=parseInt(Ue[1]),re=v[Ue[2].toLowerCase()]||null):Kt?(ie=parseInt(Kt[1]),re=parseInt(Kt[2])):f&&(re=parseInt(f[1]),ie=parseInt(f[2]))}if(ie||(ie=parseInt(g.anio||g.año||g.year||g.Year||g.Anio||g.Año||0)||null),!re){const fe=g.mes||g.Mes||g.month||g.Month||"";typeof fe=="number"?re=fe:fe&&(re=parseInt(fe)||v[String(fe).toLowerCase().trim()]||null)}if(!ie||!re||re<1||re>12)return;const ce=`${ie}-${String(re).padStart(2,"0")}`,$e=Number(g.cantidad||g.Cantidad||g.qty||g.Qty||g.unidades||g.Unidades||0);ze[U]||(ze[U]={}),ze[U][ce]||(ze[U][ce]=0),ze[U][ce]+=$e});const Ze={};Object.keys(ze).forEach(g=>{if(ze[g][nt])Ze[g]=ze[g][nt];else{let I=0;ht.forEach(U=>{I+=ze[g][U]||0}),I>0&&(Ze[g]=Math.round(I/ht.filter(U=>ze[g][U]).length))}});const Rt=(g,I)=>{const U=`${I.getFullYear()}-${String(I.getMonth()+1).padStart(2,"0")}`,H=ze[g]?.[U];if(!H)return 0;const ie=new Date(I.getFullYear(),I.getMonth()+1,0).getDate();return H/ie},pe={};(d||[]).forEach(g=>{const I=String(g.articulo||"");if(!I)return;pe[I]||(pe[I]={totalPedido:0,totalRecibida:0,pendiente:0,fechaEntregaMasCercana:null,lineas:[]});const U=Number(g.cantidad||0),H=Number(g.cantidadRecibida||0),ie=Number(g.cantidadCancelada||0),re=Math.max(0,U-H-ie);
29pe[I].totalPedido+=U,pe[I].totalRecibida+=H,pe[I].pendiente+=re;const ce=g.fechaEntregaSolicitada||g.fechaEntrega;ce instanceof Date&&!isNaN(ce.getTime())&&(!pe[I].fechaEntregaMasCercana||ce<pe[I].fechaEntregaMasCercana)&&(pe[I].fechaEntregaMasCercana=ce),pe[I].lineas.push({nroOC:g.nroOC||"",linea:g.linea||"",descripcion:g.descripcionArticulo||"",cantidad:U,recibida:H,cancelada:ie,pendiente:re,proveedor:g.proveedor||"",estadoOC:g.estadoOC||"",estadoLinea:g.estadoLineaOC||"",fechaEntrega:ce instanceof Date?ce:null})});const Ct={},Ve=Object.keys(X||{}).sort();if(Ve.length>=2){const g=Ve[Ve.length-1],I=Ve[Ve.length-2];new Set([...Object.keys((X||{})[g]||{}),...Object.keys((X||{})[I]||{})]).forEach(H=>{const ie=((X||{})[g]||{})[H]||0,re=((X||{})[I]||{})[H]||0,ce=((O||{})[H]||{})[g]||0,$e=ie-re+ce;$e>0&&(Ct[H]={cantidad:Math.round($e),stockAyer:re,stockHoy:ie,salidas:ce,fechaDeteccion:g})})}const He={},yt={};(u||[]).forEach(g=>{const I=String(g.sku||"");if(!I)return;He[I]||(He[I]={totalRecibida:0,totalKg:0,fechaMaxRecepcion:null,lineas:[]});const U=Number(g.cantidadRecibida||0),H=Number(g.kgRecibido||0);He[I].totalRecibida+=U,He[I].totalKg+=H;const ie=g.fechaRecepcion,re=ie instanceof Date&&!isNaN(ie.getTime())?ie:null;if(re){(!He[I].fechaMaxRecepcion||re>He[I].fechaMaxRecepcion)&&(He[I].fechaMaxRecepcion=re);const ce=parseFloat(String(g.precioAlsea||g.precio||g.costoUnitario||g.valorUnitario||g.costo||g.costoUnit||g.precioUnitario||g.precioUnit||g.costoAlsea||g.valorUnidad||g.precioCompra||"0").replace(/[^0-9.]/g,""))||0;ce>0&&(!yt[I]||re>yt[I].date)&&(yt[I]={price:ce,date:re})}He[I].lineas.push({oc:g.oc||"",documento:g.documento||"",lpn:g.lpn||"",lote:g.loteCliente||"",descripcion:g.descripcionSKU||"",cantidadRecibida:U,kgRecibido:H,estadoRecepcion:g.estadoRecepcion||"",site:g.site||"",fechaRecepcion:re,fechaVencimiento:g.fechaVencimiento instanceof Date?g.fechaVencimiento:null})});const Tt=7,Me={};if(Ve.length>=2){const g=Ve[Ve.length-1],I=new Date(g).getTime();Object.entries(He).forEach(([U,H])=>{if(!H.fechaMaxRecepcion||(I-H.fechaMaxRecepcion.getTime())/864e5>Tt)return;const re=H.fechaMaxRecepcion.toISOString().slice(0,10),ce=Ve.findIndex(k=>k>=re),$e=ce>0?ce-1:0,fe=Ve[$e],Pe=((X||{})[fe]||{})[U]||0,je=((X||{})[g]||{})[U]||0;let Ke=0;for(let k=$e+1;k<Ve.length;k++)Ke+=((O||{})[U]||{})[Ve[k]]||0;const Ue=Pe-Ke+H.totalRecibida,Kt=je-Ue,f=Math.max(5,H.totalRecibida*.05);Kt<-f&&(Me[U]={sku:U,totalConfirmado:H.totalRecibida,fechaRecepcion:H.fechaMaxRecepcion,stockAntes:Pe,stockActual:je,salidasPeriodo:Ke,stockEsperado:Math.round(Ue),diferencia:Math.round(Kt),descripcion:H.lineas[0]?.descripcion||""})})}const un=15,dn=new Set([...Object.keys(C||{}),...Object.keys(L||{})]),me=[];dn.forEach(g=>{const I=(C||{})[g]||{},U=(L||{})[g]||{},H=y[g]||{},ie=V[g]||{promedioDiario:0},re=I.cantidadFisica||0,ce=ie.promedioDiario,$e=x>0?(L[g]?.ingresado||0)/x:0,fe=ae[g]?.price||H.precioAlsea||0,Pe=re*fe,je=(N||{})[g]||I.tipoAlmacenamiento||H.temperatura||"",Ke=H.diasVidaUtil||0;let Ue=null,Kt=null,f="none",k=0,T=0,R=0,q=re,oe=!1;const se=[],We=(I.lotes||[]).filter(ct=>ct.fechaElabor||ct.fechaVenci);if(We.length>0){let ct=1/0,Dn=0,Jt=0;We.forEach(Ye=>{let an=Ye.fechaVenci instanceof Date?Ye.fechaVenci:Ye.fechaVenci?new Date(Ye.fechaVenci):null;const Et=Ye.fechaElabor instanceof Date?Ye.fechaElabor:Ye.fechaElabor?new Date(Ye.fechaElabor):null;if(!an&&Et&&Ke>0&&(an=new Date(Et.getTime()+Ke*864e5)),!an||isNaN(an.getTime()))return;const Rn=Et&&!isNaN(Et.getTime()),gn=Math.ceil((an-p)/864e5),Jn=gn-un,Tn=Rn?Math.ceil((an-Et)/864e5):Ke||0,Sr=Rn?Math.ceil((p-Et)/864e5):0,_r=Tn>0?Sr/Tn*100:100;gn<ct&&(ct=gn),Dn+=_r,Jt++;const Ln={lote:Ye.lote,cantidad:Ye.cantidad,fechaVenci:an,diasHastaVencReal:gn,diasHastaVencEfectivo:Jn,pctVida:Math.round(_r)};if(gn<0)T+=Ye.cantidad*fe,R+=Ye.cantidad,q-=Ye.cantidad,Ln.estado="vencido";else if(Jn<=0){const kr=ce*Math.max(0,gn),kt=Math.max(0,Ye.cantidad-kr);k+=kt*fe,Ln.estado="riesgo_alto"}else{const kr=ce*Jn,kt=Math.max(0,Ye.cantidad-kr);k+=kt*fe,Ln.estado=kt>0?Jn<=30?"riesgo_medio":"riesgo_bajo":"ok"}se.push(Ln)}),Ue=ct===1/0?null:ct,Kt=Jt>0?Dn/Jt:null,oe=R>0,Ue!==null&&(Ue<0?f="merma":Ue<=un?f="alto":Ue<=45?f="medio":Ue<=90&&(f="bajo"))}q=Math.max(0,q);const ke=ce>0?q/ce:q>0?1/0:0;let Te="normal";re>0&&ce===0?Te="nula":re>0&&ke>90&&(Te="baja");const Ge=(U.solicitado||0)>0?(U.despachado||0)/(U.solicitado||1)*100:null,St=Ze[g]||0,Qe=St>0?St/30:0,Wt=x>0?(U.despachado||0)/x:0,Bt=St>0?Math.round((U.despachado||0)/St*100):null,Qt=H.categoriaOracleCloud||H.subfam
29ilia||I.subFamilia||"";let An="ok",bn="";const qe=ce>0?ce:Qe,mn=qe>0&&q>0?Math.round(q/qe):null,Gn=mn!==null&&mn<=30&&q>0,xr=se.filter(ct=>ct.estado!=="vencido");let Pn=!1;if(xr.length>0&&q>0){let ct=0;for(const Dn of xr.sort((Jt,Ye)=>Jt.diasHastaVencReal-Ye.diasHastaVencReal)){ct+=Dn.cantidad;const Jt=Dn.diasHastaVencEfectivo,Ye=qe*Math.max(0,Jt);if(ct>Ye&&Jt>0){Pn=!0;break}}}const Qn=Ue!==null&&Ue>0&&Ue<=30&&q>0&&qe===0;Gn&&(Pn||Qn)?(An="ambos",bn=`Agotamiento en ~${mn}d, vencimiento en ${Ue}d`):Gn?(An="faltante",bn=`Stock no vencido se agota en ~${mn}d (consumo ${Math.round(qe)}/día)`):(Pn||Qn)&&(An="mermaVencimiento",bn=`Vence en ${Ue}d, stock ${Math.round(q)} uds, consumo ${Math.round(qe)}/día`);const Xt=pe[g]||null,on=Ct[g]||null,yr=Xt?Xt.pendiente:0,di=Xt?Xt.fechaEntregaMasCercana:null;let Xn="sin_pedido";Xt&&(Xt.pendiente<=0?Xn="completado":on&&on.cantidad>=Xt.pendiente*.5?Xn="ingresado":Xn="pendiente");const fi=qe>0&&q>0?Math.round((q+yr)/qe):mn,wn=He[g]||null,Zn=wn?wn.totalRecibida:0,Zt=Me[g]||null;me.push({sku:g,descripcion:I.descripcionSKU||H.descripcion||H.descripcionArticuloOracle||wn?.lineas?.[0]?.descripcion||Xt?.lineas?.[0]?.descripcion||"",familia:I.familia||H.familia||"",subFamilia:I.subFamilia||H.subfamilia||"",tipoAlmacenamiento:je,subCatComercial:Qt,marca:H.marca||"",cadena:String(H.cadena||H.marca||H.cliente||"").trim(),cantidadFisica:re,cantidadNoVencida:q,cantidadDisponible:I.cantidadDisponible||0,cantidadBloqueada:I.cantidadBloqueada||0,precio:fe,valorStock:Pe,consumoDiario:Math.round(ce*100)/100,despachoDiario:Math.round(Wt*100)/100,ingresoDiario:Math.round($e*100)/100,diasStockFinanciero:ke===1/0?null:Math.round(ke),solicitado:U.solicitado||0,despachado:U.despachado||0,entregado:U.entregado||0,devuelto:U.devuelto||0,forecastMensual:St,forecastDiario:Math.round(Qe*100)/100,pctCumplimientoForecast:Bt,diasParaVencer:Ue,pctVidaUtil:Kt!==null?Math.round(Kt*10)/10:null,riesgoVencimiento:f,valorEnRiesgo:Math.round(k),esMerma:oe,valorMerma:Math.round(T),cantidadMerma:R,prediccion:An,prediccionDetalle:bn,diasHastaAgotamiento:mn,rotacion:Te,fillRate:Ge!==null?Math.round(Ge*10)/10:null,lotesDetalle:se,pendienteIngreso:yr,ingresoDetectado:on?on.cantidad:0,ingresoEstado:Xn,fechaIngresoEsperada:di,diasStockConIngreso:fi,cantConfirmada:Zn,tieneAnomaliaIngreso:!!Zt,anomaliaIngreso:Zt})});const de=Object.entries(pe).map(([g,I])=>{const U=y[g]||{},H=Ct[g],ie=(C||{})[g]||{},re=me.find(ce=>ce.sku===g);return{key:g,sku:g,descripcion:U.descripcion||I.lineas[0]?.descripcion||"",familia:U.familia||"",totalPedido:I.totalPedido,totalRecibida:I.totalRecibida,pendiente:I.pendiente,ingresoDetectado:H?.cantidad||0,stockActual:ie.cantidadFisica||0,consumoDiario:re?.consumoDiario||0,diasStockSinIngreso:re?.diasHastaAgotamiento||null,diasStockConIngreso:re?.diasStockConIngreso||null,fechaEntrega:I.fechaEntregaMasCercana,estado:I.pendiente<=0?"completado":H&&H.cantidad>=I.pendiente*.5?"ingresado":"pendiente",deteccion:H||null,lineas:I.lineas}}).sort((g,I)=>{const U={pendiente:0,ingresado:1,completado:2};return(U[g.estado]??9)-(U[I.estado]??9)}),Oe=me.reduce((g,I)=>g+I.valorStock,0),rt=me.filter(g=>g.riesgoVencimiento==="alto").reduce((g,I)=>g+I.valorEnRiesgo,0),Lt=me.filter(g=>g.riesgoVencimiento==="medio").reduce((g,I)=>g+I.valorEnRiesgo,0),It=me.filter(g=>g.riesgoVencimiento==="bajo").reduce((g,I)=>g+I.valorEnRiesgo,0),lt=me.reduce((g,I)=>g+I.valorMerma,0),rn=me.reduce((g,I)=>g+I.cantidadMerma,0),yn=me.filter(g=>g.esMerma).sort((g,I)=>I.valorMerma-g.valorMerma),Ot=me.filter(g=>g.riesgoVencimiento==="alto").length,zt=me.filter(g=>g.riesgoVencimiento==="medio").length,B=me.filter(g=>g.riesgoVencimiento==="bajo").length,Y=[{name:"Alto (≤15d)",value:Ot,fill:"#ef5350",valorRiesgo:Math.round(rt)},{name:"Medio (≤45d)",value:zt,fill:"#ffa726",valorRiesgo:Math.round(Lt)},{name:"Bajo (≤90d)",value:B,fill:"#ffee58",valorRiesgo:Math.round(It)}],Q=me.filter(g=>g.riesgoVencimiento==="none"||g.riesgoVencimiento==="bajo"),xe=me.filter(g=>g.riesgoVencimiento==="medio"||g.riesgoVencimiento==="alto"),Se=me.filter(g=>g.riesgoVencimiento==="merma"),st=[{name:"OK",productos:Q.length,valor:Math.round(Q.reduce((g,I)=>g+I.valorStock,0))}
29,{name:"Posible Vencimiento",productos:xe.length,valor:Math.round(xe.reduce((g,I)=>g+I.valorStock,0))},{name:"Merma",productos:Se.length,valor:Math.round(Se.reduce((g,I)=>g+I.valorMerma,0))}],bt=me.filter(g=>(g.prediccion==="faltante"||g.prediccion==="ambos")&&g.cantidadNoVencida>0).map(g=>({...g,diasStockSinIngreso:g.consumoDiario>0?Math.round(g.cantidadNoVencida/g.consumoDiario):null})).sort((g,I)=>(g.diasStockSinIngreso||9999)-(I.diasStockSinIngreso||9999)),pt=me.filter(g=>(g.prediccion==="mermaVencimiento"||g.prediccion==="ambos")&&g.cantidadNoVencida>0).map(g=>({...g,lotesEnRiesgo:g.lotesDetalle.filter(I=>I.estado!=="vencido"&&I.estado!=="ok")})).sort((g,I)=>(g.diasParaVencer||9999)-(I.diasParaVencer||9999)),Yt=me.filter(g=>g.prediccion!=="ok").sort((g,I)=>{const U={ambos:0,faltante:1,mermaVencimiento:2};return(U[g.prediccion]||3)-(U[I.prediccion]||3)}),Ut=me.filter(g=>g.rotacion==="baja"),Je=me.filter(g=>g.rotacion==="nula"),Mt=me.filter(g=>g.diasParaVencer!==null&&g.diasParaVencer>0&&g.diasParaVencer<=30),et={};me.forEach(g=>{const I=y[g.sku]?.familia||g.familia||"Sin Familia";et[I]||(et[I]={familia:I,cantidad:0,valorStock:0,productos:0}),et[I].cantidad+=g.cantidadFisica,et[I].valorStock+=g.cantidadFisica*g.precio,et[I].productos++});const Mn=Object.values(et).filter(g=>g.valorStock>0).sort((g,I)=>I.valorStock-g.valorStock),Sn={};(s||[]).forEach(g=>{const I=g.familia;if(!I)return;const U=Number(g.politiFam||g["Politi Fam"]||0);U!==0&&(!Sn[I]||Sn[I].politiFam<U)&&(Sn[I]={familia:I,politiFam:U,marca:g.marca||"",pais:g.pais||""})});const fn=Object.values(Sn).map(g=>{const{familia:I,politiFam:U}=g,H=me.filter(fe=>(y[fe.sku]?.familia||fe.familia)===I),ie=H.reduce((fe,Pe)=>fe+Pe.cantidadNoVencida,0),re=H.reduce((fe,Pe)=>fe+Pe.consumoDiario,0),ce=re>0?ie/re:null;let $e;return ce===null?$e="sin_movimiento":ce<U*.85?$e="bajo":ce<=U*1.2?$e="cercano":$e="excedido",{familia:I,politiFam:U,marca:g.marca,pais:g.pais,diasStock:ce!==null?Math.round(ce):null,totalQty:Math.round(ie),avgDailyConsumo:Math.round(re*10)/10,estado:$e,productos:H.length,brecha:ce!==null?Math.round(ce-U):null}}).sort((g,I)=>{const U={bajo:0,cercano:1,excedido:2,sin_movimiento:3};return(U[g.estado]??9)-(U[I.estado]??9)}),kn=[...[...me].filter(g=>g.cantidadFisica>0).sort((g,I)=>I.valorStock-g.valorStock).slice(0,16).map(g=>({sku:g.sku,descripcion:g.descripcion,qty:g.cantidadFisica}))].sort((g,I)=>I.qty-g.qty),Yn=Math.ceil(kn.length/2),w=kn.slice(0,Yn),j=kn.slice(Yn),m=Object.keys(X||{}).sort(),S=g=>m.map(I=>{const U={fecha:I,fechaLabel:I.substring(5)};return g.forEach(({sku:H})=>{const ie=(X||{})[I]?.[H];ie!=null&&(U[H]=ie);const[re,ce,$e]=I.split("-").map(Number),fe=Rt(H,new Date(re,ce-1,$e));fe>0&&(U[`fc_${H}`]=Math.round(fe))}),U}),b=S(w),D=S(j),te=me.filter(g=>g.forecastMensual>0&&g.despachado>0).map(g=>({sku:g.sku,descripcion:g.descripcion,despachado:g.despachado,forecastMensual:g.forecastMensual,pctCumplimiento:g.pctCumplimientoForecast,diferencia:g.despachado-g.forecastMensual})).sort((g,I)=>Math.abs(I.diferencia)-Math.abs(g.diferencia)),A=te.filter(g=>g.pctCumplimiento>=70&&g.pctCumplimiento<=130).slice(0,15),K=te.filter(g=>g.pctCumplimiento<70||g.pctCumplimiento>130).slice(0,15),ge=me.reduce((g,I)=>g+I.solicitado,0),ve=me.reduce((g,I)=>g+I.despachado,0),Ie=ge>0?ve/ge*100:0,Ne={};me.forEach(g=>{const I=g.familia||"Sin Familia";Ne[I]||(Ne[I]={familia:I,valorStock:0,despachoTotal:0,productos:0}),Ne[I].valorStock+=g.valorStock,Ne[I].despachoTotal+=g.consumoDiario*(g.precio||0),Ne[I].productos++});const mt=Object.values(Ne).map(g=>({...g,diasStockFinanciero:g.despachoTotal>0?Math.round(g.valorStock/g.despachoTotal):null})).filter(g=>g.diasStockFinanciero!=null&&g.diasStockFinanciero>0).sort((g,I)=>(I.diasStockFinanciero||0)-(g.diasStockFinanciero||0)),De={};me.forEach(g=>{const I=g.subCatComercial||"Sin categoría";De[I]||(De[I]={categoria:I,productos:0,valorStock:0,despachado:0,valorEnRiesgo:0}),De[I].productos++,De[I].valorStock+=g.valorStock,De[I].despachado+=g.despachado,De[I].valorEnRiesgo+=g.valorEnRiesgo});const _t=Object.values(De).filter(g=>g.valorStock>0||g.despachado>0).sort((g,I)=>I.valorStock-g.valorStock),Ht=me.filter(g=>g.solicitado>0&&g.despachado<g.solicitado).map(g=>({sku:g.sku,descripcion:g.descripcion,solicitado:g.solicitado,despachado:g.despachado,noEnviado:g.solicitado-g.despachado,fillRate:g.fillRate})).sort((g,I)=>I.noEnviado-g.noEnviado),hn=Object.keys(_||{}).sort(),Vt={};Object.keys(F||{}
29).sort().forEach(g=>{const I=F[g];Object.keys(I).forEach(U=>{if(r){const Pe=r.toLowerCase(),je=new Set;if(n.forEach(Ke=>{const Ue=String(Ke.marca||Ke.cadena||Ke.cliente||"").toLowerCase();(Ue.includes(Pe)||Pe.includes(Ue))&&Ke.item&&je.add(String(Ke.item))}),je.size>0&&!je.has(U))return}if(i&&i.length>0&&!i.map(String).includes(U))return;const H=I[U],ie=Object.values(H).reduce((Pe,je)=>Pe+je.solicitado,0),re=Object.values(H).reduce((Pe,je)=>Pe+je.despachado,0);if(re>=ie)return;let ce=null;for(const Pe of hn)if(Pe<=g)ce=Pe;else break;const $e=ce&&(_||{})[ce]?.[U]||0;if($e<=0)return;const fe=Object.entries(H).filter(([,Pe])=>Pe.solicitado>Pe.despachado).map(([Pe,je])=>({local:Pe,solicitado:je.solicitado,despachado:je.despachado,faltante:je.solicitado-je.despachado})).sort((Pe,je)=>je.faltante-Pe.faltante);Vt[U]||(Vt[U]=[]),Vt[U].push({key:`${g}_${U}`,fecha:g,totalPedido:ie,totalEnviado:re,faltante:ie-re,stockDisponible:Math.round($e),locales:fe,cantLocales:fe.length})})});const Gt=Object.keys(Vt).map(g=>{const I=Vt[g].sort((H,ie)=>H.fecha.localeCompare(ie.fecha)),U=y[g]||{};return{key:g,sku:g,descripcion:U.descripcion||(C||{})[g]?.descripcionSKU||"",totalPedido:I.reduce((H,ie)=>H+ie.totalPedido,0),totalEnviado:I.reduce((H,ie)=>H+ie.totalEnviado,0),faltante:I.reduce((H,ie)=>H+ie.faltante,0),cantFechas:I.length,fechas:I}}).sort((g,I)=>I.faltante-g.faltante),pn=e.newestStockDate||null,Fn=me.filter(g=>{const I=(g.consumoDiario||0)*30;return Math.max(0,I-(g.cantidadNoVencida||0)-(g.pendienteIngreso||0))>0}).map(g=>{const I=y[g.sku]||{},U=Math.round((g.consumoDiario||0)*30),H=g.cantidadNoVencida||0,ie=g.pendienteIngreso||0,re=Math.max(0,U-H-ie);return{key:g.sku,codigoProveedor:I.codigoProveedor||"",nombreProveedor:I.proveedorOrigen||I.nombreFantasiaUnificado||"",sku:g.sku,descripcion:g.descripcion||I.descripcion||"",stockExistente:Math.round(H),consumo30Dias:U,pendienteIngreso:Math.round(ie),cantidadNecesaria:Math.round(re),consumoDiario:g.consumoDiario||0,diasStock:g.diasHastaAgotamiento,familia:g.familia||I.familia||""}}).sort((g,I)=>{const U=g.codigoProveedor||g.nombreProveedor||"ZZZ",H=I.codigoProveedor||I.nombreProveedor||"ZZZ";return U!==H?U.localeCompare(H):I.cantidadNecesaria-g.cantidadNecesaria});return{products:me,newestStockDate:pn,kpis:{totalProductos:me.length,totalValorStock:Math.round(Oe),totalValorRiesgoAlto:Math.round(rt),totalValorRiesgoMedio:Math.round(Lt),totalValorRiesgoBajo:Math.round(It),pctRiesgoAlto:Oe>0?Math.round(rt/Oe*1e3)/10:0,pctRiesgoMedio:Oe>0?Math.round(Lt/Oe*1e3)/10:0,pctRiesgoBajo:Oe>0?Math.round(It/Oe*1e3)/10:0,riesgoAltoCount:Ot,riesgoMedioCount:zt,riesgoBajoCount:B,productosBajaRotacion:Ut.length,productosNulaRotacion:Je.length,productosVencimientoCorto:Mt.length,totalSolicitado:Math.round(ge),totalDespachado:Math.round(ve),totalNoEnviado:Math.round(ge-ve),fillRateGlobal:Math.round(Ie*10)/10,fillRateLineas:Math.round(le*10)/10,fillRateUnidades:Math.round(Ae*10)/10,totalOrdenes:G,totalLineas:ee,lineasConFaltante:he,totalUnidadesSolOrd:Z,totalUnidadesFaltOrd:we,totalValorMerma:Math.round(lt),totalCantidadMerma:rn,totalProductosMerma:yn.length,totalProductosPrediccionFaltante:bt.length,totalProductosPrediccionMerma:pt.length,totalStockFamilia:Math.round(Mn.reduce((g,I)=>g+I.valorStock,0)),totalPoliticasBajo:fn.filter(g=>g.estado==="bajo").length,totalPoliticasCercano:fn.filter(g=>g.estado==="cercano").length,totalPoliticasExcedido:fn.filter(g=>g.estado==="excedido").length},productosBajaRotacion:Ut,productosNulaRotacion:Je,productosVencimientoCorto:Mt,productosMerma:yn,riesgoProportionData:Y,statusChartData:st,predictivoData:Yt,posibleFaltante:bt,posibleMermaVenc:pt,familiaData:mt,subCatData:_t,forecastCercanos:A,forecastLejanos:K,forecastComparison:te,noEnviados:Ht,dailyData:M,consumoTrendData:J,totalDays:x,periodDays:h,stockFamiliaData:Mn,stockEvolutionHigh:b,stockEvolutionLow:D,evolutionGroupHigh:w,evolutionGroupLow:j,politicasCumplimiento:fn,faltantesConStock:Gt,ingresoPedidoData:de,ingresoConfirmadoData:Object.entries(He).map(([g,I])=>{const U=y[g]||{},H=(C||{})[g]||{},ie=me.find(re=>re.sku===g);
29return{key:g,sku:g,descripcion:U.descripcion||I.lineas[0]?.descripcion||"",familia:U.familia||"",totalRecibida:I.totalRecibida,totalKg:I.totalKg,stockActual:H.cantidadFisica||0,consumoDiario:ie?.consumoDiario||0,diasStockActual:ie?.diasHastaAgotamiento||null,fechaUltimaRecepcion:I.fechaMaxRecepcion,tieneAnomaliaIngreso:!!Me[g],anomalia:Me[g]||null,lineas:I.lineas}}).sort((g,I)=>(I.tieneAnomaliaIngreso?1:0)-(g.tieneAnomaliaIngreso?1:0)),anomaliasIngresoData:Object.values(Me),aPedirData:Fn}},Wp=e=>{const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()));t.setUTCDate(t.getUTCDate()+4-(t.getUTCDay()||7));const n=new Date(Date.UTC(t.getUTCFullYear(),0,1)),r=Math.ceil(((t-n)/864e5+1)/7);return{year:t.getUTCFullYear(),week:r}},Pl=(e,t)=>{const n=new Date(Date.UTC(e,0,4)),r=n.getUTCDay()||7,i=new Date(n);return i.setUTCDate(n.getUTCDate()-r+1+(t-1)*7),new Date(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate())},qp=(e,t)=>{const n=Pl(e,t),r=new Date(n);return r.setDate(r.getDate()+6),r},Yp=(e,t)=>`CL-${e}-W${String(t).padStart(2,"0")}`,lr=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,Gp="analisisSemanales",ka=(e,t,n,r,i)=>{const a=r&&i?Math.max(1,Math.ceil((i-r)/864e5)+1):7,o={},s={};(n||[]).forEach(F=>{const V=String(F.item||F.ITEM||F.codigoSKU||""),J=F.temperatura||F.Temperatura||"";V&&J&&!o[V]&&(o[V]=J);const z=parseFloat(String(F.precioAlsea||F.precio||F.costoUnitario||F.valorUnitario||F.costo||F.costoUnit||F.precioUnitario||F.precioUnit||F.costoAlsea||F.valorUnidad||F.precioCompra||"0").replace(/[^0-9.]/g,""))||0,G=F.fechaInventario instanceof Date?F.fechaInventario.getTime():0;V&&z>0&&(!s[V]||G>s[V].fecha)&&(s[V]={price:z,fecha:G})});let d=null;e.forEach(F=>{const V=F.fechaStock instanceof Date?F.fechaStock:null;V&&(!d||V>d)&&(d=V)});const u=d?lr(d):null,p={};(u?e.filter(F=>{const V=F.fechaStock instanceof Date?F.fechaStock:null;return V&&lr(V)===u}):e).forEach(F=>{const V=String(F.codigoSKU||F.codigo||"");V&&(p[V]||(p[V]={sku:V,descripcionSKU:F.descripcionSKU||"",familia:F.familia||"",subFamilia:F.subFamilia||"",tipoAlmacenamiento:F.tipoAlmacenamiento||"",estado:F.estado||"",cantidadFisica:0,cantidadDisponible:0,cantidadBloqueada:0,fechaElabor:F.fechaElabor||null,fechaVenci:F.fechaVenci||null,lotes:[]}),p[V].cantidadFisica+=Number(F.cantidadFisica||0),p[V].cantidadDisponible+=Number(F.cantidadDisponible||0),p[V].cantidadBloqueada+=Number(F.cantidadBloqueada||0),(F.fechaVenci||F.fechaElabor)&&p[V].lotes.push({lote:F.loteCliente||"",cantidad:Number(F.cantidadFisica||0),fechaElabor:F.fechaElabor?F.fechaElabor instanceof Date?F.fechaElabor.toISOString():F.fechaElabor:null,fechaVenci:F.fechaVenci?F.fechaVenci instanceof Date?F.fechaVenci.toISOString():F.fechaVenci:null}))});const x={};e.forEach(F=>{const V=String(F.codigoSKU||F.codigo||"");if(!V)return;const J=F.fechaStock instanceof Date?F.fechaStock:null;if(!J)return;const z=lr(J);x[z]||(x[z]={}),x[z][V]=(x[z][V]||0)+Number(F.cantidadFisica||0)});const y={};e.forEach(F=>{const V=String(F.codigoSKU||F.codigo||"");if(!V)return;const J=F.fechaStock instanceof Date?F.fechaStock:null;if(!J)return;const z=lr(J);let G=Number(F.cantidadFisica||0);const ee=F.fechaVenci instanceof Date?F.fechaVenci:null;ee&&Math.ceil((ee-J)/864e5)<=15&&(G=0),y[z]||(y[z]={}),y[z][V]=(y[z][V]||0)+G});const C={},L={};let O=1/0,M=-1/0;t.forEach(F=>{const V=F.fecha instanceof Date?F.fecha.getTime():0;V>0&&(V<O&&(O=V),V>M&&(M=V))});const $=O<1/0?Math.max(1,Math.ceil((M-O)/864e5)+1):1,N={};t.forEach(F=>{const V=String(F.item||"");if(V&&(C[V]||(C[V]={solicitado:0,despachado:0,entregado:0,devuelto:0,ingresado:0}),C[V].solicitado+=Number(F.solicitado||0),C[V].despachado+=Number(F.despachado||0),C[V].entregado+=Number(F.entregado||0),C[V].devuelto+=Number(F.devuelto||0),(F.ingresado||F.recibido)&&(C[V].ingresado+=Number(F.ingresado||F.recibido||0)),F.fecha instanceof Date)){const J=lr(F.fecha);N[J]||(N[J]={fecha:J,despachado:0,solicitado:0,faltante:0});const z=Number(F.solicitado||0),G=Number(F.despachado||0);N[J].despachado+=G,N[J].solicitado+=z,N[J].faltante+=Math.max(0,z-G),L[V]||(L[V]={}),L[V][J]=(L[V][J]||0)+G}});const ae=Object.values(N).sort((F,V)=>F.fecha.localeCompare(V.fecha)),X={};t.forEach(F=>{const V=String(F.ordenERP||F.ordenErp||"");if(!V)return;X[V]||(X[V]={lineas:0,lineasConFaltante:0,totalSolicitado:0,totalFaltante:0}),X[V].lineas++;const J=Number(F.solicitado||0),z=Number(F.despachado||0);X[V].totalSolicitado+=J;const G=Math.max(0,J-z);X[V].totalFaltante+=G,G>0&&X[V].lineasConFaltante++});const _={};return t.forEach(F=>{const V=String(F.item||"");if(!V||!(F.fecha instanceof Date))return;const J=Number(F.solicitado||0);if(J<=0)return;const z=lr(F.fecha),G=String(F.puntoEntrega||F.PuntoEntrega||F.local||F.Local||F.sucursal||F.cuenta||F.cliente||"Sin local"),ee=Number(F.despachado||0);_[z]||(_[z]={}),_[z][V]||(_[z][V]={}),_[z][V][G]||(_[z][V][G]={solicitado:0,despachado:0}),_[z][V][G].solicitado+=J,_[z][V][G].despachado+=ee}),{stockBySku:p,stockByDaySku:x,stockDispByDaySku:y,newestStockDate:u,movBySku:C,dailyExitsBySku:L,dailyData:ae,orderMap:X,movByDateSkuLocal:_,invTempMap:o,lastInvPriceBySku:s,totalDays:$,periodDays:a,movMinDate:O===1/0?null:O,movMaxDate:M===-1/0?null:M}},Qp=e=>e?e.map(t=>({...t,fechaElabor:t.fechaElabor?new Date(t.fechaElabor):null,fechaVenci:t.fechaVenci?new Date(t.fechaVenci):null})):[],oi=e=>{const t=new Date(e);t.setHours(0,0,0,0);const n=t.getDay()||7;return n!==1&&t.setDate(t.getDate()-(n-1)),t},Xp=(e,t)=>{const n=[],r=new Date(t);r.setHours(23,59,59,999);const i=oi(t);i.setHours(0,0,0,0);const a=new Date(i);if(a.setDate(a.getDate()-1),a.setHours(23,59,59,999),e>a)return n;let o=new Date(e);for(o.setHours(0,0,0,0);o<=a;){const s=new Date(o);if(s.setDate(s.getDate()+6),s.setHours(23,59,59,999),s>a)break;if(s>=e&&o<=r){const{year:d,week:u}=Wp(o);n.push({year:d,week:u,monday:new Date(o),sunday:new Date(s)})}o.setDate(o.getDate()+7)}return n},Zp=async e=>{const t=[],n=[],r=e.map(async({year:a,week:o})=>{const s=Yp(a,o),d=await ns(rs(In,Gp,s));return d.exists()?{year:a,week:o,data:d.data(),found:!0}:{year:a,week:o,found:!1}});
29return(await Promise.all(r)).forEach(a=>{a.found?t.push(a):n.push({year:a.year,week:a.week})}),{summaries:t,missing:n}},Jp=e=>{if(e.length===0)return null;if(e.length===1)return e[0];const t={stockBySku:{},stockByDaySku:{},stockDispByDaySku:{},newestStockDate:null,movBySku:{},dailyExitsBySku:{},dailyData:[],orderMap:{},movByDateSkuLocal:{},invTempMap:{},lastInvPriceBySku:{},totalDays:0,periodDays:0,movMinDate:null,movMaxDate:null};e.forEach(r=>{if(r){if(r.newestStockDate&&(!t.newestStockDate||r.newestStockDate>t.newestStockDate)&&(t.newestStockDate=r.newestStockDate,t.stockBySku={...r.stockBySku}),Object.entries(r.stockByDaySku||{}).forEach(([i,a])=>{t.stockByDaySku[i]||(t.stockByDaySku[i]={}),Object.entries(a).forEach(([o,s])=>{t.stockByDaySku[i][o]=(t.stockByDaySku[i][o]||0)+s})}),Object.entries(r.stockDispByDaySku||{}).forEach(([i,a])=>{t.stockDispByDaySku[i]||(t.stockDispByDaySku[i]={}),Object.entries(a).forEach(([o,s])=>{t.stockDispByDaySku[i][o]=(t.stockDispByDaySku[i][o]||0)+s})}),Object.entries(r.movBySku||{}).forEach(([i,a])=>{t.movBySku[i]||(t.movBySku[i]={solicitado:0,despachado:0,entregado:0,devuelto:0,ingresado:0}),t.movBySku[i].solicitado+=a.solicitado||0,t.movBySku[i].despachado+=a.despachado||0,t.movBySku[i].entregado+=a.entregado||0,t.movBySku[i].devuelto+=a.devuelto||0,t.movBySku[i].ingresado+=a.ingresado||0}),Object.entries(r.dailyExitsBySku||{}).forEach(([i,a])=>{t.dailyExitsBySku[i]||(t.dailyExitsBySku[i]={}),Object.entries(a).forEach(([o,s])=>{t.dailyExitsBySku[i][o]=(t.dailyExitsBySku[i][o]||0)+s})}),r.dailyData&&(t.dailyData=t.dailyData.concat(r.dailyData)),Object.entries(r.orderMap||{}).forEach(([i,a])=>{t.orderMap[i]?(t.orderMap[i].lineas+=a.lineas||0,t.orderMap[i].lineasConFaltante+=a.lineasConFaltante||0,t.orderMap[i].totalSolicitado+=a.totalSolicitado||0,t.orderMap[i].totalFaltante+=a.totalFaltante||0):t.orderMap[i]={...a}}),Object.entries(r.movByDateSkuLocal||{}).forEach(([i,a])=>{t.movByDateSkuLocal[i]||(t.movByDateSkuLocal[i]={}),Object.entries(a).forEach(([o,s])=>{t.movByDateSkuLocal[i][o]||(t.movByDateSkuLocal[i][o]={}),Object.entries(s).forEach(([d,u])=>{t.movByDateSkuLocal[i][o][d]||(t.movByDateSkuLocal[i][o][d]={solicitado:0,despachado:0}),t.movByDateSkuLocal[i][o][d].solicitado+=u.solicitado||0,t.movByDateSkuLocal[i][o][d].despachado+=u.despachado||0})})}),Object.entries(r.invTempMap||{}).forEach(([i,a])=>{t.invTempMap[i]=a}),Object.entries(r.lastInvPriceBySku||{}).forEach(([i,a])=>{(!t.lastInvPriceBySku[i]||a.fecha&&a.fecha>(t.lastInvPriceBySku[i].fecha||0))&&(t.lastInvPriceBySku[i]=a)}),t.totalDays+=r.totalDays||0,t.periodDays+=r.periodDays||0,r.movMinDate!=null){const i=typeof r.movMinDate=="number"?r.movMinDate:new Date(r.movMinDate).getTime();(t.movMinDate===null||i<t.movMinDate)&&(t.movMinDate=i)}if(r.movMaxDate!=null){const i=typeof r.movMaxDate=="number"?r.movMaxDate:new Date(r.movMaxDate).getTime();(t.movMaxDate===null||i>t.movMaxDate)&&(t.movMaxDate=i)}}});const n={};return t.dailyData.forEach(r=>{n[r.fecha]||(n[r.fecha]={fecha:r.fecha,despachado:0,solicitado:0,faltante:0}),n[r.fecha].despachado+=r.despachado||0,n[r.fecha].solicitado+=r.solicitado||0,n[r.fecha].faltante+=r.faltante||0}),t.dailyData=Object.values(n).sort((r,i)=>r.fecha.localeCompare(i.fecha)),t.movMinDate!=null&&t.movMaxDate!=null&&(t.totalDays=Math.max(1,Math.ceil((t.movMaxDate-t.movMinDate)/864e5)+1)),t},em=async(e,t,n)=>{const r=oi(e),i=new Date(t);i.setHours(23,59,59,999);const a=oi(t);a.setHours(0,0,0,0);const o=new Date(Math.max(r.getTime(),a.getTime()));o.setHours(0,0,0,0);const s=Xp(r,t);if(s.length===0){n&&n("raw","Sin semanas cerradas en el rango; cargando todo en bruto...");const[C,L,O]=await Promise.all([Ki(r,t),Wi(r,t),qi(r,t)]),M=Math.max(1,Math.ceil((i-r)/864e5)+1);return{aggregated:ka(C,L,O,r,t),usedSummaries:0,rawDays:M,totalWeeks:0,missingWeeks:0,alignedDesde:r}}n&&n("check",`${s.length} semana(s) cerrada(s) desde resúmenes + semana en curso en bruto`);const{summaries:d,missing:u}=await Zp(s);console.log(`📊 Weekly summaries: ${d.length} found, ${u.length} missing`);const p=[];u.forEach(C=>{const L=Pl(C.year,C.week);L.setHours(0,0,0,0);const O=qp(C.year,C.week);O.setHours(23,59,59,999),p.push({desde:L,hasta:O})}),o<=i&&p.push({desde:o,hasta:i});const h=p.reduce((C,L)=>{const O=new Date(L.desde);O.setHours(0,0,0,0);const M=new Date(L.hasta);return M.setHours(23,59,59,999),C+Math.max(1,Math.ceil((M-O)/864e5)+1)},0),x=[];
29if(d.forEach(C=>{const L=C.data,O={};Object.entries(L.stockBySku||{}).forEach(([M,$])=>{O[M]={...$,lotes:Qp($.lotes)}}),x.push({...L,stockBySku:O})}),p.length>0){const C=new Date(Math.min(...p.map(V=>V.desde.getTime()))),L=new Date(Math.max(...p.map(V=>V.hasta.getTime())));L.setHours(23,59,59,999);const O=u.length>0?`Bruto: semana en curso + ${u.length} semana(s) sin resumen (~${h} días)...`:`Bruto: solo semana en curso (~${h} días)...`;n&&n("raw",O);const[M,$,N]=await Promise.all([Ki(C,L),Wi(C,L),qi(C,L)]),ae=V=>V?p.some(J=>V>=J.desde&&V<=J.hasta):!1,X=M.filter(V=>ae(V.fechaStock instanceof Date?V.fechaStock:null)),_=$.filter(V=>ae(V.fecha instanceof Date?V.fecha:null)),F=N.filter(V=>ae(V.fechaInventario instanceof Date?V.fechaInventario:null));x.push(ka(X,_,F,C,L))}return n&&n("merge",`Combinando ${d.length} resumen(es) + datos en bruto...`),{aggregated:Jp(x),usedSummaries:d.length,rawDays:h,totalWeeks:s.length,missingWeeks:u.length,alignedDesde:r}},{Content:tm}=Ca,{Title:ba,Text:P}=ja,c={bg:"#0f1923",card:"#1a2332",cardHover:"#1e2a3a",border:"#2a3a4a",text:"#e8edf2",textSec:"#8899aa",accent:"#4fc3f7",green:"#66bb6a",red:"#ef5350",orange:"#ffa726",yellow:"#ffee58",purple:"#ab47bc",blue:"#42a5f5",pink:"#ec407a"},ln=["#4fc3f7","#66bb6a","#ffa726","#ef5350","#ab47bc","#ec407a","#42a5f5","#ffee58"],ot=e=>e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e3?`$${(e/1e3).toFixed(0)}K`:`$${e}`,ne=e=>e!=null?Number(e).toLocaleString("es-CL"):"-",Qr=[{id:"kpis",title:"Indicadores Clave",icon:"📊"},{id:"statusChart",title:"Estado de Productos",icon:"🎯"},{id:"riesgo",title:"Riesgo de Vencimiento",icon:"⚠️"},{id:"consumoTrend",title:"Consumo Promedio 60 Días",icon:"📈"},{id:"mermas",title:"Mermas (Vencidos)",icon:"🗑️"},{id:"faltante",title:"Posible Faltante",icon:"�"},{id:"mermaVenc",title:"Posible Merma por Vencimiento",icon:"⏳"},{id:"rotacion",title:"Análisis de Rotación",icon:"🔄"},{id:"vencimiento",title:"Productos por Vencer",icon:"⏰"},{id:"fillrate",title:"Fill Rate",icon:"📦"},{id:"fillrateLineas",title:"Fill Rate por Línea",icon:"📋"},{id:"dailyChart",title:"Despacho y Faltante Diario",icon:"📉"},{id:"stockEvolution",title:"Evolución de Stock por Artículo",icon:"📈"},{id:"forecastCercanos",title:"Forecast - Cercanos al Objetivo",icon:"✅"},{id:"forecastLejanos",title:"Forecast - Lejos del Objetivo",icon:"⚠️"},{id:"familia",title:"Días Stock por Familia",icon:"🏗️"},{id:"stockFamilia",title:"Stock Valorizado por Familia",icon:"💰"},{id:"politicasCumpl",title:"Cumplimiento de Políticas",icon:"📋"},{id:"subCat",title:"Detalle por Sub-Categoría",icon:"🏷️"},{id:"valorizado",title:"Stock Valorizado (Top SKU)",icon:"💎"},{id:"noEnviados",title:"Detalle No Enviados",icon:"🚫"},{id:"faltantesStock",title:"Faltantes con Stock Disponible",icon:"🔍"},{id:"ingresoPedido",title:"Ingreso Pedido",icon:"📥"},{id:"ingresoConfirmado",title:"Ingreso Confirmado",icon:"✅"},{id:"anomaliasIngreso",title:"Anomalías de Ingreso",icon:"⚠️"},{id:"aPedir",title:"A Pedir (30 días)",icon:"🛒"}],nm={"30d":30,"60d":60,"90d":90},sr={"30d":"Últimos 30 días","60d":"Últimos 60 días","90d":"Últimos 90 días",year:"Este año"},hm=()=>{const e=Ll(),[t,n]=Le.useState(null),[r,i]=Le.useState(null),[a,o]=Le.useState([]),[s,d]=Le.useState([]),[u,p]=Le.useState(null),[h,x]=Le.useState(!1),[y,C]=Le.useState(""),[L,O]=Le.useState([]),[M,$]=Le.useState(null),[N,ae]=Le.useState(null),[X,_]=Le.useState(null),[F,V]=Le.useState(!0),[J,z]=Le.useState(!1),[G,ee]=Le.useState(Qr.map(w=>w.id)),[he,le]=Le.useState(new Set),[Z,we]=Le.useState(new Set),[Ae,ze]=Le.useState(!1),[xt,E]=Le.useState(!1),[nt,ht]=Le.useState(!1),v=Le.useRef(null),Ze={background:"#ffffff",color:"#1a1a1a",borderColor:"#3d4f63",fontWeight:600},Rt=async()=>{const w=v.current;if(!w||w.childElementCount===0){dt.warning("No hay tarjetas visibles para el informe. Active al menos una en «Tarjetas visibles».");return}E(!0);try{const j=(await wo()).default,m=await j(w,{scale:2,useCORS:!0,allowTaint:!0,backgroundColor:c.bg,logging:!1}),S=m.toDataURL("image/png"),b=(await Zl()).default,D=new b({orientation:"p",unit:"mm",format:"a4"}),te=D.internal.pageSize.getWidth(),A=D.internal.pageSize.getHeight(),K=te,ge=m.height*K/m.width;let ve=ge,Ie=0;for(D.addImage(S,"PNG",0,Ie,K,ge),ve-=A;ve>0;)Ie=ve-ge,D.addPage(),D.addImage(S,"PNG",0,Ie,K,ge),ve-=A;const Ne=`Informe_Abastecimiento_${Cn().format("YYYY-MM-DD_HHmm")}.pdf`;D.save(Ne),dt.success("Informe PDF descargado.")}catch(j){console.error(j),dt.error("No se pudo generar el PDF. Pruebe de nuevo o reduzca tarjetas visibles.")}finally{E(!1)}}
29,pe=async()=>{const w=v.current;if(!w||w.childElementCount===0){dt.warning("No hay tarjetas visibles para la presentación. Active al menos una en «Tarjetas visibles».");return}const j=G.filter(Ie=>!he.has(Ie)),m=Array.from(w.children);if(m.length!==j.length){dt.warning("Vuelva a cargar el análisis e inténtelo de nuevo.");return}ht(!0);const S=(await wo()).default,b=(await Jl()).default,D=new b;D.layout="LAYOUT_16x9",D.author="Hub Log",D.title="Análisis Abastecimiento";const te=10,A=5.625,K=.35,ge=te-2*K,ve=A-2*K;try{const Ie=D.addSlide();Ie.background={color:"1a2332"};const Ne=t&&X&&sr[X]?`${sr[X]} · ${t[0].format("DD/MM/YYYY")} — ${t[1].format("DD/MM/YYYY")}`:"Análisis de abastecimiento";Ie.addText("Análisis de Abastecimiento",{x:.5,y:1.9,w:9,h:1,fontSize:28,bold:!0,color:"E8EDF2",align:"center",fontFace:"Arial"}),Ie.addText(Ne,{x:.5,y:3.1,w:9,h:.6,fontSize:14,color:"8899AA",align:"center",fontFace:"Arial"}),Ie.addText(Cn().format("DD/MM/YYYY HH:mm"),{x:.5,y:4.5,w:9,h:.4,fontSize:11,color:"8899AA",align:"center",fontFace:"Arial"});for(let De=0;De<m.length;De++){dt.loading({content:`Generando PPT: capturando tarjeta ${De+1} de ${m.length}…`,key:"ppt-export",duration:0});const _t=m[De],Ht=await S(_t,{scale:2,useCORS:!0,allowTaint:!0,backgroundColor:c.bg,logging:!1}),hn=Ht.toDataURL("image/png"),Vt=Ht.width,Gt=Ht.height,pn=Vt/Gt,Fn=ge/ve;let g,I;pn>Fn?(g=ge,I=ge/pn):(I=ve,g=ve*pn);const U=K+(ge-g)/2,H=K+(ve-I)/2,ie=D.addSlide();ie.background={color:c.bg.replace("#","")};const re=j[De],ce=Qr.find(fe=>fe.id===re),$e=ce?`${ce.icon} ${ce.title}`:`Tarjeta ${De+1}`;ie.addNotes($e),ie.addImage({data:hn,x:U,y:H,w:g,h:I,altText:$e}),await new Promise(fe=>setTimeout(fe,0))}dt.destroy("ppt-export");const mt=`Informe_Abastecimiento_${Cn().format("YYYY-MM-DD_HHmm")}.pptx`;await D.writeFile({fileName:mt}),dt.success("Presentación PPT descargada.")}catch(Ie){console.error(Ie),dt.destroy("ppt-export"),dt.error("No se pudo generar el PPT. Pruebe con menos tarjetas visibles o de nuevo más tarde.")}finally{ht(!1)}},Ct=Le.useCallback(async w=>{const j=w||t;if(!j||!j[0]||!j[1]){dt.warning("Seleccione el período (30, 60, 90 días o Este año) y espere a que termine de cargar la fecha de stock.");return}x(!0),p(null);try{const m=j[0]instanceof Date?j[0]:j[0].toDate(),S=j[1]instanceof Date?j[1]:j[1].toDate();if(Math.ceil((S-m)/864e5)+1>14){let te,A,K,ge,ve,Ie;if(M&&M._optimized)C("Procesando con nuevos filtros..."),{fc:te,maestro:A,pols:K,aggData:ge,ip:ve,ic:Ie}=M;else{C("Cargando datos en paralelo (agregados, maestro, forecast, políticas, ingresos)...");const[mt,De,_t,Ht,hn,Vt]=await Promise.all([Ai(),em(m,S,Gt=>C(Gt)),ga(),xa(),ya(),Sa()]);A=mt,ge=De.aggregated||De,te=_t,K=Ht,ve=hn,Ie=Vt,s.length===0&&d(A),O(K),$({fc:te,maestro:A,pols:K,aggData:ge,ip:ve,ic:Ie,_optimized:!0})}C("Procesando análisis desde datos pre-agregados..."),await new Promise(mt=>setTimeout(mt,50));const Ne=Kp(ge,te,A,r,a,m,S,K,ve,Ie);p(Ne),dt.success(`Análisis completado (optimizado): ${Ne.kpis.totalProductos} productos analizados`)}else{let te,A,K,ge,ve,Ie,Ne,mt;if(M&&!M._optimized)C("Procesando con nuevos filtros..."),{stock:te,mov:A,inv:K,fc:ge,maestro:ve,pols:Ie,ip:Ne,ic:mt}=M;else{const _t=new Date(m),Ht=X==="year"?"este año":X?X.replace("d"," días"):"seleccionado";C(`Cargando en paralelo: stock/mov/inv (${Ht}), maestro, forecast, políticas, ingresos...`);const[hn,Vt,Gt,pn,Fn,g,I,U]=await Promise.all([Ai(),Ki(_t,S),Wi(_t,S),qi(_t,S),ga(),xa(),ya(),Sa()]);ve=hn,te=Vt,A=Gt,K=pn,ge=Fn,Ie=g,Ne=I,mt=U,s.length===0&&d(ve),O(Ie),$({stock:te,mov:A,inv:K,fc:ge,maestro:ve,pols:Ie,ip:Ne,ic:mt,_optimized:!1})}C("Procesando análisis..."),await new Promise(_t=>setTimeout(_t,50));const De=Hp(te,A,K,ge,ve,r,a,m,S,Ie,Ne,mt);p(De),dt.success(`Análisis completado: ${De.kpis.totalProductos} productos analizados`)}}catch(m){console.error("Error en análisis:",m),dt.error("Error: "+m.message)}finally{x(!1),C("")}},[t,r,a,s.length,M,X]);Le.useEffect(()=>{let w=!1;z(!1),V(!0);const j=Ai();return(async()=>{try{const m=await Vp();if(w)return;if(!m){dt.warning("No se encontraron registros de stock"),ae(null),_(null),n(null);try{const S=await j;w||d(S)}catch{}w||z(!0);return}ae(m)}catch(m){console.error("Error detectando fecha de stock:",m),w||dt.error("No se pudieron cargar los filtros. Intente de nuevo.");try{const S=await j;w||d(S)}catch{}w||z(!0);return}finally{w||V(!1)}try{const m=await j;w||d(m)}catch(m){console.error("Error cargando maestro de productos:",m),w||dt.warning("Catálogo de productos no dis
29ponible; podrá analizar sin filtro por SKU.")}finally{w||z(!0)}})(),()=>{w=!0}},[]);const Ve=w=>{if(!N)return;const j=nm[w];if(w!=="year"&&j==null)return;_(w),$(null),p(null);const m=new Date(N);m.setDate(m.getDate()-1);let S;w==="year"?(S=new Date(m.getFullYear(),0,1),S.setHours(0,0,0,0)):(S=new Date(m),S.setDate(S.getDate()-j),S.setHours(0,0,0,0),S=oi(S)),n([Cn(S),Cn(m)])},He=w=>{le(j=>{const m=new Set(j);return m.has(w)?m.delete(w):m.add(w),m})},yt=w=>{we(j=>{const m=new Set(j);return m.has(w)?m.delete(w):m.add(w),m})},Tt=(w,j)=>{ee(m=>{const S=[...m],b=S.indexOf(w),D=b+j;return D<0||D>=S.length||([S[b],S[D]]=[S[D],S[b]]),S})},Me=async(w,j)=>{const m=await Do(),S=m.utils.json_to_sheet(w),b=m.utils.book_new();m.utils.book_append_sheet(b,S,"Datos"),m.writeFile(b,`${j}_${Cn().format("YYYYMMDD_HHmm")}.xlsx`),dt.success("Exportado correctamente")},un=w=>{const j=[];for(const m of w){const S=m.cadena||m.marca||"",b=(m.lotesDetalle||[]).filter(D=>D.estado==="vencido");if(!b.length){j.push({Cadena:S,SKU:m.sku,Descripcion:m.descripcion,Lote:"",Vencimiento:"",CantidadMerma:m.cantidadMerma,ValorMerma:m.valorMerma,DiasVencido:Math.abs(m.diasParaVencer??0),Familia:m.familia,Precio:m.precio});continue}for(const D of b){const te=D.fechaVenci instanceof Date?D.fechaVenci:D.fechaVenci?new Date(D.fechaVenci):null,A=te&&!isNaN(te.getTime());j.push({Cadena:S,SKU:m.sku,Descripcion:m.descripcion,Lote:D.lote??"",Vencimiento:A?Cn(te).format("DD/MM/YYYY"):"",CantidadLote:D.cantidad,ValorLote:Math.round((D.cantidad||0)*(m.precio||0)),DiasVencido:Math.abs(D.diasHastaVencReal??0),Familia:m.familia,PrecioUnitario:m.precio})}}return j},dn=Le.useMemo(()=>{let w=s;if(r){const m=r.toLowerCase();w=s.filter(S=>{const b=String(S.marca||S.cadena||S.cliente||"").toLowerCase();return b.includes(m)||m.includes(b)})}const j=new Set;return w.map(m=>({value:String(m.item),label:`${m.item} - ${m.descripcion}`})).filter(m=>!m.value||j.has(m.value)?!1:(j.add(m.value),!0)).sort((m,S)=>m.label.localeCompare(S.label))},[s,r]),me=Le.useMemo(()=>{const w=[];return t&&sr[X]?w.push({label:`${sr[X]} (${t[0].format("DD/MM/YY")}–${t[1].format("DD/MM/YY")})`,key:"date"}):t&&w.push({label:`${t[0].format("DD/MM/YY")} - ${t[1].format("DD/MM/YY")}`,key:"date"}),r&&w.push({label:`Cadena: ${r}`,key:"cadena",onClose:()=>i(null)}),a.forEach(j=>{const m=s.find(S=>String(S.item)===j);w.push({label:`${j}${m?" - "+m.descripcion.substring(0,25):""}`,key:`prod_${j}`,onClose:()=>o(S=>S.filter(b=>b!==j))})}),w},[t,r,a,s,X]),de=({id:w,children:j,extra:m})=>{const S=Qr.find(D=>D.id===w);if(!S||he.has(w))return null;const b=Z.has(w);return l.jsx(So,{size:"small",style:{background:c.card,border:`1px solid ${c.border}`,borderRadius:12,marginBottom:16},headStyle:{background:c.card,borderBottom:`1px solid ${c.border}`,color:c.text},bodyStyle:{background:c.card,padding:b?0:16,display:b?"none":"block"},title:l.jsxs("span",{style:{color:c.text,fontSize:14},children:[S.icon," ",S.title]}),extra:l.jsxs(Ft,{size:4,children:[m,l.jsx(Fe,{type:"text",size:"small",icon:l.jsx(Yl,{}),style:{color:c.textSec},onClick:()=>Tt(w,-1)}),l.jsx(Fe,{type:"text",size:"small",icon:l.jsx(Gl,{}),style:{color:c.textSec},onClick:()=>Tt(w,1)}),l.jsx(Fe,{type:"text",size:"small",icon:b?l.jsx(Ql,{}):l.jsx(Xl,{}),style:{color:c.textSec},onClick:()=>yt(w)})]}),children:j})},Oe=w=>{if(!u)return null;const{kpis:j,products:m}=u;switch(w){case"kpis":return rt();case"statusChart":return rn();case"riesgo":return Lt();case"consumoTrend":return It();case"mermas":return yn();case"faltante":return bt();case"mermaVenc":return lt();case"rotacion":return Ot();case"vencimiento":return zt();case"fillrate":return B();case"fillrateLineas":return pt();case"dailyChart":return Yt();case"stockEvolution":return Je();case"forecastCercanos":return Q();case"forecastLejanos":return xe();case"familia":return Se();case"stockFamilia":return Mt();case"politicasCumpl":return et();case"subCat":return Ut();case"valorizado":return st();case"noEnviados":return Mn();case"faltantesStock":return Sn();case"ingresoPedido":return fn();case"ingresoConfirmado":return gr();case"anomaliasIngreso":return kn();case"aPedir":return Yn();default:return null}},rt=()=>{const{kpis:w}=u,j=[{title:"Productos",value:ne(w.totalProductos),color:c.accent,icon:"📦"},{title:"Valor Stock",value:ot(w.totalValorStock),color:c.green,icon:"💰"},{title:"Fill Rate",value:`${w.fillRateGlobal}%`,color:w.fillRateGlobal>=95?c.green:w.fillRateGlobal>=85?c.orange:c.red,icon:"📊"},{title:"Baja Rotación",value:ne(w.productosBajaRotacion),color:c.orange,icon:"🔄"},{title:"Nula Rotación",value:ne(w.productosNulaRotacion),color:c.red,icon:"⛔"},{title:"Venc. Corto",value:ne(w.productosVencimientoCorto),color:c.red,icon:"⏰"}];return l.jsx(de,{id:"kpis",children:l.jsx(ft,{gutter:[12,12],children:j.map((m,S)=>l.jsx(Re,{xs:12,sm:8,md:4,children:l.jsxs("div",{style:{background:c.bg,borderRadius:10,padding:"16px 12px",textAlign:"center",border:`1px solid ${c.border}`},children:[l.jsx("div",{style:{fontSize:24,marginBottom:4},children:m.icon}),l.jsx("div",{style:{color:m.color,fontSize:22,fontWeight:700,lineHeight:1.2},children:m.value}),l.jsx("div",{style:{color:c.textSec,fontSize:11,marginTop:4},children:m.title})]})},S))})})},Lt=()=>{const{kpis:w,riesgoProportionData:j}=u,m=(j||[]).filter(S=>S.value>0);return l.jsx(de,{id:"riesgo",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(u.products.filter(S=>S.riesgoVencimiento!=="none").map(S=>({SKU:S.sku,Descripcion:S.descripcion,Cantidad:S.cantidadFisica,DiasVencer:S.diasParaVencer,Pct
29VidaUtil:S.pctVidaUtil,Riesgo:S.riesgoVencimiento,ValorEnRiesgo:S.valorEnRiesgo})),"Riesgo_Vencimiento")}),children:l.jsxs(ft,{gutter:16,children:[l.jsxs(Re,{xs:24,md:10,children:[l.jsx("div",{style:{height:240},children:m.length>0?l.jsx(en,{width:"100%",height:"100%",children:l.jsxs($r,{children:[l.jsx(Ur,{data:m,dataKey:"value",cx:"50%",cy:"50%",innerRadius:55,outerRadius:90,paddingAngle:3,label:({name:S,value:b,percent:D})=>`${S}: ${b} (${(D*100).toFixed(0)}%)`,children:m.map((S,b)=>l.jsx(_n,{fill:S.fill},b))}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},formatter:(S,b,D)=>[`${S} productos - ${ot(D.payload.valorRiesgo)}`,b]})]})}):l.jsxs("div",{style:{textAlign:"center",paddingTop:60},children:[l.jsx("div",{style:{fontSize:40,marginBottom:8},children:"✅"}),l.jsx(P,{style:{color:c.green,fontSize:14},children:"Sin productos en riesgo"})]})}),l.jsx("div",{style:{textAlign:"center",color:c.textSec,fontSize:11,marginTop:-4},children:"Proporción de productos por nivel de riesgo"})]}),l.jsx(Re,{xs:24,md:14,children:l.jsx(ft,{gutter:[12,12],children:[{label:"Riesgo Alto (≤15 días)",value:ot(w.totalValorRiesgoAlto),count:w.riesgoAltoCount,pct:w.pctRiesgoAlto,color:c.red},{label:"Riesgo Medio (≤45 días)",value:ot(w.totalValorRiesgoMedio),count:w.riesgoMedioCount,pct:w.pctRiesgoMedio,color:c.orange},{label:"Riesgo Bajo (≤90 días)",value:ot(w.totalValorRiesgoBajo),count:w.riesgoBajoCount,pct:w.pctRiesgoBajo,color:c.yellow}].map((S,b)=>l.jsx(Re,{xs:24,children:l.jsxs("div",{style:{background:c.bg,borderRadius:8,padding:"10px 14px",border:`1px solid ${c.border}`},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:4},children:[l.jsx(P,{style:{color:c.text,fontSize:13},children:S.label}),l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:S.color===c.red?"red":S.color===c.orange?"orange":"gold",style:{fontSize:10},children:[S.count," prod."]}),l.jsxs(P,{strong:!0,style:{color:S.color,fontSize:13},children:[S.value," (",S.pct,"%)"]})]})]}),l.jsx(nr,{percent:Math.min(S.pct,100),strokeColor:S.color,trailColor:c.border,showInfo:!1,size:"small"})]})},b))})})]})})},It=()=>{const{consumoTrendData:w,totalDays:j}=u;if(!w||!w.length)return l.jsx(de,{id:"consumoTrend",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Sin datos de consumo"})})});const m=w.reduce((b,D)=>b+D.consumo,0)/w.length,S=w.map((b,D)=>({...b,tendencia:Math.round(m)}));return l.jsx(de,{id:"consumoTrend",extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:"blue",style:{fontSize:10},children:[j," días analizados"]}),l.jsxs(Ce,{color:"green",style:{fontSize:10},children:["Promedio: ",ne(Math.round(m))," uds/día"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w,"Consumo_Promedio_60d")})]}),children:l.jsx("div",{style:{height:320},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs(pi,{data:S,margin:{top:10,right:10,left:0,bottom:10},children:[l.jsx(Vn,{strokeDasharray:"3 3",stroke:c.border}),l.jsx(Bn,{dataKey:"fechaLabel",tick:{fill:c.textSec,fontSize:10}}),l.jsx(Nn,{tick:{fill:c.textSec,fontSize:10}}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},labelFormatter:(b,D)=>D?.[0]?.payload?.fecha||b,formatter:(b,D)=>[ne(b),D]}),l.jsx(wr,{wrapperStyle:{fontSize:11}}),l.jsx(ir,{dataKey:"consumo",name:"Consumo Diario",fill:c.accent,radius:[4,4,0,0],opacity:.8}),l.jsx(Dr,{type:"monotone",dataKey:"tendencia",name:"Promedio",stroke:c.red,strokeWidth:2,strokeDasharray:"6 3",dot:!1})]})})})})},lt=()=>{const{posibleMermaVenc:w}=u;return!w||!w.length?l.jsx(de,{id:"mermaVenc",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"No se detectaron productos con riesgo de merma por vencimiento"})})}):l.jsxs(de,{id:"mermaVenc",extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:"volcano",style:{fontSize:10},children:[w.length," productos en riesgo"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w.map(j=>({SKU:j.sku,Descripcion:j.descripcion,Familia:j.familia,StockNoVencido:j.cantidadNoVencida,ConsumoDiario:j.consumoDiario,DiasParaVencer:j.diasParaVencer,LotesEnRiesgo:(j.lotesEnRiesgo||[]).length})),"Posible_Merma_Vencimiento")})]}),children:[l.jsx(rr,{type:"error",showIcon:!0,style:{marginBottom:12,background:`${c.bg}`,border:`1px solid ${c.red}
2933`,borderRadius:8},message:l.jsx("span",{style:{color:c.red,fontSize:12,fontWeight:600},children:"Stock no vencido con riesgo de vencer antes de ser consumido"}),description:l.jsx("span",{style:{color:c.textSec,fontSize:11},children:"Se agrupan los lotes por producto y vencimiento. El margen de 15 días está aplicado. Si el consumo diario no alcanza para despachar el stock antes del vencimiento efectivo, aparece aquí."})}),l.jsx(it,{dataSource:w,rowKey:"sku",size:"small",pagination:{pageSize:10,size:"small"},columns:[{title:"SKU",dataIndex:"sku",width:110,sorter:(j,m)=>j.sku.localeCompare(m.sku),render:j=>l.jsx(P,{style:{color:c.text,fontSize:11,whiteSpace:"nowrap"},children:j})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,sorter:(j,m)=>(j.descripcion||"").localeCompare(m.descripcion||""),render:j=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:j})},{title:"Stock No Venc.",dataIndex:"cantidadNoVencida",width:90,align:"right",sorter:(j,m)=>j.cantidadNoVencida-m.cantidadNoVencida,render:j=>l.jsx(P,{style:{color:c.text,fontWeight:600,fontSize:11},children:ne(j)})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Consumo/día"}),dataIndex:"consumoDiario",width:85,align:"right",sorter:(j,m)=>(j.consumoDiario||0)-(m.consumoDiario||0),render:j=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(Math.round(j||0))})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Días Vencer"}),dataIndex:"diasParaVencer",width:80,align:"right",sorter:(j,m)=>(j.diasParaVencer||9999)-(m.diasParaVencer||9999),render:j=>j!=null?l.jsxs(P,{style:{color:j<=15?c.red:j<=30?c.orange:c.yellow,fontWeight:700,fontSize:11},children:[j,"d"]}):"-"},{title:"Días Efect.",width:80,align:"right",sorter:(j,m)=>Math.max(0,(j.diasParaVencer||0)-15)-Math.max(0,(m.diasParaVencer||0)-15),render:(j,m)=>{const S=Math.max(0,(m.diasParaVencer||0)-15);return l.jsxs(P,{style:{color:S<=0?c.red:S<=15?c.orange:c.yellow,fontWeight:700,fontSize:11},children:[S,"d"]})}},{title:"Lotes Riesgo",width:80,align:"right",sorter:(j,m)=>(j.lotesEnRiesgo||[]).length-(m.lotesEnRiesgo||[]).length,render:(j,m)=>l.jsx(Ce,{color:"volcano",style:{fontSize:10},children:(m.lotesEnRiesgo||[]).length})},{title:"Detalle",dataIndex:"prediccionDetalle",ellipsis:!0,sorter:(j,m)=>(j.prediccionDetalle||"").localeCompare(m.prediccionDetalle||""),render:j=>l.jsx(ql,{title:j,children:l.jsx(P,{style:{color:c.textSec,fontSize:10},children:j})})}]})]})},rn=()=>{const{statusChartData:w,kpis:j}=u,m=["#66bb6a","#ffa726","#ef5350"],S=w.reduce((b,D)=>b+D.productos,0);return l.jsx(de,{id:"statusChart",children:l.jsxs(ft,{gutter:16,children:[l.jsx(Re,{xs:24,md:10,children:l.jsx("div",{style:{height:280},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs($r,{children:[l.jsx(Ur,{data:w,dataKey:"productos",cx:"50%",cy:"50%",innerRadius:65,outerRadius:100,paddingAngle:3,label:({name:b,percent:D})=>`${b} ${(D*100).toFixed(0)}%`,children:w.map((b,D)=>l.jsx(_n,{fill:m[D]},D))}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},formatter:(b,D,te)=>[ne(b)+" productos",te.payload.name]})]})})})}),l.jsx(Re,{xs:24,md:14,children:l.jsx(ft,{gutter:[12,12],children:w.map((b,D)=>l.jsx(Re,{xs:24,children:l.jsxs("div",{style:{background:c.bg,borderRadius:12,padding:16,border:`1px solid ${c.border}`,borderLeft:`4px solid ${m[D]}`},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6},children:[l.jsx(P,{style:{color:c.text,fontSize:15,fontWeight:700},children:b.name}),l.jsxs(Ce,{color:m[D]==="#66bb6a"?"green":m[D]==="#ffa726"?"orange":"red",style:{fontSize:12,fontWeight:600,padding:"2px 10px"},children:[b.productos," productos"]})]}),l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs("div",{children:[l.jsx("div",{style:{color:m[D],fontSize:22,fontWeight:700},children:ot(b.valor)}),l.jsx("div",{style:{color:c.textSec,fontSize:11},children:D===0?"Valor stock en buen estado":D===1?"Valor stock en riesgo de vencer":"Valor merma (ya vencido)"})]}),l.jsxs("div",{style:{textAlign:"right"},children:[l.jsxs("div",{style:{color:c.text,fontSize:18,fontWeight:600},children:[S>0?Math.round(b.productos/S*100):0,"%"]}),l.jsx("div",{style:{color:c.textSec,fontSize:10},children:"del total"})]})]}),l.jsx(nr,{percent:S>0?Math.round(b.productos/S*100):0,strokeColor:m[D],trailColor:c.border,showInfo:!1,size:"small",style:{marginTop:8}})]})},D))})})]})})},yn=()=>{const{productosMerma:w,kpis:j}=u;return!w||!w.length?l.jsx(de,{id:"mermas",children:l.jsxs("div",{style:{textAlign:"center",padding:32},children:[l.jsx("div",{style:{fontSize:48,marginBottom:12},children:"✅"}),l.jsx(P,{style:{color:c.green,fontSize:16,fontWeight:600},children:"No se detectaron mermas"}),l.jsx("div",{style:{color:c.textSec,fontSize:12,marginTop:4},children:"Ningún producto tiene fecha de vencimiento pasada"})]})}):l.jsx(de,{id:"mermas",extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:"red",style:{fontSize:11,fontWeight:600,padding:"2px 10px"},children:[j.totalProductosMerma," productos | ",ne(j.totalCantidadMerma)," uds | ",ot(j.totalValorMerma)]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(un(w),"Mermas_Vencidos")})]}),children:l.jsxs(ft,{gutter:16,children:[l.jsx(Re,{xs:24,md:6,lg:5,children:l.jsxs("div",{style:{background:`linear-gradient(135deg, ${c.bg}, #2a1a1a)`,borderRadius:10,padding:"12px 10px",border:`1px solid ${c.red}
2933`,textAlign:"center"},children:[l.jsx("div",{style:{fontSize:26,marginBottom:4},children:"🗑️"}),l.jsx("div",{style:{color:c.red,fontSize:20,fontWeight:700,lineHeight:1.2},children:ot(j.totalValorMerma)}),l.jsx("div",{style:{color:c.textSec,fontSize:10,marginTop:2},children:"Valor Total Merma"}),l.jsxs("div",{style:{marginTop:8,display:"flex",justifyContent:"center",gap:12},children:[l.jsxs("div",{children:[l.jsx("div",{style:{color:c.red,fontSize:15,fontWeight:700},children:j.totalProductosMerma}),l.jsx("div",{style:{color:c.textSec,fontSize:9},children:"Productos"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{color:c.red,fontSize:15,fontWeight:700},children:ne(j.totalCantidadMerma)}),l.jsx("div",{style:{color:c.textSec,fontSize:9},children:"Unidades"})]})]}),j.totalValorStock>0&&l.jsxs("div",{style:{marginTop:8},children:[l.jsxs("div",{style:{color:c.orange,fontSize:12,fontWeight:600},children:[(j.totalValorMerma/j.totalValorStock*100).toFixed(1),"%"]}),l.jsx("div",{style:{color:c.textSec,fontSize:9},children:"del valor total de stock"})]})]})}),l.jsx(Re,{xs:24,md:18,lg:19,children:l.jsx(it,{dataSource:w,rowKey:"sku",size:"small",pagination:{pageSize:8,size:"small"},columns:[{title:"SKU",dataIndex:"sku",width:110,sorter:(m,S)=>m.sku.localeCompare(S.sku),render:m=>l.jsx(P,{style:{color:c.text,fontSize:11,whiteSpace:"nowrap"},children:m})},{title:"Cadena",dataIndex:"cadena",width:100,ellipsis:!0,sorter:(m,S)=>(m.cadena||m.marca||"").localeCompare(S.cadena||S.marca||""),render:(m,S)=>l.jsx(P,{style:{color:c.textSec,fontSize:10},children:S.cadena||S.marca||"—"})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,sorter:(m,S)=>(m.descripcion||"").localeCompare(S.descripcion||""),render:m=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:m})},{title:"Cant. Merma",dataIndex:"cantidadMerma",width:90,align:"right",sorter:(m,S)=>m.cantidadMerma-S.cantidadMerma,render:m=>l.jsx(P,{style:{color:c.red,fontWeight:600,fontSize:11},children:ne(m)})},{title:"Valor Merma",dataIndex:"valorMerma",width:100,align:"right",sorter:(m,S)=>m.valorMerma-S.valorMerma,render:m=>l.jsx(P,{style:{color:c.red,fontWeight:700,fontSize:11},children:ot(m)})},{title:"Días Vencido",dataIndex:"diasParaVencer",width:90,align:"right",sorter:(m,S)=>Math.abs(m.diasParaVencer)-Math.abs(S.diasParaVencer),defaultSortOrder:"descend",render:m=>l.jsxs(Ce,{color:"red",style:{fontSize:10},children:[Math.abs(m)," días"]})},{title:"Familia",dataIndex:"familia",width:100,ellipsis:!0,sorter:(m,S)=>(m.familia||"").localeCompare(S.familia||""),render:m=>l.jsx(P,{style:{color:c.textSec,fontSize:10},children:m})}]})})]})})},Ot=()=>{const{productosBajaRotacion:w,productosNulaRotacion:j,products:m}=u,S=[{name:"Normal",value:m.filter(D=>D.rotacion==="normal").length,fill:c.green},{name:"Baja",value:w.length,fill:c.orange},{name:"Nula",value:j.length,fill:c.red}],b=[...w,...j].sort((D,te)=>(te.diasStockFinanciero||9999)-(D.diasStockFinanciero||9999)).slice(0,20);return l.jsx(de,{id:"rotacion",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me([...w,...j].map(D=>({SKU:D.sku,Descripcion:D.descripcion,Cantidad:D.cantidadFisica,DespachoDiario:D.despachoDiario,DiasStock:D.diasStockFinanciero,Rotacion:D.rotacion,ValorStock:D.valorStock})),"Rotacion")}),children:l.jsxs(ft,{gutter:16,children:[l.jsx(Re,{xs:24,md:8,children:l.jsx("div",{style:{height:200},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs($r,{children:[l.jsx(Ur,{data:S,dataKey:"value",cx:"50%",cy:"50%",outerRadius:75,label:({name:D,value:te})=>`${D}: ${te}`,children:S.map((D,te)=>l.jsx(_n,{fill:D.fill},te))}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text},labelStyle:{color:c.text},itemStyle:{color:c.text}})]})})})}),l.jsx(Re,{xs:24,md:16,children:l.jsx(it,{dataSource:b,rowKey:"sku",size:"small",pagination:{pageSize:5,size:"small"},style:{background:"transparent"},columns:[{title:"SKU",dataIndex:"sku",width:120,sorter:(D,te)=>D.sku.localeCompare(te.sku),render:D=>l.jsx(P,{style:{color:c.text,fontSize:11,whiteSpace:"nowrap"},children:D})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,sorter:(D,te)=>(D.descripcion||"").localeCompare(te.descripcion||""),render:D=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:D})},{title:"Cant.",dataIndex:"cantidadFisica",width:70,align:"right",sorter:(D,te)=>(D.cantidadFisica||0)-(te.cantidadFisica||0),render:D=>l.jsx(P,{style:{color:c.text,fontSize:11},children:ne(D)})},{title:l.jsxs("span",{style:{whiteSpace:"nowrap"},children:["Desp/",l.jsx("br",{}),"Día"]}
29),dataIndex:"despachoDiario",width:70,align:"right",sorter:(D,te)=>(D.despachoDiario||0)-(te.despachoDiario||0),render:D=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(Math.round(D||0))})},{title:"Días",dataIndex:"diasStockFinanciero",width:60,align:"right",sorter:(D,te)=>(D.diasStockFinanciero||0)-(te.diasStockFinanciero||0),render:D=>l.jsx(P,{style:{color:D>90?c.red:c.orange,fontSize:11},children:D||"∞"})},{title:"Tipo",dataIndex:"rotacion",width:60,sorter:(D,te)=>(D.rotacion||"").localeCompare(te.rotacion||""),render:D=>l.jsx(Ce,{color:D==="nula"?"red":"orange",style:{fontSize:10},children:D})}]})})]})})},zt=()=>{const{products:w}=u,j=w.filter(m=>m.diasParaVencer!==null&&m.diasParaVencer>0&&m.diasParaVencer<=90).sort((m,S)=>(m.diasParaVencer||0)-(S.diasParaVencer||0));return l.jsxs(de,{id:"vencimiento",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(j.map(m=>({SKU:m.sku,Descripcion:m.descripcion,Cantidad:m.cantidadFisica,DiasVencerReal:m.diasParaVencer,DiasVencerEfectivo:Math.max(0,m.diasParaVencer-15),PctVidaUtil:m.pctVidaUtil,ConsumoDiario:m.consumoDiario,ValorEnRiesgo:m.valorEnRiesgo,Riesgo:m.riesgoVencimiento})),"Vencimiento")}),children:[l.jsx(rr,{type:"info",showIcon:!0,style:{marginBottom:12,background:`${c.bg}`,border:`1px solid ${c.accent}33`,borderRadius:8},message:l.jsx("span",{style:{color:c.accent,fontSize:12,fontWeight:600},children:"Margen de 15 días aplicado"}),description:l.jsx("span",{style:{color:c.textSec,fontSize:11},children:"Los días para vencer se calculan restando 15 días al vencimiento real del producto. Este margen asegura tiempo suficiente para su uso antes de la fecha de caducidad. Ejemplo: si un producto vence en 20 días reales, tiene solo 5 días efectivos para ser despachado."})}),l.jsx(it,{dataSource:j,rowKey:"sku",size:"small",pagination:{pageSize:10,size:"small"},columns:[{title:"SKU",dataIndex:"sku",width:120,sorter:(m,S)=>m.sku.localeCompare(S.sku),render:m=>l.jsx(P,{style:{color:c.text,fontSize:11,whiteSpace:"nowrap"},children:m})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,sorter:(m,S)=>(m.descripcion||"").localeCompare(S.descripcion||""),render:m=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:m})},{title:"Cant.",dataIndex:"cantidadFisica",width:70,align:"right",sorter:(m,S)=>(m.cantidadFisica||0)-(S.cantidadFisica||0),render:m=>l.jsx(P,{style:{color:c.text,fontSize:11},children:ne(m)})},{title:"Días Venc. Real",dataIndex:"diasParaVencer",width:90,align:"right",sorter:(m,S)=>m.diasParaVencer-S.diasParaVencer,render:m=>l.jsxs(P,{style:{color:m<=15?c.red:m<=45?c.orange:c.yellow,fontWeight:600,fontSize:11},children:[m,"d"]})},{title:"Días Efectivos",width:90,align:"right",sorter:(m,S)=>Math.max(0,(m.diasParaVencer||0)-15)-Math.max(0,(S.diasParaVencer||0)-15),render:(m,S)=>{const b=Math.max(0,S.diasParaVencer-15);return l.jsxs(P,{style:{color:b<=0?c.red:b<=15?c.orange:c.yellow,fontWeight:700,fontSize:11},children:[b,"d"]})}},{title:"% Vida",dataIndex:"pctVidaUtil",width:80,align:"right",sorter:(m,S)=>(m.pctVidaUtil||0)-(S.pctVidaUtil||0),render:m=>m!=null?l.jsx(nr,{percent:Math.min(m,100),size:"small",strokeColor:m>80?c.red:m>60?c.orange:c.green,trailColor:c.border,format:()=>l.jsxs("span",{style:{color:c.text,fontSize:10},children:[m,"%"]})}):"-"},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Consumo/día"}),dataIndex:"consumoDiario",width:80,align:"right",sorter:(m,S)=>(m.consumoDiario||0)-(S.consumoDiario||0),render:m=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(Math.round(m||0))})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Valor Riesgo"}),dataIndex:"valorEnRiesgo",width:100,align:"right",sorter:(m,S)=>m.valorEnRiesgo-S.valorEnRiesgo,render:m=>l.jsx(P,{style:{color:m>0?c.red:c.green,fontSize:11},children:ot(m)})},{title:"Riesgo",dataIndex:"riesgoVencimiento",width:70,sorter:(m,S)=>(m.riesgoVencimiento||"").localeCompare(S.riesgoVencimiento||""),render:m=>l.jsx(Ce,{color:m==="alto"?"red":m==="medio"?"orange":"gold",style:{fontSize:10},children:m})}]})]})},B=()=>{const{kpis:w}=u,j=w.fillRateGlobal>=95?c.green:w.fillRateGlobal>=85?c.orange:c.red;return l.jsx(de,{id:"fillrate",children:l.jsxs(ft,{gutter:16,align:"middle",children:[l.jsx(Re,{xs:24,md:8,children:l.jsxs("div",{style:{textAlign:"center",padding:16},children:[l.jsx("div",{style:{position:"relative",width:160,height:160,margin:"0 auto"},children:l.jsx(nr,{type:"dashboard",percent:w.fillRateGlobal,strokeColor:j,trailColor:c.border,strokeWidth:10,width:160,format:m=>l.jsxs("span",{style:{color:j,fontSize:28,fontWeight:700},children:[m,"%"]})})}),l.jsx("div",{style:{color:c.textSec,marginTop:8,fontSize:13},children:"Fill Rate Global"})]})}),l.jsx(Re,{xs:24,md:16,children:l.jsx(ft,{gutter:[12,12],children:[{label:"Solicitado",value:ne(w.totalSolicitado),color:c.accent},{label:"Despachado",value:ne(w.totalDespachado),color:c.green},{label:"No Enviado",value:ne(w.totalNoEnviado),color:c.red}].map((m,S)=>l.jsx(Re,{xs:8,children:l.jsxs("div",{style:{background:c.bg,borderRadius:8,padding:12,textAlign:"center",border:`1px solid ${c.border}`},children:[l.jsx("div",{style:{color:m.color,fontSize:20,fontWeight:700},children:m.value}),l.jsx("div",{style:{color:c.textSec,fontSize:11,marginTop:2},children:m.label})]})},S))})})]})})},Y=(w,j,m,S)=>!w||!w.length?l.jsx(de,{id:j,children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Sin datos de forecast"})})}):l.jsxs(de,{id:j,extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:m,style:{fontSize:10},children:[w.length," productos"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w,`Forecast_${S}`)})]}),children:[l.jsx("div",{style:{height:320},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs(pi,{data:w,margin:{top:10,right:10,left:0,bottom:40},children:[l.jsx(Vn,{strokeDasharray:"3 3",stroke:c.border}),l.jsx(Bn,{dataKey:"sku",tick:{fill:c.textSec,fontSize:9},angle:-45,textAnchor:"end",height:60}
29),l.jsx(Nn,{tick:{fill:c.textSec,fontSize:10}}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},formatter:(b,D)=>[ne(b),D]}),l.jsx(wr,{wrapperStyle:{color:c.text,fontSize:11}}),l.jsx(ir,{dataKey:"despachado",name:"Despachado",fill:c.accent,radius:[4,4,0,0]}),l.jsx(ir,{dataKey:"forecastMensual",name:"Forecast Mensual",fill:c.orange,radius:[4,4,0,0],opacity:.7})]})})}),l.jsx(it,{dataSource:w,rowKey:"sku",size:"small",pagination:{pageSize:8,size:"small"},style:{marginTop:12},columns:[{title:"SKU",dataIndex:"sku",width:120,sorter:(b,D)=>b.sku.localeCompare(D.sku),render:b=>l.jsx(P,{style:{color:c.text,fontSize:11},children:b})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,sorter:(b,D)=>(b.descripcion||"").localeCompare(D.descripcion||""),render:b=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:b})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Despachado"}),dataIndex:"despachado",width:90,align:"right",sorter:(b,D)=>b.despachado-D.despachado,render:b=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(b)})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Forecast"}),dataIndex:"forecastMensual",width:80,align:"right",sorter:(b,D)=>(b.forecastMensual||0)-(D.forecastMensual||0),render:b=>l.jsx(P,{style:{color:c.orange,fontSize:11},children:ne(Math.round(b||0))})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"% Cumpl."}),dataIndex:"pctCumplimiento",width:80,align:"right",sorter:(b,D)=>(b.pctCumplimiento||0)-(D.pctCumplimiento||0),render:b=>b!=null?l.jsxs(P,{style:{color:b>=90&&b<=110?c.green:b>=70?c.orange:c.red,fontWeight:600,fontSize:11},children:[b,"%"]}):"-"},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Diferencia"}),dataIndex:"diferencia",width:90,align:"right",render:b=>{const D=Math.round(b||0);return l.jsxs(P,{style:{color:D>=0?c.green:c.red,fontSize:11},children:[D>=0?"+":"",ne(D)]})}}]})]}),Q=()=>Y(u.forecastCercanos,"forecastCercanos","green","Cercanos"),xe=()=>Y(u.forecastLejanos,"forecastLejanos","red","Lejanos"),Se=()=>{const{familiaData:w}=u;if(!w.length)return l.jsx(de,{id:"familia",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Sin datos"})})});const j=w.filter(S=>S.diasStockFinanciero!=null).slice(0,15),m=S=>S>=45?c.green:S>=20?c.accent:S>=10?c.orange:c.red;return l.jsxs(de,{id:"familia",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w.map(S=>({Familia:S.familia,Productos:S.productos,Cantidad:S.cantidad,ValorStock:Math.round(S.valorStock),DiasStock:S.diasStockFinanciero})),"Dias_Stock_Familia")}),children:[l.jsx("div",{style:{height:Math.max(200,j.length*45)},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs(Co,{data:j,layout:"vertical",margin:{top:5,right:30,left:5,bottom:5},children:[l.jsx(Vn,{strokeDasharray:"3 3",stroke:c.border,horizontal:!1}),l.jsx(Bn,{type:"number",tick:{fill:c.textSec,fontSize:10},axisLine:{stroke:c.border}}),l.jsx(Nn,{dataKey:"familia",type:"category",width:130,tick:{fill:c.text,fontSize:11,fontWeight:500},axisLine:!1,tickLine:!1}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},formatter:(S,b)=>[`${S} días`,b]}),l.jsx(ir,{dataKey:"diasStockFinanciero",name:"Días Stock",radius:[0,6,6,0],barSize:24,label:{position:"right",fill:c.text,fontSize:11,fontWeight:600,formatter:S=>`${S}d`},children:j.map((S,b)=>l.jsx(_n,{fill:m(S.diasStockFinanciero),fillOpacity:.85},b))})]})})}),l.jsx("div",{style:{display:"flex",gap:12,justifyContent:"center",marginTop:8,marginBottom:8},children:[{label:"≥45d Holgado",color:c.green},{label:"20-44d Normal",color:c.accent},{label:"10-19d Bajo",color:c.orange},{label:"<10d Crítico",color:c.red}].map((S,b)=>l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,fontSize:10,color:c.textSec},children:[l.jsx("div",{style:{width:10,height:10,borderRadius:2,background:S.color}}),S.label]},b))}),l.jsx(it,{dataSource:w,rowKey:"familia",size:"small",pagination:{pageSize:10,size:"small"},columns:[{title:"Familia",dataIndex:"familia",sorter:(S,b)=>(S.familia||"").localeCompare(b.familia||""),render:S=>l.jsx(P,{style:{color:c.text,fontSize:11,fontWeight:500},children:S})},{title:"Productos",dataIndex:"productos",width:80,align:"right",sorter:(S,b)=>S.productos-b.productos,render:S=>l.jsx(P,{style:{color:c.text,fontSize:11},children:S})},{title:"Cantidad",dataIndex:"cantidad",width:90,align:"right",sorter:(S,b)=>(S.cantidad||0)-(b.cantidad||0),render:S=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(S)})},{title:"Valor Stock",dataIndex:"valorStock",width:110,align:"right",sorter:(S,b)=>S.valorStock-b.valorStock,render:S=>l.jsx(P,{style:{color:c.green,fontSize:11},children:ot(S)})},{title:"Días Stock",dataIndex:"diasStockFinanciero",width:90,align:"right",sorter:(S,b)=>(S.diasStockFinanciero||0)-(b.diasStockFinanciero||0),defaultSortOrder:"descend",render:S=>S!=null?l.jsxs(P,{style:{color:m(S),fontWeight:700,fontSize:11},children:[S,"d"]}):"-"}]})]})},st=()=>{const{kpis:w,stockFamiliaData:j}=u,m=j||[],S=m.filter(b=>b.valorStock>0).slice(0,10).map(b=>({name:b.familia,value:Math.round(b.valorStock)}));return l.jsxs(de,{id:"valorizado",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(m.map(b=>
29({Familia:b.familia,Productos:b.productos,Cantidad:b.cantidad,ValorStock:Math.round(b.valorStock)})),"Stock_Valorizado")}),children:[l.jsxs(ft,{gutter:16,children:[l.jsx(Re,{xs:24,md:8,children:l.jsxs("div",{style:{textAlign:"center",padding:16,background:c.bg,borderRadius:10,border:`1px solid ${c.border}`},children:[l.jsx("div",{style:{color:c.green,fontSize:32,fontWeight:700},children:ot(w.totalValorStock)}),l.jsx("div",{style:{color:c.textSec,fontSize:13,marginTop:4},children:"Stock Valorizado Total"})]})}),l.jsx(Re,{xs:24,md:16,children:S.length>0?l.jsx("div",{style:{height:240},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs($r,{children:[l.jsx(Ur,{data:S,dataKey:"value",cx:"50%",cy:"50%",outerRadius:90,label:({name:b,percent:D})=>`${b} ${(D*100).toFixed(0)}%`,children:S.map((b,D)=>l.jsx(_n,{fill:ln[D%ln.length]},D))}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},formatter:b=>ot(b)})]})})}):l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Sin datos de valorización"})})})]}),m.length>0&&l.jsx(it,{dataSource:m,rowKey:"familia",size:"small",pagination:{pageSize:10,size:"small"},style:{marginTop:16},columns:[{title:"Familia",dataIndex:"familia",ellipsis:!0,sorter:(b,D)=>(b.familia||"").localeCompare(D.familia||""),render:b=>l.jsx(P,{style:{color:c.text,fontSize:11},children:b})},{title:"Productos",dataIndex:"productos",width:80,align:"right",sorter:(b,D)=>b.productos-D.productos,render:b=>l.jsx(P,{style:{color:c.text,fontSize:11},children:b})},{title:"Cantidad",dataIndex:"cantidad",width:90,align:"right",sorter:(b,D)=>b.cantidad-D.cantidad,render:b=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(b)})},{title:"Valor Stock",dataIndex:"valorStock",width:110,align:"right",sorter:(b,D)=>b.valorStock-D.valorStock,defaultSortOrder:"descend",render:b=>l.jsx(P,{style:{color:c.green,fontWeight:600,fontSize:11},children:ot(b)})},{title:"% del Total",width:90,align:"right",render:(b,D)=>l.jsxs(P,{style:{color:c.textSec,fontSize:11},children:[w.totalValorStock>0?Math.round(D.valorStock/w.totalValorStock*100):0,"%"]})}]})]})},bt=()=>{const{posibleFaltante:w}=u;if(!w||!w.length)return l.jsx(de,{id:"faltante",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"No se detectaron posibles faltantes"})})});const j=w.filter(m=>m.pendienteIngreso>0);return w.filter(m=>!m.pendienteIngreso),l.jsxs(de,{id:"faltante",extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:"red",style:{fontSize:10},children:[w.length," productos en riesgo"]}),j.length>0&&l.jsxs(Ce,{color:"green",style:{fontSize:10},children:[j.length," con ingreso programado"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w.map(m=>({SKU:m.sku,Descripcion:m.descripcion,StockNoVencido:m.cantidadNoVencida,ConsumoDiario:m.consumoDiario,IngresoDiario:m.ingresoDiario,DiasStockSinIngreso:m.diasStockSinIngreso,DiasStockConIngreso:m.diasStockConIngreso,PendienteIngreso:m.pendienteIngreso,IngresoEstado:m.ingresoEstado,ForecastMensual:m.forecastMensual})),"Posible_Faltante")})]}),children:[l.jsx(rr,{type:"warning",showIcon:!0,style:{marginBottom:12,background:`${c.bg}`,border:`1px solid ${c.orange}33`,borderRadius:8},message:l.jsx("span",{style:{color:c.orange,fontSize:12,fontWeight:600},children:"Escenarios: Sin Ingreso vs Con Ingreso Pedido"}),description:l.jsx("span",{style:{color:c.textSec,fontSize:11}
29,children:'"Días s/Ing" = días de stock sin considerar ingresos programados. "Días c/Ing" = días de stock sumando las cantidades pendientes del ingreso pedido. Solo se considera stock no vencido.'})}),l.jsx(it,{dataSource:w,rowKey:"sku",size:"small",pagination:{pageSize:10,size:"small"},columns:[{title:"SKU",dataIndex:"sku",width:110,sorter:(m,S)=>m.sku.localeCompare(S.sku),render:m=>l.jsx(P,{style:{color:c.text,fontSize:11,whiteSpace:"nowrap"},children:m})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,render:m=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:m})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Stock No Venc."}),dataIndex:"cantidadNoVencida",width:85,align:"right",sorter:(m,S)=>m.cantidadNoVencida-S.cantidadNoVencida,render:m=>l.jsx(P,{style:{color:c.text,fontWeight:600,fontSize:11},children:ne(m)})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Consumo/día"}),dataIndex:"consumoDiario",width:80,align:"right",sorter:(m,S)=>m.consumoDiario-S.consumoDiario,render:m=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(Math.round(m||0))})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Días s/Ing"}),dataIndex:"diasStockSinIngreso",width:75,align:"right",sorter:(m,S)=>(m.diasStockSinIngreso||9999)-(S.diasStockSinIngreso||9999),render:m=>m!=null?l.jsxs(P,{style:{color:m<=7?c.red:m<=15?c.orange:c.yellow,fontWeight:700,fontSize:11},children:[m,"d"]}):l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"-"})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Ing. Pend."}),dataIndex:"pendienteIngreso",width:75,align:"right",render:m=>m>0?l.jsxs(P,{style:{color:c.green,fontWeight:600,fontSize:11},children:["+",ne(m)]}):l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"-"})},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Días c/Ing"}),dataIndex:"diasStockConIngreso",width:75,align:"right",sorter:(m,S)=>(m.diasStockConIngreso||9999)-(S.diasStockConIngreso||9999),render:(m,S)=>{if(m==null)return l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"-"});const b=S.pendienteIngreso>0&&m>(S.diasStockSinIngreso||0);return l.jsxs(P,{style:{color:b?c.green:m<=7?c.red:m<=15?c.orange:c.yellow,fontWeight:700,fontSize:11},children:[m,"d"]})}},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Estado Ing."}),dataIndex:"ingresoEstado",width:80,align:"center",render:m=>{if(m==="sin_pedido")return l.jsx(P,{style:{color:c.textSec,fontSize:10},children:"-"});const S={pendiente:"orange",ingresado:"green",completado:"blue"},b={pendiente:"Pend.",ingresado:"Ingr.",completado:"OK"};return l.jsx(Ce,{color:S[m]||"default",style:{fontSize:9},children:b[m]||m})}},{title:l.jsx("span",{style:{whiteSpace:"nowrap"},children:"Forecast"}),dataIndex:"forecastMensual",width:70,align:"right",render:m=>m>0?l.jsx(P,{style:{color:c.orange,fontSize:11},children:ne(Math.round(m||0))}):l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"-"})}]})]})},pt=()=>{const{kpis:w}=u,j=w.fillRateLineas>=95?c.green:w.fillRateLineas>=85?c.orange:c.red;return l.jsx(de,{id:"fillrateLineas",children:l.jsxs(ft,{gutter:16,align:"middle",children:[l.jsx(Re,{xs:24,md:8,children:l.jsxs("div",{style:{textAlign:"center",padding:16},children:[l.jsx("div",{style:{position:"relative",width:160,height:160,margin:"0 auto"},children:l.jsx(nr,{type:"dashboard",percent:w.fillRateLineas,strokeColor:j,trailColor:c.border,strokeWidth:10,width:160,format:m=>l.jsxs("span",{style:{color:j,fontSize:28,fontWeight:700},children:[m,"%"]})})}),l.jsx("div",{style:{color:c.textSec,marginTop:8,fontSize:13},children:"Fill Rate por Línea"})]})}),l.jsxs(Re,{xs:24,md:16,children:[l.jsx(ft,{gutter:[12,12],children:[{label:"Total Líneas",value:ne(w.totalLineas),color:c.accent},{label:"Líneas Completas",value:ne(w.totalLineas-w.lineasConFaltante),color:c.green},{label:"Líneas con Faltante",value:ne(w.lineasConFaltante),color:c.red}].map((m,S)=>l.jsx(Re,{xs:8,children:l.jsxs("div",{style:{background:c.bg,borderRadius:8,padding:12,textAlign:"center",border:`1px solid ${c.border}`},children:[l.jsx("div",{style:{color:m.color,fontSize:20,fontWeight:700},children:m.value}),l.jsx("div",{style:{color:c.textSec,fontSize:11,marginTop:2},children:m.label})]})},S))}),l.jsxs(ft,{gutter:[12,12],style:{marginTop:12},children:[l.jsx(Re,{xs:8,children:l.jsxs("div",{style:{background:c.bg,borderRadius:8,padding:12,textAlign:"center",border:`1px solid ${c.border}`},children:[l.jsx("div",{style:{color:c.accent,fontSize:20,fontWeight:700},children:ne(w.totalOrdenes)}),l.jsx("div",{style:{color:c.textSec,fontSize:11,marginTop:2},children:"Órdenes"})]})}),l.jsx(Re,{xs:8,children:l.jsxs("div",{style:{background:c.bg,borderRadius:8,padding:12,textAlign:"center",border:`1px solid ${c.border}`},children:[l.jsx("div",{style:{color:c.text,fontSize:20,fontWeight:700},children:ne(w.totalUnidadesSolOrd)}),l.jsx("div",{style:{color:c.textSec,fontSize:11,marginTop:2},children:"Uds Solicitadas"})]})}),l.jsx(Re,{xs:8,children:l.jsxs("div",{style:{background:c.bg,borderRadius:8,padding:12,textAlign:"center",border:`1px solid ${c.border}`},children:[l.jsx("div",{style:{color:c.red,fontSize:20,fontWeight:700},children:ne(w.totalUnidadesFaltOrd)}),l.jsx("div",{style:{color:c.textSec,fontSize:11,marginTop:2},children:"Uds Faltantes"})]})})]})]})]})})},Yt=()=>{const{dailyData:w}=u;if(!w||!w.length)return l.jsx(de,{id:"dailyChart",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Sin datos diarios"})})});const j=w.map(m=>({...m,fechaLabel:m.fecha.substring(5)}));return l.jsx(de,{id:"dailyChart",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>
29Me(w,"Despacho_Faltante_Diario")}),children:l.jsx("div",{style:{height:320},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs(Eo,{data:j,margin:{top:10,right:10,left:0,bottom:10},children:[l.jsx(Vn,{strokeDasharray:"3 3",stroke:c.border}),l.jsx(Bn,{dataKey:"fechaLabel",tick:{fill:c.textSec,fontSize:10}}),l.jsx(Nn,{tick:{fill:c.textSec,fontSize:10}}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},labelFormatter:(m,S)=>S?.[0]?.payload?.fecha||m,formatter:(m,S)=>[ne(m),S]}),l.jsx(wr,{wrapperStyle:{fontSize:11}}),l.jsx(Dr,{type:"monotone",dataKey:"despachado",name:"Despachado",stroke:c.accent,strokeWidth:2,dot:!1}),l.jsx(Dr,{type:"monotone",dataKey:"faltante",name:"Faltante",stroke:c.red,strokeWidth:2,dot:!1})]})})})})},Ut=()=>{const{subCatData:w}=u;return!w||!w.length?l.jsx(de,{id:"subCat",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Sin datos de sub-categoría"})})}):l.jsx(de,{id:"subCat",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w.map(j=>({Categoria:j.categoria,Productos:j.productos,ValorStock:Math.round(j.valorStock),Despachado:j.despachado,ValorEnRiesgo:Math.round(j.valorEnRiesgo)})),"SubCategoria_Comercial")}),children:l.jsx(it,{dataSource:w,rowKey:"categoria",size:"small",pagination:{pageSize:10,size:"small"},columns:[{title:"Sub-Categoría",dataIndex:"categoria",ellipsis:!0,sorter:(j,m)=>(j.categoria||"").localeCompare(m.categoria||""),render:j=>l.jsx(P,{style:{color:c.text,fontSize:11},children:j})},{title:"Productos",dataIndex:"productos",width:80,align:"right",sorter:(j,m)=>j.productos-m.productos,render:j=>l.jsx(P,{style:{color:c.text,fontSize:11},children:j})},{title:"Valor Stock",dataIndex:"valorStock",width:100,align:"right",sorter:(j,m)=>j.valorStock-m.valorStock,render:j=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ot(j)})},{title:"Despachado",dataIndex:"despachado",width:90,align:"right",sorter:(j,m)=>(j.despachado||0)-(m.despachado||0),render:j=>l.jsx(P,{style:{color:c.green,fontSize:11},children:ne(j)})},{title:"Valor Riesgo",dataIndex:"valorEnRiesgo",width:100,align:"right",sorter:(j,m)=>(j.valorEnRiesgo||0)-(m.valorEnRiesgo||0),render:j=>l.jsx(P,{style:{color:j>0?c.red:c.green,fontSize:11},children:ot(j)})}]})})},Je=()=>{const{stockEvolutionHigh:w,stockEvolutionLow:j,evolutionGroupHigh:m,evolutionGroupLow:S}=u;if(!(w&&w.length>0||j&&j.length>0))return l.jsx(de,{id:"stockEvolution",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Sin datos de evolución (cargue stock con fechas)"})})});const D=(te,A,K)=>!te||!te.length||!A||!A.length?null:l.jsxs("div",{style:{marginBottom:16},children:[l.jsx(P,{style:{color:c.accent,fontSize:12,fontWeight:600,marginBottom:8,display:"block"},children:K}),l.jsx("div",{style:{height:300},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs(Eo,{data:te,margin:{top:10,right:10,left:0,bottom:40},children:[l.jsx(Vn,{strokeDasharray:"3 3",stroke:c.border}),l.jsx(Bn,{dataKey:"fechaLabel",tick:{fill:c.textSec,fontSize:9},angle:-45,textAnchor:"end",height:60}),l.jsx(Nn,{tick:{fill:c.textSec,fontSize:10},tickFormatter:ge=>ne(ge)}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:11},labelStyle:{color:c.text},itemStyle:{color:c.text},labelFormatter:(ge,ve)=>ve?.[0]?.payload?.fecha||ge,formatter:(ge,ve)=>[ne(ge),ve]}),l.jsx(wr,{wrapperStyle:{color:c.text,fontSize:10}}),A.map(({sku:ge,descripcion:ve},Ie)=>l.jsx(Dr,{type:"monotone",dataKey:ge,name:`${ge} - ${(ve||"").substring(0,20)}`,stroke:ln[Ie%ln.length],strokeWidth:2,dot:!1,connectNulls:!0},ge))]})})})]});return l.jsxs(de,{id:"stockEvolution",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w||[],"Evolucion_Stock")}),children:[l.jsx("div",{style:{marginBottom:8},children:l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"Gráficos separados por escala de cantidades para mejor visualización. Artículos de mayor cantidad arriba, menor cantidad abajo."})}),D(w,m,`Escala Alta (${(m||[]).length} productos)`),D(j,S,`Escala Baja (${(S||[]).length} productos)`)]})},Mt=()=>{const{stockFamiliaData:w,kpis:j}=u;if(!w||!w.length)return l.jsx(de,{id:"stockFamilia",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Sin datos de familia"})})});const m=w.slice(0,15),S=w.reduce((b,D)=>b+D.valorStock,0);return l.jsx(de,{id:"stockFamilia",extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:"green",style:{fontSize:11,fontWeight:600},children:[ot(S)," total"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w.map(b=>
29({Familia:b.familia,Productos:b.productos,Cantidad:b.cantidad,ValorStock:Math.round(b.valorStock)})),"Stock_Familia")})]}),children:l.jsxs(ft,{gutter:16,children:[l.jsx(Re,{xs:24,md:14,children:l.jsx("div",{style:{height:320},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs(Co,{data:m,layout:"vertical",margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx(Vn,{strokeDasharray:"3 3",stroke:c.border}),l.jsx(Bn,{type:"number",tick:{fill:c.textSec,fontSize:10},tickFormatter:b=>ot(b)}),l.jsx(Nn,{dataKey:"familia",type:"category",width:130,tick:{fill:c.textSec,fontSize:10}}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},formatter:b=>[ot(b),"Valor Stock"]}),l.jsx(ir,{dataKey:"valorStock",name:"Valor Stock",radius:[0,4,4,0],children:m.map((b,D)=>l.jsx(_n,{fill:ln[D%ln.length]},D))})]})})})}),l.jsx(Re,{xs:24,md:10,children:l.jsx("div",{style:{maxHeight:320,overflowY:"auto"},children:m.map((b,D)=>l.jsxs("div",{style:{background:c.bg,borderRadius:8,padding:"8px 12px",marginBottom:6,border:`1px solid ${c.border}`,borderLeft:`3px solid ${ln[D%ln.length]}`},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsx(P,{style:{color:c.text,fontSize:12,fontWeight:600},children:b.familia}),l.jsx(P,{style:{color:ln[D%ln.length],fontSize:13,fontWeight:700},children:ot(b.valorStock)})]}),l.jsxs("div",{style:{display:"flex",gap:12,marginTop:3},children:[l.jsxs(P,{style:{color:c.textSec,fontSize:10},children:[ne(b.cantidad)," uds"]}),l.jsxs(P,{style:{color:c.textSec,fontSize:10},children:[b.productos," prods"]}),l.jsxs(P,{style:{color:c.textSec,fontSize:10},children:[S>0?Math.round(b.valorStock/S*100):0,"%"]})]})]},b.familia))})})]})})},et=()=>{const{politicasCumplimiento:w,kpis:j}=u;if(!w||!w.length)return l.jsx(de,{id:"politicasCumpl",children:l.jsxs("div",{style:{textAlign:"center",padding:32},children:[l.jsx("div",{style:{fontSize:40,marginBottom:8},children:"📋"}),l.jsx(P,{style:{color:c.textSec,fontSize:14},children:"Sin políticas cargadas o ninguna familia con Politi Fam > 0"}),l.jsx("div",{style:{color:c.textSec,fontSize:11,marginTop:6},children:"Importe políticas en el módulo Inventarios → Políticas"})]})});const m={bajo:c.red,cercano:c.orange,excedido:c.green,sin_movimiento:c.textSec},S={bajo:"Bajo política",cercano:"Cercano",excedido:"Excedido",sin_movimiento:"Sin mov."},b={bajo:"red",cercano:"orange",excedido:"green",sin_movimiento:"default"},D=w.filter(A=>A.diasStock!==null).map(A=>({familia:A.familia.length>20?A.familia.substring(0,20)+"…":A.familia,diasStock:A.diasStock,politiFam:A.politiFam,estado:A.estado})),te=[{label:"Bajo política",count:j.totalPoliticasBajo,color:c.red,icon:"📉"},{label:"Cercano",count:j.totalPoliticasCercano,color:c.orange,icon:"⚠️"},{label:"Excedido",count:j.totalPoliticasExcedido,color:c.green,icon:"✅"}];return l.jsxs(de,{id:"politicasCumpl",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w.map(A=>({Familia:A.familia,Marca:A.marca,PolitiFam:A.politiFam,DiasStock:A.diasStock,Estado:S[A.estado],Brecha:A.brecha,Productos:A.productos})),"Politicas_Cumplimiento")}),children:[l.jsx(ft,{gutter:[12,12],style:{marginBottom:16},children:te.map((A,K)=>l.jsx(Re,{xs:8,children:l.jsxs("div",{style:{background:c.bg,borderRadius:10,padding:12,border:`1px solid ${c.border}`,borderLeft:`3px solid ${A.color}`,textAlign:"center"},children:[l.jsx("div",{style:{fontSize:22},children:A.icon}),l.jsx("div",{style:{color:A.color,fontSize:22,fontWeight:700},children:A.count}),l.jsx("div",{style:{color:c.textSec,fontSize:11},children:A.label})]})},K))}),l.jsxs(ft,{gutter:16,children:[D.length>0&&l.jsx(Re,{xs:24,md:14,children:l.jsx("div",{style:{height:300},children:l.jsx(en,{width:"100%",height:"100%",children:l.jsxs(pi,{data:D,layout:"vertical",margin:{top:5,right:20,left:10,bottom:5},children:[l.jsx(Vn,{strokeDasharray:"3 3",stroke:c.border}),l.jsx(Bn,{type:"number",tick:{fill:c.textSec,fontSize:10},label:{value:"Días de Stock",fill:c.textSec,fontSize:10,position:"insideBottomRight",offset:-5}}
29),l.jsx(Nn,{dataKey:"familia",type:"category",width:140,tick:{fill:c.textSec,fontSize:9}}),l.jsx(tn,{contentStyle:{background:c.card,border:`1px solid ${c.border}`,color:c.text,fontSize:12},labelStyle:{color:c.text},itemStyle:{color:c.text},formatter:(A,K)=>[A+" días",K]}),l.jsx(wr,{wrapperStyle:{fontSize:10}}),l.jsx(ir,{dataKey:"diasStock",name:"Días Stock Real",radius:[0,4,4,0],children:D.map((A,K)=>l.jsx(_n,{fill:m[A.estado]||c.accent},K))}),l.jsx(Dr,{type:"monotone",dataKey:"politiFam",name:"Política (días)",stroke:c.purple,strokeWidth:2,strokeDasharray:"6 3",dot:{r:4,fill:c.purple}})]})})})}),l.jsx(Re,{xs:24,md:D.length>0?10:24,children:l.jsx(it,{dataSource:w,rowKey:"familia",size:"small",pagination:{pageSize:8,size:"small"},columns:[{title:"Familia",dataIndex:"familia",ellipsis:!0,sorter:(A,K)=>(A.familia||"").localeCompare(K.familia||""),render:A=>l.jsx(P,{style:{color:c.text,fontSize:11},children:A})},{title:"Política",dataIndex:"politiFam",width:60,align:"right",sorter:(A,K)=>(A.politiFam||0)-(K.politiFam||0),render:A=>l.jsxs(P,{style:{color:c.purple,fontSize:11,fontWeight:600},children:[A,"d"]})},{title:"Días Stock",dataIndex:"diasStock",width:70,align:"right",sorter:(A,K)=>(A.diasStock||0)-(K.diasStock||0),render:(A,K)=>A!=null?l.jsxs(P,{style:{color:m[K.estado],fontWeight:700,fontSize:11},children:[A,"d"]}):l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"S/M"})},{title:"Brecha",dataIndex:"brecha",width:60,align:"right",sorter:(A,K)=>(A.brecha||0)-(K.brecha||0),render:A=>A!=null?l.jsxs(P,{style:{color:A<0?c.red:c.green,fontSize:11,fontWeight:600},children:[A>0?"+":"",A,"d"]}):"-"},{title:"Estado",dataIndex:"estado",width:90,sorter:(A,K)=>(A.estado||"").localeCompare(K.estado||""),render:A=>l.jsx(Ce,{color:b[A],style:{fontSize:10},children:S[A]})}]})})]})]})},Mn=()=>{const{noEnviados:w}=u;return w.length?l.jsx(de,{id:"noEnviados",extra:l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w,"No_Enviados")}),children:l.jsx(it,{dataSource:w,rowKey:"sku",size:"small",pagination:{pageSize:10,size:"small"},columns:[{title:"SKU",dataIndex:"sku",width:120,sorter:(j,m)=>j.sku.localeCompare(m.sku),render:j=>l.jsx(P,{style:{color:c.text,fontSize:11,whiteSpace:"nowrap"},children:j})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,sorter:(j,m)=>(j.descripcion||"").localeCompare(m.descripcion||""),render:j=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:j})},{title:"Solicitado",dataIndex:"solicitado",width:80,align:"right",sorter:(j,m)=>(j.solicitado||0)-(m.solicitado||0),render:j=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(j)})},{title:"Despachado",dataIndex:"despachado",width:80,align:"right",sorter:(j,m)=>(j.despachado||0)-(m.despachado||0),render:j=>l.jsx(P,{style:{color:c.green,fontSize:11},children:ne(j)})},{title:"No Enviado",dataIndex:"noEnviado",width:80,align:"right",sorter:(j,m)=>j.noEnviado-m.noEnviado,render:j=>l.jsx(P,{style:{color:c.red,fontWeight:600,fontSize:11},children:ne(j)})},{title:"Fill Rate",dataIndex:"fillRate",width:80,align:"right",sorter:(j,m)=>(j.fillRate||0)-(m.fillRate||0),render:j=>l.jsxs(P,{style:{color:j>=95?c.green:j>=85?c.orange:c.red,fontSize:11},children:[j,"%"]})}]})}):l.jsx(de,{id:"noEnviados",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"Todos los pedidos fueron despachados"})})})},Sn=()=>{const{faltantesConStock:w}=u;if(!w||!w.length)return l.jsx(de,{id:"faltantesStock",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"No se detectaron faltantes con stock disponible"})})});const j=w.reduce((b,D)=>b+D.faltante,0),m=w.reduce((b,D)=>b+D.cantFechas,0),S=[];return w.forEach(b=>b.fechas.forEach(D=>D.locales.forEach(te=>{S.push({SKU:b.sku,Descripcion:b.descripcion,Fecha:D.fecha,Pedido:te.solicitado,Enviado:te.despachado,Faltante:te.faltante,StockDisponible:D.stockDisponible,Local:te.local})}))),l.jsx(de,{id:"faltantesStock",extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:"red",style:{fontSize:10},children:[ne(j)," uds faltantes"]}),l.jsxs(Ce,{color:"blue",style:{fontSize:10},children:[w.length," productos · ",m," fechas"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(S,"Faltantes_Stock")})]}),children:l.jsx(it,{dataSource:w,rowKey:"key",size:"small",pagination:{pageSize:15,size:"small",showTotal:b=>l.jsxs(P,{style:{color:c.textSec,fontSize:11},children:[b," productos"]})},expandable:{expandedRowRender:b=>l.jsx(it,{dataSource:b.fechas,rowKey:"key",size:"small",pagination:!1,style:{marginLeft:24},expandable:{expandedRowRender:D=>l.jsx(it,{dataSource:D.locales,rowKey:"local",size:"small",pagination:!1,style:{marginLeft:24},columns:[{title:"Local / Punto Entrega",dataIndex:"local",render:te=>l.jsx(P,{style:{color:c.text,fontSize:11},children:te})},{title:"Solicitado",dataIndex:"solicitado",width:90,align:"right",render:te=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(te)})},{title:"Despachado",dataIndex:"despachado",width:90,align:"right",render:te=>l.jsx(P,{style:{color:c.green,fontSize:11},children:ne(te)})},{title:"Faltante",dataIndex:"faltante",width:90,align:"right",render:te=>l.jsx(P,{style:{color:c.red,fontWeight:600,fontSize:11},children:ne(te)})}]}),rowExpandable:D=>D.locales&&D.locales.length>0},columns:[{title:"Fecha",dataIndex:"fecha",width:110,render:D=>l.jsx(P,{style:{color:c.text,fontSize:11},children:D})}
29,{title:"Pedido",dataIndex:"totalPedido",width:80,align:"right",render:D=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(D)})},{title:"Enviado",dataIndex:"totalEnviado",width:80,align:"right",render:D=>l.jsx(P,{style:{color:c.green,fontSize:11},children:ne(D)})},{title:"Faltante",dataIndex:"faltante",width:80,align:"right",render:D=>l.jsx(P,{style:{color:c.red,fontWeight:600,fontSize:11},children:ne(D)})},{title:"Stock Disp.",dataIndex:"stockDisponible",width:90,align:"right",render:D=>l.jsx(P,{style:{color:c.orange,fontWeight:600,fontSize:11},children:ne(D)})},{title:"Locales",dataIndex:"cantLocales",width:65,align:"center",render:D=>l.jsx(Ce,{color:"blue",style:{fontSize:10},children:D})}]}),rowExpandable:b=>b.fechas&&b.fechas.length>0},columns:[{title:"SKU",dataIndex:"sku",width:120,sorter:(b,D)=>b.sku.localeCompare(D.sku),render:b=>l.jsx(P,{style:{color:c.text,fontSize:11,whiteSpace:"nowrap"},children:b})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,sorter:(b,D)=>(b.descripcion||"").localeCompare(D.descripcion||""),render:b=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:b})},{title:"Tot. Pedido",dataIndex:"totalPedido",width:90,align:"right",sorter:(b,D)=>b.totalPedido-D.totalPedido,render:b=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(b)})},{title:"Tot. Enviado",dataIndex:"totalEnviado",width:90,align:"right",sorter:(b,D)=>b.totalEnviado-D.totalEnviado,render:b=>l.jsx(P,{style:{color:c.green,fontSize:11},children:ne(b)})},{title:"Tot. Faltante",dataIndex:"faltante",width:90,align:"right",sorter:(b,D)=>b.faltante-D.faltante,render:b=>l.jsx(P,{style:{color:c.red,fontWeight:600,fontSize:11},children:ne(b)})},{title:"Fechas",dataIndex:"cantFechas",width:65,align:"center",sorter:(b,D)=>b.cantFechas-D.cantFechas,render:b=>l.jsx(Ce,{color:"volcano",style:{fontSize:10},children:b})}]})})},fn=()=>{const{ingresoPedidoData:w}=u;if(!w||!w.length)return l.jsx(de,{id:"ingresoPedido",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"No hay datos de ingreso pedido cargados"})})});const j=w.filter(A=>A.estado==="pendiente"),m=w.filter(A=>A.estado==="ingresado"),S=w.filter(A=>A.estado==="completado"),b={pendiente:"orange",ingresado:"green",completado:"blue"},D={pendiente:"Pendiente",ingresado:"Ingresado",completado:"Completado"},te=A=>A?A instanceof Date?`${String(A.getDate()).padStart(2,"0")}/${String(A.getMonth()+1).padStart(2,"0")}/${A.getFullYear()}`:String(A):"-";return l.jsxs(de,{id:"ingresoPedido",extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:"orange",style:{fontSize:10},children:[j.length," pendientes"]}),l.jsxs(Ce,{color:"green",style:{fontSize:10},children:[m.length," ingresados"]}),l.jsxs(Ce,{color:"blue",style:{fontSize:10},children:[S.length," completados"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w.map(A=>({SKU:A.sku,Descripcion:A.descripcion,Familia:A.familia,TotalPedido:A.totalPedido,TotalRecibida:A.totalRecibida,Pendiente:A.pendiente,IngresoDetectado:A.ingresoDetectado,StockActual:A.stockActual,ConsumoDiario:A.consumoDiario,DiasStockSinIngreso:A.diasStockSinIngreso,DiasStockConIngreso:A.diasStockConIngreso,FechaEntrega:A.fechaEntrega?te(A.fechaEntrega):"",Estado:D[A.estado]||A.estado})),"Ingreso_Pedido")})]}),children:[l.jsx(ft,{gutter:[12,12],style:{marginBottom:16},children:[{label:"Pendientes",count:j.length,color:c.orange,icon:"⏳"},{label:"Ingresados",count:m.length,color:c.green,icon:"✅"},{label:"Completados",count:S.length,color:c.accent,icon:"📦"}].map((A,K)=>l.jsx(Re,{xs:8,children:l.jsxs("div",{style:{background:c.bg,borderRadius:10,padding:12,border:`1px solid ${c.border}`,borderLeft:`3px solid ${A.color}`,textAlign:"center"},children:[l.jsx("div",{style:{fontSize:22},children:A.icon}),l.jsx("div",{style:{color:A.color,fontSize:22,fontWeight:700},children:A.count}),l.jsx("div",{style:{color:c.textSec,fontSize:11},children:A.label})]})},K))}),l.jsx(it,{dataSource:w,rowKey:"key",size:"small",pagination:{pageSize:15,size:"small"},expandable:{expandedRowRender:A=>l.jsx(it,{dataSource:A.lineas,rowKey:(K,ge)=>`${K.nroOC}_${K.linea}_${ge}`,size:"small",pagination:!1,style:{marginLeft:24},columns:[{title:"OC",dataIndex:"nroOC",width:100,render:K=>l.jsx(P,{style:{color:c.text,fontSize:11},children:K})},{title:"Proveedor",dataIndex:"proveedor",ellipsis:!0,render:K=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:K})},{title:"Cantidad",dataIndex:"cantidad",width:80,align:"right",render:K=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(K)})},{title:"Recibida",dataIndex:"recibida",width:80,align:"right",render:K=>l.jsx(P,{style:{color:c.green,fontSize:11},children:ne(K)})},{title:"Pendiente",dataIndex:"pendiente",width:80,align:"right",render:K=>l.jsx(P,{style:{color:K>0?c.orange:c.green,fontWeight:600,fontSize:11},children:ne(K)})},{title:"Estado OC",dataIndex:"estadoOC",width:100,render:K=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:K})},{title:"F. Entrega",dataIndex:"fechaEntrega",width:100,render:K=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:te(K)})}]}),rowExpandable:A=>A.lineas&&A.lineas.length>0},columns:[{title:"SKU",dataIndex:"sku",width:110,sorter:(A,K)=>A.sku.localeCompare(K.sku),render:A=>l.jsx(P,{style:{color:c.text,fontSize:11,whiteSpace:"nowrap"},children:A})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,render:A=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:A})}
29,{title:"Pedido",dataIndex:"totalPedido",width:75,align:"right",sorter:(A,K)=>A.totalPedido-K.totalPedido,render:A=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(A)})},{title:"Pendiente",dataIndex:"pendiente",width:80,align:"right",sorter:(A,K)=>A.pendiente-K.pendiente,render:A=>l.jsx(P,{style:{color:A>0?c.orange:c.green,fontWeight:600,fontSize:11},children:ne(A)})},{title:"Stock",dataIndex:"stockActual",width:75,align:"right",render:A=>l.jsx(P,{style:{color:c.text,fontSize:11},children:ne(A)})},{title:"Días s/Ing",dataIndex:"diasStockSinIngreso",width:75,align:"right",sorter:(A,K)=>(A.diasStockSinIngreso||9999)-(K.diasStockSinIngreso||9999),render:A=>A!=null?l.jsxs(P,{style:{color:A<=7?c.red:A<=15?c.orange:c.text,fontWeight:600,fontSize:11},children:[A,"d"]}):l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"-"})},{title:"Días c/Ing",dataIndex:"diasStockConIngreso",width:75,align:"right",sorter:(A,K)=>(A.diasStockConIngreso||9999)-(K.diasStockConIngreso||9999),render:A=>A!=null?l.jsxs(P,{style:{color:A<=7?c.red:A<=15?c.orange:c.green,fontWeight:600,fontSize:11},children:[A,"d"]}):l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"-"})},{title:"F. Entrega",dataIndex:"fechaEntrega",width:95,sorter:(A,K)=>(A.fechaEntrega||0)-(K.fechaEntrega||0),render:A=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:te(A)})},{title:"Estado",dataIndex:"estado",width:95,sorter:(A,K)=>(A.estado||"").localeCompare(K.estado||""),render:A=>l.jsx(Ce,{color:b[A]||"default",style:{fontSize:10},children:D[A]||A})}]})]})},gr=()=>{const{ingresoConfirmadoData:w}=u,j=S=>{if(!S)return"-";const b=S instanceof Date?S:new Date(S);return isNaN(b)?"-":b.toLocaleDateString("es-CL")};if(!w||!w.length)return l.jsx(de,{id:"ingresoConfirmado",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"No hay datos de ingreso confirmado cargados"})})});const m=w.filter(S=>S.tieneAnomaliaIngreso);return l.jsxs(de,{id:"ingresoConfirmado",extra:l.jsxs(Ft,{size:8,children:[l.jsxs(Ce,{color:"green",style:{fontSize:10},children:[w.length," SKUs recibidos"]}),m.length>0&&l.jsxs(Ce,{color:"red",style:{fontSize:10},children:["⚠️ ",m.length," anomalías"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.textSec,borderColor:c.border},onClick:()=>Me(w.map(S=>({SKU:S.sku,Descripcion:S.descripcion,Familia:S.familia,TotalRecibida:S.totalRecibida,TotalKg:S.totalKg,StockActual:S.stockActual,ConsumoDiario:S.consumoDiario,DiasStock:S.diasStockActual,FechaRecepcion:j(S.fechaUltimaRecepcion),TieneAnomalia:S.tieneAnomaliaIngreso?"SÍ":"No"})),"ingreso_confirmado"),children:"Excel"})]}),children:[l.jsx(rr,{message:"Ingreso Confirmado — Solo visualización",description:"Estos ingresos están separados del stock. Se usan para validar la previsión de faltantes y detectar anomalías. No se suman al stock físico.",type:"info",showIcon:!0,style:{marginBottom:12,background:"#0d2137",border:"1px solid #1a4a7a"}}),l.jsx(it,{dataSource:w,rowKey:"key",size:"small",pagination:{pageSize:15,size:"small"},rowClassName:S=>S.tieneAnomaliaIngreso?"anomalia-row":"",expandable:{expandedRowRender:S=>l.jsx(it,{dataSource:S.lineas,rowKey:(b,D)=>`${b.oc}_${b.lpn}_${D}`,size:"small",pagination:!1,style:{marginLeft:24},columns:[{title:"OC",dataIndex:"oc",width:90,render:b=>l.jsx(P,{style:{color:c.text,fontSize:11},children:b})},{title:"Documento",dataIndex:"documento",width:90,render:b=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:b})},{title:"LPN",dataIndex:"lpn",width:110,render:b=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:b})},{title:"Lote",dataIndex:"lote",width:90,render:b=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:b})},{title:"Cant. Rec.",dataIndex:"cantidadRecibida",width:80,align:"right",render:b=>l.jsx(P,{style:{color:c.green,fontSize:11},children:ne(b)})},{title:"KG",dataIndex:"kgRecibido",width:75,align:"right",render:b=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(b)})},{title:"Site",dataIndex:"site",width:110,render:b=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:b})},{title:"Estado",dataIndex:"estadoRecepcion",width:80,render:b=>l.jsx(Ce,{color:"green",style:{fontSize:10},children:b})},{title:"F. Recepción",dataIndex:"fechaRecepcion",width:100,render:b=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:j(b)})}
29,{title:"F. Vencimiento",dataIndex:"fechaVencimiento",width:100,render:b=>l.jsx(P,{style:{color:c.yellow,fontSize:11},children:j(b)})}]}),rowExpandable:S=>S.lineas&&S.lineas.length>0},columns:[{title:"SKU",dataIndex:"sku",width:120,render:S=>l.jsx(P,{style:{color:c.text,fontSize:11},children:S})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,render:S=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:S})},{title:"Total Recibido",dataIndex:"totalRecibida",width:100,align:"right",sorter:(S,b)=>S.totalRecibida-b.totalRecibida,render:S=>l.jsx(P,{style:{color:c.green,fontWeight:600,fontSize:11},children:ne(S)})},{title:"KG Total",dataIndex:"totalKg",width:90,align:"right",sorter:(S,b)=>S.totalKg-b.totalKg,render:S=>l.jsx(P,{style:{color:c.accent,fontSize:11},children:ne(Math.round(S))})},{title:"Stock Actual",dataIndex:"stockActual",width:90,align:"right",render:S=>l.jsx(P,{style:{color:c.text,fontSize:11},children:ne(S)})},{title:"Días Stock",dataIndex:"diasStockActual",width:80,align:"right",sorter:(S,b)=>(S.diasStockActual||9999)-(b.diasStockActual||9999),render:S=>S!=null?l.jsxs(P,{style:{color:S<=7?c.red:S<=15?c.orange:c.text,fontWeight:600,fontSize:11},children:[S,"d"]}):l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"-"})},{title:"F. Recepción",dataIndex:"fechaUltimaRecepcion",width:100,render:S=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:j(S)})},{title:"Anomalía",dataIndex:"tieneAnomaliaIngreso",width:80,align:"center",render:S=>S?l.jsx(Ce,{color:"red",style:{fontSize:10},children:"⚠️ Sí"}):l.jsx(Ce,{color:"green",style:{fontSize:10},children:"✓ OK"})}]})]})},kn=()=>{const{anomaliasIngresoData:w}=u,j=m=>{if(!m)return"-";const S=m instanceof Date?m:new Date(m);return isNaN(S)?"-":S.toLocaleDateString("es-CL")};return!w||!w.length?l.jsx(de,{id:"anomaliasIngreso",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"No se detectaron anomalías de ingreso en los últimos 7 días"})})}):l.jsxs(de,{id:"anomaliasIngreso",extra:l.jsxs(Ce,{color:"red",style:{fontSize:11},children:["⚠️ ",w.length," anomalía(s) detectada(s)"]}),children:[l.jsx(rr,{message:"Anomalías de Ingreso Detectadas",description:"Un ingreso fue confirmado pero el stock actual es inferior al esperado. Esto puede indicar diferencias de inventario, errores de carga o ajustes pendientes.",type:"warning",showIcon:!0,style:{marginBottom:12,background:"#1a1200",border:"1px solid #5a3e00"}}),l.jsx(it,{dataSource:w,rowKey:"sku",size:"small",pagination:!1,columns:[{title:"SKU",dataIndex:"sku",width:120,render:m=>l.jsx(P,{style:{color:c.red,fontWeight:600,fontSize:11},children:m})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,render:m=>l.jsx(P,{style:{color:c.text,fontSize:11},children:m})},{title:"Confirmado",dataIndex:"totalConfirmado",width:90,align:"right",render:m=>l.jsxs(P,{style:{color:c.green,fontWeight:600,fontSize:11},children:["+",ne(m)]})},{title:"Stock Antes",dataIndex:"stockAntes",width:85,align:"right",render:m=>l.jsx(P,{style:{color:c.text,fontSize:11},children:ne(m)})},{title:"Salidas",dataIndex:"salidasPeriodo",width:70,align:"right",render:m=>l.jsx(P,{style:{color:c.orange,fontSize:11},children:ne(m)})},{title:"Stock Esperado",dataIndex:"stockEsperado",width:100,align:"right",render:m=>l.jsx(P,{style:{color:c.accent,fontWeight:600,fontSize:11},children:ne(m)})},{title:"Stock Real",dataIndex:"stockActual",width:80,align:"right",render:m=>l.jsx(P,{style:{color:c.red,fontWeight:600,fontSize:11},children:ne(m)})},{title:"Diferencia",dataIndex:"diferencia",width:80,align:"right",render:m=>l.jsx(P,{style:{color:c.red,fontWeight:700,fontSize:12},children:ne(m)})},{title:"F. Recepción",dataIndex:"fechaRecepcion",width:100,render:m=>l.jsx(P,{style:{color:c.textSec,fontSize:11},children:j(m)})}]})]})},Yn=()=>{const{aPedirData:w}=u;if(!w||!w.length)return l.jsx(de,{id:"aPedir",children:l.jsx(wt,{description:l.jsx("span",{style:{color:c.textSec},children:"No hay productos que necesiten pedirse para los próximos 30 días"})})});const j={};w.forEach(b=>
29{const D=`${b.codigoProveedor||"SIN_PROV"}_${b.nombreProveedor||"Sin Proveedor"}`;j[D]||(j[D]={key:`prov_${D}`,codigoProveedor:b.codigoProveedor,nombreProveedor:b.nombreProveedor,isProveedorRow:!0,itemsCount:0,stockExistente:0,pendienteIngreso:0,consumo30Dias:0,cantidadNecesaria:0,children:[]}),j[D].itemsCount++,j[D].stockExistente+=b.stockExistente||0,j[D].pendienteIngreso+=b.pendienteIngreso||0,j[D].consumo30Dias+=b.consumo30Dias||0,j[D].cantidadNecesaria+=b.cantidadNecesaria||0,j[D].children.push({...b,key:`item_${b.sku}`,isProveedorRow:!1})});const m=Object.values(j).sort((b,D)=>D.cantidadNecesaria-b.cantidadNecesaria);m.forEach(b=>{b.children.sort((D,te)=>te.cantidadNecesaria-D.cantidadNecesaria)});const S=async()=>{const b=await Do(),D=b.utils.book_new(),te=w.map(K=>({"Codigo Proveedor":K.codigoProveedor||"","Nombre Proveedor":K.nombreProveedor||"",SKU:K.sku,"Descripcion SKU":K.descripcion||"","Cantidad Existente":K.stockExistente,"Pendiente Ingreso":K.pendienteIngreso,"Consumo Est. 30 Dias":K.consumo30Dias,"Cantidad Necesaria":K.cantidadNecesaria,"Dias Stock Actual":K.diasStock!=null?Math.round(K.diasStock):"",Familia:K.familia||""})),A=b.utils.json_to_sheet(te);b.utils.book_append_sheet(D,A,"Todos_los_productos"),m.forEach(K=>{const ge=(K.nombreProveedor||K.codigoProveedor||"Sin Proveedor").replace(/[\\/?*[\]]/g,"").substring(0,31),ve=K.children.map(De=>({"Codigo Proveedor":De.codigoProveedor||"","Nombre Proveedor":De.nombreProveedor||"",SKU:De.sku,"Descripcion SKU":De.descripcion||"","Cantidad Existente":De.stockExistente,"Pendiente Ingreso":De.pendienteIngreso,"Consumo Est. 30 Dias":De.consumo30Dias,"Cantidad Necesaria":De.cantidadNecesaria,"Dias Stock Actual":De.diasStock!=null?Math.round(De.diasStock):"",Familia:De.familia||""})),Ie=b.utils.json_to_sheet(ve);let Ne=ge,mt=1;for(;D.SheetNames.includes(Ne);)Ne=`${ge.substring(0,28)}_${mt}`,mt++;b.utils.book_append_sheet(D,Ie,Ne)}),b.writeFile(D,`A_Pedir_30_Dias_${Cn().format("YYYYMMDD_HHmm")}.xlsx`),dt.success("Exportado correctamente en múltiples hojas")};return l.jsxs(de,{id:"aPedir",extra:l.jsxs(Ft,{children:[l.jsxs(Ce,{color:"blue",style:{fontSize:11},children:["🛒 ",w.length," productos | ",m.length," proveedores"]}),l.jsx(Fe,{size:"small",icon:l.jsx(tt,{}),style:{color:c.accent,borderColor:c.accent},onClick:S,children:"Excel"})]}),children:[l.jsx(rr,{message:"Necesidades de Compra - Próximos 30 días",description:"Productos que requieren reposición para cubrir el consumo estimado de 30 días y evitar quiebre de stock. Agrupado por proveedor.",type:"info",showIcon:!0,style:{marginBottom:12,background:"#001529",border:"1px solid #003a70"}}),l.jsx(it,{dataSource:m,rowKey:"key",size:"small",pagination:{pageSize:50,size:"small",showSizeChanger:!1},scroll:{x:900},expandable:{defaultExpandAllRows:!1},columns:[{title:"Cód. Prov.",dataIndex:"codigoProveedor",width:90,fixed:"left",render:(b,D)=>l.jsx(P,{style:{color:c.accent,fontWeight:D.isProveedorRow?700:600,fontSize:11},children:b||"-"})},{title:"Proveedor",dataIndex:"nombreProveedor",width:150,ellipsis:!0,render:(b,D)=>l.jsx(P,{style:{color:D.isProveedorRow?c.accent:c.text,fontWeight:D.isProveedorRow?700:400,fontSize:11},children:b||"-"})},{title:"SKU",dataIndex:"sku",width:100,render:(b,D)=>D.isProveedorRow?l.jsxs(Ce,{color:"blue",style:{fontSize:10,margin:0},children:[D.itemsCount," items"]}):l.jsx(P,{style:{color:c.text,fontWeight:500,fontSize:11},children:b})},{title:"Descripción",dataIndex:"descripcion",ellipsis:!0,render:(b,D)=>l.jsx(P,{style:{color:c.text,fontSize:11},children:D.isProveedorRow?"-":b||"-"})},{title:"Stock",dataIndex:"stockExistente",width:70,align:"right",render:(b,D)=>l.jsx(P,{style:{color:c.green,fontWeight:D.isProveedorRow?700:400,fontSize:11},children:ne(b)})},{title:"Pend.",dataIndex:"pendienteIngreso",width:60,align:"right",render:(b,D)=>b>0?l.jsxs(P,{style:{color:c.accent,fontWeight:D.isProveedorRow?700:400,fontSize:11},children:["+",ne(b)]}):l.jsx(P,{style:{color:c.textSec,fontSize:11},children:"-"})},{title:"Cons. 30d",dataIndex:"consumo30Dias",width:80,align:"right",render:(b,D)=>l.jsx(P,{style:{color:c.orange,fontWeight:D.isProveedorRow?700:400,fontSize:11},children:ne(b)})}
29,{title:"A Pedir",dataIndex:"cantidadNecesaria",width:80,align:"right",fixed:"right",render:(b,D)=>l.jsx(P,{style:{color:c.red,fontWeight:700,fontSize:D.isProveedorRow?13:12},children:ne(b)})},{title:"Días",dataIndex:"diasStock",width:50,align:"center",render:(b,D)=>D.isProveedorRow?l.jsx(P,{style:{color:c.textSec,fontSize:10},children:"-"}):b!=null?l.jsx(Ce,{color:b<=7?"red":b<=15?"orange":"blue",style:{fontSize:10,margin:0},children:Math.round(b)}):l.jsx(P,{style:{color:c.textSec,fontSize:10},children:"-"})}]})]})};return l.jsxs(Ca,{style:{minHeight:"100vh",background:c.bg},children:[l.jsxs("div",{style:{background:c.card,padding:"12px 24px",borderBottom:`1px solid ${c.border}`,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l.jsxs(Ft,{children:[l.jsx(Fe,{type:"text",icon:l.jsx($l,{}),style:{color:c.text},onClick:()=>e("/dashboard-aba")}),l.jsx(ba,{level:4,style:{margin:0,color:c.text},children:"📊 Análisis Abastecimiento"})]}),l.jsxs(Ft,{children:[l.jsx(Fe,{type:"primary",icon:l.jsx(Xr,{}),style:{background:c.accent,borderColor:c.accent,fontWeight:500},onClick:()=>ze(!0),children:"Preguntar IA"}),u&&l.jsx(Fe,{icon:l.jsx(Ul,{}),loading:xt,disabled:nt,style:Ze,onClick:Rt,children:"Informe PDF"}),u&&l.jsx(Fe,{icon:l.jsx(Hl,{}),loading:nt,disabled:xt,style:Ze,onClick:pe,children:"Generar PPT"}),u&&l.jsx(Fe,{icon:l.jsx(tt,{}),style:{color:c.accent,borderColor:c.accent},onClick:()=>Me(u.products.map(w=>({SKU:w.sku,Descripcion:w.descripcion,Familia:w.familia,Cantidad:w.cantidadFisica,CantidadNoVencida:w.cantidadNoVencida,Precio:w.precio,ValorStock:w.valorStock,ConsumoDiario:w.consumoDiario,DespachoDiario:w.despachoDiario,DiasStock:w.diasStockFinanciero,FillRate:w.fillRate,DiasVencer:w.diasParaVencer,PctVidaUtil:w.pctVidaUtil,Riesgo:w.riesgoVencimiento,ValorRiesgo:w.valorEnRiesgo,Rotacion:w.rotacion,Solicitado:w.solicitado,Despachado:w.despachado,ForecastMensual:w.forecastMensual})),"Analisis_Completo"),children:"Exportar Todo"})]})]}),l.jsx(tm,{style:{padding:16},children:l.jsxs(ft,{gutter:16,children:[l.jsx(Re,{xs:24,md:6,lg:5,children:l.jsxs(So,{size:"small",style:{background:c.card,border:`1px solid ${c.border}`,borderRadius:12,marginBottom:16,position:"sticky",top:16},headStyle:{background:c.card,borderBottom:`1px solid ${c.border}`,color:c.text},bodyStyle:{background:c.card,padding:14,maxHeight:"calc(100vh - 120px)",overflowY:"auto",overflowX:"hidden"},title:l.jsxs("span",{style:{color:c.text,fontSize:13},children:[l.jsx(Wl,{})," Filtros"]}),children:[l.jsxs("div",{style:{marginBottom:12},children:[l.jsx("div",{style:{color:c.textSec,fontSize:11,marginBottom:6},children:"Período de Análisis"}),l.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[{key:"30d",label:"30 Días"},{key:"60d",label:"60 Días"},{key:"90d",label:"90 Días"},{key:"year",label:"Este Año"}].map(w=>l.jsx(Fe,{size:"small",disabled:F||!N,type:X===w.key?"primary":"default",style:X===w.key?{background:c.accent,borderColor:c.accent,fontWeight:600,fontSize:11,flex:"1 1 auto"}:{background:c.bg,borderColor:c.border,color:c.textSec,fontSize:11,flex:"1 1 auto"},onClick:()=>Ve(w.key),children:w.label},w.key))}),F&&l.jsxs("div",{style:{marginTop:8,color:c.textSec,fontSize:11},children:[l.jsx(Ir,{size:"small",style:{marginRight:8}})," Obteniendo última fecha de stock…"]}),!F&&!J&&l.jsxs("div",{style:{marginTop:8,color:c.textSec,fontSize:11},children:[l.jsx(Ir,{size:"small",style:{marginRight:8}})," Catálogo de productos en segundo plano…"]}),!F&&N&&!t&&l.jsx("div",{style:{marginTop:8,color:c.orange,fontSize:10},children:"Elija un período para habilitar Analizar."})]}),l.jsxs("div",{style:{marginBottom:12},children:[l.jsx("div",{style:{color:c.textSec,fontSize:11,marginBottom:6},children:"Cadena"}),l.jsx(ko,{size:"small",style:{width:"100%"},placeholder:"Todas",allowClear:!0,value:r,onChange:i,options:[{value:"Burger King",label:"Burger King"},{value:"Starbucks",label:"Starbucks"}]})]}),l.jsxs("div",{style:{marginBottom:16},children:[l.jsx("div",{style:{color:c.textSec,fontSize:11,marginBottom:6},children:"Productos"}),l.jsx(ko,{size:"small",style:{width:"100%"},placeholder:J?"Buscar código o nombre...":"Cargando catálogo...",showSearch:!0,allowClear:!0,disabled:!J,loading:!J&&!F,filterOption:(w,j)=>j.label.toLowerCase().includes(w.toLowerCase()),value:void 0,onChange:w=>{w&&!a.includes(w)&&o(j=>[...j,w])},options:dn.filter(w=>!a.includes(w.value))})]}),l.jsx(Fe,{type:"primary",icon:l.jsx(bo,{}),block:!0,loading:h,disabled:F||!t,onClick:()=>Ct(),style:{background:c.accent,borderColor:c.accent,fontWeight:600},children:"Analizar"}),me.length>0&&l.jsxs("div",{style:{marginTop:12},children:[l.jsx("div",{style:{color:c.textSec,fontSize:11,marginBottom:6},children:"Filtros activos"}),me.map(w=>l.jsx(Ce,{closable:!!w.onClose,onClose:w.onClose,closeIcon:w.onClose?l.jsx(Da,{style:{color:c.red,fontSize:10}}):void 0,style:{background:c.bg,color:c.accent,borderColor:w.onClose?c.red:c.border,fontSize:10,marginBottom:4},children:w.label},w.key))]}),u&&l.jsxs("div",{style:{marginTop:16,borderTop:`1px solid ${c.border}`,paddingTop:12},children:[l.jsx("div",{style:{color:c.textSec,fontSize:11,marginBottom:8},children:"Tarjetas visibles"}),Qr.map(w=>l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[l.jsxs(P,{style:{color:c.textSec,fontSize:11},children:[w.icon," ",w.title]}),l.jsx(Kl,{size:"small",checked:!he.has(w.id),onChange:()=>He(w.id)})]},w.id))]})]})}),l.jsxs(Re,{xs:24,md:18,lg:19,children:[h&&l.jsxs("div",{style:{padding:"32px 16px 48px",maxWidth:720,margin:"0 auto"},children:[l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx(Ir,{size:"large"}),l.jsx("div",{style:{color:c.accent,fontSize:17,marginTop:20,fontWeight:600},children:y||"Iniciando…"}),l.jsxs("div",{style:{color:c.textSec,fontSize:13,marginTop:10,lineHeight:1.5},children:["Consultando Firestore (stock, movimientos, inventarios) y aplicando reglas de análisis.",l.jsx("br",{}),"En períodos largos el proceso puede tardar varios minutos; no cierre esta pestaña."]})]}),l.jsx(nr,{percent:100,status:"active",showInfo:!1,strokeColor:{"0%":c.accent,"100%":c.purple},style:{marginTop:28,maxWidth:400,marginLeft:"auto",marginRight:"auto"}}),l.jsx(ft,{gutter:[10,10],style:{marginTop:28},children:[[14,26,18,32,22,28,16],[20,14,30,18,24,12,22],[18,22,16,28,20,26,14]].map((w,j)=>l.jsx(Re,{xs:8,children:l.jsx("div",{style:{height:88,background:c.card,borderRadius:10,border:`1px solid ${c.border}`,display:"flex",alignItems:"flex-end",justifyContent:"center",gap:3,padding:"10px 8px"},children:w.map((m,S)=>l.jsx("div",{style:{width:5,height:m,borderRadius:2,background:`linear-gradient(180deg, ${c.accent}, ${c.blue})`,transformOrigin:"bottom",animation:`analisisLoadBar 0.9s ease-in-out ${(j*7+S)*.06}s infinite alternate`}},S))})},j))})]}),!h&&!u&&l.jsxs("div",{style:{textAlign:"center",padding:"80px 24px"},children:[l.jsx("div",{style:{fontSize:64,marginBottom:16},children:"📊"}),l.jsx(ba,{level:3,style:{color:c.text},children:"Análisis de Abastecimiento"}),F?l.jsxs(l.Fragment,{children:[l.jsx(Ir,{size:"large",style:{marginBottom:16}}),l.jsx(P,{style:{color:c.textSec,fontSize:15,display:"block"},children:"Obteniendo última fecha de stock…"})]}):l.jsxs(l.Fragment,{children:[l.jsxs(P,{style:{color:c.textSec,fontSize:15,display:"block",marginBottom:8},children:["Elija ",l.jsx("strong",{style:{color:c.text},children:"período"})," (30, 60, 90 días o este año), opcionalmente ",l.jsx("strong",{style:{color:c.text},children:"cadena"})," y ",l.jsx("strong",{style:{color:c.text},children:"productos"}),", luego pulse ",l.jsx("strong",{style:{color:c.accent},children:"Analizar"}),"."]}),l.jsx(P,{style:{color:c.textSec,fontSize:13,display:"block",marginBottom:24},children:t&&sr[X]?`${sr[X]} · ${t[0].format("DD/MM/YYYY")} — ${t[1].format("DD/MM/YYYY")}`:N?"Seleccione un período en el panel izquierdo.":"No hay datos de stock para fijar el período."}),l.jsx(Fe,{type:"primary",size:"large",icon:l.jsx(bo,{}),style:{background:c.accent,borderColor:c.accent},disabled:F||!t,onClick:()=>Ct(),children:"Analizar"})]})]}),!h&&u&&l.jsx("div",{ref:v,children:G.filter(w=>!he.has(w)).map(w=>l.jsx("div",{children:Oe(w)},w))})]})]})}),l.jsx("style",{children:`
30        @keyframes analisisLoadBar {
31          from { transform: scaleY(0.2); opacity: 0.35; }
32          to { transform: scaleY(1); opacity: 1; }
33        }
34        .ant-table { background: transparent !important; }
35        .ant-table-thead > tr > th { background: ${c.bg} !important; color: ${c.textSec} !important; border-bottom: 1px solid ${c.border} !important; font-size: 11px !important; padding: 6px 8px !important; }
36        .ant-table-tbody > tr > td { border-bottom: 1px solid ${c.border} !important; padding: 5px 8px !important; background: transparent !important; }
37        .ant-table-tbody > tr:hover > td { background: ${c.cardHover} !important; }
38        .ant-empty-description { color: ${c.textSec} !important; }
39        .ant-pagination .ant-pagination-item a { color: ${c.textSec} !important; }
40        .ant-pagination .ant-pagination-item-active a { color: ${c.accent} !important; }
41        .ant-select-selector { background: ${c.bg} !important; border-color: ${c.border} !important; color: ${c.text} !important; }
42        .ant-select-selection-placeholder { color: ${c.textSec} !important; }
43        .ant-picker { background: ${c.bg} !important; border-color: ${c.border} !important; }
44        .ant-picker input { color: ${c.text} !important; }
45        .ant-select-selection-item { color: ${c.text} !important; }
46        .ant-table-cell-row-hover { background: ${c.cardHover} !important; }
47      `}),l.jsx(Rp,{visible:Ae,onClose:()=>ze(!1)})]})};export{hm as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.