@llamaindex/workflow-debugger 0.2.26 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.css +1 -1
- package/dist/app.js +4 -4
- package/package.json +3 -3
package/dist/app.js
CHANGED
|
@@ -266,7 +266,7 @@ Error generating stack: `+S.message+`
|
|
|
266
266
|
*
|
|
267
267
|
* This source code is licensed under the ISC license.
|
|
268
268
|
* See the LICENSE file in the root directory of this source tree.
|
|
269
|
-
*/const KG=bn("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var Sx=rEe,XG=aEe,QG=({label:t,badge:e,icon:n})=>A.jsxs("span",{className:"flex w-full items-center gap-2",children:[A.jsx("span",{className:"flex-1 truncate",children:t}),e&&A.jsx("span",{className:"flex shrink-0",children:typeof e=="string"?A.jsx(_T,{variant:"secondary",label:e}):e}),BEe(n)]}),TT=t=>{var e=t,{ref:n,placeholder:r,badge:a,value:i,icon:o}=e,s=kn(e,["ref","placeholder","badge","value","icon"]);return A.jsxs(PG,Rr(jt({ref:n,className:"focus:ring-ring/50 flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 py-2 text-sm font-normal outline-none transition-all hover:border-ring focus:border-ring focus:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1 [&>span]:overflow-ellipsis [&>span]:whitespace-nowrap"},s),{children:[A.jsx("div",{className:"flex flex-1 overflow-hidden text-left [&>span]:w-full",children:i?A.jsx(XG,{placeholder:r,children:A.jsx(QG,{label:i,badge:a,icon:o})}):A.jsx(XG,{placeholder:r})}),A.jsx("div",{className:"flex shrink-0 items-center gap-2",children:A.jsx(iEe,{asChild:!0,children:A.jsx(bx,{className:"size-4 shrink-0 opacity-50"})})})]}))};TT.displayName=PG.displayName;var ZG=t=>{var e=t,{ref:n}=e,r=kn(e,["ref"]);return A.jsx(UG,Rr(jt({ref:n,className:"flex cursor-default items-center justify-center py-1"},r),{children:A.jsx(EEe,{className:"size-[15px]"})}))};ZG.displayName=UG.displayName;var JG=t=>{var e=t,{ref:n}=e,r=kn(e,["ref"]);return A.jsx(GG,Rr(jt({ref:n,className:"flex cursor-default items-center justify-center py-1"},r),{children:A.jsx(bx,{className:"size-[15px]"})}))};JG.displayName=GG.displayName;var CT=t=>{var e=t,{ref:n,children:r,position:a="popper"}=e,i=kn(e,["ref","children","position"]);return A.jsx(oEe,{children:A.jsxs(FG,Rr(jt({ref:n,className:a==="popper"?"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-80 relative max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1":"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-80 relative max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md",position:a},i),{children:[A.jsx(ZG,{}),A.jsx(sEe,{className:a==="popper"?"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] p-1":"p-1",children:r}),A.jsx(JG,{})]}))})};CT.displayName=FG.displayName,lEe.displayName;var BEe=t=>t?N.isValidElement(t)?A.jsx("div",{className:"flex shrink-0 items-center justify-center",children:t}):typeof t=="function"||typeof t=="object"&&!N.isValidElement(t)?N.createElement(t,{className:"size-4 shrink-0 text-muted-foreground group-focus:text-foreground","aria-hidden":"true"}):null:null,Gh=t=>{var e=t,{ref:n,label:r,caption:a,badge:i,icon:o}=e,s=kn(e,["ref","label","caption","badge","icon"]);return A.jsxs(BG,Rr(jt({ref:n,className:"group relative flex w-full cursor-default select-none items-start gap-2 rounded-sm py-1.5 pl-8 pr-2 text-sm font-normal outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50","da-cid":Gw(r)},s),{children:[A.jsx("span",{className:"absolute left-2 flex size-5 items-center justify-center",children:A.jsx(uEe,{children:A.jsx(yT,{className:"size-4"})})}),A.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[A.jsx(cEe,{children:A.jsx(QG,{label:r,badge:i,icon:o})}),a&&A.jsx("div",{className:"text-xs text-muted-foreground",children:typeof a=="string"?A.jsx("span",{className:"truncate",children:a}):a})]})]}))};Gh.displayName=BG.displayName,dEe.displayName;var ez=["PageUp","PageDown"],tz=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],nz={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},zh="Slider",[vx,UEe,GEe]=h0(zh),[rz]=pa(zh,[GEe]),[zEe,AT]=rz(zh),az=N.forwardRef((t,e)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:s=!1,minStepsBetweenThumbs:l=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:m=()=>{},inverted:h=!1,form:E,...b}=t,y=N.useRef(new Set),v=N.useRef(0),T=o==="horizontal"?qEe:HEe,[w=[],I]=Xo({prop:d,defaultProp:u,onChange:q=>{var X;(X=[...y.current][v.current])==null||X.focus(),f(q)}}),x=N.useRef(w);function D(q){const j=QEe(w,q);P(q,j)}function M(q){P(q,v.current)}function F(){const q=x.current[v.current];w[v.current]!==q&&m(w)}function P(q,j,{commit:X}={commit:!1}){const B=tSe(i),W=nSe(Math.round((q-r)/i)*i+r,B),G=m0(W,[r,a]);I((Y=[])=>{const K=KEe(Y,G,j);if(eSe(K,l*i)){v.current=K.indexOf(G);const J=String(K)!==String(Y);return J&&X&&m(K),J?K:Y}else return Y})}return A.jsx(zEe,{scope:t.__scopeSlider,name:n,disabled:s,min:r,max:a,valueIndexToChangeRef:v,thumbs:y.current,values:w,orientation:o,form:E,children:A.jsx(vx.Provider,{scope:t.__scopeSlider,children:A.jsx(vx.Slot,{scope:t.__scopeSlider,children:A.jsx(T,{"aria-disabled":s,"data-disabled":s?"":void 0,...b,ref:e,onPointerDown:Le(b.onPointerDown,()=>{s||(x.current=w)}),min:r,max:a,inverted:h,onSlideStart:s?void 0:D,onSlideMove:s?void 0:M,onSlideEnd:s?void 0:F,onHomeKeyDown:()=>!s&&P(r,0,{commit:!0}),onEndKeyDown:()=>!s&&P(a,w.length-1,{commit:!0}),onStepKeyDown:({event:q,direction:j})=>{if(!s){const W=ez.includes(q.key)||q.shiftKey&&tz.includes(q.key)?10:1,G=v.current,Y=w[G],K=i*W*j;P(Y+K,G,{commit:!0})}}})})})})});az.displayName=zh;var[iz,oz]=rz(zh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),qEe=N.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:s,onSlideEnd:l,onStepKeyDown:u,...d}=t,[f,m]=N.useState(null),h=Rt(e,T=>m(T)),E=N.useRef(void 0),b=g0(a),y=b==="ltr",v=y&&!i||!y&&i;function C(T){const w=E.current||f.getBoundingClientRect(),I=[0,w.width],D=Cx(I,v?[n,r]:[r,n]);return E.current=w,D(T-w.left)}return A.jsx(iz,{scope:t.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:A.jsx(sz,{dir:b,"data-orientation":"horizontal",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:T=>{const w=C(T.clientX);o==null||o(w)},onSlideMove:T=>{const w=C(T.clientX);s==null||s(w)},onSlideEnd:()=>{E.current=void 0,l==null||l()},onStepKeyDown:T=>{const I=nz[v?"from-left":"from-right"].includes(T.key);u==null||u({event:T,direction:I?-1:1})}})})}),HEe=N.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:s,onStepKeyDown:l,...u}=t,d=N.useRef(null),f=Rt(e,d),m=N.useRef(void 0),h=!a;function E(b){const y=m.current||d.current.getBoundingClientRect(),v=[0,y.height],T=Cx(v,h?[r,n]:[n,r]);return m.current=y,T(b-y.top)}return A.jsx(iz,{scope:t.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:A.jsx(sz,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const y=E(b.clientY);i==null||i(y)},onSlideMove:b=>{const y=E(b.clientY);o==null||o(y)},onSlideEnd:()=>{m.current=void 0,s==null||s()},onStepKeyDown:b=>{const v=nz[h?"from-bottom":"from-top"].includes(b.key);l==null||l({event:b,direction:v?-1:1})}})})}),sz=N.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:s,onStepKeyDown:l,...u}=t,d=AT(zh,n);return A.jsx(pt.span,{...u,ref:e,onKeyDown:Le(t.onKeyDown,f=>{f.key==="Home"?(o(f),f.preventDefault()):f.key==="End"?(s(f),f.preventDefault()):ez.concat(tz).includes(f.key)&&(l(f),f.preventDefault())}),onPointerDown:Le(t.onPointerDown,f=>{const m=f.target;m.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(m)?m.focus():r(f)}),onPointerMove:Le(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Le(t.onPointerUp,f=>{const m=f.target;m.hasPointerCapture(f.pointerId)&&(m.releasePointerCapture(f.pointerId),i(f))})})}),lz="SliderTrack",$Ee=N.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=AT(lz,n);return A.jsx(pt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});$Ee.displayName=lz;var yx="SliderRange",YEe=N.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=AT(yx,n),i=oz(yx,n),o=N.useRef(null),s=Rt(e,o),l=a.values.length,u=a.values.map(m=>uz(m,a.min,a.max)),d=l>1?Math.min(...u):0,f=100-Math.max(...u);return A.jsx(pt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:s,style:{...t.style,[i.startEdge]:d+"%",[i.endEdge]:f+"%"}})});YEe.displayName=yx;var Tx="SliderThumb",VEe=N.forwardRef((t,e)=>{const n=UEe(t.__scopeSlider),[r,a]=N.useState(null),i=Rt(e,s=>a(s)),o=N.useMemo(()=>r?n().findIndex(s=>s.ref.current===r):-1,[n,r]);return A.jsx(jEe,{...t,ref:i,index:o})}),jEe=N.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=AT(Tx,n),s=oz(Tx,n),[l,u]=N.useState(null),d=Rt(e,C=>u(C)),f=l?o.form||!!l.closest("form"):!0,m=nx(l),h=o.values[r],E=h===void 0?0:uz(h,o.min,o.max),b=XEe(r,o.values.length),y=m==null?void 0:m[s.size],v=y?ZEe(y,E,s.direction):0;return N.useEffect(()=>{if(l)return o.thumbs.add(l),()=>{o.thumbs.delete(l)}},[l,o.thumbs]),A.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${E}% + ${v}px)`},children:[A.jsx(vx.ItemSlot,{scope:t.__scopeSlider,children:A.jsx(pt.span,{role:"slider","aria-label":t["aria-label"]||b,"aria-valuemin":o.min,"aria-valuenow":h,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:d,style:h===void 0?{display:"none"}:t.style,onFocus:Le(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),f&&A.jsx(cz,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:h},r)]})});VEe.displayName=Tx;var WEe="RadioBubbleInput",cz=N.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=N.useRef(null),i=Rt(a,r),o=dx(e);return N.useEffect(()=>{const s=a.current;if(!s)return;const l=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(o!==e&&d){const f=new Event("input",{bubbles:!0});d.call(s,e),s.dispatchEvent(f)}},[o,e]),A.jsx(pt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});cz.displayName=WEe;function KEe(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function uz(t,e,n){const i=100/(n-e)*(t-e);return m0(i,[0,100])}function XEe(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function QEe(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),r=Math.min(...n);return n.indexOf(r)}function ZEe(t,e,n){const r=t/2,i=Cx([0,50],[0,r]);return(r-i(e)*n)*n}function JEe(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function eSe(t,e){if(e>0){const n=JEe(t);return Math.min(...n)>=e}return!0}function Cx(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function tSe(t){return(String(t).split(".")[1]||"").length}function nSe(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var rSe=az;rSe.displayName;function RT(){return RT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},RT.apply(null,arguments)}function dz(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var aSe=N.useLayoutEffect,iSe=function(e){var n=Ie.useRef(e);return aSe(function(){n.current=e}),n},pz=function(e,n){if(typeof e=="function"){e(n);return}e.current=n},oSe=function(e,n){var r=Ie.useRef();return Ie.useCallback(function(a){e.current=a,r.current&&pz(r.current,null),r.current=n,n&&pz(n,a)},[n])},fz={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},sSe=function(e){Object.keys(fz).forEach(function(n){e.style.setProperty(n,fz[n],"important")})},mz=sSe,mi=null,hz=function(e,n){var r=e.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function lSe(t,e,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),mi||(mi=document.createElement("textarea"),mi.setAttribute("tabindex","-1"),mi.setAttribute("aria-hidden","true"),mz(mi)),mi.parentNode===null&&document.body.appendChild(mi);var a=t.paddingSize,i=t.borderSize,o=t.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(m){var h=m;mi.style[h]=o[h]}),mz(mi),mi.value=e;var l=hz(mi,t);mi.value=e,l=hz(mi,t),mi.value="x";var u=mi.scrollHeight-a,d=u*n;s==="border-box"&&(d=d+a+i),l=Math.max(d,l);var f=u*r;return s==="border-box"&&(f=f+a+i),l=Math.min(f,l),[l,u]}var gz=function(){},cSe=function(e,n){return e.reduce(function(r,a){return r[a]=n[a],r},{})},uSe=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],dSe=!!document.documentElement.currentStyle,pSe=function(e){var n=window.getComputedStyle(e);if(n===null)return null;var r=cSe(uSe,n),a=r.boxSizing;if(a==="")return null;dSe&&a==="border-box"&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var i=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),o=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:i,borderSize:o}},fSe=pSe;function Ax(t,e,n){var r=iSe(n);N.useLayoutEffect(function(){var a=function(o){return r.current(o)};if(t)return t.addEventListener(e,a),function(){return t.removeEventListener(e,a)}},[])}var mSe=function(e,n){Ax(document.body,"reset",function(r){e.current.form===r.target&&n(r)})},hSe=function(e){Ax(window,"resize",e)},gSe=function(e){Ax(document.fonts,"loadingdone",e)},_Se=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],bSe=function(e,n){var r=e.cacheMeasurements,a=e.maxRows,i=e.minRows,o=e.onChange,s=o===void 0?gz:o,l=e.onHeightChange,u=l===void 0?gz:l,d=dz(e,_Se),f=d.value!==void 0,m=N.useRef(null),h=oSe(m,n),E=N.useRef(0),b=N.useRef(),y=function(){var T=m.current,w=r&&b.current?b.current:fSe(T);if(w){b.current=w;var I=lSe(w,T.value||T.placeholder||"x",i,a),x=I[0],D=I[1];E.current!==x&&(E.current=x,T.style.setProperty("height",x+"px","important"),u(x,{rowHeight:D}))}},v=function(T){f||y(),s(T)};return N.useLayoutEffect(y),mSe(m,function(){if(!f){var C=m.current.value;requestAnimationFrame(function(){var T=m.current;T&&C!==T.value&&y()})}}),hSe(y),gSe(y),N.createElement("textarea",RT({},d,{onChange:v,ref:h}))},ESe=N.forwardRef(bSe),SSe=Ps(["flex w-full resize-none rounded-md border border-input bg-background px-3 py-[6.5px] text-sm leading-normal shadow-xs transition-colors","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50","disabled:cursor-not-allowed disabled:opacity-50","aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive/20"],{variants:{variant:{default:"",error:"border-destructive focus-visible:ring-destructive/20"}},defaultVariants:{variant:"default"}}),wT=t=>{var e=t,{ref:n,variant:r,minRows:a=2,maxRows:i}=e,o=kn(e,["ref","variant","minRows","maxRows"]);return A.jsx(ESe,jt({className:Wt(SSe({variant:r}),i&&"overflow-y-auto"),ref:n,minRows:a,maxRows:i},o))};wT.displayName="Textarea";var[xT]=pa("Tooltip",[Tl]),NT=Tl(),_z="TooltipProvider",vSe=700,Rx="tooltip.open",[ySe,wx]=xT(_z),bz=t=>{const{__scopeTooltip:e,delayDuration:n=vSe,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:i}=t,o=N.useRef(!0),s=N.useRef(!1),l=N.useRef(0);return N.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),A.jsx(ySe,{scope:e,isOpenDelayedRef:o,delayDuration:n,onOpen:N.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:N.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:N.useCallback(u=>{s.current=u},[]),disableHoverableContent:a,children:i})};bz.displayName=_z;var b0="Tooltip",[TSe,E0]=xT(b0),Ez=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:s}=t,l=wx(b0,t.__scopeTooltip),u=NT(e),[d,f]=N.useState(null),m=bl(),h=N.useRef(0),E=o??l.disableHoverableContent,b=s??l.delayDuration,y=N.useRef(!1),[v,C]=Xo({prop:r,defaultProp:a??!1,onChange:D=>{D?(l.onOpen(),document.dispatchEvent(new CustomEvent(Rx))):l.onClose(),i==null||i(D)},caller:b0}),T=N.useMemo(()=>v?y.current?"delayed-open":"instant-open":"closed",[v]),w=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,C(!0)},[C]),I=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,C(!1)},[C]),x=N.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,C(!0),h.current=0},b)},[b,C]);return N.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),A.jsx(oT,{...u,children:A.jsx(TSe,{scope:e,contentId:m,open:v,stateAttribute:T,trigger:d,onTriggerChange:f,onTriggerEnter:N.useCallback(()=>{l.isOpenDelayedRef.current?x():w()},[l.isOpenDelayedRef,x,w]),onTriggerLeave:N.useCallback(()=>{E?I():(window.clearTimeout(h.current),h.current=0)},[I,E]),onOpen:w,onClose:I,disableHoverableContent:E,children:n})})};Ez.displayName=b0;var xx="TooltipTrigger",Sz=N.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,a=E0(xx,n),i=wx(xx,n),o=NT(n),s=N.useRef(null),l=Rt(e,s,a.onTriggerChange),u=N.useRef(!1),d=N.useRef(!1),f=N.useCallback(()=>u.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),A.jsx(kh,{asChild:!0,...o,children:A.jsx(pt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:l,onPointerMove:Le(t.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),d.current=!0)}),onPointerLeave:Le(t.onPointerLeave,()=>{a.onTriggerLeave(),d.current=!1}),onPointerDown:Le(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Le(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Le(t.onBlur,a.onClose),onClick:Le(t.onClick,a.onClose)})})});Sz.displayName=xx;var Nx="TooltipPortal",[CSe,ASe]=xT(Nx,{forceMount:void 0}),vz=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:a}=t,i=E0(Nx,e);return A.jsx(CSe,{scope:e,forceMount:n,children:A.jsx(Fa,{present:n||i.open,children:A.jsx(d0,{asChild:!0,container:a,children:r})})})};vz.displayName=Nx;var qh="TooltipContent",yz=N.forwardRef((t,e)=>{const n=ASe(qh,t.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...i}=t,o=E0(qh,t.__scopeTooltip);return A.jsx(Fa,{present:r||o.open,children:o.disableHoverableContent?A.jsx(Tz,{side:a,...i,ref:e}):A.jsx(RSe,{side:a,...i,ref:e})})}),RSe=N.forwardRef((t,e)=>{const n=E0(qh,t.__scopeTooltip),r=wx(qh,t.__scopeTooltip),a=N.useRef(null),i=Rt(e,a),[o,s]=N.useState(null),{trigger:l,onClose:u}=n,d=a.current,{onPointerInTransitChange:f}=r,m=N.useCallback(()=>{s(null),f(!1)},[f]),h=N.useCallback((E,b)=>{const y=E.currentTarget,v={x:E.clientX,y:E.clientY},C=OSe(v,y.getBoundingClientRect()),T=ISe(v,C),w=DSe(b.getBoundingClientRect()),I=MSe([...T,...w]);s(I),f(!0)},[f]);return N.useEffect(()=>()=>m(),[m]),N.useEffect(()=>{if(l&&d){const E=y=>h(y,d),b=y=>h(y,l);return l.addEventListener("pointerleave",E),d.addEventListener("pointerleave",b),()=>{l.removeEventListener("pointerleave",E),d.removeEventListener("pointerleave",b)}}},[l,d,h,m]),N.useEffect(()=>{if(o){const E=b=>{const y=b.target,v={x:b.clientX,y:b.clientY},C=(l==null?void 0:l.contains(y))||(d==null?void 0:d.contains(y)),T=!kSe(v,o);C?m():T&&(m(),u())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[l,d,o,u,m]),A.jsx(Tz,{...t,ref:i})}),[wSe,xSe]=xT(b0,{isInside:!1}),NSe=H8("TooltipContent"),Tz=N.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...s}=t,l=E0(qh,n),u=NT(n),{onClose:d}=l;return N.useEffect(()=>(document.addEventListener(Rx,d),()=>document.removeEventListener(Rx,d)),[d]),N.useEffect(()=>{if(l.trigger){const f=m=>{const h=m.target;h!=null&&h.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),A.jsx(nf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:A.jsxs(c0,{"data-state":l.stateAttribute,...u,...s,ref:e,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[A.jsx(NSe,{children:r}),A.jsx(wSe,{scope:n,isInside:!0,children:A.jsx(L0e,{id:l.contentId,role:"tooltip",children:a||r})})]})})});yz.displayName=qh;var Cz="TooltipArrow",Az=N.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,a=NT(n);return xSe(Cz,n).isInside?null:A.jsx(u0,{...a,...r,ref:e})});Az.displayName=Cz;function OSe(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),a=Math.abs(e.right-t.x),i=Math.abs(e.left-t.x);switch(Math.min(n,r,a,i)){case i:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function ISe(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function DSe(t){const{top:e,right:n,bottom:r,left:a}=t;return[{x:a,y:e},{x:n,y:e},{x:n,y:r},{x:a,y:r}]}function kSe(t,e){const{x:n,y:r}=t;let a=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){const s=e[i],l=e[o],u=s.x,d=s.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-u)*(r-d)/(m-d)+u&&(a=!a)}return a}function MSe(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),LSe(e)}function LSe(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const a=t[r];for(;e.length>=2;){const i=e[e.length-1],o=e[e.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))e.pop();else break}e.push(a)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const a=t[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))n.pop();else break}n.push(a)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var PSe=bz,FSe=Ez,BSe=Sz,USe=vz,GSe=yz,zSe=Az,qSe=PSe,HSe=t=>{var e=t,{delayDuration:n=0}=e,r=kn(e,["delayDuration"]);return A.jsx(qSe,jt({"data-slot":"tooltip-provider",delayDuration:n},r))},$Se=({href:t,label:e="Link",external:n=!1})=>A.jsxs("a",{href:t,target:n?"_blank":void 0,rel:n?"noopener noreferrer":void 0,className:"inline-flex items-center gap-1 text-xs font-medium text-background underline","da-cid":Gw(e),children:[e,n&&A.jsx(TEe,{className:"size-3"})]}),Al=t=>{var e=t,{trigger:n,content:r,side:a,link:i,linkExternal:o=!1,linkLabel:s,delayDuration:l=0,sideOffset:u=6}=e,d=kn(e,["trigger","content","side","link","linkExternal","linkLabel","delayDuration","sideOffset"]);return A.jsx(HSe,{delayDuration:l,children:A.jsxs(FSe,Rr(jt({"data-slot":"tooltip"},d),{children:[A.jsx(BSe,{asChild:!0,"data-slot":"tooltip-trigger",children:n}),A.jsx(USe,{children:A.jsxs(GSe,{"data-slot":"tooltip-content",side:a,sideOffset:u,className:Wt("animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","z-50 flex max-w-xs flex-col items-center gap-1 rounded-md bg-foreground px-3 py-2 text-center text-xs text-background","[&_code]:bg-background/20 [&_code]:break-all [&_code]:rounded [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono"),children:[r,i&&A.jsx($Se,{href:i,label:s,external:o}),A.jsx(zSe,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})]}))})},YSe=Ps("flex flex-col gap-3 w-full",{variants:{variant:{integrated:"",standalone:""}},defaultVariants:{variant:"integrated"}}),Bs=({label:t,required:e=!1,optional:n=!1,icon:r,badge:a,tooltip:i,description:o,children:s,variant:l="integrated",htmlFor:u,"da-cid":d})=>A.jsxs("div",{className:YSe({variant:l}),"da-cid":d,children:[A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsxs("div",{className:"flex min-h-5 w-full items-center gap-2",children:[r&&A.jsx("div",{className:"flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-full",children:r}),A.jsxs("label",{htmlFor:u,className:"flex shrink-0 items-center text-sm font-medium",children:[A.jsx("span",{className:"text-foreground",children:t}),e&&A.jsx("span",{className:"text-[rgb(225,29,72)]",children:"*"})]}),n&&A.jsx("span",{className:"shrink-0 text-sm font-normal text-muted-foreground",children:"Optional"}),a,i&&A.jsx(Al,{trigger:A.jsx("div",{className:"flex size-4 shrink-0 cursor-pointer items-center justify-center text-muted-foreground hover:text-foreground [&>svg]:size-full",children:A.jsx(vEe,{})}),content:i})]}),o&&A.jsx("p",{className:"w-full whitespace-pre-wrap text-sm font-normal text-muted-foreground",children:o})]}),l==="integrated"&&s]});Bs.displayName="Label";var Rz=Ps(["flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm leading-none shadow-xs transition-colors","file:h-7 file:border-0 file:bg-transparent file:pe-2 file:text-sm file:font-medium","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50","disabled:cursor-not-allowed disabled:opacity-50","aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive/20"],{variants:{variant:{default:"",error:"border-destructive focus-visible:ring-destructive/20",warning:"border-warning focus-visible:ring-warning/20"}},defaultVariants:{variant:"default"}}),OT=t=>{var e=t,{ref:n,variant:r,type:a,icon:i}=e,o=kn(e,["ref","variant","type","icon"]);const[s,l]=N.useState(!1),[u,d]=N.useState(""),f=()=>{l(!s)},m=C=>{var T,w;const I=C.currentTarget.files;(T=I==null?void 0:I[0])!=null&&T.name?d(I[0].name):d(""),(w=o.onChange)==null||w.call(o,C)},h=a==="password"&&s?"text":a,E=a==="password",b=a==="file",y=!!i;if(b)return A.jsxs("label",{className:Wt(Rz({variant:r}),"flex h-9 w-full items-center gap-2 overflow-hidden rounded-md border border-input bg-background px-3 py-1 text-sm text-foreground transition-colors","focus-within:ring-ring/50 focus-within:outline-none focus-within:ring-[3px]","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50"),children:[A.jsx("input",jt({ref:n,type:"file",className:"sr-only",onChange:m},o)),A.jsx("button",{type:"button",className:"pointer-events-none flex flex-shrink-0 items-center justify-center px-1.5 py-px font-medium",tabIndex:-1,children:"Choose file"}),i&&A.jsx("div",{className:"relative flex h-4 w-4 flex-shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4",children:i}),A.jsx("span",{className:"relative line-clamp-1 flex-1 text-muted-foreground",children:u||"No file chosen"})]});const v=A.jsx("input",jt({className:Wt(Rz({variant:r}),y&&!b&&"pl-9",E&&"pr-10"),ref:n,type:h},o));return y||E?A.jsxs("div",{className:"group relative w-full",children:[i&&A.jsx("div",{className:Wt("pointer-events-none absolute top-1/2 flex size-4 -translate-y-1/2 items-center justify-center text-muted-foreground [&>svg]:size-full","left-3"),children:i}),v,E&&A.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-focus-within:opacity-100 group-hover:opacity-100",onClick:f,tabIndex:-1,children:s?A.jsx(CEe,{className:"size-4"}):A.jsx(AEe,{className:"size-4"})})]}):v};OT.displayName="Input";var VSe=Ps("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 active:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",destructive:"border bg-background text-destructive shadow-xs hover:bg-accent hover:text-destructive focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",link:"text-primary underline-offset-4 hover:underline focus-visible:ring-ring/50 focus-visible:ring-[3px]"},size:{default:"h-9 px-3 py-2 gap-1.5",sm:"h-8 rounded-md gap-1.5 px-2",icon:"size-9","icon-sm":"size-8"},fullWidth:{true:"w-full"}},defaultVariants:{variant:"default",size:"default"}});function Xn(t){var e=t,{variant:n,size:r,fullWidth:a,label:i,startIcon:o,endIcon:s,isLoading:l,disabled:u,type:d="button"}=e,f=kn(e,["variant","size","fullWidth","label","startIcon","endIcon","isLoading","disabled","type"]);return A.jsxs("button",Rr(jt({type:d,"data-slot":"button",className:Wt(VSe({variant:n,size:r,fullWidth:a})),disabled:l||u,"da-cid":i?Gw(i):void 0},f),{children:[l?A.jsx(jG,{className:"animate-spin"}):o,i&&A.jsx("span",{className:Wt(r==="icon"||r==="icon-sm"?"sr-only":void 0),children:i}),!l&&s]}))}var wz=t=>{var e=t,{ref:n,disableOverflowWrapper:r}=e,a=kn(e,["ref","disableOverflowWrapper"]);const i=A.jsx("table",jt({ref:n,className:"w-full text-sm"},a));return r?i:A.jsx("div",{className:"relative w-full overflow-auto",children:i})};wz.displayName="Table";var xz=t=>{var e=t,{ref:n,sticky:r}=e,a=kn(e,["ref","sticky"]);return A.jsx("thead",jt({ref:n,className:Wt("[&_tr]:border-b [&_tr]:hover:bg-transparent",r&&"sticky top-0 z-10 bg-background")},a))};xz.displayName="TableHeader";var Nz=t=>{var e=t,{ref:n}=e,r=kn(e,["ref"]);return A.jsx("tbody",jt({ref:n,className:"[&_tr:last-child]:border-0"},r))};Nz.displayName="TableBody";var jSe=Ps("border-b transition-colors data-[state=selected]:bg-muted",{variants:{state:{default:"",hover:"hover:bg-muted/50"},isDraggingOver:{true:"border-t-2 border-t-blue-600 bg-blue-50/30",false:""},isDropZone:{true:"transition-all border-t-2",false:""},isLastItemDraggingBehind:{true:"border-b-2 border-b-blue-600",false:""}},compoundVariants:[{isDraggingOver:!0,isDropZone:!1,class:"opacity-50"},{isDropZone:!0,isDraggingOver:!1,class:"border-t-transparent"},{isDropZone:!0,isDraggingOver:!0,class:"border-t-blue-600 bg-blue-50/30"}],defaultVariants:{state:"default",isDraggingOver:!1,isDropZone:!1,isLastItemDraggingBehind:!1}}),Ox=t=>{var e=t,{ref:n,state:r,isDraggingOver:a,isDropZone:i,isLastItemDraggingBehind:o,draggable:s}=e,l=kn(e,["ref","state","isDraggingOver","isDropZone","isLastItemDraggingBehind","draggable"]);return A.jsx("tr",jt({ref:n,draggable:s,className:Wt(jSe({state:r,isDraggingOver:a,isDropZone:i,isLastItemDraggingBehind:o}),s&&"cursor-grab transition-all duration-200 ease-in-out")},l))};Ox.displayName="TableRow";var WSe=Ps("h-11 px-3 align-middle font-medium text-foreground [&:has([role=checkbox])]:pr-0 [&>div]:flex [&>div]:items-center [&>div]:gap-2 [&_svg]:size-4 [&_svg]:shrink-0 [&_button]:-ml-2 [&_button]:px-2",{variants:{alignment:{left:"text-left [&>div]:justify-start",center:"text-center [&>div]:justify-center",right:"text-right [&>div]:justify-start [&>div]:flex-row-reverse"}},defaultVariants:{alignment:"left"}}),Ix=t=>{var e=t,{ref:n,alignment:r,label:a,icon:i,badge:o,tooltip:s}=e,l=kn(e,["ref","alignment","label","icon","badge","tooltip"]);return A.jsx("th",Rr(jt({ref:n,className:WSe({alignment:r})},l),{children:A.jsxs("div",{children:[i,a,typeof o=="string"?A.jsx(_T,{variant:"secondary",label:o}):o,s&&A.jsx(Al,{trigger:A.jsx(REe,{className:"size-4 text-muted-foreground"}),content:s})]})}))};Ix.displayName="TableHead";var Oz=Ps("p-2 px-3 align-middle [&:has([role=checkbox])]:pr-0 [&>div]:flex [&>div]:items-center [&>div]:gap-2",{variants:{alignment:{left:"text-left [&>div]:justify-start",center:"text-center [&>div]:justify-center",right:"text-right [&>div]:justify-start [&>div]:flex-row-reverse"},strong:{true:"font-semibold",false:"font-normal"}},defaultVariants:{alignment:"left",strong:!1}}),Iz=t=>{var e=t,{ref:n,alignment:r,strong:a,badge:i,label:o}=e,s=kn(e,["ref","alignment","strong","badge","label"]);return A.jsx("td",Rr(jt({ref:n,className:Oz({alignment:r,strong:a})},s),{children:A.jsxs("div",{children:[o,typeof i=="string"?A.jsx(_T,{variant:"secondary",label:i}):i]})}))};Iz.displayName="TableCell";var Dz=t=>{var e=t,{ref:n,className:r,alignment:a,strong:i,children:o}=e,s=kn(e,["ref","className","alignment","strong","children"]);return A.jsx("td",Rr(jt({ref:n,className:Wt(Oz({alignment:a,strong:i}),r)},s),{children:A.jsx("div",{children:o})}))};Dz.displayName="CustomTableCell";function Dx(t,e,n,r,a){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}function S0(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)}let kz=function(){const{crypto:t}=globalThis;if(t!=null&&t.randomUUID)return kz=t.randomUUID.bind(t),t.randomUUID();const e=new Uint8Array(1),n=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};function KSe(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const kx=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){const e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};class sf extends Error{}class hi extends sf{constructor(e,n,r,a){super(`${hi.makeMessage(e,n,r)}`),this.status=e,this.headers=a,this.error=n}static makeMessage(e,n,r){const a=n!=null&&n.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return e&&a?`${e} ${a}`:e?`${e} status code (no body)`:a||"(no status code or body)"}static generate(e,n,r,a){if(!e||!a)return new IT({message:r,cause:kx(n)});const i=n;return e===400?new Lz(e,i,r,a):e===401?new Pz(e,i,r,a):e===403?new Fz(e,i,r,a):e===404?new Bz(e,i,r,a):e===409?new Uz(e,i,r,a):e===422?new Gz(e,i,r,a):e===429?new zz(e,i,r,a):e>=500?new qz(e,i,r,a):new hi(e,i,r,a)}}class Mx extends hi{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class IT extends hi{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class Mz extends IT{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Lz extends hi{}class Pz extends hi{}class Fz extends hi{}class Bz extends hi{}class Uz extends hi{}class Gz extends hi{}class zz extends hi{}class qz extends hi{}const XSe=/^[a-z][a-z0-9+.-]*:/i,QSe=t=>XSe.test(t);let Oi=t=>(Oi=Array.isArray,Oi(t)),Hz=Oi;function Hh(t){return typeof t!="object"?{}:t??{}}function ZSe(t){if(!t)return!0;for(const e in t)return!1;return!0}function JSe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const eve=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new sf(`${t} must be an integer`);if(e<0)throw new sf(`${t} must be a positive integer`);return e},tve=t=>{try{return JSON.parse(t)}catch{return}},nve=t=>new Promise(e=>setTimeout(e,t)),$h="1.2.0";function rve(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const ave=()=>{var n;const t=rve();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":Yz(Deno.build.os),"X-Stainless-Arch":$z(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:((n=Deno.version)==null?void 0:n.deno)??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":Yz(globalThis.process.platform??"unknown"),"X-Stainless-Arch":$z(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=ive();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ive(){if(typeof navigator>"u"||!navigator)return null;const t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:n}of t){const r=n.exec(navigator.userAgent);if(r){const a=r[1]||0,i=r[2]||0,o=r[3]||0;return{browser:e,version:`${a}.${i}.${o}`}}}return null}const $z=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",Yz=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown");let Vz;const ove=()=>Vz??(Vz=ave());function sve(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new LlamaCloud({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function lve(...t){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function jz(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return lve({start(){},async pull(n){const{done:r,value:a}=await e.next();r?n.close():n.enqueue(a)},async cancel(){var n;await((n=e.return)==null?void 0:n.call(e))}})}async function cve(t){var r,a;if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await((a=(r=t[Symbol.asyncIterator]()).return)==null?void 0:a.call(r));return}const e=t.getReader(),n=e.cancel();e.releaseLock(),await n}const uve=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),Wz="RFC3986",Kz=t=>String(t),Xz={RFC1738:t=>String(t).replace(/%20/g,"+"),RFC3986:Kz},dve="RFC1738";let Lx=(t,e)=>(Lx=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Lx(t,e));const Rl=(()=>{const t=[];for(let e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t})(),Px=1024,pve=(t,e,n,r,a)=>{if(t.length===0)return t;let i=t;if(typeof t=="symbol"?i=Symbol.prototype.toString.call(t):typeof t!="string"&&(i=String(t)),n==="iso-8859-1")return escape(i).replace(/%u[0-9a-f]{4}/gi,function(s){return"%26%23"+parseInt(s.slice(2),16)+"%3B"});let o="";for(let s=0;s<i.length;s+=Px){const l=i.length>=Px?i.slice(s,s+Px):i,u=[];for(let d=0;d<l.length;++d){let f=l.charCodeAt(d);if(f===45||f===46||f===95||f===126||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||a===dve&&(f===40||f===41)){u[u.length]=l.charAt(d);continue}if(f<128){u[u.length]=Rl[f];continue}if(f<2048){u[u.length]=Rl[192|f>>6]+Rl[128|f&63];continue}if(f<55296||f>=57344){u[u.length]=Rl[224|f>>12]+Rl[128|f>>6&63]+Rl[128|f&63];continue}d+=1,f=65536+((f&1023)<<10|l.charCodeAt(d)&1023),u[u.length]=Rl[240|f>>18]+Rl[128|f>>12&63]+Rl[128|f>>6&63]+Rl[128|f&63]}o+=u.join("")}return o};function fve(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}function Qz(t,e){if(Oi(t)){const n=[];for(let r=0;r<t.length;r+=1)n.push(e(t[r]));return n}return e(t)}const Zz={brackets(t){return String(t)+"[]"},comma:"comma",indices(t,e){return String(t)+"["+e+"]"},repeat(t){return String(t)}},Jz=function(t,e){Array.prototype.push.apply(t,Oi(e)?e:[e])};let eq;const fa={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:pve,encodeValuesOnly:!1,format:Wz,formatter:Kz,indices:!1,serializeDate(t){return(eq??(eq=Function.prototype.call.bind(Date.prototype.toISOString)))(t)},skipNulls:!1,strictNullHandling:!1};function mve(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"}const Fx={};function tq(t,e,n,r,a,i,o,s,l,u,d,f,m,h,E,b,y,v){let C=t,T=v,w=0,I=!1;for(;(T=T.get(Fx))!==void 0&&!I;){const P=T.get(t);if(w+=1,typeof P<"u"){if(P===w)throw new RangeError("Cyclic object value");I=!0}typeof T.get(Fx)>"u"&&(w=0)}if(typeof u=="function"?C=u(e,C):C instanceof Date?C=m==null?void 0:m(C):n==="comma"&&Oi(C)&&(C=Qz(C,function(P){return P instanceof Date?m==null?void 0:m(P):P})),C===null){if(i)return l&&!b?l(e,fa.encoder,y,"key",h):e;C=""}if(mve(C)||fve(C)){if(l){const P=b?e:l(e,fa.encoder,y,"key",h);return[(E==null?void 0:E(P))+"="+(E==null?void 0:E(l(C,fa.encoder,y,"value",h)))]}return[(E==null?void 0:E(e))+"="+(E==null?void 0:E(String(C)))]}const x=[];if(typeof C>"u")return x;let D;if(n==="comma"&&Oi(C))b&&l&&(C=Qz(C,l)),D=[{value:C.length>0?C.join(",")||null:void 0}];else if(Oi(u))D=u;else{const P=Object.keys(C);D=d?P.sort(d):P}const M=s?String(e).replace(/\./g,"%2E"):String(e),F=r&&Oi(C)&&C.length===1?M+"[]":M;if(a&&Oi(C)&&C.length===0)return F+"[]";for(let P=0;P<D.length;++P){const q=D[P],j=typeof q=="object"&&typeof q.value<"u"?q.value:C[q];if(o&&j===null)continue;const X=f&&s?q.replace(/\./g,"%2E"):q,B=Oi(C)?typeof n=="function"?n(F,X):F:F+(f?"."+X:"["+X+"]");v.set(t,w);const W=new WeakMap;W.set(Fx,v),Jz(x,tq(j,B,n,r,a,i,o,s,n==="comma"&&b&&Oi(C)?null:l,u,d,f,m,h,E,b,y,W))}return x}function hve(t=fa){if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");const e=t.charset||fa.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=Wz;if(typeof t.format<"u"){if(!Lx(Xz,t.format))throw new TypeError("Unknown format option provided.");n=t.format}const r=Xz[n];let a=fa.filter;(typeof t.filter=="function"||Oi(t.filter))&&(a=t.filter);let i;if(t.arrayFormat&&t.arrayFormat in Zz?i=t.arrayFormat:"indices"in t?i=t.indices?"indices":"repeat":i=fa.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const o=typeof t.allowDots>"u"?t.encodeDotInKeys?!0:fa.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:fa.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:fa.allowEmptyArrays,arrayFormat:i,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:fa.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?fa.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:fa.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:fa.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:fa.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:fa.encodeValuesOnly,filter:a,format:n,formatter:r,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:fa.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:fa.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:fa.strictNullHandling}}function gve(t,e={}){let n=t;const r=hve(e);let a,i;typeof r.filter=="function"?(i=r.filter,n=i("",n)):Oi(r.filter)&&(i=r.filter,a=i);const o=[];if(typeof n!="object"||n===null)return"";const s=Zz[r.arrayFormat],l=s==="comma"&&r.commaRoundTrip;a||(a=Object.keys(n)),r.sort&&a.sort(r.sort);const u=new WeakMap;for(let m=0;m<a.length;++m){const h=a[m];r.skipNulls&&n[h]===null||Jz(o,tq(n[h],h,s,l,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,u))}const d=o.join(r.delimiter);let f=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),d.length>0?f+d:""}const DT={off:0,error:200,warn:300,info:400,debug:500},nq=(t,e,n)=>{if(t){if(JSe(DT,t))return t;io(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(DT))}`)}};function v0(){}function kT(t,e,n){return!e||DT[t]>DT[n]?v0:e[t].bind(e)}const _ve={error:v0,warn:v0,info:v0,debug:v0};let rq=new WeakMap;function io(t){const e=t.logger,n=t.logLevel??"off";if(!e)return _ve;const r=rq.get(e);if(r&&r[0]===n)return r[1];const a={error:kT("error",e,n),warn:kT("warn",e,n),info:kT("info",e,n),debug:kT("debug",e,n)};return rq.set(e,[n,a]),a}const lf=t=>(t.options&&(t.options={...t.options},delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,n])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);async function aq(t,e){const{response:n,requestLogID:r,retryOfRequestLogID:a,startTime:i}=e,o=await(async()=>{var f;if(n.status===204)return null;if(e.options.__binaryResponse)return n;const s=n.headers.get("content-type"),l=(f=s==null?void 0:s.split(";")[0])==null?void 0:f.trim();return(l==null?void 0:l.includes("application/json"))||(l==null?void 0:l.endsWith("+json"))?await n.json():await n.text()})();return io(t).debug(`[${r}] response parsed`,lf({retryOfRequestLogID:a,url:n.url,status:n.status,body:o,durationMs:Date.now()-i})),o}var y0;class MT extends Promise{constructor(e,n,r=aq){super(a=>{a(null)}),this.responsePromise=n,this.parseResponse=r,y0.set(this,void 0),Dx(this,y0,e)}_thenUnwrap(e){return new MT(S0(this,y0,"f"),this.responsePromise,async(n,r)=>e(await this.parseResponse(n,r),r))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:n}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(S0(this,y0,"f"),e))),this.parsedPromise}then(e,n){return this.parse().then(e,n)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}y0=new WeakMap;var LT;class Yh{constructor(e,n,r,a){LT.set(this,void 0),Dx(this,LT,e),this.options=a,this.response=n,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new sf("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await S0(this,LT,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(LT=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const n of e.getPaginatedItems())yield n}}class bve extends MT{constructor(e,n,r){super(e,n,async(a,i)=>new r(a,i.response,await aq(a,i),i.options))}async*[Symbol.asyncIterator](){const e=await this;for await(const n of e)yield n}}class Eve extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.files=r.files||[],this.total_count=r.total_count||0,this.offset=r.offset||0}getPaginatedItems(){return this.files??[]}nextPageRequestOptions(){const e=this.offset??0,n=this.getPaginatedItems().length,r=e+n,a=this.total_count;return a&&r<a?{...this.options,query:{...Hh(this.options.query),offset:r}}:null}}class iq extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.items=r.items||[],this.total_size=r.total_size||0}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){const e=this.options.query.offset??0,n=this.getPaginatedItems().length,r=e+n,a=this.total_size;return a&&r<a?{...this.options,query:{...Hh(this.options.query),offset:r}}:null}}class Sve extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.items=r.items||[],this.total=r.total||0,this.skip=r.skip||0}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){const e=this.skip??0,n=this.getPaginatedItems().length,r=e+n,a=this.total;return a&&r<a?{...this.options,query:{...Hh(this.options.query),skip:r}}:null}}class vve extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.documents=r.documents||[],this.total_count=r.total_count||0,this.offset=r.offset||0}getPaginatedItems(){return this.documents??[]}nextPageRequestOptions(){const e=this.offset??0,n=this.getPaginatedItems().length,r=e+n,a=this.total_count;return a&&r<a?{...this.options,query:{...Hh(this.options.query),skip:r}}:null}}class ud extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.items=r.items||[],this.next_page_token=r.next_page_token||""}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){const e=this.next_page_token;return e?{...this.options,query:{...Hh(this.options.query),page_token:e}}:null}}class oq extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.items=r.items||[],this.next_page_token=r.next_page_token||""}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){const e=this.next_page_token;return e?{...this.options,body:{...Hh(this.options.body),page_token:e}}:null}}const sq=()=>{var t;if(typeof File>"u"){const{process:e}=globalThis,n=typeof((t=e==null?void 0:e.versions)==null?void 0:t.node)=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(n?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function T0(t,e,n){return sq(),new File(t,e??"unknown_file",n)}function PT(t){return(typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"").split(/[\\/]/).pop()||void 0}const lq=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",C0=async(t,e)=>({...t,body:await Tve(t.body,e)}),cq=new WeakMap;function yve(t){const e=typeof t=="function"?t:t.fetch,n=cq.get(e);if(n)return n;const r=(async()=>{try{const a="Response"in e?e.Response:(await e("data:,")).constructor,i=new FormData;return i.toString()!==await new a(i).text()}catch{return!0}})();return cq.set(e,r),r}const Tve=async(t,e)=>{if(!await yve(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(t||{}).map(([r,a])=>Bx(n,r,a))),n},Cve=t=>t instanceof Blob&&"name"in t,Bx=async(t,e,n)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")t.append(e,String(n));else if(n instanceof Response)t.append(e,T0([await n.blob()],PT(n)));else if(lq(n))t.append(e,T0([await new Response(jz(n)).blob()],PT(n)));else if(Cve(n))t.append(e,n,PT(n));else if(Array.isArray(n))await Promise.all(n.map(r=>Bx(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,a])=>Bx(t,`${e}[${r}]`,a)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},uq=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",Ave=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&uq(t),Rve=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function wve(t,e,n){if(sq(),t=await t,Ave(t))return t instanceof File?t:T0([await t.arrayBuffer()],t.name);if(Rve(t)){const a=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),T0(await Ux(a),e,n)}const r=await Ux(t);if(e||(e=PT(t)),!(n!=null&&n.type)){const a=r.find(i=>typeof i=="object"&&"type"in i&&i.type);typeof a=="string"&&(n={...n,type:a})}return T0(r,e,n)}async function Ux(t){var n;let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(uq(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(lq(t))for await(const r of t)e.push(...await Ux(r));else{const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;throw new Error(`Unexpected data type: ${typeof t}${r?`; constructor: ${r}`:""}${xve(t)}`)}return e}function xve(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}class In{constructor(e){this._client=e}}function dq(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const pq=Object.freeze(Object.create(null)),je=((t=dq)=>function(n,...r){if(n.length===1)return n[0];let a=!1;const i=[],o=n.reduce((d,f,m)=>{var b;/[?#]/.test(f)&&(a=!0);const h=r[m];let E=(a?encodeURIComponent:t)(""+h);return m!==r.length&&(h==null||typeof h=="object"&&h.toString===((b=Object.getPrototypeOf(Object.getPrototypeOf(h.hasOwnProperty??pq)??pq))==null?void 0:b.toString))&&(E=h+"",i.push({start:d.length+f.length,length:E.length,error:`Value of type ${Object.prototype.toString.call(h).slice(8,-1)} is not a valid path parameter`})),d+f+(m===r.length?"":E)},""),s=o.split(/[?#]/,1)[0],l=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let u;for(;(u=l.exec(s))!==null;)i.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(i.sort((d,f)=>d.start-f.start),i.length>0){let d=0;const f=i.reduce((m,h)=>{const E=" ".repeat(h.start-d),b="^".repeat(h.length);return d=h.start+h.length,m+E+b},"");throw new sf(`Path parameters result in path with invalid segments:
|
|
269
|
+
*/const KG=bn("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);var Sx=rEe,XG=aEe,QG=({label:t,badge:e,icon:n})=>A.jsxs("span",{className:"flex w-full items-center gap-2",children:[A.jsx("span",{className:"flex-1 truncate",children:t}),e&&A.jsx("span",{className:"flex shrink-0",children:typeof e=="string"?A.jsx(_T,{variant:"secondary",label:e}):e}),BEe(n)]}),TT=t=>{var e=t,{ref:n,placeholder:r,badge:a,value:i,icon:o}=e,s=kn(e,["ref","placeholder","badge","value","icon"]);return A.jsxs(PG,Rr(jt({ref:n,className:"focus:ring-ring/50 flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 py-2 text-sm font-normal outline-none transition-all hover:border-ring focus:border-ring focus:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1 [&>span]:overflow-ellipsis [&>span]:whitespace-nowrap"},s),{children:[A.jsx("div",{className:"flex flex-1 overflow-hidden text-left [&>span]:w-full",children:i?A.jsx(XG,{placeholder:r,children:A.jsx(QG,{label:i,badge:a,icon:o})}):A.jsx(XG,{placeholder:r})}),A.jsx("div",{className:"flex shrink-0 items-center gap-2",children:A.jsx(iEe,{asChild:!0,children:A.jsx(bx,{className:"size-4 shrink-0 opacity-50"})})})]}))};TT.displayName=PG.displayName;var ZG=t=>{var e=t,{ref:n}=e,r=kn(e,["ref"]);return A.jsx(UG,Rr(jt({ref:n,className:"flex cursor-default items-center justify-center py-1"},r),{children:A.jsx(EEe,{className:"size-[15px]"})}))};ZG.displayName=UG.displayName;var JG=t=>{var e=t,{ref:n}=e,r=kn(e,["ref"]);return A.jsx(GG,Rr(jt({ref:n,className:"flex cursor-default items-center justify-center py-1"},r),{children:A.jsx(bx,{className:"size-[15px]"})}))};JG.displayName=GG.displayName;var CT=t=>{var e=t,{ref:n,children:r,position:a="popper"}=e,i=kn(e,["ref","children","position"]);return A.jsx(oEe,{children:A.jsxs(FG,Rr(jt({ref:n,className:a==="popper"?"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-80 relative max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1":"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-80 relative max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md",position:a},i),{children:[A.jsx(ZG,{}),A.jsx(sEe,{className:a==="popper"?"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] p-1":"p-1",children:r}),A.jsx(JG,{})]}))})};CT.displayName=FG.displayName,lEe.displayName;var BEe=t=>t?N.isValidElement(t)?A.jsx("div",{className:"flex shrink-0 items-center justify-center",children:t}):typeof t=="function"||typeof t=="object"&&!N.isValidElement(t)?N.createElement(t,{className:"size-4 shrink-0 text-muted-foreground group-focus:text-foreground","aria-hidden":"true"}):null:null,Gh=t=>{var e=t,{ref:n,label:r,caption:a,badge:i,icon:o}=e,s=kn(e,["ref","label","caption","badge","icon"]);return A.jsxs(BG,Rr(jt({ref:n,className:"group relative flex w-full cursor-default select-none items-start gap-2 rounded-sm py-1.5 pl-8 pr-2 text-sm font-normal outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50","da-cid":Gw(r)},s),{children:[A.jsx("span",{className:"absolute left-2 flex size-5 items-center justify-center",children:A.jsx(uEe,{children:A.jsx(yT,{className:"size-4"})})}),A.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[A.jsx(cEe,{children:A.jsx(QG,{label:r,badge:i,icon:o})}),a&&A.jsx("div",{className:"text-xs text-muted-foreground",children:typeof a=="string"?A.jsx("span",{className:"truncate",children:a}):a})]})]}))};Gh.displayName=BG.displayName,dEe.displayName;function AT(){return AT=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},AT.apply(null,arguments)}function ez(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var UEe=N.useLayoutEffect,GEe=function(e){var n=Ie.useRef(e);return UEe(function(){n.current=e}),n},tz=function(e,n){if(typeof e=="function"){e(n);return}e.current=n},zEe=function(e,n){var r=Ie.useRef();return Ie.useCallback(function(a){e.current=a,r.current&&tz(r.current,null),r.current=n,n&&tz(n,a)},[n])},nz={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},qEe=function(e){Object.keys(nz).forEach(function(n){e.style.setProperty(n,nz[n],"important")})},rz=qEe,mi=null,az=function(e,n){var r=e.scrollHeight;return n.sizingStyle.boxSizing==="border-box"?r+n.borderSize:r-n.paddingSize};function HEe(t,e,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),mi||(mi=document.createElement("textarea"),mi.setAttribute("tabindex","-1"),mi.setAttribute("aria-hidden","true"),rz(mi)),mi.parentNode===null&&document.body.appendChild(mi);var a=t.paddingSize,i=t.borderSize,o=t.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(m){var h=m;mi.style[h]=o[h]}),rz(mi),mi.value=e;var l=az(mi,t);mi.value=e,l=az(mi,t),mi.value="x";var u=mi.scrollHeight-a,d=u*n;s==="border-box"&&(d=d+a+i),l=Math.max(d,l);var f=u*r;return s==="border-box"&&(f=f+a+i),l=Math.min(f,l),[l,u]}var iz=function(){},$Ee=function(e,n){return e.reduce(function(r,a){return r[a]=n[a],r},{})},YEe=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],VEe=!!document.documentElement.currentStyle,jEe=function(e){var n=window.getComputedStyle(e);if(n===null)return null;var r=$Ee(YEe,n),a=r.boxSizing;if(a==="")return null;VEe&&a==="border-box"&&(r.width=parseFloat(r.width)+parseFloat(r.borderRightWidth)+parseFloat(r.borderLeftWidth)+parseFloat(r.paddingRight)+parseFloat(r.paddingLeft)+"px");var i=parseFloat(r.paddingBottom)+parseFloat(r.paddingTop),o=parseFloat(r.borderBottomWidth)+parseFloat(r.borderTopWidth);return{sizingStyle:r,paddingSize:i,borderSize:o}},WEe=jEe;function vx(t,e,n){var r=GEe(n);N.useLayoutEffect(function(){var a=function(o){return r.current(o)};if(t)return t.addEventListener(e,a),function(){return t.removeEventListener(e,a)}},[])}var KEe=function(e,n){vx(document.body,"reset",function(r){e.current.form===r.target&&n(r)})},XEe=function(e){vx(window,"resize",e)},QEe=function(e){vx(document.fonts,"loadingdone",e)},ZEe=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],JEe=function(e,n){var r=e.cacheMeasurements,a=e.maxRows,i=e.minRows,o=e.onChange,s=o===void 0?iz:o,l=e.onHeightChange,u=l===void 0?iz:l,d=ez(e,ZEe),f=d.value!==void 0,m=N.useRef(null),h=zEe(m,n),E=N.useRef(0),b=N.useRef(),y=function(){var T=m.current,w=r&&b.current?b.current:WEe(T);if(w){b.current=w;var I=HEe(w,T.value||T.placeholder||"x",i,a),x=I[0],D=I[1];E.current!==x&&(E.current=x,T.style.setProperty("height",x+"px","important"),u(x,{rowHeight:D}))}},v=function(T){f||y(),s(T)};return N.useLayoutEffect(y),KEe(m,function(){if(!f){var C=m.current.value;requestAnimationFrame(function(){var T=m.current;T&&C!==T.value&&y()})}}),XEe(y),QEe(y),N.createElement("textarea",AT({},d,{onChange:v,ref:h}))},eSe=N.forwardRef(JEe),tSe=Ps(["flex w-full resize-none rounded-md border border-input bg-background px-3 py-[6.5px] text-sm leading-normal shadow-xs transition-colors","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50","disabled:cursor-not-allowed disabled:opacity-50","aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive/20"],{variants:{variant:{default:"",error:"border-destructive focus-visible:ring-destructive/20"}},defaultVariants:{variant:"default"}}),RT=t=>{var e=t,{ref:n,variant:r,minRows:a=2,maxRows:i}=e,o=kn(e,["ref","variant","minRows","maxRows"]);return A.jsx(eSe,jt({className:Wt(tSe({variant:r}),i&&"overflow-y-auto"),ref:n,minRows:a,maxRows:i},o))};RT.displayName="Textarea";var oz=["PageUp","PageDown"],sz=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],lz={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},zh="Slider",[yx,nSe,rSe]=h0(zh),[cz]=pa(zh,[rSe]),[aSe,wT]=cz(zh),uz=N.forwardRef((t,e)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:s=!1,minStepsBetweenThumbs:l=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:m=()=>{},inverted:h=!1,form:E,...b}=t,y=N.useRef(new Set),v=N.useRef(0),T=o==="horizontal"?iSe:oSe,[w=[],I]=Xo({prop:d,defaultProp:u,onChange:q=>{var X;(X=[...y.current][v.current])==null||X.focus(),f(q)}}),x=N.useRef(w);function D(q){const j=mSe(w,q);P(q,j)}function M(q){P(q,v.current)}function F(){const q=x.current[v.current];w[v.current]!==q&&m(w)}function P(q,j,{commit:X}={commit:!1}){const B=bSe(i),W=ESe(Math.round((q-r)/i)*i+r,B),G=m0(W,[r,a]);I((Y=[])=>{const K=pSe(Y,G,j);if(_Se(K,l*i)){v.current=K.indexOf(G);const J=String(K)!==String(Y);return J&&X&&m(K),J?K:Y}else return Y})}return A.jsx(aSe,{scope:t.__scopeSlider,name:n,disabled:s,min:r,max:a,valueIndexToChangeRef:v,thumbs:y.current,values:w,orientation:o,form:E,children:A.jsx(yx.Provider,{scope:t.__scopeSlider,children:A.jsx(yx.Slot,{scope:t.__scopeSlider,children:A.jsx(T,{"aria-disabled":s,"data-disabled":s?"":void 0,...b,ref:e,onPointerDown:Le(b.onPointerDown,()=>{s||(x.current=w)}),min:r,max:a,inverted:h,onSlideStart:s?void 0:D,onSlideMove:s?void 0:M,onSlideEnd:s?void 0:F,onHomeKeyDown:()=>!s&&P(r,0,{commit:!0}),onEndKeyDown:()=>!s&&P(a,w.length-1,{commit:!0}),onStepKeyDown:({event:q,direction:j})=>{if(!s){const W=oz.includes(q.key)||q.shiftKey&&sz.includes(q.key)?10:1,G=v.current,Y=w[G],K=i*W*j;P(Y+K,G,{commit:!0})}}})})})})});uz.displayName=zh;var[dz,pz]=cz(zh,{startEdge:"left",endEdge:"right",size:"width",direction:1}),iSe=N.forwardRef((t,e)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:s,onSlideEnd:l,onStepKeyDown:u,...d}=t,[f,m]=N.useState(null),h=Rt(e,T=>m(T)),E=N.useRef(void 0),b=g0(a),y=b==="ltr",v=y&&!i||!y&&i;function C(T){const w=E.current||f.getBoundingClientRect(),I=[0,w.width],D=Ax(I,v?[n,r]:[r,n]);return E.current=w,D(T-w.left)}return A.jsx(dz,{scope:t.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:A.jsx(fz,{dir:b,"data-orientation":"horizontal",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:T=>{const w=C(T.clientX);o==null||o(w)},onSlideMove:T=>{const w=C(T.clientX);s==null||s(w)},onSlideEnd:()=>{E.current=void 0,l==null||l()},onStepKeyDown:T=>{const I=lz[v?"from-left":"from-right"].includes(T.key);u==null||u({event:T,direction:I?-1:1})}})})}),oSe=N.forwardRef((t,e)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:s,onStepKeyDown:l,...u}=t,d=N.useRef(null),f=Rt(e,d),m=N.useRef(void 0),h=!a;function E(b){const y=m.current||d.current.getBoundingClientRect(),v=[0,y.height],T=Ax(v,h?[r,n]:[n,r]);return m.current=y,T(b-y.top)}return A.jsx(dz,{scope:t.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1,children:A.jsx(fz,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const y=E(b.clientY);i==null||i(y)},onSlideMove:b=>{const y=E(b.clientY);o==null||o(y)},onSlideEnd:()=>{m.current=void 0,s==null||s()},onStepKeyDown:b=>{const v=lz[h?"from-bottom":"from-top"].includes(b.key);l==null||l({event:b,direction:v?-1:1})}})})}),fz=N.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:s,onStepKeyDown:l,...u}=t,d=wT(zh,n);return A.jsx(pt.span,{...u,ref:e,onKeyDown:Le(t.onKeyDown,f=>{f.key==="Home"?(o(f),f.preventDefault()):f.key==="End"?(s(f),f.preventDefault()):oz.concat(sz).includes(f.key)&&(l(f),f.preventDefault())}),onPointerDown:Le(t.onPointerDown,f=>{const m=f.target;m.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(m)?m.focus():r(f)}),onPointerMove:Le(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Le(t.onPointerUp,f=>{const m=f.target;m.hasPointerCapture(f.pointerId)&&(m.releasePointerCapture(f.pointerId),i(f))})})}),mz="SliderTrack",sSe=N.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=wT(mz,n);return A.jsx(pt.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:e})});sSe.displayName=mz;var Tx="SliderRange",lSe=N.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,a=wT(Tx,n),i=pz(Tx,n),o=N.useRef(null),s=Rt(e,o),l=a.values.length,u=a.values.map(m=>gz(m,a.min,a.max)),d=l>1?Math.min(...u):0,f=100-Math.max(...u);return A.jsx(pt.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:s,style:{...t.style,[i.startEdge]:d+"%",[i.endEdge]:f+"%"}})});lSe.displayName=Tx;var Cx="SliderThumb",cSe=N.forwardRef((t,e)=>{const n=nSe(t.__scopeSlider),[r,a]=N.useState(null),i=Rt(e,s=>a(s)),o=N.useMemo(()=>r?n().findIndex(s=>s.ref.current===r):-1,[n,r]);return A.jsx(uSe,{...t,ref:i,index:o})}),uSe=N.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:a,...i}=t,o=wT(Cx,n),s=pz(Cx,n),[l,u]=N.useState(null),d=Rt(e,C=>u(C)),f=l?o.form||!!l.closest("form"):!0,m=nx(l),h=o.values[r],E=h===void 0?0:gz(h,o.min,o.max),b=fSe(r,o.values.length),y=m==null?void 0:m[s.size],v=y?hSe(y,E,s.direction):0;return N.useEffect(()=>{if(l)return o.thumbs.add(l),()=>{o.thumbs.delete(l)}},[l,o.thumbs]),A.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${E}% + ${v}px)`},children:[A.jsx(yx.ItemSlot,{scope:t.__scopeSlider,children:A.jsx(pt.span,{role:"slider","aria-label":t["aria-label"]||b,"aria-valuemin":o.min,"aria-valuenow":h,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:d,style:h===void 0?{display:"none"}:t.style,onFocus:Le(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),f&&A.jsx(hz,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:h},r)]})});cSe.displayName=Cx;var dSe="RadioBubbleInput",hz=N.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const a=N.useRef(null),i=Rt(a,r),o=dx(e);return N.useEffect(()=>{const s=a.current;if(!s)return;const l=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(o!==e&&d){const f=new Event("input",{bubbles:!0});d.call(s,e),s.dispatchEvent(f)}},[o,e]),A.jsx(pt.input,{style:{display:"none"},...n,ref:i,defaultValue:e})});hz.displayName=dSe;function pSe(t=[],e,n){const r=[...t];return r[n]=e,r.sort((a,i)=>a-i)}function gz(t,e,n){const i=100/(n-e)*(t-e);return m0(i,[0,100])}function fSe(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function mSe(t,e){if(t.length===1)return 0;const n=t.map(a=>Math.abs(a-e)),r=Math.min(...n);return n.indexOf(r)}function hSe(t,e,n){const r=t/2,i=Ax([0,50],[0,r]);return(r-i(e)*n)*n}function gSe(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function _Se(t,e){if(e>0){const n=gSe(t);return Math.min(...n)>=e}return!0}function Ax(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const r=(e[1]-e[0])/(t[1]-t[0]);return e[0]+r*(n-t[0])}}function bSe(t){return(String(t).split(".")[1]||"").length}function ESe(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var SSe=uz;SSe.displayName;var[xT]=pa("Tooltip",[Tl]),NT=Tl(),_z="TooltipProvider",vSe=700,Rx="tooltip.open",[ySe,wx]=xT(_z),bz=t=>{const{__scopeTooltip:e,delayDuration:n=vSe,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:i}=t,o=N.useRef(!0),s=N.useRef(!1),l=N.useRef(0);return N.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),A.jsx(ySe,{scope:e,isOpenDelayedRef:o,delayDuration:n,onOpen:N.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:N.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:N.useCallback(u=>{s.current=u},[]),disableHoverableContent:a,children:i})};bz.displayName=_z;var b0="Tooltip",[TSe,E0]=xT(b0),Ez=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:s}=t,l=wx(b0,t.__scopeTooltip),u=NT(e),[d,f]=N.useState(null),m=bl(),h=N.useRef(0),E=o??l.disableHoverableContent,b=s??l.delayDuration,y=N.useRef(!1),[v,C]=Xo({prop:r,defaultProp:a??!1,onChange:D=>{D?(l.onOpen(),document.dispatchEvent(new CustomEvent(Rx))):l.onClose(),i==null||i(D)},caller:b0}),T=N.useMemo(()=>v?y.current?"delayed-open":"instant-open":"closed",[v]),w=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,C(!0)},[C]),I=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,C(!1)},[C]),x=N.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,C(!0),h.current=0},b)},[b,C]);return N.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),A.jsx(oT,{...u,children:A.jsx(TSe,{scope:e,contentId:m,open:v,stateAttribute:T,trigger:d,onTriggerChange:f,onTriggerEnter:N.useCallback(()=>{l.isOpenDelayedRef.current?x():w()},[l.isOpenDelayedRef,x,w]),onTriggerLeave:N.useCallback(()=>{E?I():(window.clearTimeout(h.current),h.current=0)},[I,E]),onOpen:w,onClose:I,disableHoverableContent:E,children:n})})};Ez.displayName=b0;var xx="TooltipTrigger",Sz=N.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,a=E0(xx,n),i=wx(xx,n),o=NT(n),s=N.useRef(null),l=Rt(e,s,a.onTriggerChange),u=N.useRef(!1),d=N.useRef(!1),f=N.useCallback(()=>u.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),A.jsx(kh,{asChild:!0,...o,children:A.jsx(pt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:l,onPointerMove:Le(t.onPointerMove,m=>{m.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),d.current=!0)}),onPointerLeave:Le(t.onPointerLeave,()=>{a.onTriggerLeave(),d.current=!1}),onPointerDown:Le(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Le(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Le(t.onBlur,a.onClose),onClick:Le(t.onClick,a.onClose)})})});Sz.displayName=xx;var Nx="TooltipPortal",[CSe,ASe]=xT(Nx,{forceMount:void 0}),vz=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:a}=t,i=E0(Nx,e);return A.jsx(CSe,{scope:e,forceMount:n,children:A.jsx(Fa,{present:n||i.open,children:A.jsx(d0,{asChild:!0,container:a,children:r})})})};vz.displayName=Nx;var qh="TooltipContent",yz=N.forwardRef((t,e)=>{const n=ASe(qh,t.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...i}=t,o=E0(qh,t.__scopeTooltip);return A.jsx(Fa,{present:r||o.open,children:o.disableHoverableContent?A.jsx(Tz,{side:a,...i,ref:e}):A.jsx(RSe,{side:a,...i,ref:e})})}),RSe=N.forwardRef((t,e)=>{const n=E0(qh,t.__scopeTooltip),r=wx(qh,t.__scopeTooltip),a=N.useRef(null),i=Rt(e,a),[o,s]=N.useState(null),{trigger:l,onClose:u}=n,d=a.current,{onPointerInTransitChange:f}=r,m=N.useCallback(()=>{s(null),f(!1)},[f]),h=N.useCallback((E,b)=>{const y=E.currentTarget,v={x:E.clientX,y:E.clientY},C=OSe(v,y.getBoundingClientRect()),T=ISe(v,C),w=DSe(b.getBoundingClientRect()),I=MSe([...T,...w]);s(I),f(!0)},[f]);return N.useEffect(()=>()=>m(),[m]),N.useEffect(()=>{if(l&&d){const E=y=>h(y,d),b=y=>h(y,l);return l.addEventListener("pointerleave",E),d.addEventListener("pointerleave",b),()=>{l.removeEventListener("pointerleave",E),d.removeEventListener("pointerleave",b)}}},[l,d,h,m]),N.useEffect(()=>{if(o){const E=b=>{const y=b.target,v={x:b.clientX,y:b.clientY},C=(l==null?void 0:l.contains(y))||(d==null?void 0:d.contains(y)),T=!kSe(v,o);C?m():T&&(m(),u())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[l,d,o,u,m]),A.jsx(Tz,{...t,ref:i})}),[wSe,xSe]=xT(b0,{isInside:!1}),NSe=H8("TooltipContent"),Tz=N.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...s}=t,l=E0(qh,n),u=NT(n),{onClose:d}=l;return N.useEffect(()=>(document.addEventListener(Rx,d),()=>document.removeEventListener(Rx,d)),[d]),N.useEffect(()=>{if(l.trigger){const f=m=>{const h=m.target;h!=null&&h.contains(l.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[l.trigger,d]),A.jsx(nf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:A.jsxs(c0,{"data-state":l.stateAttribute,...u,...s,ref:e,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[A.jsx(NSe,{children:r}),A.jsx(wSe,{scope:n,isInside:!0,children:A.jsx(L0e,{id:l.contentId,role:"tooltip",children:a||r})})]})})});yz.displayName=qh;var Cz="TooltipArrow",Az=N.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,a=NT(n);return xSe(Cz,n).isInside?null:A.jsx(u0,{...a,...r,ref:e})});Az.displayName=Cz;function OSe(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),a=Math.abs(e.right-t.x),i=Math.abs(e.left-t.x);switch(Math.min(n,r,a,i)){case i:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function ISe(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function DSe(t){const{top:e,right:n,bottom:r,left:a}=t;return[{x:a,y:e},{x:n,y:e},{x:n,y:r},{x:a,y:r}]}function kSe(t,e){const{x:n,y:r}=t;let a=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){const s=e[i],l=e[o],u=s.x,d=s.y,f=l.x,m=l.y;d>r!=m>r&&n<(f-u)*(r-d)/(m-d)+u&&(a=!a)}return a}function MSe(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),LSe(e)}function LSe(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const a=t[r];for(;e.length>=2;){const i=e[e.length-1],o=e[e.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))e.pop();else break}e.push(a)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const a=t[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))n.pop();else break}n.push(a)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var PSe=bz,FSe=Ez,BSe=Sz,USe=vz,GSe=yz,zSe=Az,qSe=PSe,HSe=t=>{var e=t,{delayDuration:n=0}=e,r=kn(e,["delayDuration"]);return A.jsx(qSe,jt({"data-slot":"tooltip-provider",delayDuration:n},r))},$Se=({href:t,label:e="Link",external:n=!1})=>A.jsxs("a",{href:t,target:n?"_blank":void 0,rel:n?"noopener noreferrer":void 0,className:"inline-flex items-center gap-1 text-xs font-medium text-background underline","da-cid":Gw(e),children:[e,n&&A.jsx(TEe,{className:"size-3"})]}),Al=t=>{var e=t,{trigger:n,content:r,side:a,link:i,linkExternal:o=!1,linkLabel:s,delayDuration:l=0,sideOffset:u=6}=e,d=kn(e,["trigger","content","side","link","linkExternal","linkLabel","delayDuration","sideOffset"]);return A.jsx(HSe,{delayDuration:l,children:A.jsxs(FSe,Rr(jt({"data-slot":"tooltip"},d),{children:[A.jsx(BSe,{asChild:!0,"data-slot":"tooltip-trigger",children:n}),A.jsx(USe,{children:A.jsxs(GSe,{"data-slot":"tooltip-content",side:a,sideOffset:u,className:Wt("animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","z-50 flex max-w-xs flex-col items-center gap-1 rounded-md bg-foreground px-3 py-2 text-center text-xs text-background","[&_code]:bg-background/20 [&_code]:break-all [&_code]:rounded [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono"),children:[r,i&&A.jsx($Se,{href:i,label:s,external:o}),A.jsx(zSe,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})]}))})},YSe=Ps("flex flex-col gap-3 w-full",{variants:{variant:{integrated:"",standalone:""}},defaultVariants:{variant:"integrated"}}),Bs=({label:t,required:e=!1,optional:n=!1,icon:r,badge:a,tooltip:i,description:o,children:s,variant:l="integrated",htmlFor:u,"da-cid":d})=>A.jsxs("div",{className:YSe({variant:l}),"da-cid":d,children:[A.jsxs("div",{className:"flex flex-col gap-1",children:[A.jsxs("div",{className:"flex min-h-5 w-full items-center gap-2",children:[r&&A.jsx("div",{className:"flex size-4 shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-full",children:r}),A.jsxs("label",{htmlFor:u,className:"flex shrink-0 items-center text-sm font-medium",children:[A.jsx("span",{className:"text-foreground",children:t}),e&&A.jsx("span",{className:"text-[rgb(225,29,72)]",children:"*"})]}),n&&A.jsx("span",{className:"shrink-0 text-sm font-normal text-muted-foreground",children:"Optional"}),a,i&&A.jsx(Al,{trigger:A.jsx("div",{className:"flex size-4 shrink-0 cursor-pointer items-center justify-center text-muted-foreground hover:text-foreground [&>svg]:size-full",children:A.jsx(vEe,{})}),content:i})]}),o&&A.jsx("p",{className:"w-full whitespace-pre-wrap text-sm font-normal text-muted-foreground",children:o})]}),l==="integrated"&&s]});Bs.displayName="Label";var Rz=Ps(["flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm leading-none shadow-xs transition-colors","file:h-7 file:border-0 file:bg-transparent file:pe-2 file:text-sm file:font-medium","placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50","disabled:cursor-not-allowed disabled:opacity-50","aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive/20"],{variants:{variant:{default:"",error:"border-destructive focus-visible:ring-destructive/20",warning:"border-warning focus-visible:ring-warning/20"}},defaultVariants:{variant:"default"}}),OT=t=>{var e=t,{ref:n,variant:r,type:a,icon:i}=e,o=kn(e,["ref","variant","type","icon"]);const[s,l]=N.useState(!1),[u,d]=N.useState(""),f=()=>{l(!s)},m=C=>{var T,w;const I=C.currentTarget.files;(T=I==null?void 0:I[0])!=null&&T.name?d(I[0].name):d(""),(w=o.onChange)==null||w.call(o,C)},h=a==="password"&&s?"text":a,E=a==="password",b=a==="file",y=!!i;if(b)return A.jsxs("label",{className:Wt(Rz({variant:r}),"flex h-9 w-full items-center gap-2 overflow-hidden rounded-md border border-input bg-background px-3 py-1 text-sm text-foreground transition-colors","focus-within:ring-ring/50 focus-within:outline-none focus-within:ring-[3px]","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50"),children:[A.jsx("input",jt({ref:n,type:"file",className:"sr-only",onChange:m},o)),A.jsx("button",{type:"button",className:"pointer-events-none flex flex-shrink-0 items-center justify-center px-1.5 py-px font-medium",tabIndex:-1,children:"Choose file"}),i&&A.jsx("div",{className:"relative flex h-4 w-4 flex-shrink-0 items-center justify-center text-muted-foreground [&>svg]:size-4",children:i}),A.jsx("span",{className:"relative line-clamp-1 flex-1 text-muted-foreground",children:u||"No file chosen"})]});const v=A.jsx("input",jt({className:Wt(Rz({variant:r}),y&&!b&&"pl-9",E&&"pr-10"),ref:n,type:h},o));return y||E?A.jsxs("div",{className:"group relative w-full",children:[i&&A.jsx("div",{className:Wt("pointer-events-none absolute top-1/2 flex size-4 -translate-y-1/2 items-center justify-center text-muted-foreground [&>svg]:size-full","left-3"),children:i}),v,E&&A.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-focus-within:opacity-100 group-hover:opacity-100",onClick:f,tabIndex:-1,children:s?A.jsx(CEe,{className:"size-4"}):A.jsx(AEe,{className:"size-4"})})]}):v};OT.displayName="Input";var VSe=Ps("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 active:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",destructive:"border bg-background text-destructive shadow-xs hover:bg-accent hover:text-destructive focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",link:"text-primary underline-offset-4 hover:underline focus-visible:ring-ring/50 focus-visible:ring-[3px]"},size:{default:"h-9 px-3 py-2 gap-1.5",sm:"h-8 rounded-md gap-1.5 px-2",icon:"size-9","icon-sm":"size-8"},fullWidth:{true:"w-full"}},defaultVariants:{variant:"default",size:"default"}});function Xn(t){var e=t,{variant:n,size:r,fullWidth:a,label:i,startIcon:o,endIcon:s,isLoading:l,disabled:u,type:d="button"}=e,f=kn(e,["variant","size","fullWidth","label","startIcon","endIcon","isLoading","disabled","type"]);return A.jsxs("button",Rr(jt({type:d,"data-slot":"button",className:Wt(VSe({variant:n,size:r,fullWidth:a})),disabled:l||u,"da-cid":i?Gw(i):void 0},f),{children:[l?A.jsx(jG,{className:"animate-spin"}):o,i&&A.jsx("span",{className:Wt(r==="icon"||r==="icon-sm"?"sr-only":void 0),children:i}),!l&&s]}))}var wz=t=>{var e=t,{ref:n,disableOverflowWrapper:r}=e,a=kn(e,["ref","disableOverflowWrapper"]);const i=A.jsx("table",jt({ref:n,className:"w-full text-sm"},a));return r?i:A.jsx("div",{className:"relative w-full overflow-auto",children:i})};wz.displayName="Table";var xz=t=>{var e=t,{ref:n,sticky:r}=e,a=kn(e,["ref","sticky"]);return A.jsx("thead",jt({ref:n,className:Wt("[&_tr]:border-b [&_tr]:hover:bg-transparent",r&&"sticky top-0 z-10 bg-background")},a))};xz.displayName="TableHeader";var Nz=t=>{var e=t,{ref:n}=e,r=kn(e,["ref"]);return A.jsx("tbody",jt({ref:n,className:"[&_tr:last-child]:border-0"},r))};Nz.displayName="TableBody";var jSe=Ps("border-b transition-colors data-[state=selected]:bg-muted",{variants:{state:{default:"",hover:"hover:bg-muted/50"},isDraggingOver:{true:"border-t-2 border-t-blue-600 bg-blue-50/30",false:""},isDropZone:{true:"transition-all border-t-2",false:""},isLastItemDraggingBehind:{true:"border-b-2 border-b-blue-600",false:""}},compoundVariants:[{isDraggingOver:!0,isDropZone:!1,class:"opacity-50"},{isDropZone:!0,isDraggingOver:!1,class:"border-t-transparent"},{isDropZone:!0,isDraggingOver:!0,class:"border-t-blue-600 bg-blue-50/30"}],defaultVariants:{state:"default",isDraggingOver:!1,isDropZone:!1,isLastItemDraggingBehind:!1}}),Ox=t=>{var e=t,{ref:n,state:r,isDraggingOver:a,isDropZone:i,isLastItemDraggingBehind:o,draggable:s}=e,l=kn(e,["ref","state","isDraggingOver","isDropZone","isLastItemDraggingBehind","draggable"]);return A.jsx("tr",jt({ref:n,draggable:s,className:Wt(jSe({state:r,isDraggingOver:a,isDropZone:i,isLastItemDraggingBehind:o}),s&&"cursor-grab transition-all duration-200 ease-in-out")},l))};Ox.displayName="TableRow";var WSe=Ps("h-11 px-3 align-middle font-medium text-foreground [&:has([role=checkbox])]:pr-0 [&>div]:flex [&>div]:items-center [&>div]:gap-2 [&_svg]:size-4 [&_svg]:shrink-0 [&_button]:-ml-2 [&_button]:px-2",{variants:{alignment:{left:"text-left [&>div]:justify-start",center:"text-center [&>div]:justify-center",right:"text-right [&>div]:justify-start [&>div]:flex-row-reverse"}},defaultVariants:{alignment:"left"}}),Ix=t=>{var e=t,{ref:n,alignment:r,label:a,icon:i,badge:o,tooltip:s}=e,l=kn(e,["ref","alignment","label","icon","badge","tooltip"]);return A.jsx("th",Rr(jt({ref:n,className:WSe({alignment:r})},l),{children:A.jsxs("div",{children:[i,a,typeof o=="string"?A.jsx(_T,{variant:"secondary",label:o}):o,s&&A.jsx(Al,{trigger:A.jsx(REe,{className:"size-4 text-muted-foreground"}),content:s})]})}))};Ix.displayName="TableHead";var Oz=Ps("p-2 px-3 align-middle [&:has([role=checkbox])]:pr-0 [&>div]:flex [&>div]:items-center [&>div]:gap-2",{variants:{alignment:{left:"text-left [&>div]:justify-start",center:"text-center [&>div]:justify-center",right:"text-right [&>div]:justify-start [&>div]:flex-row-reverse"},strong:{true:"font-semibold",false:"font-normal"}},defaultVariants:{alignment:"left",strong:!1}}),Iz=t=>{var e=t,{ref:n,alignment:r,strong:a,badge:i,label:o}=e,s=kn(e,["ref","alignment","strong","badge","label"]);return A.jsx("td",Rr(jt({ref:n,className:Oz({alignment:r,strong:a})},s),{children:A.jsxs("div",{children:[o,typeof i=="string"?A.jsx(_T,{variant:"secondary",label:i}):i]})}))};Iz.displayName="TableCell";var Dz=t=>{var e=t,{ref:n,className:r,alignment:a,strong:i,children:o}=e,s=kn(e,["ref","className","alignment","strong","children"]);return A.jsx("td",Rr(jt({ref:n,className:Wt(Oz({alignment:a,strong:i}),r)},s),{children:A.jsx("div",{children:o})}))};Dz.displayName="CustomTableCell";function Dx(t,e,n,r,a){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}function S0(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)}let kz=function(){const{crypto:t}=globalThis;if(t!=null&&t.randomUUID)return kz=t.randomUUID.bind(t),t.randomUUID();const e=new Uint8Array(1),n=t?()=>t.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^n()&15>>+r/4).toString(16))};function KSe(t){return typeof t=="object"&&t!==null&&("name"in t&&t.name==="AbortError"||"message"in t&&String(t.message).includes("FetchRequestCanceledException"))}const kx=t=>{if(t instanceof Error)return t;if(typeof t=="object"&&t!==null){try{if(Object.prototype.toString.call(t)==="[object Error]"){const e=new Error(t.message,t.cause?{cause:t.cause}:{});return t.stack&&(e.stack=t.stack),t.cause&&!e.cause&&(e.cause=t.cause),t.name&&(e.name=t.name),e}}catch{}try{return new Error(JSON.stringify(t))}catch{}}return new Error(t)};class sf extends Error{}class hi extends sf{constructor(e,n,r,a){super(`${hi.makeMessage(e,n,r)}`),this.status=e,this.headers=a,this.error=n}static makeMessage(e,n,r){const a=n!=null&&n.message?typeof n.message=="string"?n.message:JSON.stringify(n.message):n?JSON.stringify(n):r;return e&&a?`${e} ${a}`:e?`${e} status code (no body)`:a||"(no status code or body)"}static generate(e,n,r,a){if(!e||!a)return new IT({message:r,cause:kx(n)});const i=n;return e===400?new Lz(e,i,r,a):e===401?new Pz(e,i,r,a):e===403?new Fz(e,i,r,a):e===404?new Bz(e,i,r,a):e===409?new Uz(e,i,r,a):e===422?new Gz(e,i,r,a):e===429?new zz(e,i,r,a):e>=500?new qz(e,i,r,a):new hi(e,i,r,a)}}class Mx extends hi{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}class IT extends hi{constructor({message:e,cause:n}){super(void 0,void 0,e||"Connection error.",void 0),n&&(this.cause=n)}}class Mz extends IT{constructor({message:e}={}){super({message:e??"Request timed out."})}}class Lz extends hi{}class Pz extends hi{}class Fz extends hi{}class Bz extends hi{}class Uz extends hi{}class Gz extends hi{}class zz extends hi{}class qz extends hi{}const XSe=/^[a-z][a-z0-9+.-]*:/i,QSe=t=>XSe.test(t);let Oi=t=>(Oi=Array.isArray,Oi(t)),Hz=Oi;function Hh(t){return typeof t!="object"?{}:t??{}}function ZSe(t){if(!t)return!0;for(const e in t)return!1;return!0}function JSe(t,e){return Object.prototype.hasOwnProperty.call(t,e)}const eve=(t,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new sf(`${t} must be an integer`);if(e<0)throw new sf(`${t} must be a positive integer`);return e},tve=t=>{try{return JSON.parse(t)}catch{return}},nve=t=>new Promise(e=>setTimeout(e,t)),$h="1.2.0";function rve(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const ave=()=>{var n;const t=rve();if(t==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":Yz(Deno.build.os),"X-Stainless-Arch":$z(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:((n=Deno.version)==null?void 0:n.deno)??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(t==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":Yz(globalThis.process.platform??"unknown"),"X-Stainless-Arch":$z(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const e=ive();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":$h,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function ive(){if(typeof navigator>"u"||!navigator)return null;const t=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:e,pattern:n}of t){const r=n.exec(navigator.userAgent);if(r){const a=r[1]||0,i=r[2]||0,o=r[3]||0;return{browser:e,version:`${a}.${i}.${o}`}}}return null}const $z=t=>t==="x32"?"x32":t==="x86_64"||t==="x64"?"x64":t==="arm"?"arm":t==="aarch64"||t==="arm64"?"arm64":t?`other:${t}`:"unknown",Yz=t=>(t=t.toLowerCase(),t.includes("ios")?"iOS":t==="android"?"Android":t==="darwin"?"MacOS":t==="win32"?"Windows":t==="freebsd"?"FreeBSD":t==="openbsd"?"OpenBSD":t==="linux"?"Linux":t?`Other:${t}`:"Unknown");let Vz;const ove=()=>Vz??(Vz=ave());function sve(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new LlamaCloud({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function lve(...t){const e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...t)}function jz(t){let e=Symbol.asyncIterator in t?t[Symbol.asyncIterator]():t[Symbol.iterator]();return lve({start(){},async pull(n){const{done:r,value:a}=await e.next();r?n.close():n.enqueue(a)},async cancel(){var n;await((n=e.return)==null?void 0:n.call(e))}})}async function cve(t){var r,a;if(t===null||typeof t!="object")return;if(t[Symbol.asyncIterator]){await((a=(r=t[Symbol.asyncIterator]()).return)==null?void 0:a.call(r));return}const e=t.getReader(),n=e.cancel();e.releaseLock(),await n}const uve=({headers:t,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)}),Wz="RFC3986",Kz=t=>String(t),Xz={RFC1738:t=>String(t).replace(/%20/g,"+"),RFC3986:Kz},dve="RFC1738";let Lx=(t,e)=>(Lx=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Lx(t,e));const Rl=(()=>{const t=[];for(let e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t})(),Px=1024,pve=(t,e,n,r,a)=>{if(t.length===0)return t;let i=t;if(typeof t=="symbol"?i=Symbol.prototype.toString.call(t):typeof t!="string"&&(i=String(t)),n==="iso-8859-1")return escape(i).replace(/%u[0-9a-f]{4}/gi,function(s){return"%26%23"+parseInt(s.slice(2),16)+"%3B"});let o="";for(let s=0;s<i.length;s+=Px){const l=i.length>=Px?i.slice(s,s+Px):i,u=[];for(let d=0;d<l.length;++d){let f=l.charCodeAt(d);if(f===45||f===46||f===95||f===126||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||a===dve&&(f===40||f===41)){u[u.length]=l.charAt(d);continue}if(f<128){u[u.length]=Rl[f];continue}if(f<2048){u[u.length]=Rl[192|f>>6]+Rl[128|f&63];continue}if(f<55296||f>=57344){u[u.length]=Rl[224|f>>12]+Rl[128|f>>6&63]+Rl[128|f&63];continue}d+=1,f=65536+((f&1023)<<10|l.charCodeAt(d)&1023),u[u.length]=Rl[240|f>>18]+Rl[128|f>>12&63]+Rl[128|f>>6&63]+Rl[128|f&63]}o+=u.join("")}return o};function fve(t){return!t||typeof t!="object"?!1:!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}function Qz(t,e){if(Oi(t)){const n=[];for(let r=0;r<t.length;r+=1)n.push(e(t[r]));return n}return e(t)}const Zz={brackets(t){return String(t)+"[]"},comma:"comma",indices(t,e){return String(t)+"["+e+"]"},repeat(t){return String(t)}},Jz=function(t,e){Array.prototype.push.apply(t,Oi(e)?e:[e])};let eq;const fa={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:pve,encodeValuesOnly:!1,format:Wz,formatter:Kz,indices:!1,serializeDate(t){return(eq??(eq=Function.prototype.call.bind(Date.prototype.toISOString)))(t)},skipNulls:!1,strictNullHandling:!1};function mve(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||typeof t=="symbol"||typeof t=="bigint"}const Fx={};function tq(t,e,n,r,a,i,o,s,l,u,d,f,m,h,E,b,y,v){let C=t,T=v,w=0,I=!1;for(;(T=T.get(Fx))!==void 0&&!I;){const P=T.get(t);if(w+=1,typeof P<"u"){if(P===w)throw new RangeError("Cyclic object value");I=!0}typeof T.get(Fx)>"u"&&(w=0)}if(typeof u=="function"?C=u(e,C):C instanceof Date?C=m==null?void 0:m(C):n==="comma"&&Oi(C)&&(C=Qz(C,function(P){return P instanceof Date?m==null?void 0:m(P):P})),C===null){if(i)return l&&!b?l(e,fa.encoder,y,"key",h):e;C=""}if(mve(C)||fve(C)){if(l){const P=b?e:l(e,fa.encoder,y,"key",h);return[(E==null?void 0:E(P))+"="+(E==null?void 0:E(l(C,fa.encoder,y,"value",h)))]}return[(E==null?void 0:E(e))+"="+(E==null?void 0:E(String(C)))]}const x=[];if(typeof C>"u")return x;let D;if(n==="comma"&&Oi(C))b&&l&&(C=Qz(C,l)),D=[{value:C.length>0?C.join(",")||null:void 0}];else if(Oi(u))D=u;else{const P=Object.keys(C);D=d?P.sort(d):P}const M=s?String(e).replace(/\./g,"%2E"):String(e),F=r&&Oi(C)&&C.length===1?M+"[]":M;if(a&&Oi(C)&&C.length===0)return F+"[]";for(let P=0;P<D.length;++P){const q=D[P],j=typeof q=="object"&&typeof q.value<"u"?q.value:C[q];if(o&&j===null)continue;const X=f&&s?q.replace(/\./g,"%2E"):q,B=Oi(C)?typeof n=="function"?n(F,X):F:F+(f?"."+X:"["+X+"]");v.set(t,w);const W=new WeakMap;W.set(Fx,v),Jz(x,tq(j,B,n,r,a,i,o,s,n==="comma"&&b&&Oi(C)?null:l,u,d,f,m,h,E,b,y,W))}return x}function hve(t=fa){if(typeof t.allowEmptyArrays<"u"&&typeof t.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof t.encodeDotInKeys<"u"&&typeof t.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(t.encoder!==null&&typeof t.encoder<"u"&&typeof t.encoder!="function")throw new TypeError("Encoder has to be a function.");const e=t.charset||fa.charset;if(typeof t.charset<"u"&&t.charset!=="utf-8"&&t.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=Wz;if(typeof t.format<"u"){if(!Lx(Xz,t.format))throw new TypeError("Unknown format option provided.");n=t.format}const r=Xz[n];let a=fa.filter;(typeof t.filter=="function"||Oi(t.filter))&&(a=t.filter);let i;if(t.arrayFormat&&t.arrayFormat in Zz?i=t.arrayFormat:"indices"in t?i=t.indices?"indices":"repeat":i=fa.arrayFormat,"commaRoundTrip"in t&&typeof t.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const o=typeof t.allowDots>"u"?t.encodeDotInKeys?!0:fa.allowDots:!!t.allowDots;return{addQueryPrefix:typeof t.addQueryPrefix=="boolean"?t.addQueryPrefix:fa.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof t.allowEmptyArrays=="boolean"?!!t.allowEmptyArrays:fa.allowEmptyArrays,arrayFormat:i,charset:e,charsetSentinel:typeof t.charsetSentinel=="boolean"?t.charsetSentinel:fa.charsetSentinel,commaRoundTrip:!!t.commaRoundTrip,delimiter:typeof t.delimiter>"u"?fa.delimiter:t.delimiter,encode:typeof t.encode=="boolean"?t.encode:fa.encode,encodeDotInKeys:typeof t.encodeDotInKeys=="boolean"?t.encodeDotInKeys:fa.encodeDotInKeys,encoder:typeof t.encoder=="function"?t.encoder:fa.encoder,encodeValuesOnly:typeof t.encodeValuesOnly=="boolean"?t.encodeValuesOnly:fa.encodeValuesOnly,filter:a,format:n,formatter:r,serializeDate:typeof t.serializeDate=="function"?t.serializeDate:fa.serializeDate,skipNulls:typeof t.skipNulls=="boolean"?t.skipNulls:fa.skipNulls,sort:typeof t.sort=="function"?t.sort:null,strictNullHandling:typeof t.strictNullHandling=="boolean"?t.strictNullHandling:fa.strictNullHandling}}function gve(t,e={}){let n=t;const r=hve(e);let a,i;typeof r.filter=="function"?(i=r.filter,n=i("",n)):Oi(r.filter)&&(i=r.filter,a=i);const o=[];if(typeof n!="object"||n===null)return"";const s=Zz[r.arrayFormat],l=s==="comma"&&r.commaRoundTrip;a||(a=Object.keys(n)),r.sort&&a.sort(r.sort);const u=new WeakMap;for(let m=0;m<a.length;++m){const h=a[m];r.skipNulls&&n[h]===null||Jz(o,tq(n[h],h,s,l,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,u))}const d=o.join(r.delimiter);let f=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),d.length>0?f+d:""}const DT={off:0,error:200,warn:300,info:400,debug:500},nq=(t,e,n)=>{if(t){if(JSe(DT,t))return t;io(n).warn(`${e} was set to ${JSON.stringify(t)}, expected one of ${JSON.stringify(Object.keys(DT))}`)}};function v0(){}function kT(t,e,n){return!e||DT[t]>DT[n]?v0:e[t].bind(e)}const _ve={error:v0,warn:v0,info:v0,debug:v0};let rq=new WeakMap;function io(t){const e=t.logger,n=t.logLevel??"off";if(!e)return _ve;const r=rq.get(e);if(r&&r[0]===n)return r[1];const a={error:kT("error",e,n),warn:kT("warn",e,n),info:kT("info",e,n),debug:kT("debug",e,n)};return rq.set(e,[n,a]),a}const lf=t=>(t.options&&(t.options={...t.options},delete t.options.headers),t.headers&&(t.headers=Object.fromEntries((t.headers instanceof Headers?[...t.headers]:Object.entries(t.headers)).map(([e,n])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in t&&(t.retryOfRequestLogID&&(t.retryOf=t.retryOfRequestLogID),delete t.retryOfRequestLogID),t);async function aq(t,e){const{response:n,requestLogID:r,retryOfRequestLogID:a,startTime:i}=e,o=await(async()=>{var f;if(n.status===204)return null;if(e.options.__binaryResponse)return n;const s=n.headers.get("content-type"),l=(f=s==null?void 0:s.split(";")[0])==null?void 0:f.trim();return(l==null?void 0:l.includes("application/json"))||(l==null?void 0:l.endsWith("+json"))?await n.json():await n.text()})();return io(t).debug(`[${r}] response parsed`,lf({retryOfRequestLogID:a,url:n.url,status:n.status,body:o,durationMs:Date.now()-i})),o}var y0;class MT extends Promise{constructor(e,n,r=aq){super(a=>{a(null)}),this.responsePromise=n,this.parseResponse=r,y0.set(this,void 0),Dx(this,y0,e)}_thenUnwrap(e){return new MT(S0(this,y0,"f"),this.responsePromise,async(n,r)=>e(await this.parseResponse(n,r),r))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){const[e,n]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:n}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(S0(this,y0,"f"),e))),this.parsedPromise}then(e,n){return this.parse().then(e,n)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}y0=new WeakMap;var LT;class Yh{constructor(e,n,r,a){LT.set(this,void 0),Dx(this,LT,e),this.options=a,this.response=n,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){const e=this.nextPageRequestOptions();if(!e)throw new sf("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await S0(this,LT,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(LT=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const n of e.getPaginatedItems())yield n}}class bve extends MT{constructor(e,n,r){super(e,n,async(a,i)=>new r(a,i.response,await aq(a,i),i.options))}async*[Symbol.asyncIterator](){const e=await this;for await(const n of e)yield n}}class Eve extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.files=r.files||[],this.total_count=r.total_count||0,this.offset=r.offset||0}getPaginatedItems(){return this.files??[]}nextPageRequestOptions(){const e=this.offset??0,n=this.getPaginatedItems().length,r=e+n,a=this.total_count;return a&&r<a?{...this.options,query:{...Hh(this.options.query),offset:r}}:null}}class iq extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.items=r.items||[],this.total_size=r.total_size||0}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){const e=this.options.query.offset??0,n=this.getPaginatedItems().length,r=e+n,a=this.total_size;return a&&r<a?{...this.options,query:{...Hh(this.options.query),offset:r}}:null}}class Sve extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.items=r.items||[],this.total=r.total||0,this.skip=r.skip||0}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){const e=this.skip??0,n=this.getPaginatedItems().length,r=e+n,a=this.total;return a&&r<a?{...this.options,query:{...Hh(this.options.query),skip:r}}:null}}class vve extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.documents=r.documents||[],this.total_count=r.total_count||0,this.offset=r.offset||0}getPaginatedItems(){return this.documents??[]}nextPageRequestOptions(){const e=this.offset??0,n=this.getPaginatedItems().length,r=e+n,a=this.total_count;return a&&r<a?{...this.options,query:{...Hh(this.options.query),skip:r}}:null}}class ud extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.items=r.items||[],this.next_page_token=r.next_page_token||""}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){const e=this.next_page_token;return e?{...this.options,query:{...Hh(this.options.query),page_token:e}}:null}}class oq extends Yh{constructor(e,n,r,a){super(e,n,r,a),this.items=r.items||[],this.next_page_token=r.next_page_token||""}getPaginatedItems(){return this.items??[]}nextPageRequestOptions(){const e=this.next_page_token;return e?{...this.options,body:{...Hh(this.options.body),page_token:e}}:null}}const sq=()=>{var t;if(typeof File>"u"){const{process:e}=globalThis,n=typeof((t=e==null?void 0:e.versions)==null?void 0:t.node)=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(n?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function T0(t,e,n){return sq(),new File(t,e??"unknown_file",n)}function PT(t){return(typeof t=="object"&&t!==null&&("name"in t&&t.name&&String(t.name)||"url"in t&&t.url&&String(t.url)||"filename"in t&&t.filename&&String(t.filename)||"path"in t&&t.path&&String(t.path))||"").split(/[\\/]/).pop()||void 0}const lq=t=>t!=null&&typeof t=="object"&&typeof t[Symbol.asyncIterator]=="function",C0=async(t,e)=>({...t,body:await Tve(t.body,e)}),cq=new WeakMap;function yve(t){const e=typeof t=="function"?t:t.fetch,n=cq.get(e);if(n)return n;const r=(async()=>{try{const a="Response"in e?e.Response:(await e("data:,")).constructor,i=new FormData;return i.toString()!==await new a(i).text()}catch{return!0}})();return cq.set(e,r),r}const Tve=async(t,e)=>{if(!await yve(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const n=new FormData;return await Promise.all(Object.entries(t||{}).map(([r,a])=>Bx(n,r,a))),n},Cve=t=>t instanceof Blob&&"name"in t,Bx=async(t,e,n)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")t.append(e,String(n));else if(n instanceof Response)t.append(e,T0([await n.blob()],PT(n)));else if(lq(n))t.append(e,T0([await new Response(jz(n)).blob()],PT(n)));else if(Cve(n))t.append(e,n,PT(n));else if(Array.isArray(n))await Promise.all(n.map(r=>Bx(t,e+"[]",r)));else if(typeof n=="object")await Promise.all(Object.entries(n).map(([r,a])=>Bx(t,`${e}[${r}]`,a)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}},uq=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",Ave=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&uq(t),Rve=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function wve(t,e,n){if(sq(),t=await t,Ave(t))return t instanceof File?t:T0([await t.arrayBuffer()],t.name);if(Rve(t)){const a=await t.blob();return e||(e=new URL(t.url).pathname.split(/[\\/]/).pop()),T0(await Ux(a),e,n)}const r=await Ux(t);if(e||(e=PT(t)),!(n!=null&&n.type)){const a=r.find(i=>typeof i=="object"&&"type"in i&&i.type);typeof a=="string"&&(n={...n,type:a})}return T0(r,e,n)}async function Ux(t){var n;let e=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)e.push(t);else if(uq(t))e.push(t instanceof Blob?t:await t.arrayBuffer());else if(lq(t))for await(const r of t)e.push(...await Ux(r));else{const r=(n=t==null?void 0:t.constructor)==null?void 0:n.name;throw new Error(`Unexpected data type: ${typeof t}${r?`; constructor: ${r}`:""}${xve(t)}`)}return e}function xve(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(n=>`"${n}"`).join(", ")}]`}class In{constructor(e){this._client=e}}function dq(t){return t.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const pq=Object.freeze(Object.create(null)),je=((t=dq)=>function(n,...r){if(n.length===1)return n[0];let a=!1;const i=[],o=n.reduce((d,f,m)=>{var b;/[?#]/.test(f)&&(a=!0);const h=r[m];let E=(a?encodeURIComponent:t)(""+h);return m!==r.length&&(h==null||typeof h=="object"&&h.toString===((b=Object.getPrototypeOf(Object.getPrototypeOf(h.hasOwnProperty??pq)??pq))==null?void 0:b.toString))&&(E=h+"",i.push({start:d.length+f.length,length:E.length,error:`Value of type ${Object.prototype.toString.call(h).slice(8,-1)} is not a valid path parameter`})),d+f+(m===r.length?"":E)},""),s=o.split(/[?#]/,1)[0],l=new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)","gi");let u;for(;(u=l.exec(s))!==null;)i.push({start:u.index,length:u[0].length,error:`Value "${u[0]}" can't be safely passed as a path parameter`});if(i.sort((d,f)=>d.start-f.start),i.length>0){let d=0;const f=i.reduce((m,h)=>{const E=" ".repeat(h.start-d),b="^".repeat(h.length);return d=h.start+h.length,m+E+b},"");throw new sf(`Path parameters result in path with invalid segments:
|
|
270
270
|
${i.map(m=>m.error).join(`
|
|
271
271
|
`)}
|
|
272
272
|
${o}
|
|
@@ -623,8 +623,8 @@ You can add a description to the \`${dg}\` by passing a \`${qJ}\` component as a
|
|
|
623
623
|
|
|
624
624
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${dg}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
625
625
|
|
|
626
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return N.useEffect(()=>{var r;document.getElementById((r=t.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},W3e=BJ,K3e=UJ,X3e=$J,Q3e=VJ,Z3e=zJ,J3e=HJ;W3e.displayName,K3e.displayName,Z3e.displayName,J3e.displayName,X3e.displayName,Q3e.displayName;var jJ="DropdownMenu",[eFe]=pa(jJ,[J0]),go=J0(),[bQe,WJ]=eFe(jJ),KJ="DropdownMenuTrigger",tFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=t,i=WJ(KJ,n),o=go(n);return A.jsx(YM,{asChild:!0,...o,children:A.jsx(pt.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Wy(e,i.triggerRef),onPointerDown:Le(t.onPointerDown,s=>{!r&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:Le(t.onKeyDown,s=>{r||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});tFe.displayName=KJ;var XJ="DropdownMenuContent",QJ=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=WJ(XJ,n),i=go(n),o=N.useRef(!1);return A.jsx(VM,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:e,onCloseAutoFocus:Le(t.onCloseAutoFocus,s=>{var l;o.current||(l=a.triggerRef.current)==null||l.focus(),o.current=!1,s.preventDefault()}),onInteractOutside:Le(t.onInteractOutside,s=>{const l=s.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!a.modal||d)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});QJ.displayName=XJ;var nFe="DropdownMenuGroup",rFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(jM,{...a,...r,ref:e})});rFe.displayName=nFe;var aFe="DropdownMenuLabel",ZJ=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(WM,{...a,...r,ref:e})});ZJ.displayName=aFe;var iFe="DropdownMenuItem",JJ=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(KM,{...a,...r,ref:e})});JJ.displayName=iFe;var oFe="DropdownMenuCheckboxItem",eee=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(XM,{...a,...r,ref:e})});eee.displayName=oFe;var sFe="DropdownMenuRadioGroup",lFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(QM,{...a,...r,ref:e})});lFe.displayName=sFe;var cFe="DropdownMenuRadioItem",tee=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(ZM,{...a,...r,ref:e})});tee.displayName=cFe;var uFe="DropdownMenuItemIndicator",dFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(JM,{...a,...r,ref:e})});dFe.displayName=uFe;var pFe="DropdownMenuSeparator",nee=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(eL,{...a,...r,ref:e})});nee.displayName=pFe;var fFe="DropdownMenuArrow",mFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(tL,{...a,...r,ref:e})});mFe.displayName=fFe;var hFe="DropdownMenuSubTrigger",ree=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(nL,{...a,...r,ref:e})});ree.displayName=hFe;var gFe="DropdownMenuSubContent",aee=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(rL,{...a,...r,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});aee.displayName=gFe;var _Fe=QJ,bFe=ZJ,EFe=JJ,SFe=eee,vFe=tee,yFe=nee,TFe=ree,CFe=aee;TFe.displayName,CFe.displayName,_Fe.displayName,EFe.displayName,SFe.displayName,vFe.displayName,bFe.displayName,yFe.displayName;function eA(){var t;return typeof window<"u"&&((t=window.location)!=null&&t.origin)?window.location.origin:"http://localhost:8000"}function AFe(t,e){if(t==null)return{};var n,r,a=
|
|
627
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RL(t){return RFe(t)||wFe(t)||xFe(t)||NFe()}function uE(t){"@babel/helpers - typeof";return uE=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},uE(t)}function OFe(t,e){if(uE(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(uE(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function IFe(t){var e=OFe(t,"string");return uE(e)=="symbol"?e:e+""}function iee(t,e,n){return(e=IFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,r)}return n}function pg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oee(Object(n),!0).forEach(function(r){iee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oee(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DFe(t){var e=t.length;if(e===0||e===1)return t;if(e===2)return[t[0],t[1],"".concat(t[0],".").concat(t[1]),"".concat(t[1],".").concat(t[0])];if(e===3)return[t[0],t[1],t[2],"".concat(t[0],".").concat(t[1]),"".concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[0]),"".concat(t[1],".").concat(t[2]),"".concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[1],".").concat(t[0])];if(e>=4)return[t[0],t[1],t[2],t[3],"".concat(t[0],".").concat(t[1]),"".concat(t[0],".").concat(t[2]),"".concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[0]),"".concat(t[1],".").concat(t[2]),"".concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[1]),"".concat(t[2],".").concat(t[3]),"".concat(t[3],".").concat(t[0]),"".concat(t[3],".").concat(t[1]),"".concat(t[3],".").concat(t[2]),"".concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[1],".").concat(t[3]),"".concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[2],".").concat(t[3]),"".concat(t[0],".").concat(t[3],".").concat(t[1]),"".concat(t[0],".").concat(t[3],".").concat(t[2]),"".concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[1],".").concat(t[2],".").concat(t[3]),"".concat(t[1],".").concat(t[3],".").concat(t[0]),"".concat(t[1],".").concat(t[3],".").concat(t[2]),"".concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[0],".").concat(t[3]),"".concat(t[2],".").concat(t[1],".").concat(t[0]),"".concat(t[2],".").concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[3],".").concat(t[0]),"".concat(t[2],".").concat(t[3],".").concat(t[1]),"".concat(t[3],".").concat(t[0],".").concat(t[1]),"".concat(t[3],".").concat(t[0],".").concat(t[2]),"".concat(t[3],".").concat(t[1],".").concat(t[0]),"".concat(t[3],".").concat(t[1],".").concat(t[2]),"".concat(t[3],".").concat(t[2],".").concat(t[0]),"".concat(t[3],".").concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[1],".").concat(t[2],".").concat(t[3]),"".concat(t[0],".").concat(t[1],".").concat(t[3],".").concat(t[2]),"".concat(t[0],".").concat(t[2],".").concat(t[1],".").concat(t[3]),"".concat(t[0],".").concat(t[2],".").concat(t[3],".").concat(t[1]),"".concat(t[0],".").concat(t[3],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[3],".").concat(t[2],".").concat(t[1]),"".concat(t[1],".").concat(t[0],".").concat(t[2],".").concat(t[3]),"".concat(t[1],".").concat(t[0],".").concat(t[3],".").concat(t[2]),"".concat(t[1],".").concat(t[2],".").concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[2],".").concat(t[3],".").concat(t[0]),"".concat(t[1],".").concat(t[3],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[3],".").concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[0],".").concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[0],".").concat(t[3],".").concat(t[1]),"".concat(t[2],".").concat(t[1],".").concat(t[0],".").concat(t[3]),"".concat(t[2],".").concat(t[1],".").concat(t[3],".").concat(t[0]),"".concat(t[2],".").concat(t[3],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[3],".").concat(t[1],".").concat(t[0]),"".concat(t[3],".").concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[3],".").concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[3],".").concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[3],".").concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[3],".").concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[3],".").concat(t[2],".").concat(t[1],".").concat(t[0])]}var wL={};function kFe(t){if(t.length===0||t.length===1)return t;var e=t.join(".");return wL[e]||(wL[e]=DFe(t)),wL[e]}function MFe(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=t.filter(function(i){return i!=="token"}),a=kFe(r);return a.reduce(function(i,o){return pg(pg({},i),n[o])},e)}function see(t){return t.join(" ")}function LFe(t,e){var n=0;return function(r){return n+=1,r.map(function(a,i){return lee({node:a,stylesheet:t,useInlineStyles:e,key:"code-segment-".concat(n,"-").concat(i)})})}}function lee(t){var e=t.node,n=t.stylesheet,r=t.style,a=r===void 0?{}:r,i=t.useInlineStyles,o=t.key,s=e.properties,l=e.type,u=e.tagName,d=e.value;if(l==="text")return d;if(u){var f=LFe(n,i),m;if(!i)m=pg(pg({},s),{},{className:see(s.className)});else{var h=Object.keys(n).reduce(function(v,C){return C.split(".").forEach(function(T){v.includes(T)||v.push(T)}),v},[]),E=s.className&&s.className.includes("token")?["token"]:[],b=s.className&&E.concat(s.className.filter(function(v){return!h.includes(v)}));m=pg(pg({},s),{},{className:see(b)||void 0,style:MFe(s.className,Object.assign({},s.style,a),n)})}var y=f(e.children);return Ie.createElement(u,
|
|
626
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return N.useEffect(()=>{var r;document.getElementById((r=t.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},W3e=BJ,K3e=UJ,X3e=$J,Q3e=VJ,Z3e=zJ,J3e=HJ;W3e.displayName,K3e.displayName,Z3e.displayName,J3e.displayName,X3e.displayName,Q3e.displayName;var jJ="DropdownMenu",[eFe]=pa(jJ,[J0]),go=J0(),[bQe,WJ]=eFe(jJ),KJ="DropdownMenuTrigger",tFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=t,i=WJ(KJ,n),o=go(n);return A.jsx(YM,{asChild:!0,...o,children:A.jsx(pt.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:Wy(e,i.triggerRef),onPointerDown:Le(t.onPointerDown,s=>{!r&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:Le(t.onKeyDown,s=>{r||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});tFe.displayName=KJ;var XJ="DropdownMenuContent",QJ=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=WJ(XJ,n),i=go(n),o=N.useRef(!1);return A.jsx(VM,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:e,onCloseAutoFocus:Le(t.onCloseAutoFocus,s=>{var l;o.current||(l=a.triggerRef.current)==null||l.focus(),o.current=!1,s.preventDefault()}),onInteractOutside:Le(t.onInteractOutside,s=>{const l=s.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!a.modal||d)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});QJ.displayName=XJ;var nFe="DropdownMenuGroup",rFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(jM,{...a,...r,ref:e})});rFe.displayName=nFe;var aFe="DropdownMenuLabel",ZJ=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(WM,{...a,...r,ref:e})});ZJ.displayName=aFe;var iFe="DropdownMenuItem",JJ=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(KM,{...a,...r,ref:e})});JJ.displayName=iFe;var oFe="DropdownMenuCheckboxItem",eee=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(XM,{...a,...r,ref:e})});eee.displayName=oFe;var sFe="DropdownMenuRadioGroup",lFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(QM,{...a,...r,ref:e})});lFe.displayName=sFe;var cFe="DropdownMenuRadioItem",tee=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(ZM,{...a,...r,ref:e})});tee.displayName=cFe;var uFe="DropdownMenuItemIndicator",dFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(JM,{...a,...r,ref:e})});dFe.displayName=uFe;var pFe="DropdownMenuSeparator",nee=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(eL,{...a,...r,ref:e})});nee.displayName=pFe;var fFe="DropdownMenuArrow",mFe=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(tL,{...a,...r,ref:e})});mFe.displayName=fFe;var hFe="DropdownMenuSubTrigger",ree=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(nL,{...a,...r,ref:e})});ree.displayName=hFe;var gFe="DropdownMenuSubContent",aee=N.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,a=go(n);return A.jsx(rL,{...a,...r,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});aee.displayName=gFe;var _Fe=QJ,bFe=ZJ,EFe=JJ,SFe=eee,vFe=tee,yFe=nee,TFe=ree,CFe=aee;TFe.displayName,CFe.displayName,_Fe.displayName,EFe.displayName,SFe.displayName,vFe.displayName,bFe.displayName,yFe.displayName;function eA(){var t;return typeof window<"u"&&((t=window.location)!=null&&t.origin)?window.location.origin:"http://localhost:8000"}function AFe(t,e){if(t==null)return{};var n,r,a=ez(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(a[n]=t[n])}return a}function AL(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function RFe(t){if(Array.isArray(t))return AL(t)}function wFe(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function xFe(t,e){if(t){if(typeof t=="string")return AL(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?AL(t,e):void 0}}function NFe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
627
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RL(t){return RFe(t)||wFe(t)||xFe(t)||NFe()}function uE(t){"@babel/helpers - typeof";return uE=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},uE(t)}function OFe(t,e){if(uE(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(uE(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function IFe(t){var e=OFe(t,"string");return uE(e)=="symbol"?e:e+""}function iee(t,e,n){return(e=IFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,r)}return n}function pg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oee(Object(n),!0).forEach(function(r){iee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oee(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DFe(t){var e=t.length;if(e===0||e===1)return t;if(e===2)return[t[0],t[1],"".concat(t[0],".").concat(t[1]),"".concat(t[1],".").concat(t[0])];if(e===3)return[t[0],t[1],t[2],"".concat(t[0],".").concat(t[1]),"".concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[0]),"".concat(t[1],".").concat(t[2]),"".concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[1],".").concat(t[0])];if(e>=4)return[t[0],t[1],t[2],t[3],"".concat(t[0],".").concat(t[1]),"".concat(t[0],".").concat(t[2]),"".concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[0]),"".concat(t[1],".").concat(t[2]),"".concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[1]),"".concat(t[2],".").concat(t[3]),"".concat(t[3],".").concat(t[0]),"".concat(t[3],".").concat(t[1]),"".concat(t[3],".").concat(t[2]),"".concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[1],".").concat(t[3]),"".concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[2],".").concat(t[3]),"".concat(t[0],".").concat(t[3],".").concat(t[1]),"".concat(t[0],".").concat(t[3],".").concat(t[2]),"".concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[1],".").concat(t[2],".").concat(t[3]),"".concat(t[1],".").concat(t[3],".").concat(t[0]),"".concat(t[1],".").concat(t[3],".").concat(t[2]),"".concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[0],".").concat(t[3]),"".concat(t[2],".").concat(t[1],".").concat(t[0]),"".concat(t[2],".").concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[3],".").concat(t[0]),"".concat(t[2],".").concat(t[3],".").concat(t[1]),"".concat(t[3],".").concat(t[0],".").concat(t[1]),"".concat(t[3],".").concat(t[0],".").concat(t[2]),"".concat(t[3],".").concat(t[1],".").concat(t[0]),"".concat(t[3],".").concat(t[1],".").concat(t[2]),"".concat(t[3],".").concat(t[2],".").concat(t[0]),"".concat(t[3],".").concat(t[2],".").concat(t[1]),"".concat(t[0],".").concat(t[1],".").concat(t[2],".").concat(t[3]),"".concat(t[0],".").concat(t[1],".").concat(t[3],".").concat(t[2]),"".concat(t[0],".").concat(t[2],".").concat(t[1],".").concat(t[3]),"".concat(t[0],".").concat(t[2],".").concat(t[3],".").concat(t[1]),"".concat(t[0],".").concat(t[3],".").concat(t[1],".").concat(t[2]),"".concat(t[0],".").concat(t[3],".").concat(t[2],".").concat(t[1]),"".concat(t[1],".").concat(t[0],".").concat(t[2],".").concat(t[3]),"".concat(t[1],".").concat(t[0],".").concat(t[3],".").concat(t[2]),"".concat(t[1],".").concat(t[2],".").concat(t[0],".").concat(t[3]),"".concat(t[1],".").concat(t[2],".").concat(t[3],".").concat(t[0]),"".concat(t[1],".").concat(t[3],".").concat(t[0],".").concat(t[2]),"".concat(t[1],".").concat(t[3],".").concat(t[2],".").concat(t[0]),"".concat(t[2],".").concat(t[0],".").concat(t[1],".").concat(t[3]),"".concat(t[2],".").concat(t[0],".").concat(t[3],".").concat(t[1]),"".concat(t[2],".").concat(t[1],".").concat(t[0],".").concat(t[3]),"".concat(t[2],".").concat(t[1],".").concat(t[3],".").concat(t[0]),"".concat(t[2],".").concat(t[3],".").concat(t[0],".").concat(t[1]),"".concat(t[2],".").concat(t[3],".").concat(t[1],".").concat(t[0]),"".concat(t[3],".").concat(t[0],".").concat(t[1],".").concat(t[2]),"".concat(t[3],".").concat(t[0],".").concat(t[2],".").concat(t[1]),"".concat(t[3],".").concat(t[1],".").concat(t[0],".").concat(t[2]),"".concat(t[3],".").concat(t[1],".").concat(t[2],".").concat(t[0]),"".concat(t[3],".").concat(t[2],".").concat(t[0],".").concat(t[1]),"".concat(t[3],".").concat(t[2],".").concat(t[1],".").concat(t[0])]}var wL={};function kFe(t){if(t.length===0||t.length===1)return t;var e=t.join(".");return wL[e]||(wL[e]=DFe(t)),wL[e]}function MFe(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=t.filter(function(i){return i!=="token"}),a=kFe(r);return a.reduce(function(i,o){return pg(pg({},i),n[o])},e)}function see(t){return t.join(" ")}function LFe(t,e){var n=0;return function(r){return n+=1,r.map(function(a,i){return lee({node:a,stylesheet:t,useInlineStyles:e,key:"code-segment-".concat(n,"-").concat(i)})})}}function lee(t){var e=t.node,n=t.stylesheet,r=t.style,a=r===void 0?{}:r,i=t.useInlineStyles,o=t.key,s=e.properties,l=e.type,u=e.tagName,d=e.value;if(l==="text")return d;if(u){var f=LFe(n,i),m;if(!i)m=pg(pg({},s),{},{className:see(s.className)});else{var h=Object.keys(n).reduce(function(v,C){return C.split(".").forEach(function(T){v.includes(T)||v.push(T)}),v},[]),E=s.className&&s.className.includes("token")?["token"]:[],b=s.className&&E.concat(s.className.filter(function(v){return!h.includes(v)}));m=pg(pg({},s),{},{className:see(b)||void 0,style:MFe(s.className,Object.assign({},s.style,a),n)})}var y=f(e.children);return Ie.createElement(u,AT({key:o},m),y)}}const PFe=(function(t,e){var n=t.listLanguages();return n.indexOf(e)!==-1});var FFe=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function cee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),n.push.apply(n,r)}return n}function Cd(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?cee(Object(n),!0).forEach(function(r){iee(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):cee(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var BFe=/\n/g;function UFe(t){return t.match(BFe)}function GFe(t){var e=t.lines,n=t.startingLineNumber,r=t.style;return e.map(function(a,i){var o=i+n;return Ie.createElement("span",{key:"line-".concat(i),className:"react-syntax-highlighter-line-number",style:typeof r=="function"?r(o):r},"".concat(o,`
|
|
628
628
|
`))})}function zFe(t){var e=t.codeString,n=t.codeStyle,r=t.containerStyle,a=r===void 0?{float:"left",paddingRight:"10px"}:r,i=t.numberStyle,o=i===void 0?{}:i,s=t.startingLineNumber;return Ie.createElement("code",{style:Object.assign({},n,a)},GFe({lines:e.replace(/\n$/,"").split(`
|
|
629
629
|
`),style:o,startingLineNumber:s}))}function qFe(t){return"".concat(t.toString().length,".25em")}function uee(t,e){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(t),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:e},children:[{type:"text",value:t}]}}function dee(t,e,n){var r={display:"inline-block",minWidth:qFe(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},a=typeof t=="function"?t(e):t,i=Cd(Cd({},r),a);return i}function tA(t){var e=t.children,n=t.lineNumber,r=t.lineNumberStyle,a=t.largestLineNumber,i=t.showInlineLineNumbers,o=t.lineProps,s=o===void 0?{}:o,l=t.className,u=l===void 0?[]:l,d=t.showLineNumbers,f=t.wrapLongLines,m=t.wrapLines,h=m===void 0?!1:m,E=h?Cd({},typeof s=="function"?s(n):s):{};if(E.className=E.className?[].concat(RL(E.className.trim().split(/\s+/)),RL(u)):u,n&&i){var b=dee(r,n,a);e.unshift(uee(n,b))}return f&d&&(E.style=Cd({display:"flex"},E.style)),{type:"element",tagName:"span",properties:E,children:e}}function pee(t){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],r=0;r<t.length;r++){var a=t[r];if(a.type==="text")n.push(tA({children:[a],className:RL(new Set(e))}));else if(a.children){var i=e.concat(a.properties.className);pee(a.children,i).forEach(function(o){return n.push(o)})}}return n}function HFe(t,e,n,r,a,i,o,s,l){var u,d=pee(t.value),f=[],m=-1,h=0;function E(I,x){var D=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return tA({children:I,lineNumber:x,lineNumberStyle:s,largestLineNumber:o,showInlineLineNumbers:a,lineProps:n,className:D,showLineNumbers:r,wrapLongLines:l,wrapLines:e})}function b(I,x){if(r&&x&&a){var D=dee(s,x,o);I.unshift(uee(x,D))}return I}function y(I,x){var D=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return e||D.length>0?E(I,x,D):b(I,x)}for(var v=function(){var x=d[h],D=x.children[0].value,M=UFe(D);if(M){var F=D.split(`
|
|
630
630
|
`);F.forEach(function(P,q){var j=r&&f.length+i,X={type:"text",value:"".concat(P,`
|
|
@@ -652,7 +652,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
652
652
|
`,`
|
|
653
653
|
+`).split(`
|
|
654
654
|
`)),d=u.reduce((f,m)=>f.concat(...m),[]);return[u,d]}return[[],[]]},[t]);return N.useEffect(()=>{const l=(e==null?void 0:e.target)??lle,u=(e==null?void 0:e.actInsideInputWithModifier)??!0;if(t!==null){const d=h=>{var y,v;if(a.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!a.current||a.current&&!u)&&yse(h))return!1;const b=ule(h.code,s);if(i.current.add(h[b]),cle(o,i.current,!1)){const C=((v=(y=h.composedPath)==null?void 0:y.call(h))==null?void 0:v[0])||h.target,T=(C==null?void 0:C.nodeName)==="BUTTON"||(C==null?void 0:C.nodeName)==="A";e.preventDefault!==!1&&(a.current||!T)&&h.preventDefault(),r(!0)}},f=h=>{const E=ule(h.code,s);cle(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(h[E]),h.key==="Meta"&&i.current.clear(),a.current=!1},m=()=>{i.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",d),l==null||l.addEventListener("keyup",f),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{l==null||l.removeEventListener("keydown",d),l==null||l.removeEventListener("keyup",f),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,r]),n}function cle(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(a=>e.has(a)))}function ule(t,e){return e.includes(t)?"code":"key"}const gHe=()=>{const t=Er();return N.useMemo(()=>({zoomIn:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1.2,{duration:e==null?void 0:e.duration}):Promise.resolve(!1)},zoomOut:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1/1.2,{duration:e==null?void 0:e.duration}):Promise.resolve(!1)},zoomTo:(e,n)=>{const{panZoom:r}=t.getState();return r?r.scaleTo(e,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>t.getState().transform[2],setViewport:async(e,n)=>{const{transform:[r,a,i],panZoom:o}=t.getState();return o?(await o.setViewport({x:e.x??r,y:e.y??a,zoom:e.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[e,n,r]=t.getState().transform;return{x:e,y:n,zoom:r}},setCenter:async(e,n,r)=>t.getState().setCenter(e,n,r),fitBounds:async(e,n)=>{const{width:r,height:a,minZoom:i,maxZoom:o,panZoom:s}=t.getState(),l=q5(e,r,a,i,o,(n==null?void 0:n.padding)??.1);return s?(await s.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(e,n={})=>{const{transform:r,snapGrid:a,snapToGrid:i,domNode:o}=t.getState();if(!o)return e;const{x:s,y:l}=o.getBoundingClientRect(),u={x:e.x-s,y:e.y-l},d=n.snapGrid??a,f=n.snapToGrid??i;return NE(u,r,f,d)},flowToScreenPosition:e=>{const{transform:n,domNode:r}=t.getState();if(!r)return e;const{x:a,y:i}=r.getBoundingClientRect(),o=kA(e,n);return{x:o.x+a,y:o.y+i}}}),[])};function dle(t,e){const n=[],r=new Map,a=[];for(const i of t)if(i.type==="add"){a.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const o=r.get(i.id);o?o.push(i):r.set(i.id,[i])}for(const i of e){const o=r.get(i.id);if(!o){n.push(i);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const s={...i};for(const l of o)_He(l,s);n.push(s)}return a.length&&a.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function _He(t,e){switch(t.type){case"select":{e.selected=t.selected;break}case"position":{typeof t.position<"u"&&(e.position=t.position),typeof t.dragging<"u"&&(e.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(e.measured??(e.measured={}),e.measured.width=t.dimensions.width,e.measured.height=t.dimensions.height,t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(e.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(e.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(e.resizing=t.resizing);break}}}function ple(t,e){return dle(t,e)}function fle(t,e){return dle(t,e)}function kf(t,e){return{id:t,type:"select",selected:e}}function Ag(t,e=new Set,n=!1){const r=[];for(const[a,i]of t){const o=e.has(a);!(i.selected===void 0&&!o)&&i.selected!==o&&(n&&(i.selected=o),r.push(kf(i.id,o)))}return r}function mle({items:t=[],lookup:e}){var a;const n=[],r=new Map(t.map(i=>[i.id,i]));for(const[i,o]of t.entries()){const s=e.get(o.id),l=((a=s==null?void 0:s.internals)==null?void 0:a.userNode)??s;l!==void 0&&l!==o&&n.push({id:o.id,item:o,type:"replace"}),l===void 0&&n.push({item:o,type:"add",index:i})}for(const[i]of e)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function hle(t){return{id:t.id,type:"remove"}}const gle=t=>$ze(t),bHe=t=>dse(t);function _le(t){return N.forwardRef(t)}const EHe=typeof window<"u"?N.useLayoutEffect:N.useEffect;function ble(t){const[e,n]=N.useState(BigInt(0)),[r]=N.useState(()=>SHe(()=>n(a=>a+BigInt(1))));return EHe(()=>{const a=r.get();a.length&&(t(a),r.reset())},[e]),r}function SHe(t){let e=[];return{get:()=>e,reset:()=>{e=[]},push:n=>{e.push(n),t()}}}const Ele=N.createContext(null);function vHe({children:t}){const e=Er(),n=N.useCallback(s=>{const{nodes:l=[],setNodes:u,hasDefaultNodes:d,onNodesChange:f,nodeLookup:m,fitViewQueued:h}=e.getState();let E=l;for(const y of s)E=typeof y=="function"?y(E):y;const b=mle({items:E,lookup:m});d&&u(E),b.length>0?f==null||f(b):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:v,setNodes:C}=e.getState();y&&C(v)})},[]),r=ble(n),a=N.useCallback(s=>{const{edges:l=[],setEdges:u,hasDefaultEdges:d,onEdgesChange:f,edgeLookup:m}=e.getState();let h=l;for(const E of s)h=typeof E=="function"?E(h):E;d?u(h):f&&f(mle({items:h,lookup:m}))},[]),i=ble(a),o=N.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return A.jsx(Ele.Provider,{value:o,children:t})}function yHe(){const t=N.useContext(Ele);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const THe=t=>!!t.panZoom;function rB(){const t=gHe(),e=Er(),n=yHe(),r=dn(THe),a=N.useMemo(()=>{const i=f=>e.getState().nodeLookup.get(f),o=f=>{n.nodeQueue.push(f)},s=f=>{n.edgeQueue.push(f)},l=f=>{var v,C;const{nodeLookup:m,nodeOrigin:h}=e.getState(),E=gle(f)?f:m.get(f.id),b=E.parentId?Ese(E.position,E.measured,E.parentId,m,h):E.position,y={...E,position:b,width:((v=E.measured)==null?void 0:v.width)??E.width,height:((C=E.measured)==null?void 0:C.height)??E.height};return Sg(y)},u=(f,m,h={replace:!1})=>{o(E=>E.map(b=>{if(b.id===f){const y=typeof m=="function"?m(b):m;return h.replace&&gle(y)?y:{...b,...y}}return b}))},d=(f,m,h={replace:!1})=>{s(E=>E.map(b=>{if(b.id===f){const y=typeof m=="function"?m(b):m;return h.replace&&bHe(y)?y:{...b,...y}}return b}))};return{getNodes:()=>e.getState().nodes.map(f=>({...f})),getNode:f=>{var m;return(m=i(f))==null?void 0:m.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:f=[]}=e.getState();return f.map(m=>({...m}))},getEdge:f=>e.getState().edgeLookup.get(f),setNodes:o,setEdges:s,addNodes:f=>{const m=Array.isArray(f)?f:[f];n.nodeQueue.push(h=>[...h,...m])},addEdges:f=>{const m=Array.isArray(f)?f:[f];n.edgeQueue.push(h=>[...h,...m])},toObject:()=>{const{nodes:f=[],edges:m=[],transform:h}=e.getState(),[E,b,y]=h;return{nodes:f.map(v=>({...v})),edges:m.map(v=>({...v})),viewport:{x:E,y:b,zoom:y}}},deleteElements:async({nodes:f=[],edges:m=[]})=>{const{nodes:h,edges:E,onNodesDelete:b,onEdgesDelete:y,triggerNodeChanges:v,triggerEdgeChanges:C,onDelete:T,onBeforeDelete:w}=e.getState(),{nodes:I,edges:x}=await Kze({nodesToRemove:f,edgesToRemove:m,nodes:h,edges:E,onBeforeDelete:w}),D=x.length>0,M=I.length>0;if(D){const F=x.map(hle);y==null||y(x),C(F)}if(M){const F=I.map(hle);b==null||b(I),v(F)}return(M||D)&&(T==null||T({nodes:I,edges:x})),{deletedNodes:I,deletedEdges:x}},getIntersectingNodes:(f,m=!0,h)=>{const E=_se(f),b=E?f:l(f),y=h!==void 0;return b?(h||e.getState().nodes).filter(v=>{const C=e.getState().nodeLookup.get(v.id);if(C&&!E&&(v.id===f.id||!C.internals.positionAbsolute))return!1;const T=Sg(y?v:C),w=wE(T,b);return m&&w>0||w>=T.width*T.height||w>=b.width*b.height}):[]},isNodeIntersecting:(f,m,h=!0)=>{const b=_se(f)?f:l(f);if(!b)return!1;const y=wE(b,m);return h&&y>0||y>=m.width*m.height||y>=b.width*b.height},updateNode:u,updateNodeData:(f,m,h={replace:!1})=>{u(f,E=>{const b=typeof m=="function"?m(E):m;return h.replace?{...E,data:b}:{...E,data:{...E.data,...b}}},h)},updateEdge:d,updateEdgeData:(f,m,h={replace:!1})=>{d(f,E=>{const b=typeof m=="function"?m(E):m;return h.replace?{...E,data:b}:{...E,data:{...E.data,...b}}},h)},getNodesBounds:f=>{const{nodeLookup:m,nodeOrigin:h}=e.getState();return Yze(f,{nodeLookup:m,nodeOrigin:h})},getHandleConnections:({type:f,id:m,nodeId:h})=>{var E;return Array.from(((E=e.getState().connectionLookup.get(`${h}-${f}${m?`-${m}`:""}`))==null?void 0:E.values())??[])},getNodeConnections:({type:f,handleId:m,nodeId:h})=>{var E;return Array.from(((E=e.getState().connectionLookup.get(`${h}${f?m?`-${f}-${m}`:`-${f}`:""}`))==null?void 0:E.values())??[])},fitView:async f=>{const m=e.getState().fitViewResolver??Jze();return e.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:m}),n.nodeQueue.push(h=>[...h]),m.promise}}},[]);return N.useMemo(()=>({...a,...t,viewportInitialized:r}),[r])}const Sle=t=>t.selected,CHe=typeof window<"u"?window:void 0;function AHe({deleteKeyCode:t,multiSelectionKeyCode:e}){const n=Er(),{deleteElements:r}=rB(),a=kE(t,{actInsideInputWithModifier:!1}),i=kE(e,{target:CHe});N.useEffect(()=>{if(a){const{edges:o,nodes:s}=n.getState();r({nodes:s.filter(Sle),edges:o.filter(Sle)}),n.setState({nodesSelectionActive:!1})}},[a]),N.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function RHe(t){const e=Er();N.useEffect(()=>{const n=()=>{var a,i,o,s;if(!t.current||!(((i=(a=t.current).checkVisibility)==null?void 0:i.call(a))??!0))return!1;const r=H5(t.current);(r.height===0||r.width===0)&&((s=(o=e.getState()).onError)==null||s.call(o,"004",Gl.error004())),e.setState({width:r.width||500,height:r.height||500})};if(t.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(t.current),()=>{window.removeEventListener("resize",n),r&&t.current&&r.unobserve(t.current)}}},[])}const GA={position:"absolute",width:"100%",height:"100%",top:0,left:0},wHe=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function xHe({onPaneContextMenu:t,zoomOnScroll:e=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:a=.5,panOnScrollMode:i=If.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:m,preventScrolling:h=!0,children:E,noWheelClassName:b,noPanClassName:y,onViewportChange:v,isControlledViewport:C,paneClickDistance:T}){const w=Er(),I=N.useRef(null),{userSelectionActive:x,lib:D,connectionInProgress:M}=dn(wHe,Nr),F=kE(m),P=N.useRef();RHe(I);const q=N.useCallback(j=>{v==null||v({x:j[0],y:j[1],zoom:j[2]}),C||w.setState({transform:j})},[v,C]);return N.useEffect(()=>{if(I.current){P.current=Lqe({domNode:I.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,paneClickDistance:T,onDraggingChange:W=>w.setState({paneDragging:W}),onPanZoomStart:(W,G)=>{const{onViewportChangeStart:Y,onMoveStart:K}=w.getState();K==null||K(W,G),Y==null||Y(G)},onPanZoom:(W,G)=>{const{onViewportChange:Y,onMove:K}=w.getState();K==null||K(W,G),Y==null||Y(G)},onPanZoomEnd:(W,G)=>{const{onViewportChangeEnd:Y,onMoveEnd:K}=w.getState();K==null||K(W,G),Y==null||Y(G)}});const{x:j,y:X,zoom:B}=P.current.getViewport();return w.setState({panZoom:P.current,transform:[j,X,B],domNode:I.current.closest(".react-flow")}),()=>{var W;(W=P.current)==null||W.destroy()}}},[]),N.useEffect(()=>{var j;(j=P.current)==null||j.update({onPaneContextMenu:t,zoomOnScroll:e,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:a,panOnScrollMode:i,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:F,preventScrolling:h,noPanClassName:y,userSelectionActive:x,noWheelClassName:b,lib:D,onTransformChange:q,connectionInProgress:M})},[t,e,n,r,a,i,o,s,F,h,y,x,b,D,q,M]),A.jsx("div",{className:"react-flow__renderer",ref:I,style:GA,children:E})}const NHe=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function OHe(){const{userSelectionActive:t,userSelectionRect:e}=dn(NHe,Nr);return t&&e?A.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}const aB=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},IHe=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,connectionInProgress:t.connection.inProgress,dragging:t.paneDragging});function DHe({isSelecting:t,selectionKeyPressed:e,selectionMode:n=CE.Full,panOnDrag:r,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:o,onPaneClick:s,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:m,children:h}){const E=Er(),{userSelectionActive:b,elementsSelectable:y,dragging:v,connectionInProgress:C}=dn(IHe,Nr),T=y&&(t||b),w=N.useRef(null),I=N.useRef(),x=N.useRef(new Set),D=N.useRef(new Set),M=N.useRef(!1),F=N.useRef(!1),P=Y=>{if(M.current||C){M.current=!1;return}s==null||s(Y),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},q=Y=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){Y.preventDefault();return}l==null||l(Y)},j=u?Y=>u(Y):void 0,X=Y=>{var te,U;const{resetSelectedElements:K,domNode:J}=E.getState();if(I.current=J==null?void 0:J.getBoundingClientRect(),!y||!t||Y.button!==0||Y.target!==w.current||!I.current)return;(U=(te=Y.target)==null?void 0:te.setPointerCapture)==null||U.call(te,Y.pointerId),F.current=!0,M.current=!1;const{x:$,y:Z}=Ws(Y.nativeEvent,I.current);K(),E.setState({userSelectionRect:{width:0,height:0,startX:$,startY:Z,x:$,y:Z}}),i==null||i(Y)},B=Y=>{const{userSelectionRect:K,transform:J,nodeLookup:$,edgeLookup:Z,connectionLookup:te,triggerNodeChanges:U,triggerEdgeChanges:ie,defaultEdgeOptions:se}=E.getState();if(!I.current||!K)return;M.current=!0;const{x:ue,y:ae}=Ws(Y.nativeEvent,I.current),{startX:ce,startY:ge}=K,Ee={startX:ce,startY:ge,x:ue<ce?ue:ce,y:ae<ge?ae:ge,width:Math.abs(ue-ce),height:Math.abs(ae-ge)},we=x.current,_e=D.current;x.current=new Set(G5($,Ee,J,n===CE.Partial,!0).map(Re=>Re.id)),D.current=new Set;const me=(se==null?void 0:se.selectable)??!0;for(const Re of x.current){const Pe=te.get(Re);if(Pe)for(const{edgeId:Be}of Pe.values()){const it=Z.get(Be);it&&(it.selectable??me)&&D.current.add(Be)}}if(!Sse(we,x.current)){const Re=Ag($,x.current,!0);U(Re)}if(!Sse(_e,D.current)){const Re=Ag(Z,D.current);ie(Re)}E.setState({userSelectionRect:Ee,userSelectionActive:!0,nodesSelectionActive:!1})},W=Y=>{var J,$;if(Y.button!==0||!F.current)return;($=(J=Y.target)==null?void 0:J.releasePointerCapture)==null||$.call(J,Y.pointerId);const{userSelectionRect:K}=E.getState();!b&&K&&Y.target===w.current&&(P==null||P(Y)),E.setState({userSelectionActive:!1,userSelectionRect:null,nodesSelectionActive:x.current.size>0}),o==null||o(Y),(e||a)&&(M.current=!1),F.current=!1},G=r===!0||Array.isArray(r)&&r.includes(0);return A.jsxs("div",{className:ra(["react-flow__pane",{draggable:G,dragging:v,selection:t}]),onClick:T?void 0:aB(P,w),onContextMenu:aB(q,w),onWheel:aB(j,w),onPointerEnter:T?void 0:d,onPointerDown:T?X:f,onPointerMove:T?B:f,onPointerUp:T?W:void 0,onPointerLeave:m,ref:w,style:GA,children:[h,A.jsx(OHe,{})]})}function iB({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:a,unselectNodesAndEdges:i,multiSelectionActive:o,nodeLookup:s,onError:l}=e.getState(),u=s.get(t);if(!u){l==null||l("012",Gl.error012(t));return}e.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&o)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):a([t])}function vle({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:a,isSelectable:i,nodeClickDistance:o}){const s=Er(),[l,u]=N.useState(!1),d=N.useRef();return N.useEffect(()=>{d.current=Sqe({getStoreItems:()=>s.getState(),onNodeMouseDown:f=>{iB({id:f,store:s,nodeRef:t})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),N.useEffect(()=>{var f,m;if(e)(f=d.current)==null||f.destroy();else if(t.current)return(m=d.current)==null||m.update({noDragClassName:n,handleSelector:r,domNode:t.current,isSelectable:i,nodeId:a,nodeClickDistance:o}),()=>{var h;(h=d.current)==null||h.destroy()}},[n,r,e,i,t,a]),l}const kHe=t=>e=>e.selected&&(e.draggable||t&&typeof e.draggable>"u");function yle(){const t=Er();return N.useCallback(n=>{const{nodeExtent:r,snapToGrid:a,snapGrid:i,nodesDraggable:o,onError:s,updateNodePositions:l,nodeLookup:u,nodeOrigin:d}=t.getState(),f=new Map,m=kHe(o),h=a?i[0]:5,E=a?i[1]:5,b=n.direction.x*h*n.factor,y=n.direction.y*E*n.factor;for(const[,v]of u){if(!m(v))continue;let C={x:v.internals.positionAbsolute.x+b,y:v.internals.positionAbsolute.y+y};a&&(C=xE(C,i));const{position:T,positionAbsolute:w}=pse({nodeId:v.id,nextPosition:C,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:s});v.position=T,v.internals.positionAbsolute=w,f.set(v.id,v)}l(f)},[])}const oB=N.createContext(null),MHe=oB.Provider;oB.Consumer;const Tle=()=>N.useContext(oB),LHe=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),PHe=(t,e,n)=>r=>{const{connectionClickStartHandle:a,connectionMode:i,connection:o}=r,{fromHandle:s,toHandle:l,isValid:u}=o,d=(l==null?void 0:l.nodeId)===t&&(l==null?void 0:l.id)===e&&(l==null?void 0:l.type)===n;return{connectingFrom:(s==null?void 0:s.nodeId)===t&&(s==null?void 0:s.id)===e&&(s==null?void 0:s.type)===n,connectingTo:d,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===e&&(a==null?void 0:a.type)===n,isPossibleEndHandle:i===_g.Strict?(s==null?void 0:s.type)!==n:t!==(s==null?void 0:s.nodeId)||e!==(s==null?void 0:s.id),connectionInProcess:!!s,clickConnectionInProcess:!!a,valid:d&&u}};function FHe({type:t="source",position:e=bt.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:a=!0,isConnectableEnd:i=!0,id:o,onConnect:s,children:l,className:u,onMouseDown:d,onTouchStart:f,...m},h){var W,G;const E=o||null,b=t==="target",y=Er(),v=Tle(),{connectOnClick:C,noPanClassName:T,rfId:w}=dn(LHe,Nr),{connectingFrom:I,connectingTo:x,clickConnecting:D,isPossibleEndHandle:M,connectionInProcess:F,clickConnectionInProcess:P,valid:q}=dn(PHe(v,E,t),Nr);v||(G=(W=y.getState()).onError)==null||G.call(W,"010",Gl.error010());const j=Y=>{const{defaultEdgeOptions:K,onConnect:J,hasDefaultEdges:$}=y.getState(),Z={...K,...Y};if($){const{edges:te,setEdges:U}=y.getState();U(Nse(Z,te))}J==null||J(Z),s==null||s(Z)},X=Y=>{if(!v)return;const K=Tse(Y.nativeEvent);if(a&&(K&&Y.button===0||!K)){const J=y.getState();Z5.onPointerDown(Y.nativeEvent,{handleDomNode:Y.currentTarget,autoPanOnConnect:J.autoPanOnConnect,connectionMode:J.connectionMode,connectionRadius:J.connectionRadius,domNode:J.domNode,nodeLookup:J.nodeLookup,lib:J.lib,isTarget:b,handleId:E,nodeId:v,flowId:J.rfId,panBy:J.panBy,cancelConnection:J.cancelConnection,onConnectStart:J.onConnectStart,onConnectEnd:J.onConnectEnd,updateConnection:J.updateConnection,onConnect:j,isValidConnection:n||J.isValidConnection,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:J.autoPanSpeed,dragThreshold:J.connectionDragThreshold})}K?d==null||d(Y):f==null||f(Y)},B=Y=>{const{onClickConnectStart:K,onClickConnectEnd:J,connectionClickStartHandle:$,connectionMode:Z,isValidConnection:te,lib:U,rfId:ie,nodeLookup:se,connection:ue}=y.getState();if(!v||!$&&!a)return;if(!$){K==null||K(Y.nativeEvent,{nodeId:v,handleId:E,handleType:t}),y.setState({connectionClickStartHandle:{nodeId:v,type:t,id:E}});return}const ae=vse(Y.target),ce=n||te,{connection:ge,isValid:Ee}=Z5.isValid(Y.nativeEvent,{handle:{nodeId:v,id:E,type:t},connectionMode:Z,fromNodeId:$.nodeId,fromHandleId:$.id||null,fromType:$.type,isValidConnection:ce,flowId:ie,doc:ae,lib:U,nodeLookup:se});Ee&&ge&&j(ge);const we=structuredClone(ue);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,J==null||J(Y,we),y.setState({connectionClickStartHandle:null})};return A.jsx("div",{"data-handleid":E,"data-nodeid":v,"data-handlepos":e,"data-id":`${w}-${v}-${E}-${t}`,className:ra(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",T,u,{source:!b,target:b,connectable:r,connectablestart:a,connectableend:i,clickconnecting:D,connectingfrom:I,connectingto:x,valid:q,connectionindicator:r&&(!F||M)&&(F||P?i:a)}]),onMouseDown:X,onTouchStart:X,onClick:C?B:void 0,ref:h,...m,children:l})}const zl=N.memo(_le(FHe));function BHe({data:t,isConnectable:e,sourcePosition:n=bt.Bottom}){return A.jsxs(A.Fragment,{children:[t==null?void 0:t.label,A.jsx(zl,{type:"source",position:n,isConnectable:e})]})}function UHe({data:t,isConnectable:e,targetPosition:n=bt.Top,sourcePosition:r=bt.Bottom}){return A.jsxs(A.Fragment,{children:[A.jsx(zl,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,A.jsx(zl,{type:"source",position:r,isConnectable:e})]})}function GHe(){return null}function zHe({data:t,isConnectable:e,targetPosition:n=bt.Top}){return A.jsxs(A.Fragment,{children:[A.jsx(zl,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label]})}const zA={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Cle={input:BHe,default:UHe,output:zHe,group:GHe};function qHe(t){var e,n,r,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((e=t.style)==null?void 0:e.width),height:t.height??t.initialHeight??((n=t.style)==null?void 0:n.height)}:{width:t.width??((r=t.style)==null?void 0:r.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const HHe=t=>{const{width:e,height:n,x:r,y:a}=RE(t.nodeLookup,{filter:i=>!!i.selected});return{width:js(e)?e:null,height:js(n)?n:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${r}px,${a}px)`}};function $He({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=Er(),{width:a,height:i,transformString:o,userSelectionActive:s}=dn(HHe,Nr),l=yle(),u=N.useRef(null);if(N.useEffect(()=>{var m;n||(m=u.current)==null||m.focus({preventScroll:!0})},[n]),vle({nodeRef:u}),s||!a||!i)return null;const d=t?m=>{const h=r.getState().nodes.filter(E=>E.selected);t(m,h)}:void 0,f=m=>{Object.prototype.hasOwnProperty.call(zA,m.key)&&(m.preventDefault(),l({direction:zA[m.key],factor:m.shiftKey?4:1}))};return A.jsx("div",{className:ra(["react-flow__nodesselection","react-flow__container",e]),style:{transform:o},children:A.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:a,height:i}})})}const Ale=typeof window<"u"?window:void 0,YHe=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Rle({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:l,selectionKeyCode:u,selectionOnDrag:d,selectionMode:f,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:E,panActivationKeyCode:b,zoomActivationKeyCode:y,elementsSelectable:v,zoomOnScroll:C,zoomOnPinch:T,panOnScroll:w,panOnScrollSpeed:I,panOnScrollMode:x,zoomOnDoubleClick:D,panOnDrag:M,defaultViewport:F,translateExtent:P,minZoom:q,maxZoom:j,preventScrolling:X,onSelectionContextMenu:B,noWheelClassName:W,noPanClassName:G,disableKeyboardA11y:Y,onViewportChange:K,isControlledViewport:J}){const{nodesSelectionActive:$,userSelectionActive:Z}=dn(YHe),te=kE(u,{target:Ale}),U=kE(b,{target:Ale}),ie=U||M,se=U||w,ue=d&&ie!==!0,ae=te||Z||ue;return AHe({deleteKeyCode:l,multiSelectionKeyCode:E}),A.jsx(xHe,{onPaneContextMenu:i,elementsSelectable:v,zoomOnScroll:C,zoomOnPinch:T,panOnScroll:se,panOnScrollSpeed:I,panOnScrollMode:x,zoomOnDoubleClick:D,panOnDrag:!te&&ie,defaultViewport:F,translateExtent:P,minZoom:q,maxZoom:j,zoomActivationKeyCode:y,preventScrolling:X,noWheelClassName:W,noPanClassName:G,onViewportChange:K,isControlledViewport:J,paneClickDistance:s,children:A.jsxs(DHe,{onSelectionStart:m,onSelectionEnd:h,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:o,panOnDrag:ie,isSelecting:!!ae,selectionMode:f,selectionKeyPressed:te,selectionOnDrag:ue,children:[t,$&&A.jsx($He,{onSelectionContextMenu:B,noPanClassName:G,disableKeyboardA11y:Y})]})})}Rle.displayName="FlowRenderer";const VHe=N.memo(Rle),jHe=t=>e=>t?G5(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(n=>n.id):Array.from(e.nodeLookup.keys());function WHe(t){return dn(N.useCallback(jHe(t),[t]),Nr)}const KHe=t=>t.updateNodeInternals;function XHe(){const t=dn(KHe),[e]=N.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(a=>{const i=a.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:a.target,force:!0})}),t(r)}));return N.useEffect(()=>()=>{e==null||e.disconnect()},[e]),e}function QHe({node:t,nodeType:e,hasDimensions:n,resizeObserver:r}){const a=Er(),i=N.useRef(null),o=N.useRef(null),s=N.useRef(t.sourcePosition),l=N.useRef(t.targetPosition),u=N.useRef(e),d=n&&!!t.internals.handleBounds;return N.useEffect(()=>{i.current&&!t.hidden&&(!d||o.current!==i.current)&&(o.current&&(r==null||r.unobserve(o.current)),r==null||r.observe(i.current),o.current=i.current)},[d,t.hidden]),N.useEffect(()=>()=>{o.current&&(r==null||r.unobserve(o.current),o.current=null)},[]),N.useEffect(()=>{if(i.current){const f=u.current!==e,m=s.current!==t.sourcePosition,h=l.current!==t.targetPosition;(f||m||h)&&(u.current=e,s.current=t.sourcePosition,l.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:i.current,force:!0}]])))}},[t.id,e,t.sourcePosition,t.targetPosition]),i}function ZHe({id:t,onClick:e,onMouseEnter:n,onMouseMove:r,onMouseLeave:a,onContextMenu:i,onDoubleClick:o,nodesDraggable:s,elementsSelectable:l,nodesConnectable:u,nodesFocusable:d,resizeObserver:f,noDragClassName:m,noPanClassName:h,disableKeyboardA11y:E,rfId:b,nodeTypes:y,nodeClickDistance:v,onError:C}){const{node:T,internals:w,isParent:I}=dn(ce=>{const ge=ce.nodeLookup.get(t),Ee=ce.parentLookup.has(t);return{node:ge,internals:ge.internals,isParent:Ee}},Nr);let x=T.type||"default",D=(y==null?void 0:y[x])||Cle[x];D===void 0&&(C==null||C("003",Gl.error003(x)),x="default",D=(y==null?void 0:y.default)||Cle.default);const M=!!(T.draggable||s&&typeof T.draggable>"u"),F=!!(T.selectable||l&&typeof T.selectable>"u"),P=!!(T.connectable||u&&typeof T.connectable>"u"),q=!!(T.focusable||d&&typeof T.focusable>"u"),j=Er(),X=bse(T),B=QHe({node:T,nodeType:x,hasDimensions:X,resizeObserver:f}),W=vle({nodeRef:B,disabled:T.hidden||!M,noDragClassName:m,handleSelector:T.dragHandle,nodeId:t,isSelectable:F,nodeClickDistance:v}),G=yle();if(T.hidden)return null;const Y=qc(T),K=qHe(T),J=F||M||e||n||r||a,$=n?ce=>n(ce,{...w.userNode}):void 0,Z=r?ce=>r(ce,{...w.userNode}):void 0,te=a?ce=>a(ce,{...w.userNode}):void 0,U=i?ce=>i(ce,{...w.userNode}):void 0,ie=o?ce=>o(ce,{...w.userNode}):void 0,se=ce=>{const{selectNodesOnDrag:ge,nodeDragThreshold:Ee}=j.getState();F&&(!ge||!M||Ee>0)&&iB({id:t,store:j,nodeRef:B}),e&&e(ce,{...w.userNode})},ue=ce=>{if(!(yse(ce.nativeEvent)||E)){if(ose.includes(ce.key)&&F){const ge=ce.key==="Escape";iB({id:t,store:j,unselect:ge,nodeRef:B})}else if(M&&T.selected&&Object.prototype.hasOwnProperty.call(zA,ce.key)){ce.preventDefault();const{ariaLabelConfig:ge}=j.getState();j.setState({ariaLiveMessage:ge["node.a11yDescription.ariaLiveMessage"]({direction:ce.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),G({direction:zA[ce.key],factor:ce.shiftKey?4:1})}}},ae=()=>{var Re;if(E||!((Re=B.current)!=null&&Re.matches(":focus-visible")))return;const{transform:ce,width:ge,height:Ee,autoPanOnNodeFocus:we,setCenter:_e}=j.getState();if(!we)return;G5(new Map([[t,T]]),{x:0,y:0,width:ge,height:Ee},ce,!0).length>0||_e(T.position.x+Y.width/2,T.position.y+Y.height/2,{zoom:ce[2]})};return A.jsx("div",{className:ra(["react-flow__node",`react-flow__node-${x}`,{[h]:M},T.className,{selected:T.selected,selectable:F,parent:I,draggable:M,dragging:W}]),ref:B,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:J?"all":"none",visibility:X?"visible":"hidden",...T.style,...K},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:$,onMouseMove:Z,onMouseLeave:te,onContextMenu:U,onClick:se,onDoubleClick:ie,onKeyDown:q?ue:void 0,tabIndex:q?0:void 0,onFocus:q?ae:void 0,role:T.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":E?void 0:`${nle}-${b}`,"aria-label":T.ariaLabel,...T.domAttributes,children:A.jsx(MHe,{value:t,children:A.jsx(D,{id:t,data:T.data,type:x,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:T.selected??!1,selectable:F,draggable:M,deletable:T.deletable??!0,isConnectable:P,sourcePosition:T.sourcePosition,targetPosition:T.targetPosition,dragging:W,dragHandle:T.dragHandle,zIndex:w.z,parentId:T.parentId,...Y})})})}const JHe=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function wle(t){const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:a,onError:i}=dn(JHe,Nr),o=WHe(t.onlyRenderVisibleElements),s=XHe();return A.jsx("div",{className:"react-flow__nodes",style:GA,children:o.map(l=>A.jsx(ZHe,{id:l,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:a,nodeClickDistance:t.nodeClickDistance,onError:i},l))})}wle.displayName="NodeRenderer";const e$e=N.memo(wle);function t$e(t){return dn(N.useCallback(n=>{if(!t)return n.edges.map(a=>a.id);const r=[];if(n.width&&n.height)for(const a of n.edges){const i=n.nodeLookup.get(a.source),o=n.nodeLookup.get(a.target);i&&o&&rqe({sourceNode:i,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&r.push(a.id)}return r},[t]),Nr)}const n$e=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t}};return A.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},r$e=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t,fill:t}};return A.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},xle={[bg.Arrow]:n$e,[bg.ArrowClosed]:r$e};function a$e(t){const e=Er();return N.useMemo(()=>{var a,i;return Object.prototype.hasOwnProperty.call(xle,t)?xle[t]:((i=(a=e.getState()).onError)==null||i.call(a,"009",Gl.error009(t)),null)},[t])}const i$e=({id:t,type:e,color:n,width:r=12.5,height:a=12.5,markerUnits:i="strokeWidth",strokeWidth:o,orient:s="auto-start-reverse"})=>{const l=a$e(e);return l?A.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:s,refX:"0",refY:"0",children:A.jsx(l,{color:n,strokeWidth:o})}):null},Nle=({defaultColor:t,rfId:e})=>{const n=dn(i=>i.edges),r=dn(i=>i.defaultEdgeOptions),a=N.useMemo(()=>uqe(n,{id:e,defaultColor:t,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,e,t]);return a.length?A.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:A.jsx("defs",{children:a.map(i=>A.jsx(i$e,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Nle.displayName="MarkerDefinitions";var o$e=N.memo(Nle);function Ole({x:t,y:e,label:n,labelStyle:r,labelShowBg:a=!0,labelBgStyle:i,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:l,className:u,...d}){const[f,m]=N.useState({x:1,y:0,width:0,height:0}),h=ra(["react-flow__edge-textwrapper",u]),E=N.useRef(null);return N.useEffect(()=>{if(E.current){const b=E.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?A.jsxs("g",{transform:`translate(${t-f.width/2} ${e-f.height/2})`,className:h,visibility:f.width?"visible":"hidden",...d,children:[a&&A.jsx("rect",{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:"react-flow__edge-textbg",style:i,rx:s,ry:s}),A.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:E,style:r,children:n}),l]}):null}Ole.displayName="EdgeText";const s$e=N.memo(Ole);function qA({path:t,labelX:e,labelY:n,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:l,interactionWidth:u=20,...d}){return A.jsxs(A.Fragment,{children:[A.jsx("path",{...d,d:t,fill:"none",className:ra(["react-flow__edge-path",d.className])}),u?A.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&js(e)&&js(n)?A.jsx(s$e,{x:e,y:n,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:l}):null]})}function Ile({pos:t,x1:e,y1:n,x2:r,y2:a}){return t===bt.Left||t===bt.Right?[.5*(e+r),n]:[e,.5*(n+a)]}function Dle({sourceX:t,sourceY:e,sourcePosition:n=bt.Bottom,targetX:r,targetY:a,targetPosition:i=bt.Top}){const[o,s]=Ile({pos:n,x1:t,y1:e,x2:r,y2:a}),[l,u]=Ile({pos:i,x1:r,y1:a,x2:t,y2:e}),[d,f,m,h]=Ase({sourceX:t,sourceY:e,targetX:r,targetY:a,sourceControlX:o,sourceControlY:s,targetControlX:l,targetControlY:u});return[`M${t},${e} C${o},${s} ${l},${u} ${r},${a}`,d,f,m,h]}function kle(t){return N.memo(({id:e,sourceX:n,sourceY:r,targetX:a,targetY:i,sourcePosition:o,targetPosition:s,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:h,style:E,markerEnd:b,markerStart:y,interactionWidth:v})=>{const[C,T,w]=Dle({sourceX:n,sourceY:r,sourcePosition:o,targetX:a,targetY:i,targetPosition:s}),I=t.isInternal?void 0:e;return A.jsx(qA,{id:I,path:C,labelX:T,labelY:w,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:h,style:E,markerEnd:b,markerStart:y,interactionWidth:v})})}const l$e=kle({isInternal:!1}),Mle=kle({isInternal:!0});l$e.displayName="SimpleBezierEdge",Mle.displayName="SimpleBezierEdgeInternal";function Lle(t){return N.memo(({id:e,sourceX:n,sourceY:r,targetX:a,targetY:i,label:o,labelStyle:s,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:m,sourcePosition:h=bt.Bottom,targetPosition:E=bt.Top,markerEnd:b,markerStart:y,pathOptions:v,interactionWidth:C})=>{const[T,w,I]=$5({sourceX:n,sourceY:r,sourcePosition:h,targetX:a,targetY:i,targetPosition:E,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),x=t.isInternal?void 0:e;return A.jsx(qA,{id:x,path:T,labelX:w,labelY:I,label:o,labelStyle:s,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:m,markerEnd:b,markerStart:y,interactionWidth:C})})}const Ple=Lle({isInternal:!1}),Fle=Lle({isInternal:!0});Ple.displayName="SmoothStepEdge",Fle.displayName="SmoothStepEdgeInternal";function Ble(t){return N.memo(({id:e,...n})=>{var a;const r=t.isInternal?void 0:e;return A.jsx(Ple,{...n,id:r,pathOptions:N.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(a=n.pathOptions)==null?void 0:a.offset])})})}const c$e=Ble({isInternal:!1}),Ule=Ble({isInternal:!0});c$e.displayName="StepEdge",Ule.displayName="StepEdgeInternal";function Gle(t){return N.memo(({id:e,sourceX:n,sourceY:r,targetX:a,targetY:i,label:o,labelStyle:s,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:m,markerEnd:h,markerStart:E,interactionWidth:b})=>{const[y,v,C]=Ose({sourceX:n,sourceY:r,targetX:a,targetY:i}),T=t.isInternal?void 0:e;return A.jsx(qA,{id:T,path:y,labelX:v,labelY:C,label:o,labelStyle:s,labelShowBg:l,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:m,markerEnd:h,markerStart:E,interactionWidth:b})})}const u$e=Gle({isInternal:!1}),zle=Gle({isInternal:!0});u$e.displayName="StraightEdge",zle.displayName="StraightEdgeInternal";function qle(t){return N.memo(({id:e,sourceX:n,sourceY:r,targetX:a,targetY:i,sourcePosition:o=bt.Bottom,targetPosition:s=bt.Top,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:h,style:E,markerEnd:b,markerStart:y,pathOptions:v,interactionWidth:C})=>{const[T,w,I]=wse({sourceX:n,sourceY:r,sourcePosition:o,targetX:a,targetY:i,targetPosition:s,curvature:v==null?void 0:v.curvature}),x=t.isInternal?void 0:e;return A.jsx(qA,{id:x,path:T,labelX:w,labelY:I,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:h,style:E,markerEnd:b,markerStart:y,interactionWidth:C})})}const d$e=qle({isInternal:!1}),Hle=qle({isInternal:!0});d$e.displayName="BezierEdge",Hle.displayName="BezierEdgeInternal";const $le={default:Hle,straight:zle,step:Ule,smoothstep:Fle,simplebezier:Mle},Yle={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},p$e=(t,e,n)=>n===bt.Left?t-e:n===bt.Right?t+e:t,f$e=(t,e,n)=>n===bt.Top?t-e:n===bt.Bottom?t+e:t,Vle="react-flow__edgeupdater";function jle({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:a,onMouseEnter:i,onMouseOut:o,type:s}){return A.jsx("circle",{onMouseDown:a,onMouseEnter:i,onMouseOut:o,className:ra([Vle,`${Vle}-${s}`]),cx:p$e(e,r,t),cy:f$e(n,r,t),r,stroke:"transparent",fill:"transparent"})}function m$e({isReconnectable:t,reconnectRadius:e,edge:n,sourceX:r,sourceY:a,targetX:i,targetY:o,sourcePosition:s,targetPosition:l,onReconnect:u,onReconnectStart:d,onReconnectEnd:f,setReconnecting:m,setUpdateHover:h}){const E=Er(),b=(w,I)=>{if(w.button!==0)return;const{autoPanOnConnect:x,domNode:D,isValidConnection:M,connectionMode:F,connectionRadius:P,lib:q,onConnectStart:j,onConnectEnd:X,cancelConnection:B,nodeLookup:W,rfId:G,panBy:Y,updateConnection:K}=E.getState(),J=I.type==="target",$=(U,ie)=>{m(!1),f==null||f(U,n,I.type,ie)},Z=U=>u==null?void 0:u(n,U),te=(U,ie)=>{m(!0),d==null||d(w,n,I.type),j==null||j(U,ie)};Z5.onPointerDown(w.nativeEvent,{autoPanOnConnect:x,connectionMode:F,connectionRadius:P,domNode:D,handleId:I.id,nodeId:I.nodeId,nodeLookup:W,isTarget:J,edgeUpdaterType:I.type,lib:q,flowId:G,cancelConnection:B,panBy:Y,isValidConnection:M,onConnect:Z,onConnectStart:te,onConnectEnd:X,onReconnectEnd:$,updateConnection:K,getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,dragThreshold:E.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},y=w=>b(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=w=>b(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),C=()=>h(!0),T=()=>h(!1);return A.jsxs(A.Fragment,{children:[(t===!0||t==="source")&&A.jsx(jle,{position:s,centerX:r,centerY:a,radius:e,onMouseDown:y,onMouseEnter:C,onMouseOut:T,type:"source"}),(t===!0||t==="target")&&A.jsx(jle,{position:l,centerX:i,centerY:o,radius:e,onMouseDown:v,onMouseEnter:C,onMouseOut:T,type:"target"})]})}function h$e({id:t,edgesFocusable:e,edgesReconnectable:n,elementsSelectable:r,onClick:a,onDoubleClick:i,onContextMenu:o,onMouseEnter:s,onMouseMove:l,onMouseLeave:u,reconnectRadius:d,onReconnect:f,onReconnectStart:m,onReconnectEnd:h,rfId:E,edgeTypes:b,noPanClassName:y,onError:v,disableKeyboardA11y:C}){let T=dn(_e=>_e.edgeLookup.get(t));const w=dn(_e=>_e.defaultEdgeOptions);T=w?{...w,...T}:T;let I=T.type||"default",x=(b==null?void 0:b[I])||$le[I];x===void 0&&(v==null||v("011",Gl.error011(I)),I="default",x=(b==null?void 0:b.default)||$le.default);const D=!!(T.focusable||e&&typeof T.focusable>"u"),M=typeof f<"u"&&(T.reconnectable||n&&typeof T.reconnectable>"u"),F=!!(T.selectable||r&&typeof T.selectable>"u"),P=N.useRef(null),[q,j]=N.useState(!1),[X,B]=N.useState(!1),W=Er(),{zIndex:G,sourceX:Y,sourceY:K,targetX:J,targetY:$,sourcePosition:Z,targetPosition:te}=dn(N.useCallback(_e=>{const me=_e.nodeLookup.get(T.source),Re=_e.nodeLookup.get(T.target);if(!me||!Re)return{zIndex:T.zIndex,...Yle};const Pe=cqe({id:t,sourceNode:me,targetNode:Re,sourceHandle:T.sourceHandle||null,targetHandle:T.targetHandle||null,connectionMode:_e.connectionMode,onError:v});return{zIndex:nqe({selected:T.selected,zIndex:T.zIndex,sourceNode:me,targetNode:Re,elevateOnSelect:_e.elevateEdgesOnSelect}),...Pe||Yle}},[T.source,T.target,T.sourceHandle,T.targetHandle,T.selected,T.zIndex]),Nr),U=N.useMemo(()=>T.markerStart?`url('#${Y5(T.markerStart,E)}')`:void 0,[T.markerStart,E]),ie=N.useMemo(()=>T.markerEnd?`url('#${Y5(T.markerEnd,E)}')`:void 0,[T.markerEnd,E]);if(T.hidden||Y===null||K===null||J===null||$===null)return null;const se=_e=>{var Be;const{addSelectedEdges:me,unselectNodesAndEdges:Re,multiSelectionActive:Pe}=W.getState();F&&(W.setState({nodesSelectionActive:!1}),T.selected&&Pe?(Re({nodes:[],edges:[T]}),(Be=P.current)==null||Be.blur()):me([t])),a&&a(_e,T)},ue=i?_e=>{i(_e,{...T})}:void 0,ae=o?_e=>{o(_e,{...T})}:void 0,ce=s?_e=>{s(_e,{...T})}:void 0,ge=l?_e=>{l(_e,{...T})}:void 0,Ee=u?_e=>{u(_e,{...T})}:void 0,we=_e=>{var me;if(!C&&ose.includes(_e.key)&&F){const{unselectNodesAndEdges:Re,addSelectedEdges:Pe}=W.getState();_e.key==="Escape"?((me=P.current)==null||me.blur(),Re({edges:[T]})):Pe([t])}};return A.jsx("svg",{style:{zIndex:G},children:A.jsxs("g",{className:ra(["react-flow__edge",`react-flow__edge-${I}`,T.className,y,{selected:T.selected,animated:T.animated,inactive:!F&&!a,updating:q,selectable:F}]),onClick:se,onDoubleClick:ue,onContextMenu:ae,onMouseEnter:ce,onMouseMove:ge,onMouseLeave:Ee,onKeyDown:D?we:void 0,tabIndex:D?0:void 0,role:T.ariaRole??(D?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":T.ariaLabel===null?void 0:T.ariaLabel||`Edge from ${T.source} to ${T.target}`,"aria-describedby":D?`${rle}-${E}`:void 0,ref:P,...T.domAttributes,children:[!X&&A.jsx(x,{id:t,source:T.source,target:T.target,type:T.type,selected:T.selected,animated:T.animated,selectable:F,deletable:T.deletable??!0,label:T.label,labelStyle:T.labelStyle,labelShowBg:T.labelShowBg,labelBgStyle:T.labelBgStyle,labelBgPadding:T.labelBgPadding,labelBgBorderRadius:T.labelBgBorderRadius,sourceX:Y,sourceY:K,targetX:J,targetY:$,sourcePosition:Z,targetPosition:te,data:T.data,style:T.style,sourceHandleId:T.sourceHandle,targetHandleId:T.targetHandle,markerStart:U,markerEnd:ie,pathOptions:"pathOptions"in T?T.pathOptions:void 0,interactionWidth:T.interactionWidth}),M&&A.jsx(m$e,{edge:T,isReconnectable:M,reconnectRadius:d,onReconnect:f,onReconnectStart:m,onReconnectEnd:h,sourceX:Y,sourceY:K,targetX:J,targetY:$,sourcePosition:Z,targetPosition:te,setUpdateHover:j,setReconnecting:B})]})})}const g$e=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function Wle({defaultMarkerColor:t,onlyRenderVisibleElements:e,rfId:n,edgeTypes:r,noPanClassName:a,onReconnect:i,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:d,reconnectRadius:f,onEdgeDoubleClick:m,onReconnectStart:h,onReconnectEnd:E,disableKeyboardA11y:b}){const{edgesFocusable:y,edgesReconnectable:v,elementsSelectable:C,onError:T}=dn(g$e,Nr),w=t$e(e);return A.jsxs("div",{className:"react-flow__edges",children:[A.jsx(o$e,{defaultColor:t,rfId:n}),w.map(I=>A.jsx(h$e,{id:I,edgesFocusable:y,edgesReconnectable:v,elementsSelectable:C,noPanClassName:a,onReconnect:i,onContextMenu:o,onMouseEnter:s,onMouseMove:l,onMouseLeave:u,onClick:d,reconnectRadius:f,onDoubleClick:m,onReconnectStart:h,onReconnectEnd:E,rfId:n,onError:T,edgeTypes:r,disableKeyboardA11y:b},I))]})}Wle.displayName="EdgeRenderer";const _$e=N.memo(Wle),b$e=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function E$e({children:t}){const e=dn(b$e);return A.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:e},children:t})}function S$e(t){const e=rB(),n=N.useRef(!1);N.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const v$e=t=>{var e;return(e=t.panZoom)==null?void 0:e.syncViewport};function y$e(t){const e=dn(v$e),n=Er();return N.useEffect(()=>{t&&(e==null||e(t),n.setState({transform:[t.x,t.y,t.zoom]}))},[t,e]),null}function T$e(t){return t.connection.inProgress?{...t.connection,to:NE(t.connection.to,t.transform)}:{...t.connection}}function C$e(t){return T$e}function A$e(t){const e=C$e();return dn(e,Nr)}const R$e=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function w$e({containerStyle:t,style:e,type:n,component:r}){const{nodesConnectable:a,width:i,height:o,isValid:s,inProgress:l}=dn(R$e,Nr);return!(i&&a&&l)?null:A.jsx("svg",{style:t,width:i,height:o,className:"react-flow__connectionline react-flow__container",children:A.jsx("g",{className:ra(["react-flow__connection",use(s)]),children:A.jsx(Kle,{style:e,type:n,CustomComponent:r,isValid:s})})})}const Kle=({style:t,type:e=Ad.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:a,from:i,fromNode:o,fromHandle:s,fromPosition:l,to:u,toNode:d,toHandle:f,toPosition:m}=A$e();if(!a)return;if(n)return A.jsx(n,{connectionLineType:e,connectionLineStyle:t,fromNode:o,fromHandle:s,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:l,toPosition:m,connectionStatus:use(r),toNode:d,toHandle:f});let h="";const E={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:u.x,targetY:u.y,targetPosition:m};switch(e){case Ad.Bezier:[h]=wse(E);break;case Ad.SimpleBezier:[h]=Dle(E);break;case Ad.Step:[h]=$5({...E,borderRadius:0});break;case Ad.SmoothStep:[h]=$5(E);break;default:[h]=Ose(E)}return A.jsx("path",{d:h,fill:"none",className:"react-flow__connection-path",style:t})};Kle.displayName="ConnectionLine";const x$e={};function Xle(t=x$e){N.useRef(t),Er(),N.useEffect(()=>{},[t])}function N$e(){Er(),N.useRef(!1),N.useEffect(()=>{},[])}function Qle({nodeTypes:t,edgeTypes:e,onInit:n,onNodeClick:r,onEdgeClick:a,onNodeDoubleClick:i,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:d,onSelectionContextMenu:f,onSelectionStart:m,onSelectionEnd:h,connectionLineType:E,connectionLineStyle:b,connectionLineComponent:y,connectionLineContainerStyle:v,selectionKeyCode:C,selectionOnDrag:T,selectionMode:w,multiSelectionKeyCode:I,panActivationKeyCode:x,zoomActivationKeyCode:D,deleteKeyCode:M,onlyRenderVisibleElements:F,elementsSelectable:P,defaultViewport:q,translateExtent:j,minZoom:X,maxZoom:B,preventScrolling:W,defaultMarkerColor:G,zoomOnScroll:Y,zoomOnPinch:K,panOnScroll:J,panOnScrollSpeed:$,panOnScrollMode:Z,zoomOnDoubleClick:te,panOnDrag:U,onPaneClick:ie,onPaneMouseEnter:se,onPaneMouseMove:ue,onPaneMouseLeave:ae,onPaneScroll:ce,onPaneContextMenu:ge,paneClickDistance:Ee,nodeClickDistance:we,onEdgeContextMenu:_e,onEdgeMouseEnter:me,onEdgeMouseMove:Re,onEdgeMouseLeave:Pe,reconnectRadius:Be,onReconnect:it,onReconnectStart:Xe,onReconnectEnd:Nt,noDragClassName:Sn,noWheelClassName:en,noPanClassName:Pn,disableKeyboardA11y:wn,nodeExtent:Pt,rfId:cn,viewport:ve,onViewportChange:Ne}){return Xle(t),Xle(e),N$e(),S$e(n),y$e(ve),A.jsx(VHe,{onPaneClick:ie,onPaneMouseEnter:se,onPaneMouseMove:ue,onPaneMouseLeave:ae,onPaneContextMenu:ge,onPaneScroll:ce,paneClickDistance:Ee,deleteKeyCode:M,selectionKeyCode:C,selectionOnDrag:T,selectionMode:w,onSelectionStart:m,onSelectionEnd:h,multiSelectionKeyCode:I,panActivationKeyCode:x,zoomActivationKeyCode:D,elementsSelectable:P,zoomOnScroll:Y,zoomOnPinch:K,zoomOnDoubleClick:te,panOnScroll:J,panOnScrollSpeed:$,panOnScrollMode:Z,panOnDrag:U,defaultViewport:q,translateExtent:j,minZoom:X,maxZoom:B,onSelectionContextMenu:f,preventScrolling:W,noDragClassName:Sn,noWheelClassName:en,noPanClassName:Pn,disableKeyboardA11y:wn,onViewportChange:Ne,isControlledViewport:!!ve,children:A.jsxs(E$e,{children:[A.jsx(_$e,{edgeTypes:e,onEdgeClick:a,onEdgeDoubleClick:o,onReconnect:it,onReconnectStart:Xe,onReconnectEnd:Nt,onlyRenderVisibleElements:F,onEdgeContextMenu:_e,onEdgeMouseEnter:me,onEdgeMouseMove:Re,onEdgeMouseLeave:Pe,reconnectRadius:Be,defaultMarkerColor:G,noPanClassName:Pn,disableKeyboardA11y:wn,rfId:cn}),A.jsx(w$e,{style:b,type:E,component:y,containerStyle:v}),A.jsx("div",{className:"react-flow__edgelabel-renderer"}),A.jsx(e$e,{nodeTypes:t,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:s,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:we,onlyRenderVisibleElements:F,noPanClassName:Pn,noDragClassName:Sn,disableKeyboardA11y:wn,nodeExtent:Pt,rfId:cn}),A.jsx("div",{className:"react-flow__viewport-portal"})]})})}Qle.displayName="GraphView";const O$e=N.memo(Qle),Zle=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:o,fitViewOptions:s,minZoom:l=.5,maxZoom:u=2,nodeOrigin:d,nodeExtent:f}={})=>{const m=new Map,h=new Map,E=new Map,b=new Map,y=r??e??[],v=n??t??[],C=d??[0,0],T=f??TE;Bse(E,b,y);const w=W5(v,m,h,{nodeOrigin:C,nodeExtent:T,elevateNodesOnSelect:!1});let I=[0,0,1];if(o&&a&&i){const x=RE(m,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:D,y:M,zoom:F}=q5(x,a,i,l,u,(s==null?void 0:s.padding)??.1);I=[D,M,F]}return{rfId:"1",width:a??0,height:i??0,transform:I,nodes:v,nodesInitialized:w,nodeLookup:m,parentLookup:h,edges:y,edgeLookup:b,connectionLookup:E,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:l,maxZoom:u,translateExtent:TE,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:_g.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:C,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...lse},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Xze,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:sse}},I$e=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:o,fitViewOptions:s,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f})=>Zqe((m,h)=>{async function E(){const{nodeLookup:b,panZoom:y,fitViewOptions:v,fitViewResolver:C,width:T,height:w,minZoom:I,maxZoom:x}=h();y&&(await Wze({nodes:b,width:T,height:w,panZoom:y,minZoom:I,maxZoom:x},v),C==null||C.resolve(!0),m({fitViewResolver:null}))}return{...Zle({nodes:t,edges:e,width:a,height:i,fitView:o,fitViewOptions:s,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,defaultNodes:n,defaultEdges:r}),setNodes:b=>{const{nodeLookup:y,parentLookup:v,nodeOrigin:C,elevateNodesOnSelect:T,fitViewQueued:w}=h(),I=W5(b,y,v,{nodeOrigin:C,nodeExtent:f,elevateNodesOnSelect:T,checkEquality:!0});w&&I?(E(),m({nodes:b,nodesInitialized:I,fitViewQueued:!1,fitViewOptions:void 0})):m({nodes:b,nodesInitialized:I})},setEdges:b=>{const{connectionLookup:y,edgeLookup:v}=h();Bse(y,v,b),m({edges:b})},setDefaultNodesAndEdges:(b,y)=>{if(b){const{setNodes:v}=h();v(b),m({hasDefaultNodes:!0})}if(y){const{setEdges:v}=h();v(y),m({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:y,nodeLookup:v,parentLookup:C,domNode:T,nodeOrigin:w,nodeExtent:I,debug:x,fitViewQueued:D}=h(),{changes:M,updatedInternals:F}=gqe(b,v,C,T,w,I);F&&(pqe(v,C,{nodeOrigin:w,nodeExtent:I}),D?(E(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(M==null?void 0:M.length)>0&&(x&&console.log("React Flow: trigger node changes",M),y==null||y(M)))},updateNodePositions:(b,y=!1)=>{const v=[],C=[],{nodeLookup:T,triggerNodeChanges:w}=h();for(const[I,x]of b){const D=T.get(I),M=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(x!=null&&x.position)),F={id:I,type:"position",position:M?{x:Math.max(0,x.position.x),y:Math.max(0,x.position.y)}:x.position,dragging:y};M&&D.parentId&&v.push({id:I,parentId:D.parentId,rect:{...x.internals.positionAbsolute,width:x.measured.width??0,height:x.measured.height??0}}),C.push(F)}if(v.length>0){const{parentLookup:I,nodeOrigin:x}=h(),D=X5(v,T,I,x);C.push(...D)}w(C)},triggerNodeChanges:b=>{const{onNodesChange:y,setNodes:v,nodes:C,hasDefaultNodes:T,debug:w}=h();if(b!=null&&b.length){if(T){const I=ple(b,C);v(I)}w&&console.log("React Flow: trigger node changes",b),y==null||y(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:y,setEdges:v,edges:C,hasDefaultEdges:T,debug:w}=h();if(b!=null&&b.length){if(T){const I=fle(b,C);v(I)}w&&console.log("React Flow: trigger edge changes",b),y==null||y(b)}},addSelectedNodes:b=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:C,triggerNodeChanges:T,triggerEdgeChanges:w}=h();if(y){const I=b.map(x=>kf(x,!0));T(I);return}T(Ag(C,new Set([...b]),!0)),w(Ag(v))},addSelectedEdges:b=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:C,triggerNodeChanges:T,triggerEdgeChanges:w}=h();if(y){const I=b.map(x=>kf(x,!0));w(I);return}w(Ag(v,new Set([...b]))),T(Ag(C,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:y}={})=>{const{edges:v,nodes:C,nodeLookup:T,triggerNodeChanges:w,triggerEdgeChanges:I}=h(),x=b||C,D=y||v,M=x.map(P=>{const q=T.get(P.id);return q&&(q.selected=!1),kf(P.id,!1)}),F=D.map(P=>kf(P.id,!1));w(M),I(F)},setMinZoom:b=>{const{panZoom:y,maxZoom:v}=h();y==null||y.setScaleExtent([b,v]),m({minZoom:b})},setMaxZoom:b=>{const{panZoom:y,minZoom:v}=h();y==null||y.setScaleExtent([v,b]),m({maxZoom:b})},setTranslateExtent:b=>{var y;(y=h().panZoom)==null||y.setTranslateExtent(b),m({translateExtent:b})},setPaneClickDistance:b=>{var y;(y=h().panZoom)==null||y.setClickDistance(b)},resetSelectedElements:()=>{const{edges:b,nodes:y,triggerNodeChanges:v,triggerEdgeChanges:C,elementsSelectable:T}=h();if(!T)return;const w=y.reduce((x,D)=>D.selected?[...x,kf(D.id,!1)]:x,[]),I=b.reduce((x,D)=>D.selected?[...x,kf(D.id,!1)]:x,[]);v(w),C(I)},setNodeExtent:b=>{const{nodes:y,nodeLookup:v,parentLookup:C,nodeOrigin:T,elevateNodesOnSelect:w,nodeExtent:I}=h();b[0][0]===I[0][0]&&b[0][1]===I[0][1]&&b[1][0]===I[1][0]&&b[1][1]===I[1][1]||(W5(y,v,C,{nodeOrigin:T,nodeExtent:b,elevateNodesOnSelect:w,checkEquality:!1}),m({nodeExtent:b}))},panBy:b=>{const{transform:y,width:v,height:C,panZoom:T,translateExtent:w}=h();return _qe({delta:b,panZoom:T,transform:y,translateExtent:w,width:v,height:C})},setCenter:async(b,y,v)=>{const{width:C,height:T,maxZoom:w,panZoom:I}=h();if(!I)return Promise.resolve(!1);const x=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:w;return await I.setViewport({x:C/2-b*x,y:T/2-y*x,zoom:x},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...lse}})},updateConnection:b=>{m({connection:b})},reset:()=>m({...Zle()})}},Object.is);function D$e({initialNodes:t,initialEdges:e,defaultNodes:n,defaultEdges:r,initialWidth:a,initialHeight:i,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:l,fitView:u,nodeOrigin:d,nodeExtent:f,children:m}){const[h]=N.useState(()=>I$e({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:u,minZoom:o,maxZoom:s,fitViewOptions:l,nodeOrigin:d,nodeExtent:f}));return A.jsx(Jqe,{value:h,children:A.jsx(vHe,{children:m})})}function k$e({children:t,nodes:e,edges:n,defaultNodes:r,defaultEdges:a,width:i,height:o,fitView:s,fitViewOptions:l,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:m}){return N.useContext(FA)?A.jsx(A.Fragment,{children:t}):A.jsx(D$e,{initialNodes:e,initialEdges:n,defaultNodes:r,defaultEdges:a,initialWidth:i,initialHeight:o,fitView:s,initialFitViewOptions:l,initialMinZoom:u,initialMaxZoom:d,nodeOrigin:f,nodeExtent:m,children:t})}const M$e={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function L$e({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:a,nodeTypes:i,edgeTypes:o,onNodeClick:s,onEdgeClick:l,onInit:u,onMove:d,onMoveStart:f,onMoveEnd:m,onConnect:h,onConnectStart:E,onConnectEnd:b,onClickConnectStart:y,onClickConnectEnd:v,onNodeMouseEnter:C,onNodeMouseMove:T,onNodeMouseLeave:w,onNodeContextMenu:I,onNodeDoubleClick:x,onNodeDragStart:D,onNodeDrag:M,onNodeDragStop:F,onNodesDelete:P,onEdgesDelete:q,onDelete:j,onSelectionChange:X,onSelectionDragStart:B,onSelectionDrag:W,onSelectionDragStop:G,onSelectionContextMenu:Y,onSelectionStart:K,onSelectionEnd:J,onBeforeDelete:$,connectionMode:Z,connectionLineType:te=Ad.Bezier,connectionLineStyle:U,connectionLineComponent:ie,connectionLineContainerStyle:se,deleteKeyCode:ue="Backspace",selectionKeyCode:ae="Shift",selectionOnDrag:ce=!1,selectionMode:ge=CE.Full,panActivationKeyCode:Ee="Space",multiSelectionKeyCode:we=OE()?"Meta":"Control",zoomActivationKeyCode:_e=OE()?"Meta":"Control",snapToGrid:me,snapGrid:Re,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:Be,nodesDraggable:it,autoPanOnNodeFocus:Xe,nodesConnectable:Nt,nodesFocusable:Sn,nodeOrigin:en=ale,edgesFocusable:Pn,edgesReconnectable:wn,elementsSelectable:Pt=!0,defaultViewport:cn=pHe,minZoom:ve=.5,maxZoom:Ne=2,translateExtent:$e=TE,preventScrolling:at=!0,nodeExtent:Et,defaultMarkerColor:pr="#b1b1b7",zoomOnScroll:Yn=!0,zoomOnPinch:vn=!0,panOnScroll:Ft=!1,panOnScrollSpeed:pn=.5,panOnScrollMode:kt=If.Free,zoomOnDoubleClick:Mr=!0,panOnDrag:ir=!0,onPaneClick:Lr,onPaneMouseEnter:gt,onPaneMouseMove:Hr,onPaneMouseLeave:$r,onPaneScroll:xn,onPaneContextMenu:de,paneClickDistance:Se=0,nodeClickDistance:Me=0,children:Qe,onReconnect:Kt,onReconnectStart:Bt,onReconnectEnd:Ze,onEdgeContextMenu:We,onEdgeDoubleClick:dt,onEdgeMouseEnter:_n,onEdgeMouseMove:or,onEdgeMouseLeave:Es,reconnectRadius:ku=10,onNodesChange:Mu,onEdgesChange:qo,noDragClassName:Tr="nodrag",noWheelClassName:Ea="nowheel",noPanClassName:Ss="nopan",fitView:Lu,fitViewOptions:Rp,connectOnClick:Pu,attributionPosition:th,proOptions:gc,defaultEdgeOptions:wp,elevateNodesOnSelect:Ma,elevateEdgesOnSelect:vs,disableKeyboardA11y:ys=!1,autoPanOnConnect:dl,autoPanOnNodeDrag:Pr,autoPanSpeed:nh,connectionRadius:_c,isValidConnection:Ts,onError:Ge,style:_t,id:Ut,nodeDragThreshold:yn,connectionDragThreshold:Cr,viewport:Sa,onViewportChange:di,width:Wa,height:Fn,colorMode:pi="light",debug:rh,onScroll:Cs,ariaLabelConfig:xp,...Fu},mb){const va=Ut||"1",Np=hHe(pi),bc=N.useCallback(pl=>{pl.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Cs==null||Cs(pl)},[Cs]);return A.jsx("div",{"data-testid":"rf__wrapper",...Fu,onScroll:bc,style:{..._t,...M$e},ref:mb,className:ra(["react-flow",a,Np]),id:Ut,role:"application",children:A.jsxs(k$e,{nodes:t,edges:e,width:Wa,height:Fn,fitView:Lu,fitViewOptions:Rp,minZoom:ve,maxZoom:Ne,nodeOrigin:en,nodeExtent:Et,children:[A.jsx(O$e,{onInit:u,onNodeClick:s,onEdgeClick:l,onNodeMouseEnter:C,onNodeMouseMove:T,onNodeMouseLeave:w,onNodeContextMenu:I,onNodeDoubleClick:x,nodeTypes:i,edgeTypes:o,connectionLineType:te,connectionLineStyle:U,connectionLineComponent:ie,connectionLineContainerStyle:se,selectionKeyCode:ae,selectionOnDrag:ce,selectionMode:ge,deleteKeyCode:ue,multiSelectionKeyCode:we,panActivationKeyCode:Ee,zoomActivationKeyCode:_e,onlyRenderVisibleElements:Pe,defaultViewport:cn,translateExtent:$e,minZoom:ve,maxZoom:Ne,preventScrolling:at,zoomOnScroll:Yn,zoomOnPinch:vn,zoomOnDoubleClick:Mr,panOnScroll:Ft,panOnScrollSpeed:pn,panOnScrollMode:kt,panOnDrag:ir,onPaneClick:Lr,onPaneMouseEnter:gt,onPaneMouseMove:Hr,onPaneMouseLeave:$r,onPaneScroll:xn,onPaneContextMenu:de,paneClickDistance:Se,nodeClickDistance:Me,onSelectionContextMenu:Y,onSelectionStart:K,onSelectionEnd:J,onReconnect:Kt,onReconnectStart:Bt,onReconnectEnd:Ze,onEdgeContextMenu:We,onEdgeDoubleClick:dt,onEdgeMouseEnter:_n,onEdgeMouseMove:or,onEdgeMouseLeave:Es,reconnectRadius:ku,defaultMarkerColor:pr,noDragClassName:Tr,noWheelClassName:Ea,noPanClassName:Ss,rfId:va,disableKeyboardA11y:ys,nodeExtent:Et,viewport:Sa,onViewportChange:di}),A.jsx(mHe,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:E,onConnectEnd:b,onClickConnectStart:y,onClickConnectEnd:v,nodesDraggable:it,autoPanOnNodeFocus:Xe,nodesConnectable:Nt,nodesFocusable:Sn,edgesFocusable:Pn,edgesReconnectable:wn,elementsSelectable:Pt,elevateNodesOnSelect:Ma,elevateEdgesOnSelect:vs,minZoom:ve,maxZoom:Ne,nodeExtent:Et,onNodesChange:Mu,onEdgesChange:qo,snapToGrid:me,snapGrid:Re,connectionMode:Z,translateExtent:$e,connectOnClick:Pu,defaultEdgeOptions:wp,fitView:Lu,fitViewOptions:Rp,onNodesDelete:P,onEdgesDelete:q,onDelete:j,onNodeDragStart:D,onNodeDrag:M,onNodeDragStop:F,onSelectionDrag:W,onSelectionDragStart:B,onSelectionDragStop:G,onMove:d,onMoveStart:f,onMoveEnd:m,noPanClassName:Ss,nodeOrigin:en,rfId:va,autoPanOnConnect:dl,autoPanOnNodeDrag:Pr,autoPanSpeed:nh,onError:Ge,connectionRadius:_c,isValidConnection:Ts,selectNodesOnDrag:Be,nodeDragThreshold:yn,connectionDragThreshold:Cr,onBeforeDelete:$,paneClickDistance:Se,debug:rh,ariaLabelConfig:xp}),A.jsx(dHe,{onSelectionChange:X}),Qe,A.jsx(oHe,{proOptions:gc,position:th}),A.jsx(iHe,{rfId:va,disableKeyboardA11y:ys})]})})}var P$e=_le(L$e);function F$e(t){const[e,n]=N.useState(t),r=N.useCallback(a=>n(i=>ple(a,i)),[]);return[e,n,r]}function B$e(t){const[e,n]=N.useState(t),r=N.useCallback(a=>n(i=>fle(a,i)),[]);return[e,n,r]}function U$e({dimensions:t,lineWidth:e,variant:n,className:r}){return A.jsx("path",{strokeWidth:e,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:ra(["react-flow__background-pattern",n,r])})}function G$e({radius:t,className:e}){return A.jsx("circle",{cx:t,cy:t,r:t,className:ra(["react-flow__background-pattern","dots",e])})}var Hc;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Hc||(Hc={}));const z$e={[Hc.Dots]:1,[Hc.Lines]:1,[Hc.Cross]:6},q$e=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function Jle({id:t,variant:e=Hc.Dots,gap:n=20,size:r,lineWidth:a=1,offset:i=0,color:o,bgColor:s,style:l,className:u,patternClassName:d}){const f=N.useRef(null),{transform:m,patternId:h}=dn(q$e,Nr),E=r||z$e[e],b=e===Hc.Dots,y=e===Hc.Cross,v=Array.isArray(n)?n:[n,n],C=[v[0]*m[2]||1,v[1]*m[2]||1],T=E*m[2],w=Array.isArray(i)?i:[i,i],I=y?[T,T]:C,x=[w[0]*m[2]||1+I[0]/2,w[1]*m[2]||1+I[1]/2],D=`${h}${t||""}`;return A.jsxs("svg",{className:ra(["react-flow__background",u]),style:{...l,...GA,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:f,"data-testid":"rf__background",children:[A.jsx("pattern",{id:D,x:m[0]%C[0],y:m[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${x[0]},-${x[1]})`,children:b?A.jsx(G$e,{radius:T/2,className:d}):A.jsx(U$e,{dimensions:I,lineWidth:a,variant:e,className:d})}),A.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${D})`})]})}Jle.displayName="Background";const H$e=N.memo(Jle);function $$e(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:A.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Y$e(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:A.jsx("path",{d:"M0 0h32v4.2H0z"})})}function V$e(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:A.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function j$e(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:A.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function W$e(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:A.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function HA({children:t,className:e,...n}){return A.jsx("button",{type:"button",className:ra(["react-flow__controls-button",e]),...n,children:t})}const K$e=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function ece({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:a,onZoomIn:i,onZoomOut:o,onFitView:s,onInteractiveChange:l,className:u,children:d,position:f="bottom-left",orientation:m="vertical","aria-label":h}){const E=Er(),{isInteractive:b,minZoomReached:y,maxZoomReached:v,ariaLabelConfig:C}=dn(K$e,Nr),{zoomIn:T,zoomOut:w,fitView:I}=rB(),x=()=>{T(),i==null||i()},D=()=>{w(),o==null||o()},M=()=>{I(a),s==null||s()},F=()=>{E.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),l==null||l(!b)},P=m==="horizontal"?"horizontal":"vertical";return A.jsxs(BA,{className:ra(["react-flow__controls",P,u]),position:f,style:t,"data-testid":"rf__controls","aria-label":h??C["controls.ariaLabel"],children:[e&&A.jsxs(A.Fragment,{children:[A.jsx(HA,{onClick:x,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:v,children:A.jsx($$e,{})}),A.jsx(HA,{onClick:D,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:y,children:A.jsx(Y$e,{})})]}),n&&A.jsx(HA,{className:"react-flow__controls-fitview",onClick:M,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:A.jsx(V$e,{})}),r&&A.jsx(HA,{className:"react-flow__controls-interactive",onClick:F,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:b?A.jsx(W$e,{}):A.jsx(j$e,{})}),d]})}ece.displayName="Controls",N.memo(ece);function X$e({id:t,x:e,y:n,width:r,height:a,style:i,color:o,strokeColor:s,strokeWidth:l,className:u,borderRadius:d,shapeRendering:f,selected:m,onClick:h}){const{background:E,backgroundColor:b}=i||{},y=o||E||b;return A.jsx("rect",{className:ra(["react-flow__minimap-node",{selected:m},u]),x:e,y:n,rx:d,ry:d,width:r,height:a,style:{fill:y,stroke:s,strokeWidth:l},shapeRendering:f,onClick:h?v=>h(v,t):void 0})}const Q$e=N.memo(X$e),Z$e=t=>t.nodes.map(e=>e.id),sB=t=>t instanceof Function?t:()=>t;function J$e({nodeStrokeColor:t,nodeColor:e,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:a,nodeComponent:i=Q$e,onClick:o}){const s=dn(Z$e,Nr),l=sB(e),u=sB(t),d=sB(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return A.jsx(A.Fragment,{children:s.map(m=>A.jsx(tYe,{id:m,nodeColorFunc:l,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:a,NodeComponent:i,onClick:o,shapeRendering:f},m))})}function eYe({id:t,nodeColorFunc:e,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:a,nodeStrokeWidth:i,shapeRendering:o,NodeComponent:s,onClick:l}){const{node:u,x:d,y:f,width:m,height:h}=dn(E=>{const{internals:b}=E.nodeLookup.get(t),y=b.userNode,{x:v,y:C}=b.positionAbsolute,{width:T,height:w}=qc(y);return{node:y,x:v,y:C,width:T,height:w}},Nr);return!u||u.hidden||!bse(u)?null:A.jsx(s,{x:d,y:f,width:m,height:h,style:u.style,selected:!!u.selected,className:r(u),color:e(u),borderRadius:a,strokeColor:n(u),strokeWidth:i,shapeRendering:o,onClick:l,id:u.id})}const tYe=N.memo(eYe);var nYe=N.memo(J$e);const rYe=200,aYe=150,iYe=t=>!t.hidden,oYe=t=>{const e={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:e,boundingRect:t.nodeLookup.size>0?gse(RE(t.nodeLookup,{filter:iYe}),e):e,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},sYe="react-flow__minimap-desc";function tce({style:t,className:e,nodeStrokeColor:n,nodeColor:r,nodeClassName:a="",nodeBorderRadius:i=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:l,maskColor:u,maskStrokeColor:d,maskStrokeWidth:f,position:m="bottom-right",onClick:h,onNodeClick:E,pannable:b=!1,zoomable:y=!1,ariaLabel:v,inversePan:C,zoomStep:T=1,offsetScale:w=5}){const I=Er(),x=N.useRef(null),{boundingRect:D,viewBB:M,rfId:F,panZoom:P,translateExtent:q,flowWidth:j,flowHeight:X,ariaLabelConfig:B}=dn(oYe,Nr),W=(t==null?void 0:t.width)??rYe,G=(t==null?void 0:t.height)??aYe,Y=D.width/W,K=D.height/G,J=Math.max(Y,K),$=J*W,Z=J*G,te=w*J,U=D.x-($-D.width)/2-te,ie=D.y-(Z-D.height)/2-te,se=$+te*2,ue=Z+te*2,ae=`${sYe}-${F}`,ce=N.useRef(0),ge=N.useRef();ce.current=J,N.useEffect(()=>{if(x.current&&P)return ge.current=Rqe({domNode:x.current,panZoom:P,getTransform:()=>I.getState().transform,getViewScale:()=>ce.current}),()=>{var me;(me=ge.current)==null||me.destroy()}},[P]),N.useEffect(()=>{var me;(me=ge.current)==null||me.update({translateExtent:q,width:j,height:X,inversePan:C,pannable:b,zoomStep:T,zoomable:y})},[b,y,C,T,q,j,X]);const Ee=h?me=>{var Be;const[Re,Pe]=((Be=ge.current)==null?void 0:Be.pointer(me))||[0,0];h(me,{x:Re,y:Pe})}:void 0,we=E?N.useCallback((me,Re)=>{const Pe=I.getState().nodeLookup.get(Re).internals.userNode;E(me,Pe)},[]):void 0,_e=v??B["minimap.ariaLabel"];return A.jsx(BA,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*J:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:ra(["react-flow__minimap",e]),"data-testid":"rf__minimap",children:A.jsxs("svg",{width:W,height:G,viewBox:`${U} ${ie} ${se} ${ue}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ae,ref:x,onClick:Ee,children:[_e&&A.jsx("title",{id:ae,children:_e}),A.jsx(nYe,{onClick:we,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:a,nodeStrokeWidth:o,nodeComponent:s}),A.jsx("path",{className:"react-flow__minimap-mask",d:`M${U-te},${ie-te}h${se+te*2}v${ue+te*2}h${-se-te*2}z
|
|
655
|
-
M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}tce.displayName="MiniMap",N.memo(tce);const lYe=t=>e=>t?`${Math.max(1/e.transform[2],1)}`:void 0,cYe={[Cg.Line]:"right",[Cg.Handle]:"bottom-right"};function uYe({nodeId:t,position:e,variant:n=Cg.Handle,className:r,style:a=void 0,children:i,color:o,minWidth:s=10,minHeight:l=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:m,autoScale:h=!0,shouldResize:E,onResizeStart:b,onResize:y,onResizeEnd:v}){const C=Tle(),T=typeof t=="string"?t:C,w=Er(),I=N.useRef(null),x=n===Cg.Handle,D=dn(N.useCallback(lYe(x&&h),[x,h]),Nr),M=N.useRef(null),F=e??cYe[n];N.useEffect(()=>{if(!(!I.current||!T))return M.current||(M.current=qqe({domNode:I.current,nodeId:T,getStoreItems:()=>{const{nodeLookup:q,transform:j,snapGrid:X,snapToGrid:B,nodeOrigin:W,domNode:G}=w.getState();return{nodeLookup:q,transform:j,snapGrid:X,snapToGrid:B,nodeOrigin:W,paneDomNode:G}},onChange:(q,j)=>{const{triggerNodeChanges:X,nodeLookup:B,parentLookup:W,nodeOrigin:G}=w.getState(),Y=[],K={x:q.x,y:q.y},J=B.get(T);if(J&&J.expandParent&&J.parentId){const $=J.origin??G,Z=q.width??J.measured.width??0,te=q.height??J.measured.height??0,U={id:J.id,parentId:J.parentId,rect:{width:Z,height:te,...Ese({x:q.x??J.position.x,y:q.y??J.position.y},{width:Z,height:te},J.parentId,B,$)}},ie=X5([U],B,W,G);Y.push(...ie),K.x=q.x?Math.max($[0]*Z,q.x):void 0,K.y=q.y?Math.max($[1]*te,q.y):void 0}if(K.x!==void 0&&K.y!==void 0){const $={id:T,type:"position",position:{...K}};Y.push($)}if(q.width!==void 0&&q.height!==void 0){const Z={id:T,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};Y.push(Z)}for(const $ of j){const Z={...$,type:"position"};Y.push(Z)}X(Y)},onEnd:({width:q,height:j})=>{const X={id:T,type:"dimensions",resizing:!1,dimensions:{width:q,height:j}};w.getState().triggerNodeChanges([X])}})),M.current.update({controlPosition:F,boundaries:{minWidth:s,minHeight:l,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:m,onResizeStart:b,onResize:y,onResizeEnd:v,shouldResize:E}),()=>{var q;(q=M.current)==null||q.destroy()}},[F,s,l,u,d,f,b,y,v,E]);const P=F.split("-");return A.jsx("div",{className:ra(["react-flow__resize-control","nodrag",...P,n,r]),ref:I,style:{...a,scale:D,...o&&{[x?"backgroundColor":"borderColor"]:o}},children:i})}N.memo(uYe);function dYe({workflowName:t,className:e="w-full h-[600px]",events:n,onNodeClick:r,highlightedNodeId:a,selectedNodeId:i,isComplete:o=!1}){const[s,l,u]=F$e([]),[d,f,m]=B$e([]),[h,E]=N.useState(!1),[b,y]=N.useState(null),[v,C]=N.useState(-1),[T,w]=N.useState(()=>{if(typeof window>"u")return!1;try{return document.documentElement.classList.contains("dark")?!0:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}),I=N.useMemo(()=>({step:({data:P,id:q})=>{const j=a===q,X=i===q;let B={transition:"all 1s ease-out"};return P.highlightColor&&P.highlightColor!==null?(B.backgroundColor=T?void 0:"#CCFBEF",B.borderColor=P.highlightColor,B.boxShadow=`0 0 0 3px ${P.highlightColor}66`):P.highlightColor===null&&(B.backgroundColor=T?"#0b1220":"#E6EEFF",B.borderColor=T?"#274690":"#7EA6FF",B.boxShadow="0 0 0 0px transparent"),X?B={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6",transition:"all 1s ease-out"}:j&&(B={...B,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),A.jsxs("div",{className:"px-4 py-2 shadow-md rounded-md min-w-[160px] cursor-pointer transition-all bg-[#E6EEFF] border-2 border-[#7EA6FF] dark:bg-[#0b1220] dark:border-[#274690] hover:shadow-lg hover:scale-105",style:B,onClick:()=>r==null?void 0:r(q),children:[A.jsx(zl,{type:"target",position:bt.Left}),A.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A.jsx("div",{className:"font-bold text-[#1E3A8A] text-sm dark:text-[#e5edff]",children:P.label}),P.workerCount>0&&A.jsx("div",{className:"flex items-center justify-center min-w-[20px] h-[20px] px-1.5 rounded-full bg-[#10B981] text-white text-[10px] font-bold",children:P.workerCount})]}),P.title&&A.jsx("div",{className:"text-xs text-[#1D4ED8] mt-1 dark:text-[#9db4ff]",children:P.title}),(P.lastInputEvent||P.lastOutputEvent)&&A.jsxs("div",{className:"text-[10px] text-gray-700 dark:text-gray-300 mt-1",children:[P.lastInputEvent&&A.jsxs("div",{children:[A.jsx("span",{className:"font-semibold",children:"in:"})," ",P.lastInputEvent]}),P.lastOutputEvent&&A.jsxs("div",{children:[A.jsx("span",{className:"font-semibold",children:"out:"})," ",P.lastOutputEvent]})]}),A.jsx(zl,{type:"source",position:bt.Right})]})},event:({data:P,id:q})=>{const j=a===q,X=i===q;let B={transition:"all 1s ease-out"};return P.highlightColor&&P.highlightColor!==null?(B.backgroundColor=T?void 0:"#FFE8B5",B.borderColor=P.highlightColor,B.boxShadow=`0 0 0 3px ${P.highlightColor}66`):P.highlightColor===null&&(B.backgroundColor=T?"#241a06":"#FFF3BF",B.borderColor=T?"#F59E0B":"#FFD166",B.boxShadow="0 0 0 0px transparent"),X?B={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6",transition:"all 1s ease-out"}:j&&(B={...B,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),A.jsxs("div",{className:"px-3 py-2 shadow-md rounded-full min-w-[140px] text-center cursor-pointer transition-all bg-[#FFF3BF] border-2 border-[#FFD166] dark:bg-[#241a06] dark:border-[#F59E0B] hover:shadow-lg hover:scale-105",style:B,onClick:()=>r==null?void 0:r(q),children:[A.jsx(zl,{type:"target",position:bt.Left}),A.jsx("div",{className:"font-bold text-[#92400E] text-sm dark:text-[#fde68a]",children:P.label}),P.event_type&&A.jsx("div",{className:"text-xs text-[#B45309] mt-1 dark:text-[#fbbf24]",children:P.event_type}),A.jsx(zl,{type:"source",position:bt.Right})]})},external:({data:P,id:q})=>{const j=a===q,X=i===q;let B=P.highlightColor?{backgroundColor:T?void 0:"#FFE5D4",borderColor:P.highlightColor,boxShadow:`0 0 0 3px ${P.highlightColor}66`}:void 0;return X?B={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6"}:j&&(B={backgroundColor:B==null?void 0:B.backgroundColor,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),A.jsxs("div",{className:"px-3 py-2 shadow-md rounded-lg min-w-[140px] text-center cursor-pointer transition-all bg-[#FFEDD5] border-2 border-[#FB923C] dark:bg-[#1f0f08] dark:border-[#ea7a3a] hover:shadow-lg hover:scale-105",style:B,onClick:()=>r==null?void 0:r(q),children:[A.jsx(zl,{type:"target",position:bt.Left}),A.jsx("div",{className:"font-bold text-[#7C2D12] text-sm dark:text-[#fed7aa]",children:P.label}),P.title&&A.jsx("div",{className:"text-xs text-[#C2410C] mt-1 dark:text-[#fdba74]",children:P.title}),A.jsx(zl,{type:"source",position:bt.Right})]})}}),[T,a,i,r]);N.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const P=window.matchMedia("(prefers-color-scheme: dark)"),q=j=>w(j.matches);return P.addEventListener?P.addEventListener("change",q):P.addListener(q),()=>{P.removeEventListener?P.removeEventListener("change",q):P.removeListener(q)}},[]);const x=pd(),D=N.useCallback(P=>f(q=>Nse(P,q)),[f]),M=N.useCallback(P=>{const q=new Map,j=new Map;P.nodes.forEach($=>{q.set($.id,[]),j.set($.id,0)}),P.edges.forEach(({source:$,target:Z})=>{var te;(te=q.get($))==null||te.push(Z),j.set(Z,(j.get(Z)||0)+1)});const X=[];j.forEach(($,Z)=>{$===0&&X.push(Z)});const B=new Map;for(X.forEach($=>B.set($,0));X.length;){const $=X.shift(),Z=B.get($)??0;for(const te of q.get($)||[]){const U=Math.max(Z+1,B.get(te)??0);B.set(te,U),j.set(te,(j.get(te)||0)-1),(j.get(te)||0)===0&&X.push(te)}}const W={};P.nodes.forEach($=>{const Z=B.get($.id)??0;W[Z]||(W[Z]=[]),W[Z].push($.id)});const G=260,Y=110,K=P.nodes.map($=>{const Z=B.get($.id)??0,U=W[Z].indexOf($.id),ie=Z*G,se=U*Y;return{id:$.id,type:$.node_type,position:{x:ie,y:se},data:{label:$.label,title:$.title,event_type:$.event_type,type:$.node_type}}}),J=P.edges.map(($,Z)=>({id:`edge-${Z}`,source:$.source,target:$.target,type:"smoothstep",animated:!1,style:{stroke:"var(--wf-edge-stroke)",strokeWidth:2},markerEnd:{type:bg.ArrowClosed,color:"var(--wf-edge-stroke)"}}));return{nodes:K,edges:J}},[]),F=N.useCallback(async()=>{if(!t){l([]),f([]),y(null);return}E(!0),y(null);try{const{data:P,error:q}=await Vq({client:x,path:{name:t}});if(q)throw new Error(String(q));const j=P==null?void 0:P.graph;if(!j)throw new Error("No graph data received");const X=M(j);l(X.nodes),f(X.edges)}catch(P){console.error("Error fetching workflow visualization:",P),y(P instanceof Error?P.message:"Failed to load workflow visualization"),l([]),f([])}finally{E(!1)}},[t,x,M,l,f]);return N.useEffect(()=>{F()},[F]),N.useEffect(()=>{if(!n||n.length===0){C(-1),l(X=>X.map(B=>{const W={...B.data};return delete W.highlightColor,delete W.activeWorkers,delete W.workerCount,delete W.fadeTimestamp,{...B,data:W}}));return}const P=n.slice(v+1);if(P.length===0)return;C(n.length-1);const q=X=>{if(!X)return"";try{return((typeof X=="string"?X:String(X)).replace("<class","").replace(">","").replaceAll("'","").split(".").at(-1)||"").trim()}catch{return""}},j=X=>{switch(X){case"preparing":return"#3B82F6";case"in_progress":return"#F59E0B";case"running":return"#10B981";case"not_running":case"not_in_progress":case"exited":return null;default:return"#10B981"}};for(const X of P){const B=(X==null?void 0:X.type)??"",W=(X==null?void 0:X.data)??{};if(B==="StepStateChanged"||B==="workflows.events.StepStateChanged"){const G=String((W==null?void 0:W.name)||""),Y=String((W==null?void 0:W.step_state)||""),K=String((W==null?void 0:W.worker_id)||""),J=j(Y);l($=>$.map(Z=>{const te={...Z.data};if(Z.id===G){const U=new Set(te.activeWorkers||[]);if(Y==="preparing"||Y==="in_progress"||Y==="running"?U.add(K):(Y==="not_running"||Y==="not_in_progress"||Y==="exited")&&U.delete(K),te.activeWorkers=Array.from(U),te.workerCount=U.size,U.size>0)te.highlightColor=J||"#10B981",te.fadeTimestamp=Date.now();else if((Y==="exited"||Y==="not_running")&&te.highlightColor){const ie=Date.now();te.fadeTimestamp=ie,setTimeout(()=>{l(se=>se.map(ue=>{if(ue.id===G&&ue.data.fadeTimestamp===ie){const ae={...ue.data};return ae.highlightColor=null,{...ue,data:ae}}return ue}))},1e3)}return te.lastInputEvent=q(W==null?void 0:W.input_event_name),te.lastOutputEvent=q(W==null?void 0:W.output_event_name),te.status=Y,{...Z,data:te}}return Z}))}else if(B&&!B.includes("workflows.events.EventsQueueChanged")){const G=q(B.replace("__main__.","").replace("workflows.events.",""));l(Y=>Y.map(K=>{if(K.id===G&&K.type==="event"){const J={...K.data};return J.highlightColor="#10B981",J.fadeTimestamp=Date.now(),{...K,data:J}}return K})),setTimeout(()=>{l(Y=>Y.map(K=>{if(K.id===G&&K.type==="event"){const J={...K.data};return J.highlightColor=null,J.fadeTimestamp=null,{...K,data:J}}return K}))},1e3)}}},[n,v,l,o]),h?A.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:A.jsxs("div",{className:"text-center",children:[A.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-2"}),A.jsx("p",{className:"text-muted-foreground",children:"Loading workflow visualization..."})]})}):b?A.jsx("div",{className:`${e} flex items-center justify-center bg-destructive/10 border border-destructive/30 rounded-lg`,children:A.jsxs("div",{className:"text-center p-4",children:[A.jsx("p",{className:"text-destructive font-medium",children:"Error loading visualization"}),A.jsx("p",{className:"text-sm mt-1 text-destructive",children:b}),A.jsx("button",{onClick:F,className:"mt-3 px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm hover:opacity-90 transition-colors",children:"Retry"})]})}):t?s.length===0?A.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:A.jsx("p",{className:"text-muted-foreground",children:"No workflow data available"})}):A.jsx("div",{className:`${e} border border-border rounded-lg overflow-hidden`,children:A.jsx(P$e,{nodes:s,edges:d,onNodesChange:u,onEdgesChange:m,onConnect:D,nodeTypes:I,defaultEdgeOptions:{markerEnd:{type:bg.ArrowClosed,color:"var(--wf-edge-stroke)"}},fitView:!0,attributionPosition:"bottom-left",children:A.jsx(H$e,{variant:Hc.Dots,gap:12,size:1,color:T?"#374151":"#e5e7eb"})})}):A.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:A.jsx("p",{className:"text-muted-foreground",children:"Select a workflow to view its visualization"})})}function lB(t){if(t.type)return{type:t.type,nullable:t.nullable??!1};if(t.anyOf&&Array.isArray(t.anyOf)){const e=t.anyOf.map(a=>a.type).filter(a=>typeof a=="string"),n=e.includes("null"),r=e.filter(a=>a!=="null");if(r.length===1)return{type:r[0],nullable:n}}return{type:"unknown",nullable:!1}}function pYe(t){if(!t)return!1;const e=t.toLowerCase();return e.includes("object")||e.includes("array")||e.includes("map")||e.includes("dict")||/\w+\s*\[.*\]/.test(t)}function fYe(t){const e=(t||"").toLowerCase(),n=e.includes("array")||e.includes("list")||/\w+\s*\[.*\]/.test(t||""),r=e.includes("object")||e.includes("map")||e.includes("dict");return n?{hint:'Expected: JSON array (e.g., ["a", "b"])',placeholder:'["item1", "item2"]'}:r?{hint:'Expected: JSON object (e.g., {"key": "value"})',placeholder:'{"key": "value"}'}:{hint:"Expected: valid JSON (object or array)",placeholder:"Enter value as JSON"}}const mYe={};function nce({schema:t,values:e,onChange:n,onErrorsChange:r,className:a}){const i=(t==null?void 0:t.properties)??mYe,o=new Set((t==null?void 0:t.required)||[]),[s,l]=N.useState({}),[u,d]=N.useState({});N.useEffect(()=>{r==null||r(u)},[u,r]),N.useEffect(()=>{l(h=>{const E={...h};for(const[b,y]of Object.entries(i)){const{type:v}=lB(y);if(pYe(v)&&E[b]===void 0){const C=e[b];E[b]=C!==void 0?JSON.stringify(C,null,2):""}}return E})},[i,e]),N.useEffect(()=>{const h={};for(const[E,b]of Object.entries(i)){const{type:y,nullable:v}=lB(b);y==="boolean"&&e[E]===void 0&&o.has(E)&&(h[E]=v?null:!1)}Object.keys(h).length>0&&n({...e,...h})},[i,n]);const f=(h,E)=>{n({...e,[h]:E})},m=N.useMemo(()=>Object.entries(i),[i]);return m.length===0?null:A.jsx("div",{className:a,children:m.map(([h,E])=>{const b=`field-${h}`,y=E.title||h,{type:v,nullable:C}=lB(E),T=E.description||"";if(v==="string")return A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:b,label:y,required:o.has(h)}),A.jsx(wT,{id:b,value:e[h]||"",onChange:M=>f(h,M.target.value),placeholder:T||`Enter ${y.toLowerCase()}`,minRows:3}),T&&A.jsx("p",{className:"text-xs text-muted-foreground",children:T})]},h);if(v==="number"||v==="integer")return A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:b,label:y,required:o.has(h)}),A.jsx(OT,{id:b,type:"number",value:e[h]??"",onChange:M=>{const F=M.target.value;if(F===""){f(h,null);return}const P=v==="integer"?parseInt(F,10):parseFloat(F);f(h,Number.isNaN(P)?null:P)},placeholder:T||`Enter ${y.toLowerCase()}`,step:v==="integer"?"1":"any"}),T&&A.jsx("p",{className:"text-xs text-muted-foreground",children:T})]},h);if(v==="boolean"){const M=()=>e[h]===null?"null":e[h]===!0||e[h]==="true"?"true":e[h]===!1||e[h]==="false"?"false":C?"":"false";return A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:b,label:y,required:o.has(h)}),A.jsxs(Sx,{onValueChange:F=>{F==="null"?f(h,null):f(h,F==="true")},value:M(),children:[A.jsx(TT,{placeholder:"Select..."}),A.jsxs(CT,{children:[A.jsx(Gh,{value:"true",label:"True"}),A.jsx(Gh,{value:"false",label:"False"}),C&&A.jsx(Gh,{value:"null",label:"None"})]})]}),T&&A.jsx("p",{className:"text-xs text-muted-foreground",children:T})]},h)}const{hint:w,placeholder:I}=fYe(v),x=s[h]??(e[h]!==void 0?JSON.stringify(e[h],null,2):""),D=!!u[h];return A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:b,label:`${y} (JSON)`,required:o.has(h)}),A.jsx("div",{className:"font-mono",children:A.jsx(wT,{id:b,value:x,onChange:M=>{const F=M.target.value;if(l(P=>({...P,[h]:F})),F.trim()===""){d(q=>({...q,[h]:null}));const P={...e};delete P[h],n(P);return}try{const P=JSON.parse(F);d(q=>({...q,[h]:null})),f(h,P)}catch{d(P=>({...P,[h]:"Invalid JSON"}))}},placeholder:T||I,variant:D?"error":"default",minRows:3})}),D?A.jsx("p",{className:"text-xs text-destructive mt-1",children:u[h]}):A.jsx("p",{className:"text-xs text-muted-foreground",children:w}),T&&A.jsx("p",{className:"text-xs text-muted-foreground",children:T})]},h)})})}function hYe({handlerId:t,workflowName:e,disabled:n}){const[r,a]=N.useState(!1),[i,o]=N.useState([]),[s,l]=N.useState(null),[u,d]=N.useState({}),[f,m]=N.useState(!1),[h,E]=N.useState(null),[b,y]=N.useState(!1),[v,C]=N.useState(null),[T,w]=N.useState(!1),I=pd();N.useEffect(()=>{if(!r||!e)return;(async()=>{m(!0),C(null);try{const j=(await iye({client:I,path:{name:e}})).data;if(!j){o([]);return}if(!j.events){o([]);return}if(o(j.events),j.events&&j.events.length>0){const B=j.events[0].title;l(B||null)}}catch(q){console.error("Failed to fetch event schemas:",q),C(q instanceof Error?q.message:"Failed to fetch events"),o([])}finally{m(!1)}})()},[r,e,I]),N.useEffect(()=>{r||(l(null),d({}),E(null),C(null),w(!1))},[r]),N.useEffect(()=>{d({}),C(null),w(!1)},[s]);const x=N.useMemo(()=>s&&i.find(P=>P.title===s)||null,[s,i]),D=N.useMemo(()=>h?Object.values(h).some(P=>P!==null):!1,[h]),M=async()=>{if(!(!t||!s)){y(!0),C(null),w(!1);try{const P={type:s,data:u},{error:q}=await Yq({client:I,path:{handler_id:t},body:{event:JSON.stringify(P)}});if(q)throw new Error(typeof q=="string"?q:JSON.stringify(q));w(!0),setTimeout(()=>{a(!1)},1e3)}catch(P){console.error("Failed to send event:",P),C(P instanceof Error?P.message:"Failed to send event")}finally{y(!1)}}},F=!b&&!D&&s&&t&&!T;return A.jsxs(VTe,{open:r,onOpenChange:a,children:[A.jsx(jTe,{asChild:!0,children:A.jsx(Xn,{variant:"outline",size:"sm",disabled:n||!t||!e,title:t?e?"Send event to workflow":"No workflow selected":"No active handler",label:"Send Event",startIcon:A.jsx(LEe,{})})}),A.jsxs(ZH,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[A.jsx(JH,{title:"Send Event to Workflow",description:"Send a custom event to the running workflow handler."}),A.jsx("div",{className:"space-y-4 py-4",children:f?A.jsx("div",{className:"text-center text-muted-foreground",children:"Loading event types..."}):i.length===0?A.jsx("div",{className:"text-center text-muted-foreground",children:v||"No events available for this workflow"}):A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:"eventType",label:"Event Type"}),A.jsxs(Sx,{value:s||"",onValueChange:l,children:[A.jsx(TT,{placeholder:"Select event type..."}),A.jsx(CT,{children:i.map(P=>A.jsx(Gh,{value:P.title||"",label:P.title||"Unnamed Event"},P.title||"unknown"))})]})]}),x&&A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:"eventData",label:"Event Data"}),A.jsx(nce,{schema:{properties:x.properties,required:x.required},values:u,onChange:d,onErrorsChange:E,className:"space-y-3 border border-border rounded-lg p-4 bg-muted/30"})]}),v&&A.jsx("div",{className:"text-destructive text-sm p-3 bg-destructive/10 border border-destructive/20 rounded",children:v}),T&&A.jsx("div",{className:"text-green-600 text-sm p-3 bg-green-50 border border-green-200 rounded",children:"Event sent successfully!"})]})}),A.jsx(e$,{secondary:{label:"Cancel",onClick:()=>a(!1)},primary:{label:b?"Sending...":"Send Event",onClick:M,disabled:!F}})]})]})}function gYe({handlerId:t,selectedWorkflow:e}){var C;const{state:n,subscribeToEvents:r}=P3e(t),[a,i]=N.useState(!1),[o,s]=N.useState(!0),[l,u]=N.useState(null),[d,f]=N.useState(null),{items:m,push:h,clear:E}=F3e(100,(T,w)=>T.timestamp.getTime()-w.timestamp.getTime()),b=T=>typeof T=="string"?T:!T||typeof T!="object"?String(T??""):JSON.stringify(T,null,a?0:2),y=T=>{if(!T)return"";const w=new Date(T),I=w.toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),x=String(w.getMilliseconds()).padStart(3,"0");return`${I}.${x}`};N.useEffect(()=>{if(n.status==="running"){const{disconnect:T}=r({onData:w=>{h(w)},onSuccess(w){var I,x;u(((x=(I=w[w.length-1])==null?void 0:I.data)==null?void 0:x.result)??null)},onError(w){f(w.message)}},!0);return()=>{T()}}},[r,n.status,h]),N.useEffect(()=>{E(),u(null),f(null)},[t,E]);const v=N.useMemo(()=>o?m.filter(T=>!kTe(T)):m,[m,o]);return A.jsxs("div",{className:"h-full flex flex-col",children:[A.jsxs("div",{className:"p-4 border-b border-border",children:[A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h2",{className:"font-semibold text-sm",children:"Run Details"}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx(_T,{variant:n.status==="completed"?"default":"secondary",label:n.status}),A.jsx(hYe,{handlerId:t,workflowName:e??null,disabled:!n||n.status==="completed"||n.status==="failed"})]})]}),A.jsxs("div",{className:"flex items-center justify-between gap-2 mt-2",children:[A.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:n.handler_id}),A.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["Last updated: ",(C=n.updated_at)==null?void 0:C.getTime()]})]})]}),A.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[A.jsx("div",{className:"flex-1 p-4 overflow-auto border-r border-border",children:A.jsx(dYe,{workflowName:e||null,events:m.map(T=>({type:T.type,data:T.data})),className:"w-full h-full min-h-[400px]",isComplete:n.status==="completed"||n.status==="failed"})}),A.jsxs("div",{className:"w-[480px] flex flex-col overflow-hidden",children:[A.jsx("div",{className:"p-4 pb-2 border-b border-border",children:A.jsxs("div",{className:"flex items-center justify-between mb-3",children:[A.jsxs("h4",{className:"font-medium text-sm",children:["Event Stream (",v.length,")"]}),A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx(Bs,{htmlFor:"hide-internal",label:"Hide internal"}),A.jsx(TJ,{id:"hide-internal",checked:o,onCheckedChange:T=>s(!!T)})]}),A.jsx(Xn,{variant:"ghost",size:"sm",onClick:()=>i(!a),label:a?"Formatted":"Compact"})]})]})}),A.jsx("div",{className:"flex-1 overflow-auto",children:n.handler_id?m.length===0?A.jsx("div",{className:"flex items-center justify-center h-full",children:A.jsx("p",{className:"text-muted-foreground text-sm",children:"No events yet..."})}):A.jsxs(wz,{children:[A.jsx(xz,{sticky:!0,children:A.jsxs(Ox,{children:[A.jsx(Ix,{label:"#"}),A.jsx(Ix,{label:"Event"})]})}),A.jsx(Nz,{children:v.map((T,w)=>{const I=T;return A.jsxs(Ox,{"data-event-index":w,children:[A.jsx(Iz,{label:w+1}),A.jsx(Dz,{children:A.jsxs("div",{className:"space-y-2",children:[A.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[A.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:A.jsx("code",{className:"text-sm font-mono truncate",children:I.type})}),I.timestamp!==void 0?A.jsx("span",{className:"text-[10px] text-muted-foreground font-mono whitespace-nowrap",children:y(I.timestamp.getTime())}):null]}),A.jsx(poe,{language:typeof I.data=="string"?"text":"json",value:b(I.data),wrapLongLines:a,className:"rounded border max-h-64 overflow-auto"})]})})]},`${I.type}-${w}`)})})]}):A.jsx("div",{className:"flex items-center justify-center h-full",children:A.jsx("p",{className:"text-muted-foreground text-sm",children:"Start a run to see events"})})}),(l||d)&&A.jsxs("div",{className:"p-4 border-t border-border",children:[A.jsx("h4",{className:"font-medium text-sm mb-2",children:"Final Result"}),d?A.jsxs("div",{className:"text-destructive text-sm p-3 bg-destructive/10 border border-destructive/20 rounded",children:["Failed to load final result: ",d]}):A.jsx(poe,{language:typeof l=="string"?"text":"json",value:typeof l=="string"?l:JSON.stringify(l,null,2),className:"rounded border overflow-hidden"})]})]})]})]})}function _Ye({activeHandlerId:t,onHandlerSelect:e}){const{state:n,sync:r}=FJ(),a=n.handlers,[i,o]=N.useState(!1);N.useEffect(()=>{o(!0),r().finally(()=>o(!1))},[r]);const s=u=>`${u.workflow_name||"Unknown"}`,l=Object.values(a);return A.jsxs("div",{className:"h-full flex flex-col text-sm",children:[A.jsx("div",{className:"px-3 py-2 border-b border-border",children:A.jsx("div",{className:"flex items-center justify-between",children:A.jsx("h2",{className:"font-semibold text-xs tracking-tight",children:"Recent Runs"})})}),A.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i&&A.jsxs("div",{className:"p-2 space-y-2",children:[A.jsx(uf,{className:"h-8 w-full"}),A.jsx(uf,{className:"h-8 w-full"}),A.jsx(uf,{className:"h-8 w-full"})]}),!i&&A.jsx("div",{className:"p-2 divide-y divide-border",children:l.length===0?A.jsx("div",{className:"text-muted-foreground text-xs p-3 text-center",children:"No runs yet. Start a workflow to see runs here."}):l.map(u=>A.jsx("button",{onClick:()=>e(u.handler_id),className:`w-full text-left px-2 py-1.5 transition-colors cursor-pointer border border-collapse ${t===u.handler_id?"bg-accent ":"hover:bg-accent"}`,children:A.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-2",children:[A.jsx("span",{className:"truncate text-xs",children:s(u)}),A.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:u.handler_id.slice(-8)})]})},u.handler_id))})]})]})}function bYe({selectedWorkflow:t,onRunStart:e,onCollapse:n}){const[r,a]=N.useState(null),[i,o]=N.useState({}),[s,l]=N.useState(!1),[u,d]=N.useState(null),[f,m]=N.useState(""),[h,E]=N.useState(null),[b,y]=N.useState({}),[v,C]=N.useState(!1),T=pd(),{createHandler:w}=L3e(t),{setHandler:I}=FJ();N.useEffect(()=>{t?(async()=>{if(t)try{l(!0),d(null);const{data:F,error:P}=await eye({client:T,path:{name:t}});if(F)a((F==null?void 0:F.start)??null);else throw new Error(P?String(P):"Failed to fetch schema");o({}),m(JSON.stringify({},null,2)),E(null),y({})}catch(F){d(F instanceof Error?F.message:"Failed to fetch schema"),a(null)}finally{l(!1)}})():(a(null),o({}),m(""),E(null),y({}))},[t,T]);const x=async()=>{if(t)try{C(!0);const M=await w(i);I(M),e(M.handler_id),n&&n()}catch(M){console.error("Failed to run workflow:",M)}finally{C(!1)}},D=!!(r!=null&&r.properties&&Object.keys(r.properties).length>0);return t?A.jsxs("div",{className:"h-full flex flex-col",children:[A.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[A.jsxs("h2",{className:"font-semibold text-sm",children:["Configure: ",t]}),n&&A.jsx(Xn,{variant:"ghost",size:"icon-sm",onClick:n,title:"Hide configuration panel (Ctrl+B)",startIcon:A.jsx(WG,{})})]}),A.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s&&A.jsxs("div",{className:"space-y-4",children:[A.jsx(uf,{className:"h-4 w-32"}),A.jsx(uf,{className:"h-20 w-full"}),A.jsx(uf,{className:"h-4 w-32"}),A.jsx(uf,{className:"h-20 w-full"})]}),u&&A.jsxs("div",{className:"text-destructive text-sm p-3 bg-destructive/10 border border-destructive/20 rounded",children:["Error loading schema: ",u]}),!s&&!u&&A.jsx(A.Fragment,{children:A.jsx("div",{className:"space-y-4",children:D?A.jsx(nce,{schema:r,values:i,onChange:o,onErrorsChange:y}):A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:"raw-input",label:"Input (JSON)"}),A.jsx("div",{className:"font-mono",children:A.jsx(wT,{id:"raw-input",value:f,onChange:M=>{m(M.target.value);try{const F=JSON.parse(M.target.value);o(F),E(null)}catch{E("Invalid JSON")}},placeholder:'{"key": "value"}',variant:h?"error":"default",minRows:8})}),h&&A.jsx("p",{className:"text-xs text-destructive mt-1",children:h})]})})})]}),!s&&!u&&A.jsxs("div",{className:"p-4 border-t border-border",children:[Object.values(b).some(M=>M)&&A.jsx("p",{className:"text-xs text-destructive mb-2",children:"Fix invalid JSON fields before running."}),A.jsx(Xn,{onClick:x,disabled:v||Object.values(b).some(M=>M),fullWidth:!0,label:v?"Starting...":"Run Workflow"})]})]}):A.jsxs("div",{className:"h-full flex flex-col",children:[A.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[A.jsx("h2",{className:"font-semibold text-sm",children:"Workflow Configuration"}),n&&A.jsx(Xn,{variant:"ghost",size:"icon-sm",onClick:n,title:"Hide configuration panel (Ctrl+B)",startIcon:A.jsx(WG,{})})]}),A.jsx("div",{className:"flex-1 flex items-center justify-center",children:A.jsx("p",{className:"text-muted-foreground text-center",children:"Select a workflow to configure and run"})})]})}function EYe(t,e,n=!0){N.useEffect(()=>{const r=a=>{(n&&a.ctrlKey&&a.key.toLowerCase()===t.toLowerCase()||!n&&a.key.toLowerCase()===t.toLowerCase())&&(a.preventDefault(),e())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,e,n])}function SYe(){if(typeof window>"u")return eA();const e=new URLSearchParams(window.location.search).get("api");return e?e.endsWith("/")?e.slice(0,-1):e:eA()}function vYe(){const[t,e]=N.useState(SYe),[n,r]=N.useState(t),[a,i]=N.useState(null),[o,s]=N.useState(null),{state:l,sync:u}=M3e(),[d,f]=N.useState(37.5),[m,h]=N.useState(!1),[E,b]=N.useState(!1),[y,v]=N.useState(!1),[C,T]=N.useState(null),[w,I]=N.useState(null),x=l.workflows,D=pd(),M=N.useCallback(async()=>{try{I(null);const{data:W,error:G}=await tye({client:D});if(G)throw new Error(String(G));W&&W.status?T(!0):(T(!1),I("Workflow server is unreachable"))}catch{T(!1),I("Workflow server is unreachable")}},[D]);N.useEffect(()=>{D.setConfig({baseUrl:t}),M(),u()},[t,D,M,u]);const F=()=>{const W=n.endsWith("/")?n.slice(0,-1):n;e(W)},P=()=>{const W=eA();e(W),r(W)},q=W=>{s(W)},j=W=>{W.preventDefault(),h(!0)},X=N.useCallback(W=>{const G=document.querySelector(".main-content-area");if(!G)return;const Y=G.getBoundingClientRect(),K=(W.clientX-Y.left)/Y.width*100,J=Math.max(20,Math.min(80,K));f(J)},[]),B=N.useCallback(()=>{h(!1)},[]);return N.useEffect(()=>{if(m)return document.addEventListener("mousemove",X),document.addEventListener("mouseup",B),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",X),document.removeEventListener("mouseup",B),document.body.style.cursor="",document.body.style.userSelect=""}},[m,X,B]),EYe("b",N.useCallback(()=>{v(W=>!W)},[]),!0),A.jsxs("div",{className:`h-screen flex flex-col bg-background ${m?"resize-active":""}`,children:[A.jsxs("div",{className:"flex items-center justify-between h-12 px-4 bg-card border-b border-border",children:[A.jsxs("div",{className:"flex items-center gap-4",children:[A.jsx(Xn,{variant:"ghost",size:"icon-sm",onClick:()=>b(!E),title:E?"Show sidebar":"Hide sidebar",startIcon:E?A.jsx(OEe,{}):A.jsx(NEe,{})}),A.jsx("h1",{className:"text-md font-semibold",children:"Workflow Debugger"})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:"flex items-center",children:A.jsx(Bs,{htmlFor:"workflow",label:"Workflow:",variant:"standalone"})}),A.jsx("div",{className:"w-48",children:A.jsxs(Sx,{value:a||"",onValueChange:i,children:[A.jsx(TT,{id:"workflow",placeholder:"Select workflow..."}),A.jsx(CT,{children:Object.keys(x).map(W=>A.jsx(Gh,{value:W,label:W},W))})]})})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[C!==null&&A.jsx("span",{className:`${C?"bg-green-500":"bg-red-500"} h-2 w-2 rounded-full`}),C===!1&&A.jsx("span",{className:"text-destructive text-xs",children:w||"Workflow server is unreachable"}),A.jsxs(O0e,{children:[A.jsx(I0e,{asChild:!0,children:A.jsx(Xn,{variant:"ghost",size:"icon-sm",startIcon:A.jsx(PEe,{})})}),A.jsx(rG,{className:"w-80",children:A.jsx("div",{className:"space-y-4",children:A.jsxs("div",{className:"space-y-2",children:[A.jsx("h4",{className:"font-medium text-sm",children:"API Configuration"}),A.jsx(OT,{value:n,onChange:W=>r(W.target.value),placeholder:"http://localhost:8000"}),A.jsxs("div",{className:"flex gap-2",children:[A.jsx(Xn,{onClick:F,variant:"outline",size:"sm",disabled:n===t,label:"Save"}),A.jsx(Xn,{onClick:P,variant:"outline",size:"sm",label:"Reset"})]}),A.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",t]})]})})})]})]})]}),A.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!E&&A.jsx("div",{className:"w-48 border-r border-border bg-card overflow-hidden transition-all duration-200",children:A.jsx(_Ye,{activeHandlerId:o,onHandlerSelect:s})}),A.jsxs("div",{className:"flex-1 flex overflow-hidden main-content-area",children:[y?A.jsx("div",{className:"w-10 border-r border-border bg-muted/30 flex flex-col items-center justify-center hover:bg-muted/50 transition-colors",children:A.jsx(Xn,{variant:"ghost",size:"icon-sm",onClick:()=>v(!1),title:"Show configuration panel (Ctrl+B)",startIcon:A.jsx(IEe,{})})}):A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"border-r border-border overflow-auto",style:{width:`${d}%`},children:a&&A.jsx(bYe,{selectedWorkflow:a,onRunStart:q,activeHandlerId:o,onCollapse:()=>v(!0)})}),A.jsx("div",{className:`w-2 hover:bg-gray-500/20 hover:shadow-lg cursor-col-resize flex-shrink-0 transition-all duration-200 relative group border-l border-r border-border ${m?"shadow-xl":""}`,onMouseDown:j,title:"Drag to resize panels"})]}),A.jsx("div",{className:"overflow-auto",style:{width:y?"calc(100% - 40px)":`${100-d}%`},children:o&&A.jsx(gYe,{handlerId:o,selectedWorkflow:a})})]})]})]})}class yYe extends Ie.Component{constructor(n){super(n);Ue(this,"resetError",()=>{this.setState({hasError:!1,error:void 0})});this.state={hasError:!1}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){console.error("ErrorBoundary caught an error:",n,r)}render(){if(this.state.hasError&&this.state.error){if(this.props.fallback){const n=this.props.fallback;return A.jsx(n,{error:this.state.error,resetError:this.resetError})}return A.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:A.jsxs("div",{className:"max-w-md p-6 bg-card border border-border rounded-lg shadow-sm",children:[A.jsx("h2",{className:"text-lg font-semibold text-destructive mb-2",children:"Something went wrong"}),A.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"The workflow debugger encountered an error. This might happen if the workflow server is unreachable."}),A.jsxs("details",{className:"mb-4",children:[A.jsx("summary",{className:"text-sm font-medium cursor-pointer hover:text-foreground",children:"Error Details"}),A.jsx("pre",{className:"mt-2 text-xs bg-muted p-3 rounded border overflow-auto",children:this.state.error.message})]}),A.jsxs("div",{className:"flex gap-2",children:[A.jsx("button",{onClick:this.resetError,className:"px-3 py-2 text-sm bg-primary text-primary-foreground rounded hover:bg-primary/90 transition-colors",children:"Try Again"}),A.jsx("button",{onClick:()=>window.location.reload(),className:"px-3 py-2 text-sm bg-secondary text-secondary-foreground rounded hover:bg-secondary/90 transition-colors",children:"Reload Page"})]})]})})}return this.props.children}}function TYe(){const t=eA(),e=$q({baseUrl:t});return A.jsx(yYe,{children:A.jsx(oye,{clients:{workflowsClient:e},children:A.jsx(vYe,{})})})}function rce(){const t=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",t)}rce(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",rce),Jhe.createRoot(document.getElementById("root")).render(A.jsx(N.StrictMode,{children:A.jsx(TYe,{})}));const Si=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),cB=[.001,0,0,.001,0,0],uB=1.35,Eo={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ql={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},ME="pdfjs_internal_editor_",It={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},an={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},ace={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ua={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},LE={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Xr={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Rg={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},PE={ERRORS:0,WARNINGS:1,INFOS:5},wg={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},$A={moveTo:0,lineTo:1,curveTo:2,closePath:3},ice={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let YA=PE.WARNINGS;function CYe(t){Number.isInteger(t)&&(YA=t)}function AYe(){return YA}function VA(t){YA>=PE.INFOS&&console.info(`Info: ${t}`)}function Dt(t){YA>=PE.WARNINGS&&console.warn(`Warning: ${t}`)}function er(t){throw new Error(t)}function ln(t,e){t||er(e)}function RYe(t){switch(t==null?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function dB(t,e=null,n=null){if(!t)return null;if(n&&typeof t=="string"){if(n.addDefaultProtocol&&t.startsWith("www.")){const a=t.match(/\./g);(a==null?void 0:a.length)>=2&&(t=`http://${t}`)}if(n.tryConvertEncoding)try{t=IYe(t)}catch{}}const r=e?URL.parse(t,e):URL.parse(t);return RYe(r)?r:null}function pB(t,e,n=!1){const r=URL.parse(t);return r?(r.hash=e,r.href):n&&dB(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function Ht(t,e,n,r=!1){return Object.defineProperty(t,e,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}const Mf=(function(){function e(n,r){this.message=n,this.name=r}return e.prototype=new Error,e.constructor=e,e})();class oce extends Mf{constructor(e,n){super(e,"PasswordException"),this.code=n}}class fB extends Mf{constructor(e,n){super(e,"UnknownErrorException"),this.details=n}}class jA extends Mf{constructor(e){super(e,"InvalidPDFException")}}class FE extends Mf{constructor(e,n,r){super(e,"ResponseException"),this.status=n,this.missing=r}}class wYe extends Mf{constructor(e){super(e,"FormatError")}}class $c extends Mf{constructor(e){super(e,"AbortException")}}function sce(t){(typeof t!="object"||(t==null?void 0:t.length)===void 0)&&er("Invalid argument for bytesToString");const e=t.length,n=8192;if(e<n)return String.fromCharCode.apply(null,t);const r=[];for(let a=0;a<e;a+=n){const i=Math.min(a+n,e),o=t.subarray(a,i);r.push(String.fromCharCode.apply(null,o))}return r.join("")}function BE(t){typeof t!="string"&&er("Invalid argument for stringToBytes");const e=t.length,n=new Uint8Array(e);for(let r=0;r<e;++r)n[r]=t.charCodeAt(r)&255;return n}function xYe(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255)}function NYe(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}function OYe(){try{return new Function(""),!0}catch{return!1}}class Ra{static get isLittleEndian(){return Ht(this,"isLittleEndian",NYe())}static get isEvalSupported(){return Ht(this,"isEvalSupported",OYe())}static get isOffscreenCanvasSupported(){return Ht(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Ht(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:e,userAgent:n}=navigator;return Ht(this,"platform",{isAndroid:n.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:n.includes("Firefox")})}static get isCSSRoundSupported(){var e,n;return Ht(this,"isCSSRoundSupported",(n=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:n.call(e,"width: round(1.5px, 1px)"))}}const mB=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class nt{static makeHexColor(e,n,r){return`#${mB[e]}${mB[n]}${mB[r]}`}static domMatrixToTransform(e){return[e.a,e.b,e.c,e.d,e.e,e.f]}static scaleMinMax(e,n){let r;e[0]?(e[0]<0&&(r=n[0],n[0]=n[2],n[2]=r),n[0]*=e[0],n[2]*=e[0],e[3]<0&&(r=n[1],n[1]=n[3],n[3]=r),n[1]*=e[3],n[3]*=e[3]):(r=n[0],n[0]=n[1],n[1]=r,r=n[2],n[2]=n[3],n[3]=r,e[1]<0&&(r=n[1],n[1]=n[3],n[3]=r),n[1]*=e[1],n[3]*=e[1],e[2]<0&&(r=n[0],n[0]=n[2],n[2]=r),n[0]*=e[2],n[2]*=e[2]),n[0]+=e[4],n[1]+=e[5],n[2]+=e[4],n[3]+=e[5]}static transform(e,n){return[e[0]*n[0]+e[2]*n[1],e[1]*n[0]+e[3]*n[1],e[0]*n[2]+e[2]*n[3],e[1]*n[2]+e[3]*n[3],e[0]*n[4]+e[2]*n[5]+e[4],e[1]*n[4]+e[3]*n[5]+e[5]]}static multiplyByDOMMatrix(e,n){return[e[0]*n.a+e[2]*n.b,e[1]*n.a+e[3]*n.b,e[0]*n.c+e[2]*n.d,e[1]*n.c+e[3]*n.d,e[0]*n.e+e[2]*n.f+e[4],e[1]*n.e+e[3]*n.f+e[5]]}static applyTransform(e,n,r=0){const a=e[r],i=e[r+1];e[r]=a*n[0]+i*n[2]+n[4],e[r+1]=a*n[1]+i*n[3]+n[5]}static applyTransformToBezier(e,n,r=0){const a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],u=n[5];for(let d=0;d<6;d+=2){const f=e[r+d],m=e[r+d+1];e[r+d]=f*a+m*o+l,e[r+d+1]=f*i+m*s+u}}static applyInverseTransform(e,n){const r=e[0],a=e[1],i=n[0]*n[3]-n[1]*n[2];e[0]=(r*n[3]-a*n[2]+n[2]*n[5]-n[4]*n[3])/i,e[1]=(-r*n[1]+a*n[0]+n[4]*n[1]-n[5]*n[0])/i}static axialAlignedBoundingBox(e,n,r){const a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],u=n[5],d=e[0],f=e[1],m=e[2],h=e[3];let E=a*d+l,b=E,y=a*m+l,v=y,C=s*f+u,T=C,w=s*h+u,I=w;if(i!==0||o!==0){const x=i*d,D=i*m,M=o*f,F=o*h;E+=M,v+=M,y+=F,b+=F,C+=x,I+=x,w+=D,T+=D}r[0]=Math.min(r[0],E,y,b,v),r[1]=Math.min(r[1],C,w,T,I),r[2]=Math.max(r[2],E,y,b,v),r[3]=Math.max(r[3],C,w,T,I)}static inverseTransform(e){const n=e[0]*e[3]-e[1]*e[2];return[e[3]/n,-e[1]/n,-e[2]/n,e[0]/n,(e[2]*e[5]-e[4]*e[3])/n,(e[4]*e[1]-e[5]*e[0])/n]}static singularValueDecompose2dScale(e,n){const r=e[0],a=e[1],i=e[2],o=e[3],s=r**2+a**2,l=r*i+a*o,u=i**2+o**2,d=(s+u)/2,f=Math.sqrt(d**2-(s*u-l**2));n[0]=Math.sqrt(d+f||1),n[1]=Math.sqrt(d-f||1)}static normalizeRect(e){const n=e.slice(0);return e[0]>e[2]&&(n[0]=e[2],n[2]=e[0]),e[1]>e[3]&&(n[1]=e[3],n[3]=e[1]),n}static intersect(e,n){const r=Math.max(Math.min(e[0],e[2]),Math.min(n[0],n[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(n[0],n[2]));if(r>a)return null;const i=Math.max(Math.min(e[1],e[3]),Math.min(n[1],n[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(n[1],n[3]));return i>o?null:[r,i,a,o]}static pointBoundingBox(e,n,r){r[0]=Math.min(r[0],e),r[1]=Math.min(r[1],n),r[2]=Math.max(r[2],e),r[3]=Math.max(r[3],n)}static rectBoundingBox(e,n,r,a,i){i[0]=Math.min(i[0],e,r),i[1]=Math.min(i[1],n,a),i[2]=Math.max(i[2],e,r),i[3]=Math.max(i[3],n,a)}static bezierBoundingBox(e,n,r,a,i,o,s,l,u){u[0]=Math.min(u[0],e,s),u[1]=Math.min(u[1],n,l),u[2]=Math.max(u[2],e,s),u[3]=Math.max(u[3],n,l),Q(this,jc,c7).call(this,e,r,i,s,n,a,o,l,3*(-e+3*(r-i)+s),6*(e-2*r+i),3*(r-e),u),Q(this,jc,c7).call(this,e,r,i,s,n,a,o,l,3*(-n+3*(a-o)+l),6*(n-2*a+o),3*(a-n),u)}}jc=new WeakSet,K1=function(e,n,r,a,i,o,s,l,u,d){if(u<=0||u>=1)return;const f=1-u,m=u*u,h=m*u,E=f*(f*(f*e+3*u*n)+3*m*r)+h*a,b=f*(f*(f*i+3*u*o)+3*m*s)+h*l;d[0]=Math.min(d[0],E),d[1]=Math.min(d[1],b),d[2]=Math.max(d[2],E),d[3]=Math.max(d[3],b)},c7=function(e,n,r,a,i,o,s,l,u,d,f,m){if(Math.abs(u)<1e-12){Math.abs(d)>=1e-12&&Q(this,jc,K1).call(this,e,n,r,a,i,o,s,l,-f/d,m);return}const h=d**2-4*f*u;if(h<0)return;const E=Math.sqrt(h),b=2*u;Q(this,jc,K1).call(this,e,n,r,a,i,o,s,l,(-d+E)/b,m),Q(this,jc,K1).call(this,e,n,r,a,i,o,s,l,(-d-E)/b,m)},V(nt,jc);function IYe(t){return decodeURIComponent(escape(t))}let hB=null,lce=null;function cce(t){return hB||(hB=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,lce=new Map([["ſt","ſt"]])),t.replaceAll(hB,(e,n,r)=>n?n.normalize("NFKC"):lce.get(r))}function gB(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),sce(t)}const _B="pdfjs_internal_id_";function DYe(t,e,n){if(!Array.isArray(n)||n.length<2)return!1;const[r,a,...i]=n;if(!t(r)&&!Number.isInteger(r)||!e(a))return!1;const o=i.length;let s=!0;switch(a.name){case"XYZ":if(o<2||o>3)return!1;break;case"Fit":case"FitB":return o===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1)return!1;break;case"FitR":if(o!==4)return!1;s=!1;break;default:return!1}for(const l of i)if(!(typeof l=="number"||s&&l===null))return!1;return!0}function ri(t,e,n){return Math.min(Math.max(t,e),n)}function uce(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(sce(t))}function kYe(t){return Uint8Array.fromBase64?Uint8Array.fromBase64(t):BE(atob(t))}typeof Promise.try!="function"&&(Promise.try=function(t,...e){return new Promise(n=>{n(t(...e))})}),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(t){return t.reduce((e,n)=>e+n,0)});class UE{static textContent(e){const n=[],r={items:n,styles:Object.create(null)};function a(i){var l;if(!i)return;let o=null;const s=i.name;if(s==="#text")o=i.value;else if(UE.shouldBuildText(s))(l=i==null?void 0:i.attributes)!=null&&l.textContent?o=i.attributes.textContent:i.value&&(o=i.value);else return;if(o!==null&&n.push({str:o}),!!i.children)for(const u of i.children)a(u)}return a(e),r}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}class bB{static setupStorage(e,n,r,a,i){const o=a.getValue(n,{value:null});switch(r.name){case"textarea":if(o.value!==null&&(e.textContent=o.value),i==="print")break;e.addEventListener("input",s=>{a.setValue(n,{value:s.target.value})});break;case"input":if(r.attributes.type==="radio"||r.attributes.type==="checkbox"){if(o.value===r.attributes.xfaOn?e.setAttribute("checked",!0):o.value===r.attributes.xfaOff&&e.removeAttribute("checked"),i==="print")break;e.addEventListener("change",s=>{a.setValue(n,{value:s.target.checked?s.target.getAttribute("xfaOn"):s.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&e.setAttribute("value",o.value),i==="print")break;e.addEventListener("input",s=>{a.setValue(n,{value:s.target.value})})}break;case"select":if(o.value!==null){e.setAttribute("value",o.value);for(const s of r.children)s.attributes.value===o.value?s.attributes.selected=!0:s.attributes.hasOwnProperty("selected")&&delete s.attributes.selected}e.addEventListener("input",s=>{const l=s.target.options,u=l.selectedIndex===-1?"":l[l.selectedIndex].value;a.setValue(n,{value:u})});break}}static setAttributes({html:e,element:n,storage:r=null,intent:a,linkService:i}){const{attributes:o}=n,s=e instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${a}`);for(const[l,u]of Object.entries(o))if(u!=null)switch(l){case"class":u.length&&e.setAttribute(l,u.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",u);break;case"style":Object.assign(e.style,u);break;case"textContent":e.textContent=u;break;default:(!s||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,u)}s&&i.addLinkAttributes(e,o.href,o.newWindow),r&&o.dataId&&this.setupStorage(e,o.dataId,n,r)}static render(e){var f,m;const n=e.annotationStorage,r=e.linkService,a=e.xfaHtml,i=e.intent||"display",o=document.createElement(a.name);a.attributes&&this.setAttributes({html:o,element:a,intent:i,linkService:r});const s=i!=="richText",l=e.div;if(l.append(o),e.viewport){const h=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=h}s&&l.setAttribute("class","xfaLayer xfaFont");const u=[];if(a.children.length===0){if(a.value){const h=document.createTextNode(a.value);o.append(h),s&&UE.shouldBuildText(a.name)&&u.push(h)}return{textDivs:u}}const d=[[a,-1,o]];for(;d.length>0;){const[h,E,b]=d.at(-1);if(E+1===h.children.length){d.pop();continue}const y=h.children[++d.at(-1)[1]];if(y===null)continue;const{name:v}=y;if(v==="#text"){const T=document.createTextNode(y.value);u.push(T),b.append(T);continue}const C=(f=y==null?void 0:y.attributes)!=null&&f.xmlns?document.createElementNS(y.attributes.xmlns,v):document.createElement(v);if(b.append(C),y.attributes&&this.setAttributes({html:C,element:y,storage:n,intent:i,linkService:r}),((m=y.children)==null?void 0:m.length)>0)d.push([y,-1,C]);else if(y.value){const T=document.createTextNode(y.value);s&&UE.shouldBuildText(v)&&u.push(T),C.append(T)}}for(const h of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))h.setAttribute("readOnly",!0);return{textDivs:u}}static update(e){const n=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=n,e.div.hidden=!1}}const Yc="http://www.w3.org/2000/svg",Gf=class Gf{};Ue(Gf,"CSS",96),Ue(Gf,"PDF",72),Ue(Gf,"PDF_TO_CSS_UNITS",Gf.CSS/Gf.PDF);let Vc=Gf;async function xg(t,e="text"){if(qE(t,document.baseURI)){const n=await fetch(t);if(!n.ok)throw new Error(n.statusText);switch(e){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise((n,r)=>{const a=new XMLHttpRequest;a.open("GET",t,!0),a.responseType=e,a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(a.status===200||a.status===0){switch(e){case"arraybuffer":case"blob":case"json":n(a.response);return}n(a.responseText);return}r(new Error(a.statusText))}},a.send(null)})}class GE{constructor({viewBox:e,userUnit:n,scale:r,rotation:a,offsetX:i=0,offsetY:o=0,dontFlip:s=!1}){this.viewBox=e,this.userUnit=n,this.scale=r,this.rotation=a,this.offsetX=i,this.offsetY=o,r*=n;const l=(e[2]+e[0])/2,u=(e[3]+e[1])/2;let d,f,m,h;switch(a%=360,a<0&&(a+=360),a){case 180:d=-1,f=0,m=0,h=1;break;case 90:d=0,f=1,m=1,h=0;break;case 270:d=0,f=-1,m=-1,h=0;break;case 0:d=1,f=0,m=0,h=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}s&&(m=-m,h=-h);let E,b,y,v;d===0?(E=Math.abs(u-e[1])*r+i,b=Math.abs(l-e[0])*r+o,y=(e[3]-e[1])*r,v=(e[2]-e[0])*r):(E=Math.abs(l-e[0])*r+i,b=Math.abs(u-e[1])*r+o,y=(e[2]-e[0])*r,v=(e[3]-e[1])*r),this.transform=[d*r,f*r,m*r,h*r,E-d*r*l-m*r*u,b-f*r*l-h*r*u],this.width=y,this.height=v}get rawDims(){const e=this.viewBox;return Ht(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:a=this.offsetY,dontFlip:i=!1}={}){return new GE({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:n,offsetX:r,offsetY:a,dontFlip:i})}convertToViewportPoint(e,n){const r=[e,n];return nt.applyTransform(r,this.transform),r}convertToViewportRectangle(e){const n=[e[0],e[1]];nt.applyTransform(n,this.transform);const r=[e[2],e[3]];return nt.applyTransform(r,this.transform),[n[0],n[1],r[0],r[1]]}convertToPdfPoint(e,n){const r=[e,n];return nt.applyInverseTransform(r,this.transform),r}}class WA extends Mf{constructor(e,n=0){super(e,"RenderingCancelledException"),this.extraDelay=n}}function zE(t){const e=t.length;let n=0;for(;n<e&&t[n].trim()==="";)n++;return t.substring(n,n+5).toLowerCase()==="data:"}function KA(t){return typeof t=="string"&&/\.pdf$/i.test(t)}function dce(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function pce(t,e="document.pdf"){if(typeof t!="string")return e;if(zE(t))return Dt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const r=(s=>{try{return new URL(s)}catch{try{return new URL(decodeURIComponent(s))}catch{try{return new URL(s,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(s),"https://foo.bar")}catch{return null}}}}})(t);if(!r)return e;const a=s=>{try{let l=decodeURIComponent(s);return l.includes("/")?(l=l.split("/").at(-1),l.test(/^\.pdf$/i)?l:s):l}catch{return s}},i=/\.pdf$/i,o=r.pathname.split("/").at(-1);if(i.test(o))return a(o);if(r.searchParams.size>0){const s=Array.from(r.searchParams.values()).reverse();for(const u of s)if(i.test(u))return a(u);const l=Array.from(r.searchParams.keys()).reverse();for(const u of l)if(i.test(u))return a(u)}if(r.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(r.hash);if(l)return a(l[0])}return e}class fce{constructor(){Ue(this,"started",Object.create(null));Ue(this,"times",[])}time(e){e in this.started&&Dt(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Dt(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let n=0;for(const{name:r}of this.times)n=Math.max(r.length,n);for(const{name:r,start:a,end:i}of this.times)e.push(`${r.padEnd(n)} ${i-a}ms
|
|
655
|
+
M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}tce.displayName="MiniMap",N.memo(tce);const lYe=t=>e=>t?`${Math.max(1/e.transform[2],1)}`:void 0,cYe={[Cg.Line]:"right",[Cg.Handle]:"bottom-right"};function uYe({nodeId:t,position:e,variant:n=Cg.Handle,className:r,style:a=void 0,children:i,color:o,minWidth:s=10,minHeight:l=10,maxWidth:u=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:m,autoScale:h=!0,shouldResize:E,onResizeStart:b,onResize:y,onResizeEnd:v}){const C=Tle(),T=typeof t=="string"?t:C,w=Er(),I=N.useRef(null),x=n===Cg.Handle,D=dn(N.useCallback(lYe(x&&h),[x,h]),Nr),M=N.useRef(null),F=e??cYe[n];N.useEffect(()=>{if(!(!I.current||!T))return M.current||(M.current=qqe({domNode:I.current,nodeId:T,getStoreItems:()=>{const{nodeLookup:q,transform:j,snapGrid:X,snapToGrid:B,nodeOrigin:W,domNode:G}=w.getState();return{nodeLookup:q,transform:j,snapGrid:X,snapToGrid:B,nodeOrigin:W,paneDomNode:G}},onChange:(q,j)=>{const{triggerNodeChanges:X,nodeLookup:B,parentLookup:W,nodeOrigin:G}=w.getState(),Y=[],K={x:q.x,y:q.y},J=B.get(T);if(J&&J.expandParent&&J.parentId){const $=J.origin??G,Z=q.width??J.measured.width??0,te=q.height??J.measured.height??0,U={id:J.id,parentId:J.parentId,rect:{width:Z,height:te,...Ese({x:q.x??J.position.x,y:q.y??J.position.y},{width:Z,height:te},J.parentId,B,$)}},ie=X5([U],B,W,G);Y.push(...ie),K.x=q.x?Math.max($[0]*Z,q.x):void 0,K.y=q.y?Math.max($[1]*te,q.y):void 0}if(K.x!==void 0&&K.y!==void 0){const $={id:T,type:"position",position:{...K}};Y.push($)}if(q.width!==void 0&&q.height!==void 0){const Z={id:T,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};Y.push(Z)}for(const $ of j){const Z={...$,type:"position"};Y.push(Z)}X(Y)},onEnd:({width:q,height:j})=>{const X={id:T,type:"dimensions",resizing:!1,dimensions:{width:q,height:j}};w.getState().triggerNodeChanges([X])}})),M.current.update({controlPosition:F,boundaries:{minWidth:s,minHeight:l,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:m,onResizeStart:b,onResize:y,onResizeEnd:v,shouldResize:E}),()=>{var q;(q=M.current)==null||q.destroy()}},[F,s,l,u,d,f,b,y,v,E]);const P=F.split("-");return A.jsx("div",{className:ra(["react-flow__resize-control","nodrag",...P,n,r]),ref:I,style:{...a,scale:D,...o&&{[x?"backgroundColor":"borderColor"]:o}},children:i})}N.memo(uYe);function dYe({workflowName:t,className:e="w-full h-[600px]",events:n,onNodeClick:r,highlightedNodeId:a,selectedNodeId:i,isComplete:o=!1}){const[s,l,u]=F$e([]),[d,f,m]=B$e([]),[h,E]=N.useState(!1),[b,y]=N.useState(null),[v,C]=N.useState(-1),[T,w]=N.useState(()=>{if(typeof window>"u")return!1;try{return document.documentElement.classList.contains("dark")?!0:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}),I=N.useMemo(()=>({step:({data:P,id:q})=>{const j=a===q,X=i===q;let B={transition:"all 1s ease-out"};return P.highlightColor&&P.highlightColor!==null?(B.backgroundColor=T?void 0:"#CCFBEF",B.borderColor=P.highlightColor,B.boxShadow=`0 0 0 3px ${P.highlightColor}66`):P.highlightColor===null&&(B.backgroundColor=T?"#0b1220":"#E6EEFF",B.borderColor=T?"#274690":"#7EA6FF",B.boxShadow="0 0 0 0px transparent"),X?B={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6",transition:"all 1s ease-out"}:j&&(B={...B,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),A.jsxs("div",{className:"px-4 py-2 shadow-md rounded-md min-w-[160px] cursor-pointer transition-all bg-[#E6EEFF] border-2 border-[#7EA6FF] dark:bg-[#0b1220] dark:border-[#274690] hover:shadow-lg hover:scale-105",style:B,onClick:()=>r==null?void 0:r(q),children:[A.jsx(zl,{type:"target",position:bt.Left}),A.jsxs("div",{className:"flex items-center justify-between gap-2",children:[A.jsx("div",{className:"font-bold text-[#1E3A8A] text-sm dark:text-[#e5edff]",children:P.label}),P.workerCount>0&&A.jsx("div",{className:"flex items-center justify-center min-w-[20px] h-[20px] px-1.5 rounded-full bg-[#10B981] text-white text-[10px] font-bold",children:P.workerCount})]}),P.title&&A.jsx("div",{className:"text-xs text-[#1D4ED8] mt-1 dark:text-[#9db4ff]",children:P.title}),(P.lastInputEvent||P.lastOutputEvent)&&A.jsxs("div",{className:"text-[10px] text-gray-700 dark:text-gray-300 mt-1",children:[P.lastInputEvent&&A.jsxs("div",{children:[A.jsx("span",{className:"font-semibold",children:"in:"})," ",P.lastInputEvent]}),P.lastOutputEvent&&A.jsxs("div",{children:[A.jsx("span",{className:"font-semibold",children:"out:"})," ",P.lastOutputEvent]})]}),A.jsx(zl,{type:"source",position:bt.Right})]})},event:({data:P,id:q})=>{const j=a===q,X=i===q;let B={transition:"all 1s ease-out"};return P.highlightColor&&P.highlightColor!==null?(B.backgroundColor=T?void 0:"#FFE8B5",B.borderColor=P.highlightColor,B.boxShadow=`0 0 0 3px ${P.highlightColor}66`):P.highlightColor===null&&(B.backgroundColor=T?"#241a06":"#FFF3BF",B.borderColor=T?"#F59E0B":"#FFD166",B.boxShadow="0 0 0 0px transparent"),X?B={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6",transition:"all 1s ease-out"}:j&&(B={...B,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),A.jsxs("div",{className:"px-3 py-2 shadow-md rounded-full min-w-[140px] text-center cursor-pointer transition-all bg-[#FFF3BF] border-2 border-[#FFD166] dark:bg-[#241a06] dark:border-[#F59E0B] hover:shadow-lg hover:scale-105",style:B,onClick:()=>r==null?void 0:r(q),children:[A.jsx(zl,{type:"target",position:bt.Left}),A.jsx("div",{className:"font-bold text-[#92400E] text-sm dark:text-[#fde68a]",children:P.label}),P.event_type&&A.jsx("div",{className:"text-xs text-[#B45309] mt-1 dark:text-[#fbbf24]",children:P.event_type}),A.jsx(zl,{type:"source",position:bt.Right})]})},external:({data:P,id:q})=>{const j=a===q,X=i===q;let B=P.highlightColor?{backgroundColor:T?void 0:"#FFE5D4",borderColor:P.highlightColor,boxShadow:`0 0 0 3px ${P.highlightColor}66`}:void 0;return X?B={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6"}:j&&(B={backgroundColor:B==null?void 0:B.backgroundColor,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),A.jsxs("div",{className:"px-3 py-2 shadow-md rounded-lg min-w-[140px] text-center cursor-pointer transition-all bg-[#FFEDD5] border-2 border-[#FB923C] dark:bg-[#1f0f08] dark:border-[#ea7a3a] hover:shadow-lg hover:scale-105",style:B,onClick:()=>r==null?void 0:r(q),children:[A.jsx(zl,{type:"target",position:bt.Left}),A.jsx("div",{className:"font-bold text-[#7C2D12] text-sm dark:text-[#fed7aa]",children:P.label}),P.title&&A.jsx("div",{className:"text-xs text-[#C2410C] mt-1 dark:text-[#fdba74]",children:P.title}),A.jsx(zl,{type:"source",position:bt.Right})]})}}),[T,a,i,r]);N.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const P=window.matchMedia("(prefers-color-scheme: dark)"),q=j=>w(j.matches);return P.addEventListener?P.addEventListener("change",q):P.addListener(q),()=>{P.removeEventListener?P.removeEventListener("change",q):P.removeListener(q)}},[]);const x=pd(),D=N.useCallback(P=>f(q=>Nse(P,q)),[f]),M=N.useCallback(P=>{const q=new Map,j=new Map;P.nodes.forEach($=>{q.set($.id,[]),j.set($.id,0)}),P.edges.forEach(({source:$,target:Z})=>{var te;(te=q.get($))==null||te.push(Z),j.set(Z,(j.get(Z)||0)+1)});const X=[];j.forEach(($,Z)=>{$===0&&X.push(Z)});const B=new Map;for(X.forEach($=>B.set($,0));X.length;){const $=X.shift(),Z=B.get($)??0;for(const te of q.get($)||[]){const U=Math.max(Z+1,B.get(te)??0);B.set(te,U),j.set(te,(j.get(te)||0)-1),(j.get(te)||0)===0&&X.push(te)}}const W={};P.nodes.forEach($=>{const Z=B.get($.id)??0;W[Z]||(W[Z]=[]),W[Z].push($.id)});const G=260,Y=110,K=P.nodes.map($=>{const Z=B.get($.id)??0,U=W[Z].indexOf($.id),ie=Z*G,se=U*Y;return{id:$.id,type:$.node_type,position:{x:ie,y:se},data:{label:$.label,title:$.title,event_type:$.event_type,type:$.node_type}}}),J=P.edges.map(($,Z)=>({id:`edge-${Z}`,source:$.source,target:$.target,type:"smoothstep",animated:!1,style:{stroke:"var(--wf-edge-stroke)",strokeWidth:2},markerEnd:{type:bg.ArrowClosed,color:"var(--wf-edge-stroke)"}}));return{nodes:K,edges:J}},[]),F=N.useCallback(async()=>{if(!t){l([]),f([]),y(null);return}E(!0),y(null);try{const{data:P,error:q}=await Vq({client:x,path:{name:t}});if(q)throw new Error(String(q));const j=P==null?void 0:P.graph;if(!j)throw new Error("No graph data received");const X=M(j);l(X.nodes),f(X.edges)}catch(P){console.error("Error fetching workflow visualization:",P),y(P instanceof Error?P.message:"Failed to load workflow visualization"),l([]),f([])}finally{E(!1)}},[t,x,M,l,f]);return N.useEffect(()=>{F()},[F]),N.useEffect(()=>{if(!n||n.length===0){C(-1),l(X=>X.map(B=>{const W={...B.data};return delete W.highlightColor,delete W.activeWorkers,delete W.workerCount,delete W.fadeTimestamp,{...B,data:W}}));return}const P=n.slice(v+1);if(P.length===0)return;C(n.length-1);const q=X=>{if(!X)return"";try{return((typeof X=="string"?X:String(X)).replace("<class","").replace(">","").replaceAll("'","").split(".").at(-1)||"").trim()}catch{return""}},j=X=>{switch(X){case"preparing":return"#3B82F6";case"in_progress":return"#F59E0B";case"running":return"#10B981";case"not_running":case"not_in_progress":case"exited":return null;default:return"#10B981"}};for(const X of P){const B=(X==null?void 0:X.type)??"",W=(X==null?void 0:X.data)??{};if(B==="StepStateChanged"||B==="workflows.events.StepStateChanged"){const G=String((W==null?void 0:W.name)||""),Y=String((W==null?void 0:W.step_state)||""),K=String((W==null?void 0:W.worker_id)||""),J=j(Y);l($=>$.map(Z=>{const te={...Z.data};if(Z.id===G){const U=new Set(te.activeWorkers||[]);if(Y==="preparing"||Y==="in_progress"||Y==="running"?U.add(K):(Y==="not_running"||Y==="not_in_progress"||Y==="exited")&&U.delete(K),te.activeWorkers=Array.from(U),te.workerCount=U.size,U.size>0)te.highlightColor=J||"#10B981",te.fadeTimestamp=Date.now();else if((Y==="exited"||Y==="not_running")&&te.highlightColor){const ie=Date.now();te.fadeTimestamp=ie,setTimeout(()=>{l(se=>se.map(ue=>{if(ue.id===G&&ue.data.fadeTimestamp===ie){const ae={...ue.data};return ae.highlightColor=null,{...ue,data:ae}}return ue}))},1e3)}return te.lastInputEvent=q(W==null?void 0:W.input_event_name),te.lastOutputEvent=q(W==null?void 0:W.output_event_name),te.status=Y,{...Z,data:te}}return Z}))}else if(B&&!B.includes("workflows.events.EventsQueueChanged")){const G=q(B.replace("__main__.","").replace("workflows.events.",""));l(Y=>Y.map(K=>{if(K.id===G&&K.type==="event"){const J={...K.data};return J.highlightColor="#10B981",J.fadeTimestamp=Date.now(),{...K,data:J}}return K})),setTimeout(()=>{l(Y=>Y.map(K=>{if(K.id===G&&K.type==="event"){const J={...K.data};return J.highlightColor=null,J.fadeTimestamp=null,{...K,data:J}}return K}))},1e3)}}},[n,v,l,o]),h?A.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:A.jsxs("div",{className:"text-center",children:[A.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-2"}),A.jsx("p",{className:"text-muted-foreground",children:"Loading workflow visualization..."})]})}):b?A.jsx("div",{className:`${e} flex items-center justify-center bg-destructive/10 border border-destructive/30 rounded-lg`,children:A.jsxs("div",{className:"text-center p-4",children:[A.jsx("p",{className:"text-destructive font-medium",children:"Error loading visualization"}),A.jsx("p",{className:"text-sm mt-1 text-destructive",children:b}),A.jsx("button",{onClick:F,className:"mt-3 px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm hover:opacity-90 transition-colors",children:"Retry"})]})}):t?s.length===0?A.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:A.jsx("p",{className:"text-muted-foreground",children:"No workflow data available"})}):A.jsx("div",{className:`${e} border border-border rounded-lg overflow-hidden`,children:A.jsx(P$e,{nodes:s,edges:d,onNodesChange:u,onEdgesChange:m,onConnect:D,nodeTypes:I,defaultEdgeOptions:{markerEnd:{type:bg.ArrowClosed,color:"var(--wf-edge-stroke)"}},fitView:!0,attributionPosition:"bottom-left",children:A.jsx(H$e,{variant:Hc.Dots,gap:12,size:1,color:T?"#374151":"#e5e7eb"})})}):A.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:A.jsx("p",{className:"text-muted-foreground",children:"Select a workflow to view its visualization"})})}function lB(t){if(t.type)return{type:t.type,nullable:t.nullable??!1};if(t.anyOf&&Array.isArray(t.anyOf)){const e=t.anyOf.map(a=>a.type).filter(a=>typeof a=="string"),n=e.includes("null"),r=e.filter(a=>a!=="null");if(r.length===1)return{type:r[0],nullable:n}}return{type:"unknown",nullable:!1}}function pYe(t){if(!t)return!1;const e=t.toLowerCase();return e.includes("object")||e.includes("array")||e.includes("map")||e.includes("dict")||/\w+\s*\[.*\]/.test(t)}function fYe(t){const e=(t||"").toLowerCase(),n=e.includes("array")||e.includes("list")||/\w+\s*\[.*\]/.test(t||""),r=e.includes("object")||e.includes("map")||e.includes("dict");return n?{hint:'Expected: JSON array (e.g., ["a", "b"])',placeholder:'["item1", "item2"]'}:r?{hint:'Expected: JSON object (e.g., {"key": "value"})',placeholder:'{"key": "value"}'}:{hint:"Expected: valid JSON (object or array)",placeholder:"Enter value as JSON"}}const mYe={};function nce({schema:t,values:e,onChange:n,onErrorsChange:r,className:a}){const i=(t==null?void 0:t.properties)??mYe,o=new Set((t==null?void 0:t.required)||[]),[s,l]=N.useState({}),[u,d]=N.useState({});N.useEffect(()=>{r==null||r(u)},[u,r]),N.useEffect(()=>{l(h=>{const E={...h};for(const[b,y]of Object.entries(i)){const{type:v}=lB(y);if(pYe(v)&&E[b]===void 0){const C=e[b];E[b]=C!==void 0?JSON.stringify(C,null,2):""}}return E})},[i,e]),N.useEffect(()=>{const h={};for(const[E,b]of Object.entries(i)){const{type:y,nullable:v}=lB(b);y==="boolean"&&e[E]===void 0&&o.has(E)&&(h[E]=v?null:!1)}Object.keys(h).length>0&&n({...e,...h})},[i,n]);const f=(h,E)=>{n({...e,[h]:E})},m=N.useMemo(()=>Object.entries(i),[i]);return m.length===0?null:A.jsx("div",{className:a,children:m.map(([h,E])=>{const b=`field-${h}`,y=E.title||h,{type:v,nullable:C}=lB(E),T=E.description||"";if(v==="string")return A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:b,label:y,required:o.has(h)}),A.jsx(RT,{id:b,value:e[h]||"",onChange:M=>f(h,M.target.value),placeholder:T||`Enter ${y.toLowerCase()}`,minRows:3}),T&&A.jsx("p",{className:"text-xs text-muted-foreground",children:T})]},h);if(v==="number"||v==="integer")return A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:b,label:y,required:o.has(h)}),A.jsx(OT,{id:b,type:"number",value:e[h]??"",onChange:M=>{const F=M.target.value;if(F===""){f(h,null);return}const P=v==="integer"?parseInt(F,10):parseFloat(F);f(h,Number.isNaN(P)?null:P)},placeholder:T||`Enter ${y.toLowerCase()}`,step:v==="integer"?"1":"any"}),T&&A.jsx("p",{className:"text-xs text-muted-foreground",children:T})]},h);if(v==="boolean"){const M=()=>e[h]===null?"null":e[h]===!0||e[h]==="true"?"true":e[h]===!1||e[h]==="false"?"false":C?"":"false";return A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:b,label:y,required:o.has(h)}),A.jsxs(Sx,{onValueChange:F=>{F==="null"?f(h,null):f(h,F==="true")},value:M(),children:[A.jsx(TT,{placeholder:"Select..."}),A.jsxs(CT,{children:[A.jsx(Gh,{value:"true",label:"True"}),A.jsx(Gh,{value:"false",label:"False"}),C&&A.jsx(Gh,{value:"null",label:"None"})]})]}),T&&A.jsx("p",{className:"text-xs text-muted-foreground",children:T})]},h)}const{hint:w,placeholder:I}=fYe(v),x=s[h]??(e[h]!==void 0?JSON.stringify(e[h],null,2):""),D=!!u[h];return A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:b,label:`${y} (JSON)`,required:o.has(h)}),A.jsx("div",{className:"font-mono",children:A.jsx(RT,{id:b,value:x,onChange:M=>{const F=M.target.value;if(l(P=>({...P,[h]:F})),F.trim()===""){d(q=>({...q,[h]:null}));const P={...e};delete P[h],n(P);return}try{const P=JSON.parse(F);d(q=>({...q,[h]:null})),f(h,P)}catch{d(P=>({...P,[h]:"Invalid JSON"}))}},placeholder:T||I,variant:D?"error":"default",minRows:3})}),D?A.jsx("p",{className:"text-xs text-destructive mt-1",children:u[h]}):A.jsx("p",{className:"text-xs text-muted-foreground",children:w}),T&&A.jsx("p",{className:"text-xs text-muted-foreground",children:T})]},h)})})}function hYe({handlerId:t,workflowName:e,disabled:n}){const[r,a]=N.useState(!1),[i,o]=N.useState([]),[s,l]=N.useState(null),[u,d]=N.useState({}),[f,m]=N.useState(!1),[h,E]=N.useState(null),[b,y]=N.useState(!1),[v,C]=N.useState(null),[T,w]=N.useState(!1),I=pd();N.useEffect(()=>{if(!r||!e)return;(async()=>{m(!0),C(null);try{const j=(await iye({client:I,path:{name:e}})).data;if(!j){o([]);return}if(!j.events){o([]);return}if(o(j.events),j.events&&j.events.length>0){const B=j.events[0].title;l(B||null)}}catch(q){console.error("Failed to fetch event schemas:",q),C(q instanceof Error?q.message:"Failed to fetch events"),o([])}finally{m(!1)}})()},[r,e,I]),N.useEffect(()=>{r||(l(null),d({}),E(null),C(null),w(!1))},[r]),N.useEffect(()=>{d({}),C(null),w(!1)},[s]);const x=N.useMemo(()=>s&&i.find(P=>P.title===s)||null,[s,i]),D=N.useMemo(()=>h?Object.values(h).some(P=>P!==null):!1,[h]),M=async()=>{if(!(!t||!s)){y(!0),C(null),w(!1);try{const P={type:s,data:u},{error:q}=await Yq({client:I,path:{handler_id:t},body:{event:JSON.stringify(P)}});if(q)throw new Error(typeof q=="string"?q:JSON.stringify(q));w(!0),setTimeout(()=>{a(!1)},1e3)}catch(P){console.error("Failed to send event:",P),C(P instanceof Error?P.message:"Failed to send event")}finally{y(!1)}}},F=!b&&!D&&s&&t&&!T;return A.jsxs(VTe,{open:r,onOpenChange:a,children:[A.jsx(jTe,{asChild:!0,children:A.jsx(Xn,{variant:"outline",size:"sm",disabled:n||!t||!e,title:t?e?"Send event to workflow":"No workflow selected":"No active handler",label:"Send Event",startIcon:A.jsx(LEe,{})})}),A.jsxs(ZH,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[A.jsx(JH,{title:"Send Event to Workflow",description:"Send a custom event to the running workflow handler."}),A.jsx("div",{className:"space-y-4 py-4",children:f?A.jsx("div",{className:"text-center text-muted-foreground",children:"Loading event types..."}):i.length===0?A.jsx("div",{className:"text-center text-muted-foreground",children:v||"No events available for this workflow"}):A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:"eventType",label:"Event Type"}),A.jsxs(Sx,{value:s||"",onValueChange:l,children:[A.jsx(TT,{placeholder:"Select event type..."}),A.jsx(CT,{children:i.map(P=>A.jsx(Gh,{value:P.title||"",label:P.title||"Unnamed Event"},P.title||"unknown"))})]})]}),x&&A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:"eventData",label:"Event Data"}),A.jsx(nce,{schema:{properties:x.properties,required:x.required},values:u,onChange:d,onErrorsChange:E,className:"space-y-3 border border-border rounded-lg p-4 bg-muted/30"})]}),v&&A.jsx("div",{className:"text-destructive text-sm p-3 bg-destructive/10 border border-destructive/20 rounded",children:v}),T&&A.jsx("div",{className:"text-green-600 text-sm p-3 bg-green-50 border border-green-200 rounded",children:"Event sent successfully!"})]})}),A.jsx(e$,{secondary:{label:"Cancel",onClick:()=>a(!1)},primary:{label:b?"Sending...":"Send Event",onClick:M,disabled:!F}})]})]})}function gYe({handlerId:t,selectedWorkflow:e}){var C;const{state:n,subscribeToEvents:r}=P3e(t),[a,i]=N.useState(!1),[o,s]=N.useState(!0),[l,u]=N.useState(null),[d,f]=N.useState(null),{items:m,push:h,clear:E}=F3e(100,(T,w)=>T.timestamp.getTime()-w.timestamp.getTime()),b=T=>typeof T=="string"?T:!T||typeof T!="object"?String(T??""):JSON.stringify(T,null,a?0:2),y=T=>{if(!T)return"";const w=new Date(T),I=w.toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),x=String(w.getMilliseconds()).padStart(3,"0");return`${I}.${x}`};N.useEffect(()=>{if(n.status==="running"){const{disconnect:T}=r({onData:w=>{h(w)},onSuccess(w){var I,x;u(((x=(I=w[w.length-1])==null?void 0:I.data)==null?void 0:x.result)??null)},onError(w){f(w.message)}},!0);return()=>{T()}}},[r,n.status,h]),N.useEffect(()=>{E(),u(null),f(null)},[t,E]);const v=N.useMemo(()=>o?m.filter(T=>!kTe(T)):m,[m,o]);return A.jsxs("div",{className:"h-full flex flex-col",children:[A.jsxs("div",{className:"p-4 border-b border-border",children:[A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h2",{className:"font-semibold text-sm",children:"Run Details"}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx(_T,{variant:n.status==="completed"?"default":"secondary",label:n.status}),A.jsx(hYe,{handlerId:t,workflowName:e??null,disabled:!n||n.status==="completed"||n.status==="failed"})]})]}),A.jsxs("div",{className:"flex items-center justify-between gap-2 mt-2",children:[A.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:n.handler_id}),A.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["Last updated: ",(C=n.updated_at)==null?void 0:C.getTime()]})]})]}),A.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[A.jsx("div",{className:"flex-1 p-4 overflow-auto border-r border-border",children:A.jsx(dYe,{workflowName:e||null,events:m.map(T=>({type:T.type,data:T.data})),className:"w-full h-full min-h-[400px]",isComplete:n.status==="completed"||n.status==="failed"})}),A.jsxs("div",{className:"w-[480px] flex flex-col overflow-hidden",children:[A.jsx("div",{className:"p-4 pb-2 border-b border-border",children:A.jsxs("div",{className:"flex items-center justify-between mb-3",children:[A.jsxs("h4",{className:"font-medium text-sm",children:["Event Stream (",v.length,")"]}),A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx(Bs,{htmlFor:"hide-internal",label:"Hide internal"}),A.jsx(TJ,{id:"hide-internal",checked:o,onCheckedChange:T=>s(!!T)})]}),A.jsx(Xn,{variant:"ghost",size:"sm",onClick:()=>i(!a),label:a?"Formatted":"Compact"})]})]})}),A.jsx("div",{className:"flex-1 overflow-auto",children:n.handler_id?m.length===0?A.jsx("div",{className:"flex items-center justify-center h-full",children:A.jsx("p",{className:"text-muted-foreground text-sm",children:"No events yet..."})}):A.jsxs(wz,{children:[A.jsx(xz,{sticky:!0,children:A.jsxs(Ox,{children:[A.jsx(Ix,{label:"#"}),A.jsx(Ix,{label:"Event"})]})}),A.jsx(Nz,{children:v.map((T,w)=>{const I=T;return A.jsxs(Ox,{"data-event-index":w,children:[A.jsx(Iz,{label:w+1}),A.jsx(Dz,{children:A.jsxs("div",{className:"space-y-2",children:[A.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[A.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:A.jsx("code",{className:"text-sm font-mono truncate",children:I.type})}),I.timestamp!==void 0?A.jsx("span",{className:"text-[10px] text-muted-foreground font-mono whitespace-nowrap",children:y(I.timestamp.getTime())}):null]}),A.jsx(poe,{language:typeof I.data=="string"?"text":"json",value:b(I.data),wrapLongLines:a,className:"rounded border max-h-64 overflow-auto"})]})})]},`${I.type}-${w}`)})})]}):A.jsx("div",{className:"flex items-center justify-center h-full",children:A.jsx("p",{className:"text-muted-foreground text-sm",children:"Start a run to see events"})})}),(l||d)&&A.jsxs("div",{className:"p-4 border-t border-border",children:[A.jsx("h4",{className:"font-medium text-sm mb-2",children:"Final Result"}),d?A.jsxs("div",{className:"text-destructive text-sm p-3 bg-destructive/10 border border-destructive/20 rounded",children:["Failed to load final result: ",d]}):A.jsx(poe,{language:typeof l=="string"?"text":"json",value:typeof l=="string"?l:JSON.stringify(l,null,2),className:"rounded border overflow-hidden"})]})]})]})]})}function _Ye({activeHandlerId:t,onHandlerSelect:e}){const{state:n,sync:r}=FJ(),a=n.handlers,[i,o]=N.useState(!1);N.useEffect(()=>{o(!0),r().finally(()=>o(!1))},[r]);const s=u=>`${u.workflow_name||"Unknown"}`,l=Object.values(a);return A.jsxs("div",{className:"h-full flex flex-col text-sm",children:[A.jsx("div",{className:"px-3 py-2 border-b border-border",children:A.jsx("div",{className:"flex items-center justify-between",children:A.jsx("h2",{className:"font-semibold text-xs tracking-tight",children:"Recent Runs"})})}),A.jsxs("div",{className:"flex-1 overflow-y-auto",children:[i&&A.jsxs("div",{className:"p-2 space-y-2",children:[A.jsx(uf,{className:"h-8 w-full"}),A.jsx(uf,{className:"h-8 w-full"}),A.jsx(uf,{className:"h-8 w-full"})]}),!i&&A.jsx("div",{className:"p-2 divide-y divide-border",children:l.length===0?A.jsx("div",{className:"text-muted-foreground text-xs p-3 text-center",children:"No runs yet. Start a workflow to see runs here."}):l.map(u=>A.jsx("button",{onClick:()=>e(u.handler_id),className:`w-full text-left px-2 py-1.5 transition-colors cursor-pointer border border-collapse ${t===u.handler_id?"bg-accent ":"hover:bg-accent"}`,children:A.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-2",children:[A.jsx("span",{className:"truncate text-xs",children:s(u)}),A.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:u.handler_id.slice(-8)})]})},u.handler_id))})]})]})}function bYe({selectedWorkflow:t,onRunStart:e,onCollapse:n}){const[r,a]=N.useState(null),[i,o]=N.useState({}),[s,l]=N.useState(!1),[u,d]=N.useState(null),[f,m]=N.useState(""),[h,E]=N.useState(null),[b,y]=N.useState({}),[v,C]=N.useState(!1),T=pd(),{createHandler:w}=L3e(t),{setHandler:I}=FJ();N.useEffect(()=>{t?(async()=>{if(t)try{l(!0),d(null);const{data:F,error:P}=await eye({client:T,path:{name:t}});if(F)a((F==null?void 0:F.start)??null);else throw new Error(P?String(P):"Failed to fetch schema");o({}),m(JSON.stringify({},null,2)),E(null),y({})}catch(F){d(F instanceof Error?F.message:"Failed to fetch schema"),a(null)}finally{l(!1)}})():(a(null),o({}),m(""),E(null),y({}))},[t,T]);const x=async()=>{if(t)try{C(!0);const M=await w(i);I(M),e(M.handler_id),n&&n()}catch(M){console.error("Failed to run workflow:",M)}finally{C(!1)}},D=!!(r!=null&&r.properties&&Object.keys(r.properties).length>0);return t?A.jsxs("div",{className:"h-full flex flex-col",children:[A.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[A.jsxs("h2",{className:"font-semibold text-sm",children:["Configure: ",t]}),n&&A.jsx(Xn,{variant:"ghost",size:"icon-sm",onClick:n,title:"Hide configuration panel (Ctrl+B)",startIcon:A.jsx(WG,{})})]}),A.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s&&A.jsxs("div",{className:"space-y-4",children:[A.jsx(uf,{className:"h-4 w-32"}),A.jsx(uf,{className:"h-20 w-full"}),A.jsx(uf,{className:"h-4 w-32"}),A.jsx(uf,{className:"h-20 w-full"})]}),u&&A.jsxs("div",{className:"text-destructive text-sm p-3 bg-destructive/10 border border-destructive/20 rounded",children:["Error loading schema: ",u]}),!s&&!u&&A.jsx(A.Fragment,{children:A.jsx("div",{className:"space-y-4",children:D?A.jsx(nce,{schema:r,values:i,onChange:o,onErrorsChange:y}):A.jsxs("div",{className:"space-y-2",children:[A.jsx(Bs,{htmlFor:"raw-input",label:"Input (JSON)"}),A.jsx("div",{className:"font-mono",children:A.jsx(RT,{id:"raw-input",value:f,onChange:M=>{m(M.target.value);try{const F=JSON.parse(M.target.value);o(F),E(null)}catch{E("Invalid JSON")}},placeholder:'{"key": "value"}',variant:h?"error":"default",minRows:8})}),h&&A.jsx("p",{className:"text-xs text-destructive mt-1",children:h})]})})})]}),!s&&!u&&A.jsxs("div",{className:"p-4 border-t border-border",children:[Object.values(b).some(M=>M)&&A.jsx("p",{className:"text-xs text-destructive mb-2",children:"Fix invalid JSON fields before running."}),A.jsx(Xn,{onClick:x,disabled:v||Object.values(b).some(M=>M),fullWidth:!0,label:v?"Starting...":"Run Workflow"})]})]}):A.jsxs("div",{className:"h-full flex flex-col",children:[A.jsxs("div",{className:"p-4 border-b border-border flex items-center justify-between",children:[A.jsx("h2",{className:"font-semibold text-sm",children:"Workflow Configuration"}),n&&A.jsx(Xn,{variant:"ghost",size:"icon-sm",onClick:n,title:"Hide configuration panel (Ctrl+B)",startIcon:A.jsx(WG,{})})]}),A.jsx("div",{className:"flex-1 flex items-center justify-center",children:A.jsx("p",{className:"text-muted-foreground text-center",children:"Select a workflow to configure and run"})})]})}function EYe(t,e,n=!0){N.useEffect(()=>{const r=a=>{(n&&a.ctrlKey&&a.key.toLowerCase()===t.toLowerCase()||!n&&a.key.toLowerCase()===t.toLowerCase())&&(a.preventDefault(),e())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,e,n])}function SYe(){if(typeof window>"u")return eA();const e=new URLSearchParams(window.location.search).get("api");return e?e.endsWith("/")?e.slice(0,-1):e:eA()}function vYe(){const[t,e]=N.useState(SYe),[n,r]=N.useState(t),[a,i]=N.useState(null),[o,s]=N.useState(null),{state:l,sync:u}=M3e(),[d,f]=N.useState(37.5),[m,h]=N.useState(!1),[E,b]=N.useState(!1),[y,v]=N.useState(!1),[C,T]=N.useState(null),[w,I]=N.useState(null),x=l.workflows,D=pd(),M=N.useCallback(async()=>{try{I(null);const{data:W,error:G}=await tye({client:D});if(G)throw new Error(String(G));W&&W.status?T(!0):(T(!1),I("Workflow server is unreachable"))}catch{T(!1),I("Workflow server is unreachable")}},[D]);N.useEffect(()=>{D.setConfig({baseUrl:t}),M(),u()},[t,D,M,u]);const F=()=>{const W=n.endsWith("/")?n.slice(0,-1):n;e(W)},P=()=>{const W=eA();e(W),r(W)},q=W=>{s(W)},j=W=>{W.preventDefault(),h(!0)},X=N.useCallback(W=>{const G=document.querySelector(".main-content-area");if(!G)return;const Y=G.getBoundingClientRect(),K=(W.clientX-Y.left)/Y.width*100,J=Math.max(20,Math.min(80,K));f(J)},[]),B=N.useCallback(()=>{h(!1)},[]);return N.useEffect(()=>{if(m)return document.addEventListener("mousemove",X),document.addEventListener("mouseup",B),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",X),document.removeEventListener("mouseup",B),document.body.style.cursor="",document.body.style.userSelect=""}},[m,X,B]),EYe("b",N.useCallback(()=>{v(W=>!W)},[]),!0),A.jsxs("div",{className:`h-screen flex flex-col bg-background ${m?"resize-active":""}`,children:[A.jsxs("div",{className:"flex items-center justify-between h-12 px-4 bg-card border-b border-border",children:[A.jsxs("div",{className:"flex items-center gap-4",children:[A.jsx(Xn,{variant:"ghost",size:"icon-sm",onClick:()=>b(!E),title:E?"Show sidebar":"Hide sidebar",startIcon:E?A.jsx(OEe,{}):A.jsx(NEe,{})}),A.jsx("h1",{className:"text-md font-semibold",children:"Workflow Debugger"})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:"flex items-center",children:A.jsx(Bs,{htmlFor:"workflow",label:"Workflow:",variant:"standalone"})}),A.jsx("div",{className:"w-48",children:A.jsxs(Sx,{value:a||"",onValueChange:i,children:[A.jsx(TT,{id:"workflow",placeholder:"Select workflow..."}),A.jsx(CT,{children:Object.keys(x).map(W=>A.jsx(Gh,{value:W,label:W},W))})]})})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[C!==null&&A.jsx("span",{className:`${C?"bg-green-500":"bg-red-500"} h-2 w-2 rounded-full`}),C===!1&&A.jsx("span",{className:"text-destructive text-xs",children:w||"Workflow server is unreachable"}),A.jsxs(O0e,{children:[A.jsx(I0e,{asChild:!0,children:A.jsx(Xn,{variant:"ghost",size:"icon-sm",startIcon:A.jsx(PEe,{})})}),A.jsx(rG,{className:"w-80",children:A.jsx("div",{className:"space-y-4",children:A.jsxs("div",{className:"space-y-2",children:[A.jsx("h4",{className:"font-medium text-sm",children:"API Configuration"}),A.jsx(OT,{value:n,onChange:W=>r(W.target.value),placeholder:"http://localhost:8000"}),A.jsxs("div",{className:"flex gap-2",children:[A.jsx(Xn,{onClick:F,variant:"outline",size:"sm",disabled:n===t,label:"Save"}),A.jsx(Xn,{onClick:P,variant:"outline",size:"sm",label:"Reset"})]}),A.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",t]})]})})})]})]})]}),A.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!E&&A.jsx("div",{className:"w-48 border-r border-border bg-card overflow-hidden transition-all duration-200",children:A.jsx(_Ye,{activeHandlerId:o,onHandlerSelect:s})}),A.jsxs("div",{className:"flex-1 flex overflow-hidden main-content-area",children:[y?A.jsx("div",{className:"w-10 border-r border-border bg-muted/30 flex flex-col items-center justify-center hover:bg-muted/50 transition-colors",children:A.jsx(Xn,{variant:"ghost",size:"icon-sm",onClick:()=>v(!1),title:"Show configuration panel (Ctrl+B)",startIcon:A.jsx(IEe,{})})}):A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"border-r border-border overflow-auto",style:{width:`${d}%`},children:a&&A.jsx(bYe,{selectedWorkflow:a,onRunStart:q,activeHandlerId:o,onCollapse:()=>v(!0)})}),A.jsx("div",{className:`w-2 hover:bg-gray-500/20 hover:shadow-lg cursor-col-resize flex-shrink-0 transition-all duration-200 relative group border-l border-r border-border ${m?"shadow-xl":""}`,onMouseDown:j,title:"Drag to resize panels"})]}),A.jsx("div",{className:"overflow-auto",style:{width:y?"calc(100% - 40px)":`${100-d}%`},children:o&&A.jsx(gYe,{handlerId:o,selectedWorkflow:a})})]})]})]})}class yYe extends Ie.Component{constructor(n){super(n);Ue(this,"resetError",()=>{this.setState({hasError:!1,error:void 0})});this.state={hasError:!1}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){console.error("ErrorBoundary caught an error:",n,r)}render(){if(this.state.hasError&&this.state.error){if(this.props.fallback){const n=this.props.fallback;return A.jsx(n,{error:this.state.error,resetError:this.resetError})}return A.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:A.jsxs("div",{className:"max-w-md p-6 bg-card border border-border rounded-lg shadow-sm",children:[A.jsx("h2",{className:"text-lg font-semibold text-destructive mb-2",children:"Something went wrong"}),A.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"The workflow debugger encountered an error. This might happen if the workflow server is unreachable."}),A.jsxs("details",{className:"mb-4",children:[A.jsx("summary",{className:"text-sm font-medium cursor-pointer hover:text-foreground",children:"Error Details"}),A.jsx("pre",{className:"mt-2 text-xs bg-muted p-3 rounded border overflow-auto",children:this.state.error.message})]}),A.jsxs("div",{className:"flex gap-2",children:[A.jsx("button",{onClick:this.resetError,className:"px-3 py-2 text-sm bg-primary text-primary-foreground rounded hover:bg-primary/90 transition-colors",children:"Try Again"}),A.jsx("button",{onClick:()=>window.location.reload(),className:"px-3 py-2 text-sm bg-secondary text-secondary-foreground rounded hover:bg-secondary/90 transition-colors",children:"Reload Page"})]})]})})}return this.props.children}}function TYe(){const t=eA(),e=$q({baseUrl:t});return A.jsx(yYe,{children:A.jsx(oye,{clients:{workflowsClient:e},children:A.jsx(vYe,{})})})}function rce(){const t=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",t)}rce(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",rce),Jhe.createRoot(document.getElementById("root")).render(A.jsx(N.StrictMode,{children:A.jsx(TYe,{})}));const Si=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),cB=[.001,0,0,.001,0,0],uB=1.35,Eo={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ql={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},ME="pdfjs_internal_editor_",It={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},an={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},ace={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ua={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},LE={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Xr={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Rg={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},PE={ERRORS:0,WARNINGS:1,INFOS:5},wg={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},$A={moveTo:0,lineTo:1,curveTo:2,closePath:3},ice={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let YA=PE.WARNINGS;function CYe(t){Number.isInteger(t)&&(YA=t)}function AYe(){return YA}function VA(t){YA>=PE.INFOS&&console.info(`Info: ${t}`)}function Dt(t){YA>=PE.WARNINGS&&console.warn(`Warning: ${t}`)}function er(t){throw new Error(t)}function ln(t,e){t||er(e)}function RYe(t){switch(t==null?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function dB(t,e=null,n=null){if(!t)return null;if(n&&typeof t=="string"){if(n.addDefaultProtocol&&t.startsWith("www.")){const a=t.match(/\./g);(a==null?void 0:a.length)>=2&&(t=`http://${t}`)}if(n.tryConvertEncoding)try{t=IYe(t)}catch{}}const r=e?URL.parse(t,e):URL.parse(t);return RYe(r)?r:null}function pB(t,e,n=!1){const r=URL.parse(t);return r?(r.hash=e,r.href):n&&dB(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function Ht(t,e,n,r=!1){return Object.defineProperty(t,e,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}const Mf=(function(){function e(n,r){this.message=n,this.name=r}return e.prototype=new Error,e.constructor=e,e})();class oce extends Mf{constructor(e,n){super(e,"PasswordException"),this.code=n}}class fB extends Mf{constructor(e,n){super(e,"UnknownErrorException"),this.details=n}}class jA extends Mf{constructor(e){super(e,"InvalidPDFException")}}class FE extends Mf{constructor(e,n,r){super(e,"ResponseException"),this.status=n,this.missing=r}}class wYe extends Mf{constructor(e){super(e,"FormatError")}}class $c extends Mf{constructor(e){super(e,"AbortException")}}function sce(t){(typeof t!="object"||(t==null?void 0:t.length)===void 0)&&er("Invalid argument for bytesToString");const e=t.length,n=8192;if(e<n)return String.fromCharCode.apply(null,t);const r=[];for(let a=0;a<e;a+=n){const i=Math.min(a+n,e),o=t.subarray(a,i);r.push(String.fromCharCode.apply(null,o))}return r.join("")}function BE(t){typeof t!="string"&&er("Invalid argument for stringToBytes");const e=t.length,n=new Uint8Array(e);for(let r=0;r<e;++r)n[r]=t.charCodeAt(r)&255;return n}function xYe(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255)}function NYe(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}function OYe(){try{return new Function(""),!0}catch{return!1}}class Ra{static get isLittleEndian(){return Ht(this,"isLittleEndian",NYe())}static get isEvalSupported(){return Ht(this,"isEvalSupported",OYe())}static get isOffscreenCanvasSupported(){return Ht(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Ht(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:e,userAgent:n}=navigator;return Ht(this,"platform",{isAndroid:n.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:n.includes("Firefox")})}static get isCSSRoundSupported(){var e,n;return Ht(this,"isCSSRoundSupported",(n=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:n.call(e,"width: round(1.5px, 1px)"))}}const mB=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class nt{static makeHexColor(e,n,r){return`#${mB[e]}${mB[n]}${mB[r]}`}static domMatrixToTransform(e){return[e.a,e.b,e.c,e.d,e.e,e.f]}static scaleMinMax(e,n){let r;e[0]?(e[0]<0&&(r=n[0],n[0]=n[2],n[2]=r),n[0]*=e[0],n[2]*=e[0],e[3]<0&&(r=n[1],n[1]=n[3],n[3]=r),n[1]*=e[3],n[3]*=e[3]):(r=n[0],n[0]=n[1],n[1]=r,r=n[2],n[2]=n[3],n[3]=r,e[1]<0&&(r=n[1],n[1]=n[3],n[3]=r),n[1]*=e[1],n[3]*=e[1],e[2]<0&&(r=n[0],n[0]=n[2],n[2]=r),n[0]*=e[2],n[2]*=e[2]),n[0]+=e[4],n[1]+=e[5],n[2]+=e[4],n[3]+=e[5]}static transform(e,n){return[e[0]*n[0]+e[2]*n[1],e[1]*n[0]+e[3]*n[1],e[0]*n[2]+e[2]*n[3],e[1]*n[2]+e[3]*n[3],e[0]*n[4]+e[2]*n[5]+e[4],e[1]*n[4]+e[3]*n[5]+e[5]]}static multiplyByDOMMatrix(e,n){return[e[0]*n.a+e[2]*n.b,e[1]*n.a+e[3]*n.b,e[0]*n.c+e[2]*n.d,e[1]*n.c+e[3]*n.d,e[0]*n.e+e[2]*n.f+e[4],e[1]*n.e+e[3]*n.f+e[5]]}static applyTransform(e,n,r=0){const a=e[r],i=e[r+1];e[r]=a*n[0]+i*n[2]+n[4],e[r+1]=a*n[1]+i*n[3]+n[5]}static applyTransformToBezier(e,n,r=0){const a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],u=n[5];for(let d=0;d<6;d+=2){const f=e[r+d],m=e[r+d+1];e[r+d]=f*a+m*o+l,e[r+d+1]=f*i+m*s+u}}static applyInverseTransform(e,n){const r=e[0],a=e[1],i=n[0]*n[3]-n[1]*n[2];e[0]=(r*n[3]-a*n[2]+n[2]*n[5]-n[4]*n[3])/i,e[1]=(-r*n[1]+a*n[0]+n[4]*n[1]-n[5]*n[0])/i}static axialAlignedBoundingBox(e,n,r){const a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],u=n[5],d=e[0],f=e[1],m=e[2],h=e[3];let E=a*d+l,b=E,y=a*m+l,v=y,C=s*f+u,T=C,w=s*h+u,I=w;if(i!==0||o!==0){const x=i*d,D=i*m,M=o*f,F=o*h;E+=M,v+=M,y+=F,b+=F,C+=x,I+=x,w+=D,T+=D}r[0]=Math.min(r[0],E,y,b,v),r[1]=Math.min(r[1],C,w,T,I),r[2]=Math.max(r[2],E,y,b,v),r[3]=Math.max(r[3],C,w,T,I)}static inverseTransform(e){const n=e[0]*e[3]-e[1]*e[2];return[e[3]/n,-e[1]/n,-e[2]/n,e[0]/n,(e[2]*e[5]-e[4]*e[3])/n,(e[4]*e[1]-e[5]*e[0])/n]}static singularValueDecompose2dScale(e,n){const r=e[0],a=e[1],i=e[2],o=e[3],s=r**2+a**2,l=r*i+a*o,u=i**2+o**2,d=(s+u)/2,f=Math.sqrt(d**2-(s*u-l**2));n[0]=Math.sqrt(d+f||1),n[1]=Math.sqrt(d-f||1)}static normalizeRect(e){const n=e.slice(0);return e[0]>e[2]&&(n[0]=e[2],n[2]=e[0]),e[1]>e[3]&&(n[1]=e[3],n[3]=e[1]),n}static intersect(e,n){const r=Math.max(Math.min(e[0],e[2]),Math.min(n[0],n[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(n[0],n[2]));if(r>a)return null;const i=Math.max(Math.min(e[1],e[3]),Math.min(n[1],n[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(n[1],n[3]));return i>o?null:[r,i,a,o]}static pointBoundingBox(e,n,r){r[0]=Math.min(r[0],e),r[1]=Math.min(r[1],n),r[2]=Math.max(r[2],e),r[3]=Math.max(r[3],n)}static rectBoundingBox(e,n,r,a,i){i[0]=Math.min(i[0],e,r),i[1]=Math.min(i[1],n,a),i[2]=Math.max(i[2],e,r),i[3]=Math.max(i[3],n,a)}static bezierBoundingBox(e,n,r,a,i,o,s,l,u){u[0]=Math.min(u[0],e,s),u[1]=Math.min(u[1],n,l),u[2]=Math.max(u[2],e,s),u[3]=Math.max(u[3],n,l),Q(this,jc,c7).call(this,e,r,i,s,n,a,o,l,3*(-e+3*(r-i)+s),6*(e-2*r+i),3*(r-e),u),Q(this,jc,c7).call(this,e,r,i,s,n,a,o,l,3*(-n+3*(a-o)+l),6*(n-2*a+o),3*(a-n),u)}}jc=new WeakSet,K1=function(e,n,r,a,i,o,s,l,u,d){if(u<=0||u>=1)return;const f=1-u,m=u*u,h=m*u,E=f*(f*(f*e+3*u*n)+3*m*r)+h*a,b=f*(f*(f*i+3*u*o)+3*m*s)+h*l;d[0]=Math.min(d[0],E),d[1]=Math.min(d[1],b),d[2]=Math.max(d[2],E),d[3]=Math.max(d[3],b)},c7=function(e,n,r,a,i,o,s,l,u,d,f,m){if(Math.abs(u)<1e-12){Math.abs(d)>=1e-12&&Q(this,jc,K1).call(this,e,n,r,a,i,o,s,l,-f/d,m);return}const h=d**2-4*f*u;if(h<0)return;const E=Math.sqrt(h),b=2*u;Q(this,jc,K1).call(this,e,n,r,a,i,o,s,l,(-d+E)/b,m),Q(this,jc,K1).call(this,e,n,r,a,i,o,s,l,(-d-E)/b,m)},V(nt,jc);function IYe(t){return decodeURIComponent(escape(t))}let hB=null,lce=null;function cce(t){return hB||(hB=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,lce=new Map([["ſt","ſt"]])),t.replaceAll(hB,(e,n,r)=>n?n.normalize("NFKC"):lce.get(r))}function gB(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),sce(t)}const _B="pdfjs_internal_id_";function DYe(t,e,n){if(!Array.isArray(n)||n.length<2)return!1;const[r,a,...i]=n;if(!t(r)&&!Number.isInteger(r)||!e(a))return!1;const o=i.length;let s=!0;switch(a.name){case"XYZ":if(o<2||o>3)return!1;break;case"Fit":case"FitB":return o===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1)return!1;break;case"FitR":if(o!==4)return!1;s=!1;break;default:return!1}for(const l of i)if(!(typeof l=="number"||s&&l===null))return!1;return!0}function ri(t,e,n){return Math.min(Math.max(t,e),n)}function uce(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(sce(t))}function kYe(t){return Uint8Array.fromBase64?Uint8Array.fromBase64(t):BE(atob(t))}typeof Promise.try!="function"&&(Promise.try=function(t,...e){return new Promise(n=>{n(t(...e))})}),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(t){return t.reduce((e,n)=>e+n,0)});class UE{static textContent(e){const n=[],r={items:n,styles:Object.create(null)};function a(i){var l;if(!i)return;let o=null;const s=i.name;if(s==="#text")o=i.value;else if(UE.shouldBuildText(s))(l=i==null?void 0:i.attributes)!=null&&l.textContent?o=i.attributes.textContent:i.value&&(o=i.value);else return;if(o!==null&&n.push({str:o}),!!i.children)for(const u of i.children)a(u)}return a(e),r}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}class bB{static setupStorage(e,n,r,a,i){const o=a.getValue(n,{value:null});switch(r.name){case"textarea":if(o.value!==null&&(e.textContent=o.value),i==="print")break;e.addEventListener("input",s=>{a.setValue(n,{value:s.target.value})});break;case"input":if(r.attributes.type==="radio"||r.attributes.type==="checkbox"){if(o.value===r.attributes.xfaOn?e.setAttribute("checked",!0):o.value===r.attributes.xfaOff&&e.removeAttribute("checked"),i==="print")break;e.addEventListener("change",s=>{a.setValue(n,{value:s.target.checked?s.target.getAttribute("xfaOn"):s.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&e.setAttribute("value",o.value),i==="print")break;e.addEventListener("input",s=>{a.setValue(n,{value:s.target.value})})}break;case"select":if(o.value!==null){e.setAttribute("value",o.value);for(const s of r.children)s.attributes.value===o.value?s.attributes.selected=!0:s.attributes.hasOwnProperty("selected")&&delete s.attributes.selected}e.addEventListener("input",s=>{const l=s.target.options,u=l.selectedIndex===-1?"":l[l.selectedIndex].value;a.setValue(n,{value:u})});break}}static setAttributes({html:e,element:n,storage:r=null,intent:a,linkService:i}){const{attributes:o}=n,s=e instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${a}`);for(const[l,u]of Object.entries(o))if(u!=null)switch(l){case"class":u.length&&e.setAttribute(l,u.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",u);break;case"style":Object.assign(e.style,u);break;case"textContent":e.textContent=u;break;default:(!s||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,u)}s&&i.addLinkAttributes(e,o.href,o.newWindow),r&&o.dataId&&this.setupStorage(e,o.dataId,n,r)}static render(e){var f,m;const n=e.annotationStorage,r=e.linkService,a=e.xfaHtml,i=e.intent||"display",o=document.createElement(a.name);a.attributes&&this.setAttributes({html:o,element:a,intent:i,linkService:r});const s=i!=="richText",l=e.div;if(l.append(o),e.viewport){const h=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=h}s&&l.setAttribute("class","xfaLayer xfaFont");const u=[];if(a.children.length===0){if(a.value){const h=document.createTextNode(a.value);o.append(h),s&&UE.shouldBuildText(a.name)&&u.push(h)}return{textDivs:u}}const d=[[a,-1,o]];for(;d.length>0;){const[h,E,b]=d.at(-1);if(E+1===h.children.length){d.pop();continue}const y=h.children[++d.at(-1)[1]];if(y===null)continue;const{name:v}=y;if(v==="#text"){const T=document.createTextNode(y.value);u.push(T),b.append(T);continue}const C=(f=y==null?void 0:y.attributes)!=null&&f.xmlns?document.createElementNS(y.attributes.xmlns,v):document.createElement(v);if(b.append(C),y.attributes&&this.setAttributes({html:C,element:y,storage:n,intent:i,linkService:r}),((m=y.children)==null?void 0:m.length)>0)d.push([y,-1,C]);else if(y.value){const T=document.createTextNode(y.value);s&&UE.shouldBuildText(v)&&u.push(T),C.append(T)}}for(const h of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))h.setAttribute("readOnly",!0);return{textDivs:u}}static update(e){const n=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=n,e.div.hidden=!1}}const Yc="http://www.w3.org/2000/svg",Gf=class Gf{};Ue(Gf,"CSS",96),Ue(Gf,"PDF",72),Ue(Gf,"PDF_TO_CSS_UNITS",Gf.CSS/Gf.PDF);let Vc=Gf;async function xg(t,e="text"){if(qE(t,document.baseURI)){const n=await fetch(t);if(!n.ok)throw new Error(n.statusText);switch(e){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise((n,r)=>{const a=new XMLHttpRequest;a.open("GET",t,!0),a.responseType=e,a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(a.status===200||a.status===0){switch(e){case"arraybuffer":case"blob":case"json":n(a.response);return}n(a.responseText);return}r(new Error(a.statusText))}},a.send(null)})}class GE{constructor({viewBox:e,userUnit:n,scale:r,rotation:a,offsetX:i=0,offsetY:o=0,dontFlip:s=!1}){this.viewBox=e,this.userUnit=n,this.scale=r,this.rotation=a,this.offsetX=i,this.offsetY=o,r*=n;const l=(e[2]+e[0])/2,u=(e[3]+e[1])/2;let d,f,m,h;switch(a%=360,a<0&&(a+=360),a){case 180:d=-1,f=0,m=0,h=1;break;case 90:d=0,f=1,m=1,h=0;break;case 270:d=0,f=-1,m=-1,h=0;break;case 0:d=1,f=0,m=0,h=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}s&&(m=-m,h=-h);let E,b,y,v;d===0?(E=Math.abs(u-e[1])*r+i,b=Math.abs(l-e[0])*r+o,y=(e[3]-e[1])*r,v=(e[2]-e[0])*r):(E=Math.abs(l-e[0])*r+i,b=Math.abs(u-e[1])*r+o,y=(e[2]-e[0])*r,v=(e[3]-e[1])*r),this.transform=[d*r,f*r,m*r,h*r,E-d*r*l-m*r*u,b-f*r*l-h*r*u],this.width=y,this.height=v}get rawDims(){const e=this.viewBox;return Ht(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:a=this.offsetY,dontFlip:i=!1}={}){return new GE({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:n,offsetX:r,offsetY:a,dontFlip:i})}convertToViewportPoint(e,n){const r=[e,n];return nt.applyTransform(r,this.transform),r}convertToViewportRectangle(e){const n=[e[0],e[1]];nt.applyTransform(n,this.transform);const r=[e[2],e[3]];return nt.applyTransform(r,this.transform),[n[0],n[1],r[0],r[1]]}convertToPdfPoint(e,n){const r=[e,n];return nt.applyInverseTransform(r,this.transform),r}}class WA extends Mf{constructor(e,n=0){super(e,"RenderingCancelledException"),this.extraDelay=n}}function zE(t){const e=t.length;let n=0;for(;n<e&&t[n].trim()==="";)n++;return t.substring(n,n+5).toLowerCase()==="data:"}function KA(t){return typeof t=="string"&&/\.pdf$/i.test(t)}function dce(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function pce(t,e="document.pdf"){if(typeof t!="string")return e;if(zE(t))return Dt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const r=(s=>{try{return new URL(s)}catch{try{return new URL(decodeURIComponent(s))}catch{try{return new URL(s,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(s),"https://foo.bar")}catch{return null}}}}})(t);if(!r)return e;const a=s=>{try{let l=decodeURIComponent(s);return l.includes("/")?(l=l.split("/").at(-1),l.test(/^\.pdf$/i)?l:s):l}catch{return s}},i=/\.pdf$/i,o=r.pathname.split("/").at(-1);if(i.test(o))return a(o);if(r.searchParams.size>0){const s=Array.from(r.searchParams.values()).reverse();for(const u of s)if(i.test(u))return a(u);const l=Array.from(r.searchParams.keys()).reverse();for(const u of l)if(i.test(u))return a(u)}if(r.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(r.hash);if(l)return a(l[0])}return e}class fce{constructor(){Ue(this,"started",Object.create(null));Ue(this,"times",[])}time(e){e in this.started&&Dt(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Dt(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let n=0;for(const{name:r}of this.times)n=Math.max(r.length,n);for(const{name:r,start:a,end:i}of this.times)e.push(`${r.padEnd(n)} ${i-a}ms
|
|
656
656
|
`);return e.join("")}}function qE(t,e){const n=e?URL.parse(t,e):URL.parse(t);return(n==null?void 0:n.protocol)==="http:"||(n==null?void 0:n.protocol)==="https:"}function So(t){t.preventDefault()}function Or(t){t.preventDefault(),t.stopPropagation()}function MYe(t){console.log("Deprecated API usage: "+t)}class HE{static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!="string")return null;_(this,aS)||L(this,aS,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const n=_(this,aS).exec(e);if(!n)return null;const r=parseInt(n[1],10);let a=parseInt(n[2],10);a=a>=1&&a<=12?a-1:0;let i=parseInt(n[3],10);i=i>=1&&i<=31?i:1;let o=parseInt(n[4],10);o=o>=0&&o<=23?o:0;let s=parseInt(n[5],10);s=s>=0&&s<=59?s:0;let l=parseInt(n[6],10);l=l>=0&&l<=59?l:0;const u=n[7]||"Z";let d=parseInt(n[8],10);d=d>=0&&d<=23?d:0;let f=parseInt(n[9],10)||0;return f=f>=0&&f<=59?f:0,u==="-"?(o+=d,s+=f):u==="+"&&(o-=d,s-=f),new Date(Date.UTC(r,a,i,o,s,l))}}aS=new WeakMap,V(HE,aS);function mce(t,{scale:e=1,rotation:n=0}){const{width:r,height:a}=t.attributes.style,i=[0,0,parseInt(r),parseInt(a)];return new GE({viewBox:i,userUnit:1,scale:e,rotation:n})}function Ng(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(e=>parseInt(e)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(Dt(`Not a valid color format: "${t}"`),[0,0,0])}function LYe(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const n of t.keys()){e.style.color=n;const r=window.getComputedStyle(e).color;t.set(n,Ng(r))}e.remove()}function Ir(t){const{a:e,b:n,c:r,d:a,e:i,f:o}=t.getTransform();return[e,n,r,a,i,o]}function Hl(t){const{a:e,b:n,c:r,d:a,e:i,f:o}=t.getTransform().invertSelf();return[e,n,r,a,i,o]}function xd(t,e,n=!1,r=!0){if(e instanceof GE){const{pageWidth:a,pageHeight:i}=e.rawDims,{style:o}=t,s=Ra.isCSSRoundSupported,l=`var(--total-scale-factor) * ${a}px`,u=`var(--total-scale-factor) * ${i}px`,d=s?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,f=s?`round(down, ${u}, var(--scale-round-y))`:`calc(${u})`;!n||e.rotation%180===0?(o.width=d,o.height=f):(o.width=f,o.height=d)}r&&t.setAttribute("data-main-rotation",e.rotation)}class Ks{constructor(){const{pixelRatio:e}=Ks;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(e,n,r,a,i=-1){let o=1/0,s=1/0,l=1/0;r=Ks.capPixels(r,i),r>0&&(o=Math.sqrt(r/(e*n))),a!==-1&&(s=a/e,l=a/n);const u=Math.min(o,s,l);return this.sx>u||this.sy>u?(this.sx=u,this.sy=u,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,n){if(n>=0){const r=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+n/100));return e>0?Math.min(e,r):r}return e}}const XA=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class PYe{static get isDarkMode(){var e;return Ht(this,"isDarkMode",!!((e=window==null?void 0:window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches))}}class hce{static get commentForegroundColor(){const e=document.createElement("span");e.classList.add("comment","sidebar");const{style:n}=e;n.width=n.height="0",n.display="none",n.color="var(--comment-fg-color)",document.body.append(e);const{color:r}=window.getComputedStyle(e);return e.remove(),Ht(this,"commentForegroundColor",Ng(r))}}function gce(t,e,n,r){r=Math.min(Math.max(r??1,0),1);const a=255*(1-r);return t=Math.round(t*r+a),e=Math.round(e*r+a),n=Math.round(n*r+a),[t,e,n]}function _ce(t,e){const n=t[0]/255,r=t[1]/255,a=t[2]/255,i=Math.max(n,r,a),o=Math.min(n,r,a),s=(i+o)/2;if(i===o)e[0]=e[1]=0;else{const l=i-o;switch(e[1]=s<.5?l/(i+o):l/(2-i-o),i){case n:e[0]=((r-a)/l+(r<a?6:0))*60;break;case r:e[0]=((a-n)/l+2)*60;break;case a:e[0]=((n-r)/l+4)*60;break}}e[2]=s}function EB(t,e){const n=t[0],r=t[1],a=t[2],i=(1-Math.abs(2*a-1))*r,o=i*(1-Math.abs(n/60%2-1)),s=a-i/2;switch(Math.floor(n/60)){case 0:e[0]=i+s,e[1]=o+s,e[2]=s;break;case 1:e[0]=o+s,e[1]=i+s,e[2]=s;break;case 2:e[0]=s,e[1]=i+s,e[2]=o+s;break;case 3:e[0]=s,e[1]=o+s,e[2]=i+s;break;case 4:e[0]=o+s,e[1]=s,e[2]=i+s;break;case 5:case 6:e[0]=i+s,e[1]=s,e[2]=o+s;break}}function bce(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Ece(t,e,n){EB(t,n),n.map(bce);const r=.2126*n[0]+.7152*n[1]+.0722*n[2];EB(e,n),n.map(bce);const a=.2126*n[0]+.7152*n[1]+.0722*n[2];return r>a?(r+.05)/(a+.05):(a+.05)/(r+.05)}const Sce=new Map;function vce(t,e){const n=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776;let r=Sce.get(n);if(r)return r;const a=new Float32Array(9),i=a.subarray(0,3),o=a.subarray(3,6);_ce(t,o);const s=a.subarray(6,9);_ce(e,s);const l=s[2]<.5,u=l?12:4.5;if(o[2]=l?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),Ece(o,s,i)<u){let d,f;l?(d=o[2],f=1):(d=0,f=o[2]);const m=.005;for(;f-d>m;){const h=o[2]=(d+f)/2;l===Ece(o,s,i)<u?d=h:f=h}o[2]=l?f:d}return EB(o,i),r=nt.makeHexColor(Math.round(i[0]*255),Math.round(i[1]*255),Math.round(i[2]*255)),Sce.set(n,r),r}function SB({html:t,dir:e,className:n},r){const a=document.createDocumentFragment();if(typeof t=="string"){const i=document.createElement("p");i.dir=e||"auto";const o=t.split(/(?:\r\n?|\n)/);for(let s=0,l=o.length;s<l;++s){const u=o[s];i.append(document.createTextNode(u)),s<l-1&&i.append(document.createElement("br"))}a.append(i)}else bB.render({xfaHtml:t,div:a,intent:"richText"});a.firstChild.classList.add("richText",n),r.append(a)}const Wc=class Wc{constructor(e){V(this,za);V(this,Od,null);V(this,Id,null);V(this,os);V(this,ss,null);V(this,iS,null);V(this,Dd,null);V(this,Bg,null);V(this,Ug,null);L(this,os,e),_(Wc,oS)||L(Wc,oS,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=L(this,Od,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const n=_(this,os)._uiManager._signal;n instanceof AbortSignal&&!n.aborted&&(e.addEventListener("contextmenu",So,{signal:n}),e.addEventListener("pointerdown",Q(Wc,yR,mme),{signal:n}));const r=L(this,ss,document.createElement("div"));r.className="buttons",e.append(r);const a=_(this,os).toolbarPosition;if(a){const{style:i}=e,o=_(this,os)._uiManager.direction==="ltr"?1-a[0]:a[0];i.insetInlineEnd=`${100*o}%`,i.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return _(this,Od)}hide(){var e;_(this,Od).classList.add("hidden"),(e=_(this,Id))==null||e.hideDropdown()}show(){var e,n;_(this,Od).classList.remove("hidden"),(e=_(this,iS))==null||e.shown(),(n=_(this,Dd))==null||n.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=_(this,os),r=document.createElement("button");r.classList.add("basic","deleteButton"),r.tabIndex=0,r.setAttribute("data-l10n-id",_(Wc,oS)[e]),Q(this,za,jb).call(this,r)&&r.addEventListener("click",a=>{n.delete()},{signal:n._signal}),_(this,ss).append(r)}async addAltText(e){const n=await e.render();Q(this,za,jb).call(this,n),_(this,ss).append(n,_(this,za,Ry)),L(this,iS,e)}addComment(e,n=null){if(_(this,Dd))return;const r=e.renderForToolbar();if(!r)return;Q(this,za,jb).call(this,r);const a=L(this,Bg,_(this,za,Ry));n?(_(this,ss).insertBefore(r,n),_(this,ss).insertBefore(a,n)):_(this,ss).append(r,a),L(this,Dd,e),e.toolbar=this}addColorPicker(e){if(_(this,Id))return;L(this,Id,e);const n=e.renderButton();Q(this,za,jb).call(this,n),_(this,ss).append(n,_(this,za,Ry))}async addEditSignatureButton(e){const n=L(this,Ug,await e.renderEditButton(_(this,os)));Q(this,za,jb).call(this,n),_(this,ss).append(n,_(this,za,Ry))}removeButton(e){var n,r;switch(e){case"comment":(n=_(this,Dd))==null||n.removeToolbarCommentButton(),L(this,Dd,null),(r=_(this,Bg))==null||r.remove(),L(this,Bg,null);break}}async addButton(e,n){switch(e){case"colorPicker":this.addColorPicker(n);break;case"altText":await this.addAltText(n);break;case"editSignature":await this.addEditSignatureButton(n);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(n);break}}async addButtonBefore(e,n,r){const a=_(this,ss).querySelector(r);a&&e==="comment"&&this.addComment(n,a)}updateEditSignatureButton(e){_(this,Ug)&&(_(this,Ug).title=e)}remove(){var e;_(this,Od).remove(),(e=_(this,Id))==null||e.destroy(),L(this,Id,null)}};Od=new WeakMap,Id=new WeakMap,os=new WeakMap,ss=new WeakMap,iS=new WeakMap,Dd=new WeakMap,Bg=new WeakMap,Ug=new WeakMap,oS=new WeakMap,yR=new WeakSet,mme=function(e){e.stopPropagation()},za=new WeakSet,hme=function(e){_(this,os)._focusEventsAllowed=!1,Or(e)},gme=function(e){_(this,os)._focusEventsAllowed=!0,Or(e)},jb=function(e){const n=_(this,os)._uiManager._signal;return!(n instanceof AbortSignal)||n.aborted?!1:(e.addEventListener("focusin",Q(this,za,hme).bind(this),{capture:!0,signal:n}),e.addEventListener("focusout",Q(this,za,gme).bind(this),{capture:!0,signal:n}),e.addEventListener("contextmenu",So,{signal:n}),!0)},Ry=function(){const e=document.createElement("div");return e.className="divider",e},V(Wc,yR),V(Wc,oS,null);let vB=Wc;class FYe{constructor(e){V(this,Xc);V(this,sS,null);V(this,zf,null);V(this,Kc);L(this,Kc,e)}show(e,n,r){const[a,i]=Q(this,Xc,bme).call(this,n,r),{style:o}=_(this,zf)||L(this,zf,Q(this,Xc,_me).call(this));e.append(_(this,zf)),o.insetInlineEnd=`${100*a}%`,o.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){_(this,zf).remove()}}sS=new WeakMap,zf=new WeakMap,Kc=new WeakMap,Xc=new WeakSet,_me=function(){const e=L(this,zf,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar");const n=_(this,Kc)._signal;n instanceof AbortSignal&&!n.aborted&&e.addEventListener("contextmenu",So,{signal:n});const r=L(this,sS,document.createElement("div"));return r.className="buttons",e.append(r),_(this,Kc).hasCommentManager()&&Q(this,Xc,u7).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{_(this,Kc).commentSelection("floating_button")}),Q(this,Xc,u7).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{_(this,Kc).highlightSelection("floating_button")}),e},bme=function(e,n){let r=0,a=0;for(const i of e){const o=i.y+i.height;if(o<r)continue;const s=i.x+(n?i.width:0);if(o>r){a=s,r=o;continue}n?s>a&&(a=s):s<a&&(a=s)}return[n?1-a:a,r]},u7=function(e,n,r,a){const i=document.createElement("button");i.classList.add("basic",e),i.tabIndex=0,i.setAttribute("data-l10n-id",n);const o=document.createElement("span");i.append(o),o.className="visuallyHidden",o.setAttribute("data-l10n-id",r);const s=_(this,Kc)._signal;s instanceof AbortSignal&&!s.aborted&&(i.addEventListener("contextmenu",So,{signal:s}),i.addEventListener("click",a,{signal:s})),_(this,sS).append(i)};function yce(t,e,n){for(const r of n)e.addEventListener(r,t[r].bind(t))}class BYe{constructor(){V(this,TR,0)}get id(){return`${ME}${Ca(this,TR)._++}`}}TR=new WeakMap;const r6=class r6{constructor(){V(this,zg);V(this,Gg,gB());V(this,lS,0);V(this,ii,null)}static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',r=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),a=new Image;a.src=e;const i=a.decode().then(()=>(r.drawImage(a,0,0,1,1,0,0,1,3),new Uint32Array(r.getImageData(0,0,1,1).data.buffer)[0]===0));return Ht(this,"_isSVGFittingCanvas",i)}async getFromFile(e){const{lastModified:n,name:r,size:a,type:i}=e;return Q(this,zg,X1).call(this,`${n}_${r}_${a}_${i}`,e)}async getFromUrl(e){return Q(this,zg,X1).call(this,e,e)}async getFromBlob(e,n){const r=await n;return Q(this,zg,X1).call(this,e,r)}async getFromId(e){_(this,ii)||L(this,ii,new Map);const n=_(this,ii).get(e);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return this.getFromFile(n.file);if(n.blobPromise){const{blobPromise:r}=n;return delete n.blobPromise,this.getFromBlob(n.id,r)}return this.getFromUrl(n.url)}getFromCanvas(e,n){_(this,ii)||L(this,ii,new Map);let r=_(this,ii).get(e);if(r!=null&&r.bitmap)return r.refCounter+=1,r;const a=new OffscreenCanvas(n.width,n.height);return a.getContext("2d").drawImage(n,0,0),r={bitmap:a.transferToImageBitmap(),id:`image_${_(this,Gg)}_${Ca(this,lS)._++}`,refCounter:1,isSvg:!1},_(this,ii).set(e,r),_(this,ii).set(r.id,r),r}getSvgUrl(e){const n=_(this,ii).get(e);return n!=null&&n.isSvg?n.svgUrl:null}deleteId(e){var a;_(this,ii)||L(this,ii,new Map);const n=_(this,ii).get(e);if(!n||(n.refCounter-=1,n.refCounter!==0))return;const{bitmap:r}=n;if(!n.url&&!n.file){const i=new OffscreenCanvas(r.width,r.height);i.getContext("bitmaprenderer").transferFromImageBitmap(r),n.blobPromise=i.convertToBlob()}(a=r.close)==null||a.call(r),n.bitmap=null}isValidId(e){return e.startsWith(`image_${_(this,Gg)}_`)}};Gg=new WeakMap,lS=new WeakMap,ii=new WeakMap,zg=new WeakSet,X1=async function(e,n){_(this,ii)||L(this,ii,new Map);let r=_(this,ii).get(e);if(r===null)return null;if(r!=null&&r.bitmap)return r.refCounter+=1,r;try{r||(r={bitmap:null,id:`image_${_(this,Gg)}_${Ca(this,lS)._++}`,refCounter:0,isSvg:!1});let a;if(typeof n=="string"?(r.url=n,a=await xg(n,"blob")):n instanceof File?a=r.file=n:n instanceof Blob&&(a=n),a.type==="image/svg+xml"){const i=r6._isSVGFittingCanvas,o=new FileReader,s=new Image,l=new Promise((u,d)=>{s.onload=()=>{r.bitmap=s,r.isSvg=!0,u()},o.onload=async()=>{const f=r.svgUrl=o.result;s.src=await i?`${f}#svgView(preserveAspectRatio(none))`:f},s.onerror=o.onerror=d});o.readAsDataURL(a),await l}else r.bitmap=await createImageBitmap(a);r.refCounter=1}catch(a){Dt(a),r=null}return _(this,ii).set(e,r),r&&_(this,ii).set(r.id,r),r};let yB=r6;class UYe{constructor(e=128){V(this,Qr,[]);V(this,kd,!1);V(this,cS);V(this,kr,-1);L(this,cS,e)}add({cmd:e,undo:n,post:r,mustExec:a,type:i=NaN,overwriteIfSameType:o=!1,keepUndo:s=!1}){if(a&&e(),_(this,kd))return;const l={cmd:e,undo:n,post:r,type:i};if(_(this,kr)===-1){_(this,Qr).length>0&&(_(this,Qr).length=0),L(this,kr,0),_(this,Qr).push(l);return}if(o&&_(this,Qr)[_(this,kr)].type===i){s&&(l.undo=_(this,Qr)[_(this,kr)].undo),_(this,Qr)[_(this,kr)]=l;return}const u=_(this,kr)+1;u===_(this,cS)?_(this,Qr).splice(0,1):(L(this,kr,u),u<_(this,Qr).length&&_(this,Qr).splice(u)),_(this,Qr).push(l)}undo(){if(_(this,kr)===-1)return;L(this,kd,!0);const{undo:e,post:n}=_(this,Qr)[_(this,kr)];e(),n==null||n(),L(this,kd,!1),L(this,kr,_(this,kr)-1)}redo(){if(_(this,kr)<_(this,Qr).length-1){L(this,kr,_(this,kr)+1),L(this,kd,!0);const{cmd:e,post:n}=_(this,Qr)[_(this,kr)];e(),n==null||n(),L(this,kd,!1)}}hasSomethingToUndo(){return _(this,kr)!==-1}hasSomethingToRedo(){return _(this,kr)<_(this,Qr).length-1}cleanType(e){if(_(this,kr)!==-1){for(let n=_(this,kr);n>=0;n--)if(_(this,Qr)[n].type!==e){_(this,Qr).splice(n+1,_(this,kr)-n),L(this,kr,n);return}_(this,Qr).length=0,L(this,kr,-1)}}destroy(){L(this,Qr,null)}}Qr=new WeakMap,kd=new WeakMap,cS=new WeakMap,kr=new WeakMap;class $E{constructor(e){V(this,CR);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:n}=Ra.platform;for(const[r,a,i={}]of e)for(const o of r){const s=o.startsWith("mac+");n&&s?(this.callbacks.set(o.slice(4),{callback:a,options:i}),this.allKeys.add(o.split("+").at(-1))):!n&&!s&&(this.callbacks.set(o,{callback:a,options:i}),this.allKeys.add(o.split("+").at(-1)))}}exec(e,n){if(!this.allKeys.has(n.key))return;const r=this.callbacks.get(Q(this,CR,Eme).call(this,n));if(!r)return;const{callback:a,options:{bubbles:i=!1,args:o=[],checker:s=null}}=r;s&&!s(e,n)||(a.bind(e,...o,n)(),i||Or(n))}}CR=new WeakSet,Eme=function(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const n=this.buffer.join("+");return this.buffer.length=0,n};const AR=class AR{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return LYe(e),Ht(this,"_colors",e)}convert(e){const n=Ng(e);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[r,a]of this._colors)if(a.every((i,o)=>i===n[o]))return AR._colorsMapping.get(r);return n}getHexCode(e){const n=this._colors.get(e);return n?nt.makeHexColor(...n):e}};Ue(AR,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let TB=AR;const Zg=class Zg{constructor(e,n,r,a,i,o,s,l,u,d,f,m,h,E,b,y){V(this,Ke);V(this,qg,new AbortController);V(this,yo,null);V(this,Hg,null);V(this,Br,new Map);V(this,ha,new Map);V(this,$g,null);V(this,ls,null);V(this,Yg,null);V(this,cs,new UYe);V(this,oi,null);V(this,Md,null);V(this,Ld,null);V(this,Vg,0);V(this,Pd,new Set);V(this,Vl,null);V(this,us,null);V(this,qf,new Set);Ue(this,"_editorUndoBar",null);V(this,uS,!1);V(this,dS,!1);V(this,jg,!1);V(this,pS,null);V(this,jl,null);V(this,Fd,null);V(this,Wg,null);V(this,Bd,!1);V(this,Wl,null);V(this,RR,new BYe);V(this,Ud,!1);V(this,Kg,!1);V(this,fS,!1);V(this,Gd,null);V(this,Hf,null);V(this,Xg,null);V(this,zd,null);V(this,mS,null);V(this,ia,It.NONE);V(this,Mn,new Set);V(this,Qc,null);V(this,qd,null);V(this,Hd,null);V(this,hS,null);V(this,Qg,null);V(this,gS,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});V(this,$d,[0,0]);V(this,Kl,null);V(this,Zc,null);V(this,_S,null);V(this,bS,null);V(this,ds,null);const v=this._signal=_(this,qg).signal;L(this,Zc,e),L(this,_S,n),L(this,bS,r),L(this,$g,a),L(this,oi,i),L(this,qd,o),L(this,Qg,l),this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:v}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:v}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:v}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:v}),s._on("setpreference",this.onSetPreference.bind(this),{signal:v}),s._on("switchannotationeditorparams",C=>this.updateParams(C.type,C.value),{signal:v}),window.addEventListener("pointerdown",()=>{L(this,Kg,!0)},{capture:!0,signal:v}),window.addEventListener("pointerup",()=>{L(this,Kg,!1)},{capture:!0,signal:v}),Q(this,Ke,yme).call(this),Q(this,Ke,Rme).call(this),Q(this,Ke,p7).call(this),L(this,ls,l.annotationStorage),L(this,pS,l.filterFactory),L(this,Hd,u),L(this,Wg,d||null),L(this,uS,f),L(this,dS,m),L(this,jg,h),L(this,mS,E||null),this.viewParameters={realScale:Vc.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=b||null,this._supportsPinchToZoom=y!==!1,i==null||i.setSidebarUiManager(this)}static get _keyboardManager(){const e=Zg.prototype,n=o=>_(o,Zc).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&o.hasSomethingToControl(),r=(o,{target:s})=>{if(s instanceof HTMLInputElement){const{type:l}=s;return l!=="text"&&l!=="number"}return!0},a=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return Ht(this,"_keyboardManager",new $E([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],e.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:r}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(o,{target:s})=>!(s instanceof HTMLButtonElement)&&_(o,Zc).contains(s)&&!o.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(o,{target:s})=>!(s instanceof HTMLButtonElement)&&_(o,Zc).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:n}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:n}]]))}destroy(){var e,n,r,a,i,o,s,l,u;(e=_(this,ds))==null||e.resolve(),L(this,ds,null),(n=_(this,qg))==null||n.abort(),L(this,qg,null),this._signal=null;for(const d of _(this,ha).values())d.destroy();_(this,ha).clear(),_(this,Br).clear(),_(this,qf).clear(),(r=_(this,zd))==null||r.clear(),L(this,yo,null),_(this,Mn).clear(),_(this,cs).destroy(),(a=_(this,$g))==null||a.destroy(),(i=_(this,oi))==null||i.destroy(),(o=_(this,qd))==null||o.destroy(),(s=_(this,Wl))==null||s.hide(),L(this,Wl,null),(l=_(this,Xg))==null||l.destroy(),L(this,Xg,null),L(this,Hg,null),_(this,jl)&&(clearTimeout(_(this,jl)),L(this,jl,null)),_(this,Kl)&&(clearTimeout(_(this,Kl)),L(this,Kl,null)),(u=this._editorUndoBar)==null||u.destroy(),L(this,Qg,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return _(this,mS)}get useNewAltTextFlow(){return _(this,dS)}get useNewAltTextWhenAddingImage(){return _(this,jg)}get hcmFilter(){return Ht(this,"hcmFilter",_(this,Hd)?_(this,pS).addHCMFilter(_(this,Hd).foreground,_(this,Hd).background):"none")}get direction(){return Ht(this,"direction",getComputedStyle(_(this,Zc)).direction)}get _highlightColors(){return Ht(this,"_highlightColors",_(this,Wg)?new Map(_(this,Wg).split(",").map(e=>(e=e.split("=").map(n=>n.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return Ht(this,"highlightColors",null);const n=new Map,r=!!_(this,Hd);for(const[a,i]of e){const o=a.endsWith("_HCM");if(r&&o){n.set(a.replace("_HCM",""),i);continue}!r&&!o&&n.set(a,i)}return Ht(this,"highlightColors",n)}get highlightColorNames(){return Ht(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const n=this.highlightColorNames.get(e);return this._highlightColors.get(n)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),L(this,Ld,e)}setMainHighlightColorPicker(e){L(this,Xg,e)}editAltText(e,n=!1){var r;(r=_(this,$g))==null||r.editAltText(this,e,n)}hasCommentManager(){return!!_(this,oi)}editComment(e,n,r,a){var i;(i=_(this,oi))==null||i.showDialog(this,e,n,r,a)}selectComment(e,n){const r=_(this,ha).get(e),a=r==null?void 0:r.getEditorByUID(n);a==null||a.toggleComment(!0,!0)}updateComment(e){var n;(n=_(this,oi))==null||n.updateComment(e.getData())}updatePopupColor(e){var n;(n=_(this,oi))==null||n.updatePopupColor(e)}removeComment(e){var n;(n=_(this,oi))==null||n.removeComments([e.uid])}toggleComment(e,n,r=void 0){var a;(a=_(this,oi))==null||a.toggleCommentPopup(e,n,r)}makeCommentColor(e,n){var r;return e&&((r=_(this,oi))==null?void 0:r.makeCommentColor(e,n))||null}getCommentDialogElement(){var e;return((e=_(this,oi))==null?void 0:e.dialogElement)||null}async waitForEditorsRendered(e){if(_(this,ha).has(e-1))return;const{resolve:n,promise:r}=Promise.withResolvers(),a=i=>{i.pageNumber===e&&(this._eventBus._off("editorsrendered",a),n())};this._eventBus.on("editorsrendered",a),await r}getSignature(e){var n;(n=_(this,qd))==null||n.getSignature({uiManager:this,editor:e})}get signatureManager(){return _(this,qd)}switchToMode(e,n){this._eventBus.on("annotationeditormodechanged",n,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,n){this._eventBus.dispatch("setpreference",{source:this,name:e,value:n})}onSetPreference({name:e,value:n}){switch(e){case"enableNewAltTextWhenAddingImage":L(this,jg,n);break}}onPageChanging({pageNumber:e}){L(this,Vg,e-1)}focusMainContainer(){_(this,Zc).focus()}findParent(e,n){for(const r of _(this,ha).values()){const{x:a,y:i,width:o,height:s}=r.div.getBoundingClientRect();if(e>=a&&e<=a+o&&n>=i&&n<=i+s)return r}return null}disableUserSelect(e=!1){_(this,_S).classList.toggle("noUserSelect",e)}addShouldRescale(e){_(this,qf).add(e)}removeShouldRescale(e){_(this,qf).delete(e)}onScaleChanging({scale:e}){var n;this.commitOrRemove(),this.viewParameters.realScale=e*Vc.PDF_TO_CSS_UNITS;for(const r of _(this,qf))r.onScaleChanging();(n=_(this,Ld))==null||n.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e="",n=!1){const r=document.getSelection();if(!r||r.isCollapsed)return;const{anchorNode:a,anchorOffset:i,focusNode:o,focusOffset:s}=r,l=r.toString(),d=Q(this,Ke,Q1).call(this,r).closest(".textLayer"),f=this.getSelectionBoxes(d);if(!f)return;r.empty();const m=Q(this,Ke,d7).call(this,d),h=_(this,ia)===It.NONE,E=()=>{const b=m==null?void 0:m.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:f,anchorNode:a,anchorOffset:i,focusNode:o,focusOffset:s,text:l});h&&this.showAllEditors("highlight",!0,!0),n&&(b==null||b.editComment())};if(h){this.switchToMode(It.HIGHLIGHT,E);return}E()}commentSelection(e=""){this.highlightSelection(e,!0)}getAndRemoveDataFromAnnotationStorage(e){if(!_(this,ls))return null;const n=`${ME}${e}`,r=_(this,ls).getRawValue(n);return r&&_(this,ls).remove(n),r}addToAnnotationStorage(e){!e.isEmpty()&&_(this,ls)&&!_(this,ls).has(e.id)&&_(this,ls).setValue(e.id,e)}a11yAlert(e,n=null){const r=_(this,bS);r&&(r.setAttribute("data-l10n-id",e),n?r.setAttribute("data-l10n-args",JSON.stringify(n)):r.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,_(this,Bd)&&(L(this,Bd,!1),Q(this,Ke,wy).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const n of _(this,Mn))if(n.div.contains(e)){L(this,Hf,[n,e]),n._focusEventsAllowed=!1;break}}focus(){if(!_(this,Hf))return;const[e,n]=_(this,Hf);L(this,Hf,null),n.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),n.focus()}addEditListeners(){Q(this,Ke,p7).call(this),Q(this,Ke,f7).call(this)}removeEditListeners(){Q(this,Ke,Ame).call(this),Q(this,Ke,m7).call(this)}dragOver(e){for(const{type:n}of e.dataTransfer.items)for(const r of _(this,us))if(r.isHandlingMimeForPasting(n)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const n of e.dataTransfer.items)for(const r of _(this,us))if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer),e.preventDefault();return}}copy(e){var r;if(e.preventDefault(),(r=_(this,yo))==null||r.commitOrRemove(),!this.hasSelection)return;const n=[];for(const a of _(this,Mn)){const i=a.serialize(!0);i&&n.push(i)}n.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:n}=e;for(const i of n.items)for(const o of _(this,us))if(o.isHandlingMimeForPasting(i.type)){o.paste(i,this.currentLayer);return}let r=n.getData("application/pdfjs");if(!r)return;try{r=JSON.parse(r)}catch(i){Dt(`paste: "${i.message}".`);return}if(!Array.isArray(r))return;this.unselectAll();const a=this.currentLayer;try{const i=[];for(const l of r){const u=await a.deserialize(l);if(!u)return;i.push(u)}const o=()=>{for(const l of i)Q(this,Ke,h7).call(this,l);Q(this,Ke,g7).call(this,i)},s=()=>{for(const l of i)l.remove()};this.addCommands({cmd:o,undo:s,mustExec:!0})}catch(i){Dt(`paste: "${i.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),_(this,ia)!==It.NONE&&!this.isEditorHandlingKeyboard&&Zg._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,_(this,Bd)&&(L(this,Bd,!1),Q(this,Ke,wy).call(this,"main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}setEditingState(e){e?(Q(this,Ke,Tme).call(this),Q(this,Ke,f7).call(this),Q(this,Ke,Ni).call(this,{isEditing:_(this,ia)!==It.NONE,isEmpty:Q(this,Ke,xy).call(this),hasSomethingToUndo:_(this,cs).hasSomethingToUndo(),hasSomethingToRedo:_(this,cs).hasSomethingToRedo(),hasSelectedEditor:!1})):(Q(this,Ke,Cme).call(this),Q(this,Ke,m7).call(this),Q(this,Ke,Ni).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!_(this,us)){L(this,us,e);for(const n of _(this,us))Q(this,Ke,ed).call(this,n.defaultPropertiesToUpdate)}}getId(){return _(this,RR).id}get currentLayer(){return _(this,ha).get(_(this,Vg))}getLayer(e){return _(this,ha).get(e)}get currentPageIndex(){return _(this,Vg)}addLayer(e){_(this,ha).set(e.pageIndex,e),_(this,Ud)?e.enable():e.disable()}removeLayer(e){_(this,ha).delete(e.pageIndex)}async updateMode(e,n=null,r=!1,a=!1,i=!1){var o,s,l,u,d,f;if(_(this,ia)!==e&&!(_(this,ds)&&(await _(this,ds).promise,!_(this,ds)))){if(L(this,ds,Promise.withResolvers()),(o=_(this,Ld))==null||o.commitOrRemove(),_(this,ia)===It.POPUP&&((s=_(this,oi))==null||s.hideSidebar()),(l=_(this,oi))==null||l.destroyPopup(),L(this,ia,e),e===It.NONE){this.setEditingState(!1),Q(this,Ke,xme).call(this);for(const m of _(this,Br).values())m.hideStandaloneCommentButton();(u=this._editorUndoBar)==null||u.hide(),this.toggleComment(null),_(this,ds).resolve();return}for(const m of _(this,Br).values())m.addStandaloneCommentButton();e===It.SIGNATURE&&await((d=_(this,qd))==null?void 0:d.loadSignatures()),this.setEditingState(!0),await Q(this,Ke,wme).call(this),this.unselectAll();for(const m of _(this,ha).values())m.updateMode(e);if(e===It.POPUP){_(this,Hg)||L(this,Hg,await _(this,Qg).getAnnotationsByType(new Set(_(this,us).map(E=>E._editorType))));const m=new Set,h=[];for(const E of _(this,Br).values()){const{annotationElementId:b,hasComment:y,deleted:v}=E;b&&m.add(b),y&&!v&&h.push(E.getData())}for(const E of _(this,Hg)){const{id:b,popupRef:y,contentsObj:v}=E;y&&(v!=null&&v.str)&&!m.has(b)&&!_(this,Pd).has(b)&&h.push(E)}(f=_(this,oi))==null||f.showSidebar(h)}if(!n){r&&this.addNewEditorFromKeyboard(),_(this,ds).resolve();return}for(const m of _(this,Br).values())m.uid===n?(this.setSelected(m),i?m.editComment():a?m.enterInEditMode():m.focus()):m.unselect();_(this,ds).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==_(this,ia)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,n){if(_(this,us)){switch(e){case an.CREATE:this.currentLayer.addNewEditor(n);return;case an.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_(this,hS)||L(this,hS,new Map)).set(e,n),this.showAllEditors("highlight",n);break}if(this.hasSelection)for(const r of _(this,Mn))r.updateParams(e,n);else for(const r of _(this,us))r.updateDefaultParams(e,n)}}showAllEditors(e,n,r=!1){var i;for(const o of _(this,Br).values())o.editorType===e&&o.show(n);(((i=_(this,hS))==null?void 0:i.get(an.HIGHLIGHT_SHOW_ALL))??!0)!==n&&Q(this,Ke,ed).call(this,[[an.HIGHLIGHT_SHOW_ALL,n]])}enableWaiting(e=!1){if(_(this,fS)!==e){L(this,fS,e);for(const n of _(this,ha).values())e?n.disableClick():n.enableClick(),n.div.classList.toggle("waiting",e)}}*getEditors(e){for(const n of _(this,Br).values())n.pageIndex===e&&(yield n)}getEditor(e){return _(this,Br).get(e)}addEditor(e){_(this,Br).set(e.id,e)}removeEditor(e){var n,r;e.div.contains(document.activeElement)&&(_(this,jl)&&clearTimeout(_(this,jl)),L(this,jl,setTimeout(()=>{this.focusMainContainer(),L(this,jl,null)},0))),_(this,Br).delete(e.id),e.annotationElementId&&((n=_(this,zd))==null||n.delete(e.annotationElementId)),this.unselect(e),(!e.annotationElementId||!_(this,Pd).has(e.annotationElementId))&&((r=_(this,ls))==null||r.remove(e.id))}addDeletedAnnotationElement(e){_(this,Pd).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return _(this,Pd).has(e)}removeDeletedAnnotationElement(e){_(this,Pd).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){_(this,yo)!==e&&(L(this,yo,e),e&&Q(this,Ke,ed).call(this,e.propertiesToUpdate))}updateUI(e){_(this,Ke,Nme)===e&&Q(this,Ke,ed).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){Q(this,Ke,ed).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(_(this,Mn).has(e)){_(this,Mn).delete(e),e.unselect(),Q(this,Ke,Ni).call(this,{hasSelectedEditor:this.hasSelection});return}_(this,Mn).add(e),e.select(),Q(this,Ke,ed).call(this,e.propertiesToUpdate),Q(this,Ke,Ni).call(this,{hasSelectedEditor:!0})}setSelected(e){var n;this.updateToolbar({mode:e.mode,editId:e.id}),(n=_(this,Ld))==null||n.commitOrRemove();for(const r of _(this,Mn))r!==e&&r.unselect();_(this,Mn).clear(),_(this,Mn).add(e),e.select(),Q(this,Ke,ed).call(this,e.propertiesToUpdate),Q(this,Ke,Ni).call(this,{hasSelectedEditor:!0})}isSelected(e){return _(this,Mn).has(e)}get firstSelectedEditor(){return _(this,Mn).values().next().value}unselect(e){e.unselect(),_(this,Mn).delete(e),Q(this,Ke,Ni).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return _(this,Mn).size!==0}get isEnterHandled(){return _(this,Mn).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;_(this,cs).undo(),Q(this,Ke,Ni).call(this,{hasSomethingToUndo:_(this,cs).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:Q(this,Ke,xy).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){_(this,cs).redo(),Q(this,Ke,Ni).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_(this,cs).hasSomethingToRedo(),isEmpty:Q(this,Ke,xy).call(this)})}addCommands(e){_(this,cs).add(e),Q(this,Ke,Ni).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:Q(this,Ke,xy).call(this)})}cleanUndoStack(e){_(this,cs).cleanType(e)}delete(){var i;this.commitOrRemove();const e=(i=this.currentLayer)==null?void 0:i.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const n=e?[e]:[..._(this,Mn)],r=()=>{var o;(o=this._editorUndoBar)==null||o.show(a,n.length===1?n[0].editorType:n.length);for(const s of n)s.remove()},a=()=>{for(const o of n)Q(this,Ke,h7).call(this,o)};this.addCommands({cmd:r,undo:a,mustExec:!0})}commitOrRemove(){var e;(e=_(this,yo))==null||e.commitOrRemove()}hasSomethingToControl(){return _(this,yo)||this.hasSelection}selectAll(){for(const e of _(this,Mn))e.commit();Q(this,Ke,g7).call(this,_(this,Br).values())}unselectAll(){var e;if(!(_(this,yo)&&(_(this,yo).commitOrRemove(),_(this,ia)!==It.NONE))&&!((e=_(this,Ld))!=null&&e.commitOrRemove())&&this.hasSelection){for(const n of _(this,Mn))n.unselect();_(this,Mn).clear(),Q(this,Ke,Ni).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,n,r=!1){if(r||this.commitOrRemove(),!this.hasSelection)return;_(this,$d)[0]+=e,_(this,$d)[1]+=n;const[a,i]=_(this,$d),o=[..._(this,Mn)],s=1e3;_(this,Kl)&&clearTimeout(_(this,Kl)),L(this,Kl,setTimeout(()=>{L(this,Kl,null),_(this,$d)[0]=_(this,$d)[1]=0,this.addCommands({cmd:()=>{for(const l of o)_(this,Br).has(l.id)&&(l.translateInPage(a,i),l.translationDone())},undo:()=>{for(const l of o)_(this,Br).has(l.id)&&(l.translateInPage(-a,-i),l.translationDone())},mustExec:!1})},s));for(const l of o)l.translateInPage(e,n),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),L(this,Vl,new Map);for(const e of _(this,Mn))_(this,Vl).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!_(this,Vl))return!1;this.disableUserSelect(!1);const e=_(this,Vl);L(this,Vl,null);let n=!1;for(const[{x:a,y:i,pageIndex:o},s]of e)s.newX=a,s.newY=i,s.newPageIndex=o,n||(n=a!==s.savedX||i!==s.savedY||o!==s.savedPageIndex);if(!n)return!1;const r=(a,i,o,s)=>{if(_(this,Br).has(a.id)){const l=_(this,ha).get(s);l?a._setParentAndPosition(l,i,o):(a.pageIndex=s,a.x=i,a.y=o)}};return this.addCommands({cmd:()=>{for(const[a,{newX:i,newY:o,newPageIndex:s}]of e)r(a,i,o,s)},undo:()=>{for(const[a,{savedX:i,savedY:o,savedPageIndex:s}]of e)r(a,i,o,s)},mustExec:!0}),!0}dragSelectedEditors(e,n){if(_(this,Vl))for(const r of _(this,Vl).keys())r.drag(e,n)}rebuild(e){if(e.parent===null){const n=this.getLayer(e.pageIndex);n?(n.changeParent(e),n.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||_(this,Mn).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return _(this,yo)===e}getActive(){return _(this,yo)}getMode(){return _(this,ia)}isEditingMode(){return _(this,ia)!==It.NONE}get imageManager(){return Ht(this,"imageManager",new yB)}getSelectionBoxes(e){if(!e)return null;const n=document.getSelection();for(let u=0,d=n.rangeCount;u<d;u++)if(!e.contains(n.getRangeAt(u).commonAncestorContainer))return null;const{x:r,y:a,width:i,height:o}=e.getBoundingClientRect();let s;switch(e.getAttribute("data-main-rotation")){case"90":s=(u,d,f,m)=>({x:(d-a)/o,y:1-(u+f-r)/i,width:m/o,height:f/i});break;case"180":s=(u,d,f,m)=>({x:1-(u+f-r)/i,y:1-(d+m-a)/o,width:f/i,height:m/o});break;case"270":s=(u,d,f,m)=>({x:1-(d+m-a)/o,y:(u-r)/i,width:m/o,height:f/i});break;default:s=(u,d,f,m)=>({x:(u-r)/i,y:(d-a)/o,width:f/i,height:m/o});break}const l=[];for(let u=0,d=n.rangeCount;u<d;u++){const f=n.getRangeAt(u);if(!f.collapsed)for(const{x:m,y:h,width:E,height:b}of f.getClientRects())E===0||b===0||l.push(s(m,h,E,b))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:e,id:n}){(_(this,Yg)||L(this,Yg,new Map)).set(e,n)}removeChangedExistingAnnotation({annotationElementId:e}){var n;(n=_(this,Yg))==null||n.delete(e)}renderAnnotationElement(e){var a;const n=(a=_(this,Yg))==null?void 0:a.get(e.data.id);if(!n)return;const r=_(this,ls).getRawValue(n);r&&(_(this,ia)===It.NONE&&!r.hasBeenModified||r.renderAnnotationElement(e))}setMissingCanvas(e,n,r){var i;const a=(i=_(this,zd))==null?void 0:i.get(e);a&&(a.setCanvas(n,r),_(this,zd).delete(e))}addMissingCanvas(e,n){(_(this,zd)||L(this,zd,new Map)).set(e,n)}};qg=new WeakMap,yo=new WeakMap,Hg=new WeakMap,Br=new WeakMap,ha=new WeakMap,$g=new WeakMap,ls=new WeakMap,Yg=new WeakMap,cs=new WeakMap,oi=new WeakMap,Md=new WeakMap,Ld=new WeakMap,Vg=new WeakMap,Pd=new WeakMap,Vl=new WeakMap,us=new WeakMap,qf=new WeakMap,uS=new WeakMap,dS=new WeakMap,jg=new WeakMap,pS=new WeakMap,jl=new WeakMap,Fd=new WeakMap,Wg=new WeakMap,Bd=new WeakMap,Wl=new WeakMap,RR=new WeakMap,Ud=new WeakMap,Kg=new WeakMap,fS=new WeakMap,Gd=new WeakMap,Hf=new WeakMap,Xg=new WeakMap,zd=new WeakMap,mS=new WeakMap,ia=new WeakMap,Mn=new WeakMap,Qc=new WeakMap,qd=new WeakMap,Hd=new WeakMap,hS=new WeakMap,Qg=new WeakMap,gS=new WeakMap,$d=new WeakMap,Kl=new WeakMap,Zc=new WeakMap,_S=new WeakMap,bS=new WeakMap,ds=new WeakMap,Ke=new WeakSet,Q1=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},d7=function(e){const{currentLayer:n}=this;if(n.hasTextLayer(e))return n;for(const r of _(this,ha).values())if(r.hasTextLayer(e))return r;return null},Sme=function(){const e=document.getSelection();if(!e||e.isCollapsed)return;const r=Q(this,Ke,Q1).call(this,e).closest(".textLayer"),a=this.getSelectionBoxes(r);a&&(_(this,Wl)||L(this,Wl,new FYe(this)),_(this,Wl).show(r,a,this.direction==="ltr"))},vme=function(){var i,o,s;const e=document.getSelection();if(!e||e.isCollapsed){_(this,Qc)&&((i=_(this,Wl))==null||i.hide(),L(this,Qc,null),Q(this,Ke,Ni).call(this,{hasSelectedText:!1}));return}const{anchorNode:n}=e;if(n===_(this,Qc))return;const a=Q(this,Ke,Q1).call(this,e).closest(".textLayer");if(!a){_(this,Qc)&&((o=_(this,Wl))==null||o.hide(),L(this,Qc,null),Q(this,Ke,Ni).call(this,{hasSelectedText:!1}));return}if((s=_(this,Wl))==null||s.hide(),L(this,Qc,n),Q(this,Ke,Ni).call(this,{hasSelectedText:!0}),!(_(this,ia)!==It.HIGHLIGHT&&_(this,ia)!==It.NONE)&&(_(this,ia)===It.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),L(this,Bd,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=_(this,ia)===It.HIGHLIGHT?Q(this,Ke,d7).call(this,a):null;if(l==null||l.toggleDrawing(),_(this,Kg)){const u=new AbortController,d=this.combinedSignal(u),f=m=>{m.type==="pointerup"&&m.button!==0||(u.abort(),l==null||l.toggleDrawing(!0),m.type==="pointerup"&&Q(this,Ke,wy).call(this,"main_toolbar"))};window.addEventListener("pointerup",f,{signal:d}),window.addEventListener("blur",f,{signal:d})}else l==null||l.toggleDrawing(!0),Q(this,Ke,wy).call(this,"main_toolbar")}},wy=function(e=""){_(this,ia)===It.HIGHLIGHT?this.highlightSelection(e):_(this,uS)&&Q(this,Ke,Sme).call(this)},yme=function(){document.addEventListener("selectionchange",Q(this,Ke,vme).bind(this),{signal:this._signal})},Tme=function(){if(_(this,Fd))return;L(this,Fd,new AbortController);const e=this.combinedSignal(_(this,Fd));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},Cme=function(){var e;(e=_(this,Fd))==null||e.abort(),L(this,Fd,null)},p7=function(){if(_(this,Gd))return;L(this,Gd,new AbortController);const e=this.combinedSignal(_(this,Gd));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},Ame=function(){var e;(e=_(this,Gd))==null||e.abort(),L(this,Gd,null)},f7=function(){if(_(this,Md))return;L(this,Md,new AbortController);const e=this.combinedSignal(_(this,Md));document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})},m7=function(){var e;(e=_(this,Md))==null||e.abort(),L(this,Md,null)},Rme=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},Ni=function(e){Object.entries(e).some(([r,a])=>_(this,gS)[r]!==a)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_(this,gS),e)}),_(this,ia)===It.HIGHLIGHT&&e.hasSelectedEditor===!1&&Q(this,Ke,ed).call(this,[[an.HIGHLIGHT_FREE,!0]]))},ed=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},wme=async function(){if(!_(this,Ud)){L(this,Ud,!0);const e=[];for(const n of _(this,ha).values())e.push(n.enable());await Promise.all(e);for(const n of _(this,Br).values())n.enable()}},xme=function(){if(this.unselectAll(),_(this,Ud)){L(this,Ud,!1);for(const e of _(this,ha).values())e.disable();for(const e of _(this,Br).values())e.disable()}},h7=function(e){const n=_(this,ha).get(e.pageIndex);n?n.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},Nme=function(){let e=null;for(e of _(this,Mn));return e},xy=function(){if(_(this,Br).size===0)return!0;if(_(this,Br).size===1)for(const e of _(this,Br).values())return e.isEmpty();return!1},g7=function(e){for(const n of _(this,Mn))n.unselect();_(this,Mn).clear();for(const n of e)n.isEmpty()||(_(this,Mn).add(n),n.select());Q(this,Ke,Ni).call(this,{hasSelectedEditor:this.hasSelection})},Ue(Zg,"TRANSLATE_SMALL",1),Ue(Zg,"TRANSLATE_BIG",10);let Nd=Zg;const vi=class vi{constructor(e){V(this,Qs);V(this,wa,null);V(this,Xl,!1);V(this,Xs,null);V(this,Jg,null);V(this,Ql,null);V(this,To,null);V(this,e_,!1);V(this,Zl,null);V(this,qi,null);V(this,Jc,null);V(this,$f,null);V(this,Jl,!1);L(this,qi,e),L(this,Jl,e._uiManager.useNewAltTextFlow),_(vi,Yd)||L(vi,Yd,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){vi._l10n??(vi._l10n=e)}async render(){const e=L(this,Xs,document.createElement("button"));e.className="altText",e.tabIndex="0";const n=L(this,Jg,document.createElement("span"));e.append(n),_(this,Jl)?(e.classList.add("new"),e.setAttribute("data-l10n-id",_(vi,Yd).missing),n.setAttribute("data-l10n-id",_(vi,Yd)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const r=_(this,qi)._uiManager._signal;e.addEventListener("contextmenu",So,{signal:r}),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:r});const a=i=>{i.preventDefault(),_(this,qi)._uiManager.editAltText(_(this,qi)),_(this,Jl)&&_(this,qi)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:_(this,Qs,Ny)}})};return e.addEventListener("click",a,{capture:!0,signal:r}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(L(this,e_,!0),a(i))},{signal:r}),await Q(this,Qs,Z1).call(this),e}finish(){_(this,Xs)&&(_(this,Xs).focus({focusVisible:_(this,e_)}),L(this,e_,!1))}isEmpty(){return _(this,Jl)?_(this,wa)===null:!_(this,wa)&&!_(this,Xl)}hasData(){return _(this,Jl)?_(this,wa)!==null||!!_(this,Jc):this.isEmpty()}get guessedText(){return _(this,Jc)}async setGuessedText(e){_(this,wa)===null&&(L(this,Jc,e),L(this,$f,await vi._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),Q(this,Qs,Z1).call(this))}toggleAltTextBadge(e=!1){var n;if(!_(this,Jl)||_(this,wa)){(n=_(this,Zl))==null||n.remove(),L(this,Zl,null);return}if(!_(this,Zl)){const r=L(this,Zl,document.createElement("div"));r.className="noAltTextBadge",_(this,qi).div.append(r)}_(this,Zl).classList.toggle("hidden",!e)}serialize(e){let n=_(this,wa);return!e&&_(this,Jc)===n&&(n=_(this,$f)),{altText:n,decorative:_(this,Xl),guessedText:_(this,Jc),textWithDisclaimer:_(this,$f)}}get data(){return{altText:_(this,wa),decorative:_(this,Xl)}}set data({altText:e,decorative:n,guessedText:r,textWithDisclaimer:a,cancel:i=!1}){r&&(L(this,Jc,r),L(this,$f,a)),!(_(this,wa)===e&&_(this,Xl)===n)&&(i||(L(this,wa,e),L(this,Xl,n)),Q(this,Qs,Z1).call(this))}toggle(e=!1){_(this,Xs)&&(!e&&_(this,To)&&(clearTimeout(_(this,To)),L(this,To,null)),_(this,Xs).disabled=!e)}shown(){_(this,qi)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:_(this,Qs,Ny)}})}destroy(){var e,n;(e=_(this,Xs))==null||e.remove(),L(this,Xs,null),L(this,Jg,null),L(this,Ql,null),(n=_(this,Zl))==null||n.remove(),L(this,Zl,null)}};wa=new WeakMap,Xl=new WeakMap,Xs=new WeakMap,Jg=new WeakMap,Ql=new WeakMap,To=new WeakMap,e_=new WeakMap,Zl=new WeakMap,qi=new WeakMap,Jc=new WeakMap,$f=new WeakMap,Jl=new WeakMap,Yd=new WeakMap,Qs=new WeakSet,Ny=function(){return _(this,wa)&&"added"||_(this,wa)===null&&this.guessedText&&"review"||"missing"},Z1=async function(){var a,i,o;const e=_(this,Xs);if(!e)return;if(_(this,Jl)){if(e.classList.toggle("done",!!_(this,wa)),e.setAttribute("data-l10n-id",_(vi,Yd)[_(this,Qs,Ny)]),(a=_(this,Jg))==null||a.setAttribute("data-l10n-id",_(vi,Yd)[`${_(this,Qs,Ny)}-label`]),!_(this,wa)){(i=_(this,Ql))==null||i.remove();return}}else{if(!_(this,wa)&&!_(this,Xl)){e.classList.remove("done"),(o=_(this,Ql))==null||o.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=_(this,Ql);if(!n){L(this,Ql,n=document.createElement("span")),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${_(this,qi).id}`;const s=100,l=_(this,qi)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(_(this,To)),L(this,To,null)},{once:!0}),e.addEventListener("mouseenter",()=>{L(this,To,setTimeout(()=>{L(this,To,null),_(this,Ql).classList.add("show"),_(this,qi)._reportTelemetry({action:"alt_text_tooltip"})},s))},{signal:l}),e.addEventListener("mouseleave",()=>{var u;_(this,To)&&(clearTimeout(_(this,To)),L(this,To,null)),(u=_(this,Ql))==null||u.classList.remove("show")},{signal:l})}_(this,Xl)?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=_(this,wa)),n.parentNode||e.append(n);const r=_(this,qi).getElementForAltText();r==null||r.setAttribute("aria-describedby",n.id)},V(vi,Yd,null),Ue(vi,"_l10n",null);let QA=vi;class ZA{constructor(e){V(this,SS);V(this,qa,null);V(this,ps,null);V(this,Yf,!1);V(this,dr,null);V(this,ES,null);V(this,Vf,null);V(this,Zs,null);V(this,jf,null);V(this,Wf,!1);V(this,Kf,null);L(this,dr,e)}renderForToolbar(){const e=L(this,ps,document.createElement("button"));return e.className="comment",Q(this,SS,_7).call(this,e,!1)}renderForStandalone(){const e=L(this,qa,document.createElement("button"));e.className="annotationCommentButton";const n=_(this,dr).commentButtonPosition;if(n){const{style:r}=e;r.insetInlineEnd=`calc(${100*(_(this,dr)._uiManager.direction==="ltr"?1-n[0]:n[0])}% - var(--comment-button-dim))`,r.top=`calc(${100*n[1]}% - var(--comment-button-dim))`;const a=_(this,dr).commentButtonColor;a&&(r.backgroundColor=a)}return Q(this,SS,_7).call(this,e,!0)}focusButton(){setTimeout(()=>{var e;(e=_(this,qa)??_(this,ps))==null||e.focus()},0)}onUpdatedColor(){if(!_(this,qa))return;const e=_(this,dr).commentButtonColor;e&&(_(this,qa).style.backgroundColor=e),_(this,dr)._uiManager.updatePopupColor(_(this,dr))}get commentButtonWidth(){var e;return(((e=_(this,qa))==null?void 0:e.getBoundingClientRect().width)??0)/_(this,dr).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(_(this,Kf))return _(this,Kf);if(!_(this,qa))return null;const{x:e,y:n,height:r}=_(this,qa).getBoundingClientRect(),{x:a,y:i,width:o,height:s}=_(this,dr).parent.boundingClientRect;return[(e-a)/o,(n+r-i)/s]}set commentPopupPositionInLayer(e){L(this,Kf,e)}hasDefaultPopupPosition(){return _(this,Kf)===null}removeStandaloneCommentButton(){var e;(e=_(this,qa))==null||e.remove(),L(this,qa,null)}removeToolbarCommentButton(){var e;(e=_(this,ps))==null||e.remove(),L(this,ps,null)}setCommentButtonStates({selected:e,hasPopup:n}){_(this,qa)&&(_(this,qa).classList.toggle("selected",e),_(this,qa).ariaExpanded=n)}edit(e){const n=this.commentPopupPositionInLayer;let r,a;if(n)[r,a]=n;else{[r,a]=_(this,dr).commentButtonPosition;const{width:d,height:f,x:m,y:h}=_(this,dr);r=m+r*d,a=h+a*f}const i=_(this,dr).parent.boundingClientRect,{x:o,y:s,width:l,height:u}=i;_(this,dr)._uiManager.editComment(_(this,dr),o+r*l,s+a*u,{...e,parentDimensions:i})}finish(){_(this,ps)&&(_(this,ps).focus({focusVisible:_(this,Yf)}),L(this,Yf,!1))}isDeleted(){return _(this,Wf)||_(this,Zs)===""}isEmpty(){return _(this,Zs)===null}hasBeenEdited(){return this.isDeleted()||_(this,Zs)!==_(this,ES)}serialize(){return this.data}get data(){return{text:_(this,Zs),richText:_(this,Vf),date:_(this,jf),deleted:this.isDeleted()}}set data(e){if(e!==_(this,Zs)&&L(this,Vf,null),e===null){L(this,Zs,""),L(this,Wf,!0);return}L(this,Zs,e),L(this,jf,new Date),L(this,Wf,!1)}setInitialText(e,n=null){L(this,ES,e),this.data=e,L(this,jf,null),L(this,Vf,n)}shown(){}destroy(){var e,n;(e=_(this,ps))==null||e.remove(),L(this,ps,null),(n=_(this,qa))==null||n.remove(),L(this,qa,null),L(this,Zs,""),L(this,Vf,null),L(this,jf,null),L(this,dr,null),L(this,Yf,!1),L(this,Wf,!1)}}qa=new WeakMap,ps=new WeakMap,Yf=new WeakMap,dr=new WeakMap,ES=new WeakMap,Vf=new WeakMap,Zs=new WeakMap,jf=new WeakMap,Wf=new WeakMap,Kf=new WeakMap,SS=new WeakSet,_7=function(e,n){if(!_(this,dr)._uiManager.hasCommentManager())return null;e.tabIndex="0",e.ariaHasPopup="dialog",n?(e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(e.ariaControlsElements=[_(this,dr)._uiManager.getCommentDialogElement()],e.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const r=_(this,dr)._uiManager._signal;if(!(r instanceof AbortSignal)||r.aborted)return e;e.addEventListener("contextmenu",So,{signal:r}),n&&(e.addEventListener("focusin",i=>{_(this,dr)._focusEventsAllowed=!1,Or(i)},{capture:!0,signal:r}),e.addEventListener("focusout",i=>{_(this,dr)._focusEventsAllowed=!0,Or(i)},{capture:!0,signal:r})),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:r});const a=i=>{i.preventDefault(),e===_(this,ps)?this.edit():_(this,dr).toggleComment(!0)};return e.addEventListener("click",a,{capture:!0,signal:r}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(L(this,Yf,!0),a(i))},{signal:r}),e.addEventListener("pointerenter",()=>{_(this,dr).toggleComment(!1,!0)},{signal:r}),e.addEventListener("pointerleave",()=>{_(this,dr).toggleComment(!1,!1)},{signal:r}),e};const a6=class a6{constructor({container:e,isPinchingDisabled:n=null,isPinchingStopped:r=null,onPinchStart:a=null,onPinching:i=null,onPinchEnd:o=null,signal:s}){V(this,Vd);V(this,t_);V(this,Xf,!1);V(this,vS,null);V(this,yS);V(this,TS);V(this,CS);V(this,AS);V(this,eu,null);V(this,Qf);V(this,tu,null);V(this,Zf);V(this,nu,null);L(this,t_,e),L(this,vS,r),L(this,yS,n),L(this,TS,a),L(this,CS,i),L(this,AS,o),L(this,Zf,new AbortController),L(this,Qf,AbortSignal.any([s,_(this,Zf).signal])),e.addEventListener("touchstart",Q(this,Vd,Ome).bind(this),{passive:!1,signal:_(this,Qf)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ks.pixelRatio}destroy(){var e,n;(e=_(this,Zf))==null||e.abort(),L(this,Zf,null),(n=_(this,eu))==null||n.abort(),L(this,eu,null)}};t_=new WeakMap,Xf=new WeakMap,vS=new WeakMap,yS=new WeakMap,TS=new WeakMap,CS=new WeakMap,AS=new WeakMap,eu=new WeakMap,Qf=new WeakMap,tu=new WeakMap,Zf=new WeakMap,nu=new WeakMap,Vd=new WeakSet,Ome=function(e){var a,i,o;if((a=_(this,yS))!=null&&a.call(this))return;if(e.touches.length===1){if(_(this,eu))return;const s=L(this,eu,new AbortController),l=AbortSignal.any([_(this,Qf),s.signal]),u=_(this,t_),d={capture:!0,signal:l,passive:!1},f=m=>{var h;m.pointerType==="touch"&&((h=_(this,eu))==null||h.abort(),L(this,eu,null))};u.addEventListener("pointerdown",m=>{m.pointerType==="touch"&&(Or(m),f(m))},d),u.addEventListener("pointerup",f,d),u.addEventListener("pointercancel",f,d);return}if(!_(this,nu)){L(this,nu,new AbortController);const s=AbortSignal.any([_(this,Qf),_(this,nu).signal]),l=_(this,t_),u={signal:s,capture:!1,passive:!1};l.addEventListener("touchmove",Q(this,Vd,Ime).bind(this),u);const d=Q(this,Vd,Dme).bind(this);l.addEventListener("touchend",d,u),l.addEventListener("touchcancel",d,u),u.capture=!0,l.addEventListener("pointerdown",Or,u),l.addEventListener("pointermove",Or,u),l.addEventListener("pointercancel",Or,u),l.addEventListener("pointerup",Or,u),(i=_(this,TS))==null||i.call(this)}if(Or(e),e.touches.length!==2||(o=_(this,vS))!=null&&o.call(this)){L(this,tu,null);return}let[n,r]=e.touches;n.identifier>r.identifier&&([n,r]=[r,n]),L(this,tu,{touch0X:n.screenX,touch0Y:n.screenY,touch1X:r.screenX,touch1Y:r.screenY})},Ime=function(e){var w;if(!_(this,tu)||e.touches.length!==2)return;Or(e);let[n,r]=e.touches;n.identifier>r.identifier&&([n,r]=[r,n]);const{screenX:a,screenY:i}=n,{screenX:o,screenY:s}=r,l=_(this,tu),{touch0X:u,touch0Y:d,touch1X:f,touch1Y:m}=l,h=f-u,E=m-d,b=o-a,y=s-i,v=Math.hypot(b,y)||1,C=Math.hypot(h,E)||1;if(!_(this,Xf)&&Math.abs(C-v)<=a6.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=a,l.touch0Y=i,l.touch1X=o,l.touch1Y=s,!_(this,Xf)){L(this,Xf,!0);return}const T=[(a+o)/2,(i+s)/2];(w=_(this,CS))==null||w.call(this,T,C,v)},Dme=function(e){var n;e.touches.length>=2||(_(this,nu)&&(_(this,nu).abort(),L(this,nu,null),(n=_(this,AS))==null||n.call(this)),_(this,tu)&&(Or(e),L(this,tu,null),L(this,Xf,!1)))};let YE=a6;const Mt=class Mt{constructor(e){V(this,Ct);V(this,Jf,null);V(this,Js,null);V(this,Sr,null);V(this,nr,null);V(this,ru,null);V(this,n_,!1);V(this,jd,null);V(this,RS,"");V(this,Ha,null);V(this,em,null);V(this,au,null);V(this,ec,null);V(this,Wd,null);V(this,wS,"");V(this,tm,!1);V(this,Co,null);V(this,xS,!1);V(this,nm,!1);V(this,iu,!1);V(this,tc,null);V(this,r_,0);V(this,a_,0);V(this,fs,null);V(this,rm,null);Ue(this,"isSelected",!1);Ue(this,"_isCopy",!1);Ue(this,"_editToolbar",null);Ue(this,"_initialOptions",Object.create(null));Ue(this,"_initialData",null);Ue(this,"_isVisible",!0);Ue(this,"_uiManager",null);Ue(this,"_focusEventsAllowed",!0);V(this,NS,!1);V(this,wR,Mt._zIndex++);this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null;const{rotation:n,rawDims:{pageWidth:r,pageHeight:a,pageX:i,pageY:o}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,a],this.pageTranslation=[i,o];const[s,l]=this.parentDimensions;this.x=e.x/s,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=Mt.prototype._resizeWithKeyboard,n=Nd.TRANSLATE_SMALL,r=Nd.TRANSLATE_BIG;return Ht(this,"_resizerKeyboardManager",new $E([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,r]}],[["Escape","mac+Escape"],Mt.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return Ht(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const n=new GYe({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});n.annotationElementId=e.annotationElementId,n.deleted=!0,n._uiManager.addToAnnotationStorage(n)}static initialize(e,n){if(Mt._l10n??(Mt._l10n=e),Mt._l10nResizer||(Mt._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),Mt._borderLineWidth!==-1)return;const r=getComputedStyle(document.documentElement);Mt._borderLineWidth=parseFloat(r.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,n){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,n){er("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _(this,NS)}set _isDraggable(e){var n;L(this,NS,e),(n=this.div)==null||n.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[e,n]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*n/(e*2),this.y+=this.width*e/(n*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*n/(e*2),this.y-=this.width*e/(n*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=_(this,wR)}setParent(e){var n;e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):(Q(this,Ct,Oy).call(this),(n=_(this,ec))==null||n.remove(),L(this,ec,null)),this.parent=e}focusin(e){this._focusEventsAllowed&&(_(this,tm)?L(this,tm,!1):this.parent.setSelected(this))}focusout(e){var r;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const n=e.relatedTarget;n!=null&&n.closest(`#${this.id}`)||(e.preventDefault(),(r=this.parent)!=null&&r.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,n,r,a){const[i,o]=this.parentDimensions;[r,a]=this.screenToPageTranslation(r,a),this.x=(e+r)/i,this.y=(n+a)/o,this.fixAndSetPosition()}_moveAfterPaste(e,n){const[r,a]=this.parentDimensions;this.setAt(e*r,n*a,this.width*r,this.height*a),this._onTranslated()}translate(e,n){Q(this,Ct,b7).call(this,this.parentDimensions,e,n)}translateInPage(e,n){_(this,Co)||L(this,Co,[this.x,this.y,this.width,this.height]),Q(this,Ct,b7).call(this,this.pageDimensions,e,n),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,n){_(this,Co)||L(this,Co,[this.x,this.y,this.width,this.height]);const{div:r,parentDimensions:[a,i]}=this;if(this.x+=e/a,this.y+=n/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:f,y:m}=this.div.getBoundingClientRect();this.parent.findNewParent(this,f,m)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:s}=this;const[l,u]=this.getBaseTranslation();o+=l,s+=u;const{style:d}=r;d.left=`${(100*o).toFixed(2)}%`,d.top=`${(100*s).toFixed(2)}%`,this._onTranslating(o,s),r.scrollIntoView({block:"nearest"})}_onTranslating(e,n){}_onTranslated(e,n){}get _hasBeenMoved(){return!!_(this,Co)&&(_(this,Co)[0]!==this.x||_(this,Co)[1]!==this.y)}get _hasBeenResized(){return!!_(this,Co)&&(_(this,Co)[2]!==this.width||_(this,Co)[3]!==this.height)}getBaseTranslation(){const[e,n]=this.parentDimensions,{_borderLineWidth:r}=Mt,a=r/e,i=r/n;switch(this.rotation){case 90:return[-a,i];case 180:return[a,i];case 270:return[a,-i];default:return[-a,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:n},pageDimensions:[r,a]}=this;let{x:i,y:o,width:s,height:l}=this;if(s*=r,l*=a,i*=r,o*=a,this._mustFixPosition)switch(e){case 0:i=ri(i,0,r-s),o=ri(o,0,a-l);break;case 90:i=ri(i,0,r-l),o=ri(o,s,a);break;case 180:i=ri(i,s,r),o=ri(o,l,a);break;case 270:i=ri(i,l,r),o=ri(o,0,a-s);break}this.x=i/=r,this.y=o/=a;const[u,d]=this.getBaseTranslation();i+=u,o+=d,n.left=`${(100*i).toFixed(2)}%`,n.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,n){var r;return Q(r=Mt,OS,E7).call(r,e,n,this.parentRotation)}pageTranslationToScreen(e,n){var r;return Q(r=Mt,OS,E7).call(r,e,n,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[n,r]}=this;return[n*e,r*e]}setDims(){const{div:{style:e},width:n,height:r}=this;e.width=`${(100*n).toFixed(2)}%`,e.height=`${(100*r).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=_(this,Sr))==null||e.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||_(this,nm))return this._editToolbar;this._editToolbar=new vB(this),this.div.append(this._editToolbar.render());const{toolbarButtons:e}=this;if(e)for(const[n,r]of e)await this._editToolbar.addButton(n,r);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var e;(e=this._editToolbar)==null||e.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var e;(e=this._editToolbar)==null||e.removeButton("comment")}removeEditToolbar(){var e,n;(e=this._editToolbar)==null||e.remove(),this._editToolbar=null,(n=_(this,Sr))==null||n.destroy()}addContainer(e){var r;const n=(r=this._editToolbar)==null?void 0:r.div;n?n.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return _(this,Sr)||(QA.initialize(Mt._l10n),L(this,Sr,new QA(this)),_(this,Jf)&&(_(this,Sr).data=_(this,Jf),L(this,Jf,null))),_(this,Sr)}get altTextData(){var e;return(e=_(this,Sr))==null?void 0:e.data}set altTextData(e){_(this,Sr)&&(_(this,Sr).data=e)}get guessedAltText(){var e;return(e=_(this,Sr))==null?void 0:e.guessedText}async setGuessedAltText(e){var n;await((n=_(this,Sr))==null?void 0:n.setGuessedText(e))}serializeAltText(e){var n;return(n=_(this,Sr))==null?void 0:n.serialize(e)}hasAltText(){return!!_(this,Sr)&&!_(this,Sr).isEmpty()}hasAltTextData(){var e;return((e=_(this,Sr))==null?void 0:e.hasData())??!1}focusCommentButton(){var e;(e=_(this,nr))==null||e.focusButton()}addCommentButton(){return _(this,nr)||L(this,nr,new ZA(this))}addStandaloneCommentButton(){if(_(this,ru)){this._uiManager.isEditingMode()&&_(this,ru).classList.remove("hidden");return}this.hasComment&&(L(this,ru,_(this,nr).renderForStandalone()),this.div.append(_(this,ru)))}removeStandaloneCommentButton(){_(this,nr).removeStandaloneCommentButton(),L(this,ru,null)}hideStandaloneCommentButton(){var e;(e=_(this,ru))==null||e.classList.add("hidden")}get comment(){const{data:{richText:e,text:n,date:r,deleted:a}}=_(this,nr);return{text:n,richText:e,date:r,deleted:a,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){_(this,nr)||L(this,nr,new ZA(this)),_(this,nr).data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:n,richText:r}){if(!n||(_(this,nr)||L(this,nr,new ZA(this)),_(this,nr).setInitialText(e,r),!this.annotationElementId))return;const a=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);a&&this.updateFromAnnotationLayer(a)}get hasEditedComment(){var e;return(e=_(this,nr))==null?void 0:e.hasBeenEdited()}get hasDeletedComment(){var e;return(e=_(this,nr))==null?void 0:e.isDeleted()}get hasComment(){return!!_(this,nr)&&!_(this,nr).isEmpty()&&!_(this,nr).isDeleted()}async editComment(e){_(this,nr)||L(this,nr,new ZA(this)),_(this,nr).edit(e)}toggleComment(e,n=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,n)}setSelectedCommentButton(e){_(this,nr).setSelectedButton(e)}addComment(e){if(this.hasEditedComment){const[,,,a]=e.rect,[i]=this.pageDimensions,[o]=this.pageTranslation,s=o+i+1,l=a-100,u=s+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[s,l,u,a]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:n}}){_(this,nr).data=n?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var o;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=_(this,n_)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),Q(this,Ct,T7).call(this);const[n,r]=this.parentDimensions;this.parentRotation%180!==0&&(e.style.maxWidth=`${(100*r/n).toFixed(2)}%`,e.style.maxHeight=`${(100*n/r).toFixed(2)}%`);const[a,i]=this.getInitialTranslation();return this.translate(a,i),yce(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_(this,rm)||L(this,rm,new YE({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:Q(this,Ct,Lme).bind(this),onPinching:Q(this,Ct,Pme).bind(this),onPinchEnd:Q(this,Ct,Fme).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(o=this._uiManager._editorUndoBar)==null||o.hide(),e}pointerdown(e){const{isMac:n}=Ra.platform;if(e.button!==0||e.ctrlKey&&n){e.preventDefault();return}if(L(this,tm,!0),this._isDraggable){Q(this,Ct,Bme).call(this,e);return}Q(this,Ct,y7).call(this,e)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_(this,tc)&&clearTimeout(_(this,tc)),L(this,tc,setTimeout(()=>{var e;L(this,tc,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,n,r){e.changeParent(this),this.x=n,this.y=r,this.fixAndSetPosition(),this._onTranslated()}getRect(e,n,r=this.rotation){const a=this.parentScale,[i,o]=this.pageDimensions,[s,l]=this.pageTranslation,u=e/a,d=n/a,f=this.x*i,m=this.y*o,h=this.width*i,E=this.height*o;switch(r){case 0:return[f+u+s,o-m-d-E+l,f+u+h+s,o-m-d+l];case 90:return[f+d+s,o-m+u+l,f+d+E+s,o-m+u+h+l];case 180:return[f-u-h+s,o-m+d+l,f-u+s,o-m+d+E+l];case 270:return[f-d-E+s,o-m-u-h+l,f-d+s,o-m-u+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,n){const[r,a,i,o]=e,s=i-r,l=o-a;switch(this.rotation){case 0:return[r,n-o,s,l];case 90:return[r,n-a,l,s];case 180:return[i,n-a,s,l];case 270:return[i,n-o,l,s];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&Mt._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var e;(e=_(this,nr))==null||e.onUpdatedColor()}getData(){const{comment:{text:e,color:n,date:r,opacity:a,deleted:i,richText:o},uid:s,pageIndex:l,creationDate:u,modificationDate:d}=this;return{id:s,pageIndex:l,rect:this.getPDFRect(),richText:o,contentsObj:{str:e},creationDate:u,modificationDate:r||d,popupRef:!i,color:n,opacity:a}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),L(this,nm,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),L(this,nm,!1),!0):!1}isInEditMode(){return _(this,nm)}shouldGetKeyboardEvents(){return _(this,iu)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:n,bottom:r,right:a}=this.getClientDimensions(),{innerHeight:i,innerWidth:o}=window;return n<o&&a>0&&e<i&&r>0}rebuild(){Q(this,Ct,T7).call(this)}rotate(e){}resize(){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||""}}serialize(e=!1,n=null){var r;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((r=this._initialData)==null?void 0:r.popupRef)||""}}static async deserialize(e,n,r){const a=new this.prototype.constructor({parent:n,id:n.getNextId(),uiManager:r,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});a.rotation=e.rotation,L(a,Jf,e.accessibilityData),a._isCopy=e.isCopy||!1;const[i,o]=a.pageDimensions,[s,l,u,d]=a.getRectInCurrentCoords(e.rect,o);return a.x=s/i,a.y=l/o,a.width=u/i,a.height=d/o,a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e,n;if((e=_(this,Wd))==null||e.abort(),L(this,Wd,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_(this,tc)&&(clearTimeout(_(this,tc)),L(this,tc,null)),Q(this,Ct,Oy).call(this),this.removeEditToolbar(),_(this,fs)){for(const r of _(this,fs).values())clearTimeout(r);L(this,fs,null)}this.parent=null,(n=_(this,rm))==null||n.destroy(),L(this,rm,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(Q(this,Ct,kme).call(this),_(this,Ha).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,n]}=this,[r,a,i,o]=this.getPDFRect();return[Mt._round(r+(i-r)*e),Mt._round(a+(o-a)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return _(this,nr).commentPopupPositionInLayer}set commentPopupPosition(e){_(this,nr).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return _(this,nr).hasDefaultPopupPosition()}get commentButtonWidth(){return _(this,nr).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){_(this,nr).setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),L(this,au,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=_(this,Ha).children;if(!_(this,Js)){L(this,Js,Array.from(n));const o=Q(this,Ct,Ume).bind(this),s=Q(this,Ct,Gme).bind(this),l=this._uiManager._signal;for(const u of _(this,Js)){const d=u.getAttribute("data-resizer-name");u.setAttribute("role","spinbutton"),u.addEventListener("keydown",o,{signal:l}),u.addEventListener("blur",s,{signal:l}),u.addEventListener("focus",Q(this,Ct,zme).bind(this,d),{signal:l}),u.setAttribute("data-l10n-id",Mt._l10nResizer[d])}}const r=_(this,Js)[0];let a=0;for(const o of n){if(o===r)break;a++}const i=(360-this.rotation+this.parentRotation)%360/90*(_(this,Js).length/4);if(i!==a){if(i<a)for(let s=0;s<a-i;s++)_(this,Ha).append(_(this,Ha).firstChild);else if(i>a)for(let s=0;s<i-a;s++)_(this,Ha).firstChild.before(_(this,Ha).lastChild);let o=0;for(const s of n){const u=_(this,Js)[o++].getAttribute("data-resizer-name");s.setAttribute("data-l10n-id",Mt._l10nResizer[u])}}Q(this,Ct,C7).call(this,0),L(this,iu,!0),_(this,Ha).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(e,n){_(this,iu)&&Q(this,Ct,v7).call(this,_(this,wS),{deltaX:e,deltaY:n,fromKeyboard:!0})}_stopResizingWithKeyboard(){Q(this,Ct,Oy).call(this),this.div.focus()}select(){var e,n,r;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(e=this.div)==null||e.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var a,i;(a=this.div)!=null&&a.classList.contains("selectedEditor")&&((i=this._editToolbar)==null||i.show())});return}(n=this._editToolbar)==null||n.show(),(r=_(this,Sr))==null||r.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var e;return(e=this.div)==null?void 0:e.focus({preventScroll:!0})},0)}unselect(){var e,n,r,a,i;this.isSelected&&(this.isSelected=!1,(e=_(this,Ha))==null||e.classList.add("hidden"),(n=this.div)==null||n.classList.remove("selectedEditor"),(r=this.div)!=null&&r.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(a=this._editToolbar)==null||a.hide(),(i=_(this,Sr))==null||i.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(e,n){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return _(this,xS)}set isEditing(e){L(this,xS,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,n=!1){if(n){_(this,fs)||L(this,fs,new Map);const{action:r}=e;let a=_(this,fs).get(r);a&&clearTimeout(a),a=setTimeout(()=>{this._reportTelemetry(e),_(this,fs).delete(r),_(this,fs).size===0&&L(this,fs,null)},Mt._telemetryTimeout),_(this,fs).set(r,a);return}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),L(this,n_,!1)}disable(){this.div&&(this.div.tabIndex=-1),L(this,n_,!0)}updateFakeAnnotationElement(e){if(!_(this,ec)&&!this.deleted){L(this,ec,e.addFakeAnnotation(this));return}if(this.deleted){_(this,ec).remove(),L(this,ec,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&_(this,ec).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let n=e.container.querySelector(".annotationContent");if(!n)n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),e.container.prepend(n);else if(n.nodeName==="CANVAS"){const r=n;n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),r.before(n)}return n}resetAnnotationElement(e){const{firstChild:n}=e.container;(n==null?void 0:n.nodeName)==="DIV"&&n.classList.contains("annotationContent")&&n.remove()}};Jf=new WeakMap,Js=new WeakMap,Sr=new WeakMap,nr=new WeakMap,ru=new WeakMap,n_=new WeakMap,jd=new WeakMap,RS=new WeakMap,Ha=new WeakMap,em=new WeakMap,au=new WeakMap,ec=new WeakMap,Wd=new WeakMap,wS=new WeakMap,tm=new WeakMap,Co=new WeakMap,xS=new WeakMap,nm=new WeakMap,iu=new WeakMap,tc=new WeakMap,r_=new WeakMap,a_=new WeakMap,fs=new WeakMap,rm=new WeakMap,NS=new WeakMap,wR=new WeakMap,Ct=new WeakSet,b7=function([e,n],r,a){[r,a]=this.screenToPageTranslation(r,a),this.x+=r/e,this.y+=a/n,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},OS=new WeakSet,E7=function(e,n,r){switch(r){case 90:return[n,-e];case 180:return[-e,-n];case 270:return[-n,e];default:return[e,n]}},J1=function(e){switch(e){case 90:{const[n,r]=this.pageDimensions;return[0,-n/r,r/n,0]}case 180:return[-1,0,0,-1];case 270:{const[n,r]=this.pageDimensions;return[0,n/r,-r/n,0]}default:return[1,0,0,1]}},kme=function(){if(_(this,Ha))return;L(this,Ha,document.createElement("div")),_(this,Ha).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],n=this._uiManager._signal;for(const r of e){const a=document.createElement("div");_(this,Ha).append(a),a.classList.add("resizer",r),a.setAttribute("data-resizer-name",r),a.addEventListener("pointerdown",Q(this,Ct,Mme).bind(this,r),{signal:n}),a.addEventListener("contextmenu",So,{signal:n}),a.tabIndex=-1}this.div.prepend(_(this,Ha))},Mme=function(e,n){var d;n.preventDefault();const{isMac:r}=Ra.platform;if(n.button!==0||n.ctrlKey&&r)return;(d=_(this,Sr))==null||d.toggle(!1);const a=this._isDraggable;this._isDraggable=!1,L(this,em,[n.screenX,n.screenY]);const i=new AbortController,o=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",Q(this,Ct,v7).bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener("touchmove",Or,{passive:!1,signal:o}),window.addEventListener("contextmenu",So,{signal:o}),L(this,au,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const s=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(n.target).cursor;const u=()=>{var f;i.abort(),this.parent.togglePointerEvents(!0),(f=_(this,Sr))==null||f.toggle(!0),this._isDraggable=a,this.parent.div.style.cursor=s,this.div.style.cursor=l,Q(this,Ct,ew).call(this)};window.addEventListener("pointerup",u,{signal:o}),window.addEventListener("blur",u,{signal:o})},S7=function(e,n,r,a){this.width=r,this.height=a,this.x=e,this.y=n,this.setDims(),this.fixAndSetPosition(),this._onResized()},ew=function(){if(!_(this,au))return;const{savedX:e,savedY:n,savedWidth:r,savedHeight:a}=_(this,au);L(this,au,null);const i=this.x,o=this.y,s=this.width,l=this.height;i===e&&o===n&&s===r&&l===a||this.addCommands({cmd:Q(this,Ct,S7).bind(this,i,o,s,l),undo:Q(this,Ct,S7).bind(this,e,n,r,a),mustExec:!0})},v7=function(e,n){const[r,a]=this.parentDimensions,i=this.x,o=this.y,s=this.width,l=this.height,u=Mt.MIN_SIZE/r,d=Mt.MIN_SIZE/a,f=Q(this,Ct,J1).call(this,this.rotation),m=(G,Y)=>[f[0]*G+f[2]*Y,f[1]*G+f[3]*Y],h=Q(this,Ct,J1).call(this,360-this.rotation),E=(G,Y)=>[h[0]*G+h[2]*Y,h[1]*G+h[3]*Y];let b,y,v=!1,C=!1;switch(e){case"topLeft":v=!0,b=(G,Y)=>[0,0],y=(G,Y)=>[G,Y];break;case"topMiddle":b=(G,Y)=>[G/2,0],y=(G,Y)=>[G/2,Y];break;case"topRight":v=!0,b=(G,Y)=>[G,0],y=(G,Y)=>[0,Y];break;case"middleRight":C=!0,b=(G,Y)=>[G,Y/2],y=(G,Y)=>[0,Y/2];break;case"bottomRight":v=!0,b=(G,Y)=>[G,Y],y=(G,Y)=>[0,0];break;case"bottomMiddle":b=(G,Y)=>[G/2,Y],y=(G,Y)=>[G/2,0];break;case"bottomLeft":v=!0,b=(G,Y)=>[0,Y],y=(G,Y)=>[G,0];break;case"middleLeft":C=!0,b=(G,Y)=>[0,Y/2],y=(G,Y)=>[G,Y/2];break}const T=b(s,l),w=y(s,l);let I=m(...w);const x=Mt._round(i+I[0]),D=Mt._round(o+I[1]);let M=1,F=1,P,q;if(n.fromKeyboard)({deltaX:P,deltaY:q}=n);else{const{screenX:G,screenY:Y}=n,[K,J]=_(this,em);[P,q]=this.screenToPageTranslation(G-K,Y-J),_(this,em)[0]=G,_(this,em)[1]=Y}if([P,q]=E(P/r,q/a),v){const G=Math.hypot(s,l);M=F=Math.max(Math.min(Math.hypot(w[0]-T[0]-P,w[1]-T[1]-q)/G,1/s,1/l),u/s,d/l)}else C?M=ri(Math.abs(w[0]-T[0]-P),u,1)/s:F=ri(Math.abs(w[1]-T[1]-q),d,1)/l;const j=Mt._round(s*M),X=Mt._round(l*F);I=m(...y(j,X));const B=x-I[0],W=D-I[1];_(this,Co)||L(this,Co,[this.x,this.y,this.width,this.height]),this.width=j,this.height=X,this.x=B,this.y=W,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Lme=function(){var e;L(this,au,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=_(this,Sr))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)},Pme=function(e,n,r){let i=.7*(r/n)+1-.7;if(i===1)return;const o=Q(this,Ct,J1).call(this,this.rotation),s=(x,D)=>[o[0]*x+o[2]*D,o[1]*x+o[3]*D],[l,u]=this.parentDimensions,d=this.x,f=this.y,m=this.width,h=this.height,E=Mt.MIN_SIZE/l,b=Mt.MIN_SIZE/u;i=Math.max(Math.min(i,1/m,1/h),E/m,b/h);const y=Mt._round(m*i),v=Mt._round(h*i);if(y===m&&v===h)return;_(this,Co)||L(this,Co,[d,f,m,h]);const C=s(m/2,h/2),T=Mt._round(d+C[0]),w=Mt._round(f+C[1]),I=s(y/2,v/2);this.x=T-I[0],this.y=w-I[1],this.width=y,this.height=v,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Fme=function(){var e;(e=_(this,Sr))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),Q(this,Ct,ew).call(this)},y7=function(e){const{isMac:n}=Ra.platform;e.ctrlKey&&!n||e.shiftKey||e.metaKey&&n?this.parent.toggleSelected(this):this.parent.setSelected(this)},Bme=function(e){const{isSelected:n}=this;this._uiManager.setUpDragSession();let r=!1;const a=new AbortController,i=this._uiManager.combinedSignal(a),o={capture:!0,passive:!1,signal:i},s=u=>{a.abort(),L(this,jd,null),L(this,tm,!1),this._uiManager.endDragSession()||Q(this,Ct,y7).call(this,u),r&&this._onStopDragging()};n&&(L(this,r_,e.clientX),L(this,a_,e.clientY),L(this,jd,e.pointerId),L(this,RS,e.pointerType),window.addEventListener("pointermove",u=>{r||(r=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:d,clientY:f,pointerId:m}=u;if(m!==_(this,jd)){Or(u);return}const[h,E]=this.screenToPageTranslation(d-_(this,r_),f-_(this,a_));L(this,r_,d),L(this,a_,f),this._uiManager.dragSelectedEditors(h,E)},o),window.addEventListener("touchmove",Or,o),window.addEventListener("pointerdown",u=>{u.pointerType===_(this,RS)&&(_(this,rm)||u.isPrimary)&&s(u),Or(u)},o));const l=u=>{if(!_(this,jd)||_(this,jd)===u.pointerId){s(u);return}Or(u)};window.addEventListener("pointerup",l,{signal:i}),window.addEventListener("blur",l,{signal:i})},T7=function(){if(_(this,Wd)||!this.div)return;L(this,Wd,new AbortController);const e=this._uiManager.combinedSignal(_(this,Wd));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},Ume=function(e){Mt._resizerKeyboardManager.exec(this,e)},Gme=function(e){var n;_(this,iu)&&((n=e.relatedTarget)==null?void 0:n.parentNode)!==_(this,Ha)&&Q(this,Ct,Oy).call(this)},zme=function(e){L(this,wS,_(this,iu)?e:"")},C7=function(e){if(_(this,Js))for(const n of _(this,Js))n.tabIndex=e},Oy=function(){L(this,iu,!1),Q(this,Ct,C7).call(this,-1),Q(this,Ct,ew).call(this)},V(Mt,OS),Ue(Mt,"_l10n",null),Ue(Mt,"_l10nResizer",null),Ue(Mt,"_borderLineWidth",-1),Ue(Mt,"_colorManager",new TB),Ue(Mt,"_zIndex",1),Ue(Mt,"_telemetryTimeout",1e3);let ur=Mt;class GYe extends ur{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Tce=3285377520,rs=4294901760,$l=65535;class Cce{constructor(e){this.h1=e?e&4294967295:Tce,this.h2=e?e&4294967295:Tce}update(e){let n,r;if(typeof e=="string"){n=new Uint8Array(e.length*2),r=0;for(let b=0,y=e.length;b<y;b++){const v=e.charCodeAt(b);v<=255?n[r++]=v:(n[r++]=v>>>8,n[r++]=v&255)}}else if(ArrayBuffer.isView(e))n=e.slice(),r=n.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const a=r>>2,i=r-a*4,o=new Uint32Array(n.buffer,0,a);let s=0,l=0,u=this.h1,d=this.h2;const f=3432918353,m=461845907,h=f&$l,E=m&$l;for(let b=0;b<a;b++)b&1?(s=o[b],s=s*f&rs|s*h&$l,s=s<<15|s>>>17,s=s*m&rs|s*E&$l,u^=s,u=u<<13|u>>>19,u=u*5+3864292196):(l=o[b],l=l*f&rs|l*h&$l,l=l<<15|l>>>17,l=l*m&rs|l*E&$l,d^=l,d=d<<13|d>>>19,d=d*5+3864292196);switch(s=0,i){case 3:s^=n[a*4+2]<<16;case 2:s^=n[a*4+1]<<8;case 1:s^=n[a*4],s=s*f&rs|s*h&$l,s=s<<15|s>>>17,s=s*m&rs|s*E&$l,a&1?u^=s:d^=s}this.h1=u,this.h2=d}hexdigest(){let e=this.h1,n=this.h2;return e^=n>>>1,e=e*3981806797&rs|e*36045&$l,n=n*4283543511&rs|((n<<16|e>>>16)*2950163797&rs)>>>16,e^=n>>>1,e=e*444984403&rs|e*60499&$l,n=n*3301882366&rs|((n<<16|e>>>16)*3120437893&rs)>>>16,e^=n>>>1,(e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}}const CB=Object.freeze({map:null,hash:"",transfer:void 0});class AB{constructor(){V(this,xR);V(this,am,!1);V(this,im,null);V(this,ou,null);V(this,$a,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,n){const r=_(this,$a).get(e);return r===void 0?n:Object.assign(n,r)}getRawValue(e){return _(this,$a).get(e)}remove(e){const n=_(this,$a).get(e);if(n!==void 0&&(n instanceof ur&&_(this,ou).delete(n.annotationElementId),_(this,$a).delete(e),_(this,$a).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const r of _(this,$a).values())if(r instanceof ur)return;this.onAnnotationEditor(null)}}setValue(e,n){const r=_(this,$a).get(e);let a=!1;if(r!==void 0)for(const[i,o]of Object.entries(n))r[i]!==o&&(a=!0,r[i]=o);else a=!0,_(this,$a).set(e,n);a&&Q(this,xR,qme).call(this),n instanceof ur&&((_(this,ou)||L(this,ou,new Map)).set(n.annotationElementId,n),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(n.constructor._type))}has(e){return _(this,$a).has(e)}get size(){return _(this,$a).size}resetModified(){_(this,am)&&(L(this,am,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Ace(this)}get serializable(){if(_(this,$a).size===0)return CB;const e=new Map,n=new Cce,r=[],a=Object.create(null);let i=!1;for(const[o,s]of _(this,$a)){const l=s instanceof ur?s.serialize(!1,a):s;l&&(e.set(o,l),n.update(`${o}:${JSON.stringify(l)}`),i||(i=!!l.bitmap))}if(i)for(const o of e.values())o.bitmap&&r.push(o.bitmap);return e.size>0?{map:e,hash:n.hexdigest(),transfer:r}:CB}get editorStats(){let e=null;const n=new Map;let r=0,a=0;for(const i of _(this,$a).values()){if(!(i instanceof ur)){i.popup&&(i.popup.deleted?a+=1:r+=1);continue}i.isCommentDeleted?a+=1:i.hasEditedComment&&(r+=1);const o=i.telemetryFinalData;if(!o)continue;const{type:s}=o;n.has(s)||n.set(s,Object.getPrototypeOf(i).constructor),e||(e=Object.create(null));const l=e[s]||(e[s]=new Map);for(const[u,d]of Object.entries(o)){if(u==="type")continue;let f=l.get(u);f||(f=new Map,l.set(u,f));const m=f.get(d)??0;f.set(d,m+1)}}if((a>0||r>0)&&(e||(e=Object.create(null)),e.comments={deleted:a,edited:r}),!e)return null;for(const[i,o]of n)e[i]=o.computeTelemetryFinalData(e[i]);return e}resetModifiedIds(){L(this,im,null)}updateEditor(e,n){var a;const r=(a=_(this,ou))==null?void 0:a.get(e);return r?(r.updateFromAnnotationLayer(n),!0):!1}getEditor(e){var n;return((n=_(this,ou))==null?void 0:n.get(e))||null}get modifiedIds(){if(_(this,im))return _(this,im);const e=[];if(_(this,ou))for(const n of _(this,ou).values())n.serialize()&&e.push(n.annotationElementId);return L(this,im,{ids:new Set(e),hash:e.join(",")})}[Symbol.iterator](){return _(this,$a).entries()}}am=new WeakMap,im=new WeakMap,ou=new WeakMap,$a=new WeakMap,xR=new WeakSet,qme=function(){_(this,am)||(L(this,am,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class Ace extends AB{constructor(n){super();V(this,IS);const{map:r,hash:a,transfer:i}=n.serializable,o=structuredClone(r,i?{transfer:i}:null);L(this,IS,{map:o,hash:a,transfer:i})}get print(){er("Should not call PrintAnnotationStorage.print")}get serializable(){return _(this,IS)}get modifiedIds(){return Ht(this,"modifiedIds",{ids:new Set,hash:""})}}IS=new WeakMap;class zYe{constructor({ownerDocument:e=globalThis.document,styleElement:n=null}){V(this,i_,new Set);this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const n=this.styleElement.sheet;n.insertRule(e,n.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),_(this,i_).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,disableFontFace:n,_inspectFont:r}){if(!(!e||_(this,i_).has(e.loadedName))){if(ln(!n,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:a,src:i,style:o}=e,s=new FontFace(a,i,o);this.addNativeFontFace(s);try{await s.load(),_(this,i_).add(a),r==null||r(e)}catch{Dt(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(s)}return}er("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const r=e.createNativeFontFace();if(r){this.addNativeFontFace(r);try{await r.loaded}catch(a){throw Dt(`Failed to load font '${r.family}': '${a}'.`),e.disableFontFace=!0,a}}return}const n=e.createFontFaceRule();if(n){if(this.insertRule(n),this.isSyncFontLoadingSupported)return;await new Promise(r=>{const a=this._queueLoadingCallback(r);this._prepareFontLoadEvent(e,a)})}}get isFontLoadingAPISupported(){var n;const e=!!((n=this._document)!=null&&n.fonts);return Ht(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return Ht(this,"isSyncFontLoadingSupported",Si||Ra.platform.isFirefox)}_queueLoadingCallback(e){function n(){for(ln(!a.done,"completeRequest() cannot be called twice."),a.done=!0;r.length>0&&r[0].done;){const i=r.shift();setTimeout(i.callback,0)}}const{loadingRequests:r}=this,a={done:!1,complete:n,callback:e};return r.push(a),a}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Ht(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,n){function r(w,I){return w.charCodeAt(I)<<24|w.charCodeAt(I+1)<<16|w.charCodeAt(I+2)<<8|w.charCodeAt(I+3)&255}function a(w,I,x,D){const M=w.substring(0,I),F=w.substring(I+x);return M+D+F}let i,o;const s=this._document.createElement("canvas");s.width=1,s.height=1;const l=s.getContext("2d");let u=0;function d(w,I){if(++u>30){Dt("Load test font never loaded."),I();return}if(l.font="30px "+w,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){I();return}setTimeout(d.bind(null,w,I))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let m=this._loadTestFont;m=a(m,976,f.length,f);const E=16,b=1482184792;let y=r(m,E);for(i=0,o=f.length-3;i<o;i+=4)y=y-b+r(f,i)|0;i<f.length&&(y=y-b+r(f+"XXX",i)|0),m=a(m,E,4,xYe(y));const v=`url(data:font/opentype;base64,${btoa(m)});`,C=`@font-face {font-family:"${f}";src:${v}}`;this.insertRule(C);const T=this._document.createElement("div");T.style.visibility="hidden",T.style.width=T.style.height="10px",T.style.position="absolute",T.style.top=T.style.left="0px";for(const w of[e.loadedName,f]){const I=this._document.createElement("span");I.textContent="Hi",I.style.fontFamily=w,T.append(I)}this._document.body.append(T),d(f,()=>{T.remove(),n.complete()})}}i_=new WeakMap;class qYe{constructor(e,n=null,r,a){V(this,Gn);this.compiledGlyphs=Object.create(null),L(this,Gn,e),this._inspectFont=n,r&&Object.assign(this,r),a&&(this.charProcOperatorList=a)}createNativeFontFace(){var n;if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}return(n=this._inspectFont)==null||n.call(this,this),e}createFontFaceRule(){var r;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${uce(this.data)});`;let n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let a=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(a+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${a}src:${e}}`}return(r=this._inspectFont)==null||r.call(this,this,e),n}getPathGenerator(e,n){if(this.compiledGlyphs[n]!==void 0)return this.compiledGlyphs[n];const r=this.loadedName+"_path_"+n;let a;try{a=e.get(r)}catch(o){Dt(`getPathGenerator - ignoring character: "${o}".`)}const i=new Path2D(a||"");return this.fontExtraProperties||e.delete(r),this.compiledGlyphs[n]=i}get black(){return _(this,Gn).black}get bold(){return _(this,Gn).bold}get disableFontFace(){return _(this,Gn).disableFontFace??!1}get fontExtraProperties(){return _(this,Gn).fontExtraProperties??!1}get isInvalidPDFjsFont(){return _(this,Gn).isInvalidPDFjsFont}get isType3Font(){return _(this,Gn).isType3Font}get italic(){return _(this,Gn).italic}get missingFile(){return _(this,Gn).missingFile}get remeasure(){return _(this,Gn).remeasure}get vertical(){return _(this,Gn).vertical}get ascent(){return _(this,Gn).ascent}get defaultWidth(){return _(this,Gn).defaultWidth}get descent(){return _(this,Gn).descent}get bbox(){return _(this,Gn).bbox}get fontMatrix(){return _(this,Gn).fontMatrix}get fallbackName(){return _(this,Gn).fallbackName}get loadedName(){return _(this,Gn).loadedName}get mimetype(){return _(this,Gn).mimetype}get name(){return _(this,Gn).name}get data(){return _(this,Gn).data}clearData(){_(this,Gn).clearData()}get cssFontInfo(){return _(this,Gn).cssFontInfo}get systemFontInfo(){return _(this,Gn).systemFontInfo}get defaultVMetrics(){return _(this,Gn).defaultVMetrics}}Gn=new WeakMap;function HYe(t){if(t instanceof URL)return t.href;if(typeof t=="string"){if(Si)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function $Ye(t){if(Si&&typeof Buffer<"u"&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if(typeof t=="string")return BE(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t=="object"&&!isNaN(t==null?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function JA(t){if(typeof t!="string")return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const RB=t=>typeof t=="object"&&Number.isInteger(t==null?void 0:t.num)&&t.num>=0&&Number.isInteger(t==null?void 0:t.gen)&&t.gen>=0,YYe=t=>typeof t=="object"&&typeof(t==null?void 0:t.name)=="string",Rce=DYe.bind(null,RB,YYe);class VYe{constructor(){V(this,su,new Map);V(this,NR,Promise.resolve())}postMessage(e,n){const r={data:structuredClone(e,n?{transfer:n}:null)};_(this,NR).then(()=>{for(const[a]of _(this,su))a.call(this,r)})}addEventListener(e,n,r=null){let a=null;if((r==null?void 0:r.signal)instanceof AbortSignal){const{signal:i}=r;if(i.aborted){Dt("LoopbackPort - cannot use an `aborted` signal.");return}const o=()=>this.removeEventListener(e,n);a=()=>i.removeEventListener("abort",o),i.addEventListener("abort",o)}_(this,su).set(n,a)}removeEventListener(e,n){const r=_(this,su).get(n);r==null||r(),_(this,su).delete(n)}terminate(){for(const[,e]of _(this,su))e==null||e();_(this,su).clear()}}su=new WeakMap,NR=new WeakMap;const eR={DATA:1,ERROR:2},aa={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function wce(){}function Gi(t){if(t instanceof $c||t instanceof jA||t instanceof oce||t instanceof FE||t instanceof fB)return t;switch(t instanceof Error||typeof t=="object"&&t!==null||er('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new $c(t.message);case"InvalidPDFException":return new jA(t.message);case"PasswordException":return new oce(t.message,t.code);case"ResponseException":return new FE(t.message,t.status,t.missing);case"UnknownErrorException":return new fB(t.message,t.details)}return new fB(t.message,t.toString())}class VE{constructor(e,n,r){V(this,ms);V(this,o_,new AbortController);this.sourceName=e,this.targetName=n,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",Q(this,ms,Hme).bind(this),{signal:_(this,o_).signal})}on(e,n){const r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=n}send(e,n,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:n},r)}sendWithPromise(e,n,r){const a=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[a]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:a,data:n},r)}catch(o){i.reject(o)}return i.promise}sendWithStream(e,n,r,a){const i=this.streamId++,o=this.sourceName,s=this.targetName,l=this.comObj;return new ReadableStream({start:u=>{const d=Promise.withResolvers();return this.streamControllers[i]={controller:u,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:o,targetName:s,action:e,streamId:i,data:n,desiredSize:u.desiredSize},a),d.promise},pull:u=>{const d=Promise.withResolvers();return this.streamControllers[i].pullCall=d,l.postMessage({sourceName:o,targetName:s,stream:aa.PULL,streamId:i,desiredSize:u.desiredSize}),d.promise},cancel:u=>{ln(u instanceof Error,"cancel must have a valid reason");const d=Promise.withResolvers();return this.streamControllers[i].cancelCall=d,this.streamControllers[i].isClosed=!0,l.postMessage({sourceName:o,targetName:s,stream:aa.CANCEL,streamId:i,reason:Gi(u)}),d.promise}},r)}destroy(){var e;(e=_(this,o_))==null||e.abort(),L(this,o_,null)}}o_=new WeakMap,ms=new WeakSet,Hme=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){Q(this,ms,Yme).call(this,e);return}if(e.callback){const r=e.callbackId,a=this.callbackCapabilities[r];if(!a)throw new Error(`Cannot resolve callback ${r}`);if(delete this.callbackCapabilities[r],e.callback===eR.DATA)a.resolve(e.data);else if(e.callback===eR.ERROR)a.reject(Gi(e.reason));else throw new Error("Unexpected callback case");return}const n=this.actionHandler[e.action];if(!n)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const r=this.sourceName,a=e.sourceName,i=this.comObj;Promise.try(n,e.data).then(function(o){i.postMessage({sourceName:r,targetName:a,callback:eR.DATA,callbackId:e.callbackId,data:o})},function(o){i.postMessage({sourceName:r,targetName:a,callback:eR.ERROR,callbackId:e.callbackId,reason:Gi(o)})});return}if(e.streamId){Q(this,ms,$me).call(this,e);return}n(e.data)},$me=function(e){const n=e.streamId,r=this.sourceName,a=e.sourceName,i=this.comObj,o=this,s=this.actionHandler[e.action],l={enqueue(u,d=1,f){if(this.isCancelled)return;const m=this.desiredSize;this.desiredSize-=d,m>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:r,targetName:a,stream:aa.ENQUEUE,streamId:n,chunk:u},f)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:a,stream:aa.CLOSE,streamId:n}),delete o.streamSinks[n])},error(u){ln(u instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:a,stream:aa.ERROR,streamId:n,reason:Gi(u)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[n]=l,Promise.try(s,e.data,l).then(function(){i.postMessage({sourceName:r,targetName:a,stream:aa.START_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:aa.START_COMPLETE,streamId:n,reason:Gi(u)})})},Yme=function(e){const n=e.streamId,r=this.sourceName,a=e.sourceName,i=this.comObj,o=this.streamControllers[n],s=this.streamSinks[n];switch(e.stream){case aa.START_COMPLETE:e.success?o.startCall.resolve():o.startCall.reject(Gi(e.reason));break;case aa.PULL_COMPLETE:e.success?o.pullCall.resolve():o.pullCall.reject(Gi(e.reason));break;case aa.PULL:if(!s){i.postMessage({sourceName:r,targetName:a,stream:aa.PULL_COMPLETE,streamId:n,success:!0});break}s.desiredSize<=0&&e.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=e.desiredSize,Promise.try(s.onPull||wce).then(function(){i.postMessage({sourceName:r,targetName:a,stream:aa.PULL_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:aa.PULL_COMPLETE,streamId:n,reason:Gi(u)})});break;case aa.ENQUEUE:if(ln(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case aa.CLOSE:if(ln(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),Q(this,ms,tw).call(this,o,n);break;case aa.ERROR:ln(o,"error should have stream controller"),o.controller.error(Gi(e.reason)),Q(this,ms,tw).call(this,o,n);break;case aa.CANCEL_COMPLETE:e.success?o.cancelCall.resolve():o.cancelCall.reject(Gi(e.reason)),Q(this,ms,tw).call(this,o,n);break;case aa.CANCEL:if(!s)break;const l=Gi(e.reason);Promise.try(s.onCancel||wce,l).then(function(){i.postMessage({sourceName:r,targetName:a,stream:aa.CANCEL_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:aa.CANCEL_COMPLETE,streamId:n,reason:Gi(u)})}),s.sinkCapability.reject(l),s.isCancelled=!0,delete this.streamSinks[n];break;default:throw new Error("Unexpected stream case")}},tw=async function(e,n){var r,a,i;await Promise.allSettled([(r=e.startCall)==null?void 0:r.promise,(a=e.pullCall)==null?void 0:a.promise,(i=e.cancelCall)==null?void 0:i.promise]),delete this.streamControllers[n]};class xce{constructor({enableHWA:e=!1}){V(this,DS,!1);L(this,DS,e)}create(e,n){if(e<=0||n<=0)throw new Error("Invalid canvas size");const r=this._createCanvas(e,n);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!_(this,DS)})}}reset(e,n,r){if(!e.canvas)throw new Error("Canvas is not specified");if(n<=0||r<=0)throw new Error("Invalid canvas size");e.canvas.width=n,e.canvas.height=r}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,n){er("Abstract method `_createCanvas` called.")}}DS=new WeakMap;class jYe extends xce{constructor({ownerDocument:e=globalThis.document,enableHWA:n=!1}){super({enableHWA:n}),this._document=e}_createCanvas(e,n){const r=this._document.createElement("canvas");return r.width=e,r.height=n,r}}class Nce{constructor({baseUrl:e=null,isCompressed:n=!0}){this.baseUrl=e,this.isCompressed=n}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const n=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(n).then(r=>({cMapData:r,isCompressed:this.isCompressed})).catch(r=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${n}`)})}async _fetch(e){er("Abstract method `_fetch` called.")}}class Oce extends Nce{async _fetch(e){const n=await xg(e,this.isCompressed?"arraybuffer":"text");return n instanceof ArrayBuffer?new Uint8Array(n):BE(n)}}class Ice{addFilter(e){return"none"}addHCMFilter(e,n){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,n,r,a,i){return"none"}destroy(e=!1){}}class WYe extends Ice{constructor({docId:n,ownerDocument:r=globalThis.document}){super();V(this,tt);V(this,om);V(this,s_);V(this,lu);V(this,cu);V(this,si);V(this,sm);V(this,lm,0);L(this,cu,n),L(this,si,r)}addFilter(n){if(!n)return"none";let r=_(this,tt,fi).get(n);if(r)return r;const[a,i,o]=Q(this,tt,nw).call(this,n),s=n.length===1?a:`${a}${i}${o}`;if(r=_(this,tt,fi).get(s),r)return _(this,tt,fi).set(n,r),r;const l=`g_${_(this,cu)}_transfer_map_${Ca(this,lm)._++}`,u=Q(this,tt,Kb).call(this,l);_(this,tt,fi).set(n,u),_(this,tt,fi).set(s,u);const d=Q(this,tt,Xb).call(this,l);return Q(this,tt,ky).call(this,a,i,o,d),u}addHCMFilter(n,r){var E;const a=`${n}-${r}`,i="base";let o=_(this,tt,Iy).get(i);if((o==null?void 0:o.key)===a||(o?((E=o.filter)==null||E.remove(),o.key=a,o.url="none",o.filter=null):(o={key:a,url:"none",filter:null},_(this,tt,Iy).set(i,o)),!n||!r))return o.url;const s=Q(this,tt,My).call(this,n);n=nt.makeHexColor(...s);const l=Q(this,tt,My).call(this,r);if(r=nt.makeHexColor(...l),_(this,tt,Wb).style.color="",n==="#000000"&&r==="#ffffff"||n===r)return o.url;const u=new Array(256);for(let b=0;b<=255;b++){const y=b/255;u[b]=y<=.03928?y/12.92:((y+.055)/1.055)**2.4}const d=u.join(","),f=`g_${_(this,cu)}_hcm_filter`,m=o.filter=Q(this,tt,Xb).call(this,f);Q(this,tt,ky).call(this,d,d,d,m),Q(this,tt,A7).call(this,m);const h=(b,y)=>{const v=s[b]/255,C=l[b]/255,T=new Array(y+1);for(let w=0;w<=y;w++)T[w]=v+w/y*(C-v);return T.join(",")};return Q(this,tt,ky).call(this,h(0,5),h(1,5),h(2,5),m),o.url=Q(this,tt,Kb).call(this,f),o.url}addAlphaFilter(n){let r=_(this,tt,fi).get(n);if(r)return r;const[a]=Q(this,tt,nw).call(this,[n]),i=`alpha_${a}`;if(r=_(this,tt,fi).get(i),r)return _(this,tt,fi).set(n,r),r;const o=`g_${_(this,cu)}_alpha_map_${Ca(this,lm)._++}`,s=Q(this,tt,Kb).call(this,o);_(this,tt,fi).set(n,s),_(this,tt,fi).set(i,s);const l=Q(this,tt,Xb).call(this,o);return Q(this,tt,R7).call(this,a,l),s}addLuminosityFilter(n){let r=_(this,tt,fi).get(n||"luminosity");if(r)return r;let a,i;if(n?([a]=Q(this,tt,nw).call(this,[n]),i=`luminosity_${a}`):i="luminosity",r=_(this,tt,fi).get(i),r)return _(this,tt,fi).set(n,r),r;const o=`g_${_(this,cu)}_luminosity_map_${Ca(this,lm)._++}`,s=Q(this,tt,Kb).call(this,o);_(this,tt,fi).set(n,s),_(this,tt,fi).set(i,s);const l=Q(this,tt,Xb).call(this,o);return Q(this,tt,Vme).call(this,l),n&&Q(this,tt,R7).call(this,a,l),s}addHighlightHCMFilter(n,r,a,i,o){var C;const s=`${r}-${a}-${i}-${o}`;let l=_(this,tt,Iy).get(n);if((l==null?void 0:l.key)===s||(l?((C=l.filter)==null||C.remove(),l.key=s,l.url="none",l.filter=null):(l={key:s,url:"none",filter:null},_(this,tt,Iy).set(n,l)),!r||!a))return l.url;const[u,d]=[r,a].map(Q(this,tt,My).bind(this));let f=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),m=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[h,E]=[i,o].map(Q(this,tt,My).bind(this));m<f&&([f,m,h,E]=[m,f,E,h]),_(this,tt,Wb).style.color="";const b=(T,w,I)=>{const x=new Array(256),D=(m-f)/I,M=T/255,F=(w-T)/(255*I);let P=0;for(let q=0;q<=I;q++){const j=Math.round(f+q*D),X=M+q*F;for(let B=P;B<=j;B++)x[B]=X;P=j+1}for(let q=P;q<256;q++)x[q]=x[P-1];return x.join(",")},y=`g_${_(this,cu)}_hcm_${n}_filter`,v=l.filter=Q(this,tt,Xb).call(this,y);return Q(this,tt,A7).call(this,v),Q(this,tt,ky).call(this,b(h[0],E[0],5),b(h[1],E[1],5),b(h[2],E[2],5),v),l.url=Q(this,tt,Kb).call(this,y),l.url}destroy(n=!1){var r,a,i,o;n&&((r=_(this,sm))!=null&&r.size)||((a=_(this,lu))==null||a.parentNode.parentNode.remove(),L(this,lu,null),(i=_(this,s_))==null||i.clear(),L(this,s_,null),(o=_(this,sm))==null||o.clear(),L(this,sm,null),L(this,lm,0))}}om=new WeakMap,s_=new WeakMap,lu=new WeakMap,cu=new WeakMap,si=new WeakMap,sm=new WeakMap,lm=new WeakMap,tt=new WeakSet,fi=function(){return _(this,s_)||L(this,s_,new Map)},Iy=function(){return _(this,sm)||L(this,sm,new Map)},Wb=function(){if(!_(this,lu)){const n=_(this,si).createElement("div"),{style:r}=n;r.visibility="hidden",r.contain="strict",r.width=r.height=0,r.position="absolute",r.top=r.left=0,r.zIndex=-1;const a=_(this,si).createElementNS(Yc,"svg");a.setAttribute("width",0),a.setAttribute("height",0),L(this,lu,_(this,si).createElementNS(Yc,"defs")),n.append(a),a.append(_(this,lu)),_(this,si).body.append(n)}return _(this,lu)},nw=function(n){if(n.length===1){const u=n[0],d=new Array(256);for(let m=0;m<256;m++)d[m]=u[m]/255;const f=d.join(",");return[f,f,f]}const[r,a,i]=n,o=new Array(256),s=new Array(256),l=new Array(256);for(let u=0;u<256;u++)o[u]=r[u]/255,s[u]=a[u]/255,l[u]=i[u]/255;return[o.join(","),s.join(","),l.join(",")]},Kb=function(n){if(_(this,om)===void 0){L(this,om,"");const r=_(this,si).URL;r!==_(this,si).baseURI&&(zE(r)?Dt('#createUrl: ignore "data:"-URL for performance reasons.'):L(this,om,pB(r,"")))}return`url(${_(this,om)}#${n})`},Vme=function(n){const r=_(this,si).createElementNS(Yc,"feColorMatrix");r.setAttribute("type","matrix"),r.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),n.append(r)},A7=function(n){const r=_(this,si).createElementNS(Yc,"feColorMatrix");r.setAttribute("type","matrix"),r.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),n.append(r)},Xb=function(n){const r=_(this,si).createElementNS(Yc,"filter");return r.setAttribute("color-interpolation-filters","sRGB"),r.setAttribute("id",n),_(this,tt,Wb).append(r),r},Dy=function(n,r,a){const i=_(this,si).createElementNS(Yc,r);i.setAttribute("type","discrete"),i.setAttribute("tableValues",a),n.append(i)},ky=function(n,r,a,i){const o=_(this,si).createElementNS(Yc,"feComponentTransfer");i.append(o),Q(this,tt,Dy).call(this,o,"feFuncR",n),Q(this,tt,Dy).call(this,o,"feFuncG",r),Q(this,tt,Dy).call(this,o,"feFuncB",a)},R7=function(n,r){const a=_(this,si).createElementNS(Yc,"feComponentTransfer");r.append(a),Q(this,tt,Dy).call(this,a,"feFuncA",n)},My=function(n){return _(this,tt,Wb).style.color=n,Ng(getComputedStyle(_(this,tt,Wb)).getPropertyValue("color"))};class Dce{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const n=`${this.baseUrl}${e}`;return this._fetch(n).catch(r=>{throw new Error(`Unable to load font data at: ${n}`)})}async _fetch(e){er("Abstract method `_fetch` called.")}}class kce extends Dce{async _fetch(e){const n=await xg(e,"arraybuffer");return new Uint8Array(n)}}class Mce{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!e)throw new Error("Wasm filename must be specified.");const n=`${this.baseUrl}${e}`;return this._fetch(n).catch(r=>{throw new Error(`Unable to load wasm data at: ${n}`)})}async _fetch(e){er("Abstract method `_fetch` called.")}}class Lce extends Mce{async _fetch(e){const n=await xg(e,"arraybuffer");return new Uint8Array(n)}}Si&&Dt("Please use the `legacy` build in Node.js environments.");async function wB(t){const n=await process.getBuiltinModule("fs").promises.readFile(t);return new Uint8Array(n)}class KYe extends Ice{}class XYe extends xce{_createCanvas(e,n){return process.getBuiltinModule("module").createRequire(On&&On.tagName.toUpperCase()==="SCRIPT"&&On.src||new URL("app.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(e,n)}}class QYe extends Nce{async _fetch(e){return wB(e)}}class ZYe extends Dce{async _fetch(e){return wB(e)}}class JYe extends Mce{async _fetch(e){return wB(e)}}const Og="__forcedDependency",{floor:Pce,ceil:Fce}=Math;function tR(t,e,n,r,a,i){t[e*4+0]=Math.min(t[e*4+0],n),t[e*4+1]=Math.min(t[e*4+1],r),t[e*4+2]=Math.max(t[e*4+2],a),t[e*4+3]=Math.max(t[e*4+3],i)}const xB=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class eVe{constructor(e,n){V(this,l_);V(this,Kd);L(this,l_,e),L(this,Kd,n)}get length(){return _(this,l_).length}isEmpty(e){return _(this,l_)[e]===xB}minX(e){return _(this,Kd)[e*4+0]/256}minY(e){return _(this,Kd)[e*4+1]/256}maxX(e){return(_(this,Kd)[e*4+2]+1)/256}maxY(e){return(_(this,Kd)[e*4+3]+1)/256}}l_=new WeakMap,Kd=new WeakMap;const nR=(t,e)=>{if(!t)return;let n=t.get(e);return n||(n={dependencies:new Set,isRenderingOperation:!1},t.set(e,n)),n};class tVe{constructor(e,n,r=!1){V(this,MS);V(this,Hi,{__proto__:null});V(this,$i,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Og]:[]});V(this,cm,new Map);V(this,el,[]);V(this,um,[]);V(this,uu,[[1,0,0,1,0,0]]);V(this,Ln,[-1/0,-1/0,1/0,1/0]);V(this,zn,new Float64Array([1/0,1/0,-1/0,-1/0]));V(this,du,-1);V(this,Yi,new Set);V(this,kS,new Map);V(this,c_,new Map);V(this,dm);V(this,pm);V(this,pu);V(this,li);V(this,nc);L(this,dm,e.width),L(this,pm,e.height),Q(this,MS,w7).call(this,n),r&&L(this,nc,new Map)}growOperationsCount(e){e>=_(this,li).length&&Q(this,MS,w7).call(this,e,_(this,li))}save(e){return L(this,Hi,{__proto__:_(this,Hi)}),L(this,$i,{__proto__:_(this,$i),transform:{__proto__:_(this,$i).transform},moveText:{__proto__:_(this,$i).moveText},sameLineText:{__proto__:_(this,$i).sameLineText},[Og]:{__proto__:_(this,$i)[Og]}}),L(this,Ln,{__proto__:_(this,Ln)}),_(this,el).push(e),this}restore(e){var a;const n=Object.getPrototypeOf(_(this,Hi));if(n===null)return this;L(this,Hi,n),L(this,$i,Object.getPrototypeOf(_(this,$i))),L(this,Ln,Object.getPrototypeOf(_(this,Ln)));const r=_(this,el).pop();return r!==void 0&&((a=nR(_(this,nc),e))==null||a.dependencies.add(r),_(this,li)[e]=_(this,li)[r]),this}recordOpenMarker(e){return _(this,el).push(e),this}getOpenMarker(){return _(this,el).length===0?null:_(this,el).at(-1)}recordCloseMarker(e){var r;const n=_(this,el).pop();return n!==void 0&&((r=nR(_(this,nc),e))==null||r.dependencies.add(n),_(this,li)[e]=_(this,li)[n]),this}beginMarkedContent(e){return _(this,um).push(e),this}endMarkedContent(e){var r;const n=_(this,um).pop();return n!==void 0&&((r=nR(_(this,nc),e))==null||r.dependencies.add(n),_(this,li)[e]=_(this,li)[n]),this}pushBaseTransform(e){return _(this,uu).push(nt.multiplyByDOMMatrix(_(this,uu).at(-1),e.getTransform())),this}popBaseTransform(){return _(this,uu).length>1&&_(this,uu).pop(),this}recordSimpleData(e,n){return _(this,Hi)[e]=n,this}recordIncrementalData(e,n){return _(this,$i)[e].push(n),this}resetIncrementalData(e,n){return _(this,$i)[e].length=0,this}recordNamedData(e,n){return _(this,cm).set(e,n),this}recordSimpleDataFromNamed(e,n,r){_(this,Hi)[e]=_(this,cm).get(n)??r}recordFutureForcedDependency(e,n){return this.recordIncrementalData(Og,n),this}inheritSimpleDataAsFutureForcedDependencies(e){for(const n of e)n in _(this,Hi)&&this.recordFutureForcedDependency(n,_(this,Hi)[n]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of _(this,Yi))this.recordFutureForcedDependency(Og,e);return this}resetBBox(e){return _(this,du)!==e&&(L(this,du,e),_(this,zn)[0]=1/0,_(this,zn)[1]=1/0,_(this,zn)[2]=-1/0,_(this,zn)[3]=-1/0),this}recordClipBox(e,n,r,a,i,o){const s=nt.multiplyByDOMMatrix(_(this,uu).at(-1),n.getTransform()),l=[1/0,1/0,-1/0,-1/0];nt.axialAlignedBoundingBox([r,i,a,o],s,l);const u=nt.intersect(_(this,Ln),l);return u?(_(this,Ln)[0]=u[0],_(this,Ln)[1]=u[1],_(this,Ln)[2]=u[2],_(this,Ln)[3]=u[3]):(_(this,Ln)[0]=_(this,Ln)[1]=1/0,_(this,Ln)[2]=_(this,Ln)[3]=-1/0),this}recordBBox(e,n,r,a,i,o){const s=_(this,Ln);if(s[0]===1/0)return this;const l=nt.multiplyByDOMMatrix(_(this,uu).at(-1),n.getTransform());if(s[0]===-1/0)return nt.axialAlignedBoundingBox([r,i,a,o],l,_(this,zn)),this;const u=[1/0,1/0,-1/0,-1/0];return nt.axialAlignedBoundingBox([r,i,a,o],l,u),_(this,zn)[0]=Math.min(_(this,zn)[0],Math.max(u[0],s[0])),_(this,zn)[1]=Math.min(_(this,zn)[1],Math.max(u[1],s[1])),_(this,zn)[2]=Math.max(_(this,zn)[2],Math.min(u[2],s[2])),_(this,zn)[3]=Math.max(_(this,zn)[3],Math.min(u[3],s[3])),this}recordCharacterBBox(e,n,r,a=1,i=0,o=0,s){const l=r.bbox;let u,d;if(l&&(u=l[2]!==l[0]&&l[3]!==l[1]&&_(this,c_).get(r),u!==!1&&(d=[0,0,0,0],nt.axialAlignedBoundingBox(l,r.fontMatrix,d),(a!==1||i!==0||o!==0)&&nt.scaleMinMax([a,0,0,-a,i,o],d),u)))return this.recordBBox(e,n,d[0],d[2],d[1],d[3]);if(!s)return this.recordFullPageBBox(e);const f=s();return l&&d&&u===void 0&&(u=d[0]<=i-f.actualBoundingBoxLeft&&d[2]>=i+f.actualBoundingBoxRight&&d[1]<=o-f.actualBoundingBoxAscent&&d[3]>=o+f.actualBoundingBoxDescent,_(this,c_).set(r,u),u)?this.recordBBox(e,n,d[0],d[2],d[1],d[3]):this.recordBBox(e,n,i-f.actualBoundingBoxLeft,i+f.actualBoundingBoxRight,o-f.actualBoundingBoxAscent,o+f.actualBoundingBoxDescent)}recordFullPageBBox(e){return _(this,zn)[0]=Math.max(0,_(this,Ln)[0]),_(this,zn)[1]=Math.max(0,_(this,Ln)[1]),_(this,zn)[2]=Math.min(_(this,dm),_(this,Ln)[2]),_(this,zn)[3]=Math.min(_(this,pm),_(this,Ln)[3]),this}getSimpleIndex(e){return _(this,Hi)[e]}recordDependencies(e,n){const r=_(this,Yi),a=_(this,Hi),i=_(this,$i);for(const o of n)o in _(this,Hi)?r.add(a[o]):o in i&&i[o].forEach(r.add,r);return this}recordNamedDependency(e,n){return _(this,cm).has(n)&&_(this,Yi).add(_(this,cm).get(n)),this}recordOperation(e,n=!1){if(this.recordDependencies(e,[Og]),_(this,nc)){const r=nR(_(this,nc),e),{dependencies:a}=r;_(this,Yi).forEach(a.add,a),_(this,el).forEach(a.add,a),_(this,um).forEach(a.add,a),a.delete(e),r.isRenderingOperation=!0}if(_(this,du)===e){const r=Pce(_(this,zn)[0]*256/_(this,dm)),a=Pce(_(this,zn)[1]*256/_(this,pm)),i=Fce(_(this,zn)[2]*256/_(this,dm)),o=Fce(_(this,zn)[3]*256/_(this,pm));tR(_(this,pu),e,r,a,i,o);for(const s of _(this,Yi))s!==e&&tR(_(this,pu),s,r,a,i,o);for(const s of _(this,el))s!==e&&tR(_(this,pu),s,r,a,i,o);for(const s of _(this,um))s!==e&&tR(_(this,pu),s,r,a,i,o);n||(_(this,Yi).clear(),L(this,du,-1))}return this}recordShowTextOperation(e,n=!1){const r=Array.from(_(this,Yi));this.recordOperation(e,n),this.recordIncrementalData("sameLineText",e);for(const a of r)this.recordIncrementalData("sameLineText",a);return this}bboxToClipBoxDropOperation(e,n=!1){return _(this,du)===e&&(L(this,du,-1),_(this,Ln)[0]=Math.max(_(this,Ln)[0],_(this,zn)[0]),_(this,Ln)[1]=Math.max(_(this,Ln)[1],_(this,zn)[1]),_(this,Ln)[2]=Math.min(_(this,Ln)[2],_(this,zn)[2]),_(this,Ln)[3]=Math.min(_(this,Ln)[3],_(this,zn)[3]),n||_(this,Yi).clear()),this}_takePendingDependencies(){const e=_(this,Yi);return L(this,Yi,new Set),e}_extractOperation(e){const n=_(this,kS).get(e);return _(this,kS).delete(e),n}_pushPendingDependencies(e){for(const n of e)_(this,Yi).add(n)}take(){return _(this,c_).clear(),new eVe(_(this,li),_(this,pu))}takeDebugMetadata(){return _(this,nc)}}Hi=new WeakMap,$i=new WeakMap,cm=new WeakMap,el=new WeakMap,um=new WeakMap,uu=new WeakMap,Ln=new WeakMap,zn=new WeakMap,du=new WeakMap,Yi=new WeakMap,kS=new WeakMap,c_=new WeakMap,dm=new WeakMap,pm=new WeakMap,pu=new WeakMap,li=new WeakMap,nc=new WeakMap,MS=new WeakSet,w7=function(e,n){const r=new ArrayBuffer(e*4);L(this,pu,new Uint8ClampedArray(r)),L(this,li,new Uint32Array(r)),n&&n.length>0?(_(this,li).set(n),_(this,li).fill(xB,n.length)):_(this,li).fill(xB)};const i6=class i6{constructor(e,n,r){V(this,rr);V(this,Ur);V(this,tl);V(this,u_,0);V(this,d_,0);if(e instanceof i6&&_(e,tl)===!!r)return e;L(this,rr,e),L(this,Ur,n),L(this,tl,!!r)}growOperationsCount(){throw new Error("Unreachable")}save(e){return Ca(this,d_)._++,_(this,rr).save(_(this,Ur)),this}restore(e){return _(this,d_)>0&&(_(this,rr).restore(_(this,Ur)),Ca(this,d_)._--),this}recordOpenMarker(e){return Ca(this,u_)._++,this}getOpenMarker(){return _(this,u_)>0?_(this,Ur):_(this,rr).getOpenMarker()}recordCloseMarker(e){return Ca(this,u_)._--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return _(this,rr).pushBaseTransform(e),this}popBaseTransform(){return _(this,rr).popBaseTransform(),this}recordSimpleData(e,n){return _(this,rr).recordSimpleData(e,_(this,Ur)),this}recordIncrementalData(e,n){return _(this,rr).recordIncrementalData(e,_(this,Ur)),this}resetIncrementalData(e,n){return _(this,rr).resetIncrementalData(e,_(this,Ur)),this}recordNamedData(e,n){return this}recordSimpleDataFromNamed(e,n,r){return _(this,rr).recordSimpleDataFromNamed(e,n,_(this,Ur)),this}recordFutureForcedDependency(e,n){return _(this,rr).recordFutureForcedDependency(e,_(this,Ur)),this}inheritSimpleDataAsFutureForcedDependencies(e){return _(this,rr).inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return _(this,rr).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return _(this,tl)||_(this,rr).resetBBox(_(this,Ur)),this}recordClipBox(e,n,r,a,i,o){return _(this,tl)||_(this,rr).recordClipBox(_(this,Ur),n,r,a,i,o),this}recordBBox(e,n,r,a,i,o){return _(this,tl)||_(this,rr).recordBBox(_(this,Ur),n,r,a,i,o),this}recordCharacterBBox(e,n,r,a,i,o,s){return _(this,tl)||_(this,rr).recordCharacterBBox(_(this,Ur),n,r,a,i,o,s),this}recordFullPageBBox(e){return _(this,tl)||_(this,rr).recordFullPageBBox(_(this,Ur)),this}getSimpleIndex(e){return _(this,rr).getSimpleIndex(e)}recordDependencies(e,n){return _(this,rr).recordDependencies(_(this,Ur),n),this}recordNamedDependency(e,n){return _(this,rr).recordNamedDependency(_(this,Ur),n),this}recordOperation(e){return _(this,rr).recordOperation(_(this,Ur),!0),this}recordShowTextOperation(e){return _(this,rr).recordShowTextOperation(_(this,Ur),!0),this}bboxToClipBoxDropOperation(e){return _(this,tl)||_(this,rr).bboxToClipBoxDropOperation(_(this,Ur),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};rr=new WeakMap,Ur=new WeakMap,tl=new WeakMap,u_=new WeakMap,d_=new WeakMap;let rR=i6;const as={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},Ga={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function NB(t,e){if(!e)return;const n=e[2]-e[0],r=e[3]-e[1],a=new Path2D;a.rect(e[0],e[1],n,r),t.clip(a)}class OB{isModifyingCurrentTransform(){return!1}getPattern(){er("Abstract method `getPattern` called.")}}class nVe extends OB{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let n;this._type==="axial"?n=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(n=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const r of this._colorStops)n.addColorStop(r[0],r[1]);return n}getPattern(e,n,r,a){let i;if(a===Ga.STROKE||a===Ga.FILL){const o=n.current.getClippedPathBoundingBox(a,Ir(e))||[0,0,0,0],s=Math.ceil(o[2]-o[0])||1,l=Math.ceil(o[3]-o[1])||1,u=n.cachedCanvases.getCanvas("pattern",s,l),d=u.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-o[0],-o[1]),r=nt.transform(r,[1,0,0,1,o[0],o[1]]),d.transform(...n.baseTransform),this.matrix&&d.transform(...this.matrix),NB(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),i=e.createPattern(u.canvas,"no-repeat");const f=new DOMMatrix(r);i.setTransform(f)}else NB(e,this._bbox),i=this._createGradient(e);return i}}function IB(t,e,n,r,a,i,o,s){const l=e.coords,u=e.colors,d=t.data,f=t.width*4;let m;l[n+1]>l[r+1]&&(m=n,n=r,r=m,m=i,i=o,o=m),l[r+1]>l[a+1]&&(m=r,r=a,a=m,m=o,o=s,s=m),l[n+1]>l[r+1]&&(m=n,n=r,r=m,m=i,i=o,o=m);const h=(l[n]+e.offsetX)*e.scaleX,E=(l[n+1]+e.offsetY)*e.scaleY,b=(l[r]+e.offsetX)*e.scaleX,y=(l[r+1]+e.offsetY)*e.scaleY,v=(l[a]+e.offsetX)*e.scaleX,C=(l[a+1]+e.offsetY)*e.scaleY;if(E>=C)return;const T=u[i],w=u[i+1],I=u[i+2],x=u[o],D=u[o+1],M=u[o+2],F=u[s],P=u[s+1],q=u[s+2],j=Math.round(E),X=Math.round(C);let B,W,G,Y,K,J,$,Z;for(let te=j;te<=X;te++){if(te<y){const ae=te<E?0:(E-te)/(E-y);B=h-(h-b)*ae,W=T-(T-x)*ae,G=w-(w-D)*ae,Y=I-(I-M)*ae}else{let ae;te>C?ae=1:y===C?ae=0:ae=(y-te)/(y-C),B=b-(b-v)*ae,W=x-(x-F)*ae,G=D-(D-P)*ae,Y=M-(M-q)*ae}let U;te<E?U=0:te>C?U=1:U=(E-te)/(E-C),K=h-(h-v)*U,J=T-(T-F)*U,$=w-(w-P)*U,Z=I-(I-q)*U;const ie=Math.round(Math.min(B,K)),se=Math.round(Math.max(B,K));let ue=f*te+ie*4;for(let ae=ie;ae<=se;ae++)U=(B-ae)/(B-K),U<0?U=0:U>1&&(U=1),d[ue++]=W-(W-J)*U|0,d[ue++]=G-(G-$)*U|0,d[ue++]=Y-(Y-Z)*U|0,d[ue++]=255}}function rVe(t,e,n){const r=e.coords,a=e.colors;let i,o;switch(e.type){case"lattice":const s=e.verticesPerRow,l=Math.floor(r.length/s)-1,u=s-1;for(i=0;i<l;i++){let d=i*s;for(let f=0;f<u;f++,d++)IB(t,n,r[d],r[d+1],r[d+s],a[d],a[d+1],a[d+s]),IB(t,n,r[d+s+1],r[d+1],r[d+s],a[d+s+1],a[d+1],a[d+s])}break;case"triangles":for(i=0,o=r.length;i<o;i+=3)IB(t,n,r[i],r[i+1],r[i+2],a[i],a[i+1],a[i+2]);break;default:throw new Error("illegal figure")}}class aVe extends OB{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[6],this._background=e[7],this.matrix=null}_createMeshCanvas(e,n,r){const s=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),u=Math.ceil(this._bounds[2])-s,d=Math.ceil(this._bounds[3])-l,f=Math.min(Math.ceil(Math.abs(u*e[0]*1.1)),3e3),m=Math.min(Math.ceil(Math.abs(d*e[1]*1.1)),3e3),h=u/f,E=d/m,b={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-l,scaleX:1/h,scaleY:1/E},y=f+4,v=m+4,C=r.getCanvas("mesh",y,v),T=C.context,w=T.createImageData(f,m);if(n){const x=w.data;for(let D=0,M=x.length;D<M;D+=4)x[D]=n[0],x[D+1]=n[1],x[D+2]=n[2],x[D+3]=255}for(const x of this._figures)rVe(w,x,b);return T.putImageData(w,2,2),{canvas:C.canvas,offsetX:s-2*h,offsetY:l-2*E,scaleX:h,scaleY:E}}isModifyingCurrentTransform(){return!0}getPattern(e,n,r,a){NB(e,this._bbox);const i=new Float32Array(2);if(a===Ga.SHADING)nt.singularValueDecompose2dScale(Ir(e),i);else if(this.matrix){nt.singularValueDecompose2dScale(this.matrix,i);const[s,l]=i;nt.singularValueDecompose2dScale(n.baseTransform,i),i[0]*=s,i[1]*=l}else nt.singularValueDecompose2dScale(n.baseTransform,i);const o=this._createMeshCanvas(i,a===Ga.SHADING?null:this._background,n.cachedCanvases);return a!==Ga.SHADING&&(e.setTransform(...n.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(o.offsetX,o.offsetY),e.scale(o.scaleX,o.scaleY),e.createPattern(o.canvas,"no-repeat")}}class iVe extends OB{getPattern(){return"hotpink"}}function oVe(t){switch(t[0]){case"RadialAxial":return new nVe(t);case"Mesh":return new aVe(t);case"Dummy":return new iVe}throw new Error(`Unknown IR type: ${t[0]}`)}const Bce={COLORED:1,UNCOLORED:2},OR=class OR{constructor(e,n,r,a){this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(e,n){var J,$;const{bbox:r,operatorList:a,paintType:i,tilingType:o,color:s,canvasGraphicsFactory:l}=this;let{xstep:u,ystep:d}=this;u=Math.abs(u),d=Math.abs(d),VA("TilingType: "+o);const f=r[0],m=r[1],h=r[2],E=r[3],b=h-f,y=E-m,v=new Float32Array(2);nt.singularValueDecompose2dScale(this.matrix,v);const[C,T]=v;nt.singularValueDecompose2dScale(this.baseTransform,v);const w=C*v[0],I=T*v[1];let x=b,D=y,M=!1,F=!1;const P=Math.ceil(u*w),q=Math.ceil(d*I),j=Math.ceil(b*w),X=Math.ceil(y*I);P>=j?x=u:M=!0,q>=X?D=d:F=!0;const B=this.getSizeAndScale(x,this.ctx.canvas.width,w),W=this.getSizeAndScale(D,this.ctx.canvas.height,I),G=e.cachedCanvases.getCanvas("pattern",B.size,W.size),Y=G.context,K=l.createCanvasGraphics(Y,n);if(K.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(K,i,s),Y.translate(-B.scale*f,-W.scale*m),K.transform(0,B.scale,0,0,W.scale,0,0),Y.save(),(J=K.dependencyTracker)==null||J.save(),this.clipBbox(K,f,m,h,E),K.baseTransform=Ir(K.ctx),K.executeOperatorList(a),K.endDrawing(),($=K.dependencyTracker)==null||$.restore(),Y.restore(),M||F){const Z=G.canvas;M&&(x=u),F&&(D=d);const te=this.getSizeAndScale(x,this.ctx.canvas.width,w),U=this.getSizeAndScale(D,this.ctx.canvas.height,I),ie=te.size,se=U.size,ue=e.cachedCanvases.getCanvas("pattern-workaround",ie,se),ae=ue.context,ce=M?Math.floor(b/u):0,ge=F?Math.floor(y/d):0;for(let Ee=0;Ee<=ce;Ee++)for(let we=0;we<=ge;we++)ae.drawImage(Z,ie*Ee,se*we,ie,se,0,0,ie,se);return{canvas:ue.canvas,scaleX:te.scale,scaleY:U.scale,offsetX:f,offsetY:m}}return{canvas:G.canvas,scaleX:B.scale,scaleY:W.scale,offsetX:f,offsetY:m}}getSizeAndScale(e,n,r){const a=Math.max(OR.MAX_PATTERN_SIZE,n);let i=Math.ceil(e*r);return i>=a?i=a:r=i/e,{scale:r,size:i}}clipBbox(e,n,r,a,i){const o=a-n,s=i-r;e.ctx.rect(n,r,o,s),nt.axialAlignedBoundingBox([n,r,a,i],Ir(e.ctx),e.current.minMax),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,n,r){const a=e.ctx,i=e.current;switch(n){case Bce.COLORED:const{fillStyle:o,strokeStyle:s}=this.ctx;a.fillStyle=i.fillColor=o,a.strokeStyle=i.strokeColor=s;break;case Bce.UNCOLORED:a.fillStyle=a.strokeStyle=r,i.fillColor=i.strokeColor=r;break;default:throw new wYe(`Unsupported paint type: ${n}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,n,r,a,i){let o=r;a!==Ga.SHADING&&(o=nt.transform(o,n.baseTransform),this.matrix&&(o=nt.transform(o,this.matrix)));const s=this.createPatternCanvas(n,i);let l=new DOMMatrix(o);l=l.translate(s.offsetX,s.offsetY),l=l.scale(1/s.scaleX,1/s.scaleY);const u=e.createPattern(s.canvas,"repeat");return u.setTransform(l),u}};Ue(OR,"MAX_PATTERN_SIZE",3e3);let DB=OR;function sVe({src:t,srcPos:e=0,dest:n,width:r,height:a,nonBlackColor:i=4294967295,inverseDecode:o=!1}){const s=Ra.isLittleEndian?4278190080:255,[l,u]=o?[i,s]:[s,i],d=r>>3,f=r&7,m=t.length;n=new Uint32Array(n.buffer);let h=0;for(let E=0;E<a;E++){for(const y=e+d;e<y;e++){const v=e<m?t[e]:255;n[h++]=v&128?u:l,n[h++]=v&64?u:l,n[h++]=v&32?u:l,n[h++]=v&16?u:l,n[h++]=v&8?u:l,n[h++]=v&4?u:l,n[h++]=v&2?u:l,n[h++]=v&1?u:l}if(f===0)continue;const b=e<m?t[e++]:255;for(let y=0;y<f;y++)n[h++]=b&1<<7-y?u:l}return{srcPos:e,destPos:h}}const Uce=16,Gce=100,lVe=15,zce=10,zi=16,kB=new DOMMatrix,vo=new Float32Array(2),Ig=new Float32Array([1/0,1/0,-1/0,-1/0]);function cVe(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(n,r){e.translate(n,r),this.__originalTranslate(n,r)},t.scale=function(n,r){e.scale(n,r),this.__originalScale(n,r)},t.transform=function(n,r,a,i,o,s){e.transform(n,r,a,i,o,s),this.__originalTransform(n,r,a,i,o,s)},t.setTransform=function(n,r,a,i,o,s){e.setTransform(n,r,a,i,o,s),this.__originalSetTransform(n,r,a,i,o,s)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(n){e.rotate(n),this.__originalRotate(n)},t.clip=function(n){e.clip(n),this.__originalClip(n)},t.moveTo=function(n,r){e.moveTo(n,r),this.__originalMoveTo(n,r)},t.lineTo=function(n,r){e.lineTo(n,r),this.__originalLineTo(n,r)},t.bezierCurveTo=function(n,r,a,i,o,s){e.bezierCurveTo(n,r,a,i,o,s),this.__originalBezierCurveTo(n,r,a,i,o,s)},t.rect=function(n,r,a,i){e.rect(n,r,a,i),this.__originalRect(n,r,a,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}class uVe{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,n,r){let a;return this.cache[e]!==void 0?(a=this.cache[e],this.canvasFactory.reset(a,n,r)):(a=this.canvasFactory.create(n,r),this.cache[e]=a),a}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const n=this.cache[e];this.canvasFactory.destroy(n),delete this.cache[e]}}}function aR(t,e,n,r,a,i,o,s,l,u){const[d,f,m,h,E,b]=Ir(t);if(f===0&&m===0){const C=o*d+E,T=Math.round(C),w=s*h+b,I=Math.round(w),x=(o+l)*d+E,D=Math.abs(Math.round(x)-T)||1,M=(s+u)*h+b,F=Math.abs(Math.round(M)-I)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(h),T,I),t.drawImage(e,n,r,a,i,0,0,D,F),t.setTransform(d,f,m,h,E,b),[D,F]}if(d===0&&h===0){const C=s*m+E,T=Math.round(C),w=o*f+b,I=Math.round(w),x=(s+u)*m+E,D=Math.abs(Math.round(x)-T)||1,M=(o+l)*f+b,F=Math.abs(Math.round(M)-I)||1;return t.setTransform(0,Math.sign(f),Math.sign(m),0,T,I),t.drawImage(e,n,r,a,i,0,0,F,D),t.setTransform(d,f,m,h,E,b),[F,D]}t.drawImage(e,n,r,a,i,o,s,l,u);const y=Math.hypot(d,f),v=Math.hypot(m,h);return[y*l,v*u]}class qce{constructor(e,n,r){Ue(this,"alphaIsShape",!1);Ue(this,"fontSize",0);Ue(this,"fontSizeScale",1);Ue(this,"textMatrix",null);Ue(this,"textMatrixScale",1);Ue(this,"fontMatrix",cB);Ue(this,"leading",0);Ue(this,"x",0);Ue(this,"y",0);Ue(this,"lineX",0);Ue(this,"lineY",0);Ue(this,"charSpacing",0);Ue(this,"wordSpacing",0);Ue(this,"textHScale",1);Ue(this,"textRenderingMode",Ua.FILL);Ue(this,"textRise",0);Ue(this,"fillColor","#000000");Ue(this,"strokeColor","#000000");Ue(this,"patternFill",!1);Ue(this,"patternStroke",!1);Ue(this,"fillAlpha",1);Ue(this,"strokeAlpha",1);Ue(this,"lineWidth",1);Ue(this,"activeSMask",null);Ue(this,"transferMaps","none");r==null||r(this),this.clipBox=new Float32Array([0,0,e,n]),this.minMax=Ig.slice()}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e.minMax=this.minMax.slice(),e}getPathBoundingBox(e=Ga.FILL,n=null){const r=this.minMax.slice();if(e===Ga.STROKE){n||er("Stroke bounding box must include transform."),nt.singularValueDecompose2dScale(n,vo);const a=vo[0]*this.lineWidth/2,i=vo[1]*this.lineWidth/2;r[0]-=a,r[1]-=i,r[2]+=a,r[3]+=i}return r}updateClipFromPath(){const e=nt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0),this.minMax.set(Ig,0)}getClippedPathBoundingBox(e=Ga.FILL,n=null){return nt.intersect(this.clipBox,this.getPathBoundingBox(e,n))}}function Hce(t,e){if(e instanceof ImageData){t.putImageData(e,0,0);return}const n=e.height,r=e.width,a=n%zi,i=(n-a)/zi,o=a===0?i:i+1,s=t.createImageData(r,zi);let l=0,u;const d=e.data,f=s.data;let m,h,E,b;if(e.kind===LE.GRAYSCALE_1BPP){const y=d.byteLength,v=new Uint32Array(f.buffer,0,f.byteLength>>2),C=v.length,T=r+7>>3,w=4294967295,I=Ra.isLittleEndian?4278190080:255;for(m=0;m<o;m++){for(E=m<i?zi:a,u=0,h=0;h<E;h++){const x=y-l;let D=0;const M=x>T?r:x*8-7,F=M&-8;let P=0,q=0;for(;D<F;D+=8)q=d[l++],v[u++]=q&128?w:I,v[u++]=q&64?w:I,v[u++]=q&32?w:I,v[u++]=q&16?w:I,v[u++]=q&8?w:I,v[u++]=q&4?w:I,v[u++]=q&2?w:I,v[u++]=q&1?w:I;for(;D<M;D++)P===0&&(q=d[l++],P=128),v[u++]=q&P?w:I,P>>=1}for(;u<C;)v[u++]=0;t.putImageData(s,0,m*zi)}}else if(e.kind===LE.RGBA_32BPP){for(h=0,b=r*zi*4,m=0;m<i;m++)f.set(d.subarray(l,l+b)),l+=b,t.putImageData(s,0,h),h+=zi;m<o&&(b=r*a*4,f.set(d.subarray(l,l+b)),t.putImageData(s,0,h))}else if(e.kind===LE.RGB_24BPP)for(E=zi,b=r*E,m=0;m<o;m++){for(m>=i&&(E=a,b=r*E),u=0,h=b;h--;)f[u++]=d[l++],f[u++]=d[l++],f[u++]=d[l++],f[u++]=255;t.putImageData(s,0,m*zi)}else throw new Error(`bad image kind: ${e.kind}`)}function $ce(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const n=e.height,r=e.width,a=n%zi,i=(n-a)/zi,o=a===0?i:i+1,s=t.createImageData(r,zi);let l=0;const u=e.data,d=s.data;for(let f=0;f<o;f++){const m=f<i?zi:a;({srcPos:l}=sVe({src:u,srcPos:l,dest:d,width:r,height:m,nonBlackColor:0})),t.putImageData(s,0,f*zi)}}function jE(t,e){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const r of n)t[r]!==void 0&&(e[r]=t[r]);t.setLineDash!==void 0&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function iR(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",t.setLineDash!==void 0&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;e!=="none"&&e!==""&&(t.filter="none")}function Yce(t,e){if(e)return!0;nt.singularValueDecompose2dScale(t,vo);const n=Math.fround(Ks.pixelRatio*Vc.PDF_TO_CSS_UNITS);return vo[0]<=n&&vo[1]<=n}const dVe=["butt","round","square"],pVe=["miter","round","bevel"],fVe={},Vce={},o6=class o6{constructor(e,n,r,a,i,{optionalContentConfig:o,markedContentStack:s=null},l,u,d){V(this,nl);this.ctx=e,this.current=new qce(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=n,this.objs=r,this.canvasFactory=a,this.filterFactory=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=s||[],this.optionalContentConfig=o,this.cachedCanvases=new uVe(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=u,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=d??null}getObject(e,n,r=null){var a;return typeof n=="string"?((a=this.dependencyTracker)==null||a.recordNamedDependency(e,n),n.startsWith("g_")?this.commonObjs.get(n):this.objs.get(n)):r}beginDrawing({transform:e,viewport:n,transparency:r=!1,background:a=null}){const i=this.ctx.canvas.width,o=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=a||"#ffffff",this.ctx.fillRect(0,0,i,o),this.ctx.fillStyle=s,r){const l=this.cachedCanvases.getCanvas("transparent",i,o);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Ir(this.compositeCtx))}this.ctx.save(),iR(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...n.transform),this.viewportScale=n.scale,this.baseTransform=Ir(this.ctx)}executeOperatorList(e,n,r,a,i){var v;const o=e.argsArray,s=e.fnArray;let l=n||0;const u=o.length;if(u===l)return l;const d=u-l>zce&&typeof r=="function",f=d?Date.now()+lVe:0;let m=0;const h=this.commonObjs,E=this.objs;let b,y;for(;;){if(a!==void 0&&l===a.nextBreakPoint)return a.breakIt(l,r),l;if(!i||i(l))if(b=s[l],y=o[l]??null,b!==wg.dependency)y===null?this[b](l):this[b](l,...y);else for(const C of y){(v=this.dependencyTracker)==null||v.recordNamedData(C,l);const T=C.startsWith("g_")?h:E;if(!T.has(C))return T.get(C,r),l}if(l++,l===u)return l;if(d&&++m>zce){if(Date.now()>f)return r(),l;m=0}}}endDrawing(){Q(this,nl,x7).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const n of e.values())typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&(n.width=n.height=0);e.clear()}this._cachedBitmapsMap.clear(),Q(this,nl,N7).call(this)}_scaleImage(e,n){const r=e.width??e.displayWidth,a=e.height??e.displayHeight;let i=Math.max(Math.hypot(n[0],n[1]),1),o=Math.max(Math.hypot(n[2],n[3]),1),s=r,l=a,u="prescale1",d,f;for(;i>2&&s>1||o>2&&l>1;){let m=s,h=l;i>2&&s>1&&(m=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s/2),i/=s/m),o>2&&l>1&&(h=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,o/=l/h),d=this.cachedCanvases.getCanvas(u,m,h),f=d.context,f.clearRect(0,0,m,h),f.drawImage(e,0,0,s,l,0,0,m,h),e=d.canvas,s=m,l=h,u=u==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:s,paintHeight:l}}_createMaskCanvas(e,n){var P,q;const r=this.ctx,{width:a,height:i}=n,o=this.current.fillColor,s=this.current.patternFill,l=Ir(r);let u,d,f,m;if((n.bitmap||n.data)&&n.count>1){const j=n.bitmap||n.data.buffer;d=JSON.stringify(s?l:[l.slice(0,4),o]),u=this._cachedBitmapsMap.get(j),u||(u=new Map,this._cachedBitmapsMap.set(j,u));const X=u.get(d);if(X&&!s){const B=Math.round(Math.min(l[0],l[2])+l[4]),W=Math.round(Math.min(l[1],l[3])+l[5]);return(P=this.dependencyTracker)==null||P.recordDependencies(e,as.transformAndFill),{canvas:X,offsetX:B,offsetY:W}}f=X}f||(m=this.cachedCanvases.getCanvas("maskCanvas",a,i),$ce(m.context,n));let h=nt.transform(l,[1/a,0,0,-1/i,0,0]);h=nt.transform(h,[1,0,0,1,0,-i]);const E=Ig.slice();nt.axialAlignedBoundingBox([0,0,a,i],h,E);const[b,y,v,C]=E,T=Math.round(v-b)||1,w=Math.round(C-y)||1,I=this.cachedCanvases.getCanvas("fillCanvas",T,w),x=I.context,D=b,M=y;x.translate(-D,-M),x.transform(...h),f||(f=this._scaleImage(m.canvas,Hl(x)),f=f.img,u&&s&&u.set(d,f)),x.imageSmoothingEnabled=Yce(Ir(x),n.interpolate),aR(x,f,0,0,f.width,f.height,0,0,a,i),x.globalCompositeOperation="source-in";const F=nt.transform(Hl(x),[1,0,0,1,-D,-M]);return x.fillStyle=s?o.getPattern(r,this,F,Ga.FILL,e):o,x.fillRect(0,0,a,i),u&&!s&&(this.cachedCanvases.delete("fillCanvas"),u.set(d,I.canvas)),(q=this.dependencyTracker)==null||q.recordDependencies(e,as.transformAndFill),{canvas:I.canvas,offsetX:Math.round(D),offsetY:Math.round(M)}}setLineWidth(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineWidth",e),n!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=n,this.ctx.lineWidth=n}setLineCap(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineCap",e),this.ctx.lineCap=dVe[n]}setLineJoin(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineJoin",e),this.ctx.lineJoin=pVe[n]}setMiterLimit(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("miterLimit",e),this.ctx.miterLimit=n}setDash(e,n,r){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("dash",e);const a=this.ctx;a.setLineDash!==void 0&&(a.setLineDash(n),a.lineDashOffset=r)}setRenderingIntent(e,n){}setFlatness(e,n){}setGState(e,n){var r,a,i,o,s;for(const[l,u]of n)switch(l){case"LW":this.setLineWidth(e,u);break;case"LC":this.setLineCap(e,u);break;case"LJ":this.setLineJoin(e,u);break;case"ML":this.setMiterLimit(e,u);break;case"D":this.setDash(e,u[0],u[1]);break;case"RI":this.setRenderingIntent(e,u);break;case"FL":this.setFlatness(e,u);break;case"Font":this.setFont(e,u[0],u[1]);break;case"CA":(r=this.dependencyTracker)==null||r.recordSimpleData("strokeAlpha",e),this.current.strokeAlpha=u;break;case"ca":(a=this.dependencyTracker)==null||a.recordSimpleData("fillAlpha",e),this.ctx.globalAlpha=this.current.fillAlpha=u;break;case"BM":(i=this.dependencyTracker)==null||i.recordSimpleData("globalCompositeOperation",e),this.ctx.globalCompositeOperation=u;break;case"SMask":(o=this.dependencyTracker)==null||o.recordSimpleData("SMask",e),this.current.activeSMask=u?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(s=this.dependencyTracker)==null||s.recordSimpleData("filter",e),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(u);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(e){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(a,n,r);this.suspendedCtx=this.ctx;const o=this.ctx=i.context;o.setTransform(this.suspendedCtx.getTransform()),jE(this.suspendedCtx,o),cVe(o,this.suspendedCtx),this.setGState(e,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),jE(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const n=this.current.activeSMask,r=this.suspendedCtx;this.composeSMask(r,n,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,n,r,a){const i=a[0],o=a[1],s=a[2]-i,l=a[3]-o;s===0||l===0||(this.genericComposeSMask(n.context,r,s,l,n.subtype,n.backdrop,n.transferMap,i,o,n.offsetX,n.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(r.canvas,0,0),e.restore())}genericComposeSMask(e,n,r,a,i,o,s,l,u,d,f){let m=e.canvas,h=l-d,E=u-f;if(o)if(h<0||E<0||h+r>m.width||E+a>m.height){const y=this.cachedCanvases.getCanvas("maskExtension",r,a),v=y.context;v.drawImage(m,-h,-E),v.globalCompositeOperation="destination-atop",v.fillStyle=o,v.fillRect(0,0,r,a),v.globalCompositeOperation="source-over",m=y.canvas,h=E=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const y=new Path2D;y.rect(h,E,r,a),e.clip(y),e.globalCompositeOperation="destination-atop",e.fillStyle=o,e.fillRect(h,E,r,a),e.restore()}n.save(),n.globalAlpha=1,n.setTransform(1,0,0,1,0,0),i==="Alpha"&&s?n.filter=this.filterFactory.addAlphaFilter(s):i==="Luminosity"&&(n.filter=this.filterFactory.addLuminosityFilter(s));const b=new Path2D;b.rect(l,u,r,a),n.clip(b),n.globalCompositeOperation="destination-in",n.drawImage(m,h,E,r,a,l,u,r,a),n.restore()}save(e){var r;this.inSMaskMode&&jE(this.ctx,this.suspendedCtx),this.ctx.save();const n=this.current;this.stateStack.push(n),this.current=n.clone(),(r=this.dependencyTracker)==null||r.save(e)}restore(e){var n;if((n=this.dependencyTracker)==null||n.restore(e),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&jE(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(e,n,r,a,i,o,s){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",e),this.ctx.transform(n,r,a,i,o,s),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,n,r,a){let[i]=r;if(!a){i||(i=r[0]=new Path2D),this[n](e,i);return}if(this.dependencyTracker!==null){const o=n===wg.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,a[0]-o,a[2]+o,a[1]-o,a[3]+o).recordDependencies(e,["transform"])}if(!(i instanceof Path2D)){const o=r[0]=new Path2D;for(let s=0,l=i.length;s<l;)switch(i[s++]){case $A.moveTo:o.moveTo(i[s++],i[s++]);break;case $A.lineTo:o.lineTo(i[s++],i[s++]);break;case $A.curveTo:o.bezierCurveTo(i[s++],i[s++],i[s++],i[s++],i[s++],i[s++]);break;case $A.closePath:o.closePath();break;default:Dt(`Unrecognized drawing path operator: ${i[s-1]}`);break}i=o}nt.axialAlignedBoundingBox(a,Ir(this.ctx),this.current.minMax),this[n](e,i),this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,n,r=!0){var o;const a=this.ctx,i=this.current.strokeColor;if(a.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof i=="object"&&(i!=null&&i.getPattern)){const s=i.isModifyingCurrentTransform()?a.getTransform():null;if(a.save(),a.strokeStyle=i.getPattern(a,this,Hl(a),Ga.STROKE,e),s){const l=new Path2D;l.addPath(n,a.getTransform().invertSelf().multiplySelf(s)),n=l}this.rescaleAndStroke(n,!1),a.restore()}else this.rescaleAndStroke(n,!0);(o=this.dependencyTracker)==null||o.recordDependencies(e,as.stroke),r&&this.consumePath(e,n,this.current.getClippedPathBoundingBox(Ga.STROKE,Ir(this.ctx))),a.globalAlpha=this.current.fillAlpha}closeStroke(e,n){this.stroke(e,n)}fill(e,n,r=!0){var u,d,f;const a=this.ctx,i=this.current.fillColor,o=this.current.patternFill;let s=!1;if(o){const m=i.isModifyingCurrentTransform()?a.getTransform():null;if((u=this.dependencyTracker)==null||u.save(e),a.save(),a.fillStyle=i.getPattern(a,this,Hl(a),Ga.FILL,e),m){const h=new Path2D;h.addPath(n,a.getTransform().invertSelf().multiplySelf(m)),n=h}s=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(a.fill(n,"evenodd"),this.pendingEOFill=!1):a.fill(n)),(d=this.dependencyTracker)==null||d.recordDependencies(e,as.fill),s&&(a.restore(),(f=this.dependencyTracker)==null||f.restore(e)),r&&this.consumePath(e,n,l)}eoFill(e,n){this.pendingEOFill=!0,this.fill(e,n)}fillStroke(e,n){this.fill(e,n,!1),this.stroke(e,n,!1),this.consumePath(e,n)}eoFillStroke(e,n){this.pendingEOFill=!0,this.fillStroke(e,n)}closeFillStroke(e,n){this.fillStroke(e,n)}closeEOFillStroke(e,n){this.pendingEOFill=!0,this.fillStroke(e,n)}endPath(e,n){this.consumePath(e,n)}rawFillPath(e,n){var r;this.ctx.fill(n),(r=this.dependencyTracker)==null||r.recordDependencies(e,as.rawFillPath).recordOperation(e)}clip(e){var n;(n=this.dependencyTracker)==null||n.recordFutureForcedDependency("clipMode",e),this.pendingClip=fVe}eoClip(e){var n;(n=this.dependencyTracker)==null||n.recordFutureForcedDependency("clipMode",e),this.pendingClip=Vce}beginText(e){var n;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(n=this.dependencyTracker)==null||n.recordOpenMarker(e).resetIncrementalData("sameLineText").resetIncrementalData("moveText",e)}endText(e){const n=this.pendingTextPaths,r=this.ctx;if(this.dependencyTracker){const{dependencyTracker:a}=this;n!==void 0&&a.recordFutureForcedDependency("textClip",a.getOpenMarker()).recordFutureForcedDependency("textClip",e),a.recordCloseMarker(e)}if(n!==void 0){const a=new Path2D,i=r.getTransform().invertSelf();for(const{transform:o,x:s,y:l,fontSize:u,path:d}of n)d&&a.addPath(d,new DOMMatrix(o).preMultiplySelf(i).translate(s,l).scale(u,-u));r.clip(a)}delete this.pendingTextPaths}setCharSpacing(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("charSpacing",e),this.current.charSpacing=n}setWordSpacing(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("wordSpacing",e),this.current.wordSpacing=n}setHScale(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("hScale",e),this.current.textHScale=n/100}setLeading(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("leading",e),this.current.leading=-n}setFont(e,n,r){var f,m;(f=this.dependencyTracker)==null||f.recordSimpleData("font",e).recordSimpleDataFromNamed("fontObj",n,e);const a=this.commonObjs.get(n),i=this.current;if(!a)throw new Error(`Can't find font for ${n}`);if(i.fontMatrix=a.fontMatrix||cB,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&Dt("Invalid font matrix for font "+n),r<0?(r=-r,i.fontDirection=-1):i.fontDirection=1,this.current.font=a,this.current.fontSize=r,a.isType3Font)return;const o=a.loadedName||"sans-serif",s=((m=a.systemFontInfo)==null?void 0:m.css)||`"${o}", ${a.fallbackName}`;let l="normal";a.black?l="900":a.bold&&(l="bold");const u=a.italic?"italic":"normal";let d=r;r<Uce?d=Uce:r>Gce&&(d=Gce),this.current.fontSizeScale=r/d,this.ctx.font=`${u} ${l} ${d}px ${s}`}setTextRenderingMode(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("textRenderingMode",e),this.current.textRenderingMode=n}setTextRise(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("textRise",e),this.current.textRise=n}moveText(e,n,r){var a;(a=this.dependencyTracker)==null||a.resetIncrementalData("sameLineText").recordIncrementalData("moveText",e),this.current.x=this.current.lineX+=n,this.current.y=this.current.lineY+=r}setLeadingMoveText(e,n,r){this.setLeading(e,-r),this.moveText(e,n,r)}setTextMatrix(e,n){var a;(a=this.dependencyTracker)==null||a.recordSimpleData("textMatrix",e);const{current:r}=this;r.textMatrix=n,r.textMatrixScale=Math.hypot(n[0],n[1]),r.x=r.lineX=0,r.y=r.lineY=0}nextLine(e){var n;this.moveText(e,0,this.current.leading),(n=this.dependencyTracker)==null||n.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??e)}paintChar(e,n,r,a,i,o){var v,C,T,w;const s=this.ctx,l=this.current,u=l.font,d=l.textRenderingMode,f=l.fontSize/l.fontSizeScale,m=d&Ua.FILL_STROKE_MASK,h=!!(d&Ua.ADD_TO_PATH_FLAG),E=l.patternFill&&!u.missingFile,b=l.patternStroke&&!u.missingFile;let y;if((u.disableFontFace||h||E||b)&&!u.missingFile&&(y=u.getPathGenerator(this.commonObjs,n)),y&&(u.disableFontFace||E||b)){s.save(),s.translate(r,a),s.scale(f,-f),(v=this.dependencyTracker)==null||v.recordCharacterBBox(e,s,u);let I;if(m===Ua.FILL||m===Ua.FILL_STROKE)if(i){I=s.getTransform(),s.setTransform(...i);const x=Q(this,nl,O7).call(this,y,I,i);s.fill(x)}else s.fill(y);if(m===Ua.STROKE||m===Ua.FILL_STROKE)if(o){I||(I=s.getTransform()),s.setTransform(...o);const{a:x,b:D,c:M,d:F}=I,P=nt.inverseTransform(o),q=nt.transform([x,D,M,F,0,0],P);nt.singularValueDecompose2dScale(q,vo),s.lineWidth*=Math.max(vo[0],vo[1])/f,s.stroke(Q(this,nl,O7).call(this,y,I,o))}else s.lineWidth/=f,s.stroke(y);s.restore()}else(m===Ua.FILL||m===Ua.FILL_STROKE)&&(s.fillText(n,r,a),(C=this.dependencyTracker)==null||C.recordCharacterBBox(e,s,u,f,r,a,()=>s.measureText(n))),(m===Ua.STROKE||m===Ua.FILL_STROKE)&&(this.dependencyTracker&&((T=this.dependencyTracker)==null||T.recordCharacterBBox(e,s,u,f,r,a,()=>s.measureText(n)).recordDependencies(e,as.stroke)),s.strokeText(n,r,a));h&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Ir(s),x:r,y:a,fontSize:f,path:y}),(w=this.dependencyTracker)==null||w.recordCharacterBBox(e,s,u,f,r,a))}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const n=e.getImageData(0,0,10,10).data;let r=!1;for(let a=3;a<n.length;a+=4)if(n[a]>0&&n[a]<255){r=!0;break}return Ht(this,"isFontSubpixelAAEnabled",r)}showText(e,n){var M,F,P,q;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(e,as.showText).resetBBox(e),this.current.textRenderingMode&Ua.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies());const r=this.current,a=r.font;if(a.isType3Font){this.showType3Text(e,n),(M=this.dependencyTracker)==null||M.recordShowTextOperation(e);return}const i=r.fontSize;if(i===0){(F=this.dependencyTracker)==null||F.recordOperation(e);return}const o=this.ctx,s=r.fontSizeScale,l=r.charSpacing,u=r.wordSpacing,d=r.fontDirection,f=r.textHScale*d,m=n.length,h=a.vertical,E=h?1:-1,b=a.defaultVMetrics,y=i*r.fontMatrix[0],v=r.textRenderingMode===Ua.FILL&&!a.disableFontFace&&!r.patternFill;o.save(),r.textMatrix&&o.transform(...r.textMatrix),o.translate(r.x,r.y+r.textRise),d>0?o.scale(f,-1):o.scale(f,1);let C,T;if(r.patternFill){o.save();const j=r.fillColor.getPattern(o,this,Hl(o),Ga.FILL,e);C=Ir(o),o.restore(),o.fillStyle=j}if(r.patternStroke){o.save();const j=r.strokeColor.getPattern(o,this,Hl(o),Ga.STROKE,e);T=Ir(o),o.restore(),o.strokeStyle=j}let w=r.lineWidth;const I=r.textMatrixScale;if(I===0||w===0){const j=r.textRenderingMode&Ua.FILL_STROKE_MASK;(j===Ua.STROKE||j===Ua.FILL_STROKE)&&(w=this.getSinglePixelWidth())}else w/=I;if(s!==1&&(o.scale(s,s),w/=s),o.lineWidth=w,a.isInvalidPDFjsFont){const j=[];let X=0;for(const W of n)j.push(W.unicode),X+=W.width;const B=j.join("");if(o.fillText(B,0,0),this.dependencyTracker!==null){const W=o.measureText(B);this.dependencyTracker.recordBBox(e,this.ctx,-W.actualBoundingBoxLeft,W.actualBoundingBoxRight,-W.actualBoundingBoxAscent,W.actualBoundingBoxDescent).recordShowTextOperation(e)}r.x+=X*y*f,o.restore(),this.compose();return}let x=0,D;for(D=0;D<m;++D){const j=n[D];if(typeof j=="number"){x+=E*j*i/1e3;continue}let X=!1;const B=(j.isSpace?u:0)+l,W=j.fontChar,G=j.accent;let Y,K,J=j.width;if(h){const te=j.vmetric||b,U=-(j.vmetric?te[1]:J*.5)*y,ie=te[2]*y;J=te?-te[0]:J,Y=U/s,K=(x+ie)/s}else Y=x/s,K=0;let $;if(a.remeasure&&J>0){$=o.measureText(W);const te=$.width*1e3/i*s;if(J<te&&this.isFontSubpixelAAEnabled){const U=J/te;X=!0,o.save(),o.scale(U,1),Y/=U}else J!==te&&(Y+=(J-te)/2e3*i/s)}if(this.contentVisible&&(j.isInFont||a.missingFile)){if(v&&!G)o.fillText(W,Y,K),(P=this.dependencyTracker)==null||P.recordCharacterBBox(e,o,$?{bbox:null}:a,i/s,Y,K,()=>$??o.measureText(W));else if(this.paintChar(e,W,Y,K,C,T),G){const te=Y+i*G.offset.x/s,U=K-i*G.offset.y/s;this.paintChar(e,G.fontChar,te,U,C,T)}}const Z=h?J*y-B*d:J*y+B*d;x+=Z,X&&o.restore()}h?r.y-=x:r.x+=x*f,o.restore(),this.compose(),(q=this.dependencyTracker)==null||q.recordShowTextOperation(e)}showType3Text(e,n){const r=this.ctx,a=this.current,i=a.font,o=a.fontSize,s=a.fontDirection,l=i.vertical?1:-1,u=a.charSpacing,d=a.wordSpacing,f=a.textHScale*s,m=a.fontMatrix||cB,h=n.length,E=a.textRenderingMode===Ua.INVISIBLE;let b,y,v,C;if(E||o===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,r.save(),a.textMatrix&&r.transform(...a.textMatrix),r.translate(a.x,a.y+a.textRise),r.scale(f,s);const T=this.dependencyTracker;for(this.dependencyTracker=T?new rR(T,e):null,b=0;b<h;++b){if(y=n[b],typeof y=="number"){C=l*y*o/1e3,this.ctx.translate(C,0),a.x+=C*f;continue}const w=(y.isSpace?d:0)+u,I=i.charProcOperatorList[y.operatorListId];I?this.contentVisible&&(this.save(),r.scale(o,o),r.transform(...m),this.executeOperatorList(I),this.restore()):Dt(`Type3 character "${y.operatorListId}" is not available.`);const x=[y.width,0];nt.applyTransform(x,m),v=x[0]*o+w,r.translate(v,0),a.x+=v*f}r.restore(),T&&(this.dependencyTracker=T)}setCharWidth(e,n,r){}setCharWidthAndBounds(e,n,r,a,i,o,s){var u;const l=new Path2D;l.rect(a,i,o-a,s-i),this.ctx.clip(l),(u=this.dependencyTracker)==null||u.recordBBox(e,this.ctx,a,o,i,s).recordClipBox(e,this.ctx,a,o,i,s),this.endPath(e)}getColorN_Pattern(e,n){let r;if(n[0]==="TilingPattern"){const a=this.baseTransform||Ir(this.ctx),i={createCanvasGraphics:(o,s)=>new o6(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new rR(this.dependencyTracker,s,!0):null)};r=new DB(n,this.ctx,i,a)}else r=this._getPattern(e,n[1],n[2]);return r}setStrokeColorN(e,...n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("strokeColor",e),this.current.strokeColor=this.getColorN_Pattern(e,n),this.current.patternStroke=!0}setFillColorN(e,...n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("fillColor",e),this.current.fillColor=this.getColorN_Pattern(e,n),this.current.patternFill=!0}setStrokeRGBColor(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor=n,this.current.patternStroke=!1}setStrokeTransparent(e){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor=n,this.current.patternFill=!1}setFillTransparent(e){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,n,r=null){let a;return this.cachedPatterns.has(n)?a=this.cachedPatterns.get(n):(a=oVe(this.getObject(e,n)),this.cachedPatterns.set(n,a)),r&&(a.matrix=r),a}shadingFill(e,n){var o;if(!this.contentVisible)return;const r=this.ctx;this.save(e);const a=this._getPattern(e,n);r.fillStyle=a.getPattern(r,this,Hl(r),Ga.SHADING,e);const i=Hl(r);if(i){const{width:s,height:l}=r.canvas,u=Ig.slice();nt.axialAlignedBoundingBox([0,0,s,l],i,u);const[d,f,m,h]=u;this.ctx.fillRect(d,f,m-d,h-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,as.transform).recordDependencies(e,as.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e)}beginInlineImage(){er("Should not call beginInlineImage")}beginImageData(){er("Should not call beginImageData")}paintFormXObjectBegin(e,n,r){var a;if(this.contentVisible&&(this.save(e),this.baseTransformStack.push(this.baseTransform),n&&this.transform(e,...n),this.baseTransform=Ir(this.ctx),r)){nt.axialAlignedBoundingBox(r,this.baseTransform,this.current.minMax);const[i,o,s,l]=r,u=new Path2D;u.rect(i,o,s-i,l-o),this.ctx.clip(u),(a=this.dependencyTracker)==null||a.recordClipBox(e,this.ctx,i,s,o,l),this.endPath(e)}}paintFormXObjectEnd(e){this.contentVisible&&(this.restore(e),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e,n){var T;if(!this.contentVisible)return;this.save(e),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const r=this.ctx;n.isolated||VA("TODO: Support non-isolated groups."),n.knockout&&Dt("Knockout groups not supported.");const a=Ir(r);if(n.matrix&&r.transform(...n.matrix),!n.bbox)throw new Error("Bounding box is required.");let i=Ig.slice();nt.axialAlignedBoundingBox(n.bbox,Ir(r),i);const o=[0,0,r.canvas.width,r.canvas.height];i=nt.intersect(i,o)||[0,0,0,0];const s=Math.floor(i[0]),l=Math.floor(i[1]),u=Math.max(Math.ceil(i[2])-s,1),d=Math.max(Math.ceil(i[3])-l,1);this.current.startNewPathAndClipBox([0,0,u,d]);let f="groupAt"+this.groupLevel;n.smask&&(f+="_smask_"+this.smaskCounter++%2);const m=this.cachedCanvases.getCanvas(f,u,d),h=m.context;h.translate(-s,-l),h.transform(...a);let E=new Path2D;const[b,y,v,C]=n.bbox;if(E.rect(b,y,v-b,C-y),n.matrix){const w=new Path2D;w.addPath(E,new DOMMatrix(n.matrix)),E=w}h.clip(E),n.smask&&this.smaskStack.push({canvas:m.canvas,context:h,offsetX:s,offsetY:l,subtype:n.smask.subtype,backdrop:n.smask.backdrop,transferMap:n.smask.transferMap||null,startTransformInverse:null}),(!n.smask||this.dependencyTracker)&&(r.setTransform(1,0,0,1,0,0),r.translate(s,l),r.save()),jE(r,h),this.ctx=h,(T=this.dependencyTracker)==null||T.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(r),this.setGState(e,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(r),this.groupLevel++}endGroup(e,n){var i;if(!this.contentVisible)return;this.groupLevel--;const r=this.ctx,a=this.groupStack.pop();if(this.ctx=a,this.ctx.imageSmoothingEnabled=!1,(i=this.dependencyTracker)==null||i.popBaseTransform(),n.smask)this.tempSMask=this.smaskStack.pop(),this.restore(e),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const o=Ir(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...o);const s=Ig.slice();nt.axialAlignedBoundingBox([0,0,r.canvas.width,r.canvas.height],o,s),this.ctx.drawImage(r.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(e,n,r,a,i,o){if(Q(this,nl,x7).call(this),iR(this.ctx),this.ctx.save(),this.save(e),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),r){const s=r[2]-r[0],l=r[3]-r[1];if(o&&this.annotationCanvasMap){a=a.slice(),a[4]-=r[0],a[5]-=r[1],r=r.slice(),r[0]=r[1]=0,r[2]=s,r[3]=l,nt.singularValueDecompose2dScale(Ir(this.ctx),vo);const{viewportScale:u}=this,d=Math.ceil(s*this.outputScaleX*u),f=Math.ceil(l*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:m,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(n,m),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(vo[0],0,0,-vo[1],0,l*vo[1]),iR(this.ctx)}else{iR(this.ctx),this.endPath(e);const u=new Path2D;u.rect(r[0],r[1],s,l),this.ctx.clip(u)}}this.current=new qce(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(e,...a),this.transform(e,...i)}endAnnotation(e){this.annotationCanvas&&(this.ctx.restore(),Q(this,nl,N7).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e,n){var s;if(!this.contentVisible)return;const r=n.count;n=this.getObject(e,n.data,n),n.count=r;const a=this.ctx,i=this._createMaskCanvas(e,n),o=i.canvas;a.save(),a.setTransform(1,0,0,1,0,0),a.drawImage(o,i.offsetX,i.offsetY),(s=this.dependencyTracker)==null||s.resetBBox(e).recordBBox(e,this.ctx,i.offsetX,i.offsetX+o.width,i.offsetY,i.offsetY+o.height).recordOperation(e),a.restore(),this.compose()}paintImageMaskXObjectRepeat(e,n,r,a=0,i=0,o,s){var f,m,h;if(!this.contentVisible)return;n=this.getObject(e,n.data,n);const l=this.ctx;l.save();const u=Ir(l);l.transform(r,a,i,o,0,0);const d=this._createMaskCanvas(e,n);l.setTransform(1,0,0,1,d.offsetX-u[4],d.offsetY-u[5]),(f=this.dependencyTracker)==null||f.resetBBox(e);for(let E=0,b=s.length;E<b;E+=2){const y=nt.transform(u,[r,a,i,o,s[E],s[E+1]]);l.drawImage(d.canvas,y[4],y[5]),(m=this.dependencyTracker)==null||m.recordBBox(e,this.ctx,y[4],y[4]+d.canvas.width,y[5],y[5]+d.canvas.height)}l.restore(),this.compose(),(h=this.dependencyTracker)==null||h.recordOperation(e)}paintImageMaskXObjectGroup(e,n){var o,s,l;if(!this.contentVisible)return;const r=this.ctx,a=this.current.fillColor,i=this.current.patternFill;(o=this.dependencyTracker)==null||o.resetBBox(e).recordDependencies(e,as.transformAndFill);for(const u of n){const{data:d,width:f,height:m,transform:h}=u,E=this.cachedCanvases.getCanvas("maskCanvas",f,m),b=E.context;b.save();const y=this.getObject(e,d,u);$ce(b,y),b.globalCompositeOperation="source-in",b.fillStyle=i?a.getPattern(b,this,Hl(r),Ga.FILL,e):a,b.fillRect(0,0,f,m),b.restore(),r.save(),r.transform(...h),r.scale(1,-1),aR(r,E.canvas,0,0,f,m,0,-1,1,1),(s=this.dependencyTracker)==null||s.recordBBox(e,r,0,f,0,m),r.restore()}this.compose(),(l=this.dependencyTracker)==null||l.recordOperation(e)}paintImageXObject(e,n){if(!this.contentVisible)return;const r=this.getObject(e,n);if(!r){Dt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e,r)}paintImageXObjectRepeat(e,n,r,a,i){if(!this.contentVisible)return;const o=this.getObject(e,n);if(!o){Dt("Dependent image isn't ready yet");return}const s=o.width,l=o.height,u=[];for(let d=0,f=i.length;d<f;d+=2)u.push({transform:[r,0,0,a,i[d],i[d+1]],x:0,y:0,w:s,h:l});this.paintInlineImageXObjectGroup(e,o,u)}applyTransferMapsToCanvas(e){return this.current.transferMaps!=="none"&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return e.bitmap;const{bitmap:n,width:r,height:a}=e,i=this.cachedCanvases.getCanvas("inlineImage",r,a),o=i.context;return o.filter=this.current.transferMaps,o.drawImage(n,0,0),o.filter="none",i.canvas}paintInlineImageXObject(e,n){var u;if(!this.contentVisible)return;const r=n.width,a=n.height,i=this.ctx;this.save(e);const{filter:o}=i;o!=="none"&&o!==""&&(i.filter="none"),i.scale(1/r,-1/a);let s;if(n.bitmap)s=this.applyTransferMapsToBitmap(n);else if(typeof HTMLElement=="function"&&n instanceof HTMLElement||!n.data)s=n;else{const f=this.cachedCanvases.getCanvas("inlineImage",r,a).context;Hce(f,n),s=this.applyTransferMapsToCanvas(f)}const l=this._scaleImage(s,Hl(i));i.imageSmoothingEnabled=Yce(Ir(i),n.interpolate),(u=this.dependencyTracker)==null||u.resetBBox(e).recordBBox(e,i,0,r,-a,0).recordDependencies(e,as.imageXObject).recordOperation(e),aR(i,l.img,0,0,l.paintWidth,l.paintHeight,0,-a,r,a),this.compose(),this.restore(e)}paintInlineImageXObjectGroup(e,n,r){var o,s,l;if(!this.contentVisible)return;const a=this.ctx;let i;if(n.bitmap)i=n.bitmap;else{const u=n.width,d=n.height,m=this.cachedCanvases.getCanvas("inlineImage",u,d).context;Hce(m,n),i=this.applyTransferMapsToCanvas(m)}(o=this.dependencyTracker)==null||o.resetBBox(e);for(const u of r)a.save(),a.transform(...u.transform),a.scale(1,-1),aR(a,i,u.x,u.y,u.w,u.h,0,-1,1,1),(s=this.dependencyTracker)==null||s.recordBBox(e,a,0,1,-1,0),a.restore();(l=this.dependencyTracker)==null||l.recordOperation(e),this.compose()}paintSolidColorImageMask(e){var n;this.contentVisible&&((n=this.dependencyTracker)==null||n.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,as.fill).recordOperation(e),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e,n){}markPointProps(e,n,r){}beginMarkedContent(e,n){var r;(r=this.dependencyTracker)==null||r.beginMarkedContent(e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,n,r){var a;(a=this.dependencyTracker)==null||a.beginMarkedContent(e),n==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(r)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(e){var n;(n=this.dependencyTracker)==null||n.endMarkedContent(e),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,n,r){var o,s;const a=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(r);const i=this.ctx;this.pendingClip?(a||(this.pendingClip===Vce?i.clip(n,"evenodd"):i.clip(n)),this.pendingClip=null,(o=this.dependencyTracker)==null||o.bboxToClipBoxDropOperation(e).recordFutureForcedDependency("clipPath",e)):(s=this.dependencyTracker)==null||s.recordOperation(e),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=Ir(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const n=Math.abs(e[0]*e[3]-e[2]*e[1]),r=Math.hypot(e[0],e[2]),a=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(r,a)/n}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:e}=this.current,{a:n,b:r,c:a,d:i}=this.ctx.getTransform();let o,s;if(r===0&&a===0){const l=Math.abs(n),u=Math.abs(i);if(l===u)if(e===0)o=s=1/l;else{const d=l*e;o=s=d<1?1/d:1}else if(e===0)o=1/l,s=1/u;else{const d=l*e,f=u*e;o=d<1?1/d:1,s=f<1?1/f:1}}else{const l=Math.abs(n*i-r*a),u=Math.hypot(n,r),d=Math.hypot(a,i);if(e===0)o=d/l,s=u/l;else{const f=e*l;o=d>f?d/f:1,s=u>f?u/f:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=s}return this._cachedScaleForStroking}rescaleAndStroke(e,n){const{ctx:r,current:{lineWidth:a}}=this,[i,o]=this.getScaleForStroking();if(i===o){r.lineWidth=(a||1)*i,r.stroke(e);return}const s=r.getLineDash();n&&r.save(),r.scale(i,o),kB.a=1/i,kB.d=1/o;const l=new Path2D;if(l.addPath(e,kB),s.length>0){const u=Math.max(i,o);r.setLineDash(s.map(d=>d/u)),r.lineDashOffset/=u}r.lineWidth=a||1,r.stroke(l),n&&r.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};nl=new WeakSet,x7=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},N7=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const n=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=n}}},O7=function(e,n,r){const a=new Path2D;return a.addPath(e,new DOMMatrix(r).invertSelf().multiplySelf(n)),a};let Dg=o6;for(const t in wg)Dg.prototype[t]!==void 0&&(Dg.prototype[wg[t]]=Dg.prototype[t]);const h_=class h_{constructor(e){V(this,m_);V(this,p_);V(this,f_);V(this,LS);L(this,p_,e),L(this,f_,new DataView(_(this,p_))),L(this,LS,new TextDecoder)}static write(e){const n=new TextEncoder,r={};let a=0;for(const u of h_.strings){const d=n.encode(e[u]);r[u]=d,a+=4+d.length}const i=new ArrayBuffer(a),o=new Uint8Array(i),s=new DataView(i);let l=0;for(const u of h_.strings){const d=r[u],f=d.length;s.setUint32(l,f),o.set(d,l+4),l+=4+f}return ln(l===i.byteLength,"CssFontInfo.write: Buffer overflow"),i}get fontFamily(){return Q(this,m_,rw).call(this,0)}get fontWeight(){return Q(this,m_,rw).call(this,1)}get italicAngle(){return Q(this,m_,rw).call(this,2)}};p_=new WeakMap,f_=new WeakMap,LS=new WeakMap,m_=new WeakSet,rw=function(e){ln(e<h_.strings.length,"Invalid string index");let n=0;for(let a=0;a<e;a++)n+=_(this,f_).getUint32(n)+4;const r=_(this,f_).getUint32(n);return _(this,LS).decode(new Uint8Array(_(this,p_),n+4,r))},Ue(h_,"strings",["fontFamily","fontWeight","italicAngle"]);let oR=h_;const g_=class g_{constructor(e){V(this,mm);V(this,Xd);V(this,rc);V(this,fm);L(this,Xd,e),L(this,rc,new DataView(_(this,Xd))),L(this,fm,new TextDecoder)}static write(e){const n=new TextEncoder,r={};let a=0;for(const m of g_.strings){const h=n.encode(e[m]);r[m]=h,a+=4+h.length}a+=4;let i,o,s=1+a;e.style&&(i=n.encode(e.style.style),o=n.encode(e.style.weight),s+=4+i.length+4+o.length);const l=new ArrayBuffer(s),u=new Uint8Array(l),d=new DataView(l);let f=0;d.setUint8(f++,e.guessFallback?1:0),d.setUint32(f,0),f+=4,a=0;for(const m of g_.strings){const h=r[m],E=h.length;a+=4+E,d.setUint32(f,E),u.set(h,f+4),f+=4+E}return d.setUint32(f-a-4,a),e.style&&(d.setUint32(f,i.length),u.set(i,f+4),f+=4+i.length,d.setUint32(f,o.length),u.set(o,f+4),f+=4+o.length),ln(f<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(f)}get guessFallback(){return _(this,rc).getUint8(0)!==0}get css(){return Q(this,mm,Ly).call(this,0)}get loadedName(){return Q(this,mm,Ly).call(this,1)}get baseFontName(){return Q(this,mm,Ly).call(this,2)}get src(){return Q(this,mm,Ly).call(this,3)}get style(){let e=1;e+=4+_(this,rc).getUint32(e);const n=_(this,rc).getUint32(e),r=_(this,fm).decode(new Uint8Array(_(this,Xd),e+4,n));e+=4+n;const a=_(this,rc).getUint32(e),i=_(this,fm).decode(new Uint8Array(_(this,Xd),e+4,a));return{style:r,weight:i}}};Xd=new WeakMap,rc=new WeakMap,fm=new WeakMap,mm=new WeakSet,Ly=function(e){ln(e<g_.strings.length,"Invalid string index");let n=5;for(let a=0;a<e;a++)n+=_(this,rc).getUint32(n)+4;const r=_(this,rc).getUint32(n);return _(this,fm).decode(new Uint8Array(_(this,Xd),n+4,r))},Ue(g_,"strings",["css","loadedName","baseFontName","src"]);let sR=g_;const Lt=class Lt{constructor({data:e,extra:n}){V(this,Gr);V(this,ac);V(this,PS);V(this,qn);L(this,ac,e),L(this,PS,new TextDecoder),L(this,qn,new DataView(_(this,ac))),n&&Object.assign(this,n)}get black(){return Q(this,Gr,_l).call(this,0)}get bold(){return Q(this,Gr,_l).call(this,1)}get disableFontFace(){return Q(this,Gr,_l).call(this,2)}get fontExtraProperties(){return Q(this,Gr,_l).call(this,3)}get isInvalidPDFjsFont(){return Q(this,Gr,_l).call(this,4)}get isType3Font(){return Q(this,Gr,_l).call(this,5)}get italic(){return Q(this,Gr,_l).call(this,6)}get missingFile(){return Q(this,Gr,_l).call(this,7)}get remeasure(){return Q(this,Gr,_l).call(this,8)}get vertical(){return Q(this,Gr,_l).call(this,9)}get ascent(){return Q(this,Gr,aw).call(this,0)}get defaultWidth(){return Q(this,Gr,aw).call(this,1)}get descent(){return Q(this,Gr,aw).call(this,2)}get bbox(){let e=_(Lt,b_);if(_(this,qn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<4;a++)r.push(_(this,qn).getInt16(e,!0)),e+=2;return r}get fontMatrix(){let e=_(Lt,E_);if(_(this,qn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<6;a++)r.push(_(this,qn).getFloat64(e,!0)),e+=8;return r}get defaultVMetrics(){let e=_(Lt,S_);if(_(this,qn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<3;a++)r.push(_(this,qn).getInt16(e,!0)),e+=2;return r}get fallbackName(){return Q(this,Gr,Py).call(this,0)}get loadedName(){return Q(this,Gr,Py).call(this,1)}get mimetype(){return Q(this,Gr,Py).call(this,2)}get name(){return Q(this,Gr,Py).call(this,3)}get data(){let e=_(Lt,Ao);const n=_(this,qn).getUint32(e);e+=4+n;const r=_(this,qn).getUint32(e);e+=4+r;const a=_(this,qn).getUint32(e);e+=4+a;const i=_(this,qn).getUint32(e);if(i!==0)return new Uint8Array(_(this,ac),e+4,i)}clearData(){let e=_(Lt,Ao);const n=_(this,qn).getUint32(e);e+=4+n;const r=_(this,qn).getUint32(e);e+=4+r;const a=_(this,qn).getUint32(e);e+=4+a;const i=_(this,qn).getUint32(e);new Uint8Array(_(this,ac),e+4,i).fill(0),_(this,qn).setUint32(e,0)}get cssFontInfo(){let e=_(Lt,Ao);const n=_(this,qn).getUint32(e);e+=4+n;const r=_(this,qn).getUint32(e);e+=4+r;const a=_(this,qn).getUint32(e);if(a===0)return null;const i=new Uint8Array(a);return i.set(new Uint8Array(_(this,ac),e+4,a)),new oR(i.buffer)}get systemFontInfo(){let e=_(Lt,Ao);const n=_(this,qn).getUint32(e);e+=4+n;const r=_(this,qn).getUint32(e);if(r===0)return null;const a=new Uint8Array(r);return a.set(new Uint8Array(_(this,ac),e+4,r)),new sR(a.buffer)}static write(e){const n=e.systemFontInfo?sR.write(e.systemFontInfo):null,r=e.cssFontInfo?oR.write(e.cssFontInfo):null,a=new TextEncoder,i={};let o=0;for(const b of Lt.strings)i[b]=a.encode(e[b]),o+=4+i[b].length;const s=_(Lt,Ao)+4+o+4+(n?n.byteLength:0)+4+(r?r.byteLength:0)+4+(e.data?e.data.length:0),l=new ArrayBuffer(s),u=new Uint8Array(l),d=new DataView(l);let f=0;const m=Lt.bools.length;let h=0,E=0;for(let b=0;b<m;b++){const y=e[Lt.bools[b]];h|=(y===void 0?0:y?2:1)<<E,E+=2,(E===8||b===m-1)&&(d.setUint8(f++,h),h=0,E=0)}ln(f===_(Lt,__),"FontInfo.write: Boolean properties offset mismatch");for(const b of Lt.numbers)d.setFloat64(f,e[b]),f+=8;if(ln(f===_(Lt,b_),"FontInfo.write: Number properties offset mismatch"),e.bbox){d.setUint8(f++,4);for(const b of e.bbox)d.setInt16(f,b,!0),f+=2}else d.setUint8(f++,0),f+=8;if(ln(f===_(Lt,E_),"FontInfo.write: BBox properties offset mismatch"),e.fontMatrix){d.setUint8(f++,6);for(const b of e.fontMatrix)d.setFloat64(f,b,!0),f+=8}else d.setUint8(f++,0),f+=48;if(ln(f===_(Lt,S_),"FontInfo.write: FontMatrix properties offset mismatch"),e.defaultVMetrics){d.setUint8(f++,1);for(const b of e.defaultVMetrics)d.setInt16(f,b,!0),f+=2}else d.setUint8(f++,0),f+=6;ln(f===_(Lt,Ao),"FontInfo.write: DefaultVMetrics properties offset mismatch"),d.setUint32(_(Lt,Ao),0),f+=4;for(const b of Lt.strings){const y=i[b],v=y.length;d.setUint32(f,v),u.set(y,f+4),f+=4+v}if(d.setUint32(_(Lt,Ao),f-_(Lt,Ao)-4),!n)d.setUint32(f,0),f+=4;else{const b=n.byteLength;d.setUint32(f,b),ln(f+4+b<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),u.set(new Uint8Array(n),f+4),f+=4+b}if(!r)d.setUint32(f,0),f+=4;else{const b=r.byteLength;d.setUint32(f,b),ln(f+4+b<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),u.set(new Uint8Array(r),f+4),f+=4+b}return e.data===void 0?(d.setUint32(f,0),f+=4):(d.setUint32(f,e.data.length),u.set(e.data,f+4),f+=4+e.data.length),ln(f<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(f)}};__=new WeakMap,b_=new WeakMap,E_=new WeakMap,S_=new WeakMap,Ao=new WeakMap,ac=new WeakMap,PS=new WeakMap,qn=new WeakMap,Gr=new WeakSet,_l=function(e){ln(e<Lt.bools.length,"Invalid boolean index");const n=Math.floor(e/4),r=e*2%8,a=_(this,qn).getUint8(n)>>r&3;return a===0?void 0:a===2},aw=function(e){return ln(e<Lt.numbers.length,"Invalid number index"),_(this,qn).getFloat64(_(Lt,__)+e*8)},Py=function(e){ln(e<Lt.strings.length,"Invalid string index");let n=_(Lt,Ao)+4;for(let i=0;i<e;i++)n+=_(this,qn).getUint32(n)+4;const r=_(this,qn).getUint32(n),a=new Uint8Array(r);return a.set(new Uint8Array(_(this,ac),n+4,r)),_(this,PS).decode(a)},Ue(Lt,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),Ue(Lt,"numbers",["ascent","defaultWidth","descent"]),Ue(Lt,"strings",["fallbackName","loadedName","mimetype","name"]),V(Lt,__,Math.ceil(Lt.bools.length*2/8)),V(Lt,b_,_(Lt,__)+Lt.numbers.length*8),V(Lt,E_,_(Lt,b_)+1+8),V(Lt,S_,_(Lt,E_)+1+48),V(Lt,Ao,_(Lt,S_)+1+6);let MB=Lt;class is{static get workerPort(){return _(this,FS)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");L(this,FS,e)}static get workerSrc(){return _(this,BS)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");L(this,BS,e)}}FS=new WeakMap,BS=new WeakMap,V(is,FS,null),V(is,BS,"");class mVe{constructor({parsedData:e,rawData:n}){V(this,v_);V(this,US);L(this,v_,e),L(this,US,n)}getRaw(){return _(this,US)}get(e){return _(this,v_).get(e)??null}[Symbol.iterator](){return _(this,v_).entries()}}v_=new WeakMap,US=new WeakMap;const kg=Symbol("INTERNAL");class hVe{constructor(e,{name:n,intent:r,usage:a,rbGroups:i}){V(this,GS,!1);V(this,zS,!1);V(this,qS,!1);V(this,y_,!0);L(this,GS,!!(e&Eo.DISPLAY)),L(this,zS,!!(e&Eo.PRINT)),this.name=n,this.intent=r,this.usage=a,this.rbGroups=i}get visible(){if(_(this,qS))return _(this,y_);if(!_(this,y_))return!1;const{print:e,view:n}=this.usage;return _(this,GS)?(n==null?void 0:n.viewState)!=="OFF":_(this,zS)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,n,r=!1){e!==kg&&er("Internal method `_setVisible` called."),L(this,qS,r),L(this,y_,n)}}GS=new WeakMap,zS=new WeakMap,qS=new WeakMap,y_=new WeakMap;class gVe{constructor(e,n=Eo.DISPLAY){V(this,HS);V(this,Qd,null);V(this,Hn,new Map);V(this,T_,null);V(this,C_,null);if(this.renderingIntent=n,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,L(this,C_,e.order);for(const r of e.groups)_(this,Hn).set(r.id,new hVe(n,r));if(e.baseState==="OFF")for(const r of _(this,Hn).values())r._setVisible(kg,!1);for(const r of e.on)_(this,Hn).get(r)._setVisible(kg,!0);for(const r of e.off)_(this,Hn).get(r)._setVisible(kg,!1);L(this,T_,this.getHash())}}isVisible(e){if(_(this,Hn).size===0)return!0;if(!e)return VA("Optional content group not defined."),!0;if(e.type==="OCG")return _(this,Hn).has(e.id)?_(this,Hn).get(e.id).visible:(Dt(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return Q(this,HS,I7).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const n of e.ids){if(!_(this,Hn).has(n))return Dt(`Optional content group not found: ${n}`),!0;if(_(this,Hn).get(n).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const n of e.ids){if(!_(this,Hn).has(n))return Dt(`Optional content group not found: ${n}`),!0;if(!_(this,Hn).get(n).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const n of e.ids){if(!_(this,Hn).has(n))return Dt(`Optional content group not found: ${n}`),!0;if(!_(this,Hn).get(n).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const n of e.ids){if(!_(this,Hn).has(n))return Dt(`Optional content group not found: ${n}`),!0;if(_(this,Hn).get(n).visible)return!1}return!0}return Dt(`Unknown optional content policy ${e.policy}.`),!0}return Dt(`Unknown group type ${e.type}.`),!0}setVisibility(e,n=!0,r=!0){var i;const a=_(this,Hn).get(e);if(!a){Dt(`Optional content group not found: ${e}`);return}if(r&&n&&a.rbGroups.length)for(const o of a.rbGroups)for(const s of o)s!==e&&((i=_(this,Hn).get(s))==null||i._setVisible(kg,!1,!0));a._setVisible(kg,!!n,!0),L(this,Qd,null)}setOCGState({state:e,preserveRB:n}){let r;for(const a of e){switch(a){case"ON":case"OFF":case"Toggle":r=a;continue}const i=_(this,Hn).get(a);if(i)switch(r){case"ON":this.setVisibility(a,!0,n);break;case"OFF":this.setVisibility(a,!1,n);break;case"Toggle":this.setVisibility(a,!i.visible,n);break}}L(this,Qd,null)}get hasInitialVisibility(){return _(this,T_)===null||this.getHash()===_(this,T_)}getOrder(){return _(this,Hn).size?_(this,C_)?_(this,C_).slice():[..._(this,Hn).keys()]:null}getGroup(e){return _(this,Hn).get(e)||null}getHash(){if(_(this,Qd)!==null)return _(this,Qd);const e=new Cce;for(const[n,r]of _(this,Hn))e.update(`${n}:${r.visible}`);return L(this,Qd,e.hexdigest())}[Symbol.iterator](){return _(this,Hn).entries()}}Qd=new WeakMap,Hn=new WeakMap,T_=new WeakMap,C_=new WeakMap,HS=new WeakSet,I7=function(e){const n=e.length;if(n<2)return!0;const r=e[0];for(let a=1;a<n;a++){const i=e[a];let o;if(Array.isArray(i))o=Q(this,HS,I7).call(this,i);else if(_(this,Hn).has(i))o=_(this,Hn).get(i).visible;else return Dt(`Optional content group not found: ${i}`),!0;switch(r){case"And":if(!o)return!1;break;case"Or":if(o)return!0;break;case"Not":return!o;default:return!0}}return r==="And"};class _Ve{constructor(e,{disableRange:n=!1,disableStream:r=!1}){ln(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:a,initialData:i,progressiveDone:o,contentDispositionFilename:s}=e;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=s,(i==null?void 0:i.length)>0){const l=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!r,this._isRangeSupported=!n,this._contentLength=a,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((l,u)=>{this._onReceiveData({begin:l,chunk:u})}),e.addProgressListener((l,u)=>{this._onProgress({loaded:l,total:u})}),e.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:n}){const r=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(r):this._queuedChunks.push(r);else{const a=this._rangeReaders.some(function(i){return i._begin!==e?!1:(i._enqueue(r),!0)});ln(a,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}_onProgress(e){var n,r,a,i;e.total===void 0?(r=(n=this._rangeReaders[0])==null?void 0:n.onProgress)==null||r.call(n,{loaded:e.loaded}):(i=(a=this._fullRequestReader)==null?void 0:a.onProgress)==null||i.call(a,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;(e=this._fullRequestReader)==null||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const n=this._rangeReaders.indexOf(e);n>=0&&this._rangeReaders.splice(n,1)}getFullReader(){ln(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new bVe(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new EVe(this,e,n);return this._pdfDataRangeTransport.requestDataRange(e,n),this._rangeReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeReaders.slice(0))r.cancel(e);this._pdfDataRangeTransport.abort()}}class bVe{constructor(e,n,r=!1,a=null){this._stream=e,this._done=r||!1,this._filename=KA(a)?a:null,this._queuedChunks=n||[],this._loaded=0;for(const i of this._queuedChunks)this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class EVe{constructor(e,n,r){this._stream=e,this._begin=n,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const n=this._queuedChunk;return this._queuedChunk=null,{value:n,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function SVe(t){let e=!0,n=r("filename\\*","i").exec(t);if(n){n=n[1];let d=s(n);return d=unescape(d),d=l(d),d=u(d),i(d)}if(n=o(t),n){const d=u(n);return i(d)}if(n=r("filename","i").exec(t),n){n=n[1];let d=s(n);return d=u(d),i(d)}function r(d,f){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',f)}function a(d,f){if(d){if(!/^[\x00-\xFF]+$/.test(f))return f;try{const m=new TextDecoder(d,{fatal:!0}),h=BE(f);f=m.decode(h),e=!1}catch{}}return f}function i(d){return e&&/[\x80-\xff]/.test(d)&&(d=a("utf-8",d),e&&(d=a("iso-8859-1",d))),d}function o(d){const f=[];let m;const h=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(m=h.exec(d))!==null;){let[,b,y,v]=m;if(b=parseInt(b,10),b in f){if(b===0)break;continue}f[b]=[y,v]}const E=[];for(let b=0;b<f.length&&b in f;++b){let[y,v]=f[b];v=s(v),y&&(v=unescape(v),b===0&&(v=l(v))),E.push(v)}return E.join("")}function s(d){if(d.startsWith('"')){const f=d.slice(1).split('\\"');for(let m=0;m<f.length;++m){const h=f[m].indexOf('"');h!==-1&&(f[m]=f[m].slice(0,h),f.length=m+1),f[m]=f[m].replaceAll(/\\(.)/g,"$1")}d=f.join('"')}return d}function l(d){const f=d.indexOf("'");if(f===-1)return d;const m=d.slice(0,f),E=d.slice(f+1).replace(/^[^']*'/,"");return a(m,E)}function u(d){return!d.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(d)?d:d.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(f,m,h,E){if(h==="q"||h==="Q")return E=E.replaceAll("_"," "),E=E.replaceAll(/=([0-9a-fA-F]{2})/g,function(b,y){return String.fromCharCode(parseInt(y,16))}),a(m,E);try{E=atob(E)}catch{}return a(m,E)})}return""}function jce(t,e){const n=new Headers;if(!t||!e||typeof e!="object")return n;for(const r in e){const a=e[r];a!==void 0&&n.append(r,a)}return n}function lR(t){var e;return((e=URL.parse(t))==null?void 0:e.origin)??null}function Wce({responseHeaders:t,isHttp:e,rangeChunkSize:n,disableRange:r}){const a={allowRangeRequests:!1,suggestedLength:void 0},i=parseInt(t.get("Content-Length"),10);return!Number.isInteger(i)||(a.suggestedLength=i,i<=2*n)||r||!e||t.get("Accept-Ranges")!=="bytes"||(t.get("Content-Encoding")||"identity")!=="identity"||(a.allowRangeRequests=!0),a}function Kce(t){const e=t.get("Content-Disposition");if(e){let n=SVe(e);if(n.includes("%"))try{n=decodeURIComponent(n)}catch{}if(KA(n))return n}return null}function WE(t,e){return new FE(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,t===404||t===0&&e.startsWith("file:"))}function Xce(t){return t===200||t===206}function Qce(t,e,n){return{method:"GET",headers:t,signal:n.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Zce(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Dt(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class vVe{constructor(e){Ue(this,"_responseOrigin",null);this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=jce(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return ln(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new yVe(this),this._fullRequestReader}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new TVe(this,e,n);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class yVe{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const n=e.source;this._withCredentials=n.withCredentials||!1,this._contentLength=n.length,this._headersCapability=Promise.withResolvers(),this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange;const r=new Headers(e.headers),a=n.url;fetch(a,Qce(r,this._withCredentials,this._abortController)).then(i=>{if(e._responseOrigin=lR(i.url),!Xce(i.status))throw WE(i.status,a);this._reader=i.body.getReader(),this._headersCapability.resolve();const o=i.headers,{allowRangeRequests:s,suggestedLength:l}=Wce({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s,this._contentLength=l||this._contentLength,this._filename=Kce(o),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new $c("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._headersCapability.promise;const{value:e,done:n}=await this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:Zce(e),done:!1})}cancel(e){var n;(n=this._reader)==null||n.cancel(e),this._abortController.abort()}}class TVe{constructor(e,n,r){this._stream=e,this._reader=null,this._loaded=0;const a=e.source;this._withCredentials=a.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!a.disableStream,this._abortController=new AbortController;const i=new Headers(e.headers);i.append("Range",`bytes=${n}-${r-1}`);const o=a.url;fetch(o,Qce(i,this._withCredentials,this._abortController)).then(s=>{const l=lR(s.url);if(l!==e._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${e._responseOrigin}".`);if(!Xce(s.status))throw WE(s.status,o);this._readCapability.resolve(),this._reader=s.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._readCapability.promise;const{value:e,done:n}=await this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded}),{value:Zce(e),done:!1})}cancel(e){var n;(n=this._reader)==null||n.cancel(e),this._abortController.abort()}}const LB=200,PB=206;function CVe(t){const e=t.response;return typeof e!="string"?e:BE(e).buffer}class AVe{constructor({url:e,httpHeaders:n,withCredentials:r}){Ue(this,"_responseOrigin",null);this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=jce(this.isHttp,n),this.withCredentials=r||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const n=new XMLHttpRequest,r=this.currXhrId++,a=this.pendingRequests[r]={xhr:n};n.open("GET",this.url),n.withCredentials=this.withCredentials;for(const[i,o]of this.headers)n.setRequestHeader(i,o);return this.isHttp&&"begin"in e&&"end"in e?(n.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),a.expectedStatus=PB):a.expectedStatus=LB,n.responseType="arraybuffer",ln(e.onError,"Expected `onError` callback to be provided."),n.onerror=()=>{e.onError(n.status)},n.onreadystatechange=this.onStateChange.bind(this,r),n.onprogress=this.onProgress.bind(this,r),a.onHeadersReceived=e.onHeadersReceived,a.onDone=e.onDone,a.onError=e.onError,a.onProgress=e.onProgress,n.send(null),r}onProgress(e,n){var a;const r=this.pendingRequests[e];r&&((a=r.onProgress)==null||a.call(r,n))}onStateChange(e,n){const r=this.pendingRequests[e];if(!r)return;const a=r.xhr;if(a.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),a.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],a.status===0&&this.isHttp){r.onError(a.status);return}const i=a.status||LB;if(!(i===LB&&r.expectedStatus===PB)&&i!==r.expectedStatus){r.onError(a.status);return}const s=CVe(a);if(i===PB){const l=a.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);u?r.onDone({begin:parseInt(u[1],10),chunk:s}):(Dt('Missing or invalid "Content-Range" header.'),r.onError(0))}else s?r.onDone({begin:0,chunk:s}):r.onError(a.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const n=this.pendingRequests[e].xhr;delete this.pendingRequests[e],n.abort()}}class RVe{constructor(e){this._source=e,this._manager=new AVe(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const n=this._rangeRequestReaders.indexOf(e);n>=0&&this._rangeRequestReaders.splice(n,1)}getFullReader(){return ln(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new wVe(this._manager,this._source),this._fullRequestReader}getRangeReader(e,n){const r=new xVe(this._manager,e,n);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class wVe{constructor(e,n){this._manager=e,this._url=n.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=n.disableRange||!1,this._contentLength=n.length,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,n=this._manager.getRequestXhr(e);this._manager._responseOrigin=lR(n.responseURL);const r=n.getAllResponseHeaders(),a=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(s=>{const[l,...u]=s.split(": ");return[l,u.join(": ")]}):[]),{allowRangeRequests:i,suggestedLength:o}=Wce({responseHeaders:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=Kce(a),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=WE(e,this._url),this._headersCapability.reject(this._storedError);for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var n;(n=this.onProgress)==null||n.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class xVe{constructor(e,n,r){this._manager=e,this._url=e.url,this._requestId=e.request({begin:n,end:r,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var n;const e=lR((n=this._manager.getRequestXhr(this._requestId))==null?void 0:n.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var e;(e=this.onClosed)==null||e.call(this,this)}_onDone(e){const n=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:n,done:!1}):this._queuedChunk=n,this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??(this._storedError=WE(e,this._url));for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var n;this.isStreamingSupported||(n=this.onProgress)==null||n.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const n=this._queuedChunk;return this._queuedChunk=null,{value:n,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const NVe=/^[a-z][a-z0-9\-+.]+:/i;function OVe(t){if(NVe.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}class IVe{constructor(e){this.source=e,this.url=OVe(e.url),ln(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return ln(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new DVe(this),this._fullRequestReader}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new kVe(this,e,n);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class DVe{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const n=e.source;this._contentLength=n.length,this._loaded=0,this._filename=null,this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const r=process.getBuiltinModule("fs");r.promises.lstat(this._url).then(a=>{this._contentLength=a.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()},a=>{a.code==="ENOENT"&&(a=WE(0,this._url.href)),this._storedError=a,this._headersCapability.reject(a)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",n=>{this._error(n)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new $c("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class kVe{constructor(e,n,r){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const a=e.source;this._isStreamingSupported=!a.disableStream;const i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:n,end:r-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",n=>{this._error(n)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const KE=Symbol("INITIAL_DATA");class Jce{constructor(){V(this,$S);V(this,Ro,Object.create(null))}get(e,n=null){if(n){const a=Q(this,$S,D7).call(this,e);return a.promise.then(()=>n(a.data)),null}const r=_(this,Ro)[e];if(!r||r.data===KE)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return r.data}has(e){const n=_(this,Ro)[e];return!!n&&n.data!==KE}delete(e){const n=_(this,Ro)[e];return!n||n.data===KE?!1:(delete _(this,Ro)[e],!0)}resolve(e,n=null){const r=Q(this,$S,D7).call(this,e);r.data=n,r.resolve()}clear(){var e;for(const n in _(this,Ro)){const{data:r}=_(this,Ro)[n];(e=r==null?void 0:r.bitmap)==null||e.close()}L(this,Ro,Object.create(null))}*[Symbol.iterator](){for(const e in _(this,Ro)){const{data:n}=_(this,Ro)[e];n!==KE&&(yield[e,n])}}}Ro=new WeakMap,$S=new WeakSet,D7=function(e){var n;return(n=_(this,Ro))[e]||(n[e]={...Promise.withResolvers(),data:KE})};const MVe=1e5,eue=30;let XE=(zr=class{constructor({textContentSource:e,container:n,viewport:r}){V(this,mu);V(this,Zd,Promise.withResolvers());V(this,Vi,null);V(this,YS,!1);V(this,VS,!!((Mue=globalThis.FontInspector)!=null&&Mue.enabled));V(this,hm,null);V(this,fu,null);V(this,jS,0);V(this,WS,0);V(this,gm,null);V(this,A_,null);V(this,R_,0);V(this,Jd,0);V(this,w_,Object.create(null));V(this,KS,[]);V(this,x_,null);V(this,_m,[]);V(this,XS,new WeakMap);V(this,QS,null);var l;if(e instanceof ReadableStream)L(this,x_,e);else if(typeof e=="object")L(this,x_,new ReadableStream({start(u){u.enqueue(e),u.close()}}));else throw new Error('No "textContentSource" parameter specified.');L(this,Vi,L(this,A_,n)),L(this,Jd,r.scale*Ks.pixelRatio),L(this,R_,r.rotation),L(this,fu,{div:null,properties:null,ctx:null});const{pageWidth:a,pageHeight:i,pageX:o,pageY:s}=r.rawDims;L(this,QS,[1,0,0,-1,-o,s+i]),L(this,WS,a),L(this,jS,i),Q(l=zr,wo,Kme).call(l),xd(n,r),_(this,Zd).promise.finally(()=>{_(zr,O_).delete(this),L(this,fu,null),L(this,w_,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:n}=Ra.platform;return Ht(this,"fontFamilyMap",new Map([["sans-serif",`${e&&n?"Calibri, ":""}sans-serif`],["monospace",`${e&&n?"Lucida Console, ":""}monospace`]]))}render(){const e=()=>{_(this,gm).read().then(({value:n,done:r})=>{if(r){_(this,Zd).resolve();return}_(this,hm)??L(this,hm,n.lang),Object.assign(_(this,w_),n.styles),Q(this,mu,jme).call(this,n.items),e()},_(this,Zd).reject)};return L(this,gm,_(this,x_).getReader()),_(zr,O_).add(this),e(),_(this,Zd).promise}update({viewport:e,onBefore:n=null}){var i;const r=e.scale*Ks.pixelRatio,a=e.rotation;if(a!==_(this,R_)&&(n==null||n(),L(this,R_,a),xd(_(this,A_),{rotation:a})),r!==_(this,Jd)){n==null||n(),L(this,Jd,r);const o={div:null,properties:null,ctx:Q(i=zr,wo,iw).call(i,_(this,hm))};for(const s of _(this,_m))o.properties=_(this,XS).get(s),o.div=s,Q(this,mu,k7).call(this,o)}}cancel(){var n;const e=new $c("TextLayer task cancelled.");(n=_(this,gm))==null||n.cancel(e).catch(()=>{}),L(this,gm,null),_(this,Zd).reject(e)}get textDivs(){return _(this,_m)}get textContentItemsStr(){return _(this,KS)}static cleanup(){if(!(_(this,O_).size>0)){_(this,N_).clear();for(const{canvas:e}of _(this,bm).values())e.remove();_(this,bm).clear()}}},Zd=new WeakMap,Vi=new WeakMap,YS=new WeakMap,VS=new WeakMap,hm=new WeakMap,fu=new WeakMap,jS=new WeakMap,WS=new WeakMap,gm=new WeakMap,A_=new WeakMap,R_=new WeakMap,Jd=new WeakMap,w_=new WeakMap,KS=new WeakMap,x_=new WeakMap,_m=new WeakMap,XS=new WeakMap,QS=new WeakMap,N_=new WeakMap,bm=new WeakMap,ZS=new WeakMap,ep=new WeakMap,O_=new WeakMap,mu=new WeakSet,jme=function(e){var a,i;if(_(this,YS))return;(i=_(this,fu)).ctx??(i.ctx=Q(a=zr,wo,iw).call(a,_(this,hm)));const n=_(this,_m),r=_(this,KS);for(const o of e){if(n.length>MVe){Dt("Ignoring additional textDivs for performance reasons."),L(this,YS,!0);return}if(o.str===void 0){if(o.type==="beginMarkedContentProps"||o.type==="beginMarkedContent"){const s=_(this,Vi);L(this,Vi,document.createElement("span")),_(this,Vi).classList.add("markedContent"),o.id&&_(this,Vi).setAttribute("id",`${o.id}`),s.append(_(this,Vi))}else o.type==="endMarkedContent"&&L(this,Vi,_(this,Vi).parentNode);continue}r.push(o.str),Q(this,mu,Wme).call(this,o)}},Wme=function(e){var b;const n=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};_(this,_m).push(n);const a=nt.transform(_(this,QS),e.transform);let i=Math.atan2(a[1],a[0]);const o=_(this,w_)[e.fontName];o.vertical&&(i+=Math.PI/2);let s=_(this,VS)&&o.fontSubstitution||o.fontFamily;s=zr.fontFamilyMap.get(s)||s;const l=Math.hypot(a[2],a[3]),u=l*Q(b=zr,wo,Xme).call(b,s,o,_(this,hm));let d,f;i===0?(d=a[4],f=a[5]-u):(d=a[4]+u*Math.sin(i),f=a[5]-u*Math.cos(i));const m="calc(var(--total-scale-factor) *",h=n.style;_(this,Vi)===_(this,A_)?(h.left=`${(100*d/_(this,WS)).toFixed(2)}%`,h.top=`${(100*f/_(this,jS)).toFixed(2)}%`):(h.left=`${m}${d.toFixed(2)}px)`,h.top=`${m}${f.toFixed(2)}px)`),h.fontSize=`${m}${(_(zr,ep)*l).toFixed(2)}px)`,h.fontFamily=s,r.fontSize=l,n.setAttribute("role","presentation"),n.textContent=e.str,n.dir=e.dir,_(this,VS)&&(n.dataset.fontName=o.fontSubstitutionLoadedName||e.fontName),i!==0&&(r.angle=i*(180/Math.PI));let E=!1;if(e.str.length>1)E=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const y=Math.abs(e.transform[0]),v=Math.abs(e.transform[3]);y!==v&&Math.max(y,v)/Math.min(y,v)>1.5&&(E=!0)}if(E&&(r.canvasWidth=o.vertical?e.height:e.width),_(this,XS).set(n,r),_(this,fu).div=n,_(this,fu).properties=r,Q(this,mu,k7).call(this,_(this,fu)),r.hasText&&_(this,Vi).append(n),r.hasEOL){const y=document.createElement("br");y.setAttribute("role","presentation"),_(this,Vi).append(y)}},k7=function(e){var s;const{div:n,properties:r,ctx:a}=e,{style:i}=n;let o="";if(_(zr,ep)>1&&(o=`scale(${1/_(zr,ep)})`),r.canvasWidth!==0&&r.hasText){const{fontFamily:l}=i,{canvasWidth:u,fontSize:d}=r;Q(s=zr,wo,M7).call(s,a,d*_(this,Jd),l);const{width:f}=a.measureText(n.textContent);f>0&&(o=`scaleX(${u*_(this,Jd)/f}) ${o}`)}r.angle!==0&&(o=`rotate(${r.angle}deg) ${o}`),o.length>0&&(i.transform=o)},wo=new WeakSet,iw=function(e=null){let n=_(this,bm).get(e||(e=""));if(!n){const r=document.createElement("canvas");r.className="hiddenCanvasElement",r.lang=e,document.body.append(r),n=r.getContext("2d",{alpha:!1,willReadFrequently:!0}),_(this,bm).set(e,n),_(this,ZS).set(n,{size:0,family:""})}return n},M7=function(e,n,r){const a=_(this,ZS).get(e);n===a.size&&r===a.family||(e.font=`${n}px ${r}`,a.size=n,a.family=r)},Kme=function(){if(_(this,ep)!==null)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),L(this,ep,e.getBoundingClientRect().height),e.remove()},Xme=function(e,n,r){const a=_(this,N_).get(e);if(a)return a;const i=Q(this,wo,iw).call(this,r);i.canvas.width=i.canvas.height=eue,Q(this,wo,M7).call(this,i,eue,e);const o=i.measureText(""),s=o.fontBoundingBoxAscent,l=Math.abs(o.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let u=.8;return s?u=s/(s+l):(Ra.platform.isFirefox&&Dt("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),n.ascent?u=n.ascent:n.descent&&(u=1+n.descent)),_(this,N_).set(e,u),u},V(zr,wo),V(zr,N_,new Map),V(zr,bm,new Map),V(zr,ZS,new WeakMap),V(zr,ep,null),V(zr,O_,new Set),zr);const LVe=100;function FB(t={}){typeof t=="string"||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new BB,{docId:n}=e,r=t.url?HYe(t.url):null,a=t.data?$Ye(t.data):null,i=t.httpHeaders||null,o=t.withCredentials===!0,s=t.password??null,l=t.range instanceof UB?t.range:null,u=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:2**16;let d=t.worker instanceof Mg?t.worker:null;const f=t.verbosity,m=typeof t.docBaseUrl=="string"&&!zE(t.docBaseUrl)?t.docBaseUrl:null,h=JA(t.cMapUrl),E=t.cMapPacked!==!1,b=t.CMapReaderFactory||(Si?QYe:Oce),y=JA(t.iccUrl),v=JA(t.standardFontDataUrl),C=t.StandardFontDataFactory||(Si?ZYe:kce),T=JA(t.wasmUrl),w=t.WasmFactory||(Si?JYe:Lce),I=t.stopAtErrors!==!0,x=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,D=t.isEvalSupported!==!1,M=typeof t.isOffscreenCanvasSupported=="boolean"?t.isOffscreenCanvasSupported:!Si,F=typeof t.isImageDecoderSupported=="boolean"?t.isImageDecoderSupported:!Si&&(Ra.platform.isFirefox||!globalThis.chrome),P=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,q=typeof t.disableFontFace=="boolean"?t.disableFontFace:Si,j=t.fontExtraProperties===!0,X=t.enableXfa===!0,B=t.ownerDocument||globalThis.document,W=t.disableRange===!0,G=t.disableStream===!0,Y=t.disableAutoFetch===!0,K=t.pdfBug===!0,J=t.CanvasFactory||(Si?XYe:jYe),$=t.FilterFactory||(Si?KYe:WYe),Z=t.enableHWA===!0,te=t.useWasm!==!1,U=l?l.length:t.length??NaN,ie=typeof t.useSystemFonts=="boolean"?t.useSystemFonts:!Si&&!q,se=typeof t.useWorkerFetch=="boolean"?t.useWorkerFetch:!!(b===Oce&&C===kce&&w===Lce&&h&&v&&T&&qE(h,document.baseURI)&&qE(v,document.baseURI)&&qE(T,document.baseURI)),ue=null;CYe(f);const ae={canvasFactory:new J({ownerDocument:B,enableHWA:Z}),filterFactory:new $({docId:n,ownerDocument:B}),cMapReaderFactory:se?null:new b({baseUrl:h,isCompressed:E}),standardFontDataFactory:se?null:new C({baseUrl:v}),wasmFactory:se?null:new w({baseUrl:T})};d||(d=Mg.create({verbosity:f,port:is.workerPort}),e._worker=d);const ce={docId:n,apiVersion:"5.4.296",data:a,password:s,disableAutoFetch:Y,rangeChunkSize:u,length:U,docBaseUrl:m,enableXfa:X,evaluatorOptions:{maxImageSize:x,disableFontFace:q,ignoreErrors:I,isEvalSupported:D,isOffscreenCanvasSupported:M,isImageDecoderSupported:F,canvasMaxAreaInBytes:P,fontExtraProperties:j,useSystemFonts:ie,useWasm:te,useWorkerFetch:se,cMapUrl:h,iccUrl:y,standardFontDataUrl:v,wasmUrl:T}},ge={ownerDocument:B,pdfBug:K,styleElement:ue,loadingParams:{disableAutoFetch:Y,enableXfa:X}};return d.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const Ee=d.messageHandler.sendWithPromise("GetDocRequest",ce,a?[a.buffer]:null);let we;if(l)we=new _Ve(l,{disableRange:W,disableStream:G});else if(!a){if(!r)throw new Error("getDocument - no `url` parameter provided.");const _e=qE(r)?vVe:Si?IVe:RVe;we=new _e({url:r,length:U,httpHeaders:i,withCredentials:o,rangeChunkSize:u,disableRange:W,disableStream:G})}return Ee.then(_e=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const me=new VE(n,_e,d.port),Re=new BVe(me,e,we,ge,ae,Z);e._transport=Re,me.send("Ready",null)})}).catch(e._capability.reject),e}const DR=class DR{constructor(){Ue(this,"_capability",Promise.withResolvers());Ue(this,"_transport",null);Ue(this,"_worker",null);Ue(this,"docId",`d${Ca(DR,IR)._++}`);Ue(this,"destroyed",!1);Ue(this,"onPassword",null);Ue(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var e,n,r,a;this.destroyed=!0;try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await((n=this._transport)==null?void 0:n.destroy())}catch(i){throw(r=this._worker)!=null&&r.port&&delete this._worker._pendingDestroy,i}this._transport=null,(a=this._worker)==null||a.destroy(),this._worker=null}async getData(){return this._transport.getData()}};IR=new WeakMap,V(DR,IR,0);let BB=DR,UB=(Lue=class{constructor(e,n,r=!1,a=null){V(this,Em,Promise.withResolvers());V(this,JS,[]);V(this,ev,[]);V(this,tv,[]);V(this,nv,[]);this.length=e,this.initialData=n,this.progressiveDone=r,this.contentDispositionFilename=a}addRangeListener(e){_(this,nv).push(e)}addProgressListener(e){_(this,tv).push(e)}addProgressiveReadListener(e){_(this,ev).push(e)}addProgressiveDoneListener(e){_(this,JS).push(e)}onDataRange(e,n){for(const r of _(this,nv))r(e,n)}onDataProgress(e,n){_(this,Em).promise.then(()=>{for(const r of _(this,tv))r(e,n)})}onDataProgressiveRead(e){_(this,Em).promise.then(()=>{for(const n of _(this,ev))n(e)})}onDataProgressiveDone(){_(this,Em).promise.then(()=>{for(const e of _(this,JS))e()})}transportReady(){_(this,Em).resolve()}requestDataRange(e,n){er("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},Em=new WeakMap,JS=new WeakMap,ev=new WeakMap,tv=new WeakMap,nv=new WeakMap,Lue);class PVe{constructor(e,n){this._pdfInfo=e,this._transport=n}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Ht(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(e,n){return this._transport.getAnnotationsByType(e,n)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:n}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(n)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class FVe{constructor(e,n,r,a=!1){V(this,Sm);V(this,hu,!1);this._pageIndex=e,this._pageInfo=n,this._transport=r,this._stats=a?new fce:null,this._pdfBug=a,this.commonObjs=r.commonObjs,this.objs=new Jce,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:n=this.rotate,offsetX:r=0,offsetY:a=0,dontFlip:i=!1}={}){return new GE({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:n,offsetX:r,offsetY:a,dontFlip:i})}getAnnotations({intent:e="display"}={}){const{renderingIntent:n}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,n)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Ht(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var e;return((e=this._transport._htmlForXfa)==null?void 0:e.children[this._pageIndex])||null}render({canvasContext:e,canvas:n=e.canvas,viewport:r,intent:a="display",annotationMode:i=ql.ENABLE,transform:o=null,background:s=null,optionalContentConfigPromise:l=null,annotationCanvasMap:u=null,pageColors:d=null,printAnnotationStorage:f=null,isEditing:m=!1,recordOperations:h=!1,operationsFilter:E=null}){var F,P,q;(F=this._stats)==null||F.time("Overall");const b=this._transport.getRenderingIntent(a,i,f,m),{renderingIntent:y,cacheKey:v}=b;L(this,hu,!1),l||(l=this._transport.getOptionalContentConfig(y));let C=this._intentStates.get(v);C||(C=Object.create(null),this._intentStates.set(v,C)),C.streamReaderCancelTimeout&&(clearTimeout(C.streamReaderCancelTimeout),C.streamReaderCancelTimeout=null);const T=!!(y&Eo.PRINT);C.displayReadyCapability||(C.displayReadyCapability=Promise.withResolvers(),C.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(P=this._stats)==null||P.time("Page Request"),this._pumpOperatorList(b));const w=!!(this._pdfBug&&((q=globalThis.StepperManager)!=null&&q.enabled)),I=!this.recordedBBoxes&&(h||w),x=j=>{var X,B;if(C.renderTasks.delete(D),I){const W=(X=D.gfx)==null?void 0:X.dependencyTracker.take();W&&(D.stepper&&D.stepper.setOperatorBBoxes(W,D.gfx.dependencyTracker.takeDebugMetadata()),h&&(this.recordedBBoxes=W))}T&&L(this,hu,!0),Q(this,Sm,Fy).call(this),j?(D.capability.reject(j),this._abortOperatorList({intentState:C,reason:j instanceof Error?j:new Error(j)})):D.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(B=globalThis.Stats)!=null&&B.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},D=new GB({callback:x,params:{canvas:n,canvasContext:e,dependencyTracker:I?new tVe(n,C.operatorList.length,w):null,viewport:r,transform:o,background:s},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:u,operatorList:C.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!T,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA,operationsFilter:E});(C.renderTasks||(C.renderTasks=new Set)).add(D);const M=D.task;return Promise.all([C.displayReadyCapability.promise,l]).then(([j,X])=>{var B;if(this.destroyed){x();return}if((B=this._stats)==null||B.time("Rendering"),!(X.renderingIntent&y))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");D.initializeGraphics({transparency:j,optionalContentConfig:X}),D.operatorListChanged()}).catch(x),M}getOperatorList({intent:e="display",annotationMode:n=ql.ENABLE,printAnnotationStorage:r=null,isEditing:a=!1}={}){var u;function i(){s.operatorList.lastChunk&&(s.opListReadCapability.resolve(s.operatorList),s.renderTasks.delete(l))}const o=this._transport.getRenderingIntent(e,n,r,a,!0);let s=this._intentStates.get(o.cacheKey);s||(s=Object.create(null),this._intentStates.set(o.cacheKey,s));let l;return s.opListReadCapability||(l=Object.create(null),l.operatorListChanged=i,s.opListReadCapability=Promise.withResolvers(),(s.renderTasks||(s.renderTasks=new Set)).add(l),s.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(u=this._stats)==null||u.time("Page Request"),this._pumpOperatorList(o)),s.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:n=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:n===!0},{highWaterMark:100,size(a){return a.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(r=>UE.textContent(r));const n=this.streamTextContent(e);return new Promise(function(r,a){function i(){o.read().then(function({value:l,done:u}){if(u){r(s);return}s.lang??(s.lang=l.lang),Object.assign(s.styles,l.styles),s.items.push(...l.items),i()},a)}const o=n.getReader(),s={items:[],styles:Object.create(null),lang:null};i()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const n of this._intentStates.values())if(this._abortOperatorList({intentState:n,reason:new Error("Page was destroyed."),force:!0}),!n.opListReadCapability)for(const r of n.renderTasks)e.push(r.completed),r.cancel();return this.objs.clear(),L(this,hu,!1),Promise.all(e)}cleanup(e=!1){L(this,hu,!0);const n=Q(this,Sm,Fy).call(this);return e&&n&&this._stats&&(this._stats=new fce),n}_startRenderPage(e,n){var a,i;const r=this._intentStates.get(n);r&&((a=this._stats)==null||a.timeEnd("Page Request"),(i=r.displayReadyCapability)==null||i.resolve(e))}_renderPageChunk(e,n){for(let r=0,a=e.length;r<a;r++)n.operatorList.fnArray.push(e.fnArray[r]),n.operatorList.argsArray.push(e.argsArray[r]);n.operatorList.lastChunk=e.lastChunk,n.operatorList.separateAnnots=e.separateAnnots;for(const r of n.renderTasks)r.operatorListChanged();e.lastChunk&&Q(this,Sm,Fy).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:n,annotationStorageSerializable:r,modifiedIds:a}){const{map:i,transfer:o}=r,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:n,annotationStorage:i,modifiedIds:a},o).getReader(),u=this._intentStates.get(n);u.streamReader=l;const d=()=>{l.read().then(({value:f,done:m})=>{if(m){u.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(f,u),d())},f=>{if(u.streamReader=null,!this._transport.destroyed){if(u.operatorList){u.operatorList.lastChunk=!0;for(const m of u.renderTasks)m.operatorListChanged();Q(this,Sm,Fy).call(this)}if(u.displayReadyCapability)u.displayReadyCapability.reject(f);else if(u.opListReadCapability)u.opListReadCapability.reject(f);else throw f}})};d()}_abortOperatorList({intentState:e,reason:n,force:r=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!r){if(e.renderTasks.size>0)return;if(n instanceof WA){let a=LVe;n.extraDelay>0&&n.extraDelay<1e3&&(a+=n.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:n,force:!0})},a);return}}if(e.streamReader.cancel(new $c(n.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[a,i]of this._intentStates)if(i===e){this._intentStates.delete(a);break}this.cleanup()}}}get stats(){return this._stats}}hu=new WeakMap,Sm=new WeakSet,Fy=function(){if(!_(this,hu)||this.destroyed)return!1;for(const{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),L(this,hu,!1),!0};const vr=class vr{constructor({name:e=null,port:n=null,verbosity:r=AYe()}={}){V(this,yi);V(this,tp,Promise.withResolvers());V(this,rl,null);V(this,gu,null);V(this,vm,null);if(this.name=e,this.destroyed=!1,this.verbosity=r,n){if(_(vr,Tm).has(n))throw new Error("Cannot use more than one PDFWorker per port.");_(vr,Tm).set(n,this),Q(this,yi,Qme).call(this,n)}else Q(this,yi,Zme).call(this)}get promise(){return _(this,tp).promise}get port(){return _(this,gu)}get messageHandler(){return _(this,rl)}destroy(){var e,n;this.destroyed=!0,(e=_(this,vm))==null||e.terminate(),L(this,vm,null),_(vr,Tm).delete(_(this,gu)),L(this,gu,null),(n=_(this,rl))==null||n.destroy(),L(this,rl,null)}static create(e){const n=_(this,Tm).get(e==null?void 0:e.port);if(n){if(n._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new vr(e)}static get workerSrc(){if(is.workerSrc)return is.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Ht(this,"_setupFakeWorkerGlobal",(async()=>_(this,I_,sw)?_(this,I_,sw):(await import(this.workerSrc)).WorkerMessageHandler)())}};tp=new WeakMap,rl=new WeakMap,gu=new WeakMap,vm=new WeakMap,kR=new WeakMap,ym=new WeakMap,Tm=new WeakMap,yi=new WeakSet,ow=function(){_(this,tp).resolve(),_(this,rl).send("configure",{verbosity:this.verbosity})},Qme=function(e){L(this,gu,e),L(this,rl,new VE("main","worker",e)),_(this,rl).on("ready",()=>{}),Q(this,yi,ow).call(this)},Zme=function(){if(_(vr,ym)||_(vr,I_,sw)){Q(this,yi,By).call(this);return}let{workerSrc:e}=vr;try{vr._isSameOrigin(window.location,e)||(e=vr._createCDNWrapper(new URL(e,window.location).href));const n=new Worker(e,{type:"module"}),r=new VE("main","worker",n),a=()=>{i.abort(),r.destroy(),n.terminate(),this.destroyed?_(this,tp).reject(new Error("Worker was destroyed")):Q(this,yi,By).call(this)},i=new AbortController;n.addEventListener("error",()=>{_(this,vm)||a()},{signal:i.signal}),r.on("test",s=>{if(i.abort(),this.destroyed||!s){a();return}L(this,rl,r),L(this,gu,n),L(this,vm,n),Q(this,yi,ow).call(this)}),r.on("ready",s=>{if(i.abort(),this.destroyed){a();return}try{o()}catch{Q(this,yi,By).call(this)}});const o=()=>{const s=new Uint8Array;r.send("test",s,[s.buffer])};o();return}catch{VA("The worker has been disabled.")}Q(this,yi,By).call(this)},By=function(){_(vr,ym)||(Dt("Setting up fake worker."),L(vr,ym,!0)),vr._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){_(this,tp).reject(new Error("Worker was destroyed"));return}const n=new VYe;L(this,gu,n);const r=`fake${Ca(vr,kR)._++}`,a=new VE(r+"_worker",r,n);e.setup(a,n),L(this,rl,new VE(r,r+"_worker",n)),Q(this,yi,ow).call(this)}).catch(e=>{_(this,tp).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})},I_=new WeakSet,sw=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},V(vr,I_),V(vr,kR,0),V(vr,ym,!1),V(vr,Tm,new WeakMap),Si&&(L(vr,ym,!0),is.workerSrc||(is.workerSrc="./pdf.worker.mjs")),vr._isSameOrigin=(e,n)=>{const r=URL.parse(e);if(!(r!=null&&r.origin)||r.origin==="null")return!1;const a=new URL(n,r);return r.origin===a.origin},vr._createCDNWrapper=e=>{const n=`await import("${e}");`;return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))},vr.fromPort=e=>{if(MYe("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return vr.create(e)};let Mg=vr;class BVe{constructor(e,n,r,a,i,o){V(this,Cm);V(this,_u,new Map);V(this,ic,new Map);V(this,D_,new Map);V(this,k_,new Map);V(this,bu,null);this.messageHandler=e,this.loadingTask=n,this.commonObjs=new Jce,this.fontLoader=new zYe({ownerDocument:a.ownerDocument,styleElement:a.styleElement}),this.loadingParams=a.loadingParams,this._params=a,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.wasmFactory=i.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=o,this.setupMessageHandler()}get annotationStorage(){return Ht(this,"annotationStorage",new AB)}getRenderingIntent(e,n=ql.ENABLE,r=null,a=!1,i=!1){let o=Eo.DISPLAY,s=CB;switch(e){case"any":o=Eo.ANY;break;case"display":break;case"print":o=Eo.PRINT;break;default:Dt(`getRenderingIntent - invalid intent: ${e}`)}const l=o&Eo.PRINT&&r instanceof Ace?r:this.annotationStorage;switch(n){case ql.DISABLE:o+=Eo.ANNOTATIONS_DISABLE;break;case ql.ENABLE:break;case ql.ENABLE_FORMS:o+=Eo.ANNOTATIONS_FORMS;break;case ql.ENABLE_STORAGE:o+=Eo.ANNOTATIONS_STORAGE,s=l.serializable;break;default:Dt(`getRenderingIntent - invalid annotationMode: ${n}`)}a&&(o+=Eo.IS_EDITING),i&&(o+=Eo.OPLIST);const{ids:u,hash:d}=l.modifiedIds,f=[o,s.hash,d];return{renderingIntent:o,cacheKey:f.join("_"),annotationStorageSerializable:s,modifiedIds:u}}destroy(){var r;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(r=_(this,bu))==null||r.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const a of _(this,ic).values())e.push(a._destroy());_(this,ic).clear(),_(this,D_).clear(),_(this,k_).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then(()=>{var a,i;this.commonObjs.clear(),this.fontLoader.clear(),_(this,_u).clear(),this.filterFactory.destroy(),XE.cleanup(),(a=this._networkStream)==null||a.cancelAllRequests(new $c("Worker was terminated.")),(i=this.messageHandler)==null||i.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:n}=this;e.on("GetReader",(r,a)=>{ln(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=i=>{this._lastProgress={loaded:i.loaded,total:i.total}},a.onPull=()=>{this._fullReader.read().then(function({value:i,done:o}){if(o){a.close();return}ln(i instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),a.enqueue(new Uint8Array(i),1,[i])}).catch(i=>{a.error(i)})},a.onCancel=i=>{this._fullReader.cancel(i),a.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("ReaderHeadersReady",async r=>{var s;await this._fullReader.headersReady;const{isStreamingSupported:a,isRangeSupported:i,contentLength:o}=this._fullReader;return(!a||!i)&&(this._lastProgress&&((s=n.onProgress)==null||s.call(n,this._lastProgress)),this._fullReader.onProgress=l=>{var u;(u=n.onProgress)==null||u.call(n,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:a,isRangeSupported:i,contentLength:o}}),e.on("GetRangeReader",(r,a)=>{ln(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(r.begin,r.end);if(!i){a.close();return}a.onPull=()=>{i.read().then(function({value:o,done:s}){if(s){a.close();return}ln(o instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),a.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{a.error(o)})},a.onCancel=o=>{i.cancel(o),a.ready.catch(s=>{if(!this.destroyed)throw s})}}),e.on("GetDoc",({pdfInfo:r})=>{this._numPages=r.numPages,this._htmlForXfa=r.htmlForXfa,delete r.htmlForXfa,n._capability.resolve(new PVe(r,this))}),e.on("DocException",r=>{n._capability.reject(Gi(r))}),e.on("PasswordRequest",r=>{L(this,bu,Promise.withResolvers());try{if(!n.onPassword)throw Gi(r);const a=i=>{i instanceof Error?_(this,bu).reject(i):_(this,bu).resolve({password:i})};n.onPassword(a,r.code)}catch(a){_(this,bu).reject(a)}return _(this,bu).promise}),e.on("DataLoaded",r=>{var a;(a=n.onProgress)==null||a.call(n,{loaded:r.length,total:r.length}),this.downloadInfoCapability.resolve(r)}),e.on("StartRenderPage",r=>{if(this.destroyed)return;_(this,ic).get(r.pageIndex)._startRenderPage(r.transparency,r.cacheKey)}),e.on("commonobj",([r,a,i])=>{var o;if(this.destroyed||this.commonObjs.has(r))return null;switch(a){case"Font":if("error"in i){const f=i.error;Dt(`Error during font loading: ${f}`),this.commonObjs.resolve(r,f);break}const s=new MB(i),l=this._params.pdfBug&&((o=globalThis.FontInspector)!=null&&o.enabled)?(f,m)=>globalThis.FontInspector.fontAdded(f,m):null,u=new qYe(s,l,i.extra,i.charProcOperatorList);this.fontLoader.bind(u).catch(()=>e.sendWithPromise("FontFallback",{id:r})).finally(()=>{!u.fontExtraProperties&&u.data&&u.clearData(),this.commonObjs.resolve(r,u)});break;case"CopyLocalImage":const{imageRef:d}=i;ln(d,"The imageRef must be defined.");for(const f of _(this,ic).values())for(const[,m]of f.objs)if((m==null?void 0:m.ref)===d)return m.dataLen?(this.commonObjs.resolve(r,structuredClone(m)),m.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(r,i);break;default:throw new Error(`Got unknown common object type ${a}`)}return null}),e.on("obj",([r,a,i,o])=>{var l;if(this.destroyed)return;const s=_(this,ic).get(a);if(!s.objs.has(r)){if(s._intentStates.size===0){(l=o==null?void 0:o.bitmap)==null||l.close();return}switch(i){case"Image":case"Pattern":s.objs.resolve(r,o);break;default:throw new Error(`Got unknown object type ${i}`)}}}),e.on("DocProgress",r=>{var a;this.destroyed||(a=n.onProgress)==null||a.call(n,{loaded:r.loaded,total:r.total})}),e.on("FetchBinaryData",async r=>{if(this.destroyed)throw new Error("Worker was destroyed.");const a=this[r.type];if(!a)throw new Error(`${r.type} not initialized, see the \`useWorkerFetch\` parameter.`);return a.fetch(r)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var r;this.annotationStorage.size<=0&&Dt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:((r=this._fullReader)==null?void 0:r.filename)??null},n).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const n=e-1,r=_(this,D_).get(n);if(r)return r;const a=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&_(this,k_).set(i.refStr,e);const o=new FVe(n,i,this,this._params.pdfBug);return _(this,ic).set(n,o),o});return _(this,D_).set(n,a),a}getPageIndex(e){return RB(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,n){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:n})}getFieldObjects(){return Q(this,Cm,Uy).call(this,"GetFieldObjects")}hasJSActions(){return Q(this,Cm,Uy).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(e,n){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:e,pageIndexesToSkip:n})}getDocJSActions(){return Q(this,Cm,Uy).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return Q(this,Cm,Uy).call(this,"GetOptionalContentConfig").then(n=>new gVe(n,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",n=_(this,_u).get(e);if(n)return n;const r=this.messageHandler.sendWithPromise(e,null).then(a=>{var i,o;return{info:a[0],metadata:a[1]?new mVe(a[1]):null,contentDispositionFilename:((i=this._fullReader)==null?void 0:i.filename)??null,contentLength:((o=this._fullReader)==null?void 0:o.contentLength)??null}});return _(this,_u).set(e,r),r}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const n of _(this,ic).values())if(!n.cleanup())throw new Error(`startCleanup: Page ${n.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),_(this,_u).clear(),this.filterFactory.destroy(!0),XE.cleanup()}}cachedPageNumber(e){if(!RB(e))return null;const n=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return _(this,k_).get(n)??null}}_u=new WeakMap,ic=new WeakMap,D_=new WeakMap,k_=new WeakMap,bu=new WeakMap,Cm=new WeakSet,Uy=function(e,n=null){const r=_(this,_u).get(e);if(r)return r;const a=this.messageHandler.sendWithPromise(e,n);return _(this,_u).set(e,a),a};class UVe{constructor(e){V(this,np,null);Ue(this,"onContinue",null);Ue(this,"onError",null);L(this,np,e)}get promise(){return _(this,np).capability.promise}cancel(e=0){_(this,np).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=_(this,np).operatorList;if(!e)return!1;const{annotationCanvasMap:n}=_(this,np);return e.form||e.canvas&&(n==null?void 0:n.size)>0}}np=new WeakMap;const Rm=class Rm{constructor({callback:e,params:n,objs:r,commonObjs:a,annotationCanvasMap:i,operatorList:o,pageIndex:s,canvasFactory:l,filterFactory:u,useRequestAnimationFrame:d=!1,pdfBug:f=!1,pageColors:m=null,enableHWA:h=!1,operationsFilter:E=null}){V(this,rp,null);this.callback=e,this.params=n,this.objs=r,this.commonObjs=a,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=s,this.canvasFactory=l,this.filterFactory=u,this._pdfBug=f,this.pageColors=m,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new UVe(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=n.canvas,this._canvasContext=n.canvas?null:n.canvasContext,this._enableHWA=h,this._dependencyTracker=n.dependencyTracker,this._operationsFilter=E}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:n}){var l,u;if(this.cancelled)return;if(this._canvas){if(_(Rm,Am).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");_(Rm,Am).add(this._canvas)}this._pdfBug&&((l=globalThis.StepperManager)!=null&&l.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:r,transform:a,background:i,dependencyTracker:o}=this.params,s=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Dg(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors,o),this.gfx.beginDrawing({transform:a,viewport:r,transparency:e,background:i}),this.operatorListIdx=0,this.graphicsReady=!0,(u=this.graphicsReadyCallback)==null||u.call(this)}cancel(e=null,n=0){var r,a,i;this.running=!1,this.cancelled=!0,(r=this.gfx)==null||r.endDrawing(),_(this,rp)&&(window.cancelAnimationFrame(_(this,rp)),L(this,rp,null)),_(Rm,Am).delete(this._canvas),e||(e=new WA(`Rendering cancelled, page ${this._pageIndex+1}`,n)),this.callback(e),(i=(a=this.task).onError)==null||i.call(a,e)}operatorListChanged(){var e,n;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.gfx.dependencyTracker)==null||e.growOperationsCount(this.operatorList.fnArray.length),(n=this.stepper)==null||n.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?L(this,rp,window.requestAnimationFrame(()=>{L(this,rp,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_(Rm,Am).delete(this._canvas),this.callback())))}};rp=new WeakMap,Am=new WeakMap,V(Rm,Am,new WeakSet);let GB=Rm;const QE="5.4.296",tue="f56dc8601",ji=class ji{constructor({editor:e=null,uiManager:n=null}){V(this,$n);V(this,xo,null);V(this,wm,null);V(this,M_);V(this,ga,null);V(this,rv,!1);V(this,L_,!1);V(this,Eu,null);V(this,av);V(this,ap,null);V(this,al,null);var r,a;e?(L(this,L_,!1),L(this,Eu,e)):L(this,L_,!0),L(this,al,(e==null?void 0:e._uiManager)||n),L(this,av,_(this,al)._eventBus),L(this,M_,((r=e==null?void 0:e.color)==null?void 0:r.toUpperCase())||((a=_(this,al))==null?void 0:a.highlightColors.values().next().value)||"#FFFF98"),_(ji,iv)||L(ji,iv,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return Ht(this,"_keyboardManager",new $E([[["Escape","mac+Escape"],ji.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ji.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ji.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ji.prototype._moveToPrevious],[["Home","mac+Home"],ji.prototype._moveToBeginning],[["End","mac+End"],ji.prototype._moveToEnd]]))}renderButton(){const e=L(this,xo,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.ariaHasPopup="true",_(this,Eu)&&(e.ariaControls=`${_(this,Eu).id}_colorpicker_dropdown`);const n=_(this,al)._signal;e.addEventListener("click",Q(this,$n,vh).bind(this),{signal:n}),e.addEventListener("keydown",Q(this,$n,F7).bind(this),{signal:n});const r=L(this,wm,document.createElement("span"));return r.className="swatch",r.ariaHidden="true",r.style.backgroundColor=_(this,M_),e.append(r),e}renderMainDropdown(){const e=L(this,ga,Q(this,$n,L7).call(this));return e.ariaOrientation="horizontal",e.ariaLabelledBy="highlightColorPickerLabel",e}_colorSelectFromKeyboard(e){if(e.target===_(this,xo)){Q(this,$n,vh).call(this,e);return}const n=e.target.getAttribute("data-color");n&&Q(this,$n,P7).call(this,n,e)}_moveToNext(e){var n,r;if(!_(this,$n,ef)){Q(this,$n,vh).call(this,e);return}if(e.target===_(this,xo)){(n=_(this,ga).firstChild)==null||n.focus();return}(r=e.target.nextSibling)==null||r.focus()}_moveToPrevious(e){var n,r;if(e.target===((n=_(this,ga))==null?void 0:n.firstChild)||e.target===_(this,xo)){_(this,$n,ef)&&this._hideDropdownFromKeyboard();return}_(this,$n,ef)||Q(this,$n,vh).call(this,e),(r=e.target.previousSibling)==null||r.focus()}_moveToBeginning(e){var n;if(!_(this,$n,ef)){Q(this,$n,vh).call(this,e);return}(n=_(this,ga).firstChild)==null||n.focus()}_moveToEnd(e){var n;if(!_(this,$n,ef)){Q(this,$n,vh).call(this,e);return}(n=_(this,ga).lastChild)==null||n.focus()}hideDropdown(){var e,n;(e=_(this,ga))==null||e.classList.add("hidden"),_(this,xo).ariaExpanded="false",(n=_(this,ap))==null||n.abort(),L(this,ap,null)}_hideDropdownFromKeyboard(){var e;if(!_(this,L_)){if(!_(this,$n,ef)){(e=_(this,Eu))==null||e.unselect();return}this.hideDropdown(),_(this,xo).focus({preventScroll:!0,focusVisible:_(this,rv)})}}updateColor(e){if(_(this,wm)&&(_(this,wm).style.backgroundColor=e),!_(this,ga))return;const n=_(this,al).highlightColors.values();for(const r of _(this,ga).children)r.ariaSelected=n.next().value===e.toUpperCase()}destroy(){var e,n;(e=_(this,xo))==null||e.remove(),L(this,xo,null),L(this,wm,null),(n=_(this,ga))==null||n.remove(),L(this,ga,null)}};xo=new WeakMap,wm=new WeakMap,M_=new WeakMap,ga=new WeakMap,rv=new WeakMap,L_=new WeakMap,Eu=new WeakMap,av=new WeakMap,ap=new WeakMap,al=new WeakMap,iv=new WeakMap,$n=new WeakSet,L7=function(){const e=document.createElement("div"),n=_(this,al)._signal;e.addEventListener("contextmenu",So,{signal:n}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),_(this,Eu)&&(e.id=`${_(this,Eu).id}_colorpicker_dropdown`);for(const[r,a]of _(this,al).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",a),i.title=r,i.setAttribute("data-l10n-id",_(ji,iv)[r]);const o=document.createElement("span");i.append(o),o.className="swatch",o.style.backgroundColor=a,i.ariaSelected=a===_(this,M_),i.addEventListener("click",Q(this,$n,P7).bind(this,a),{signal:n}),e.append(i)}return e.addEventListener("keydown",Q(this,$n,F7).bind(this),{signal:n}),e},P7=function(e,n){n.stopPropagation(),_(this,av).dispatch("switchannotationeditorparams",{source:this,type:an.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)},F7=function(e){ji._keyboardManager.exec(this,e)},vh=function(e){if(_(this,$n,ef)){this.hideDropdown();return}if(L(this,rv,e.detail===0),_(this,ap)||(L(this,ap,new AbortController),window.addEventListener("pointerdown",Q(this,$n,Jme).bind(this),{signal:_(this,al).combinedSignal(_(this,ap))})),_(this,xo).ariaExpanded="true",_(this,ga)){_(this,ga).classList.remove("hidden");return}const n=L(this,ga,Q(this,$n,L7).call(this));_(this,xo).append(n)},Jme=function(e){var n;(n=_(this,ga))!=null&&n.contains(e.target)||this.hideDropdown()},ef=function(){return _(this,ga)&&!_(this,ga).classList.contains("hidden")},V(ji,iv,null);let ZE=ji;const xm=class xm{constructor(e){V(this,oc,null);V(this,ov,null);V(this,P_,null);L(this,ov,e),L(this,P_,e._uiManager),_(xm,sv)||L(xm,sv,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(_(this,oc))return _(this,oc);const{editorType:e,colorType:n,colorValue:r}=_(this,ov),a=L(this,oc,document.createElement("input"));return a.type="color",a.value=r||"#000000",a.className="basicColorPicker",a.tabIndex=0,a.setAttribute("data-l10n-id",_(xm,sv)[e]),a.addEventListener("input",()=>{_(this,P_).updateParams(n,a.value)},{signal:_(this,P_)._signal}),a}update(e){_(this,oc)&&(_(this,oc).value=e)}destroy(){var e;(e=_(this,oc))==null||e.remove(),L(this,oc,null)}hideDropdown(){}};oc=new WeakMap,ov=new WeakMap,P_=new WeakMap,sv=new WeakMap,V(xm,sv,null);let cR=xm;function nue(t){return Math.floor(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,"0")}function JE(t){return Math.max(0,Math.min(255,255*t))}class rue{static CMYK_G([e,n,r,a]){return["G",1-Math.min(1,.3*e+.59*r+.11*n+a)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=JE(e),[e,e,e]}static G_HTML([e]){const n=nue(e);return`#${n}${n}${n}`}static RGB_G([e,n,r]){return["G",.3*e+.59*n+.11*r]}static RGB_rgb(e){return e.map(JE)}static RGB_HTML(e){return`#${e.map(nue).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,n,r,a]){return["RGB",1-Math.min(1,e+a),1-Math.min(1,r+a),1-Math.min(1,n+a)]}static CMYK_rgb([e,n,r,a]){return[JE(1-Math.min(1,e+a)),JE(1-Math.min(1,r+a)),JE(1-Math.min(1,n+a))]}static CMYK_HTML(e){const n=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(n)}static RGB_CMYK([e,n,r]){const a=1-e,i=1-n,o=1-r,s=Math.min(a,i,o);return["CMYK",a,i,o,s]}}class GVe{create(e,n,r=!1){if(e<=0||n<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");return a.setAttribute("version","1.1"),r||(a.setAttribute("width",`${e}px`),a.setAttribute("height",`${n}px`)),a.setAttribute("preserveAspectRatio","none"),a.setAttribute("viewBox",`0 0 ${e} ${n}`),a}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){er("Abstract method `_createSVG` called.")}}class eS extends GVe{_createSVG(e){return document.createElementNS(Yc,e)}}const zVe=9,Lf=new WeakSet,qVe=new Date().getTimezoneOffset()*60*1e3;class aue{static create(e){switch(e.data.annotationType){case Xr.LINK:return new zB(e);case Xr.TEXT:return new $Ve(e);case Xr.WIDGET:switch(e.data.fieldType){case"Tx":return new YVe(e);case"Btn":return e.data.radioButton?new iue(e):e.data.checkBox?new jVe(e):new WVe(e);case"Ch":return new KVe(e);case"Sig":return new VVe(e)}return new Pf(e);case Xr.POPUP:return new qB(e);case Xr.FREETEXT:return new oue(e);case Xr.LINE:return new QVe(e);case Xr.SQUARE:return new ZVe(e);case Xr.CIRCLE:return new JVe(e);case Xr.POLYLINE:return new sue(e);case Xr.CARET:return new tje(e);case Xr.INK:return new HB(e);case Xr.POLYGON:return new eje(e);case Xr.HIGHLIGHT:return new lue(e);case Xr.UNDERLINE:return new nje(e);case Xr.SQUIGGLY:return new rje(e);case Xr.STRIKEOUT:return new aje(e);case Xr.STAMP:return new cue(e);case Xr.FILEATTACHMENT:return new ije(e);default:return new Dr(e)}}}const s6=class s6{constructor(e,{isRenderable:n=!1,ignoreBorder:r=!1,createQuadrilaterals:a=!1}={}){V(this,lv);V(this,Nm,null);V(this,F_,!1);V(this,hs,null);this.isRenderable=n,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableComment=e.enableComment,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,n&&(this.container=this._createContainer(r)),a&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:n}){return!!(e!=null&&e.str||n!=null&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return s6._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var r;const{data:e}=this,n=(r=this.annotationStorage)==null?void 0:r.getEditor(e.id);return n?n.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var s;const e=(s=this.annotationStorage)==null?void 0:s.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const{quadPoints:n,inkLists:r,rect:a}=this.data;let i=-1/0,o=-1/0;if((n==null?void 0:n.length)>=8){for(let l=0;l<n.length;l+=8)n[l+1]>o?(o=n[l+1],i=n[l+2]):n[l+1]===o&&(i=Math.max(i,n[l+2]));return[i,o]}if((r==null?void 0:r.length)>=1){for(const l of r)for(let u=0,d=l.length;u<d;u+=2)l[u+1]>o?(o=l[u+1],i=l[u]):l[u+1]===o&&(i=Math.max(i,l[u]));if(i!==1/0)return[i,o]}return a?[a[2],a[3]]:null}_normalizePoint(e){const{page:{view:n},viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:i,pageY:o}}}=this.parent;return e[1]=n[3]-e[1]+n[1],e[0]=100*(e[0]-i)/r,e[1]=100*(e[1]-o)/a,e}get commentText(){var n,r,a;const{data:e}=this;return((r=(n=this.annotationStorage.getRawValue(`${ME}${e.id}`))==null?void 0:n.popup)==null?void 0:r.contents)||((a=e.contentsObj)==null?void 0:a.str)||""}set commentText(e){const{data:n}=this,r={deleted:!e,contents:e||""};this.annotationStorage.updateEditor(n.id,{popup:r})||this.annotationStorage.setValue(`${ME}${n.id}`,{id:n.id,annotationType:n.annotationType,pageIndex:this.parent.page._pageIndex,popup:r,popupRef:n.popupRef,modificationDate:new Date}),e||this.removePopup()}removePopup(){var e,n;(n=((e=_(this,hs))==null?void 0:e.popup)||this.popup)==null||n.remove(),L(this,hs,this.popup=null)}updateEdited(e){var i;if(!this.container)return;e.rect&&(_(this,Nm)||L(this,Nm,{rect:this.data.rect.slice(0)}));const{rect:n,popup:r}=e;n&&Q(this,lv,B7).call(this,n);let a=((i=_(this,hs))==null?void 0:i.popup)||this.popup;!a&&(r!=null&&r.text)&&(this._createPopup(r),a=_(this,hs).popup),a&&(a.updateEdited(e),r!=null&&r.deleted&&(a.remove(),L(this,hs,null),this.popup=null))}resetEdited(){var e;_(this,Nm)&&(Q(this,lv,B7).call(this,_(this,Nm).rect),(e=_(this,hs))==null||e.popup.resetEdited(),L(this,Nm,null))}_createContainer(e){const{data:n,parent:{page:r,viewport:a}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",n.id),!(this instanceof Pf)&&!(this instanceof zB)&&(i.tabIndex=0);const{style:o}=i;if(o.zIndex=this.parent.zIndex,this.parent.zIndex+=2,n.alternativeText&&(i.title=n.alternativeText),n.noRotate&&i.classList.add("norotate"),!n.rect||this instanceof qB){const{rotation:b}=n;return!n.hasOwnCanvas&&b!==0&&this.setRotation(b,i),i}const{width:s,height:l}=this;if(!e&&n.borderStyle.width>0){o.borderWidth=`${n.borderStyle.width}px`;const b=n.borderStyle.horizontalCornerRadius,y=n.borderStyle.verticalCornerRadius;if(b>0||y>0){const C=`calc(${b}px * var(--total-scale-factor)) / calc(${y}px * var(--total-scale-factor))`;o.borderRadius=C}else if(this instanceof iue){const C=`calc(${s}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;o.borderRadius=C}switch(n.borderStyle.style){case Rg.SOLID:o.borderStyle="solid";break;case Rg.DASHED:o.borderStyle="dashed";break;case Rg.BEVELED:Dt("Unimplemented border style: beveled");break;case Rg.INSET:Dt("Unimplemented border style: inset");break;case Rg.UNDERLINE:o.borderBottomStyle="solid";break}const v=n.borderColor||null;v?(L(this,F_,!0),o.borderColor=nt.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):o.borderWidth=0}const u=nt.normalizeRect([n.rect[0],r.view[3]-n.rect[1]+r.view[1],n.rect[2],r.view[3]-n.rect[3]+r.view[1]]),{pageWidth:d,pageHeight:f,pageX:m,pageY:h}=a.rawDims;o.left=`${100*(u[0]-m)/d}%`,o.top=`${100*(u[1]-h)/f}%`;const{rotation:E}=n;return n.hasOwnCanvas||E===0?(o.width=`${100*s/d}%`,o.height=`${100*l/f}%`):this.setRotation(E,i),i}setRotation(e,n=this.container){if(!this.data.rect)return;const{pageWidth:r,pageHeight:a}=this.parent.viewport.rawDims;let{width:i,height:o}=this;e%180!==0&&([i,o]=[o,i]),n.style.width=`${100*i/r}%`,n.style.height=`${100*o/a}%`,n.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(n,r,a)=>{const i=a.detail[n],o=i[0],s=i.slice(1);a.target.style[r]=rue[`${o}_HTML`](s),this.annotationStorage.setValue(this.data.id,{[r]:rue[`${o}_rgb`](s)})};return Ht(this,"_commonActions",{display:n=>{const{display:r}=n.detail,a=r%2===1;this.container.style.visibility=a?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:a,noPrint:r===1||r===2})},print:n=>{this.annotationStorage.setValue(this.data.id,{noPrint:!n.detail.print})},hidden:n=>{const{hidden:r}=n.detail;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:r,noView:r})},focus:n=>{setTimeout(()=>n.target.focus({preventScroll:!1}),0)},userName:n=>{n.target.title=n.detail.userName},readonly:n=>{n.target.disabled=n.detail.readonly},required:n=>{this._setRequired(n.target,n.detail.required)},bgColor:n=>{e("bgColor","backgroundColor",n)},fillColor:n=>{e("fillColor","backgroundColor",n)},fgColor:n=>{e("fgColor","color",n)},textColor:n=>{e("textColor","color",n)},borderColor:n=>{e("borderColor","borderColor",n)},strokeColor:n=>{e("strokeColor","borderColor",n)},rotation:n=>{const r=n.detail.rotation;this.setRotation(r),this.annotationStorage.setValue(this.data.id,{rotation:r})}})}_dispatchEventFromSandbox(e,n){const r=this._commonActions;for(const a of Object.keys(n.detail)){const i=e[a]||r[a];i==null||i(n)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const n=this.annotationStorage.getRawValue(this.data.id);if(!n)return;const r=this._commonActions;for(const[a,i]of Object.entries(n)){const o=r[a];if(o){const s={detail:{[a]:i},target:e};o(s),delete n[a]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[n,r,a,i]=this.data.rect.map(b=>Math.fround(b));if(e.length===8){const[b,y,v,C]=e.subarray(2,6);if(a===b&&i===y&&n===v&&r===C)return}const{style:o}=this.container;let s;if(_(this,F_)){const{borderColor:b,borderWidth:y}=o;o.borderWidth=0,s=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${b}" stroke-width="${y}">`],this.container.classList.add("hasBorder")}const l=a-n,u=i-r,{svgFactory:d}=this,f=d.createElement("svg");f.classList.add("quadrilateralsContainer"),f.setAttribute("width",0),f.setAttribute("height",0),f.role="none";const m=d.createElement("defs");f.append(m);const h=d.createElement("clipPath"),E=`clippath_${this.data.id}`;h.setAttribute("id",E),h.setAttribute("clipPathUnits","objectBoundingBox"),m.append(h);for(let b=2,y=e.length;b<y;b+=8){const v=e[b],C=e[b+1],T=e[b+2],w=e[b+3],I=d.createElement("rect"),x=(T-n)/l,D=(i-C)/u,M=(v-T)/l,F=(C-w)/u;I.setAttribute("x",x),I.setAttribute("y",D),I.setAttribute("width",M),I.setAttribute("height",F),h.append(I),s==null||s.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${D}" width="${M}" height="${F}"/>`)}_(this,F_)&&(s.push("</g></svg>')"),o.backgroundImage=s.join("")),this.container.append(f),this.container.style.clipPath=`url(#${E})`}_createPopup(e=null){const{data:n}=this;let r,a;e?(r={str:e.text},a=e.date):(r=n.contentsObj,a=n.modificationDate);const i=L(this,hs,new qB({data:{color:n.color,titleObj:n.titleObj,modificationDate:a,contentsObj:r,richText:n.richText,parentRect:n.rect,borderStyle:0,id:`popup_${n.id}`,rotation:n.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent._commentManager||this.parent.div.append(i.render())}get hasPopupElement(){return!!(_(this,hs)||this.popup||this.data.popupRef)}get extraPopupElement(){return _(this,hs)}render(){er("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,n=null){const r=[];if(this._fieldObjects){const a=this._fieldObjects[e];if(a)for(const{page:i,id:o,exportValues:s}of a){if(i===-1||o===n)continue;const l=typeof s=="string"?s:null,u=document.querySelector(`[data-element-id="${o}"]`);if(u&&!Lf.has(u)){Dt(`_getElementsByName - element not allowed: ${o}`);continue}r.push({id:o,exportValue:l,domElement:u})}return r}for(const a of document.getElementsByName(e)){const{exportValue:i}=a,o=a.getAttribute("data-element-id");o!==n&&Lf.has(a)&&r.push({id:o,exportValue:i,domElement:a})}return r}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const n of e)n.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:n}}=this;this.container.addEventListener("dblclick",()=>{var r;(r=this.linkService.eventBus)==null||r.dispatch("switchannotationeditormode",{source:this,mode:e,editId:n,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};Nm=new WeakMap,F_=new WeakMap,hs=new WeakMap,lv=new WeakSet,B7=function(e){const{container:{style:n},data:{rect:r,rotation:a},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:o,pageX:s,pageY:l}}}}=this;r==null||r.splice(0,4,...e),n.left=`${100*(e[0]-s)/i}%`,n.top=`${100*(o-e[3]+l)/o}%`,a===0?(n.width=`${100*(e[2]-e[0])/i}%`,n.height=`${100*(e[3]-e[1])/o}%`):this.setRotation(a)};let Dr=s6;class HVe extends Dr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.editor=e.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:e}=this;e.hasComment&&(this._createPopup(e.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e,e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class zB extends Dr{constructor(n,r=null){super(n,{isRenderable:!0,ignoreBorder:!!(r!=null&&r.ignoreBorder),createQuadrilaterals:!0});V(this,No);this.isTooltipOnly=n.data.isTooltipOnly}render(){const{data:n,linkService:r}=this,a=document.createElement("a");a.setAttribute("data-element-id",n.id);let i=!1;return n.url?(r.addLinkAttributes(a,n.url,n.newWindow),i=!0):n.action?(this._bindNamedAction(a,n.action,n.overlaidText),i=!0):n.attachment?(Q(this,No,ehe).call(this,a,n.attachment,n.overlaidText,n.attachmentDest),i=!0):n.setOCGState?(Q(this,No,the).call(this,a,n.setOCGState,n.overlaidText),i=!0):n.dest?(this._bindLink(a,n.dest,n.overlaidText),i=!0):(n.actions&&(n.actions.Action||n.actions["Mouse Up"]||n.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(a,n),i=!0),n.resetForm?(this._bindResetFormAction(a,n.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(a,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(a),this.container}_bindLink(n,r,a=""){n.href=this.linkService.getDestinationHash(r),n.onclick=()=>(r&&this.linkService.goToDestination(r),!1),(r||r==="")&&Q(this,No,yh).call(this),a&&(n.title=a)}_bindNamedAction(n,r,a=""){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeNamedAction(r),!1),a&&(n.title=a),Q(this,No,yh).call(this)}_bindJSAction(n,r){n.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(r.actions)){const o=a.get(i);o&&(n[o]=()=>{var s;return(s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r.id,name:i}}),!1})}r.overlaidText&&(n.title=r.overlaidText),n.onclick||(n.onclick=()=>!1),Q(this,No,yh).call(this)}_bindResetFormAction(n,r){const a=n.onclick;if(a||(n.href=this.linkService.getAnchorUrl("")),Q(this,No,yh).call(this),!this._fieldObjects){Dt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),a||(n.onclick=()=>!1);return}n.onclick=()=>{var f;a==null||a();const{fields:i,refs:o,include:s}=r,l=[];if(i.length!==0||o.length!==0){const m=new Set(o);for(const h of i){const E=this._fieldObjects[h]||[];for(const{id:b}of E)m.add(b)}for(const h of Object.values(this._fieldObjects))for(const E of h)m.has(E.id)===s&&l.push(E)}else for(const m of Object.values(this._fieldObjects))l.push(...m);const u=this.annotationStorage,d=[];for(const m of l){const{id:h}=m;switch(d.push(h),m.type){case"text":{const b=m.defaultValue||"";u.setValue(h,{value:b});break}case"checkbox":case"radiobutton":{const b=m.defaultValue===m.exportValues;u.setValue(h,{value:b});break}case"combobox":case"listbox":{const b=m.defaultValue||"";u.setValue(h,{value:b});break}default:continue}const E=document.querySelector(`[data-element-id="${h}"]`);if(E){if(!Lf.has(E)){Dt(`_bindResetFormAction - element not allowed: ${h}`);continue}}else continue;E.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((f=this.linkService.eventBus)==null||f.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}})),!1}}}No=new WeakSet,yh=function(){this.container.setAttribute("data-internal-link","")},ehe=function(n,r,a="",i=null){n.href=this.linkService.getAnchorUrl(""),r.description?n.title=r.description:a&&(n.title=a),n.onclick=()=>{var o;return(o=this.downloadManager)==null||o.openOrDownloadData(r.content,r.filename,i),!1},Q(this,No,yh).call(this)},the=function(n,r,a=""){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeSetOCGState(r),!1),a&&(n.title=a),Q(this,No,yh).call(this)};class $Ve extends Dr{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class Pf extends Dr{render(){return this.container}showElementAndHideCanvas(e){var n;this.data.hasOwnCanvas&&(((n=e.previousSibling)==null?void 0:n.nodeName)==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return Ra.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,n,r,a,i){r.includes("mouse")?e.addEventListener(r,o=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:i(o),shift:o.shiftKey,modifier:this._getKeyModifier(o)}})}):e.addEventListener(r,o=>{var s;if(r==="blur"){if(!n.focused||!o.relatedTarget)return;n.focused=!1}else if(r==="focus"){if(n.focused)return;n.focused=!0}i&&((s=this.linkService.eventBus)==null||s.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:i(o)}}))})}_setEventListeners(e,n,r,a){var i,o,s;for(const[l,u]of r)(u==="Action"||(i=this.data.actions)!=null&&i[u])&&((u==="Focus"||u==="Blur")&&(n||(n={focused:!1})),this._setEventListener(e,n,l,u,a),u==="Focus"&&!((o=this.data.actions)!=null&&o.Blur)?this._setEventListener(e,n,"blur","Blur",null):u==="Blur"&&!((s=this.data.actions)!=null&&s.Focus)&&this._setEventListener(e,n,"focus","Focus",null))}_setBackgroundColor(e){const n=this.data.backgroundColor||null;e.style.backgroundColor=n===null?"transparent":nt.makeHexColor(n[0],n[1],n[2])}_setTextStyle(e){const n=["left","center","right"],{fontColor:r}=this.data.defaultAppearanceData,a=this.data.defaultAppearanceData.fontSize||zVe,i=e.style;let o;const s=2,l=u=>Math.round(10*u)/10;if(this.data.multiLine){const u=Math.abs(this.data.rect[3]-this.data.rect[1]-s),d=Math.round(u/(uB*a))||1,f=u/d;o=Math.min(a,l(f/uB))}else{const u=Math.abs(this.data.rect[3]-this.data.rect[1]-s);o=Math.min(a,l(u/uB))}i.fontSize=`calc(${o}px * var(--total-scale-factor))`,i.color=nt.makeHexColor(r[0],r[1],r[2]),this.data.textAlignment!==null&&(i.textAlign=n[this.data.textAlignment])}_setRequired(e,n){n?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",n)}}class YVe extends Pf{constructor(e){const n=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:n})}setPropertyOnSiblings(e,n,r,a){const i=this.annotationStorage;for(const o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[n]=r),i.setValue(o.id,{[a]:r})}render(){var a,i;const e=this.annotationStorage,n=this.data.id;this.container.classList.add("textWidgetAnnotation");let r=null;if(this.renderForms){const o=e.getValue(n,{value:this.data.fieldValue});let s=o.value||"";const l=e.getValue(n,{charLimit:this.data.maxLen}).charLimit;l&&s.length>l&&(s=s.slice(0,l));let u=o.formattedValue||((a=this.data.textContent)==null?void 0:a.join(`
|
|
657
657
|
`))||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,""));const d={userValue:s,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(r=document.createElement("textarea"),r.textContent=u??s,this.data.doNotScroll&&(r.style.overflowY="hidden")):(r=document.createElement("input"),r.type=this.data.password?"password":"text",r.setAttribute("value",u??s),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),Lf.add(r),r.setAttribute("data-element-id",n),r.disabled=this.data.readOnly,r.name=this.data.fieldName,r.tabIndex=0;const{datetimeFormat:f,datetimeType:m,timeStep:h}=this.data,E=!!m&&this.enableScripting;f&&(r.title=f),this._setRequired(r,this.data.required),l&&(r.maxLength=l),r.addEventListener("input",y=>{e.setValue(n,{value:y.target.value}),this.setPropertyOnSiblings(r,"value",y.target.value,"value"),d.formattedValue=null}),r.addEventListener("resetform",y=>{const v=this.data.defaultFieldValue??"";r.value=d.userValue=v,d.formattedValue=null});let b=y=>{const{formattedValue:v}=d;v!=null&&(y.target.value=v),y.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){r.addEventListener("focus",v=>{var T;if(d.focused)return;const{target:C}=v;if(E&&(C.type=m,h&&(C.step=h)),d.userValue){const w=d.userValue;if(E)if(m==="time"){const I=new Date(w),x=[I.getHours(),I.getMinutes(),I.getSeconds()];C.value=x.map(D=>D.toString().padStart(2,"0")).join(":")}else C.value=new Date(w-qVe).toISOString().split(m==="date"?"T":".",1)[0];else C.value=w}d.lastCommittedValue=C.value,d.commitKey=1,(T=this.data.actions)!=null&&T.Focus||(d.focused=!0)}),r.addEventListener("updatefromsandbox",v=>{this.showElementAndHideCanvas(v.target);const C={value(T){d.userValue=T.detail.value??"",E||e.setValue(n,{value:d.userValue.toString()}),T.target.value=d.userValue},formattedValue(T){const{formattedValue:w}=T.detail;d.formattedValue=w,w!=null&&T.target!==document.activeElement&&(T.target.value=w);const I={formattedValue:w};E&&(I.value=w),e.setValue(n,I)},selRange(T){T.target.setSelectionRange(...T.detail.selRange)},charLimit:T=>{var D;const{charLimit:w}=T.detail,{target:I}=T;if(w===0){I.removeAttribute("maxLength");return}I.setAttribute("maxLength",w);let x=d.userValue;!x||x.length<=w||(x=x.slice(0,w),I.value=d.userValue=x,e.setValue(n,{value:x}),(D=this.linkService.eventBus)==null||D.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:x,willCommit:!0,commitKey:1,selStart:I.selectionStart,selEnd:I.selectionEnd}}))}};this._dispatchEventFromSandbox(C,v)}),r.addEventListener("keydown",v=>{var w;d.commitKey=1;let C=-1;if(v.key==="Escape"?C=0:v.key==="Enter"&&!this.data.multiLine?C=2:v.key==="Tab"&&(d.commitKey=3),C===-1)return;const{value:T}=v.target;d.lastCommittedValue!==T&&(d.lastCommittedValue=T,d.userValue=T,(w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:T,willCommit:!0,commitKey:C,selStart:v.target.selectionStart,selEnd:v.target.selectionEnd}}))});const y=b;b=null,r.addEventListener("blur",v=>{var w,I;if(!d.focused||!v.relatedTarget)return;(w=this.data.actions)!=null&&w.Blur||(d.focused=!1);const{target:C}=v;let{value:T}=C;if(E){if(T&&m==="time"){const x=T.split(":").map(D=>parseInt(D,10));T=new Date(2e3,0,1,x[0],x[1],x[2]||0).valueOf(),C.step=""}else T.includes("T")||(T=`${T}T00:00`),T=new Date(T).valueOf();C.type="text"}d.userValue=T,d.lastCommittedValue!==T&&((I=this.linkService.eventBus)==null||I.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:T,willCommit:!0,commitKey:d.commitKey,selStart:v.target.selectionStart,selEnd:v.target.selectionEnd}})),y(v)}),(i=this.data.actions)!=null&&i.Keystroke&&r.addEventListener("beforeinput",v=>{var F;d.lastCommittedValue=null;const{data:C,target:T}=v,{value:w,selectionStart:I,selectionEnd:x}=T;let D=I,M=x;switch(v.inputType){case"deleteWordBackward":{const P=w.substring(0,I).match(/\w*[^\w]*$/);P&&(D-=P[0].length);break}case"deleteWordForward":{const P=w.substring(I).match(/^[^\w]*\w*/);P&&(M+=P[0].length);break}case"deleteContentBackward":I===x&&(D-=1);break;case"deleteContentForward":I===x&&(M+=1);break}v.preventDefault(),(F=this.linkService.eventBus)==null||F.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:w,change:C||"",willCommit:!1,selStart:D,selEnd:M}})}),this._setEventListeners(r,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],v=>v.target.value)}if(b&&r.addEventListener("blur",b),this.data.comb){const v=(this.data.rect[2]-this.data.rect[0])/l;r.classList.add("comb"),r.style.letterSpacing=`calc(${v}px * var(--total-scale-factor) - 1ch)`}}else r=document.createElement("div"),r.textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell",this.data.hasOwnCanvas&&(r.hidden=!0);return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class VVe extends Pf{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class jVe extends Pf{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,n=this.data,r=n.id;let a=e.getValue(r,{value:n.exportValue===n.fieldValue}).value;typeof a=="string"&&(a=a!=="Off",e.setValue(r,{value:a})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return Lf.add(i),i.setAttribute("data-element-id",r),i.disabled=n.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=n.fieldName,a&&i.setAttribute("checked",!0),i.setAttribute("exportValue",n.exportValue),i.tabIndex=0,i.addEventListener("change",o=>{const{name:s,checked:l}=o.target;for(const u of this._getElementsByName(s,r)){const d=l&&u.exportValue===n.exportValue;u.domElement&&(u.domElement.checked=d),e.setValue(u.id,{value:d})}e.setValue(r,{value:l})}),i.addEventListener("resetform",o=>{const s=n.defaultFieldValue||"Off";o.target.checked=s===n.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",o=>{const s={value(l){l.target.checked=l.detail.value!=="Off",e.setValue(r,{value:l.target.checked})}};this._dispatchEventFromSandbox(s,o)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class iue extends Pf{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,n=this.data,r=n.id;let a=e.getValue(r,{value:n.fieldValue===n.buttonValue}).value;if(typeof a=="string"&&(a=a!==n.buttonValue,e.setValue(r,{value:a})),a)for(const o of this._getElementsByName(n.fieldName,r))e.setValue(o.id,{value:!1});const i=document.createElement("input");if(Lf.add(i),i.setAttribute("data-element-id",r),i.disabled=n.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=n.fieldName,a&&i.setAttribute("checked",!0),i.tabIndex=0,i.addEventListener("change",o=>{const{name:s,checked:l}=o.target;for(const u of this._getElementsByName(s,r))e.setValue(u.id,{value:!1});e.setValue(r,{value:l})}),i.addEventListener("resetform",o=>{const s=n.defaultFieldValue;o.target.checked=s!=null&&s===n.buttonValue}),this.enableScripting&&this.hasJSActions){const o=n.buttonValue;i.addEventListener("updatefromsandbox",s=>{const l={value:u=>{const d=o===u.detail.value;for(const f of this._getElementsByName(u.target.name)){const m=d&&f.id===r;f.domElement&&(f.domElement.checked=m),e.setValue(f.id,{value:m})}}};this._dispatchEventFromSandbox(l,s)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],s=>s.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class WVe extends zB{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const n=e.lastChild;return this.enableScripting&&this.hasJSActions&&n&&(this._setDefaultPropertiesFromJS(n),n.addEventListener("updatefromsandbox",r=>{this._dispatchEventFromSandbox({},r)})),e}}class KVe extends Pf{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,n=this.data.id,r=e.getValue(n,{value:this.data.fieldValue}),a=document.createElement("select");Lf.add(a),a.setAttribute("data-element-id",n),a.disabled=this.data.readOnly,this._setRequired(a,this.data.required),a.name=this.data.fieldName,a.tabIndex=0;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(a.size=this.data.options.length,this.data.multiSelect&&(a.multiple=!0)),a.addEventListener("resetform",d=>{const f=this.data.defaultFieldValue;for(const m of a.options)m.selected=m.value===f});for(const d of this.data.options){const f=document.createElement("option");f.textContent=d.displayValue,f.value=d.exportValue,r.value.includes(d.exportValue)&&(f.setAttribute("selected",!0),i=!1),a.append(f)}let o=null;if(i){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),a.prepend(d),o=()=>{d.remove(),a.removeEventListener("input",o),o=null},a.addEventListener("input",o)}const s=d=>{const f=d?"value":"textContent",{options:m,multiple:h}=a;return h?Array.prototype.filter.call(m,E=>E.selected).map(E=>E[f]):m.selectedIndex===-1?null:m[m.selectedIndex][f]};let l=s(!1);const u=d=>{const f=d.target.options;return Array.prototype.map.call(f,m=>({displayValue:m.textContent,exportValue:m.value}))};return this.enableScripting&&this.hasJSActions?(a.addEventListener("updatefromsandbox",d=>{const f={value(m){o==null||o();const h=m.detail.value,E=new Set(Array.isArray(h)?h:[h]);for(const b of a.options)b.selected=E.has(b.value);e.setValue(n,{value:s(!0)}),l=s(!1)},multipleSelection(m){a.multiple=!0},remove(m){const h=a.options,E=m.detail.remove;h[E].selected=!1,a.remove(E),h.length>0&&Array.prototype.findIndex.call(h,y=>y.selected)===-1&&(h[0].selected=!0),e.setValue(n,{value:s(!0),items:u(m)}),l=s(!1)},clear(m){for(;a.length!==0;)a.remove(0);e.setValue(n,{value:null,items:[]}),l=s(!1)},insert(m){const{index:h,displayValue:E,exportValue:b}=m.detail.insert,y=a.children[h],v=document.createElement("option");v.textContent=E,v.value=b,y?y.before(v):a.append(v),e.setValue(n,{value:s(!0),items:u(m)}),l=s(!1)},items(m){const{items:h}=m.detail;for(;a.length!==0;)a.remove(0);for(const E of h){const{displayValue:b,exportValue:y}=E,v=document.createElement("option");v.textContent=b,v.value=y,a.append(v)}a.options.length>0&&(a.options[0].selected=!0),e.setValue(n,{value:s(!0),items:u(m)}),l=s(!1)},indices(m){const h=new Set(m.detail.indices);for(const E of m.target.options)E.selected=h.has(E.index);e.setValue(n,{value:s(!0)}),l=s(!1)},editable(m){m.target.disabled=!m.detail.editable}};this._dispatchEventFromSandbox(f,d)}),a.addEventListener("input",d=>{var h;const f=s(!0),m=s(!1);e.setValue(n,{value:f}),d.preventDefault(),(h=this.linkService.eventBus)==null||h.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:l,change:m,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(a,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):a.addEventListener("input",function(d){e.setValue(n,{value:s(!0)})}),this.data.combo&&this._setTextStyle(a),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class qB extends Dr{constructor(n){const{data:r,elements:a,parent:i}=n,o=!!i._commentManager;super(n,{isRenderable:!o&&Dr._hasPopupData(r)});V(this,cv);if(this.elements=a,o&&Dr._hasPopupData(r)){const s=this.popup=Q(this,cv,U7).call(this);for(const l of a)l.popup=s}else this.popup=null}render(){const{container:n}=this;n.classList.add("popupAnnotation"),n.role="comment";const r=this.popup=Q(this,cv,U7).call(this),a=[];for(const i of this.elements)i.popup=r,i.container.ariaHasPopup="dialog",a.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",a.map(i=>`${_B}${i}`).join(",")),this.container}}cv=new WeakSet,U7=function(){return new XVe({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};class XVe{constructor({container:e,color:n,elements:r,titleObj:a,modificationDate:i,contentsObj:o,richText:s,parent:l,rect:u,parentRect:d,open:f,commentManager:m=null}){V(this,$t);V(this,Oo,null);V(this,ip,Q(this,$t,ahe).bind(this));V(this,MR,Q(this,$t,$7).bind(this));V(this,LR,Q(this,$t,dw).bind(this));V(this,B_,Q(this,$t,uw).bind(this));V(this,U_,null);V(this,qr,null);V(this,sc,null);V(this,op,null);V(this,Om,null);V(this,G_,null);V(this,z_,null);V(this,lc,!1);V(this,Io,null);V(this,Su,null);V(this,vu,null);V(this,xa,null);V(this,yu,null);V(this,sp,null);V(this,uv,null);V(this,Tu,null);V(this,q_,null);V(this,Im,null);V(this,lp,!1);V(this,ci,null);V(this,cp,null);L(this,qr,e),L(this,q_,a),L(this,sc,o),L(this,Tu,s),L(this,G_,l),L(this,U_,n),L(this,uv,u),L(this,z_,d),L(this,Om,r),L(this,Oo,m),L(this,ci,r[0]),L(this,op,HE.toDateObject(i)),this.trigger=r.flatMap(h=>h.getElementsToTriggerPopup()),m?this.renderCommentButton():(Q(this,$t,lw).call(this),_(this,qr).hidden=!0,f&&Q(this,$t,uw).call(this))}renderCommentButton(){if(_(this,xa)||(_(this,yu)||Q(this,$t,G7).call(this),!_(this,yu)))return;const{signal:e}=L(this,Su,new AbortController),n=!!_(this,ci).extraPopupElement,r=()=>{_(this,Oo).toggleCommentPopup(this,!0,void 0,!n)},a=()=>{_(this,Oo).toggleCommentPopup(this,!1,!0,!n)},i=()=>{_(this,Oo).toggleCommentPopup(this,!1,!1)};if(n){L(this,xa,_(this,ci).container);for(const o of this.trigger)o.ariaHasPopup="dialog",o.ariaControls="commentPopup",o.addEventListener("keydown",_(this,ip),{signal:e}),o.addEventListener("click",r,{signal:e}),o.addEventListener("pointerenter",a,{signal:e}),o.addEventListener("pointerleave",i,{signal:e}),o.classList.add("popupTriggerArea")}else{const o=L(this,xa,document.createElement("button"));o.className="annotationCommentButton";const s=_(this,ci).container;o.style.zIndex=s.style.zIndex+1,o.tabIndex=0,o.ariaHasPopup="dialog",o.ariaControls="commentPopup",o.setAttribute("data-l10n-id","pdfjs-show-comment-button"),Q(this,$t,q7).call(this),Q(this,$t,z7).call(this),o.addEventListener("keydown",_(this,ip),{signal:e}),o.addEventListener("click",r,{signal:e}),o.addEventListener("pointerenter",a,{signal:e}),o.addEventListener("pointerleave",i,{signal:e}),s.after(o)}}get commentButtonColor(){const{color:e,opacity:n}=_(this,ci).commentData;return e?_(this,G_)._commentManager.makeCommentColor(e,n):null}focusCommentButton(){setTimeout(()=>{var e;(e=_(this,xa))==null||e.focus()},0)}getData(){const{richText:e,color:n,opacity:r,creationDate:a,modificationDate:i}=_(this,ci).commentData;return{contentsObj:{str:this.comment},richText:e,color:n,opacity:r,creationDate:a,modificationDate:i}}get elementBeforePopup(){return _(this,xa)}get comment(){return _(this,cp)||L(this,cp,_(this,ci).commentText),_(this,cp)}set comment(e){e!==this.comment&&(_(this,ci).commentText=L(this,cp,e))}get parentBoundingClientRect(){return _(this,ci).layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:n}){_(this,xa)&&(_(this,xa).classList.toggle("selected",e),_(this,xa).ariaExpanded=n)}setSelectedCommentButton(e){_(this,xa).classList.toggle("selected",e)}get commentPopupPosition(){if(_(this,sp))return _(this,sp);const{x:e,y:n,height:r}=_(this,xa).getBoundingClientRect(),{x:a,y:i,width:o,height:s}=_(this,ci).layer.getBoundingClientRect();return[(e-a)/o,(n+r-i)/s]}set commentPopupPosition(e){L(this,sp,e)}hasDefaultPopupPosition(){return _(this,sp)===null}get commentButtonPosition(){return _(this,yu)}get commentButtonWidth(){return _(this,xa).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){const[n,r]=_(this,sp)||this.commentButtonPosition.map(u=>u/100),a=this.parentBoundingClientRect,{x:i,y:o,width:s,height:l}=a;_(this,Oo).showDialog(null,this,i+n*s,o+r*l,{...e,parentDimensions:a})}render(){var r,a;if(_(this,Io))return;const e=L(this,Io,document.createElement("div"));if(e.className="popup",_(this,U_)){const i=e.style.outlineColor=nt.makeHexColor(..._(this,U_));e.style.backgroundColor=`color-mix(in srgb, ${i} 30%, white)`}const n=document.createElement("span");if(n.className="header",(r=_(this,q_))!=null&&r.str){const i=document.createElement("span");i.className="title",n.append(i),{dir:i.dir,str:i.textContent}=_(this,q_)}if(e.append(n),_(this,op)){const i=document.createElement("time");i.className="popupDate",i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:_(this,op).valueOf()})),i.dateTime=_(this,op).toISOString(),n.append(i)}SB({html:_(this,$t,cw)||_(this,sc).str,dir:(a=_(this,sc))==null?void 0:a.dir,className:"popupContent"},e),_(this,qr).append(e)}updateEdited({rect:e,popup:n,deleted:r}){var a;if(_(this,Oo)){r?(this.remove(),L(this,cp,null)):n&&(n.deleted?this.remove():(Q(this,$t,q7).call(this),L(this,cp,n.text))),e&&(L(this,yu,null),Q(this,$t,G7).call(this),Q(this,$t,z7).call(this));return}if(r||n!=null&&n.deleted){this.remove();return}Q(this,$t,lw).call(this),_(this,Im)||L(this,Im,{contentsObj:_(this,sc),richText:_(this,Tu)}),e&&L(this,vu,null),n&&n.text&&(L(this,Tu,Q(this,$t,rhe).call(this,n.text)),L(this,op,HE.toDateObject(n.date)),L(this,sc,null)),(a=_(this,Io))==null||a.remove(),L(this,Io,null)}resetEdited(){var e;_(this,Im)&&({contentsObj:Ca(this,sc)._,richText:Ca(this,Tu)._}=_(this,Im),L(this,Im,null),(e=_(this,Io))==null||e.remove(),L(this,Io,null),L(this,vu,null))}remove(){var e,n,r;if((e=_(this,Su))==null||e.abort(),L(this,Su,null),(n=_(this,Io))==null||n.remove(),L(this,Io,null),L(this,lp,!1),L(this,lc,!1),(r=_(this,xa))==null||r.remove(),L(this,xa,null),this.trigger)for(const a of this.trigger)a.classList.remove("popupTriggerArea")}forceHide(){L(this,lp,this.isVisible),_(this,lp)&&(_(this,qr).hidden=!0)}maybeShow(){_(this,Oo)||(Q(this,$t,lw).call(this),_(this,lp)&&(_(this,Io)||Q(this,$t,dw).call(this),L(this,lp,!1),_(this,qr).hidden=!1))}get isVisible(){return _(this,Oo)?!1:_(this,qr).hidden===!1}}Oo=new WeakMap,ip=new WeakMap,MR=new WeakMap,LR=new WeakMap,B_=new WeakMap,U_=new WeakMap,qr=new WeakMap,sc=new WeakMap,op=new WeakMap,Om=new WeakMap,G_=new WeakMap,z_=new WeakMap,lc=new WeakMap,Io=new WeakMap,Su=new WeakMap,vu=new WeakMap,xa=new WeakMap,yu=new WeakMap,sp=new WeakMap,uv=new WeakMap,Tu=new WeakMap,q_=new WeakMap,Im=new WeakMap,lp=new WeakMap,ci=new WeakMap,cp=new WeakMap,$t=new WeakSet,lw=function(){var n;if(_(this,Su))return;L(this,Su,new AbortController);const{signal:e}=_(this,Su);for(const r of this.trigger)r.addEventListener("click",_(this,B_),{signal:e}),r.addEventListener("pointerenter",_(this,LR),{signal:e}),r.addEventListener("pointerleave",_(this,MR),{signal:e}),r.classList.add("popupTriggerArea");for(const r of _(this,Om))(n=r.container)==null||n.addEventListener("keydown",_(this,ip),{signal:e})},G7=function(){const e=_(this,Om).find(n=>n.hasCommentButton);e&&L(this,yu,e._normalizePoint(e.commentButtonPosition))},z7=function(){if(_(this,ci).extraPopupElement&&!_(this,ci).editor)return;this.renderCommentButton();const[e,n]=_(this,yu),{style:r}=_(this,xa);r.left=`calc(${e}%)`,r.top=`calc(${n}% - var(--comment-button-dim))`},q7=function(){_(this,ci).extraPopupElement||(this.renderCommentButton(),_(this,xa).style.backgroundColor=this.commentButtonColor||"")},cw=function(){const e=_(this,Tu),n=_(this,sc);return e!=null&&e.str&&(!(n!=null&&n.str)||n.str===e.str)&&_(this,Tu).html||null},H7=function(){var e,n,r;return((r=(n=(e=_(this,$t,cw))==null?void 0:e.attributes)==null?void 0:n.style)==null?void 0:r.fontSize)||0},nhe=function(){var e,n,r;return((r=(n=(e=_(this,$t,cw))==null?void 0:e.attributes)==null?void 0:n.style)==null?void 0:r.color)||null},rhe=function(e){const n=[],r={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:n}]}},a={style:{color:_(this,$t,nhe),fontSize:_(this,$t,H7)?`calc(${_(this,$t,H7)}px * var(--total-scale-factor))`:""}};for(const i of e.split(`
|
|
658
658
|
`))n.push({name:"span",value:i,attributes:a});return r},ahe=function(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key==="Enter"||e.key==="Escape"&&_(this,lc))&&Q(this,$t,uw).call(this)},ihe=function(){if(_(this,vu)!==null)return;const{page:{view:e},viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:i}}}=_(this,G_);let o=!!_(this,z_),s=o?_(this,z_):_(this,uv);for(const E of _(this,Om))if(!s||nt.intersect(E.data.rect,s)!==null){s=E.data.rect,o=!0;break}const l=nt.normalizeRect([s[0],e[3]-s[1]+e[1],s[2],e[3]-s[3]+e[1]]),d=o?s[2]-s[0]+5:0,f=l[0]+d,m=l[1];L(this,vu,[100*(f-a)/n,100*(m-i)/r]);const{style:h}=_(this,qr);h.left=`${_(this,vu)[0]}%`,h.top=`${_(this,vu)[1]}%`},uw=function(){if(_(this,Oo)){_(this,Oo).toggleCommentPopup(this,!1);return}L(this,lc,!_(this,lc)),_(this,lc)?(Q(this,$t,dw).call(this),_(this,qr).addEventListener("click",_(this,B_)),_(this,qr).addEventListener("keydown",_(this,ip))):(Q(this,$t,$7).call(this),_(this,qr).removeEventListener("click",_(this,B_)),_(this,qr).removeEventListener("keydown",_(this,ip)))},dw=function(){_(this,Io)||this.render(),this.isVisible?_(this,lc)&&_(this,qr).classList.add("focused"):(Q(this,$t,ihe).call(this),_(this,qr).hidden=!1,_(this,qr).style.zIndex=parseInt(_(this,qr).style.zIndex)+1e3)},$7=function(){_(this,qr).classList.remove("focused"),!(_(this,lc)||!this.isVisible)&&(_(this,qr).hidden=!0,_(this,qr).style.zIndex=parseInt(_(this,qr).style.zIndex)-1e3)};class oue extends Dr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=It.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const n of this.textContent){const r=document.createElement("span");r.textContent=n,e.append(r)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class QVe extends Dr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});V(this,dv,null)}render(){this.container.classList.add("lineAnnotation");const{data:n,width:r,height:a}=this,i=this.svgFactory.create(r,a,!0),o=L(this,dv,this.svgFactory.createElement("svg:line"));return o.setAttribute("x1",n.rect[2]-n.lineCoordinates[0]),o.setAttribute("y1",n.rect[3]-n.lineCoordinates[1]),o.setAttribute("x2",n.rect[2]-n.lineCoordinates[2]),o.setAttribute("y2",n.rect[3]-n.lineCoordinates[3]),o.setAttribute("stroke-width",n.borderStyle.width||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,dv)}addHighlightArea(){this.container.classList.add("highlightArea")}}dv=new WeakMap;class ZVe extends Dr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});V(this,pv,null)}render(){this.container.classList.add("squareAnnotation");const{data:n,width:r,height:a}=this,i=this.svgFactory.create(r,a,!0),o=n.borderStyle.width,s=L(this,pv,this.svgFactory.createElement("svg:rect"));return s.setAttribute("x",o/2),s.setAttribute("y",o/2),s.setAttribute("width",r-o),s.setAttribute("height",a-o),s.setAttribute("stroke-width",o||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),i.append(s),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,pv)}addHighlightArea(){this.container.classList.add("highlightArea")}}pv=new WeakMap;class JVe extends Dr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});V(this,fv,null)}render(){this.container.classList.add("circleAnnotation");const{data:n,width:r,height:a}=this,i=this.svgFactory.create(r,a,!0),o=n.borderStyle.width,s=L(this,fv,this.svgFactory.createElement("svg:ellipse"));return s.setAttribute("cx",r/2),s.setAttribute("cy",a/2),s.setAttribute("rx",r/2-o/2),s.setAttribute("ry",a/2-o/2),s.setAttribute("stroke-width",o||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),i.append(s),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,fv)}addHighlightArea(){this.container.classList.add("highlightArea")}}fv=new WeakMap;class sue extends Dr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});V(this,mv,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:n,vertices:r,borderStyle:a,popupRef:i},width:o,height:s}=this;if(!r)return this.container;const l=this.svgFactory.create(o,s,!0);let u=[];for(let f=0,m=r.length;f<m;f+=2){const h=r[f]-n[0],E=n[3]-r[f+1];u.push(`${h},${E}`)}u=u.join(" ");const d=L(this,mv,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",u),d.setAttribute("stroke-width",a.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),l.append(d),this.container.append(l),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,mv)}addHighlightArea(){this.container.classList.add("highlightArea")}}mv=new WeakMap;class eje extends sue{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class tje extends Dr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class HB extends Dr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});V(this,gv);V(this,hv,null);V(this,Dm,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?It.HIGHLIGHT:It.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:n,rotation:r,inkLists:a,borderStyle:i,popupRef:o}}=this,{transform:s,width:l,height:u}=Q(this,gv,Y7).call(this,r,n),d=this.svgFactory.create(l,u,!0),f=L(this,hv,this.svgFactory.createElement("svg:g"));d.append(f),f.setAttribute("stroke-width",i.width||1),f.setAttribute("stroke-linecap","round"),f.setAttribute("stroke-linejoin","round"),f.setAttribute("stroke-miterlimit",10),f.setAttribute("stroke","transparent"),f.setAttribute("fill","transparent"),f.setAttribute("transform",s);for(let m=0,h=a.length;m<h;m++){const E=this.svgFactory.createElement(this.svgElementName);_(this,Dm).push(E),E.setAttribute("points",a[m].join(",")),f.append(E)}return!o&&this.hasPopupData&&this._createPopup(),this.container.append(d),this._editOnDoubleClick(),this.container}updateEdited(n){super.updateEdited(n);const{thickness:r,points:a,rect:i}=n,o=_(this,hv);if(r>=0&&o.setAttribute("stroke-width",r||1),a)for(let s=0,l=_(this,Dm).length;s<l;s++)_(this,Dm)[s].setAttribute("points",a[s].join(","));if(i){const{transform:s,width:l,height:u}=Q(this,gv,Y7).call(this,this.data.rotation,i);o.parentElement.setAttribute("viewBox",`0 0 ${l} ${u}`),o.setAttribute("transform",s)}}getElementsToTriggerPopup(){return _(this,Dm)}addHighlightArea(){this.container.classList.add("highlightArea")}}hv=new WeakMap,Dm=new WeakMap,gv=new WeakSet,Y7=function(n,r){switch(n){case 90:return{transform:`rotate(90) translate(${-r[0]},${r[1]}) scale(1,-1)`,width:r[3]-r[1],height:r[2]-r[0]};case 180:return{transform:`rotate(180) translate(${-r[2]},${r[1]}) scale(1,-1)`,width:r[2]-r[0],height:r[3]-r[1]};case 270:return{transform:`rotate(270) translate(${-r[2]},${r[3]}) scale(1,-1)`,width:r[3]-r[1],height:r[2]-r[0]};default:return{transform:`translate(${-r[0]},${r[3]}) scale(1,-1)`,width:r[2]-r[0],height:r[3]-r[1]}}};class lue extends Dr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=It.HIGHLIGHT}render(){const{data:{overlaidText:e,popupRef:n}}=this;if(!n&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),e){const r=document.createElement("mark");r.classList.add("overlaidText"),r.textContent=e,this.container.append(r)}return this.container}}class nje extends Dr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:n}}=this;if(!n&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),e){const r=document.createElement("u");r.classList.add("overlaidText"),r.textContent=e,this.container.append(r)}return this.container}}class rje extends Dr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:n}}=this;if(!n&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),e){const r=document.createElement("u");r.classList.add("overlaidText"),r.textContent=e,this.container.append(r)}return this.container}}class aje extends Dr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:n}}=this;if(!n&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),e){const r=document.createElement("s");r.classList.add("overlaidText"),r.textContent=e,this.container.append(r)}return this.container}}class cue extends Dr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=It.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class ije extends Dr{constructor(n){var a;super(n,{isRenderable:!0});V(this,bv);V(this,_v,null);const{file:r}=this.data;this.filename=r.filename,this.content=r.content,(a=this.linkService.eventBus)==null||a.dispatch("fileattachmentannotation",{source:this,...r})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:n,data:r}=this;let a;r.hasAppearance||r.fillAlpha===0?a=document.createElement("div"):(a=document.createElement("img"),a.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(r.name)?"paperclip":"pushpin"}.svg`,r.fillAlpha&&r.fillAlpha<1&&(a.style=`filter: opacity(${Math.round(r.fillAlpha*100)}%);`)),a.addEventListener("dblclick",Q(this,bv,V7).bind(this)),L(this,_v,a);const{isMac:i}=Ra.platform;return n.addEventListener("keydown",o=>{o.key==="Enter"&&(i?o.metaKey:o.ctrlKey)&&Q(this,bv,V7).call(this)}),!r.popupRef&&this.hasPopupData?this._createPopup():a.classList.add("popupTriggerArea"),n.append(a),n}getElementsToTriggerPopup(){return _(this,_v)}addHighlightArea(){this.container.classList.add("highlightArea")}}_v=new WeakMap,bv=new WeakSet,V7=function(){var n;(n=this.downloadManager)==null||n.openOrDownloadData(this.content,this.filename)};let $B=(Y_=class{constructor({div:e,accessibilityManager:n,annotationCanvasMap:r,annotationEditorUIManager:a,page:i,viewport:o,structTreeLayer:s,commentManager:l,linkService:u,annotationStorage:d}){V(this,dp);V(this,H_,null);V(this,km,null);V(this,$_,null);V(this,up,new Map);V(this,Ev,null);V(this,Mm,null);this.div=e,L(this,H_,n),L(this,km,r),L(this,Ev,s||null),L(this,Mm,u||null),L(this,$_,d||new AB),this.page=i,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=a,this._commentManager=l||null}hasEditableAnnotations(){return _(this,up).size>0}async render(e){var o,s,l;const{annotations:n}=e,r=this.div;xd(r,this.viewport);const a=new Map,i={data:null,layer:r,linkService:_(this,Mm),downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new eS,annotationStorage:_(this,$_),enableComment:e.enableComment===!0,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const u of n){if(u.noHTML)continue;const d=u.annotationType===Xr.POPUP;if(d){const h=a.get(u.id);if(!h)continue;i.elements=h}else if(u.rect[2]===u.rect[0]||u.rect[3]===u.rect[1])continue;i.data=u;const f=aue.create(i);if(!f.isRenderable)continue;if(!d&&u.popupRef){const h=a.get(u.popupRef);h?h.push(f):a.set(u.popupRef,[f])}const m=f.render();u.hidden&&(m.style.visibility="hidden"),await Q(this,dp,j7).call(this,m,u.id,i.elements),(s=(o=f.extraPopupElement)==null?void 0:o.popup)==null||s.renderCommentButton(),f._isEditable&&(_(this,up).set(f.data.id,f),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(f))}Q(this,dp,W7).call(this)}async addLinkAnnotations(e){const n={data:null,layer:this.div,linkService:_(this,Mm),svgFactory:new eS,parent:this};for(const r of e){r.borderStyle||(r.borderStyle=Y_._defaultBorderStyle),n.data=r;const a=aue.create(n);if(!a.isRenderable)continue;const i=a.render();await Q(this,dp,j7).call(this,i,r.id,null)}}update({viewport:e}){const n=this.div;this.viewport=e,xd(n,{rotation:e.rotation}),Q(this,dp,W7).call(this),n.hidden=!1}getEditableAnnotations(){return Array.from(_(this,up).values())}getEditableAnnotation(e){return _(this,up).get(e)}addFakeAnnotation(e){var s;const{div:n}=this,{id:r,rotation:a}=e,i=new HVe({data:{id:r,rect:e.getPDFRect(),rotation:a},editor:e,layer:n,parent:this,enableComment:!!this._commentManager,linkService:_(this,Mm),annotationStorage:_(this,$_)}),o=i.render();return n.append(o),(s=_(this,H_))==null||s.moveElementInDOM(n,o,o,!1),i.createOrUpdatePopup(),i}static get _defaultBorderStyle(){return Ht(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Rg.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},H_=new WeakMap,km=new WeakMap,$_=new WeakMap,up=new WeakMap,Ev=new WeakMap,Mm=new WeakMap,dp=new WeakSet,j7=async function(e,n,r){var s,l;const a=e.firstChild||e,i=a.id=`${_B}${n}`,o=await((s=_(this,Ev))==null?void 0:s.getAriaAttributes(i));if(o)for(const[u,d]of o)a.setAttribute(u,d);r?r.at(-1).container.after(e):(this.div.append(e),(l=_(this,H_))==null||l.moveElementInDOM(this.div,e,a,!1))},W7=function(){var n;if(!_(this,km))return;const e=this.div;for(const[r,a]of _(this,km)){const i=e.querySelector(`[data-annotation-id="${r}"]`);if(!i)continue;a.className="annotationContent";const{firstChild:o}=i;o?o.nodeName==="CANVAS"?o.replaceWith(a):o.classList.contains("annotationContent")?o.after(a):o.before(a):i.append(a);const s=_(this,up).get(r);s&&(s._hasNoCanvas?((n=this._annotationEditorUIManager)==null||n.setMissingCanvas(r,i.id,a),s._hasNoCanvas=!1):s.canvas=a)}_(this,km).clear()},Y_);const uR=/\r\n?|\n/g,mr=class mr extends ur{constructor(n){super({...n,name:"freeTextEditor"});V(this,oa);V(this,Do,"");V(this,Sv,`${this.id}-editor`);V(this,Lm,null);V(this,ko);Ue(this,"_colorPicker",null);this.color=n.color||mr._defaultColor||ur._defaultLineColor,L(this,ko,n.fontSize||mr._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const n=mr.prototype,r=o=>o.isEmpty(),a=Nd.TRANSLATE_SMALL,i=Nd.TRANSLATE_BIG;return Ht(this,"_keyboardManager",new $E([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],n.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],n.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],n._translateEmpty,{args:[-a,0],checker:r}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],n._translateEmpty,{args:[-i,0],checker:r}],[["ArrowRight","mac+ArrowRight"],n._translateEmpty,{args:[a,0],checker:r}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],n._translateEmpty,{args:[i,0],checker:r}],[["ArrowUp","mac+ArrowUp"],n._translateEmpty,{args:[0,-a],checker:r}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],n._translateEmpty,{args:[0,-i],checker:r}],[["ArrowDown","mac+ArrowDown"],n._translateEmpty,{args:[0,a],checker:r}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],n._translateEmpty,{args:[0,i],checker:r}]]))}static initialize(n,r){ur.initialize(n,r);const a=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(a.getPropertyValue("--freetext-padding"))}static updateDefaultParams(n,r){switch(n){case an.FREETEXT_SIZE:mr._defaultFontSize=r;break;case an.FREETEXT_COLOR:mr._defaultColor=r;break}}updateParams(n,r){switch(n){case an.FREETEXT_SIZE:Q(this,oa,ohe).call(this,r);break;case an.FREETEXT_COLOR:Q(this,oa,she).call(this,r);break}}static get defaultPropertiesToUpdate(){return[[an.FREETEXT_SIZE,mr._defaultFontSize],[an.FREETEXT_COLOR,mr._defaultColor||ur._defaultLineColor]]}get propertiesToUpdate(){return[[an.FREETEXT_SIZE,_(this,ko)],[an.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new cR(this)),[["colorPicker",this._colorPicker]]}get colorType(){return an.FREETEXT_COLOR}onUpdatedColor(){var n;this.editorDiv.style.color=this.color,(n=this._colorPicker)==null||n.update(this.color),super.onUpdatedColor()}_translateEmpty(n,r){this._uiManager.translateSelectedEditors(n,r,!0)}getInitialTranslation(){const n=this.parentScale;return[-mr._internalPadding*n,-(mr._internalPadding+_(this,ko))*n]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),L(this,Lm,new AbortController);const n=this._uiManager.combinedSignal(_(this,Lm));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:n}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:n}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:n}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:n}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:n}),!0}disableEditMode(){var n;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",_(this,Sv)),this._isDraggable=!0,(n=_(this,Lm))==null||n.abort(),L(this,Lm,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(n){this._focusEventsAllowed&&(super.focusin(n),n.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(n){var r;this.width||(this.enableEditMode(),n&&this.editorDiv.focus(),(r=this._initialOptions)!=null&&r.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const n=_(this,Do),r=L(this,Do,Q(this,oa,lhe).call(this).trimEnd());if(n===r)return;const a=i=>{if(L(this,Do,i),!i){this.remove();return}Q(this,oa,mw).call(this),this._uiManager.rebuild(this),Q(this,oa,pw).call(this)};this.addCommands({cmd:()=>{a(r)},undo:()=>{a(n)},mustExec:!1}),Q(this,oa,pw).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(n){n.target===this.div&&n.key==="Enter"&&(this.enterInEditMode(),n.preventDefault())}editorDivKeydown(n){mr._keyboardManager.exec(this,n)}editorDivFocus(n){this.isEditing=!0}editorDivBlur(n){this.isEditing=!1}editorDivInput(n){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let n,r;(this._isCopy||this.annotationElementId)&&(n=this.x,r=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",_(this,Sv)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:a}=this.editorDiv;if(a.fontSize=`calc(${_(this,ko)}px * var(--total-scale-factor))`,a.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,o]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this._initialData;let[l,u]=this.getInitialTranslation();[l,u]=this.pageTranslationToScreen(l,u);const[d,f]=this.pageDimensions,[m,h]=this.pageTranslation;let E,b;switch(this.rotation){case 0:E=n+(s[0]-m)/d,b=r+this.height-(s[1]-h)/f;break;case 90:E=n+(s[0]-m)/d,b=r-(s[1]-h)/f,[l,u]=[u,-l];break;case 180:E=n-this.width+(s[0]-m)/d,b=r-(s[1]-h)/f,[l,u]=[-l,-u];break;case 270:E=n+(s[0]-m-this.height*f)/d,b=r+(s[1]-h-this.width*d)/f,[l,u]=[-u,l];break}this.setAt(E*i,b*o,l,u)}else this._moveAfterPaste(n,r);Q(this,oa,mw).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(n){var E,b,y;const r=n.clipboardData||window.clipboardData,{types:a}=r;if(a.length===1&&a[0]==="text/plain")return;n.preventDefault();const i=Q(E=mr,Cu,K7).call(E,r.getData("text")||"").replaceAll(uR,`
|