@fileverse-dev/ddoc 1.3.3 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.umd.js CHANGED
@@ -423,7 +423,7 @@ img.ProseMirror-separator {
423
423
 
424
424
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
425
425
 
426
- For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return H.useEffect(()=>{n&&(document.getElementById(n)||console.error(t))},[t,n]),null},Fj="DialogDescriptionWarning",jj=({contentRef:n,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${BC(Fj).contentName}}.`;return H.useEffect(()=>{var i;const s=(i=n.current)==null?void 0:i.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(r))},[r,n,e]),null},FC=EC,jC=CC,UC=TC,ob=NC,ab=OC,lb=MC,cb=PC,HC=LC;function Uj(n){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",e.appendChild(t),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}const zC=L.createContext({drawerRef:{current:null},overlayRef:{current:null},scaleBackground:()=>{},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,handleOnly:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},visible:!1,closeDrawer:()=>{},setVisible:()=>{},direction:"bottom"}),op=()=>{const n=L.useContext(zC);if(!n)throw new Error("useDrawerContext must be used within a Drawer.Root");return n};Uj("[vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1)}[vaul-drawer][vaul-drawer-direction=bottom]{transform:translate3d(0,100%,0)}[vaul-drawer][vaul-drawer-direction=top]{transform:translate3d(0,-100%,0)}[vaul-drawer][vaul-drawer-direction=left]{transform:translate3d(-100%,0,0)}[vaul-drawer][vaul-drawer-direction=right]{transform:translate3d(100%,0,0)}.vaul-dragging .vaul-scrollable [vault-drawer-direction=top]{overflow-y:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=bottom]{overflow-y:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=left]{overflow-x:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=right]{overflow-x:hidden!important}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[vaul-overlay]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[vaul-overlay][vaul-drawer-visible=true]{opacity:1}[vaul-drawer]::after{content:'';position:absolute;background:inherit;background-color:inherit}[vaul-drawer][vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[vaul-drawer][vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[vaul-drawer][vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[vaul-drawer][vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[vaul-handle]{display:block;position:relative;opacity:.8;margin-left:auto;margin-right:auto;height:5px;width:56px;border-radius:1rem;touch-action:pan-y;cursor:grab}[vaul-handle]:active,[vaul-handle]:hover{opacity:1}[vaul-handle]:active{cursor:grabbing}[vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}[vaul-overlay][vaul-snap-points=true]:not([vaul-snap-points-overlay=true]):not([data-state=closed]){opacity:0}[vaul-overlay][vaul-snap-points-overlay=true]:not([vaul-drawer-visible=false]){opacity:1}@media (hover:hover) and (pointer:fine){[vaul-drawer]{user-select:none}}@media (pointer:fine){[vaul-handle-hitarea]:{width:100%;height:100%}}");const Hj=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ub(...n){return(...e)=>{for(let t of n)typeof t=="function"&&t(...e)}}function zj(){return fb(/^Mac/)}function Vj(){return fb(/^iPhone/)}function $j(){return fb(/^iPad/)||zj()&&navigator.maxTouchPoints>1}function VC(){return Vj()||$j()}function fb(n){return typeof window<"u"&&window.navigator!=null?n.test(window.navigator.platform):void 0}const db=typeof document<"u"&&window.visualViewport;function $C(n){let e=window.getComputedStyle(n);return/(auto|scroll)/.test(e.overflow+e.overflowX+e.overflowY)}function WC(n){for($C(n)&&(n=n.parentElement);n&&!$C(n);)n=n.parentElement;return n||document.scrollingElement||document.documentElement}const Wj=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let ap=0,hb;function Gj(n={}){let{isDisabled:e}=n;Hj(()=>{if(!e)return ap++,ap===1&&(VC()?hb=Jj():hb=Kj()),()=>{ap--,ap===0&&hb()}},[e])}function Kj(){return ub(GC(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`))}function Jj(){let n,e=0,t=f=>{n=WC(f.target),!(n===document.documentElement&&n===document.body)&&(e=f.changedTouches[0].pageY)},r=f=>{if(!n||n===document.documentElement||n===document.body){f.preventDefault();return}let d=f.changedTouches[0].pageY,h=n.scrollTop,p=n.scrollHeight-n.clientHeight;p!==0&&((h<=0&&d>e||h>=p&&d<e)&&f.preventDefault(),e=d)},s=f=>{let d=f.target;pb(d)&&d!==document.activeElement&&(f.preventDefault(),d.style.transform="translateY(-2000px)",d.focus(),requestAnimationFrame(()=>{d.style.transform=""}))},i=f=>{let d=f.target;pb(d)&&(d.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{d.style.transform="",db&&(db.height<window.innerHeight?requestAnimationFrame(()=>{KC(d)}):db.addEventListener("resize",()=>KC(d),{once:!0}))}))},o=()=>{window.scrollTo(0,0)},a=window.pageXOffset,l=window.pageYOffset,c=ub(GC(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let u=ub(Cf(document,"touchstart",t,{passive:!1,capture:!0}),Cf(document,"touchmove",r,{passive:!1,capture:!0}),Cf(document,"touchend",s,{passive:!1,capture:!0}),Cf(document,"focus",i,!0),Cf(window,"scroll",o));return()=>{c(),u(),window.scrollTo(a,l)}}function GC(n,e,t){let r=n.style[e];return n.style[e]=t,()=>{n.style[e]=r}}function Cf(n,e,t,r){return n.addEventListener(e,t,r),()=>{n.removeEventListener(e,t,r)}}function KC(n){let e=document.scrollingElement||document.documentElement;for(;n&&n!==e;){let t=WC(n);if(t!==document.documentElement&&t!==document.body&&t!==n){let r=t.getBoundingClientRect().top,s=n.getBoundingClientRect().top,i=n.getBoundingClientRect().bottom;const o=t.getBoundingClientRect().bottom;i>o&&(t.scrollTop+=s-r)}n=t.parentElement}}function pb(n){return n instanceof HTMLInputElement&&!Wj.has(n.type)||n instanceof HTMLTextAreaElement||n instanceof HTMLElement&&n.isContentEditable}function qj(n,e){typeof n=="function"?n(e):n!=null&&(n.current=e)}function Qj(...n){return e=>n.forEach(t=>qj(t,e))}function JC(...n){return H.useCallback(Qj(...n),n)}let Sf=null;function Yj({isOpen:n,modal:e,nested:t,hasBeenOpened:r,preventScrollRestoration:s,noBodyStyles:i}){const[o,a]=L.useState(()=>typeof window<"u"?window.location.href:""),l=L.useRef(0),c=L.useCallback(()=>{if(Sf===null&&n&&!i){Sf={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:f,innerHeight:d}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-l.current}px`,left:`${-f}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const h=d-window.innerHeight;h&&l.current>=d&&(document.body.style.top=`${-(l.current+h)}px`)}),300)}},[n]),u=L.useCallback(()=>{if(Sf!==null&&!i){const f=-parseInt(document.body.style.top,10),d=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Sf),window.requestAnimationFrame(()=>{if(s&&o!==window.location.href){a(window.location.href);return}window.scrollTo(d,f)}),Sf=null}},[o]);return L.useEffect(()=>{function f(){l.current=window.scrollY}return f(),window.addEventListener("scroll",f),()=>{window.removeEventListener("scroll",f)}},[]),L.useEffect(()=>{t||!r||(n?(!window.matchMedia("(display-mode: standalone)").matches&&c(),e||window.setTimeout(()=>{u()},500)):u())},[n,r,o,e,t,c,u]),{restorePositionSetting:u}}const qC=new WeakMap;function kt(n,e,t=!1){if(!n||!(n instanceof HTMLElement))return;let r={};Object.entries(e).forEach(([s,i])=>{if(s.startsWith("--")){n.style.setProperty(s,i);return}r[s]=n.style[s],n.style[s]=i}),!t&&qC.set(n,r)}function lp(n,e){if(!n||!(n instanceof HTMLElement))return;let t=qC.get(n);t&&(e?n.style[e]=t[e]:Object.entries(t).forEach(([r,s])=>{n.style[r]=s}))}const Gt=n=>{switch(n){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return n}};function cp(n,e){if(!n)return null;const t=window.getComputedStyle(n),r=t.transform||t.webkitTransform||t.mozTransform;let s=r.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[Gt(e)?13:12]):(s=r.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[Gt(e)?5:4]):null)}function Xj(n){return 8*(Math.log(n+1)-2)}const mt={DURATION:.5,EASE:[.32,.72,0,1]},QC=.4;function YC(n){const e=L.useRef(n);return L.useEffect(()=>{e.current=n}),L.useMemo(()=>(...t)=>e.current==null?void 0:e.current.call(e,...t),[])}function Zj({defaultProp:n,onChange:e}){const t=L.useState(n),[r]=t,s=L.useRef(r),i=YC(e);return L.useEffect(()=>{s.current!==r&&(i(r),s.current=r)},[r,s,i]),t}function eU({prop:n,defaultProp:e,onChange:t=()=>{}}){const[r,s]=Zj({defaultProp:e,onChange:t}),i=n!==void 0,o=i?n:r,a=YC(t),l=L.useCallback(c=>{if(i){const f=typeof c=="function"?c(n):c;f!==n&&a(f)}else s(c)},[i,n,s,a]);return[o,l]}function tU({activeSnapPointProp:n,setActiveSnapPointProp:e,snapPoints:t,drawerRef:r,overlayRef:s,fadeFromIndex:i,onSnapPointChange:o,direction:a="bottom"}){const[l,c]=eU({prop:n,defaultProp:t==null?void 0:t[0],onChange:e}),u=L.useMemo(()=>l===(t==null?void 0:t[t.length-1])||null,[t,l]),f=t&&t.length>0&&(i||i===0)&&!Number.isNaN(i)&&t[i]===l||!t,d=L.useMemo(()=>t==null?void 0:t.findIndex(v=>v===l),[t,l]),h=L.useMemo(()=>{var v;return(v=t==null?void 0:t.map(w=>{const E=typeof window<"u",k=typeof w=="string";let S=0;if(k&&(S=parseInt(w,10)),Gt(a)){const O=k?S:E?w*window.innerHeight:0;return E?a==="bottom"?window.innerHeight-O:-window.innerHeight+O:O}const M=k?S:E?w*window.innerWidth:0;return E?a==="right"?window.innerWidth-M:-window.innerWidth+M:M}))!=null?v:[]},[t]),p=L.useMemo(()=>d!==null?h==null?void 0:h[d]:null,[h,d]),m=L.useCallback(v=>{var w;const E=(w=h==null?void 0:h.findIndex(k=>k===v))!=null?w:null;o(E),kt(r.current,{transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,transform:Gt(a)?`translate3d(0, ${v}px, 0)`:`translate3d(${v}px, 0, 0)`}),h&&E!==h.length-1&&E!==i?kt(s.current,{transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,opacity:"0"}):kt(s.current,{transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,opacity:"1"}),c(E!==null?t==null?void 0:t[E]:null)},[r.current,t,h,i,s,c]);L.useEffect(()=>{if(l||n){var v;const w=(v=t==null?void 0:t.findIndex(E=>E===n||E===l))!=null?v:-1;h&&w!==-1&&typeof h[w]=="number"&&m(h[w])}},[l,n,t,h,m]);function y({draggedDistance:v,closeDrawer:w,velocity:E,dismissible:k}){if(i===void 0)return;const S=a==="bottom"||a==="right"?(p??0)-v:(p??0)+v,M=d===i-1,O=d===0,R=v>0;if(M&&kt(s.current,{transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`}),E>2&&!R){k?w():m(h[0]);return}if(E>2&&R&&h&&t){m(h[t.length-1]);return}const D=h==null?void 0:h.reduce((U,K)=>typeof U!="number"||typeof K!="number"?U:Math.abs(K-S)<Math.abs(U-S)?K:U),F=Gt(a)?window.innerHeight:window.innerWidth;if(E>QC&&Math.abs(v)<F*.4){const U=R?1:-1;if(U>0&&u){m(h[t.length-1]);return}if(O&&U<0&&k&&w(),d===null)return;m(h[d+U]);return}m(D)}function b({draggedDistance:v}){if(p===null)return;const w=a==="bottom"||a==="right"?p-v:p+v;(a==="bottom"||a==="right")&&w<h[h.length-1]||(a==="top"||a==="left")&&w>h[h.length-1]||kt(r.current,{transform:Gt(a)?`translate3d(0, ${w}px, 0)`:`translate3d(${w}px, 0, 0)`})}function x(v,w){if(!t||typeof d!="number"||!h||i===void 0)return null;const E=d===i-1;if(d>=i&&w)return 0;if(E&&!w)return 1;if(!f&&!E)return null;const S=E?d+1:d-1,M=E?h[S]-h[S-1]:h[S+1]-h[S],O=v/Math.abs(M);return E?1-O:O}return{isLastSnapPoint:u,activeSnapPoint:l,shouldFade:f,getPercentageDragged:x,setActiveSnapPoint:c,activeSnapPointIndex:d,onRelease:y,onDrag:b,snapPointsOffset:h}}const nU=.25,rU=100,XC=8,ma=16,ZC=26,mb="vaul-dragging";function eS({open:n,onOpenChange:e,children:t,shouldScaleBackground:r,onDrag:s,onRelease:i,snapPoints:o,nested:a=!1,setBackgroundColorOnScale:l=!0,closeThreshold:c=nU,scrollLockTimeout:u=rU,dismissible:f=!0,handleOnly:d=!1,fadeFromIndex:h=o&&o.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:y,modal:b=!0,onClose:x,noBodyStyles:v,direction:w="bottom",preventScrollRestoration:E=!0,disablePreventScroll:k=!1}){var S;const[M=!1,O]=L.useState(!1),[R,D]=L.useState(!1),[F,U]=L.useState(!1),[K,_]=L.useState(!1),[G,Y]=L.useState(!1),[re,Z]=L.useState(!1),me=L.useRef(null),ke=L.useRef(null),Pe=L.useRef(null),Ce=L.useRef(null),Ee=L.useRef(null),Ue=L.useRef(!1),Fe=L.useRef(null),He=L.useRef(0),Le=L.useRef(!1),Ze=L.useRef(0),le=L.useRef(null),ze=L.useRef(((S=le.current)==null?void 0:S.getBoundingClientRect().height)||0),ae=L.useRef(0),be=L.useCallback(te=>{o&&te===ce.length-1&&(ke.current=new Date)},[]),{activeSnapPoint:_e,activeSnapPointIndex:z,setActiveSnapPoint:J,onRelease:ne,snapPointsOffset:ce,onDrag:P,shouldFade:g,getPercentageDragged:A}=tU({snapPoints:o,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:le,fadeFromIndex:h,overlayRef:me,onSnapPointChange:be,direction:w});Gj({isDisabled:!M||G||!b||re||!R||k});const{restorePositionSetting:N}=Yj({isOpen:M,modal:b,nested:a,hasBeenOpened:R,preventScrollRestoration:E,noBodyStyles:v});function B(){return(window.innerWidth-ZC)/window.innerWidth}function W(te){var se;!f&&!o||le.current&&!le.current.contains(te.target)||(ze.current=((se=le.current)==null?void 0:se.getBoundingClientRect().height)||0,Y(!0),Pe.current=new Date,VC()&&window.addEventListener("touchend",()=>Ue.current=!1,{once:!0}),te.target.setPointerCapture(te.pointerId),He.current=Gt(w)?te.clientY:te.clientX)}function Q(te,se){var Te;let he=te;const Ke=(Te=window.getSelection())==null?void 0:Te.toString(),et=le.current?cp(le.current,w):null,ht=new Date;if(he.hasAttribute("data-vaul-no-drag")||he.closest("[data-vaul-no-drag]"))return!1;if(w==="right"||w==="left")return!0;if(ke.current&&ht.getTime()-ke.current.getTime()<500)return!1;if(et!==null&&(w==="bottom"?et>0:et<0))return!0;if(Ke&&Ke.length>0)return!1;if(Ee.current&&ht.getTime()-Ee.current.getTime()<u&&et===0||se)return Ee.current=ht,!1;for(;he;){if(he.scrollHeight>he.clientHeight){if(he.scrollTop!==0)return Ee.current=new Date,!1;if(he.getAttribute("role")==="dialog")return!0}he=he.parentNode}return!0}function ye(te){if(le.current&&G){const se=w==="bottom"||w==="right"?1:-1,Te=(He.current-(Gt(w)?te.clientY:te.clientX))*se,he=Te>0,Ke=o&&!f&&!he;if(Ke&&z===0)return;const et=Math.abs(Te),ht=document.querySelector("[vaul-drawer-wrapper]");let Xt=et/ze.current;const It=A(et,he);if(It!==null&&(Xt=It),Ke&&Xt>=1||!Ue.current&&!Q(te.target,he))return;if(le.current.classList.add(mb),Ue.current=!0,kt(le.current,{transition:"none"}),kt(me.current,{transition:"none"}),o&&P({draggedDistance:Te}),he&&!o){const ir=Xj(Te),or=Math.min(ir*-1,0)*se;kt(le.current,{transform:Gt(w)?`translate3d(0, ${or}px, 0)`:`translate3d(${or}px, 0, 0)`});return}const gs=1-Xt;if((g||h&&z===h-1)&&(s==null||s(te,Xt),kt(me.current,{opacity:`${gs}`,transition:"none"},!0)),ht&&me.current&&r){const ir=Math.min(B()+Xt*(1-B()),1),or=8-Xt*8,Lu=Math.max(0,14-Xt*14);kt(ht,{borderRadius:`${or}px`,transform:Gt(w)?`scale(${ir}) translate3d(0, ${Lu}px, 0)`:`scale(${ir}) translate3d(${Lu}px, 0, 0)`,transition:"none"},!0)}if(!o){const ir=et*se;kt(le.current,{transform:Gt(w)?`translate3d(0, ${ir}px, 0)`:`translate3d(${ir}px, 0, 0)`})}}}L.useEffect(()=>()=>{ct(!1),N()},[]),L.useEffect(()=>{var te;function se(){if(!le.current)return;const Te=document.activeElement;if(pb(Te)||Le.current){var he;const Ke=((he=window.visualViewport)==null?void 0:he.height)||0;let et=window.innerHeight-Ke;const ht=le.current.getBoundingClientRect().height||0;ae.current||(ae.current=ht);const Xt=le.current.getBoundingClientRect().top;if(Math.abs(Ze.current-et)>60&&(Le.current=!Le.current),o&&o.length>0&&ce&&z){const It=ce[z]||0;et+=It}if(Ze.current=et,ht>Ke||Le.current){const It=le.current.getBoundingClientRect().height;let gs=It;It>Ke&&(gs=Ke-ZC),y?le.current.style.height=`${It-Math.max(et,0)}px`:le.current.style.height=`${Math.max(gs,Ke-Xt)}px`}else le.current.style.height=`${ae.current}px`;o&&o.length>0&&!Le.current?le.current.style.bottom="0px":le.current.style.bottom=`${Math.max(et,0)}px`}}return(te=window.visualViewport)==null||te.addEventListener("resize",se),()=>{var Te;return(Te=window.visualViewport)==null?void 0:Te.removeEventListener("resize",se)}},[z,o,ce]);function Se(){le.current&&(je(),x==null||x(),kt(le.current,{transform:Gt(w)?`translate3d(0, ${w==="bottom"?"100%":"-100%"}, 0)`:`translate3d(${w==="right"?"100%":"-100%"}, 0, 0)`,transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`}),kt(me.current,{opacity:"0",transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`}),ct(!1),setTimeout(()=>{U(!1),O(!1)},300),setTimeout(()=>{o&&J(o[0])},mt.DURATION*1e3))}L.useEffect(()=>{if(!M&&r){const te=setTimeout(()=>{lp(document.body)},200);return()=>clearTimeout(te)}},[M,r]),L.useLayoutEffect(()=>{n?(O(!0),D(!0)):Se()},[n]),L.useEffect(()=>{K&&(e==null||e(M))},[M]),L.useEffect(()=>{_(!0)},[]);function qe(){if(!le.current)return;const te=document.querySelector("[vaul-drawer-wrapper]"),se=cp(le.current,w);kt(le.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`}),kt(me.current,{transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,opacity:"1"}),r&&se&&se>0&&M&&kt(te,{borderRadius:`${XC}px`,overflow:"hidden",...Gt(w)?{transform:`scale(${B()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${B()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${mt.DURATION}s`,transitionTimingFunction:`cubic-bezier(${mt.EASE.join(",")})`},!0)}function je(){!G||!le.current||(le.current.classList.remove(mb),Ue.current=!1,Y(!1),Ce.current=new Date)}function Be(te){if(!G||!le.current)return;le.current.classList.remove(mb),Ue.current=!1,Y(!1),Ce.current=new Date;const se=cp(le.current,w);if(!Q(te.target,!1)||!se||Number.isNaN(se)||Pe.current===null)return;const Te=Ce.current.getTime()-Pe.current.getTime(),he=He.current-(Gt(w)?te.clientY:te.clientX),Ke=Math.abs(he)/Te;if(Ke>.05&&(Z(!0),setTimeout(()=>{Z(!1)},200)),o){ne({draggedDistance:he*(w==="bottom"||w==="right"?1:-1),closeDrawer:Se,velocity:Ke,dismissible:f}),i==null||i(te,!0);return}if(w==="bottom"||w==="right"?he>0:he<0){qe(),i==null||i(te,!0);return}if(Ke>QC){Se(),i==null||i(te,!1);return}var et;const ht=Math.min((et=le.current.getBoundingClientRect().height)!=null?et:0,window.innerHeight);if(se>=ht*c){Se(),i==null||i(te,!1);return}i==null||i(te,!0),qe()}L.useEffect(()=>{M&&(kt(document.documentElement,{scrollBehavior:"auto"}),ke.current=new Date,ct(!0))},[M]),L.useEffect(()=>{if(le.current&&F){var te;const se=le==null||(te=le.current)==null?void 0:te.querySelectorAll("*");se==null||se.forEach(Te=>{const he=Te;(he.scrollHeight>he.clientHeight||he.scrollWidth>he.clientWidth)&&he.classList.add("vaul-scrollable")})}},[F]);function ct(te){const se=document.querySelector("[vaul-drawer-wrapper]");!se||!r||(te?(l&&(v||(kt(document.body,{background:document.body.style.backgroundColor||document.body.style.background}),kt(document.body,{background:"black"},!0))),kt(se,{borderRadius:`${XC}px`,overflow:"hidden",...Gt(w)?{transform:`scale(${B()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${B()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${mt.DURATION}s`,transitionTimingFunction:`cubic-bezier(${mt.EASE.join(",")})`})):(lp(se,"overflow"),lp(se,"transform"),lp(se,"borderRadius"),kt(se,{transitionProperty:"transform, border-radius",transitionDuration:`${mt.DURATION}s`,transitionTimingFunction:`cubic-bezier(${mt.EASE.join(",")})`})))}function Un(te){const se=te?(window.innerWidth-ma)/window.innerWidth:1,Te=te?-ma:0;Fe.current&&window.clearTimeout(Fe.current),kt(le.current,{transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,transform:`scale(${se}) translate3d(0, ${Te}px, 0)`}),!te&&le.current&&(Fe.current=setTimeout(()=>{const he=cp(le.current,w);kt(le.current,{transition:"none",transform:Gt(w)?`translate3d(0, ${he}px, 0)`:`translate3d(${he}px, 0, 0)`})},500))}function sr(te,se){if(se<0)return;const Te=Gt(w)?window.innerHeight:window.innerWidth,he=(Te-ma)/Te,Ke=he+se*(1-he),et=-ma+se*ma;kt(le.current,{transform:Gt(w)?`scale(${Ke}) translate3d(0, ${et}px, 0)`:`scale(${Ke}) translate3d(${et}px, 0, 0)`,transition:"none"})}function X(te,se){const Te=Gt(w)?window.innerHeight:window.innerWidth,he=se?(Te-ma)/Te:1,Ke=se?-ma:0;se&&kt(le.current,{transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,transform:Gt(w)?`scale(${he}) translate3d(0, ${Ke}px, 0)`:`scale(${he}) translate3d(${Ke}px, 0, 0)`})}return L.createElement(FC,{modal:b,onOpenChange:te=>{if(n!==void 0){e==null||e(te);return}te?(D(!0),O(te)):Se()},open:M},L.createElement(zC.Provider,{value:{visible:F,activeSnapPoint:_e,snapPoints:o,setActiveSnapPoint:J,drawerRef:le,overlayRef:me,scaleBackground:ct,onOpenChange:e,onPress:W,setVisible:U,onRelease:Be,onDrag:ye,dismissible:f,handleOnly:d,isOpen:M,isDragging:G,shouldFade:g,closeDrawer:Se,onNestedDrag:sr,onNestedOpenChange:Un,onNestedRelease:X,keyboardIsOpen:Le,openProp:n,modal:b,snapPointsOffset:ce,direction:w}},t))}const sU=250,iU=120,tS=L.forwardRef(function({preventCycle:n=!1,children:e,...t},r){const{visible:s,closeDrawer:i,isDragging:o,snapPoints:a,activeSnapPoint:l,setActiveSnapPoint:c,dismissible:u,handleOnly:f,onPress:d,onDrag:h}=op(),p=L.useRef(null),m=L.useRef(!1);function y(){if(m.current){v();return}window.setTimeout(()=>{b()},iU)}function b(){if(o||n||m.current){v();return}if(v(),(!a||a.length===0)&&u){i();return}if(l===a[a.length-1]&&u){i();return}const E=a.findIndex(S=>S===l);if(E===-1)return;const k=a[E+1];c(k)}function x(){p.current=window.setTimeout(()=>{m.current=!0},sU)}function v(){window.clearTimeout(p.current),m.current=!1}return L.createElement("div",{onClick:y,onDoubleClick:()=>{m.current=!0,i()},onPointerCancel:v,onPointerDown:w=>{f&&d(w),x()},onPointerMove:w=>{f&&h(w)},ref:r,"vaul-drawer-visible":s?"true":"false","vaul-handle":"","aria-hidden":"true",...t},L.createElement("span",{"vaul-handle-hitarea":"","aria-hidden":"true"},e))});tS.displayName="Drawer.Handle";const nS=L.forwardRef(function({children:n,...e},t){const{overlayRef:r,snapPoints:s,onRelease:i,shouldFade:o,isOpen:a,visible:l}=op(),c=JC(t,r),u=s&&s.length>0;return L.createElement(ob,{onMouseUp:i,ref:c,"vaul-drawer-visible":l?"true":"false","vaul-overlay":"","vaul-snap-points":a&&u?"true":"false","vaul-snap-points-overlay":a&&o?"true":"false",...e})});nS.displayName="Drawer.Overlay";const rS=L.forwardRef(function({onOpenAutoFocus:n,onPointerDownOutside:e,onAnimationEnd:t,style:r,...s},i){const{drawerRef:o,onPress:a,onRelease:l,onDrag:c,dismissible:u,keyboardIsOpen:f,snapPointsOffset:d,visible:h,closeDrawer:p,modal:m,openProp:y,onOpenChange:b,setVisible:x,handleOnly:v,direction:w}=op(),E=JC(i,o),k=L.useRef(null),S=L.useRef(!1),M=(O,R,D=0)=>{if(S.current)return!0;const F=Math.abs(O.y),U=Math.abs(O.x),K=U>F,_=["bottom","right"].includes(R)?1:-1;if(R==="left"||R==="right"){if(!(O.x*_<0)&&U>=0&&U<=D)return K}else if(!(O.y*_<0)&&F>=0&&F<=D)return!K;return S.current=!0,!0};return L.useEffect(()=>{x(!0)},[]),L.createElement(ab,{"vaul-drawer":"","vaul-drawer-direction":w,"vaul-drawer-visible":h?"true":"false",...s,ref:E,style:d&&d.length>0?{"--snap-point-height":`${d[0]}px`,...r}:r,onOpenAutoFocus:O=>{if(n)n(O);else{var R;O.preventDefault(),(R=o.current)==null||R.focus()}},onPointerDown:O=>{v||(s.onPointerDown==null||s.onPointerDown.call(s,O),k.current={x:O.clientX,y:O.clientY},a(O))},onPointerDownOutside:O=>{if(e==null||e(O),!m||O.defaultPrevented){O.preventDefault();return}f.current&&(f.current=!1),O.preventDefault(),b==null||b(!1),!(!u||y!==void 0)&&p()},onFocusOutside:O=>{if(!m){O.preventDefault();return}},onEscapeKeyDown:O=>{if(!m){O.preventDefault();return}},onPointerMove:O=>{if(v||(s.onPointerMove==null||s.onPointerMove.call(s,O),!k.current))return;const R=O.clientY-k.current.y,D=O.clientX-k.current.x,F=O.pointerType==="touch"?10:2;M({x:D,y:R},w,F)?c(O):(Math.abs(D)>F||Math.abs(R)>F)&&(k.current=null)},onPointerUp:O=>{s.onPointerUp==null||s.onPointerUp.call(s,O),k.current=null,S.current=!1,l(O)}})});rS.displayName="Drawer.Content";function oU({onDrag:n,onOpenChange:e,...t}){const{onNestedDrag:r,onNestedOpenChange:s,onNestedRelease:i}=op();if(!r)throw new Error("Drawer.NestedRoot must be placed in another drawer");return L.createElement(eS,{nested:!0,onClose:()=>{s(!1)},onDrag:(o,a)=>{r(o,a),n==null||n(o,a)},onOpenChange:o=>{o&&s(o),e==null||e(o)},onRelease:i,...t})}const qr={Root:eS,NestedRoot:oU,Content:rS,Handle:tS,Overlay:nS,Trigger:jC,Portal:UC,Close:HC,Title:lb,Description:cb},sS=({shouldScaleBackground:n=!0,...e})=>C.jsx(qr.Root,{shouldScaleBackground:n,...e});sS.displayName="Drawer";const aU=qr.Trigger,lU=qr.Portal,iS=L.forwardRef(({className:n,...e},t)=>C.jsx(qr.Overlay,{ref:t,className:pe("fixed inset-0 z-50 bg-black/5 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...e}));iS.displayName=qr.Overlay.displayName;const oS=L.forwardRef(({className:n,children:e,...t},r)=>C.jsxs(lU,{children:[C.jsx(iS,{}),C.jsx(Ef,{trapped:!1,children:C.jsxs(qr.Content,{ref:r,className:pe("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-[16px] drop-shadow-2xl bg-white",n),...t,children:[C.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-white"}),e,C.jsx(qr.Close,{className:"absolute right-2 top-4 hover:bg-gray-200 rounded-full p-2 ring-offset-white transition focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2 disabled:pointer-events-none text-black data-[state=open]:bg-gray-100 data-[state=open]:text-black",children:C.jsx(l4,{size:20,fill:"black"})})]})})]}));oS.displayName="DrawerContent";const aS=({className:n,...e})=>C.jsx("div",{className:pe("grid gap-1.5 p-4 text-center sm:text-left",n),...e});aS.displayName="DrawerHeader";const lS=L.forwardRef(({className:n,...e},t)=>C.jsx(qr.Title,{ref:t,className:pe("text-lg font-semibold leading-none tracking-tight",n),...e}));lS.displayName=qr.Title.displayName;const cU=L.forwardRef(({className:n,...e},t)=>C.jsx(qr.Description,{ref:t,className:pe("text-sm text-black",n),...e}));cU.displayName=qr.Description.displayName;const cS=({title:n,content:e,contentClassName:t})=>C.jsxs(oS,{className:"w-full z-20",children:[C.jsx(aS,{className:"px-4 pt-0",children:C.jsx(lS,{className:"text-left sm:text-center text-base",children:n})}),C.jsx("div",{className:pe("flex flex-col gap-4 w-full h-full pb-4 text-base text-black",t),children:e&&e})]}),uU=FC,fU=jC,dU=UC,hU=HC,uS=H.forwardRef(({className:n,...e},t)=>C.jsx(ob,{ref:t,className:pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...e}));uS.displayName=ob.displayName;const fS=H.forwardRef(({className:n,children:e,...t},r)=>C.jsxs(dU,{children:[C.jsx(uS,{}),C.jsx(Ef,{trapped:!1,children:C.jsxs(ab,{ref:r,className:pe("fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 bg-white duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-xl",n),...t,children:[C.jsx("div",{}),e]})})]}));fS.displayName=ab.displayName;const dS=({className:n,...e})=>C.jsx("div",{className:pe("grid gap-1.5 p-4 text-center sm:text-left",n),...e});dS.displayName="DialogHeader";const hS=({className:n,...e})=>C.jsx("div",{className:pe("flex space-x-2",n),...e});hS.displayName="DialogFooter";const pS=H.forwardRef(({className:n,...e},t)=>C.jsx(lb,{ref:t,className:pe("text-lg font-semibold leading-none tracking-tight",n),...e}));pS.displayName=lb.displayName;const pU=H.forwardRef(({className:n,...e},t)=>C.jsx(cb,{ref:t,className:pe("text-sm text-black",n),...e}));pU.displayName=cb.displayName;function mU(n){return Object.prototype.toString.call(n)==="[object Object]"}function mS(n){return mU(n)||Array.isArray(n)}function gU(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function gb(n,e){const t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;const s=JSON.stringify(Object.keys(n.breakpoints||{})),i=JSON.stringify(Object.keys(e.breakpoints||{}));return s!==i?!1:t.every(o=>{const a=n[o],l=e[o];return typeof a=="function"?`${a}`==`${l}`:!mS(a)||!mS(l)?a===l:gb(a,l)})}function gS(n){return n.concat().sort((e,t)=>e.name>t.name?1:-1).map(e=>e.options)}function yU(n,e){if(n.length!==e.length)return!1;const t=gS(n),r=gS(e);return t.every((s,i)=>{const o=r[i];return gb(s,o)})}function yb(n){return typeof n=="number"}function bb(n){return typeof n=="string"}function wb(n){return typeof n=="boolean"}function yS(n){return Object.prototype.toString.call(n)==="[object Object]"}function Tt(n){return Math.abs(n)}function vb(n){return Math.sign(n)}function Tf(n,e){return Tt(n-e)}function bU(n,e){if(n===0||e===0||Tt(n)<=Tt(e))return 0;const t=Tf(Tt(n),Tt(e));return Tt(t/n)}function Nf(n){return Rf(n).map(Number)}function Qr(n){return n[Of(n)]}function Of(n){return Math.max(0,n.length-1)}function xb(n,e){return e===Of(n)}function bS(n,e=0){return Array.from(Array(n),(t,r)=>e+r)}function Rf(n){return Object.keys(n)}function wS(n,e){return[n,e].reduce((t,r)=>(Rf(r).forEach(s=>{const i=t[s],o=r[s],a=yS(i)&&yS(o);t[s]=a?wS(i,o):o}),t),{})}function Ab(n,e){return typeof e.MouseEvent<"u"&&n instanceof e.MouseEvent}function wU(n,e){const t={start:r,center:s,end:i};function r(){return 0}function s(l){return i(l)/2}function i(l){return e-l}function o(l,c){return bb(n)?t[n](l):n(e,l,c)}return{measure:o}}function Mf(){let n=[];function e(s,i,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(i,o,a),l=()=>s.removeEventListener(i,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return n.push(l),r}function t(){n=n.filter(s=>s())}const r={add:e,clear:t};return r}function vU(n,e,t,r){const s=Mf(),i=1e3/60;let o=null,a=0,l=0;function c(){s.add(n,"visibilitychange",()=>{n.hidden&&p()})}function u(){h(),s.clear()}function f(y){if(!l)return;o||(o=y);const b=y-o;for(o=y,a+=b;a>=i;)t(),a-=i;const x=Tt(a/i);r(x),l&&e.requestAnimationFrame(f)}function d(){l||(l=e.requestAnimationFrame(f))}function h(){e.cancelAnimationFrame(l),o=null,a=0,l=0}function p(){o=null,a=0}return{init:c,destroy:u,start:d,stop:h,update:t,render:r}}function xU(n,e){const t=e==="rtl",r=n==="y",s=r?"y":"x",i=r?"x":"y",o=!r&&t?-1:1,a=u(),l=f();function c(p){const{height:m,width:y}=p;return r?m:y}function u(){return r?"top":t?"right":"left"}function f(){return r?"bottom":t?"left":"right"}function d(p){return p*o}return{scroll:s,cross:i,startEdge:a,endEdge:l,measureSize:c,direction:d}}function ga(n=0,e=0){const t=Tt(n-e);function r(c){return c<n}function s(c){return c>e}function i(c){return r(c)||s(c)}function o(c){return i(c)?r(c)?n:e:c}function a(c){return t?c-t*Math.ceil((c-e)/t):c}return{length:t,max:e,min:n,constrain:o,reachedAny:i,reachedMax:s,reachedMin:r,removeOffset:a}}function vS(n,e,t){const{constrain:r}=ga(0,n),s=n+1;let i=o(e);function o(d){return t?Tt((s+d)%s):r(d)}function a(){return i}function l(d){return i=o(d),f}function c(d){return u().set(a()+d)}function u(){return vS(n,a(),t)}const f={get:a,set:l,add:c,clone:u};return f}function AU(n,e,t,r,s,i,o,a,l,c,u,f,d,h,p,m,y,b,x){const{cross:v,direction:w}=n,E=["INPUT","SELECT","TEXTAREA"],k={passive:!1},S=Mf(),M=Mf(),O=ga(50,225).constrain(h.measure(20)),R={mouse:300,touch:400},D={mouse:500,touch:600},F=p?43:25;let U=!1,K=0,_=0,G=!1,Y=!1,re=!1,Z=!1;function me(ae){if(!x)return;function be(z){(wb(x)||x(ae,z))&&Fe(z)}const _e=e;S.add(_e,"dragstart",z=>z.preventDefault(),k).add(_e,"touchmove",()=>{},k).add(_e,"touchend",()=>{}).add(_e,"touchstart",be).add(_e,"mousedown",be).add(_e,"touchcancel",Le).add(_e,"contextmenu",Le).add(_e,"click",Ze,!0)}function ke(){S.clear(),M.clear()}function Pe(){const ae=Z?t:e;M.add(ae,"touchmove",He,k).add(ae,"touchend",Le).add(ae,"mousemove",He,k).add(ae,"mouseup",Le)}function Ce(ae){const be=ae.nodeName||"";return E.includes(be)}function Ee(){return(p?D:R)[Z?"mouse":"touch"]}function Ue(ae,be){const _e=f.add(vb(ae)*-1),z=u.byDistance(ae,!p).distance;return p||Tt(ae)<O?z:y&&be?z*.5:u.byIndex(_e.get(),0).distance}function Fe(ae){const be=Ab(ae,r);Z=be,re=p&&be&&!ae.buttons&&U,U=Tf(s.get(),o.get())>=2,!(be&&ae.button!==0)&&(Ce(ae.target)||(G=!0,i.pointerDown(ae),c.useFriction(0).useDuration(0),s.set(o),Pe(),K=i.readPoint(ae),_=i.readPoint(ae,v),d.emit("pointerDown")))}function He(ae){if(!Ab(ae,r)&&ae.touches.length>=2)return Le(ae);const _e=i.readPoint(ae),z=i.readPoint(ae,v),J=Tf(_e,K),ne=Tf(z,_);if(!Y&&!Z&&(!ae.cancelable||(Y=J>ne,!Y)))return Le(ae);const ce=i.pointerMove(ae);J>m&&(re=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(w(ce)),ae.preventDefault()}function Le(ae){const _e=u.byDistance(0,!1).index!==f.get(),z=i.pointerUp(ae)*Ee(),J=Ue(w(z),_e),ne=bU(z,J),ce=F-10*ne,P=b+ne/50;Y=!1,G=!1,M.clear(),c.useDuration(ce).useFriction(P),l.distance(J,!p),Z=!1,d.emit("pointerUp")}function Ze(ae){re&&(ae.stopPropagation(),ae.preventDefault(),re=!1)}function le(){return G}return{init:me,destroy:ke,pointerDown:le}}function EU(n,e){let r,s;function i(f){return f.timeStamp}function o(f,d){const p=`client${(d||n.scroll)==="x"?"X":"Y"}`;return(Ab(f,e)?f:f.touches[0])[p]}function a(f){return r=f,s=f,o(f)}function l(f){const d=o(f)-o(s),h=i(f)-i(r)>170;return s=f,h&&(r=f),d}function c(f){if(!r||!s)return 0;const d=o(s)-o(r),h=i(f)-i(r),p=i(f)-i(s)>170,m=d/h;return h&&!p&&Tt(m)>.1?m:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function kU(){function n(t){const{offsetTop:r,offsetLeft:s,offsetWidth:i,offsetHeight:o}=t;return{top:r,right:s+i,bottom:r+o,left:s,width:i,height:o}}return{measure:n}}function CU(n){function e(r){return n*(r/100)}return{measure:e}}function SU(n,e,t,r,s,i,o){let a,l,c=[],u=!1;function f(m){return s.measureSize(o.measure(m))}function d(m){if(!i)return;l=f(n),c=r.map(f);function y(x){for(const v of x){const w=v.target===n,E=r.indexOf(v.target),k=w?l:c[E],S=f(w?n:r[E]);if(Tt(S-k)>=.5){t.requestAnimationFrame(()=>{m.reInit(),e.emit("resize")});break}}}a=new ResizeObserver(x=>{u||(wb(i)||i(m,x))&&y(x)}),[n].concat(r).forEach(x=>a.observe(x))}function h(){a&&a.disconnect(),u=!0}return{init:d,destroy:h}}function TU(n,e,t,r,s){let i=0,o=0,a=r,l=s,c=n.get(),u=0;function f(){const E=t.get()-n.get(),k=!a;let S=0;return k?(i=0,n.set(t),S=E):(i+=E/a,i*=l,c+=i,n.add(i),S=c-u),o=vb(S),u=c,w}function d(){const E=t.get()-e.get();return Tt(E)<.001}function h(){return a}function p(){return o}function m(){return i}function y(){return x(r)}function b(){return v(s)}function x(E){return a=E,w}function v(E){return l=E,w}const w={direction:p,duration:h,velocity:m,seek:f,settled:d,useBaseFriction:b,useBaseDuration:y,useFriction:v,useDuration:x};return w}function NU(n,e,t,r,s){const i=s.measure(10),o=s.measure(50),a=ga(.1,.99);let l=!1;function c(){return!(l||!n.reachedAny(t.get())||!n.reachedAny(e.get()))}function u(h){if(!c())return;const p=n.reachedMin(e.get())?"min":"max",m=Tt(n[p]-e.get()),y=t.get()-e.get(),b=a.constrain(m/o);t.subtract(y*b),!h&&Tt(y)<i&&(t.set(n.constrain(t.get())),r.useDuration(25).useBaseFriction())}function f(h){l=!h}return{shouldConstrain:c,constrain:u,toggleActive:f}}function OU(n,e,t,r,s){const i=ga(-e+n,0),o=f(),a=u(),l=d();function c(p,m){return Tf(p,m)<1}function u(){const p=o[0],m=Qr(o),y=o.lastIndexOf(p),b=o.indexOf(m)+1;return ga(y,b)}function f(){return t.map((p,m)=>{const{min:y,max:b}=i,x=i.constrain(p),v=!m,w=xb(t,m);return v?b:w||c(y,x)?y:c(b,x)?b:x}).map(p=>parseFloat(p.toFixed(3)))}function d(){if(e<=n+s)return[i.max];if(r==="keepSnaps")return o;const{min:p,max:m}=a;return o.slice(p,m)}return{snapsContained:l,scrollContainLimit:a}}function RU(n,e,t){const r=e[0],s=t?r-n:Qr(e);return{limit:ga(s,r)}}function MU(n,e,t,r){const i=e.min+.1,o=e.max+.1,{reachedMin:a,reachedMax:l}=ga(i,o);function c(d){return d===1?l(t.get()):d===-1?a(t.get()):!1}function u(d){if(!c(d))return;const h=n*(d*-1);r.forEach(p=>p.add(h))}return{loop:u}}function DU(n){const{max:e,length:t}=n;function r(i){const o=i-e;return t?o/-t:0}return{get:r}}function PU(n,e,t,r,s){const{startEdge:i,endEdge:o}=n,{groupSlides:a}=s,l=f().map(e.measure),c=d(),u=h();function f(){return a(r).map(m=>Qr(m)[o]-m[0][i]).map(Tt)}function d(){return r.map(m=>t[i]-m[i]).map(m=>-Tt(m))}function h(){return a(c).map(m=>m[0]).map((m,y)=>m+l[y])}return{snaps:c,snapsAligned:u}}function IU(n,e,t,r,s,i){const{groupSlides:o}=s,{min:a,max:l}=r,c=u();function u(){const d=o(i),h=!n||e==="keepSnaps";return t.length===1?[i]:h?d:d.slice(a,l).map((p,m,y)=>{const b=!m,x=xb(y,m);if(b){const v=Qr(y[0])+1;return bS(v)}if(x){const v=Of(i)-Qr(y)[0]+1;return bS(v,Qr(y)[0])}return p})}return{slideRegistry:c}}function LU(n,e,t,r,s){const{reachedAny:i,removeOffset:o,constrain:a}=r;function l(p){return p.concat().sort((m,y)=>Tt(m)-Tt(y))[0]}function c(p){const m=n?o(p):a(p),y=e.map((x,v)=>({diff:u(x-m,0),index:v})).sort((x,v)=>Tt(x.diff)-Tt(v.diff)),{index:b}=y[0];return{index:b,distance:m}}function u(p,m){const y=[p,p+t,p-t];if(!n)return p;if(!m)return l(y);const b=y.filter(x=>vb(x)===m);return b.length?l(b):Qr(y)-t}function f(p,m){const y=e[p]-s.get(),b=u(y,m);return{index:p,distance:b}}function d(p,m){const y=s.get()+p,{index:b,distance:x}=c(y),v=!n&&i(y);if(!m||v)return{index:b,distance:p};const w=e[b]-x,E=p+u(w,0);return{index:b,distance:E}}return{byDistance:d,byIndex:f,shortcut:u}}function _U(n,e,t,r,s,i,o){function a(f){const d=f.distance,h=f.index!==e.get();i.add(d),d&&(r.duration()?n.start():(n.update(),n.render(1),n.update())),h&&(t.set(e.get()),e.set(f.index),o.emit("select"))}function l(f,d){const h=s.byDistance(f,d);a(h)}function c(f,d){const h=e.clone().set(f),p=s.byIndex(h.get(),d);a(p)}return{distance:l,index:c}}function BU(n,e,t,r,s,i,o){let a=0;function l(){i.add(document,"keydown",c,!1),e.forEach(u)}function c(d){d.code==="Tab"&&(a=new Date().getTime())}function u(d){const h=()=>{if(new Date().getTime()-a>10)return;n.scrollLeft=0;const y=e.indexOf(d),b=t.findIndex(x=>x.includes(y));yb(b)&&(s.useDuration(0),r.index(b,0),o.emit("slideFocus"))};i.add(d,"focus",h,{passive:!0,capture:!0})}return{init:l}}function up(n){let e=n;function t(){return e}function r(l){e=o(l)}function s(l){e+=o(l)}function i(l){e-=o(l)}function o(l){return yb(l)?l:l.get()}return{get:t,set:r,add:s,subtract:i}}function xS(n,e){const t=n.scroll==="x"?i:o,r=e.style;let s=!1;function i(f){return`translate3d(${f}px,0px,0px)`}function o(f){return`translate3d(0px,${f}px,0px)`}function a(f){s||(r.transform=t(n.direction(f)))}function l(f){s=!f}function c(){s||(r.transform="",e.getAttribute("style")||e.removeAttribute("style"))}return{clear:c,to:a,toggleActive:l}}function FU(n,e,t,r,s,i,o,a,l){const u=Nf(s),f=Nf(s).reverse(),d=b().concat(x());function h(S,M){return S.reduce((O,R)=>O-s[R],M)}function p(S,M){return S.reduce((O,R)=>h(O,M)>0?O.concat([R]):O,[])}function m(S){return i.map((M,O)=>({start:M-r[O]+.5+S,end:M+e-.5+S}))}function y(S,M,O){const R=m(M);return S.map(D=>{const F=O?0:-t,U=O?t:0,K=O?"end":"start",_=R[D][K];return{index:D,loopPoint:_,slideLocation:up(-1),translate:xS(n,l[D]),target:()=>a.get()>_?F:U}})}function b(){const S=o[0],M=p(f,S);return y(M,t,!1)}function x(){const S=e-o[0]-1,M=p(u,S);return y(M,-t,!0)}function v(){return d.every(({index:S})=>{const M=u.filter(O=>O!==S);return h(M,e)<=.1})}function w(){d.forEach(S=>{const{target:M,translate:O,slideLocation:R}=S,D=M();D!==R.get()&&(O.to(D),R.set(D))})}function E(){d.forEach(S=>S.translate.clear())}return{canLoop:v,clear:E,loop:w,loopPoints:d}}function jU(n,e,t){let r,s=!1;function i(l){if(!t)return;function c(u){for(const f of u)if(f.type==="childList"){l.reInit(),e.emit("slidesChanged");break}}r=new MutationObserver(u=>{s||(wb(t)||t(l,u))&&c(u)}),r.observe(n,{childList:!0})}function o(){r&&r.disconnect(),s=!0}return{init:i,destroy:o}}function UU(n,e,t,r){const s={};let i=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(p=>{l||(p.forEach(m=>{const y=e.indexOf(m.target);s[y]=m}),i=null,o=null,t.emit("slidesInView"))},{root:n.parentElement,threshold:r}),e.forEach(p=>a.observe(p))}function u(){a&&a.disconnect(),l=!0}function f(p){return Rf(s).reduce((m,y)=>{const b=parseInt(y),{isIntersecting:x}=s[b];return(p&&x||!p&&!x)&&m.push(b),m},[])}function d(p=!0){if(p&&i)return i;if(!p&&o)return o;const m=f(p);return p&&(i=m),p||(o=m),m}return{init:c,destroy:u,get:d}}function HU(n,e,t,r,s,i){const{measureSize:o,startEdge:a,endEdge:l}=n,c=t[0]&&s,u=p(),f=m(),d=t.map(o),h=y();function p(){if(!c)return 0;const x=t[0];return Tt(e[a]-x[a])}function m(){if(!c)return 0;const x=i.getComputedStyle(Qr(r));return parseFloat(x.getPropertyValue(`margin-${l}`))}function y(){return t.map((x,v,w)=>{const E=!v,k=xb(w,v);return E?d[v]+u:k?d[v]+f:w[v+1][a]-x[a]}).map(Tt)}return{slideSizes:d,slideSizesWithGaps:h,startGap:u,endGap:f}}function zU(n,e,t,r,s,i,o,a,l){const{startEdge:c,endEdge:u,direction:f}=n,d=yb(t);function h(b,x){return Nf(b).filter(v=>v%x===0).map(v=>b.slice(v,v+x))}function p(b){return b.length?Nf(b).reduce((x,v,w)=>{const E=Qr(x)||0,k=E===0,S=v===Of(b),M=s[c]-i[E][c],O=s[c]-i[v][u],R=!r&&k?f(o):0,D=!r&&S?f(a):0,F=Tt(O-D-(M+R));return w&&F>e+l&&x.push(v),S&&x.push(b.length),x},[]).map((x,v,w)=>{const E=Math.max(w[v-1]||0);return b.slice(E,x)}):[]}function m(b){return d?h(b,t):p(b)}return{groupSlides:m}}function VU(n,e,t,r,s,i,o){const{align:a,axis:l,direction:c,startIndex:u,loop:f,duration:d,dragFree:h,dragThreshold:p,inViewThreshold:m,slidesToScroll:y,skipSnaps:b,containScroll:x,watchResize:v,watchSlides:w,watchDrag:E}=i,k=2,S=kU(),M=S.measure(e),O=t.map(S.measure),R=xU(l,c),D=R.measureSize(M),F=CU(D),U=wU(a,D),K=!f&&!!x,_=f||!!x,{slideSizes:G,slideSizesWithGaps:Y,startGap:re,endGap:Z}=HU(R,M,O,t,_,s),me=zU(R,D,y,f,M,O,re,Z,k),{snaps:ke,snapsAligned:Pe}=PU(R,U,M,O,me),Ce=-Qr(ke)+Qr(Y),{snapsContained:Ee,scrollContainLimit:Ue}=OU(D,Ce,Pe,x,k),Fe=K?Ee:Pe,{limit:He}=RU(Ce,Fe,f),Le=vS(Of(Fe),u,f),Ze=Le.clone(),le=Nf(t),ze=({dragHandler:qe,scrollBody:je,scrollBounds:Be,options:{loop:ct}})=>{ct||Be.constrain(qe.pointerDown()),je.seek()},ae=({scrollBody:qe,translate:je,location:Be,offsetLocation:ct,scrollLooper:Un,slideLooper:sr,dragHandler:X,animation:te,eventHandler:se,scrollBounds:Te,options:{loop:he}},Ke)=>{const et=qe.velocity(),ht=qe.settled(),Xt=!Te.shouldConstrain(),It=he?ht:ht&&Xt;It&&!X.pointerDown()&&(te.stop(),se.emit("settle")),It||se.emit("scroll"),ct.set(Be.get()-et+et*Ke),he&&(Un.loop(qe.direction()),sr.loop()),je.to(ct.get())},be=vU(r,s,()=>ze(Se),qe=>ae(Se,qe)),_e=.68,z=Fe[Le.get()],J=up(z),ne=up(z),ce=up(z),P=TU(J,ne,ce,d,_e),g=LU(f,Fe,Ce,He,ce),A=_U(be,Le,Ze,P,g,ce,o),N=DU(He),B=Mf(),W=UU(e,t,o,m),{slideRegistry:Q}=IU(K,x,Fe,Ue,me,le),ye=BU(n,t,Q,A,P,B,o),Se={ownerDocument:r,ownerWindow:s,eventHandler:o,containerRect:M,slideRects:O,animation:be,axis:R,dragHandler:AU(R,n,r,s,ce,EU(R,s),J,be,A,P,g,Le,o,F,h,p,b,_e,E),eventStore:B,percentOfView:F,index:Le,indexPrevious:Ze,limit:He,location:J,offsetLocation:ne,options:i,resizeHandler:SU(e,o,s,t,R,v,S),scrollBody:P,scrollBounds:NU(He,ne,ce,P,F),scrollLooper:MU(Ce,He,ne,[J,ne,ce]),scrollProgress:N,scrollSnapList:Fe.map(N.get),scrollSnaps:Fe,scrollTarget:g,scrollTo:A,slideLooper:FU(R,D,Ce,G,Y,ke,Fe,ne,t),slideFocus:ye,slidesHandler:jU(e,o,w),slidesInView:W,slideIndexes:le,slideRegistry:Q,slidesToScroll:me,target:ce,translate:xS(R,e)};return Se}function $U(){let n={},e;function t(c){e=c}function r(c){return n[c]||[]}function s(c){return r(c).forEach(u=>u(e,c)),l}function i(c,u){return n[c]=r(c).concat([u]),l}function o(c,u){return n[c]=r(c).filter(f=>f!==u),l}function a(){n={}}const l={init:t,emit:s,off:o,on:i,clear:a};return l}const WU={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function GU(n){function e(i,o){return wS(i,o||{})}function t(i){const o=i.breakpoints||{},a=Rf(o).filter(l=>n.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>e(l,c),{});return e(i,a)}function r(i){return i.map(o=>Rf(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(n.matchMedia)}return{mergeOptions:e,optionsAtMedia:t,optionsMediaQueries:r}}function KU(n){let e=[];function t(i,o){return e=o.filter(({options:a})=>n.optionsAtMedia(a).active!==!1),e.forEach(a=>a.init(i,n)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function r(){e=e.filter(i=>i.destroy())}return{init:t,destroy:r}}function fp(n,e,t){const r=n.ownerDocument,s=r.defaultView,i=GU(s),o=KU(i),a=Mf(),l=$U(),{mergeOptions:c,optionsAtMedia:u,optionsMediaQueries:f}=i,{on:d,off:h,emit:p}=l,m=D;let y=!1,b,x=c(WU,fp.globalOptions),v=c(x),w=[],E,k,S;function M(){const{container:ze,slides:ae}=v;k=(bb(ze)?n.querySelector(ze):ze)||n.children[0];const _e=bb(ae)?k.querySelectorAll(ae):ae;S=[].slice.call(_e||k.children)}function O(ze){const ae=VU(n,k,S,r,s,ze,l);if(ze.loop&&!ae.slideLooper.canLoop()){const be=Object.assign({},ze,{loop:!1});return O(be)}return ae}function R(ze,ae){y||(x=c(x,ze),v=u(x),w=ae||w,M(),b=O(v),f([x,...w.map(({options:be})=>be)]).forEach(be=>a.add(be,"change",D)),v.active&&(b.translate.to(b.location.get()),b.animation.init(),b.slidesInView.init(),b.slideFocus.init(),b.eventHandler.init(le),b.resizeHandler.init(le),b.slidesHandler.init(le),b.options.loop&&b.slideLooper.loop(),k.offsetParent&&S.length&&b.dragHandler.init(le),E=o.init(le,w)))}function D(ze,ae){const be=ke();F(),R(c({startIndex:be},ze),ae),l.emit("reInit")}function F(){b.dragHandler.destroy(),b.eventStore.clear(),b.translate.clear(),b.slideLooper.clear(),b.resizeHandler.destroy(),b.slidesHandler.destroy(),b.slidesInView.destroy(),b.animation.destroy(),o.destroy(),a.clear()}function U(){y||(y=!0,a.clear(),F(),l.emit("destroy"),l.clear())}function K(ze,ae,be){!v.active||y||(b.scrollBody.useBaseFriction().useDuration(ae===!0?0:v.duration),b.scrollTo.index(ze,be||0))}function _(ze){const ae=b.index.add(1).get();K(ae,ze,-1)}function G(ze){const ae=b.index.add(-1).get();K(ae,ze,1)}function Y(){return b.index.add(1).get()!==ke()}function re(){return b.index.add(-1).get()!==ke()}function Z(){return b.scrollSnapList}function me(){return b.scrollProgress.get(b.location.get())}function ke(){return b.index.get()}function Pe(){return b.indexPrevious.get()}function Ce(){return b.slidesInView.get()}function Ee(){return b.slidesInView.get(!1)}function Ue(){return E}function Fe(){return b}function He(){return n}function Le(){return k}function Ze(){return S}const le={canScrollNext:Y,canScrollPrev:re,containerNode:Le,internalEngine:Fe,destroy:U,off:h,on:d,emit:p,plugins:Ue,previousScrollSnap:Pe,reInit:m,rootNode:He,scrollNext:_,scrollPrev:G,scrollProgress:me,scrollSnapList:Z,scrollTo:K,selectedScrollSnap:ke,slideNodes:Ze,slidesInView:Ce,slidesNotInView:Ee};return R(e,t),setTimeout(()=>l.emit("init"),0),le}fp.globalOptions=void 0;function Eb(n={},e=[]){const t=L.useRef(n),r=L.useRef(e),[s,i]=L.useState(),[o,a]=L.useState(),l=L.useCallback(()=>{s&&s.reInit(t.current,r.current)},[s]);return L.useEffect(()=>{if(gU()&&o){fp.globalOptions=Eb.globalOptions;const c=fp(o,t.current,r.current);return i(c),()=>c.destroy()}else i(void 0)},[o,i]),L.useEffect(()=>{gb(t.current,n)||(t.current=n,l())},[n,l]),L.useEffect(()=>{yU(r.current,e)||(r.current=e,l())},[e,l]),[a,s]}Eb.globalOptions=void 0;const AS=L.createContext(null);function Df(){const n=L.useContext(AS);if(!n)throw new Error("useCarousel must be used within a <Carousel />");return n}const ES=L.forwardRef(({orientation:n="horizontal",opts:e,setApi:t,plugins:r,className:s,children:i,...o},a)=>{const[l,c]=Eb({...e,axis:n==="horizontal"?"x":"y"},r),[u,f]=L.useState(!1),[d,h]=L.useState(!1),p=L.useCallback(x=>{x&&(f(x.canScrollPrev()),h(x.canScrollNext()))},[]),m=L.useCallback(()=>{c==null||c.scrollPrev()},[c]),y=L.useCallback(()=>{c==null||c.scrollNext()},[c]),b=L.useCallback(x=>{x.key==="ArrowLeft"?(x.preventDefault(),m()):x.key==="ArrowRight"&&(x.preventDefault(),y())},[m,y]);return L.useEffect(()=>{!c||!t||t(c)},[c,t]),L.useEffect(()=>{if(c)return p(c),c.on("reInit",p),c.on("select",p),()=>{c==null||c.off("select",p)}},[c,p]),C.jsx(AS.Provider,{value:{carouselRef:l,api:c,opts:e,orientation:n||((e==null?void 0:e.axis)==="y"?"vertical":"horizontal"),scrollPrev:m,scrollNext:y,canScrollPrev:u,canScrollNext:d},children:C.jsx("div",{ref:a,onKeyDownCapture:b,className:pe("relative",s),role:"region","aria-roledescription":"carousel",...o,children:i})})});ES.displayName="Carousel";const kS=L.forwardRef(({className:n,...e},t)=>{const{carouselRef:r,orientation:s}=Df();return C.jsx("div",{ref:r,className:"overflow-hidden",children:C.jsx("div",{ref:t,className:pe("flex",s==="horizontal"?"-ml-4":"-mt-4 flex-col",n),...e})})});kS.displayName="CarouselContent";const kb=L.forwardRef(({className:n,...e},t)=>{const{orientation:r}=Df();return C.jsx("div",{ref:t,role:"group","aria-roledescription":"slide",className:pe("min-w-0 shrink-0 grow-0 basis-full",r==="horizontal"?"pl-4":"pt-4",n),...e})});kb.displayName="CarouselItem";const CS=L.forwardRef(({index:n,className:e,...t},r)=>{const{api:s}=Df(),[i,o]=L.useState(0),[,a]=L.useState([]),l=L.useCallback(d=>{s&&s.scrollTo(d)},[s]),c=L.useCallback(d=>{d&&a(d.scrollSnapList())},[]),u=L.useCallback(d=>{d&&o(d.selectedScrollSnap())},[]);L.useEffect(()=>{s&&(c(s),u(s),s.on("reInit",c),s.on("reInit",u),s.on("select",u))},[s,c,u]);const f=i===n;return C.jsx("button",{ref:r,className:pe("w-2 h-2 transition-colors duration-200 rounded-full",f?"bg-black":"bg-[#E8EBEC] hover:bg-black/50",e),onClick:()=>l(n),...t})});CS.displayName="CarouselIndicator";const JU=L.forwardRef(({className:n,...e},t)=>{const{scrollPrev:r,canScrollPrev:s}=Df();return C.jsx("button",{ref:t,className:pe("btn bg-white hover:bg-[#F2F4F5] transition text-black flex items-center border-2 rounded h-9 px-4 py-2 text-sm font-medium disabled:bg-[#E8EBEC] disabled:text-[#A1AAB1]",n),disabled:!s,onClick:r,...e,children:C.jsx("span",{children:"Back"})})});JU.displayName="CarouselPrevious";const qU=L.forwardRef(({className:n,...e},t)=>{const{scrollNext:r,canScrollNext:s}=Df();return C.jsx("button",{ref:t,className:pe("btn bg-black hover:bg-black text-white flex items-center border-2 rounded h-9 px-4 py-2 text-sm font-medium disabled:bg-[#E8EBEC] disabled:text-[#A1AAB1]",n),disabled:!s,onClick:r,...e,children:C.jsx("span",{children:"Next"})})});qU.displayName="CarouselNext";const dp=H.forwardRef(({className:n,label:e,type:t="text",isValid:r=!0,message:s,onChange:i,leftIcon:o,rightIcon:a,...l},c)=>{const u=H.useRef(null),f=Or(c,u),d=H.useCallback(()=>{var m;(m=u.current)==null||m.focus()},[]),h=H.useMemo(()=>{if(o==null)return;const m=H.Children.only(o);if(H.isValidElement(m))return H.cloneElement(m,{...m.props,onClick:y=>{var b,x;(x=(b=m.props).onClick)==null||x.call(b,y),d()},className:pe("absolute left-3 text-[#A1AAB1]",{"cursor-not-allowed":l.disabled})})},[d,o,l.disabled]),p=H.useMemo(()=>{if(a==null)return;const m=H.Children.only(a);if(H.isValidElement(m))return H.cloneElement(m,{...m.props,onClick:y=>{var b,x;(x=(b=m.props).onClick)==null||x.call(b,y),d()},className:pe("absolute right-3 cursor-pointer text-[#A1AAB1]",{"cursor-not-allowed":l.disabled},{"text-red-500":!r})})},[d,a,l.disabled,r]);return C.jsxs("div",{className:"flex flex-col",children:[e?C.jsx("label",{className:"mb-2 text-sm font-medium",children:e}):null,C.jsxs("div",{className:"relative flex items-center group",children:[h,C.jsx("input",{type:t,className:pe("flex h-9 w-full rounded border-[1px] border-[#E8EBEC] hover:border-black bg-transparent px-3 py-2 text-sm text-black transition-colors file:border-0 file:bg-transparent file:text-sm placeholder:text-[#A1AAB1] focus-visible:outline-none focus-visible:border-black",{"pr-3 pl-10":h},{"pr-10":p},{"border-red-500":!r},{"disabled:cursor-not-allowed disabled:bg-[#E8EBEC] disabled:border-[#A1AAB1] disabled:text-[#A1AAB1]":l.disabled},n),onChange:i,ref:f,...l}),p]}),s?C.jsx("p",{className:pe("text-sm mt-2 font-normal text-wrap text-justify",{"text-red-500":!r,"text-black":r}),children:s}):null]})});dp.displayName="TextField";const Pf=L.forwardRef(({active:n,buttonSize:e="medium",children:t,disabled:r,variant:s="primary",className:i,activeClassname:o,isLoading:a=!1,...l},c)=>{const u=pe("flex items-center justify-center border-2 gap-2 transition text-sm font-semibold rounded disabled:opacity-50 whitespace-nowrap",s==="primary"&&pe("text-white bg-black border-black",!r&&!n&&"hover:bg-neutral-800 active:bg-neutral-900",n&&pe("bg-neutral-900 dark:bg-neutral-300",o)),s==="secondary"&&pe("text-neutral-900 border-black",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200",n&&"bg-neutral-200"),s==="tertiary"&&pe("bg-neutral-50 text-neutral-900 border-transparent",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200",n&&pe("bg-neutral-200",o)),s==="ghost"&&pe("bg-transparent border-transparent text-neutral-900",!r&&!n&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10",n&&pe("bg-black/10",o)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",i);return C.jsx("button",{ref:c,disabled:r,className:u,...l,children:a?C.jsx(t4,{size:20,className:"animate-spin",fill:"transparent",stroke:"currentColor"}):t})});Pf.displayName="Button";const SS=[{title:"Trebuchet MS",value:"Trebuchet MS, sans-serif",command:n=>{n.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",value:"Verdana, Geneva, sans-serif",command:n=>{n.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",value:"Georgia, serif",command:n=>{n.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",value:"Arial, Helvetica, sans-serif",command:n=>{n.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",value:"Comic Sans MS, Comic Sans",command:n=>{n.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",value:"Impact, Charcoal, sans-serif",command:n=>{n.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",value:"Palatino Linotype, Book Antiqua, Palatino, serif",command:n=>{n.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",value:"Lucida Sans Unicode, Lucida Grande, sans-serif",command:n=>{n.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",value:"serif",command:n=>{n.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",value:"monospace",command:n=>{n.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",value:"cursive",command:n=>{n.chain().focus().setFontFamily("cursive").run()}}],Cb=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}],Sb=({editor:n})=>{const{ref:e,toolVisibilty:t,setToolVisibility:r}=f4(Re.NONE),s=[{icon:C.jsx(Fk,{size:20}),title:"Text Color",onClick:()=>r(Re.TEXT_COLOR),isActive:t===Re.TEXT_COLOR},{icon:C.jsx(Uk,{size:20}),title:"Highlight",onClick:()=>r(Re.HIGHLIGHT),isActive:t===Re.HIGHLIGHT},null,{icon:C.jsx(L0,{size:20}),title:"Bold",onClick:()=>n==null?void 0:n.chain().focus().toggleBold().run(),isActive:n==null?void 0:n.isActive("bold")},{icon:C.jsx(_0,{size:20}),title:"Italic",onClick:()=>n==null?void 0:n.chain().focus().toggleItalic().run(),isActive:n==null?void 0:n.isActive("italic")},{icon:C.jsx(H0,{size:20}),title:"Underlined",onClick:()=>n==null?void 0:n.chain().focus().toggleUnderline().run(),isActive:n==null?void 0:n.isActive("underline")},{icon:C.jsx(j0,{size:20}),title:"Strikethrough",onClick:()=>n==null?void 0:n.chain().focus().toggleStrike().run(),isActive:n==null?void 0:n.isActive("strike")},null,{icon:C.jsx(Gh,{size:20}),title:"List",onClick:()=>{n==null||n.chain().focus().toggleBulletList().run(),r(Re.NONE)},isActive:n==null?void 0:n.isActive("bulletList")},{icon:C.jsx(Wl,{size:20}),title:"Ordered List",onClick:()=>{n==null||n.chain().focus().toggleOrderedList().run(),r(Re.NONE)},isActive:n==null?void 0:n.isActive("orderedList")},{icon:C.jsx(F0,{size:20}),title:"To-do List",onClick:()=>{n==null||n.chain().focus().toggleTaskList().run(),r(Re.NONE)},isActive:n==null?void 0:n.isActive("taskList")},{icon:C.jsx(vf,{size:20}),title:"Alignment",onClick:()=>r(Re.ALIGNMENT),isActive:t===Re.ALIGNMENT},{icon:C.jsx(Kh,{size:20}),title:"Quote",onClick:()=>n==null?void 0:n.chain().focus().toggleBlockquote().run(),isActive:n==null?void 0:n.isActive("blockquote")},null,{icon:C.jsx(Hk,{size:20}),title:"Upload Image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.state.selection).run();const o=document.createElement("input");o.type="file",o.accept="image/*",o.onchange=async()=>{var a;if((a=o.files)!=null&&a.length){const l=o.files[0],c=n.view.state.selection.from;z0(l,n.view,c)}},o.click()},isActive:!1},{icon:C.jsx(B0,{size:20}),title:"Link",onClick:()=>r(Re.LINK),isActive:n==null?void 0:n.isActive("link")},{icon:C.jsx(Af,{size:20}),title:"Code",onClick:()=>n==null?void 0:n.chain().focus().toggleCodeBlock().run(),isActive:n==null?void 0:n.isActive("codeBlock")}],i=[{icon:C.jsx(U0,{size:24}),title:"Text formating",onClick:()=>r(Re.TEXT_FORMATING),isActive:t===Re.TEXT_FORMATING},{icon:C.jsx(Fk,{size:24}),title:"Text color",onClick:()=>r(Re.TEXT_COLOR_PICKER),isActive:t===Re.TEXT_COLOR_PICKER},{icon:C.jsx(Vk,{size:24}),title:"Add table",onClick:()=>n==null?void 0:n.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),isActive:t===Re.TEXT_COLOR},{icon:C.jsx(F0,{size:24}),title:"To-do list",onClick:()=>{n==null||n.chain().focus().toggleTaskList().run(),r(Re.NONE)},isActive:t===Re.LIST},{icon:C.jsx(Hk,{size:24}),title:"Add image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.state.selection).run();const o=document.createElement("input");o.type="file",o.accept="image/*",o.onchange=async()=>{var a;if((a=o.files)!=null&&a.length){const l=o.files[0],c=n.view.state.selection.from;z0(l,n.view,c)}},o.click()},isActive:!1}];return{toolbar:s,bottomToolbar:i,toolRef:e,toolVisibilty:t,setToolVisibility:r}},TS=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return C.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[C.jsx(I0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetHighlight().run(),e(Re.NONE)}}),r.map(s=>C.jsx("div",{onClick:()=>{n.chain().focus().toggleHighlight({color:s.color}).run(),e(Re.NONE)},className:pe("w-6 drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",s.code),children:C.jsx(xf,{size:14,className:pe(n.isActive("highlight",{color:s.color})?"visible":"invisible")})},s.color))]})},QU=({elementRef:n,editor:e,setToolVisibility:t})=>C.jsx("div",{ref:n,className:pe("z-50 h-auto absolute top-[50px] left-0 max-h-[330px] w-48 overflow-y-auto scroll-smooth bg-white px-1 py-2 shadow-lg transition-all animate-in fade-in slide-in-from-top-1"),children:SS.map(r=>C.jsx("button",{onClick:()=>{r.command(e),t(Re.NONE)},style:{fontFamily:r.title},className:pe("flex w-full items-center space-x-2 rounded px-2 py-1 text-left text-sm text-black transition",e.isActive("textStyle",{fontFamily:r.value})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:C.jsx("p",{className:"font-medium",children:r.title})},r.title))}),NS=({elementRef:n,editor:e,setToolVisibility:t})=>C.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-14 left-[60%] translate-x-1/2 flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[C.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),t(Re.NONE)},className:pe("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"left"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:C.jsx(vf,{})}),C.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),t(Re.NONE)},className:pe("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"center"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:C.jsx(D0,{})}),C.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),t(Re.NONE)},className:pe("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"right"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:C.jsx(P0,{})})]}),YU=({elementRef:n,editor:e,setToolVisibility:t})=>C.jsxs("div",{ref:n,className:pe("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all"),children:[C.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:C.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),t(Re.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:C.jsx(Gh,{size:20})})}),C.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:C.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),t(Re.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:C.jsx(Wl,{size:20})})}),C.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:C.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),t(Re.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:C.jsx(F0,{size:20})})})]}),OS=({elementRef:n,editor:e,setToolVisibility:t,bubbleMenu:r,setIsLinkPopupOpen:s})=>{const[i,o]=L.useState(e.getAttributes("link").href),a=()=>{if(i===null)return;if(i===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let l=i;!i.startsWith("http://")&&!i.startsWith("https://")&&(l="https://"+i);try{l.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:l}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:l}).run(),t(Re.NONE),r&&s&&s(!1)};return C.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-14 translate-x-1/2 items-center flex max-h-[330px] overflow-y-auto scroll-smooth rounded-lg bg-white p-2 shadow-lg transition-all",children:[C.jsx(dp,{onChange:l=>o(l.target.value),className:"w-full",placeholder:"Add link here",value:i}),C.jsx("div",{className:"h-full flex items-center",children:C.jsx(Pf,{variant:"secondary",onClick:()=>a(),className:"min-w-fit h-[36px]",children:"Apply"})})]})},XU=({editor:n,setVisibility:e,elementRef:t})=>C.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[C.jsx(I0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run(),e(Re.NONE)}}),Cb.map(r=>C.jsx("div",{onClick:()=>{n.chain().focus().setColor(r.color).run(),e(Re.NONE)},className:pe("w-6 drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",r.code),children:C.jsx(xf,{size:14,className:pe(n.isActive("textStyle",{color:r.color})?"visible":"invisible")})},r.color))]}),ZU=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{title:"Text",description:"Normal",icon:C.jsx(U0,{size:20}),command:s=>s.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:C.jsx(Vh,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:1}).run()},isActive:()=>n.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:C.jsx($h,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:2}).run()},isActive:()=>n.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:C.jsx(Wh,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:3}).run()},isActive:()=>n.isActive("heading",{level:3})}];return C.jsx("div",{ref:t,className:pe("absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded bg-white p-1 shadow-lg animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(s=>C.jsxs("button",{onClick:()=>{s.command(n),e(Re.NONE)},className:pe("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-black transition",{"bg-yellow-300 hover:brightness-90":s.isActive(),"hover:bg-[#f2f2f2]":!s.isActive()}),children:[C.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded bg-white",children:s.icon}),C.jsxs("div",{children:[C.jsx("p",{className:"font-medium",children:s.title}),C.jsxs("p",{className:"text-xs text-stone-500",children:[" ",s.description," "]})]})]},s.title))})},e8=({editor:n,setToolVisibility:e})=>{const t=[{title:"Text",description:"Normal",icon:C.jsx(U0,{size:20}),command:r=>r.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:C.jsx(Vh,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:1}).run()},isActive:()=>n.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:C.jsx($h,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:2}).run()},isActive:()=>n.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:C.jsx(Wh,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:3}).run()},isActive:()=>n.isActive("heading",{level:3})}];return C.jsx(cS,{title:"Text formating",content:C.jsxs("div",{className:"px-4 flex flex-col gap-2 w-full",children:[C.jsx("div",{className:"flex justify-start sm:justify-center items-center gap-1",children:t.map(r=>C.jsx("button",{onClick:()=>r.command(n),className:pe("flex w-fit items-center font-medium space-x-2 rounded p-2 text-center text-sm text-black transition",{"bg-yellow-300 hover:brightness-90":r.isActive(),"hover:bg-[#f2f2f2]":!r.isActive()}),children:r.title},r.title))}),C.jsxs("div",{className:"flex justify-between sm:justify-center items-center gap-1",children:[C.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-2 justify-evenly w-full sm:w-fit p-2",children:[C.jsx("button",{onClick:()=>{n==null||n.chain().focus().setTextAlign("left").run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive({textAlign:"left"}),"hover:bg-[#f2f2f2]":!n.isActive({textAlign:"left"})}),children:C.jsx(vf,{size:20})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().setTextAlign("center").run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive({textAlign:"center"}),"hover:bg-[#f2f2f2]":!n.isActive({textAlign:"center"})}),children:C.jsx(D0,{size:20})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().setTextAlign("right").run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive({textAlign:"right"}),"hover:bg-[#f2f2f2]":!n.isActive({textAlign:"right"})}),children:C.jsx(P0,{size:20})})]}),C.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-2 justify-evenly w-full sm:w-fit p-2",children:[C.jsx(fU,{asChild:!0,children:C.jsx("button",{onClick:()=>e(Re.LINK_POPUP),className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("link"),"hover:bg-[#f2f2f2]":!n.isActive("link")}),children:C.jsx(B0,{size:20})})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().toggleCodeBlock().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("codeBlock"),"hover:bg-[#f2f2f2]":!n.isActive("codeBlock")}),children:C.jsx(Af,{size:20})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().toggleBlockquote().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("blockquote"),"hover:bg-[#f2f2f2]":!n.isActive("blockquote")}),children:C.jsx(Kh,{size:20})})]})]}),C.jsxs("div",{className:"flex justify-between sm:justify-center items-center gap-1",children:[C.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-2 justify-evenly w-full sm:w-fit p-2",children:[C.jsx("button",{onClick:()=>{n.chain().focus().toggleBold().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("bold"),"hover:bg-[#f2f2f2]":!n.isActive("bold")}),children:C.jsx(L0,{size:20})}),C.jsx("button",{onClick:()=>{n.chain().focus().toggleItalic().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("italic"),"hover:bg-[#f2f2f2]":!n.isActive("italic")}),children:C.jsx(_0,{size:20})}),C.jsx("button",{onClick:()=>{n.chain().focus().toggleUnderline().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("underline"),"hover:bg-[#f2f2f2]":!n.isActive("bold")}),children:C.jsx(H0,{size:20})}),C.jsx("button",{onClick:()=>{n.chain().focus().toggleStrike().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("strike"),"hover:bg-[#f2f2f2]":!n.isActive("bold")}),children:C.jsx(j0,{size:20})})]}),C.jsxs("div",{className:"bg-[#f8f9fa] rounded flex flex-[0.5] sm:flex-none gap-2 justify-evenly w-full sm:w-fit p-2",children:[C.jsx("button",{onClick:()=>{n==null||n.chain().focus().toggleBulletList().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("bulletList"),"hover:bg-[#f2f2f2]":!n.isActive("bulletList")}),children:C.jsx(Gh,{size:20})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().toggleOrderedList().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("orderedList"),"hover:bg-[#f2f2f2]":!n.isActive("orderedList")}),children:C.jsx(Wl,{size:20})})]})]})]})})},t8=({editor:n})=>C.jsx(cS,{title:"Text color",content:C.jsxs(ES,{opts:{align:"start",dragFree:!0,slidesToScroll:"auto"},className:"w-full max-w-md px-4 mx-auto",children:[C.jsxs(kS,{children:[C.jsx(kb,{style:{flexBasis:"calc(100% / 12)"},children:C.jsx(I0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run()}})}),Cb.map((e,t)=>C.jsx(kb,{style:{flexBasis:"calc(100% / 12)"},children:C.jsx("button",{onClick:()=>{n.chain().focus().setColor(e.color).run()},className:pe("w-6 h-6 border-[0.25px] border-black/[0.025] rounded-full flex justify-center items-center cursor-pointer transition",e.code),children:C.jsx(xf,{size:14,className:pe(n.isActive("textStyle",{color:e.color})?"visible":"invisible")})},e.color)},t))]}),C.jsx("div",{className:"flex justify-center gap-2 mt-4 w-full max-w-sm",children:Array.from({length:Cb.length/8}).map((e,t)=>C.jsx(CS,{index:t},t))})]})}),n8=n=>{const e=[{name:"Bold",isActive:()=>n.editor.isActive("bold"),command:()=>n.editor.chain().focus().toggleBold().run(),icon:C.jsx(L0,{size:20})},{name:"Italic",isActive:()=>n.editor.isActive("italic"),command:()=>n.editor.chain().focus().toggleItalic().run(),icon:C.jsx(_0,{size:20})},{name:"Underline",isActive:()=>n.editor.isActive("underline"),command:()=>n.editor.chain().focus().toggleUnderline().run(),icon:C.jsx(H0,{size:20})},{name:"Strikethrough",isActive:()=>n.editor.isActive("strike"),command:()=>n.editor.chain().focus().toggleStrike().run(),icon:C.jsx(j0,{size:20})},{name:"Alignment",isActive:()=>f===Re.ALIGNMENT,command:()=>u(Re.ALIGNMENT),icon:C.jsx(vf,{size:20})},{name:"Code",isActive:()=>n.editor.isActive("codeBlock"),command:()=>n.editor.chain().focus().toggleCodeBlock().run(),icon:C.jsx(Af,{size:20})},{name:"Link",isActive:()=>n.editor.isActive("link"),command:()=>l(!a),icon:C.jsx(B0,{size:20})}],t={...n,shouldShow:({state:d,editor:h})=>{const{selection:p}=d,{empty:m}=p;return!(h.isActive("image")||m||jE(p))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{s(!1),o(!1),l(!1)}}},[r,s]=L.useState(!1),[i,o]=L.useState(!1),[a,l]=L.useState(!1),{toolRef:c,setToolVisibility:u,toolVisibilty:f}=Sb({editor:n.editor});return C.jsxs(Mk,{...t,className:"hidden lg:flex gap-2 overflow-hidden rounded-[12px] h-[52px] min-w-[550px] w-full py-2 px-4 bg-white items-center shadow-lg",children:[C.jsx(c4,{editor:n.editor,isOpen:r,setIsOpen:()=>{s(!r),o(!1)}}),e.map((d,h)=>C.jsxs("div",{className:"flex items-center",children:[C.jsx("button",{onClick:d.command,className:pe("min-w-fit w-8 h-8 px-2 rounded",{"bg-yellow-300":d.isActive()}),children:d.icon}),(h===4||h===6)&&C.jsx("div",{className:"w-1.5 h-4 bg-gray-300 mx-2"})]},h)),C.jsx(u4,{editor:n.editor,isOpen:i,setIsOpen:()=>{o(!i),s(!1)}}),C.jsx("button",{onClick:()=>u(Re.HIGHLIGHT),className:pe("min-w-fit w-8 h-8 px-2",{"bg-yellow-300":f===Re.HIGHLIGHT}),children:C.jsx(Uk,{size:20})}),f===Re.ALIGNMENT&&C.jsx(NS,{setToolVisibility:u,editor:n.editor,elementRef:c}),a&&C.jsx(OS,{setToolVisibility:u,editor:n.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:l}),f===Re.HIGHLIGHT&&C.jsx(TS,{setVisibility:u,editor:n.editor,elementRef:c})]})};function r8(){const n=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?e[t]="-":e[t]=n[Math.ceil(Math.random()*n.length-1)];return e.join("")}var s8=r8;const i8=iy(s8),RS=vt.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:n=>n.getAttribute("data-position"),renderHTML:n=>({"data-position":n.position})}}},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),o8=(n,e)=>Array.from({length:n},(t,r)=>e(r)),hp=({type:n,content:e})=>e?{type:n,content:e}:{type:n},a8=({content:n})=>hp({type:"paragraph",content:n}),MS=({content:n})=>hp({type:"dBlock",content:n}),DS=({content:n})=>hp({type:"column",content:n}),PS=({content:n})=>hp({type:"columns",content:n}),IS=n=>{const e=[MS({content:[a8({})]})];return o8(n,()=>DS({content:e}))},LS=(n,e)=>{for(let t=n.depth;t>0;t--){const r=n.node(t),s=t>0?n.before(t):0,i=n.start(t);if(e({node:r,pos:s,start:i}))return{start:i,depth:t,node:r,pos:s}}throw Error("no ancestor found")};class pp extends Ie{constructor(t){const{$from:r,$to:s}=t;super(r,s);$(this,"_$from");$(this,"_$to");this._$from=r,this._$to=s}get $from(){return this._$from}get $to(){return this._$to}map(){return this}content(){return this.$from.doc.slice(this.from,this.to,!0)}eq(t){return t instanceof pp&&t.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(t){var l;const r=({pos:c,node:u})=>u.type.name===RS.name?!0:t.resolve(c).depth<=0,{pos:s}=LS(this.$from,r);this._$from=t.resolve(s);const{pos:i,node:o}=LS(this.$to,r);this._$to=t.resolve(i+o.nodeSize),((l=this.getFirstNode())==null?void 0:l.type.name)===mp.name&&(this._$from=t.resolve(this.$from.pos+2),this._$to=t.resolve(this.$to.pos+2));const a=this;a.$anchor=this._$from,a.$head=this._$to,a.ranges=[new Ay(this._$from,this._$to)]}static create(t,r,s){const i=t.resolve(r),o=t.resolve(s),a=new Me(i,o);return new pp(a)}getFirstNode(){return this.content().content.firstChild}}var ya=(n=>(n.AlignLeft="align-left",n.AlignRight="align-right",n.AlignCenter="align-center",n))(ya||{});const mp=vt.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:n,dispatch:e})=>{try{if(!e)return;const t=n.selection.$from,s=a0(t,({node:l})=>!this.options.nestedColumns&&l.type==this.type?!0:l.type==this.type);if(s===void 0)return;let i=[];s.node.descendants((l,c,u)=>{(u==null?void 0:u.type.name)===mp.name&&i.push(l)}),i=i.reverse().filter(l=>l.content.size>0);const o=n.doc.resolve(s.pos),a=new Ne(o);return n=n.setSelection(a),i.forEach(l=>n=n.insert(s.pos,l)),n=n.deleteSelection(),e(n)}catch(t){console.error(t)}},setColumns:(n,e=!1)=>({tr:t,dispatch:r})=>{try{const{doc:s,selection:i}=t;if(!r){console.log("no dispatch");return}const o=new pp(i);o.expandSelection(s);const{openStart:a,openEnd:l}=o.content();if(a!==l){console.warn("failed depth check");return}let c;if(e){const h=o.content().toJSON(),p=DS(h),m=IS(n-1);c=PS({content:[p,...m]})}else{const h=IS(n);c=PS({content:h})}const u=s.type.schema.nodeFromJSON(MS({content:[c]}));if(u===null)return;const f=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===mp.name))(f)){console.warn("content not allowed");return}return t=t.setSelection(o),t=t.replaceSelectionWith(u,!1),r(t)}catch(s){console.error(s)}},setLayout:n=>({commands:e})=>e.updateAttributes("columns",{layout:n})}},renderHTML({HTMLAttributes:n}){return["div",{"data-type":"columns",class:`layout-${n.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),l8=(n,e)=>{const{view:t,state:{selection:{from:r}}}=n,s=document.querySelectorAll(".has-focus"),i=s.length,a=s[i-1];if(a&&a.getAttribute("data-type")&&a.getAttribute("data-type")===e||a&&a.classList&&a.classList.contains(e))return a;const l=t.domAtPos(r).node;let c=l;for(c.tagName||(c=l.parentElement);c&&!(c.getAttribute("data-type")&&c.getAttribute("data-type")===e)&&!c.classList.contains(e);)c=c.parentElement;return c},Tb=L.forwardRef(({children:n,className:e,withShadow:t=!0,withBorder:r=!0,...s},i)=>{const o=pe(e,"bg-white rounded-md",t?"shadow-md":"",r?"border border-neutral-200":"");return C.jsx("div",{className:o,...s,ref:i,children:n})});Tb.displayName="Surface";const _S=({content:n,children:e})=>{const[t,r]=L.useState(!1);return C.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,t&&C.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:n})]})},BS=L.forwardRef(({shouldShowContent:n=!0,children:e,isVertical:t=!1,className:r,...s},i)=>{const o=pe("text-black inline-flex h-full leading-none gap-0.5",t?"flex-col p-2":"flex-row p-1 items-center",r);return n?n&&C.jsx(Tb,{className:o,...s,ref:i,children:e}):null});BS.displayName="Toolbar";const FS=L.forwardRef(({horizontal:n,className:e,...t},r)=>{const s=pe("bg-neutral-200",n?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return C.jsx("div",{className:s,ref:r,...t})});FS.displayName="Toolbar.Divider";const jS=L.forwardRef(({children:n,buttonSize:e="icon",variant:t="ghost",className:r,tooltip:s,activeClassname:i,...o},a)=>{const l=pe("gap-1 min-w-[2rem] px-2 w-auto",r),c=C.jsx(Pf,{activeClassname:i,className:l,variant:t,buttonSize:e,ref:a,...o,children:n});return s?C.jsx(_S,{content:s,children:c}):c});jS.displayName="ToolbarButton";const If={Wrapper:BS,Divider:FS,Button:jS},c8=({editor:n,appendTo:e})=>{const t=L.useCallback(()=>{const a=l8(n,"columns");return(a==null?void 0:a.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[n]),r=L.useCallback(()=>n.isActive("columns"),[n]),s=L.useCallback(()=>{n.chain().focus().setLayout(ya.AlignLeft).run()},[n]),i=L.useCallback(()=>{n.chain().focus().setLayout(ya.AlignRight).run()},[n]),o=L.useCallback(()=>{n.chain().focus().setLayout(ya.AlignCenter).run()},[n]);return C.jsx(Mk,{editor:n,pluginKey:`columnsMenu-${i8()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[P3],sticky:"popper"},children:C.jsxs(If.Wrapper,{children:[C.jsx(If.Button,{tooltip:"Align left",active:n.isActive("columns",{layout:ya.AlignLeft}),onClick:s,children:C.jsx(r4,{size:20})}),C.jsx(If.Button,{tooltip:"Align center",active:n.isActive("columns",{layout:ya.AlignCenter}),onClick:o,children:C.jsx(jk,{size:20})}),C.jsx(If.Button,{tooltip:"Align right",active:n.isActive("columns",{layout:ya.AlignRight}),onClick:i,children:C.jsx(s4,{size:20})})]})})},US=L.createContext(null),gp=()=>L.useContext(US),u8=({children:n,isPreviewMode:e})=>C.jsx(US.Provider,{value:e,children:n}),HS=({height:n,width:e})=>C.jsx("span",{className:"flex items-center justify-center ",children:C.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${n?`h-${n}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),f8=({editor:n})=>{var i;const{toolRef:e,toolVisibilty:t,setToolVisibility:r,toolbar:s}=Sb({editor:n});return C.jsxs("div",{className:"w-fit bg-transparent px-4 items-center h-16 flex gap-1 justify-center relative",children:[C.jsxs("button",{className:"bg-transparent flex items-center gap-2 min-w-[55px]",onClick:()=>r(Re.FONT_FAMILY),children:[C.jsx("span",{className:"text-sm",children:((i=SS.find(o=>n==null?void 0:n.isActive("textStyle",{fontFamily:o.value})))==null?void 0:i.title)||"Font"}),C.jsx(zh,{size:16})]}),C.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"}),C.jsxs("button",{className:"bg-transparent gap-2 flex items-center min-w-[55px]",onClick:()=>r(Re.HEADING),children:[C.jsx("span",{className:"text-sm",children:n!=null&&n.isActive("heading",{level:1})?"Heading 1":n!=null&&n.isActive("heading",{level:2})?"Heading 2":n!=null&&n.isActive("heading",{level:3})?"Heading 3":"Text"}),C.jsx(zh,{size:16})]}),C.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"}),s.map((o,a)=>o?C.jsx("div",{className:"tooltip tooltip-bottom","data-tip":o.title,children:C.jsx("span",{onClick:()=>o.onClick(),className:pe("rounded w-8 h-8 p-1 flex cursor-pointer justify-center items-center transition",o.isActive?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:typeof o.icon=="string"?C.jsx("img",{src:o.icon,className:"w-4"}):o.icon})},o.title):C.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"},a)),t===Re.FONT_FAMILY&&C.jsx(QU,{setToolVisibility:r,editor:n,elementRef:e}),t===Re.HEADING&&C.jsx(ZU,{setVisibility:r,editor:n,elementRef:e}),t===Re.TEXT_COLOR&&C.jsx(XU,{setVisibility:r,editor:n,elementRef:e}),t===Re.HIGHLIGHT&&C.jsx(TS,{setVisibility:r,editor:n,elementRef:e}),t===Re.ALIGNMENT&&C.jsx(NS,{setToolVisibility:r,editor:n,elementRef:e}),t===Re.LIST&&C.jsx(YU,{setToolVisibility:r,editor:n,elementRef:e}),t===Re.LINK&&C.jsx(OS,{setToolVisibility:r,editor:n,elementRef:e})]})},Mn=()=>new Map,Nb=n=>{const e=Mn();return n.forEach((t,r)=>{e.set(r,t)}),e},Jn=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},d8=(n,e)=>{const t=[];for(const[r,s]of n)t.push(e(s,r));return t},h8=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},oi=()=>new Set,Ob=n=>n[n.length-1],p8=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},ai=Array.from,m8=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},Rb=Array.isArray;class Mb{constructor(){this._observers=Mn()}on(e,t){return Jn(this._observers,e,oi).add(t),t}once(e,t){const r=(...s)=>{this.off(e,r),t(...s)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return ai((this._observers.get(e)||Mn()).values()).forEach(r=>r(...t))}destroy(){this._observers=Mn()}}class zS{constructor(){this._observers=Mn()}on(e,t){Jn(this._observers,e,oi).add(t)}once(e,t){const r=(...s)=>{this.off(e,r),t(...s)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return ai((this._observers.get(e)||Mn()).values()).forEach(r=>r(...t))}destroy(){this._observers=Mn()}}const Yr=Math.floor,yp=Math.abs,g8=Math.log10,io=(n,e)=>n<e?n:e,li=(n,e)=>n>e?n:e,VS=n=>n!==0?n<0:1/n<0,Ts=Date.now,y8=1200,b8=2500,bp=3e4,Db=n=>{if(n.shouldConnect&&n.ws===null){const e=new WebSocket(n.url),t=n.binaryType;let r=null;t&&(e.binaryType=t),n.ws=e,n.connecting=!0,n.connected=!1,e.onmessage=o=>{n.lastMessageReceived=Ts();const a=o.data,l=typeof a=="string"?JSON.parse(a):a;l&&l.type==="pong"&&(clearTimeout(r),r=setTimeout(i,bp/2)),n.emit("message",[l,n])};const s=o=>{n.ws!==null&&(n.ws=null,n.connecting=!1,n.connected?(n.connected=!1,n.emit("disconnect",[{type:"disconnect",error:o},n])):n.unsuccessfulReconnects++,setTimeout(Db,io(g8(n.unsuccessfulReconnects+1)*y8,b8),n)),clearTimeout(r)},i=()=>{n.ws===e&&n.send({type:"ping"})};e.onclose=()=>s(null),e.onerror=o=>s(o),e.onopen=()=>{n.lastMessageReceived=Ts(),n.connecting=!1,n.connected=!0,n.unsuccessfulReconnects=0,n.emit("connect",[{type:"connect"},n]),r=setTimeout(i,bp/2)}}};class w8 extends zS{constructor(e,{binaryType:t}={}){super(),this.url=e,this.ws=null,this.binaryType=t||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&bp<Ts()-this.lastMessageReceived&&this.ws.close()},bp/2),Db(this)}send(e){this.ws&&this.ws.send(JSON.stringify(e))}destroy(){clearInterval(this._checkInterval),this.disconnect(),super.destroy()}disconnect(){this.shouldConnect=!1,this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.connected&&this.ws===null&&Db(this)}}const Ns=n=>new Error(n),Xr=()=>{throw Ns("Method unimplemented")},dr=()=>{throw Ns("Unexpected case")},$S=1,WS=2,Pb=4,Ib=8,Lf=32,ci=64,hr=128,wp=31,Lb=63,ba=127,v8=2147483647,x8=crypto.getRandomValues.bind(crypto),GS=Math.random,KS=()=>x8(new Uint32Array(1))[0],A8=n=>n[Yr(GS()*n.length)],E8="10000000-1000-4000-8000"+-1e11,JS=()=>E8.replace(/[018]/g,n=>(n^KS()&15>>n/4).toString(16)),qS=Number.MAX_SAFE_INTEGER,k8=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&Yr(n)===n),C8=String.fromCharCode,S8=n=>n.toLowerCase(),T8=/^\s*/g,N8=n=>n.replace(T8,""),O8=/([A-Z])/g,QS=(n,e)=>N8(n.replace(O8,t=>`${e}${S8(t)}`)),R8=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let s=0;s<t;s++)r[s]=e.codePointAt(s);return r},_f=typeof TextEncoder<"u"?new TextEncoder:null,_b=_f?n=>_f.encode(n):R8;let Bf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Bf&&Bf.decode(new Uint8Array).length===1&&(Bf=null);class Ff{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const nn=()=>new Ff,M8=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Rt=n=>{const e=new Uint8Array(M8(n));let t=0;for(let r=0;r<n.bufs.length;r++){const s=n.bufs[r];e.set(s,t),t+=s.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},D8=(n,e)=>{const t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(li(t,e)*2),n.cpos=0)},rn=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},jf=rn,De=(n,e)=>{for(;e>ba;)rn(n,hr|ba&e),e=Yr(e/128);rn(n,ba&e)},Bb=(n,e)=>{const t=VS(e);for(t&&(e=-e),rn(n,(e>Lb?hr:0)|(t?ci:0)|Lb&e),e=Yr(e/64);e>0;)rn(n,(e>ba?hr:0)|ba&e),e=Yr(e/128)},Fb=new Uint8Array(3e4),P8=Fb.length/3,I8=(n,e)=>{if(e.length<P8){const t=_f.encodeInto(e,Fb).written||0;De(n,t);for(let r=0;r<t;r++)rn(n,Fb[r])}else Lt(n,_b(e))},L8=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;De(n,r);for(let s=0;s<r;s++)rn(n,t.codePointAt(s))},Os=_f&&_f.encodeInto?I8:L8,vp=(n,e)=>{const t=n.cbuf.length,r=n.cpos,s=io(t-r,e.length),i=e.length-s;n.cbuf.set(e.subarray(0,s),r),n.cpos+=s,i>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(li(t*2,i)),n.cbuf.set(e.subarray(s)),n.cpos=i)},Lt=(n,e)=>{De(n,e.byteLength),vp(n,e)},jb=(n,e)=>{D8(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},_8=(n,e)=>jb(n,4).setFloat32(0,e,!1),B8=(n,e)=>jb(n,8).setFloat64(0,e,!1),F8=(n,e)=>jb(n,8).setBigInt64(0,e,!1),YS=new DataView(new ArrayBuffer(4)),j8=n=>(YS.setFloat32(0,n),YS.getFloat32(0)===n),Ql=(n,e)=>{switch(typeof e){case"string":rn(n,119),Os(n,e);break;case"number":k8(e)&&yp(e)<=v8?(rn(n,125),Bb(n,e)):j8(e)?(rn(n,124),_8(n,e)):(rn(n,123),B8(n,e));break;case"bigint":rn(n,122),F8(n,e);break;case"object":if(e===null)rn(n,126);else if(Rb(e)){rn(n,117),De(n,e.length);for(let t=0;t<e.length;t++)Ql(n,e[t])}else if(e instanceof Uint8Array)rn(n,116),Lt(n,e);else{rn(n,118);const t=Object.keys(e);De(n,t.length);for(let r=0;r<t.length;r++){const s=t[r];Os(n,s),Ql(n,e[s])}}break;case"boolean":rn(n,e?120:121);break;default:rn(n,127)}};class XS extends Ff{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&De(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const ZS=n=>{n.count>0&&(Bb(n.encoder,n.count===1?n.s:-n.s),n.count>1&&De(n.encoder,n.count-2))};class xp{constructor(){this.encoder=new Ff,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ZS(this),this.count=1,this.s=e)}toUint8Array(){return ZS(this),Rt(this.encoder)}}const eT=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);Bb(n.encoder,e),n.count>1&&De(n.encoder,n.count-2)}};class Ub{constructor(){this.encoder=new Ff,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(eT(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return eT(this),Rt(this.encoder)}}class U8{constructor(){this.sarr=[],this.s="",this.lensE=new xp}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Ff;return this.sarr.push(this.s),this.s="",Os(e,this.sarr.join("")),vp(e,this.lensE.toUint8Array()),Rt(e)}}const tT=Ns("Unexpected end of array"),nT=Ns("Integer out of Range");class Ap{constructor(e){this.arr=e,this.pos=0}}const Rs=n=>new Ap(n),H8=n=>n.pos!==n.arr.length,z8=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},sn=n=>z8(n,We(n)),wa=n=>n.arr[n.pos++],We=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const s=n.arr[n.pos++];if(e=e+(s&ba)*t,t*=128,s<hr)return e;if(e>qS)throw nT}throw tT},Hb=n=>{let e=n.arr[n.pos++],t=e&Lb,r=64;const s=(e&ci)>0?-1:1;if(!(e&hr))return s*t;const i=n.arr.length;for(;n.pos<i;){if(e=n.arr[n.pos++],t=t+(e&ba)*r,r*=128,e<hr)return s*t;if(t>qS)throw nT}throw tT},ui=Bf?n=>Bf.decode(sn(n)):n=>{let e=We(n);if(e===0)return"";{let t=String.fromCodePoint(wa(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(wa(n));else for(;e>0;){const r=e<1e4?e:1e4,s=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(t))}},zb=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},V8=[n=>{},n=>null,Hb,n=>zb(n,4).getFloat32(0,!1),n=>zb(n,8).getFloat64(0,!1),n=>zb(n,8).getBigInt64(0,!1),n=>!1,n=>!0,ui,n=>{const e=We(n),t={};for(let r=0;r<e;r++){const s=ui(n);t[s]=Yl(n)}return t},n=>{const e=We(n),t=[];for(let r=0;r<e;r++)t.push(Yl(n));return t},sn],Yl=n=>V8[127-wa(n)](n);class rT extends Ap{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),H8(this)?this.count=We(this)+1:this.count=-1),this.count--,this.s}}class Ep extends Ap{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Hb(this);const e=VS(this.s);this.count=1,e&&(this.s=-this.s,this.count=We(this)+2)}return this.count--,this.s}}class Vb extends Ap{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Hb(this),t=e&1;this.diff=Yr(e/2),this.count=1,t&&(this.count=We(this)+2)}return this.s+=this.diff,this.count--,this.s}}class $8{constructor(e){this.decoder=new Ep(e),this.str=ui(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const sT=n=>n===void 0?null:n;class W8{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let iT=new W8,$b=!0;try{typeof localStorage<"u"&&localStorage&&(iT=localStorage,$b=!1)}catch{}const oT=iT,G8=n=>$b||addEventListener("storage",n),K8=n=>$b||removeEventListener("storage",n),J8=Object.assign,Wb=Object.keys,q8=(n,e)=>{for(const t in n)e(n[t],t)},aT=n=>Wb(n).length,lT=n=>Wb(n).length,Q8=n=>{for(const e in n)return!1;return!0},Y8=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},cT=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),X8=(n,e)=>n===e||lT(n)===lT(e)&&Y8(n,(t,r)=>(t!==void 0||cT(e,r))&&e[r]===t),Gb=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&Gb(n,e,t+1)}},Z8=()=>{},eH=n=>n,tH=(n,e)=>n===e,Uf=(n,e)=>{if(n==null||e==null)return tH(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!Uf(n.get(t),e.get(t)))return!1;break}case Object:if(aT(n)!==aT(e))return!1;for(const t in n)if(!cT(n,t)||!Uf(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Uf(n[t],e[t]))return!1;break;default:return!1}return!0},nH=(n,e)=>e.includes(n),Xl=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Kb=typeof window<"u"&&typeof document<"u"&&!Xl;let Ms;const rH=()=>{if(Ms===void 0)if(Xl){Ms=Mn();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&Ms.set(e,""),e=r):e!==null&&(Ms.set(e,r),e=null)}e!==null&&Ms.set(e,"")}else typeof location=="object"?(Ms=Mn(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");Ms.set(`--${QS(e,"-")}`,t),Ms.set(`-${QS(e,"-")}`,t)}})):Ms=Mn();return Ms},Jb=n=>rH().has(n),kp=n=>sT(Xl?process.env[n.toUpperCase().replaceAll("-","_")]:oT.getItem(n));(n=>Jb("--"+n)||kp(n)!==null)("production");const uT=Xl&&nH(process.env.FORCE_COLOR,["true","1","2"]),sH=!Jb("--no-colors")&&(!Xl||process.stdout.isTTY||uT)&&(!Xl||Jb("--color")||uT||kp("COLORTERM")!==null||(kp("TERM")||"").includes("color"));class iH{constructor(e,t){this.left=e,this.right=t}}const fi=(n,e)=>new iH(n,e),oH=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const aH=n=>d8(n,(e,t)=>`${t}:${e};`).join(""),lH=JSON.stringify,cH=(n=>class{constructor(t){this._=t}destroy(){n(this._)}})(clearTimeout),qb=(n,e)=>new cH(setTimeout(e,n)),di=Symbol,Rr=di(),va=di(),fT=di(),Qb=di(),dT=di(),hT=di(),pT=di(),Cp=di(),Sp=di(),uH=n=>{var r;n.length===1&&((r=n[0])==null?void 0:r.constructor)===Function&&(n=n[0]());const e=[];let t=0;for(;t<n.length;t++){const s=n[t];s===void 0||s.constructor===String||s.constructor===Number||s.constructor===Object&&e.push(JSON.stringify(s))}return e},mT=[dT,pT,Cp,fT];let Yb=0,gT=Ts();const fH=(n,e)=>{const t=mT[Yb],r=kp("log"),s=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return Yb=(Yb+1)%mT.length,e+=": ",s?(...i)=>{var l;i.length===1&&((l=i[0])==null?void 0:l.constructor)===Function&&(i=i[0]());const o=Ts(),a=o-gT;gT=o,n(t,e,Sp,...i.map(c=>{switch(c!=null&&c.constructor===Uint8Array&&(c=Array.from(c)),typeof c){case"string":case"symbol":return c;default:return lH(c)}}),t," +"+a+"ms")}:Z8},dH={[Rr]:fi("font-weight","bold"),[va]:fi("font-weight","normal"),[fT]:fi("color","blue"),[dT]:fi("color","green"),[Qb]:fi("color","grey"),[hT]:fi("color","red"),[pT]:fi("color","purple"),[Cp]:fi("color","orange"),[Sp]:fi("color","black")},yT=sH?n=>{var o;n.length===1&&((o=n[0])==null?void 0:o.constructor)===Function&&(n=n[0]());const e=[],t=[],r=Mn();let s=[],i=0;for(;i<n.length;i++){const a=n[i],l=dH[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const c=aH(r);i>0||c.length>0?(e.push("%c"+a),t.push(c)):e.push(a)}else break}}for(i>0&&(s=t,s.unshift(e.join("")));i<n.length;i++){const a=n[i];a instanceof Symbol||s.push(a)}return s}:uH,bT=(...n)=>{console.log(...yT(n)),wT.forEach(e=>e.print(n))},hH=(...n)=>{console.warn(...yT(n)),n.unshift(Cp),wT.forEach(e=>e.print(n))},wT=oi(),pH=n=>fH(bT,n),vT=n=>new Promise(n);Promise.all.bind(Promise);const mH=n=>Promise.reject(n),Xb=n=>Promise.resolve(n),xT=n=>new Uint8Array(n),gH=(n,e,t)=>new Uint8Array(n,e,t),yH=n=>new Uint8Array(n),bH=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=C8(n[t]);return btoa(e)},wH=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),vH=n=>{const e=atob(n),t=xT(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},xH=n=>{const e=Buffer.from(n,"base64");return gH(e.buffer,e.byteOffset,e.byteLength)},AT=Kb?bH:wH,ET=Kb?vH:xH,AH=n=>{const e=xT(n.byteLength);return e.set(n),e},kT=new Map;class EH{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:ET(t.newValue||"")}),G8(this._onChange)}postMessage(e){oT.setItem(this.room,AT(yH(e)))}close(){K8(this._onChange)}}const kH=typeof BroadcastChannel>"u"?EH:BroadcastChannel,Zb=n=>Jn(kT,n,()=>{const e=oi(),t=new kH(n);return t.onmessage=r=>e.forEach(s=>s(r.data,"broadcastchannel")),{bc:t,subs:e}}),CH=(n,e)=>(Zb(n).subs.add(e),e),SH=(n,e)=>{const t=Zb(n),r=t.subs.delete(e);return r&&t.subs.size===0&&(t.bc.close(),kT.delete(n)),r},TH=(n,e,t=null)=>{const r=Zb(n);r.bc.postMessage(e),r.subs.forEach(s=>s(e,t))},CT=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},ST=n=>({[Symbol.iterator](){return this},next:n}),NH=(n,e)=>ST(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),ew=(n,e)=>ST(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class tw{constructor(e,t){this.clock=e,this.len=t}}class Zl{constructor(){this.clients=new Map}}const oo=(n,e,t)=>e.clients.forEach((r,s)=>{const i=n.doc.store.clients.get(s);for(let o=0;o<r.length;o++){const a=r[o];GT(n,i,a.clock,a.len,t)}}),OH=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const s=Yr((t+r)/2),i=n[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;t=s+1}else r=s-1}return null},ec=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&OH(t,e.clock)!==null},nw=n=>{n.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let t,r;for(t=1,r=1;t<e.length;t++){const s=e[r-1],i=e[t];s.clock+s.len>=i.clock?s.len=li(s.len,i.clock+i.len-s.clock):(r<t&&(e[r]=i),r++)}e.length=r})},rw=n=>{const e=new Zl;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=t+1;o<n.length;o++)p8(i,n[o].clients.get(s)||[]);e.clients.set(s,i)}});return nw(e),e},Hf=(n,e,t,r)=>{Jn(n.clients,e,()=>[]).push(new tw(t,r))},TT=()=>new Zl,NT=n=>{const e=TT();return n.clients.forEach((t,r)=>{const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(o.deleted){const a=o.id.clock;let l=o.length;if(i+1<t.length)for(let c=t[i+1];i+1<t.length&&c.deleted;c=t[++i+1])l+=c.length;s.push(new tw(a,l))}}s.length>0&&e.clients.set(r,s)}),e},tc=(n,e)=>{De(n.restEncoder,e.clients.size),ai(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),De(n.restEncoder,t);const s=r.length;De(n.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},sw=n=>{const e=new Zl,t=We(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const s=We(n.restDecoder),i=We(n.restDecoder);if(i>0){const o=Jn(e.clients,s,()=>[]);for(let a=0;a<i;a++)o.push(new tw(n.readDsClock(),n.readDsLen()))}}return e},OT=(n,e,t)=>{const r=new Zl,s=We(n.restDecoder);for(let i=0;i<s;i++){n.resetDsCurVal();const o=We(n.restDecoder),a=We(n.restDecoder),l=t.clients.get(o)||[],c=jt(t,o);for(let u=0;u<a;u++){const f=n.readDsClock(),d=f+n.readDsLen();if(f<c){c<d&&Hf(r,o,c,d-c);let h=Ds(l,f),p=l[h];for(!p.deleted&&p.id.clock<f&&(l.splice(h+1,0,Up(e,p,f-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(h,0,Up(e,p,d-p.id.clock)),p.delete(e))}else Hf(r,o,f,d-f)}}if(r.clients.size>0){const i=new Aa;return De(i.restEncoder,0),tc(i,r),i.toUint8Array()}return null},RT=KS;class xa extends Mb{constructor({guid:e=JS(),collectionid:t=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=RT(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new VT,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=vT(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>vT(c=>{const u=f=>{(f===void 0||f===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&gt(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ai(this.subdocs).map(e=>e.guid))}transact(e,t=null){return gt(this,e,t)}get(e,t=mn){const r=Jn(this.share,e,()=>{const i=new t;return i._integrate(this,null),i}),s=r.constructor;if(t!==mn&&s!==t)if(s===mn){const i=new t;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,oc)}getText(e=""){return this.get(e,ka)}getMap(e=""){return this.get(e,ac)}getXmlElement(e=""){return this.get(e,Dn)}getXmlFragment(e=""){return this.get(e,Ca)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){ai(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new xa({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,gt(e.parent.doc,r=>{const s=t.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class MT{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return We(this.restDecoder)}readDsLen(){return We(this.restDecoder)}}class DT extends MT{readLeftID(){return Ge(We(this.restDecoder),We(this.restDecoder))}readRightID(){return Ge(We(this.restDecoder),We(this.restDecoder))}readClient(){return We(this.restDecoder)}readInfo(){return wa(this.restDecoder)}readString(){return ui(this.restDecoder)}readParentInfo(){return We(this.restDecoder)===1}readTypeRef(){return We(this.restDecoder)}readLen(){return We(this.restDecoder)}readAny(){return Yl(this.restDecoder)}readBuf(){return AH(sn(this.restDecoder))}readJSON(){return JSON.parse(ui(this.restDecoder))}readKey(){return ui(this.restDecoder)}}class RH{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=We(this.restDecoder),this.dsCurrVal}readDsLen(){const e=We(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class nc extends RH{constructor(e){super(e),this.keys=[],We(e),this.keyClockDecoder=new Vb(sn(e)),this.clientDecoder=new Ep(sn(e)),this.leftClockDecoder=new Vb(sn(e)),this.rightClockDecoder=new Vb(sn(e)),this.infoDecoder=new rT(sn(e),wa),this.stringDecoder=new $8(sn(e)),this.parentInfoDecoder=new rT(sn(e),wa),this.typeRefDecoder=new Ep(sn(e)),this.lenDecoder=new Ep(sn(e))}readLeftID(){return new rc(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new rc(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Yl(this.restDecoder)}readBuf(){return sn(this.restDecoder)}readJSON(){return Yl(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class PT{constructor(){this.restEncoder=nn()}toUint8Array(){return Rt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){De(this.restEncoder,e)}writeDsLen(e){De(this.restEncoder,e)}}class zf extends PT{writeLeftID(e){De(this.restEncoder,e.client),De(this.restEncoder,e.clock)}writeRightID(e){De(this.restEncoder,e.client),De(this.restEncoder,e.clock)}writeClient(e){De(this.restEncoder,e)}writeInfo(e){jf(this.restEncoder,e)}writeString(e){Os(this.restEncoder,e)}writeParentInfo(e){De(this.restEncoder,e?1:0)}writeTypeRef(e){De(this.restEncoder,e)}writeLen(e){De(this.restEncoder,e)}writeAny(e){Ql(this.restEncoder,e)}writeBuf(e){Lt(this.restEncoder,e)}writeJSON(e){Os(this.restEncoder,JSON.stringify(e))}writeKey(e){Os(this.restEncoder,e)}}class IT{constructor(){this.restEncoder=nn(),this.dsCurrVal=0}toUint8Array(){return Rt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,De(this.restEncoder,t)}writeDsLen(e){e===0&&dr(),De(this.restEncoder,e-1),this.dsCurrVal+=e}}class Aa extends IT{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ub,this.clientEncoder=new xp,this.leftClockEncoder=new Ub,this.rightClockEncoder=new Ub,this.infoEncoder=new XS(jf),this.stringEncoder=new U8,this.parentInfoEncoder=new XS(jf),this.typeRefEncoder=new xp,this.lenEncoder=new xp}toUint8Array(){const e=nn();return De(e,0),Lt(e,this.keyClockEncoder.toUint8Array()),Lt(e,this.clientEncoder.toUint8Array()),Lt(e,this.leftClockEncoder.toUint8Array()),Lt(e,this.rightClockEncoder.toUint8Array()),Lt(e,Rt(this.infoEncoder)),Lt(e,this.stringEncoder.toUint8Array()),Lt(e,Rt(this.parentInfoEncoder)),Lt(e,this.typeRefEncoder.toUint8Array()),Lt(e,this.lenEncoder.toUint8Array()),vp(e,Rt(this.restEncoder)),Rt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ql(this.restEncoder,e)}writeBuf(e){Lt(this.restEncoder,e)}writeJSON(e){Ql(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const MH=(n,e,t,r)=>{r=li(r,e[0].id.clock);const s=Ds(e,r);De(n.restEncoder,e.length-s),n.writeClient(t),De(n.restEncoder,r);const i=e[s];i.write(n,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(n,0)},iw=(n,e,t)=>{const r=new Map;t.forEach((s,i)=>{jt(e,i)>s&&r.set(i,s)}),Kf(e).forEach((s,i)=>{t.has(i)||r.set(i,0)}),De(n.restEncoder,r.size),ai(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{MH(n,e.clients.get(s),s,i)})},DH=(n,e)=>{const t=Mn(),r=We(n.restDecoder);for(let s=0;s<r;s++){const i=We(n.restDecoder),o=new Array(i),a=n.readClient();let l=We(n.restDecoder);t.set(a,{i:0,refs:o});for(let c=0;c<i;c++){const u=n.readInfo();switch(wp&u){case 0:{const f=n.readLen();o[c]=new Mr(Ge(a,l),f),l+=f;break}case 10:{const f=We(n.restDecoder);o[c]=new Dr(Ge(a,l),f),l+=f;break}default:{const f=(u&(ci|hr))===0,d=new xt(Ge(a,l),null,(u&hr)===hr?n.readLeftID():null,null,(u&ci)===ci?n.readRightID():null,f?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,f&&(u&Lf)===Lf?n.readString():null,E2(n,u));o[c]=d,l+=d.length}}}}return t},PH=(n,e,t)=>{const r=[];let s=ai(t.keys()).sort((h,p)=>h-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let h=t.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=t.get(s[s.length-1]);else return null;return h};let o=i();if(o===null)return null;const a=new VT,l=new Map,c=(h,p)=>{const m=l.get(h);(m==null||m>p)&&l.set(h,p)};let u=o.refs[o.i++];const f=new Map,d=()=>{for(const h of r){const p=h.id.client,m=t.get(p);m?(m.i--,a.clients.set(p,m.refs.slice(m.i)),t.delete(p),m.i=0,m.refs=[]):a.clients.set(p,[h]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==Dr){const p=Jn(f,u.id.client,()=>jt(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),d();else{const m=u.getMissing(n,e);if(m!==null){r.push(u);const y=t.get(m)||{refs:[],i:0};if(y.refs.length===y.i)c(m,jt(e,m)),d();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(n,p),f.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(a.clients.size>0){const h=new Aa;return iw(h,a,new Map),De(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},IH=(n,e)=>iw(n,e.doc.store,e.beforeState),LH=(n,e,t,r=new nc(n))=>gt(e,s=>{s.local=!1;let i=!1;const o=s.doc,a=o.store,l=DH(r,o),c=PH(s,a,l),u=a.pendingStructs;if(u){for(const[d,h]of u.missing)if(h<jt(a,d)){i=!0;break}if(c){for(const[d,h]of c.missing){const p=u.missing.get(d);(p==null||p>h)&&u.missing.set(d,h)}u.update=Rp([u.update,c.update])}}else a.pendingStructs=c;const f=OT(r,s,a);if(a.pendingDs){const d=new nc(Rs(a.pendingDs));We(d.restDecoder);const h=OT(d,s,a);f&&h?a.pendingDs=Rp([f,h]):a.pendingDs=f||h}else a.pendingDs=f;if(i){const d=a.pendingStructs.update;a.pendingStructs=null,Tp(s.doc,d)}},t,!1),Tp=(n,e,t,r=nc)=>{const s=Rs(e);LH(s,n,t,new r(s))},_H=(n,e,t)=>Tp(n,e,t,DT),BH=(n,e,t=new Map)=>{iw(n,e.store,t),tc(n,NT(e.store))},FH=(n,e=new Uint8Array([0]),t=new Aa)=>{const r=LT(e);BH(t,n,r);const s=[t.toUint8Array()];if(n.store.pendingDs&&s.push(n.store.pendingDs),n.store.pendingStructs&&s.push(n5(n.store.pendingStructs.update,e)),s.length>1){if(t.constructor===zf)return e5(s.map((i,o)=>o===0?i:s5(i)));if(t.constructor===Aa)return Rp(s)}return s[0]},jH=(n,e)=>FH(n,e,new zf),UH=n=>{const e=new Map,t=We(n.restDecoder);for(let r=0;r<t;r++){const s=We(n.restDecoder),i=We(n.restDecoder);e.set(s,i)}return e},LT=n=>UH(new MT(Rs(n))),_T=(n,e)=>(De(n.restEncoder,e.size),ai(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{De(n.restEncoder,t),De(n.restEncoder,r)}),n),HH=(n,e)=>_T(n,Kf(e.store)),zH=(n,e=new IT)=>(n instanceof Map?_T(e,n):HH(e,n),e.toUint8Array()),VH=n=>zH(n,new PT);class $H{constructor(){this.l=[]}}const BT=()=>new $H,FT=(n,e)=>n.l.push(e),jT=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(s=>e!==s),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},UT=(n,e,t)=>Gb(n.l,[e,t]);class rc{constructor(e,t){this.client=e,this.clock=t}}const sc=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,Ge=(n,e)=>new rc(n,e),Vf=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw dr()},$f=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class Wf{constructor(e,t,r,s=0){this.type=e,this.tname=t,this.item=r,this.assoc=s}}const Gf=n=>new Wf(n.type==null?null:Ge(n.type.client,n.type.clock),n.tname??null,n.item==null?null:Ge(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class WH{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const GH=(n,e,t=0)=>new WH(n,e,t),Np=(n,e,t)=>{let r=null,s=null;return n._item===null?s=Vf(n):r=Ge(n._item.id.client,n._item.id.clock),new Wf(r,s,e,t)},ow=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return Np(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Np(n,Ge(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return Np(n,r.lastId,t);r=r.right}return Np(n,null,t)},KH=(n,e,t=!0)=>{const r=e.store,s=n.item,i=n.type,o=n.tname,a=n.assoc;let l=null,c=0;if(s!==null){if(jt(r,s.client)<=s.clock)return null;const u=t?xw(r,s):{item:ic(r,s),diff:0},f=u.item;if(!(f instanceof xt))return null;if(l=f.parent,l._item===null||!l._item.deleted){c=f.deleted||!f.countable?0:u.diff+(a>=0?0:1);let d=f.left;for(;d!==null;)!d.deleted&&d.countable&&(c+=d.length),d=d.left}}else{if(o!==null)l=e.get(o);else if(i!==null){if(jt(r,i.client)<=i.clock)return null;const{item:u}=t?xw(r,i):{item:ic(r,i)};if(u instanceof xt&&u.content instanceof es)l=u.content.type;else return null}else throw dr();a>=0?c=l._length:c=0}return GH(l,c,n.assoc)},HT=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&sc(n.item,e.item)&&sc(n.type,e.type)&&n.assoc===e.assoc;class aw{constructor(e,t){this.ds=e,this.sv=t}}const zT=(n,e)=>new aw(n,e),lw=n=>zT(NT(n.store),Kf(n.store)),Ea=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!ec(e.ds,n.id),cw=(n,e)=>{const t=Jn(n.meta,cw,oi),r=n.doc.store;t.has(e)||(e.sv.forEach((s,i)=>{s<jt(r,i)&&qn(n,Ge(i,s))}),oo(n,e.ds,s=>{}),t.add(e))};class VT{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Kf=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const s=t[t.length-1];e.set(r,s.id.clock+s.length)}),e},jt=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},$T=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw dr()}t.push(e)},Ds=(n,e)=>{let t=0,r=n.length-1,s=n[r],i=s.id.clock;if(i===e)return r;let o=Yr(e/(i+s.length-1)*r);for(;t<=r;){if(s=n[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;t=o+1}else r=o-1;o=Yr((t+r)/2)}throw dr()},ic=(n,e)=>{const t=n.clients.get(e.client);return t[Ds(t,e.clock)]},uw=(n,e,t)=>{const r=Ds(e,t),s=e[r];return s.id.clock<t&&s instanceof xt?(e.splice(r+1,0,Up(n,s,t-s.id.clock)),r+1):r},qn=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[uw(n,t,e.clock)]},WT=(n,e,t)=>{const r=e.clients.get(t.client),s=Ds(r,t.clock),i=r[s];return t.clock!==i.id.clock+i.length-1&&i.constructor!==Mr&&r.splice(s+1,0,Up(n,i,t.clock-i.id.clock+1)),i},JH=(n,e,t)=>{const r=n.clients.get(e.id.client);r[Ds(r,e.id.clock)]=t},GT=(n,e,t,r,s)=>{if(r===0)return;const i=t+r;let o=uw(n,e,t),a;do a=e[o++],i<a.id.clock+a.length&&uw(n,e,i),s(a);while(o<e.length&&e[o].id.clock<i)};let qH=class{constructor(e,t,r){this.doc=e,this.deleteSet=new Zl,this.beforeState=Kf(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}};const KT=(n,e)=>e.deleteSet.clients.size===0&&!h8(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(nw(e.deleteSet),IH(n,e),tc(n,e.deleteSet),!0),JT=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Jn(n.changed,e,oi).add(t)},Op=(n,e)=>{let t=n[e],r=n[e-1],s=e;for(;s>0;t=r,r=n[--s-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof xt&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const i=e-s;return i&&n.splice(e+1-i,i),i},QH=(n,e,t)=>{for(const[r,s]of n.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const a=s[o],l=a.clock+a.len;for(let c=Ds(i,a.clock),u=i[c];c<i.length&&u.id.clock<l;u=i[++c]){const f=i[c];if(a.clock+a.len<=f.id.clock)break;f instanceof xt&&f.deleted&&!f.keep&&t(f)&&f.gc(e,!1)}}}},YH=(n,e)=>{n.clients.forEach((t,r)=>{const s=e.clients.get(r);for(let i=t.length-1;i>=0;i--){const o=t[i],a=io(s.length-1,1+Ds(s,o.clock+o.len-1));for(let l=a,c=s[l];l>0&&c.id.clock>=o.clock;c=s[l])l-=1+Op(s,l)}})},qT=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,s=r.store,i=t.deleteSet,o=t._mergeStructs;try{nw(i),t.afterState=Kf(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const a=[];t.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,l)})),a.push(()=>{t.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,f)=>u.path.length-f.path.length),UT(c._dEH,l,t))})}),a.push(()=>r.emit("afterTransaction",[t,r])),Gb(a,[]),t._needFormattingCleanup&&b5(t)}finally{r.gc&&QH(i,s,r.gcFilter),YH(i,s),t.afterState.forEach((u,f)=>{const d=t.beforeState.get(f)||0;if(d!==u){const h=s.clients.get(f),p=li(Ds(h,d),1);for(let m=h.length-1;m>=p;)m-=1+Op(h,m)}});for(let u=o.length-1;u>=0;u--){const{client:f,clock:d}=o[u].id,h=s.clients.get(f),p=Ds(h,d);p+1<h.length&&Op(h,p+1)>1||p>0&&Op(h,p)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(bT(Cp,Rr,"[yjs] ",va,hT,"Changed the client-id because another client seems to be using it."),r.clientID=RT()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const u=new zf;KT(u,t)&&r.emit("update",[u.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const u=new Aa;KT(u,t)&&r.emit("updateV2",[u.toUint8Array(),t.origin,r,t])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=t;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,t]),c.forEach(u=>u.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):qT(n,e+1)}}},gt=(n,e,t=null,r=!0)=>{const s=n._transactionCleanups;let i=!1,o=null;n._transaction===null&&(i=!0,n._transaction=new qH(n,t,r),s.push(n._transaction),s.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction)}finally{if(i){const a=n._transaction===s[0];n._transaction=null,a&&qT(s,0)}}return o};class XH{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const QT=(n,e,t)=>{oo(n,t.deletions,r=>{r instanceof xt&&e.scope.some(s=>$f(s,r))&&Aw(r,!1)})},YT=(n,e,t)=>{let r=null;const s=n.doc,i=n.scope;gt(s,a=>{for(;e.length>0&&n.currStackItem===null;){const l=s.store,c=e.pop(),u=new Set,f=[];let d=!1;oo(a,c.insertions,h=>{if(h instanceof xt){if(h.redone!==null){let{item:p,diff:m}=xw(l,h.id);m>0&&(p=qn(a,Ge(p.id.client,p.id.clock+m))),h=p}!h.deleted&&i.some(p=>$f(p,h))&&f.push(h)}}),oo(a,c.deletions,h=>{h instanceof xt&&i.some(p=>$f(p,h))&&!ec(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{d=A2(a,h,u,c.insertions,n.ignoreRemoteMapChanges,n)!==null||d});for(let h=f.length-1;h>=0;h--){const p=f[h];n.deleteFilter(p)&&(p.delete(a),d=!0)}n.currStackItem=d?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},n);const o=n.currStackItem;if(o!=null){const a=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:o,type:t,changedParentTypes:a,origin:n},n]),n.currStackItem=null}return o};class XT extends Mb{constructor(e,{captureTimeout:t=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:a=Rb(e)?e[0].doc:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=t,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(y=>l.changedParentTypes.has(y))||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,u=this.redoing,f=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const d=new Zl;l.afterState.forEach((y,b)=>{const x=l.beforeState.get(b)||0,v=y-x;v>0&&Hf(d,b,x,v)});const h=Ts();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&f.length>0&&!c&&!u){const y=f[f.length-1];y.deletions=rw([y.deletions,l.deleteSet]),y.insertions=rw([y.insertions,d])}else f.push(new XH(l.deleteSet,d)),p=!0;!c&&!u&&(this.lastChange=h),oo(l,l.deleteSet,y=>{y instanceof xt&&this.scope.some(b=>$f(b,y))&&Aw(y,!0)});const m=[{stackItem:f[f.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){e=Rb(e)?e:[e],e.forEach(t=>{this.scope.every(r=>r!==t)&&(t.doc!==this.doc&&hH("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>QT(r,this,s)),this.undoStack=[]),t&&(this.redoStack.forEach(s=>QT(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=YT(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=YT(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*ZH(n){const e=We(n.restDecoder);for(let t=0;t<e;t++){const r=We(n.restDecoder),s=n.readClient();let i=We(n.restDecoder);for(let o=0;o<r;o++){const a=n.readInfo();if(a===10){const l=We(n.restDecoder);yield new Dr(Ge(s,i),l),i+=l}else if(wp&a){const l=(a&(ci|hr))===0,c=new xt(Ge(s,i),null,(a&hr)===hr?n.readLeftID():null,null,(a&ci)===ci?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&Lf)===Lf?n.readString():null,E2(n,a));yield c,i+=c.length}else{const l=n.readLen();yield new Mr(Ge(s,i),l),i+=l}}}}class fw{constructor(e,t){this.gen=ZH(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Dr);return this.curr}}class dw{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const e5=n=>Rp(n,DT,zf),t5=(n,e)=>{if(n.constructor===Mr){const{client:t,clock:r}=n.id;return new Mr(Ge(t,r+e),n.length-e)}else if(n.constructor===Dr){const{client:t,clock:r}=n.id;return new Dr(Ge(t,r+e),n.length-e)}else{const t=n,{client:r,clock:s}=t.id;return new xt(Ge(r,s+e),null,Ge(r,s+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},Rp=(n,e=nc,t=Aa)=>{if(n.length===1)return n[0];const r=n.map(u=>new e(Rs(u)));let s=r.map(u=>new fw(u,!0)),i=null;const o=new t,a=new dw(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,h)=>{if(d.curr.id.client===h.curr.id.client){const p=d.curr.id.clock-h.curr.id.clock;return p===0?d.curr.constructor===h.curr.constructor?0:d.curr.constructor===Dr?1:-1:p}else return h.curr.id.client-d.curr.id.client}),s.length!==0;){const u=s[0],f=u.curr.id.client;if(i!==null){let d=u.curr,h=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=u.next(),h=!0;if(d===null||d.id.client!==f||h&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(f!==i.struct.id.client)ao(a,i.struct,i.offset),i={struct:d,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===Dr)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{ao(a,i.struct,i.offset);const p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Dr(Ge(f,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===Dr?i.struct.length-=p:d=t5(d,p)),i.struct.mergeWith(d)||(ao(a,i.struct,i.offset),i={struct:d,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let d=u.curr;d!==null&&d.id.client===f&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==Dr;d=u.next())ao(a,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(ao(a,i.struct,i.offset),i=null),hw(a);const l=r.map(u=>sw(u)),c=rw(l);return tc(o,c),o.toUint8Array()},n5=(n,e,t=nc,r=Aa)=>{const s=LT(e),i=new r,o=new dw(i),a=new t(Rs(n)),l=new fw(a,!1);for(;l.curr;){const u=l.curr,f=u.id.client,d=s.get(f)||0;if(l.curr.constructor===Dr){l.next();continue}if(u.id.clock+u.length>d)for(ao(o,u,li(d-u.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)ao(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=d;)l.next()}hw(o);const c=sw(a);return tc(i,c),i.toUint8Array()},ZT=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:Rt(n.encoder.restEncoder)}),n.encoder.restEncoder=nn(),n.written=0)},ao=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&ZT(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),De(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},hw=n=>{ZT(n);const e=n.encoder.restEncoder;De(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];De(e,r.written),vp(e,r.restEncoder)}},r5=(n,e,t,r)=>{const s=new t(Rs(n)),i=new fw(s,!1),o=new r,a=new dw(o);for(let c=i.curr;c!==null;c=i.next())ao(a,e(c),0);hw(a);const l=sw(s);return tc(o,l),o.toUint8Array()},s5=n=>r5(n,eH,nc,zf),e2="You must not compute changes after the event-handler fired.";class Mp{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=i5(this.currentTarget,this.target))}deletes(e){return ec(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ns(e2);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(s=>{if(s!==null){const i=t._map.get(s);let o,a;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",a=Ob(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",a=Ob(l.content.getContent())):(o="add",a=void 0)}else if(this.deletes(i))o="delete",a=Ob(i.content.getContent());else return;e.set(s,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ns(e2);const t=this.target,r=oi(),s=oi(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let a=null;const l=()=>{a&&i.push(a)};for(let c=t._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,s.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const i5=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;t.unshift(r)}e=e._item.parent}return t},t2=80;let pw=0;class o5{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=pw++}}const a5=n=>{n.timestamp=pw++},n2=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=pw++},l5=(n,e,t)=>{if(n.length>=t2){const r=n.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return n2(r,e,t),r}else{const r=new o5(e,t);return n.push(r),r}},Dp=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((i,o)=>yp(e-i.index)<yp(e-o.index)?i:o);let r=n._start,s=0;for(t!==null&&(r=t.p,s=t.index,a5(t));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return t!==null&&yp(t.index-s)<r.parent.length/t2?(n2(t,r,s),t):l5(n._searchMarker,r,s)},Jf=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const s=n[r];if(t>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){n.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||t>0&&e===s.index)&&(s.index=li(e,s.index+t))}},Pp=(n,e,t)=>{const r=n,s=e.changedParentTypes;for(;Jn(s,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;UT(r._eH,t,e)};class mn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=BT(),this._dEH=BT(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Xr()}clone(){throw Xr()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){FT(this._eH,e)}observeDeep(e){FT(this._dEH,e)}unobserve(e){jT(this._eH,e)}unobserveDeep(e){jT(this._dEH,e)}toJSON(){}}const r2=(n,e,t)=>{e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const s=[];let i=n._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a<o.length&&r>0;a++)s.push(o[a]),r--;e=0}}i=i.right}return s},s2=n=>{const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}t=t.right}return e},i2=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&Ea(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)t.push(s[i])}r=r.right}return t},qf=(n,e)=>{let t=0,r=n._start;for(;r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],t++,n)}r=r.right}},o2=(n,e)=>{const t=[];return qf(n,(r,s)=>{t.push(e(r,s,n))}),t},c5=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const s=t[r++];return t.length<=r&&(t=null),{done:!1,value:s}}}},a2=(n,e)=>{const t=Dp(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Ip=(n,e,t,r)=>{let s=t;const i=n.doc,o=i.clientID,a=i.store,l=t===null?e._start:t.right;let c=[];const u=()=>{c.length>0&&(s=new xt(Ge(o,jt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Ta(c)),s.integrate(n,0),c=[])};r.forEach(f=>{if(f===null)c.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(f);break;default:switch(u(),f.constructor){case Uint8Array:case ArrayBuffer:s=new xt(Ge(o,jt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Qf(new Uint8Array(f))),s.integrate(n,0);break;case xa:s=new xt(Ge(o,jt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Xf(f)),s.integrate(n,0);break;default:if(f instanceof mn)s=new xt(Ge(o,jt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new es(f)),s.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},l2=()=>Ns("Length exceeded!"),c2=(n,e,t,r)=>{if(t>e._length)throw l2();if(t===0)return e._searchMarker&&Jf(e._searchMarker,t,r.length),Ip(n,e,null,r);const s=t,i=Dp(e,t);let o=e._start;for(i!==null&&(o=i.p,t-=i.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&qn(n,Ge(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&Jf(e._searchMarker,s,r.length),Ip(n,e,o,r)},u5=(n,e,t)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return Ip(n,e,s,t)},u2=(n,e,t,r)=>{if(r===0)return;const s=t,i=r,o=Dp(e,t);let a=e._start;for(o!==null&&(a=o.p,t-=o.index);a!==null&&t>0;a=a.right)!a.deleted&&a.countable&&(t<a.length&&qn(n,Ge(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&qn(n,Ge(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw l2();e._searchMarker&&Jf(e._searchMarker,s,-i+r)},Lp=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},mw=(n,e,t,r)=>{const s=e._map.get(t)||null,i=n.doc,o=i.clientID;let a;if(r==null)a=new Ta([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new Ta([r]);break;case Uint8Array:a=new Qf(r);break;case xa:a=new Xf(r);break;default:if(r instanceof mn)a=new es(r);else throw new Error("Unexpected content type")}new xt(Ge(o,jt(i.store,o)),s,s&&s.lastId,null,null,e,t,a).integrate(n,0)},gw=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},f2=n=>{const e={};return n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},d2=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted},f5=(n,e)=>{const t={};return n._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&Ea(i,e)&&(t[s]=i.content.getContent()[i.length-1])}),t},_p=n=>NH(n.entries(),e=>!e[1].deleted);class d5 extends Mp{}class oc extends mn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new oc;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new oc}clone(){const e=new oc;return e.insert(0,this.toArray().map(t=>t instanceof mn?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),Pp(this,e,new d5(this,e))}insert(e,t){this.doc!==null?gt(this.doc,r=>{c2(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?gt(this.doc,t=>{u5(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?gt(this.doc,r=>{u2(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return a2(this,e)}toArray(){return s2(this)}slice(e=0,t=this.length){return r2(this,e,t)}toJSON(){return this.map(e=>e instanceof mn?e.toJSON():e)}map(e){return o2(this,e)}forEach(e){qf(this,e)}[Symbol.iterator](){return c5(this)}_write(e){e.writeTypeRef(_5)}}const h5=n=>new oc;class p5 extends Mp{constructor(e,t,r){super(e,t),this.keysChanged=r}}class ac extends mn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new ac}clone(){const e=new ac;return this.forEach((t,r)=>{e.set(r,t instanceof mn?t.clone():t)}),e}_callObserver(e,t){Pp(this,e,new p5(this,e,t))}toJSON(){const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const s=t.content.getContent()[t.length-1];e[r]=s instanceof mn?s.toJSON():s}}),e}get size(){return[..._p(this._map)].length}keys(){return ew(_p(this._map),e=>e[0])}values(){return ew(_p(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return ew(_p(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?gt(this.doc,t=>{Lp(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?gt(this.doc,r=>{mw(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return gw(this,e)}has(e){return d2(this,e)}clear(){this.doc!==null?gt(this.doc,e=>{this.forEach(function(t,r,s){Lp(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(B5)}}const m5=n=>new ac,lo=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&X8(n,e);class yw{constructor(e,t,r,s){this.left=e,this.right=t,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&dr(),this.right.content.constructor){case Kt:this.right.deleted||lc(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const h2=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case Kt:e.right.deleted||lc(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&qn(n,Ge(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},Bp=(n,e,t,r)=>{const s=new Map,i=r?Dp(e,t):null;if(i){const o=new yw(i.p.left,i.p,i.index,s);return h2(n,o,t-i.index)}else{const o=new yw(null,e._start,0,s);return h2(n,o,t)}},p2=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===Kt&&lo(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const s=n.doc,i=s.clientID;r.forEach((o,a)=>{const l=t.left,c=t.right,u=new xt(Ge(i,jt(s.store,i)),l,l&&l.lastId,c,c&&c.id,e,null,new Kt(a,o));u.integrate(n,0),t.right=u,t.forward()})},lc=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},m2=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===Kt&&lo(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},g2=(n,e,t,r)=>{const s=n.doc,i=s.clientID,o=new Map;for(const a in r){const l=r[a],c=t.currentAttributes.get(a)??null;if(!lo(c,l)){o.set(a,c);const{left:u,right:f}=t;t.right=new xt(Ge(i,jt(s.store,i)),u,u&&u.lastId,f,f&&f.id,e,null,new Kt(a,l)),t.right.integrate(n,0),t.forward()}}return o},bw=(n,e,t,r,s)=>{t.currentAttributes.forEach((d,h)=>{s[h]===void 0&&(s[h]=null)});const i=n.doc,o=i.clientID;m2(t,s);const a=g2(n,e,t,s),l=r.constructor===String?new Zr(r):r instanceof mn?new es(r):new Sa(r);let{left:c,right:u,index:f}=t;e._searchMarker&&Jf(e._searchMarker,t.index,l.getLength()),u=new xt(Ge(o,jt(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,l),u.integrate(n,0),t.right=u,t.index=f,t.forward(),p2(n,e,t,a)},y2=(n,e,t,r,s)=>{const i=n.doc,o=i.clientID;m2(t,s);const a=g2(n,e,t,s);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===Kt));){if(!t.right.deleted)switch(t.right.content.constructor){case Kt:{const{key:l,value:c}=t.right.content,u=s[l];if(u!==void 0){if(lo(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}t.right.delete(n)}else t.currentAttributes.set(l,c);break}default:r<t.right.length&&qn(n,Ge(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
426
+ For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return H.useEffect(()=>{n&&(document.getElementById(n)||console.error(t))},[t,n]),null},Fj="DialogDescriptionWarning",jj=({contentRef:n,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${BC(Fj).contentName}}.`;return H.useEffect(()=>{var i;const s=(i=n.current)==null?void 0:i.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(r))},[r,n,e]),null},FC=EC,jC=CC,UC=TC,ob=NC,ab=OC,lb=MC,cb=PC,HC=LC;function Uj(n){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",e.appendChild(t),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}const zC=L.createContext({drawerRef:{current:null},overlayRef:{current:null},scaleBackground:()=>{},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,handleOnly:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},visible:!1,closeDrawer:()=>{},setVisible:()=>{},direction:"bottom"}),op=()=>{const n=L.useContext(zC);if(!n)throw new Error("useDrawerContext must be used within a Drawer.Root");return n};Uj("[vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1)}[vaul-drawer][vaul-drawer-direction=bottom]{transform:translate3d(0,100%,0)}[vaul-drawer][vaul-drawer-direction=top]{transform:translate3d(0,-100%,0)}[vaul-drawer][vaul-drawer-direction=left]{transform:translate3d(-100%,0,0)}[vaul-drawer][vaul-drawer-direction=right]{transform:translate3d(100%,0,0)}.vaul-dragging .vaul-scrollable [vault-drawer-direction=top]{overflow-y:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=bottom]{overflow-y:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=left]{overflow-x:hidden!important}.vaul-dragging .vaul-scrollable [vault-drawer-direction=right]{overflow-x:hidden!important}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[vaul-drawer][vaul-drawer-visible=true][vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[vaul-overlay]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[vaul-overlay][vaul-drawer-visible=true]{opacity:1}[vaul-drawer]::after{content:'';position:absolute;background:inherit;background-color:inherit}[vaul-drawer][vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[vaul-drawer][vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[vaul-drawer][vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[vaul-drawer][vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[vaul-handle]{display:block;position:relative;opacity:.8;margin-left:auto;margin-right:auto;height:5px;width:56px;border-radius:1rem;touch-action:pan-y;cursor:grab}[vaul-handle]:active,[vaul-handle]:hover{opacity:1}[vaul-handle]:active{cursor:grabbing}[vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}[vaul-overlay][vaul-snap-points=true]:not([vaul-snap-points-overlay=true]):not([data-state=closed]){opacity:0}[vaul-overlay][vaul-snap-points-overlay=true]:not([vaul-drawer-visible=false]){opacity:1}@media (hover:hover) and (pointer:fine){[vaul-drawer]{user-select:none}}@media (pointer:fine){[vaul-handle-hitarea]:{width:100%;height:100%}}");const Hj=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ub(...n){return(...e)=>{for(let t of n)typeof t=="function"&&t(...e)}}function zj(){return fb(/^Mac/)}function Vj(){return fb(/^iPhone/)}function $j(){return fb(/^iPad/)||zj()&&navigator.maxTouchPoints>1}function VC(){return Vj()||$j()}function fb(n){return typeof window<"u"&&window.navigator!=null?n.test(window.navigator.platform):void 0}const db=typeof document<"u"&&window.visualViewport;function $C(n){let e=window.getComputedStyle(n);return/(auto|scroll)/.test(e.overflow+e.overflowX+e.overflowY)}function WC(n){for($C(n)&&(n=n.parentElement);n&&!$C(n);)n=n.parentElement;return n||document.scrollingElement||document.documentElement}const Wj=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);let ap=0,hb;function Gj(n={}){let{isDisabled:e}=n;Hj(()=>{if(!e)return ap++,ap===1&&(VC()?hb=Jj():hb=Kj()),()=>{ap--,ap===0&&hb()}},[e])}function Kj(){return ub(GC(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`))}function Jj(){let n,e=0,t=f=>{n=WC(f.target),!(n===document.documentElement&&n===document.body)&&(e=f.changedTouches[0].pageY)},r=f=>{if(!n||n===document.documentElement||n===document.body){f.preventDefault();return}let d=f.changedTouches[0].pageY,h=n.scrollTop,p=n.scrollHeight-n.clientHeight;p!==0&&((h<=0&&d>e||h>=p&&d<e)&&f.preventDefault(),e=d)},s=f=>{let d=f.target;pb(d)&&d!==document.activeElement&&(f.preventDefault(),d.style.transform="translateY(-2000px)",d.focus(),requestAnimationFrame(()=>{d.style.transform=""}))},i=f=>{let d=f.target;pb(d)&&(d.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{d.style.transform="",db&&(db.height<window.innerHeight?requestAnimationFrame(()=>{KC(d)}):db.addEventListener("resize",()=>KC(d),{once:!0}))}))},o=()=>{window.scrollTo(0,0)},a=window.pageXOffset,l=window.pageYOffset,c=ub(GC(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let u=ub(Cf(document,"touchstart",t,{passive:!1,capture:!0}),Cf(document,"touchmove",r,{passive:!1,capture:!0}),Cf(document,"touchend",s,{passive:!1,capture:!0}),Cf(document,"focus",i,!0),Cf(window,"scroll",o));return()=>{c(),u(),window.scrollTo(a,l)}}function GC(n,e,t){let r=n.style[e];return n.style[e]=t,()=>{n.style[e]=r}}function Cf(n,e,t,r){return n.addEventListener(e,t,r),()=>{n.removeEventListener(e,t,r)}}function KC(n){let e=document.scrollingElement||document.documentElement;for(;n&&n!==e;){let t=WC(n);if(t!==document.documentElement&&t!==document.body&&t!==n){let r=t.getBoundingClientRect().top,s=n.getBoundingClientRect().top,i=n.getBoundingClientRect().bottom;const o=t.getBoundingClientRect().bottom;i>o&&(t.scrollTop+=s-r)}n=t.parentElement}}function pb(n){return n instanceof HTMLInputElement&&!Wj.has(n.type)||n instanceof HTMLTextAreaElement||n instanceof HTMLElement&&n.isContentEditable}function qj(n,e){typeof n=="function"?n(e):n!=null&&(n.current=e)}function Qj(...n){return e=>n.forEach(t=>qj(t,e))}function JC(...n){return H.useCallback(Qj(...n),n)}let Sf=null;function Yj({isOpen:n,modal:e,nested:t,hasBeenOpened:r,preventScrollRestoration:s,noBodyStyles:i}){const[o,a]=L.useState(()=>typeof window<"u"?window.location.href:""),l=L.useRef(0),c=L.useCallback(()=>{if(Sf===null&&n&&!i){Sf={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};const{scrollX:f,innerHeight:d}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-l.current}px`,left:`${-f}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{const h=d-window.innerHeight;h&&l.current>=d&&(document.body.style.top=`${-(l.current+h)}px`)}),300)}},[n]),u=L.useCallback(()=>{if(Sf!==null&&!i){const f=-parseInt(document.body.style.top,10),d=-parseInt(document.body.style.left,10);Object.assign(document.body.style,Sf),window.requestAnimationFrame(()=>{if(s&&o!==window.location.href){a(window.location.href);return}window.scrollTo(d,f)}),Sf=null}},[o]);return L.useEffect(()=>{function f(){l.current=window.scrollY}return f(),window.addEventListener("scroll",f),()=>{window.removeEventListener("scroll",f)}},[]),L.useEffect(()=>{t||!r||(n?(!window.matchMedia("(display-mode: standalone)").matches&&c(),e||window.setTimeout(()=>{u()},500)):u())},[n,r,o,e,t,c,u]),{restorePositionSetting:u}}const qC=new WeakMap;function kt(n,e,t=!1){if(!n||!(n instanceof HTMLElement))return;let r={};Object.entries(e).forEach(([s,i])=>{if(s.startsWith("--")){n.style.setProperty(s,i);return}r[s]=n.style[s],n.style[s]=i}),!t&&qC.set(n,r)}function lp(n,e){if(!n||!(n instanceof HTMLElement))return;let t=qC.get(n);t&&(e?n.style[e]=t[e]:Object.entries(t).forEach(([r,s])=>{n.style[r]=s}))}const Gt=n=>{switch(n){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return n}};function cp(n,e){if(!n)return null;const t=window.getComputedStyle(n),r=t.transform||t.webkitTransform||t.mozTransform;let s=r.match(/^matrix3d\((.+)\)$/);return s?parseFloat(s[1].split(", ")[Gt(e)?13:12]):(s=r.match(/^matrix\((.+)\)$/),s?parseFloat(s[1].split(", ")[Gt(e)?5:4]):null)}function Xj(n){return 8*(Math.log(n+1)-2)}const mt={DURATION:.5,EASE:[.32,.72,0,1]},QC=.4;function YC(n){const e=L.useRef(n);return L.useEffect(()=>{e.current=n}),L.useMemo(()=>(...t)=>e.current==null?void 0:e.current.call(e,...t),[])}function Zj({defaultProp:n,onChange:e}){const t=L.useState(n),[r]=t,s=L.useRef(r),i=YC(e);return L.useEffect(()=>{s.current!==r&&(i(r),s.current=r)},[r,s,i]),t}function eU({prop:n,defaultProp:e,onChange:t=()=>{}}){const[r,s]=Zj({defaultProp:e,onChange:t}),i=n!==void 0,o=i?n:r,a=YC(t),l=L.useCallback(c=>{if(i){const f=typeof c=="function"?c(n):c;f!==n&&a(f)}else s(c)},[i,n,s,a]);return[o,l]}function tU({activeSnapPointProp:n,setActiveSnapPointProp:e,snapPoints:t,drawerRef:r,overlayRef:s,fadeFromIndex:i,onSnapPointChange:o,direction:a="bottom"}){const[l,c]=eU({prop:n,defaultProp:t==null?void 0:t[0],onChange:e}),u=L.useMemo(()=>l===(t==null?void 0:t[t.length-1])||null,[t,l]),f=t&&t.length>0&&(i||i===0)&&!Number.isNaN(i)&&t[i]===l||!t,d=L.useMemo(()=>t==null?void 0:t.findIndex(v=>v===l),[t,l]),h=L.useMemo(()=>{var v;return(v=t==null?void 0:t.map(w=>{const E=typeof window<"u",k=typeof w=="string";let S=0;if(k&&(S=parseInt(w,10)),Gt(a)){const O=k?S:E?w*window.innerHeight:0;return E?a==="bottom"?window.innerHeight-O:-window.innerHeight+O:O}const M=k?S:E?w*window.innerWidth:0;return E?a==="right"?window.innerWidth-M:-window.innerWidth+M:M}))!=null?v:[]},[t]),p=L.useMemo(()=>d!==null?h==null?void 0:h[d]:null,[h,d]),m=L.useCallback(v=>{var w;const E=(w=h==null?void 0:h.findIndex(k=>k===v))!=null?w:null;o(E),kt(r.current,{transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,transform:Gt(a)?`translate3d(0, ${v}px, 0)`:`translate3d(${v}px, 0, 0)`}),h&&E!==h.length-1&&E!==i?kt(s.current,{transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,opacity:"0"}):kt(s.current,{transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,opacity:"1"}),c(E!==null?t==null?void 0:t[E]:null)},[r.current,t,h,i,s,c]);L.useEffect(()=>{if(l||n){var v;const w=(v=t==null?void 0:t.findIndex(E=>E===n||E===l))!=null?v:-1;h&&w!==-1&&typeof h[w]=="number"&&m(h[w])}},[l,n,t,h,m]);function y({draggedDistance:v,closeDrawer:w,velocity:E,dismissible:k}){if(i===void 0)return;const S=a==="bottom"||a==="right"?(p??0)-v:(p??0)+v,M=d===i-1,O=d===0,R=v>0;if(M&&kt(s.current,{transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`}),E>2&&!R){k?w():m(h[0]);return}if(E>2&&R&&h&&t){m(h[t.length-1]);return}const D=h==null?void 0:h.reduce((U,K)=>typeof U!="number"||typeof K!="number"?U:Math.abs(K-S)<Math.abs(U-S)?K:U),F=Gt(a)?window.innerHeight:window.innerWidth;if(E>QC&&Math.abs(v)<F*.4){const U=R?1:-1;if(U>0&&u){m(h[t.length-1]);return}if(O&&U<0&&k&&w(),d===null)return;m(h[d+U]);return}m(D)}function b({draggedDistance:v}){if(p===null)return;const w=a==="bottom"||a==="right"?p-v:p+v;(a==="bottom"||a==="right")&&w<h[h.length-1]||(a==="top"||a==="left")&&w>h[h.length-1]||kt(r.current,{transform:Gt(a)?`translate3d(0, ${w}px, 0)`:`translate3d(${w}px, 0, 0)`})}function x(v,w){if(!t||typeof d!="number"||!h||i===void 0)return null;const E=d===i-1;if(d>=i&&w)return 0;if(E&&!w)return 1;if(!f&&!E)return null;const S=E?d+1:d-1,M=E?h[S]-h[S-1]:h[S+1]-h[S],O=v/Math.abs(M);return E?1-O:O}return{isLastSnapPoint:u,activeSnapPoint:l,shouldFade:f,getPercentageDragged:x,setActiveSnapPoint:c,activeSnapPointIndex:d,onRelease:y,onDrag:b,snapPointsOffset:h}}const nU=.25,rU=100,XC=8,ma=16,ZC=26,mb="vaul-dragging";function eS({open:n,onOpenChange:e,children:t,shouldScaleBackground:r,onDrag:s,onRelease:i,snapPoints:o,nested:a=!1,setBackgroundColorOnScale:l=!0,closeThreshold:c=nU,scrollLockTimeout:u=rU,dismissible:f=!0,handleOnly:d=!1,fadeFromIndex:h=o&&o.length-1,activeSnapPoint:p,setActiveSnapPoint:m,fixed:y,modal:b=!0,onClose:x,noBodyStyles:v,direction:w="bottom",preventScrollRestoration:E=!0,disablePreventScroll:k=!1}){var S;const[M=!1,O]=L.useState(!1),[R,D]=L.useState(!1),[F,U]=L.useState(!1),[K,_]=L.useState(!1),[G,Y]=L.useState(!1),[re,Z]=L.useState(!1),me=L.useRef(null),ke=L.useRef(null),Pe=L.useRef(null),Ce=L.useRef(null),Ee=L.useRef(null),Ue=L.useRef(!1),Fe=L.useRef(null),He=L.useRef(0),Le=L.useRef(!1),Ze=L.useRef(0),le=L.useRef(null),ze=L.useRef(((S=le.current)==null?void 0:S.getBoundingClientRect().height)||0),ae=L.useRef(0),be=L.useCallback(te=>{o&&te===ce.length-1&&(ke.current=new Date)},[]),{activeSnapPoint:_e,activeSnapPointIndex:z,setActiveSnapPoint:J,onRelease:ne,snapPointsOffset:ce,onDrag:P,shouldFade:g,getPercentageDragged:A}=tU({snapPoints:o,activeSnapPointProp:p,setActiveSnapPointProp:m,drawerRef:le,fadeFromIndex:h,overlayRef:me,onSnapPointChange:be,direction:w});Gj({isDisabled:!M||G||!b||re||!R||k});const{restorePositionSetting:N}=Yj({isOpen:M,modal:b,nested:a,hasBeenOpened:R,preventScrollRestoration:E,noBodyStyles:v});function B(){return(window.innerWidth-ZC)/window.innerWidth}function W(te){var se;!f&&!o||le.current&&!le.current.contains(te.target)||(ze.current=((se=le.current)==null?void 0:se.getBoundingClientRect().height)||0,Y(!0),Pe.current=new Date,VC()&&window.addEventListener("touchend",()=>Ue.current=!1,{once:!0}),te.target.setPointerCapture(te.pointerId),He.current=Gt(w)?te.clientY:te.clientX)}function Q(te,se){var Te;let he=te;const Ke=(Te=window.getSelection())==null?void 0:Te.toString(),et=le.current?cp(le.current,w):null,ht=new Date;if(he.hasAttribute("data-vaul-no-drag")||he.closest("[data-vaul-no-drag]"))return!1;if(w==="right"||w==="left")return!0;if(ke.current&&ht.getTime()-ke.current.getTime()<500)return!1;if(et!==null&&(w==="bottom"?et>0:et<0))return!0;if(Ke&&Ke.length>0)return!1;if(Ee.current&&ht.getTime()-Ee.current.getTime()<u&&et===0||se)return Ee.current=ht,!1;for(;he;){if(he.scrollHeight>he.clientHeight){if(he.scrollTop!==0)return Ee.current=new Date,!1;if(he.getAttribute("role")==="dialog")return!0}he=he.parentNode}return!0}function ye(te){if(le.current&&G){const se=w==="bottom"||w==="right"?1:-1,Te=(He.current-(Gt(w)?te.clientY:te.clientX))*se,he=Te>0,Ke=o&&!f&&!he;if(Ke&&z===0)return;const et=Math.abs(Te),ht=document.querySelector("[vaul-drawer-wrapper]");let Xt=et/ze.current;const It=A(et,he);if(It!==null&&(Xt=It),Ke&&Xt>=1||!Ue.current&&!Q(te.target,he))return;if(le.current.classList.add(mb),Ue.current=!0,kt(le.current,{transition:"none"}),kt(me.current,{transition:"none"}),o&&P({draggedDistance:Te}),he&&!o){const ir=Xj(Te),or=Math.min(ir*-1,0)*se;kt(le.current,{transform:Gt(w)?`translate3d(0, ${or}px, 0)`:`translate3d(${or}px, 0, 0)`});return}const gs=1-Xt;if((g||h&&z===h-1)&&(s==null||s(te,Xt),kt(me.current,{opacity:`${gs}`,transition:"none"},!0)),ht&&me.current&&r){const ir=Math.min(B()+Xt*(1-B()),1),or=8-Xt*8,Lu=Math.max(0,14-Xt*14);kt(ht,{borderRadius:`${or}px`,transform:Gt(w)?`scale(${ir}) translate3d(0, ${Lu}px, 0)`:`scale(${ir}) translate3d(${Lu}px, 0, 0)`,transition:"none"},!0)}if(!o){const ir=et*se;kt(le.current,{transform:Gt(w)?`translate3d(0, ${ir}px, 0)`:`translate3d(${ir}px, 0, 0)`})}}}L.useEffect(()=>()=>{ct(!1),N()},[]),L.useEffect(()=>{var te;function se(){if(!le.current)return;const Te=document.activeElement;if(pb(Te)||Le.current){var he;const Ke=((he=window.visualViewport)==null?void 0:he.height)||0;let et=window.innerHeight-Ke;const ht=le.current.getBoundingClientRect().height||0;ae.current||(ae.current=ht);const Xt=le.current.getBoundingClientRect().top;if(Math.abs(Ze.current-et)>60&&(Le.current=!Le.current),o&&o.length>0&&ce&&z){const It=ce[z]||0;et+=It}if(Ze.current=et,ht>Ke||Le.current){const It=le.current.getBoundingClientRect().height;let gs=It;It>Ke&&(gs=Ke-ZC),y?le.current.style.height=`${It-Math.max(et,0)}px`:le.current.style.height=`${Math.max(gs,Ke-Xt)}px`}else le.current.style.height=`${ae.current}px`;o&&o.length>0&&!Le.current?le.current.style.bottom="0px":le.current.style.bottom=`${Math.max(et,0)}px`}}return(te=window.visualViewport)==null||te.addEventListener("resize",se),()=>{var Te;return(Te=window.visualViewport)==null?void 0:Te.removeEventListener("resize",se)}},[z,o,ce]);function Se(){le.current&&(je(),x==null||x(),kt(le.current,{transform:Gt(w)?`translate3d(0, ${w==="bottom"?"100%":"-100%"}, 0)`:`translate3d(${w==="right"?"100%":"-100%"}, 0, 0)`,transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`}),kt(me.current,{opacity:"0",transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`}),ct(!1),setTimeout(()=>{U(!1),O(!1)},300),setTimeout(()=>{o&&J(o[0])},mt.DURATION*1e3))}L.useEffect(()=>{if(!M&&r){const te=setTimeout(()=>{lp(document.body)},200);return()=>clearTimeout(te)}},[M,r]),L.useLayoutEffect(()=>{n?(O(!0),D(!0)):Se()},[n]),L.useEffect(()=>{K&&(e==null||e(M))},[M]),L.useEffect(()=>{_(!0)},[]);function qe(){if(!le.current)return;const te=document.querySelector("[vaul-drawer-wrapper]"),se=cp(le.current,w);kt(le.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`}),kt(me.current,{transition:`opacity ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,opacity:"1"}),r&&se&&se>0&&M&&kt(te,{borderRadius:`${XC}px`,overflow:"hidden",...Gt(w)?{transform:`scale(${B()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${B()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${mt.DURATION}s`,transitionTimingFunction:`cubic-bezier(${mt.EASE.join(",")})`},!0)}function je(){!G||!le.current||(le.current.classList.remove(mb),Ue.current=!1,Y(!1),Ce.current=new Date)}function Be(te){if(!G||!le.current)return;le.current.classList.remove(mb),Ue.current=!1,Y(!1),Ce.current=new Date;const se=cp(le.current,w);if(!Q(te.target,!1)||!se||Number.isNaN(se)||Pe.current===null)return;const Te=Ce.current.getTime()-Pe.current.getTime(),he=He.current-(Gt(w)?te.clientY:te.clientX),Ke=Math.abs(he)/Te;if(Ke>.05&&(Z(!0),setTimeout(()=>{Z(!1)},200)),o){ne({draggedDistance:he*(w==="bottom"||w==="right"?1:-1),closeDrawer:Se,velocity:Ke,dismissible:f}),i==null||i(te,!0);return}if(w==="bottom"||w==="right"?he>0:he<0){qe(),i==null||i(te,!0);return}if(Ke>QC){Se(),i==null||i(te,!1);return}var et;const ht=Math.min((et=le.current.getBoundingClientRect().height)!=null?et:0,window.innerHeight);if(se>=ht*c){Se(),i==null||i(te,!1);return}i==null||i(te,!0),qe()}L.useEffect(()=>{M&&(kt(document.documentElement,{scrollBehavior:"auto"}),ke.current=new Date,ct(!0))},[M]),L.useEffect(()=>{if(le.current&&F){var te;const se=le==null||(te=le.current)==null?void 0:te.querySelectorAll("*");se==null||se.forEach(Te=>{const he=Te;(he.scrollHeight>he.clientHeight||he.scrollWidth>he.clientWidth)&&he.classList.add("vaul-scrollable")})}},[F]);function ct(te){const se=document.querySelector("[vaul-drawer-wrapper]");!se||!r||(te?(l&&(v||(kt(document.body,{background:document.body.style.backgroundColor||document.body.style.background}),kt(document.body,{background:"black"},!0))),kt(se,{borderRadius:`${XC}px`,overflow:"hidden",...Gt(w)?{transform:`scale(${B()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${B()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${mt.DURATION}s`,transitionTimingFunction:`cubic-bezier(${mt.EASE.join(",")})`})):(lp(se,"overflow"),lp(se,"transform"),lp(se,"borderRadius"),kt(se,{transitionProperty:"transform, border-radius",transitionDuration:`${mt.DURATION}s`,transitionTimingFunction:`cubic-bezier(${mt.EASE.join(",")})`})))}function Un(te){const se=te?(window.innerWidth-ma)/window.innerWidth:1,Te=te?-ma:0;Fe.current&&window.clearTimeout(Fe.current),kt(le.current,{transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,transform:`scale(${se}) translate3d(0, ${Te}px, 0)`}),!te&&le.current&&(Fe.current=setTimeout(()=>{const he=cp(le.current,w);kt(le.current,{transition:"none",transform:Gt(w)?`translate3d(0, ${he}px, 0)`:`translate3d(${he}px, 0, 0)`})},500))}function sr(te,se){if(se<0)return;const Te=Gt(w)?window.innerHeight:window.innerWidth,he=(Te-ma)/Te,Ke=he+se*(1-he),et=-ma+se*ma;kt(le.current,{transform:Gt(w)?`scale(${Ke}) translate3d(0, ${et}px, 0)`:`scale(${Ke}) translate3d(${et}px, 0, 0)`,transition:"none"})}function X(te,se){const Te=Gt(w)?window.innerHeight:window.innerWidth,he=se?(Te-ma)/Te:1,Ke=se?-ma:0;se&&kt(le.current,{transition:`transform ${mt.DURATION}s cubic-bezier(${mt.EASE.join(",")})`,transform:Gt(w)?`scale(${he}) translate3d(0, ${Ke}px, 0)`:`scale(${he}) translate3d(${Ke}px, 0, 0)`})}return L.createElement(FC,{modal:b,onOpenChange:te=>{if(n!==void 0){e==null||e(te);return}te?(D(!0),O(te)):Se()},open:M},L.createElement(zC.Provider,{value:{visible:F,activeSnapPoint:_e,snapPoints:o,setActiveSnapPoint:J,drawerRef:le,overlayRef:me,scaleBackground:ct,onOpenChange:e,onPress:W,setVisible:U,onRelease:Be,onDrag:ye,dismissible:f,handleOnly:d,isOpen:M,isDragging:G,shouldFade:g,closeDrawer:Se,onNestedDrag:sr,onNestedOpenChange:Un,onNestedRelease:X,keyboardIsOpen:Le,openProp:n,modal:b,snapPointsOffset:ce,direction:w}},t))}const sU=250,iU=120,tS=L.forwardRef(function({preventCycle:n=!1,children:e,...t},r){const{visible:s,closeDrawer:i,isDragging:o,snapPoints:a,activeSnapPoint:l,setActiveSnapPoint:c,dismissible:u,handleOnly:f,onPress:d,onDrag:h}=op(),p=L.useRef(null),m=L.useRef(!1);function y(){if(m.current){v();return}window.setTimeout(()=>{b()},iU)}function b(){if(o||n||m.current){v();return}if(v(),(!a||a.length===0)&&u){i();return}if(l===a[a.length-1]&&u){i();return}const E=a.findIndex(S=>S===l);if(E===-1)return;const k=a[E+1];c(k)}function x(){p.current=window.setTimeout(()=>{m.current=!0},sU)}function v(){window.clearTimeout(p.current),m.current=!1}return L.createElement("div",{onClick:y,onDoubleClick:()=>{m.current=!0,i()},onPointerCancel:v,onPointerDown:w=>{f&&d(w),x()},onPointerMove:w=>{f&&h(w)},ref:r,"vaul-drawer-visible":s?"true":"false","vaul-handle":"","aria-hidden":"true",...t},L.createElement("span",{"vaul-handle-hitarea":"","aria-hidden":"true"},e))});tS.displayName="Drawer.Handle";const nS=L.forwardRef(function({children:n,...e},t){const{overlayRef:r,snapPoints:s,onRelease:i,shouldFade:o,isOpen:a,visible:l}=op(),c=JC(t,r),u=s&&s.length>0;return L.createElement(ob,{onMouseUp:i,ref:c,"vaul-drawer-visible":l?"true":"false","vaul-overlay":"","vaul-snap-points":a&&u?"true":"false","vaul-snap-points-overlay":a&&o?"true":"false",...e})});nS.displayName="Drawer.Overlay";const rS=L.forwardRef(function({onOpenAutoFocus:n,onPointerDownOutside:e,onAnimationEnd:t,style:r,...s},i){const{drawerRef:o,onPress:a,onRelease:l,onDrag:c,dismissible:u,keyboardIsOpen:f,snapPointsOffset:d,visible:h,closeDrawer:p,modal:m,openProp:y,onOpenChange:b,setVisible:x,handleOnly:v,direction:w}=op(),E=JC(i,o),k=L.useRef(null),S=L.useRef(!1),M=(O,R,D=0)=>{if(S.current)return!0;const F=Math.abs(O.y),U=Math.abs(O.x),K=U>F,_=["bottom","right"].includes(R)?1:-1;if(R==="left"||R==="right"){if(!(O.x*_<0)&&U>=0&&U<=D)return K}else if(!(O.y*_<0)&&F>=0&&F<=D)return!K;return S.current=!0,!0};return L.useEffect(()=>{x(!0)},[]),L.createElement(ab,{"vaul-drawer":"","vaul-drawer-direction":w,"vaul-drawer-visible":h?"true":"false",...s,ref:E,style:d&&d.length>0?{"--snap-point-height":`${d[0]}px`,...r}:r,onOpenAutoFocus:O=>{if(n)n(O);else{var R;O.preventDefault(),(R=o.current)==null||R.focus()}},onPointerDown:O=>{v||(s.onPointerDown==null||s.onPointerDown.call(s,O),k.current={x:O.clientX,y:O.clientY},a(O))},onPointerDownOutside:O=>{if(e==null||e(O),!m||O.defaultPrevented){O.preventDefault();return}f.current&&(f.current=!1),O.preventDefault(),b==null||b(!1),!(!u||y!==void 0)&&p()},onFocusOutside:O=>{if(!m){O.preventDefault();return}},onEscapeKeyDown:O=>{if(!m){O.preventDefault();return}},onPointerMove:O=>{if(v||(s.onPointerMove==null||s.onPointerMove.call(s,O),!k.current))return;const R=O.clientY-k.current.y,D=O.clientX-k.current.x,F=O.pointerType==="touch"?10:2;M({x:D,y:R},w,F)?c(O):(Math.abs(D)>F||Math.abs(R)>F)&&(k.current=null)},onPointerUp:O=>{s.onPointerUp==null||s.onPointerUp.call(s,O),k.current=null,S.current=!1,l(O)}})});rS.displayName="Drawer.Content";function oU({onDrag:n,onOpenChange:e,...t}){const{onNestedDrag:r,onNestedOpenChange:s,onNestedRelease:i}=op();if(!r)throw new Error("Drawer.NestedRoot must be placed in another drawer");return L.createElement(eS,{nested:!0,onClose:()=>{s(!1)},onDrag:(o,a)=>{r(o,a),n==null||n(o,a)},onOpenChange:o=>{o&&s(o),e==null||e(o)},onRelease:i,...t})}const qr={Root:eS,NestedRoot:oU,Content:rS,Handle:tS,Overlay:nS,Trigger:jC,Portal:UC,Close:HC,Title:lb,Description:cb},sS=({shouldScaleBackground:n=!0,...e})=>C.jsx(qr.Root,{shouldScaleBackground:n,...e});sS.displayName="Drawer";const aU=qr.Trigger,lU=qr.Portal,iS=L.forwardRef(({className:n,...e},t)=>C.jsx(qr.Overlay,{ref:t,className:pe("fixed inset-0 z-50 bg-black/5 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...e}));iS.displayName=qr.Overlay.displayName;const oS=L.forwardRef(({className:n,children:e,...t},r)=>C.jsxs(lU,{children:[C.jsx(iS,{}),C.jsx(Ef,{trapped:!1,children:C.jsxs(qr.Content,{ref:r,className:pe("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-[16px] drop-shadow-2xl bg-white",n),...t,children:[C.jsx("div",{className:"mx-auto mt-4 h-2 w-[100px] rounded-full bg-white"}),e,C.jsx(qr.Close,{className:"absolute right-2 top-4 hover:bg-gray-200 rounded-full p-2 ring-offset-white transition focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2 disabled:pointer-events-none text-black data-[state=open]:bg-gray-100 data-[state=open]:text-black",children:C.jsx(l4,{size:20,fill:"black"})})]})})]}));oS.displayName="DrawerContent";const aS=({className:n,...e})=>C.jsx("div",{className:pe("grid gap-1.5 p-4 text-center sm:text-left",n),...e});aS.displayName="DrawerHeader";const lS=L.forwardRef(({className:n,...e},t)=>C.jsx(qr.Title,{ref:t,className:pe("text-lg font-semibold leading-none tracking-tight",n),...e}));lS.displayName=qr.Title.displayName;const cU=L.forwardRef(({className:n,...e},t)=>C.jsx(qr.Description,{ref:t,className:pe("text-sm text-black",n),...e}));cU.displayName=qr.Description.displayName;const cS=({title:n,content:e,contentClassName:t})=>C.jsxs(oS,{className:"w-full z-20",children:[C.jsx(aS,{className:"px-4 pt-0",children:C.jsx(lS,{className:"text-left sm:text-center text-base",children:n})}),C.jsx("div",{className:pe("flex flex-col gap-4 w-full h-full pb-4 text-base text-black",t),children:e&&e})]}),uU=FC,fU=jC,dU=UC,hU=HC,uS=H.forwardRef(({className:n,...e},t)=>C.jsx(ob,{ref:t,className:pe("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...e}));uS.displayName=ob.displayName;const fS=H.forwardRef(({className:n,children:e,...t},r)=>C.jsxs(dU,{children:[C.jsx(uS,{}),C.jsx(Ef,{trapped:!1,children:C.jsxs(ab,{ref:r,className:pe("fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 bg-white duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-xl",n),...t,children:[C.jsx("div",{}),e]})})]}));fS.displayName=ab.displayName;const dS=({className:n,...e})=>C.jsx("div",{className:pe("grid gap-1.5 p-4 text-center sm:text-left",n),...e});dS.displayName="DialogHeader";const hS=({className:n,...e})=>C.jsx("div",{className:pe("flex space-x-2",n),...e});hS.displayName="DialogFooter";const pS=H.forwardRef(({className:n,...e},t)=>C.jsx(lb,{ref:t,className:pe("text-lg font-semibold leading-none tracking-tight",n),...e}));pS.displayName=lb.displayName;const pU=H.forwardRef(({className:n,...e},t)=>C.jsx(cb,{ref:t,className:pe("text-sm text-black",n),...e}));pU.displayName=cb.displayName;function mU(n){return Object.prototype.toString.call(n)==="[object Object]"}function mS(n){return mU(n)||Array.isArray(n)}function gU(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function gb(n,e){const t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;const s=JSON.stringify(Object.keys(n.breakpoints||{})),i=JSON.stringify(Object.keys(e.breakpoints||{}));return s!==i?!1:t.every(o=>{const a=n[o],l=e[o];return typeof a=="function"?`${a}`==`${l}`:!mS(a)||!mS(l)?a===l:gb(a,l)})}function gS(n){return n.concat().sort((e,t)=>e.name>t.name?1:-1).map(e=>e.options)}function yU(n,e){if(n.length!==e.length)return!1;const t=gS(n),r=gS(e);return t.every((s,i)=>{const o=r[i];return gb(s,o)})}function yb(n){return typeof n=="number"}function bb(n){return typeof n=="string"}function wb(n){return typeof n=="boolean"}function yS(n){return Object.prototype.toString.call(n)==="[object Object]"}function Tt(n){return Math.abs(n)}function vb(n){return Math.sign(n)}function Tf(n,e){return Tt(n-e)}function bU(n,e){if(n===0||e===0||Tt(n)<=Tt(e))return 0;const t=Tf(Tt(n),Tt(e));return Tt(t/n)}function Nf(n){return Rf(n).map(Number)}function Qr(n){return n[Of(n)]}function Of(n){return Math.max(0,n.length-1)}function xb(n,e){return e===Of(n)}function bS(n,e=0){return Array.from(Array(n),(t,r)=>e+r)}function Rf(n){return Object.keys(n)}function wS(n,e){return[n,e].reduce((t,r)=>(Rf(r).forEach(s=>{const i=t[s],o=r[s],a=yS(i)&&yS(o);t[s]=a?wS(i,o):o}),t),{})}function Ab(n,e){return typeof e.MouseEvent<"u"&&n instanceof e.MouseEvent}function wU(n,e){const t={start:r,center:s,end:i};function r(){return 0}function s(l){return i(l)/2}function i(l){return e-l}function o(l,c){return bb(n)?t[n](l):n(e,l,c)}return{measure:o}}function Mf(){let n=[];function e(s,i,o,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(i,o,a),l=()=>s.removeEventListener(i,o,a);else{const c=s;c.addListener(o),l=()=>c.removeListener(o)}return n.push(l),r}function t(){n=n.filter(s=>s())}const r={add:e,clear:t};return r}function vU(n,e,t,r){const s=Mf(),i=1e3/60;let o=null,a=0,l=0;function c(){s.add(n,"visibilitychange",()=>{n.hidden&&p()})}function u(){h(),s.clear()}function f(y){if(!l)return;o||(o=y);const b=y-o;for(o=y,a+=b;a>=i;)t(),a-=i;const x=Tt(a/i);r(x),l&&e.requestAnimationFrame(f)}function d(){l||(l=e.requestAnimationFrame(f))}function h(){e.cancelAnimationFrame(l),o=null,a=0,l=0}function p(){o=null,a=0}return{init:c,destroy:u,start:d,stop:h,update:t,render:r}}function xU(n,e){const t=e==="rtl",r=n==="y",s=r?"y":"x",i=r?"x":"y",o=!r&&t?-1:1,a=u(),l=f();function c(p){const{height:m,width:y}=p;return r?m:y}function u(){return r?"top":t?"right":"left"}function f(){return r?"bottom":t?"left":"right"}function d(p){return p*o}return{scroll:s,cross:i,startEdge:a,endEdge:l,measureSize:c,direction:d}}function ga(n=0,e=0){const t=Tt(n-e);function r(c){return c<n}function s(c){return c>e}function i(c){return r(c)||s(c)}function o(c){return i(c)?r(c)?n:e:c}function a(c){return t?c-t*Math.ceil((c-e)/t):c}return{length:t,max:e,min:n,constrain:o,reachedAny:i,reachedMax:s,reachedMin:r,removeOffset:a}}function vS(n,e,t){const{constrain:r}=ga(0,n),s=n+1;let i=o(e);function o(d){return t?Tt((s+d)%s):r(d)}function a(){return i}function l(d){return i=o(d),f}function c(d){return u().set(a()+d)}function u(){return vS(n,a(),t)}const f={get:a,set:l,add:c,clone:u};return f}function AU(n,e,t,r,s,i,o,a,l,c,u,f,d,h,p,m,y,b,x){const{cross:v,direction:w}=n,E=["INPUT","SELECT","TEXTAREA"],k={passive:!1},S=Mf(),M=Mf(),O=ga(50,225).constrain(h.measure(20)),R={mouse:300,touch:400},D={mouse:500,touch:600},F=p?43:25;let U=!1,K=0,_=0,G=!1,Y=!1,re=!1,Z=!1;function me(ae){if(!x)return;function be(z){(wb(x)||x(ae,z))&&Fe(z)}const _e=e;S.add(_e,"dragstart",z=>z.preventDefault(),k).add(_e,"touchmove",()=>{},k).add(_e,"touchend",()=>{}).add(_e,"touchstart",be).add(_e,"mousedown",be).add(_e,"touchcancel",Le).add(_e,"contextmenu",Le).add(_e,"click",Ze,!0)}function ke(){S.clear(),M.clear()}function Pe(){const ae=Z?t:e;M.add(ae,"touchmove",He,k).add(ae,"touchend",Le).add(ae,"mousemove",He,k).add(ae,"mouseup",Le)}function Ce(ae){const be=ae.nodeName||"";return E.includes(be)}function Ee(){return(p?D:R)[Z?"mouse":"touch"]}function Ue(ae,be){const _e=f.add(vb(ae)*-1),z=u.byDistance(ae,!p).distance;return p||Tt(ae)<O?z:y&&be?z*.5:u.byIndex(_e.get(),0).distance}function Fe(ae){const be=Ab(ae,r);Z=be,re=p&&be&&!ae.buttons&&U,U=Tf(s.get(),o.get())>=2,!(be&&ae.button!==0)&&(Ce(ae.target)||(G=!0,i.pointerDown(ae),c.useFriction(0).useDuration(0),s.set(o),Pe(),K=i.readPoint(ae),_=i.readPoint(ae,v),d.emit("pointerDown")))}function He(ae){if(!Ab(ae,r)&&ae.touches.length>=2)return Le(ae);const _e=i.readPoint(ae),z=i.readPoint(ae,v),J=Tf(_e,K),ne=Tf(z,_);if(!Y&&!Z&&(!ae.cancelable||(Y=J>ne,!Y)))return Le(ae);const ce=i.pointerMove(ae);J>m&&(re=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(w(ce)),ae.preventDefault()}function Le(ae){const _e=u.byDistance(0,!1).index!==f.get(),z=i.pointerUp(ae)*Ee(),J=Ue(w(z),_e),ne=bU(z,J),ce=F-10*ne,P=b+ne/50;Y=!1,G=!1,M.clear(),c.useDuration(ce).useFriction(P),l.distance(J,!p),Z=!1,d.emit("pointerUp")}function Ze(ae){re&&(ae.stopPropagation(),ae.preventDefault(),re=!1)}function le(){return G}return{init:me,destroy:ke,pointerDown:le}}function EU(n,e){let r,s;function i(f){return f.timeStamp}function o(f,d){const p=`client${(d||n.scroll)==="x"?"X":"Y"}`;return(Ab(f,e)?f:f.touches[0])[p]}function a(f){return r=f,s=f,o(f)}function l(f){const d=o(f)-o(s),h=i(f)-i(r)>170;return s=f,h&&(r=f),d}function c(f){if(!r||!s)return 0;const d=o(s)-o(r),h=i(f)-i(r),p=i(f)-i(s)>170,m=d/h;return h&&!p&&Tt(m)>.1?m:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:o}}function kU(){function n(t){const{offsetTop:r,offsetLeft:s,offsetWidth:i,offsetHeight:o}=t;return{top:r,right:s+i,bottom:r+o,left:s,width:i,height:o}}return{measure:n}}function CU(n){function e(r){return n*(r/100)}return{measure:e}}function SU(n,e,t,r,s,i,o){let a,l,c=[],u=!1;function f(m){return s.measureSize(o.measure(m))}function d(m){if(!i)return;l=f(n),c=r.map(f);function y(x){for(const v of x){const w=v.target===n,E=r.indexOf(v.target),k=w?l:c[E],S=f(w?n:r[E]);if(Tt(S-k)>=.5){t.requestAnimationFrame(()=>{m.reInit(),e.emit("resize")});break}}}a=new ResizeObserver(x=>{u||(wb(i)||i(m,x))&&y(x)}),[n].concat(r).forEach(x=>a.observe(x))}function h(){a&&a.disconnect(),u=!0}return{init:d,destroy:h}}function TU(n,e,t,r,s){let i=0,o=0,a=r,l=s,c=n.get(),u=0;function f(){const E=t.get()-n.get(),k=!a;let S=0;return k?(i=0,n.set(t),S=E):(i+=E/a,i*=l,c+=i,n.add(i),S=c-u),o=vb(S),u=c,w}function d(){const E=t.get()-e.get();return Tt(E)<.001}function h(){return a}function p(){return o}function m(){return i}function y(){return x(r)}function b(){return v(s)}function x(E){return a=E,w}function v(E){return l=E,w}const w={direction:p,duration:h,velocity:m,seek:f,settled:d,useBaseFriction:b,useBaseDuration:y,useFriction:v,useDuration:x};return w}function NU(n,e,t,r,s){const i=s.measure(10),o=s.measure(50),a=ga(.1,.99);let l=!1;function c(){return!(l||!n.reachedAny(t.get())||!n.reachedAny(e.get()))}function u(h){if(!c())return;const p=n.reachedMin(e.get())?"min":"max",m=Tt(n[p]-e.get()),y=t.get()-e.get(),b=a.constrain(m/o);t.subtract(y*b),!h&&Tt(y)<i&&(t.set(n.constrain(t.get())),r.useDuration(25).useBaseFriction())}function f(h){l=!h}return{shouldConstrain:c,constrain:u,toggleActive:f}}function OU(n,e,t,r,s){const i=ga(-e+n,0),o=f(),a=u(),l=d();function c(p,m){return Tf(p,m)<1}function u(){const p=o[0],m=Qr(o),y=o.lastIndexOf(p),b=o.indexOf(m)+1;return ga(y,b)}function f(){return t.map((p,m)=>{const{min:y,max:b}=i,x=i.constrain(p),v=!m,w=xb(t,m);return v?b:w||c(y,x)?y:c(b,x)?b:x}).map(p=>parseFloat(p.toFixed(3)))}function d(){if(e<=n+s)return[i.max];if(r==="keepSnaps")return o;const{min:p,max:m}=a;return o.slice(p,m)}return{snapsContained:l,scrollContainLimit:a}}function RU(n,e,t){const r=e[0],s=t?r-n:Qr(e);return{limit:ga(s,r)}}function MU(n,e,t,r){const i=e.min+.1,o=e.max+.1,{reachedMin:a,reachedMax:l}=ga(i,o);function c(d){return d===1?l(t.get()):d===-1?a(t.get()):!1}function u(d){if(!c(d))return;const h=n*(d*-1);r.forEach(p=>p.add(h))}return{loop:u}}function DU(n){const{max:e,length:t}=n;function r(i){const o=i-e;return t?o/-t:0}return{get:r}}function PU(n,e,t,r,s){const{startEdge:i,endEdge:o}=n,{groupSlides:a}=s,l=f().map(e.measure),c=d(),u=h();function f(){return a(r).map(m=>Qr(m)[o]-m[0][i]).map(Tt)}function d(){return r.map(m=>t[i]-m[i]).map(m=>-Tt(m))}function h(){return a(c).map(m=>m[0]).map((m,y)=>m+l[y])}return{snaps:c,snapsAligned:u}}function IU(n,e,t,r,s,i){const{groupSlides:o}=s,{min:a,max:l}=r,c=u();function u(){const d=o(i),h=!n||e==="keepSnaps";return t.length===1?[i]:h?d:d.slice(a,l).map((p,m,y)=>{const b=!m,x=xb(y,m);if(b){const v=Qr(y[0])+1;return bS(v)}if(x){const v=Of(i)-Qr(y)[0]+1;return bS(v,Qr(y)[0])}return p})}return{slideRegistry:c}}function LU(n,e,t,r,s){const{reachedAny:i,removeOffset:o,constrain:a}=r;function l(p){return p.concat().sort((m,y)=>Tt(m)-Tt(y))[0]}function c(p){const m=n?o(p):a(p),y=e.map((x,v)=>({diff:u(x-m,0),index:v})).sort((x,v)=>Tt(x.diff)-Tt(v.diff)),{index:b}=y[0];return{index:b,distance:m}}function u(p,m){const y=[p,p+t,p-t];if(!n)return p;if(!m)return l(y);const b=y.filter(x=>vb(x)===m);return b.length?l(b):Qr(y)-t}function f(p,m){const y=e[p]-s.get(),b=u(y,m);return{index:p,distance:b}}function d(p,m){const y=s.get()+p,{index:b,distance:x}=c(y),v=!n&&i(y);if(!m||v)return{index:b,distance:p};const w=e[b]-x,E=p+u(w,0);return{index:b,distance:E}}return{byDistance:d,byIndex:f,shortcut:u}}function _U(n,e,t,r,s,i,o){function a(f){const d=f.distance,h=f.index!==e.get();i.add(d),d&&(r.duration()?n.start():(n.update(),n.render(1),n.update())),h&&(t.set(e.get()),e.set(f.index),o.emit("select"))}function l(f,d){const h=s.byDistance(f,d);a(h)}function c(f,d){const h=e.clone().set(f),p=s.byIndex(h.get(),d);a(p)}return{distance:l,index:c}}function BU(n,e,t,r,s,i,o){let a=0;function l(){i.add(document,"keydown",c,!1),e.forEach(u)}function c(d){d.code==="Tab"&&(a=new Date().getTime())}function u(d){const h=()=>{if(new Date().getTime()-a>10)return;n.scrollLeft=0;const y=e.indexOf(d),b=t.findIndex(x=>x.includes(y));yb(b)&&(s.useDuration(0),r.index(b,0),o.emit("slideFocus"))};i.add(d,"focus",h,{passive:!0,capture:!0})}return{init:l}}function up(n){let e=n;function t(){return e}function r(l){e=o(l)}function s(l){e+=o(l)}function i(l){e-=o(l)}function o(l){return yb(l)?l:l.get()}return{get:t,set:r,add:s,subtract:i}}function xS(n,e){const t=n.scroll==="x"?i:o,r=e.style;let s=!1;function i(f){return`translate3d(${f}px,0px,0px)`}function o(f){return`translate3d(0px,${f}px,0px)`}function a(f){s||(r.transform=t(n.direction(f)))}function l(f){s=!f}function c(){s||(r.transform="",e.getAttribute("style")||e.removeAttribute("style"))}return{clear:c,to:a,toggleActive:l}}function FU(n,e,t,r,s,i,o,a,l){const u=Nf(s),f=Nf(s).reverse(),d=b().concat(x());function h(S,M){return S.reduce((O,R)=>O-s[R],M)}function p(S,M){return S.reduce((O,R)=>h(O,M)>0?O.concat([R]):O,[])}function m(S){return i.map((M,O)=>({start:M-r[O]+.5+S,end:M+e-.5+S}))}function y(S,M,O){const R=m(M);return S.map(D=>{const F=O?0:-t,U=O?t:0,K=O?"end":"start",_=R[D][K];return{index:D,loopPoint:_,slideLocation:up(-1),translate:xS(n,l[D]),target:()=>a.get()>_?F:U}})}function b(){const S=o[0],M=p(f,S);return y(M,t,!1)}function x(){const S=e-o[0]-1,M=p(u,S);return y(M,-t,!0)}function v(){return d.every(({index:S})=>{const M=u.filter(O=>O!==S);return h(M,e)<=.1})}function w(){d.forEach(S=>{const{target:M,translate:O,slideLocation:R}=S,D=M();D!==R.get()&&(O.to(D),R.set(D))})}function E(){d.forEach(S=>S.translate.clear())}return{canLoop:v,clear:E,loop:w,loopPoints:d}}function jU(n,e,t){let r,s=!1;function i(l){if(!t)return;function c(u){for(const f of u)if(f.type==="childList"){l.reInit(),e.emit("slidesChanged");break}}r=new MutationObserver(u=>{s||(wb(t)||t(l,u))&&c(u)}),r.observe(n,{childList:!0})}function o(){r&&r.disconnect(),s=!0}return{init:i,destroy:o}}function UU(n,e,t,r){const s={};let i=null,o=null,a,l=!1;function c(){a=new IntersectionObserver(p=>{l||(p.forEach(m=>{const y=e.indexOf(m.target);s[y]=m}),i=null,o=null,t.emit("slidesInView"))},{root:n.parentElement,threshold:r}),e.forEach(p=>a.observe(p))}function u(){a&&a.disconnect(),l=!0}function f(p){return Rf(s).reduce((m,y)=>{const b=parseInt(y),{isIntersecting:x}=s[b];return(p&&x||!p&&!x)&&m.push(b),m},[])}function d(p=!0){if(p&&i)return i;if(!p&&o)return o;const m=f(p);return p&&(i=m),p||(o=m),m}return{init:c,destroy:u,get:d}}function HU(n,e,t,r,s,i){const{measureSize:o,startEdge:a,endEdge:l}=n,c=t[0]&&s,u=p(),f=m(),d=t.map(o),h=y();function p(){if(!c)return 0;const x=t[0];return Tt(e[a]-x[a])}function m(){if(!c)return 0;const x=i.getComputedStyle(Qr(r));return parseFloat(x.getPropertyValue(`margin-${l}`))}function y(){return t.map((x,v,w)=>{const E=!v,k=xb(w,v);return E?d[v]+u:k?d[v]+f:w[v+1][a]-x[a]}).map(Tt)}return{slideSizes:d,slideSizesWithGaps:h,startGap:u,endGap:f}}function zU(n,e,t,r,s,i,o,a,l){const{startEdge:c,endEdge:u,direction:f}=n,d=yb(t);function h(b,x){return Nf(b).filter(v=>v%x===0).map(v=>b.slice(v,v+x))}function p(b){return b.length?Nf(b).reduce((x,v,w)=>{const E=Qr(x)||0,k=E===0,S=v===Of(b),M=s[c]-i[E][c],O=s[c]-i[v][u],R=!r&&k?f(o):0,D=!r&&S?f(a):0,F=Tt(O-D-(M+R));return w&&F>e+l&&x.push(v),S&&x.push(b.length),x},[]).map((x,v,w)=>{const E=Math.max(w[v-1]||0);return b.slice(E,x)}):[]}function m(b){return d?h(b,t):p(b)}return{groupSlides:m}}function VU(n,e,t,r,s,i,o){const{align:a,axis:l,direction:c,startIndex:u,loop:f,duration:d,dragFree:h,dragThreshold:p,inViewThreshold:m,slidesToScroll:y,skipSnaps:b,containScroll:x,watchResize:v,watchSlides:w,watchDrag:E}=i,k=2,S=kU(),M=S.measure(e),O=t.map(S.measure),R=xU(l,c),D=R.measureSize(M),F=CU(D),U=wU(a,D),K=!f&&!!x,_=f||!!x,{slideSizes:G,slideSizesWithGaps:Y,startGap:re,endGap:Z}=HU(R,M,O,t,_,s),me=zU(R,D,y,f,M,O,re,Z,k),{snaps:ke,snapsAligned:Pe}=PU(R,U,M,O,me),Ce=-Qr(ke)+Qr(Y),{snapsContained:Ee,scrollContainLimit:Ue}=OU(D,Ce,Pe,x,k),Fe=K?Ee:Pe,{limit:He}=RU(Ce,Fe,f),Le=vS(Of(Fe),u,f),Ze=Le.clone(),le=Nf(t),ze=({dragHandler:qe,scrollBody:je,scrollBounds:Be,options:{loop:ct}})=>{ct||Be.constrain(qe.pointerDown()),je.seek()},ae=({scrollBody:qe,translate:je,location:Be,offsetLocation:ct,scrollLooper:Un,slideLooper:sr,dragHandler:X,animation:te,eventHandler:se,scrollBounds:Te,options:{loop:he}},Ke)=>{const et=qe.velocity(),ht=qe.settled(),Xt=!Te.shouldConstrain(),It=he?ht:ht&&Xt;It&&!X.pointerDown()&&(te.stop(),se.emit("settle")),It||se.emit("scroll"),ct.set(Be.get()-et+et*Ke),he&&(Un.loop(qe.direction()),sr.loop()),je.to(ct.get())},be=vU(r,s,()=>ze(Se),qe=>ae(Se,qe)),_e=.68,z=Fe[Le.get()],J=up(z),ne=up(z),ce=up(z),P=TU(J,ne,ce,d,_e),g=LU(f,Fe,Ce,He,ce),A=_U(be,Le,Ze,P,g,ce,o),N=DU(He),B=Mf(),W=UU(e,t,o,m),{slideRegistry:Q}=IU(K,x,Fe,Ue,me,le),ye=BU(n,t,Q,A,P,B,o),Se={ownerDocument:r,ownerWindow:s,eventHandler:o,containerRect:M,slideRects:O,animation:be,axis:R,dragHandler:AU(R,n,r,s,ce,EU(R,s),J,be,A,P,g,Le,o,F,h,p,b,_e,E),eventStore:B,percentOfView:F,index:Le,indexPrevious:Ze,limit:He,location:J,offsetLocation:ne,options:i,resizeHandler:SU(e,o,s,t,R,v,S),scrollBody:P,scrollBounds:NU(He,ne,ce,P,F),scrollLooper:MU(Ce,He,ne,[J,ne,ce]),scrollProgress:N,scrollSnapList:Fe.map(N.get),scrollSnaps:Fe,scrollTarget:g,scrollTo:A,slideLooper:FU(R,D,Ce,G,Y,ke,Fe,ne,t),slideFocus:ye,slidesHandler:jU(e,o,w),slidesInView:W,slideIndexes:le,slideRegistry:Q,slidesToScroll:me,target:ce,translate:xS(R,e)};return Se}function $U(){let n={},e;function t(c){e=c}function r(c){return n[c]||[]}function s(c){return r(c).forEach(u=>u(e,c)),l}function i(c,u){return n[c]=r(c).concat([u]),l}function o(c,u){return n[c]=r(c).filter(f=>f!==u),l}function a(){n={}}const l={init:t,emit:s,off:o,on:i,clear:a};return l}const WU={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0};function GU(n){function e(i,o){return wS(i,o||{})}function t(i){const o=i.breakpoints||{},a=Rf(o).filter(l=>n.matchMedia(l).matches).map(l=>o[l]).reduce((l,c)=>e(l,c),{});return e(i,a)}function r(i){return i.map(o=>Rf(o.breakpoints||{})).reduce((o,a)=>o.concat(a),[]).map(n.matchMedia)}return{mergeOptions:e,optionsAtMedia:t,optionsMediaQueries:r}}function KU(n){let e=[];function t(i,o){return e=o.filter(({options:a})=>n.optionsAtMedia(a).active!==!1),e.forEach(a=>a.init(i,n)),o.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function r(){e=e.filter(i=>i.destroy())}return{init:t,destroy:r}}function fp(n,e,t){const r=n.ownerDocument,s=r.defaultView,i=GU(s),o=KU(i),a=Mf(),l=$U(),{mergeOptions:c,optionsAtMedia:u,optionsMediaQueries:f}=i,{on:d,off:h,emit:p}=l,m=D;let y=!1,b,x=c(WU,fp.globalOptions),v=c(x),w=[],E,k,S;function M(){const{container:ze,slides:ae}=v;k=(bb(ze)?n.querySelector(ze):ze)||n.children[0];const _e=bb(ae)?k.querySelectorAll(ae):ae;S=[].slice.call(_e||k.children)}function O(ze){const ae=VU(n,k,S,r,s,ze,l);if(ze.loop&&!ae.slideLooper.canLoop()){const be=Object.assign({},ze,{loop:!1});return O(be)}return ae}function R(ze,ae){y||(x=c(x,ze),v=u(x),w=ae||w,M(),b=O(v),f([x,...w.map(({options:be})=>be)]).forEach(be=>a.add(be,"change",D)),v.active&&(b.translate.to(b.location.get()),b.animation.init(),b.slidesInView.init(),b.slideFocus.init(),b.eventHandler.init(le),b.resizeHandler.init(le),b.slidesHandler.init(le),b.options.loop&&b.slideLooper.loop(),k.offsetParent&&S.length&&b.dragHandler.init(le),E=o.init(le,w)))}function D(ze,ae){const be=ke();F(),R(c({startIndex:be},ze),ae),l.emit("reInit")}function F(){b.dragHandler.destroy(),b.eventStore.clear(),b.translate.clear(),b.slideLooper.clear(),b.resizeHandler.destroy(),b.slidesHandler.destroy(),b.slidesInView.destroy(),b.animation.destroy(),o.destroy(),a.clear()}function U(){y||(y=!0,a.clear(),F(),l.emit("destroy"),l.clear())}function K(ze,ae,be){!v.active||y||(b.scrollBody.useBaseFriction().useDuration(ae===!0?0:v.duration),b.scrollTo.index(ze,be||0))}function _(ze){const ae=b.index.add(1).get();K(ae,ze,-1)}function G(ze){const ae=b.index.add(-1).get();K(ae,ze,1)}function Y(){return b.index.add(1).get()!==ke()}function re(){return b.index.add(-1).get()!==ke()}function Z(){return b.scrollSnapList}function me(){return b.scrollProgress.get(b.location.get())}function ke(){return b.index.get()}function Pe(){return b.indexPrevious.get()}function Ce(){return b.slidesInView.get()}function Ee(){return b.slidesInView.get(!1)}function Ue(){return E}function Fe(){return b}function He(){return n}function Le(){return k}function Ze(){return S}const le={canScrollNext:Y,canScrollPrev:re,containerNode:Le,internalEngine:Fe,destroy:U,off:h,on:d,emit:p,plugins:Ue,previousScrollSnap:Pe,reInit:m,rootNode:He,scrollNext:_,scrollPrev:G,scrollProgress:me,scrollSnapList:Z,scrollTo:K,selectedScrollSnap:ke,slideNodes:Ze,slidesInView:Ce,slidesNotInView:Ee};return R(e,t),setTimeout(()=>l.emit("init"),0),le}fp.globalOptions=void 0;function Eb(n={},e=[]){const t=L.useRef(n),r=L.useRef(e),[s,i]=L.useState(),[o,a]=L.useState(),l=L.useCallback(()=>{s&&s.reInit(t.current,r.current)},[s]);return L.useEffect(()=>{if(gU()&&o){fp.globalOptions=Eb.globalOptions;const c=fp(o,t.current,r.current);return i(c),()=>c.destroy()}else i(void 0)},[o,i]),L.useEffect(()=>{gb(t.current,n)||(t.current=n,l())},[n,l]),L.useEffect(()=>{yU(r.current,e)||(r.current=e,l())},[e,l]),[a,s]}Eb.globalOptions=void 0;const AS=L.createContext(null);function Df(){const n=L.useContext(AS);if(!n)throw new Error("useCarousel must be used within a <Carousel />");return n}const ES=L.forwardRef(({orientation:n="horizontal",opts:e,setApi:t,plugins:r,className:s,children:i,...o},a)=>{const[l,c]=Eb({...e,axis:n==="horizontal"?"x":"y"},r),[u,f]=L.useState(!1),[d,h]=L.useState(!1),p=L.useCallback(x=>{x&&(f(x.canScrollPrev()),h(x.canScrollNext()))},[]),m=L.useCallback(()=>{c==null||c.scrollPrev()},[c]),y=L.useCallback(()=>{c==null||c.scrollNext()},[c]),b=L.useCallback(x=>{x.key==="ArrowLeft"?(x.preventDefault(),m()):x.key==="ArrowRight"&&(x.preventDefault(),y())},[m,y]);return L.useEffect(()=>{!c||!t||t(c)},[c,t]),L.useEffect(()=>{if(c)return p(c),c.on("reInit",p),c.on("select",p),()=>{c==null||c.off("select",p)}},[c,p]),C.jsx(AS.Provider,{value:{carouselRef:l,api:c,opts:e,orientation:n||((e==null?void 0:e.axis)==="y"?"vertical":"horizontal"),scrollPrev:m,scrollNext:y,canScrollPrev:u,canScrollNext:d},children:C.jsx("div",{ref:a,onKeyDownCapture:b,className:pe("relative",s),role:"region","aria-roledescription":"carousel",...o,children:i})})});ES.displayName="Carousel";const kS=L.forwardRef(({className:n,...e},t)=>{const{carouselRef:r,orientation:s}=Df();return C.jsx("div",{ref:r,className:"overflow-hidden",children:C.jsx("div",{ref:t,className:pe("flex",s==="horizontal"?"-ml-4":"-mt-4 flex-col",n),...e})})});kS.displayName="CarouselContent";const kb=L.forwardRef(({className:n,...e},t)=>{const{orientation:r}=Df();return C.jsx("div",{ref:t,role:"group","aria-roledescription":"slide",className:pe("min-w-0 shrink-0 grow-0 basis-full",r==="horizontal"?"pl-4":"pt-4",n),...e})});kb.displayName="CarouselItem";const CS=L.forwardRef(({index:n,className:e,...t},r)=>{const{api:s}=Df(),[i,o]=L.useState(0),[,a]=L.useState([]),l=L.useCallback(d=>{s&&s.scrollTo(d)},[s]),c=L.useCallback(d=>{d&&a(d.scrollSnapList())},[]),u=L.useCallback(d=>{d&&o(d.selectedScrollSnap())},[]);L.useEffect(()=>{s&&(c(s),u(s),s.on("reInit",c),s.on("reInit",u),s.on("select",u))},[s,c,u]);const f=i===n;return C.jsx("button",{ref:r,className:pe("w-2 h-2 transition-colors duration-200 rounded-full",f?"bg-black":"bg-[#E8EBEC] hover:bg-black/50",e),onClick:()=>l(n),...t})});CS.displayName="CarouselIndicator";const JU=L.forwardRef(({className:n,...e},t)=>{const{scrollPrev:r,canScrollPrev:s}=Df();return C.jsx("button",{ref:t,className:pe("btn bg-white hover:bg-[#F2F4F5] transition text-black flex items-center border-2 rounded h-9 px-4 py-2 text-sm font-medium disabled:bg-[#E8EBEC] disabled:text-[#A1AAB1]",n),disabled:!s,onClick:r,...e,children:C.jsx("span",{children:"Back"})})});JU.displayName="CarouselPrevious";const qU=L.forwardRef(({className:n,...e},t)=>{const{scrollNext:r,canScrollNext:s}=Df();return C.jsx("button",{ref:t,className:pe("btn bg-black hover:bg-black text-white flex items-center border-2 rounded h-9 px-4 py-2 text-sm font-medium disabled:bg-[#E8EBEC] disabled:text-[#A1AAB1]",n),disabled:!s,onClick:r,...e,children:C.jsx("span",{children:"Next"})})});qU.displayName="CarouselNext";const dp=H.forwardRef(({className:n,label:e,type:t="text",isValid:r=!0,message:s,onChange:i,leftIcon:o,rightIcon:a,...l},c)=>{const u=H.useRef(null),f=Or(c,u),d=H.useCallback(()=>{var m;(m=u.current)==null||m.focus()},[]),h=H.useMemo(()=>{if(o==null)return;const m=H.Children.only(o);if(H.isValidElement(m))return H.cloneElement(m,{...m.props,onClick:y=>{var b,x;(x=(b=m.props).onClick)==null||x.call(b,y),d()},className:pe("absolute left-3 text-[#A1AAB1]",{"cursor-not-allowed":l.disabled})})},[d,o,l.disabled]),p=H.useMemo(()=>{if(a==null)return;const m=H.Children.only(a);if(H.isValidElement(m))return H.cloneElement(m,{...m.props,onClick:y=>{var b,x;(x=(b=m.props).onClick)==null||x.call(b,y),d()},className:pe("absolute right-3 cursor-pointer text-[#A1AAB1]",{"cursor-not-allowed":l.disabled},{"text-red-500":!r})})},[d,a,l.disabled,r]);return C.jsxs("div",{className:"flex flex-col",children:[e?C.jsx("label",{className:"mb-2 text-sm font-medium",children:e}):null,C.jsxs("div",{className:"relative flex items-center group",children:[h,C.jsx("input",{type:t,className:pe("flex h-9 w-full rounded border-[1px] border-[#E8EBEC] hover:border-black bg-transparent px-3 py-2 text-sm text-black transition-colors file:border-0 file:bg-transparent file:text-sm placeholder:text-[#A1AAB1] focus-visible:outline-none focus-visible:border-black",{"pr-3 pl-10":h},{"pr-10":p},{"border-red-500":!r},{"disabled:cursor-not-allowed disabled:bg-[#E8EBEC] disabled:border-[#A1AAB1] disabled:text-[#A1AAB1]":l.disabled},n),onChange:i,ref:f,...l}),p]}),s?C.jsx("p",{className:pe("text-sm mt-2 font-normal text-wrap text-justify",{"text-red-500":!r,"text-black":r}),children:s}):null]})});dp.displayName="TextField";const Pf=L.forwardRef(({active:n,buttonSize:e="medium",children:t,disabled:r,variant:s="primary",className:i,activeClassname:o,isLoading:a=!1,...l},c)=>{const u=pe("flex items-center justify-center border-2 gap-2 transition text-sm font-semibold rounded disabled:opacity-50 whitespace-nowrap",s==="primary"&&pe("text-white bg-black border-black",!r&&!n&&"hover:bg-neutral-800 active:bg-neutral-900",n&&pe("bg-neutral-900 dark:bg-neutral-300",o)),s==="secondary"&&pe("text-neutral-900 border-black",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200",n&&"bg-neutral-200"),s==="tertiary"&&pe("bg-neutral-50 text-neutral-900 border-transparent",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200",n&&pe("bg-neutral-200",o)),s==="ghost"&&pe("bg-transparent border-transparent text-neutral-900",!r&&!n&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10",n&&pe("bg-black/10",o)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",i);return C.jsx("button",{ref:c,disabled:r,className:u,...l,children:a?C.jsx(t4,{size:20,className:"animate-spin",fill:"transparent",stroke:"currentColor"}):t})});Pf.displayName="Button";const SS=[{title:"Trebuchet MS",value:"Trebuchet MS, sans-serif",command:n=>{n.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",value:"Verdana, Geneva, sans-serif",command:n=>{n.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",value:"Georgia, serif",command:n=>{n.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",value:"Arial, Helvetica, sans-serif",command:n=>{n.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",value:"Comic Sans MS, Comic Sans",command:n=>{n.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",value:"Impact, Charcoal, sans-serif",command:n=>{n.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",value:"Palatino Linotype, Book Antiqua, Palatino, serif",command:n=>{n.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",value:"Lucida Sans Unicode, Lucida Grande, sans-serif",command:n=>{n.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",value:"serif",command:n=>{n.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",value:"monospace",command:n=>{n.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",value:"cursive",command:n=>{n.chain().focus().setFontFamily("cursive").run()}}],Cb=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}],Sb=({editor:n})=>{const{ref:e,toolVisibilty:t,setToolVisibility:r}=f4(Re.NONE),s=[{icon:C.jsx(Fk,{size:20}),title:"Text Color",onClick:()=>r(Re.TEXT_COLOR),isActive:t===Re.TEXT_COLOR},{icon:C.jsx(Uk,{size:20}),title:"Highlight",onClick:()=>r(Re.HIGHLIGHT),isActive:t===Re.HIGHLIGHT},null,{icon:C.jsx(L0,{size:20}),title:"Bold",onClick:()=>n==null?void 0:n.chain().focus().toggleBold().run(),isActive:n==null?void 0:n.isActive("bold")},{icon:C.jsx(_0,{size:20}),title:"Italic",onClick:()=>n==null?void 0:n.chain().focus().toggleItalic().run(),isActive:n==null?void 0:n.isActive("italic")},{icon:C.jsx(H0,{size:20}),title:"Underlined",onClick:()=>n==null?void 0:n.chain().focus().toggleUnderline().run(),isActive:n==null?void 0:n.isActive("underline")},{icon:C.jsx(j0,{size:20}),title:"Strikethrough",onClick:()=>n==null?void 0:n.chain().focus().toggleStrike().run(),isActive:n==null?void 0:n.isActive("strike")},null,{icon:C.jsx(Gh,{size:20}),title:"List",onClick:()=>{n==null||n.chain().focus().toggleBulletList().run(),r(Re.NONE)},isActive:n==null?void 0:n.isActive("bulletList")},{icon:C.jsx(Wl,{size:20}),title:"Ordered List",onClick:()=>{n==null||n.chain().focus().toggleOrderedList().run(),r(Re.NONE)},isActive:n==null?void 0:n.isActive("orderedList")},{icon:C.jsx(F0,{size:20}),title:"To-do List",onClick:()=>{n==null||n.chain().focus().toggleTaskList().run(),r(Re.NONE)},isActive:n==null?void 0:n.isActive("taskList")},{icon:C.jsx(vf,{size:20}),title:"Alignment",onClick:()=>r(Re.ALIGNMENT),isActive:t===Re.ALIGNMENT},{icon:C.jsx(Kh,{size:20}),title:"Quote",onClick:()=>n==null?void 0:n.chain().focus().toggleBlockquote().run(),isActive:n==null?void 0:n.isActive("blockquote")},null,{icon:C.jsx(Hk,{size:20}),title:"Upload Image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.state.selection).run();const o=document.createElement("input");o.type="file",o.accept="image/*",o.onchange=async()=>{var a;if((a=o.files)!=null&&a.length){const l=o.files[0],c=n.view.state.selection.from;z0(l,n.view,c)}},o.click()},isActive:!1},{icon:C.jsx(B0,{size:20}),title:"Link",onClick:()=>r(Re.LINK),isActive:n==null?void 0:n.isActive("link")},{icon:C.jsx(Af,{size:20}),title:"Code",onClick:()=>n==null?void 0:n.chain().focus().toggleCodeBlock().run(),isActive:n==null?void 0:n.isActive("codeBlock")}],i=[{icon:C.jsx(U0,{size:24}),title:"Text formating",onClick:()=>r(Re.TEXT_FORMATING),isActive:t===Re.TEXT_FORMATING},{icon:C.jsx(Fk,{size:24}),title:"Text color",onClick:()=>r(Re.TEXT_COLOR_PICKER),isActive:t===Re.TEXT_COLOR_PICKER},{icon:C.jsx(Vk,{size:24}),title:"Add table",onClick:()=>n==null?void 0:n.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),isActive:t===Re.TEXT_COLOR},{icon:C.jsx(F0,{size:24}),title:"To-do list",onClick:()=>{n==null||n.chain().focus().toggleTaskList().run(),r(Re.NONE)},isActive:t===Re.LIST},{icon:C.jsx(Hk,{size:24}),title:"Add image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.state.selection).run();const o=document.createElement("input");o.type="file",o.accept="image/*",o.onchange=async()=>{var a;if((a=o.files)!=null&&a.length){const l=o.files[0],c=n.view.state.selection.from;z0(l,n.view,c)}},o.click()},isActive:!1}];return{toolbar:s,bottomToolbar:i,toolRef:e,toolVisibilty:t,setToolVisibility:r}},TS=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return C.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-14 flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[C.jsx(I0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetHighlight().run(),e(Re.NONE)}}),r.map(s=>C.jsx("div",{onClick:()=>{n.chain().focus().toggleHighlight({color:s.color}).run(),e(Re.NONE)},className:pe("w-6 drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",s.code),children:C.jsx(xf,{size:14,className:pe(n.isActive("highlight",{color:s.color})?"visible":"invisible")})},s.color))]})},QU=({elementRef:n,editor:e,setToolVisibility:t})=>C.jsx("div",{ref:n,className:pe("z-50 h-auto absolute top-14 left-0 max-h-[330px] w-48 overflow-y-auto scroll-smooth bg-white px-1 py-2 shadow-lg transition-all rounded animate-in fade-in slide-in-from-top-1"),children:SS.map(r=>C.jsx("button",{onClick:()=>{r.command(e),t(Re.NONE)},style:{fontFamily:r.title},className:pe("flex w-full items-center space-x-2 rounded px-2 py-1 text-left text-sm text-black transition",e.isActive("textStyle",{fontFamily:r.value})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:C.jsx("p",{className:"font-medium",children:r.title})},r.title))}),NS=({elementRef:n,editor:e,setToolVisibility:t})=>C.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-14 left-[60%] translate-x-1/2 flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[C.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),t(Re.NONE)},className:pe("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"left"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:C.jsx(vf,{})}),C.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),t(Re.NONE)},className:pe("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"center"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:C.jsx(D0,{})}),C.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),t(Re.NONE)},className:pe("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer transition",e.isActive({textAlign:"right"})?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:C.jsx(P0,{})})]}),YU=({elementRef:n,editor:e,setToolVisibility:t})=>C.jsxs("div",{ref:n,className:pe("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all"),children:[C.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:C.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),t(Re.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:C.jsx(Gh,{size:20})})}),C.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:C.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),t(Re.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:C.jsx(Wl,{size:20})})}),C.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:C.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),t(Re.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:C.jsx(F0,{size:20})})})]}),OS=({elementRef:n,editor:e,setToolVisibility:t,bubbleMenu:r,setIsLinkPopupOpen:s})=>{const[i,o]=L.useState(e.getAttributes("link").href),a=()=>{if(i===null)return;if(i===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let l=i;!i.startsWith("http://")&&!i.startsWith("https://")&&(l="https://"+i);try{l.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:l}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:l}).run(),t(Re.NONE),r&&s&&s(!1)};return C.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-14 translate-x-1/2 items-center flex max-h-[330px] overflow-y-auto scroll-smooth rounded-lg bg-white p-2 shadow-lg transition-all",children:[C.jsx(dp,{onChange:l=>o(l.target.value),className:"w-full",placeholder:"Add link here",value:i}),C.jsx("div",{className:"h-full flex items-center",children:C.jsx(Pf,{variant:"secondary",onClick:()=>a(),className:"min-w-fit h-[36px]",children:"Apply"})})]})},XU=({editor:n,setVisibility:e,elementRef:t})=>C.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-14 flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-lg transition-all",children:[C.jsx(I0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run(),e(Re.NONE)}}),Cb.map(r=>C.jsx("div",{onClick:()=>{n.chain().focus().setColor(r.color).run(),e(Re.NONE)},className:pe("w-6 drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",r.code),children:C.jsx(xf,{size:14,className:pe(n.isActive("textStyle",{color:r.color})?"visible":"invisible")})},r.color))]}),ZU=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{title:"Text",description:"Normal",icon:C.jsx(U0,{size:20}),command:s=>s.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:C.jsx(Vh,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:1}).run()},isActive:()=>n.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:C.jsx($h,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:2}).run()},isActive:()=>n.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:C.jsx(Wh,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:3}).run()},isActive:()=>n.isActive("heading",{level:3})}];return C.jsx("div",{ref:t,className:pe("absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded bg-white p-1 shadow-lg animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(s=>C.jsxs("button",{onClick:()=>{s.command(n),e(Re.NONE)},className:pe("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-black transition",{"bg-yellow-300 hover:brightness-90":s.isActive(),"hover:bg-[#f2f2f2]":!s.isActive()}),children:[C.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded bg-white",children:s.icon}),C.jsxs("div",{children:[C.jsx("p",{className:"font-medium",children:s.title}),C.jsxs("p",{className:"text-xs text-stone-500",children:[" ",s.description," "]})]})]},s.title))})},e8=({editor:n,setToolVisibility:e})=>{const t=[{title:"Text",description:"Normal",icon:C.jsx(U0,{size:20}),command:r=>r.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:C.jsx(Vh,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:1}).run()},isActive:()=>n.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:C.jsx($h,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:2}).run()},isActive:()=>n.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:C.jsx(Wh,{size:20}),command:r=>{r.chain().focus().toggleHeading({level:3}).run()},isActive:()=>n.isActive("heading",{level:3})}];return C.jsx(cS,{title:"Text formating",content:C.jsxs("div",{className:"px-4 flex flex-col gap-2 w-full",children:[C.jsx("div",{className:"flex justify-start sm:justify-center items-center gap-1",children:t.map(r=>C.jsx("button",{onClick:()=>r.command(n),className:pe("flex w-fit items-center font-medium space-x-2 rounded p-2 text-center text-sm text-black transition",{"bg-yellow-300 hover:brightness-90":r.isActive(),"hover:bg-[#f2f2f2]":!r.isActive()}),children:r.title},r.title))}),C.jsxs("div",{className:"flex justify-between sm:justify-center items-center gap-1",children:[C.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-2 justify-evenly w-full sm:w-fit p-2",children:[C.jsx("button",{onClick:()=>{n==null||n.chain().focus().setTextAlign("left").run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive({textAlign:"left"}),"hover:bg-[#f2f2f2]":!n.isActive({textAlign:"left"})}),children:C.jsx(vf,{size:20})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().setTextAlign("center").run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive({textAlign:"center"}),"hover:bg-[#f2f2f2]":!n.isActive({textAlign:"center"})}),children:C.jsx(D0,{size:20})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().setTextAlign("right").run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive({textAlign:"right"}),"hover:bg-[#f2f2f2]":!n.isActive({textAlign:"right"})}),children:C.jsx(P0,{size:20})})]}),C.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-2 justify-evenly w-full sm:w-fit p-2",children:[C.jsx(fU,{asChild:!0,children:C.jsx("button",{onClick:()=>e(Re.LINK_POPUP),className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("link"),"hover:bg-[#f2f2f2]":!n.isActive("link")}),children:C.jsx(B0,{size:20})})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().toggleCodeBlock().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("codeBlock"),"hover:bg-[#f2f2f2]":!n.isActive("codeBlock")}),children:C.jsx(Af,{size:20})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().toggleBlockquote().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("blockquote"),"hover:bg-[#f2f2f2]":!n.isActive("blockquote")}),children:C.jsx(Kh,{size:20})})]})]}),C.jsxs("div",{className:"flex justify-between sm:justify-center items-center gap-1",children:[C.jsxs("div",{className:"bg-[#f8f9fa] rounded flex gap-2 justify-evenly w-full sm:w-fit p-2",children:[C.jsx("button",{onClick:()=>{n.chain().focus().toggleBold().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("bold"),"hover:bg-[#f2f2f2]":!n.isActive("bold")}),children:C.jsx(L0,{size:20})}),C.jsx("button",{onClick:()=>{n.chain().focus().toggleItalic().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("italic"),"hover:bg-[#f2f2f2]":!n.isActive("italic")}),children:C.jsx(_0,{size:20})}),C.jsx("button",{onClick:()=>{n.chain().focus().toggleUnderline().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("underline"),"hover:bg-[#f2f2f2]":!n.isActive("bold")}),children:C.jsx(H0,{size:20})}),C.jsx("button",{onClick:()=>{n.chain().focus().toggleStrike().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("strike"),"hover:bg-[#f2f2f2]":!n.isActive("bold")}),children:C.jsx(j0,{size:20})})]}),C.jsxs("div",{className:"bg-[#f8f9fa] rounded flex flex-[0.5] sm:flex-none gap-2 justify-evenly w-full sm:w-fit p-2",children:[C.jsx("button",{onClick:()=>{n==null||n.chain().focus().toggleBulletList().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("bulletList"),"hover:bg-[#f2f2f2]":!n.isActive("bulletList")}),children:C.jsx(Gh,{size:20})}),C.jsx("button",{onClick:()=>{n==null||n.chain().focus().toggleOrderedList().run()},className:pe("flex items-center space-x-2 rounded px-2 py-1 text-black transition h-8",{"bg-yellow-300 hover:brightness-90":n.isActive("orderedList"),"hover:bg-[#f2f2f2]":!n.isActive("orderedList")}),children:C.jsx(Wl,{size:20})})]})]})]})})},t8=({editor:n})=>C.jsx(cS,{title:"Text color",content:C.jsxs(ES,{opts:{align:"start",dragFree:!0,slidesToScroll:"auto"},className:"w-full max-w-md px-4 mx-auto",children:[C.jsxs(kS,{children:[C.jsx(kb,{style:{flexBasis:"calc(100% / 12)"},children:C.jsx(I0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run()}})}),Cb.map((e,t)=>C.jsx(kb,{style:{flexBasis:"calc(100% / 12)"},children:C.jsx("button",{onClick:()=>{n.chain().focus().setColor(e.color).run()},className:pe("w-6 h-6 mb-1 drop-shadow rounded-full flex justify-center items-center cursor-pointer transition",e.code),children:C.jsx(xf,{size:14,className:pe(n.isActive("textStyle",{color:e.color})?"visible":"invisible")})},e.color)},t))]}),C.jsx("div",{className:"flex justify-center gap-2 mt-4 w-full max-w-sm",children:Array.from({length:Cb.length/8}).map((e,t)=>C.jsx(CS,{index:t},t))})]})}),n8=n=>{const e=[{name:"Bold",isActive:()=>n.editor.isActive("bold"),command:()=>n.editor.chain().focus().toggleBold().run(),icon:C.jsx(L0,{size:20})},{name:"Italic",isActive:()=>n.editor.isActive("italic"),command:()=>n.editor.chain().focus().toggleItalic().run(),icon:C.jsx(_0,{size:20})},{name:"Underline",isActive:()=>n.editor.isActive("underline"),command:()=>n.editor.chain().focus().toggleUnderline().run(),icon:C.jsx(H0,{size:20})},{name:"Strikethrough",isActive:()=>n.editor.isActive("strike"),command:()=>n.editor.chain().focus().toggleStrike().run(),icon:C.jsx(j0,{size:20})},{name:"Alignment",isActive:()=>f===Re.ALIGNMENT,command:()=>u(Re.ALIGNMENT),icon:C.jsx(vf,{size:20})},{name:"Code",isActive:()=>n.editor.isActive("codeBlock"),command:()=>n.editor.chain().focus().toggleCodeBlock().run(),icon:C.jsx(Af,{size:20})},{name:"Link",isActive:()=>n.editor.isActive("link"),command:()=>l(!a),icon:C.jsx(B0,{size:20})}],t={...n,shouldShow:({state:d,editor:h})=>{const{selection:p}=d,{empty:m}=p;return!(h.isActive("image")||m||jE(p))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{s(!1),o(!1),l(!1)}}},[r,s]=L.useState(!1),[i,o]=L.useState(!1),[a,l]=L.useState(!1),{toolRef:c,setToolVisibility:u,toolVisibilty:f}=Sb({editor:n.editor});return C.jsxs(Mk,{...t,className:"hidden lg:flex gap-2 overflow-hidden rounded-[12px] h-[52px] min-w-[550px] w-full py-2 px-4 bg-white items-center shadow-lg",children:[C.jsx(c4,{editor:n.editor,isOpen:r,setIsOpen:()=>{s(!r),o(!1)}}),e.map((d,h)=>C.jsxs("div",{className:"flex items-center",children:[C.jsx("button",{onClick:d.command,className:pe("min-w-fit w-8 h-8 px-2 rounded",{"bg-yellow-300":d.isActive()}),children:d.icon}),(h===4||h===6)&&C.jsx("div",{className:"w-1.5 h-4 bg-gray-300 mx-2"})]},h)),C.jsx(u4,{editor:n.editor,isOpen:i,setIsOpen:()=>{o(!i),s(!1)}}),C.jsx("button",{onClick:()=>u(Re.HIGHLIGHT),className:pe("min-w-fit w-8 h-8 px-2",{"bg-yellow-300":f===Re.HIGHLIGHT}),children:C.jsx(Uk,{size:20})}),f===Re.ALIGNMENT&&C.jsx(NS,{setToolVisibility:u,editor:n.editor,elementRef:c}),a&&C.jsx(OS,{setToolVisibility:u,editor:n.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:l}),f===Re.HIGHLIGHT&&C.jsx(TS,{setVisibility:u,editor:n.editor,elementRef:c})]})};function r8(){const n=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?e[t]="-":e[t]=n[Math.ceil(Math.random()*n.length-1)];return e.join("")}var s8=r8;const i8=iy(s8),RS=vt.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:n=>n.getAttribute("data-position"),renderHTML:n=>({"data-position":n.position})}}},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),o8=(n,e)=>Array.from({length:n},(t,r)=>e(r)),hp=({type:n,content:e})=>e?{type:n,content:e}:{type:n},a8=({content:n})=>hp({type:"paragraph",content:n}),MS=({content:n})=>hp({type:"dBlock",content:n}),DS=({content:n})=>hp({type:"column",content:n}),PS=({content:n})=>hp({type:"columns",content:n}),IS=n=>{const e=[MS({content:[a8({})]})];return o8(n,()=>DS({content:e}))},LS=(n,e)=>{for(let t=n.depth;t>0;t--){const r=n.node(t),s=t>0?n.before(t):0,i=n.start(t);if(e({node:r,pos:s,start:i}))return{start:i,depth:t,node:r,pos:s}}throw Error("no ancestor found")};class pp extends Ie{constructor(t){const{$from:r,$to:s}=t;super(r,s);$(this,"_$from");$(this,"_$to");this._$from=r,this._$to=s}get $from(){return this._$from}get $to(){return this._$to}map(){return this}content(){return this.$from.doc.slice(this.from,this.to,!0)}eq(t){return t instanceof pp&&t.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(t){var l;const r=({pos:c,node:u})=>u.type.name===RS.name?!0:t.resolve(c).depth<=0,{pos:s}=LS(this.$from,r);this._$from=t.resolve(s);const{pos:i,node:o}=LS(this.$to,r);this._$to=t.resolve(i+o.nodeSize),((l=this.getFirstNode())==null?void 0:l.type.name)===mp.name&&(this._$from=t.resolve(this.$from.pos+2),this._$to=t.resolve(this.$to.pos+2));const a=this;a.$anchor=this._$from,a.$head=this._$to,a.ranges=[new Ay(this._$from,this._$to)]}static create(t,r,s){const i=t.resolve(r),o=t.resolve(s),a=new Me(i,o);return new pp(a)}getFirstNode(){return this.content().content.firstChild}}var ya=(n=>(n.AlignLeft="align-left",n.AlignRight="align-right",n.AlignCenter="align-center",n))(ya||{});const mp=vt.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:n,dispatch:e})=>{try{if(!e)return;const t=n.selection.$from,s=a0(t,({node:l})=>!this.options.nestedColumns&&l.type==this.type?!0:l.type==this.type);if(s===void 0)return;let i=[];s.node.descendants((l,c,u)=>{(u==null?void 0:u.type.name)===mp.name&&i.push(l)}),i=i.reverse().filter(l=>l.content.size>0);const o=n.doc.resolve(s.pos),a=new Ne(o);return n=n.setSelection(a),i.forEach(l=>n=n.insert(s.pos,l)),n=n.deleteSelection(),e(n)}catch(t){console.error(t)}},setColumns:(n,e=!1)=>({tr:t,dispatch:r})=>{try{const{doc:s,selection:i}=t;if(!r){console.log("no dispatch");return}const o=new pp(i);o.expandSelection(s);const{openStart:a,openEnd:l}=o.content();if(a!==l){console.warn("failed depth check");return}let c;if(e){const h=o.content().toJSON(),p=DS(h),m=IS(n-1);c=PS({content:[p,...m]})}else{const h=IS(n);c=PS({content:h})}const u=s.type.schema.nodeFromJSON(MS({content:[c]}));if(u===null)return;const f=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===mp.name))(f)){console.warn("content not allowed");return}return t=t.setSelection(o),t=t.replaceSelectionWith(u,!1),r(t)}catch(s){console.error(s)}},setLayout:n=>({commands:e})=>e.updateAttributes("columns",{layout:n})}},renderHTML({HTMLAttributes:n}){return["div",{"data-type":"columns",class:`layout-${n.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),l8=(n,e)=>{const{view:t,state:{selection:{from:r}}}=n,s=document.querySelectorAll(".has-focus"),i=s.length,a=s[i-1];if(a&&a.getAttribute("data-type")&&a.getAttribute("data-type")===e||a&&a.classList&&a.classList.contains(e))return a;const l=t.domAtPos(r).node;let c=l;for(c.tagName||(c=l.parentElement);c&&!(c.getAttribute("data-type")&&c.getAttribute("data-type")===e)&&!c.classList.contains(e);)c=c.parentElement;return c},Tb=L.forwardRef(({children:n,className:e,withShadow:t=!0,withBorder:r=!0,...s},i)=>{const o=pe(e,"bg-white rounded-md",t?"shadow-md":"",r?"border border-neutral-200":"");return C.jsx("div",{className:o,...s,ref:i,children:n})});Tb.displayName="Surface";const _S=({content:n,children:e})=>{const[t,r]=L.useState(!1);return C.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,t&&C.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:n})]})},BS=L.forwardRef(({shouldShowContent:n=!0,children:e,isVertical:t=!1,className:r,...s},i)=>{const o=pe("text-black inline-flex h-full leading-none gap-0.5",t?"flex-col p-2":"flex-row p-1 items-center",r);return n?n&&C.jsx(Tb,{className:o,...s,ref:i,children:e}):null});BS.displayName="Toolbar";const FS=L.forwardRef(({horizontal:n,className:e,...t},r)=>{const s=pe("bg-neutral-200",n?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return C.jsx("div",{className:s,ref:r,...t})});FS.displayName="Toolbar.Divider";const jS=L.forwardRef(({children:n,buttonSize:e="icon",variant:t="ghost",className:r,tooltip:s,activeClassname:i,...o},a)=>{const l=pe("gap-1 min-w-[2rem] px-2 w-auto",r),c=C.jsx(Pf,{activeClassname:i,className:l,variant:t,buttonSize:e,ref:a,...o,children:n});return s?C.jsx(_S,{content:s,children:c}):c});jS.displayName="ToolbarButton";const If={Wrapper:BS,Divider:FS,Button:jS},c8=({editor:n,appendTo:e})=>{const t=L.useCallback(()=>{const a=l8(n,"columns");return(a==null?void 0:a.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[n]),r=L.useCallback(()=>n.isActive("columns"),[n]),s=L.useCallback(()=>{n.chain().focus().setLayout(ya.AlignLeft).run()},[n]),i=L.useCallback(()=>{n.chain().focus().setLayout(ya.AlignRight).run()},[n]),o=L.useCallback(()=>{n.chain().focus().setLayout(ya.AlignCenter).run()},[n]);return C.jsx(Mk,{editor:n,pluginKey:`columnsMenu-${i8()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[P3],sticky:"popper"},children:C.jsxs(If.Wrapper,{children:[C.jsx(If.Button,{tooltip:"Align left",active:n.isActive("columns",{layout:ya.AlignLeft}),onClick:s,children:C.jsx(r4,{size:20})}),C.jsx(If.Button,{tooltip:"Align center",active:n.isActive("columns",{layout:ya.AlignCenter}),onClick:o,children:C.jsx(jk,{size:20})}),C.jsx(If.Button,{tooltip:"Align right",active:n.isActive("columns",{layout:ya.AlignRight}),onClick:i,children:C.jsx(s4,{size:20})})]})})},US=L.createContext(null),gp=()=>L.useContext(US),u8=({children:n,isPreviewMode:e})=>C.jsx(US.Provider,{value:e,children:n}),HS=({height:n,width:e})=>C.jsx("span",{className:"flex items-center justify-center ",children:C.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${n?`h-${n}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),f8=({editor:n})=>{var i;const{toolRef:e,toolVisibilty:t,setToolVisibility:r,toolbar:s}=Sb({editor:n});return C.jsxs("div",{className:"w-fit bg-transparent px-4 items-center h-16 flex gap-1 justify-center relative",children:[C.jsxs("button",{className:"bg-transparent flex items-center gap-2 min-w-[55px]",onClick:()=>r(Re.FONT_FAMILY),children:[C.jsx("span",{className:"text-sm",children:((i=SS.find(o=>n==null?void 0:n.isActive("textStyle",{fontFamily:o.value})))==null?void 0:i.title)||"Font"}),C.jsx(zh,{size:16})]}),C.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"}),C.jsxs("button",{className:"bg-transparent gap-2 flex items-center min-w-[55px]",onClick:()=>r(Re.HEADING),children:[C.jsx("span",{className:"text-sm",children:n!=null&&n.isActive("heading",{level:1})?"Heading 1":n!=null&&n.isActive("heading",{level:2})?"Heading 2":n!=null&&n.isActive("heading",{level:3})?"Heading 3":"Text"}),C.jsx(zh,{size:16})]}),C.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"}),s.map((o,a)=>o?C.jsx("div",{className:"tooltip tooltip-bottom","data-tip":o.title,children:C.jsx("span",{onClick:()=>o.onClick(),className:pe("rounded w-8 h-8 p-1 flex cursor-pointer justify-center items-center transition",o.isActive?"bg-yellow-300 hover:brightness-90":"hover:bg-[#f2f2f2]"),children:typeof o.icon=="string"?C.jsx("img",{src:o.icon,className:"w-4"}):o.icon})},o.title):C.jsx("div",{className:"w-[2px] h-4 bg-gray-200 mx-2"},a)),t===Re.FONT_FAMILY&&C.jsx(QU,{setToolVisibility:r,editor:n,elementRef:e}),t===Re.HEADING&&C.jsx(ZU,{setVisibility:r,editor:n,elementRef:e}),t===Re.TEXT_COLOR&&C.jsx(XU,{setVisibility:r,editor:n,elementRef:e}),t===Re.HIGHLIGHT&&C.jsx(TS,{setVisibility:r,editor:n,elementRef:e}),t===Re.ALIGNMENT&&C.jsx(NS,{setToolVisibility:r,editor:n,elementRef:e}),t===Re.LIST&&C.jsx(YU,{setToolVisibility:r,editor:n,elementRef:e}),t===Re.LINK&&C.jsx(OS,{setToolVisibility:r,editor:n,elementRef:e})]})},Mn=()=>new Map,Nb=n=>{const e=Mn();return n.forEach((t,r)=>{e.set(r,t)}),e},Jn=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},d8=(n,e)=>{const t=[];for(const[r,s]of n)t.push(e(s,r));return t},h8=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},oi=()=>new Set,Ob=n=>n[n.length-1],p8=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},ai=Array.from,m8=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},Rb=Array.isArray;class Mb{constructor(){this._observers=Mn()}on(e,t){return Jn(this._observers,e,oi).add(t),t}once(e,t){const r=(...s)=>{this.off(e,r),t(...s)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return ai((this._observers.get(e)||Mn()).values()).forEach(r=>r(...t))}destroy(){this._observers=Mn()}}class zS{constructor(){this._observers=Mn()}on(e,t){Jn(this._observers,e,oi).add(t)}once(e,t){const r=(...s)=>{this.off(e,r),t(...s)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return ai((this._observers.get(e)||Mn()).values()).forEach(r=>r(...t))}destroy(){this._observers=Mn()}}const Yr=Math.floor,yp=Math.abs,g8=Math.log10,io=(n,e)=>n<e?n:e,li=(n,e)=>n>e?n:e,VS=n=>n!==0?n<0:1/n<0,Ts=Date.now,y8=1200,b8=2500,bp=3e4,Db=n=>{if(n.shouldConnect&&n.ws===null){const e=new WebSocket(n.url),t=n.binaryType;let r=null;t&&(e.binaryType=t),n.ws=e,n.connecting=!0,n.connected=!1,e.onmessage=o=>{n.lastMessageReceived=Ts();const a=o.data,l=typeof a=="string"?JSON.parse(a):a;l&&l.type==="pong"&&(clearTimeout(r),r=setTimeout(i,bp/2)),n.emit("message",[l,n])};const s=o=>{n.ws!==null&&(n.ws=null,n.connecting=!1,n.connected?(n.connected=!1,n.emit("disconnect",[{type:"disconnect",error:o},n])):n.unsuccessfulReconnects++,setTimeout(Db,io(g8(n.unsuccessfulReconnects+1)*y8,b8),n)),clearTimeout(r)},i=()=>{n.ws===e&&n.send({type:"ping"})};e.onclose=()=>s(null),e.onerror=o=>s(o),e.onopen=()=>{n.lastMessageReceived=Ts(),n.connecting=!1,n.connected=!0,n.unsuccessfulReconnects=0,n.emit("connect",[{type:"connect"},n]),r=setTimeout(i,bp/2)}}};class w8 extends zS{constructor(e,{binaryType:t}={}){super(),this.url=e,this.ws=null,this.binaryType=t||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&bp<Ts()-this.lastMessageReceived&&this.ws.close()},bp/2),Db(this)}send(e){this.ws&&this.ws.send(JSON.stringify(e))}destroy(){clearInterval(this._checkInterval),this.disconnect(),super.destroy()}disconnect(){this.shouldConnect=!1,this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.connected&&this.ws===null&&Db(this)}}const Ns=n=>new Error(n),Xr=()=>{throw Ns("Method unimplemented")},dr=()=>{throw Ns("Unexpected case")},$S=1,WS=2,Pb=4,Ib=8,Lf=32,ci=64,hr=128,wp=31,Lb=63,ba=127,v8=2147483647,x8=crypto.getRandomValues.bind(crypto),GS=Math.random,KS=()=>x8(new Uint32Array(1))[0],A8=n=>n[Yr(GS()*n.length)],E8="10000000-1000-4000-8000"+-1e11,JS=()=>E8.replace(/[018]/g,n=>(n^KS()&15>>n/4).toString(16)),qS=Number.MAX_SAFE_INTEGER,k8=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&Yr(n)===n),C8=String.fromCharCode,S8=n=>n.toLowerCase(),T8=/^\s*/g,N8=n=>n.replace(T8,""),O8=/([A-Z])/g,QS=(n,e)=>N8(n.replace(O8,t=>`${e}${S8(t)}`)),R8=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let s=0;s<t;s++)r[s]=e.codePointAt(s);return r},_f=typeof TextEncoder<"u"?new TextEncoder:null,_b=_f?n=>_f.encode(n):R8;let Bf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Bf&&Bf.decode(new Uint8Array).length===1&&(Bf=null);class Ff{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const nn=()=>new Ff,M8=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},Rt=n=>{const e=new Uint8Array(M8(n));let t=0;for(let r=0;r<n.bufs.length;r++){const s=n.bufs[r];e.set(s,t),t+=s.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},D8=(n,e)=>{const t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(li(t,e)*2),n.cpos=0)},rn=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},jf=rn,De=(n,e)=>{for(;e>ba;)rn(n,hr|ba&e),e=Yr(e/128);rn(n,ba&e)},Bb=(n,e)=>{const t=VS(e);for(t&&(e=-e),rn(n,(e>Lb?hr:0)|(t?ci:0)|Lb&e),e=Yr(e/64);e>0;)rn(n,(e>ba?hr:0)|ba&e),e=Yr(e/128)},Fb=new Uint8Array(3e4),P8=Fb.length/3,I8=(n,e)=>{if(e.length<P8){const t=_f.encodeInto(e,Fb).written||0;De(n,t);for(let r=0;r<t;r++)rn(n,Fb[r])}else Lt(n,_b(e))},L8=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;De(n,r);for(let s=0;s<r;s++)rn(n,t.codePointAt(s))},Os=_f&&_f.encodeInto?I8:L8,vp=(n,e)=>{const t=n.cbuf.length,r=n.cpos,s=io(t-r,e.length),i=e.length-s;n.cbuf.set(e.subarray(0,s),r),n.cpos+=s,i>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(li(t*2,i)),n.cbuf.set(e.subarray(s)),n.cpos=i)},Lt=(n,e)=>{De(n,e.byteLength),vp(n,e)},jb=(n,e)=>{D8(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},_8=(n,e)=>jb(n,4).setFloat32(0,e,!1),B8=(n,e)=>jb(n,8).setFloat64(0,e,!1),F8=(n,e)=>jb(n,8).setBigInt64(0,e,!1),YS=new DataView(new ArrayBuffer(4)),j8=n=>(YS.setFloat32(0,n),YS.getFloat32(0)===n),Ql=(n,e)=>{switch(typeof e){case"string":rn(n,119),Os(n,e);break;case"number":k8(e)&&yp(e)<=v8?(rn(n,125),Bb(n,e)):j8(e)?(rn(n,124),_8(n,e)):(rn(n,123),B8(n,e));break;case"bigint":rn(n,122),F8(n,e);break;case"object":if(e===null)rn(n,126);else if(Rb(e)){rn(n,117),De(n,e.length);for(let t=0;t<e.length;t++)Ql(n,e[t])}else if(e instanceof Uint8Array)rn(n,116),Lt(n,e);else{rn(n,118);const t=Object.keys(e);De(n,t.length);for(let r=0;r<t.length;r++){const s=t[r];Os(n,s),Ql(n,e[s])}}break;case"boolean":rn(n,e?120:121);break;default:rn(n,127)}};class XS extends Ff{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&De(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const ZS=n=>{n.count>0&&(Bb(n.encoder,n.count===1?n.s:-n.s),n.count>1&&De(n.encoder,n.count-2))};class xp{constructor(){this.encoder=new Ff,this.s=0,this.count=0}write(e){this.s===e?this.count++:(ZS(this),this.count=1,this.s=e)}toUint8Array(){return ZS(this),Rt(this.encoder)}}const eT=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);Bb(n.encoder,e),n.count>1&&De(n.encoder,n.count-2)}};class Ub{constructor(){this.encoder=new Ff,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(eT(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return eT(this),Rt(this.encoder)}}class U8{constructor(){this.sarr=[],this.s="",this.lensE=new xp}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Ff;return this.sarr.push(this.s),this.s="",Os(e,this.sarr.join("")),vp(e,this.lensE.toUint8Array()),Rt(e)}}const tT=Ns("Unexpected end of array"),nT=Ns("Integer out of Range");class Ap{constructor(e){this.arr=e,this.pos=0}}const Rs=n=>new Ap(n),H8=n=>n.pos!==n.arr.length,z8=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},sn=n=>z8(n,We(n)),wa=n=>n.arr[n.pos++],We=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const s=n.arr[n.pos++];if(e=e+(s&ba)*t,t*=128,s<hr)return e;if(e>qS)throw nT}throw tT},Hb=n=>{let e=n.arr[n.pos++],t=e&Lb,r=64;const s=(e&ci)>0?-1:1;if(!(e&hr))return s*t;const i=n.arr.length;for(;n.pos<i;){if(e=n.arr[n.pos++],t=t+(e&ba)*r,r*=128,e<hr)return s*t;if(t>qS)throw nT}throw tT},ui=Bf?n=>Bf.decode(sn(n)):n=>{let e=We(n);if(e===0)return"";{let t=String.fromCodePoint(wa(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(wa(n));else for(;e>0;){const r=e<1e4?e:1e4,s=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(t))}},zb=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},V8=[n=>{},n=>null,Hb,n=>zb(n,4).getFloat32(0,!1),n=>zb(n,8).getFloat64(0,!1),n=>zb(n,8).getBigInt64(0,!1),n=>!1,n=>!0,ui,n=>{const e=We(n),t={};for(let r=0;r<e;r++){const s=ui(n);t[s]=Yl(n)}return t},n=>{const e=We(n),t=[];for(let r=0;r<e;r++)t.push(Yl(n));return t},sn],Yl=n=>V8[127-wa(n)](n);class rT extends Ap{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),H8(this)?this.count=We(this)+1:this.count=-1),this.count--,this.s}}class Ep extends Ap{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Hb(this);const e=VS(this.s);this.count=1,e&&(this.s=-this.s,this.count=We(this)+2)}return this.count--,this.s}}class Vb extends Ap{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Hb(this),t=e&1;this.diff=Yr(e/2),this.count=1,t&&(this.count=We(this)+2)}return this.s+=this.diff,this.count--,this.s}}class $8{constructor(e){this.decoder=new Ep(e),this.str=ui(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const sT=n=>n===void 0?null:n;class W8{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let iT=new W8,$b=!0;try{typeof localStorage<"u"&&localStorage&&(iT=localStorage,$b=!1)}catch{}const oT=iT,G8=n=>$b||addEventListener("storage",n),K8=n=>$b||removeEventListener("storage",n),J8=Object.assign,Wb=Object.keys,q8=(n,e)=>{for(const t in n)e(n[t],t)},aT=n=>Wb(n).length,lT=n=>Wb(n).length,Q8=n=>{for(const e in n)return!1;return!0},Y8=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},cT=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),X8=(n,e)=>n===e||lT(n)===lT(e)&&Y8(n,(t,r)=>(t!==void 0||cT(e,r))&&e[r]===t),Gb=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&Gb(n,e,t+1)}},Z8=()=>{},eH=n=>n,tH=(n,e)=>n===e,Uf=(n,e)=>{if(n==null||e==null)return tH(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!Uf(n.get(t),e.get(t)))return!1;break}case Object:if(aT(n)!==aT(e))return!1;for(const t in n)if(!cT(n,t)||!Uf(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Uf(n[t],e[t]))return!1;break;default:return!1}return!0},nH=(n,e)=>e.includes(n),Xl=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Kb=typeof window<"u"&&typeof document<"u"&&!Xl;let Ms;const rH=()=>{if(Ms===void 0)if(Xl){Ms=Mn();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&Ms.set(e,""),e=r):e!==null&&(Ms.set(e,r),e=null)}e!==null&&Ms.set(e,"")}else typeof location=="object"?(Ms=Mn(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");Ms.set(`--${QS(e,"-")}`,t),Ms.set(`-${QS(e,"-")}`,t)}})):Ms=Mn();return Ms},Jb=n=>rH().has(n),kp=n=>sT(Xl?process.env[n.toUpperCase().replaceAll("-","_")]:oT.getItem(n));(n=>Jb("--"+n)||kp(n)!==null)("production");const uT=Xl&&nH(process.env.FORCE_COLOR,["true","1","2"]),sH=!Jb("--no-colors")&&(!Xl||process.stdout.isTTY||uT)&&(!Xl||Jb("--color")||uT||kp("COLORTERM")!==null||(kp("TERM")||"").includes("color"));class iH{constructor(e,t){this.left=e,this.right=t}}const fi=(n,e)=>new iH(n,e),oH=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const aH=n=>d8(n,(e,t)=>`${t}:${e};`).join(""),lH=JSON.stringify,cH=(n=>class{constructor(t){this._=t}destroy(){n(this._)}})(clearTimeout),qb=(n,e)=>new cH(setTimeout(e,n)),di=Symbol,Rr=di(),va=di(),fT=di(),Qb=di(),dT=di(),hT=di(),pT=di(),Cp=di(),Sp=di(),uH=n=>{var r;n.length===1&&((r=n[0])==null?void 0:r.constructor)===Function&&(n=n[0]());const e=[];let t=0;for(;t<n.length;t++){const s=n[t];s===void 0||s.constructor===String||s.constructor===Number||s.constructor===Object&&e.push(JSON.stringify(s))}return e},mT=[dT,pT,Cp,fT];let Yb=0,gT=Ts();const fH=(n,e)=>{const t=mT[Yb],r=kp("log"),s=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return Yb=(Yb+1)%mT.length,e+=": ",s?(...i)=>{var l;i.length===1&&((l=i[0])==null?void 0:l.constructor)===Function&&(i=i[0]());const o=Ts(),a=o-gT;gT=o,n(t,e,Sp,...i.map(c=>{switch(c!=null&&c.constructor===Uint8Array&&(c=Array.from(c)),typeof c){case"string":case"symbol":return c;default:return lH(c)}}),t," +"+a+"ms")}:Z8},dH={[Rr]:fi("font-weight","bold"),[va]:fi("font-weight","normal"),[fT]:fi("color","blue"),[dT]:fi("color","green"),[Qb]:fi("color","grey"),[hT]:fi("color","red"),[pT]:fi("color","purple"),[Cp]:fi("color","orange"),[Sp]:fi("color","black")},yT=sH?n=>{var o;n.length===1&&((o=n[0])==null?void 0:o.constructor)===Function&&(n=n[0]());const e=[],t=[],r=Mn();let s=[],i=0;for(;i<n.length;i++){const a=n[i],l=dH[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const c=aH(r);i>0||c.length>0?(e.push("%c"+a),t.push(c)):e.push(a)}else break}}for(i>0&&(s=t,s.unshift(e.join("")));i<n.length;i++){const a=n[i];a instanceof Symbol||s.push(a)}return s}:uH,bT=(...n)=>{console.log(...yT(n)),wT.forEach(e=>e.print(n))},hH=(...n)=>{console.warn(...yT(n)),n.unshift(Cp),wT.forEach(e=>e.print(n))},wT=oi(),pH=n=>fH(bT,n),vT=n=>new Promise(n);Promise.all.bind(Promise);const mH=n=>Promise.reject(n),Xb=n=>Promise.resolve(n),xT=n=>new Uint8Array(n),gH=(n,e,t)=>new Uint8Array(n,e,t),yH=n=>new Uint8Array(n),bH=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=C8(n[t]);return btoa(e)},wH=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),vH=n=>{const e=atob(n),t=xT(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},xH=n=>{const e=Buffer.from(n,"base64");return gH(e.buffer,e.byteOffset,e.byteLength)},AT=Kb?bH:wH,ET=Kb?vH:xH,AH=n=>{const e=xT(n.byteLength);return e.set(n),e},kT=new Map;class EH{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:ET(t.newValue||"")}),G8(this._onChange)}postMessage(e){oT.setItem(this.room,AT(yH(e)))}close(){K8(this._onChange)}}const kH=typeof BroadcastChannel>"u"?EH:BroadcastChannel,Zb=n=>Jn(kT,n,()=>{const e=oi(),t=new kH(n);return t.onmessage=r=>e.forEach(s=>s(r.data,"broadcastchannel")),{bc:t,subs:e}}),CH=(n,e)=>(Zb(n).subs.add(e),e),SH=(n,e)=>{const t=Zb(n),r=t.subs.delete(e);return r&&t.subs.size===0&&(t.bc.close(),kT.delete(n)),r},TH=(n,e,t=null)=>{const r=Zb(n);r.bc.postMessage(e),r.subs.forEach(s=>s(e,t))},CT=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},ST=n=>({[Symbol.iterator](){return this},next:n}),NH=(n,e)=>ST(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),ew=(n,e)=>ST(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class tw{constructor(e,t){this.clock=e,this.len=t}}class Zl{constructor(){this.clients=new Map}}const oo=(n,e,t)=>e.clients.forEach((r,s)=>{const i=n.doc.store.clients.get(s);for(let o=0;o<r.length;o++){const a=r[o];GT(n,i,a.clock,a.len,t)}}),OH=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const s=Yr((t+r)/2),i=n[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;t=s+1}else r=s-1}return null},ec=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&OH(t,e.clock)!==null},nw=n=>{n.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let t,r;for(t=1,r=1;t<e.length;t++){const s=e[r-1],i=e[t];s.clock+s.len>=i.clock?s.len=li(s.len,i.clock+i.len-s.clock):(r<t&&(e[r]=i),r++)}e.length=r})},rw=n=>{const e=new Zl;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=t+1;o<n.length;o++)p8(i,n[o].clients.get(s)||[]);e.clients.set(s,i)}});return nw(e),e},Hf=(n,e,t,r)=>{Jn(n.clients,e,()=>[]).push(new tw(t,r))},TT=()=>new Zl,NT=n=>{const e=TT();return n.clients.forEach((t,r)=>{const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(o.deleted){const a=o.id.clock;let l=o.length;if(i+1<t.length)for(let c=t[i+1];i+1<t.length&&c.deleted;c=t[++i+1])l+=c.length;s.push(new tw(a,l))}}s.length>0&&e.clients.set(r,s)}),e},tc=(n,e)=>{De(n.restEncoder,e.clients.size),ai(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),De(n.restEncoder,t);const s=r.length;De(n.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},sw=n=>{const e=new Zl,t=We(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const s=We(n.restDecoder),i=We(n.restDecoder);if(i>0){const o=Jn(e.clients,s,()=>[]);for(let a=0;a<i;a++)o.push(new tw(n.readDsClock(),n.readDsLen()))}}return e},OT=(n,e,t)=>{const r=new Zl,s=We(n.restDecoder);for(let i=0;i<s;i++){n.resetDsCurVal();const o=We(n.restDecoder),a=We(n.restDecoder),l=t.clients.get(o)||[],c=jt(t,o);for(let u=0;u<a;u++){const f=n.readDsClock(),d=f+n.readDsLen();if(f<c){c<d&&Hf(r,o,c,d-c);let h=Ds(l,f),p=l[h];for(!p.deleted&&p.id.clock<f&&(l.splice(h+1,0,Up(e,p,f-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(h,0,Up(e,p,d-p.id.clock)),p.delete(e))}else Hf(r,o,f,d-f)}}if(r.clients.size>0){const i=new Aa;return De(i.restEncoder,0),tc(i,r),i.toUint8Array()}return null},RT=KS;class xa extends Mb{constructor({guid:e=JS(),collectionid:t=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=RT(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new VT,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=vT(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>vT(c=>{const u=f=>{(f===void 0||f===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&gt(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ai(this.subdocs).map(e=>e.guid))}transact(e,t=null){return gt(this,e,t)}get(e,t=mn){const r=Jn(this.share,e,()=>{const i=new t;return i._integrate(this,null),i}),s=r.constructor;if(t!==mn&&s!==t)if(s===mn){const i=new t;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,oc)}getText(e=""){return this.get(e,ka)}getMap(e=""){return this.get(e,ac)}getXmlElement(e=""){return this.get(e,Dn)}getXmlFragment(e=""){return this.get(e,Ca)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){ai(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new xa({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,gt(e.parent.doc,r=>{const s=t.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class MT{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return We(this.restDecoder)}readDsLen(){return We(this.restDecoder)}}class DT extends MT{readLeftID(){return Ge(We(this.restDecoder),We(this.restDecoder))}readRightID(){return Ge(We(this.restDecoder),We(this.restDecoder))}readClient(){return We(this.restDecoder)}readInfo(){return wa(this.restDecoder)}readString(){return ui(this.restDecoder)}readParentInfo(){return We(this.restDecoder)===1}readTypeRef(){return We(this.restDecoder)}readLen(){return We(this.restDecoder)}readAny(){return Yl(this.restDecoder)}readBuf(){return AH(sn(this.restDecoder))}readJSON(){return JSON.parse(ui(this.restDecoder))}readKey(){return ui(this.restDecoder)}}class RH{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=We(this.restDecoder),this.dsCurrVal}readDsLen(){const e=We(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class nc extends RH{constructor(e){super(e),this.keys=[],We(e),this.keyClockDecoder=new Vb(sn(e)),this.clientDecoder=new Ep(sn(e)),this.leftClockDecoder=new Vb(sn(e)),this.rightClockDecoder=new Vb(sn(e)),this.infoDecoder=new rT(sn(e),wa),this.stringDecoder=new $8(sn(e)),this.parentInfoDecoder=new rT(sn(e),wa),this.typeRefDecoder=new Ep(sn(e)),this.lenDecoder=new Ep(sn(e))}readLeftID(){return new rc(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new rc(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Yl(this.restDecoder)}readBuf(){return sn(this.restDecoder)}readJSON(){return Yl(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class PT{constructor(){this.restEncoder=nn()}toUint8Array(){return Rt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){De(this.restEncoder,e)}writeDsLen(e){De(this.restEncoder,e)}}class zf extends PT{writeLeftID(e){De(this.restEncoder,e.client),De(this.restEncoder,e.clock)}writeRightID(e){De(this.restEncoder,e.client),De(this.restEncoder,e.clock)}writeClient(e){De(this.restEncoder,e)}writeInfo(e){jf(this.restEncoder,e)}writeString(e){Os(this.restEncoder,e)}writeParentInfo(e){De(this.restEncoder,e?1:0)}writeTypeRef(e){De(this.restEncoder,e)}writeLen(e){De(this.restEncoder,e)}writeAny(e){Ql(this.restEncoder,e)}writeBuf(e){Lt(this.restEncoder,e)}writeJSON(e){Os(this.restEncoder,JSON.stringify(e))}writeKey(e){Os(this.restEncoder,e)}}class IT{constructor(){this.restEncoder=nn(),this.dsCurrVal=0}toUint8Array(){return Rt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,De(this.restEncoder,t)}writeDsLen(e){e===0&&dr(),De(this.restEncoder,e-1),this.dsCurrVal+=e}}class Aa extends IT{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ub,this.clientEncoder=new xp,this.leftClockEncoder=new Ub,this.rightClockEncoder=new Ub,this.infoEncoder=new XS(jf),this.stringEncoder=new U8,this.parentInfoEncoder=new XS(jf),this.typeRefEncoder=new xp,this.lenEncoder=new xp}toUint8Array(){const e=nn();return De(e,0),Lt(e,this.keyClockEncoder.toUint8Array()),Lt(e,this.clientEncoder.toUint8Array()),Lt(e,this.leftClockEncoder.toUint8Array()),Lt(e,this.rightClockEncoder.toUint8Array()),Lt(e,Rt(this.infoEncoder)),Lt(e,this.stringEncoder.toUint8Array()),Lt(e,Rt(this.parentInfoEncoder)),Lt(e,this.typeRefEncoder.toUint8Array()),Lt(e,this.lenEncoder.toUint8Array()),vp(e,Rt(this.restEncoder)),Rt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ql(this.restEncoder,e)}writeBuf(e){Lt(this.restEncoder,e)}writeJSON(e){Ql(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const MH=(n,e,t,r)=>{r=li(r,e[0].id.clock);const s=Ds(e,r);De(n.restEncoder,e.length-s),n.writeClient(t),De(n.restEncoder,r);const i=e[s];i.write(n,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(n,0)},iw=(n,e,t)=>{const r=new Map;t.forEach((s,i)=>{jt(e,i)>s&&r.set(i,s)}),Kf(e).forEach((s,i)=>{t.has(i)||r.set(i,0)}),De(n.restEncoder,r.size),ai(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{MH(n,e.clients.get(s),s,i)})},DH=(n,e)=>{const t=Mn(),r=We(n.restDecoder);for(let s=0;s<r;s++){const i=We(n.restDecoder),o=new Array(i),a=n.readClient();let l=We(n.restDecoder);t.set(a,{i:0,refs:o});for(let c=0;c<i;c++){const u=n.readInfo();switch(wp&u){case 0:{const f=n.readLen();o[c]=new Mr(Ge(a,l),f),l+=f;break}case 10:{const f=We(n.restDecoder);o[c]=new Dr(Ge(a,l),f),l+=f;break}default:{const f=(u&(ci|hr))===0,d=new xt(Ge(a,l),null,(u&hr)===hr?n.readLeftID():null,null,(u&ci)===ci?n.readRightID():null,f?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,f&&(u&Lf)===Lf?n.readString():null,E2(n,u));o[c]=d,l+=d.length}}}}return t},PH=(n,e,t)=>{const r=[];let s=ai(t.keys()).sort((h,p)=>h-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let h=t.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=t.get(s[s.length-1]);else return null;return h};let o=i();if(o===null)return null;const a=new VT,l=new Map,c=(h,p)=>{const m=l.get(h);(m==null||m>p)&&l.set(h,p)};let u=o.refs[o.i++];const f=new Map,d=()=>{for(const h of r){const p=h.id.client,m=t.get(p);m?(m.i--,a.clients.set(p,m.refs.slice(m.i)),t.delete(p),m.i=0,m.refs=[]):a.clients.set(p,[h]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==Dr){const p=Jn(f,u.id.client,()=>jt(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),d();else{const m=u.getMissing(n,e);if(m!==null){r.push(u);const y=t.get(m)||{refs:[],i:0};if(y.refs.length===y.i)c(m,jt(e,m)),d();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(n,p),f.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(a.clients.size>0){const h=new Aa;return iw(h,a,new Map),De(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},IH=(n,e)=>iw(n,e.doc.store,e.beforeState),LH=(n,e,t,r=new nc(n))=>gt(e,s=>{s.local=!1;let i=!1;const o=s.doc,a=o.store,l=DH(r,o),c=PH(s,a,l),u=a.pendingStructs;if(u){for(const[d,h]of u.missing)if(h<jt(a,d)){i=!0;break}if(c){for(const[d,h]of c.missing){const p=u.missing.get(d);(p==null||p>h)&&u.missing.set(d,h)}u.update=Rp([u.update,c.update])}}else a.pendingStructs=c;const f=OT(r,s,a);if(a.pendingDs){const d=new nc(Rs(a.pendingDs));We(d.restDecoder);const h=OT(d,s,a);f&&h?a.pendingDs=Rp([f,h]):a.pendingDs=f||h}else a.pendingDs=f;if(i){const d=a.pendingStructs.update;a.pendingStructs=null,Tp(s.doc,d)}},t,!1),Tp=(n,e,t,r=nc)=>{const s=Rs(e);LH(s,n,t,new r(s))},_H=(n,e,t)=>Tp(n,e,t,DT),BH=(n,e,t=new Map)=>{iw(n,e.store,t),tc(n,NT(e.store))},FH=(n,e=new Uint8Array([0]),t=new Aa)=>{const r=LT(e);BH(t,n,r);const s=[t.toUint8Array()];if(n.store.pendingDs&&s.push(n.store.pendingDs),n.store.pendingStructs&&s.push(n5(n.store.pendingStructs.update,e)),s.length>1){if(t.constructor===zf)return e5(s.map((i,o)=>o===0?i:s5(i)));if(t.constructor===Aa)return Rp(s)}return s[0]},jH=(n,e)=>FH(n,e,new zf),UH=n=>{const e=new Map,t=We(n.restDecoder);for(let r=0;r<t;r++){const s=We(n.restDecoder),i=We(n.restDecoder);e.set(s,i)}return e},LT=n=>UH(new MT(Rs(n))),_T=(n,e)=>(De(n.restEncoder,e.size),ai(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{De(n.restEncoder,t),De(n.restEncoder,r)}),n),HH=(n,e)=>_T(n,Kf(e.store)),zH=(n,e=new IT)=>(n instanceof Map?_T(e,n):HH(e,n),e.toUint8Array()),VH=n=>zH(n,new PT);class $H{constructor(){this.l=[]}}const BT=()=>new $H,FT=(n,e)=>n.l.push(e),jT=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(s=>e!==s),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},UT=(n,e,t)=>Gb(n.l,[e,t]);class rc{constructor(e,t){this.client=e,this.clock=t}}const sc=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,Ge=(n,e)=>new rc(n,e),Vf=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw dr()},$f=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class Wf{constructor(e,t,r,s=0){this.type=e,this.tname=t,this.item=r,this.assoc=s}}const Gf=n=>new Wf(n.type==null?null:Ge(n.type.client,n.type.clock),n.tname??null,n.item==null?null:Ge(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class WH{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const GH=(n,e,t=0)=>new WH(n,e,t),Np=(n,e,t)=>{let r=null,s=null;return n._item===null?s=Vf(n):r=Ge(n._item.id.client,n._item.id.clock),new Wf(r,s,e,t)},ow=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return Np(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Np(n,Ge(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return Np(n,r.lastId,t);r=r.right}return Np(n,null,t)},KH=(n,e,t=!0)=>{const r=e.store,s=n.item,i=n.type,o=n.tname,a=n.assoc;let l=null,c=0;if(s!==null){if(jt(r,s.client)<=s.clock)return null;const u=t?xw(r,s):{item:ic(r,s),diff:0},f=u.item;if(!(f instanceof xt))return null;if(l=f.parent,l._item===null||!l._item.deleted){c=f.deleted||!f.countable?0:u.diff+(a>=0?0:1);let d=f.left;for(;d!==null;)!d.deleted&&d.countable&&(c+=d.length),d=d.left}}else{if(o!==null)l=e.get(o);else if(i!==null){if(jt(r,i.client)<=i.clock)return null;const{item:u}=t?xw(r,i):{item:ic(r,i)};if(u instanceof xt&&u.content instanceof es)l=u.content.type;else return null}else throw dr();a>=0?c=l._length:c=0}return GH(l,c,n.assoc)},HT=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&sc(n.item,e.item)&&sc(n.type,e.type)&&n.assoc===e.assoc;class aw{constructor(e,t){this.ds=e,this.sv=t}}const zT=(n,e)=>new aw(n,e),lw=n=>zT(NT(n.store),Kf(n.store)),Ea=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!ec(e.ds,n.id),cw=(n,e)=>{const t=Jn(n.meta,cw,oi),r=n.doc.store;t.has(e)||(e.sv.forEach((s,i)=>{s<jt(r,i)&&qn(n,Ge(i,s))}),oo(n,e.ds,s=>{}),t.add(e))};class VT{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Kf=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const s=t[t.length-1];e.set(r,s.id.clock+s.length)}),e},jt=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},$T=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw dr()}t.push(e)},Ds=(n,e)=>{let t=0,r=n.length-1,s=n[r],i=s.id.clock;if(i===e)return r;let o=Yr(e/(i+s.length-1)*r);for(;t<=r;){if(s=n[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;t=o+1}else r=o-1;o=Yr((t+r)/2)}throw dr()},ic=(n,e)=>{const t=n.clients.get(e.client);return t[Ds(t,e.clock)]},uw=(n,e,t)=>{const r=Ds(e,t),s=e[r];return s.id.clock<t&&s instanceof xt?(e.splice(r+1,0,Up(n,s,t-s.id.clock)),r+1):r},qn=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[uw(n,t,e.clock)]},WT=(n,e,t)=>{const r=e.clients.get(t.client),s=Ds(r,t.clock),i=r[s];return t.clock!==i.id.clock+i.length-1&&i.constructor!==Mr&&r.splice(s+1,0,Up(n,i,t.clock-i.id.clock+1)),i},JH=(n,e,t)=>{const r=n.clients.get(e.id.client);r[Ds(r,e.id.clock)]=t},GT=(n,e,t,r,s)=>{if(r===0)return;const i=t+r;let o=uw(n,e,t),a;do a=e[o++],i<a.id.clock+a.length&&uw(n,e,i),s(a);while(o<e.length&&e[o].id.clock<i)};let qH=class{constructor(e,t,r){this.doc=e,this.deleteSet=new Zl,this.beforeState=Kf(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}};const KT=(n,e)=>e.deleteSet.clients.size===0&&!h8(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(nw(e.deleteSet),IH(n,e),tc(n,e.deleteSet),!0),JT=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Jn(n.changed,e,oi).add(t)},Op=(n,e)=>{let t=n[e],r=n[e-1],s=e;for(;s>0;t=r,r=n[--s-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof xt&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const i=e-s;return i&&n.splice(e+1-i,i),i},QH=(n,e,t)=>{for(const[r,s]of n.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const a=s[o],l=a.clock+a.len;for(let c=Ds(i,a.clock),u=i[c];c<i.length&&u.id.clock<l;u=i[++c]){const f=i[c];if(a.clock+a.len<=f.id.clock)break;f instanceof xt&&f.deleted&&!f.keep&&t(f)&&f.gc(e,!1)}}}},YH=(n,e)=>{n.clients.forEach((t,r)=>{const s=e.clients.get(r);for(let i=t.length-1;i>=0;i--){const o=t[i],a=io(s.length-1,1+Ds(s,o.clock+o.len-1));for(let l=a,c=s[l];l>0&&c.id.clock>=o.clock;c=s[l])l-=1+Op(s,l)}})},qT=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,s=r.store,i=t.deleteSet,o=t._mergeStructs;try{nw(i),t.afterState=Kf(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const a=[];t.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,l)})),a.push(()=>{t.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,f)=>u.path.length-f.path.length),UT(c._dEH,l,t))})}),a.push(()=>r.emit("afterTransaction",[t,r])),Gb(a,[]),t._needFormattingCleanup&&b5(t)}finally{r.gc&&QH(i,s,r.gcFilter),YH(i,s),t.afterState.forEach((u,f)=>{const d=t.beforeState.get(f)||0;if(d!==u){const h=s.clients.get(f),p=li(Ds(h,d),1);for(let m=h.length-1;m>=p;)m-=1+Op(h,m)}});for(let u=o.length-1;u>=0;u--){const{client:f,clock:d}=o[u].id,h=s.clients.get(f),p=Ds(h,d);p+1<h.length&&Op(h,p+1)>1||p>0&&Op(h,p)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(bT(Cp,Rr,"[yjs] ",va,hT,"Changed the client-id because another client seems to be using it."),r.clientID=RT()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const u=new zf;KT(u,t)&&r.emit("update",[u.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const u=new Aa;KT(u,t)&&r.emit("updateV2",[u.toUint8Array(),t.origin,r,t])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=t;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,t]),c.forEach(u=>u.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):qT(n,e+1)}}},gt=(n,e,t=null,r=!0)=>{const s=n._transactionCleanups;let i=!1,o=null;n._transaction===null&&(i=!0,n._transaction=new qH(n,t,r),s.push(n._transaction),s.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction)}finally{if(i){const a=n._transaction===s[0];n._transaction=null,a&&qT(s,0)}}return o};class XH{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const QT=(n,e,t)=>{oo(n,t.deletions,r=>{r instanceof xt&&e.scope.some(s=>$f(s,r))&&Aw(r,!1)})},YT=(n,e,t)=>{let r=null;const s=n.doc,i=n.scope;gt(s,a=>{for(;e.length>0&&n.currStackItem===null;){const l=s.store,c=e.pop(),u=new Set,f=[];let d=!1;oo(a,c.insertions,h=>{if(h instanceof xt){if(h.redone!==null){let{item:p,diff:m}=xw(l,h.id);m>0&&(p=qn(a,Ge(p.id.client,p.id.clock+m))),h=p}!h.deleted&&i.some(p=>$f(p,h))&&f.push(h)}}),oo(a,c.deletions,h=>{h instanceof xt&&i.some(p=>$f(p,h))&&!ec(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{d=A2(a,h,u,c.insertions,n.ignoreRemoteMapChanges,n)!==null||d});for(let h=f.length-1;h>=0;h--){const p=f[h];n.deleteFilter(p)&&(p.delete(a),d=!0)}n.currStackItem=d?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},n);const o=n.currStackItem;if(o!=null){const a=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:o,type:t,changedParentTypes:a,origin:n},n]),n.currStackItem=null}return o};class XT extends Mb{constructor(e,{captureTimeout:t=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:a=Rb(e)?e[0].doc:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=t,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(y=>l.changedParentTypes.has(y))||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,u=this.redoing,f=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const d=new Zl;l.afterState.forEach((y,b)=>{const x=l.beforeState.get(b)||0,v=y-x;v>0&&Hf(d,b,x,v)});const h=Ts();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&f.length>0&&!c&&!u){const y=f[f.length-1];y.deletions=rw([y.deletions,l.deleteSet]),y.insertions=rw([y.insertions,d])}else f.push(new XH(l.deleteSet,d)),p=!0;!c&&!u&&(this.lastChange=h),oo(l,l.deleteSet,y=>{y instanceof xt&&this.scope.some(b=>$f(b,y))&&Aw(y,!0)});const m=[{stackItem:f[f.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){e=Rb(e)?e:[e],e.forEach(t=>{this.scope.every(r=>r!==t)&&(t.doc!==this.doc&&hH("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>QT(r,this,s)),this.undoStack=[]),t&&(this.redoStack.forEach(s=>QT(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=YT(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=YT(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*ZH(n){const e=We(n.restDecoder);for(let t=0;t<e;t++){const r=We(n.restDecoder),s=n.readClient();let i=We(n.restDecoder);for(let o=0;o<r;o++){const a=n.readInfo();if(a===10){const l=We(n.restDecoder);yield new Dr(Ge(s,i),l),i+=l}else if(wp&a){const l=(a&(ci|hr))===0,c=new xt(Ge(s,i),null,(a&hr)===hr?n.readLeftID():null,null,(a&ci)===ci?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&Lf)===Lf?n.readString():null,E2(n,a));yield c,i+=c.length}else{const l=n.readLen();yield new Mr(Ge(s,i),l),i+=l}}}}class fw{constructor(e,t){this.gen=ZH(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Dr);return this.curr}}class dw{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const e5=n=>Rp(n,DT,zf),t5=(n,e)=>{if(n.constructor===Mr){const{client:t,clock:r}=n.id;return new Mr(Ge(t,r+e),n.length-e)}else if(n.constructor===Dr){const{client:t,clock:r}=n.id;return new Dr(Ge(t,r+e),n.length-e)}else{const t=n,{client:r,clock:s}=t.id;return new xt(Ge(r,s+e),null,Ge(r,s+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},Rp=(n,e=nc,t=Aa)=>{if(n.length===1)return n[0];const r=n.map(u=>new e(Rs(u)));let s=r.map(u=>new fw(u,!0)),i=null;const o=new t,a=new dw(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,h)=>{if(d.curr.id.client===h.curr.id.client){const p=d.curr.id.clock-h.curr.id.clock;return p===0?d.curr.constructor===h.curr.constructor?0:d.curr.constructor===Dr?1:-1:p}else return h.curr.id.client-d.curr.id.client}),s.length!==0;){const u=s[0],f=u.curr.id.client;if(i!==null){let d=u.curr,h=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=u.next(),h=!0;if(d===null||d.id.client!==f||h&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(f!==i.struct.id.client)ao(a,i.struct,i.offset),i={struct:d,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===Dr)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{ao(a,i.struct,i.offset);const p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Dr(Ge(f,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===Dr?i.struct.length-=p:d=t5(d,p)),i.struct.mergeWith(d)||(ao(a,i.struct,i.offset),i={struct:d,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let d=u.curr;d!==null&&d.id.client===f&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==Dr;d=u.next())ao(a,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(ao(a,i.struct,i.offset),i=null),hw(a);const l=r.map(u=>sw(u)),c=rw(l);return tc(o,c),o.toUint8Array()},n5=(n,e,t=nc,r=Aa)=>{const s=LT(e),i=new r,o=new dw(i),a=new t(Rs(n)),l=new fw(a,!1);for(;l.curr;){const u=l.curr,f=u.id.client,d=s.get(f)||0;if(l.curr.constructor===Dr){l.next();continue}if(u.id.clock+u.length>d)for(ao(o,u,li(d-u.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)ao(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=d;)l.next()}hw(o);const c=sw(a);return tc(i,c),i.toUint8Array()},ZT=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:Rt(n.encoder.restEncoder)}),n.encoder.restEncoder=nn(),n.written=0)},ao=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&ZT(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),De(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},hw=n=>{ZT(n);const e=n.encoder.restEncoder;De(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];De(e,r.written),vp(e,r.restEncoder)}},r5=(n,e,t,r)=>{const s=new t(Rs(n)),i=new fw(s,!1),o=new r,a=new dw(o);for(let c=i.curr;c!==null;c=i.next())ao(a,e(c),0);hw(a);const l=sw(s);return tc(o,l),o.toUint8Array()},s5=n=>r5(n,eH,nc,zf),e2="You must not compute changes after the event-handler fired.";class Mp{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=i5(this.currentTarget,this.target))}deletes(e){return ec(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ns(e2);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(s=>{if(s!==null){const i=t._map.get(s);let o,a;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",a=Ob(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",a=Ob(l.content.getContent())):(o="add",a=void 0)}else if(this.deletes(i))o="delete",a=Ob(i.content.getContent());else return;e.set(s,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ns(e2);const t=this.target,r=oi(),s=oi(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let a=null;const l=()=>{a&&i.push(a)};for(let c=t._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,s.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const i5=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;t.unshift(r)}e=e._item.parent}return t},t2=80;let pw=0;class o5{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=pw++}}const a5=n=>{n.timestamp=pw++},n2=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=pw++},l5=(n,e,t)=>{if(n.length>=t2){const r=n.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return n2(r,e,t),r}else{const r=new o5(e,t);return n.push(r),r}},Dp=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((i,o)=>yp(e-i.index)<yp(e-o.index)?i:o);let r=n._start,s=0;for(t!==null&&(r=t.p,s=t.index,a5(t));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return t!==null&&yp(t.index-s)<r.parent.length/t2?(n2(t,r,s),t):l5(n._searchMarker,r,s)},Jf=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const s=n[r];if(t>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){n.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||t>0&&e===s.index)&&(s.index=li(e,s.index+t))}},Pp=(n,e,t)=>{const r=n,s=e.changedParentTypes;for(;Jn(s,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;UT(r._eH,t,e)};class mn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=BT(),this._dEH=BT(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Xr()}clone(){throw Xr()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){FT(this._eH,e)}observeDeep(e){FT(this._dEH,e)}unobserve(e){jT(this._eH,e)}unobserveDeep(e){jT(this._dEH,e)}toJSON(){}}const r2=(n,e,t)=>{e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const s=[];let i=n._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a<o.length&&r>0;a++)s.push(o[a]),r--;e=0}}i=i.right}return s},s2=n=>{const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}t=t.right}return e},i2=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&Ea(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)t.push(s[i])}r=r.right}return t},qf=(n,e)=>{let t=0,r=n._start;for(;r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],t++,n)}r=r.right}},o2=(n,e)=>{const t=[];return qf(n,(r,s)=>{t.push(e(r,s,n))}),t},c5=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const s=t[r++];return t.length<=r&&(t=null),{done:!1,value:s}}}},a2=(n,e)=>{const t=Dp(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Ip=(n,e,t,r)=>{let s=t;const i=n.doc,o=i.clientID,a=i.store,l=t===null?e._start:t.right;let c=[];const u=()=>{c.length>0&&(s=new xt(Ge(o,jt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Ta(c)),s.integrate(n,0),c=[])};r.forEach(f=>{if(f===null)c.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(f);break;default:switch(u(),f.constructor){case Uint8Array:case ArrayBuffer:s=new xt(Ge(o,jt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Qf(new Uint8Array(f))),s.integrate(n,0);break;case xa:s=new xt(Ge(o,jt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Xf(f)),s.integrate(n,0);break;default:if(f instanceof mn)s=new xt(Ge(o,jt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new es(f)),s.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},l2=()=>Ns("Length exceeded!"),c2=(n,e,t,r)=>{if(t>e._length)throw l2();if(t===0)return e._searchMarker&&Jf(e._searchMarker,t,r.length),Ip(n,e,null,r);const s=t,i=Dp(e,t);let o=e._start;for(i!==null&&(o=i.p,t-=i.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&qn(n,Ge(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&Jf(e._searchMarker,s,r.length),Ip(n,e,o,r)},u5=(n,e,t)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return Ip(n,e,s,t)},u2=(n,e,t,r)=>{if(r===0)return;const s=t,i=r,o=Dp(e,t);let a=e._start;for(o!==null&&(a=o.p,t-=o.index);a!==null&&t>0;a=a.right)!a.deleted&&a.countable&&(t<a.length&&qn(n,Ge(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&qn(n,Ge(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw l2();e._searchMarker&&Jf(e._searchMarker,s,-i+r)},Lp=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},mw=(n,e,t,r)=>{const s=e._map.get(t)||null,i=n.doc,o=i.clientID;let a;if(r==null)a=new Ta([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new Ta([r]);break;case Uint8Array:a=new Qf(r);break;case xa:a=new Xf(r);break;default:if(r instanceof mn)a=new es(r);else throw new Error("Unexpected content type")}new xt(Ge(o,jt(i.store,o)),s,s&&s.lastId,null,null,e,t,a).integrate(n,0)},gw=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},f2=n=>{const e={};return n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},d2=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted},f5=(n,e)=>{const t={};return n._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&Ea(i,e)&&(t[s]=i.content.getContent()[i.length-1])}),t},_p=n=>NH(n.entries(),e=>!e[1].deleted);class d5 extends Mp{}class oc extends mn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new oc;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new oc}clone(){const e=new oc;return e.insert(0,this.toArray().map(t=>t instanceof mn?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),Pp(this,e,new d5(this,e))}insert(e,t){this.doc!==null?gt(this.doc,r=>{c2(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?gt(this.doc,t=>{u5(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?gt(this.doc,r=>{u2(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return a2(this,e)}toArray(){return s2(this)}slice(e=0,t=this.length){return r2(this,e,t)}toJSON(){return this.map(e=>e instanceof mn?e.toJSON():e)}map(e){return o2(this,e)}forEach(e){qf(this,e)}[Symbol.iterator](){return c5(this)}_write(e){e.writeTypeRef(_5)}}const h5=n=>new oc;class p5 extends Mp{constructor(e,t,r){super(e,t),this.keysChanged=r}}class ac extends mn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new ac}clone(){const e=new ac;return this.forEach((t,r)=>{e.set(r,t instanceof mn?t.clone():t)}),e}_callObserver(e,t){Pp(this,e,new p5(this,e,t))}toJSON(){const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const s=t.content.getContent()[t.length-1];e[r]=s instanceof mn?s.toJSON():s}}),e}get size(){return[..._p(this._map)].length}keys(){return ew(_p(this._map),e=>e[0])}values(){return ew(_p(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return ew(_p(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?gt(this.doc,t=>{Lp(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?gt(this.doc,r=>{mw(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return gw(this,e)}has(e){return d2(this,e)}clear(){this.doc!==null?gt(this.doc,e=>{this.forEach(function(t,r,s){Lp(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(B5)}}const m5=n=>new ac,lo=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&X8(n,e);class yw{constructor(e,t,r,s){this.left=e,this.right=t,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&dr(),this.right.content.constructor){case Kt:this.right.deleted||lc(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const h2=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case Kt:e.right.deleted||lc(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&qn(n,Ge(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},Bp=(n,e,t,r)=>{const s=new Map,i=r?Dp(e,t):null;if(i){const o=new yw(i.p.left,i.p,i.index,s);return h2(n,o,t-i.index)}else{const o=new yw(null,e._start,0,s);return h2(n,o,t)}},p2=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===Kt&&lo(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const s=n.doc,i=s.clientID;r.forEach((o,a)=>{const l=t.left,c=t.right,u=new xt(Ge(i,jt(s.store,i)),l,l&&l.lastId,c,c&&c.id,e,null,new Kt(a,o));u.integrate(n,0),t.right=u,t.forward()})},lc=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},m2=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===Kt&&lo(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},g2=(n,e,t,r)=>{const s=n.doc,i=s.clientID,o=new Map;for(const a in r){const l=r[a],c=t.currentAttributes.get(a)??null;if(!lo(c,l)){o.set(a,c);const{left:u,right:f}=t;t.right=new xt(Ge(i,jt(s.store,i)),u,u&&u.lastId,f,f&&f.id,e,null,new Kt(a,l)),t.right.integrate(n,0),t.forward()}}return o},bw=(n,e,t,r,s)=>{t.currentAttributes.forEach((d,h)=>{s[h]===void 0&&(s[h]=null)});const i=n.doc,o=i.clientID;m2(t,s);const a=g2(n,e,t,s),l=r.constructor===String?new Zr(r):r instanceof mn?new es(r):new Sa(r);let{left:c,right:u,index:f}=t;e._searchMarker&&Jf(e._searchMarker,t.index,l.getLength()),u=new xt(Ge(o,jt(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,l),u.integrate(n,0),t.right=u,t.index=f,t.forward(),p2(n,e,t,a)},y2=(n,e,t,r,s)=>{const i=n.doc,o=i.clientID;m2(t,s);const a=g2(n,e,t,s);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===Kt));){if(!t.right.deleted)switch(t.right.content.constructor){case Kt:{const{key:l,value:c}=t.right.content,u=s[l];if(u!==void 0){if(lo(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}t.right.delete(n)}else t.currentAttributes.set(l,c);break}default:r<t.right.length&&qn(n,Ge(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
427
427
  `;t.right=new xt(Ge(o,jt(i.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new Zr(l)),t.right.integrate(n,0),t.forward()}p2(n,e,t,a)},b2=(n,e,t,r,s)=>{let i=e;const o=Mn();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Kt){const c=i.content;o.set(c.key,c)}i=i.right}let a=0,l=!1;for(;e!==i;){if(t===e&&(l=!0),!e.deleted){const c=e.content;switch(c.constructor){case Kt:{const{key:u,value:f}=c,d=r.get(u)??null;(o.get(u)!==c||d===f)&&(e.delete(n),a++,!l&&(s.get(u)??null)===f&&d!==f&&(d===null?s.delete(u):s.set(u,d))),!l&&!e.deleted&&lc(s,c);break}}}e=e.right}return a},g5=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Kt){const r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},y5=n=>{let e=0;return gt(n.doc,t=>{let r=n._start,s=n._start,i=Mn();const o=Nb(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case Kt:lc(o,s.content);break;default:e+=b2(t,r,s,i,o),i=Nb(o),r=s;break}s=s.right}}),e},b5=n=>{const e=new Set,t=n.doc;for(const[r,s]of n.afterState.entries()){const i=n.beforeState.get(r)||0;s!==i&&GT(n,t.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===Kt&&o.constructor!==Mr&&e.add(o.parent)})}gt(t,r=>{oo(n,n.deleteSet,s=>{if(s instanceof Mr||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===Kt?e.add(i):g5(r,s)});for(const s of e)y5(s)})},w2=(n,e,t)=>{const r=t,s=Nb(e.currentAttributes),i=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case es:case Sa:case Zr:t<e.right.length&&qn(n,Ge(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}i&&b2(n,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Jf(o._searchMarker,e.index,-r+t),e};class w5 extends Mp{constructor(e,t,r){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];gt(e,r=>{const s=new Map,i=new Map;let o=this.target._start,a=null;const l={};let c="",u=0,f=0;const d=()=>{if(a!==null){let h=null;switch(a){case"delete":f>0&&(h={delete:f}),f=0;break;case"insert":(typeof c=="object"||c.length>0)&&(h={insert:c},s.size>0&&(h.attributes={},s.forEach((p,m)=>{p!==null&&(h.attributes[m]=p)}))),c="";break;case"retain":u>0&&(h={retain:u},Q8(l)||(h.attributes=J8({},l))),u=0;break}h&&t.push(h),a=null}};for(;o!==null;){switch(o.content.constructor){case es:case Sa:this.adds(o)?this.deletes(o)||(d(),a="insert",c=o.content.getContent()[0],d()):this.deletes(o)?(a!=="delete"&&(d(),a="delete"),f+=1):o.deleted||(a!=="retain"&&(d(),a="retain"),u+=1);break;case Zr:this.adds(o)?this.deletes(o)||(a!=="insert"&&(d(),a="insert"),c+=o.content.str):this.deletes(o)?(a!=="delete"&&(d(),a="delete"),f+=o.length):o.deleted||(a!=="retain"&&(d(),a="retain"),u+=o.length);break;case Kt:{const{key:h,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=s.get(h)??null;lo(m,p)?p!==null&&o.delete(r):(a==="retain"&&d(),lo(p,i.get(h)??null)?delete l[h]:l[h]=p)}}else if(this.deletes(o)){i.set(h,p);const m=s.get(h)??null;lo(m,p)||(a==="retain"&&d(),l[h]=m)}else if(!o.deleted){i.set(h,p);const m=l[h];m!==void 0&&(lo(m,p)?m!==null&&o.delete(r):(a==="retain"&&d(),p===null?delete l[h]:l[h]=p))}o.deleted||(a==="insert"&&d(),lc(s,o.content));break}}o=o.right}for(d();t.length>0;){const h=t[t.length-1];if(h.retain!==void 0&&h.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class ka extends mn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ka}clone(){const e=new ka;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const r=new w5(this,e,t);Pp(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Zr&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?gt(this.doc,r=>{const s=new yw(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const a=!t&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
428
428
  `?o.insert.slice(0,-1):o.insert;(typeof a!="string"||a.length>0)&&bw(r,this,s,a,o.attributes||{})}else o.retain!==void 0?y2(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&w2(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){const s=[],i=new Map,o=this.doc;let a="",l=this._start;function c(){if(a.length>0){const f={};let d=!1;i.forEach((p,m)=>{d=!0,f[m]=p});const h={insert:a};d&&(h.attributes=f),s.push(h),a=""}}const u=()=>{for(;l!==null;){if(Ea(l,e)||t!==void 0&&Ea(l,t))switch(l.content.constructor){case Zr:{const f=i.get("ychange");e!==void 0&&!Ea(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(c(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):t!==void 0&&!Ea(l,t)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(c(),i.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(c(),i.delete("ychange")),a+=l.content.str;break}case es:case Sa:{c();const f={insert:l.content.getContent()[0]};if(i.size>0){const d={};f.attributes=d,i.forEach((h,p)=>{d[p]=h})}s.push(f);break}case Kt:Ea(l,e)&&(c(),lc(i,l.content));break}l=l.right}c()};return e||t?gt(o,f=>{e&&cw(f,e),t&&cw(f,t),u()},"cleanup"):u(),s}insert(e,t,r){if(t.length<=0)return;const s=this.doc;s!==null?gt(s,i=>{const o=Bp(i,this,e,!r);r||(r={},o.currentAttributes.forEach((a,l)=>{r[l]=a})),bw(i,this,o,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const s=this.doc;s!==null?gt(s,i=>{const o=Bp(i,this,e,!r);bw(i,this,o,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;const r=this.doc;r!==null?gt(r,s=>{w2(s,Bp(s,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;const s=this.doc;s!==null?gt(s,i=>{const o=Bp(i,this,e,!1);o.right!==null&&y2(i,this,o,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?gt(this.doc,t=>{Lp(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?gt(this.doc,r=>{mw(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return gw(this,e)}getAttributes(){return f2(this)}_write(e){e.writeTypeRef(F5)}}const v5=n=>new ka;class ww{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===Dn||t.constructor===Ca)&&t._start!==null)e=t._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Ca extends mn{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ca}clone(){const e=new Ca;return e.insert(0,this.toArray().map(t=>t instanceof mn?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ww(this,e)}querySelector(e){e=e.toUpperCase();const r=new ww(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),ai(new ww(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Pp(this,e,new E5(this,t,e))}toString(){return o2(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),qf(this,i=>{s.insertBefore(i.toDOM(e,t,r),null)}),s}insert(e,t){this.doc!==null?gt(this.doc,r=>{c2(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)gt(this.doc,r=>{const s=e&&e instanceof mn?e._item:e;Ip(r,this,s,t)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw Ns("Reference item not found");r.splice(s,0,...t)}}delete(e,t=1){this.doc!==null?gt(this.doc,r=>{u2(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return s2(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return a2(this,e)}slice(e=0,t=this.length){return r2(this,e,t)}forEach(e){qf(this,e)}_write(e){e.writeTypeRef(U5)}}const x5=n=>new Ca;class Dn extends Ca{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new Dn(this.nodeName)}clone(){const e=new Dn(this.nodeName),t=this.getAttributes();return q8(t,(r,s)=>{typeof r=="string"&&e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof mn?r.clone():r)),e}toString(){const e=this.getAttributes(),t=[],r=[];for(const a in e)r.push(a);r.sort();const s=r.length;for(let a=0;a<s;a++){const l=r[a];t.push(l+'="'+e[l]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?gt(this.doc,t=>{Lp(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?gt(this.doc,r=>{mw(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return gw(this,e)}hasAttribute(e){return d2(this,e)}getAttributes(e){return e?f5(this,e):f2(this)}toDOM(e=document,t={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const a=i[o];typeof a=="string"&&s.setAttribute(o,a)}return qf(this,o=>{s.appendChild(o.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(j5),e.writeKey(this.nodeName)}}const A5=n=>new Dn(n.readKey());class E5 extends Mp{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class Fp extends ac{constructor(e){super(),this.hookName=e}_copy(){return new Fp(this.hookName)}clone(){const e=new Fp(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){const s=t[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(H5),e.writeKey(this.hookName)}}const k5=n=>new Fp(n.readKey());class pr extends ka{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new pr}clone(){const e=new pr;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const t=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,a)=>o.key<a.key?-1:1),t.push({nodeName:s,attrs:i})}t.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<t.length;s++){const i=t[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const a=i.attrs[o];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let s=t.length-1;s>=0;s--)r+=`</${t[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(z5)}}const C5=n=>new pr;class vw{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Xr()}mergeWith(e){return!1}write(e,t,r){throw Xr()}integrate(e,t){throw Xr()}}const S5=0;class Mr extends vw{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),$T(e.doc.store,this)}write(e,t){e.writeInfo(S5),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Qf{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Qf(this.content)}splice(e){throw Xr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const T5=n=>new Qf(n.readBuf());class Yf{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Yf(this.len)}splice(e){const t=new Yf(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Hf(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const N5=n=>new Yf(n.readLen()),v2=(n,e)=>new xa({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Xf{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Xf(v2(this.doc.guid,this.opts))}splice(e){throw Xr()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const O5=n=>new Xf(v2(n.readString(),n.readAny()));class Sa{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Sa(this.embed)}splice(e){throw Xr()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const R5=n=>new Sa(n.readJSON());class Kt{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Kt(this.key,this.value)}splice(e){throw Xr()}mergeWith(e){return!1}integrate(e,t){const r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const M5=n=>new Kt(n.readKey(),n.readJSON());class jp{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new jp(this.arr)}splice(e){const t=new jp(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let s=t;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const D5=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++){const s=n.readString();s==="undefined"?t.push(void 0):t.push(JSON.parse(s))}return new jp(t)};class Ta{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ta(this.arr)}splice(e){const t=new Ta(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let s=t;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const P5=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new Ta(t)};class Zr{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Zr(this.str)}splice(e){const t=new Zr(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}const I5=n=>new Zr(n.readString()),L5=[h5,m5,v5,A5,x5,k5,C5],_5=0,B5=1,F5=2,j5=3,U5=4,H5=5,z5=6;class es{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new es(this.type._copy())}splice(e){throw Xr()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const V5=n=>new es(L5[n.readTypeRef()](n)),xw=(n,e)=>{let t=e,r=0,s;do r>0&&(t=Ge(t.client,t.clock+r)),s=ic(n,t),r=t.clock-s.id.clock,t=s.redone;while(t!==null&&s instanceof xt);return{item:s,diff:r}},Aw=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},Up=(n,e,t)=>{const{client:r,clock:s}=e.id,i=new xt(Ge(r,s+t),e,Ge(r,s+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=Ge(e.redone.client,e.redone.clock+t)),e.right=i,i.right!==null&&(i.right.left=i),n._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=t,i},x2=(n,e)=>m8(n,t=>ec(t.deletions,e)),A2=(n,e,t,r,s,i)=>{const o=n.doc,a=o.store,l=o.clientID,c=e.redone;if(c!==null)return qn(n,c);let u=e.parent._item,f=null,d;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!t.has(u)||A2(n,u,t,r,s,i)===null))return null;for(;u.redone!==null;)u=qn(n,u.redone)}const h=u===null?e.parent:u.content.type;if(e.parentSub===null){for(f=e.left,d=e;f!==null;){let b=f;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:qn(n,b.redone);if(b!==null&&b.parent._item===u){f=b;break}f=f.left}for(;d!==null;){let b=d;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:qn(n,b.redone);if(b!==null&&b.parent._item===u){d=b;break}d=d.right}}else if(d=null,e.right&&!s){for(f=e;f!==null&&f.right!==null&&(f.right.redone||ec(r,f.right.id)||x2(i.undoStack,f.right.id)||x2(i.redoStack,f.right.id));)for(f=f.right;f.redone;)f=qn(n,f.redone);if(f&&f.right!==null)return null}else f=h._map.get(e.parentSub)||null;const p=jt(a,l),m=Ge(l,p),y=new xt(m,f,f&&f.lastId,d,d&&d.id,h,e.parentSub,e.content.copy());return e.redone=m,Aw(y,!0),y.integrate(n,0),y};let xt=class tx extends vw{constructor(e,t,r,s,i,o,a,l){super(e,l.getLength()),this.origin=r,this.left=t,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?WS:0}set marker(e){(this.info&Ib)>0!==e&&(this.info^=Ib)}get marker(){return(this.info&Ib)>0}get keep(){return(this.info&$S)>0}set keep(e){this.keep!==e&&(this.info^=$S)}get countable(){return(this.info&WS)>0}get deleted(){return(this.info&Pb)>0}set deleted(e){this.deleted!==e&&(this.info^=Pb)}markDeleted(){this.info|=Pb}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=jt(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=jt(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===rc&&this.id.client!==this.parent.client&&this.parent.clock>=jt(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=WT(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=qn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Mr||this.right&&this.right.constructor===Mr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===tx&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===tx&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===rc){const r=ic(t,this.parent);r.constructor===Mr?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=WT(e,e.doc.store,Ge(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),sc(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(sc(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(ic(e.doc.store,s.origin)))i.has(ic(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),$T(e.doc.store,this),this.content.integrate(e,this),JT(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Mr(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Ge(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&sc(e.origin,this.lastId)&&this.right===e&&sc(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Hf(e.deleteSet,this.id.client,this.id.clock,this.length),JT(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw dr();this.content.gc(e),t?JH(e,this,new Mr(this.id,this.length)):this.content=new Yf(this.length)}write(e,t){const r=t>0?Ge(this.id.client,this.id.clock+t-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&wp|(r===null?0:hr)|(s===null?0:ci)|(i===null?0:Lf);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=Vf(a);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===rc?(e.writeParentInfo(!1),e.writeLeftID(a)):dr();i!==null&&e.writeString(i)}this.content.write(e,t)}};const E2=(n,e)=>$5[e&wp](n),$5=[()=>{dr()},N5,D5,T5,I5,R5,M5,V5,P5,O5,()=>{dr()}],W5=10;class Dr extends vw{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){dr()}write(e,t){e.writeInfo(W5),De(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const k2=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},C2="__ $YJS$ __";k2[C2]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),k2[C2]=!0;function Hp(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var S2={exports:{}};(function(n,e){(function(t){n.exports=t()})(function(){var t=Math.floor,r=Math.abs,s=Math.pow;return function(){function i(o,a,l){function c(d,h){if(!a[d]){if(!o[d]){var p=typeof Hp=="function"&&Hp;if(!h&&p)return p(d,!0);if(u)return u(d,!0);var m=new Error("Cannot find module '"+d+"'");throw m.code="MODULE_NOT_FOUND",m}var y=a[d]={exports:{}};o[d][0].call(y.exports,function(b){var x=o[d][1][b];return c(x||b)},y,y.exports,i,o,a,l)}return a[d].exports}for(var u=typeof Hp=="function"&&Hp,f=0;f<l.length;f++)c(l[f]);return c}return i}()({1:[function(i,o,a){function l(w){var E=w.length;if(0<E%4)throw new Error("Invalid string. Length must be a multiple of 4");var k=w.indexOf("=");k===-1&&(k=E);var S=k===E?0:4-k%4;return[k,S]}function c(w,E,k){return 3*(E+k)/4-k}function u(w){var E,k,S=l(w),M=S[0],O=S[1],R=new y(c(w,M,O)),D=0,F=0<O?M-4:M;for(k=0;k<F;k+=4)E=m[w.charCodeAt(k)]<<18|m[w.charCodeAt(k+1)]<<12|m[w.charCodeAt(k+2)]<<6|m[w.charCodeAt(k+3)],R[D++]=255&E>>16,R[D++]=255&E>>8,R[D++]=255&E;return O===2&&(E=m[w.charCodeAt(k)]<<2|m[w.charCodeAt(k+1)]>>4,R[D++]=255&E),O===1&&(E=m[w.charCodeAt(k)]<<10|m[w.charCodeAt(k+1)]<<4|m[w.charCodeAt(k+2)]>>2,R[D++]=255&E>>8,R[D++]=255&E),R}function f(w){return p[63&w>>18]+p[63&w>>12]+p[63&w>>6]+p[63&w]}function d(w,E,k){for(var S,M=[],O=E;O<k;O+=3)S=(16711680&w[O]<<16)+(65280&w[O+1]<<8)+(255&w[O+2]),M.push(f(S));return M.join("")}function h(w){for(var E,k=w.length,S=k%3,M=[],O=16383,R=0,D=k-S;R<D;R+=O)M.push(d(w,R,R+O>D?D:R+O));return S===1?(E=w[k-1],M.push(p[E>>2]+p[63&E<<4]+"==")):S===2&&(E=(w[k-2]<<8)+w[k-1],M.push(p[E>>10]+p[63&E>>4]+p[63&E<<2]+"=")),M.join("")}a.byteLength=function(w){var E=l(w),k=E[0],S=E[1];return 3*(k+S)/4-S},a.toByteArray=u,a.fromByteArray=h;for(var p=[],m=[],y=typeof Uint8Array>"u"?Array:Uint8Array,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=0,v=b.length;x<v;++x)p[x]=b[x],m[b.charCodeAt(x)]=x;m[45]=62,m[95]=63},{}],2:[function(){},{}],3:[function(i,o,a){(function(){(function(){var l=String.fromCharCode,c=Math.min;function u(g){if(2147483647<g)throw new RangeError('The value "'+g+'" is invalid for option "size"');var A=new Uint8Array(g);return A.__proto__=f.prototype,A}function f(g,A,N){if(typeof g=="number"){if(typeof A=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(g)}return d(g,A,N)}function d(g,A,N){if(typeof g=="string")return y(g,A);if(ArrayBuffer.isView(g))return b(g);if(g==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g);if(z(g,ArrayBuffer)||g&&z(g.buffer,ArrayBuffer))return x(g,A,N);if(typeof g=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var B=g.valueOf&&g.valueOf();if(B!=null&&B!==g)return f.from(B,A,N);var W=v(g);if(W)return W;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof g[Symbol.toPrimitive]=="function")return f.from(g[Symbol.toPrimitive]("string"),A,N);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof g)}function h(g){if(typeof g!="number")throw new TypeError('"size" argument must be of type number');if(0>g)throw new RangeError('The value "'+g+'" is invalid for option "size"')}function p(g,A,N){return h(g),0>=g||A===void 0?u(g):typeof N=="string"?u(g).fill(A,N):u(g).fill(A)}function m(g){return h(g),u(0>g?0:0|w(g))}function y(g,A){if((typeof A!="string"||A==="")&&(A="utf8"),!f.isEncoding(A))throw new TypeError("Unknown encoding: "+A);var N=0|E(g,A),B=u(N),W=B.write(g,A);return W!==N&&(B=B.slice(0,W)),B}function b(g){for(var A=0>g.length?0:0|w(g.length),N=u(A),B=0;B<A;B+=1)N[B]=255&g[B];return N}function x(g,A,N){if(0>A||g.byteLength<A)throw new RangeError('"offset" is outside of buffer bounds');if(g.byteLength<A+(N||0))throw new RangeError('"length" is outside of buffer bounds');var B;return B=A===void 0&&N===void 0?new Uint8Array(g):N===void 0?new Uint8Array(g,A):new Uint8Array(g,A,N),B.__proto__=f.prototype,B}function v(g){if(f.isBuffer(g)){var A=0|w(g.length),N=u(A);return N.length===0||g.copy(N,0,0,A),N}return g.length===void 0?g.type==="Buffer"&&Array.isArray(g.data)?b(g.data):void 0:typeof g.length!="number"||J(g.length)?u(0):b(g)}function w(g){if(g>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|g}function E(g,A){if(f.isBuffer(g))return g.length;if(ArrayBuffer.isView(g)||z(g,ArrayBuffer))return g.byteLength;if(typeof g!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof g);var N=g.length,B=2<arguments.length&&arguments[2]===!0;if(!B&&N===0)return 0;for(var W=!1;;)switch(A){case"ascii":case"latin1":case"binary":return N;case"utf8":case"utf-8":return le(g).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*N;case"hex":return N>>>1;case"base64":return be(g).length;default:if(W)return B?-1:le(g).length;A=(""+A).toLowerCase(),W=!0}}function k(g,A,N){var B=!1;if((A===void 0||0>A)&&(A=0),A>this.length||((N===void 0||N>this.length)&&(N=this.length),0>=N)||(N>>>=0,A>>>=0,N<=A))return"";for(g||(g="utf8");;)switch(g){case"hex":return ke(this,A,N);case"utf8":case"utf-8":return Y(this,A,N);case"ascii":return Z(this,A,N);case"latin1":case"binary":return me(this,A,N);case"base64":return G(this,A,N);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pe(this,A,N);default:if(B)throw new TypeError("Unknown encoding: "+g);g=(g+"").toLowerCase(),B=!0}}function S(g,A,N){var B=g[A];g[A]=g[N],g[N]=B}function M(g,A,N,B,W){if(g.length===0)return-1;if(typeof N=="string"?(B=N,N=0):2147483647<N?N=2147483647:-2147483648>N&&(N=-2147483648),N=+N,J(N)&&(N=W?0:g.length-1),0>N&&(N=g.length+N),N>=g.length){if(W)return-1;N=g.length-1}else if(0>N)if(W)N=0;else return-1;if(typeof A=="string"&&(A=f.from(A,B)),f.isBuffer(A))return A.length===0?-1:O(g,A,N,B,W);if(typeof A=="number")return A&=255,typeof Uint8Array.prototype.indexOf=="function"?W?Uint8Array.prototype.indexOf.call(g,A,N):Uint8Array.prototype.lastIndexOf.call(g,A,N):O(g,[A],N,B,W);throw new TypeError("val must be string, number or Buffer")}function O(g,A,N,B,W){function Q(sr,X){return ye===1?sr[X]:sr.readUInt16BE(X*ye)}var ye=1,Se=g.length,qe=A.length;if(B!==void 0&&(B=(B+"").toLowerCase(),B==="ucs2"||B==="ucs-2"||B==="utf16le"||B==="utf-16le")){if(2>g.length||2>A.length)return-1;ye=2,Se/=2,qe/=2,N/=2}var je;if(W){var Be=-1;for(je=N;je<Se;je++)if(Q(g,je)!==Q(A,Be===-1?0:je-Be))Be!==-1&&(je-=je-Be),Be=-1;else if(Be===-1&&(Be=je),je-Be+1===qe)return Be*ye}else for(N+qe>Se&&(N=Se-qe),je=N;0<=je;je--){for(var ct=!0,Un=0;Un<qe;Un++)if(Q(g,je+Un)!==Q(A,Un)){ct=!1;break}if(ct)return je}return-1}function R(g,A,N,B){N=+N||0;var W=g.length-N;B?(B=+B,B>W&&(B=W)):B=W;var Q=A.length;B>Q/2&&(B=Q/2);for(var ye,Se=0;Se<B;++Se){if(ye=parseInt(A.substr(2*Se,2),16),J(ye))return Se;g[N+Se]=ye}return Se}function D(g,A,N,B){return _e(le(A,g.length-N),g,N,B)}function F(g,A,N,B){return _e(ze(A),g,N,B)}function U(g,A,N,B){return F(g,A,N,B)}function K(g,A,N,B){return _e(be(A),g,N,B)}function _(g,A,N,B){return _e(ae(A,g.length-N),g,N,B)}function G(g,A,N){return A===0&&N===g.length?ne.fromByteArray(g):ne.fromByteArray(g.slice(A,N))}function Y(g,A,N){N=c(g.length,N);for(var B=[],W=A;W<N;){var Q=g[W],ye=null,Se=239<Q?4:223<Q?3:191<Q?2:1;if(W+Se<=N){var qe,je,Be,ct;Se===1?128>Q&&(ye=Q):Se===2?(qe=g[W+1],(192&qe)==128&&(ct=(31&Q)<<6|63&qe,127<ct&&(ye=ct))):Se===3?(qe=g[W+1],je=g[W+2],(192&qe)==128&&(192&je)==128&&(ct=(15&Q)<<12|(63&qe)<<6|63&je,2047<ct&&(55296>ct||57343<ct)&&(ye=ct))):Se===4&&(qe=g[W+1],je=g[W+2],Be=g[W+3],(192&qe)==128&&(192&je)==128&&(192&Be)==128&&(ct=(15&Q)<<18|(63&qe)<<12|(63&je)<<6|63&Be,65535<ct&&1114112>ct&&(ye=ct)))}ye===null?(ye=65533,Se=1):65535<ye&&(ye-=65536,B.push(55296|1023&ye>>>10),ye=56320|1023&ye),B.push(ye),W+=Se}return re(B)}function re(g){var A=g.length;if(A<=4096)return l.apply(String,g);for(var N="",B=0;B<A;)N+=l.apply(String,g.slice(B,B+=4096));return N}function Z(g,A,N){var B="";N=c(g.length,N);for(var W=A;W<N;++W)B+=l(127&g[W]);return B}function me(g,A,N){var B="";N=c(g.length,N);for(var W=A;W<N;++W)B+=l(g[W]);return B}function ke(g,A,N){var B=g.length;(!A||0>A)&&(A=0),(!N||0>N||N>B)&&(N=B);for(var W="",Q=A;Q<N;++Q)W+=Ze(g[Q]);return W}function Pe(g,A,N){for(var B=g.slice(A,N),W="",Q=0;Q<B.length;Q+=2)W+=l(B[Q]+256*B[Q+1]);return W}function Ce(g,A,N){if(g%1!=0||0>g)throw new RangeError("offset is not uint");if(g+A>N)throw new RangeError("Trying to access beyond buffer length")}function Ee(g,A,N,B,W,Q){if(!f.isBuffer(g))throw new TypeError('"buffer" argument must be a Buffer instance');if(A>W||A<Q)throw new RangeError('"value" argument is out of bounds');if(N+B>g.length)throw new RangeError("Index out of range")}function Ue(g,A,N,B){if(N+B>g.length)throw new RangeError("Index out of range");if(0>N)throw new RangeError("Index out of range")}function Fe(g,A,N,B,W){return A=+A,N>>>=0,W||Ue(g,A,N,4),ce.write(g,A,N,B,23,4),N+4}function He(g,A,N,B,W){return A=+A,N>>>=0,W||Ue(g,A,N,8),ce.write(g,A,N,B,52,8),N+8}function Le(g){if(g=g.split("=")[0],g=g.trim().replace(P,""),2>g.length)return"";for(;g.length%4!=0;)g+="=";return g}function Ze(g){return 16>g?"0"+g.toString(16):g.toString(16)}function le(g,A){A=A||1/0;for(var N,B=g.length,W=null,Q=[],ye=0;ye<B;++ye){if(N=g.charCodeAt(ye),55295<N&&57344>N){if(!W){if(56319<N){-1<(A-=3)&&Q.push(239,191,189);continue}else if(ye+1===B){-1<(A-=3)&&Q.push(239,191,189);continue}W=N;continue}if(56320>N){-1<(A-=3)&&Q.push(239,191,189),W=N;continue}N=(W-55296<<10|N-56320)+65536}else W&&-1<(A-=3)&&Q.push(239,191,189);if(W=null,128>N){if(0>(A-=1))break;Q.push(N)}else if(2048>N){if(0>(A-=2))break;Q.push(192|N>>6,128|63&N)}else if(65536>N){if(0>(A-=3))break;Q.push(224|N>>12,128|63&N>>6,128|63&N)}else if(1114112>N){if(0>(A-=4))break;Q.push(240|N>>18,128|63&N>>12,128|63&N>>6,128|63&N)}else throw new Error("Invalid code point")}return Q}function ze(g){for(var A=[],N=0;N<g.length;++N)A.push(255&g.charCodeAt(N));return A}function ae(g,A){for(var N,B,W,Q=[],ye=0;ye<g.length&&!(0>(A-=2));++ye)N=g.charCodeAt(ye),B=N>>8,W=N%256,Q.push(W),Q.push(B);return Q}function be(g){return ne.toByteArray(Le(g))}function _e(g,A,N,B){for(var W=0;W<B&&!(W+N>=A.length||W>=g.length);++W)A[W+N]=g[W];return W}function z(g,A){return g instanceof A||g!=null&&g.constructor!=null&&g.constructor.name!=null&&g.constructor.name===A.name}function J(g){return g!==g}var ne=i("base64-js"),ce=i("ieee754");a.Buffer=f,a.SlowBuffer=function(g){return+g!=g&&(g=0),f.alloc(+g)},a.INSPECT_MAX_BYTES=50,a.kMaxLength=2147483647,f.TYPED_ARRAY_SUPPORT=function(){try{var g=new Uint8Array(1);return g.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},g.foo()===42}catch{return!1}}(),f.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){return f.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){return f.isBuffer(this)?this.byteOffset:void 0}}),typeof Symbol<"u"&&Symbol.species!=null&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),f.poolSize=8192,f.from=function(g,A,N){return d(g,A,N)},f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,f.alloc=function(g,A,N){return p(g,A,N)},f.allocUnsafe=function(g){return m(g)},f.allocUnsafeSlow=function(g){return m(g)},f.isBuffer=function(g){return g!=null&&g._isBuffer===!0&&g!==f.prototype},f.compare=function(g,A){if(z(g,Uint8Array)&&(g=f.from(g,g.offset,g.byteLength)),z(A,Uint8Array)&&(A=f.from(A,A.offset,A.byteLength)),!f.isBuffer(g)||!f.isBuffer(A))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(g===A)return 0;for(var N=g.length,B=A.length,W=0,Q=c(N,B);W<Q;++W)if(g[W]!==A[W]){N=g[W],B=A[W];break}return N<B?-1:B<N?1:0},f.isEncoding=function(g){switch((g+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(g,A){if(!Array.isArray(g))throw new TypeError('"list" argument must be an Array of Buffers');if(g.length===0)return f.alloc(0);var N;if(A===void 0)for(A=0,N=0;N<g.length;++N)A+=g[N].length;var B=f.allocUnsafe(A),W=0;for(N=0;N<g.length;++N){var Q=g[N];if(z(Q,Uint8Array)&&(Q=f.from(Q)),!f.isBuffer(Q))throw new TypeError('"list" argument must be an Array of Buffers');Q.copy(B,W),W+=Q.length}return B},f.byteLength=E,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var g=this.length;if(g%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var A=0;A<g;A+=2)S(this,A,A+1);return this},f.prototype.swap32=function(){var g=this.length;if(g%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var A=0;A<g;A+=4)S(this,A,A+3),S(this,A+1,A+2);return this},f.prototype.swap64=function(){var g=this.length;if(g%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var A=0;A<g;A+=8)S(this,A,A+7),S(this,A+1,A+6),S(this,A+2,A+5),S(this,A+3,A+4);return this},f.prototype.toString=function(){var g=this.length;return g===0?"":arguments.length===0?Y(this,0,g):k.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(g){if(!f.isBuffer(g))throw new TypeError("Argument must be a Buffer");return this===g||f.compare(this,g)===0},f.prototype.inspect=function(){var g="",A=a.INSPECT_MAX_BYTES;return g=this.toString("hex",0,A).replace(/(.{2})/g,"$1 ").trim(),this.length>A&&(g+=" ... "),"<Buffer "+g+">"},f.prototype.compare=function(g,A,N,B,W){if(z(g,Uint8Array)&&(g=f.from(g,g.offset,g.byteLength)),!f.isBuffer(g))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof g);if(A===void 0&&(A=0),N===void 0&&(N=g?g.length:0),B===void 0&&(B=0),W===void 0&&(W=this.length),0>A||N>g.length||0>B||W>this.length)throw new RangeError("out of range index");if(B>=W&&A>=N)return 0;if(B>=W)return-1;if(A>=N)return 1;if(A>>>=0,N>>>=0,B>>>=0,W>>>=0,this===g)return 0;for(var Q=W-B,ye=N-A,Se=c(Q,ye),qe=this.slice(B,W),je=g.slice(A,N),Be=0;Be<Se;++Be)if(qe[Be]!==je[Be]){Q=qe[Be],ye=je[Be];break}return Q<ye?-1:ye<Q?1:0},f.prototype.includes=function(g,A,N){return this.indexOf(g,A,N)!==-1},f.prototype.indexOf=function(g,A,N){return M(this,g,A,N,!0)},f.prototype.lastIndexOf=function(g,A,N){return M(this,g,A,N,!1)},f.prototype.write=function(g,A,N,B){if(A===void 0)B="utf8",N=this.length,A=0;else if(N===void 0&&typeof A=="string")B=A,N=this.length,A=0;else if(isFinite(A))A>>>=0,isFinite(N)?(N>>>=0,B===void 0&&(B="utf8")):(B=N,N=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var W=this.length-A;if((N===void 0||N>W)&&(N=W),0<g.length&&(0>N||0>A)||A>this.length)throw new RangeError("Attempt to write outside buffer bounds");B||(B="utf8");for(var Q=!1;;)switch(B){case"hex":return R(this,g,A,N);case"utf8":case"utf-8":return D(this,g,A,N);case"ascii":return F(this,g,A,N);case"latin1":case"binary":return U(this,g,A,N);case"base64":return K(this,g,A,N);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,g,A,N);default:if(Q)throw new TypeError("Unknown encoding: "+B);B=(""+B).toLowerCase(),Q=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},f.prototype.slice=function(g,A){var N=this.length;g=~~g,A=A===void 0?N:~~A,0>g?(g+=N,0>g&&(g=0)):g>N&&(g=N),0>A?(A+=N,0>A&&(A=0)):A>N&&(A=N),A<g&&(A=g);var B=this.subarray(g,A);return B.__proto__=f.prototype,B},f.prototype.readUIntLE=function(g,A,N){g>>>=0,A>>>=0,N||Ce(g,A,this.length);for(var B=this[g],W=1,Q=0;++Q<A&&(W*=256);)B+=this[g+Q]*W;return B},f.prototype.readUIntBE=function(g,A,N){g>>>=0,A>>>=0,N||Ce(g,A,this.length);for(var B=this[g+--A],W=1;0<A&&(W*=256);)B+=this[g+--A]*W;return B},f.prototype.readUInt8=function(g,A){return g>>>=0,A||Ce(g,1,this.length),this[g]},f.prototype.readUInt16LE=function(g,A){return g>>>=0,A||Ce(g,2,this.length),this[g]|this[g+1]<<8},f.prototype.readUInt16BE=function(g,A){return g>>>=0,A||Ce(g,2,this.length),this[g]<<8|this[g+1]},f.prototype.readUInt32LE=function(g,A){return g>>>=0,A||Ce(g,4,this.length),(this[g]|this[g+1]<<8|this[g+2]<<16)+16777216*this[g+3]},f.prototype.readUInt32BE=function(g,A){return g>>>=0,A||Ce(g,4,this.length),16777216*this[g]+(this[g+1]<<16|this[g+2]<<8|this[g+3])},f.prototype.readIntLE=function(g,A,N){g>>>=0,A>>>=0,N||Ce(g,A,this.length);for(var B=this[g],W=1,Q=0;++Q<A&&(W*=256);)B+=this[g+Q]*W;return W*=128,B>=W&&(B-=s(2,8*A)),B},f.prototype.readIntBE=function(g,A,N){g>>>=0,A>>>=0,N||Ce(g,A,this.length);for(var B=A,W=1,Q=this[g+--B];0<B&&(W*=256);)Q+=this[g+--B]*W;return W*=128,Q>=W&&(Q-=s(2,8*A)),Q},f.prototype.readInt8=function(g,A){return g>>>=0,A||Ce(g,1,this.length),128&this[g]?-1*(255-this[g]+1):this[g]},f.prototype.readInt16LE=function(g,A){g>>>=0,A||Ce(g,2,this.length);var N=this[g]|this[g+1]<<8;return 32768&N?4294901760|N:N},f.prototype.readInt16BE=function(g,A){g>>>=0,A||Ce(g,2,this.length);var N=this[g+1]|this[g]<<8;return 32768&N?4294901760|N:N},f.prototype.readInt32LE=function(g,A){return g>>>=0,A||Ce(g,4,this.length),this[g]|this[g+1]<<8|this[g+2]<<16|this[g+3]<<24},f.prototype.readInt32BE=function(g,A){return g>>>=0,A||Ce(g,4,this.length),this[g]<<24|this[g+1]<<16|this[g+2]<<8|this[g+3]},f.prototype.readFloatLE=function(g,A){return g>>>=0,A||Ce(g,4,this.length),ce.read(this,g,!0,23,4)},f.prototype.readFloatBE=function(g,A){return g>>>=0,A||Ce(g,4,this.length),ce.read(this,g,!1,23,4)},f.prototype.readDoubleLE=function(g,A){return g>>>=0,A||Ce(g,8,this.length),ce.read(this,g,!0,52,8)},f.prototype.readDoubleBE=function(g,A){return g>>>=0,A||Ce(g,8,this.length),ce.read(this,g,!1,52,8)},f.prototype.writeUIntLE=function(g,A,N,B){if(g=+g,A>>>=0,N>>>=0,!B){var W=s(2,8*N)-1;Ee(this,g,A,N,W,0)}var Q=1,ye=0;for(this[A]=255&g;++ye<N&&(Q*=256);)this[A+ye]=255&g/Q;return A+N},f.prototype.writeUIntBE=function(g,A,N,B){if(g=+g,A>>>=0,N>>>=0,!B){var W=s(2,8*N)-1;Ee(this,g,A,N,W,0)}var Q=N-1,ye=1;for(this[A+Q]=255&g;0<=--Q&&(ye*=256);)this[A+Q]=255&g/ye;return A+N},f.prototype.writeUInt8=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,1,255,0),this[A]=255&g,A+1},f.prototype.writeUInt16LE=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,2,65535,0),this[A]=255&g,this[A+1]=g>>>8,A+2},f.prototype.writeUInt16BE=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,2,65535,0),this[A]=g>>>8,this[A+1]=255&g,A+2},f.prototype.writeUInt32LE=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,4,4294967295,0),this[A+3]=g>>>24,this[A+2]=g>>>16,this[A+1]=g>>>8,this[A]=255&g,A+4},f.prototype.writeUInt32BE=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,4,4294967295,0),this[A]=g>>>24,this[A+1]=g>>>16,this[A+2]=g>>>8,this[A+3]=255&g,A+4},f.prototype.writeIntLE=function(g,A,N,B){if(g=+g,A>>>=0,!B){var W=s(2,8*N-1);Ee(this,g,A,N,W-1,-W)}var Q=0,ye=1,Se=0;for(this[A]=255&g;++Q<N&&(ye*=256);)0>g&&Se===0&&this[A+Q-1]!==0&&(Se=1),this[A+Q]=255&(g/ye>>0)-Se;return A+N},f.prototype.writeIntBE=function(g,A,N,B){if(g=+g,A>>>=0,!B){var W=s(2,8*N-1);Ee(this,g,A,N,W-1,-W)}var Q=N-1,ye=1,Se=0;for(this[A+Q]=255&g;0<=--Q&&(ye*=256);)0>g&&Se===0&&this[A+Q+1]!==0&&(Se=1),this[A+Q]=255&(g/ye>>0)-Se;return A+N},f.prototype.writeInt8=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,1,127,-128),0>g&&(g=255+g+1),this[A]=255&g,A+1},f.prototype.writeInt16LE=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,2,32767,-32768),this[A]=255&g,this[A+1]=g>>>8,A+2},f.prototype.writeInt16BE=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,2,32767,-32768),this[A]=g>>>8,this[A+1]=255&g,A+2},f.prototype.writeInt32LE=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,4,2147483647,-2147483648),this[A]=255&g,this[A+1]=g>>>8,this[A+2]=g>>>16,this[A+3]=g>>>24,A+4},f.prototype.writeInt32BE=function(g,A,N){return g=+g,A>>>=0,N||Ee(this,g,A,4,2147483647,-2147483648),0>g&&(g=4294967295+g+1),this[A]=g>>>24,this[A+1]=g>>>16,this[A+2]=g>>>8,this[A+3]=255&g,A+4},f.prototype.writeFloatLE=function(g,A,N){return Fe(this,g,A,!0,N)},f.prototype.writeFloatBE=function(g,A,N){return Fe(this,g,A,!1,N)},f.prototype.writeDoubleLE=function(g,A,N){return He(this,g,A,!0,N)},f.prototype.writeDoubleBE=function(g,A,N){return He(this,g,A,!1,N)},f.prototype.copy=function(g,A,N,B){if(!f.isBuffer(g))throw new TypeError("argument should be a Buffer");if(N||(N=0),B||B===0||(B=this.length),A>=g.length&&(A=g.length),A||(A=0),0<B&&B<N&&(B=N),B===N||g.length===0||this.length===0)return 0;if(0>A)throw new RangeError("targetStart out of bounds");if(0>N||N>=this.length)throw new RangeError("Index out of range");if(0>B)throw new RangeError("sourceEnd out of bounds");B>this.length&&(B=this.length),g.length-A<B-N&&(B=g.length-A+N);var W=B-N;if(this===g&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(A,N,B);else if(this===g&&N<A&&A<B)for(var Q=W-1;0<=Q;--Q)g[Q+A]=this[Q+N];else Uint8Array.prototype.set.call(g,this.subarray(N,B),A);return W},f.prototype.fill=function(g,A,N,B){if(typeof g=="string"){if(typeof A=="string"?(B=A,A=0,N=this.length):typeof N=="string"&&(B=N,N=this.length),B!==void 0&&typeof B!="string")throw new TypeError("encoding must be a string");if(typeof B=="string"&&!f.isEncoding(B))throw new TypeError("Unknown encoding: "+B);if(g.length===1){var W=g.charCodeAt(0);(B==="utf8"&&128>W||B==="latin1")&&(g=W)}}else typeof g=="number"&&(g&=255);if(0>A||this.length<A||this.length<N)throw new RangeError("Out of range index");if(N<=A)return this;A>>>=0,N=N===void 0?this.length:N>>>0,g||(g=0);var Q;if(typeof g=="number")for(Q=A;Q<N;++Q)this[Q]=g;else{var ye=f.isBuffer(g)?g:f.from(g,B),Se=ye.length;if(Se===0)throw new TypeError('The value "'+g+'" is invalid for argument "value"');for(Q=0;Q<N-A;++Q)this[Q+A]=ye[Q%Se]}return this};var P=/[^+/0-9A-Za-z-_]/g}).call(this)}).call(this,i("buffer").Buffer)},{"base64-js":1,buffer:3,ieee754:9}],4:[function(i,o,a){(function(l){(function(){function c(){let f;try{f=a.storage.getItem("debug")}catch{}return!f&&typeof l<"u"&&"env"in l&&(f=l.env.DEBUG),f}a.formatArgs=function(f){if(f[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+f[0]+(this.useColors?"%c ":" ")+"+"+o.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;f.splice(1,0,d,"color: inherit");let h=0,p=0;f[0].replace(/%[a-zA-Z%]/g,m=>{m==="%%"||(h++,m==="%c"&&(p=h))}),f.splice(p,0,d)},a.save=function(f){try{f?a.storage.setItem("debug",f):a.storage.removeItem("debug")}catch{}},a.load=c,a.useColors=function(){return!!(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},a.storage=function(){try{return localStorage}catch{}}(),a.destroy=(()=>{let f=!1;return()=>{f||(f=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),a.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],a.log=console.debug||console.log||(()=>{}),o.exports=i("./common")(a);const{formatters:u}=o.exports;u.j=function(f){try{return JSON.stringify(f)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}}).call(this)}).call(this,i("_process"))},{"./common":5,_process:12}],5:[function(i,o){o.exports=function(a){function l(f){function d(...m){if(!d.enabled)return;const y=d,b=+new Date,x=b-(h||b);y.diff=x,y.prev=h,y.curr=b,h=b,m[0]=l.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let v=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(E,k)=>{if(E==="%%")return"%";v++;const S=l.formatters[k];if(typeof S=="function"){const M=m[v];E=S.call(y,M),m.splice(v,1),v--}return E}),l.formatArgs.call(y,m),(y.log||l.log).apply(y,m)}let h,p=null;return d.namespace=f,d.useColors=l.useColors(),d.color=l.selectColor(f),d.extend=c,d.destroy=l.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>p===null?l.enabled(f):p,set:m=>{p=m}}),typeof l.init=="function"&&l.init(d),d}function c(f,d){const h=l(this.namespace+(typeof d>"u"?":":d)+f);return h.log=this.log,h}function u(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}return l.debug=l,l.default=l,l.coerce=function(f){return f instanceof Error?f.stack||f.message:f},l.disable=function(){const f=[...l.names.map(u),...l.skips.map(u).map(d=>"-"+d)].join(",");return l.enable(""),f},l.enable=function(f){l.save(f),l.names=[],l.skips=[];let d;const h=(typeof f=="string"?f:"").split(/[\s,]+/),p=h.length;for(d=0;d<p;d++)h[d]&&(f=h[d].replace(/\*/g,".*?"),f[0]==="-"?l.skips.push(new RegExp("^"+f.substr(1)+"$")):l.names.push(new RegExp("^"+f+"$")))},l.enabled=function(f){if(f[f.length-1]==="*")return!0;let d,h;for(d=0,h=l.skips.length;d<h;d++)if(l.skips[d].test(f))return!1;for(d=0,h=l.names.length;d<h;d++)if(l.names[d].test(f))return!0;return!1},l.humanize=i("ms"),l.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(a).forEach(f=>{l[f]=a[f]}),l.names=[],l.skips=[],l.formatters={},l.selectColor=function(f){let d=0;for(let h=0;h<f.length;h++)d=(d<<5)-d+f.charCodeAt(h),d|=0;return l.colors[r(d)%l.colors.length]},l.enable(l.load()),l}},{ms:11}],6:[function(i,o){function a(l,c){for(const u in c)Object.defineProperty(l,u,{value:c[u],enumerable:!0,configurable:!0});return l}o.exports=function(l,c,u){if(!l||typeof l=="string")throw new TypeError("Please pass an Error to err-code");u||(u={}),typeof c=="object"&&(u=c,c=""),c&&(u.code=c);try{return a(l,u)}catch{u.message=l.message,u.stack=l.stack;const d=function(){};return d.prototype=Object.create(Object.getPrototypeOf(l)),a(new d,u)}}},{}],7:[function(i,o){function a(R){console&&console.warn&&console.warn(R)}function l(){l.init.call(this)}function c(R){if(typeof R!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof R)}function u(R){return R._maxListeners===void 0?l.defaultMaxListeners:R._maxListeners}function f(R,D,F,U){var K,_,G;if(c(F),_=R._events,_===void 0?(_=R._events=Object.create(null),R._eventsCount=0):(_.newListener!==void 0&&(R.emit("newListener",D,F.listener?F.listener:F),_=R._events),G=_[D]),G===void 0)G=_[D]=F,++R._eventsCount;else if(typeof G=="function"?G=_[D]=U?[F,G]:[G,F]:U?G.unshift(F):G.push(F),K=u(R),0<K&&G.length>K&&!G.warned){G.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+(D+" listeners added. Use emitter.setMaxListeners() to increase limit"));Y.name="MaxListenersExceededWarning",Y.emitter=R,Y.type=D,Y.count=G.length,a(Y)}return R}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(R,D,F){var U={fired:!1,wrapFn:void 0,target:R,type:D,listener:F},K=d.bind(U);return K.listener=F,U.wrapFn=K,K}function p(R,D,F){var U=R._events;if(U===void 0)return[];var K=U[D];return K===void 0?[]:typeof K=="function"?F?[K.listener||K]:[K]:F?x(K):y(K,K.length)}function m(R){var D=this._events;if(D!==void 0){var F=D[R];if(typeof F=="function")return 1;if(F!==void 0)return F.length}return 0}function y(R,D){for(var F=Array(D),U=0;U<D;++U)F[U]=R[U];return F}function b(R,D){for(;D+1<R.length;D++)R[D]=R[D+1];R.pop()}function x(R){for(var D=Array(R.length),F=0;F<D.length;++F)D[F]=R[F].listener||R[F];return D}function v(R,D,F){typeof R.on=="function"&&w(R,"error",D,F)}function w(R,D,F,U){if(typeof R.on=="function")U.once?R.once(D,F):R.on(D,F);else if(typeof R.addEventListener=="function")R.addEventListener(D,function K(_){U.once&&R.removeEventListener(D,K),F(_)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof R)}var E,k=typeof Reflect=="object"?Reflect:null,S=k&&typeof k.apply=="function"?k.apply:function(R,D,F){return Function.prototype.apply.call(R,D,F)};E=k&&typeof k.ownKeys=="function"?k.ownKeys:Object.getOwnPropertySymbols?function(R){return Object.getOwnPropertyNames(R).concat(Object.getOwnPropertySymbols(R))}:function(R){return Object.getOwnPropertyNames(R)};var M=Number.isNaN||function(R){return R!==R};o.exports=l,o.exports.once=function(R,D){return new Promise(function(F,U){function K(G){R.removeListener(D,_),U(G)}function _(){typeof R.removeListener=="function"&&R.removeListener("error",K),F([].slice.call(arguments))}w(R,D,_,{once:!0}),D!=="error"&&v(R,K,{once:!0})})},l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var O=10;Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return O},set:function(R){if(typeof R!="number"||0>R||M(R))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+R+".");O=R}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(R){if(typeof R!="number"||0>R||M(R))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+R+".");return this._maxListeners=R,this},l.prototype.getMaxListeners=function(){return u(this)},l.prototype.emit=function(R){for(var D=[],F=1;F<arguments.length;F++)D.push(arguments[F]);var U=R==="error",K=this._events;if(K!==void 0)U=U&&K.error===void 0;else if(!U)return!1;if(U){var _;if(0<D.length&&(_=D[0]),_ instanceof Error)throw _;var G=new Error("Unhandled error."+(_?" ("+_.message+")":""));throw G.context=_,G}var Y=K[R];if(Y===void 0)return!1;if(typeof Y=="function")S(Y,this,D);else for(var re=Y.length,Z=y(Y,re),F=0;F<re;++F)S(Z[F],this,D);return!0},l.prototype.addListener=function(R,D){return f(this,R,D,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(R,D){return f(this,R,D,!0)},l.prototype.once=function(R,D){return c(D),this.on(R,h(this,R,D)),this},l.prototype.prependOnceListener=function(R,D){return c(D),this.prependListener(R,h(this,R,D)),this},l.prototype.removeListener=function(R,D){var F,U,K,_,G;if(c(D),U=this._events,U===void 0)return this;if(F=U[R],F===void 0)return this;if(F===D||F.listener===D)--this._eventsCount==0?this._events=Object.create(null):(delete U[R],U.removeListener&&this.emit("removeListener",R,F.listener||D));else if(typeof F!="function"){for(K=-1,_=F.length-1;0<=_;_--)if(F[_]===D||F[_].listener===D){G=F[_].listener,K=_;break}if(0>K)return this;K===0?F.shift():b(F,K),F.length===1&&(U[R]=F[0]),U.removeListener!==void 0&&this.emit("removeListener",R,G||D)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(R){var D,F,U;if(F=this._events,F===void 0)return this;if(F.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):F[R]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete F[R]),this;if(arguments.length===0){var K,_=Object.keys(F);for(U=0;U<_.length;++U)K=_[U],K!=="removeListener"&&this.removeAllListeners(K);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(D=F[R],typeof D=="function")this.removeListener(R,D);else if(D!==void 0)for(U=D.length-1;0<=U;U--)this.removeListener(R,D[U]);return this},l.prototype.listeners=function(R){return p(this,R,!0)},l.prototype.rawListeners=function(R){return p(this,R,!1)},l.listenerCount=function(R,D){return typeof R.listenerCount=="function"?R.listenerCount(D):m.call(R,D)},l.prototype.listenerCount=m,l.prototype.eventNames=function(){return 0<this._eventsCount?E(this._events):[]}},{}],8:[function(i,o){o.exports=function(){if(typeof globalThis>"u")return null;var a={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return a.RTCPeerConnection?a:null}},{}],9:[function(i,o,a){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */a.read=function(l,c,u,f,d){var h,p,m=8*d-f-1,y=(1<<m)-1,b=y>>1,x=-7,v=u?d-1:0,w=u?-1:1,E=l[c+v];for(v+=w,h=E&(1<<-x)-1,E>>=-x,x+=m;0<x;h=256*h+l[c+v],v+=w,x-=8);for(p=h&(1<<-x)-1,h>>=-x,x+=f;0<x;p=256*p+l[c+v],v+=w,x-=8);if(h===0)h=1-b;else{if(h===y)return p?NaN:(E?-1:1)*(1/0);p+=s(2,f),h-=b}return(E?-1:1)*p*s(2,h-f)},a.write=function(l,c,u,f,d,h){var p,m,y,b=Math.LN2,x=Math.log,v=8*h-d-1,w=(1<<v)-1,E=w>>1,k=d===23?s(2,-24)-s(2,-77):0,S=f?0:h-1,M=f?1:-1,O=0>c||c===0&&0>1/c?1:0;for(c=r(c),isNaN(c)||c===1/0?(m=isNaN(c)?1:0,p=w):(p=t(x(c)/b),1>c*(y=s(2,-p))&&(p--,y*=2),c+=1<=p+E?k/y:k*s(2,1-E),2<=c*y&&(p++,y/=2),p+E>=w?(m=0,p=w):1<=p+E?(m=(c*y-1)*s(2,d),p+=E):(m=c*s(2,E-1)*s(2,d),p=0));8<=d;l[u+S]=255&m,S+=M,m/=256,d-=8);for(p=p<<d|m,v+=d;0<v;l[u+S]=255&p,S+=M,p/=256,v-=8);l[u+S-M]|=128*O}},{}],10:[function(i,o){o.exports=typeof Object.create=="function"?function(a,l){l&&(a.super_=l,a.prototype=Object.create(l.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:function(a,l){if(l){a.super_=l;var c=function(){};c.prototype=l.prototype,a.prototype=new c,a.prototype.constructor=a}}},{}],11:[function(i,o){var a=Math.round;function l(d){if(d+="",!(100<d.length)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(h){var p=parseFloat(h[1]),m=(h[2]||"ms").toLowerCase();return m==="years"||m==="year"||m==="yrs"||m==="yr"||m==="y"?315576e5*p:m==="weeks"||m==="week"||m==="w"?6048e5*p:m==="days"||m==="day"||m==="d"?864e5*p:m==="hours"||m==="hour"||m==="hrs"||m==="hr"||m==="h"?36e5*p:m==="minutes"||m==="minute"||m==="mins"||m==="min"||m==="m"?6e4*p:m==="seconds"||m==="second"||m==="secs"||m==="sec"||m==="s"?1e3*p:m==="milliseconds"||m==="millisecond"||m==="msecs"||m==="msec"||m==="ms"?p:void 0}}}function c(d){var h=r(d);return 864e5<=h?a(d/864e5)+"d":36e5<=h?a(d/36e5)+"h":6e4<=h?a(d/6e4)+"m":1e3<=h?a(d/1e3)+"s":d+"ms"}function u(d){var h=r(d);return 864e5<=h?f(d,h,864e5,"day"):36e5<=h?f(d,h,36e5,"hour"):6e4<=h?f(d,h,6e4,"minute"):1e3<=h?f(d,h,1e3,"second"):d+" ms"}function f(d,h,p,m){return a(d/p)+" "+m+(h>=1.5*p?"s":"")}o.exports=function(d,h){h=h||{};var p=typeof d;if(p=="string"&&0<d.length)return l(d);if(p==="number"&&isFinite(d))return h.long?u(d):c(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},{}],12:[function(i,o){function a(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function c(k){if(m===setTimeout)return setTimeout(k,0);if((m===a||!m)&&setTimeout)return m=setTimeout,setTimeout(k,0);try{return m(k,0)}catch{try{return m.call(null,k,0)}catch{return m.call(this,k,0)}}}function u(k){if(y===clearTimeout)return clearTimeout(k);if((y===l||!y)&&clearTimeout)return y=clearTimeout,clearTimeout(k);try{return y(k)}catch{try{return y.call(null,k)}catch{return y.call(this,k)}}}function f(){w&&x&&(w=!1,x.length?v=x.concat(v):E=-1,v.length&&d())}function d(){if(!w){var k=c(f);w=!0;for(var S=v.length;S;){for(x=v,v=[];++E<S;)x&&x[E].run();E=-1,S=v.length}x=null,w=!1,u(k)}}function h(k,S){this.fun=k,this.array=S}function p(){}var m,y,b=o.exports={};(function(){try{m=typeof setTimeout=="function"?setTimeout:a}catch{m=a}try{y=typeof clearTimeout=="function"?clearTimeout:l}catch{y=l}})();var x,v=[],w=!1,E=-1;b.nextTick=function(k){var S=Array(arguments.length-1);if(1<arguments.length)for(var M=1;M<arguments.length;M++)S[M-1]=arguments[M];v.push(new h(k,S)),v.length!==1||w||c(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},b.title="browser",b.browser=!0,b.env={},b.argv=[],b.version="",b.versions={},b.on=p,b.addListener=p,b.once=p,b.off=p,b.removeListener=p,b.removeAllListeners=p,b.emit=p,b.prependListener=p,b.prependOnceListener=p,b.listeners=function(){return[]},b.binding=function(){throw new Error("process.binding is not supported")},b.cwd=function(){return"/"},b.chdir=function(){throw new Error("process.chdir is not supported")},b.umask=function(){return 0}},{}],13:[function(i,o){(function(a){(function(){/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let l;o.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window>"u"?a:window):c=>(l||(l=Promise.resolve())).then(c).catch(u=>setTimeout(()=>{throw u},0))}).call(this)}).call(this,typeof ys>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ys)},{}],14:[function(i,o){(function(a,l){(function(){var c=i("safe-buffer").Buffer,u=l.crypto||l.msCrypto;o.exports=u&&u.getRandomValues?function(f,d){if(f>4294967295)throw new RangeError("requested too many random bytes");var h=c.allocUnsafe(f);if(0<f)if(65536<f)for(var p=0;p<f;p+=65536)u.getRandomValues(h.slice(p,p+65536));else u.getRandomValues(h);return typeof d=="function"?a.nextTick(function(){d(null,h)}):h}:function(){throw new Error(`Secure random number generation is not supported by this browser.
429
429
  Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,i("_process"),typeof ys>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ys)},{_process:12,"safe-buffer":30}],15:[function(i,o){function a(p,m){p.prototype=Object.create(m.prototype),p.prototype.constructor=p,p.__proto__=m}function l(p,m,y){function b(v,w,E){return typeof m=="string"?m:m(v,w,E)}y||(y=Error);var x=function(v){function w(E,k,S){return v.call(this,b(E,k,S))||this}return a(w,v),w}(y);x.prototype.name=y.name,x.prototype.code=p,h[p]=x}function c(p,m){if(Array.isArray(p)){var y=p.length;return p=p.map(function(b){return b+""}),2<y?"one of ".concat(m," ").concat(p.slice(0,y-1).join(", "),", or ")+p[y-1]:y===2?"one of ".concat(m," ").concat(p[0]," or ").concat(p[1]):"of ".concat(m," ").concat(p[0])}return"of ".concat(m," ").concat(p+"")}function u(p,m,y){return p.substr(0,m.length)===m}function f(p,m,y){return(y===void 0||y>p.length)&&(y=p.length),p.substring(y-m.length,y)===m}function d(p,m,y){return typeof y!="number"&&(y=0),!(y+m.length>p.length)&&p.indexOf(m,y)!==-1}var h={};l("ERR_INVALID_OPT_VALUE",function(p,m){return'The value "'+m+'" is invalid for option "'+p+'"'},TypeError),l("ERR_INVALID_ARG_TYPE",function(p,m,y){var b;typeof m=="string"&&u(m,"not ")?(b="must not be",m=m.replace(/^not /,"")):b="must be";var x;if(f(p," argument"))x="The ".concat(p," ").concat(b," ").concat(c(m,"type"));else{var v=d(p,".")?"property":"argument";x='The "'.concat(p,'" ').concat(v," ").concat(b," ").concat(c(m,"type"))}return x+=". Received type ".concat(typeof y),x},TypeError),l("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),l("ERR_METHOD_NOT_IMPLEMENTED",function(p){return"The "+p+" method is not implemented"}),l("ERR_STREAM_PREMATURE_CLOSE","Premature close"),l("ERR_STREAM_DESTROYED",function(p){return"Cannot call "+p+" after a stream was destroyed"}),l("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),l("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),l("ERR_STREAM_WRITE_AFTER_END","write after end"),l("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),l("ERR_UNKNOWN_ENCODING",function(p){return"Unknown encoding: "+p},TypeError),l("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),o.exports.codes=h},{}],16:[function(i,o){(function(a){(function(){function l(b){return this instanceof l?(d.call(this,b),h.call(this,b),this.allowHalfOpen=!0,void(b&&(b.readable===!1&&(this.readable=!1),b.writable===!1&&(this.writable=!1),b.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",c))))):new l(b)}function c(){this._writableState.ended||a.nextTick(u,this)}function u(b){b.end()}var f=Object.keys||function(b){var x=[];for(var v in b)x.push(v);return x};o.exports=l;var d=i("./_stream_readable"),h=i("./_stream_writable");i("inherits")(l,d);for(var p,m=f(h.prototype),y=0;y<m.length;y++)p=m[y],l.prototype[p]||(l.prototype[p]=h.prototype[p]);Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(b){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=b,this._writableState.destroyed=b)}})}).call(this)}).call(this,i("_process"))},{"./_stream_readable":18,"./_stream_writable":20,_process:12,inherits:10}],17:[function(i,o){function a(c){return this instanceof a?void l.call(this,c):new a(c)}o.exports=a;var l=i("./_stream_transform");i("inherits")(a,l),a.prototype._transform=function(c,u,f){f(null,c)}},{"./_stream_transform":19,inherits:10}],18:[function(i,o){(function(a,l){(function(){function c(P){return Pe.from(P)}function u(P){return Pe.isBuffer(P)||P instanceof Ce}function f(P,g,A){return typeof P.prependListener=="function"?P.prependListener(g,A):void(P._events&&P._events[g]?Array.isArray(P._events[g])?P._events[g].unshift(A):P._events[g]=[A,P._events[g]]:P.on(g,A))}function d(P,g,A){re=re||i("./_stream_duplex"),P=P||{},typeof A!="boolean"&&(A=g instanceof re),this.objectMode=!!P.objectMode,A&&(this.objectMode=this.objectMode||!!P.readableObjectMode),this.highWaterMark=ze(this,P,"readableHighWaterMark",A),this.buffer=new Le,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=P.emitClose!==!1,this.autoDestroy=!!P.autoDestroy,this.destroyed=!1,this.defaultEncoding=P.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,P.encoding&&(!Ue&&(Ue=i("string_decoder/").StringDecoder),this.decoder=new Ue(P.encoding),this.encoding=P.encoding)}function h(P){if(re=re||i("./_stream_duplex"),!(this instanceof h))return new h(P);var g=this instanceof re;this._readableState=new d(P,this,g),this.readable=!0,P&&(typeof P.read=="function"&&(this._read=P.read),typeof P.destroy=="function"&&(this._destroy=P.destroy)),ke.call(this)}function p(P,g,A,N,B){Z("readableAddChunk",g);var W=P._readableState;if(g===null)W.reading=!1,v(P,W);else{var Q;if(B||(Q=y(W,g)),Q)ne(P,Q);else if(!(W.objectMode||g&&0<g.length))N||(W.reading=!1,k(P,W));else if(typeof g=="string"||W.objectMode||Object.getPrototypeOf(g)===Pe.prototype||(g=c(g)),N)W.endEmitted?ne(P,new J):m(P,W,g,!0);else if(W.ended)ne(P,new _e);else{if(W.destroyed)return!1;W.reading=!1,W.decoder&&!A?(g=W.decoder.write(g),W.objectMode||g.length!==0?m(P,W,g,!1):k(P,W)):m(P,W,g,!1)}}return!W.ended&&(W.length<W.highWaterMark||W.length===0)}function m(P,g,A,N){g.flowing&&g.length===0&&!g.sync?(g.awaitDrain=0,P.emit("data",A)):(g.length+=g.objectMode?1:A.length,N?g.buffer.unshift(A):g.buffer.push(A),g.needReadable&&w(P)),k(P,g)}function y(P,g){var A;return u(g)||typeof g=="string"||g===void 0||P.objectMode||(A=new be("chunk",["string","Buffer","Uint8Array"],g)),A}function b(P){return 1073741824<=P?P=1073741824:(P--,P|=P>>>1,P|=P>>>2,P|=P>>>4,P|=P>>>8,P|=P>>>16,P++),P}function x(P,g){return 0>=P||g.length===0&&g.ended?0:g.objectMode?1:P===P?(P>g.highWaterMark&&(g.highWaterMark=b(P)),P<=g.length?P:g.ended?g.length:(g.needReadable=!0,0)):g.flowing&&g.length?g.buffer.head.data.length:g.length}function v(P,g){if(Z("onEofChunk"),!g.ended){if(g.decoder){var A=g.decoder.end();A&&A.length&&(g.buffer.push(A),g.length+=g.objectMode?1:A.length)}g.ended=!0,g.sync?w(P):(g.needReadable=!1,!g.emittedReadable&&(g.emittedReadable=!0,E(P)))}}function w(P){var g=P._readableState;Z("emitReadable",g.needReadable,g.emittedReadable),g.needReadable=!1,g.emittedReadable||(Z("emitReadable",g.flowing),g.emittedReadable=!0,a.nextTick(E,P))}function E(P){var g=P._readableState;Z("emitReadable_",g.destroyed,g.length,g.ended),!g.destroyed&&(g.length||g.ended)&&(P.emit("readable"),g.emittedReadable=!1),g.needReadable=!g.flowing&&!g.ended&&g.length<=g.highWaterMark,U(P)}function k(P,g){g.readingMore||(g.readingMore=!0,a.nextTick(S,P,g))}function S(P,g){for(;!g.reading&&!g.ended&&(g.length<g.highWaterMark||g.flowing&&g.length===0);){var A=g.length;if(Z("maybeReadMore read 0"),P.read(0),A===g.length)break}g.readingMore=!1}function M(P){return function(){var g=P._readableState;Z("pipeOnDrain",g.awaitDrain),g.awaitDrain&&g.awaitDrain--,g.awaitDrain===0&&me(P,"data")&&(g.flowing=!0,U(P))}}function O(P){var g=P._readableState;g.readableListening=0<P.listenerCount("readable"),g.resumeScheduled&&!g.paused?g.flowing=!0:0<P.listenerCount("data")&&P.resume()}function R(P){Z("readable nexttick read 0"),P.read(0)}function D(P,g){g.resumeScheduled||(g.resumeScheduled=!0,a.nextTick(F,P,g))}function F(P,g){Z("resume",g.reading),g.reading||P.read(0),g.resumeScheduled=!1,P.emit("resume"),U(P),g.flowing&&!g.reading&&P.read(0)}function U(P){var g=P._readableState;for(Z("flow",g.flowing);g.flowing&&P.read()!==null;);}function K(P,g){if(g.length===0)return null;var A;return g.objectMode?A=g.buffer.shift():!P||P>=g.length?(A=g.decoder?g.buffer.join(""):g.buffer.length===1?g.buffer.first():g.buffer.concat(g.length),g.buffer.clear()):A=g.buffer.consume(P,g.decoder),A}function _(P){var g=P._readableState;Z("endReadable",g.endEmitted),g.endEmitted||(g.ended=!0,a.nextTick(G,g,P))}function G(P,g){if(Z("endReadableNT",P.endEmitted,P.length),!P.endEmitted&&P.length===0&&(P.endEmitted=!0,g.readable=!1,g.emit("end"),P.autoDestroy)){var A=g._writableState;(!A||A.autoDestroy&&A.finished)&&g.destroy()}}function Y(P,g){for(var A=0,N=P.length;A<N;A++)if(P[A]===g)return A;return-1}o.exports=h;var re;h.ReadableState=d;var Z;i("events").EventEmitter;var me=function(P,g){return P.listeners(g).length},ke=i("./internal/streams/stream"),Pe=i("buffer").Buffer,Ce=l.Uint8Array||function(){},Ee=i("util");Z=Ee&&Ee.debuglog?Ee.debuglog("stream"):function(){};var Ue,Fe,He,Le=i("./internal/streams/buffer_list"),Ze=i("./internal/streams/destroy"),le=i("./internal/streams/state"),ze=le.getHighWaterMark,ae=i("../errors").codes,be=ae.ERR_INVALID_ARG_TYPE,_e=ae.ERR_STREAM_PUSH_AFTER_EOF,z=ae.ERR_METHOD_NOT_IMPLEMENTED,J=ae.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;i("inherits")(h,ke);var ne=Ze.errorOrDestroy,ce=["error","close","destroy","pause","resume"];Object.defineProperty(h.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(P){this._readableState&&(this._readableState.destroyed=P)}}),h.prototype.destroy=Ze.destroy,h.prototype._undestroy=Ze.undestroy,h.prototype._destroy=function(P,g){g(P)},h.prototype.push=function(P,g){var A,N=this._readableState;return N.objectMode?A=!0:typeof P=="string"&&(g=g||N.defaultEncoding,g!==N.encoding&&(P=Pe.from(P,g),g=""),A=!0),p(this,P,g,!1,A)},h.prototype.unshift=function(P){return p(this,P,null,!0,!1)},h.prototype.isPaused=function(){return this._readableState.flowing===!1},h.prototype.setEncoding=function(P){Ue||(Ue=i("string_decoder/").StringDecoder);var g=new Ue(P);this._readableState.decoder=g,this._readableState.encoding=this._readableState.decoder.encoding;for(var A=this._readableState.buffer.head,N="";A!==null;)N+=g.write(A.data),A=A.next;return this._readableState.buffer.clear(),N!==""&&this._readableState.buffer.push(N),this._readableState.length=N.length,this},h.prototype.read=function(P){Z("read",P),P=parseInt(P,10);var g=this._readableState,A=P;if(P!==0&&(g.emittedReadable=!1),P===0&&g.needReadable&&((g.highWaterMark===0?0<g.length:g.length>=g.highWaterMark)||g.ended))return Z("read: emitReadable",g.length,g.ended),g.length===0&&g.ended?_(this):w(this),null;if(P=x(P,g),P===0&&g.ended)return g.length===0&&_(this),null;var N=g.needReadable;Z("need readable",N),(g.length===0||g.length-P<g.highWaterMark)&&(N=!0,Z("length less than watermark",N)),g.ended||g.reading?(N=!1,Z("reading or ended",N)):N&&(Z("do read"),g.reading=!0,g.sync=!0,g.length===0&&(g.needReadable=!0),this._read(g.highWaterMark),g.sync=!1,!g.reading&&(P=x(A,g)));var B;return B=0<P?K(P,g):null,B===null?(g.needReadable=g.length<=g.highWaterMark,P=0):(g.length-=P,g.awaitDrain=0),g.length===0&&(!g.ended&&(g.needReadable=!0),A!==P&&g.ended&&_(this)),B!==null&&this.emit("data",B),B},h.prototype._read=function(){ne(this,new z("_read()"))},h.prototype.pipe=function(P,g){function A(te,se){Z("onunpipe"),te===je&&se&&se.hasUnpiped===!1&&(se.hasUnpiped=!0,B())}function N(){Z("onend"),P.end()}function B(){Z("cleanup"),P.removeListener("close",ye),P.removeListener("finish",Se),P.removeListener("drain",sr),P.removeListener("error",Q),P.removeListener("unpipe",A),je.removeListener("end",N),je.removeListener("end",qe),je.removeListener("data",W),X=!0,Be.awaitDrain&&(!P._writableState||P._writableState.needDrain)&&sr()}function W(te){Z("ondata");var se=P.write(te);Z("dest.write",se),se===!1&&((Be.pipesCount===1&&Be.pipes===P||1<Be.pipesCount&&Y(Be.pipes,P)!==-1)&&!X&&(Z("false write response, pause",Be.awaitDrain),Be.awaitDrain++),je.pause())}function Q(te){Z("onerror",te),qe(),P.removeListener("error",Q),me(P,"error")===0&&ne(P,te)}function ye(){P.removeListener("finish",Se),qe()}function Se(){Z("onfinish"),P.removeListener("close",ye),qe()}function qe(){Z("unpipe"),je.unpipe(P)}var je=this,Be=this._readableState;switch(Be.pipesCount){case 0:Be.pipes=P;break;case 1:Be.pipes=[Be.pipes,P];break;default:Be.pipes.push(P)}Be.pipesCount+=1,Z("pipe count=%d opts=%j",Be.pipesCount,g);var ct=(!g||g.end!==!1)&&P!==a.stdout&&P!==a.stderr,Un=ct?N:qe;Be.endEmitted?a.nextTick(Un):je.once("end",Un),P.on("unpipe",A);var sr=M(je);P.on("drain",sr);var X=!1;return je.on("data",W),f(P,"error",Q),P.once("close",ye),P.once("finish",Se),P.emit("pipe",je),Be.flowing||(Z("pipe resume"),je.resume()),P},h.prototype.unpipe=function(P){var g=this._readableState,A={hasUnpiped:!1};if(g.pipesCount===0)return this;if(g.pipesCount===1)return P&&P!==g.pipes?this:(P||(P=g.pipes),g.pipes=null,g.pipesCount=0,g.flowing=!1,P&&P.emit("unpipe",this,A),this);if(!P){var N=g.pipes,B=g.pipesCount;g.pipes=null,g.pipesCount=0,g.flowing=!1;for(var W=0;W<B;W++)N[W].emit("unpipe",this,{hasUnpiped:!1});return this}var Q=Y(g.pipes,P);return Q===-1?this:(g.pipes.splice(Q,1),g.pipesCount-=1,g.pipesCount===1&&(g.pipes=g.pipes[0]),P.emit("unpipe",this,A),this)},h.prototype.on=function(P,g){var A=ke.prototype.on.call(this,P,g),N=this._readableState;return P==="data"?(N.readableListening=0<this.listenerCount("readable"),N.flowing!==!1&&this.resume()):P=="readable"&&!N.endEmitted&&!N.readableListening&&(N.readableListening=N.needReadable=!0,N.flowing=!1,N.emittedReadable=!1,Z("on readable",N.length,N.reading),N.length?w(this):!N.reading&&a.nextTick(R,this)),A},h.prototype.addListener=h.prototype.on,h.prototype.removeListener=function(P,g){var A=ke.prototype.removeListener.call(this,P,g);return P==="readable"&&a.nextTick(O,this),A},h.prototype.removeAllListeners=function(P){var g=ke.prototype.removeAllListeners.apply(this,arguments);return(P==="readable"||P===void 0)&&a.nextTick(O,this),g},h.prototype.resume=function(){var P=this._readableState;return P.flowing||(Z("resume"),P.flowing=!P.readableListening,D(this,P)),P.paused=!1,this},h.prototype.pause=function(){return Z("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Z("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},h.prototype.wrap=function(P){var g=this,A=this._readableState,N=!1;for(var B in P.on("end",function(){if(Z("wrapped end"),A.decoder&&!A.ended){var Q=A.decoder.end();Q&&Q.length&&g.push(Q)}g.push(null)}),P.on("data",function(Q){if(Z("wrapped data"),A.decoder&&(Q=A.decoder.write(Q)),!(A.objectMode&&Q==null)&&(A.objectMode||Q&&Q.length)){var ye=g.push(Q);ye||(N=!0,P.pause())}}),P)this[B]===void 0&&typeof P[B]=="function"&&(this[B]=function(Q){return function(){return P[Q].apply(P,arguments)}}(B));for(var W=0;W<ce.length;W++)P.on(ce[W],this.emit.bind(this,ce[W]));return this._read=function(Q){Z("wrapped _read",Q),N&&(N=!1,P.resume())},this},typeof Symbol=="function"&&(h.prototype[Symbol.asyncIterator]=function(){return Fe===void 0&&(Fe=i("./internal/streams/async_iterator")),Fe(this)}),Object.defineProperty(h.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(h.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(h.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(P){this._readableState&&(this._readableState.flowing=P)}}),h._fromList=K,Object.defineProperty(h.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(h.from=function(P,g){return He===void 0&&(He=i("./internal/streams/from")),He(h,P,g)})}).call(this)}).call(this,i("_process"),typeof ys>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ys)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/async_iterator":21,"./internal/streams/buffer_list":22,"./internal/streams/destroy":23,"./internal/streams/from":25,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,events:7,inherits:10,"string_decoder/":31,util:2}],19:[function(i,o){function a(b,x){var v=this._transformState;v.transforming=!1;var w=v.writecb;if(w===null)return this.emit("error",new h);v.writechunk=null,v.writecb=null,x!=null&&this.push(x),w(b);var E=this._readableState;E.reading=!1,(E.needReadable||E.length<E.highWaterMark)&&this._read(E.highWaterMark)}function l(b){return this instanceof l?(y.call(this,b),this._transformState={afterTransform:a.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,b&&(typeof b.transform=="function"&&(this._transform=b.transform),typeof b.flush=="function"&&(this._flush=b.flush)),void this.on("prefinish",c)):new l(b)}function c(){var b=this;typeof this._flush!="function"||this._readableState.destroyed?u(this,null,null):this._flush(function(x,v){u(b,x,v)})}function u(b,x,v){if(x)return b.emit("error",x);if(v!=null&&b.push(v),b._writableState.length)throw new m;if(b._transformState.transforming)throw new p;return b.push(null)}o.exports=l;var f=i("../errors").codes,d=f.ERR_METHOD_NOT_IMPLEMENTED,h=f.ERR_MULTIPLE_CALLBACK,p=f.ERR_TRANSFORM_ALREADY_TRANSFORMING,m=f.ERR_TRANSFORM_WITH_LENGTH_0,y=i("./_stream_duplex");i("inherits")(l,y),l.prototype.push=function(b,x){return this._transformState.needTransform=!1,y.prototype.push.call(this,b,x)},l.prototype._transform=function(b,x,v){v(new d("_transform()"))},l.prototype._write=function(b,x,v){var w=this._transformState;if(w.writecb=v,w.writechunk=b,w.writeencoding=x,!w.transforming){var E=this._readableState;(w.needTransform||E.needReadable||E.length<E.highWaterMark)&&this._read(E.highWaterMark)}},l.prototype._read=function(){var b=this._transformState;b.writechunk===null||b.transforming?b.needTransform=!0:(b.transforming=!0,this._transform(b.writechunk,b.writeencoding,b.afterTransform))},l.prototype._destroy=function(b,x){y.prototype._destroy.call(this,b,function(v){x(v)})}},{"../errors":15,"./_stream_duplex":16,inherits:10}],20:[function(i,o){(function(a,l){(function(){function c(z){var J=this;this.next=null,this.entry=null,this.finish=function(){_(J,z)}}function u(z){return Z.from(z)}function f(z){return Z.isBuffer(z)||z instanceof me}function d(){}function h(z,J,ne){G=G||i("./_stream_duplex"),z=z||{},typeof ne!="boolean"&&(ne=J instanceof G),this.objectMode=!!z.objectMode,ne&&(this.objectMode=this.objectMode||!!z.writableObjectMode),this.highWaterMark=Ce(this,z,"writableHighWaterMark",ne),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var ce=z.decodeStrings===!1;this.decodeStrings=!ce,this.defaultEncoding=z.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(P){k(J,P)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=z.emitClose!==!1,this.autoDestroy=!!z.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new c(this)}function p(z){G=G||i("./_stream_duplex");var J=this instanceof G;return J||_e.call(p,this)?(this._writableState=new h(z,this,J),this.writable=!0,z&&(typeof z.write=="function"&&(this._write=z.write),typeof z.writev=="function"&&(this._writev=z.writev),typeof z.destroy=="function"&&(this._destroy=z.destroy),typeof z.final=="function"&&(this._final=z.final)),void re.call(this)):new p(z)}function m(z,J){var ne=new ze;be(z,ne),a.nextTick(J,ne)}function y(z,J,ne,ce){var P;return ne===null?P=new le:typeof ne!="string"&&!J.objectMode&&(P=new Ue("chunk",["string","Buffer"],ne)),!P||(be(z,P),a.nextTick(ce,P),!1)}function b(z,J,ne){return z.objectMode||z.decodeStrings===!1||typeof J!="string"||(J=Z.from(J,ne)),J}function x(z,J,ne,ce,P,g){if(!ne){var A=b(J,ce,P);ce!==A&&(ne=!0,P="buffer",ce=A)}var N=J.objectMode?1:ce.length;J.length+=N;var B=J.length<J.highWaterMark;if(B||(J.needDrain=!0),J.writing||J.corked){var W=J.lastBufferedRequest;J.lastBufferedRequest={chunk:ce,encoding:P,isBuf:ne,callback:g,next:null},W?W.next=J.lastBufferedRequest:J.bufferedRequest=J.lastBufferedRequest,J.bufferedRequestCount+=1}else v(z,J,!1,N,ce,P,g);return B}function v(z,J,ne,ce,P,g,A){J.writelen=ce,J.writecb=A,J.writing=!0,J.sync=!0,J.destroyed?J.onwrite(new Ze("write")):ne?z._writev(P,J.onwrite):z._write(P,g,J.onwrite),J.sync=!1}function w(z,J,ne,ce,P){--J.pendingcb,ne?(a.nextTick(P,ce),a.nextTick(U,z,J),z._writableState.errorEmitted=!0,be(z,ce)):(P(ce),z._writableState.errorEmitted=!0,be(z,ce),U(z,J))}function E(z){z.writing=!1,z.writecb=null,z.length-=z.writelen,z.writelen=0}function k(z,J){var ne=z._writableState,ce=ne.sync,P=ne.writecb;if(typeof P!="function")throw new He;if(E(ne),J)w(z,ne,ce,J,P);else{var g=R(ne)||z.destroyed;g||ne.corked||ne.bufferProcessing||!ne.bufferedRequest||O(z,ne),ce?a.nextTick(S,z,ne,g,P):S(z,ne,g,P)}}function S(z,J,ne,ce){ne||M(z,J),J.pendingcb--,ce(),U(z,J)}function M(z,J){J.length===0&&J.needDrain&&(J.needDrain=!1,z.emit("drain"))}function O(z,J){J.bufferProcessing=!0;var ne=J.bufferedRequest;if(z._writev&&ne&&ne.next){var ce=J.bufferedRequestCount,P=Array(ce),g=J.corkedRequestsFree;g.entry=ne;for(var A=0,N=!0;ne;)P[A]=ne,ne.isBuf||(N=!1),ne=ne.next,A+=1;P.allBuffers=N,v(z,J,!0,J.length,P,"",g.finish),J.pendingcb++,J.lastBufferedRequest=null,g.next?(J.corkedRequestsFree=g.next,g.next=null):J.corkedRequestsFree=new c(J),J.bufferedRequestCount=0}else{for(;ne;){var B=ne.chunk,W=ne.encoding,Q=ne.callback,ye=J.objectMode?1:B.length;if(v(z,J,!1,ye,B,W,Q),ne=ne.next,J.bufferedRequestCount--,J.writing)break}ne===null&&(J.lastBufferedRequest=null)}J.bufferedRequest=ne,J.bufferProcessing=!1}function R(z){return z.ending&&z.length===0&&z.bufferedRequest===null&&!z.finished&&!z.writing}function D(z,J){z._final(function(ne){J.pendingcb--,ne&&be(z,ne),J.prefinished=!0,z.emit("prefinish"),U(z,J)})}function F(z,J){J.prefinished||J.finalCalled||(typeof z._final!="function"||J.destroyed?(J.prefinished=!0,z.emit("prefinish")):(J.pendingcb++,J.finalCalled=!0,a.nextTick(D,z,J)))}function U(z,J){var ne=R(J);if(ne&&(F(z,J),J.pendingcb===0&&(J.finished=!0,z.emit("finish"),J.autoDestroy))){var ce=z._readableState;(!ce||ce.autoDestroy&&ce.endEmitted)&&z.destroy()}return ne}function K(z,J,ne){J.ending=!0,U(z,J),ne&&(J.finished?a.nextTick(ne):z.once("finish",ne)),J.ended=!0,z.writable=!1}function _(z,J,ne){var ce=z.entry;for(z.entry=null;ce;){var P=ce.callback;J.pendingcb--,P(ne),ce=ce.next}J.corkedRequestsFree.next=z}o.exports=p;var G;p.WritableState=h;var Y={deprecate:i("util-deprecate")},re=i("./internal/streams/stream"),Z=i("buffer").Buffer,me=l.Uint8Array||function(){},ke=i("./internal/streams/destroy"),Pe=i("./internal/streams/state"),Ce=Pe.getHighWaterMark,Ee=i("../errors").codes,Ue=Ee.ERR_INVALID_ARG_TYPE,Fe=Ee.ERR_METHOD_NOT_IMPLEMENTED,He=Ee.ERR_MULTIPLE_CALLBACK,Le=Ee.ERR_STREAM_CANNOT_PIPE,Ze=Ee.ERR_STREAM_DESTROYED,le=Ee.ERR_STREAM_NULL_VALUES,ze=Ee.ERR_STREAM_WRITE_AFTER_END,ae=Ee.ERR_UNKNOWN_ENCODING,be=ke.errorOrDestroy;i("inherits")(p,re),h.prototype.getBuffer=function(){for(var z=this.bufferedRequest,J=[];z;)J.push(z),z=z.next;return J},function(){try{Object.defineProperty(h.prototype,"buffer",{get:Y.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var _e;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(_e=Function.prototype[Symbol.hasInstance],Object.defineProperty(p,Symbol.hasInstance,{value:function(z){return!!_e.call(this,z)||this===p&&z&&z._writableState instanceof h}})):_e=function(z){return z instanceof this},p.prototype.pipe=function(){be(this,new Le)},p.prototype.write=function(z,J,ne){var ce=this._writableState,P=!1,g=!ce.objectMode&&f(z);return g&&!Z.isBuffer(z)&&(z=u(z)),typeof J=="function"&&(ne=J,J=null),g?J="buffer":!J&&(J=ce.defaultEncoding),typeof ne!="function"&&(ne=d),ce.ending?m(this,ne):(g||y(this,ce,z,ne))&&(ce.pendingcb++,P=x(this,ce,g,z,J,ne)),P},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var z=this._writableState;z.corked&&(z.corked--,!z.writing&&!z.corked&&!z.bufferProcessing&&z.bufferedRequest&&O(this,z))},p.prototype.setDefaultEncoding=function(z){if(typeof z=="string"&&(z=z.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((z+"").toLowerCase())))throw new ae(z);return this._writableState.defaultEncoding=z,this},Object.defineProperty(p.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(p.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),p.prototype._write=function(z,J,ne){ne(new Fe("_write()"))},p.prototype._writev=null,p.prototype.end=function(z,J,ne){var ce=this._writableState;return typeof z=="function"?(ne=z,z=null,J=null):typeof J=="function"&&(ne=J,J=null),z!=null&&this.write(z,J),ce.corked&&(ce.corked=1,this.uncork()),ce.ending||K(this,ce,ne),this},Object.defineProperty(p.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(p.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(z){this._writableState&&(this._writableState.destroyed=z)}}),p.prototype.destroy=ke.destroy,p.prototype._undestroy=ke.undestroy,p.prototype._destroy=function(z,J){J(z)}}).call(this)}).call(this,i("_process"),typeof ys>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ys)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/destroy":23,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,inherits:10,"util-deprecate":32}],21:[function(i,o){(function(a){(function(){function l(M,O,R){return O in M?Object.defineProperty(M,O,{value:R,enumerable:!0,configurable:!0,writable:!0}):M[O]=R,M}function c(M,O){return{value:M,done:O}}function u(M){var O=M[m];if(O!==null){var R=M[E].read();R!==null&&(M[v]=null,M[m]=null,M[y]=null,O(c(R,!1)))}}function f(M){a.nextTick(u,M)}function d(M,O){return function(R,D){M.then(function(){return O[x]?void R(c(void 0,!0)):void O[w](R,D)},D)}}var h,p=i("./end-of-stream"),m=Symbol("lastResolve"),y=Symbol("lastReject"),b=Symbol("error"),x=Symbol("ended"),v=Symbol("lastPromise"),w=Symbol("handlePromise"),E=Symbol("stream"),k=Object.getPrototypeOf(function(){}),S=Object.setPrototypeOf((h={get stream(){return this[E]},next:function(){var M=this,O=this[b];if(O!==null)return Promise.reject(O);if(this[x])return Promise.resolve(c(void 0,!0));if(this[E].destroyed)return new Promise(function(U,K){a.nextTick(function(){M[b]?K(M[b]):U(c(void 0,!0))})});var R,D=this[v];if(D)R=new Promise(d(D,this));else{var F=this[E].read();if(F!==null)return Promise.resolve(c(F,!1));R=new Promise(this[w])}return this[v]=R,R}},l(h,Symbol.asyncIterator,function(){return this}),l(h,"return",function(){var M=this;return new Promise(function(O,R){M[E].destroy(null,function(D){return D?void R(D):void O(c(void 0,!0))})})}),h),k);o.exports=function(M){var O,R=Object.create(S,(O={},l(O,E,{value:M,writable:!0}),l(O,m,{value:null,writable:!0}),l(O,y,{value:null,writable:!0}),l(O,b,{value:null,writable:!0}),l(O,x,{value:M._readableState.endEmitted,writable:!0}),l(O,w,{value:function(D,F){var U=R[E].read();U?(R[v]=null,R[m]=null,R[y]=null,D(c(U,!1))):(R[m]=D,R[y]=F)},writable:!0}),O));return R[v]=null,p(M,function(D){if(D&&D.code!=="ERR_STREAM_PREMATURE_CLOSE"){var F=R[y];return F!==null&&(R[v]=null,R[m]=null,R[y]=null,F(D)),void(R[b]=D)}var U=R[m];U!==null&&(R[v]=null,R[m]=null,R[y]=null,U(c(void 0,!0))),R[x]=!0}),M.on("readable",f.bind(null,R)),R}}).call(this)}).call(this,i("_process"))},{"./end-of-stream":24,_process:12}],22:[function(i,o){function a(v,w){var E=Object.keys(v);if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(v);w&&(k=k.filter(function(S){return Object.getOwnPropertyDescriptor(v,S).enumerable})),E.push.apply(E,k)}return E}function l(v){for(var w,E=1;E<arguments.length;E++)w=arguments[E]==null?{}:arguments[E],E%2?a(Object(w),!0).forEach(function(k){c(v,k,w[k])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(w)):a(Object(w)).forEach(function(k){Object.defineProperty(v,k,Object.getOwnPropertyDescriptor(w,k))});return v}function c(v,w,E){return w in v?Object.defineProperty(v,w,{value:E,enumerable:!0,configurable:!0,writable:!0}):v[w]=E,v}function u(v,w){if(!(v instanceof w))throw new TypeError("Cannot call a class as a function")}function f(v,w){for(var E,k=0;k<w.length;k++)E=w[k],E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(v,E.key,E)}function d(v,w,E){return w&&f(v.prototype,w),v}function h(v,w,E){m.prototype.copy.call(v,w,E)}var p=i("buffer"),m=p.Buffer,y=i("util"),b=y.inspect,x=b&&b.custom||"inspect";o.exports=function(){function v(){u(this,v),this.head=null,this.tail=null,this.length=0}return d(v,[{key:"push",value:function(w){var E={data:w,next:null};0<this.length?this.tail.next=E:this.head=E,this.tail=E,++this.length}},{key:"unshift",value:function(w){var E={data:w,next:this.head};this.length===0&&(this.tail=E),this.head=E,++this.length}},{key:"shift",value:function(){if(this.length!==0){var w=this.head.data;return this.head=this.length===1?this.tail=null:this.head.next,--this.length,w}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(w){if(this.length===0)return"";for(var E=this.head,k=""+E.data;E=E.next;)k+=w+E.data;return k}},{key:"concat",value:function(w){if(this.length===0)return m.alloc(0);for(var E=m.allocUnsafe(w>>>0),k=this.head,S=0;k;)h(k.data,E,S),S+=k.data.length,k=k.next;return E}},{key:"consume",value:function(w,E){var k;return w<this.head.data.length?(k=this.head.data.slice(0,w),this.head.data=this.head.data.slice(w)):w===this.head.data.length?k=this.shift():k=E?this._getString(w):this._getBuffer(w),k}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(w){var E=this.head,k=1,S=E.data;for(w-=S.length;E=E.next;){var M=E.data,O=w>M.length?M.length:w;if(S+=O===M.length?M:M.slice(0,w),w-=O,w===0){O===M.length?(++k,this.head=E.next?E.next:this.tail=null):(this.head=E,E.data=M.slice(O));break}++k}return this.length-=k,S}},{key:"_getBuffer",value:function(w){var E=m.allocUnsafe(w),k=this.head,S=1;for(k.data.copy(E),w-=k.data.length;k=k.next;){var M=k.data,O=w>M.length?M.length:w;if(M.copy(E,E.length-w,0,O),w-=O,w===0){O===M.length?(++S,this.head=k.next?k.next:this.tail=null):(this.head=k,k.data=M.slice(O));break}++S}return this.length-=S,E}},{key:x,value:function(w,E){return b(this,l({},E,{depth:0,customInspect:!1}))}}]),v}()},{buffer:3,util:2}],23:[function(i,o){(function(a){(function(){function l(f,d){u(f,d),c(f)}function c(f){f._writableState&&!f._writableState.emitClose||f._readableState&&!f._readableState.emitClose||f.emit("close")}function u(f,d){f.emit("error",d)}o.exports={destroy:function(f,d){var h=this,p=this._readableState&&this._readableState.destroyed,m=this._writableState&&this._writableState.destroyed;return p||m?(d?d(f):f&&(this._writableState?!this._writableState.errorEmitted&&(this._writableState.errorEmitted=!0,a.nextTick(u,this,f)):a.nextTick(u,this,f)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(f||null,function(y){!d&&y?h._writableState?h._writableState.errorEmitted?a.nextTick(c,h):(h._writableState.errorEmitted=!0,a.nextTick(l,h,y)):a.nextTick(l,h,y):d?(a.nextTick(c,h),d(y)):a.nextTick(c,h)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(f,d){var h=f._readableState,p=f._writableState;h&&h.autoDestroy||p&&p.autoDestroy?f.destroy(d):f.emit("error",d)}}}).call(this)}).call(this,i("_process"))},{_process:12}],24:[function(i,o){function a(d){var h=!1;return function(){if(!h){h=!0;for(var p=arguments.length,m=Array(p),y=0;y<p;y++)m[y]=arguments[y];d.apply(this,m)}}}function l(){}function c(d){return d.setHeader&&typeof d.abort=="function"}function u(d,h,p){if(typeof h=="function")return u(d,null,h);h||(h={}),p=a(p||l);var m=h.readable||h.readable!==!1&&d.readable,y=h.writable||h.writable!==!1&&d.writable,b=function(){d.writable||v()},x=d._writableState&&d._writableState.finished,v=function(){y=!1,x=!0,m||p.call(d)},w=d._readableState&&d._readableState.endEmitted,E=function(){m=!1,w=!0,y||p.call(d)},k=function(O){p.call(d,O)},S=function(){var O;return m&&!w?(d._readableState&&d._readableState.ended||(O=new f),p.call(d,O)):y&&!x?(d._writableState&&d._writableState.ended||(O=new f),p.call(d,O)):void 0},M=function(){d.req.on("finish",v)};return c(d)?(d.on("complete",v),d.on("abort",S),d.req?M():d.on("request",M)):y&&!d._writableState&&(d.on("end",b),d.on("close",b)),d.on("end",E),d.on("finish",v),h.error!==!1&&d.on("error",k),d.on("close",S),function(){d.removeListener("complete",v),d.removeListener("abort",S),d.removeListener("request",M),d.req&&d.req.removeListener("finish",v),d.removeListener("end",b),d.removeListener("close",b),d.removeListener("finish",v),d.removeListener("end",E),d.removeListener("error",k),d.removeListener("close",S)}}var f=i("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;o.exports=u},{"../../../errors":15}],25:[function(i,o){o.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],26:[function(i,o){function a(x){var v=!1;return function(){v||(v=!0,x.apply(void 0,arguments))}}function l(x){if(x)throw x}function c(x){return x.setHeader&&typeof x.abort=="function"}function u(x,v,w,E){E=a(E);var k=!1;x.on("close",function(){k=!0}),p===void 0&&(p=i("./end-of-stream")),p(x,{readable:v,writable:w},function(M){return M?E(M):(k=!0,void E())});var S=!1;return function(M){if(!k)return S?void 0:(S=!0,c(x)?x.abort():typeof x.destroy=="function"?x.destroy():void E(M||new b("pipe")))}}function f(x){x()}function d(x,v){return x.pipe(v)}function h(x){return x.length&&typeof x[x.length-1]=="function"?x.pop():l}var p,m=i("../../../errors").codes,y=m.ERR_MISSING_ARGS,b=m.ERR_STREAM_DESTROYED;o.exports=function(){for(var x=arguments.length,v=Array(x),w=0;w<x;w++)v[w]=arguments[w];var E=h(v);if(Array.isArray(v[0])&&(v=v[0]),2>v.length)throw new y("streams");var k,S=v.map(function(M,O){var R=O<v.length-1;return u(M,R,0<O,function(D){k||(k=D),D&&S.forEach(f),R||(S.forEach(f),E(k))})});return v.reduce(d)}},{"../../../errors":15,"./end-of-stream":24}],27:[function(i,o){function a(c,u,f){return c.highWaterMark==null?u?c[f]:null:c.highWaterMark}var l=i("../../../errors").codes.ERR_INVALID_OPT_VALUE;o.exports={getHighWaterMark:function(c,u,f,d){var h=a(u,d,f);if(h!=null){if(!(isFinite(h)&&t(h)===h)||0>h){var p=d?f:"highWaterMark";throw new l(p,h)}return t(h)}return c.objectMode?16:16384}}},{"../../../errors":15}],28:[function(i,o){o.exports=i("events").EventEmitter},{events:7}],29:[function(i,o,a){a=o.exports=i("./lib/_stream_readable.js"),a.Stream=a,a.Readable=a,a.Writable=i("./lib/_stream_writable.js"),a.Duplex=i("./lib/_stream_duplex.js"),a.Transform=i("./lib/_stream_transform.js"),a.PassThrough=i("./lib/_stream_passthrough.js"),a.finished=i("./lib/internal/streams/end-of-stream.js"),a.pipeline=i("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":16,"./lib/_stream_passthrough.js":17,"./lib/_stream_readable.js":18,"./lib/_stream_transform.js":19,"./lib/_stream_writable.js":20,"./lib/internal/streams/end-of-stream.js":24,"./lib/internal/streams/pipeline.js":26}],30:[function(i,o,a){function l(d,h){for(var p in d)h[p]=d[p]}function c(d,h,p){return f(d,h,p)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var u=i("buffer"),f=u.Buffer;f.from&&f.alloc&&f.allocUnsafe&&f.allocUnsafeSlow?o.exports=u:(l(u,a),a.Buffer=c),c.prototype=Object.create(f.prototype),l(f,c),c.from=function(d,h,p){if(typeof d=="number")throw new TypeError("Argument must not be a number");return f(d,h,p)},c.alloc=function(d,h,p){if(typeof d!="number")throw new TypeError("Argument must be a number");var m=f(d);return h===void 0?m.fill(0):typeof p=="string"?m.fill(h,p):m.fill(h),m},c.allocUnsafe=function(d){if(typeof d!="number")throw new TypeError("Argument must be a number");return f(d)},c.allocUnsafeSlow=function(d){if(typeof d!="number")throw new TypeError("Argument must be a number");return u.SlowBuffer(d)}},{buffer:3}],31:[function(i,o,a){function l(S){if(!S)return"utf8";for(var M;;)switch(S){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return S;default:if(M)return;S=(""+S).toLowerCase(),M=!0}}function c(S){var M=l(S);if(typeof M!="string"&&(E.isEncoding===k||!k(S)))throw new Error("Unknown encoding: "+S);return M||S}function u(S){this.encoding=c(S);var M;switch(this.encoding){case"utf16le":this.text=m,this.end=y,M=4;break;case"utf8":this.fillLast=p,M=4;break;case"base64":this.text=b,this.end=x,M=3;break;default:return this.write=v,void(this.end=w)}this.lastNeed=0,this.lastTotal=0,this.lastChar=E.allocUnsafe(M)}function f(S){return 127>=S?0:S>>5==6?2:S>>4==14?3:S>>3==30?4:S>>6==2?-1:-2}function d(S,M,O){var R=M.length-1;if(R<O)return 0;var D=f(M[R]);return 0<=D?(0<D&&(S.lastNeed=D-1),D):--R<O||D===-2?0:(D=f(M[R]),0<=D?(0<D&&(S.lastNeed=D-2),D):--R<O||D===-2?0:(D=f(M[R]),0<=D?(0<D&&(D===2?D=0:S.lastNeed=D-3),D):0))}function h(S,M){if((192&M[0])!=128)return S.lastNeed=0,"�";if(1<S.lastNeed&&1<M.length){if((192&M[1])!=128)return S.lastNeed=1,"�";if(2<S.lastNeed&&2<M.length&&(192&M[2])!=128)return S.lastNeed=2,"�"}}function p(S){var M=this.lastTotal-this.lastNeed,O=h(this,S);return O===void 0?this.lastNeed<=S.length?(S.copy(this.lastChar,M,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(S.copy(this.lastChar,M,0,S.length),void(this.lastNeed-=S.length)):O}function m(S,M){if((S.length-M)%2==0){var O=S.toString("utf16le",M);if(O){var R=O.charCodeAt(O.length-1);if(55296<=R&&56319>=R)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=S[S.length-2],this.lastChar[1]=S[S.length-1],O.slice(0,-1)}return O}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=S[S.length-1],S.toString("utf16le",M,S.length-1)}function y(S){var M=S&&S.length?this.write(S):"";if(this.lastNeed){var O=this.lastTotal-this.lastNeed;return M+this.lastChar.toString("utf16le",0,O)}return M}function b(S,M){var O=(S.length-M)%3;return O==0?S.toString("base64",M):(this.lastNeed=3-O,this.lastTotal=3,O==1?this.lastChar[0]=S[S.length-1]:(this.lastChar[0]=S[S.length-2],this.lastChar[1]=S[S.length-1]),S.toString("base64",M,S.length-O))}function x(S){var M=S&&S.length?this.write(S):"";return this.lastNeed?M+this.lastChar.toString("base64",0,3-this.lastNeed):M}function v(S){return S.toString(this.encoding)}function w(S){return S&&S.length?this.write(S):""}var E=i("safe-buffer").Buffer,k=E.isEncoding||function(S){switch(S=""+S,S&&S.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};a.StringDecoder=u,u.prototype.write=function(S){if(S.length===0)return"";var M,O;if(this.lastNeed){if(M=this.fillLast(S),M===void 0)return"";O=this.lastNeed,this.lastNeed=0}else O=0;return O<S.length?M?M+this.text(S,O):this.text(S,O):M||""},u.prototype.end=function(S){var M=S&&S.length?this.write(S):"";return this.lastNeed?M+"�":M},u.prototype.text=function(S,M){var O=d(this,S,M);if(!this.lastNeed)return S.toString("utf8",M);this.lastTotal=O;var R=S.length-(O-this.lastNeed);return S.copy(this.lastChar,0,R),S.toString("utf8",M,R)},u.prototype.fillLast=function(S){return this.lastNeed<=S.length?(S.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(S.copy(this.lastChar,this.lastTotal-this.lastNeed,0,S.length),void(this.lastNeed-=S.length))}},{"safe-buffer":30}],32:[function(i,o){(function(a){(function(){function l(c){try{if(!a.localStorage)return!1}catch{return!1}var u=a.localStorage[c];return u!=null&&(u+"").toLowerCase()==="true"}o.exports=function(c,u){function f(){if(!d){if(l("throwDeprecation"))throw new Error(u);l("traceDeprecation")?console.trace(u):console.warn(u),d=!0}return c.apply(this,arguments)}if(l("noDeprecation"))return c;var d=!1;return f}}).call(this)}).call(this,typeof ys>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ys)},{}],"/":[function(i,o){function a(x){return x.replace(/a=ice-options:trickle\s\n/g,"")}function l(x){console.warn(x)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const c=i("debug")("simple-peer"),u=i("get-browser-rtc"),f=i("randombytes"),d=i("readable-stream"),h=i("queue-microtask"),p=i("err-code"),{Buffer:m}=i("buffer"),y=65536;class b extends d.Duplex{constructor(v){if(v=Object.assign({allowHalfOpen:!1},v),super(v),this._id=f(4).toString("hex").slice(0,7),this._debug("new peer %o",v),this.channelName=v.initiator?v.channelName||f(20).toString("hex"):null,this.initiator=v.initiator||!1,this.channelConfig=v.channelConfig||b.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},b.config,v.config),this.offerOptions=v.offerOptions||{},this.answerOptions=v.answerOptions||{},this.sdpTransform=v.sdpTransform||(w=>w),this.streams=v.streams||(v.stream?[v.stream]:[]),this.trickle=v.trickle===void 0||v.trickle,this.allowHalfTrickle=v.allowHalfTrickle!==void 0&&v.allowHalfTrickle,this.iceCompleteTimeout=v.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=v.wrtc&&typeof v.wrtc=="object"?v.wrtc:u(),!this._wrtc)throw p(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(w){return void this.destroy(p(w,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=w=>{this._onIceCandidate(w)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(w=>{this.destroy(p(w,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=w=>{this._setupData(w)},this.streams&&this.streams.forEach(w=>{this.addStream(w)}),this._pc.ontrack=w=>{this._onTrack(w)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(v){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof v=="string")try{v=JSON.parse(v)}catch{v={}}this._debug("signal()"),v.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),v.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(v.transceiverRequest.kind,v.transceiverRequest.init)),v.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(v.candidate):this._pendingCandidates.push(v.candidate)),v.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(v)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(w=>{this._addIceCandidate(w)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(w=>{this.destroy(p(w,"ERR_SET_REMOTE_DESCRIPTION"))}),v.sdp||v.candidate||v.renegotiate||v.transceiverRequest||this.destroy(p(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(v){const w=new this._wrtc.RTCIceCandidate(v);this._pc.addIceCandidate(w).catch(E=>{!w.address||w.address.endsWith(".local")?l("Ignoring unsupported ICE candidate."):this.destroy(p(E,"ERR_ADD_ICE_CANDIDATE"))})}send(v){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(v)}}addTransceiver(v,w){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(v,w),this._needsNegotiation()}catch(E){this.destroy(p(E,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:v,init:w}})}}addStream(v){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),v.getTracks().forEach(w=>{this.addTrack(w,v)})}}addTrack(v,w){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const E=this._senderMap.get(v)||new Map;let k=E.get(w);if(!k)k=this._pc.addTrack(v,w),E.set(w,k),this._senderMap.set(v,E),this._needsNegotiation();else throw k.removed?p(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):p(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(v,w,E){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const k=this._senderMap.get(v),S=k?k.get(E):null;if(!S)throw p(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");w&&this._senderMap.set(w,k),S.replaceTrack==null?this.destroy(p(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):S.replaceTrack(w)}removeTrack(v,w){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const E=this._senderMap.get(v),k=E?E.get(w):null;if(!k)throw p(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{k.removed=!0,this._pc.removeTrack(k)}catch(S){S.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(k):this.destroy(p(S,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(v){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),v.getTracks().forEach(w=>{this.removeTrack(w,v)})}}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,h(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(v){this._destroy(v,()=>{})}_destroy(v,w){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",v&&(v.message||v)),h(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",v&&(v.message||v)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,v&&this.emit("error",v),this.emit("close"),w()}))}_setupData(v){if(!v.channel)return this.destroy(p(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=v.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=y),this.channelName=this._channel.label,this._channel.onmessage=E=>{this._onChannelMessage(E)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=E=>{const k=E.error instanceof Error?E.error:new Error(`Datachannel error: ${E.message} ${E.filename}:${E.lineno}:${E.colno}`);this.destroy(p(k,"ERR_DATA_CHANNEL"))};let w=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(w&&this._onChannelClose(),w=!0):w=!1},5e3)}_read(){}_write(v,w,E){if(this.destroyed)return E(p(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(v)}catch(k){return this.destroy(p(k,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>y?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=E):E(null)}else this._debug("write before connect"),this._chunk=v,this._cb=E}_onFinish(){if(!this.destroyed){const v=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?v():this.once("connect",v)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(v=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(v.sdp=a(v.sdp)),v.sdp=this.sdpTransform(v.sdp);const w=()=>{if(!this.destroyed){const E=this._pc.localDescription||v;this._debug("signal"),this.emit("signal",{type:E.type,sdp:E.sdp})}};this._pc.setLocalDescription(v).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?w():this.once("_iceComplete",w))}).catch(E=>{this.destroy(p(E,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(v=>{this.destroy(p(v,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(v=>{v.mid||!v.sender.track||v.requested||(v.requested=!0,this.addTransceiver(v.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(v=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(v.sdp=a(v.sdp)),v.sdp=this.sdpTransform(v.sdp);const w=()=>{if(!this.destroyed){const E=this._pc.localDescription||v;this._debug("signal"),this.emit("signal",{type:E.type,sdp:E.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(v).then(()=>{this.destroyed||(this.trickle||this._iceComplete?w():this.once("_iceComplete",w))}).catch(E=>{this.destroy(p(E,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(v=>{this.destroy(p(v,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(p(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const v=this._pc.iceConnectionState,w=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",v,w),this.emit("iceStateChange",v,w),(v==="connected"||v==="completed")&&(this._pcReady=!0,this._maybeReady()),v==="failed"&&this.destroy(p(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),v==="closed"&&this.destroy(p(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(v){const w=E=>(Object.prototype.toString.call(E.values)==="[object Array]"&&E.values.forEach(k=>{Object.assign(E,k)}),E);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(E=>{const k=[];E.forEach(S=>{k.push(w(S))}),v(null,k)},E=>v(E)):0<this._pc.getStats.length?this._pc.getStats(E=>{if(this.destroyed)return;const k=[];E.result().forEach(S=>{const M={};S.names().forEach(O=>{M[O]=S.stat(O)}),M.id=S.id,M.type=S.type,M.timestamp=S.timestamp,k.push(w(M))}),v(null,k)},E=>v(E)):v(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const v=()=>{this.destroyed||this.getStats((w,E)=>{if(this.destroyed)return;w&&(E=[]);const k={},S={},M={};let O=!1;E.forEach(D=>{(D.type==="remotecandidate"||D.type==="remote-candidate")&&(k[D.id]=D),(D.type==="localcandidate"||D.type==="local-candidate")&&(S[D.id]=D),(D.type==="candidatepair"||D.type==="candidate-pair")&&(M[D.id]=D)});const R=D=>{O=!0;let F=S[D.localCandidateId];F&&(F.ip||F.address)?(this.localAddress=F.ip||F.address,this.localPort=+F.port):F&&F.ipAddress?(this.localAddress=F.ipAddress,this.localPort=+F.portNumber):typeof D.googLocalAddress=="string"&&(F=D.googLocalAddress.split(":"),this.localAddress=F[0],this.localPort=+F[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let U=k[D.remoteCandidateId];U&&(U.ip||U.address)?(this.remoteAddress=U.ip||U.address,this.remotePort=+U.port):U&&U.ipAddress?(this.remoteAddress=U.ipAddress,this.remotePort=+U.portNumber):typeof D.googRemoteAddress=="string"&&(U=D.googRemoteAddress.split(":"),this.remoteAddress=U[0],this.remotePort=+U[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(E.forEach(D=>{D.type==="transport"&&D.selectedCandidatePairId&&R(M[D.selectedCandidatePairId]),(D.type==="googCandidatePair"&&D.googActiveConnection==="true"||(D.type==="candidatepair"||D.type==="candidate-pair")&&D.selected)&&R(D)}),!O&&(!Object.keys(M).length||Object.keys(S).length))return void setTimeout(v,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(F){return this.destroy(p(F,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const D=this._cb;this._cb=null,D(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};v()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>y)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(v=>{this._pc.removeTrack(v),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(v){this.destroyed||(v.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:v.candidate.candidate,sdpMLineIndex:v.candidate.sdpMLineIndex,sdpMid:v.candidate.sdpMid}}):!v.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),v.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(v){if(this.destroyed)return;let w=v.data;w instanceof ArrayBuffer&&(w=m.from(w)),this.push(w)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const v=this._cb;this._cb=null,v(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(v){this.destroyed||v.streams.forEach(w=>{this._debug("on track"),this.emit("track",v.track,w),this._remoteTracks.push({track:v.track,stream:w}),this._remoteStreams.some(E=>E.id===w.id)||(this._remoteStreams.push(w),h(()=>{this._debug("on stream"),this.emit("stream",w)}))})}_debug(){const v=[].slice.call(arguments);v[0]="["+this._id+"] "+v[0],c.apply(null,v)}}b.WEBRTC_SUPPORT=!!u(),b.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},b.channelConfig={},o.exports=b},{buffer:3,debug:4,"err-code":6,"get-browser-rtc":8,"queue-microtask":13,randombytes:14,"readable-stream":29}]},{},[])("/")})})(S2);var G5=S2.exports;const K5=iy(G5),Ew=0,kw=1,T2=2,N2=(n,e)=>{De(n,Ew);const t=VH(e);Lt(n,t)},O2=(n,e,t)=>{De(n,kw),Lt(n,jH(e,t))},J5=(n,e,t)=>O2(e,t,sn(n)),R2=(n,e,t)=>{try{_H(e,sn(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},q5=(n,e)=>{De(n,T2),Lt(n,e)},Q5=R2,Y5=(n,e,t,r)=>{const s=We(n);switch(s){case Ew:J5(n,e,t);break;case kw:R2(n,t,r);break;case T2:Q5(n,t,r);break;default:throw new Error("Unknown message type")}return s},Cw=3e4;class X5 extends zS{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Ts();this.getLocalState()!==null&&Cw/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((s,i)=>{i!==this.clientID&&Cw<=t-s.lastUpdated&&this.states.has(i)&&r.push(i)}),r.length>0&&Sw(this,r,"timeout")},Yr(Cw/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,r=this.meta.get(t),s=r===void 0?0:r.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:s,lastUpdated:Ts()});const o=[],a=[],l=[],c=[];e===null?c.push(t):i==null?e!=null&&o.push(t):(a.push(t),Uf(i,e)||l.push(t)),(o.length>0||l.length>0||c.length>0)&&this.emit("change",[{added:o,updated:l,removed:c},"local"]),this.emit("update",[{added:o,updated:a,removed:c},"local"])}setLocalStateField(e,t){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:t})}getStates(){return this.states}}const Sw=(n,e,t)=>{const r=[];for(let s=0;s<e.length;s++){const i=e[s];if(n.states.has(i)){if(n.states.delete(i),i===n.clientID){const o=n.meta.get(i);n.meta.set(i,{clock:o.clock+1,lastUpdated:Ts()})}r.push(i)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},zp=(n,e,t=n.states)=>{const r=e.length,s=nn();De(s,r);for(let i=0;i<r;i++){const o=e[i],a=t.get(o)||null,l=n.meta.get(o).clock;De(s,o),De(s,l),Os(s,JSON.stringify(a))}return Rt(s)},Z5=(n,e,t)=>{const r=Rs(e),s=Ts(),i=[],o=[],a=[],l=[],c=We(r);for(let u=0;u<c;u++){const f=We(r);let d=We(r);const h=JSON.parse(ui(r)),p=n.meta.get(f),m=n.states.get(f),y=p===void 0?0:p.clock;(y<d||y===d&&h===null&&n.states.has(f))&&(h===null?f===n.clientID&&n.getLocalState()!=null?d++:n.states.delete(f):n.states.set(f,h),n.meta.set(f,{clock:d,lastUpdated:s}),p===void 0&&h!==null?i.push(f):p!==void 0&&h===null?l.push(f):h!==null&&(Uf(h,m)||a.push(f),o.push(f)))}(i.length>0||a.length>0||l.length>0)&&n.emit("change",[{added:i,updated:a,removed:l},t]),(i.length>0||o.length>0||l.length>0)&&n.emit("update",[{added:i,updated:o,removed:l},t])},e6=(n,e)=>{const t=_b(n).buffer,r=_b(e).buffer;return crypto.subtle.importKey("raw",t,"PBKDF2",!1,["deriveKey"]).then(s=>crypto.subtle.deriveKey({name:"PBKDF2",salt:r,iterations:1e5,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]))},M2=(n,e)=>{if(!e)return Xb(n);const t=crypto.getRandomValues(new Uint8Array(12));return crypto.subtle.encrypt({name:"AES-GCM",iv:t},e,n).then(r=>{const s=nn();return Os(s,"AES-GCM"),Lt(s,t),Lt(s,new Uint8Array(r)),Rt(s)})},t6=(n,e)=>{const t=nn();return Ql(t,n),M2(Rt(t),e)},D2=(n,e)=>{if(!e)return Xb(n);const t=Rs(n);ui(t)!=="AES-GCM"&&mH(Ns("Unknown encryption algorithm"));const s=sn(t),i=sn(t);return crypto.subtle.decrypt({name:"AES-GCM",iv:s},e,i).then(o=>new Uint8Array(o))},n6=(n,e)=>D2(n,e).then(t=>Yl(Rs(new Uint8Array(t)))),mr=pH("y-webrtc"),cc=0,P2=3,Zf=1,Tw=4,Vp=new Map,Na=new Map,I2=n=>{let e=!0;n.webrtcConns.forEach(t=>{t.synced||(e=!1)}),(!e&&n.synced||e&&!n.synced)&&(n.synced=e,n.provider.emit("synced",[{synced:e}]),mr("synced ",Rr,n.name,va," with all peers"))},L2=(n,e,t)=>{const r=Rs(e),s=nn(),i=We(r);if(n===void 0)return null;const o=n.awareness,a=n.doc;let l=!1;switch(i){case cc:{De(s,cc);const c=Y5(r,s,a,n);c===kw&&!n.synced&&t(),c===Ew&&(l=!0);break}case P2:De(s,Zf),Lt(s,zp(o,Array.from(o.getStates().keys()))),l=!0;break;case Zf:Z5(o,sn(r),n);break;case Tw:{const c=wa(r)===1,u=ui(r);if(u!==n.peerId&&(n.bcConns.has(u)&&!c||!n.bcConns.has(u)&&c)){const f=[],d=[];c?(n.bcConns.add(u),d.push(u)):(n.bcConns.delete(u),f.push(u)),n.provider.emit("peers",[{added:d,removed:f,webrtcPeers:Array.from(n.webrtcConns.keys()),bcPeers:Array.from(n.bcConns)}]),F2(n)}break}default:return console.error("Unable to compute message"),s}return l?s:null},r6=(n,e)=>{const t=n.room;return mr("received message from ",Rr,n.remotePeerId,Qb," (",t.name,")",va,Sp),L2(t,e,()=>{n.synced=!0,mr("synced ",Rr,t.name,va," with ",Rr,n.remotePeerId),I2(t)})},Nw=(n,e)=>{mr("send message to ",Rr,n.remotePeerId,va,Qb," (",n.room.name,")",Sp);try{n.peer.send(Rt(e))}catch{}},s6=(n,e)=>{mr("broadcast message in ",Rr,n.name,va),n.webrtcConns.forEach(t=>{try{t.peer.send(e)}catch{}})};class _2{constructor(e,t,r,s){mr("establishing connection to ",Rr,r),this.room=s,this.remotePeerId=r,this.glareToken=void 0,this.closed=!1,this.connected=!1,this.synced=!1,this.peer=new K5({initiator:t,...s.provider.peerOpts}),this.peer.on("signal",i=>{this.glareToken===void 0&&(this.glareToken=Date.now()+Math.random()),Rw(e,s,{to:r,from:s.peerId,type:"signal",token:this.glareToken,signal:i})}),this.peer.on("connect",()=>{mr("connected to ",Rr,r),this.connected=!0;const o=s.provider.doc,a=s.awareness,l=nn();De(l,cc),N2(l,o),Nw(this,l);const c=a.getStates();if(c.size>0){const u=nn();De(u,Zf),Lt(u,zp(a,Array.from(c.keys()))),Nw(this,u)}}),this.peer.on("close",()=>{this.connected=!1,this.closed=!0,s.webrtcConns.has(this.remotePeerId)&&(s.webrtcConns.delete(this.remotePeerId),s.provider.emit("peers",[{removed:[this.remotePeerId],added:[],webrtcPeers:Array.from(s.webrtcConns.keys()),bcPeers:Array.from(s.bcConns)}])),I2(s),this.peer.destroy(),mr("closed connection to ",Rr,r),Ow(s)}),this.peer.on("error",i=>{mr("Error in connection to ",Rr,r,": ",i),Ow(s)}),this.peer.on("data",i=>{const o=r6(this,i);o!==null&&Nw(this,o)})}destroy(){this.peer.destroy()}}const co=(n,e)=>M2(e,n.key).then(t=>n.mux(()=>TH(n.name,t))),B2=(n,e)=>{n.bcconnected&&co(n,e),s6(n,e)},Ow=n=>{Vp.forEach(e=>{e.connected&&(e.send({type:"subscribe",topics:[n.name]}),n.webrtcConns.size<n.provider.maxConns&&Rw(e,n,{type:"announce",from:n.peerId}))})},F2=n=>{if(n.provider.filterBcConns){const e=nn();De(e,Tw),jf(e,1),Os(e,n.peerId),co(n,Rt(e))}};class i6{constructor(e,t,r,s){this.peerId=JS(),this.doc=e,this.awareness=t.awareness,this.provider=t,this.synced=!1,this.name=r,this.key=s,this.webrtcConns=new Map,this.bcConns=new Set,this.mux=CT(),this.bcconnected=!1,this._bcSubscriber=i=>D2(new Uint8Array(i),s).then(o=>this.mux(()=>{const a=L2(this,o,()=>{});a&&co(this,Rt(a))})),this._docUpdateHandler=(i,o)=>{const a=nn();De(a,cc),q5(a,i),B2(this,Rt(a))},this._awarenessUpdateHandler=({added:i,updated:o,removed:a},l)=>{const c=i.concat(o).concat(a),u=nn();De(u,Zf),Lt(u,zp(this.awareness,c)),B2(this,Rt(u))},this._beforeUnloadHandler=()=>{Sw(this.awareness,[e.clientID],"window unload"),Na.forEach(i=>{i.disconnect()})},typeof window<"u"?window.addEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.on("exit",this._beforeUnloadHandler)}connect(){this.doc.on("update",this._docUpdateHandler),this.awareness.on("update",this._awarenessUpdateHandler),Ow(this);const e=this.name;CH(e,this._bcSubscriber),this.bcconnected=!0,F2(this);const t=nn();De(t,cc),N2(t,this.doc),co(this,Rt(t));const r=nn();De(r,cc),O2(r,this.doc),co(this,Rt(r));const s=nn();De(s,P2),co(this,Rt(s));const i=nn();De(i,Zf),Lt(i,zp(this.awareness,[this.doc.clientID])),co(this,Rt(i))}disconnect(){Vp.forEach(t=>{t.connected&&t.send({type:"unsubscribe",topics:[this.name]})}),Sw(this.awareness,[this.doc.clientID],"disconnect");const e=nn();De(e,Tw),jf(e,0),Os(e,this.peerId),co(this,Rt(e)),SH(this.name,this._bcSubscriber),this.bcconnected=!1,this.doc.off("update",this._docUpdateHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.webrtcConns.forEach(t=>t.destroy())}destroy(){this.disconnect(),typeof window<"u"?window.removeEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.off("exit",this._beforeUnloadHandler)}}const o6=(n,e,t,r)=>{if(Na.has(t))throw Ns(`A Yjs Doc connected to room "${t}" already exists!`);const s=new i6(n,e,t,r);return Na.set(t,s),s},Rw=(n,e,t)=>{e.key?t6(t,e.key).then(r=>{n.send({type:"publish",topic:e.name,data:AT(r)})}):n.send({type:"publish",topic:e.name,data:t})};class a6 extends w8{constructor(e){super(e),this.providers=new Set,this.on("connect",()=>{mr(`connected (${e})`);const t=Array.from(Na.keys());this.send({type:"subscribe",topics:t}),Na.forEach(r=>Rw(this,r,{type:"announce",from:r.peerId}))}),this.on("message",t=>{switch(t.type){case"publish":{const r=t.topic,s=Na.get(r);if(s==null||typeof r!="string")return;const i=o=>{const a=s.webrtcConns,l=s.peerId;if(o==null||o.from===l||o.to!==void 0&&o.to!==l||s.bcConns.has(o.from))return;const c=a.has(o.from)?()=>{}:()=>s.provider.emit("peers",[{removed:[],added:[o.from],webrtcPeers:Array.from(s.webrtcConns.keys()),bcPeers:Array.from(s.bcConns)}]);switch(o.type){case"announce":a.size<s.provider.maxConns&&(Jn(a,o.from,()=>new _2(this,!0,o.from,s)),c());break;case"signal":if(o.signal.type==="offer"){const u=a.get(o.from);if(u){const f=o.token,d=u.glareToken;if(d&&d>f){mr("offer rejected: ",o.from);return}u.glareToken=void 0}}if(o.signal.type==="answer"){mr("offer answered by: ",o.from);const u=a.get(o.from);u.glareToken=void 0}o.to===l&&(Jn(a,o.from,()=>new _2(this,!1,o.from,s)).peer.signal(o.signal),c());break}};s.key?typeof t.data=="string"&&n6(ET(t.data),s.key).then(i):i(t.data)}}}),this.on("disconnect",()=>mr(`disconnect (${e})`))}}const Mw=n=>{n.emit("status",[{connected:n.connected}])};class l6 extends Mb{constructor(e,t,{signaling:r=["wss://y-webrtc-eu.fly.dev"],password:s=null,awareness:i=new X5(t),maxConns:o=20+Yr(GS()*15),filterBcConns:a=!0,peerOpts:l={}}={}){super(),this.roomName=e,this.doc=t,this.filterBcConns=a,this.awareness=i,this.shouldConnect=!1,this.signalingUrls=r,this.signalingConns=[],this.maxConns=o,this.peerOpts=l,this.key=s?e6(s,e):Xb(null),this.room=null,this.key.then(c=>{this.room=o6(t,this,e,c),this.shouldConnect?this.room.connect():this.room.disconnect(),Mw(this)}),this.connect(),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}get connected(){return this.room!==null&&this.shouldConnect}connect(){this.shouldConnect=!0,this.signalingUrls.forEach(e=>{const t=Jn(Vp,e,()=>new a6(e));this.signalingConns.push(t),t.providers.add(this)}),this.room&&(this.room.connect(),Mw(this))}disconnect(){this.shouldConnect=!1,this.signalingConns.forEach(e=>{e.providers.delete(this),e.providers.size===0&&(e.destroy(),Vp.delete(e.url))}),this.room&&(this.room.disconnect(),Mw(this))}destroy(){this.doc.off("destroy",this.destroy),this.key.then(()=>{this.room.destroy(),Na.delete(this.roomName)}),super.destroy()}}const j2={attributes:{class:"prose-lg prose-headings:font-display prose prose-p:my-2 prose-h1:my-2 prose-h2:my-2 prose-h3:my-2 prose-ul:my-2 prose-ol:my-2 max-w-none focus:outline-none w-full",spellcheck:"false",suppressContentEditableWarning:"true"},handleDOMEvents:{keydown:(n,e)=>{if(["ArrowUp","ArrowDown","Enter"].includes(e.key)&&document.querySelector("#slash-command"))return!0}}},c6=/[\uD800-\uDBFF]/,u6=/[\uDC00-\uDFFF]/,f6=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&c6.test(n[t-1])&&t--;r+t<n.length&&r+t<e.length&&n[n.length-r-1]===e[e.length-r-1];)r++;return r>0&&u6.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},Mt=new Ot("y-sync"),hi=new Ot("y-undo"),$p=new Ot("yjs-cursor"),Wp=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!ec(e.ds,n.id),d6=[{light:"#ecd44433",dark:"#ecd444"}],h6=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){const r=oi();n.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}n.set(t,A8(e))}return n.get(t)},p6=(n,{colors:e=d6,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const a=new g6(n,i),l=new bt({props:{editable:c=>{const u=Mt.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:Mt,state:{init:(c,u)=>({type:n,doc:n.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,permanentUserData:r}),apply:(c,u)=>{const f=c.getMeta(Mt);if(f!==void 0){u=Object.assign({},u);for(const d in f)u[d]=f[d]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=f!==void 0&&!!f.isChangeOrigin,u.isUndoRedoOperation=f!==void 0&&!!f.isChangeOrigin&&!!f.isUndoRedoOperation,a.prosemirrorView!==null&&f!==void 0&&(f.snapshot!=null||f.prevSnapshot!=null)&&qb(0,()=>{a.prosemirrorView!=null&&(f.restore==null?a._renderSnapshot(f.snapshot,f.prevSnapshot,u):(a._renderSnapshot(f.snapshot,f.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),u}},view:c=>(a.initView(c),i==null&&a._forceRerender(),s(),{update:()=>{const u=l.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,u.addToHistory===!1&&!u.isChangeOrigin){const f=hi.getState(c.state),d=f&&f.undoManager;d&&d.stopCapturing()}a.mux(()=>{u.doc.transact(f=>{f.meta.set("addToHistory",u.addToHistory),a._prosemirrorChanged(c.state.doc)},Mt)})}},destroy:()=>{a.destroy()}})});return l},m6=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null){const r=nd(t.doc,t.type,e.anchor,t.mapping),s=nd(t.doc,t.type,e.head,t.mapping);r!==null&&s!==null&&(n=n.setSelection(Me.create(n.doc,r,s)))}},Dw=(n,e)=>({anchor:qp(e.selection.anchor,n.type,n.mapping),head:qp(e.selection.head,n.type,n.mapping)});class g6{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=CT(),this.mapping=t,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Dw(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Kb&&this._domSelectionInView===null&&(qb(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection(),t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);const s=t.getBoundingClientRect(),i=oH.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,t){t||(t=zT(TT(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Mt,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Gp(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ue(oe.from(e),0,0));t.setMeta(Mt,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,t=this.type.toArray().map(s=>Gp(s,this.prosemirrorView.state.schema,this.mapping)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ue(oe.from(t),0,0));e&&r.setSelection(Me.create(r.doc,e.anchor,e.head)),this.prosemirrorView.dispatch(r.setMeta(Mt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){let s=this.doc;e||(e=lw(this.doc)),(e instanceof Uint8Array||t instanceof Uint8Array)&&((!(e instanceof Uint8Array)||!(t instanceof Uint8Array))&&dr(),s=new xa({gc:!1}),Tp(s,t),t=lw(s),Tp(s,e),e=lw(s)),this.mapping.clear(),this.mux(()=>{s.transact(i=>{const o=r.permanentUserData;o&&o.dss.forEach(u=>{oo(i,u,f=>{})});const a=(u,f)=>{const d=u==="added"?o.getUserByClientId(f.client):o.getUserByDeletedId(f);return{user:d,type:u,color:h6(r.colorMapping,r.colors,d)}},l=i2(this.type,new aw(t.ds,e.sv)).map(u=>!u._item.deleted||Wp(u._item,e)||Wp(u._item,t)?Gp(u,this.prosemirrorView.state.schema,new Map,e,t,a):null).filter(u=>u!==null),c=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ue(oe.from(l),0,0));this.prosemirrorView.dispatch(c.setMeta(Mt,{isChangeOrigin:!0}))},Mt)})}_typeChanged(e,t){if(this.prosemirrorView==null)return;const r=Mt.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(a,l)=>this.mapping.delete(l);oo(t,t.deleteSet,a=>{if(a.constructor===xt){const l=a.content.type;l&&this.mapping.delete(l)}}),t.changed.forEach(s),t.changedParentTypes.forEach(s);const i=this.type.toArray().map(a=>U2(a,this.prosemirrorView.state.schema,this.mapping)).filter(a=>a!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ue(oe.from(i),0,0));m6(o,this.beforeTransactionSelection,this),o=o.setMeta(Mt,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof XT}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Lw(this.doc,this.type,e,this.mapping),this.beforeTransactionSelection=Dw(this,this.prosemirrorView.state)},Mt)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const U2=(n,e,t,r,s,i)=>{const o=t.get(n);if(o===void 0){if(n instanceof Dn)return Gp(n,e,t,r,s,i);throw Xr()}return o},Gp=(n,e,t,r,s,i)=>{const o=[],a=l=>{if(l.constructor===Dn){const c=U2(l,e,t,r,s,i);c!==null&&o.push(c)}else{const c=y6(l,e,t,r,s,i);c!==null&&c.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||s===void 0?n.toArray().forEach(a):i2(n,new aw(s.ds,r.sv)).forEach(a);try{const l=n.getAttributes(r);r!==void 0&&(Wp(n._item,r)?Wp(n._item,s)||(l.ychange=i?i("added",n._item.id):{type:"added"}):l.ychange=i?i("removed",n._item.id):{type:"removed"});const c=e.node(n.nodeName,l,o);return t.set(n,c),c}catch{return n.doc.transact(c=>{n._item.delete(c)},Mt),t.delete(n),null}},y6=(n,e,t,r,s,i)=>{const o=[],a=n.toDelta(r,s,i);try{for(let l=0;l<a.length;l++){const c=a[l],u=[];for(const f in c.attributes)u.push(e.mark(f,c.attributes[f]));o.push(e.text(c.insert,u))}}catch{return n.doc.transact(c=>{n._item.delete(c)},Mt),null}return o},b6=(n,e)=>{const t=new pr,r=n.map(s=>({insert:s.text,attributes:$2(s.marks)}));return t.applyDelta(r),e.set(t,n),t},w6=(n,e)=>{const t=new Dn(n.type.name);for(const r in n.attrs){const s=n.attrs[r];s!==null&&r!=="ychange"&&t.setAttribute(r,s)}return t.insert(0,Kp(n).map(r=>Pw(r,e))),e.set(t,n),t},Pw=(n,e)=>n instanceof Array?b6(n,e):w6(n,e),H2=n=>typeof n=="object"&&n!==null,Iw=(n,e)=>{const t=Object.keys(n).filter(s=>n[s]!==null);let r=t.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<t.length&&r;s++){const i=t[s],o=n[i],a=e[i];r=i==="ychange"||o===a||H2(o)&&H2(a)&&Iw(o,a)}return r},Kp=n=>{const e=n.content.content,t=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,t.push(i)}else t.push(s)}return t},z2=(n,e)=>{const t=n.toDelta();return t.length===e.length&&t.every((r,s)=>r.insert===e[s].text&&Wb(r.attributes||{}).length===e[s].marks.length&&e[s].marks.every(i=>Iw(r.attributes[i.type.name]||{},i.attrs)))},ed=(n,e)=>{if(n instanceof Dn&&!(e instanceof Array)&&_w(n,e)){const t=Kp(e);return n._length===t.length&&Iw(n.getAttributes(),e.attrs)&&n.toArray().every((r,s)=>ed(r,t[s]))}return n instanceof pr&&e instanceof Array&&z2(n,e)},Jp=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),V2=(n,e,t)=>{const r=n.toArray(),s=Kp(e),i=s.length,o=r.length,a=io(o,i);let l=0,c=0,u=!1;for(;l<a;l++){const f=r[l],d=s[l];if(Jp(t.get(f),d))u=!0;else if(!ed(f,d))break}for(;l+c<a;c++){const f=r[o-c-1],d=s[i-c-1];if(Jp(t.get(f),d))u=!0;else if(!ed(f,d))break}return{equalityFactor:l+c,foundMappedChild:u}},v6=n=>{let e="",t=n._start;const r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof Zr?e+=t.content.str:t.content instanceof Kt&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},x6=(n,e,t)=>{t.set(n,e);const{nAttrs:r,str:s}=v6(n),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,$2(c.marks))})),{insert:o,remove:a,index:l}=f6(s,i.map(c=>c.insert).join(""));n.delete(l,a),n.insert(l,o),n.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},$2=n=>{const e={};return n.forEach(t=>{t.type.name!=="ychange"&&(e[t.type.name]=t.attrs)}),e},Lw=(n,e,t,r)=>{if(e instanceof Dn&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.set(e,t),e instanceof Dn){const f=e.getAttributes(),d=t.attrs;for(const h in d)d[h]!==null?f[h]!==d[h]&&h!=="ychange"&&e.setAttribute(h,d[h]):e.removeAttribute(h);for(const h in f)d[h]===void 0&&e.removeAttribute(h)}const s=Kp(t),i=s.length,o=e.toArray(),a=o.length,l=io(i,a);let c=0,u=0;for(;c<l;c++){const f=o[c],d=s[c];if(!Jp(r.get(f),d))if(ed(f,d))r.set(f,d);else break}for(;u+c+1<l;u++){const f=o[a-u-1],d=s[i-u-1];if(!Jp(r.get(f),d))if(ed(f,d))r.set(f,d);else break}n.transact(()=>{for(;a-c-u>0&&i-c-u>0;){const d=o[c],h=s[c],p=o[a-u-1],m=s[i-u-1];if(d instanceof pr&&h instanceof Array)z2(d,h)||x6(d,h,r),c+=1;else{let y=d instanceof Dn&&_w(d,h),b=p instanceof Dn&&_w(p,m);if(y&&b){const x=V2(d,h,r),v=V2(p,m,r);x.foundMappedChild&&!v.foundMappedChild?b=!1:!x.foundMappedChild&&v.foundMappedChild||x.equalityFactor<v.equalityFactor?y=!1:b=!1}y?(Lw(n,d,h,r),c+=1):b?(Lw(n,p,m,r),u+=1):(r.delete(e.get(c)),e.delete(c,1),e.insert(c,[Pw(h,r)]),c+=1)}}const f=a-c-u;if(a===1&&i===0&&o[0]instanceof pr?(r.delete(o[0]),o[0].delete(0,o[0].length)):f>0&&(e.slice(c,c+f).forEach(d=>r.delete(d)),e.delete(c,f)),c+u<i){const d=[];for(let h=c;h<i-u;h++)d.push(Pw(s[h],r));e.insert(c,d)}},Mt)},_w=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;let td=null;const A6=()=>{const n=td;td=null,n.forEach((e,t)=>{const r=t.state.tr,s=Mt.getState(t.state);s&&s.binding&&!s.binding.isDestroyed&&(e.forEach((i,o)=>{r.setMeta(o,i)}),t.dispatch(r))})},E6=(n,e,t)=>{td||(td=new Map,qb(0,A6)),Jn(td,n,Mn).set(e,t)},qp=(n,e,t)=>{if(n===0)return ow(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof pr){if(r._length>=n)return ow(r,n,-1);if(n-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,n--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(t.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&n<s)r=r._first.content.type,n--;else{if(n===1&&r._length===0&&s>1)return new Wf(r._item===null?null:r._item.id,r._item===null?Vf(r):null,null);if(n-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(n===0)return r=r._item===null?r:r._item.parent,new Wf(r._item===null?null:r._item.id,r._item===null?Vf(r):null,null);do r=r._item.parent,n--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw dr();if(n===0&&r.constructor!==pr&&r!==e)return k6(r._item.parent,r._item)}return ow(e,e._length,-1)},k6=(n,e)=>{let t=null,r=null;return n._item===null?r=Vf(n):t=Ge(n._item.id.client,n._item.id.clock),new Wf(t,r,e.id)},nd=(n,e,t,r)=>{const s=KH(t,n);if(s===null||s.type!==e&&!$f(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===pr)o=s.index;else if(i._item===null||!i._item.deleted){let a=i._first,l=0;for(;l<i._length&&l<s.index&&a!==null;){if(!a.deleted){const c=a.content.type;l++,c instanceof pr?o+=c._length:o+=r.get(c).nodeSize}a=a.right}o+=1}for(;i!==e&&i._item!==null;){const a=i._item.parent;if(a._item===null||!a._item.deleted){o+=1;let l=a._first;for(;l!==null;){const c=l.content.type;if(c===i)break;l.deleted||(c instanceof pr?o+=c._length:o+=r.get(c).nodeSize),l=l.right}}i=a}return o-1},C6=(n,e,t)=>n!==e,S6=n=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null);const r=document.createTextNode("⁠"),s=document.createTextNode("⁠");return e.insertBefore(r,null),e.insertBefore(t,null),e.insertBefore(s,null),e},W2=n=>({style:`background-color: ${n.color}70`,class:"ProseMirror-yjs-selection"}),T6=/^#[0-9a-fA-F]{6}$/,G2=(n,e,t,r,s)=>{const i=Mt.getState(n),o=i.doc,a=[];return i.snapshot!=null||i.prevSnapshot!=null||i.binding===null?wt.create(n.doc,[]):(e.getStates().forEach((l,c)=>{if(t(o.clientID,c,l)&&l.cursor!=null){const u=l.user||{};u.color==null?u.color="#ffa500":T6.test(u.color)||console.warn("A user uses an unsupported color format",u),u.name==null&&(u.name=`User: ${c}`);let f=nd(o,i.type,Gf(l.cursor.anchor),i.binding.mapping),d=nd(o,i.type,Gf(l.cursor.head),i.binding.mapping);if(f!==null&&d!==null){const h=li(n.doc.content.size-1,0);f=io(f,h),d=io(d,h),a.push(Qt.widget(d,()=>r(u),{key:c+"",side:10}));const p=io(f,d),m=li(f,d);a.push(Qt.inline(p,m,s(u),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),wt.create(n.doc,a))},N6=(n,{awarenessStateFilter:e=C6,cursorBuilder:t=S6,selectionBuilder:r=W2,getSelection:s=o=>o.selection}={},i="cursor")=>new bt({key:$p,state:{init(o,a){return G2(a,n,e,t,r)},apply(o,a,l,c){const u=Mt.getState(c),f=o.getMeta($p);return u&&u.isChangeOrigin||f&&f.awarenessUpdated?G2(c,n,e,t,r):a.map(o.mapping,o.doc)}},props:{decorations:o=>$p.getState(o)},view:o=>{const a=()=>{o.docView&&E6(o,$p,{awarenessUpdated:!0})},l=()=>{const c=Mt.getState(o.state),u=n.getLocalState()||{};if(c.binding!=null)if(o.hasFocus()){const f=s(o.state),d=qp(f.anchor,c.type,c.binding.mapping),h=qp(f.head,c.type,c.binding.mapping);(u.cursor==null||!HT(Gf(u.cursor.anchor),d)||!HT(Gf(u.cursor.head),h))&&n.setLocalStateField(i,{anchor:d,head:h})}else u.cursor!=null&&nd(c.doc,c.type,Gf(u.cursor.anchor),c.binding.mapping)!==null&&n.setLocalStateField(i,null)};return n.on("change",a),o.dom.addEventListener("focusin",l),o.dom.addEventListener("focusout",l),{update:l,destroy:()=>{o.dom.removeEventListener("focusin",l),o.dom.removeEventListener("focusout",l),n.off("change",a),n.setLocalStateField(i,null)}}}}),O6=n=>{const e=hi.getState(n).undoManager;if(e!=null)return e.undo(),!0},R6=n=>{const e=hi.getState(n).undoManager;if(e!=null)return e.redo(),!0},M6=new Set(["paragraph"]),D6=(n,e)=>!(n instanceof xt)||!(n.content instanceof es)||!(n.content.type instanceof ka||n.content.type instanceof Dn&&e.has(n.content.type.nodeName))||n.content.type._length===0,P6=({protectedNodes:n=M6,trackedOrigins:e=[],undoManager:t=null}={})=>new bt({key:hi,state:{init:(r,s)=>{const i=Mt.getState(s),o=t||new XT(i.type,{trackedOrigins:new Set([Mt].concat(e)),deleteFilter:a=>D6(a,n),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const a=Mt.getState(o).binding,l=s.undoManager,c=l.undoStack.length>0,u=l.redoStack.length>0;return a?{undoManager:l,prevSel:Dw(a,i),hasUndoOps:c,hasRedoOps:u}:c!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):s}},view:r=>{const s=Mt.getState(r.state),i=hi.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const a=s.binding;a&&o.meta.set(a,hi.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const a=s.binding;a&&(a.beforeTransactionSelection=o.meta.get(a)||a.beforeTransactionSelection)}),{destroy:()=>{i.destroy()}}}}),I6=St.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},onCreate(){this.editor.extensionManager.extensions.find(n=>n.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),hi.getState(e).undoManager.undoStack.length===0?!1:t?O6(e):!0),redo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),hi.getState(e).undoManager.redoStack.length===0?!1:t?R6(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const n=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=P6(),t=e.spec.view;e.spec.view=a=>{const{undoManager:l}=hi.getState(a.state);l.restore&&(l.restore(),l.restore=()=>{});const c=t?t(a):void 0;return{destroy:()=>{const u=l.trackedOrigins.has(l),f=l._observers;l.restore=()=>{u&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=f},c!=null&&c.destroy&&c.destroy()}}};const r=this.options.ySyncOptions,s=this.options.onFirstRender,i={...r?{...r}:{},...s?{onFirstRender:s}:{}};return[p6(n,i),e]}}),K2=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t.user})),J2=()=>null,L6=St.create({name:"collaborationCursor",addOptions(){return{provider:null,user:{name:null,color:null},render:n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},selectionRender:W2,onUpdate:J2}},onCreate(){this.options.onUpdate!==J2&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor')},addStorage(){return{users:[]}},addCommands(){return{updateUser:n=>()=>(this.options.user=n,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:n=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(n))}},addProseMirrorPlugins(){return[N6((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=K2(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=K2(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),_6=/^\s*>\s$/,B6=vt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Fl({find:_6,type:this.type})]}}),F6=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,j6=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,U6=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,H6=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,z6=$n.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[aa({find:F6,type:this.type}),aa({find:U6,type:this.type})]},addPasteRules(){return[to({find:j6,type:this.type}),to({find:H6,type:this.type})]}}),V6=vt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",tt(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),q2=$n.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=lf(n,this.type);return Object.entries(t).some(([,s])=>!!s)?!0:e.unsetMark(this.name)}}}}),Q2=/^\s*([-+*])\s$/,$6=vt.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(V6.name,this.editor.getAttributes(q2.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Fl({find:Q2,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Fl({find:Q2,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(q2.name),editor:this.editor})),[n]}}),W6=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,G6=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,K6=$n.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[aa({find:W6,type:this.type})]},addPasteRules(){return[to({find:G6,type:this.type})]}}),J6=/^```([a-z]+)?[\s\n]$/,q6=/^~~~([a-z]+)?[\s\n]$/,Q6=vt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",tt(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
@@ -434,4 +434,4 @@ Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,i("_proc
434
434
  `,Hz="️",zz="‍";let Mm=null,Dm=null;function Vz(n){n===void 0&&(n=[]);const e={};Qn.groups=e;const t=new Qn;Mm==null&&(Mm=yN(Lz)),Dm==null&&(Dm=yN(_z)),de(t,"'",ym),de(t,"{",sd),de(t,"}",id),de(t,"[",nm),de(t,"]",rm),de(t,"(",sm),de(t,")",im),de(t,"<",om),de(t,">",am),de(t,"(",lm),de(t,")",cm),de(t,"「",um),de(t,"」",fm),de(t,"『",dm),de(t,"』",hm),de(t,"<",pm),de(t,">",mm),de(t,"&",gm),de(t,"*",bm),de(t,"@",fo),de(t,"`",vm),de(t,"^",xm),de(t,":",ho),de(t,",",qw),de(t,"$",Am),de(t,".",Is),de(t,"=",Em),de(t,"!",Qw),de(t,"-",Ls),de(t,"%",km),de(t,"|",Cm),de(t,"+",Sm),de(t,"#",Tm),de(t,"?",Nm),de(t,'"',Yw),de(t,"/",_s),de(t,";",Xw),de(t,"~",od),de(t,"_",Om),de(t,"\\",wm);const r=Pr(t,tv,Kw,{[Uw]:!0});Pr(r,tv,r);const s=Pr(t,dc,pi,{[Hw]:!0});Pr(s,dc,s);const i=Pr(t,Zw,$w,{[zw]:!0});Pr(i,dc),Pr(i,Zw,i);const o=Pr(t,mN,dN,{[uN]:!0});de(t,gN,Jw,{[uN]:!0}),de(o,gN),Pr(o,mN,o);const a=Pr(t,ev,hN,{[cN]:!0});Pr(a,ev,a),de(a,Hz,a);const l=de(a,zz);Pr(l,ev,a);const c=[[dc,s]],u=[[dc,null],[Zw,i]];for(let f=0;f<Mm.length;f++)po(t,Mm[f],Ww,pi,c);for(let f=0;f<Dm.length;f++)po(t,Dm[f],Gw,$w,u);Ra(Ww,{tld:!0,ascii:!0},e),Ra(Gw,{utld:!0,alpha:!0},e),po(t,"file",tm,pi,c),po(t,"mailto",tm,pi,c),po(t,"http",fc,pi,c),po(t,"https",fc,pi,c),po(t,"ftp",fc,pi,c),po(t,"ftps",fc,pi,c),Ra(tm,{scheme:!0,ascii:!0},e),Ra(fc,{slashscheme:!0,ascii:!0},e),n=n.sort((f,d)=>f[0]>d[0]?1:-1);for(let f=0;f<n.length;f++){const d=n[f][0],p=n[f][1]?{[Bz]:!0}:{[Fz]:!0};d.indexOf("-")>=0?p[Vw]=!0:dc.test(d)?tv.test(d)?p[Zp]=!0:p[Hw]=!0:p[Uw]=!0,fN(t,d,d,p)}return fN(t,"localhost",rd,{ascii:!0}),t.jd=new Qn(Rm),{start:t,tokens:uc({groups:e},pN)}}function $z(n,e){const t=Wz(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=t.length,s=[];let i=0,o=0;for(;o<r;){let a=n,l=null,c=0,u=null,f=-1,d=-1;for(;o<r&&(l=a.go(t[o]));)a=l,a.accepts()?(f=0,d=0,u=a):f>=0&&(f+=t[o].length,d++),c+=t[o].length,i+=t[o].length,o++;i-=f,o-=d,c-=f,s.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function Wz(n){const e=[],t=n.length;let r=0;for(;r<t;){let s=n.charCodeAt(r),i,o=s<55296||s>56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function po(n,e,t,r,s){let i;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];n.j[l]?i=n.j[l]:(i=new Qn(r),i.jr=s.slice(),n.j[l]=i),n=i}return i=new Qn(t),i.jr=s.slice(),n.j[e[o-1]]=i,i}function yN(n){const e=[],t=[];let r=0,s="0123456789";for(;r<n.length;){let i=0;for(;s.indexOf(n[r+i])>=0;)i++;if(i>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+i),10);o>0;o--)t.pop();r+=i}else t.push(n[r]),r++}return e}const ad={defaultProtocol:"http",events:null,format:bN,formatHref:bN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function nv(n,e){e===void 0&&(e=null);let t=uc({},ad);n&&(t=uc(t,n instanceof nv?n.o:n));const r=t.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=s}nv.prototype={o:ad,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let s=this.o[n];return s&&(typeof s=="object"?(s=t.t in s?s[t.t]:ad[n],typeof s=="function"&&r&&(s=s(e,t))):typeof s=="function"&&r&&(s=s(e,t.t,t)),s)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function bN(n){return n}function wN(n,e){this.t="token",this.v=n,this.tk=e}wN.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n){return n===void 0&&(n=ad.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),s=n.get("tagName",t,e),i=this.toFormattedString(n),o={},a=n.get("className",t,e),l=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),f=n.getObj("events",t,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),u&&uc(o,u),{tagName:s,attributes:o,content:i,eventListeners:f}}};function Pm(n,e){class t extends wN{constructor(s,i){super(s,i),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const vN=Pm("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),xN=Pm("text"),Gz=Pm("nl"),Im=Pm("url",{isLink:!0,toHref(n){return n===void 0&&(n=ad.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==rd&&n[1].t===ho}}),Ir=n=>new Qn(n);function Kz(n){let{groups:e}=n;const t=e.domain.concat([gm,bm,fo,wm,vm,xm,Am,Em,Ls,Kw,km,Cm,Sm,Tm,_s,Rm,od,Om]),r=[ym,ho,qw,Is,Qw,Nm,Yw,Xw,om,am,sd,id,rm,nm,sm,im,lm,cm,um,fm,dm,hm,pm,mm],s=[gm,ym,bm,wm,vm,xm,Am,Em,Ls,sd,id,km,Cm,Sm,Tm,Nm,_s,Rm,od,Om],i=Ir(),o=de(i,od);Ye(o,s,o),Ye(o,e.domain,o);const a=Ir(),l=Ir(),c=Ir();Ye(i,e.domain,a),Ye(i,e.scheme,l),Ye(i,e.slashscheme,c),Ye(a,s,o),Ye(a,e.domain,a);const u=de(a,fo);de(o,fo,u),de(l,fo,u),de(c,fo,u);const f=de(o,Is);Ye(f,s,o),Ye(f,e.domain,o);const d=Ir();Ye(u,e.domain,d),Ye(d,e.domain,d);const h=de(d,Is);Ye(h,e.domain,d);const p=Ir(vN);Ye(h,e.tld,p),Ye(h,e.utld,p),de(u,rd,p);const m=de(d,Ls);Ye(m,e.domain,d),Ye(p,e.domain,d),de(p,Is,h),de(p,Ls,m);const y=de(p,ho);Ye(y,e.numeric,vN);const b=de(a,Ls),x=de(a,Is);Ye(b,e.domain,a),Ye(x,s,o),Ye(x,e.domain,a);const v=Ir(Im);Ye(x,e.tld,v),Ye(x,e.utld,v),Ye(v,e.domain,a),Ye(v,s,o),de(v,Is,x),de(v,Ls,b),de(v,fo,u);const w=de(v,ho),E=Ir(Im);Ye(w,e.numeric,E);const k=Ir(Im),S=Ir();Ye(k,t,k),Ye(k,r,S),Ye(S,t,k),Ye(S,r,S),de(v,_s,k),de(E,_s,k);const M=de(l,ho),O=de(c,ho),R=de(O,_s),D=de(R,_s);Ye(l,e.domain,a),de(l,Is,x),de(l,Ls,b),Ye(c,e.domain,a),de(c,Is,x),de(c,Ls,b),Ye(M,e.domain,k),de(M,_s,k),Ye(D,e.domain,k),Ye(D,t,k),de(D,_s,k);const F=[[sd,id],[nm,rm],[sm,im],[om,am],[lm,cm],[um,fm],[dm,hm],[pm,mm]];for(let U=0;U<F.length;U++){const[K,_]=F[U],G=de(k,K);de(S,K,G),de(G,_,k);const Y=Ir(Im);Ye(G,t,Y);const re=Ir();Ye(G,r),Ye(Y,t,Y),Ye(Y,r,re),Ye(re,t,Y),Ye(re,r,re),de(Y,_,k),de(re,_,k)}return de(i,rd,v),de(i,Jw,Gz),{start:i,tokens:pN}}function Jz(n,e,t){let r=t.length,s=0,i=[],o=[];for(;s<r;){let a=n,l=null,c=null,u=0,f=null,d=-1;for(;s<r&&!(l=a.go(t[s].t));)o.push(t[s++]);for(;s<r&&(c=l||a.go(t[s].t));)l=null,a=c,a.accepts()?(d=0,f=a):d>=0&&d++,s++,u++;if(d<0)s-=u,s<r&&(o.push(t[s]),s++);else{o.length>0&&(i.push(rv(xN,e,o)),o=[]),s-=d,u-=d;const h=f.t,p=t.slice(s-u,s);i.push(rv(h,e,p))}}return o.length>0&&i.push(rv(xN,e,o)),i}function rv(n,e,t){const r=t[0].s,s=t[t.length-1].e,i=e.slice(r,s);return new n(i,t)}const qz=typeof console<"u"&&console&&console.warn||(()=>{}),Qz="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Dt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Yz(){Qn.groups={},Dt.scanner=null,Dt.parser=null,Dt.tokenQueue=[],Dt.pluginQueue=[],Dt.customSchemes=[],Dt.initialized=!1}function AN(n,e){if(e===void 0&&(e=!1),Dt.initialized&&qz(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Qz}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
435
435
  1. Must only contain digits, lowercase ASCII letters or "-"
436
436
  2. Cannot start or end with "-"
437
- 3. "-" cannot repeat`);Dt.customSchemes.push([n,e])}function Xz(){Dt.scanner=Vz(Dt.customSchemes);for(let n=0;n<Dt.tokenQueue.length;n++)Dt.tokenQueue[n][1]({scanner:Dt.scanner});Dt.parser=Kz(Dt.scanner.tokens);for(let n=0;n<Dt.pluginQueue.length;n++)Dt.pluginQueue[n][1]({scanner:Dt.scanner,parser:Dt.parser});Dt.initialized=!0}function EN(n){return Dt.initialized||Xz(),Jz(Dt.parser.start,n,$z(Dt.scanner.start,n))}function kN(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new nv(t),s=EN(n),i=[];for(let o=0;o<s.length;o++){const a=s[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}function Zz(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function eV(n){return new bt({key:new Ot("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=xB(t.doc,[...e]);if(OB(a).forEach(({newRange:c})=>{const u=EB(r.doc,c,h=>h.isTextblock);let f,d;if(u.length>1?(f=u[0],d=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(f=u[0],d=r.doc.textBetween(f.pos,c.to,void 0," ")),f&&d){const h=d.split(" ").filter(b=>b!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=f.pos+d.lastIndexOf(p);if(!p)return!1;const y=EN(p).map(b=>b.toObject());if(!Zz(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate?n.validate(b.value):!0).forEach(b=>{c0(b.from,b.to,r.doc).some(x=>x.mark.type===n.type)||o.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function tV(n){return new bt({key:new Ot("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(n.whenNotEditable&&e.editable||r.button!==0)return!1;let o=r.target;const a=[];for(;o.nodeName!=="DIV";)a.push(o),o=o.parentNode;if(!a.find(d=>d.nodeName==="A"))return!1;const l=BE(e.state,n.type.name),c=r.target,u=(s=c==null?void 0:c.href)!==null&&s!==void 0?s:l.href,f=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:l.target;return c&&u?(window.open(u,f),!0):!1}}})}function nV(n){return new bt({key:new Ot("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=kN(a).find(c=>c.isLink&&c.value===a);return!a||!l?!1:(n.editor.commands.setMark(n.type,{href:l.href}),!0)}}})}const rV=$n.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){AN(n);return}AN(n.scheme,n.optionalSlashes)})},onDestroy(){Yz()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",tt(this.options.HTMLAttributes,{...n,href:""}),0]:["a",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[to({find:n=>{const e=[];if(n){const t=kN(n).filter(r=>r.isLink);t.length&&t.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(eV({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(tV({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&n.push(nV({editor:this.editor,type:this.type})),n}}),sV=St.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,considerAnyAsEmpty:!1,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new bt({key:new Ot("placeholder"),props:{decorations:({doc:n,selection:e})=>{var t;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=e,i=[];if(!r)return null;const{firstChild:o}=n.content,a=o&&o.type.isLeaf,l=o&&o.isAtom,c=this.options.considerAnyAsEmpty?!0:o&&o.type.name===((t=n.type.contentMatch.defaultType)===null||t===void 0?void 0:t.name),u=n.content.childCount<=1&&o&&c&&o.nodeSize<=2&&(!a||!l);return n.descendants((f,d)=>{const h=s>=d&&s<=d+f.nodeSize,p=!f.isLeaf&&!f.childCount;if((h||!this.options.showOnlyCurrent)&&p){const m=[this.options.emptyNodeClass];u&&m.push(this.options.emptyEditorClass);const y=Qt.node(d,d+f.nodeSize,{class:m.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:f,pos:d,hasAnchor:h}):this.options.placeholder});i.push(y)}return this.options.includeChildren}),wt.create(n,i)}}})]}}),iV=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,oV=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,aV=$n.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[aa({find:iV,type:this.type})]},addPasteRules(){return[to({find:oV,type:this.type})]}}),lV=vt.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",tt(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),cV=/^\s*(\[([( |x])?\])\s$/,uV=vt.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>n.getAttribute("data-checked")==="true",renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",tt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");return i.contentEditable="false",a.type="checkbox",a.addEventListener("change",c=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=c.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const d=t(),h=f.doc.nodeAt(d);return f.setNodeMarkup(d,void 0,{...h==null?void 0:h.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{s.setAttribute(c,u)}),s.dataset.checked=n.attrs.checked,n.attrs.checked&&a.setAttribute("checked","checked"),i.append(a,o),s.append(i,l),Object.entries(e).forEach(([c,u])=>{s.setAttribute(c,u)}),{dom:s,contentDOM:l,update:c=>c.type!==this.type?!1:(s.dataset.checked=c.attrs.checked,c.attrs.checked?a.setAttribute("checked","checked"):a.removeAttribute("checked"),!0)}}},addInputRules(){return[Fl({find:cV,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),fV=$n.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function dV(n){var e;const{char:t,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:o}=n,a=ZB(t),l=new RegExp(`\\s${a}$`),c=i?"^":"",u=r?new RegExp(`${c}${a}.*?(?=\\s${a}|$)`,"gm"):new RegExp(`${c}(?:^)?${a}[^\\s${a}]*`,"gm"),f=((e=o.nodeBefore)===null||e===void 0?void 0:e.isText)&&o.nodeBefore.text;if(!f)return null;const d=o.pos-f.length,h=Array.from(f.matchAll(u)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const p=h.input.slice(Math.max(0,h.index-1),h.index),m=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(p);if(s!==null&&!m)return null;const y=d+h.index;let b=y+h[0].length;return r&&l.test(f.slice(b-1,b+1))&&(h[0]+=" ",b+=1),y<o.pos&&b>=o.pos?{range:{from:y,to:b},query:h[0].slice(t.length),text:h[0]}:null}const hV=new Ot("suggestion");function pV({pluginKey:n=hV,editor:e,char:t="@",allowSpaces:r=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:o="span",decorationClass:a="suggestion",command:l=()=>null,items:c=()=>[],render:u=()=>({}),allow:f=()=>!0,findSuggestionMatch:d=dV}){let h;const p=u==null?void 0:u(),m=new bt({key:n,view(){return{update:async(y,b)=>{var x,v,w,E,k,S,M;const O=(x=this.key)===null||x===void 0?void 0:x.getState(b),R=(v=this.key)===null||v===void 0?void 0:v.getState(y.state),D=O.active&&R.active&&O.range.from!==R.range.from,F=!O.active&&R.active,U=O.active&&!R.active,K=!F&&!U&&O.query!==R.query,_=F||D,G=K&&!D,Y=U||D;if(!_&&!G&&!Y)return;const re=Y&&!_?O:R,Z=y.dom.querySelector(`[data-decoration-id="${re.decorationId}"]`);h={editor:e,range:re.range,query:re.query,text:re.text,items:[],command:me=>l({editor:e,range:re.range,props:me}),decorationNode:Z,clientRect:Z?()=>{var me;const{decorationId:ke}=(me=this.key)===null||me===void 0?void 0:me.getState(e.state),Pe=y.dom.querySelector(`[data-decoration-id="${ke}"]`);return(Pe==null?void 0:Pe.getBoundingClientRect())||null}:null},_&&((w=p==null?void 0:p.onBeforeStart)===null||w===void 0||w.call(p,h)),G&&((E=p==null?void 0:p.onBeforeUpdate)===null||E===void 0||E.call(p,h)),(G||_)&&(h.items=await c({editor:e,query:re.query})),Y&&((k=p==null?void 0:p.onExit)===null||k===void 0||k.call(p,h)),G&&((S=p==null?void 0:p.onUpdate)===null||S===void 0||S.call(p,h)),_&&((M=p==null?void 0:p.onStart)===null||M===void 0||M.call(p,h))},destroy:()=>{var y;h&&((y=p==null?void 0:p.onExit)===null||y===void 0||y.call(p,h))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(y,b,x,v){const{isEditable:w}=e,{composing:E}=e.view,{selection:k}=y,{empty:S,from:M}=k,O={...b};if(O.composing=E,w&&(S||e.view.composing)){(M<b.range.from||M>b.range.to)&&!E&&!b.composing&&(O.active=!1);const R=d({char:t,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:k.$from}),D=`id_${Math.floor(Math.random()*4294967295)}`;R&&f({editor:e,state:v,range:R.range})?(O.active=!0,O.decorationId=b.decorationId?b.decorationId:D,O.range=R.range,O.query=R.query,O.text=R.text):O.active=!1}else O.active=!1;return O.active||(O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null),O}},props:{handleKeyDown(y,b){var x;const{active:v,range:w}=m.getState(y.state);return v&&((x=p==null?void 0:p.onKeyDown)===null||x===void 0?void 0:x.call(p,{view:y,event:b,range:w}))||!1},decorations(y){const{active:b,range:x,decorationId:v}=m.getState(y);return b?wt.create(y.doc,[Qt.inline(x.from,x.to,{nodeName:o,class:a,"data-decoration-id":v})]):null}}});return m}const mV=St.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:n,range:e,props:t})=>{t.command({editor:n,range:e})}}}},addProseMirrorPlugins(){return[pV({editor:this.editor,...this.options.suggestion})]}}),gV=({query:n})=>[{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:C.jsx($k,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run()}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:C.jsx(zk,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:C.jsx(Vh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:C.jsx($h,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:C.jsx(Wh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:C.jsx(Gh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:C.jsx(Wl,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{title:"Divider",description:"Visually divide content.",searchTerms:["hr","divider","break","line","delimiter"],icon:C.jsx(n4,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:C.jsx(Kh,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:C.jsx(Af,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"Table",description:"Create a table.",searchTerms:["table"],icon:C.jsx(Vk,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:C.jsx(e4,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const r=document.createElement("input");r.type="file",r.accept="image/*",r.onchange=async()=>{var s;if((s=r.files)!=null&&s.length){const i=r.files[0],o=e.view.state.selection.from;z0(i,e.view,o)}},r.click()}},{title:"Video Embed",description:"Embed a video from YouTube, Vimeo, etc.",searchTerms:["iframe","embed","video","youtube"],icon:C.jsx(Kk,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("iframe").run()}},{title:"Twitter",description:"Embed a Twitter tweet.",searchTerms:["embed","twitter","tweet"],icon:C.jsx(Gk,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("twitter").run()}},{title:"2 Columns",description:"Create 2 columns of block",searchTerms:["col","column","2","layout"],icon:C.jsx(jk,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(2).focus(e.state.selection.head-1).run()}},{title:"3 Columns",description:"Create 3 columns of block",searchTerms:["col","column","3","layout"],icon:C.jsx(Q3,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(3).focus(e.state.selection.head-1).run()}}].filter(e=>{if(typeof n=="string"&&n.length>0){const t=n.toLowerCase();return e.title.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.searchTerms&&e.searchTerms.some(r=>r.includes(t))}return!0}),yV=(n,e)=>{const t=n.offsetHeight,r=e?e.offsetHeight:0,s=e.offsetTop,i=s+r;s<n.scrollTop?n.scrollTop-=n.scrollTop-s+5:i>t+n.scrollTop&&(n.scrollTop+=i-t-n.scrollTop+5)},bV=({items:n,command:e,editor:t})=>{const[r,s]=L.useState(0),i=L.useCallback(a=>{const l=n[a];l&&(l.title==="Continue writing"||e(l))},[e,t,n]);L.useEffect(()=>{const a=["ArrowUp","ArrowDown","Enter"],l=c=>{if(a.includes(c.key))return c.preventDefault(),c.key==="ArrowUp"?(s((r+n.length-1)%n.length),!0):c.key==="ArrowDown"?(s((r+1)%n.length),!0):c.key==="Enter"?(i(r),!0):!1};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[n,r,s,i]),L.useEffect(()=>{s(0)},[n]);const o=L.useRef(null);return L.useLayoutEffect(()=>{const a=o==null?void 0:o.current,l=a==null?void 0:a.children[r];l&&a&&yV(a,l)},[r]),n.length>0?C.jsx("div",{id:"slash-command",ref:o,className:"z-50 h-auto max-h-[330px] w-72 overflow-y-auto scroll-smooth rounded-md border border-[#DDD] bg-white px-1 py-2 shadow-md transition-all",children:n.map((a,l)=>C.jsxs("button",{className:`flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-neutral-500 hover:bg-neutral-100 hover:border-neutral-200 border border-transparent transition-all ${l===r?"bg-neutral-200 text-neutral-800":""}`,onClick:()=>i(l),children:[C.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-neutral-200 bg-white",children:a.icon}),C.jsxs("div",{children:[C.jsx("p",{className:"font-medium",children:a.title}),C.jsx("p",{className:"text-xs text-neutral-500",children:a.description})]})]},l))}):null},wV=()=>{let n=null,e=null;return{onStart:t=>{n=new Lk(bV,{props:t,editor:t.editor}),e=fa("body",{getReferenceClientRect:t.clientRect,appendTo:()=>document.body,content:n.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:t=>{n==null||n.updateProps(t),e&&e[0].setProps({getReferenceClientRect:t.clientRect})},onKeyDown:t=>{var r;return t.event.key==="Escape"?(e==null||e[0].hide(),!0):(r=n==null?void 0:n.ref)==null?void 0:r.onKeyDown(t)},onExit:()=>{e==null||e[0].destroy(),n==null||n.destroy()}}},vV=mV.configure({suggestion:{items:gV,render:wV}}),xV=oN.extend({renderHTML(){return["div",tt(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),AV=St.create({name:"columnExtension",addExtensions(){const n=[];return this.options.column!==!1&&n.push(RS),this.options.columns!==!1&&n.push(mp),n}}),EV=St.create({name:"CustomKeymap",addCommands(){return{selectTextWithinNodeBoundaries:()=>({editor:n,commands:e})=>{const{state:t}=n,{tr:r}=t,s=r.selection.$from.start(),i=r.selection.$to.end();return e.setTextSelection({from:s,to:i})}}},addKeyboardShortcuts(){return{"Mod-a":({editor:n})=>{const{state:e}=n,{tr:t}=e,r=t.selection.from,s=t.selection.to,i=t.selection.$from.start(),o=t.selection.$to.end();return r>i||s<o?(n.chain().selectTextWithinNodeBoundaries().run(),!0):!1}}}}),kV=St.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),CN=[{tooltip:"Align left",action:n=>n({dataAlign:"start",dataFloat:null}),icon:"AlignLeft",isActive:n=>n.dataAlign==="start"},{tooltip:"Align center",action:n=>n({dataAlign:"center",dataFloat:null}),icon:"AlignCenter",isActive:n=>n.dataAlign==="center"},{tooltip:"Align right",action:n=>n({dataAlign:"end",dataFloat:null}),icon:"AlignRight",isActive:n=>n.dataAlign==="end"},{tooltip:"Delete",icon:"Trash2",delete:n=>n()}];let hc;const SN=({node:n,updateAttributes:e,deleteNode:t})=>{const r=gp(),[s,i]=L.useState(),[o,a]=L.useState(0),[l,c]=L.useState(0),[u,f]=L.useState({}),d=L.useRef(null),[h,p]=L.useState(!1),m=()=>{const U={};CN.forEach(({tooltip:K,isActive:_})=>{U[K]=!!(_!=null&&_(n.attrs))}),f(U)},y=()=>{const U=document.querySelector(".ProseMirror");if(U&&c(U==null?void 0:U.clientWidth),!!d.current){if(s==="video"){const K=d.current;K.addEventListener("loadeddata",function(){a(K.videoWidth/K.videoHeight),k("left",0)})}else if(s==="iframe"){const K=d.current;K.onload=()=>{a(K.offsetWidth/K.offsetHeight),k("left",0)}}else d.current.onload=()=>{a(d.current.naturalWidth/d.current.naturalHeight)};setTimeout(()=>m(),200)}},b=U=>{hc=U};L.useEffect(()=>{y()},[]);const x=({width:U,height:K})=>U<200||K<200,v=U=>{setTimeout(()=>S(U))},w=U=>{hc=U.clientX,setTimeout(()=>{document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)}),p(!0)},E=()=>{hc=-1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",E),p(!1)},k=(U,K)=>{var Y,re;if(!d.current){console.error("Media ref is undefined|null",{resizableImg:d.current});return}const _={width:(Y=d.current)==null?void 0:Y.width,height:(re=d.current)==null?void 0:re.height},G={width:-1,height:-1};U==="left"?G.width=_.width-Math.abs(K):(typeof _.width=="string"&&(_.width=Number(_.width)),G.width=_.width+Math.abs(K)),G.width>l&&(G.width=l),s==="iframe"?G.height=G.width/(16/9):G.height=G.width/o,!x(G)&&e(G)},S=U=>{if(hc===-1)return;const{clientX:K}=U,_=hc-K;if(_===0)return;const G=_>0?"left":"right";setTimeout(()=>{k(G,Math.abs(_)),hc=K})},[M,O]=L.useState(),[R,D]=L.useState();L.useEffect(()=>{i(n.attrs["media-type"]),m(),O(n.attrs.dataFloat),D(n.attrs.dataAlign)},[n.attrs]);const F=U=>{switch(U){case"AlignLeft":return C.jsx(vf,{size:16});case"AlignCenter":return C.jsx(D0,{size:16});case"AlignRight":return C.jsx(P0,{size:16});case"Trash2":return C.jsx(Wk,{size:16});default:return null}};return C.jsx(wf,{as:"article",className:pe("media-node-view not-prose transition-all ease-in-out w-full",M&&`f-${n.attrs.dataFloat}`,R&&`justify-${n.attrs.dataAlign}`),children:C.jsxs("div",{className:"w-fit flex relative group transition-all ease-in-out",children:[s==="img"&&C.jsx("img",{src:n.attrs.src,ref:d,className:"rounded-lg",alt:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),s==="video"&&C.jsx("video",{ref:d,className:"rounded-lg",controls:!0,width:n.attrs.width,height:n.attrs.height,children:C.jsx("source",{src:n.attrs.src})}),s==="iframe"&&C.jsx("iframe",{ref:d,className:pe("rounded-lg max-w-full",h&&"pointer-events-none"),src:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),!r&&C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"horizontal-resize-handle group-hover:bg-black group-hover:border-2 group-hover:border-white/80",title:"Resize",onClick:({clientX:U})=>b(U),onMouseDown:w,onMouseUp:E}),C.jsx("section",{className:"media-control-buttons opacity-0 group-hover:opacity-100 transition-opacity duration-200 flex",children:CN.map(U=>C.jsx("div",{className:"tooltip","data-tip":U.tooltip,children:C.jsx("button",{type:"button",className:pe("btn rounded-none h-8 px-2 py-1 transition",u[U.tooltip]&&"active"),onClick:()=>{var K;return U.tooltip==="Delete"?t():(K=U.action)==null?void 0:K.call(U,e)},children:U.icon&&F(U.icon)})}))})]})]})})},CV=vt.create({name:"iframe",group:"block",atom:!0,draggable:!0,addOptions(){return{allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"}}},addAttributes(){return{src:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},"media-type":{default:"iframe"},alt:{default:null},title:{default:null},width:{default:this.options.width},height:{default:this.options.height},dataAlign:{default:"left"},dataFloat:{default:null}}},addNodeView(){return da(SN)},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:n}){return["iframe",tt(this.options.HTMLAttributes,n)]},addCommands(){return{setIframe:n=>({tr:e,dispatch:t})=>{const{selection:r}=e,s=this.type.create(n);return t&&e.replaceRangeWith(r.from-1,r.to,s),!0}}}});var SV="https://platform.twitter.com/widgets.js",sv="createTweet",TV=function(e){var t=L.useRef(null),r=L.useState(!0),s=r[0],i=r[1];return L.useEffect(function(){var o=!0,a=require("scriptjs");return a(SV,"twitter-embed",function(){if(!window.twttr){console.error("Failure to load window.twttr, aborting load");return}if(o){if(!window.twttr.widgets[sv]){console.error("Method "+sv+" is not present anymore in twttr.widget api");return}window.twttr.widgets[sv](e.tweetId,t==null?void 0:t.current,e.options).then(function(l){i(!1),e.onLoad&&e.onLoad(l)})}}),function(){o=!1}},[]),L.createElement(L.Fragment,null,s&&L.createElement(L.Fragment,null,e.placeholder),L.createElement("div",{ref:t}))};const NV=({node:n,editor:e})=>{const[t,r]=L.useState(!0);return L.useEffect(()=>{e==null||e.chain().focus()},[]),C.jsx(wf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:C.jsxs("div",{className:"w-full max-w-sm",children:[t&&C.jsx(HS,{width:5,height:5}),C.jsx(TV,{tweetId:n.attrs.tweetId,onLoad:()=>r(!1)})]})})},OV=vt.create({name:"embeddedTweet",group:"block",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:""}}},addAttributes(){return{tweetId:{default:null},align:{default:"center"}}},parseHTML(){return[{tag:"div[data-tweet-id]"}]},renderHTML({HTMLAttributes:n}){return["div",tt(this.options.HTMLAttributes,n)]},addNodeView(){return da(NV)},addCommands(){return{setTweetEmbed:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{tweetId:n.tweetId,align:"center"},content:[]})}}}),RV=n=>new bt({key:new Ot("media-paste-drop"),props:{handlePaste(e,t){var s;return Array.from(((s=t.clipboardData)==null?void 0:s.items)||[]).forEach(i=>{const o=i.getAsFile();if(((o==null?void 0:o.type.indexOf("image"))===0||(o==null?void 0:o.type.indexOf("video"))===0)&&(t.preventDefault(),o&&o.size>1024*1024))throw new Error("Image too large")}),!1},handleDrop(e,t){var a;if(!(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length))return!1;const s=Array.from(((a=t.dataTransfer)==null?void 0:a.files)??[]).filter(({type:l})=>/image|video/i.test(l));if(s.length===0)return!1;t.preventDefault();const{schema:i}=e.state,o=e.posAtCoords({left:t.clientX,top:t.clientY});return o?(s.forEach(async l=>{const c=new FileReader;if(n){const u=i.nodes.resizableMedia.create({src:await n(l),"media-type":l.type.includes("image")?"img":"video"}),f=e.state.tr.insert(o.pos,u);e.dispatch(f)}else c.onload=u=>{var h;const f=i.nodes.resizableMedia.create({src:(h=u.target)==null?void 0:h.result,"media-type":l.type.includes("image")?"img":"video"}),d=e.state.tr.insert(o.pos,f);e.dispatch(d)},c.readAsDataURL(l)}),!0):!1}}}),MV=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,DV=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,PV=vt.create({name:"resizableMedia",addOptions(){return{HTMLAttributes:{class:"rounded-lg border border-stone-200"},uploadFn:async()=>""}},inline:!1,group:"block",draggable:!0,addAttributes(){return{src:{default:null},"media-type":{default:null},alt:{default:null},title:{default:null},width:{default:"100%"},height:{default:"auto"},dataAlign:{default:"left"},dataFloat:{default:null}}},selectable:!0,parseHTML(){return[{tag:'img[src]:not([src^="data:"])',getAttrs:n=>({src:n.getAttribute("src"),"media-type":"img"})},{tag:"video",getAttrs:n=>({src:n.getAttribute("src"),"media-type":"video"})}]},renderHTML({HTMLAttributes:n}){const{"media-type":e}=n;return e==="img"?["img",tt(this.options.HTMLAttributes,n)]:e==="video"?["video",{controls:"true",style:"width: 100%",...n},["source",n]]:(e||console.error("TiptapMediaExtension-renderHTML method: Media Type not set, going default with image"),["img",tt(this.options.HTMLAttributes,n)])},addCommands(){return{setMedia:n=>({commands:e})=>{const{"media-type":t}=n;return t==="img"?e.insertContent({type:this.name,attrs:n}):t==="video"?e.insertContent({type:this.name,attrs:{...n,controls:"true"}}):(t||console.error("TiptapMediaExtension-setMedia: Media Type not set, going default with image"),e.insertContent({type:this.name,attrs:n}))}}},addNodeView(){return da(SN)},addKeyboardShortcuts(){return{Enter:({editor:n})=>{const{selection:e}=n.state;if(e.empty)return!1;const t=e.$to.pos;return n.commands.insertContentAt(t,{type:"dBlock",content:[{type:"paragraph"}]})}}},addInputRules(){return[h0({find:MV,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r,"media-type":"img"}}}),h0({find:DV,type:this.type,getAttributes:n=>{const[,,e]=n;return{src:e,"media-type":"video"}}})]},addProseMirrorPlugins(){return[RV(this.options.uploadFn),d4()]}});function iv(n,e){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>n(...s),e)}}const IV=["top","right","bottom","left"],Bs=Math.min,gr=Math.max,Lm=Math.round,_m=Math.floor,mo=n=>({x:n,y:n}),LV={left:"right",right:"left",bottom:"top",top:"bottom"},_V={start:"end",end:"start"};function ov(n,e,t){return gr(n,Bs(e,t))}function mi(n,e){return typeof n=="function"?n(e):n}function gi(n){return n.split("-")[0]}function pc(n){return n.split("-")[1]}function av(n){return n==="x"?"y":"x"}function lv(n){return n==="y"?"height":"width"}function mc(n){return["top","bottom"].includes(gi(n))?"y":"x"}function cv(n){return av(mc(n))}function BV(n,e,t){t===void 0&&(t=!1);const r=pc(n),s=cv(n),i=lv(s);let o=s==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Bm(o)),[o,Bm(o)]}function FV(n){const e=Bm(n);return[uv(n),e,uv(e)]}function uv(n){return n.replace(/start|end/g,e=>_V[e])}function jV(n,e,t){const r=["left","right"],s=["right","left"],i=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return t?e?s:r:e?r:s;case"left":case"right":return e?i:o;default:return[]}}function UV(n,e,t,r){const s=pc(n);let i=jV(gi(n),t==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(uv)))),i}function Bm(n){return n.replace(/left|right|bottom|top/g,e=>LV[e])}function HV(n){return{top:0,right:0,bottom:0,left:0,...n}}function TN(n){return typeof n!="number"?HV(n):{top:n,right:n,bottom:n,left:n}}function Fm(n){const{x:e,y:t,width:r,height:s}=n;return{width:r,height:s,top:t,left:e,right:e+r,bottom:t+s,x:e,y:t}}function NN(n,e,t){let{reference:r,floating:s}=n;const i=mc(e),o=cv(e),a=lv(o),l=gi(e),c=i==="y",u=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,d=r[a]/2-s[a]/2;let h;switch(l){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(pc(e)){case"start":h[o]-=d*(t&&c?-1:1);break;case"end":h[o]+=d*(t&&c?-1:1);break}return h}const zV=async(n,e,t)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=t,a=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:s}),{x:u,y:f}=NN(c,r,l),d=r,h={},p=0;for(let m=0;m<a.length;m++){const{name:y,fn:b}=a[m],{x,y:v,data:w,reset:E}=await b({x:u,y:f,initialPlacement:r,placement:d,strategy:s,middlewareData:h,rects:c,platform:o,elements:{reference:n,floating:e}});u=x??u,f=v??f,h={...h,[y]:{...h[y],...w}},E&&p<=50&&(p++,typeof E=="object"&&(E.placement&&(d=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:s}):E.rects),{x:u,y:f}=NN(c,d,l)),m=-1)}return{x:u,y:f,placement:d,strategy:s,middlewareData:h}};async function ld(n,e){var t;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=mi(e,n),p=TN(h),y=a[d?f==="floating"?"reference":"floating":f],b=Fm(await i.getClippingRect({element:(t=await(i.isElement==null?void 0:i.isElement(y)))==null||t?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=f==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),w=await(i.isElement==null?void 0:i.isElement(v))?await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1}:{x:1,y:1},E=Fm(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:v,strategy:l}):x);return{top:(b.top-E.top+p.top)/w.y,bottom:(E.bottom-b.bottom+p.bottom)/w.y,left:(b.left-E.left+p.left)/w.x,right:(E.right-b.right+p.right)/w.x}}const VV=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:s,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=mi(n,e)||{};if(c==null)return{};const f=TN(u),d={x:t,y:r},h=cv(s),p=lv(h),m=await o.getDimensions(c),y=h==="y",b=y?"top":"left",x=y?"bottom":"right",v=y?"clientHeight":"clientWidth",w=i.reference[p]+i.reference[h]-d[h]-i.floating[p],E=d[h]-i.reference[h],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let S=k?k[v]:0;(!S||!await(o.isElement==null?void 0:o.isElement(k)))&&(S=a.floating[v]||i.floating[p]);const M=w/2-E/2,O=S/2-m[p]/2-1,R=Bs(f[b],O),D=Bs(f[x],O),F=R,U=S-m[p]-D,K=S/2-m[p]/2+M,_=ov(F,K,U),G=!l.arrow&&pc(s)!=null&&K!==_&&i.reference[p]/2-(K<F?R:D)-m[p]/2<0,Y=G?K<F?K-F:K-U:0;return{[h]:d[h]+Y,data:{[h]:_,centerOffset:K-_-Y,...G&&{alignmentOffset:Y}},reset:G}}}),$V=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...y}=mi(n,e);if((t=i.arrow)!=null&&t.alignmentOffset)return{};const b=gi(s),x=gi(a)===a,v=await(l.isRTL==null?void 0:l.isRTL(c.floating)),w=d||(x||!m?[Bm(a)]:FV(a));!d&&p!=="none"&&w.push(...UV(a,m,p,v));const E=[a,...w],k=await ld(e,y),S=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&S.push(k[b]),f){const F=BV(s,o,v);S.push(k[F[0]],k[F[1]])}if(M=[...M,{placement:s,overflows:S}],!S.every(F=>F<=0)){var O,R;const F=(((O=i.flip)==null?void 0:O.index)||0)+1,U=E[F];if(U)return{data:{index:F,overflows:M},reset:{placement:U}};let K=(R=M.filter(_=>_.overflows[0]<=0).sort((_,G)=>_.overflows[1]-G.overflows[1])[0])==null?void 0:R.placement;if(!K)switch(h){case"bestFit":{var D;const _=(D=M.map(G=>[G.placement,G.overflows.filter(Y=>Y>0).reduce((Y,re)=>Y+re,0)]).sort((G,Y)=>G[1]-Y[1])[0])==null?void 0:D[0];_&&(K=_);break}case"initialPlacement":K=a;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function ON(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function RN(n){return IV.some(e=>n[e]>=0)}const WV=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...s}=mi(n,e);switch(r){case"referenceHidden":{const i=await ld(e,{...s,elementContext:"reference"}),o=ON(i,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:RN(o)}}}case"escaped":{const i=await ld(e,{...s,altBoundary:!0}),o=ON(i,t.floating);return{data:{escapedOffsets:o,escaped:RN(o)}}}default:return{}}}}};async function GV(n,e){const{placement:t,platform:r,elements:s}=n,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=gi(t),a=pc(t),l=mc(t)==="y",c=["left","top"].includes(o)?-1:1,u=i&&l?-1:1,f=mi(e,n);let{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),l?{x:h*u,y:d*c}:{x:d*c,y:h*u}}const KV=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:s,y:i,placement:o,middlewareData:a}=e,l=await GV(e,n);return o===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},JV=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:a={fn:y=>{let{x:b,y:x}=y;return{x:b,y:x}}},...l}=mi(n,e),c={x:t,y:r},u=await ld(e,l),f=mc(gi(s)),d=av(f);let h=c[d],p=c[f];if(i){const y=d==="y"?"top":"left",b=d==="y"?"bottom":"right",x=h+u[y],v=h-u[b];h=ov(x,h,v)}if(o){const y=f==="y"?"top":"left",b=f==="y"?"bottom":"right",x=p+u[y],v=p-u[b];p=ov(x,p,v)}const m=a.fn({...e,[d]:h,[f]:p});return{...m,data:{x:m.x-t,y:m.y-r}}}}},qV=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:r,placement:s,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=mi(n,e),u={x:t,y:r},f=mc(s),d=av(f);let h=u[d],p=u[f];const m=mi(a,e),y=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const v=d==="y"?"height":"width",w=i.reference[d]-i.floating[v]+y.mainAxis,E=i.reference[d]+i.reference[v]-y.mainAxis;h<w?h=w:h>E&&(h=E)}if(c){var b,x;const v=d==="y"?"width":"height",w=["top","left"].includes(gi(s)),E=i.reference[f]-i.floating[v]+(w&&((b=o.offset)==null?void 0:b[f])||0)+(w?0:y.crossAxis),k=i.reference[f]+i.reference[v]+(w?0:((x=o.offset)==null?void 0:x[f])||0)-(w?y.crossAxis:0);p<E?p=E:p>k&&(p=k)}return{[d]:h,[f]:p}}}},QV=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){const{placement:t,rects:r,platform:s,elements:i}=e,{apply:o=()=>{},...a}=mi(n,e),l=await ld(e,a),c=gi(t),u=pc(t),f=mc(t)==="y",{width:d,height:h}=r.floating;let p,m;c==="top"||c==="bottom"?(p=c,m=u===(await(s.isRTL==null?void 0:s.isRTL(i.floating))?"start":"end")?"left":"right"):(m=c,p=u==="end"?"top":"bottom");const y=h-l.top-l.bottom,b=d-l.left-l.right,x=Bs(h-l[p],y),v=Bs(d-l[m],b),w=!e.middlewareData.shift;let E=x,k=v;if(f?k=u||w?Bs(v,b):b:E=u||w?Bs(x,y):y,w&&!u){const M=gr(l.left,0),O=gr(l.right,0),R=gr(l.top,0),D=gr(l.bottom,0);f?k=d-2*(M!==0||O!==0?M+O:gr(l.left,l.right)):E=h-2*(R!==0||D!==0?R+D:gr(l.top,l.bottom))}await o({...e,availableWidth:k,availableHeight:E});const S=await s.getDimensions(i.floating);return d!==S.width||h!==S.height?{reset:{rects:!0}}:{}}}};function gc(n){return MN(n)?(n.nodeName||"").toLowerCase():"#document"}function yr(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function yi(n){var e;return(e=(MN(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function MN(n){return n instanceof Node||n instanceof yr(n).Node}function Fs(n){return n instanceof Element||n instanceof yr(n).Element}function js(n){return n instanceof HTMLElement||n instanceof yr(n).HTMLElement}function DN(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof yr(n).ShadowRoot}function cd(n){const{overflow:e,overflowX:t,overflowY:r,display:s}=ns(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!["inline","contents"].includes(s)}function YV(n){return["table","td","th"].includes(gc(n))}function fv(n){const e=dv(),t=ns(n);return t.transform!=="none"||t.perspective!=="none"||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(t.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(t.contain||"").includes(r))}function XV(n){let e=go(n);for(;js(e)&&!yc(e);){if(fv(e))return e;e=go(e)}return null}function dv(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function yc(n){return["html","body","#document"].includes(gc(n))}function ns(n){return yr(n).getComputedStyle(n)}function jm(n){return Fs(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function go(n){if(gc(n)==="html")return n;const e=n.assignedSlot||n.parentNode||DN(n)&&n.host||yi(n);return DN(e)?e.host:e}function PN(n){const e=go(n);return yc(e)?n.ownerDocument?n.ownerDocument.body:n.body:js(e)&&cd(e)?e:PN(e)}function ud(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=PN(n),i=s===((r=n.ownerDocument)==null?void 0:r.body),o=yr(s);return i?e.concat(o,o.visualViewport||[],cd(s)?s:[],o.frameElement&&t?ud(o.frameElement):[]):e.concat(s,ud(s,[],t))}function IN(n){const e=ns(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=js(n),i=s?n.offsetWidth:t,o=s?n.offsetHeight:r,a=Lm(t)!==i||Lm(r)!==o;return a&&(t=i,r=o),{width:t,height:r,$:a}}function hv(n){return Fs(n)?n:n.contextElement}function bc(n){const e=hv(n);if(!js(e))return mo(1);const t=e.getBoundingClientRect(),{width:r,height:s,$:i}=IN(e);let o=(i?Lm(t.width):t.width)/r,a=(i?Lm(t.height):t.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const ZV=mo(0);function LN(n){const e=yr(n);return!dv()||!e.visualViewport?ZV:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function e$(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==yr(n)?!1:e}function Ma(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=n.getBoundingClientRect(),i=hv(n);let o=mo(1);e&&(r?Fs(r)&&(o=bc(r)):o=bc(n));const a=e$(i,t,r)?LN(i):mo(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,f=s.height/o.y;if(i){const d=yr(i),h=r&&Fs(r)?yr(r):r;let p=d,m=p.frameElement;for(;m&&r&&h!==p;){const y=bc(m),b=m.getBoundingClientRect(),x=ns(m),v=b.left+(m.clientLeft+parseFloat(x.paddingLeft))*y.x,w=b.top+(m.clientTop+parseFloat(x.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,f*=y.y,l+=v,c+=w,p=yr(m),m=p.frameElement}}return Fm({width:u,height:f,x:l,y:c})}const t$=[":popover-open",":modal"];function pv(n){return t$.some(e=>{try{return n.matches(e)}catch{return!1}})}function n$(n){let{elements:e,rect:t,offsetParent:r,strategy:s}=n;const i=s==="fixed",o=yi(r),a=e?pv(e.floating):!1;if(r===o||a&&i)return t;let l={scrollLeft:0,scrollTop:0},c=mo(1);const u=mo(0),f=js(r);if((f||!f&&!i)&&((gc(r)!=="body"||cd(o))&&(l=jm(r)),js(r))){const d=Ma(r);c=bc(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x,y:t.y*c.y-l.scrollTop*c.y+u.y}}function r$(n){return Array.from(n.getClientRects())}function _N(n){return Ma(yi(n)).left+jm(n).scrollLeft}function s$(n){const e=yi(n),t=jm(n),r=n.ownerDocument.body,s=gr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=gr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+_N(n);const a=-t.scrollTop;return ns(r).direction==="rtl"&&(o+=gr(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:a}}function i$(n,e){const t=yr(n),r=yi(n),s=t.visualViewport;let i=r.clientWidth,o=r.clientHeight,a=0,l=0;if(s){i=s.width,o=s.height;const c=dv();(!c||c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:i,height:o,x:a,y:l}}function o$(n,e){const t=Ma(n,!0,e==="fixed"),r=t.top+n.clientTop,s=t.left+n.clientLeft,i=js(n)?bc(n):mo(1),o=n.clientWidth*i.x,a=n.clientHeight*i.y,l=s*i.x,c=r*i.y;return{width:o,height:a,x:l,y:c}}function BN(n,e,t){let r;if(e==="viewport")r=i$(n,t);else if(e==="document")r=s$(yi(n));else if(Fs(e))r=o$(e,t);else{const s=LN(n);r={...e,x:e.x-s.x,y:e.y-s.y}}return Fm(r)}function FN(n,e){const t=go(n);return t===e||!Fs(t)||yc(t)?!1:ns(t).position==="fixed"||FN(t,e)}function a$(n,e){const t=e.get(n);if(t)return t;let r=ud(n,[],!1).filter(a=>Fs(a)&&gc(a)!=="body"),s=null;const i=ns(n).position==="fixed";let o=i?go(n):n;for(;Fs(o)&&!yc(o);){const a=ns(o),l=fv(o);!l&&a.position==="fixed"&&(s=null),(i?!l&&!s:!l&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||cd(o)&&!l&&FN(n,o))?r=r.filter(u=>u!==o):s=a,o=go(o)}return e.set(n,r),r}function l$(n){let{element:e,boundary:t,rootBoundary:r,strategy:s}=n;const o=[...t==="clippingAncestors"?pv(e)?[]:a$(e,this._c):[].concat(t),r],a=o[0],l=o.reduce((c,u)=>{const f=BN(e,u,s);return c.top=gr(f.top,c.top),c.right=Bs(f.right,c.right),c.bottom=Bs(f.bottom,c.bottom),c.left=gr(f.left,c.left),c},BN(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function c$(n){const{width:e,height:t}=IN(n);return{width:e,height:t}}function u$(n,e,t){const r=js(e),s=yi(e),i=t==="fixed",o=Ma(n,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=mo(0);if(r||!r&&!i)if((gc(e)!=="body"||cd(s))&&(a=jm(e)),r){const f=Ma(e,!0,i,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else s&&(l.x=_N(s));const c=o.left+a.scrollLeft-l.x,u=o.top+a.scrollTop-l.y;return{x:c,y:u,width:o.width,height:o.height}}function mv(n){return ns(n).position==="static"}function jN(n,e){return!js(n)||ns(n).position==="fixed"?null:e?e(n):n.offsetParent}function UN(n,e){const t=yr(n);if(pv(n))return t;if(!js(n)){let s=go(n);for(;s&&!yc(s);){if(Fs(s)&&!mv(s))return s;s=go(s)}return t}let r=jN(n,e);for(;r&&YV(r)&&mv(r);)r=jN(r,e);return r&&yc(r)&&mv(r)&&!fv(r)?t:r||XV(n)||t}const f$=async function(n){const e=this.getOffsetParent||UN,t=this.getDimensions,r=await t(n.floating);return{reference:u$(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function d$(n){return ns(n).direction==="rtl"}const h$={convertOffsetParentRelativeRectToViewportRelativeRect:n$,getDocumentElement:yi,getClippingRect:l$,getOffsetParent:UN,getElementRects:f$,getClientRects:r$,getDimensions:c$,getScale:bc,isElement:Fs,isRTL:d$};function p$(n,e){let t=null,r;const s=yi(n);function i(){var a;clearTimeout(r),(a=t)==null||a.disconnect(),t=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:c,top:u,width:f,height:d}=n.getBoundingClientRect();if(a||e(),!f||!d)return;const h=_m(u),p=_m(s.clientWidth-(c+f)),m=_m(s.clientHeight-(u+d)),y=_m(c),x={rootMargin:-h+"px "+-p+"px "+-m+"px "+-y+"px",threshold:gr(0,Bs(1,l))||1};let v=!0;function w(E){const k=E[0].intersectionRatio;if(k!==l){if(!v)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}v=!1}try{t=new IntersectionObserver(w,{...x,root:s.ownerDocument})}catch{t=new IntersectionObserver(w,x)}t.observe(n)}return o(!0),i}function m$(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=hv(n),u=s||i?[...c?ud(c):[],...ud(e)]:[];u.forEach(b=>{s&&b.addEventListener("scroll",t,{passive:!0}),i&&b.addEventListener("resize",t)});const f=c&&a?p$(c,t):null;let d=-1,h=null;o&&(h=new ResizeObserver(b=>{let[x]=b;x&&x.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var v;(v=h)==null||v.observe(e)})),t()}),c&&!l&&h.observe(c),h.observe(e));let p,m=l?Ma(n):null;l&&y();function y(){const b=Ma(n);m&&(b.x!==m.x||b.y!==m.y||b.width!==m.width||b.height!==m.height)&&t(),m=b,p=requestAnimationFrame(y)}return t(),()=>{var b;u.forEach(x=>{s&&x.removeEventListener("scroll",t),i&&x.removeEventListener("resize",t)}),f==null||f(),(b=h)==null||b.disconnect(),h=null,l&&cancelAnimationFrame(p)}}const g$=KV,y$=JV,b$=$V,w$=QV,v$=WV,HN=VV,x$=qV,A$=(n,e,t)=>{const r=new Map,s={platform:h$,...t},i={...s.platform,_c:r};return zV(n,e,{...s,platform:i})};var Um=typeof document<"u"?L.useLayoutEffect:L.useEffect;function Hm(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,s;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!Hm(n[r],e[r]))return!1;return!0}if(s=Object.keys(n),t=s.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=t;r--!==0;){const i=s[r];if(!(i==="_owner"&&n.$$typeof)&&!Hm(n[i],e[i]))return!1}return!0}return n!==n&&e!==e}function zN(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function VN(n,e){const t=zN(n);return Math.round(e*t)/t}function $N(n){const e=H.useRef(n);return Um(()=>{e.current=n}),e}function E$(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=n,[u,f]=H.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[d,h]=H.useState(r);Hm(d,r)||h(r);const[p,m]=H.useState(null),[y,b]=H.useState(null),x=H.useCallback(Y=>{Y!==k.current&&(k.current=Y,m(Y))},[]),v=H.useCallback(Y=>{Y!==S.current&&(S.current=Y,b(Y))},[]),w=i||p,E=o||y,k=H.useRef(null),S=H.useRef(null),M=H.useRef(u),O=l!=null,R=$N(l),D=$N(s),F=H.useCallback(()=>{if(!k.current||!S.current)return;const Y={placement:e,strategy:t,middleware:d};D.current&&(Y.platform=D.current),A$(k.current,S.current,Y).then(re=>{const Z={...re,isPositioned:!0};U.current&&!Hm(M.current,Z)&&(M.current=Z,sy.flushSync(()=>{f(Z)}))})},[d,e,t,D]);Um(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,f(Y=>({...Y,isPositioned:!1})))},[c]);const U=H.useRef(!1);Um(()=>(U.current=!0,()=>{U.current=!1}),[]),Um(()=>{if(w&&(k.current=w),E&&(S.current=E),w&&E){if(R.current)return R.current(w,E,F);F()}},[w,E,F,R,O]);const K=H.useMemo(()=>({reference:k,floating:S,setReference:x,setFloating:v}),[x,v]),_=H.useMemo(()=>({reference:w,floating:E}),[w,E]),G=H.useMemo(()=>{const Y={position:t,left:0,top:0};if(!_.floating)return Y;const re=VN(_.floating,u.x),Z=VN(_.floating,u.y);return a?{...Y,transform:"translate("+re+"px, "+Z+"px)",...zN(_.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:re,top:Z}},[t,a,_.floating,u.x,u.y]);return H.useMemo(()=>({...u,update:F,refs:K,elements:_,floatingStyles:G}),[u,F,K,_,G])}const k$=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:s}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?HN({element:r.current,padding:s}).fn(t):{}:r?HN({element:r,padding:s}).fn(t):{}}}},C$=(n,e)=>({...g$(n),options:[n,e]}),S$=(n,e)=>({...y$(n),options:[n,e]}),T$=(n,e)=>({...x$(n),options:[n,e]}),N$=(n,e)=>({...b$(n),options:[n,e]}),O$=(n,e)=>({...w$(n),options:[n,e]}),R$=(n,e)=>({...v$(n),options:[n,e]}),M$=(n,e)=>({...k$(n),options:[n,e]});var D$="Arrow",WN=H.forwardRef((n,e)=>{const{children:t,width:r=10,height:s=5,...i}=n;return C.jsx(Kn.svg,{...i,ref:e,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:C.jsx("polygon",{points:"0,0 30,0 15,10"})})});WN.displayName=D$;var P$=WN;function I$(n){const[e,t]=H.useState(void 0);return ha(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=n.offsetWidth,a=n.offsetHeight;t({width:o,height:a})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else t(void 0)},[n]),e}var gv="Popper",[GN,KN]=V0(gv),[L$,JN]=GN(gv),qN=n=>{const{__scopePopper:e,children:t}=n,[r,s]=H.useState(null);return C.jsx(L$,{scope:e,anchor:r,onAnchorChange:s,children:t})};qN.displayName=gv;var QN="PopperAnchor",YN=H.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:r,...s}=n,i=JN(QN,t),o=H.useRef(null),a=Or(e,o);return H.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:C.jsx(Kn.div,{...s,ref:a})});YN.displayName=QN;var yv="PopperContent",[_$,B$]=GN(yv),XN=H.forwardRef((n,e)=>{var He,Le,Ze,le,ze,ae;const{__scopePopper:t,side:r="bottom",sideOffset:s=0,align:i="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:d=!1,updatePositionStrategy:h="optimized",onPlaced:p,...m}=n,y=JN(yv,t),[b,x]=H.useState(null),v=Or(e,be=>x(be)),[w,E]=H.useState(null),k=I$(w),S=(k==null?void 0:k.width)??0,M=(k==null?void 0:k.height)??0,O=r+(i!=="center"?"-"+i:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],F=D.length>0,U={padding:R,boundary:D.filter(j$),altBoundary:F},{refs:K,floatingStyles:_,placement:G,isPositioned:Y,middlewareData:re}=E$({strategy:"fixed",placement:O,whileElementsMounted:(...be)=>m$(...be,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[C$({mainAxis:s+M,alignmentAxis:o}),l&&S$({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T$():void 0,...U}),l&&N$({...U}),O$({...U,apply:({elements:be,rects:_e,availableWidth:z,availableHeight:J})=>{const{width:ne,height:ce}=_e.reference,P=be.floating.style;P.setProperty("--radix-popper-available-width",`${z}px`),P.setProperty("--radix-popper-available-height",`${J}px`),P.setProperty("--radix-popper-anchor-width",`${ne}px`),P.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),w&&M$({element:w,padding:a}),U$({arrowWidth:S,arrowHeight:M}),d&&R$({strategy:"referenceHidden",...U})]}),[Z,me]=tO(G),ke=ro(p);ha(()=>{Y&&(ke==null||ke())},[Y,ke]);const Pe=(He=re.arrow)==null?void 0:He.x,Ce=(Le=re.arrow)==null?void 0:Le.y,Ee=((Ze=re.arrow)==null?void 0:Ze.centerOffset)!==0,[Ue,Fe]=H.useState();return ha(()=>{b&&Fe(window.getComputedStyle(b).zIndex)},[b]),C.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:Y?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ue,"--radix-popper-transform-origin":[(le=re.transformOrigin)==null?void 0:le.x,(ze=re.transformOrigin)==null?void 0:ze.y].join(" "),...((ae=re.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:C.jsx(_$,{scope:t,placedSide:Z,onArrowChange:E,arrowX:Pe,arrowY:Ce,shouldHideArrow:Ee,children:C.jsx(Kn.div,{"data-side":Z,"data-align":me,...m,ref:v,style:{...m.style,animation:Y?void 0:"none"}})})})});XN.displayName=yv;var ZN="PopperArrow",F$={top:"bottom",right:"left",bottom:"top",left:"right"},eO=H.forwardRef(function(e,t){const{__scopePopper:r,...s}=e,i=B$(ZN,r),o=F$[i.placedSide];return C.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:C.jsx(P$,{...s,ref:t,style:{...s.style,display:"block"}})})});eO.displayName=ZN;function j$(n){return n!==null}var U$=n=>({name:"transformOrigin",options:n,fn(e){var y,b,x;const{placement:t,rects:r,middlewareData:s}=e,o=((y=s.arrow)==null?void 0:y.centerOffset)!==0,a=o?0:n.arrowWidth,l=o?0:n.arrowHeight,[c,u]=tO(t),f={start:"0%",center:"50%",end:"100%"}[u],d=(((b=s.arrow)==null?void 0:b.x)??0)+a/2,h=(((x=s.arrow)==null?void 0:x.y)??0)+l/2;let p="",m="";return c==="bottom"?(p=o?f:`${d}px`,m=`${-l}px`):c==="top"?(p=o?f:`${d}px`,m=`${r.floating.height+l}px`):c==="right"?(p=`${-l}px`,m=o?f:`${h}px`):c==="left"&&(p=`${r.floating.width+l}px`,m=o?f:`${h}px`),{data:{x:p,y:m}}}});function tO(n){const[e,t="center"]=n.split("-");return[e,t]}var H$=qN,nO=YN,z$=XN,V$=eO,bv="Popover",[rO,oQ]=V0(bv,[KN]),fd=KN(),[$$,Da]=rO(bv),sO=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=n,a=fd(e),l=H.useRef(null),[c,u]=H.useState(!1),[f=!1,d]=qk({prop:r,defaultProp:s,onChange:i});return C.jsx(H$,{...a,children:C.jsx($$,{scope:e,contentId:qh(),triggerRef:l,open:f,onOpenChange:d,onOpenToggle:H.useCallback(()=>d(h=>!h),[d]),hasCustomAnchor:c,onCustomAnchorAdd:H.useCallback(()=>u(!0),[]),onCustomAnchorRemove:H.useCallback(()=>u(!1),[]),modal:o,children:t})})};sO.displayName=bv;var iO="PopoverAnchor",W$=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(iO,t),i=fd(t),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=s;return H.useEffect(()=>(o(),()=>a()),[o,a]),C.jsx(nO,{...i,...r,ref:e})});W$.displayName=iO;var oO="PopoverTrigger",aO=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(oO,t),i=fd(t),o=Or(e,s.triggerRef),a=C.jsx(Kn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":dO(s.open),...r,ref:o,onClick:fr(n.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:C.jsx(nO,{asChild:!0,...i,children:a})});aO.displayName=oO;var G$="PopoverPortal",[aQ,K$]=rO(G$,{forceMount:void 0}),wc="PopoverContent",lO=H.forwardRef((n,e)=>{const t=K$(wc,n.__scopePopover),{forceMount:r=t.forceMount,...s}=n,i=Da(wc,n.__scopePopover);return C.jsx(kf,{present:r||i.open,children:i.modal?C.jsx(J$,{...s,ref:e}):C.jsx(q$,{...s,ref:e})})});lO.displayName=wc;var J$=H.forwardRef((n,e)=>{const t=Da(wc,n.__scopePopover),r=H.useRef(null),s=Or(e,r),i=H.useRef(!1);return H.useEffect(()=>{const o=r.current;if(o)return xC(o)},[]),C.jsx(eb,{as:Qh,allowPinchZoom:!0,children:C.jsx(cO,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fr(n.onCloseAutoFocus,o=>{var a;o.preventDefault(),i.current||(a=t.triggerRef.current)==null||a.focus()}),onPointerDownOutside:fr(n.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:fr(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),q$=H.forwardRef((n,e)=>{const t=Da(wc,n.__scopePopover),r=H.useRef(!1),s=H.useRef(!1);return C.jsx(cO,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,i),i.defaultPrevented||(r.current||(a=t.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),cO=H.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=n,d=Da(wc,t),h=fd(t);return oC(),C.jsx(Ef,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:C.jsx(G0,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>d.onOpenChange(!1),children:C.jsx(z$,{"data-state":dO(d.open),role:"dialog",id:d.contentId,...h,...f,ref:e,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),uO="PopoverClose",fO=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(uO,t);return C.jsx(Kn.button,{type:"button",...r,ref:e,onClick:fr(n.onClick,()=>s.onOpenChange(!1))})});fO.displayName=uO;var Q$="PopoverArrow",Y$=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=fd(t);return C.jsx(V$,{...s,...r,ref:e})});Y$.displayName=Q$;function dO(n){return n?"open":"closed"}var X$=sO,Z$=aO,e9=lO,zm=fO;const Vm=({children:n,isActive:e,onClick:t,disabled:r,className:s})=>{const i=pe("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",s);return C.jsx("button",{className:i,disabled:r,onClick:t,children:n})},t9=(n,e,t)=>{const r=L.useCallback(()=>{const a=n.chain();a.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&a.setParagraph(),a.run()},[n,t,e==null?void 0:e.type.name]),s=L.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:a}=n.state.selection,l=a.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),l.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),i=L.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=L.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:s,copyNodeToClipboard:i,deleteNode:o}},n9=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[s,i]=L.useState(!1),o=t9(t,n,e()),a=gp(),l=["https://twitter.com","https://x.com"],c=L.useMemo(()=>{const{content:O}=n.content;return O[0].type.name==="table"},[n.content]),u=L.useMemo(()=>{var R;const{content:O}=n.content;return(R=O[0].content.content[0])==null?void 0:R.text},[n.content]),f=L.useMemo(()=>{var R;const{content:O}=n.content;return(R=O[0].content.content[1])==null?void 0:R.text},[n.content]),d=L.useMemo(()=>{const{content:O}=n.content;return O[0].content.content.find(R=>{var D;return(D=R==null?void 0:R.text)==null?void 0:D.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let O=u;if(u.includes("<iframe"))O=f;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const K=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);K&&K.length>0&&(O=`https://www.youtube.com/embed/${K[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const K=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);K&&K.length>0&&(O=`https://player.vimeo.com/video/${K[1]}`);break}default:return}const R=640,D=360,F=e(),U=F+n.nodeSize;O&&(t==null||t.chain().focus(F).deleteRange({from:F===0?F:F+1,to:U}).setIframe({src:O,width:R,height:D}).run())},p=O=>{const R=O.match(/\/status\/([0-9]*)/);return R&&R.length>0?R[1]:null},m=()=>{if(!u)return;let O=u;const R=l.some(K=>u.includes(K)),D=p(u);R&&D?O=D:d&&(O=p(d.text));const F=e(),U=F+n.nodeSize;O&&(t==null||t.chain().focus(F).deleteRange({from:F===2?F:F+1,to:U}).setTweetEmbed({tweetId:O}).run())},y=()=>{const O=e()+n.nodeSize;t.commands.insertContentAt(O,{type:"dBlock",content:[{type:"paragraph"}]})},b=()=>{const O=e();t.commands.insertContentAt(O,{type:"dBlock",content:[{type:"paragraph"}]})},x=()=>{r()},v=O=>{O.altKey?E():w()},w=()=>{y()},E=()=>{b()},k=O=>{O.altKey&&x()},M=iv(()=>{if(l.some(O=>u.includes(O))||d!=null&&d.text){m();return}else{h();return}},1e3);return L.useEffect(()=>{u&&M()},[u]),C.jsxs(wf,{as:"div",className:pe("flex gap-2 group w-full relative justify-center items-start",a&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[C.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[C.jsx(_S,{content:C.jsxs("div",{className:"flex flex-col w-40",children:[C.jsx("div",{className:"text-xs",children:"Click to add below"}),C.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:C.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:v,children:C.jsx(i4,{size:18})})}),C.jsxs(X$,{open:s,onOpenChange:i,children:[C.jsx(Z$,{asChild:!0,children:C.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:k,children:C.jsx(Z3,{size:18})})}),C.jsx(e9,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:C.jsxs(Tb,{className:"p-2 flex flex-col min-w-[16rem]",children:[C.jsx(zm,{children:C.jsxs(Vm,{onClick:o.resetTextFormatting,children:[C.jsx(o4,{size:18}),"Clear formatting"]})}),C.jsx(zm,{children:C.jsxs(Vm,{onClick:o.copyNodeToClipboard,children:[C.jsx(q3,{size:18}),"Copy to clipboard"]})}),C.jsx(zm,{children:C.jsxs(Vm,{onClick:o.duplicateNode,children:[C.jsx(Y3,{size:18}),"Duplicate"]})}),C.jsx(If.Divider,{horizontal:!0}),C.jsx(zm,{children:C.jsxs(Vm,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[C.jsx(Wk,{size:18}),"Delete"]})})]})})]})]}),C.jsx(Ik,{className:pe("node-view-content w-full",{"is-table min-w-auto":c})})]})},r9=vt.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,s=n!==void 0||n!==null?r:n;return t().insertContentAt(s,{type:this.name,content:[{type:"paragraph"}]}).focus(s+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;const o=[];if(e.doc.nodesBetween(r,s,l=>{if(l.type.name===this.name){const c=e.schema.nodes.listItem.create(null,l.content);c&&o.push(c)}}),o.length===0)return!1;const a=e.schema.nodes[n].create(null,o);return a?(i=i.replaceRangeWith(r,s,a),t(i),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;return e.doc.nodesBetween(r,s,(o,a)=>{if(o.type.name===n){const l=e.schema.nodes[this.name].create(null,o.content);i=i.insert(a,l)}}),t(i),!0}}},addNodeView(){return da(n9)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:s}=n.state,i=e.node(e.depth-1);if((i==null?void 0:i.type.name)!=="dBlock")return!1;let o=-1,a="";s.descendants((u,f)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[d,h]=[f,f+u.nodeSize];return d<=t&&r<=h&&(o=h,a=u.type.name),!1});const l=(c=s.slice(t,o))==null?void 0:c.toJSON().content;try{return a==="codeBlock"?n.chain().newlineInCode().focus(o+1).run():["columns","heading"].includes(a)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:l}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let wv,vv;if(typeof WeakMap<"u"){let n=new WeakMap;wv=e=>n.get(e),vv=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;wv=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},vv=(r,s)=>(t==e&&(t=0),n[t++]=r,n[t++]=s)}class vc{constructor(e,t,r,s){this.left=e,this.top=t,this.right=r,this.bottom=s}}class Bt{constructor(e,t,r,s){this.width=e,this.height=t,this.map=r,this.problems=s}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let s=t%this.width,i=t/this.width|0,o=s+1,a=i+1;for(let l=1;o<this.width&&this.map[t+l]==r;l++)o++;for(let l=1;a<this.height&&this.map[t+this.width*l]==r;l++)a++;return new vc(s,i,o,a)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:s,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(r<0?s==0:i==this.width)?null:this.map[o*this.width+(r<0?s-1:i)]:(r<0?o==0:a==this.height)?null:this.map[s+this.width*(r<0?o-1:a)]}rectBetween(e,t){let{left:r,right:s,top:i,bottom:o}=this.findCell(e),{left:a,right:l,top:c,bottom:u}=this.findCell(t);return new vc(Math.min(r,a),Math.min(i,c),Math.max(s,l),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let s=e.top;s<e.bottom;s++)for(let i=e.left;i<e.right;i++){let o=s*this.width+i,a=this.map[o];r[a]||(r[a]=!0,(i!=e.left||!i||this.map[o-1]!=a)&&(s!=e.top||!s||this.map[o-this.width]!=a)&&t.push(a))}return t}positionAt(e,t,r){for(let s=0,i=0;;s++){let o=i+r.child(s).nodeSize;if(s==e){let a=t+e*this.width,l=(e+1)*this.width;for(;a<l&&this.map[a]<i;)a++;return a==l?o-1:this.map[a]}i=o}}static get(e){return wv(e)||vv(e,s9(e))}}function s9(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=i9(n),t=n.childCount,r=[],s=0,i=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let f=n.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==f.childCount)break;let m=f.child(p),{colspan:y,rowspan:b,colwidth:x}=m.attrs;for(let v=0;v<b;v++){if(v+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-v});break}let w=s+v*e;for(let E=0;E<y;E++){r[w+E]==0?r[w+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-E});let k=x&&x[E];if(k){let S=(w+E)%e*2,M=o[S];M==null||M!=k&&o[S+1]==1?(o[S]=k,o[S+1]=1):M==k&&o[S+1]++}}}s+=y,u+=m.nodeSize}let d=(c+1)*e,h=0;for(;s<d;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}let a=new Bt(e,t,r,i),l=!1;for(let c=0;!l&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(l=!0);return l&&o9(a,o,n),a}function i9(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let s=n.child(r),i=0;if(t)for(let o=0;o<r;o++){let a=n.child(o);for(let l=0;l<a.childCount;l++){let c=a.child(l);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){let a=s.child(o);i+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function o9(n,e,t){n.problems||(n.problems=[]);for(let r=0,s={};r<n.map.length;r++){let i=n.map[r];if(s[i])continue;s[i]=!0;let o=t.nodeAt(i),a=null;for(let l=0;l<o.attrs.colspan;l++){let c=(r+l)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[l]!=u)&&((a||(a=a9(o.attrs)))[l]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function a9(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function xn(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const yo=new Ot("selectingCells");function xc(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function l9(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function rs(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function $m(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:xc(e.$head)||c9(e.$head)}function c9(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function xv(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function u9(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Av(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function hO(n,e,t){let r=n.start(-1),i=Bt.get(n.node(-1)).nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function an(n,e,t){let r={};for(let s in n)r[s]=n[s];return r[e]=t,r}function Pa(n,e,t=1){let r=an(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function pO(n,e,t=1){let r=an(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function f9(n,e,t){let r=xn(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}class it extends Ie{constructor(e,t=e){let r=e.node(-1),s=Bt.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),a=e.node(0),l=s.cellsInRect(o).filter(u=>u!=t.pos-i);l.unshift(t.pos-i);let c=l.map(u=>{let f=r.nodeAt(u),d=u+i+1;return new Ay(a.resolve(d),a.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(xv(r)&&xv(s)&&Av(r,s)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?it.rowSelection(r,s):i&&this.isColSelection()?it.colSelection(r,s):new it(r,s)}return Me.between(r,s)}content(){let e=this.$anchorCell.node(-1),t=Bt.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let l=s.top;l<s.bottom;l++){let c=[];for(let u=l*t.width+s.left,f=s.left;f<s.right;f++,u++){let d=t.map[u];if(!i[d]){i[d]=!0;let h=t.findCell(d),p=e.nodeAt(d),m=s.left-h.left,y=h.right-s.right;if(m>0||y>0){let b=p.attrs;m>0&&(b=Pa(b,0,m)),y>0&&(b=Pa(b,b.colspan-y,y)),h.left<s.left?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}if(h.top<s.top||h.bottom>s.bottom){let b=an(p.attrs,"rowspan",Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top));h.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}}o.push(e.child(l).copy(oe.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new ue(oe.from(a),1,1)}replace(e,t=ue.empty){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),o?ue.empty:t)}let i=Ie.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new ue(oe.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=Bt.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=Bt.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.top<=o.top?(i.top>0&&(e=a.resolve(s+r.map[i.left])),o.bottom<r.height&&(t=a.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=a.resolve(s+r.map[o.left])),i.bottom<r.height&&(e=a.resolve(s+r.map[r.width*(r.height-1)+i.right-1]))),new it(e,t)}isRowSelection(){let e=Bt.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),s=e.colCount(this.$headCell.pos-t);if(Math.min(r,s)>0)return!1;let i=r+this.$anchorCell.nodeAfter.attrs.colspan,o=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,o)==e.width}eq(e){return e instanceof it&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=Bt.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.left<=o.left?(i.left>0&&(e=a.resolve(s+r.map[i.top*r.width])),o.right<r.width&&(t=a.resolve(s+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=a.resolve(s+r.map[o.top*r.width])),i.right<r.width&&(e=a.resolve(s+r.map[r.width*(i.top+1)-1]))),new it(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new it(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new it(e.resolve(t),e.resolve(r))}getBookmark(){return new Ev(this.$anchorCell.pos,this.$headCell.pos)}}it.prototype.visible=!1,Ie.jsonID("cell",it);class Ev{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ev(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Av(t,r)?new it(t,r):Ie.near(r,1)}}function d9(n){if(!(n.selection instanceof it))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(Qt.node(r,r+t.nodeSize,{class:"selectedCell"}))}),wt.create(n.doc,e)}function h9({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function p9({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){let i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){let i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function m9(n,e,t){let r=(e||n).selection,s=(e||n).doc,i,o;if(r instanceof Ne&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=it.create(s,r.from);else if(o=="row"){let a=s.resolve(r.from+1);i=it.rowSelection(a,a)}else if(!t){let a=Bt.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];i=it.create(s,l+1,c)}}else r instanceof Me&&h9(r)?i=Me.create(s,r.from):r instanceof Me&&p9(r)&&(i=Me.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function g9(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let s=e.firstChild,i=s.type.spec.tableRole,o=s.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content,u=l?0:Math.max(0,t-1),f=l<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=kv(xn(o).row,new ue(c,u,f)).content),a.push(c)}else if(i=="cell"||i=="header_cell")a.push(t||r?kv(xn(o).row,new ue(e,t,r)).content:e);else return null;return y9(o,a)}function y9(n,e){let t=[];for(let s=0;s<e.length;s++){let i=e[s];for(let o=i.childCount-1;o>=0;o--){let{rowspan:a,colspan:l}=i.child(o).attrs;for(let c=s;c<s+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(oe.empty),t[s]<r){let i=xn(n).cell.createAndFill(),o=[];for(let a=t[s];a<r;a++)o.push(i);e[s]=e[s].append(oe.from(o))}return{height:e.length,width:r,rows:e}}function kv(n,e){let t=n.createAndFill();return new vy(t).replace(0,t.content.size,e).doc}function b9({width:n,height:e,rows:t},r,s){if(n!=r){let i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a],c=[];for(let u=i[a]||0,f=0;u<r;f++){let d=l.child(f%l.childCount);u+d.attrs.colspan>r&&(d=d.type.create(Pa(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)i[a+h]=(i[a+h]||0)+d.attrs.colspan}o.push(oe.from(c))}t=o,n=r}if(e!=s){let i=[];for(let o=0,a=0;o<s;o++,a++){let l=[],c=t[a%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);o+f.attrs.rowspan>s&&(f=f.type.create(an(f.attrs,"rowspan",Math.max(1,s-f.attrs.rowspan)),f.content)),l.push(f)}i.push(oe.from(l))}t=i,e=s}return{width:n,height:e,rows:t}}function w9(n,e,t,r,s,i,o){let a=n.doc.type.schema,l=xn(a),c,u;if(s>e.width)for(let f=0,d=0;f<e.height;f++){let h=t.child(f);d+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==l.cell?m=c||(c=l.cell.createAndFill()):m=u||(u=l.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(m);n.insert(n.mapping.slice(o).map(d-1+r),p)}if(i>e.height){let f=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){let y=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==l.header_cell;f.push(y?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}let d=l.row.create(null,oe.from(f)),h=[];for(let p=e.height;p<i;p++)h.push(d);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function mO(n,e,t,r,s,i,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let c=s;c<i;c++){let u=o*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){l=!0;let d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(a).map(f+r),null,an(d.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(a).map(e.positionAt(o,p,t)),d.type.createAndFill(an(d.attrs,"rowspan",h+d.attrs.rowspan-o))),c+=d.attrs.colspan-1}}return l}function gO(n,e,t,r,s,i,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let c=s;c<i;c++){let u=c*e.width+o,f=e.map[u];if(e.map[u-1]==f){l=!0;let d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(a).map(f+r);n.setNodeMarkup(p,null,Pa(d.attrs,o-h,d.attrs.colspan-(o-h))),n.insert(p+d.nodeSize,d.type.createAndFill(Pa(d.attrs,0,o-h))),c+=d.attrs.rowspan-1}}return l}function yO(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc,o=Bt.get(i),{top:a,left:l}=r,c=l+s.width,u=a+s.height,f=n.tr,d=0;function h(){i=t?f.doc.nodeAt(t-1):f.doc,o=Bt.get(i),d=f.mapping.maps.length}w9(f,o,i,t,c,u,d)&&h(),mO(f,o,i,t,l,c,a,d)&&h(),mO(f,o,i,t,l,c,u,d)&&h(),gO(f,o,i,t,a,u,l,d)&&h(),gO(f,o,i,t,a,u,c,d)&&h();for(let p=a;p<u;p++){let m=o.positionAt(p,l,i),y=o.positionAt(p,c,i);f.replace(f.mapping.slice(d).map(m+t),f.mapping.slice(d).map(y+t),new ue(s.rows[p-a],0,0))}h(),f.setSelection(new it(f.doc.resolve(t+o.positionAt(a,l,i)),f.doc.resolve(t+o.positionAt(u-1,c-1,i)))),e(f)}const v9=Yy({ArrowLeft:Gm("horiz",-1),ArrowRight:Gm("horiz",1),ArrowUp:Gm("vert",-1),ArrowDown:Gm("vert",1),"Shift-ArrowLeft":Km("horiz",-1),"Shift-ArrowRight":Km("horiz",1),"Shift-ArrowUp":Km("vert",-1),"Shift-ArrowDown":Km("vert",1),Backspace:Jm,"Mod-Backspace":Jm,Delete:Jm,"Mod-Delete":Jm});function Wm(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Gm(n,e){return(t,r,s)=>{let i=t.selection;if(i instanceof it)return Wm(t,r,Ie.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let o=bO(s,n,e);if(o==null)return!1;if(n=="horiz")return Wm(t,r,Ie.near(t.doc.resolve(i.head+e),e));{let a=t.doc.resolve(o),l=hO(a,n,e),c;return l?c=Ie.near(l,1):e<0?c=Ie.near(t.doc.resolve(a.before(-1)),-1):c=Ie.near(t.doc.resolve(a.after(-1)),1),Wm(t,r,c)}}}function Km(n,e){return(t,r,s)=>{let i=t.selection;if(!(i instanceof it)){let a=bO(s,n,e);if(a==null)return!1;i=new it(t.doc.resolve(a))}let o=hO(i.$headCell,n,e);return o?Wm(t,r,new it(i.$anchorCell,o)):!1}}function Jm(n,e){let t=n.selection;if(!(t instanceof it))return!1;if(e){let r=n.tr,s=xn(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new ue(s,0,0))}),r.docChanged&&e(r)}return!0}function x9(n,e){let t=n.state.doc,r=xc(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new it(r))),!0):!1}function A9(n,e,t){if(!rs(n.state))return!1;let r=g9(t),s=n.state.selection;if(s instanceof it){r||(r={width:1,height:1,rows:[oe.from(kv(xn(n.state.schema).cell,t))]});let i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),a=Bt.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=b9(r,a.right-a.left,a.bottom-a.top),yO(n.state,n.dispatch,o,a,r),!0}else if(r){let i=$m(n.state),o=i.start(-1);return yO(n.state,n.dispatch,o,Bt.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function E9(n,e){if(e.ctrlKey||e.metaKey)return;let t=wO(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof it)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=xc(n.state.selection.$anchor))!=null&&Cv(n,e).pos!=r.pos)s(r,e),e.preventDefault();else if(!t)return;function s(a,l){let c=Cv(n,l),u=yo.getState(n.state)==null;if(!c||!Av(a,c))if(u)c=a;else return;let f=new it(a,c);if(u||!n.state.selection.eq(f)){let d=n.state.tr.setSelection(f);u&&d.setMeta(yo,a.pos),n.dispatch(d)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",o),yo.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(yo,-1))}function o(a){let l=yo.getState(n.state),c;if(l!=null)c=n.state.doc.resolve(l);else if(wO(n,a.target)!=t&&(c=Cv(n,e),!c))return i();c&&s(c,a)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",o)}function bO(n,e,t){if(!(n.state.selection instanceof Me))return null;let{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){let i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let a=r.before(s),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?a:null}}return null}function wO(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function Cv(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?xc(n.state.doc.resolve(t.pos)):null}const k9=new Ot("fix-tables");function vO(n,e,t,r){let s=n.childCount,i=e.childCount;e:for(let o=0,a=0;o<i;o++){let l=e.child(o);for(let c=a,u=Math.min(s,o+3);c<u;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<s&&n.child(a).sameMarkup(l)?vO(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function xO(n,e){let t,r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=C9(n,s,i,t))};return e?e.doc!=n.doc&&vO(e.doc,n.doc,0,r):n.doc.descendants(r),t}function C9(n,e,t,r){let s=Bt.get(e);if(!s.problems)return r;r||(r=n.tr);let i=[];for(let l=0;l<s.height;l++)i.push(0);for(let l=0;l<s.problems.length;l++){let c=s.problems[l];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let f=0;f<u.attrs.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Pa(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u.attrs,"colwidth",c.colwidth))}}let o,a;for(let l=0;l<i.length;l++)i[l]&&(o==null&&(o=l),a=l);for(let l=0,c=t+1;l<s.height;l++){let u=e.child(l),f=c+u.nodeSize,d=i[l];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let y=0;y<d;y++)p.push(xn(n.schema)[h].createAndFill());let m=(l==0||o==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(m),p)}c=f}return r.setMeta(k9,{fixTables:!0})}function Us(n){let e=n.selection,t=$m(n),r=t.node(-1),s=t.start(-1),i=Bt.get(r),o;return e instanceof it?o=i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o=i.findCell(t.pos-s),o.tableStart=s,o.map=i,o.table=r,o}function AO(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;f9(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){let a=o*e.width+s;if(s>0&&s<e.width&&e.map[a-1]==e.map[a]){let l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,pO(c.attrs,s-e.colCount(l))),o+=c.attrs.rowspan-1}else{let l=i==null?xn(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function S9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(AO(n.tr,t,t.left))}return!0}function T9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(AO(n.tr,t,t.right))}return!0}function N9(n,{map:e,table:t,tableStart:r},s){let i=n.mapping.maps.length;for(let o=0;o<e.height;){let a=o*e.width+s,l=e.map[a],c=t.nodeAt(l);if(s>0&&e.map[a-1]==l||s<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(i).map(r+l),null,Pa(c.attrs,s-e.colCount(l)));else{let u=n.mapping.slice(i).map(r+l);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function O9(n,e){if(!rs(n))return!1;if(e){let t=Us(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;N9(r,t,s),s!=t.left;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Bt.get(t.table);e(r)}return!0}function R9(n,e,t){let r=xn(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(e.nodeAt(n.map[s+t*n.width]).type!=r)return!1;return!0}function EO(n,{map:e,tableStart:t,table:r},s){let i=t;for(let l=0;l<s;l++)i+=r.child(l).nodeSize;let o=[],a=s>0?-1:0;R9(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let l=0,c=e.width*s;l<e.width;l++,c++)if(s>0&&s<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,an(f,"rowspan",f.rowspan+1)),l+=f.colspan-1}else{let u=a==null?xn(r.type.schema).cell:r.nodeAt(e.map[c+a*e.width]).type;o.push(u.createAndFill())}return n.insert(i,xn(r.type.schema).row.create(null,o)),n}function M9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(EO(n.tr,t,t.top))}return!0}function D9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(EO(n.tr,t,t.bottom))}return!0}function P9(n,{map:e,table:t,tableStart:r},s){let i=0;for(let l=0;l<s;l++)i+=t.child(l).nodeSize;let o=i+t.child(s).nodeSize,a=n.mapping.maps.length;n.delete(i+r,o+r);for(let l=0,c=s*e.width;l<e.width;l++,c++){let u=e.map[c];if(s>0&&u==e.map[c-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,an(f,"rowspan",f.rowspan-1)),l+=f.colspan-1}else if(s<e.width&&u==e.map[c+e.width]){let f=t.nodeAt(u),d=f.type.create(an(f.attrs,"rowspan",f.attrs.rowspan-1),f.content),h=e.positionAt(s+1,l,t);n.insert(n.mapping.slice(a).map(r+h),d),l+=f.attrs.colspan-1}}}function I9(n,e){if(!rs(n))return!1;if(e){let t=Us(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;P9(r,t,s),s!=t.top;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Bt.get(t.table);e(r)}return!0}function kO(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function L9({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,a=s+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[a]==t[a+1])return!0;i+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function CO(n,e){let t=n.selection;if(!(t instanceof it)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Us(n),{map:s}=r;if(L9(s,r))return!1;if(e){let i=n.tr,o={},a=oe.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){let d=s.map[u*s.width+f],h=r.table.nodeAt(d);if(!o[d])if(o[d]=!0,l==null)l=d,c=h;else{kO(h)||(a=a.append(h.content));let p=i.mapping.map(d+r.tableStart);i.delete(p,p+h.nodeSize)}}if(i.setNodeMarkup(l+r.tableStart,null,an(pO(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),a.size){let u=l+1+c.content.size,f=kO(c)?l+1:u;i.replaceWith(f+r.tableStart,u+r.tableStart,a)}i.setSelection(new it(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function SO(n,e){const t=xn(n.schema);return _9(({node:r})=>t[r.type.spec.tableRole])(n,e)}function _9(n){return(e,t)=>{let r=e.selection,s,i;if(r instanceof it){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{if(s=l9(r.$from),!s)return!1;i=xc(r.$from).pos}if(s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let o=s.attrs,a=[],l=o.colwidth;o.rowspan>1&&(o=an(o,"rowspan",1)),o.colspan>1&&(o=an(o,"colspan",1));let c=Us(e),u=e.tr;for(let d=0;d<c.right-c.left;d++)a.push(l?an(o,"colwidth",l&&l[d]?[l[d]]:null):o);let f;for(let d=c.top;d<c.bottom;d++){let h=c.map.positionAt(d,c.left,c.table);d==c.top&&(h+=s.nodeSize);for(let p=c.left,m=0;p<c.right;p++,m++)p==c.left&&d==c.top||u.insert(f=u.mapping.map(h+c.tableStart,1),n({node:s,row:d,col:p}).createAndFill(a[m]))}u.setNodeMarkup(i,n({node:s,row:c.top,col:c.left}),a[0]),r instanceof it&&u.setSelection(new it(u.doc.resolve(r.$anchorCell.pos),f&&u.doc.resolve(f))),t(u)}return!0}}function B9(n,e){return function(t,r){if(!rs(t))return!1;let s=$m(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof it?t.selection.forEachCell((o,a)=>{o.attrs[n]!==e&&i.setNodeMarkup(a,null,an(o.attrs,n,e))}):i.setNodeMarkup(s.pos,null,an(s.nodeAfter.attrs,n,e)),r(i)}return!0}}function F9(n){return function(e,t){if(!rs(e))return!1;if(t){let r=xn(e.schema),s=Us(e),i=e.tr,o=s.map.cellsInRect(n=="column"?new vc(s.left,0,s.right,s.map.height):n=="row"?new vc(0,s.top,s.map.width,s.bottom):s),a=o.map(l=>s.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[l],r.cell,a[l].attrs);if(i.steps.length==0)for(let l=0;l<o.length;l++)i.setNodeMarkup(s.tableStart+o[l],r.header_cell,a[l].attrs);t(i)}return!0}}function TO(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function dd(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?F9(n):function(t,r){if(!rs(t))return!1;if(r){let s=xn(t.schema),i=Us(t),o=t.tr,a=TO("row",i,s),l=TO("column",i,s),u=(n==="column"?a:n==="row"?l:!1)?1:0,f=n=="column"?new vc(0,u,1,i.map.height):n=="row"?new vc(u,0,i.map.width,1):i,d=n=="column"?l?s.cell:s.header_cell:n=="row"?a?s.cell:s.header_cell:s.cell;i.map.cellsInRect(f).forEach(h=>{const p=h+i.tableStart,m=o.doc.nodeAt(p);m&&o.setNodeMarkup(p,d,m.attrs)}),r(o)}return!0}}dd("row",{useDeprecatedLogic:!0}),dd("column",{useDeprecatedLogic:!0});let j9=dd("cell",{useDeprecatedLogic:!0});function U9(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){let i=n.node(-1).child(r);if(i.childCount)return s-1-i.lastChild.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}}function NO(n){return function(e,t){if(!rs(e))return!1;let r=U9($m(e),n);if(r!=null){if(t){let s=e.doc.resolve(r);t(e.tr.setSelection(Me.between(s,u9(s))).scrollIntoView())}return!0}}}function H9(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let z9=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Sv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Sv(n,e,t,r,s,i){let o=0,a=!0,l=e.firstChild,c=n.firstChild;for(let u=0,f=0;u<c.childCount;u++){let{colspan:d,colwidth:h}=c.child(u).attrs;for(let p=0;p<d;p++,f++){let m=s==f?i:h&&h[p],y=m?m+"px":"";o+=m||r,m||(a=!1),l?(l.style.width!=y&&(l.style.width=y),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;l;){let u=l.nextSibling;l.parentNode.removeChild(l),l=u}a?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const Lr=new Ot("tableColumnResizing");function V9({handleWidth:n=5,cellMinWidth:e=25,View:t=z9,lastColumnResizable:r=!0}={}){return new bt({key:Lr,state:{init(i,o){return this.spec.props.nodeViews[xn(o.schema).table.name]=(a,l)=>new t(a,e,l),new hd(-1,!1)},apply(i,o){return o.apply(i)}},props:{attributes(i){return Lr.getState(i).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(i,o){$9(i,o,n,e,r)},mouseleave(i){W9(i)},mousedown(i,o){G9(i,o,e)}},decorations(i){let o=Lr.getState(i);if(o.activeHandle>-1)return X9(i,o.activeHandle)},nodeViews:{}}})}class hd{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new hd(r.setHandle,null);if(r&&r.setDragging!==void 0)return new hd(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);xv(e.doc.resolve(s))||(s=null),t=new hd(s,t.dragging)}return t}}function $9(n,e,t,r,s){let i=Lr.getState(n.state);if(!i.dragging){let o=J9(e.target),a=-1;if(o){let{left:l,right:c}=o.getBoundingClientRect();e.clientX-l<=t?a=OO(n,e,"left"):c-e.clientX<=t&&(a=OO(n,e,"right"))}if(a!=i.activeHandle){if(!s&&a!==-1){let l=n.state.doc.resolve(a),c=l.node(-1),u=Bt.get(c),f=l.start(-1);if(u.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==u.width-1)return}MO(n,a)}}}function W9(n){let e=Lr.getState(n.state);e.activeHandle>-1&&!e.dragging&&MO(n,-1)}function G9(n,e,t){let r=Lr.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let s=n.state.doc.nodeAt(r.activeHandle),i=K9(n,r.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:i}}));function o(l){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",a);let c=Lr.getState(n.state);c.dragging&&(q9(n,c.activeHandle,RO(c.dragging,l,t)),n.dispatch(n.state.tr.setMeta(Lr,{setDragging:null})))}function a(l){if(!l.which)return o(l);let c=Lr.getState(n.state),u=RO(c.dragging,l,t);Q9(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",a),e.preventDefault(),!0}function K9(n,e,{colspan:t,colwidth:r}){let s=r&&r[r.length-1];if(s)return s;let i=n.domAtPos(e),a=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let c=0;c<t;c++)r[c]&&(a-=r[c],l--);return a/l}function J9(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function OO(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:s}=r,i=xc(n.state.doc.resolve(s));if(!i)return-1;if(t=="right")return i.pos;let o=Bt.get(i.node(-1)),a=i.start(-1),l=o.map.indexOf(i.pos-a);return l%o.width==0?-1:a+o.map[l-1]}function RO(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function MO(n,e){n.dispatch(n.state.tr.setMeta(Lr,{setHandle:e}))}function q9(n,e,t){let r=n.state.doc.resolve(e),s=r.node(-1),i=Bt.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+a;if(c&&i.map[u]==i.map[u-i.width])continue;let f=i.map[u],{attrs:d}=s.nodeAt(f),h=d.colspan==1?0:a-i.colCount(f);if(d.colwidth&&d.colwidth[h]==t)continue;let p=d.colwidth?d.colwidth.slice():Y9(d.colspan);p[h]=t,l.setNodeMarkup(o+f,null,an(d,"colwidth",p))}l.docChanged&&n.dispatch(l)}function Q9(n,e,t,r){let s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),a=Bt.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,l=n.domAtPos(s.start(-1)).node;for(;l.nodeName!="TABLE";)l=l.parentNode;Sv(i,l.firstChild,l,r,a,t)}function Y9(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function X9(n,e){let t=[],r=n.doc.resolve(e),s=r.node(-1),i=Bt.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let l=0;l<i.height;l++){let c=a+l*i.width-1;if((a==i.width||i.map[c]!=i.map[c+1])&&(l==0||i.map[c-1]!=i.map[c-1-i.width])){let u=i.map[c],f=o+u+s.nodeAt(u).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",t.push(Qt.widget(f,d))}}return wt.create(n.doc,t)}function Z9({allowTableNodeSelection:n=!1}={}){return new bt({key:yo,state:{init(){return null},apply(e,t){let r=e.getMeta(yo);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:d9,handleDOMEvents:{mousedown:E9},createSelectionBetween(e){if(yo.getState(e.state)!=null)return e.state.selection},handleTripleClick:x9,handleKeyDown:v9,handlePaste:A9},appendTransaction(e,t,r){return m9(r,xO(r,t),n)}})}function DO(n,e,t,r,s,i){var u;let o=0,a=!0,l=e.firstChild;const c=n.firstChild;if(c)for(let f=0,d=0;f<c.childCount;f+=1){const{colspan:h,colwidth:p}=c.child(f).attrs;for(let m=0;m<h;m+=1,d+=1){const y=s===d?i:p&&p[m],b=y?`${y}px`:"";o+=y||r,y||(a=!1),l?(l.style.width!==b&&(l.style.width=b),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=b}}for(;l;){const f=l.nextSibling;(u=l==null?void 0:l.parentNode)==null||u.removeChild(l),l=f}a?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class eW{constructor(e,t){$(this,"node");$(this,"cellMinWidth");$(this,"dom");$(this,"table");$(this,"colgroup");$(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),DO(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,DO(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function PO(n,e){return n.createAndFill()}function tW(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function nW(n,e,t,r,s){const i=tW(n),o=[],a=[];for(let c=0;c<t;c+=1){const u=PO(i.cell);if(u&&a.push(u),r){const f=PO(i.header_cell);f&&o.push(f)}}const l=[];for(let c=0;c<e;c+=1)l.push(i.row.createChecked(null,r&&c===0?o:a));return i.table.createChecked(null,l)}function rW(n){return n instanceof it}const qm=({editor:n})=>{const{selection:e}=n.state;if(!rW(e))return!1;let t=0;const r=a0(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},sW=vt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:eW,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(i=>{if(i.attrs.colwidth)i.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=i.attrs.colspan?i.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",tt(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const{selection:o}=r,a=nW(i.schema,n,e,t);if(s){const l=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,a).scrollIntoView().setSelection(Me.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>S9(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>T9(n,e),deleteColumn:()=>({state:n,dispatch:e})=>O9(n,e),addRowBefore:()=>({state:n,dispatch:e})=>M9(n,e),addRowAfter:()=>({state:n,dispatch:e})=>D9(n,e),deleteRow:()=>({state:n,dispatch:e})=>I9(n,e),deleteTable:()=>({state:n,dispatch:e})=>H9(n,e),mergeCells:()=>({state:n,dispatch:e})=>CO(n,e),splitCell:()=>({state:n,dispatch:e})=>SO(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dd("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dd("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>j9(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>CO(n,e)?!0:SO(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>B9(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>NO(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>NO(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&xO(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=it.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:qm,"Mod-Backspace":qm,Delete:qm,"Mod-Delete":qm}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[V9({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Z9({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Qe(xe(n,"tableRole",e))}}});function IO(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,i;for(i=0;i<r.length;i++)s=r[i],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}var LO=typeof window<"u"&&typeof document<"u";function Tv(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function _O(){return LO&&document.createElement("div")}function iW(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function BO(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!BO(n[t],e[t]))return!1}else return!1;return!0}else return!1}function oW(n){var e=[];return n.forEach(function(t){e.find(function(r){return BO(t,r)})||e.push(t)}),e}function aW(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:oW([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Nv=LO?L.useLayoutEffect:L.useEffect;function lW(n){var e=L.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function FO(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var cW={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var a;return!!((a=e.props.render)!=null&&a.$$tippy)};function s(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}FO(t,"add",e.props.className)}function i(){r()&&FO(t,"remove",e.props.className)}return{onCreate:s,onBeforeUpdate:i,onAfterUpdate:s}}};function uW(n){function e(t){var r=t.children,s=t.content,i=t.visible,o=t.singleton,a=t.render,l=t.reference,c=t.disabled,u=c===void 0?!1:c,f=t.ignoreAttributes,d=f===void 0?!0:f;t.__source,t.__self;var h=IO(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=i!==void 0,m=o!==void 0,y=L.useState(!1),b=y[0],x=y[1],v=L.useState({}),w=v[0],E=v[1],k=L.useState(),S=k[0],M=k[1],O=lW(function(){return{container:_O(),renders:1}}),R=Object.assign({ignoreAttributes:d},h,{content:O.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(K){R[K]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+K+"` prop in","controlled mode (`visible` prop)"].join(" "))}),R.trigger="manual",R.hideOnClick=!1),m&&(u=!0);var D=R,F=R.plugins||[];a&&(D=Object.assign({},R,{plugins:m&&o.data!=null?[].concat(F,[{fn:function(){return{onTrigger:function(G,Y){var re=o.data.children.find(function(Z){var me=Z.instance;return me.reference===Y.currentTarget});G.state.$$activeSingletonInstance=re.instance,M(re.content)}}}}]):F,render:function(){return{popper:O.container}}}));var U=[l].concat(r?[r.type]:[]);return Nv(function(){var K=l;l&&l.hasOwnProperty("current")&&(K=l.current);var _=n(K||O.ref||_O(),Object.assign({},D,{plugins:[cW].concat(R.plugins||[])}));return O.instance=_,u&&_.disable(),i&&_.show(),m&&o.hook({instance:_,content:s,props:D,setSingletonContent:M}),x(!0),function(){_.destroy(),o==null||o.cleanup(_)}},U),Nv(function(){var K;if(O.renders===1){O.renders++;return}var _=O.instance;_.setProps(aW(_.props,D)),(K=_.popperInstance)==null||K.forceUpdate(),u?_.disable():_.enable(),p&&(i?_.show():_.hide()),m&&o.hook({instance:_,content:s,props:D,setSingletonContent:M})}),Nv(function(){var K;if(a){var _=O.instance;_.setProps({popperOptions:Object.assign({},_.props.popperOptions,{modifiers:[].concat((((K=_.props.popperOptions)==null?void 0:K.modifiers)||[]).filter(function(G){var Y=G.name;return Y!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Y){var re,Z=Y.state,me=(re=Z.modifiersData)==null?void 0:re.hide;(w.placement!==Z.placement||w.referenceHidden!==(me==null?void 0:me.isReferenceHidden)||w.escaped!==(me==null?void 0:me.hasPopperEscaped))&&E({placement:Z.placement,referenceHidden:me==null?void 0:me.isReferenceHidden,escaped:me==null?void 0:me.hasPopperEscaped}),Z.attributes.popper={}}}])})})}},[w.placement,w.referenceHidden,w.escaped].concat(U)),L.createElement(L.Fragment,null,r?L.cloneElement(r,{ref:function(_){O.ref=_,Tv(r.ref,_)}}):null,b&&Et.createPortal(a?a(iW(w),S,O.instance):s,O.container))}return e}var fW=function(n,e){return L.forwardRef(function(r,s){var i=r.children,o=IO(r,["children"]);return L.createElement(n,Object.assign({},e,o),i?L.cloneElement(i,{ref:function(l){Tv(s,l),Tv(i.ref,l)}}):null)})},dW=fW(uW(fa));const hW=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],jO=({node:n,getPos:e,selected:t,editor:r})=>{const[s,i]=L.useState(!1),o=gp(),a=L.useRef(null),l=()=>{const{from:u,to:f}=r.state.selection,d=e(),h=d+n.nodeSize;i(d<=u&&f<=h)};L.useEffect(()=>(r.on("selectionUpdate",l),setTimeout(l,100),()=>{r.off("selectionUpdate",l)}));const c=()=>{var d,h;let u=(d=a.current)==null?void 0:d.clientTop;u&&(u+=5);let f=(h=a.current)==null?void 0:h.clientLeft;return f&&(f+=5),{top:`${u}px`,left:`${f}px`}};return C.jsxs(wf,{className:"group",children:[C.jsx(Ik,{as:"span"}),(s||t)&&C.jsx(dW,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:C.jsx("article",{className:"dropdown",contentEditable:!1,children:C.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:hW.map(u=>C.jsx("li",{children:C.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[C.jsx("span",{children:u.icon}),C.jsx("span",{children:u.name})]})},u.name))})}),children:C.jsx("label",{tabIndex:0,className:pe("trigger-button",{hidden:o}),contentEditable:!1,children:C.jsx(X3,{fontSize:"small"})})})]})},pW=vt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return da(jO,{as:"td",className:"relative"})}}),mW=vt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return da(jO,{as:"th",className:"relative"})}}),UO=n=>(n.stopPropagation(),n.preventDefault(),n),gW=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},HO=function(n){return!n||n===document.body?document.body:gW(n)?n:HO(n.parentNode)},Ov=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([s,i])=>r.setAttribute(s,i)),t&&Object.entries(t).forEach(([s,i])=>r.addEventListener(s,i)),r},yW=vt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),s=HO(n.options.element);let i=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const b=r(),x=n.state.doc.resolve(b),v=new Ne(x);n.view.dispatch(n.state.tr.setSelection(v))}},a=()=>{i=!0},l=()=>{i=!1},c=Ov("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:b=>{b&&UO(b),o.selectRow()},mouseenter:()=>{a()},mouseover:()=>{a()},mouseleave:()=>{l(),d()}}),u=Ov("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:b=>{b&&UO(b),o.deleteRow()}}),f=()=>{m(),c.classList.remove("hidden")},d=()=>{setTimeout(()=>{i||c.classList.add("hidden")},100)},h=Ov("tr",{...e},{mouseenter:f,mouseover:f,mouseleave:d});c.append(u),document.body.append(c);let p="";const m=()=>{setTimeout(()=>{const b=h.getBoundingClientRect(),x=JSON.stringify(b);p!==x&&(c.style.top=`${b.top+document.documentElement.scrollTop}px`,c.style.left=`${b.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${b.height+1}px`,p=x)})};return setTimeout(()=>{m()},100),n.on("selectionUpdate",m),n.on("update",m),s==null||s.addEventListener("scroll",m),document.addEventListener("scroll",m),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",m),n.off("update",m),s==null||s.removeEventListener("scroll",m),document.removeEventListener("scroll",m)}}}}}),bW=[sW.configure({resizable:!0}),pW,mW,yW],wW=Y2.extend({content:"(dBlock|columns)+"});function zO({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const vW=St.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new Ot(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new bt({key:n,appendTransaction:(t,r,s)=>{const{doc:i,tr:o,schema:a}=s,l=n.getState(s),c=i.content.size,u=a.nodes[this.options.node];if(l)return o.insert(c,u.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!zO({node:s,types:e})},apply:(t,r)=>{var i,o,a;if(!t.docChanged)return r;const s=(a=(o=(i=t.doc.lastChild)==null?void 0:i.content)==null?void 0:o.content)==null?void 0:a[0];return!zO({node:s,types:e})}}})]}}),xW=({node:n,editor:e,getPos:t})=>{const[r,s]=L.useState(""),i=gp(),o=["https://twitter.com","https://x.com"],a=()=>{switch(n.attrs.data){case"twitter":return C.jsx(Gk,{});case"iframe":return C.jsx(Kk,{});default:return C.jsx(a4,{})}},l=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const v=r.match(/src="([^"]*)"/);v&&v.length>0&&(p=v[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://www.youtube.com/embed/${v[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://player.vimeo.com/video/${v[1]}`);break}default:{alert("Please enter a valid url");return}}const m=640,y=360,b=t(),x=b+n.nodeSize;p&&(e==null||e.chain().focus(b).deleteRange({from:b,to:x}).setIframe({src:p,width:m,height:y}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const m=o.some(w=>r.includes(w)),y=r.match(/\/status\/([0-9]*)/),b=y&&y.length>0;if(m&&b)p=y[1];else{alert("invalid url");return}const x=t(),v=x+n.nodeSize;p&&(e==null||e.chain().focus(x).deleteRange({from:x,to:v}).setTweetEmbed({tweetId:p}).run())},d=iv(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);L.useEffect(()=>{r&&d()},[r]),L.useEffect(()=>{e==null||e.chain().focus()},[]);const h=L.useRef(null);return L.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),C.jsx(wf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!i&&C.jsxs("div",{className:"relative w-full",children:[C.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:a()}),C.jsx("input",{ref:h,value:r,placeholder:l(),onChange:p=>s(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},AW=vt.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return da(xW)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),EW=[Pz,Mz.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-[#E8EBEC] p-5 font-serif italic text-black"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-black"},exitOnArrowDown:!0},code:{HTMLAttributes:{class:"rounded bg-transparent p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),Iz.configure({types:["heading","paragraph"]}),xV,rV.extend({exitable:!0}).configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),sV.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),aV.configure({multicolor:!0}),vV,fV.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),Dz,kV,lV.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),uV.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),X2.configure({width:3,color:"#d1d5db"}),Z2,r9,vW,wW,...bW,PV.configure({uploadFn:m4}),EV,CV,OV,AW.extend({addInputRules(){return[VO(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),VO(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),AV],VO=(n,e,t)=>new of({find:n,handler:({state:r,range:s,commands:i})=>{const o={data:e},{tr:a}=r,l=s.from,c=s.to;a.insert(l-1,t.create(o)).delete(a.mapping.map(l),a.mapping.map(c)),i.focus(c-1)}}),kW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAYAAAD0f5bSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAE/SURBVHgBhVJBTsJQEH3zMcElR+gRuIF6gwYPAOwkLoQTUE6ArEA3xbWJ4gnQE8gNwBuwhMR2fPNLk9o0ZZImM/P/e39e3wgqojPXXiPFJnFovw1kWT53xSKca3C70LXlr/eySYFdZ6Fb61eCePnBCb6VF3P21UA+WX+wv+086fgfyMbh4aPlqWJSZH2/k6EINlBEJI6tdxHG2tIDrsUqxYzsO5Qi+UXfNfwUPT7w49wRU1EyZWNFqIgV9REw84Wga+P1Uj7PsW5QE9pEZMT8Aq+JQmNcYl8HwgEtEvf9fc3RR4zrMCRe84WA6dJRz8upPwyftV0FOP3ugHqu0iZGzsSbF3bYUMRlgDdWMcyE4WvVl73XRC9CNiaqaHMDpkUQrYh8kmKUmy5lVpvdBNs2mOk0tptk9a5AVKHhzML+AZaSjR/r++n9AAAAAElFTkSuQmCC",CW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEjSURBVHgBjZJBToNQEIb/NzTeoMbGjTeoN5Au1S7wBrqwyk5OoD1B46pRF9UbsEBc9nmEHsI08QhGZnxMpaGUEv4EwoP/mxnyj0GNTp++AoPORA+Gx+mo91r1mOJh+LL0WYwDqC8i/obJGCuSfRJ1bHLdtWtQIaY5WoiYBknYtZQfmOGjpTIvC7TAahTvpMksmUQCvK0A6itzNl1egmi2k2K+2gPsD+mvHGkh4MIVoPuSLYbIYxOk3YAJVRuktwd3DhjvggqRB0Slc3D+/D1Lw95DE5Rnq3E487ySXeyu4zooz/R9tD/QUYV5Ufke1HbKvW4RdFS9icRoKeKO1c7Fi+HUbQ/BzzPdXjmxDCy8TOIk7G2CZf1nqzEJfqOPm8Otif4AFnp3K1F5HHAAAAAASUVORK5CYII=",SW=n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},TW=n=>{const e=document.createElement("span");e.classList.add("custom-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.classList.add("custom-cursor__label-container"),t.setAttribute("style",`border: 1px solid ${n.color}`);const r=document.createElement("img");r.src=kW,r.classList.add("custom-cursor__icon");const s=document.createElement("div");s.classList.add("custom-cursor__label");const i=document.createElement("span");i.classList.add("custom-cursor__text"),i.textContent=n.name;const o=document.createElement("img");return o.src=CW,o.classList.add("custom-cursor__badge"),s.appendChild(i),t.appendChild(r),t.appendChild(s),t.appendChild(o),e.appendChild(t),e},NW=n=>n.isEns?TW(n):SW(n),OW="6.13.1";function RW(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function An(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function Oe(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&RW(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function Ac(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ac).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Ac(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Ac(t)}: ${Ac(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function ln(n,e){return n&&n.code===e}function Rv(n){return ln(n,"CALL_EXCEPTION")}function Nt(n,e,t){let r=n;{const i=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ac(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];i.push(o+"="+Ac(a))}}i.push(`code=${e}`),i.push(`version=${OW}`),i.length&&(n+=" ("+i.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(n);break;default:s=new Error(n)}return Oe(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&Oe(s,{shortMessage:r}),s}function ee(n,e,t,r){if(!n)throw Nt(e,t,r)}function V(n,e,t,r){ee(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function $O(n,e,t){t==null&&(t=""),t&&(t=": "+t),ee(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),ee(n<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(e)}catch{}return n},[]);function Qm(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),ee(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function WO(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}V(!1,"invalid BytesLike value",e||"value",n)}function lt(n,e){return WO(n,e,!1)}function Pn(n,e){return WO(n,e,!0)}function At(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}function Mv(n){return At(n,!0)||n instanceof Uint8Array}const GO="0123456789abcdef";function we(n){const e=lt(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=GO[(s&240)>>4]+GO[s&15]}return t}function Ut(n){return"0x"+n.map(e=>we(e).substring(2)).join("")}function Ec(n){return At(n,!0)?(n.length-2)/2:lt(n).length}function Ft(n,e,t){const r=lt(n);return t!=null&&t>r.length&&ee(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),we(r.slice(e??0,t??r.length))}function KO(n,e,t){const r=lt(n);ee(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),we(s)}function Ia(n,e){return KO(n,e,!0)}function MW(n,e){return KO(n,e,!1)}const Ym=BigInt(0),ss=BigInt(1),kc=9007199254740991;function DW(n,e){const t=Xm(n,"value"),r=BigInt(Je(e,"width"));if(ee(t>>r===Ym,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-ss){const s=(ss<<r)-ss;return-((~t&s)+ss)}return t}function JO(n,e){let t=Ae(n,"value");const r=BigInt(Je(e,"width")),s=ss<<r-ss;if(t<Ym){t=-t,ee(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(ss<<r)-ss;return(~t&i)+ss}else ee(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function pd(n,e){const t=Xm(n,"value"),r=BigInt(Je(e,"bits"));return t&(ss<<r)-ss}function Ae(n,e){switch(typeof n){case"bigint":return n;case"number":return V(Number.isInteger(n),"underflow",e||"value",n),V(n>=-kc&&n<=kc,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){V(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}V(!1,"invalid BigNumberish value",e||"value",n)}function Xm(n,e){const t=Ae(n,e);return ee(t>=Ym,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const qO="0123456789abcdef";function Dv(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=qO[t>>4],e+=qO[t&15];return BigInt(e)}return Ae(n)}function Je(n,e){switch(typeof n){case"bigint":return V(n>=-kc&&n<=kc,"overflow",e||"value",n),Number(n);case"number":return V(Number.isInteger(n),"underflow",e||"value",n),V(n>=-kc&&n<=kc,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return Je(BigInt(n),e)}catch(t){V(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}V(!1,"invalid numeric value",e||"value",n)}function PW(n){return Je(Dv(n))}function bo(n,e){let r=Xm(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=Je(e,"width");for(ee(s*2>=r.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function In(n){const e=Xm(n,"value");if(e===Ym)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}function La(n){let e=we(Mv(n)?n:In(n)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const QO="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const YO=BigInt(58);function IW(n){const e=lt(n);let t=Dv(e),r="";for(;t;)r=QO[Number(t%YO)]+r,t/=YO;for(let s=0;s<e.length&&!e[s];s++)r=QO[0]+r;return r}function LW(n){n=atob(n);const e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return lt(e)}function _W(n){const e=lt(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}class XO{constructor(e,t,r){$(this,"filter");$(this,"emitter");q(this,$c);I(this,$c,t),Oe(this,{emitter:e,filter:r})}async removeListener(){T(this,$c)!=null&&await this.emitter.off(this.filter,T(this,$c))}}$c=new WeakMap;function BW(n,e,t,r,s){V(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function ZO(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function FW(n,e,t,r,s){return n==="OVERLONG"?(V(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),ZO(n,e,t))}const jW=Object.freeze({error:BW,ignore:ZO,replace:FW});function UW(n,e){e==null&&(e=jW.error);const t=lt(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let l=i&(1<<8-o-1)-1;for(let c=0;c<o;c++){let u=t[s];if((u&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),l=null;break}l=l<<6|u&63,s++}if(l!==null){if(l>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,l);continue}if(l>=55296&&l<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,l);continue}if(l<=a){s+=e("OVERLONG",s-1-o,t,r,l);continue}r.push(l)}}return r}function bi(n,e){V(typeof n=="string","invalid string value","str",n);let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);V(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function HW(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Cc(n,e){return HW(UW(n,e))}function eR(n){async function e(t,r){ee(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();ee(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),ee(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const o=new AbortController,a=setTimeout(()=>{i=Nt("request timeout","TIMEOUT"),o.abort()},t.timeout);r&&r.addListener(()=>{i=Nt("request cancelled","CANCELLED"),o.abort()});const l={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let c;try{c=await fetch(t.url,l)}catch(h){throw clearTimeout(a),i||h}clearTimeout(a);const u={};c.headers.forEach((h,p)=>{u[p.toLowerCase()]=h});const f=await c.arrayBuffer(),d=f==null?null:new Uint8Array(f);return{statusCode:c.status,statusMessage:c.statusText,headers:u,body:d}}return e}const zW=12,VW=250;let tR=eR();const $W=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),WW=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Pv=!1;async function nR(n,e){try{const t=n.match($W);if(!t)throw new Error("invalid data");return new wo(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?LW(t[3]):KW(t[3]))}catch{return new wo(599,"BAD REQUEST (invalid data: URI)",{},null,new Ln(n))}}function rR(n){async function e(t,r){try{const s=t.match(WW);if(!s)throw new Error("invalid link");return new Ln(`${n}${s[2]}`)}catch{return new wo(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Ln(t))}}return e}const Zm={data:nR,ipfs:rR("https://gateway.ipfs.io/ipfs/")},sR=new WeakMap;class GW{constructor(e){q(this,qa);q(this,To);I(this,qa,[]),I(this,To,!1),sR.set(e,()=>{if(!T(this,To)){I(this,To,!0);for(const t of T(this,qa))setTimeout(()=>{t()},0);I(this,qa,[])}})}addListener(e){ee(!T(this,To),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,qa).push(e)}get cancelled(){return T(this,To)}checkSignal(){ee(!this.cancelled,"cancelled","CANCELLED",{})}}qa=new WeakMap,To=new WeakMap;function eg(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}const $g=class $g{constructor(e){q(this,Za);q(this,Wc);q(this,Gc);q(this,us);q(this,Ti);q(this,Kc);q(this,Jc);q(this,fn);q(this,wr);q(this,Ni);q(this,Qa);q(this,Ya);q(this,Xa);q(this,$s);q(this,fs);q(this,No);I(this,Jc,String(e)),I(this,Wc,!1),I(this,Gc,!0),I(this,us,{}),I(this,Ti,""),I(this,Kc,3e5),I(this,fs,{slotInterval:VW,maxAttempts:zW}),I(this,No,null)}get url(){return T(this,Jc)}set url(e){I(this,Jc,String(e))}get body(){return T(this,fn)==null?null:new Uint8Array(T(this,fn))}set body(e){if(e==null)I(this,fn,void 0),I(this,wr,void 0);else if(typeof e=="string")I(this,fn,bi(e)),I(this,wr,"text/plain");else if(e instanceof Uint8Array)I(this,fn,e),I(this,wr,"application/octet-stream");else if(typeof e=="object")I(this,fn,bi(JSON.stringify(e))),I(this,wr,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,fn)!=null}get method(){return T(this,Ti)?T(this,Ti):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),I(this,Ti,String(e).toUpperCase())}get headers(){const e=Object.assign({},T(this,us));return T(this,Ni)&&(e.authorization=`Basic ${_W(bi(T(this,Ni)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&T(this,wr)&&(e["content-type"]=T(this,wr)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){T(this,us)[String(e).toLowerCase()]=String(t)}clearHeaders(){I(this,us,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,Ni)||null}setCredentials(e,t){V(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),I(this,Ni,`${e}:${t}`)}get allowGzip(){return T(this,Gc)}set allowGzip(e){I(this,Gc,!!e)}get allowInsecureAuthentication(){return!!T(this,Wc)}set allowInsecureAuthentication(e){I(this,Wc,!!e)}get timeout(){return T(this,Kc)}set timeout(e){V(e>=0,"timeout must be non-zero","timeout",e),I(this,Kc,e)}get preflightFunc(){return T(this,Qa)||null}set preflightFunc(e){I(this,Qa,e)}get processFunc(){return T(this,Ya)||null}set processFunc(e){I(this,Ya,e)}get retryFunc(){return T(this,Xa)||null}set retryFunc(e){I(this,Xa,e)}get getUrlFunc(){return T(this,No)||tR}set getUrlFunc(e){I(this,No,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,fn)?we(T(this,fn)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(T(this,fs).slotInterval=e.slotInterval),e.maxAttempts!=null&&(T(this,fs).maxAttempts=e.maxAttempts)}send(){return ee(T(this,$s)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),I(this,$s,new GW(this)),fe(this,Za,eh).call(this,0,iR()+this.timeout,0,this,new wo(0,"",{},null,this))}cancel(){ee(T(this,$s)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=sR.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();ee(this.method==="GET"&&(t!=="https"||r!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new $g(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,I(s,us,Object.assign({},T(this,us))),T(this,fn)&&I(s,fn,new Uint8Array(T(this,fn))),I(s,wr,T(this,wr)),s}clone(){const e=new $g(this.url);return I(e,Ti,T(this,Ti)),T(this,fn)&&I(e,fn,T(this,fn)),I(e,wr,T(this,wr)),I(e,us,Object.assign({},T(this,us))),I(e,Ni,T(this,Ni)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),I(e,Qa,T(this,Qa)),I(e,Ya,T(this,Ya)),I(e,Xa,T(this,Xa)),I(e,fs,Object.assign({},T(this,fs))),I(e,No,T(this,No)),e}static lockConfig(){Pv=!0}static getGateway(e){return Zm[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Pv)throw new Error("gateways locked");Zm[e]=t}static registerGetUrl(e){if(Pv)throw new Error("gateways locked");tR=e}static createGetUrlFunc(e){return eR()}static createDataGateway(){return nR}static createIpfsGatewayFunc(e){return rR(e)}};Wc=new WeakMap,Gc=new WeakMap,us=new WeakMap,Ti=new WeakMap,Kc=new WeakMap,Jc=new WeakMap,fn=new WeakMap,wr=new WeakMap,Ni=new WeakMap,Qa=new WeakMap,Ya=new WeakMap,Xa=new WeakMap,$s=new WeakMap,fs=new WeakMap,No=new WeakMap,Za=new WeakSet,eh=async function(e,t,r,s,i){var u,f,d;if(e>=T(this,fs).maxAttempts)return i.makeServerError("exceeded maximum retry limit");ee(iR()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),r>0&&await JW(r);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Zm){const h=await Zm[a](o.url,eg(T(s,$s)));if(h instanceof wo){let p=h;if(this.processFunc){eg(T(s,$s));try{p=await this.processFunc(o,p)}catch(m){(m.throttle==null||typeof m.stall!="number")&&p.makeServerError("error in post-processing function",m).assertOk()}}return p}o=h}this.preflightFunc&&(o=await this.preflightFunc(o));const l=await this.getUrlFunc(o,eg(T(s,$s)));let c=new wo(l.statusCode,l.statusMessage,l.headers,l.body,s);if(c.statusCode===301||c.statusCode===302){try{const h=c.headers.location||"";return fe(u=o.redirect(h),Za,eh).call(u,e+1,t,0,s,c)}catch{}return c}else if(c.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,c,e))){const h=c.headers["retry-after"];let p=T(this,fs).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof h=="string"&&h.match(/^[1-9][0-9]*$/)&&(p=parseInt(h)),fe(f=o.clone(),Za,eh).call(f,e+1,t,p,s,c)}if(this.processFunc){eg(T(s,$s));try{c=await this.processFunc(o,c)}catch(h){(h.throttle==null||typeof h.stall!="number")&&c.makeServerError("error in post-processing function",h).assertOk();let p=T(this,fs).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return h.stall>=0&&(p=h.stall),fe(d=o.clone(),Za,eh).call(d,e+1,t,p,s,c)}}return c};let Ln=$g;const G1=class G1{constructor(e,t,r,s,i){q(this,Fd);q(this,jd);q(this,Ud);q(this,vr);q(this,qc);q(this,el);I(this,Fd,e),I(this,jd,t),I(this,Ud,Object.keys(r).reduce((o,a)=>(o[a.toLowerCase()]=String(r[a]),o),{})),I(this,vr,s==null?null:new Uint8Array(s)),I(this,qc,i||null),I(this,el,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,vr)?we(T(this,vr)):"null"}>`}get statusCode(){return T(this,Fd)}get statusMessage(){return T(this,jd)}get headers(){return Object.assign({},T(this,Ud))}get body(){return T(this,vr)==null?null:new Uint8Array(T(this,vr))}get bodyText(){try{return T(this,vr)==null?"":Cc(T(this,vr))}catch{ee(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ee(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let r;e?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new G1(599,r,this.headers,this.body,T(this,qc)||void 0);return I(s,el,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:V(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const r=new Error(e||"throttling requests");throw Oe(r,{stall:t,throttle:!0}),r}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return T(this,vr)!=null}get request(){return T(this,qc)}ok(){return T(this,el).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=T(this,el);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let s=null;try{T(this,vr)&&(s=Cc(T(this,vr)))}catch{}ee(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:r,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};Fd=new WeakMap,jd=new WeakMap,Ud=new WeakMap,vr=new WeakMap,qc=new WeakMap,el=new WeakMap;let wo=G1;function iR(){return new Date().getTime()}function KW(n){return bi(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function JW(n){return new Promise(e=>setTimeout(e,n))}function qW(n){let e=n.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function oR(n,e,t){let r=0;for(let s=0;s<t;s++)r=r*256+n[e+s];return r}function aR(n,e,t,r){const s=[];for(;t<e+1+r;){const i=lR(n,t);s.push(i.result),t+=i.consumed,ee(t<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:e})}return{consumed:1+r,result:s}}function lR(n,e){ee(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const t=r=>{ee(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[e]>=248){const r=n[e]-247;t(e+1+r);const s=oR(n,e+1,r);return t(e+1+r+s),aR(n,e,e+1+r,r+s)}else if(n[e]>=192){const r=n[e]-192;return t(e+1+r),aR(n,e,e+1,r)}else if(n[e]>=184){const r=n[e]-183;t(e+1+r);const s=oR(n,e+1,r);t(e+1+r+s);const i=we(n.slice(e+1+r,e+1+r+s));return{consumed:1+r+s,result:i}}else if(n[e]>=128){const r=n[e]-128;t(e+1+r);const s=we(n.slice(e+1,e+1+r));return{consumed:1+r,result:s}}return{consumed:1,result:qW(n[e])}}function tg(n){const e=lt(n,"data"),t=lR(e,0);return V(t.consumed===e.length,"unexpected junk after rlp payload","data",n),t.result}function cR(n){const e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function uR(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(i){r=r.concat(uR(i))}),r.length<=55)return r.unshift(192+r.length),r;const s=cR(r.length);return s.unshift(247+s.length),s.concat(r)}const e=Array.prototype.slice.call(lt(n,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=cR(e.length);return t.unshift(183+t.length),t.concat(e)}const fR="0123456789abcdef";function _a(n){let e="0x";for(const t of uR(n))e+=fR[t>>4],e+=fR[t&15];return e}const _n=32,Iv=new Uint8Array(_n),QW=["then"],ng={},dR=new WeakMap;function Ba(n){return dR.get(n)}function hR(n,e){dR.set(n,e)}function md(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}function Lv(n,e,t){return n.indexOf(null)>=0?e.map((r,s)=>r instanceof Sc?Lv(Ba(r),r,t):r):n.reduce((r,s,i)=>{let o=e.getValue(s);return s in r||(t&&o instanceof Sc&&(o=Lv(Ba(o),o,t)),r[s]=o),r},{})}const Yc=class Yc extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==ng&&(s=t,i=[],o=!1);super(s.length);q(this,Qc);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(hR(this,Object.freeze(s.map((c,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null}))),I(this,Qc,[]),T(this,Qc)==null&&T(this,Qc),!o)return;Object.freeze(this);const l=new Proxy(this,{get:(c,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const h=Je(u,"%index");if(h<0||h>=this.length)throw new RangeError("out of result range");const p=c[h];return p instanceof Error&&md(`index ${h}`,p),p}if(QW.indexOf(u)>=0)return Reflect.get(c,u,f);const d=c[u];if(d instanceof Function)return function(...h){return d.apply(this===f?c:this,h)};if(!(u in c))return c.getValue.apply(this===f?c:this,[u])}return Reflect.get(c,u,f)}});return hR(l,Ba(this)),l}toArray(t){const r=[];return this.forEach((s,i)=>{s instanceof Error&&md(`index ${i}`,s),t&&s instanceof Yc&&(s=s.toArray(t)),r.push(s)}),r}toObject(t){const r=Ba(this);return r.reduce((s,i,o)=>(ee(i!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Lv(r,this,t)),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=Ba(this),i=[],o=[];for(let a=t;a<r;a++)i.push(this[a]),o.push(s[a]);return new Yc(ng,i,o)}filter(t,r){const s=Ba(this),i=[],o=[];for(let a=0;a<this.length;a++){const l=this[a];l instanceof Error&&md(`index ${a}`,l),t.call(r,l,a,this)&&(i.push(l),o.push(s[a]))}return new Yc(ng,i,o)}map(t,r){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&md(`index ${i}`,o),s.push(t.call(r,o,i,this))}return s}getValue(t){const r=Ba(this).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&md(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new Yc(ng,t,r)}};Qc=new WeakMap;let Sc=Yc;function pR(n){let e=In(n);return ee(e.length<=_n,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:_n,offset:e.length}),e.length!==_n&&(e=Pn(Ut([Iv.slice(e.length%_n),e]))),e}class wi{constructor(e,t,r,s){$(this,"name");$(this,"type");$(this,"localName");$(this,"dynamic");Oe(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){V(!1,e,this.localName,t)}}class _v{constructor(){q(this,Xc);q(this,Oi);q(this,tl);I(this,Oi,[]),I(this,tl,0)}get data(){return Ut(T(this,Oi))}get length(){return T(this,tl)}appendWriter(e){return fe(this,Xc,Yg).call(this,Pn(e.data))}writeBytes(e){let t=Pn(e);const r=t.length%_n;return r&&(t=Pn(Ut([t,Iv.slice(r)]))),fe(this,Xc,Yg).call(this,t)}writeValue(e){return fe(this,Xc,Yg).call(this,pR(e))}writeUpdatableValue(){const e=T(this,Oi).length;return T(this,Oi).push(Iv),I(this,tl,T(this,tl)+_n),t=>{T(this,Oi)[e]=pR(t)}}}Oi=new WeakMap,tl=new WeakMap,Xc=new WeakSet,Yg=function(e){return T(this,Oi).push(e),I(this,tl,T(this,tl)+e.length),e.length};const K1=class K1{constructor(e,t,r){q(this,sl);$(this,"allowLoose");q(this,er);q(this,xr);q(this,nl);q(this,rl);q(this,Oo);Oe(this,{allowLoose:!!t}),I(this,er,Pn(e)),I(this,nl,0),I(this,rl,null),I(this,Oo,r??1024),I(this,xr,0)}get data(){return we(T(this,er))}get dataLength(){return T(this,er).length}get consumed(){return T(this,xr)}get bytes(){return new Uint8Array(T(this,er))}subReader(e){const t=new K1(T(this,er).slice(T(this,xr)+e),this.allowLoose,T(this,Oo));return I(t,rl,this),t}readBytes(e,t){let r=fe(this,sl,eP).call(this,0,e,!!t);return fe(this,sl,nx).call(this,e),I(this,xr,T(this,xr)+r.length),r.slice(0,e)}readValue(){return Dv(this.readBytes(_n))}readIndex(){return PW(this.readBytes(_n))}};er=new WeakMap,xr=new WeakMap,nl=new WeakMap,rl=new WeakMap,Oo=new WeakMap,sl=new WeakSet,nx=function(e){var t;if(T(this,rl))return fe(t=T(this,rl),sl,nx).call(t,e);I(this,nl,T(this,nl)+e),ee(T(this,Oo)<1||T(this,nl)<=T(this,Oo)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,Oo)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Pn(T(this,er)),offset:T(this,xr),length:e,info:{bytesRead:T(this,nl),dataLength:this.dataLength}})},eP=function(e,t,r){let s=Math.ceil(t/_n)*_n;return T(this,xr)+s>T(this,er).length&&(this.allowLoose&&r&&T(this,xr)+t<=T(this,er).length?s=t:ee(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Pn(T(this,er)),length:T(this,er).length,offset:T(this,xr)+s})),T(this,er).slice(T(this,xr),T(this,xr)+s)};let Bv=K1;function rg(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Fv(n,...e){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function YW(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rg(n.outputLen),rg(n.blockLen)}function Tc(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function mR(n,e){Fv(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const jv=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gR=n=>n instanceof Uint8Array,XW=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Uv=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Hs=(n,e)=>n<<32-e|n>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function ZW(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function sg(n){if(typeof n=="string"&&(n=ZW(n)),!gR(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function e7(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!gR(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}class Hv{clone(){return this._cloneInto()}}function zv(n){const e=r=>n().update(sg(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function t7(n=32){if(jv&&typeof jv.getRandomValues=="function")return jv.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class yR extends Hv{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,YW(e);const r=sg(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Tc(this),this.iHash.update(e),this}digestInto(e){Tc(this),Fv(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bR=(n,e,t)=>new yR(n,e).update(t).digest();bR.create=(n,e)=>new yR(n,e);function n7(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),l=r?4:0,c=r?0:4;n.setUint32(e+l,o,r),n.setUint32(e+c,a,r)}class wR extends Hv{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Uv(this.buffer)}update(e){Tc(this);const{view:t,buffer:r,blockLen:s}=this;e=sg(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=Uv(e);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Tc(this),mR(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let f=o;f<s;f++)t[f]=0;n7(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Uv(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<c;f++)a.setUint32(4*f,u[f],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const r7=(n,e,t)=>n&e^~n&t,s7=(n,e,t)=>n&e^n&t^e&t,i7=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),vo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xo=new Uint32Array(64);class o7 extends wR{constructor(){super(64,32,8,!1),this.A=vo[0]|0,this.B=vo[1]|0,this.C=vo[2]|0,this.D=vo[3]|0,this.E=vo[4]|0,this.F=vo[5]|0,this.G=vo[6]|0,this.H=vo[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[e,t,r,s,i,o,a,l]}set(e,t,r,s,i,o,a,l){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let f=0;f<16;f++,t+=4)xo[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const d=xo[f-15],h=xo[f-2],p=Hs(d,7)^Hs(d,18)^d>>>3,m=Hs(h,17)^Hs(h,19)^h>>>10;xo[f]=m+xo[f-7]+p+xo[f-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:c,H:u}=this;for(let f=0;f<64;f++){const d=Hs(a,6)^Hs(a,11)^Hs(a,25),h=u+d+r7(a,l,c)+i7[f]+xo[f]|0,m=(Hs(r,2)^Hs(r,13)^Hs(r,22))+s7(r,s,i)|0;u=c,c=l,l=a,a=o+h|0,o=i,i=s,s=r,r=h+m|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,s,i,o,a,l,c,u)}roundClean(){xo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const vR=zv(()=>new o7),ig=BigInt(2**32-1),Vv=BigInt(32);function xR(n,e=!1){return e?{h:Number(n&ig),l:Number(n>>Vv&ig)}:{h:Number(n>>Vv&ig)|0,l:Number(n&ig)|0}}function AR(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=xR(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const a7=(n,e)=>BigInt(n>>>0)<<Vv|BigInt(e>>>0),l7=(n,e,t)=>n>>>t,c7=(n,e,t)=>n<<32-t|e>>>t,u7=(n,e,t)=>n>>>t|e<<32-t,f7=(n,e,t)=>n<<32-t|e>>>t,d7=(n,e,t)=>n<<64-t|e>>>t-32,h7=(n,e,t)=>n>>>t-32|e<<64-t,p7=(n,e)=>e,m7=(n,e)=>n,ER=(n,e,t)=>n<<t|e>>>32-t,kR=(n,e,t)=>e<<t|n>>>32-t,CR=(n,e,t)=>e<<t-32|n>>>64-t,SR=(n,e,t)=>n<<t-32|e>>>64-t;function g7(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const Xe={fromBig:xR,split:AR,toBig:a7,shrSH:l7,shrSL:c7,rotrSH:u7,rotrSL:f7,rotrBH:d7,rotrBL:h7,rotr32H:p7,rotr32L:m7,rotlSH:ER,rotlSL:kR,rotlBH:CR,rotlBL:SR,add:g7,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[y7,b7]=Xe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),Ao=new Uint32Array(80),Eo=new Uint32Array(80);class w7 extends wR{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:c,El:u,Fh:f,Fl:d,Gh:h,Gl:p,Hh:m,Hl:y}=this;return[e,t,r,s,i,o,a,l,c,u,f,d,h,p,m,y]}set(e,t,r,s,i,o,a,l,c,u,f,d,h,p,m,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=l|0,this.Eh=c|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=p|0,this.Hh=m|0,this.Hl=y|0}process(e,t){for(let v=0;v<16;v++,t+=4)Ao[v]=e.getUint32(t),Eo[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){const w=Ao[v-15]|0,E=Eo[v-15]|0,k=Xe.rotrSH(w,E,1)^Xe.rotrSH(w,E,8)^Xe.shrSH(w,E,7),S=Xe.rotrSL(w,E,1)^Xe.rotrSL(w,E,8)^Xe.shrSL(w,E,7),M=Ao[v-2]|0,O=Eo[v-2]|0,R=Xe.rotrSH(M,O,19)^Xe.rotrBH(M,O,61)^Xe.shrSH(M,O,6),D=Xe.rotrSL(M,O,19)^Xe.rotrBL(M,O,61)^Xe.shrSL(M,O,6),F=Xe.add4L(S,D,Eo[v-7],Eo[v-16]),U=Xe.add4H(F,k,R,Ao[v-7],Ao[v-16]);Ao[v]=U|0,Eo[v]=F|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:l,Dh:c,Dl:u,Eh:f,El:d,Fh:h,Fl:p,Gh:m,Gl:y,Hh:b,Hl:x}=this;for(let v=0;v<80;v++){const w=Xe.rotrSH(f,d,14)^Xe.rotrSH(f,d,18)^Xe.rotrBH(f,d,41),E=Xe.rotrSL(f,d,14)^Xe.rotrSL(f,d,18)^Xe.rotrBL(f,d,41),k=f&h^~f&m,S=d&p^~d&y,M=Xe.add5L(x,E,S,b7[v],Eo[v]),O=Xe.add5H(M,b,w,k,y7[v],Ao[v]),R=M|0,D=Xe.rotrSH(r,s,28)^Xe.rotrBH(r,s,34)^Xe.rotrBH(r,s,39),F=Xe.rotrSL(r,s,28)^Xe.rotrBL(r,s,34)^Xe.rotrBL(r,s,39),U=r&i^r&a^i&a,K=s&o^s&l^o&l;b=m|0,x=y|0,m=h|0,y=p|0,h=f|0,p=d|0,{h:f,l:d}=Xe.add(c|0,u|0,O|0,R|0),c=a|0,u=l|0,a=i|0,l=o|0,i=r|0,o=s|0;const _=Xe.add3L(R,F,K);r=Xe.add3H(_,O,D,U),s=_|0}({h:r,l:s}=Xe.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=Xe.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l}=Xe.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:c,l:u}=Xe.add(this.Dh|0,this.Dl|0,c|0,u|0),{h:f,l:d}=Xe.add(this.Eh|0,this.El|0,f|0,d|0),{h,l:p}=Xe.add(this.Fh|0,this.Fl|0,h|0,p|0),{h:m,l:y}=Xe.add(this.Gh|0,this.Gl|0,m|0,y|0),{h:b,l:x}=Xe.add(this.Hh|0,this.Hl|0,b|0,x|0),this.set(r,s,i,o,a,l,c,u,f,d,h,p,m,y,b,x)}roundClean(){Ao.fill(0),Eo.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const v7=zv(()=>new w7);function x7(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const TR=x7();TR.crypto||TR.msCrypto;function A7(n){switch(n){case"sha256":return vR.create();case"sha512":return v7.create()}V(!1,"invalid hashing algorithm name","algorithm",n)}const[NR,OR,RR]=[[],[],[]],E7=BigInt(0),gd=BigInt(1),k7=BigInt(2),C7=BigInt(7),S7=BigInt(256),T7=BigInt(113);for(let n=0,e=gd,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],NR.push(2*(5*r+t)),OR.push((n+1)*(n+2)/2%64);let s=E7;for(let i=0;i<7;i++)e=(e<<gd^(e>>C7)*T7)%S7,e&k7&&(s^=gd<<(gd<<BigInt(i))-gd);RR.push(s)}const[N7,O7]=AR(RR,!0),MR=(n,e,t)=>t>32?CR(n,e,t):ER(n,e,t),DR=(n,e,t)=>t>32?SR(n,e,t):kR(n,e,t);function R7(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],u=t[l+1],f=MR(c,u,1)^t[a],d=DR(c,u,1)^t[a+1];for(let h=0;h<50;h+=10)n[o+h]^=f,n[o+h+1]^=d}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=OR[o],l=MR(s,i,a),c=DR(s,i,a),u=NR[o];s=n[u],i=n[u+1],n[u]=l,n[u+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=N7[r],n[1]^=O7[r]}t.fill(0)}class $v extends Hv{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rg(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=XW(this.state)}keccak(){R7(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Tc(this);const{blockLen:t,state:r}=this;e=sg(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Tc(this,!1),Fv(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rg(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(mR(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new $v(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const M7=((n,e,t)=>zv(()=>new $v(e,n,t)))(1,136,256/8);let PR=!1;const IR=function(n){return M7(n)};let LR=IR;function Jt(n){const e=lt(n,"data");return we(LR(e))}Jt._=IR,Jt.lock=function(){PR=!0},Jt.register=function(n){if(PR)throw new TypeError("keccak256 is locked");LR=n},Object.freeze(Jt);const _R=function(n){return A7("sha256").update(n).digest()};let BR=_R,FR=!1;function Nc(n){const e=lt(n,"data");return we(BR(e))}Nc._=_R,Nc.lock=function(){FR=!0},Nc.register=function(n){if(FR)throw new Error("sha256 is locked");BR=n},Object.freeze(Nc),Object.freeze(Nc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const jR=BigInt(0),og=BigInt(1),D7=BigInt(2),ag=n=>n instanceof Uint8Array,P7=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function Oc(n){if(!ag(n))throw new Error("Uint8Array expected");let e="";for(let t=0;t<n.length;t++)e+=P7[n[t]];return e}function UR(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Wv(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function Rc(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let r=0;r<t.length;r++){const s=r*2,i=n.slice(s,s+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function Fa(n){return Wv(Oc(n))}function Gv(n){if(!ag(n))throw new Error("Uint8Array expected");return Wv(Oc(Uint8Array.from(n).reverse()))}function Mc(n,e){return Rc(n.toString(16).padStart(e*2,"0"))}function Kv(n,e){return Mc(n,e).reverse()}function I7(n){return Rc(UR(n))}function is(n,e,t){let r;if(typeof e=="string")try{r=Rc(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(ag(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function yd(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!ag(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}function L7(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function _7(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function B7(n){let e;for(e=0;n>jR;n>>=og,e+=1);return e}function F7(n,e){return n>>BigInt(e)&og}const j7=(n,e,t)=>n|(t?og:jR)<<BigInt(e),Jv=n=>(D7<<BigInt(n-1))-og,qv=n=>new Uint8Array(n),HR=n=>Uint8Array.from(n);function zR(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=qv(n),s=qv(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...f)=>t(s,r,...f),l=(f=qv())=>{s=a(HR([0]),f),r=a(),f.length!==0&&(s=a(HR([1]),f),r=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const d=[];for(;f<e;){r=a();const h=r.slice();d.push(h),f+=r.length}return yd(...d)};return(f,d)=>{o(),l(f);let h;for(;!(h=d(c()));)l();return o(),h}}const U7={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function bd(n,e,t={}){const r=(s,i,o)=>{const a=U7[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const H7=Object.freeze(Object.defineProperty({__proto__:null,bitGet:F7,bitLen:B7,bitMask:Jv,bitSet:j7,bytesToHex:Oc,bytesToNumberBE:Fa,bytesToNumberLE:Gv,concatBytes:yd,createHmacDrbg:zR,ensureBytes:is,equalBytes:L7,hexToBytes:Rc,hexToNumber:Wv,numberToBytesBE:Mc,numberToBytesLE:Kv,numberToHexUnpadded:UR,numberToVarBytesBE:I7,utf8ToBytes:_7,validateObject:bd},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cn=BigInt(0),Ht=BigInt(1),ja=BigInt(2),z7=BigInt(3),Qv=BigInt(4),VR=BigInt(5),$R=BigInt(8);BigInt(9),BigInt(16);function Yn(n,e){const t=n%e;return t>=cn?t:e+t}function V7(n,e,t){if(t<=cn||e<cn)throw new Error("Expected power/modulo > 0");if(t===Ht)return cn;let r=Ht;for(;e>cn;)e&Ht&&(r=r*n%t),n=n*n%t,e>>=Ht;return r}function _r(n,e,t){let r=n;for(;e-- >cn;)r*=r,r%=t;return r}function Yv(n,e){if(n===cn||e<=cn)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Yn(n,e),r=e,s=cn,i=Ht;for(;t!==cn;){const a=r/t,l=r%t,c=s-i*a;r=t,t=l,s=i,i=c}if(r!==Ht)throw new Error("invert: does not exist");return Yn(s,e)}function $7(n){const e=(n-Ht)/ja;let t,r,s;for(t=n-Ht,r=0;t%ja===cn;t/=ja,r++);for(s=ja;s<n&&V7(s,e,n)!==n-Ht;s++);if(r===1){const o=(n+Ht)/Qv;return function(l,c){const u=l.pow(c,o);if(!l.eql(l.sqr(u),c))throw new Error("Cannot find square root");return u}}const i=(t+Ht)/ja;return function(a,l){if(a.pow(l,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let c=r,u=a.pow(a.mul(a.ONE,s),t),f=a.pow(l,i),d=a.pow(l,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let h=1;for(let m=a.sqr(d);h<c&&!a.eql(m,a.ONE);h++)m=a.sqr(m);const p=a.pow(u,Ht<<BigInt(c-h-1));u=a.sqr(p),f=a.mul(f,p),d=a.mul(d,u),c=h}return f}}function W7(n){if(n%Qv===z7){const e=(n+Ht)/Qv;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%$R===VR){const e=(n-VR)/$R;return function(r,s){const i=r.mul(s,ja),o=r.pow(i,e),a=r.mul(s,o),l=r.mul(r.mul(a,ja),o),c=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(c),s))throw new Error("Cannot find square root");return c}}return $7(n)}const G7=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function K7(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=G7.reduce((r,s)=>(r[s]="function",r),e);return bd(n,t)}function J7(n,e,t){if(t<cn)throw new Error("Expected power > 0");if(t===cn)return n.ONE;if(t===Ht)return e;let r=n.ONE,s=e;for(;t>cn;)t&Ht&&(r=n.mul(r,s)),s=n.sqr(s),t>>=Ht;return r}function q7(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function WR(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Q7(n,e,t=!1,r={}){if(n<=cn)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=WR(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=W7(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Jv(s),ZERO:cn,ONE:Ht,create:l=>Yn(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return cn<=l&&l<n},is0:l=>l===cn,isOdd:l=>(l&Ht)===Ht,neg:l=>Yn(-l,n),eql:(l,c)=>l===c,sqr:l=>Yn(l*l,n),add:(l,c)=>Yn(l+c,n),sub:(l,c)=>Yn(l-c,n),mul:(l,c)=>Yn(l*c,n),pow:(l,c)=>J7(a,l,c),div:(l,c)=>Yn(l*Yv(c,n),n),sqrN:l=>l*l,addN:(l,c)=>l+c,subN:(l,c)=>l-c,mulN:(l,c)=>l*c,inv:l=>Yv(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>q7(a,l),cmov:(l,c,u)=>u?c:l,toBytes:l=>t?Kv(l,i):Mc(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return t?Gv(l):Fa(l)}});return Object.freeze(a)}function GR(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function KR(n){const e=GR(n);return e+Math.ceil(e/2)}function Y7(n,e,t=!1){const r=n.length,s=GR(e),i=KR(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?Fa(n):Gv(n),a=Yn(o,e-Ht)+Ht;return t?Kv(a,s):Mc(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const X7=BigInt(0),Xv=BigInt(1);function Z7(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>X7;)i&Xv&&(o=o.add(a)),a=a.double(),i>>=Xv;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let c=s,u=c;for(let f=0;f<o;f++){u=c,l.push(u);for(let d=1;d<a;d++)u=u.add(c),l.push(u);c=u.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let c=n.ZERO,u=n.BASE;const f=BigInt(2**s-1),d=2**s,h=BigInt(s);for(let p=0;p<a;p++){const m=p*l;let y=Number(o&f);o>>=h,y>l&&(y-=d,o+=Xv);const b=m,x=m+Math.abs(y)-1,v=p%2!==0,w=y<0;y===0?u=u.add(t(v,i[b])):c=c.add(t(w,i[x]))}return{p:c,f:u}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let c=i.get(s);return c||(c=this.precomputeWindow(s,l),l!==1&&i.set(s,a(c))),this.wNAF(l,c,o)}}}function JR(n){return K7(n.Fp),bd(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...WR(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function eG(n){const e=JR(n);bd(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:tG,hexToBytes:nG}=H7,Ua={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=Ua;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:tG(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=Ua,t=typeof n=="string"?nG(n):n;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=Ua._parseInt(t.subarray(2)),{d:o,l:a}=Ua._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=c=>Number.parseInt(c[0],16)&8?"00"+c:c,t=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),l=t(o);return`30${t(o+i+4)}02${l}${s}02${a}${r}`}},vi=BigInt(0),Br=BigInt(1);BigInt(2);const qR=BigInt(3);BigInt(4);function rG(n){const e=eG(n),{Fp:t}=e,r=e.toBytes||((p,m,y)=>{const b=m.toAffine();return yd(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),s=e.fromBytes||(p=>{const m=p.subarray(1),y=t.fromBytes(m.subarray(0,t.BYTES)),b=t.fromBytes(m.subarray(t.BYTES,2*t.BYTES));return{x:y,y:b}});function i(p){const{a:m,b:y}=e,b=t.sqr(p),x=t.mul(b,p);return t.add(t.add(x,t.mul(p,m)),y)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(p){return typeof p=="bigint"&&vi<p&&p<e.n}function a(p){if(!o(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(p){const{allowedPrivateKeyLengths:m,nByteLength:y,wrapPrivateKey:b,n:x}=e;if(m&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=Oc(p)),typeof p!="string"||!m.includes(p.length))throw new Error("Invalid key");p=p.padStart(y*2,"0")}let v;try{v=typeof p=="bigint"?p:Fa(is("private key",p,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof p}`)}return b&&(v=Yn(v,x)),a(v),v}const c=new Map;function u(p){if(!(p instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(m,y,b){if(this.px=m,this.py=y,this.pz=b,m==null||!t.isValid(m))throw new Error("x required");if(y==null||!t.isValid(y))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required")}static fromAffine(m){const{x:y,y:b}=m||{};if(!m||!t.isValid(y)||!t.isValid(b))throw new Error("invalid affine point");if(m instanceof f)throw new Error("projective point not allowed");const x=v=>t.eql(v,t.ZERO);return x(y)&&x(b)?f.ZERO:new f(y,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const y=t.invertBatch(m.map(b=>b.pz));return m.map((b,x)=>b.toAffine(y[x])).map(f.fromAffine)}static fromHex(m){const y=f.fromAffine(s(is("pointHex",m)));return y.assertValidity(),y}static fromPrivateKey(m){return f.BASE.multiply(l(m))}_setWindowSize(m){this._WINDOW_SIZE=m,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:m,y}=this.toAffine();if(!t.isValid(m)||!t.isValid(y))throw new Error("bad point: x or y not FE");const b=t.sqr(y),x=i(m);if(!t.eql(b,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:m}=this.toAffine();if(t.isOdd)return!t.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){u(m);const{px:y,py:b,pz:x}=this,{px:v,py:w,pz:E}=m,k=t.eql(t.mul(y,E),t.mul(v,x)),S=t.eql(t.mul(b,E),t.mul(w,x));return k&&S}negate(){return new f(this.px,t.neg(this.py),this.pz)}double(){const{a:m,b:y}=e,b=t.mul(y,qR),{px:x,py:v,pz:w}=this;let E=t.ZERO,k=t.ZERO,S=t.ZERO,M=t.mul(x,x),O=t.mul(v,v),R=t.mul(w,w),D=t.mul(x,v);return D=t.add(D,D),S=t.mul(x,w),S=t.add(S,S),E=t.mul(m,S),k=t.mul(b,R),k=t.add(E,k),E=t.sub(O,k),k=t.add(O,k),k=t.mul(E,k),E=t.mul(D,E),S=t.mul(b,S),R=t.mul(m,R),D=t.sub(M,R),D=t.mul(m,D),D=t.add(D,S),S=t.add(M,M),M=t.add(S,M),M=t.add(M,R),M=t.mul(M,D),k=t.add(k,M),R=t.mul(v,w),R=t.add(R,R),M=t.mul(R,D),E=t.sub(E,M),S=t.mul(R,O),S=t.add(S,S),S=t.add(S,S),new f(E,k,S)}add(m){u(m);const{px:y,py:b,pz:x}=this,{px:v,py:w,pz:E}=m;let k=t.ZERO,S=t.ZERO,M=t.ZERO;const O=e.a,R=t.mul(e.b,qR);let D=t.mul(y,v),F=t.mul(b,w),U=t.mul(x,E),K=t.add(y,b),_=t.add(v,w);K=t.mul(K,_),_=t.add(D,F),K=t.sub(K,_),_=t.add(y,x);let G=t.add(v,E);return _=t.mul(_,G),G=t.add(D,U),_=t.sub(_,G),G=t.add(b,x),k=t.add(w,E),G=t.mul(G,k),k=t.add(F,U),G=t.sub(G,k),M=t.mul(O,_),k=t.mul(R,U),M=t.add(k,M),k=t.sub(F,M),M=t.add(F,M),S=t.mul(k,M),F=t.add(D,D),F=t.add(F,D),U=t.mul(O,U),_=t.mul(R,_),F=t.add(F,U),U=t.sub(D,U),U=t.mul(O,U),_=t.add(_,U),D=t.mul(F,_),S=t.add(S,D),D=t.mul(G,_),k=t.mul(K,k),k=t.sub(k,D),D=t.mul(K,F),M=t.mul(G,M),M=t.add(M,D),new f(k,S,M)}subtract(m){return this.add(m.negate())}is0(){return this.equals(f.ZERO)}wNAF(m){return h.wNAFCached(this,c,m,y=>{const b=t.invertBatch(y.map(x=>x.pz));return y.map((x,v)=>x.toAffine(b[v])).map(f.fromAffine)})}multiplyUnsafe(m){const y=f.ZERO;if(m===vi)return y;if(a(m),m===Br)return this;const{endo:b}=e;if(!b)return h.unsafeLadder(this,m);let{k1neg:x,k1:v,k2neg:w,k2:E}=b.splitScalar(m),k=y,S=y,M=this;for(;v>vi||E>vi;)v&Br&&(k=k.add(M)),E&Br&&(S=S.add(M)),M=M.double(),v>>=Br,E>>=Br;return x&&(k=k.negate()),w&&(S=S.negate()),S=new f(t.mul(S.px,b.beta),S.py,S.pz),k.add(S)}multiply(m){a(m);let y=m,b,x;const{endo:v}=e;if(v){const{k1neg:w,k1:E,k2neg:k,k2:S}=v.splitScalar(y);let{p:M,f:O}=this.wNAF(E),{p:R,f:D}=this.wNAF(S);M=h.constTimeNegate(w,M),R=h.constTimeNegate(k,R),R=new f(t.mul(R.px,v.beta),R.py,R.pz),b=M.add(R),x=O.add(D)}else{const{p:w,f:E}=this.wNAF(y);b=w,x=E}return f.normalizeZ([b,x])[0]}multiplyAndAddUnsafe(m,y,b){const x=f.BASE,v=(E,k)=>k===vi||k===Br||!E.equals(x)?E.multiplyUnsafe(k):E.multiply(k),w=v(this,y).add(v(m,b));return w.is0()?void 0:w}toAffine(m){const{px:y,py:b,pz:x}=this,v=this.is0();m==null&&(m=v?t.ONE:t.inv(x));const w=t.mul(y,m),E=t.mul(b,m),k=t.mul(x,m);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(k,t.ONE))throw new Error("invZ was invalid");return{x:w,y:E}}isTorsionFree(){const{h:m,isTorsionFree:y}=e;if(m===Br)return!0;if(y)return y(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:y}=e;return m===Br?this:y?y(f,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return this.assertValidity(),r(f,this,m)}toHex(m=!0){return Oc(this.toRawBytes(m))}}f.BASE=new f(e.Gx,e.Gy,t.ONE),f.ZERO=new f(t.ZERO,t.ONE,t.ZERO);const d=e.nBitLength,h=Z7(f,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function sG(n){const e=JR(n);return bd(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function iG(n){const e=sG(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(_){return vi<_&&_<t.ORDER}function a(_){return Yn(_,r)}function l(_){return Yv(_,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:d}=rG({...e,toBytes(_,G,Y){const re=G.toAffine(),Z=t.toBytes(re.x),me=yd;return Y?me(Uint8Array.from([G.hasEvenY()?2:3]),Z):me(Uint8Array.from([4]),Z,t.toBytes(re.y))},fromBytes(_){const G=_.length,Y=_[0],re=_.subarray(1);if(G===s&&(Y===2||Y===3)){const Z=Fa(re);if(!o(Z))throw new Error("Point is not on curve");const me=f(Z);let ke=t.sqrt(me);const Pe=(ke&Br)===Br;return(Y&1)===1!==Pe&&(ke=t.neg(ke)),{x:Z,y:ke}}else if(G===i&&Y===4){const Z=t.fromBytes(re.subarray(0,t.BYTES)),me=t.fromBytes(re.subarray(t.BYTES,2*t.BYTES));return{x:Z,y:me}}else throw new Error(`Point of length ${G} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),h=_=>Oc(Mc(_,e.nByteLength));function p(_){const G=r>>Br;return _>G}function m(_){return p(_)?a(-_):_}const y=(_,G,Y)=>Fa(_.slice(G,Y));class b{constructor(G,Y,re){this.r=G,this.s=Y,this.recovery=re,this.assertValidity()}static fromCompact(G){const Y=e.nByteLength;return G=is("compactSignature",G,Y*2),new b(y(G,0,Y),y(G,Y,2*Y))}static fromDER(G){const{r:Y,s:re}=Ua.toSig(is("DER",G));return new b(Y,re)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(G){return new b(this.r,this.s,G)}recoverPublicKey(G){const{r:Y,s:re,recovery:Z}=this,me=S(is("msgHash",G));if(Z==null||![0,1,2,3].includes(Z))throw new Error("recovery id invalid");const ke=Z===2||Z===3?Y+e.n:Y;if(ke>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const Pe=Z&1?"03":"02",Ce=c.fromHex(Pe+h(ke)),Ee=l(ke),Ue=a(-me*Ee),Fe=a(re*Ee),He=c.BASE.multiplyAndAddUnsafe(Ce,Ue,Fe);if(!He)throw new Error("point at infinify");return He.assertValidity(),He}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Rc(this.toDERHex())}toDERHex(){return Ua.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rc(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const x={isValidPrivateKey(_){try{return u(_),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const _=KR(e.n);return Y7(e.randomBytes(_),e.n)},precompute(_=8,G=c.BASE){return G._setWindowSize(_),G.multiply(BigInt(3)),G}};function v(_,G=!0){return c.fromPrivateKey(_).toRawBytes(G)}function w(_){const G=_ instanceof Uint8Array,Y=typeof _=="string",re=(G||Y)&&_.length;return G?re===s||re===i:Y?re===2*s||re===2*i:_ instanceof c}function E(_,G,Y=!0){if(w(_))throw new Error("first arg must be private key");if(!w(G))throw new Error("second arg must be public key");return c.fromHex(G).multiply(u(_)).toRawBytes(Y)}const k=e.bits2int||function(_){const G=Fa(_),Y=_.length*8-e.nBitLength;return Y>0?G>>BigInt(Y):G},S=e.bits2int_modN||function(_){return a(k(_))},M=Jv(e.nBitLength);function O(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(vi<=_&&_<M))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Mc(_,e.nByteLength)}function R(_,G,Y=D){if(["recovered","canonical"].some(Ze=>Ze in Y))throw new Error("sign() legacy options not supported");const{hash:re,randomBytes:Z}=e;let{lowS:me,prehash:ke,extraEntropy:Pe}=Y;me==null&&(me=!0),_=is("msgHash",_),ke&&(_=is("prehashed msgHash",re(_)));const Ce=S(_),Ee=u(G),Ue=[O(Ee),O(Ce)];if(Pe!=null){const Ze=Pe===!0?Z(t.BYTES):Pe;Ue.push(is("extraEntropy",Ze))}const Fe=yd(...Ue),He=Ce;function Le(Ze){const le=k(Ze);if(!d(le))return;const ze=l(le),ae=c.BASE.multiply(le).toAffine(),be=a(ae.x);if(be===vi)return;const _e=a(ze*a(He+be*Ee));if(_e===vi)return;let z=(ae.x===be?0:2)|Number(ae.y&Br),J=_e;return me&&p(_e)&&(J=m(_e),z^=1),new b(be,J,z)}return{seed:Fe,k2sig:Le}}const D={lowS:e.lowS,prehash:!1},F={lowS:e.lowS,prehash:!1};function U(_,G,Y=D){const{seed:re,k2sig:Z}=R(_,G,Y),me=e;return zR(me.hash.outputLen,me.nByteLength,me.hmac)(re,Z)}c.BASE._setWindowSize(8);function K(_,G,Y,re=F){var ae;const Z=_;if(G=is("msgHash",G),Y=is("publicKey",Y),"strict"in re)throw new Error("options.strict was renamed to lowS");const{lowS:me,prehash:ke}=re;let Pe,Ce;try{if(typeof Z=="string"||Z instanceof Uint8Array)try{Pe=b.fromDER(Z)}catch(be){if(!(be instanceof Ua.Err))throw be;Pe=b.fromCompact(Z)}else if(typeof Z=="object"&&typeof Z.r=="bigint"&&typeof Z.s=="bigint"){const{r:be,s:_e}=Z;Pe=new b(be,_e)}else throw new Error("PARSE");Ce=c.fromHex(Y)}catch(be){if(be.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(me&&Pe.hasHighS())return!1;ke&&(G=e.hash(G));const{r:Ee,s:Ue}=Pe,Fe=S(G),He=l(Ue),Le=a(Fe*He),Ze=a(Ee*He),le=(ae=c.BASE.multiplyAndAddUnsafe(Ce,Le,Ze))==null?void 0:ae.toAffine();return le?a(le.x)===Ee:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:E,sign:U,verify:K,ProjectivePoint:c,Signature:b,utils:x}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function oG(n){return{hash:n,hmac:(e,...t)=>bR(n,e,e7(...t)),randomBytes:t7}}function aG(n,e){const t=r=>iG({...n,...oG(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const QR=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),YR=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lG=BigInt(1),Zv=BigInt(2),XR=(n,e)=>(n+e/Zv)/e;function cG(n){const e=QR,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=n*n*n%e,u=c*c*n%e,f=_r(u,t,e)*u%e,d=_r(f,t,e)*u%e,h=_r(d,Zv,e)*c%e,p=_r(h,s,e)*h%e,m=_r(p,i,e)*p%e,y=_r(m,a,e)*m%e,b=_r(y,l,e)*y%e,x=_r(b,a,e)*m%e,v=_r(x,t,e)*u%e,w=_r(v,o,e)*p%e,E=_r(w,r,e)*c%e,k=_r(E,Zv,e);if(!e1.eql(e1.sqr(k),n))throw new Error("Cannot find square root");return k}const e1=Q7(QR,void 0,void 0,{sqrt:cG}),ko=aG({a:BigInt(0),b:BigInt(7),Fp:e1,n:YR,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=YR,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-lG*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=XR(i*n,e),l=XR(-r*n,e);let c=Yn(n-a*t-l*s,e),u=Yn(-a*r-l*i,e);const f=c>o,d=u>o;if(f&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:f,k1:c,k2neg:d,k2:u}}}},vR);BigInt(0),ko.ProjectivePoint;const wd="0x0000000000000000000000000000000000000000",ZR="0x0000000000000000000000000000000000000000000000000000000000000000",eM=BigInt(0),tM=BigInt(1),nM=BigInt(2),rM=BigInt(27),sM=BigInt(28),lg=BigInt(35),Dc={};function iM(n){return Ia(In(n),32)}const ds=class ds{constructor(e,t,r,s){q(this,Zc);q(this,eu);q(this,tu);q(this,il);Qm(e,Dc,"Signature"),I(this,Zc,t),I(this,eu,r),I(this,tu,s),I(this,il,null)}get r(){return T(this,Zc)}set r(e){V(Ec(e)===32,"invalid r","value",e),I(this,Zc,we(e))}get s(){return T(this,eu)}set s(e){V(Ec(e)===32,"invalid s","value",e);const t=we(e);V(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),I(this,eu,t)}get v(){return T(this,tu)}set v(e){const t=Je(e,"value");V(t===27||t===28,"invalid v","v",e),I(this,tu,t)}get networkV(){return T(this,il)}get legacyChainId(){const e=this.networkV;return e==null?null:ds.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=lt(this.s);return this.yParity&&(e[0]|=128),we(e)}get compactSerialized(){return Ut([this.r,this.yParityAndS])}get serialized(){return Ut([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new ds(Dc,this.r,this.s,this.v);return this.networkV&&I(e,il,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=Ae(e,"v");return t==rM||t==sM?eM:(V(t>=lg,"invalid EIP-155 v","v",e),(t-lg)/nM)}static getChainIdV(e,t){return Ae(e)*nM+BigInt(35+t-27)}static getNormalizedV(e){const t=Ae(e);return t===eM||t===rM?27:t===tM||t===sM?28:(V(t>=lg,"invalid v","v",e),t&tM?27:28)}static from(e){function t(c,u){V(c,u,"signature",e)}if(e==null)return new ds(Dc,ZR,ZR,27);if(typeof e=="string"){const c=lt(e,"signature");if(c.length===64){const u=we(c.slice(0,32)),f=c.slice(32,64),d=f[0]&128?28:27;return f[0]&=127,new ds(Dc,u,we(f),d)}if(c.length===65){const u=we(c.slice(0,32)),f=c.slice(32,64);t((f[0]&128)===0,"non-canonical s");const d=ds.getNormalizedV(c[64]);return new ds(Dc,u,we(f),d)}t(!1,"invalid raw signature length")}if(e instanceof ds)return e.clone();const r=e.r;t(r!=null,"missing r");const s=iM(r),i=function(c,u){if(c!=null)return iM(c);if(u!=null){t(At(u,32),"invalid yParityAndS");const f=lt(u);return f[0]&=127,we(f)}t(!1,"missing s")}(e.s,e.yParityAndS);t((lt(i)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(c,u,f){if(c!=null){const d=Ae(c);return{networkV:d>=lg?d:void 0,v:ds.getNormalizedV(d)}}if(u!=null)return t(At(u,32),"invalid yParityAndS"),{v:lt(u)[0]&128?28:27};if(f!=null){switch(Je(f,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new ds(Dc,s,i,a);return o&&I(l,il,o),t(e.yParity==null||Je(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};Zc=new WeakMap,eu=new WeakMap,tu=new WeakMap,il=new WeakMap;let as=ds;const ol=class ol{constructor(e){q(this,Ri);V(Ec(e)===32,"invalid private key","privateKey","[REDACTED]"),I(this,Ri,we(e))}get privateKey(){return T(this,Ri)}get publicKey(){return ol.computePublicKey(T(this,Ri))}get compressedPublicKey(){return ol.computePublicKey(T(this,Ri),!0)}sign(e){V(Ec(e)===32,"invalid digest length","digest",e);const t=ko.sign(Pn(e),Pn(T(this,Ri)),{lowS:!0});return as.from({r:bo(t.r,32),s:bo(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=ol.computePublicKey(e);return we(ko.getSharedSecret(Pn(T(this,Ri)),lt(t),!1))}static computePublicKey(e,t){let r=lt(e,"key");if(r.length===32){const i=ko.getPublicKey(r,!!t);return we(i)}if(r.length===64){const i=new Uint8Array(65);i[0]=4,i.set(r,1),r=i}const s=ko.ProjectivePoint.fromHex(r);return we(s.toRawBytes(t))}static recoverPublicKey(e,t){V(Ec(e)===32,"invalid digest length","digest",e);const r=as.from(t);let s=ko.Signature.fromCompact(Pn(Ut([r.r,r.s])));s=s.addRecoveryBit(r.yParity);const i=s.recoverPublicKey(Pn(e));return V(i!=null,"invalid signautre for digest","signature",t),"0x"+i.toHex(!1)}static addPoints(e,t,r){const s=ko.ProjectivePoint.fromHex(ol.computePublicKey(e).substring(2)),i=ko.ProjectivePoint.fromHex(ol.computePublicKey(t).substring(2));return"0x"+s.add(i).toHex(!!r)}};Ri=new WeakMap;let vd=ol;const uG=BigInt(0),fG=BigInt(36);function oM(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=lt(Jt(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const t1={};for(let n=0;n<10;n++)t1[String(n)]=String(n);for(let n=0;n<26;n++)t1[String.fromCharCode(65+n)]=String(10+n);const aM=15;function dG(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>t1[r]).join("");for(;e.length>=aM;){let r=e.substring(0,aM);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const hG=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function pG(n){n=n.toLowerCase();let e=uG;for(let t=0;t<n.length;t++)e=e*fG+hG[n[t]];return e}function dt(n){if(V(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=oM(n);return V(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){V(n.substring(2,4)===dG(n),"bad icap checksum","address",n);let e=pG(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return oM("0x"+e)}V(!1,"invalid address","address",n)}function mG(n){const e=dt(n.from);let r=Ae(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,dt(Ft(Jt(_a([e,r])),12))}function lM(n){return n&&typeof n.getAddress=="function"}function gG(n){try{return dt(n),!0}catch{}return!1}async function n1(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(ee(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),V(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),dt(t)}function Bn(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?dt(n):(ee(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),n1(n,e.resolveName(n)));if(lM(n))return n1(n,n.getAddress());if(n&&typeof n.then=="function")return n1(n,n);V(!1,"unsupported addressable value","target",n)}const xi={};function ve(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new En(xi,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function ut(n,e){return new En(xi,`bytes${e||""}`,n,{size:e})}const cM=Symbol.for("_ethers_typed"),Mi=class Mi{constructor(e,t,r,s){$(this,"type");$(this,"value");q(this,al);$(this,"_typedSymbol");s==null&&(s=null),Qm(xi,e,"Typed"),Oe(this,{_typedSymbol:cM,type:t,value:r}),I(this,al,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return T(this,al)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,al)===!0?-1:T(this,al)===!1?this.value.length:null}static from(e,t){return new Mi(xi,e,t)}static uint8(e){return ve(e,8)}static uint16(e){return ve(e,16)}static uint24(e){return ve(e,24)}static uint32(e){return ve(e,32)}static uint40(e){return ve(e,40)}static uint48(e){return ve(e,48)}static uint56(e){return ve(e,56)}static uint64(e){return ve(e,64)}static uint72(e){return ve(e,72)}static uint80(e){return ve(e,80)}static uint88(e){return ve(e,88)}static uint96(e){return ve(e,96)}static uint104(e){return ve(e,104)}static uint112(e){return ve(e,112)}static uint120(e){return ve(e,120)}static uint128(e){return ve(e,128)}static uint136(e){return ve(e,136)}static uint144(e){return ve(e,144)}static uint152(e){return ve(e,152)}static uint160(e){return ve(e,160)}static uint168(e){return ve(e,168)}static uint176(e){return ve(e,176)}static uint184(e){return ve(e,184)}static uint192(e){return ve(e,192)}static uint200(e){return ve(e,200)}static uint208(e){return ve(e,208)}static uint216(e){return ve(e,216)}static uint224(e){return ve(e,224)}static uint232(e){return ve(e,232)}static uint240(e){return ve(e,240)}static uint248(e){return ve(e,248)}static uint256(e){return ve(e,256)}static uint(e){return ve(e,256)}static int8(e){return ve(e,-8)}static int16(e){return ve(e,-16)}static int24(e){return ve(e,-24)}static int32(e){return ve(e,-32)}static int40(e){return ve(e,-40)}static int48(e){return ve(e,-48)}static int56(e){return ve(e,-56)}static int64(e){return ve(e,-64)}static int72(e){return ve(e,-72)}static int80(e){return ve(e,-80)}static int88(e){return ve(e,-88)}static int96(e){return ve(e,-96)}static int104(e){return ve(e,-104)}static int112(e){return ve(e,-112)}static int120(e){return ve(e,-120)}static int128(e){return ve(e,-128)}static int136(e){return ve(e,-136)}static int144(e){return ve(e,-144)}static int152(e){return ve(e,-152)}static int160(e){return ve(e,-160)}static int168(e){return ve(e,-168)}static int176(e){return ve(e,-176)}static int184(e){return ve(e,-184)}static int192(e){return ve(e,-192)}static int200(e){return ve(e,-200)}static int208(e){return ve(e,-208)}static int216(e){return ve(e,-216)}static int224(e){return ve(e,-224)}static int232(e){return ve(e,-232)}static int240(e){return ve(e,-240)}static int248(e){return ve(e,-248)}static int256(e){return ve(e,-256)}static int(e){return ve(e,-256)}static bytes1(e){return ut(e,1)}static bytes2(e){return ut(e,2)}static bytes3(e){return ut(e,3)}static bytes4(e){return ut(e,4)}static bytes5(e){return ut(e,5)}static bytes6(e){return ut(e,6)}static bytes7(e){return ut(e,7)}static bytes8(e){return ut(e,8)}static bytes9(e){return ut(e,9)}static bytes10(e){return ut(e,10)}static bytes11(e){return ut(e,11)}static bytes12(e){return ut(e,12)}static bytes13(e){return ut(e,13)}static bytes14(e){return ut(e,14)}static bytes15(e){return ut(e,15)}static bytes16(e){return ut(e,16)}static bytes17(e){return ut(e,17)}static bytes18(e){return ut(e,18)}static bytes19(e){return ut(e,19)}static bytes20(e){return ut(e,20)}static bytes21(e){return ut(e,21)}static bytes22(e){return ut(e,22)}static bytes23(e){return ut(e,23)}static bytes24(e){return ut(e,24)}static bytes25(e){return ut(e,25)}static bytes26(e){return ut(e,26)}static bytes27(e){return ut(e,27)}static bytes28(e){return ut(e,28)}static bytes29(e){return ut(e,29)}static bytes30(e){return ut(e,30)}static bytes31(e){return ut(e,31)}static bytes32(e){return ut(e,32)}static address(e){return new Mi(xi,"address",e)}static bool(e){return new Mi(xi,"bool",!!e)}static bytes(e){return new Mi(xi,"bytes",e)}static string(e){return new Mi(xi,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Mi(xi,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===cM}static dereference(e,t){if(Mi.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};al=new WeakMap;let En=Mi;class yG extends wi{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=En.dereference(t,"string");try{r=dt(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return dt(bo(e.readValue(),20))}}class bG extends wi{constructor(t){super(t.name,t.type,"_",t.dynamic);$(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function uM(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let l={};r=e.map(c=>{const u=c.localName;return ee(u,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),ee(!l[u],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),l[u]=!0,t[u]})}else V(!1,"invalid tuple value","tuple",t);V(e.length===r.length,"types/value length mismatch","tuple",t);let s=new _v,i=new _v,o=[];e.forEach((l,c)=>{let u=r[c];if(l.dynamic){let f=i.length;l.encode(i,u);let d=s.writeUpdatableValue();o.push(h=>{d(h+f)})}else l.encode(s,u)}),o.forEach(l=>{l(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function fM(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),l=s.subReader(a);try{o=i.decode(l)}catch(c){if(ln(c,"BUFFER_OVERRUN"))throw c;o=c,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(ln(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),Sc.fromItems(t,r)}class wG extends wi{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);$(this,"coder");$(this,"length");Oe(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=En.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),$O(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return uM(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),ee(r*_n<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*_n,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new bG(this.coder));return fM(t,s)}}class vG extends wi{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=En.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class dM extends wi{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Pn(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class xG extends dM{constructor(e){super("bytes",e)}decode(e){return we(super.decode(e))}}class AG extends wi{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);$(this,"size");Oe(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Pn(En.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return we(t.readBytes(this.size))}}const EG=new Uint8Array([]);class kG extends wi{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(EG)}decode(e){return e.readBytes(0),null}}const CG=BigInt(0),SG=BigInt(1),TG=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class NG extends wi{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);$(this,"size");$(this,"signed");Oe(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=Ae(En.dereference(r,this.type)),i=pd(TG,_n*8);if(this.signed){let o=pd(i,this.size*8-1);(s>o||s<-(o+SG))&&this._throwError("value out-of-bounds",r),s=JO(s,8*_n)}else(s<CG||s>pd(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=pd(t.readValue(),this.size*8);return this.signed&&(r=DW(r,this.size*8)),r}}class OG extends dM{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,bi(En.dereference(t,"string")))}decode(e){return Cc(super.decode(e))}}class cg extends wi{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);$(this,"coders");Oe(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=En.dereference(r,"tuple");return uM(t,this.coders,s)}decode(t){return fM(t,this.coders)}}function Ha(n){return Jt(bi(n))}var RG="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";const hM=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),pM=4;function MG(n){let e=0;function t(){return n[e++]<<8|n[e++]}let r=t(),s=1,i=[0,1];for(let E=1;E<r;E++)i.push(s+=t());let o=t(),a=e;e+=o;let l=0,c=0;function u(){return l==0&&(c=c<<8|n[e++],l=8),c>>--l&1}const f=31,d=2**f,h=d>>>1,p=h>>1,m=d-1;let y=0;for(let E=0;E<f;E++)y=y<<1|u();let b=[],x=0,v=d;for(;;){let E=Math.floor(((y-x+1)*s-1)/v),k=0,S=r;for(;S-k>1;){let R=k+S>>>1;E<i[R]?S=R:k=R}if(k==0)break;b.push(k);let M=x+Math.floor(v*i[k]/s),O=x+Math.floor(v*i[k+1]/s)-1;for(;!((M^O)&h);)y=y<<1&m|u(),M=M<<1&m,O=O<<1&m|1;for(;M&~O&p;)y=y&h|y<<1&m>>>1|u(),M=M<<1^h,O=(O^h)<<1|h|1;x=M,v=1+O-M}let w=r-4;return b.map(E=>{switch(E-w){case 3:return w+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return w+256+(n[a++]<<8|n[a++]);case 1:return w+n[a++];default:return E-1}})}function DG(n){let e=0;return()=>n[e++]}function mM(n){return DG(MG(PG(n)))}function PG(n){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,i)=>e[s.charCodeAt(0)]=i);let t=n.length,r=new Uint8Array(6*t>>3);for(let s=0,i=0,o=0,a=0;s<t;s++)a=a<<6|e[n.charCodeAt(s)],o+=6,o>=8&&(r[i++]=a>>(o-=8));return r}function IG(n){return n&1?~n>>1:n>>1}function LG(n,e){let t=Array(n);for(let r=0,s=0;r<n;r++)t[r]=s+=IG(e());return t}function xd(n,e=0){let t=[];for(;;){let r=n(),s=n();if(!s)break;e+=r;for(let i=0;i<s;i++)t.push(e+i);e+=s+1}return t}function gM(n){return Ad(()=>{let e=xd(n);if(e.length)return e})}function yM(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(_G(t,n))}for(;;){let t=n()-1;if(t<0)break;e.push(BG(t,n))}return e.flat()}function Ad(n){let e=[];for(;;){let t=n(e.length);if(!t)break;e.push(t)}return e}function bM(n,e,t){let r=Array(n).fill().map(()=>[]);for(let s=0;s<e;s++)LG(n,t).forEach((i,o)=>r[o].push(i));return r}function _G(n,e){let t=1+e(),r=e(),s=Ad(e);return bM(s.length,1+n,e).flatMap((o,a)=>{let[l,...c]=o;return Array(s[a]).fill().map((u,f)=>{let d=f*r;return[l+f*t,c.map(h=>h+d)]})})}function BG(n,e){let t=1+e();return bM(t,1+n,e).map(s=>[s[0],s.slice(1)])}function FG(n){let e=[],t=xd(n);return s(r([]),[]),e;function r(i){let o=n(),a=Ad(()=>{let l=xd(n).map(c=>t[c]);if(l.length)return r(l)});return{S:o,B:a,Q:i}}function s({S:i,B:o},a,l){if(!(i&4&&l===a[a.length-1])){i&2&&(l=a[a.length-1]),i&1&&e.push(a);for(let c of o)for(let u of c.Q)s(c,[...a,u],l)}}}function jG(n){return n.toString(16).toUpperCase().padStart(2,"0")}function wM(n){return`{${jG(n)}}`}function UG(n){let e=[];for(let t=0,r=n.length;t<r;){let s=n.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function Pc(n){let t=n.length;if(t<4096)return String.fromCodePoint(...n);let r=[];for(let s=0;s<t;)r.push(String.fromCodePoint(...n.slice(s,s+=4096)));return r.join("")}function HG(n,e){let t=n.length,r=t-e.length;for(let s=0;r==0&&s<t;s++)r=n[s]-e[s];return r}var zG="AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g";const Ed=44032,ug=4352,fg=4449,dg=4519,vM=19,xM=21,Ic=28,hg=xM*Ic,VG=vM*hg,$G=Ed+VG,WG=ug+vM,GG=fg+xM,KG=dg+Ic;function kd(n){return n>>24&255}function AM(n){return n&16777215}let r1,EM,s1,pg;function JG(){let n=mM(zG);r1=new Map(gM(n).flatMap((e,t)=>e.map(r=>[r,t+1<<24]))),EM=new Set(xd(n)),s1=new Map,pg=new Map;for(let[e,t]of yM(n)){if(!EM.has(e)&&t.length==2){let[r,s]=t,i=pg.get(r);i||(i=new Map,pg.set(r,i)),i.set(s,e)}s1.set(e,t.reverse())}}function kM(n){return n>=Ed&&n<$G}function qG(n,e){if(n>=ug&&n<WG&&e>=fg&&e<GG)return Ed+(n-ug)*hg+(e-fg)*Ic;if(kM(n)&&e>dg&&e<KG&&(n-Ed)%Ic==0)return n+(e-dg);{let t=pg.get(n);return t&&(t=t.get(e),t)?t:-1}}function CM(n){r1||JG();let e=[],t=[],r=!1;function s(i){let o=r1.get(i);o&&(r=!0,i|=o),e.push(i)}for(let i of n)for(;;){if(i<128)e.push(i);else if(kM(i)){let o=i-Ed,a=o/hg|0,l=o%hg/Ic|0,c=o%Ic;s(ug+a),s(fg+l),c>0&&s(dg+c)}else{let o=s1.get(i);o?t.push(...o):s(i)}if(!t.length)break;i=t.pop()}if(r&&e.length>1){let i=kd(e[0]);for(let o=1;o<e.length;o++){let a=kd(e[o]);if(a==0||i<=a){i=a;continue}let l=o-1;for(;;){let c=e[l+1];if(e[l+1]=e[l],e[l]=c,!l||(i=kd(e[--l]),i<=a))break}i=kd(e[o])}}return e}function QG(n){let e=[],t=[],r=-1,s=0;for(let i of n){let o=kd(i),a=AM(i);if(r==-1)o==0?r=a:e.push(a);else if(s>0&&s>=o)o==0?(e.push(r,...t),t.length=0,r=a):t.push(a),s=o;else{let l=qG(r,a);l>=0?r=l:s==0&&o==0?(e.push(r),r=a):(t.push(a),s=o)}}return r>=0&&e.push(r,...t),e}function SM(n){return CM(n).map(AM)}function YG(n){return QG(CM(n))}const TM=45,NM=".",OM=65039,RM=1,mg=n=>Array.from(n);function Cd(n,e){return n.P.has(e)||n.Q.has(e)}class XG extends Array{get is_emoji(){return!0}}let i1,MM,za,o1,DM,Lc,a1,_c,Va,PM,l1;function c1(){if(i1)return;let n=mM(RG);const e=()=>xd(n),t=()=>new Set(e()),r=(u,f)=>f.forEach(d=>u.add(d));i1=new Map(yM(n)),MM=t(),za=e(),o1=new Set(e().map(u=>za[u])),za=new Set(za),DM=t(),t();let s=gM(n),i=n();const o=()=>{let u=new Set;return e().forEach(f=>r(u,s[f])),r(u,e()),u};Lc=Ad(u=>{let f=Ad(n).map(d=>d+96);if(f.length){let d=u>=i;f[0]-=32,f=Pc(f),d&&(f=`Restricted[${f}]`);let h=o(),p=o(),m=!n();return{N:f,P:h,Q:p,M:m,R:d}}}),a1=t(),_c=new Map;let a=e().concat(mg(a1)).sort((u,f)=>u-f);a.forEach((u,f)=>{let d=n(),h=a[f]=d?a[f-d]:{V:[],M:new Map};h.V.push(u),a1.has(u)||_c.set(u,h)});for(let{V:u,M:f}of new Set(_c.values())){let d=[];for(let p of u){let m=Lc.filter(b=>Cd(b,p)),y=d.find(({G:b})=>m.some(x=>b.has(x)));y||(y={G:new Set,V:[]},d.push(y)),y.V.push(p),r(y.G,m)}let h=d.flatMap(p=>mg(p.G));for(let{G:p,V:m}of d){let y=new Set(h.filter(b=>!p.has(b)));for(let b of m)f.set(b,y)}}Va=new Set;let l=new Set;const c=u=>Va.has(u)?l.add(u):Va.add(u);for(let u of Lc){for(let f of u.P)c(f);for(let f of u.Q)c(f)}for(let u of Va)!_c.has(u)&&!l.has(u)&&_c.set(u,RM);r(Va,SM(Va)),PM=FG(n).map(u=>XG.from(u)).sort(HG),l1=new Map;for(let u of PM){let f=[l1];for(let d of u){let h=f.map(p=>{let m=p.get(d);return m||(m=new Map,p.set(d,m)),m});d===OM?f.push(...h):f=h}for(let d of f)d.V=u}}function u1(n){return(IM(n)?"":`${f1(gg([n]))} `)+wM(n)}function f1(n){return`"${n}"‎`}function ZG(n){if(n.length>=4&&n[2]==TM&&n[3]==TM)throw new Error(`invalid label extension: "${Pc(n.slice(0,4))}"`)}function eK(n){for(let t=n.lastIndexOf(95);t>0;)if(n[--t]!==95)throw new Error("underscore allowed only at start")}function tK(n){let e=n[0],t=hM.get(e);if(t)throw Sd(`leading ${t}`);let r=n.length,s=-1;for(let i=1;i<r;i++){e=n[i];let o=hM.get(e);if(o){if(s==i)throw Sd(`${t} + ${o}`);s=i+1,t=o}}if(s==r)throw Sd(`trailing ${t}`)}function gg(n,e=1/0,t=wM){let r=[];nK(n[0])&&r.push("◌"),n.length>e&&(e>>=1,n=[...n.slice(0,e),8230,...n.slice(-e)]);let s=0,i=n.length;for(let o=0;o<i;o++){let a=n[o];IM(a)&&(r.push(Pc(n.slice(s,o))),r.push(t(a)),s=o+1)}return r.push(Pc(n.slice(s,i))),r.join("")}function nK(n){return c1(),za.has(n)}function IM(n){return c1(),DM.has(n)}function rK(n){return aK(sK(n,YG,uK))}function sK(n,e,t){if(!n)return[];c1();let r=0;return n.split(NM).map(s=>{let i=UG(s),o={input:i,offset:r};r+=i.length+1;try{let a=o.tokens=cK(i,e,t),l=a.length,c;if(!l)throw new Error("empty label");let u=o.output=a.flat();if(eK(u),!(o.emoji=l>1||a[0].is_emoji)&&u.every(d=>d<128))ZG(u),c="ASCII";else{let d=a.flatMap(h=>h.is_emoji?[]:h);if(!d.length)c="Emoji";else{if(za.has(u[0]))throw Sd("leading combining mark");for(let m=1;m<l;m++){let y=a[m];if(!y.is_emoji&&za.has(y[0]))throw Sd(`emoji + combining mark: "${Pc(a[m-1])} + ${gg([y[0]])}"`)}tK(u);let h=mg(new Set(d)),[p]=oK(h);lK(p,d),iK(p,h),c=p.N}}o.type=c}catch(a){o.error=a}return o})}function iK(n,e){let t,r=[];for(let s of e){let i=_c.get(s);if(i===RM)return;if(i){let o=i.M.get(s);if(t=t?t.filter(a=>o.has(a)):mg(o),!t.length)return}else r.push(s)}if(t){for(let s of t)if(r.every(i=>Cd(s,i)))throw new Error(`whole-script confusable: ${n.N}/${s.N}`)}}function oK(n){let e=Lc;for(let t of n){let r=e.filter(s=>Cd(s,t));if(!r.length)throw Lc.some(s=>Cd(s,t))?_M(e[0],t):LM(t);if(e=r,r.length==1)break}return e}function aK(n){return n.map(({input:e,error:t,output:r})=>{if(t){let s=t.message;throw new Error(n.length==1?s:`Invalid label ${f1(gg(e,63))}: ${s}`)}return Pc(r)}).join(NM)}function LM(n){return new Error(`disallowed character: ${u1(n)}`)}function _M(n,e){let t=u1(e),r=Lc.find(s=>s.P.has(e));return r&&(t=`${r.N} ${t}`),new Error(`illegal mixture: ${n.N} + ${t}`)}function Sd(n){return new Error(`illegal placement: ${n}`)}function lK(n,e){for(let t of e)if(!Cd(n,t))throw _M(n,t);if(n.M){let t=SM(e);for(let r=1,s=t.length;r<s;r++)if(o1.has(t[r])){let i=r+1;for(let o;i<s&&o1.has(o=t[i]);i++)for(let a=r;a<i;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${u1(o)}`);if(i-r>pM)throw new Error(`excessive non-spacing marks: ${f1(gg(t.slice(r-1,i)))} (${i-r}/${pM})`);r=i}}}function cK(n,e,t){let r=[],s=[];for(n=n.slice().reverse();n.length;){let i=fK(n);if(i)s.length&&(r.push(e(s)),s=[]),r.push(t(i));else{let o=n.pop();if(Va.has(o))s.push(o);else{let a=i1.get(o);if(a)s.push(...a);else if(!MM.has(o))throw LM(o)}}}return s.length&&r.push(e(s)),r}function uK(n){return n.filter(e=>e!=OM)}function fK(n,e){let t=l1,r,s=n.length;for(;s&&(t=t.get(n[--s]),!!t);){let{V:i}=t;i&&(r=i,n.length=s)}return r}const BM=new Uint8Array(32);BM.fill(0);function FM(n){return V(n.length!==0,"invalid ENS name; empty component","comp",n),n}function jM(n){const e=bi(dK(n)),t=[];if(n.length===0)return t;let r=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(FM(e.slice(r,s))),r=s+1);return V(r<e.length,"invalid ENS name; empty component","name",n),t.push(FM(e.slice(r))),t}function dK(n){try{if(n.length===0)throw new Error("empty label");return rK(n)}catch(e){V(!1,`invalid ENS name (${e.message})`,"name",n)}}function d1(n){V(typeof n=="string","invalid ENS name; not a string","name",n),V(n.length,"invalid ENS name (empty label)","name",n);let e=BM;const t=jM(n);for(;t.length;)e=Jt(Ut([e,Jt(t.pop())]));return we(e)}function hK(n,e){const t=e;return V(t<=255,"DNS encoded label cannot exceed 255","length",t),we(Ut(jM(n).map(r=>{V(r.length<=t,`label ${JSON.stringify(n)} exceeds ${t} bytes`,"name",n);const s=new Uint8Array(r.length+1);return s.set(r,1),s[0]=s.length-1,s})))+"00"}function h1(n,e){return{address:dt(n),storageKeys:e.map((t,r)=>(V(At(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function Co(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(V(t.length===2,"invalid slot set",`value[${r}]`,t),h1(t[0],t[1])):(V(t!=null&&typeof t=="object","invalid address-slot set","value",n),h1(t.address,t.storageKeys)));V(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return h1(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function pK(n){let e;return typeof n=="string"?e=vd.computePublicKey(n,!1):e=n.publicKey,dt(Jt("0x"+e.substring(4)).substring(26))}function mK(n,e){return pK(vd.recoverPublicKey(n,e))}const un=BigInt(0),gK=BigInt(2),yK=BigInt(27),bK=BigInt(28),wK=BigInt(35),vK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),p1=4096*32;function UM(n,e){let t=n.toString(16);for(;t.length<2;)t="0"+t;return t+=Nc(e).substring(4),"0x"+t}function yg(n){return n==="0x"?null:dt(n)}function m1(n,e){try{return Co(n)}catch(t){V(!1,t.message,e,n)}}function Td(n,e){return n==="0x"?0:Je(n,e)}function zt(n,e){if(n==="0x")return un;const t=Ae(n,e);return V(t<=vK,"value exceeds uint size",e,t),t}function Ct(n,e){const t=Ae(n,"value"),r=In(t);return V(r.length<=32,"value too large",`tx.${e}`,t),r}function g1(n){return Co(n).map(e=>[e.address,e.storageKeys])}function xK(n,e){V(Array.isArray(n),`invalid ${e}`,"value",n);for(let t=0;t<n.length;t++)V(At(n[t],32),"invalid ${ param } hash",`value[${t}]`,n[t]);return n}function AK(n){const e=tg(n);V(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",n);const t={type:0,nonce:Td(e[0],"nonce"),gasPrice:zt(e[1],"gasPrice"),gasLimit:zt(e[2],"gasLimit"),to:yg(e[3]),value:zt(e[4],"value"),data:we(e[5]),chainId:un};if(e.length===6)return t;const r=zt(e[6],"v"),s=zt(e[7],"r"),i=zt(e[8],"s");if(s===un&&i===un)t.chainId=r;else{let o=(r-wK)/gK;o<un&&(o=un),t.chainId=o,V(o!==un||r===yK||r===bK,"non-canonical legacy v","v",e[6]),t.signature=as.from({r:Ia(e[7],32),s:Ia(e[8],32),v:r})}return t}function EK(n,e){const t=[Ct(n.nonce,"nonce"),Ct(n.gasPrice||0,"gasPrice"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data];let r=un;if(n.chainId!=un)r=Ae(n.chainId,"tx.chainId"),V(!e||e.networkV==null||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(n.signature){const i=n.signature.legacyChainId;i!=null&&(r=i)}if(!e)return r!==un&&(t.push(In(r)),t.push("0x"),t.push("0x")),_a(t);let s=BigInt(27+e.yParity);return r!==un?s=as.getChainIdV(r,e.v):BigInt(e.v)!==s&&V(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(In(s)),t.push(In(e.r)),t.push(In(e.s)),_a(t)}function y1(n,e){let t;try{if(t=Td(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{V(!1,"invalid yParity","yParity",e[0])}const r=Ia(e[1],32),s=Ia(e[2],32),i=as.from({r,s,yParity:t});n.signature=i}function kK(n){const e=tg(lt(n).slice(1));V(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",we(n));const t={type:2,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),maxPriorityFeePerGas:zt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:zt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:zt(e[4],"gasLimit"),to:yg(e[5]),value:zt(e[6],"value"),data:we(e[7]),accessList:m1(e[8],"accessList")};return e.length===9||y1(t,e.slice(9)),t}function CK(n,e){const t=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ct(n.maxFeePerGas||0,"maxFeePerGas"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data,g1(n.accessList||[])];return e&&(t.push(Ct(e.yParity,"yParity")),t.push(In(e.r)),t.push(In(e.s))),Ut(["0x02",_a(t)])}function SK(n){const e=tg(lt(n).slice(1));V(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",we(n));const t={type:1,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),gasPrice:zt(e[2],"gasPrice"),gasLimit:zt(e[3],"gasLimit"),to:yg(e[4]),value:zt(e[5],"value"),data:we(e[6]),accessList:m1(e[7],"accessList")};return e.length===8||y1(t,e.slice(8)),t}function TK(n,e){const t=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.gasPrice||0,"gasPrice"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data,g1(n.accessList||[])];return e&&(t.push(Ct(e.yParity,"recoveryParam")),t.push(In(e.r)),t.push(In(e.s))),Ut(["0x01",_a(t)])}function NK(n){let e=tg(lt(n).slice(1)),t="3",r=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const i=e[1],o=e[2],a=e[3];V(Array.isArray(i),"invalid network format: blobs not an array","fields[1]",i),V(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),V(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),V(i.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),V(i.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),r=[];for(let l=0;l<e[1].length;l++)r.push({data:i[l],commitment:o[l],proof:a[l]});e=e[0]}V(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",we(n));const s={type:3,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),maxPriorityFeePerGas:zt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:zt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:zt(e[4],"gasLimit"),to:yg(e[5]),value:zt(e[6],"value"),data:we(e[7]),accessList:m1(e[8],"accessList"),maxFeePerBlobGas:zt(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};r&&(s.blobs=r),V(s.to!=null,`invalid address for transaction type: ${t}`,"data",n),V(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let i=0;i<s.blobVersionedHashes.length;i++)V(At(s.blobVersionedHashes[i],32),`invalid blobVersionedHash at index ${i}: must be length 32`,"data",n);return e.length===11||y1(s,e.slice(11)),s}function OK(n,e,t){const r=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ct(n.maxFeePerGas||0,"maxFeePerGas"),Ct(n.gasLimit,"gasLimit"),n.to||wd,Ct(n.value,"value"),n.data,g1(n.accessList||[]),Ct(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),xK(n.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(r.push(Ct(e.yParity,"yParity")),r.push(In(e.r)),r.push(In(e.s)),t)?Ut(["0x03",_a([r,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])]):Ut(["0x03",_a(r)])}const Pi=class Pi{constructor(){q(this,hu);q(this,Ws);q(this,nu);q(this,ru);q(this,su);q(this,iu);q(this,ou);q(this,au);q(this,lu);q(this,cu);q(this,uu);q(this,fu);q(this,du);q(this,ll);q(this,Ro);q(this,Di);q(this,Mo);I(this,Ws,null),I(this,nu,null),I(this,su,0),I(this,iu,un),I(this,ou,null),I(this,au,null),I(this,lu,null),I(this,ru,"0x"),I(this,cu,un),I(this,uu,un),I(this,fu,null),I(this,du,null),I(this,ll,null),I(this,Ro,null),I(this,Mo,null),I(this,Di,null)}get type(){return T(this,Ws)}set type(e){switch(e){case null:I(this,Ws,null);break;case 0:case"legacy":I(this,Ws,0);break;case 1:case"berlin":case"eip-2930":I(this,Ws,1);break;case 2:case"london":case"eip-1559":I(this,Ws,2);break;case 3:case"cancun":case"eip-4844":I(this,Ws,3);break;default:V(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=T(this,nu);return e==null&&this.type===3?wd:e}set to(e){I(this,nu,e==null?null:dt(e))}get nonce(){return T(this,su)}set nonce(e){I(this,su,Je(e,"value"))}get gasLimit(){return T(this,iu)}set gasLimit(e){I(this,iu,Ae(e))}get gasPrice(){const e=T(this,ou);return e==null&&(this.type===0||this.type===1)?un:e}set gasPrice(e){I(this,ou,e==null?null:Ae(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=T(this,au);return e??(this.type===2||this.type===3?un:null)}set maxPriorityFeePerGas(e){I(this,au,e==null?null:Ae(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=T(this,lu);return e??(this.type===2||this.type===3?un:null)}set maxFeePerGas(e){I(this,lu,e==null?null:Ae(e,"maxFeePerGas"))}get data(){return T(this,ru)}set data(e){I(this,ru,we(e))}get value(){return T(this,cu)}set value(e){I(this,cu,Ae(e,"value"))}get chainId(){return T(this,uu)}set chainId(e){I(this,uu,Ae(e))}get signature(){return T(this,fu)||null}set signature(e){I(this,fu,e==null?null:as.from(e))}get accessList(){const e=T(this,du)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){I(this,du,e==null?null:Co(e))}get maxFeePerBlobGas(){const e=T(this,ll);return e==null&&this.type===3?un:e}set maxFeePerBlobGas(e){I(this,ll,e==null?null:Ae(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=T(this,Ro);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){V(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)V(At(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}I(this,Ro,e)}get blobs(){return T(this,Mo)==null?null:T(this,Mo).map(e=>Object.assign({},e))}set blobs(e){if(e==null){I(this,Mo,null);return}const t=[],r=[];for(let s=0;s<e.length;s++){const i=e[s];if(Mv(i)){ee(T(this,Di),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=lt(i);if(V(o.length<=p1,"blob is too large",`blobs[${s}]`,i),o.length!==p1){const c=new Uint8Array(p1);c.set(o),o=c}const a=T(this,Di).blobToKzgCommitment(o),l=we(T(this,Di).computeBlobKzgProof(o,a));t.push({data:we(o),commitment:we(a),proof:l}),r.push(UM(1,a))}else{const o=we(i.commitment);t.push({data:we(i.data),commitment:o,proof:we(i.proof)}),r.push(UM(1,o))}}I(this,Mo,t),I(this,Ro,r)}get kzg(){return T(this,Di)}set kzg(e){I(this,Di,e)}get hash(){return this.signature==null?null:Jt(fe(this,hu,Xg).call(this,!0,!1))}get unsignedHash(){return Jt(this.unsignedSerialized)}get from(){return this.signature==null?null:mK(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:vd.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return fe(this,hu,Xg).call(this,!0,!0)}get unsignedSerialized(){return fe(this,hu,Xg).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,s=T(this,ll)!=null||T(this,Ro);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ee(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ee(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ee(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):t?i.push(2):e?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(s&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Pi.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new Pi;if(typeof e=="string"){const r=lt(e);if(r[0]>=127)return Pi.from(AK(r));switch(r[0]){case 1:return Pi.from(SK(r));case 2:return Pi.from(kK(r));case 3:return Pi.from(NK(r))}ee(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Pi;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=as.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),V(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),V(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Ws=new WeakMap,nu=new WeakMap,ru=new WeakMap,su=new WeakMap,iu=new WeakMap,ou=new WeakMap,au=new WeakMap,lu=new WeakMap,cu=new WeakMap,uu=new WeakMap,fu=new WeakMap,du=new WeakMap,ll=new WeakMap,Ro=new WeakMap,Di=new WeakMap,Mo=new WeakMap,hu=new WeakSet,Xg=function(e,t){ee(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=e?this.signature:null;switch(this.inferType()){case 0:return EK(this,r);case 1:return TK(this,r);case 2:return CK(this,r);case 3:return OK(this,r,t?this.blobs:null)}ee(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Nd=Pi;const HM=new Uint8Array(32);HM.fill(0);const RK=BigInt(-1),zM=BigInt(0),VM=BigInt(1),MK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function DK(n){const e=lt(n),t=e.length%32;return t?Ut([e,HM.slice(t)]):we(e)}const PK=bo(VM,32),IK=bo(zM,32),$M={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},b1=["name","version","chainId","verifyingContract","salt"];function WM(n){return function(e){return V(typeof e=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,e),e}}const LK={name:WM("name"),version:WM("version"),chainId:function(n){const e=Ae(n,"domain.chainId");return V(e>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(e)?Number(e):La(e)},verifyingContract:function(n){try{return dt(n).toLowerCase()}catch{}V(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const e=lt(n,"domain.salt");return V(e.length===32,'invalid domain value "salt"',"domain.salt",n),we(e)}};function w1(n){{const e=n.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",r=parseInt(e[2]);V(r%8===0&&r!==0&&r<=256&&e[2]===String(r),"invalid numeric width","type",n);const s=pd(MK,t?r-1:r),i=t?(s+VM)*RK:zM;return function(o){const a=Ae(o,"value");return V(a>=i&&a<=s,`value out-of-bounds for ${n}`,"value",a),bo(t?JO(a,256):a,32)}}}{const e=n.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return V(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",n),function(r){const s=lt(r);return V(s.length===t,`invalid length for ${n}`,"value",r),DK(r)}}}switch(n){case"address":return function(e){return Ia(dt(e),32)};case"bool":return function(e){return e?PK:IK};case"bytes":return function(e){return Jt(e)};case"string":return function(e){return Ha(e)}}return null}function GM(n,e){return`${n}(${e.map(({name:t,type:r})=>r+" "+t).join(",")})`}function bg(n){const e=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:n}}const Fr=class Fr{constructor(e){q(this,Wg);$(this,"primaryType");q(this,Hd);q(this,Ii);q(this,pu);I(this,Ii,new Map),I(this,pu,new Map);const t=new Map,r=new Map,s=new Map,i={};Object.keys(e).forEach(l=>{i[l]=e[l].map(({name:c,type:u})=>{let{base:f,index:d}=bg(u);return f==="int"&&!e.int&&(f="int256"),f==="uint"&&!e.uint&&(f="uint256"),{name:c,type:f+(d||"")}}),t.set(l,new Set),r.set(l,[]),s.set(l,new Set)}),I(this,Hd,JSON.stringify(i));for(const l in i){const c=new Set;for(const u of i[l]){V(!c.has(u.name),`duplicate variable name ${JSON.stringify(u.name)} in ${JSON.stringify(l)}`,"types",e),c.add(u.name);const f=bg(u.type).base;V(f!==l,`circular type reference to ${JSON.stringify(f)}`,"types",e),!w1(f)&&(V(r.has(f),`unknown type ${JSON.stringify(f)}`,"types",e),r.get(f).push(l),t.get(l).add(f))}}const o=Array.from(r.keys()).filter(l=>r.get(l).length===0);V(o.length!==0,"missing primary type","types",e),V(o.length===1,`ambiguous primary types or unused types: ${o.map(l=>JSON.stringify(l)).join(", ")}`,"types",e),Oe(this,{primaryType:o[0]});function a(l,c){V(!c.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",e),c.add(l);for(const u of t.get(l))if(r.has(u)){a(u,c);for(const f of c)s.get(f).add(u)}c.delete(l)}a(this.primaryType,new Set);for(const[l,c]of s){const u=Array.from(c);u.sort(),T(this,Ii).set(l,GM(l,i[l])+u.map(f=>GM(f,i[f])).join(""))}}get types(){return JSON.parse(T(this,Hd))}getEncoder(e){let t=T(this,pu).get(e);return t||(t=fe(this,Wg,tP).call(this,e),T(this,pu).set(e,t)),t}encodeType(e){const t=T(this,Ii).get(e);return V(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Jt(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(w1(e))return r(e,t);const s=bg(e).array;if(s)return V(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(o=>this._visit(s.prefix,o,r));const i=this.types[e];if(i)return i.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,t[a],r),o),{});V(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Fr(e)}static getPrimaryType(e){return Fr.from(e).primaryType}static hashStruct(e,t,r){return Fr.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){if(e[r]==null)continue;const s=$M[r];V(s,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:s})}return t.sort((r,s)=>b1.indexOf(r.name)-b1.indexOf(s.name)),Fr.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return Ut(["0x1901",Fr.hashDomain(e),Fr.from(t).hash(r)])}static hash(e,t,r){return Jt(Fr.encode(e,t,r))}static async resolveNames(e,t,r,s){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const i={};e.verifyingContract&&!At(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=Fr.from(t);o.visit(r,(a,l)=>(a==="address"&&!At(l,20)&&(i[l]="0x"),l));for(const a in i)i[a]=await s(a);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),r=o.visit(r,(a,l)=>a==="address"&&i[l]?i[l]:l),{domain:e,value:r}}static getPayload(e,t,r){Fr.hashDomain(e);const s={},i=[];b1.forEach(l=>{const c=e[l];c!=null&&(s[l]=LK[l](c),i.push({name:l,type:$M[l]}))});const o=Fr.from(t);t=o.types;const a=Object.assign({},t);return V(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=i,o.encode(r),{types:a,domain:s,primaryType:o.primaryType,message:o.visit(r,(l,c)=>{if(l.match(/^bytes(\d*)/))return we(lt(c));if(l.match(/^u?int/))return Ae(c).toString();switch(l){case"address":return c.toLowerCase();case"bool":return!!c;case"string":return V(typeof c=="string","invalid string","value",c),c}V(!1,"unsupported type","type",l)})}}};Hd=new WeakMap,Ii=new WeakMap,pu=new WeakMap,Wg=new WeakSet,tP=function(e){{const s=w1(e);if(s)return s}const t=bg(e).array;if(t){const s=t.prefix,i=this.getEncoder(s);return o=>{V(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(i);return T(this,Ii).has(s)&&(a=a.map(Jt)),Jt(Ut(a))}}const r=this.types[e];if(r){const s=Ha(T(this,Ii).get(e));return i=>{const o=r.map(({name:a,type:l})=>{const c=this.getEncoder(l)(i[a]);return T(this,Ii).has(l)?Jt(c):c});return o.unshift(s),Ut(o)}}V(!1,`unknown type: ${e}`,"type",e)};let wg=Fr;function Fn(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const _K=Fn("external public payable override".split(" ")),KM="constant external internal payable private public pure view override",BK=Fn(KM.split(" ")),JM="constructor error event fallback function receive struct",qM=Fn(JM.split(" ")),QM="calldata memory storage payable indexed",FK=Fn(QM.split(" ")),jK=[JM,QM,"tuple returns",KM].join(" "),UK=Fn(jK.split(" ")),HK={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},zK=new RegExp("^(\\s*)"),VK=new RegExp("^([0-9]+)"),$K=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),YM=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),XM=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Gg=class Gg{constructor(e){q(this,zd);q(this,bn);q(this,hs);I(this,bn,0),I(this,hs,e.slice())}get offset(){return T(this,bn)}get length(){return T(this,hs).length-T(this,bn)}clone(){return new Gg(T(this,hs))}reset(){I(this,bn,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=fe(this,zd,rx).call(this,T(this,bn)+1,e.match+1);return I(this,bn,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;T(this,bn)<e.match-1;){const r=this.peek().linkNext;t.push(fe(this,zd,rx).call(this,T(this,bn)+1,r)),I(this,bn,r)}return I(this,bn,e.match+1),t}peek(){if(T(this,bn)>=T(this,hs).length)throw new Error("out-of-bounds");return T(this,hs)[T(this,bn)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Zd(this,bn)._++,e}toString(){const e=[];for(let t=T(this,bn);t<T(this,hs).length;t++){const r=T(this,hs)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};bn=new WeakMap,hs=new WeakMap,zd=new WeakSet,rx=function(e=0,t=0){return new Gg(T(this,hs).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};let ls=Gg;function So(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(zK);a&&(i+=a[1].length,o=n.substring(i));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(l);let c=HK[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,c==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(c=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),l.match=r.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1;else if(c==="COMMA")l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(c==="OPEN_BRACKET")l.type="BRACKET";else if(c==="CLOSE_BRACKET"){let u=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const f=e.pop().text;u=f+u,e[e.length-1].value=Je(f)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=u}continue}if(a=o.match($K),a){if(l.text=a[1],i+=l.text.length,UK.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(XM)){l.type="TYPE";continue}l.type="ID";continue}if(a=o.match(VK),a){l.text=a[1],l.type="NUMBER",i+=l.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new ls(e.map(o=>Object.freeze(o)))}function ZM(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function vg(n,e){if(e.peekKeyword(qM)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function Ai(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function eD(n){let e=Ai(n,BK);return ZM(e,Fn("constant payable nonpayable".split(" "))),ZM(e,Fn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function Ei(n,e){return n.popParams().map(t=>gn.from(t,e))}function tD(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Ae(n.pop().text);throw new Error("invalid gas")}return null}function $a(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const WK=new RegExp(/^(.*)\[([0-9]*)\]$/);function nD(n){const e=n.match(XM);if(V(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);V(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);V(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const Pt={},Xn=Symbol.for("_ethers_internal"),rD="_ParamTypeInternal",sD="_ErrorInternal",iD="_EventInternal",oD="_ConstructorInternal",aD="_FallbackInternal",lD="_FunctionInternal",cD="_StructInternal",jr=class jr{constructor(e,t,r,s,i,o,a,l){q(this,mu);$(this,"name");$(this,"type");$(this,"baseType");$(this,"indexed");$(this,"components");$(this,"arrayLength");$(this,"arrayChildren");if(Qm(e,Pt,"ParamType"),Object.defineProperty(this,Xn,{value:rD}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||l==null)throw new Error("")}else if(a!=null||l!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");Oe(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:l})}format(e){if(e==null&&(e="sighash"),e==="json"){const r=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=r,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return fe(this,mu,Zg).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(jr.isParamType(e))return e;if(typeof e=="string")try{return jr.from(So(e),t)}catch{V(!1,"invalid param type","obj",e)}else if(e instanceof ls){let a="",l="",c=null;Ai(e,Fn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(l="tuple",c=e.popParams().map(m=>jr.from(m)),a=`tuple(${c.map(m=>m.format()).join(",")})`):(a=nD(e.popType("TYPE")),l=a);let u=null,f=null;for(;e.length&&e.peekType("BRACKET");){const m=e.pop();u=new jr(Pt,"",a,l,null,c,f,u),f=m.value,a+=m.text,l="array",c=null}let d=null;if(Ai(e,FK).has("indexed")){if(!t)throw new Error("");d=!0}const p=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new jr(Pt,p,a,l,d,c,f,u)}const r=e.name;V(!r||typeof r=="string"&&r.match(YM),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(V(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(WK);if(o){const a=parseInt(o[2]||"-1"),l=jr.from({type:o[1],components:e.components});return new jr(Pt,r||"",i,"array",s,null,a,l)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(c=>jr.from(c)):null;return new jr(Pt,r||"",i,"tuple",s,a,null,null)}return i=nD(e.type),new jr(Pt,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Xn]===rD}};mu=new WeakSet,Zg=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((l,c)=>{var u;fe(u=o,mu,Zg).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(l=>{if(!l.name)throw new Error("cannot use object value with unnamed components");if(!(l.name in t))throw new Error(`missing value for component ${l.name}`);return t[l.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((l,c)=>{var u;fe(u=o[c],mu,Zg).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};let gn=jr;class Wa{constructor(e,t,r){$(this,"type");$(this,"inputs");Qm(e,Pt,"Fragment"),r=Object.freeze(r.slice()),Oe(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{Wa.from(JSON.parse(e))}catch{}return Wa.from(So(e))}if(e instanceof ls)switch(e.peekKeyword(qM)){case"constructor":return ki.from(e);case"error":return Zn.from(e);case"event":return zs.from(e);case"fallback":case"receive":return Ci.from(e);case"function":return Vs.from(e);case"struct":return Ga.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return ki.from(e);case"error":return Zn.from(e);case"event":return zs.from(e);case"fallback":case"receive":return Ci.from(e);case"function":return Vs.from(e);case"struct":return Ga.from(e)}ee(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}V(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return ki.isFragment(e)}static isError(e){return Zn.isFragment(e)}static isEvent(e){return zs.isFragment(e)}static isFunction(e){return Vs.isFragment(e)}static isStruct(e){return Ga.isFragment(e)}}class xg extends Wa{constructor(t,r,s,i){super(t,r,i);$(this,"name");V(typeof s=="string"&&s.match(YM),"invalid identifier","name",s),i=Object.freeze(i.slice()),Oe(this,{name:s})}}function Od(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class Zn extends xg{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,Xn,{value:sD})}get selector(){return Ha(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Od(e,this.inputs)),t.join(" ")}static from(e){if(Zn.isFragment(e))return e;if(typeof e=="string")return Zn.from(So(e));if(e instanceof ls){const t=vg("error",e),r=Ei(e);return $a(e),new Zn(Pt,t,r)}return new Zn(Pt,e.name,e.inputs?e.inputs.map(gn.from):[])}static isFragment(e){return e&&e[Xn]===sD}}class zs extends xg{constructor(t,r,s,i){super(t,"event",r,s);$(this,"anonymous");Object.defineProperty(this,Xn,{value:iD}),Oe(this,{anonymous:i})}get topicHash(){return Ha(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+Od(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>gn.from(i)),new zs(Pt,t,r,!1).topicHash}static from(t){if(zs.isFragment(t))return t;if(typeof t=="string")try{return zs.from(So(t))}catch{V(!1,"invalid event fragment","obj",t)}else if(t instanceof ls){const r=vg("event",t),s=Ei(t,!0),i=!!Ai(t,Fn(["anonymous"])).has("anonymous");return $a(t),new zs(Pt,r,s,i)}return new zs(Pt,t.name,t.inputs?t.inputs.map(r=>gn.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Xn]===iD}}class ki extends Wa{constructor(t,r,s,i,o){super(t,r,s);$(this,"payable");$(this,"gas");Object.defineProperty(this,Xn,{value:oD}),Oe(this,{payable:i,gas:o})}format(t){if(ee(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${Od(t,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(ki.isFragment(t))return t;if(typeof t=="string")try{return ki.from(So(t))}catch{V(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof ls){Ai(t,Fn(["constructor"]));const r=Ei(t),s=!!Ai(t,_K).has("payable"),i=tD(t);return $a(t),new ki(Pt,"constructor",r,s,i)}return new ki(Pt,"constructor",t.inputs?t.inputs.map(gn.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Xn]===oD}}class Ci extends Wa{constructor(t,r,s){super(t,"fallback",r);$(this,"payable");Object.defineProperty(this,Xn,{value:aD}),Oe(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(Ci.isFragment(t))return t;if(typeof t=="string")try{return Ci.from(So(t))}catch{V(!1,"invalid fallback fragment","obj",t)}else if(t instanceof ls){const r=t.toString(),s=t.peekKeyword(Fn(["fallback","receive"]));if(V(s,"type must be fallback or receive","obj",r),t.popKeyword(Fn(["fallback","receive"]))==="receive"){const l=Ei(t);return V(l.length===0,"receive cannot have arguments","obj.inputs",l),Ai(t,Fn(["payable"])),$a(t),new Ci(Pt,[],!0)}let o=Ei(t);o.length?V(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(l=>l.format("minimal")).join(", ")):o=[gn.from("bytes")];const a=eD(t);if(V(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Ai(t,Fn(["returns"])).has("returns")){const l=Ei(t);V(l.length===1&&l[0].type==="bytes","invalid fallback outputs","obj.outputs",l.map(c=>c.format("minimal")).join(", "))}return $a(t),new Ci(Pt,o,a==="payable")}if(t.type==="receive")return new Ci(Pt,[],!0);if(t.type==="fallback"){const r=[gn.from("bytes")],s=t.stateMutability==="payable";return new Ci(Pt,r,s)}V(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Xn]===aD}}class Vs extends xg{constructor(t,r,s,i,o,a){super(t,"function",r,i);$(this,"constant");$(this,"outputs");$(this,"stateMutability");$(this,"payable");$(this,"gas");Object.defineProperty(this,Xn,{value:lD}),o=Object.freeze(o.slice()),Oe(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return Ha(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+Od(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(Od(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>gn.from(i)),new Vs(Pt,t,"view",r,[],null).selector}static from(t){if(Vs.isFragment(t))return t;if(typeof t=="string")try{return Vs.from(So(t))}catch{V(!1,"invalid function fragment","obj",t)}else if(t instanceof ls){const s=vg("function",t),i=Ei(t),o=eD(t);let a=[];Ai(t,Fn(["returns"])).has("returns")&&(a=Ei(t));const l=tD(t);return $a(t),new Vs(Pt,s,o,i,a,l)}let r=t.stateMutability;return r==null&&(r="payable",typeof t.constant=="boolean"?(r="view",t.constant||(r="payable",typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable")),new Vs(Pt,t.name,r,t.inputs?t.inputs.map(gn.from):[],t.outputs?t.outputs.map(gn.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Xn]===lD}}class Ga extends xg{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,Xn,{value:cD})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Ga.from(So(e))}catch{V(!1,"invalid struct fragment","obj",e)}else if(e instanceof ls){const t=vg("struct",e),r=Ei(e);return $a(e),new Ga(Pt,t,r)}return new Ga(Pt,e.name,e.inputs?e.inputs.map(gn.from):[])}static isFragment(e){return e&&e[Xn]===cD}}const cs=new Map;cs.set(0,"GENERIC_PANIC"),cs.set(1,"ASSERT_FALSE"),cs.set(17,"OVERFLOW"),cs.set(18,"DIVIDE_BY_ZERO"),cs.set(33,"ENUM_RANGE_ERROR"),cs.set(34,"BAD_STORAGE_DATA"),cs.set(49,"STACK_UNDERFLOW"),cs.set(50,"ARRAY_RANGE_ERROR"),cs.set(65,"OUT_OF_MEMORY"),cs.set(81,"UNINITIALIZED_FUNCTION_CALL");const GK=new RegExp(/^bytes([0-9]*)$/),KK=new RegExp(/^(u?int)([0-9]*)$/);let v1=null,uD=1024;function JK(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const c=lt(t);if(t=we(t),c.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(c.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(we(c.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],c.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(we(c.slice(0,4))==="0x4e487b71")try{const u=Number(r.decode(["uint256"],c.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[u]},i=`Panic due to ${cs.get(u)||"UNKNOWN"}(${u})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const l={to:e.to?dt(e.to):null,data:e.data||"0x"};return e.from&&(l.from=dt(e.from)),Nt(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:l,invocation:o,revert:a})}const Kg=class Kg{constructor(){q(this,Do)}getDefaultValue(e){const t=e.map(s=>fe(this,Do,Fu).call(this,gn.from(s)));return new cg(t,"_").defaultValue()}encode(e,t){$O(t.length,e.length,"types/values length mismatch");const r=e.map(o=>fe(this,Do,Fu).call(this,gn.from(o))),s=new cg(r,"_"),i=new _v;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>fe(this,Do,Fu).call(this,gn.from(o)));return new cg(s,"_").decode(new Bv(t,r,uD))}static _setDefaultMaxInflation(e){V(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),uD=e}static defaultAbiCoder(){return v1==null&&(v1=new Kg),v1}static getBuiltinCallException(e,t,r){return JK(e,t,r,Kg.defaultAbiCoder())}};Do=new WeakSet,Fu=function(e){if(e.isArray())return new wG(fe(this,Do,Fu).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new cg(e.components.map(r=>fe(this,Do,Fu).call(this,r)),e.name);switch(e.baseType){case"address":return new yG(e.name);case"bool":return new vG(e.name);case"string":return new OG(e.name);case"bytes":return new xG(e.name);case"":return new kG(e.name)}let t=e.type.match(KK);if(t){let r=parseInt(t[2]||"256");return V(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new NG(r/8,t[1]==="int",e.name)}if(t=e.type.match(GK),t){let r=parseInt(t[1]);return V(r!==0&&r<=32,"invalid bytes length","param",e),new AG(r,e.name)}V(!1,"invalid type","type",e.type)};let Bc=Kg;class qK{constructor(e,t,r){$(this,"fragment");$(this,"name");$(this,"signature");$(this,"topic");$(this,"args");const s=e.name,i=e.format();Oe(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class QK{constructor(e,t,r,s){$(this,"fragment");$(this,"name");$(this,"args");$(this,"signature");$(this,"selector");$(this,"value");const i=e.name,o=e.format();Oe(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class YK{constructor(e,t,r){$(this,"fragment");$(this,"name");$(this,"args");$(this,"signature");$(this,"selector");const s=e.name,i=e.format();Oe(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class fD{constructor(e){$(this,"hash");$(this,"_isIndexed");Oe(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const dD={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},hD={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&dD[n.toString()]&&(e=dD[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}},cl=class cl{constructor(e){q(this,qs);$(this,"fragments");$(this,"deploy");$(this,"fallback");$(this,"receive");q(this,Gs);q(this,Ks);q(this,Js);q(this,kn);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,I(this,Js,new Map),I(this,Gs,new Map),I(this,Ks,new Map);const r=[];for(const o of t)try{r.push(Wa.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}Oe(this,{fragments:Object.freeze(r)});let s=null,i=!1;I(this,kn,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let l;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}Oe(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(V(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":l=T(this,Js);break;case"event":l=T(this,Ks);break;case"error":l=T(this,Gs);break;default:return}const c=o.format();l.has(c)||l.set(c,o)}),this.deploy||Oe(this,{deploy:ki.from("constructor()")}),Oe(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Bc.defaultAbiCoder()}getFunctionName(e){const t=fe(this,qs,ey).call(this,e,null,!1);return V(t,"no matching function","key",e),t.name}hasFunction(e){return!!fe(this,qs,ey).call(this,e,null,!1)}getFunction(e,t){return fe(this,qs,ey).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(T(this,Js).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Js).get(s),r)}}getEventName(e){const t=fe(this,qs,ty).call(this,e,null,!1);return V(t,"no matching event","key",e),t.name}hasEvent(e){return!!fe(this,qs,ty).call(this,e,null,!1)}getEvent(e,t){return fe(this,qs,ty).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(T(this,Ks).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Ks).get(s),r)}}getError(e,t){if(At(e)){const s=e.toLowerCase();if(hD[s])return Zn.from(hD[s].signature);for(const i of T(this,Gs).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of T(this,Gs))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?Zn.from("error Error(string)"):e==="Panic"?Zn.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");V(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=Zn.from(e).format(),e==="Error(string)")return Zn.from("error Error(string)");if(e==="Panic(uint256)")return Zn.from("error Panic(uint256)");const r=T(this,Gs).get(e);return r||null}forEachError(e){const t=Array.from(T(this,Gs).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Gs).get(s),r)}}_decodeParams(e,t){return T(this,kn).decode(e,t)}_encodeParams(e,t){return T(this,kn).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);V(r,"unknown error","fragment",e),e=r}return V(Ft(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Ft(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);V(r,"unknown error","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return V(Ft(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Ft(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);V(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Pn(t);if(s.length%32===0)try{return T(this,kn).decode(e.outputs,s)}catch{r="could not decode result data"}ee(!1,r,"BAD_DATA",{value:we(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=lt(e,"data"),s=Bc.getBuiltinCallException("call",t,r);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=we(r.slice(0,4)),l=this.getError(a);if(l)try{const c=T(this,kn).decode(l.inputs,r.slice(4));s.revert={name:l.name,signature:l.format(),args:c},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return we(T(this,kn).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);V(i,"unknown event","eventFragment",e),e=i}ee(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?Ha(o):i.type==="bytes"?Jt(we(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=bo(o):i.type.match(/^bytes/)?o=MW(o,32):i.type==="address"&&T(this,kn).encode(["address"],[o]),Ia(we(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){V(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?V(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(l=>s(a,l))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);V(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),V(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const l=t[a];if(o.indexed)if(o.type==="string")r.push(Ha(l));else if(o.type==="bytes")r.push(Jt(l));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(T(this,kn).encode([o.type],[l]))}else s.push(o),i.push(l)}),{data:T(this,kn).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const h=this.getEvent(e);V(h,"unknown event","eventFragment",e),e=h}if(r!=null&&!e.anonymous){const h=e.topicHash;V(At(r[0],32)&&r[0].toLowerCase()===h,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((h,p)=>{h.indexed?h.type==="string"||h.type==="bytes"||h.baseType==="tuple"||h.baseType==="array"?(s.push(gn.from({type:"bytes32",name:h.name})),o.push(!0)):(s.push(h),o.push(!1)):(i.push(h),o.push(!1))});const a=r!=null?T(this,kn).decode(s,Ut(r)):null,l=T(this,kn).decode(i,t,!0),c=[],u=[];let f=0,d=0;return e.inputs.forEach((h,p)=>{let m=null;if(h.indexed)if(a==null)m=new fD(null);else if(o[p])m=new fD(a[d++]);else try{m=a[d++]}catch(y){m=y}else try{m=l[f++]}catch(y){m=y}c.push(m),u.push(h.name||null)}),Sc.fromItems(c,u)}parseTransaction(e){const t=lt(e.data,"tx.data"),r=Ae(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(we(t.slice(0,4)));if(!s)return null;const i=T(this,kn).decode(s.inputs,t.slice(4));return new QK(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new qK(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=we(e),r=this.getError(Ft(t,0,4));if(!r)return null;const s=T(this,kn).decode(r.inputs,Ft(t,4));return new YK(r,r.selector,s)}static from(e){return e instanceof cl?e:typeof e=="string"?new cl(JSON.parse(e)):typeof e.formatJson=="function"?new cl(e.formatJson()):typeof e.format=="function"?new cl(e.format("json")):new cl(e)}};Gs=new WeakMap,Ks=new WeakMap,Js=new WeakMap,kn=new WeakMap,qs=new WeakSet,ey=function(e,t,r){if(At(e)){const i=e.toLowerCase();for(const o of T(this,Js).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of T(this,Js))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,l=!0;En.isTyped(o)&&o.type==="overrides"&&(l=!1,a--);for(let c=i.length-1;c>=0;c--){const u=i[c].inputs.length;u!==a&&(!l||u!==a-1)&&i.splice(c,1)}for(let c=i.length-1;c>=0;c--){const u=i[c].inputs;for(let f=0;f<t.length;f++)if(En.isTyped(t[f])){if(f>=u.length){if(t[f].type==="overrides")continue;i.splice(c,1);break}if(t[f].type!==u[f].baseType){i.splice(c,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=T(this,Js).get(Vs.from(e).format());return s||null},ty=function(e,t,r){if(At(e)){const i=e.toLowerCase();for(const o of T(this,Ks).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of T(this,Ks))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let l=0;l<t.length;l++)if(En.isTyped(t[l])&&t[l].type!==a[l].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=T(this,Ks).get(zs.from(e).format());return s||null};let x1=cl;const pD=BigInt(0);function Fc(n){return n??null}function Vt(n){return n==null?null:n.toString()}class mD{constructor(e,t,r){$(this,"gasPrice");$(this,"maxFeePerGas");$(this,"maxPriorityFeePerGas");Oe(this,{gasPrice:Fc(e),maxFeePerGas:Fc(t),maxPriorityFeePerGas:Fc(r)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Vt(e),maxFeePerGas:Vt(t),maxPriorityFeePerGas:Vt(r)}}}function Ag(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=we(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=Ae(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=Je(n[s],`request.${s}`));return n.accessList&&(e.accessList=Co(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(e.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(e.kzg=n.kzg),"blobs"in n&&n.blobs&&(e.blobs=n.blobs.map(s=>Mv(s)?we(s):Object.assign({},s))),e}class XK{constructor(e,t){$(this,"provider");$(this,"number");$(this,"hash");$(this,"timestamp");$(this,"parentHash");$(this,"parentBeaconBlockRoot");$(this,"nonce");$(this,"difficulty");$(this,"gasLimit");$(this,"gasUsed");$(this,"stateRoot");$(this,"receiptsRoot");$(this,"blobGasUsed");$(this,"excessBlobGas");$(this,"miner");$(this,"prevRandao");$(this,"extraData");$(this,"baseFeePerGas");q(this,Li);I(this,Li,e.transactions.map(r=>typeof r!="string"?new Md(r,t):r)),Oe(this,{provider:t,hash:Fc(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Fc(e.prevRandao),extraData:e.extraData,baseFeePerGas:Fc(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return T(this,Li).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=T(this,Li).slice();return e.length===0?[]:(ee(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:r,gasLimit:s,gasUsed:i,hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,timestamp:m,transactions:y}=this;return{_type:"Block",baseFeePerGas:Vt(e),difficulty:Vt(t),extraData:r,gasLimit:Vt(s),gasUsed:Vt(i),blobGasUsed:Vt(this.blobGasUsed),excessBlobGas:Vt(this.excessBlobGas),hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,timestamp:m,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,transactions:y}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Li).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=T(this,Li)[e];else{const r=e.toLowerCase();for(const s of T(this,Li))if(typeof s=="string"){if(s!==r)continue;t=s;break}else{if(s.hash===r)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const r of t)if(r.hash===e)return r;V(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return ZK(this)}}Li=new WeakMap;class Rd{constructor(e,t){$(this,"provider");$(this,"transactionHash");$(this,"blockHash");$(this,"blockNumber");$(this,"removed");$(this,"address");$(this,"data");$(this,"topics");$(this,"index");$(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());Oe(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return ee(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return ee(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return ee(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return eJ(this)}}class gD{constructor(e,t){$(this,"provider");$(this,"to");$(this,"from");$(this,"contractAddress");$(this,"hash");$(this,"index");$(this,"blockHash");$(this,"blockNumber");$(this,"logsBloom");$(this,"gasUsed");$(this,"blobGasUsed");$(this,"cumulativeGasUsed");$(this,"gasPrice");$(this,"blobGasPrice");$(this,"type");$(this,"status");$(this,"root");q(this,Vd);I(this,Vd,Object.freeze(e.logs.map(s=>new Rd(s,t))));let r=pD;e.effectiveGasPrice!=null?r=e.effectiveGasPrice:e.gasPrice!=null&&(r=e.gasPrice),Oe(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:r,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return T(this,Vd)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:l,logs:c,status:u,root:f}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:Vt(this.cumulativeGasUsed),from:t,gasPrice:Vt(this.gasPrice),blobGasUsed:Vt(this.blobGasUsed),blobGasPrice:Vt(this.blobGasPrice),gasUsed:Vt(this.gasUsed),hash:s,index:i,logs:c,logsBloom:l,root:f,status:u,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return bD(this)}reorderedEvent(e){return ee(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),yD(this,e)}}Vd=new WeakMap;const J1=class J1{constructor(e,t){$(this,"provider");$(this,"blockNumber");$(this,"blockHash");$(this,"index");$(this,"hash");$(this,"type");$(this,"to");$(this,"from");$(this,"nonce");$(this,"gasLimit");$(this,"gasPrice");$(this,"maxPriorityFeePerGas");$(this,"maxFeePerGas");$(this,"maxFeePerBlobGas");$(this,"data");$(this,"value");$(this,"chainId");$(this,"signature");$(this,"accessList");$(this,"blobVersionedHashes");q(this,Po);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,I(this,Po,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:l,data:c,signature:u,accessList:f,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:f,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:Vt(this.chainId),data:c,from:a,gasLimit:Vt(this.gasLimit),gasPrice:Vt(this.gasPrice),hash:s,maxFeePerGas:Vt(this.maxFeePerGas),maxPriorityFeePerGas:Vt(this.maxPriorityFeePerGas),maxFeePerBlobGas:Vt(this.maxFeePerBlobGas),nonce:l,signature:u,to:o,index:r,type:i,value:Vt(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:r}=await An({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:r-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const r=e??1,s=t??0;let i=T(this,Po),o=-1,a=i===-1;const l=async()=>{if(a)return null;const{blockNumber:d,nonce:h}=await An({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(h<this.nonce){i=d;return}if(a)return null;const p=await this.getTransaction();if(!(p&&p.blockNumber!=null))for(o===-1&&(o=i-3,o<T(this,Po)&&(o=T(this,Po)));o<=d;){if(a)return null;const m=await this.provider.getBlock(o,!0);if(m==null)return;for(const y of m)if(y===this.hash)return;for(let y=0;y<m.length;y++){const b=await m.getTransaction(y);if(b.from===this.from&&b.nonce===this.nonce){if(a)return null;const x=await this.provider.getTransactionReceipt(b.hash);if(x==null||d-x.blockNumber+1<r)return;let v="replaced";b.data===this.data&&b.to===this.to&&b.value===this.value?v="repriced":b.data==="0x"&&b.from===b.to&&b.value===pD&&(v="cancelled"),ee(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:v==="replaced"||v==="cancelled",reason:v,replacement:b.replaceableTransaction(i),hash:b.hash,receipt:x})}}o++}},c=d=>{if(d==null||d.status!==0)return d;ee(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},u=await this.provider.getTransactionReceipt(this.hash);if(r===0)return c(u);if(u){if(await u.confirmations()>=r)return c(u)}else if(await l(),r===0)return null;return await new Promise((d,h)=>{const p=[],m=()=>{p.forEach(b=>b())};if(p.push(()=>{a=!0}),s>0){const b=setTimeout(()=>{m(),h(Nt("wait for transaction timeout","TIMEOUT"))},s);p.push(()=>{clearTimeout(b)})}const y=async b=>{if(await b.confirmations()>=r){m();try{d(c(b))}catch(x){h(x)}}};if(p.push(()=>{this.provider.off(this.hash,y)}),this.provider.on(this.hash,y),i>=0){const b=async()=>{try{await l()}catch(x){if(ln(x,"TRANSACTION_REPLACED")){m(),h(x);return}}a||this.provider.once("block",b)};p.push(()=>{this.provider.off("block",b)}),this.provider.once("block",b)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return ee(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),bD(this)}reorderedEvent(e){return ee(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ee(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),yD(this,e)}replaceableTransaction(e){V(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new J1(this,this.provider);return I(t,Po,e),t}};Po=new WeakMap;let Md=J1;function ZK(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function yD(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function bD(n){return{orphan:"drop-transaction",tx:n}}function eJ(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class A1 extends Rd{constructor(t,r,s){super(t,t.provider);$(this,"interface");$(this,"fragment");$(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);Oe(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class wD extends Rd{constructor(t,r){super(t,t.provider);$(this,"error");Oe(this,{error:r})}}class tJ extends gD{constructor(t,r,s){super(s,r);q(this,gu);I(this,gu,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?T(this,gu).getEvent(t.topics[0]):null;if(r)try{return new A1(t,T(this,gu),r)}catch(s){return new wD(t,s)}return t})}}gu=new WeakMap;class E1 extends Md{constructor(t,r,s){super(s,r);q(this,$d);I(this,$d,t)}async wait(t,r){const s=await super.wait(t,r);return s==null?null:new tJ(T(this,$d),this.provider,s)}}$d=new WeakMap;class vD extends XO{constructor(t,r,s,i){super(t,r,s);$(this,"log");Oe(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class nJ extends vD{constructor(e,t,r,s,i){super(e,t,r,new A1(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);Oe(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const xD=BigInt(0);function AD(n){return n&&typeof n.call=="function"}function ED(n){return n&&typeof n.estimateGas=="function"}function Eg(n){return n&&typeof n.resolveName=="function"}function kD(n){return n&&typeof n.sendTransaction=="function"}function CD(n){if(n!=null){if(Eg(n))return n;if(n.provider)return n.provider}}class rJ{constructor(e,t,r){q(this,Wd);$(this,"fragment");if(Oe(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=Ka(e.runner,"resolveName"),i=Eg(s)?s:null;I(this,Wd,async function(){const o=await Promise.all(t.inputs.map((a,l)=>r[l]==null?null:a.walkAsync(r[l],(u,f)=>u==="address"?Array.isArray(f)?Promise.all(f.map(d=>Bn(d,i))):Bn(f,i):f)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return T(this,Wd)}}Wd=new WeakMap;function Ka(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function Ja(n){return n==null?null:n.provider||null}async function SD(n,e){const t=En.dereference(n,"overrides");V(typeof t=="object","invalid overrides parameter","overrides",n);const r=Ag(t);return V(r.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),V(r.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function sJ(n,e,t){const r=Ka(n,"resolveName"),s=Eg(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,l)=>(l=En.dereference(l,a),a==="address"?Bn(l,s):l))))}function iJ(n){const e=async function(o){const a=await SD(o,["data"]);a.to=await n.getAddress(),a.from&&(a.from=await Bn(a.from,CD(n.runner)));const l=n.interface,c=Ae(a.value||xD,"overrides.value")===xD,u=(a.data||"0x")==="0x";l.fallback&&!l.fallback.payable&&l.receive&&!u&&!c&&V(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),V(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data);const f=l.receive||l.fallback&&l.fallback.payable;return V(f||c,"cannot send value to non-payable fallback","overrides.value",a.value),V(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=Ka(n.runner,"call");ee(AD(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const l=await e(o);try{return await a.call(l)}catch(c){throw Rv(c)&&c.data?n.interface.makeError(c.data,l):c}},r=async function(o){const a=n.runner;ee(kD(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const l=await a.sendTransaction(await e(o)),c=Ja(n.runner);return new E1(n.interface,c,l)},s=async function(o){const a=Ka(n.runner,"estimateGas");return ee(ED(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},i=async o=>await r(o);return Oe(i,{_contract:n,estimateGas:s,populateTransaction:e,send:r,staticCall:t}),i}function oJ(n,e){const t=function(...c){const u=n.interface.getFunction(e,c);return ee(u,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:c}}),u},r=async function(...c){const u=t(...c);let f={};if(u.inputs.length+1===c.length&&(f=await SD(c.pop()),f.from&&(f.from=await Bn(f.from,CD(n.runner)))),u.inputs.length!==c.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await sJ(n.runner,u.inputs,c);return Object.assign({},f,await An({to:n.getAddress(),data:n.interface.encodeFunctionData(u,d)}))},s=async function(...c){const u=await a(...c);return u.length===1?u[0]:u},i=async function(...c){const u=n.runner;ee(kD(u),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const f=await u.sendTransaction(await r(...c)),d=Ja(n.runner);return new E1(n.interface,d,f)},o=async function(...c){const u=Ka(n.runner,"estimateGas");return ee(ED(u),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await u.estimateGas(await r(...c))},a=async function(...c){const u=Ka(n.runner,"call");ee(AD(u),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const f=await r(...c);let d="0x";try{d=await u.call(f)}catch(p){throw Rv(p)&&p.data?n.interface.makeError(p.data,f):p}const h=t(...c);return n.interface.decodeFunctionResult(h,d)},l=async(...c)=>t(...c).constant?await s(...c):await i(...c);return Oe(l,{name:n.interface.getFunctionName(e),_contract:n,_key:e,getFragment:t,estimateGas:o,populateTransaction:r,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(l,"fragment",{configurable:!1,enumerable:!0,get:()=>{const c=n.interface.getFunction(e);return ee(c,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),c}}),l}function aJ(n,e){const t=function(...s){const i=n.interface.getEvent(e,s);return ee(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),i},r=function(...s){return new rJ(n,t(...s),s)};return Oe(r,{name:n.interface.getEventName(e),_contract:n,_key:e,getFragment:t}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=n.interface.getEvent(e);return ee(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),r}const kg=Symbol.for("_ethersInternal_contract"),TD=new WeakMap;function lJ(n,e){TD.set(n[kg],e)}function br(n){return TD.get(n[kg])}function cJ(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function k1(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(At(o,32))return o;const a=n.interface.getEvent(o);return V(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?At(e,32)?t=[e]:(r=n.interface.getEvent(e),V(r,"unknown fragment","event",e),t=[r.topicHash]):cJ(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):V(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function Dd(n,e){const{subs:t}=br(n);return t.get((await k1(n,e)).tag)||null}async function ND(n,e,t){const r=Ja(n.runner);ee(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await k1(n,t),{addr:a,subs:l}=br(n);let c=l.get(i);if(!c){const f={address:a||n,topics:o},d=y=>{let b=s;if(b==null)try{b=n.interface.getEvent(y.topics[0])}catch{}if(b){const x=b,v=s?n.interface.decodeEventLog(s,y.data,y.topics):[];S1(n,t,v,w=>new nJ(n,w,t,x,y))}else S1(n,t,[],x=>new vD(n,x,t,y))};let h=[];c={tag:i,listeners:[],start:()=>{h.length||h.push(r.on(f,d))},stop:async()=>{if(h.length==0)return;let y=h;h=[],await Promise.all(y),r.off(f,d)}},l.set(i,c)}return c}let C1=Promise.resolve();async function uJ(n,e,t,r){await C1;const s=await Dd(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const l=Array.from(t);r&&l.push(r(a?null:o));try{o.call(n,...l)}catch{}return!a}),s.listeners.length===0&&(s.stop(),br(n).subs.delete(s.tag)),i>0}async function S1(n,e,t,r){try{await C1}catch{}const s=uJ(n,e,t,r);return C1=s,await s}const Cg=["then"];qD=kg;const Gd=class Gd{constructor(e,t,r,s){$(this,"target");$(this,"interface");$(this,"runner");$(this,"filters");$(this,qD);$(this,"fallback");V(typeof e=="string"||lM(e),"invalid value for Contract target","target",e),r==null&&(r=null);const i=x1.from(t);Oe(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,kg,{value:{}});let o,a=null,l=null;if(s){const f=Ja(r);l=new E1(this.interface,f,s)}let c=new Map;if(typeof e=="string")if(At(e))a=e,o=Promise.resolve(e);else{const f=Ka(r,"resolveName");if(!Eg(f))throw Nt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=f.resolveName(e).then(d=>{if(d==null)throw Nt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return br(this).addr=d,d})}else o=e.getAddress().then(f=>{if(f==null)throw new Error("TODO");return br(this).addr=f,f});lJ(this,{addrPromise:o,addr:a,deployTx:l,subs:c});const u=new Proxy({},{get:(f,d,h)=>{if(typeof d=="symbol"||Cg.indexOf(d)>=0)return Reflect.get(f,d,h);try{return this.getEvent(d)}catch(p){if(!ln(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>Cg.indexOf(d)>=0?Reflect.has(f,d):Reflect.has(f,d)||this.interface.hasEvent(String(d))});return Oe(this,{filters:u}),Oe(this,{fallback:i.receive||i.fallback?iJ(this):null}),new Proxy(this,{get:(f,d,h)=>{if(typeof d=="symbol"||d in f||Cg.indexOf(d)>=0)return Reflect.get(f,d,h);try{return f.getFunction(d)}catch(p){if(!ln(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>typeof d=="symbol"||d in f||Cg.indexOf(d)>=0?Reflect.has(f,d):f.interface.hasFunction(d)})}connect(e){return new Gd(this.target,this.interface,e)}attach(e){return new Gd(e,this.interface,this.runner)}async getAddress(){return await br(this).addrPromise}async getDeployedCode(){const e=Ja(this.runner);ee(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Ja(this.runner);return ee(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return br(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),oJ(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),aJ(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=br(this),o=s||await i,{fragment:a,topics:l}=await k1(this,e),c={address:o,topics:l,fromBlock:t,toBlock:r},u=Ja(this.runner);return ee(u,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await u.getLogs(c)).map(f=>{let d=a;if(d==null)try{d=this.interface.getEvent(f.topics[0])}catch{}if(d)try{return new A1(f,this.interface,d)}catch(h){return new wD(f,h)}return new Rd(f,u)})}async on(e,t){const r=await ND(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await ND(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await S1(this,e,t,null)}async listenerCount(e){if(e){const s=await Dd(this,e);return s?s.listeners.length:0}const{subs:t}=br(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await Dd(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=br(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await Dd(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),br(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await Dd(this,e);if(!t)return this;t.stop(),br(this).subs.delete(t.tag)}else{const{subs:t}=br(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Gd{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};let T1=Gd;function fJ(){return T1}class jc extends fJ(){}function N1(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):V(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class dJ{constructor(e){$(this,"name");Oe(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const OD=new RegExp("^(ipfs)://(.*)$","i"),RD=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),OD,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],yu=class yu{constructor(e,t,r){q(this,Lo);$(this,"provider");$(this,"address");$(this,"name");q(this,Io);q(this,ul);Oe(this,{provider:e,address:t,name:r}),I(this,Io,null),I(this,ul,new jc(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return T(this,Io)==null&&I(this,Io,(async()=>{try{return await T(this,ul).supportsInterface("0x9061b923")}catch(e){if(ln(e,"CALL_EXCEPTION"))return!1;throw I(this,Io,null),e}})()),await T(this,Io)}async getAddress(e){if(e==null&&(e=60),e===60)try{const i=await fe(this,Lo,ju).call(this,"addr(bytes32)");return i==null||i===wd?null:i}catch(i){if(ln(i,"CALL_EXCEPTION"))return null;throw i}if(e>=0&&e<2147483648){let i=e+2147483648;const o=await fe(this,Lo,ju).call(this,"addr(bytes32,uint)",[i]);if(At(o,20))return dt(o)}let t=null;for(const i of this.provider.plugins)if(i instanceof dJ&&i.supportsCoinType(e)){t=i;break}if(t==null)return null;const r=await fe(this,Lo,ju).call(this,"addr(bytes32,uint)",[e]);if(r==null||r==="0x")return null;const s=await t.decodeAddress(e,r);if(s!=null)return s;ee(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:r}})}async getText(e){const t=await fe(this,Lo,ju).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await fe(this,Lo,ju).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",i=parseInt(t[4],16);if(t[5].length===i*2)return`${s}://${IW("0x"+t[2])}`}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;ee(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let r=0;r<RD.length;r++){const s=t.match(RD[r]);if(s==null)continue;const i=s[1].toLowerCase();switch(i){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=N1(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=i==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:i,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const l=(s[2]||"").split("/");if(l.length!==2)return e.push({type:`!${i}caip`,value:s[2]||""}),{url:null,linkage:e};const c=l[1],u=new jc(l[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(i==="erc721"){const m=await u.ownerOf(c);if(a!==m)return e.push({type:"!owner",value:m}),{url:null,linkage:e};e.push({type:"owner",value:m})}else if(i==="erc1155"){const m=await u.balanceOf(a,c);if(!m)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:m.toString()})}let f=await u[o](c);if(f==null||f==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:f}),i==="erc1155"&&(f=f.replace("{id}",bo(c,32).substring(2)),e.push({type:"metadata-url-expanded",value:f})),f.match(/^ipfs:/i)&&(f=N1(f)),e.push({type:"metadata-url",value:f});let d={};const h=await new Ln(f).send();h.assertOk();try{d=h.bodyJson}catch{try{e.push({type:"!metadata",value:h.bodyText})}catch{const b=h.body;return b&&e.push({type:"!metadata",value:we(b)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!d)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(d)});let p=d.image;if(typeof p!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!p.match(/^(https:\/\/|data:)/i)){if(p.match(OD)==null)return e.push({type:"!imageUrl-ipfs",value:p}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:p}),p=N1(p)}return e.push({type:"url",value:p}),{linkage:e,url:p}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),r=t.getPlugin("org.ethers.plugins.network.Ens");return ee(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),r.address}static async fromName(e,t){var s;let r=t;for(;;){if(r===""||r==="."||t!=="eth"&&r==="eth")return null;const i=await fe(s=yu,Jg,nP).call(s,e,r);if(i!=null){const o=new yu(e,i,t);return r!==t&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};Io=new WeakMap,ul=new WeakMap,Lo=new WeakSet,ju=async function(e,t){t=(t||[]).slice();const r=T(this,ul).interface;t.unshift(d1(this.name));let s=null;await this.supportsWildcard()&&(s=r.getFunction(e),ee(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[hK(this.name,255),r.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const i=await T(this,ul)[e](...t);return s?r.decodeFunctionResult(s,i)[0]:i}catch(i){if(!ln(i,"CALL_EXCEPTION"))throw i}return null},Jg=new WeakSet,nP=async function(e,t){const r=await yu.getEnsAddress(e);try{const i=await new jc(r,["function resolver(bytes32) view returns (address)"],e).resolver(d1(t),{enableCcipRead:!0});return i===wd?null:i}catch(s){throw s}return null},q(yu,Jg);let Sg=yu;const MD=BigInt(0);function ot(n,e){return function(t){return t==null?e:n(t)}}function Tg(n,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(r=>n(r))}}function Pd(n,e){return t=>{const r={};for(const s in n){let i=s;if(e&&s in e&&!(i in t)){for(const o of e[s])if(o in t){i=o;break}}try{const o=n[s](t[i]);o!==void 0&&(r[s]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";ee(!1,`invalid value for value.${s} (${a})`,"BAD_DATA",{value:t})}}return r}}function hJ(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}V(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Uc(n){return V(At(n,!0),"invalid data","value",n),n}function yn(n){return V(At(n,32),"invalid hash","value",n),n}const pJ=Pd({address:dt,blockHash:yn,blockNumber:Je,data:Uc,index:Je,removed:ot(hJ,!1),topics:Tg(yn),transactionHash:yn,transactionIndex:Je},{index:["logIndex"]});function mJ(n){return pJ(n)}const gJ=Pd({hash:ot(yn),parentHash:yn,parentBeaconBlockRoot:ot(yn,null),number:Je,timestamp:Je,nonce:ot(Uc),difficulty:Ae,gasLimit:Ae,gasUsed:Ae,stateRoot:ot(yn,null),receiptsRoot:ot(yn,null),blobGasUsed:ot(Ae,null),excessBlobGas:ot(Ae,null),miner:ot(dt),prevRandao:ot(yn,null),extraData:Uc,baseFeePerGas:ot(Ae)},{prevRandao:["mixHash"]});function yJ(n){const e=gJ(n);return e.transactions=n.transactions.map(t=>typeof t=="string"?t:DD(t)),e}const bJ=Pd({transactionIndex:Je,blockNumber:Je,transactionHash:yn,address:dt,topics:Tg(yn),data:Uc,index:Je,blockHash:yn},{index:["logIndex"]});function wJ(n){return bJ(n)}const vJ=Pd({to:ot(dt,null),from:ot(dt,null),contractAddress:ot(dt,null),index:Je,root:ot(we),gasUsed:Ae,blobGasUsed:ot(Ae,null),logsBloom:ot(Uc),blockHash:yn,hash:yn,logs:Tg(wJ),blockNumber:Je,cumulativeGasUsed:Ae,effectiveGasPrice:ot(Ae),blobGasPrice:ot(Ae,null),status:ot(Je),type:ot(Je,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function xJ(n){return vJ(n)}function DD(n){n.to&&Ae(n.to)===MD&&(n.to="0x0000000000000000000000000000000000000000");const e=Pd({hash:yn,index:ot(Je,void 0),type:t=>t==="0x"||t==null?0:Je(t),accessList:ot(Co,null),blobVersionedHashes:ot(Tg(yn,!0),null),blockHash:ot(yn,null),blockNumber:ot(Je,null),transactionIndex:ot(Je,null),from:dt,gasPrice:ot(Ae),maxPriorityFeePerGas:ot(Ae),maxFeePerGas:ot(Ae),maxFeePerBlobGas:ot(Ae,null),gasLimit:Ae,to:ot(dt,null),value:Ae,nonce:Je,data:Uc,creates:ot(dt,null),chainId:ot(Ae,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(e.to==null&&e.creates==null&&(e.creates=mG(e)),(n.type===1||n.type===2)&&n.accessList==null&&(e.accessList=[]),n.signature?e.signature=as.from(n.signature):e.signature=as.from(n),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Ae(e.blockHash)===MD&&(e.blockHash=null),e}const AJ="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Id{constructor(e){$(this,"name");Oe(this,{name:e})}clone(){return new Id(this.name)}}class Ng extends Id{constructor(t,r){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);$(this,"effectiveBlock");$(this,"txBase");$(this,"txCreate");$(this,"txDataZero");$(this,"txDataNonzero");$(this,"txAccessListStorageKey");$(this,"txAccessListAddress");const s={effectiveBlock:t};function i(o,a){let l=(r||{})[o];l==null&&(l=a),V(typeof l=="number",`invalud value for ${o}`,"costs",r),s[o]=l}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),Oe(this,s)}clone(){return new Ng(this.effectiveBlock,this)}}class Og extends Id{constructor(t,r){super("org.ethers.plugins.network.Ens");$(this,"address");$(this,"targetNetwork");Oe(this,{address:t||AJ,targetNetwork:r??1})}clone(){return new Og(this.address,this.targetNetwork)}}class EJ extends Id{constructor(t,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");q(this,Kd);q(this,Jd);I(this,Kd,t),I(this,Jd,r)}get url(){return T(this,Kd)}get processFunc(){return T(this,Jd)}clone(){return this}}Kd=new WeakMap,Jd=new WeakMap;const O1=new Map,vu=class vu{constructor(e,t){q(this,bu);q(this,wu);q(this,_o);I(this,bu,e),I(this,wu,Ae(t)),I(this,_o,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,bu)}set name(e){I(this,bu,e)}get chainId(){return T(this,wu)}set chainId(e){I(this,wu,Ae(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Ae(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Ae(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Ae(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(T(this,_o).values())}attachPlugin(e){if(T(this,_o).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,_o).set(e.name,e.clone()),this}getPlugin(e){return T(this,_o).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new vu(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new Ng;let r=t.txBase;if(e.to==null&&(r+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?r+=t.txDataZero:r+=t.txDataNonzero;if(e.accessList){const s=Co(e.accessList);for(const i in s)r+=t.txAccessListAddress+t.txAccessListStorageKey*s[i].storageKeys.length}return r}static from(e){if(kJ(),e==null)return vu.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=O1.get(e);if(t)return t();if(typeof e=="bigint")return new vu("unknown",e);V(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){V(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new vu(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Og(e.ensAddress,e.ensNetwork)),t}V(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const r=O1.get(e);r&&V(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",e),O1.set(e,t)}};bu=new WeakMap,wu=new WeakMap,_o=new WeakMap;let Yt=vu;function PD(n,e){const t=String(n);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=t.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<e;)r[1]+="0";if(r[1].length>9){let s=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||s++,r[1]=s.toString()}return BigInt(r[0]+r[1])}function ID(n){return new EJ(n,async(e,t,r)=>{r.setHeader("User-Agent","ethers");let s;try{const[i,o]=await Promise.all([r.send(),e()]);s=i;const a=s.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:PD(a.maxFee,9),maxPriorityFeePerGas:PD(a.maxPriorityFee,9)}}catch(i){ee(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:s,error:i})}})}let LD=!1;function kJ(){if(LD)return;LD=!0;function n(e,t,r){const s=function(){const i=new Yt(e,t);return r.ensNetwork!=null&&i.attachPlugin(new Og(null,r.ensNetwork)),i.attachPlugin(new Ng),(r.plugins||[]).forEach(o=>{i.attachPlugin(o)}),i};Yt.register(e,s),Yt.register(t,s),r.altNames&&r.altNames.forEach(i=>{Yt.register(i,s)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[ID("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[ID("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function R1(n){return JSON.parse(JSON.stringify(n))}class CJ{constructor(e){q(this,xu);q(this,_i);q(this,Ur);q(this,Bo);q(this,Qs);I(this,_i,e),I(this,Ur,null),I(this,Bo,4e3),I(this,Qs,-2)}get pollingInterval(){return T(this,Bo)}set pollingInterval(e){I(this,Bo,e)}start(){T(this,Ur)||(I(this,Ur,T(this,_i)._setTimeout(fe(this,xu,ny).bind(this),T(this,Bo))),fe(this,xu,ny).call(this))}stop(){T(this,Ur)&&(T(this,_i)._clearTimeout(T(this,Ur)),I(this,Ur,null))}pause(e){this.stop(),e&&I(this,Qs,-2)}resume(){this.start()}}_i=new WeakMap,Ur=new WeakMap,Bo=new WeakMap,Qs=new WeakMap,xu=new WeakSet,ny=async function(){try{const e=await T(this,_i).getBlockNumber();if(T(this,Qs)===-2){I(this,Qs,e);return}if(e!==T(this,Qs)){for(let t=T(this,Qs)+1;t<=e;t++){if(T(this,Ur)==null)return;await T(this,_i).emit("block",t)}I(this,Qs,e)}}catch{}T(this,Ur)!=null&&I(this,Ur,T(this,_i)._setTimeout(fe(this,xu,ny).bind(this),T(this,Bo)))};class M1{constructor(e){q(this,fl);q(this,dl);q(this,Fo);I(this,fl,e),I(this,Fo,!1),I(this,dl,t=>{this._poll(t,T(this,fl))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){T(this,Fo)||(I(this,Fo,!0),T(this,dl).call(this,-2),T(this,fl).on("block",T(this,dl)))}stop(){T(this,Fo)&&(I(this,Fo,!1),T(this,fl).off("block",T(this,dl)))}pause(e){this.stop()}resume(){this.start()}}fl=new WeakMap,dl=new WeakMap,Fo=new WeakMap;class SJ extends M1{constructor(t,r){super(t);q(this,Au);q(this,Bi);I(this,Au,r),I(this,Bi,-2)}pause(t){t&&I(this,Bi,-2),super.pause(t)}async _poll(t,r){const s=await r.getBlock(T(this,Au));s!=null&&(T(this,Bi)===-2?I(this,Bi,s.number):s.number>T(this,Bi)&&(r.emit(T(this,Au),s.number),I(this,Bi,s.number)))}}Au=new WeakMap,Bi=new WeakMap;class TJ extends M1{constructor(t,r){super(t);q(this,qg);I(this,qg,R1(r))}async _poll(t,r){throw new Error("@TODO")}}qg=new WeakMap;class NJ extends M1{constructor(t,r){super(t);q(this,Eu);I(this,Eu,r)}async _poll(t,r){const s=await r.getTransactionReceipt(T(this,Eu));s&&r.emit(T(this,Eu),s)}}Eu=new WeakMap;class D1{constructor(e,t){q(this,Qg);q(this,Fi);q(this,ku);q(this,Cu);q(this,jo);q(this,Hr);I(this,Fi,e),I(this,ku,R1(t)),I(this,Cu,fe(this,Qg,rP).bind(this)),I(this,jo,!1),I(this,Hr,-2)}start(){T(this,jo)||(I(this,jo,!0),T(this,Hr)===-2&&T(this,Fi).getBlockNumber().then(e=>{I(this,Hr,e)}),T(this,Fi).on("block",T(this,Cu)))}stop(){T(this,jo)&&(I(this,jo,!1),T(this,Fi).off("block",T(this,Cu)))}pause(e){this.stop(),e&&I(this,Hr,-2)}resume(){this.start()}}Fi=new WeakMap,ku=new WeakMap,Cu=new WeakMap,jo=new WeakMap,Hr=new WeakMap,Qg=new WeakSet,rP=async function(e){if(T(this,Hr)===-2)return;const t=R1(T(this,ku));t.fromBlock=T(this,Hr)+1,t.toBlock=e;const r=await T(this,Fi).getLogs(t);if(r.length===0){T(this,Hr)<e-60&&I(this,Hr,e-60);return}for(const s of r)T(this,Fi).emit(T(this,ku),s),I(this,Hr,s.blockNumber)};const OJ=BigInt(2),RJ=10;function Rg(n){return n&&typeof n.then=="function"}function Mg(n,e){return n+":"+JSON.stringify(e,(t,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const s=Object.keys(r);return s.sort(),s.reduce((i,o)=>(i[o]=r[o],i),{})}return r})}class Dg{constructor(e){$(this,"name");Oe(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function MJ(n){return JSON.parse(JSON.stringify(n))}function P1(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function I1(n,e){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(At(n,32)){const t=n.toLowerCase();return{type:"transaction",tag:Mg("tx",{hash:t}),hash:t}}if(n.orphan){const t=n;return{type:"orphan",tag:Mg("orphan",t),filter:MJ(t)}}if(n.address||n.topics){const t=n,r={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?P1(s.map(i=>i.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],i=[],o=a=>{At(a)?s.push(a):i.push((async()=>{s.push(await Bn(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),i.length&&await Promise.all(i),r.address=P1(s.map(a=>a.toLowerCase()))}return{filter:r,tag:Mg("event",r),type:"event"}}V(!1,"unknown ProviderEvent","event",n)}function L1(){return new Date().getTime()}const DJ={cacheTimeout:250,pollingInterval:4e3};class Pg{constructor(e,t){q(this,nt);q(this,Cn);q(this,Uo);q(this,Sn);q(this,Su);q(this,Ar);q(this,hl);q(this,Ho);q(this,ji);q(this,qd);q(this,zr);q(this,Tu);q(this,Nu);if(I(this,Nu,Object.assign({},DJ,t||{})),e==="any")I(this,hl,!0),I(this,Ar,null);else if(e){const r=Yt.from(e);I(this,hl,!1),I(this,Ar,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else I(this,hl,!1),I(this,Ar,null);I(this,ji,-1),I(this,Ho,new Map),I(this,Cn,new Map),I(this,Uo,new Map),I(this,Sn,null),I(this,Su,!1),I(this,qd,1),I(this,zr,new Map),I(this,Tu,!1)}get pollingInterval(){return T(this,Nu).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Uo).values())}attachPlugin(e){if(T(this,Uo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,Uo).set(e.name,e.connect(this)),this}getPlugin(e){return T(this,Uo).get(e)||null}get disableCcipRead(){return T(this,Tu)}set disableCcipRead(e){I(this,Tu,!!e)}async ccipReadFetch(e,t,r){if(this.disableCcipRead||r.length===0||e.to==null)return null;const s=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let a=0;a<r.length;a++){const l=r[a],c=l.replace("{sender}",s).replace("{data}",i),u=new Ln(c);l.indexOf("{data}")===-1&&(u.body={data:i,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:a,urls:r});let f="unknown error";const d=await u.send();try{const h=d.bodyJson;if(h.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:h}),h.data;h.message&&(f=h.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:h})}catch{}ee(d.statusCode<400||d.statusCode>=500,`response not found during CCIP fetch: ${f}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:l,errorMessage:f}}),o.push(f)}ee(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:r,errorMessages:o}})}_wrapBlock(e,t){return new XK(yJ(e),this)}_wrapLog(e,t){return new Rd(mJ(e),this)}_wrapTransactionReceipt(e,t){return new gD(xJ(e),this)}_wrapTransactionResponse(e,t){return new Md(DD(e),this)}_detectNetwork(){ee(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){ee(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=Je(await fe(this,nt,Er).call(this,{method:"getBlockNumber"}),"%response");return T(this,ji)>=0&&I(this,ji,e),e}_getAddress(e){return Bn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(At(e))return At(e,32)?e:La(e);if(typeof e=="bigint"&&(e=Je(e,"blockTag")),typeof e=="number")return e>=0?La(e):T(this,ji)>=0?La(T(this,ji)+e):this.getBlockNumber().then(t=>La(t+e));V(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(l=>l==null?null:Array.isArray(l)?P1(l.map(c=>c.toLowerCase())):l.toLowerCase()),r="blockHash"in e?e.blockHash:void 0,s=(l,c,u)=>{let f;switch(l.length){case 0:break;case 1:f=l[0];break;default:l.sort(),f=l}if(r&&(c!=null||u!=null))throw new Error("invalid filter");const d={};return f&&(d.address=f),t.length&&(d.topics=t),c&&(d.fromBlock=c),u&&(d.toBlock=u),r&&(d.blockHash=r),d};let i=[];if(e.address)if(Array.isArray(e.address))for(const l of e.address)i.push(this._getAddress(l));else i.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),i.filter(l=>typeof l!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(i),o,a]).then(l=>s(l[0],l[1],l[2])):s(i,o,a)}_getTransactionRequest(e){const t=Ag(e),r=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const i=Bn(t[s],this);Rg(i)?r.push(async function(){t[s]=await i}()):t[s]=i}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);Rg(s)?r.push(async function(){t.blockTag=await s}()):t.blockTag=s}return r.length?async function(){return await Promise.all(r),t}():t}async getNetwork(){if(T(this,Ar)==null){const s=(async()=>{try{const i=await this._detectNetwork();return this.emit("network",i,null),i}catch(i){throw T(this,Ar)===s&&I(this,Ar,null),i}})();return I(this,Ar,s),(await s).clone()}const e=T(this,Ar),[t,r]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==r.chainId&&(T(this,hl)?(this.emit("network",r,t),T(this,Ar)===e&&I(this,Ar,Promise.resolve(r))):ee(!1,`network changed: ${t.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:i,priorityFee:o}=await An({_block:fe(this,nt,ox).call(this,"latest",!1),gasPrice:(async()=>{try{const u=await fe(this,nt,Er).call(this,{method:"getGasPrice"});return Ae(u,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const u=await fe(this,nt,Er).call(this,{method:"getPriorityFee"});return Ae(u,"%response")}catch{}return null})()});let a=null,l=null;const c=this._wrapBlock(s,e);return c&&c.baseFeePerGas&&(l=o??BigInt("1000000000"),a=c.baseFeePerGas*OJ+l),new mD(i,a,l)},r=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const s=new Ln(r.url),i=await r.processFunc(t,this,s);return new mD(i.gasPrice,i.maxFeePerGas,i.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return Rg(t)&&(t=await t),Ae(await fe(this,nt,Er).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:r}=await An({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await fe(this,nt,ix).call(this,fe(this,nt,sx).call(this,t,r,e.enableCcipRead?0:-1))}async getBalance(e,t){return Ae(await fe(this,nt,th).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return Je(await fe(this,nt,th).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return we(await fe(this,nt,th).call(this,{method:"getCode"},e,t))}async getStorage(e,t,r){const s=Ae(t,"position");return we(await fe(this,nt,th).call(this,{method:"getStorage",position:s},e,r))}async broadcastTransaction(e){const{blockNumber:t,hash:r,network:s}=await An({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),i=Nd.from(e);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,s).replaceableTransaction(t)}async getBlock(e,t){const{network:r,params:s}=await An({network:this.getNetwork(),params:fe(this,nt,ox).call(this,e,!!t)});return s==null?null:this._wrapBlock(s,r)}async getTransaction(e){const{network:t,params:r}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getTransaction",hash:e})});return r==null?null:this._wrapTransactionResponse(r,t)}async getTransactionReceipt(e){const{network:t,params:r}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getTransactionReceipt",hash:e})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const s=await fe(this,nt,Er).call(this,{method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(r,t)}async getTransactionResult(e){const{result:t}=await An({network:this.getNetwork(),result:fe(this,nt,Er).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:we(t)}async getLogs(e){let t=this._getFilter(e);Rg(t)&&(t=await t);const{network:r,params:s}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getLogs",filter:t})});return s.map(i=>this._wrapLog(i,r))}_getProvider(e){ee(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Sg.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=dt(e);const t=d1(e.substring(2).toLowerCase()+".addr.reverse");try{const r=await Sg.getEnsAddress(this),i=await new jc(r,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(i==null||i===wd)return null;const a=await new jc(i,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(r){if(ln(r,"BAD_DATA")&&r.value==="0x"||ln(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(e,t,r){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(i,o)=>{let a=null;const l=async c=>{try{const u=await this.getTransactionReceipt(e);if(u!=null&&c-u.blockNumber+1>=s){i(u),a&&(clearTimeout(a),a=null);return}}catch(u){console.log("EEE",u)}this.once("block",l)};r!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",l),o(Nt("timeout","TIMEOUT",{reason:"timeout"})))},r)),l(await this.getBlockNumber())})}async waitForBlock(e){ee(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=T(this,zr).get(e);t&&(t.timer&&clearTimeout(t.timer),T(this,zr).delete(e))}_setTimeout(e,t){t==null&&(t=0);const r=Zd(this,qd)._++,s=()=>{T(this,zr).delete(r),e()};if(this.paused)T(this,zr).set(r,{timer:null,func:s,time:t});else{const i=setTimeout(s,t);T(this,zr).set(r,{timer:i,func:s,time:L1()})}return r}_forEachSubscriber(e){for(const t of T(this,Cn).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Dg(e.type);case"block":{const t=new CJ(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new SJ(this,e.type);case"event":return new D1(this,e.filter);case"transaction":return new NJ(this,e.hash);case"orphan":return new TJ(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const r of T(this,Cn).values())if(r.subscriber===e){r.started&&r.subscriber.stop(),r.subscriber=t,r.started&&t.start(),T(this,Sn)!=null&&t.pause(T(this,Sn));break}}async on(e,t){const r=await fe(this,nt,ry).call(this,e);return r.listeners.push({listener:t,once:!1}),r.started||(r.subscriber.start(),r.started=!0,T(this,Sn)!=null&&r.subscriber.pause(T(this,Sn))),this}async once(e,t){const r=await fe(this,nt,ry).call(this,e);return r.listeners.push({listener:t,once:!0}),r.started||(r.subscriber.start(),r.started=!0,T(this,Sn)!=null&&r.subscriber.pause(T(this,Sn))),this}async emit(e,...t){const r=await fe(this,nt,nh).call(this,e,t);if(!r||r.listeners.length===0)return!1;const s=r.listeners.length;return r.listeners=r.listeners.filter(({listener:i,once:o})=>{const a=new XO(this,o?null:i,e);try{i.call(this,...t,a)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),T(this,Cn).delete(r.tag)),s>0}async listenerCount(e){if(e){const r=await fe(this,nt,nh).call(this,e);return r?r.listeners.length:0}let t=0;for(const{listeners:r}of T(this,Cn).values())t+=r.length;return t}async listeners(e){if(e){const r=await fe(this,nt,nh).call(this,e);return r?r.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:r}of T(this,Cn).values())t=t.concat(r.map(({listener:s})=>s));return t}async off(e,t){const r=await fe(this,nt,nh).call(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(!t||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),T(this,Cn).delete(r.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:r,subscriber:s}=await fe(this,nt,ry).call(this,e);r&&s.stop(),T(this,Cn).delete(t)}else for(const[t,{started:r,subscriber:s}]of T(this,Cn))r&&s.stop(),T(this,Cn).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return T(this,Su)}destroy(){this.removeAllListeners();for(const e of T(this,zr).keys())this._clearTimeout(e);I(this,Su,!0)}get paused(){return T(this,Sn)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(I(this,ji,-1),T(this,Sn)!=null){if(T(this,Sn)==!!e)return;ee(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),I(this,Sn,!!e);for(const t of T(this,zr).values())t.timer&&clearTimeout(t.timer),t.time=L1()-t.time}resume(){if(T(this,Sn)!=null){this._forEachSubscriber(e=>e.resume()),I(this,Sn,null);for(const e of T(this,zr).values()){let t=e.time;t<0&&(t=0),e.time=L1(),setTimeout(e.func,t)}}}}Cn=new WeakMap,Uo=new WeakMap,Sn=new WeakMap,Su=new WeakMap,Ar=new WeakMap,hl=new WeakMap,Ho=new WeakMap,ji=new WeakMap,qd=new WeakMap,zr=new WeakMap,Tu=new WeakMap,Nu=new WeakMap,nt=new WeakSet,Er=async function(e){const t=T(this,Nu).cacheTimeout;if(t<0)return await this._perform(e);const r=Mg(e.method,e);let s=T(this,Ho).get(r);return s||(s=this._perform(e),T(this,Ho).set(r,s),setTimeout(()=>{T(this,Ho).get(r)===s&&T(this,Ho).delete(r)},t)),await s},sx=async function(e,t,r){ee(r<RJ,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=Ag(e);try{return we(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(i){if(!this.disableCcipRead&&Rv(i)&&i.data&&r>=0&&t==="latest"&&s.to!=null&&Ft(i.data,0,4)==="0x556f1830"){const o=i.data,a=await Bn(s.to,this);let l;try{l=BJ(Ft(i.data,4))}catch(f){ee(!1,f.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:o}})}ee(l.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:l.errorArgs}});const c=await this.ccipReadFetch(s,l.calldata,l.urls);ee(c!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:i.data,errorArgs:l.errorArgs}});const u={to:a,data:Ut([l.selector,_J([c,l.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const f=await fe(this,nt,sx).call(this,u,t,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:f}),f}catch(f){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:f}),f}}throw i}},ix=async function(e){const{value:t}=await An({network:this.getNetwork(),value:e});return t},th=async function(e,t,r){let s=this._getAddress(t),i=this._getBlockTag(r);return(typeof s!="string"||typeof i!="string")&&([s,i]=await Promise.all([s,i])),await fe(this,nt,ix).call(this,fe(this,nt,Er).call(this,Object.assign(e,{address:s,blockTag:i})))},ox=async function(e,t){if(At(e,32))return await fe(this,nt,Er).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let r=this._getBlockTag(e);return typeof r!="string"&&(r=await r),await fe(this,nt,Er).call(this,{method:"getBlock",blockTag:r,includeTransactions:t})},nh=async function(e,t){let r=await I1(e,this);return r.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(r=await I1({orphan:"drop-log",log:t[0]},this)),T(this,Cn).get(r.tag)||null},ry=async function(e){const t=await I1(e,this),r=t.tag;let s=T(this,Cn).get(r);return s||(s={subscriber:this._getSubscriber(t),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,Cn).set(r,s)),s};function PJ(n,e){try{const t=_1(n,e);if(t)return Cc(t)}catch{}return null}function _1(n,e){if(n==="0x")return null;try{const t=Je(Ft(n,e,e+32)),r=Je(Ft(n,t,t+32));return Ft(n,t+32,t+32+r)}catch{}return null}function _D(n){const e=In(n);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function IJ(n){if(n.length%32===0)return n;const e=new Uint8Array(Math.ceil(n.length/32)*32);return e.set(n),e}const LJ=new Uint8Array([]);function _J(n){const e=[];let t=0;for(let r=0;r<n.length;r++)e.push(LJ),t+=32;for(let r=0;r<n.length;r++){const s=lt(n[r]);e[r]=_D(t),e.push(_D(s.length)),e.push(IJ(s)),t+=32+Math.ceil(s.length/32)*32}return Ut(e)}const BD="0x0000000000000000000000000000000000000000000000000000000000000000";function BJ(n){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ee(Ec(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=Ft(n,0,32);ee(Ft(t,0,12)===Ft(BD,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Ft(t,12);try{const r=[],s=Je(Ft(n,32,64)),i=Je(Ft(n,s,s+32)),o=Ft(n,s+32);for(let a=0;a<i;a++){const l=PJ(o,a*32);if(l==null)throw new Error("abort");r.push(l)}e.urls=r}catch{ee(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=_1(n,64);if(r==null)throw new Error("abort");e.calldata=r}catch{ee(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ee(Ft(n,100,128)===Ft(BD,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Ft(n,96,100);try{const r=_1(n,128);if(r==null)throw new Error("abort");e.extraData=r}catch{ee(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>e[r]),e}function Hc(n,e){if(n.provider)return n.provider;ee(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function FD(n,e){let t=Ag(e);if(t.to!=null&&(t.to=Bn(t.to,n)),t.from!=null){const r=t.from;t.from=Promise.all([n.getAddress(),Bn(r,n)]).then(([s,i])=>(V(s.toLowerCase()===i.toLowerCase(),"transaction from mismatch","tx.from",i),s))}else t.from=n.getAddress();return await An(t)}class FJ{constructor(e){$(this,"provider");Oe(this,{provider:e||null})}async getNonce(e){return Hc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await FD(this,e)}async populateTransaction(e){const t=Hc(this,"populateTransaction"),r=await FD(this,e);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const s=await this.provider.getNetwork();if(r.chainId!=null){const o=Ae(r.chainId);V(o===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else r.chainId=s.chainId;const i=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||i)?V(!1,"eip-1559 transaction do not support gasPrice","tx",e):(r.type===0||r.type===1)&&i&&V(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await t.getFeeData();ee(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const a=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=a,r.maxPriorityFeePerGas=a}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ee(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):ee(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await An(r)}async estimateGas(e){return Hc(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Hc(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Hc(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Hc(this,"sendTransaction"),r=await this.populateTransaction(e);delete r.from;const s=Nd.from(r);return await t.broadcastTransaction(await this.signTransaction(s))}}const jD=new Set;function zc(n){jD.has(n)||(jD.add(n),console.log("========= NOTICE ========="),console.log(`Request-Rate Exceeded for ${n} (this message will not be repeated)`),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.org/api-keys/"),console.log("=========================="))}function jJ(n){return JSON.parse(JSON.stringify(n))}class UD{constructor(e){q(this,Vo);q(this,jn);q(this,Ys);q(this,pl);q(this,zo);q(this,ml);q(this,Ou);I(this,jn,e),I(this,Ys,null),I(this,pl,fe(this,Vo,ax).bind(this)),I(this,zo,!1),I(this,ml,null),I(this,Ou,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){T(this,zo)||(I(this,zo,!0),fe(this,Vo,ax).call(this,-2))}stop(){T(this,zo)&&(I(this,zo,!1),I(this,Ou,!0),fe(this,Vo,lx).call(this),T(this,jn).off("block",T(this,pl)))}pause(e){e&&fe(this,Vo,lx).call(this),T(this,jn).off("block",T(this,pl))}resume(){this.start()}}jn=new WeakMap,Ys=new WeakMap,pl=new WeakMap,zo=new WeakMap,ml=new WeakMap,Ou=new WeakMap,Vo=new WeakSet,ax=async function(e){try{T(this,Ys)==null&&I(this,Ys,this._subscribe(T(this,jn)));let t=null;try{t=await T(this,Ys)}catch(i){if(!ln(i,"UNSUPPORTED_OPERATION")||i.operation!=="eth_newFilter")throw i}if(t==null){I(this,Ys,null),T(this,jn)._recoverSubscriber(this,this._recover(T(this,jn)));return}const r=await T(this,jn).getNetwork();if(T(this,ml)||I(this,ml,r),T(this,ml).chainId!==r.chainId)throw new Error("chaid changed");if(T(this,Ou))return;const s=await T(this,jn).send("eth_getFilterChanges",[t]);await this._emitResults(T(this,jn),s)}catch(t){console.log("@TODO",t)}T(this,jn).once("block",T(this,pl))},lx=function(){const e=T(this,Ys);e&&(I(this,Ys,null),e.then(t=>{T(this,jn).destroyed||T(this,jn).send("eth_uninstallFilter",[t])}))};class UJ extends UD{constructor(t,r){super(t);q(this,gl);I(this,gl,jJ(r))}_recover(t){return new D1(t,T(this,gl))}async _subscribe(t){return await t.send("eth_newFilter",[T(this,gl)])}async _emitResults(t,r){for(const s of r)t.emit(T(this,gl),t._wrapLog(s,t._network))}}gl=new WeakMap;class HJ extends UD{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const r of t)e.emit("pending",r)}}const zJ="bigint,boolean,function,number,string,symbol".split(/,/g);function Ig(n){if(n==null||zJ.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(Ig);if(typeof n=="object")return Object.keys(n).reduce((e,t)=>(e[t]=n[t],e),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function VJ(n){return new Promise(e=>{setTimeout(e,n)})}function Vc(n){return n&&n.toLowerCase()}function HD(n){return n&&typeof n.pollingInterval=="number"}const zD={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class B1 extends FJ{constructor(t,r){super(t);$(this,"address");r=dt(r),Oe(this,{address:r})}connect(t){ee(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const r=Ig(t),s=[];if(r.from){const o=r.from;s.push((async()=>{const a=await Bn(o,this.provider);V(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=a})())}else r.from=this.address;if(r.gasLimit==null&&s.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;s.push((async()=>{r.to=await Bn(o,this.provider)})())}s.length&&await Promise.all(s);const i=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const r=await this.provider.getBlockNumber(),s=await this.sendUncheckedTransaction(t);return await new Promise((i,o)=>{const a=[1e3,100];let l=0;const c=async()=>{try{const u=await this.provider.getTransaction(s);if(u!=null){i(u.replaceableTransaction(r));return}}catch(u){if(ln(u,"CANCELLED")||ln(u,"BAD_DATA")||ln(u,"NETWORK_ERROR")){u.info==null&&(u.info={}),u.info.sendTransactionHash=s,o(u);return}if(ln(u,"INVALID_ARGUMENT")&&(l++,u.info==null&&(u.info={}),u.info.sendTransactionHash=s,l>10)){o(u);return}this.provider.emit("error",Nt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:u}))}this.provider._setTimeout(()=>{c()},a.pop()||4e3)};c()})}async signTransaction(t){const r=Ig(t);if(r.from){const i=await Bn(r.from,this.provider);V(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=i}else r.from=this.address;const s=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[s])}async signMessage(t){const r=typeof t=="string"?bi(t):t;return await this.provider.send("personal_sign",[we(r),this.address.toLowerCase()])}async signTypedData(t,r,s){const i=Ig(s),o=await wg.resolveNames(t,r,i,async a=>{const l=await Bn(a);return V(l!=null,"TypedData does not support null address","value",a),l});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(wg.getPayload(o.domain,r,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const r=typeof t=="string"?bi(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),we(r)])}}class VD extends Pg{constructor(t,r){super(t,r);q(this,Qd);q(this,yl);q(this,Ru);q(this,Ui);q(this,Xs);q(this,ps);q(this,Vr);q(this,tr);I(this,Ru,1),I(this,yl,Object.assign({},zD,r||{})),I(this,Ui,[]),I(this,Xs,null),I(this,Vr,null),I(this,tr,null);{let i=null;const o=new Promise(a=>{i=a});I(this,ps,{promise:o,resolve:i})}const s=this._getOption("staticNetwork");typeof s=="boolean"?(V(!s||t!=="any","staticNetwork cannot be used on special network 'any'","options",r),s&&t!=null&&I(this,Vr,Yt.from(t))):s&&(V(t==null||s.matches(t),"staticNetwork MUST match network object","options",r),I(this,Vr,s))}_getOption(t){return T(this,yl)[t]}get _network(){return ee(T(this,Vr),"network is not available yet","NETWORK_ERROR"),T(this,Vr)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let s=t.transaction;if(s&&s.type!=null&&Ae(s.type)&&s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},s,{type:void 0})}))}}const r=this.getRpcRequest(t);return r!=null?await this.send(r.method,r.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(T(this,Vr))return T(this,Vr)}else return t;return T(this,tr)?await T(this,tr):this.ready?(I(this,tr,(async()=>{try{const r=Yt.from(Ae(await this.send("eth_chainId",[])));return I(this,tr,null),r}catch(r){throw I(this,tr,null),r}})()),await T(this,tr)):(I(this,tr,(async()=>{const r={id:Zd(this,Ru)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let s;try{s=(await this._send(r))[0],I(this,tr,null)}catch(i){throw I(this,tr,null),this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:s}),"result"in s)return Yt.from(Ae(s.result));throw this.getRpcError(r,s)})()),await T(this,tr))}_start(){T(this,ps)==null||T(this,ps).resolve==null||(T(this,ps).resolve(),I(this,ps,null),(async()=>{for(;T(this,Vr)==null&&!this.destroyed;)try{I(this,Vr,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Nt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await VJ(1e3)}fe(this,Qd,cx).call(this)})())}async _waitUntilReady(){if(T(this,ps)!=null)return await T(this,ps).promise}_getSubscriber(t){return t.type==="pending"?new HJ(this):t.type==="event"?this._getOption("polling")?new D1(this,t.filter):new UJ(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Dg("orphan"):super._getSubscriber(t)}get ready(){return T(this,ps)==null}getRpcTransaction(t){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(s=>{if(t[s]==null)return;let i=s;s==="gasLimit"&&(i="gas"),r[i]=La(Ae(t[s],`tx.${s}`))}),["from","to","data"].forEach(s=>{t[s]!=null&&(r[s]=we(t[s]))}),t.accessList&&(r.accessList=Co(t.accessList)),t.blobVersionedHashes&&(r.blobVersionedHashes=t.blobVersionedHashes.map(s=>s.toLowerCase())),r}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Vc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Vc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Vc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Vc(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Vc):t.filter.address=Vc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,r){const{method:s}=t,{error:i}=r;if(s==="eth_estimateGas"&&i.message){const l=i.message;if(!l.match(/revert/i)&&l.match(/insufficient funds/i))return Nt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(s==="eth_call"||s==="eth_estimateGas"){const l=F1(i),c=Bc.getBuiltinCallException(s==="eth_call"?"call":"estimateGas",t.params[0],l?l.data:null);return c.info={error:i,payload:t},c}const o=JSON.stringify(WJ(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return Nt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[s]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(s==="eth_sendRawTransaction"||s==="eth_sendTransaction"){const l=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Nt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:l,info:{error:i}});if(o.match(/nonce/i)&&o.match(/too low/i))return Nt("nonce has already been used","NONCE_EXPIRED",{transaction:l,info:{error:i}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Nt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:l,info:{error:i}});if(o.match(/only replay-protected/i))return Nt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:s,info:{transaction:l,info:{error:i}}})}let a=!!o.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?Nt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):Nt("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,r){if(this.destroyed)return Promise.reject(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const s=Zd(this,Ru)._++,i=new Promise((o,a)=>{T(this,Ui).push({resolve:o,reject:a,payload:{method:t,params:r,id:s,jsonrpc:"2.0"}})});return fe(this,Qd,cx).call(this),i}async getSigner(t){t==null&&(t=0);const r=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await r;if(t>=i.length)throw new Error("no such account");return new B1(this,i[t])}const{accounts:s}=await An({network:this.getNetwork(),accounts:r});t=dt(t);for(const i of s)if(dt(i)===t)return new B1(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new B1(this,r))}destroy(){T(this,Xs)&&(clearTimeout(T(this,Xs)),I(this,Xs,null));for(const{payload:t,reject:r}of T(this,Ui))r(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));I(this,Ui,[]),super.destroy()}}yl=new WeakMap,Ru=new WeakMap,Ui=new WeakMap,Xs=new WeakMap,ps=new WeakMap,Vr=new WeakMap,tr=new WeakMap,Qd=new WeakSet,cx=function(){if(T(this,Xs))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");I(this,Xs,setTimeout(()=>{I(this,Xs,null);const r=T(this,Ui);for(I(this,Ui,[]);r.length;){const s=[r.shift()];for(;r.length&&s.length!==T(this,yl).batchMaxCount;)if(s.push(r.shift()),JSON.stringify(s.map(o=>o.payload)).length>T(this,yl).batchMaxSize){r.unshift(s.pop());break}(async()=>{const i=s.length===1?s[0].payload:s.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const o=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:l,payload:c}of s){if(this.destroyed){l(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:c.method}));continue}const u=o.filter(f=>f.id===c.id)[0];if(u==null){const f=Nt("missing response for request","BAD_DATA",{value:o,info:{payload:c}});this.emit("error",f),l(f);continue}if("error"in u){l(this.getRpcError(c,u));continue}a(u.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of s)a(o)}})()}},t))};class $J extends VD{constructor(t,r){super(t,r);q(this,$o);let s=this._getOption("pollingInterval");s==null&&(s=zD.pollingInterval),I(this,$o,s)}_getSubscriber(t){const r=super._getSubscriber(t);return HD(r)&&(r.pollingInterval=T(this,$o)),r}get pollingInterval(){return T(this,$o)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");I(this,$o,t),this._forEachSubscriber(r=>{HD(r)&&(r.pollingInterval=T(this,$o))})}}$o=new WeakMap;class Si extends $J{constructor(t,r,s){t==null&&(t="http://localhost:8545");super(r,s);q(this,Mu);typeof t=="string"?I(this,Mu,new Ln(t)):I(this,Mu,t.clone())}_getConnection(){return T(this,Mu).clone()}async send(t,r){return await this._start(),await super.send(t,r)}async _send(t){const r=this._getConnection();r.body=JSON.stringify(t),r.setHeader("content-type","application/json");const s=await r.send();s.assertOk();let i=s.bodyJson;return Array.isArray(i)||(i=[i]),i}}Mu=new WeakMap;function F1(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&At(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const e in n){const t=F1(n[e]);if(t)return t}return null}if(typeof n=="string")try{return F1(JSON.parse(n))}catch{}return null}function j1(n,e){if(n!=null){if(typeof n.message=="string"&&e.push(n.message),typeof n=="object")for(const t in n)j1(n[t],e);if(typeof n=="string")try{return j1(JSON.parse(n),e)}catch{}}}function WJ(n){const e=[];return j1(n,e),e}const Lg="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function GJ(n){switch(n){case"mainnet":return"rpc.ankr.com/eth";case"goerli":return"rpc.ankr.com/eth_goerli";case"sepolia":return"rpc.ankr.com/eth_sepolia";case"arbitrum":return"rpc.ankr.com/arbitrum";case"base":return"rpc.ankr.com/base";case"base-goerli":return"rpc.ankr.com/base_goerli";case"base-sepolia":return"rpc.ankr.com/base_sepolia";case"bnb":return"rpc.ankr.com/bsc";case"bnbt":return"rpc.ankr.com/bsc_testnet_chapel";case"matic":return"rpc.ankr.com/polygon";case"matic-mumbai":return"rpc.ankr.com/polygon_mumbai";case"optimism":return"rpc.ankr.com/optimism";case"optimism-goerli":return"rpc.ankr.com/optimism_testnet";case"optimism-sepolia":return"rpc.ankr.com/optimism_sepolia"}V(!1,"unsupported network","network",n)}class _g extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Lg);const i={polling:!0,staticNetwork:s},o=_g.getRequest(s,r);super(o,s,i);$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new _g(t,this.apiKey)}catch{}return super._getProvider(t)}static getRequest(t,r){r==null&&(r=Lg);const s=new Ln(`https://${GJ(t.name)}/${r}`);return s.allowGzip=!0,r===Lg&&(s.retryFunc=async(i,o,a)=>(zc("AnkrProvider"),!0)),s}getRpcError(t,r){return t.method==="eth_sendRawTransaction"&&r&&r.error&&r.error.message==="INTERNAL_ERROR: could not replace existing tx"&&(r.error.message="replacement transaction underpriced"),super.getRpcError(t,r)}isCommunityResource(){return this.apiKey===Lg}}const Bg="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";function KJ(n){switch(n){case"mainnet":return"eth-mainnet.alchemyapi.io";case"goerli":return"eth-goerli.g.alchemy.com";case"sepolia":return"eth-sepolia.g.alchemy.com";case"arbitrum":return"arb-mainnet.g.alchemy.com";case"arbitrum-goerli":return"arb-goerli.g.alchemy.com";case"arbitrum-sepolia":return"arb-sepolia.g.alchemy.com";case"base":return"base-mainnet.g.alchemy.com";case"base-goerli":return"base-goerli.g.alchemy.com";case"base-sepolia":return"base-sepolia.g.alchemy.com";case"matic":return"polygon-mainnet.g.alchemy.com";case"matic-amoy":return"polygon-amoy.g.alchemy.com";case"matic-mumbai":return"polygon-mumbai.g.alchemy.com";case"optimism":return"opt-mainnet.g.alchemy.com";case"optimism-goerli":return"opt-goerli.g.alchemy.com";case"optimism-sepolia":return"opt-sepolia.g.alchemy.com"}V(!1,"unsupported network","network",n)}class Fg extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Bg);const i=Fg.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new Fg(t,this.apiKey)}catch{}return super._getProvider(t)}async _perform(t){if(t.method==="getTransactionResult"){const{trace:r,tx:s}=await An({trace:this.send("trace_transaction",[t.hash]),tx:this.getTransaction(t.hash)});if(r==null||s==null)return null;let i,o=!1;try{i=r[0].result.output,o=r[0].error==="Reverted"}catch{}if(i)return ee(!o,"an error occurred during transaction executions","CALL_EXCEPTION",{action:"getTransactionResult",data:i,reason:null,transaction:s,invocation:null,revert:null}),i;ee(!1,"could not parse trace result","BAD_DATA",{value:r})}return await super._perform(t)}isCommunityResource(){return this.apiKey===Bg}static getRequest(t,r){r==null&&(r=Bg);const s=new Ln(`https://${KJ(t.name)}/v2/${r}`);return s.allowGzip=!0,r===Bg&&(s.retryFunc=async(i,o,a)=>(zc("alchemy"),!0)),s}}function jg(n){switch(n){case"mainnet":return"39f1d67cedf8b7831010a665328c9197";case"arbitrum":return"0550c209db33c3abf4cc927e1e18cea1";case"bnb":return"98b5a77e531614387366f6fc5da097f8";case"matic":return"cd9d4d70377471aa7c142ec4a4205249"}V(!1,"unsupported network","network",n)}function JJ(n){switch(n){case"mainnet":return"ethereum-mainnet.core.chainstack.com";case"arbitrum":return"arbitrum-mainnet.core.chainstack.com";case"bnb":return"bsc-mainnet.core.chainstack.com";case"matic":return"polygon-mainnet.core.chainstack.com"}V(!1,"unsupported network","network",n)}class Ug extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=jg(s.name));const i=Ug.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new Ug(t,this.apiKey)}catch{}return super._getProvider(t)}isCommunityResource(){return this.apiKey===jg(this._network.name)}static getRequest(t,r){r==null&&(r=jg(t.name));const s=new Ln(`https://${JJ(t.name)}/${r}`);return s.allowGzip=!0,r===jg(t.name)&&(s.retryFunc=async(i,o,a)=>(zc("ChainstackProvider"),!0)),s}}class qJ extends Si{constructor(e){e==null&&(e="mainnet");const t=Yt.from(e);V(t.name==="mainnet","unsupported network","network",e),super("https://cloudflare-eth.com/",t,{staticNetwork:t})}}const $D=2e3;function QJ(n){return n&&typeof n.then=="function"}const YJ="org.ethers.plugins.provider.Etherscan",XJ=["enableCcipRead"];let ZJ=1;class eq extends Pg{constructor(t,r){const s=r??null;super();$(this,"network");$(this,"apiKey");q(this,Du);const i=Yt.from(t);I(this,Du,i.getPlugin(YJ)),Oe(this,{apiKey:s,network:i}),this.getBaseUrl()}getBaseUrl(){if(T(this,Du))return T(this,Du).baseUrl;switch(this.network.name){case"mainnet":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"holesky":return"https://api-holesky.etherscan.io";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"base":return"https://api.basescan.org";case"base-sepolia":return"https://api-sepolia.basescan.org";case"bnb":return"https://api.bscscan.com";case"bnbt":return"https://api-testnet.bscscan.com";case"matic":return"https://api.polygonscan.com";case"matic-amoy":return"https://api-amoy.polygonscan.com";case"matic-mumbai":return"https://api-testnet.polygonscan.com";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}V(!1,"unsupported network","network",this.network)}getUrl(t,r){const s=Object.keys(r).reduce((o,a)=>{const l=r[a];return l!=null&&(o+=`&${a}=${l}`),o},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.getBaseUrl()}/api?module=${t}${s}${i}`}getPostUrl(){return`${this.getBaseUrl()}/api`}getPostData(t,r){return r.module=t,r.apikey=this.apiKey,r}async detectNetwork(){return this.network}async fetch(t,r,s){const i=ZJ++,o=s?this.getPostUrl():this.getUrl(t,r),a=s?this.getPostData(t,r):null;this.emit("debug",{action:"sendRequest",id:i,url:o,payload:a});const l=new Ln(o);l.setThrottleParams({slotInterval:1e3}),l.retryFunc=(f,d,h)=>(this.isCommunityResource()&&zc("Etherscan"),Promise.resolve(!0)),l.processFunc=async(f,d)=>{const h=d.hasBody()?JSON.parse(Cc(d.body)):{},p=(typeof h.result=="string"?h.result:"").toLowerCase().indexOf("rate limit")>=0;return t==="proxy"?h&&h.status==0&&h.message=="NOTOK"&&p&&(this.emit("debug",{action:"receiveError",id:i,reason:"proxy-NOTOK",error:h}),d.throwThrottleError(h.result,$D)):p&&(this.emit("debug",{action:"receiveError",id:i,reason:"null result",error:h.result}),d.throwThrottleError(h.result,$D)),d},a&&(l.setHeader("content-type","application/x-www-form-urlencoded; charset=UTF-8"),l.body=Object.keys(a).map(f=>`${f}=${a[f]}`).join("&"));const c=await l.send();try{c.assertOk()}catch(f){this.emit("debug",{action:"receiveError",id:i,error:f,reason:"assertOk"}),ee(!1,"response error","SERVER_ERROR",{request:l,response:c})}c.hasBody()||(this.emit("debug",{action:"receiveError",id:i,error:"missing body",reason:"null body"}),ee(!1,"missing response","SERVER_ERROR",{request:l,response:c}));const u=JSON.parse(Cc(c.body));return t==="proxy"?(u.jsonrpc!="2.0"&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"invalid JSON-RPC"}),ee(!1,"invalid JSON-RPC response (missing jsonrpc='2.0')","SERVER_ERROR",{request:l,response:c,info:{result:u}})),u.error&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"JSON-RPC error"}),ee(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):u.status==0&&(u.message==="No records found"||u.message==="No transactions found")?(this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):((u.status!=1||typeof u.message=="string"&&!u.message.match(/^OK/))&&(this.emit("debug",{action:"receiveError",id:i,result:u}),ee(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result)}_getTransactionPostData(t){const r={};for(let s in t){if(XJ.indexOf(s)>=0||t[s]==null)continue;let i=t[s];if(!(s==="type"&&i===0)&&!(s==="blockTag"&&i==="latest")){if({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[s])i=La(i);else if(s==="accessList")i="["+Co(i).map(o=>`{address:"${o.address}",storageKeys:["${o.storageKeys.join('","')}"]}`).join(",")+"]";else if(s==="blobVersionedHashes"){if(i.length===0)continue;ee(!1,"Etherscan API does not support blobVersionedHashes","UNSUPPORTED_OPERATION",{operation:"_getTransactionPostData",info:{transaction:t}})}else i=we(i);r[s]=i}}return r}_checkError(t,r,s){let i="";if(ln(r,"SERVER_ERROR")){try{i=r.info.result.error.message}catch{}if(!i)try{i=r.info.message}catch{}}if(t.method==="estimateGas"&&!i.match(/revert/i)&&i.match(/insufficient funds/i)&&ee(!1,"insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.transaction}),(t.method==="call"||t.method==="estimateGas")&&i.match(/execution reverted/i)){let o="";try{o=r.info.result.error.data}catch{}const a=Bc.getBuiltinCallException(t.method,t.transaction,o);throw a.info={request:t,error:r},a}if(i&&t.method==="broadcastTransaction"){const o=Nd.from(t.signedTransaction);i.match(/replacement/i)&&i.match(/underpriced/i)&&ee(!1,"replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:o}),i.match(/insufficient funds/)&&ee(!1,"insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:o}),i.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&ee(!1,"nonce has already been used","NONCE_EXPIRED",{transaction:o})}throw r}async _detectNetwork(){return this.network}async _perform(t){switch(t.method){case"chainId":return this.network.chainId;case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getPriorityFee":if(this.network.name==="mainnet")return"1000000000";if(this.network.name==="optimism")return"1000000";throw new Error("fallback onto the AbstractProvider default");case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorage":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"broadcastTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch(r=>this._checkError(t,r,t.signedTransaction));case"getBlock":if("blockTag"in t)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});ee(!1,"getBlock by blockHash not supported by Etherscan","UNSUPPORTED_OPERATION",{operation:"getBlock(blockHash)"});case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.hash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.hash});case"call":{if(t.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_call";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}case"estimateGas":{const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_estimateGas";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}}return super._perform(t)}async getNetwork(){return this.network}async getEtherPrice(){return this.network.name!=="mainnet"?0:parseFloat((await this.fetch("stats",{action:"ethprice"})).ethusd)}async getContract(t){let r=this._getAddress(t);QJ(r)&&(r=await r);try{const s=await this.fetch("contract",{action:"getabi",address:r}),i=JSON.parse(s);return new jc(r,i,this)}catch{return null}}isCommunityResource(){return this.apiKey==null}}Du=new WeakMap;function tq(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const nq=tq().WebSocket;class U1{constructor(e,t){q(this,Zs);q(this,Yd);q(this,Wo);q(this,bl);q(this,Go);I(this,Zs,e),I(this,Yd,JSON.stringify(t)),I(this,Wo,null),I(this,bl,null),I(this,Go,null)}get filter(){return JSON.parse(T(this,Yd))}start(){I(this,Wo,T(this,Zs).send("eth_subscribe",this.filter).then(e=>(T(this,Zs)._register(e,this),e)))}stop(){T(this,Wo).then(e=>{T(this,Zs).destroyed||T(this,Zs).send("eth_unsubscribe",[e])}),I(this,Wo,null)}pause(e){ee(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),I(this,bl,!!e)}resume(){I(this,bl,null)}_handleMessage(e){if(T(this,Wo)!=null&&T(this,bl)===null){let t=T(this,Go);t==null?t=this._emit(T(this,Zs),e):t=t.then(async()=>{await this._emit(T(this,Zs),e)}),I(this,Go,t.then(()=>{T(this,Go)===t&&I(this,Go,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}Zs=new WeakMap,Yd=new WeakMap,Wo=new WeakMap,bl=new WeakMap,Go=new WeakMap;class rq extends U1{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class sq extends U1{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class iq extends U1{constructor(t,r){super(t,["logs",r]);q(this,Xd);I(this,Xd,JSON.stringify(r))}get logFilter(){return JSON.parse(T(this,Xd))}async _emit(t,r){t.emit(this.logFilter,t._wrapLog(r,t._network))}}Xd=new WeakMap;class oq extends VD{constructor(t,r){const s=Object.assign({},r??{});V(s.batchMaxCount==null||s.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),s.batchMaxCount=1,s.staticNetwork==null&&(s.staticNetwork=!0);super(t,s);q(this,wl);q(this,Pu);q(this,Ko);I(this,wl,new Map),I(this,Pu,new Map),I(this,Ko,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Dg("close");case"block":return new rq(this);case"pending":return new sq(this);case"event":return new iq(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Dg("drop-log")}return super._getSubscriber(t)}_register(t,r){T(this,Pu).set(t,r);const s=T(this,Ko).get(t);if(s){for(const i of s)r._handleMessage(i);T(this,Ko).delete(t)}}async _send(t){V(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const r=new Promise((s,i)=>{T(this,wl).set(t.id,{payload:t,resolve:s,reject:i})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await r]}async _processMessage(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&"id"in r){const s=T(this,wl).get(r.id);if(s==null){this.emit("error",Nt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}T(this,wl).delete(r.id),s.resolve(r)}else if(r&&r.method==="eth_subscription"){const s=r.params.subscription,i=T(this,Pu).get(s);if(i)i._handleMessage(r.params.result);else{let o=T(this,Ko).get(s);o==null&&(o=[],T(this,Ko).set(s,o)),o.push(r.params.result)}}else{this.emit("error",Nt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(t){throw new Error("sub-classes must override this")}}wl=new WeakMap,Pu=new WeakMap,Ko=new WeakMap;class WD extends oq{constructor(t,r,s){super(r,s);q(this,vl);q(this,ms);typeof t=="string"?(I(this,vl,()=>new nq(t)),I(this,ms,T(this,vl).call(this))):typeof t=="function"?(I(this,vl,t),I(this,ms,t())):(I(this,vl,null),I(this,ms,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(i){console.log("failed to start WebsocketProvider",i)}},this.websocket.onmessage=i=>{this._processMessage(i.data)}}get websocket(){if(T(this,ms)==null)throw new Error("websocket closed");return T(this,ms)}async _write(t){this.websocket.send(t)}async destroy(){T(this,ms)!=null&&(T(this,ms).close(),I(this,ms,null)),super.destroy()}}vl=new WeakMap,ms=new WeakMap;const Ld="84842078b09946638c03157f83405213";function aq(n){switch(n){case"mainnet":return"mainnet.infura.io";case"goerli":return"goerli.infura.io";case"sepolia":return"sepolia.infura.io";case"arbitrum":return"arbitrum-mainnet.infura.io";case"arbitrum-goerli":return"arbitrum-goerli.infura.io";case"arbitrum-sepolia":return"arbitrum-sepolia.infura.io";case"base":return"base-mainnet.infura.io";case"base-goerlia":return"base-goerli.infura.io";case"base-sepolia":return"base-sepolia.infura.io";case"bnb":return"bnbsmartchain-mainnet.infura.io";case"bnbt":return"bnbsmartchain-testnet.infura.io";case"linea":return"linea-mainnet.infura.io";case"linea-goerli":return"linea-goerli.infura.io";case"linea-sepolia":return"linea-sepolia.infura.io";case"matic":return"polygon-mainnet.infura.io";case"matic-amoy":return"polygon-amoy.infura.io";case"matic-mumbai":return"polygon-mumbai.infura.io";case"optimism":return"optimism-mainnet.infura.io";case"optimism-goerli":return"optimism-goerli.infura.io";case"optimism-sepolia":return"optimism-sepolia.infura.io"}V(!1,"unsupported network","network",n)}class lq extends WD{constructor(t,r){const s=new _d(t,r),i=s._getConnection();ee(!i.credentials,"INFURA WebSocket project secrets unsupported","UNSUPPORTED_OPERATION",{operation:"InfuraProvider.getWebSocketProvider()"});const o=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(o,s._network);$(this,"projectId");$(this,"projectSecret");Oe(this,{projectId:s.projectId,projectSecret:s.projectSecret})}isCommunityResource(){return this.projectId===Ld}}class _d extends Si{constructor(t,r,s){t==null&&(t="mainnet");const i=Yt.from(t);r==null&&(r=Ld),s==null&&(s=null);const o=_d.getRequest(i,r,s);super(o,i,{staticNetwork:i});$(this,"projectId");$(this,"projectSecret");Oe(this,{projectId:r,projectSecret:s})}_getProvider(t){try{return new _d(t,this.projectId,this.projectSecret)}catch{}return super._getProvider(t)}isCommunityResource(){return this.projectId===Ld}static getWebSocketProvider(t,r){return new lq(t,r)}static getRequest(t,r,s){r==null&&(r=Ld),s==null&&(s=null);const i=new Ln(`https://${aq(t.name)}/v3/${r}`);return i.allowGzip=!0,s&&i.setCredentials("",s),r===Ld&&(i.retryFunc=async(o,a,l)=>(zc("InfuraProvider"),!0)),i}}const Hg="919b412a057b5e9c9b6dce193c5a60242d6efadb";function cq(n){switch(n){case"mainnet":return"ethers.quiknode.pro";case"goerli":return"ethers.ethereum-goerli.quiknode.pro";case"sepolia":return"ethers.ethereum-sepolia.quiknode.pro";case"holesky":return"ethers.ethereum-holesky.quiknode.pro";case"arbitrum":return"ethers.arbitrum-mainnet.quiknode.pro";case"arbitrum-goerli":return"ethers.arbitrum-goerli.quiknode.pro";case"arbitrum-sepolia":return"ethers.arbitrum-sepolia.quiknode.pro";case"base":return"ethers.base-mainnet.quiknode.pro";case"base-goerli":return"ethers.base-goerli.quiknode.pro";case"base-spolia":return"ethers.base-sepolia.quiknode.pro";case"bnb":return"ethers.bsc.quiknode.pro";case"bnbt":return"ethers.bsc-testnet.quiknode.pro";case"matic":return"ethers.matic.quiknode.pro";case"matic-mumbai":return"ethers.matic-testnet.quiknode.pro";case"optimism":return"ethers.optimism.quiknode.pro";case"optimism-goerli":return"ethers.optimism-goerli.quiknode.pro";case"optimism-sepolia":return"ethers.optimism-sepolia.quiknode.pro";case"xdai":return"ethers.xdai.quiknode.pro"}V(!1,"unsupported network","network",n)}class zg extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Hg);const i=zg.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"token");Oe(this,{token:r})}_getProvider(t){try{return new zg(t,this.token)}catch{}return super._getProvider(t)}isCommunityResource(){return this.token===Hg}static getRequest(t,r){r==null&&(r=Hg);const s=new Ln(`https://${cq(t.name)}/${r}`);return s.allowGzip=!0,r===Hg&&(s.retryFunc=async(i,o,a)=>(zc("QuickNodeProvider"),!0)),s}}const uq=BigInt("1"),fq=BigInt("2");function dq(n){for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}}function hq(n){return new Promise(e=>{setTimeout(e,n)})}function H1(){return new Date().getTime()}function z1(n){return JSON.stringify(n,(e,t)=>typeof t=="bigint"?{type:"bigint",value:t.toString()}:t)}const GD={stallTimeout:400,priority:1,weight:1},KD={blockNumber:-2,requests:0,lateResponses:0,errorResponses:0,outOfSync:-1,unsupportedEvents:0,rollingDuration:0,score:0,_network:null,_updateNumber:null,_totalTime:0,_lastFatalError:null,_lastFatalErrorTimestamp:0};async function pq(n,e){for(;(n.blockNumber<0||n.blockNumber<e)&&(n._updateNumber||(n._updateNumber=(async()=>{try{const t=await n.provider.getBlockNumber();t>n.blockNumber&&(n.blockNumber=t)}catch(t){n.blockNumber=-2,n._lastFatalError=t,n._lastFatalErrorTimestamp=H1()}n._updateNumber=null})()),await n._updateNumber,n.outOfSync++,!n._lastFatalError););}function Bd(n){if(n==null)return"null";if(Array.isArray(n))return"["+n.map(Bd).join(",")+"]";if(typeof n=="object"&&typeof n.toJSON=="function")return Bd(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":case"number":return BigInt(n).toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{"+e.map(t=>`${JSON.stringify(t)}:${Bd(n[t])}`).join(",")+"}"}}throw console.log("Could not serialize",n),new Error("Hmm...")}function V1(n){if("error"in n){const t=n.error;return{tag:Bd(t),value:t}}const e=n.result;return{tag:Bd(e),value:e}}function Vg(n,e){const t=new Map;for(const{value:s,tag:i,weight:o}of e){const a=t.get(i)||{value:s,weight:0};a.weight+=o,t.set(i,a)}let r=null;for(const s of t.values())s.weight>=n&&(!r||s.weight>r.weight)&&(r=s);if(r)return r.value}function $1(n,e){let t=0;const r=new Map;let s=null;const i=[];for(const{value:a,tag:l,weight:c}of e)if(a instanceof Error){const u=r.get(l)||{value:a,weight:0};u.weight+=c,r.set(l,u),(s==null||u.weight>s.weight)&&(s=u)}else i.push(BigInt(a)),t+=c;if(t<n)return s&&s.weight>=n?s.value:void 0;i.sort((a,l)=>a<l?-1:l>a?1:0);const o=Math.floor(i.length/2);return i.length%2?i[o]:(i[o-1]+i[o]+uq)/fq}function W1(n,e){const t=Vg(n,e);if(t!==void 0)return t;for(const r of e)if(r.value)return r.value}function mq(n,e){if(n===1)return Je($1(n,e),"%internal");const t=new Map,r=(o,a)=>{const l=t.get(o)||{result:o,weight:0};l.weight+=a,t.set(o,l)};for(const{weight:o,value:a}of e){const l=Je(a);r(l-1,o),r(l,o),r(l+1,o)}let s=0,i;for(const{weight:o,result:a}of t.values())o>=n&&(o>s||i!=null&&o===s&&a>i)&&(s=o,i=a);return i}class gq extends Pg{constructor(t,r,s){super(r,s);q(this,rr);$(this,"quorum");$(this,"eventQuorum");$(this,"eventWorkers");q(this,nr);q(this,Hi);q(this,Iu);I(this,nr,t.map(i=>i instanceof Pg?Object.assign({provider:i},GD,KD):Object.assign({},GD,i,KD))),I(this,Hi,-2),I(this,Iu,null),s&&s.quorum!=null?this.quorum=s.quorum:this.quorum=Math.ceil(T(this,nr).reduce((i,o)=>(i+=o.weight,i),0)/2),this.eventQuorum=1,this.eventWorkers=1,V(this.quorum<=T(this,nr).reduce((i,o)=>i+o.weight,0),"quorum exceed provider weight","quorum",this.quorum)}get providerConfigs(){return T(this,nr).map(t=>{const r=Object.assign({},t);for(const s in r)s[0]==="_"&&delete r[s];return r})}async _detectNetwork(){return Yt.from(Ae(await this._perform({method:"chainId"})))}async _translatePerform(t,r){switch(r.method){case"broadcastTransaction":return await t.broadcastTransaction(r.signedTransaction);case"call":return await t.call(Object.assign({},r.transaction,{blockTag:r.blockTag}));case"chainId":return(await t.getNetwork()).chainId;case"estimateGas":return await t.estimateGas(r.transaction);case"getBalance":return await t.getBalance(r.address,r.blockTag);case"getBlock":{const s="blockHash"in r?r.blockHash:r.blockTag;return await t.getBlock(s,r.includeTransactions)}case"getBlockNumber":return await t.getBlockNumber();case"getCode":return await t.getCode(r.address,r.blockTag);case"getGasPrice":return(await t.getFeeData()).gasPrice;case"getPriorityFee":return(await t.getFeeData()).maxPriorityFeePerGas;case"getLogs":return await t.getLogs(r.filter);case"getStorage":return await t.getStorage(r.address,r.position,r.blockTag);case"getTransaction":return await t.getTransaction(r.hash);case"getTransactionCount":return await t.getTransactionCount(r.address,r.blockTag);case"getTransactionReceipt":return await t.getTransactionReceipt(r.hash);case"getTransactionResult":return await t.getTransactionResult(r.hash)}}async _perform(t){if(t.method==="broadcastTransaction"){const o=T(this,nr).map(c=>null),a=T(this,nr).map(async({provider:c,weight:u},f)=>{try{const d=await c._perform(t);o[f]=Object.assign(V1({result:d}),{weight:u})}catch(d){o[f]=Object.assign(V1({error:d}),{weight:u})}});for(;;){const c=o.filter(d=>d!=null);for(const{value:d}of c)if(!(d instanceof Error))return d;const u=Vg(this.quorum,o.filter(d=>d!=null));if(ln(u,"INSUFFICIENT_FUNDS"))throw u;const f=a.filter((d,h)=>o[h]==null);if(f.length===0)break;await Promise.race(f)}const l=W1(this.quorum,o);if(ee(l!==void 0,"problem multi-broadcasting","SERVER_ERROR",{request:"%sub-requests",info:{request:t,results:o.map(z1)}}),l instanceof Error)throw l;return l}await fe(this,rr,iP).call(this);const r=new Set;let s=0;for(;;){const o=fe(this,rr,ux).call(this,r,t);if(o==null||(s+=o.config.weight,s>=this.quorum))break}const i=await fe(this,rr,fx).call(this,r,t);for(const o of r)o.perform&&o.result==null&&o.config.lateResponses++;return i}async destroy(){for(const{provider:t}of T(this,nr))t.destroy();super.destroy()}}nr=new WeakMap,Hi=new WeakMap,Iu=new WeakMap,rr=new WeakSet,sP=function(t){const r=Array.from(t).map(i=>i.config),s=T(this,nr).slice();dq(s),s.sort((i,o)=>i.priority-o.priority);for(const i of s)if(!i._lastFatalError&&r.indexOf(i)===-1)return i;return null},ux=function(t,r){const s=fe(this,rr,sP).call(this,t);if(s==null)return null;const i={config:s,result:null,didBump:!1,perform:null,staller:null},o=H1();return i.perform=(async()=>{try{s.requests++;const l=await this._translatePerform(s.provider,r);i.result={result:l}}catch(l){s.errorResponses++,i.result={error:l}}const a=H1()-o;s._totalTime+=a,s.rollingDuration=.95*s.rollingDuration+.05*a,i.perform=null})(),i.staller=(async()=>{await hq(s.stallTimeout),i.staller=null})(),t.add(i),i},iP=async function(){let t=T(this,Iu);if(!t){const r=[];T(this,nr).forEach(s=>{r.push((async()=>{await pq(s,0),s._lastFatalError||(s._network=await s.provider.getNetwork())})())}),I(this,Iu,t=(async()=>{await Promise.all(r);let s=null;for(const i of T(this,nr)){if(i._lastFatalError)continue;const o=i._network;s==null?s=o.chainId:o.chainId!==s&&ee(!1,"cannot mix providers on different networks","UNSUPPORTED_OPERATION",{operation:"new FallbackProvider"})}})())}await t},oP=async function(t,r){const s=[];for(const i of t)if(i.result!=null){const{tag:o,value:a}=V1(i.result);s.push({tag:o,value:a,weight:i.config.weight})}if(!(s.reduce((i,o)=>i+o.weight,0)<this.quorum)){switch(r.method){case"getBlockNumber":{T(this,Hi)===-2&&I(this,Hi,Math.ceil(Je($1(this.quorum,T(this,nr).filter(o=>!o._lastFatalError).map(o=>({value:o.blockNumber,tag:Je(o.blockNumber).toString(),weight:o.weight}))))));const i=mq(this.quorum,s);return i===void 0?void 0:(i>T(this,Hi)&&I(this,Hi,i),T(this,Hi))}case"getGasPrice":case"getPriorityFee":case"estimateGas":return $1(this.quorum,s);case"getBlock":return"blockTag"in r&&r.blockTag==="pending"?W1(this.quorum,s):Vg(this.quorum,s);case"call":case"chainId":case"getBalance":case"getTransactionCount":case"getCode":case"getStorage":case"getTransaction":case"getTransactionReceipt":case"getLogs":return Vg(this.quorum,s);case"broadcastTransaction":return W1(this.quorum,s)}ee(!1,"unsupported method","UNSUPPORTED_OPERATION",{operation:`_perform(${z1(r.method)})`})}},fx=async function(t,r){if(t.size===0)throw new Error("no runners?!");const s=[];let i=0;for(const a of t){if(a.perform&&s.push(a.perform),a.staller){s.push(a.staller);continue}a.didBump||(a.didBump=!0,i++)}const o=await fe(this,rr,oP).call(this,t,r);if(o!==void 0){if(o instanceof Error)throw o;return o}for(let a=0;a<i;a++)fe(this,rr,ux).call(this,t,r);return ee(s.length>0,"quorum not met","SERVER_ERROR",{request:"%sub-requests",info:{request:r,results:Array.from(t).map(a=>z1(a.result))}}),await Promise.race(s),await fe(this,rr,fx).call(this,t,r)};function yq(n){return n&&typeof n.send=="function"&&typeof n.close=="function"}const bq="goerli kovan sepolia classicKotti optimism-goerli arbitrum-goerli matic-mumbai bnbt".split(" ");function wq(n,e){e==null&&(e={});const t=o=>e[o]==="-"?!1:typeof e.exclusive=="string"?o===e.exclusive:Array.isArray(e.exclusive)?e.exclusive.indexOf(o)!==-1:!0;if(typeof n=="string"&&n.match(/^https?:/))return new Si(n);if(typeof n=="string"&&n.match(/^wss?:/)||yq(n))return new WD(n);let r=null;try{r=Yt.from(n)}catch{}const s=[];if(t("publicPolygon")&&r&&(r.name==="matic"?s.push(new Si("https://polygon-rpc.com/",r,{staticNetwork:r})):r.name==="matic-amoy"&&s.push(new Si("https://rpc-amoy.polygon.technology/",r,{staticNetwork:r}))),t("alchemy"))try{s.push(new Fg(n,e.alchemy))}catch{}if(t("ankr")&&e.ankr!=null)try{s.push(new _g(n,e.ankr))}catch{}if(t("chainstack"))try{s.push(new Ug(n,e.chainstack))}catch{}if(t("cloudflare"))try{s.push(new qJ(n))}catch{}if(t("etherscan"))try{s.push(new eq(n,e.etherscan))}catch{}if(t("infura"))try{let o=e.infura,a;typeof o=="object"&&(a=o.projectSecret,o=o.projectId),s.push(new _d(n,o,a))}catch{}if(t("quicknode"))try{let o=e.quicknode;s.push(new zg(n,o))}catch{}if(ee(s.length,"unsupported default network","UNSUPPORTED_OPERATION",{operation:"getDefaultProvider"}),s.length===1)return s[0];let i=Math.floor(s.length/2);return i>2&&(i=2),r&&bq.indexOf(r.name)!==-1&&(i=1),e&&e.quorum&&(i=e.quorum),new gq(s,void 0,{quorum:i})}const vq=async(n,e)=>{const t={name:n,isEns:!1};if(!e)throw new Error("cannot fetch ens name without a provider url");if(!gG(n))return t;try{const r=await xq(n,e);r&&(t.name=r,t.isEns=!0)}catch(r){console.log(r)}return t},xq=async(n,e)=>await Aq(e).lookupAddress(n),Aq=n=>wq(n),JD=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],Eq=({isPreviewMode:n,initialContent:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:s,username:i,onAutoSave:o,onChange:a})=>{const[l]=L.useState(new xa),[c,u]=L.useState(!1),[f,d]=L.useState([...EW]),h=Ok({extensions:f,editorProps:j2,autofocus:"start",onUpdate:k=>{var S;console.log("EDITOR IS EMPTY",(S=k.editor)==null?void 0:S.isEmpty),!(x!=null&&x.isEmpty)&&(a==null||a(k.editor.getJSON()))}},[f]),p=Ok({extensions:f,editorProps:j2,autofocus:"start",onUpdate:k=>{var S;console.log("EDITOR IS EMPTY",(S=k.editor)==null?void 0:S.isEmpty),!(x!=null&&x.isEmpty)&&(a==null||a(k.editor.getJSON()))}}),m=L.useRef(()=>{}),y=(k,S=!1)=>{if(!t||!r||!k)throw new Error("docId or username is not provided");u(!0);const M=new l6(r,l,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});d([...f,I6.configure({document:l}),L6.configure({provider:M,user:{name:k,color:JD[Math.floor(Math.random()*JD.length)],isEns:S},render:NW})]);const O=setTimeout(()=>{u(!1)},100);return m.current=()=>{clearTimeout(O),M.destroy(),l.destroy(),u(!1)},m.current},b=L.useRef(null),x=L.useMemo(()=>t&&r&&h&&!c?h:p,[h,p,c]),v=k=>{var S;(S=b.current)!=null&&S.contains(k.target)||x==null||x.chain().focus().run()};L.useEffect(()=>{x==null||x.chain().focus()},[]),L.useEffect(()=>{x==null||x.setEditable(!n)},[n,x]),L.useEffect(()=>{e&&x&&setTimeout(()=>{x==null||x.commands.setContent(e)})},[e,x]);const w=async()=>{if(!i)return;let k=i,S=!1;if(s){const{name:M,isEns:O}=await vq(i,s);k=M,S=O}y(k,S)};L.useEffect(()=>{t&&i?w():m.current()},[t]);const E=L.useMemo(()=>iv((k,S)=>{S({editorJSONData:k.getJSON()})},1e3),[o]);return L.useEffect(()=>{if(x&&o){const k=()=>{E(x,o)};return x.on("update",k),()=>{x.off("update",k)}}},[x,o,E]),{editor:x,focusEditor:v,ref:b,loading:c,connect:y}},kq=({title:n,content:e,contentClassName:t,open:r,onOpenChange:s,primaryAction:i,secondaryAction:o})=>C.jsx(uU,{open:r,onOpenChange:s,children:C.jsxs(fS,{className:"max-w-md sm:w-full w-[90%] z-20",children:[C.jsx(dS,{className:"px-4 pt-0 border-b-[1px]",children:C.jsx(pS,{className:"text-left text-base",children:n})}),C.jsx("div",{className:pe("flex flex-col gap-4 w-full h-full pb-4 text-base text-black",t),children:e&&e}),C.jsxs(hS,{className:"px-5 pb-5 justify-end sm:",children:[o&&C.jsx(hU,{asChild:!0,children:C.jsx(Pf,{disabled:o==null?void 0:o.isLoading,isLoading:o==null?void 0:o.isLoading,className:o==null?void 0:o.className,variant:(o==null?void 0:o.variant)||"ghost",onClick:o==null?void 0:o.onClick,children:o==null?void 0:o.label})}),i&&C.jsx(Pf,{disabled:i==null?void 0:i.isLoading,isLoading:i==null?void 0:i.isLoading,className:i==null?void 0:i.className,variant:(i==null?void 0:i.variant)||"primary",onClick:i==null?void 0:i.onClick,children:i==null?void 0:i.label})]})]})}),Cq=({editor:n})=>{const{toolVisibilty:e,setToolVisibility:t,bottomToolbar:r}=Sb({editor:n}),[s,i]=L.useState(""),[o,a]=L.useState(""),[l,c]=L.useState(!0),u=()=>{if(s===null){c(!1);return}if(s===""){n.chain().focus().extendMarkRange("link").unsetLink().run(),c(!1);return}let d=s;!s.startsWith("http://")&&!s.startsWith("https://")&&(d="https://"+s);try{d.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&n.chain().focus().extendMarkRange("link").setLink({href:d}).command(({tr:h})=>(h.insertText(o),!0)).run(),c(!0)}catch{console.error("Invalid URL"),c(!1);return}n.chain().focus().extendMarkRange("link").setLink({href:d}).command(({tr:h})=>(h.insertText(o),!0)).run(),c(!0),t(Re.NONE)},f=d=>{const{from:h,to:p}=d.state.selection;return d.state.doc.textBetween(h,p)};return C.jsxs(sS,{children:[C.jsx("div",{className:"flex w-full justify-between sm:justify-evenly",children:r.map(d=>{if(d)return C.jsx("div",{className:"flex items-center",children:d.title==="Text formating"||d.title==="Text color"?C.jsx(aU,{asChild:!0,children:C.jsx("button",{onClick:()=>d.onClick(),children:d.icon})}):C.jsx("button",{className:pe("flex items-center rounded px-2 py-1 text-black transition"),onClick:()=>d.onClick(),children:d.icon})},d.title)})}),e===Re.TEXT_FORMATING&&C.jsx(e8,{editor:n,setToolVisibility:t}),e===Re.TEXT_COLOR_PICKER&&C.jsx(t8,{editor:n,setToolVisibility:t}),e===Re.LINK_POPUP&&C.jsx(kq,{open:e===Re.LINK_POPUP,onOpenChange:()=>t(Re.NONE),title:"Link",content:C.jsxs("div",{className:"flex flex-col gap-4 w-full h-full px-4",children:[C.jsx(dp,{label:"Text",placeholder:"Link text",className:"w-full",defaultValue:f(n),onChange:d=>a(d.target.value)}),C.jsx(dp,{label:"Link",placeholder:"Paste URL",className:"w-full",defaultValue:n.getAttributes("link").href,onChange:d=>{i(d.target.value)},isValid:l,message:l?"":"Invalid URL"})]}),primaryAction:{label:"Save",onClick:()=>u(),isLoading:!1,className:"w-auto min-w-[80px]"},secondaryAction:{label:"Cancel",variant:"secondary",onClick:()=>t(Re.NONE),className:"w-auto min-w-[80px]"}})]})},Sq=({isPreviewMode:n=!1,initialContent:e,enableCollaboration:t,collaborationId:r,username:s,onAutoSave:i,renderToolRightSection:o,renderToolLeftSection:a,ensProviderUrl:l,onChange:c})=>{const{editor:u,focusEditor:f,ref:d,loading:h}=Eq({isPreviewMode:n,initialContent:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:l,username:s,onAutoSave:i,onChange:c});return!u||h?C.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[C.jsx(HS,{}),C.jsx("p",{children:"Loading Editor..."})]}):C.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f8f9fa]",children:C.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:C.jsxs("div",{className:"w-full h-full",children:[C.jsx("div",{className:"flex items-center w-full h-16 fixed z-10 px-4 bg-[#f8f9fa]",children:C.jsxs("div",{className:"flex items-center justify-between gap-2 w-full",children:[C.jsx("div",{className:"grow",children:a==null?void 0:a({editor:u.getJSON()})}),!n&&C.jsx("div",{className:"grow relative hidden xl:block",children:C.jsx(f8,{editor:u})}),o==null?void 0:o({editor:u.getJSON()})]})}),C.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:C.jsx("div",{onClick:f,className:"mt-8 lg:mt-[5rem] w-full flex justify-center relative",children:C.jsx("div",{className:"px-4 pt-12 sm:p-[88px] h-screen bg-white overflow-scroll no-scrollbar w-full sm:w-[70%] max-w-[856px]",children:C.jsxs("div",{ref:d,className:"w-full h-full",children:[!n&&C.jsxs("div",{children:[C.jsx(n8,{editor:u}),C.jsx(c8,{editor:u,appendTo:d})]}),C.jsx(u8,{isPreviewMode:n,children:C.jsx(j3,{editor:u})})]})})})}),C.jsx("div",{className:"flex xl:hidden items-center w-full h-16 fixed bottom-0 z-10 px-4 bg-[#f8f9fa]",children:C.jsx(Cq,{editor:u})})]})})})};st.DdocEditor=Sq,Object.defineProperty(st,Symbol.toStringTag,{value:"Module"})});
437
+ 3. "-" cannot repeat`);Dt.customSchemes.push([n,e])}function Xz(){Dt.scanner=Vz(Dt.customSchemes);for(let n=0;n<Dt.tokenQueue.length;n++)Dt.tokenQueue[n][1]({scanner:Dt.scanner});Dt.parser=Kz(Dt.scanner.tokens);for(let n=0;n<Dt.pluginQueue.length;n++)Dt.pluginQueue[n][1]({scanner:Dt.scanner,parser:Dt.parser});Dt.initialized=!0}function EN(n){return Dt.initialized||Xz(),Jz(Dt.parser.start,n,$z(Dt.scanner.start,n))}function kN(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new nv(t),s=EN(n),i=[];for(let o=0;o<s.length;o++){const a=s[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}function Zz(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function eV(n){return new bt({key:new Ot("autolink"),appendTransaction:(e,t,r)=>{const s=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=xB(t.doc,[...e]);if(OB(a).forEach(({newRange:c})=>{const u=EB(r.doc,c,h=>h.isTextblock);let f,d;if(u.length>1?(f=u[0],d=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(f=u[0],d=r.doc.textBetween(f.pos,c.to,void 0," ")),f&&d){const h=d.split(" ").filter(b=>b!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=f.pos+d.lastIndexOf(p);if(!p)return!1;const y=EN(p).map(b=>b.toObject());if(!Zz(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate?n.validate(b.value):!0).forEach(b=>{c0(b.from,b.to,r.doc).some(x=>x.mark.type===n.type)||o.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function tV(n){return new bt({key:new Ot("handleClickLink"),props:{handleClick:(e,t,r)=>{var s,i;if(n.whenNotEditable&&e.editable||r.button!==0)return!1;let o=r.target;const a=[];for(;o.nodeName!=="DIV";)a.push(o),o=o.parentNode;if(!a.find(d=>d.nodeName==="A"))return!1;const l=BE(e.state,n.type.name),c=r.target,u=(s=c==null?void 0:c.href)!==null&&s!==void 0?s:l.href,f=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:l.target;return c&&u?(window.open(u,f),!0):!1}}})}function nV(n){return new bt({key:new Ot("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:s}=e,{selection:i}=s,{empty:o}=i;if(o)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=kN(a).find(c=>c.isLink&&c.value===a);return!a||!l?!1:(n.editor.commands.setMark(n.type,{href:l.href}),!0)}}})}const rV=$n.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){AN(n);return}AN(n.scheme,n.optionalSlashes)})},onDestroy(){Yz()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",tt(this.options.HTMLAttributes,{...n,href:""}),0]:["a",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[to({find:n=>{const e=[];if(n){const t=kN(n).filter(r=>r.isLink);t.length&&t.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(eV({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(tV({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&n.push(nV({editor:this.editor,type:this.type})),n}}),sV=St.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,considerAnyAsEmpty:!1,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new bt({key:new Ot("placeholder"),props:{decorations:({doc:n,selection:e})=>{var t;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=e,i=[];if(!r)return null;const{firstChild:o}=n.content,a=o&&o.type.isLeaf,l=o&&o.isAtom,c=this.options.considerAnyAsEmpty?!0:o&&o.type.name===((t=n.type.contentMatch.defaultType)===null||t===void 0?void 0:t.name),u=n.content.childCount<=1&&o&&c&&o.nodeSize<=2&&(!a||!l);return n.descendants((f,d)=>{const h=s>=d&&s<=d+f.nodeSize,p=!f.isLeaf&&!f.childCount;if((h||!this.options.showOnlyCurrent)&&p){const m=[this.options.emptyNodeClass];u&&m.push(this.options.emptyEditorClass);const y=Qt.node(d,d+f.nodeSize,{class:m.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:f,pos:d,hasAnchor:h}):this.options.placeholder});i.push(y)}return this.options.includeChildren}),wt.create(n,i)}}})]}}),iV=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,oV=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,aV=$n.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[aa({find:iV,type:this.type})]},addPasteRules(){return[to({find:oV,type:this.type})]}}),lV=vt.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:n}){return["ul",tt(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),cV=/^\s*(\[([( |x])?\])\s$/,uV=vt.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:n=>n.getAttribute("data-checked")==="true",renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",tt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div");return i.contentEditable="false",a.type="checkbox",a.addEventListener("change",c=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:u}=c.target;r.isEditable&&typeof t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const d=t(),h=f.doc.nodeAt(d);return f.setNodeMarkup(d,void 0,{...h==null?void 0:h.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(n,u)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{s.setAttribute(c,u)}),s.dataset.checked=n.attrs.checked,n.attrs.checked&&a.setAttribute("checked","checked"),i.append(a,o),s.append(i,l),Object.entries(e).forEach(([c,u])=>{s.setAttribute(c,u)}),{dom:s,contentDOM:l,update:c=>c.type!==this.type?!1:(s.dataset.checked=c.attrs.checked,c.attrs.checked?a.setAttribute("checked","checked"):a.removeAttribute("checked"),!0)}}},addInputRules(){return[Fl({find:cV,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),fV=$n.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",tt(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function dV(n){var e;const{char:t,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:o}=n,a=ZB(t),l=new RegExp(`\\s${a}$`),c=i?"^":"",u=r?new RegExp(`${c}${a}.*?(?=\\s${a}|$)`,"gm"):new RegExp(`${c}(?:^)?${a}[^\\s${a}]*`,"gm"),f=((e=o.nodeBefore)===null||e===void 0?void 0:e.isText)&&o.nodeBefore.text;if(!f)return null;const d=o.pos-f.length,h=Array.from(f.matchAll(u)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const p=h.input.slice(Math.max(0,h.index-1),h.index),m=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(p);if(s!==null&&!m)return null;const y=d+h.index;let b=y+h[0].length;return r&&l.test(f.slice(b-1,b+1))&&(h[0]+=" ",b+=1),y<o.pos&&b>=o.pos?{range:{from:y,to:b},query:h[0].slice(t.length),text:h[0]}:null}const hV=new Ot("suggestion");function pV({pluginKey:n=hV,editor:e,char:t="@",allowSpaces:r=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:o="span",decorationClass:a="suggestion",command:l=()=>null,items:c=()=>[],render:u=()=>({}),allow:f=()=>!0,findSuggestionMatch:d=dV}){let h;const p=u==null?void 0:u(),m=new bt({key:n,view(){return{update:async(y,b)=>{var x,v,w,E,k,S,M;const O=(x=this.key)===null||x===void 0?void 0:x.getState(b),R=(v=this.key)===null||v===void 0?void 0:v.getState(y.state),D=O.active&&R.active&&O.range.from!==R.range.from,F=!O.active&&R.active,U=O.active&&!R.active,K=!F&&!U&&O.query!==R.query,_=F||D,G=K&&!D,Y=U||D;if(!_&&!G&&!Y)return;const re=Y&&!_?O:R,Z=y.dom.querySelector(`[data-decoration-id="${re.decorationId}"]`);h={editor:e,range:re.range,query:re.query,text:re.text,items:[],command:me=>l({editor:e,range:re.range,props:me}),decorationNode:Z,clientRect:Z?()=>{var me;const{decorationId:ke}=(me=this.key)===null||me===void 0?void 0:me.getState(e.state),Pe=y.dom.querySelector(`[data-decoration-id="${ke}"]`);return(Pe==null?void 0:Pe.getBoundingClientRect())||null}:null},_&&((w=p==null?void 0:p.onBeforeStart)===null||w===void 0||w.call(p,h)),G&&((E=p==null?void 0:p.onBeforeUpdate)===null||E===void 0||E.call(p,h)),(G||_)&&(h.items=await c({editor:e,query:re.query})),Y&&((k=p==null?void 0:p.onExit)===null||k===void 0||k.call(p,h)),G&&((S=p==null?void 0:p.onUpdate)===null||S===void 0||S.call(p,h)),_&&((M=p==null?void 0:p.onStart)===null||M===void 0||M.call(p,h))},destroy:()=>{var y;h&&((y=p==null?void 0:p.onExit)===null||y===void 0||y.call(p,h))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(y,b,x,v){const{isEditable:w}=e,{composing:E}=e.view,{selection:k}=y,{empty:S,from:M}=k,O={...b};if(O.composing=E,w&&(S||e.view.composing)){(M<b.range.from||M>b.range.to)&&!E&&!b.composing&&(O.active=!1);const R=d({char:t,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:k.$from}),D=`id_${Math.floor(Math.random()*4294967295)}`;R&&f({editor:e,state:v,range:R.range})?(O.active=!0,O.decorationId=b.decorationId?b.decorationId:D,O.range=R.range,O.query=R.query,O.text=R.text):O.active=!1}else O.active=!1;return O.active||(O.decorationId=null,O.range={from:0,to:0},O.query=null,O.text=null),O}},props:{handleKeyDown(y,b){var x;const{active:v,range:w}=m.getState(y.state);return v&&((x=p==null?void 0:p.onKeyDown)===null||x===void 0?void 0:x.call(p,{view:y,event:b,range:w}))||!1},decorations(y){const{active:b,range:x,decorationId:v}=m.getState(y);return b?wt.create(y.doc,[Qt.inline(x.from,x.to,{nodeName:o,class:a,"data-decoration-id":v})]):null}}});return m}const mV=St.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:n,range:e,props:t})=>{t.command({editor:n,range:e})}}}},addProseMirrorPlugins(){return[pV({editor:this.editor,...this.options.suggestion})]}}),gV=({query:n})=>[{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:C.jsx($k,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run()}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:C.jsx(zk,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:C.jsx(Vh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:C.jsx($h,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:C.jsx(Wh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:C.jsx(Gh,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:C.jsx(Wl,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{title:"Divider",description:"Visually divide content.",searchTerms:["hr","divider","break","line","delimiter"],icon:C.jsx(n4,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:C.jsx(Kh,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:C.jsx(Af,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"Table",description:"Create a table.",searchTerms:["table"],icon:C.jsx(Vk,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:C.jsx(e4,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).run();const r=document.createElement("input");r.type="file",r.accept="image/*",r.onchange=async()=>{var s;if((s=r.files)!=null&&s.length){const i=r.files[0],o=e.view.state.selection.from;z0(i,e.view,o)}},r.click()}},{title:"Video Embed",description:"Embed a video from YouTube, Vimeo, etc.",searchTerms:["iframe","embed","video","youtube"],icon:C.jsx(Kk,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("iframe").run()}},{title:"Twitter",description:"Embed a Twitter tweet.",searchTerms:["embed","twitter","tweet"],icon:C.jsx(Gk,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("twitter").run()}},{title:"2 Columns",description:"Create 2 columns of block",searchTerms:["col","column","2","layout"],icon:C.jsx(jk,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(2).focus(e.state.selection.head-1).run()}},{title:"3 Columns",description:"Create 3 columns of block",searchTerms:["col","column","3","layout"],icon:C.jsx(Q3,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(3).focus(e.state.selection.head-1).run()}}].filter(e=>{if(typeof n=="string"&&n.length>0){const t=n.toLowerCase();return e.title.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.searchTerms&&e.searchTerms.some(r=>r.includes(t))}return!0}),yV=(n,e)=>{const t=n.offsetHeight,r=e?e.offsetHeight:0,s=e.offsetTop,i=s+r;s<n.scrollTop?n.scrollTop-=n.scrollTop-s+5:i>t+n.scrollTop&&(n.scrollTop+=i-t-n.scrollTop+5)},bV=({items:n,command:e,editor:t})=>{const[r,s]=L.useState(0),i=L.useCallback(a=>{const l=n[a];l&&(l.title==="Continue writing"||e(l))},[e,t,n]);L.useEffect(()=>{const a=["ArrowUp","ArrowDown","Enter"],l=c=>{if(a.includes(c.key))return c.preventDefault(),c.key==="ArrowUp"?(s((r+n.length-1)%n.length),!0):c.key==="ArrowDown"?(s((r+1)%n.length),!0):c.key==="Enter"?(i(r),!0):!1};return document.addEventListener("keydown",l),()=>{document.removeEventListener("keydown",l)}},[n,r,s,i]),L.useEffect(()=>{s(0)},[n]);const o=L.useRef(null);return L.useLayoutEffect(()=>{const a=o==null?void 0:o.current,l=a==null?void 0:a.children[r];l&&a&&yV(a,l)},[r]),n.length>0?C.jsx("div",{id:"slash-command",ref:o,className:"z-50 h-auto max-h-[330px] w-72 overflow-y-auto scroll-smooth rounded-md border border-[#DDD] bg-white px-1 py-2 shadow-md transition-all",children:n.map((a,l)=>C.jsxs("button",{className:`flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-neutral-500 hover:bg-neutral-100 hover:border-neutral-200 border border-transparent transition-all ${l===r?"bg-neutral-200 text-neutral-800":""}`,onClick:()=>i(l),children:[C.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-neutral-200 bg-white",children:a.icon}),C.jsxs("div",{children:[C.jsx("p",{className:"font-medium",children:a.title}),C.jsx("p",{className:"text-xs text-neutral-500",children:a.description})]})]},l))}):null},wV=()=>{let n=null,e=null;return{onStart:t=>{n=new Lk(bV,{props:t,editor:t.editor}),e=fa("body",{getReferenceClientRect:t.clientRect,appendTo:()=>document.body,content:n.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:t=>{n==null||n.updateProps(t),e&&e[0].setProps({getReferenceClientRect:t.clientRect})},onKeyDown:t=>{var r;return t.event.key==="Escape"?(e==null||e[0].hide(),!0):(r=n==null?void 0:n.ref)==null?void 0:r.onKeyDown(t)},onExit:()=>{e==null||e[0].destroy(),n==null||n.destroy()}}},vV=mV.configure({suggestion:{items:gV,render:wV}}),xV=oN.extend({renderHTML(){return["div",tt(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),AV=St.create({name:"columnExtension",addExtensions(){const n=[];return this.options.column!==!1&&n.push(RS),this.options.columns!==!1&&n.push(mp),n}}),EV=St.create({name:"CustomKeymap",addCommands(){return{selectTextWithinNodeBoundaries:()=>({editor:n,commands:e})=>{const{state:t}=n,{tr:r}=t,s=r.selection.$from.start(),i=r.selection.$to.end();return e.setTextSelection({from:s,to:i})}}},addKeyboardShortcuts(){return{"Mod-a":({editor:n})=>{const{state:e}=n,{tr:t}=e,r=t.selection.from,s=t.selection.to,i=t.selection.$from.start(),o=t.selection.$to.end();return r>i||s<o?(n.chain().selectTextWithinNodeBoundaries().run(),!0):!1}}}}),kV=St.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),CN=[{tooltip:"Align left",action:n=>n({dataAlign:"start",dataFloat:null}),icon:"AlignLeft",isActive:n=>n.dataAlign==="start"},{tooltip:"Align center",action:n=>n({dataAlign:"center",dataFloat:null}),icon:"AlignCenter",isActive:n=>n.dataAlign==="center"},{tooltip:"Align right",action:n=>n({dataAlign:"end",dataFloat:null}),icon:"AlignRight",isActive:n=>n.dataAlign==="end"},{tooltip:"Delete",icon:"Trash2",delete:n=>n()}];let hc;const SN=({node:n,updateAttributes:e,deleteNode:t})=>{const r=gp(),[s,i]=L.useState(),[o,a]=L.useState(0),[l,c]=L.useState(0),[u,f]=L.useState({}),d=L.useRef(null),[h,p]=L.useState(!1),m=()=>{const U={};CN.forEach(({tooltip:K,isActive:_})=>{U[K]=!!(_!=null&&_(n.attrs))}),f(U)},y=()=>{const U=document.querySelector(".ProseMirror");if(U&&c(U==null?void 0:U.clientWidth),!!d.current){if(s==="video"){const K=d.current;K.addEventListener("loadeddata",function(){a(K.videoWidth/K.videoHeight),k("left",0)})}else if(s==="iframe"){const K=d.current;K.onload=()=>{a(K.offsetWidth/K.offsetHeight),k("left",0)}}else d.current.onload=()=>{a(d.current.naturalWidth/d.current.naturalHeight)};setTimeout(()=>m(),200)}},b=U=>{hc=U};L.useEffect(()=>{y()},[]);const x=({width:U,height:K})=>U<200||K<200,v=U=>{setTimeout(()=>S(U))},w=U=>{hc=U.clientX,setTimeout(()=>{document.addEventListener("mousemove",v),document.addEventListener("mouseup",E)}),p(!0)},E=()=>{hc=-1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",E),p(!1)},k=(U,K)=>{var Y,re;if(!d.current){console.error("Media ref is undefined|null",{resizableImg:d.current});return}const _={width:(Y=d.current)==null?void 0:Y.width,height:(re=d.current)==null?void 0:re.height},G={width:-1,height:-1};U==="left"?G.width=_.width-Math.abs(K):(typeof _.width=="string"&&(_.width=Number(_.width)),G.width=_.width+Math.abs(K)),G.width>l&&(G.width=l),s==="iframe"?G.height=G.width/(16/9):G.height=G.width/o,!x(G)&&e(G)},S=U=>{if(hc===-1)return;const{clientX:K}=U,_=hc-K;if(_===0)return;const G=_>0?"left":"right";setTimeout(()=>{k(G,Math.abs(_)),hc=K})},[M,O]=L.useState(),[R,D]=L.useState();L.useEffect(()=>{i(n.attrs["media-type"]),m(),O(n.attrs.dataFloat),D(n.attrs.dataAlign)},[n.attrs]);const F=U=>{switch(U){case"AlignLeft":return C.jsx(vf,{size:16});case"AlignCenter":return C.jsx(D0,{size:16});case"AlignRight":return C.jsx(P0,{size:16});case"Trash2":return C.jsx(Wk,{size:16});default:return null}};return C.jsx(wf,{as:"article",className:pe("media-node-view not-prose transition-all ease-in-out w-full",M&&`f-${n.attrs.dataFloat}`,R&&`justify-${n.attrs.dataAlign}`),children:C.jsxs("div",{className:"w-fit flex relative group transition-all ease-in-out",children:[s==="img"&&C.jsx("img",{src:n.attrs.src,ref:d,className:"rounded-lg",alt:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),s==="video"&&C.jsx("video",{ref:d,className:"rounded-lg",controls:!0,width:n.attrs.width,height:n.attrs.height,children:C.jsx("source",{src:n.attrs.src})}),s==="iframe"&&C.jsx("iframe",{ref:d,className:pe("rounded-lg max-w-full",h&&"pointer-events-none"),src:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),!r&&C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"horizontal-resize-handle group-hover:bg-black group-hover:border-2 group-hover:border-white/80",title:"Resize",onClick:({clientX:U})=>b(U),onMouseDown:w,onMouseUp:E}),C.jsx("section",{className:"media-control-buttons opacity-0 group-hover:opacity-100 transition-opacity duration-200 flex",children:CN.map(U=>C.jsx("div",{className:"tooltip","data-tip":U.tooltip,children:C.jsx("button",{type:"button",className:pe("btn rounded-none h-8 px-2 py-1 transition",u[U.tooltip]&&"active"),onClick:()=>{var K;return U.tooltip==="Delete"?t():(K=U.action)==null?void 0:K.call(U,e)},children:U.icon&&F(U.icon)})}))})]})]})})},CV=vt.create({name:"iframe",group:"block",atom:!0,draggable:!0,addOptions(){return{allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"}}},addAttributes(){return{src:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},"media-type":{default:"iframe"},alt:{default:null},title:{default:null},width:{default:this.options.width},height:{default:this.options.height},dataAlign:{default:"left"},dataFloat:{default:null}}},addNodeView(){return da(SN)},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:n}){return["iframe",tt(this.options.HTMLAttributes,n)]},addCommands(){return{setIframe:n=>({tr:e,dispatch:t})=>{const{selection:r}=e,s=this.type.create(n);return t&&e.replaceRangeWith(r.from-1,r.to,s),!0}}}});var SV="https://platform.twitter.com/widgets.js",sv="createTweet",TV=function(e){var t=L.useRef(null),r=L.useState(!0),s=r[0],i=r[1];return L.useEffect(function(){var o=!0,a=require("scriptjs");return a(SV,"twitter-embed",function(){if(!window.twttr){console.error("Failure to load window.twttr, aborting load");return}if(o){if(!window.twttr.widgets[sv]){console.error("Method "+sv+" is not present anymore in twttr.widget api");return}window.twttr.widgets[sv](e.tweetId,t==null?void 0:t.current,e.options).then(function(l){i(!1),e.onLoad&&e.onLoad(l)})}}),function(){o=!1}},[]),L.createElement(L.Fragment,null,s&&L.createElement(L.Fragment,null,e.placeholder),L.createElement("div",{ref:t}))};const NV=({node:n,editor:e})=>{const[t,r]=L.useState(!0);return L.useEffect(()=>{e==null||e.chain().focus()},[]),C.jsx(wf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:C.jsxs("div",{className:"w-full max-w-sm",children:[t&&C.jsx(HS,{width:5,height:5}),C.jsx(TV,{tweetId:n.attrs.tweetId,onLoad:()=>r(!1)})]})})},OV=vt.create({name:"embeddedTweet",group:"block",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:""}}},addAttributes(){return{tweetId:{default:null},align:{default:"center"}}},parseHTML(){return[{tag:"div[data-tweet-id]"}]},renderHTML({HTMLAttributes:n}){return["div",tt(this.options.HTMLAttributes,n)]},addNodeView(){return da(NV)},addCommands(){return{setTweetEmbed:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{tweetId:n.tweetId,align:"center"},content:[]})}}}),RV=n=>new bt({key:new Ot("media-paste-drop"),props:{handlePaste(e,t){var s;return Array.from(((s=t.clipboardData)==null?void 0:s.items)||[]).forEach(i=>{const o=i.getAsFile();if(((o==null?void 0:o.type.indexOf("image"))===0||(o==null?void 0:o.type.indexOf("video"))===0)&&(t.preventDefault(),o&&o.size>1024*1024))throw new Error("Image too large")}),!1},handleDrop(e,t){var a;if(!(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length))return!1;const s=Array.from(((a=t.dataTransfer)==null?void 0:a.files)??[]).filter(({type:l})=>/image|video/i.test(l));if(s.length===0)return!1;t.preventDefault();const{schema:i}=e.state,o=e.posAtCoords({left:t.clientX,top:t.clientY});return o?(s.forEach(async l=>{const c=new FileReader;if(n){const u=i.nodes.resizableMedia.create({src:await n(l),"media-type":l.type.includes("image")?"img":"video"}),f=e.state.tr.insert(o.pos,u);e.dispatch(f)}else c.onload=u=>{var h;const f=i.nodes.resizableMedia.create({src:(h=u.target)==null?void 0:h.result,"media-type":l.type.includes("image")?"img":"video"}),d=e.state.tr.insert(o.pos,f);e.dispatch(d)},c.readAsDataURL(l)}),!0):!1}}}),MV=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,DV=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,PV=vt.create({name:"resizableMedia",addOptions(){return{HTMLAttributes:{class:"rounded-lg border border-stone-200"},uploadFn:async()=>""}},inline:!1,group:"block",draggable:!0,addAttributes(){return{src:{default:null},"media-type":{default:null},alt:{default:null},title:{default:null},width:{default:"100%"},height:{default:"auto"},dataAlign:{default:"left"},dataFloat:{default:null}}},selectable:!0,parseHTML(){return[{tag:'img[src]:not([src^="data:"])',getAttrs:n=>({src:n.getAttribute("src"),"media-type":"img"})},{tag:"video",getAttrs:n=>({src:n.getAttribute("src"),"media-type":"video"})}]},renderHTML({HTMLAttributes:n}){const{"media-type":e}=n;return e==="img"?["img",tt(this.options.HTMLAttributes,n)]:e==="video"?["video",{controls:"true",style:"width: 100%",...n},["source",n]]:(e||console.error("TiptapMediaExtension-renderHTML method: Media Type not set, going default with image"),["img",tt(this.options.HTMLAttributes,n)])},addCommands(){return{setMedia:n=>({commands:e})=>{const{"media-type":t}=n;return t==="img"?e.insertContent({type:this.name,attrs:n}):t==="video"?e.insertContent({type:this.name,attrs:{...n,controls:"true"}}):(t||console.error("TiptapMediaExtension-setMedia: Media Type not set, going default with image"),e.insertContent({type:this.name,attrs:n}))}}},addNodeView(){return da(SN)},addKeyboardShortcuts(){return{Enter:({editor:n})=>{const{selection:e}=n.state;if(e.empty)return!1;const t=e.$to.pos;return n.commands.insertContentAt(t,{type:"dBlock",content:[{type:"paragraph"}]})}}},addInputRules(){return[h0({find:MV,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r,"media-type":"img"}}}),h0({find:DV,type:this.type,getAttributes:n=>{const[,,e]=n;return{src:e,"media-type":"video"}}})]},addProseMirrorPlugins(){return[RV(this.options.uploadFn),d4()]}});function iv(n,e){let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>n(...s),e)}}const IV=["top","right","bottom","left"],Bs=Math.min,gr=Math.max,Lm=Math.round,_m=Math.floor,mo=n=>({x:n,y:n}),LV={left:"right",right:"left",bottom:"top",top:"bottom"},_V={start:"end",end:"start"};function ov(n,e,t){return gr(n,Bs(e,t))}function mi(n,e){return typeof n=="function"?n(e):n}function gi(n){return n.split("-")[0]}function pc(n){return n.split("-")[1]}function av(n){return n==="x"?"y":"x"}function lv(n){return n==="y"?"height":"width"}function mc(n){return["top","bottom"].includes(gi(n))?"y":"x"}function cv(n){return av(mc(n))}function BV(n,e,t){t===void 0&&(t=!1);const r=pc(n),s=cv(n),i=lv(s);let o=s==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Bm(o)),[o,Bm(o)]}function FV(n){const e=Bm(n);return[uv(n),e,uv(e)]}function uv(n){return n.replace(/start|end/g,e=>_V[e])}function jV(n,e,t){const r=["left","right"],s=["right","left"],i=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return t?e?s:r:e?r:s;case"left":case"right":return e?i:o;default:return[]}}function UV(n,e,t,r){const s=pc(n);let i=jV(gi(n),t==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(uv)))),i}function Bm(n){return n.replace(/left|right|bottom|top/g,e=>LV[e])}function HV(n){return{top:0,right:0,bottom:0,left:0,...n}}function TN(n){return typeof n!="number"?HV(n):{top:n,right:n,bottom:n,left:n}}function Fm(n){const{x:e,y:t,width:r,height:s}=n;return{width:r,height:s,top:t,left:e,right:e+r,bottom:t+s,x:e,y:t}}function NN(n,e,t){let{reference:r,floating:s}=n;const i=mc(e),o=cv(e),a=lv(o),l=gi(e),c=i==="y",u=r.x+r.width/2-s.width/2,f=r.y+r.height/2-s.height/2,d=r[a]/2-s[a]/2;let h;switch(l){case"top":h={x:u,y:r.y-s.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:f};break;case"left":h={x:r.x-s.width,y:f};break;default:h={x:r.x,y:r.y}}switch(pc(e)){case"start":h[o]-=d*(t&&c?-1:1);break;case"end":h[o]+=d*(t&&c?-1:1);break}return h}const zV=async(n,e,t)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=t,a=i.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:s}),{x:u,y:f}=NN(c,r,l),d=r,h={},p=0;for(let m=0;m<a.length;m++){const{name:y,fn:b}=a[m],{x,y:v,data:w,reset:E}=await b({x:u,y:f,initialPlacement:r,placement:d,strategy:s,middlewareData:h,rects:c,platform:o,elements:{reference:n,floating:e}});u=x??u,f=v??f,h={...h,[y]:{...h[y],...w}},E&&p<=50&&(p++,typeof E=="object"&&(E.placement&&(d=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:s}):E.rects),{x:u,y:f}=NN(c,d,l)),m=-1)}return{x:u,y:f,placement:d,strategy:s,middlewareData:h}};async function ld(n,e){var t;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:h=0}=mi(e,n),p=TN(h),y=a[d?f==="floating"?"reference":"floating":f],b=Fm(await i.getClippingRect({element:(t=await(i.isElement==null?void 0:i.isElement(y)))==null||t?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),x=f==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),w=await(i.isElement==null?void 0:i.isElement(v))?await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1}:{x:1,y:1},E=Fm(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:v,strategy:l}):x);return{top:(b.top-E.top+p.top)/w.y,bottom:(E.bottom-b.bottom+p.bottom)/w.y,left:(b.left-E.left+p.left)/w.x,right:(E.right-b.right+p.right)/w.x}}const VV=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:s,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=mi(n,e)||{};if(c==null)return{};const f=TN(u),d={x:t,y:r},h=cv(s),p=lv(h),m=await o.getDimensions(c),y=h==="y",b=y?"top":"left",x=y?"bottom":"right",v=y?"clientHeight":"clientWidth",w=i.reference[p]+i.reference[h]-d[h]-i.floating[p],E=d[h]-i.reference[h],k=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let S=k?k[v]:0;(!S||!await(o.isElement==null?void 0:o.isElement(k)))&&(S=a.floating[v]||i.floating[p]);const M=w/2-E/2,O=S/2-m[p]/2-1,R=Bs(f[b],O),D=Bs(f[x],O),F=R,U=S-m[p]-D,K=S/2-m[p]/2+M,_=ov(F,K,U),G=!l.arrow&&pc(s)!=null&&K!==_&&i.reference[p]/2-(K<F?R:D)-m[p]/2<0,Y=G?K<F?K-F:K-U:0;return{[h]:d[h]+Y,data:{[h]:_,centerOffset:K-_-Y,...G&&{alignmentOffset:Y}},reset:G}}}),$V=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...y}=mi(n,e);if((t=i.arrow)!=null&&t.alignmentOffset)return{};const b=gi(s),x=gi(a)===a,v=await(l.isRTL==null?void 0:l.isRTL(c.floating)),w=d||(x||!m?[Bm(a)]:FV(a));!d&&p!=="none"&&w.push(...UV(a,m,p,v));const E=[a,...w],k=await ld(e,y),S=[];let M=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&S.push(k[b]),f){const F=BV(s,o,v);S.push(k[F[0]],k[F[1]])}if(M=[...M,{placement:s,overflows:S}],!S.every(F=>F<=0)){var O,R;const F=(((O=i.flip)==null?void 0:O.index)||0)+1,U=E[F];if(U)return{data:{index:F,overflows:M},reset:{placement:U}};let K=(R=M.filter(_=>_.overflows[0]<=0).sort((_,G)=>_.overflows[1]-G.overflows[1])[0])==null?void 0:R.placement;if(!K)switch(h){case"bestFit":{var D;const _=(D=M.map(G=>[G.placement,G.overflows.filter(Y=>Y>0).reduce((Y,re)=>Y+re,0)]).sort((G,Y)=>G[1]-Y[1])[0])==null?void 0:D[0];_&&(K=_);break}case"initialPlacement":K=a;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function ON(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function RN(n){return IV.some(e=>n[e]>=0)}const WV=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...s}=mi(n,e);switch(r){case"referenceHidden":{const i=await ld(e,{...s,elementContext:"reference"}),o=ON(i,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:RN(o)}}}case"escaped":{const i=await ld(e,{...s,altBoundary:!0}),o=ON(i,t.floating);return{data:{escapedOffsets:o,escaped:RN(o)}}}default:return{}}}}};async function GV(n,e){const{placement:t,platform:r,elements:s}=n,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=gi(t),a=pc(t),l=mc(t)==="y",c=["left","top"].includes(o)?-1:1,u=i&&l?-1:1,f=mi(e,n);let{mainAxis:d,crossAxis:h,alignmentAxis:p}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),l?{x:h*u,y:d*c}:{x:d*c,y:h*u}}const KV=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:s,y:i,placement:o,middlewareData:a}=e,l=await GV(e,n);return o===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},JV=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:a={fn:y=>{let{x:b,y:x}=y;return{x:b,y:x}}},...l}=mi(n,e),c={x:t,y:r},u=await ld(e,l),f=mc(gi(s)),d=av(f);let h=c[d],p=c[f];if(i){const y=d==="y"?"top":"left",b=d==="y"?"bottom":"right",x=h+u[y],v=h-u[b];h=ov(x,h,v)}if(o){const y=f==="y"?"top":"left",b=f==="y"?"bottom":"right",x=p+u[y],v=p-u[b];p=ov(x,p,v)}const m=a.fn({...e,[d]:h,[f]:p});return{...m,data:{x:m.x-t,y:m.y-r}}}}},qV=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:r,placement:s,rects:i,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=mi(n,e),u={x:t,y:r},f=mc(s),d=av(f);let h=u[d],p=u[f];const m=mi(a,e),y=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const v=d==="y"?"height":"width",w=i.reference[d]-i.floating[v]+y.mainAxis,E=i.reference[d]+i.reference[v]-y.mainAxis;h<w?h=w:h>E&&(h=E)}if(c){var b,x;const v=d==="y"?"width":"height",w=["top","left"].includes(gi(s)),E=i.reference[f]-i.floating[v]+(w&&((b=o.offset)==null?void 0:b[f])||0)+(w?0:y.crossAxis),k=i.reference[f]+i.reference[v]+(w?0:((x=o.offset)==null?void 0:x[f])||0)-(w?y.crossAxis:0);p<E?p=E:p>k&&(p=k)}return{[d]:h,[f]:p}}}},QV=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){const{placement:t,rects:r,platform:s,elements:i}=e,{apply:o=()=>{},...a}=mi(n,e),l=await ld(e,a),c=gi(t),u=pc(t),f=mc(t)==="y",{width:d,height:h}=r.floating;let p,m;c==="top"||c==="bottom"?(p=c,m=u===(await(s.isRTL==null?void 0:s.isRTL(i.floating))?"start":"end")?"left":"right"):(m=c,p=u==="end"?"top":"bottom");const y=h-l.top-l.bottom,b=d-l.left-l.right,x=Bs(h-l[p],y),v=Bs(d-l[m],b),w=!e.middlewareData.shift;let E=x,k=v;if(f?k=u||w?Bs(v,b):b:E=u||w?Bs(x,y):y,w&&!u){const M=gr(l.left,0),O=gr(l.right,0),R=gr(l.top,0),D=gr(l.bottom,0);f?k=d-2*(M!==0||O!==0?M+O:gr(l.left,l.right)):E=h-2*(R!==0||D!==0?R+D:gr(l.top,l.bottom))}await o({...e,availableWidth:k,availableHeight:E});const S=await s.getDimensions(i.floating);return d!==S.width||h!==S.height?{reset:{rects:!0}}:{}}}};function gc(n){return MN(n)?(n.nodeName||"").toLowerCase():"#document"}function yr(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function yi(n){var e;return(e=(MN(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function MN(n){return n instanceof Node||n instanceof yr(n).Node}function Fs(n){return n instanceof Element||n instanceof yr(n).Element}function js(n){return n instanceof HTMLElement||n instanceof yr(n).HTMLElement}function DN(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof yr(n).ShadowRoot}function cd(n){const{overflow:e,overflowX:t,overflowY:r,display:s}=ns(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!["inline","contents"].includes(s)}function YV(n){return["table","td","th"].includes(gc(n))}function fv(n){const e=dv(),t=ns(n);return t.transform!=="none"||t.perspective!=="none"||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(t.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(t.contain||"").includes(r))}function XV(n){let e=go(n);for(;js(e)&&!yc(e);){if(fv(e))return e;e=go(e)}return null}function dv(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function yc(n){return["html","body","#document"].includes(gc(n))}function ns(n){return yr(n).getComputedStyle(n)}function jm(n){return Fs(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function go(n){if(gc(n)==="html")return n;const e=n.assignedSlot||n.parentNode||DN(n)&&n.host||yi(n);return DN(e)?e.host:e}function PN(n){const e=go(n);return yc(e)?n.ownerDocument?n.ownerDocument.body:n.body:js(e)&&cd(e)?e:PN(e)}function ud(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=PN(n),i=s===((r=n.ownerDocument)==null?void 0:r.body),o=yr(s);return i?e.concat(o,o.visualViewport||[],cd(s)?s:[],o.frameElement&&t?ud(o.frameElement):[]):e.concat(s,ud(s,[],t))}function IN(n){const e=ns(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=js(n),i=s?n.offsetWidth:t,o=s?n.offsetHeight:r,a=Lm(t)!==i||Lm(r)!==o;return a&&(t=i,r=o),{width:t,height:r,$:a}}function hv(n){return Fs(n)?n:n.contextElement}function bc(n){const e=hv(n);if(!js(e))return mo(1);const t=e.getBoundingClientRect(),{width:r,height:s,$:i}=IN(e);let o=(i?Lm(t.width):t.width)/r,a=(i?Lm(t.height):t.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const ZV=mo(0);function LN(n){const e=yr(n);return!dv()||!e.visualViewport?ZV:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function e$(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==yr(n)?!1:e}function Ma(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=n.getBoundingClientRect(),i=hv(n);let o=mo(1);e&&(r?Fs(r)&&(o=bc(r)):o=bc(n));const a=e$(i,t,r)?LN(i):mo(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,u=s.width/o.x,f=s.height/o.y;if(i){const d=yr(i),h=r&&Fs(r)?yr(r):r;let p=d,m=p.frameElement;for(;m&&r&&h!==p;){const y=bc(m),b=m.getBoundingClientRect(),x=ns(m),v=b.left+(m.clientLeft+parseFloat(x.paddingLeft))*y.x,w=b.top+(m.clientTop+parseFloat(x.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,f*=y.y,l+=v,c+=w,p=yr(m),m=p.frameElement}}return Fm({width:u,height:f,x:l,y:c})}const t$=[":popover-open",":modal"];function pv(n){return t$.some(e=>{try{return n.matches(e)}catch{return!1}})}function n$(n){let{elements:e,rect:t,offsetParent:r,strategy:s}=n;const i=s==="fixed",o=yi(r),a=e?pv(e.floating):!1;if(r===o||a&&i)return t;let l={scrollLeft:0,scrollTop:0},c=mo(1);const u=mo(0),f=js(r);if((f||!f&&!i)&&((gc(r)!=="body"||cd(o))&&(l=jm(r)),js(r))){const d=Ma(r);c=bc(r),u.x=d.x+r.clientLeft,u.y=d.y+r.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x,y:t.y*c.y-l.scrollTop*c.y+u.y}}function r$(n){return Array.from(n.getClientRects())}function _N(n){return Ma(yi(n)).left+jm(n).scrollLeft}function s$(n){const e=yi(n),t=jm(n),r=n.ownerDocument.body,s=gr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=gr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+_N(n);const a=-t.scrollTop;return ns(r).direction==="rtl"&&(o+=gr(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:a}}function i$(n,e){const t=yr(n),r=yi(n),s=t.visualViewport;let i=r.clientWidth,o=r.clientHeight,a=0,l=0;if(s){i=s.width,o=s.height;const c=dv();(!c||c&&e==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:i,height:o,x:a,y:l}}function o$(n,e){const t=Ma(n,!0,e==="fixed"),r=t.top+n.clientTop,s=t.left+n.clientLeft,i=js(n)?bc(n):mo(1),o=n.clientWidth*i.x,a=n.clientHeight*i.y,l=s*i.x,c=r*i.y;return{width:o,height:a,x:l,y:c}}function BN(n,e,t){let r;if(e==="viewport")r=i$(n,t);else if(e==="document")r=s$(yi(n));else if(Fs(e))r=o$(e,t);else{const s=LN(n);r={...e,x:e.x-s.x,y:e.y-s.y}}return Fm(r)}function FN(n,e){const t=go(n);return t===e||!Fs(t)||yc(t)?!1:ns(t).position==="fixed"||FN(t,e)}function a$(n,e){const t=e.get(n);if(t)return t;let r=ud(n,[],!1).filter(a=>Fs(a)&&gc(a)!=="body"),s=null;const i=ns(n).position==="fixed";let o=i?go(n):n;for(;Fs(o)&&!yc(o);){const a=ns(o),l=fv(o);!l&&a.position==="fixed"&&(s=null),(i?!l&&!s:!l&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||cd(o)&&!l&&FN(n,o))?r=r.filter(u=>u!==o):s=a,o=go(o)}return e.set(n,r),r}function l$(n){let{element:e,boundary:t,rootBoundary:r,strategy:s}=n;const o=[...t==="clippingAncestors"?pv(e)?[]:a$(e,this._c):[].concat(t),r],a=o[0],l=o.reduce((c,u)=>{const f=BN(e,u,s);return c.top=gr(f.top,c.top),c.right=Bs(f.right,c.right),c.bottom=Bs(f.bottom,c.bottom),c.left=gr(f.left,c.left),c},BN(e,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function c$(n){const{width:e,height:t}=IN(n);return{width:e,height:t}}function u$(n,e,t){const r=js(e),s=yi(e),i=t==="fixed",o=Ma(n,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=mo(0);if(r||!r&&!i)if((gc(e)!=="body"||cd(s))&&(a=jm(e)),r){const f=Ma(e,!0,i,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else s&&(l.x=_N(s));const c=o.left+a.scrollLeft-l.x,u=o.top+a.scrollTop-l.y;return{x:c,y:u,width:o.width,height:o.height}}function mv(n){return ns(n).position==="static"}function jN(n,e){return!js(n)||ns(n).position==="fixed"?null:e?e(n):n.offsetParent}function UN(n,e){const t=yr(n);if(pv(n))return t;if(!js(n)){let s=go(n);for(;s&&!yc(s);){if(Fs(s)&&!mv(s))return s;s=go(s)}return t}let r=jN(n,e);for(;r&&YV(r)&&mv(r);)r=jN(r,e);return r&&yc(r)&&mv(r)&&!fv(r)?t:r||XV(n)||t}const f$=async function(n){const e=this.getOffsetParent||UN,t=this.getDimensions,r=await t(n.floating);return{reference:u$(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function d$(n){return ns(n).direction==="rtl"}const h$={convertOffsetParentRelativeRectToViewportRelativeRect:n$,getDocumentElement:yi,getClippingRect:l$,getOffsetParent:UN,getElementRects:f$,getClientRects:r$,getDimensions:c$,getScale:bc,isElement:Fs,isRTL:d$};function p$(n,e){let t=null,r;const s=yi(n);function i(){var a;clearTimeout(r),(a=t)==null||a.disconnect(),t=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),i();const{left:c,top:u,width:f,height:d}=n.getBoundingClientRect();if(a||e(),!f||!d)return;const h=_m(u),p=_m(s.clientWidth-(c+f)),m=_m(s.clientHeight-(u+d)),y=_m(c),x={rootMargin:-h+"px "+-p+"px "+-m+"px "+-y+"px",threshold:gr(0,Bs(1,l))||1};let v=!0;function w(E){const k=E[0].intersectionRatio;if(k!==l){if(!v)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}v=!1}try{t=new IntersectionObserver(w,{...x,root:s.ownerDocument})}catch{t=new IntersectionObserver(w,x)}t.observe(n)}return o(!0),i}function m$(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=hv(n),u=s||i?[...c?ud(c):[],...ud(e)]:[];u.forEach(b=>{s&&b.addEventListener("scroll",t,{passive:!0}),i&&b.addEventListener("resize",t)});const f=c&&a?p$(c,t):null;let d=-1,h=null;o&&(h=new ResizeObserver(b=>{let[x]=b;x&&x.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var v;(v=h)==null||v.observe(e)})),t()}),c&&!l&&h.observe(c),h.observe(e));let p,m=l?Ma(n):null;l&&y();function y(){const b=Ma(n);m&&(b.x!==m.x||b.y!==m.y||b.width!==m.width||b.height!==m.height)&&t(),m=b,p=requestAnimationFrame(y)}return t(),()=>{var b;u.forEach(x=>{s&&x.removeEventListener("scroll",t),i&&x.removeEventListener("resize",t)}),f==null||f(),(b=h)==null||b.disconnect(),h=null,l&&cancelAnimationFrame(p)}}const g$=KV,y$=JV,b$=$V,w$=QV,v$=WV,HN=VV,x$=qV,A$=(n,e,t)=>{const r=new Map,s={platform:h$,...t},i={...s.platform,_c:r};return zV(n,e,{...s,platform:i})};var Um=typeof document<"u"?L.useLayoutEffect:L.useEffect;function Hm(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,s;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!Hm(n[r],e[r]))return!1;return!0}if(s=Object.keys(n),t=s.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=t;r--!==0;){const i=s[r];if(!(i==="_owner"&&n.$$typeof)&&!Hm(n[i],e[i]))return!1}return!0}return n!==n&&e!==e}function zN(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function VN(n,e){const t=zN(n);return Math.round(e*t)/t}function $N(n){const e=H.useRef(n);return Um(()=>{e.current=n}),e}function E$(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=n,[u,f]=H.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[d,h]=H.useState(r);Hm(d,r)||h(r);const[p,m]=H.useState(null),[y,b]=H.useState(null),x=H.useCallback(Y=>{Y!==k.current&&(k.current=Y,m(Y))},[]),v=H.useCallback(Y=>{Y!==S.current&&(S.current=Y,b(Y))},[]),w=i||p,E=o||y,k=H.useRef(null),S=H.useRef(null),M=H.useRef(u),O=l!=null,R=$N(l),D=$N(s),F=H.useCallback(()=>{if(!k.current||!S.current)return;const Y={placement:e,strategy:t,middleware:d};D.current&&(Y.platform=D.current),A$(k.current,S.current,Y).then(re=>{const Z={...re,isPositioned:!0};U.current&&!Hm(M.current,Z)&&(M.current=Z,sy.flushSync(()=>{f(Z)}))})},[d,e,t,D]);Um(()=>{c===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,f(Y=>({...Y,isPositioned:!1})))},[c]);const U=H.useRef(!1);Um(()=>(U.current=!0,()=>{U.current=!1}),[]),Um(()=>{if(w&&(k.current=w),E&&(S.current=E),w&&E){if(R.current)return R.current(w,E,F);F()}},[w,E,F,R,O]);const K=H.useMemo(()=>({reference:k,floating:S,setReference:x,setFloating:v}),[x,v]),_=H.useMemo(()=>({reference:w,floating:E}),[w,E]),G=H.useMemo(()=>{const Y={position:t,left:0,top:0};if(!_.floating)return Y;const re=VN(_.floating,u.x),Z=VN(_.floating,u.y);return a?{...Y,transform:"translate("+re+"px, "+Z+"px)",...zN(_.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:re,top:Z}},[t,a,_.floating,u.x,u.y]);return H.useMemo(()=>({...u,update:F,refs:K,elements:_,floatingStyles:G}),[u,F,K,_,G])}const k$=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:s}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?HN({element:r.current,padding:s}).fn(t):{}:r?HN({element:r,padding:s}).fn(t):{}}}},C$=(n,e)=>({...g$(n),options:[n,e]}),S$=(n,e)=>({...y$(n),options:[n,e]}),T$=(n,e)=>({...x$(n),options:[n,e]}),N$=(n,e)=>({...b$(n),options:[n,e]}),O$=(n,e)=>({...w$(n),options:[n,e]}),R$=(n,e)=>({...v$(n),options:[n,e]}),M$=(n,e)=>({...k$(n),options:[n,e]});var D$="Arrow",WN=H.forwardRef((n,e)=>{const{children:t,width:r=10,height:s=5,...i}=n;return C.jsx(Kn.svg,{...i,ref:e,width:r,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:C.jsx("polygon",{points:"0,0 30,0 15,10"})})});WN.displayName=D$;var P$=WN;function I$(n){const[e,t]=H.useState(void 0);return ha(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,a;if("borderBoxSize"in i){const l=i.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=n.offsetWidth,a=n.offsetHeight;t({width:o,height:a})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else t(void 0)},[n]),e}var gv="Popper",[GN,KN]=V0(gv),[L$,JN]=GN(gv),qN=n=>{const{__scopePopper:e,children:t}=n,[r,s]=H.useState(null);return C.jsx(L$,{scope:e,anchor:r,onAnchorChange:s,children:t})};qN.displayName=gv;var QN="PopperAnchor",YN=H.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:r,...s}=n,i=JN(QN,t),o=H.useRef(null),a=Or(e,o);return H.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:C.jsx(Kn.div,{...s,ref:a})});YN.displayName=QN;var yv="PopperContent",[_$,B$]=GN(yv),XN=H.forwardRef((n,e)=>{var He,Le,Ze,le,ze,ae;const{__scopePopper:t,side:r="bottom",sideOffset:s=0,align:i="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:d=!1,updatePositionStrategy:h="optimized",onPlaced:p,...m}=n,y=JN(yv,t),[b,x]=H.useState(null),v=Or(e,be=>x(be)),[w,E]=H.useState(null),k=I$(w),S=(k==null?void 0:k.width)??0,M=(k==null?void 0:k.height)??0,O=r+(i!=="center"?"-"+i:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],F=D.length>0,U={padding:R,boundary:D.filter(j$),altBoundary:F},{refs:K,floatingStyles:_,placement:G,isPositioned:Y,middlewareData:re}=E$({strategy:"fixed",placement:O,whileElementsMounted:(...be)=>m$(...be,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[C$({mainAxis:s+M,alignmentAxis:o}),l&&S$({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T$():void 0,...U}),l&&N$({...U}),O$({...U,apply:({elements:be,rects:_e,availableWidth:z,availableHeight:J})=>{const{width:ne,height:ce}=_e.reference,P=be.floating.style;P.setProperty("--radix-popper-available-width",`${z}px`),P.setProperty("--radix-popper-available-height",`${J}px`),P.setProperty("--radix-popper-anchor-width",`${ne}px`),P.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),w&&M$({element:w,padding:a}),U$({arrowWidth:S,arrowHeight:M}),d&&R$({strategy:"referenceHidden",...U})]}),[Z,me]=tO(G),ke=ro(p);ha(()=>{Y&&(ke==null||ke())},[Y,ke]);const Pe=(He=re.arrow)==null?void 0:He.x,Ce=(Le=re.arrow)==null?void 0:Le.y,Ee=((Ze=re.arrow)==null?void 0:Ze.centerOffset)!==0,[Ue,Fe]=H.useState();return ha(()=>{b&&Fe(window.getComputedStyle(b).zIndex)},[b]),C.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{..._,transform:Y?_.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ue,"--radix-popper-transform-origin":[(le=re.transformOrigin)==null?void 0:le.x,(ze=re.transformOrigin)==null?void 0:ze.y].join(" "),...((ae=re.hide)==null?void 0:ae.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:C.jsx(_$,{scope:t,placedSide:Z,onArrowChange:E,arrowX:Pe,arrowY:Ce,shouldHideArrow:Ee,children:C.jsx(Kn.div,{"data-side":Z,"data-align":me,...m,ref:v,style:{...m.style,animation:Y?void 0:"none"}})})})});XN.displayName=yv;var ZN="PopperArrow",F$={top:"bottom",right:"left",bottom:"top",left:"right"},eO=H.forwardRef(function(e,t){const{__scopePopper:r,...s}=e,i=B$(ZN,r),o=F$[i.placedSide];return C.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:C.jsx(P$,{...s,ref:t,style:{...s.style,display:"block"}})})});eO.displayName=ZN;function j$(n){return n!==null}var U$=n=>({name:"transformOrigin",options:n,fn(e){var y,b,x;const{placement:t,rects:r,middlewareData:s}=e,o=((y=s.arrow)==null?void 0:y.centerOffset)!==0,a=o?0:n.arrowWidth,l=o?0:n.arrowHeight,[c,u]=tO(t),f={start:"0%",center:"50%",end:"100%"}[u],d=(((b=s.arrow)==null?void 0:b.x)??0)+a/2,h=(((x=s.arrow)==null?void 0:x.y)??0)+l/2;let p="",m="";return c==="bottom"?(p=o?f:`${d}px`,m=`${-l}px`):c==="top"?(p=o?f:`${d}px`,m=`${r.floating.height+l}px`):c==="right"?(p=`${-l}px`,m=o?f:`${h}px`):c==="left"&&(p=`${r.floating.width+l}px`,m=o?f:`${h}px`),{data:{x:p,y:m}}}});function tO(n){const[e,t="center"]=n.split("-");return[e,t]}var H$=qN,nO=YN,z$=XN,V$=eO,bv="Popover",[rO,oQ]=V0(bv,[KN]),fd=KN(),[$$,Da]=rO(bv),sO=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=n,a=fd(e),l=H.useRef(null),[c,u]=H.useState(!1),[f=!1,d]=qk({prop:r,defaultProp:s,onChange:i});return C.jsx(H$,{...a,children:C.jsx($$,{scope:e,contentId:qh(),triggerRef:l,open:f,onOpenChange:d,onOpenToggle:H.useCallback(()=>d(h=>!h),[d]),hasCustomAnchor:c,onCustomAnchorAdd:H.useCallback(()=>u(!0),[]),onCustomAnchorRemove:H.useCallback(()=>u(!1),[]),modal:o,children:t})})};sO.displayName=bv;var iO="PopoverAnchor",W$=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(iO,t),i=fd(t),{onCustomAnchorAdd:o,onCustomAnchorRemove:a}=s;return H.useEffect(()=>(o(),()=>a()),[o,a]),C.jsx(nO,{...i,...r,ref:e})});W$.displayName=iO;var oO="PopoverTrigger",aO=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(oO,t),i=fd(t),o=Or(e,s.triggerRef),a=C.jsx(Kn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":dO(s.open),...r,ref:o,onClick:fr(n.onClick,s.onOpenToggle)});return s.hasCustomAnchor?a:C.jsx(nO,{asChild:!0,...i,children:a})});aO.displayName=oO;var G$="PopoverPortal",[aQ,K$]=rO(G$,{forceMount:void 0}),wc="PopoverContent",lO=H.forwardRef((n,e)=>{const t=K$(wc,n.__scopePopover),{forceMount:r=t.forceMount,...s}=n,i=Da(wc,n.__scopePopover);return C.jsx(kf,{present:r||i.open,children:i.modal?C.jsx(J$,{...s,ref:e}):C.jsx(q$,{...s,ref:e})})});lO.displayName=wc;var J$=H.forwardRef((n,e)=>{const t=Da(wc,n.__scopePopover),r=H.useRef(null),s=Or(e,r),i=H.useRef(!1);return H.useEffect(()=>{const o=r.current;if(o)return xC(o)},[]),C.jsx(eb,{as:Qh,allowPinchZoom:!0,children:C.jsx(cO,{...n,ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:fr(n.onCloseAutoFocus,o=>{var a;o.preventDefault(),i.current||(a=t.triggerRef.current)==null||a.focus()}),onPointerDownOutside:fr(n.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:fr(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),q$=H.forwardRef((n,e)=>{const t=Da(wc,n.__scopePopover),r=H.useRef(!1),s=H.useRef(!1);return C.jsx(cO,{...n,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,a;(o=n.onCloseAutoFocus)==null||o.call(n,i),i.defaultPrevented||(r.current||(a=t.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,s.current=!1},onInteractOutside:i=>{var l,c;(l=n.onInteractOutside)==null||l.call(n,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const o=i.target;((c=t.triggerRef.current)==null?void 0:c.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),cO=H.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=n,d=Da(wc,t),h=fd(t);return oC(),C.jsx(Ef,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i,children:C.jsx(G0,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>d.onOpenChange(!1),children:C.jsx(z$,{"data-state":dO(d.open),role:"dialog",id:d.contentId,...h,...f,ref:e,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),uO="PopoverClose",fO=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=Da(uO,t);return C.jsx(Kn.button,{type:"button",...r,ref:e,onClick:fr(n.onClick,()=>s.onOpenChange(!1))})});fO.displayName=uO;var Q$="PopoverArrow",Y$=H.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=fd(t);return C.jsx(V$,{...s,...r,ref:e})});Y$.displayName=Q$;function dO(n){return n?"open":"closed"}var X$=sO,Z$=aO,e9=lO,zm=fO;const Vm=({children:n,isActive:e,onClick:t,disabled:r,className:s})=>{const i=pe("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",s);return C.jsx("button",{className:i,disabled:r,onClick:t,children:n})},t9=(n,e,t)=>{const r=L.useCallback(()=>{const a=n.chain();a.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&a.setParagraph(),a.run()},[n,t,e==null?void 0:e.type.name]),s=L.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:a}=n.state.selection,l=a.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),l.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),i=L.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=L.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:s,copyNodeToClipboard:i,deleteNode:o}},n9=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[s,i]=L.useState(!1),o=t9(t,n,e()),a=gp(),l=["https://twitter.com","https://x.com"],c=L.useMemo(()=>{const{content:O}=n.content;return O[0].type.name==="table"},[n.content]),u=L.useMemo(()=>{var R;const{content:O}=n.content;return(R=O[0].content.content[0])==null?void 0:R.text},[n.content]),f=L.useMemo(()=>{var R;const{content:O}=n.content;return(R=O[0].content.content[1])==null?void 0:R.text},[n.content]),d=L.useMemo(()=>{const{content:O}=n.content;return O[0].content.content.find(R=>{var D;return(D=R==null?void 0:R.text)==null?void 0:D.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let O=u;if(u.includes("<iframe"))O=f;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const K=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);K&&K.length>0&&(O=`https://www.youtube.com/embed/${K[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const K=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);K&&K.length>0&&(O=`https://player.vimeo.com/video/${K[1]}`);break}default:return}const R=640,D=360,F=e(),U=F+n.nodeSize;O&&(t==null||t.chain().focus(F).deleteRange({from:F===0?F:F+1,to:U}).setIframe({src:O,width:R,height:D}).run())},p=O=>{const R=O.match(/\/status\/([0-9]*)/);return R&&R.length>0?R[1]:null},m=()=>{if(!u)return;let O=u;const R=l.some(K=>u.includes(K)),D=p(u);R&&D?O=D:d&&(O=p(d.text));const F=e(),U=F+n.nodeSize;O&&(t==null||t.chain().focus(F).deleteRange({from:F===2?F:F+1,to:U}).setTweetEmbed({tweetId:O}).run())},y=()=>{const O=e()+n.nodeSize;t.commands.insertContentAt(O,{type:"dBlock",content:[{type:"paragraph"}]})},b=()=>{const O=e();t.commands.insertContentAt(O,{type:"dBlock",content:[{type:"paragraph"}]})},x=()=>{r()},v=O=>{O.altKey?E():w()},w=()=>{y()},E=()=>{b()},k=O=>{O.altKey&&x()},M=iv(()=>{if(l.some(O=>u.includes(O))||d!=null&&d.text){m();return}else{h();return}},1e3);return L.useEffect(()=>{u&&M()},[u]),C.jsxs(wf,{as:"div",className:pe("flex gap-2 group w-full relative justify-center items-start",a&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[C.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[C.jsx(_S,{content:C.jsxs("div",{className:"flex flex-col w-40",children:[C.jsx("div",{className:"text-xs",children:"Click to add below"}),C.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:C.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:v,children:C.jsx(i4,{size:18})})}),C.jsxs(X$,{open:s,onOpenChange:i,children:[C.jsx(Z$,{asChild:!0,children:C.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:k,children:C.jsx(Z3,{size:18})})}),C.jsx(e9,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:C.jsxs(Tb,{className:"p-2 flex flex-col min-w-[16rem]",children:[C.jsx(zm,{children:C.jsxs(Vm,{onClick:o.resetTextFormatting,children:[C.jsx(o4,{size:18}),"Clear formatting"]})}),C.jsx(zm,{children:C.jsxs(Vm,{onClick:o.copyNodeToClipboard,children:[C.jsx(q3,{size:18}),"Copy to clipboard"]})}),C.jsx(zm,{children:C.jsxs(Vm,{onClick:o.duplicateNode,children:[C.jsx(Y3,{size:18}),"Duplicate"]})}),C.jsx(If.Divider,{horizontal:!0}),C.jsx(zm,{children:C.jsxs(Vm,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[C.jsx(Wk,{size:18}),"Delete"]})})]})})]})]}),C.jsx(Ik,{className:pe("node-view-content w-full",{"is-table min-w-auto":c})})]})},r9=vt.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,s=n!==void 0||n!==null?r:n;return t().insertContentAt(s,{type:this.name,content:[{type:"paragraph"}]}).focus(s+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;const o=[];if(e.doc.nodesBetween(r,s,l=>{if(l.type.name===this.name){const c=e.schema.nodes.listItem.create(null,l.content);c&&o.push(c)}}),o.length===0)return!1;const a=e.schema.nodes[n].create(null,o);return a?(i=i.replaceRangeWith(r,s,a),t(i),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;return e.doc.nodesBetween(r,s,(o,a)=>{if(o.type.name===n){const l=e.schema.nodes[this.name].create(null,o.content);i=i.insert(a,l)}}),t(i),!0}}},addNodeView(){return da(n9)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:s}=n.state,i=e.node(e.depth-1);if((i==null?void 0:i.type.name)!=="dBlock")return!1;let o=-1,a="";s.descendants((u,f)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[d,h]=[f,f+u.nodeSize];return d<=t&&r<=h&&(o=h,a=u.type.name),!1});const l=(c=s.slice(t,o))==null?void 0:c.toJSON().content;try{return a==="codeBlock"?n.chain().newlineInCode().focus(o+1).run():["columns","heading"].includes(a)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:l}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let wv,vv;if(typeof WeakMap<"u"){let n=new WeakMap;wv=e=>n.get(e),vv=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;wv=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},vv=(r,s)=>(t==e&&(t=0),n[t++]=r,n[t++]=s)}class vc{constructor(e,t,r,s){this.left=e,this.top=t,this.right=r,this.bottom=s}}class Bt{constructor(e,t,r,s){this.width=e,this.height=t,this.map=r,this.problems=s}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let s=t%this.width,i=t/this.width|0,o=s+1,a=i+1;for(let l=1;o<this.width&&this.map[t+l]==r;l++)o++;for(let l=1;a<this.height&&this.map[t+this.width*l]==r;l++)a++;return new vc(s,i,o,a)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:s,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(r<0?s==0:i==this.width)?null:this.map[o*this.width+(r<0?s-1:i)]:(r<0?o==0:a==this.height)?null:this.map[s+this.width*(r<0?o-1:a)]}rectBetween(e,t){let{left:r,right:s,top:i,bottom:o}=this.findCell(e),{left:a,right:l,top:c,bottom:u}=this.findCell(t);return new vc(Math.min(r,a),Math.min(i,c),Math.max(s,l),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let s=e.top;s<e.bottom;s++)for(let i=e.left;i<e.right;i++){let o=s*this.width+i,a=this.map[o];r[a]||(r[a]=!0,(i!=e.left||!i||this.map[o-1]!=a)&&(s!=e.top||!s||this.map[o-this.width]!=a)&&t.push(a))}return t}positionAt(e,t,r){for(let s=0,i=0;;s++){let o=i+r.child(s).nodeSize;if(s==e){let a=t+e*this.width,l=(e+1)*this.width;for(;a<l&&this.map[a]<i;)a++;return a==l?o-1:this.map[a]}i=o}}static get(e){return wv(e)||vv(e,s9(e))}}function s9(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=i9(n),t=n.childCount,r=[],s=0,i=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let f=n.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==f.childCount)break;let m=f.child(p),{colspan:y,rowspan:b,colwidth:x}=m.attrs;for(let v=0;v<b;v++){if(v+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-v});break}let w=s+v*e;for(let E=0;E<y;E++){r[w+E]==0?r[w+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-E});let k=x&&x[E];if(k){let S=(w+E)%e*2,M=o[S];M==null||M!=k&&o[S+1]==1?(o[S]=k,o[S+1]=1):M==k&&o[S+1]++}}}s+=y,u+=m.nodeSize}let d=(c+1)*e,h=0;for(;s<d;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}let a=new Bt(e,t,r,i),l=!1;for(let c=0;!l&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(l=!0);return l&&o9(a,o,n),a}function i9(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let s=n.child(r),i=0;if(t)for(let o=0;o<r;o++){let a=n.child(o);for(let l=0;l<a.childCount;l++){let c=a.child(l);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){let a=s.child(o);i+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function o9(n,e,t){n.problems||(n.problems=[]);for(let r=0,s={};r<n.map.length;r++){let i=n.map[r];if(s[i])continue;s[i]=!0;let o=t.nodeAt(i),a=null;for(let l=0;l<o.attrs.colspan;l++){let c=(r+l)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[l]!=u)&&((a||(a=a9(o.attrs)))[l]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function a9(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function xn(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const yo=new Ot("selectingCells");function xc(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function l9(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function rs(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function $m(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:xc(e.$head)||c9(e.$head)}function c9(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function xv(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function u9(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Av(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function hO(n,e,t){let r=n.start(-1),i=Bt.get(n.node(-1)).nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function an(n,e,t){let r={};for(let s in n)r[s]=n[s];return r[e]=t,r}function Pa(n,e,t=1){let r=an(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function pO(n,e,t=1){let r=an(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function f9(n,e,t){let r=xn(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}class it extends Ie{constructor(e,t=e){let r=e.node(-1),s=Bt.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),a=e.node(0),l=s.cellsInRect(o).filter(u=>u!=t.pos-i);l.unshift(t.pos-i);let c=l.map(u=>{let f=r.nodeAt(u),d=u+i+1;return new Ay(a.resolve(d),a.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(xv(r)&&xv(s)&&Av(r,s)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?it.rowSelection(r,s):i&&this.isColSelection()?it.colSelection(r,s):new it(r,s)}return Me.between(r,s)}content(){let e=this.$anchorCell.node(-1),t=Bt.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let l=s.top;l<s.bottom;l++){let c=[];for(let u=l*t.width+s.left,f=s.left;f<s.right;f++,u++){let d=t.map[u];if(!i[d]){i[d]=!0;let h=t.findCell(d),p=e.nodeAt(d),m=s.left-h.left,y=h.right-s.right;if(m>0||y>0){let b=p.attrs;m>0&&(b=Pa(b,0,m)),y>0&&(b=Pa(b,b.colspan-y,y)),h.left<s.left?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}if(h.top<s.top||h.bottom>s.bottom){let b=an(p.attrs,"rowspan",Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top));h.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}}o.push(e.child(l).copy(oe.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new ue(oe.from(a),1,1)}replace(e,t=ue.empty){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),o?ue.empty:t)}let i=Ie.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new ue(oe.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=Bt.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=Bt.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.top<=o.top?(i.top>0&&(e=a.resolve(s+r.map[i.left])),o.bottom<r.height&&(t=a.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=a.resolve(s+r.map[o.left])),i.bottom<r.height&&(e=a.resolve(s+r.map[r.width*(r.height-1)+i.right-1]))),new it(e,t)}isRowSelection(){let e=Bt.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),s=e.colCount(this.$headCell.pos-t);if(Math.min(r,s)>0)return!1;let i=r+this.$anchorCell.nodeAfter.attrs.colspan,o=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,o)==e.width}eq(e){return e instanceof it&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=Bt.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.left<=o.left?(i.left>0&&(e=a.resolve(s+r.map[i.top*r.width])),o.right<r.width&&(t=a.resolve(s+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=a.resolve(s+r.map[o.top*r.width])),i.right<r.width&&(e=a.resolve(s+r.map[r.width*(i.top+1)-1]))),new it(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new it(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new it(e.resolve(t),e.resolve(r))}getBookmark(){return new Ev(this.$anchorCell.pos,this.$headCell.pos)}}it.prototype.visible=!1,Ie.jsonID("cell",it);class Ev{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Ev(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Av(t,r)?new it(t,r):Ie.near(r,1)}}function d9(n){if(!(n.selection instanceof it))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(Qt.node(r,r+t.nodeSize,{class:"selectedCell"}))}),wt.create(n.doc,e)}function h9({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function p9({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){let i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){let i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function m9(n,e,t){let r=(e||n).selection,s=(e||n).doc,i,o;if(r instanceof Ne&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=it.create(s,r.from);else if(o=="row"){let a=s.resolve(r.from+1);i=it.rowSelection(a,a)}else if(!t){let a=Bt.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];i=it.create(s,l+1,c)}}else r instanceof Me&&h9(r)?i=Me.create(s,r.from):r instanceof Me&&p9(r)&&(i=Me.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function g9(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let s=e.firstChild,i=s.type.spec.tableRole,o=s.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content,u=l?0:Math.max(0,t-1),f=l<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=kv(xn(o).row,new ue(c,u,f)).content),a.push(c)}else if(i=="cell"||i=="header_cell")a.push(t||r?kv(xn(o).row,new ue(e,t,r)).content:e);else return null;return y9(o,a)}function y9(n,e){let t=[];for(let s=0;s<e.length;s++){let i=e[s];for(let o=i.childCount-1;o>=0;o--){let{rowspan:a,colspan:l}=i.child(o).attrs;for(let c=s;c<s+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(oe.empty),t[s]<r){let i=xn(n).cell.createAndFill(),o=[];for(let a=t[s];a<r;a++)o.push(i);e[s]=e[s].append(oe.from(o))}return{height:e.length,width:r,rows:e}}function kv(n,e){let t=n.createAndFill();return new vy(t).replace(0,t.content.size,e).doc}function b9({width:n,height:e,rows:t},r,s){if(n!=r){let i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a],c=[];for(let u=i[a]||0,f=0;u<r;f++){let d=l.child(f%l.childCount);u+d.attrs.colspan>r&&(d=d.type.create(Pa(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)i[a+h]=(i[a+h]||0)+d.attrs.colspan}o.push(oe.from(c))}t=o,n=r}if(e!=s){let i=[];for(let o=0,a=0;o<s;o++,a++){let l=[],c=t[a%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);o+f.attrs.rowspan>s&&(f=f.type.create(an(f.attrs,"rowspan",Math.max(1,s-f.attrs.rowspan)),f.content)),l.push(f)}i.push(oe.from(l))}t=i,e=s}return{width:n,height:e,rows:t}}function w9(n,e,t,r,s,i,o){let a=n.doc.type.schema,l=xn(a),c,u;if(s>e.width)for(let f=0,d=0;f<e.height;f++){let h=t.child(f);d+=h.nodeSize;let p=[],m;h.lastChild==null||h.lastChild.type==l.cell?m=c||(c=l.cell.createAndFill()):m=u||(u=l.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(m);n.insert(n.mapping.slice(o).map(d-1+r),p)}if(i>e.height){let f=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){let y=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==l.header_cell;f.push(y?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}let d=l.row.create(null,oe.from(f)),h=[];for(let p=e.height;p<i;p++)h.push(d);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function mO(n,e,t,r,s,i,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let c=s;c<i;c++){let u=o*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){l=!0;let d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(a).map(f+r),null,an(d.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(a).map(e.positionAt(o,p,t)),d.type.createAndFill(an(d.attrs,"rowspan",h+d.attrs.rowspan-o))),c+=d.attrs.colspan-1}}return l}function gO(n,e,t,r,s,i,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let c=s;c<i;c++){let u=c*e.width+o,f=e.map[u];if(e.map[u-1]==f){l=!0;let d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(a).map(f+r);n.setNodeMarkup(p,null,Pa(d.attrs,o-h,d.attrs.colspan-(o-h))),n.insert(p+d.nodeSize,d.type.createAndFill(Pa(d.attrs,0,o-h))),c+=d.attrs.rowspan-1}}return l}function yO(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc,o=Bt.get(i),{top:a,left:l}=r,c=l+s.width,u=a+s.height,f=n.tr,d=0;function h(){i=t?f.doc.nodeAt(t-1):f.doc,o=Bt.get(i),d=f.mapping.maps.length}w9(f,o,i,t,c,u,d)&&h(),mO(f,o,i,t,l,c,a,d)&&h(),mO(f,o,i,t,l,c,u,d)&&h(),gO(f,o,i,t,a,u,l,d)&&h(),gO(f,o,i,t,a,u,c,d)&&h();for(let p=a;p<u;p++){let m=o.positionAt(p,l,i),y=o.positionAt(p,c,i);f.replace(f.mapping.slice(d).map(m+t),f.mapping.slice(d).map(y+t),new ue(s.rows[p-a],0,0))}h(),f.setSelection(new it(f.doc.resolve(t+o.positionAt(a,l,i)),f.doc.resolve(t+o.positionAt(u-1,c-1,i)))),e(f)}const v9=Yy({ArrowLeft:Gm("horiz",-1),ArrowRight:Gm("horiz",1),ArrowUp:Gm("vert",-1),ArrowDown:Gm("vert",1),"Shift-ArrowLeft":Km("horiz",-1),"Shift-ArrowRight":Km("horiz",1),"Shift-ArrowUp":Km("vert",-1),"Shift-ArrowDown":Km("vert",1),Backspace:Jm,"Mod-Backspace":Jm,Delete:Jm,"Mod-Delete":Jm});function Wm(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Gm(n,e){return(t,r,s)=>{let i=t.selection;if(i instanceof it)return Wm(t,r,Ie.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let o=bO(s,n,e);if(o==null)return!1;if(n=="horiz")return Wm(t,r,Ie.near(t.doc.resolve(i.head+e),e));{let a=t.doc.resolve(o),l=hO(a,n,e),c;return l?c=Ie.near(l,1):e<0?c=Ie.near(t.doc.resolve(a.before(-1)),-1):c=Ie.near(t.doc.resolve(a.after(-1)),1),Wm(t,r,c)}}}function Km(n,e){return(t,r,s)=>{let i=t.selection;if(!(i instanceof it)){let a=bO(s,n,e);if(a==null)return!1;i=new it(t.doc.resolve(a))}let o=hO(i.$headCell,n,e);return o?Wm(t,r,new it(i.$anchorCell,o)):!1}}function Jm(n,e){let t=n.selection;if(!(t instanceof it))return!1;if(e){let r=n.tr,s=xn(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new ue(s,0,0))}),r.docChanged&&e(r)}return!0}function x9(n,e){let t=n.state.doc,r=xc(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new it(r))),!0):!1}function A9(n,e,t){if(!rs(n.state))return!1;let r=g9(t),s=n.state.selection;if(s instanceof it){r||(r={width:1,height:1,rows:[oe.from(kv(xn(n.state.schema).cell,t))]});let i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),a=Bt.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=b9(r,a.right-a.left,a.bottom-a.top),yO(n.state,n.dispatch,o,a,r),!0}else if(r){let i=$m(n.state),o=i.start(-1);return yO(n.state,n.dispatch,o,Bt.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function E9(n,e){if(e.ctrlKey||e.metaKey)return;let t=wO(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof it)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=xc(n.state.selection.$anchor))!=null&&Cv(n,e).pos!=r.pos)s(r,e),e.preventDefault();else if(!t)return;function s(a,l){let c=Cv(n,l),u=yo.getState(n.state)==null;if(!c||!Av(a,c))if(u)c=a;else return;let f=new it(a,c);if(u||!n.state.selection.eq(f)){let d=n.state.tr.setSelection(f);u&&d.setMeta(yo,a.pos),n.dispatch(d)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",o),yo.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(yo,-1))}function o(a){let l=yo.getState(n.state),c;if(l!=null)c=n.state.doc.resolve(l);else if(wO(n,a.target)!=t&&(c=Cv(n,e),!c))return i();c&&s(c,a)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",o)}function bO(n,e,t){if(!(n.state.selection instanceof Me))return null;let{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){let i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let a=r.before(s),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?a:null}}return null}function wO(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function Cv(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?xc(n.state.doc.resolve(t.pos)):null}const k9=new Ot("fix-tables");function vO(n,e,t,r){let s=n.childCount,i=e.childCount;e:for(let o=0,a=0;o<i;o++){let l=e.child(o);for(let c=a,u=Math.min(s,o+3);c<u;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<s&&n.child(a).sameMarkup(l)?vO(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function xO(n,e){let t,r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=C9(n,s,i,t))};return e?e.doc!=n.doc&&vO(e.doc,n.doc,0,r):n.doc.descendants(r),t}function C9(n,e,t,r){let s=Bt.get(e);if(!s.problems)return r;r||(r=n.tr);let i=[];for(let l=0;l<s.height;l++)i.push(0);for(let l=0;l<s.problems.length;l++){let c=s.problems[l];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let f=0;f<u.attrs.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Pa(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,an(u.attrs,"colwidth",c.colwidth))}}let o,a;for(let l=0;l<i.length;l++)i[l]&&(o==null&&(o=l),a=l);for(let l=0,c=t+1;l<s.height;l++){let u=e.child(l),f=c+u.nodeSize,d=i[l];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let y=0;y<d;y++)p.push(xn(n.schema)[h].createAndFill());let m=(l==0||o==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(m),p)}c=f}return r.setMeta(k9,{fixTables:!0})}function Us(n){let e=n.selection,t=$m(n),r=t.node(-1),s=t.start(-1),i=Bt.get(r),o;return e instanceof it?o=i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o=i.findCell(t.pos-s),o.tableStart=s,o.map=i,o.table=r,o}function AO(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;f9(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){let a=o*e.width+s;if(s>0&&s<e.width&&e.map[a-1]==e.map[a]){let l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,pO(c.attrs,s-e.colCount(l))),o+=c.attrs.rowspan-1}else{let l=i==null?xn(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function S9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(AO(n.tr,t,t.left))}return!0}function T9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(AO(n.tr,t,t.right))}return!0}function N9(n,{map:e,table:t,tableStart:r},s){let i=n.mapping.maps.length;for(let o=0;o<e.height;){let a=o*e.width+s,l=e.map[a],c=t.nodeAt(l);if(s>0&&e.map[a-1]==l||s<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(i).map(r+l),null,Pa(c.attrs,s-e.colCount(l)));else{let u=n.mapping.slice(i).map(r+l);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function O9(n,e){if(!rs(n))return!1;if(e){let t=Us(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;N9(r,t,s),s!=t.left;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Bt.get(t.table);e(r)}return!0}function R9(n,e,t){let r=xn(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(e.nodeAt(n.map[s+t*n.width]).type!=r)return!1;return!0}function EO(n,{map:e,tableStart:t,table:r},s){let i=t;for(let l=0;l<s;l++)i+=r.child(l).nodeSize;let o=[],a=s>0?-1:0;R9(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let l=0,c=e.width*s;l<e.width;l++,c++)if(s>0&&s<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,an(f,"rowspan",f.rowspan+1)),l+=f.colspan-1}else{let u=a==null?xn(r.type.schema).cell:r.nodeAt(e.map[c+a*e.width]).type;o.push(u.createAndFill())}return n.insert(i,xn(r.type.schema).row.create(null,o)),n}function M9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(EO(n.tr,t,t.top))}return!0}function D9(n,e){if(!rs(n))return!1;if(e){let t=Us(n);e(EO(n.tr,t,t.bottom))}return!0}function P9(n,{map:e,table:t,tableStart:r},s){let i=0;for(let l=0;l<s;l++)i+=t.child(l).nodeSize;let o=i+t.child(s).nodeSize,a=n.mapping.maps.length;n.delete(i+r,o+r);for(let l=0,c=s*e.width;l<e.width;l++,c++){let u=e.map[c];if(s>0&&u==e.map[c-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,an(f,"rowspan",f.rowspan-1)),l+=f.colspan-1}else if(s<e.width&&u==e.map[c+e.width]){let f=t.nodeAt(u),d=f.type.create(an(f.attrs,"rowspan",f.attrs.rowspan-1),f.content),h=e.positionAt(s+1,l,t);n.insert(n.mapping.slice(a).map(r+h),d),l+=f.attrs.colspan-1}}}function I9(n,e){if(!rs(n))return!1;if(e){let t=Us(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;P9(r,t,s),s!=t.top;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Bt.get(t.table);e(r)}return!0}function kO(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function L9({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,a=s+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[a]==t[a+1])return!0;i+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function CO(n,e){let t=n.selection;if(!(t instanceof it)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Us(n),{map:s}=r;if(L9(s,r))return!1;if(e){let i=n.tr,o={},a=oe.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){let d=s.map[u*s.width+f],h=r.table.nodeAt(d);if(!o[d])if(o[d]=!0,l==null)l=d,c=h;else{kO(h)||(a=a.append(h.content));let p=i.mapping.map(d+r.tableStart);i.delete(p,p+h.nodeSize)}}if(i.setNodeMarkup(l+r.tableStart,null,an(pO(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),a.size){let u=l+1+c.content.size,f=kO(c)?l+1:u;i.replaceWith(f+r.tableStart,u+r.tableStart,a)}i.setSelection(new it(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function SO(n,e){const t=xn(n.schema);return _9(({node:r})=>t[r.type.spec.tableRole])(n,e)}function _9(n){return(e,t)=>{let r=e.selection,s,i;if(r instanceof it){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{if(s=l9(r.$from),!s)return!1;i=xc(r.$from).pos}if(s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let o=s.attrs,a=[],l=o.colwidth;o.rowspan>1&&(o=an(o,"rowspan",1)),o.colspan>1&&(o=an(o,"colspan",1));let c=Us(e),u=e.tr;for(let d=0;d<c.right-c.left;d++)a.push(l?an(o,"colwidth",l&&l[d]?[l[d]]:null):o);let f;for(let d=c.top;d<c.bottom;d++){let h=c.map.positionAt(d,c.left,c.table);d==c.top&&(h+=s.nodeSize);for(let p=c.left,m=0;p<c.right;p++,m++)p==c.left&&d==c.top||u.insert(f=u.mapping.map(h+c.tableStart,1),n({node:s,row:d,col:p}).createAndFill(a[m]))}u.setNodeMarkup(i,n({node:s,row:c.top,col:c.left}),a[0]),r instanceof it&&u.setSelection(new it(u.doc.resolve(r.$anchorCell.pos),f&&u.doc.resolve(f))),t(u)}return!0}}function B9(n,e){return function(t,r){if(!rs(t))return!1;let s=$m(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof it?t.selection.forEachCell((o,a)=>{o.attrs[n]!==e&&i.setNodeMarkup(a,null,an(o.attrs,n,e))}):i.setNodeMarkup(s.pos,null,an(s.nodeAfter.attrs,n,e)),r(i)}return!0}}function F9(n){return function(e,t){if(!rs(e))return!1;if(t){let r=xn(e.schema),s=Us(e),i=e.tr,o=s.map.cellsInRect(n=="column"?new vc(s.left,0,s.right,s.map.height):n=="row"?new vc(0,s.top,s.map.width,s.bottom):s),a=o.map(l=>s.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[l],r.cell,a[l].attrs);if(i.steps.length==0)for(let l=0;l<o.length;l++)i.setNodeMarkup(s.tableStart+o[l],r.header_cell,a[l].attrs);t(i)}return!0}}function TO(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function dd(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?F9(n):function(t,r){if(!rs(t))return!1;if(r){let s=xn(t.schema),i=Us(t),o=t.tr,a=TO("row",i,s),l=TO("column",i,s),u=(n==="column"?a:n==="row"?l:!1)?1:0,f=n=="column"?new vc(0,u,1,i.map.height):n=="row"?new vc(u,0,i.map.width,1):i,d=n=="column"?l?s.cell:s.header_cell:n=="row"?a?s.cell:s.header_cell:s.cell;i.map.cellsInRect(f).forEach(h=>{const p=h+i.tableStart,m=o.doc.nodeAt(p);m&&o.setNodeMarkup(p,d,m.attrs)}),r(o)}return!0}}dd("row",{useDeprecatedLogic:!0}),dd("column",{useDeprecatedLogic:!0});let j9=dd("cell",{useDeprecatedLogic:!0});function U9(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){let i=n.node(-1).child(r);if(i.childCount)return s-1-i.lastChild.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}}function NO(n){return function(e,t){if(!rs(e))return!1;let r=U9($m(e),n);if(r!=null){if(t){let s=e.doc.resolve(r);t(e.tr.setSelection(Me.between(s,u9(s))).scrollIntoView())}return!0}}}function H9(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let z9=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Sv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Sv(n,e,t,r,s,i){let o=0,a=!0,l=e.firstChild,c=n.firstChild;for(let u=0,f=0;u<c.childCount;u++){let{colspan:d,colwidth:h}=c.child(u).attrs;for(let p=0;p<d;p++,f++){let m=s==f?i:h&&h[p],y=m?m+"px":"";o+=m||r,m||(a=!1),l?(l.style.width!=y&&(l.style.width=y),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;l;){let u=l.nextSibling;l.parentNode.removeChild(l),l=u}a?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const Lr=new Ot("tableColumnResizing");function V9({handleWidth:n=5,cellMinWidth:e=25,View:t=z9,lastColumnResizable:r=!0}={}){return new bt({key:Lr,state:{init(i,o){return this.spec.props.nodeViews[xn(o.schema).table.name]=(a,l)=>new t(a,e,l),new hd(-1,!1)},apply(i,o){return o.apply(i)}},props:{attributes(i){return Lr.getState(i).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(i,o){$9(i,o,n,e,r)},mouseleave(i){W9(i)},mousedown(i,o){G9(i,o,e)}},decorations(i){let o=Lr.getState(i);if(o.activeHandle>-1)return X9(i,o.activeHandle)},nodeViews:{}}})}class hd{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new hd(r.setHandle,null);if(r&&r.setDragging!==void 0)return new hd(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);xv(e.doc.resolve(s))||(s=null),t=new hd(s,t.dragging)}return t}}function $9(n,e,t,r,s){let i=Lr.getState(n.state);if(!i.dragging){let o=J9(e.target),a=-1;if(o){let{left:l,right:c}=o.getBoundingClientRect();e.clientX-l<=t?a=OO(n,e,"left"):c-e.clientX<=t&&(a=OO(n,e,"right"))}if(a!=i.activeHandle){if(!s&&a!==-1){let l=n.state.doc.resolve(a),c=l.node(-1),u=Bt.get(c),f=l.start(-1);if(u.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==u.width-1)return}MO(n,a)}}}function W9(n){let e=Lr.getState(n.state);e.activeHandle>-1&&!e.dragging&&MO(n,-1)}function G9(n,e,t){let r=Lr.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let s=n.state.doc.nodeAt(r.activeHandle),i=K9(n,r.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:i}}));function o(l){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",a);let c=Lr.getState(n.state);c.dragging&&(q9(n,c.activeHandle,RO(c.dragging,l,t)),n.dispatch(n.state.tr.setMeta(Lr,{setDragging:null})))}function a(l){if(!l.which)return o(l);let c=Lr.getState(n.state),u=RO(c.dragging,l,t);Q9(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",a),e.preventDefault(),!0}function K9(n,e,{colspan:t,colwidth:r}){let s=r&&r[r.length-1];if(s)return s;let i=n.domAtPos(e),a=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let c=0;c<t;c++)r[c]&&(a-=r[c],l--);return a/l}function J9(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function OO(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:s}=r,i=xc(n.state.doc.resolve(s));if(!i)return-1;if(t=="right")return i.pos;let o=Bt.get(i.node(-1)),a=i.start(-1),l=o.map.indexOf(i.pos-a);return l%o.width==0?-1:a+o.map[l-1]}function RO(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function MO(n,e){n.dispatch(n.state.tr.setMeta(Lr,{setHandle:e}))}function q9(n,e,t){let r=n.state.doc.resolve(e),s=r.node(-1),i=Bt.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+a;if(c&&i.map[u]==i.map[u-i.width])continue;let f=i.map[u],{attrs:d}=s.nodeAt(f),h=d.colspan==1?0:a-i.colCount(f);if(d.colwidth&&d.colwidth[h]==t)continue;let p=d.colwidth?d.colwidth.slice():Y9(d.colspan);p[h]=t,l.setNodeMarkup(o+f,null,an(d,"colwidth",p))}l.docChanged&&n.dispatch(l)}function Q9(n,e,t,r){let s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),a=Bt.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,l=n.domAtPos(s.start(-1)).node;for(;l.nodeName!="TABLE";)l=l.parentNode;Sv(i,l.firstChild,l,r,a,t)}function Y9(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function X9(n,e){let t=[],r=n.doc.resolve(e),s=r.node(-1),i=Bt.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let l=0;l<i.height;l++){let c=a+l*i.width-1;if((a==i.width||i.map[c]!=i.map[c+1])&&(l==0||i.map[c-1]!=i.map[c-1-i.width])){let u=i.map[c],f=o+u+s.nodeAt(u).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",t.push(Qt.widget(f,d))}}return wt.create(n.doc,t)}function Z9({allowTableNodeSelection:n=!1}={}){return new bt({key:yo,state:{init(){return null},apply(e,t){let r=e.getMeta(yo);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:d9,handleDOMEvents:{mousedown:E9},createSelectionBetween(e){if(yo.getState(e.state)!=null)return e.state.selection},handleTripleClick:x9,handleKeyDown:v9,handlePaste:A9},appendTransaction(e,t,r){return m9(r,xO(r,t),n)}})}function DO(n,e,t,r,s,i){var u;let o=0,a=!0,l=e.firstChild;const c=n.firstChild;if(c)for(let f=0,d=0;f<c.childCount;f+=1){const{colspan:h,colwidth:p}=c.child(f).attrs;for(let m=0;m<h;m+=1,d+=1){const y=s===d?i:p&&p[m],b=y?`${y}px`:"";o+=y||r,y||(a=!1),l?(l.style.width!==b&&(l.style.width=b),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=b}}for(;l;){const f=l.nextSibling;(u=l==null?void 0:l.parentNode)==null||u.removeChild(l),l=f}a?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class eW{constructor(e,t){$(this,"node");$(this,"cellMinWidth");$(this,"dom");$(this,"table");$(this,"colgroup");$(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),DO(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,DO(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function PO(n,e){return n.createAndFill()}function tW(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function nW(n,e,t,r,s){const i=tW(n),o=[],a=[];for(let c=0;c<t;c+=1){const u=PO(i.cell);if(u&&a.push(u),r){const f=PO(i.header_cell);f&&o.push(f)}}const l=[];for(let c=0;c<e;c+=1)l.push(i.row.createChecked(null,r&&c===0?o:a));return i.table.createChecked(null,l)}function rW(n){return n instanceof it}const qm=({editor:n})=>{const{selection:e}=n.state;if(!rW(e))return!1;let t=0;const r=a0(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},sW=vt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:eW,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(i=>{if(i.attrs.colwidth)i.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=i.attrs.colspan?i.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",tt(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const{selection:o}=r,a=nW(i.schema,n,e,t);if(s){const l=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,a).scrollIntoView().setSelection(Me.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>S9(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>T9(n,e),deleteColumn:()=>({state:n,dispatch:e})=>O9(n,e),addRowBefore:()=>({state:n,dispatch:e})=>M9(n,e),addRowAfter:()=>({state:n,dispatch:e})=>D9(n,e),deleteRow:()=>({state:n,dispatch:e})=>I9(n,e),deleteTable:()=>({state:n,dispatch:e})=>H9(n,e),mergeCells:()=>({state:n,dispatch:e})=>CO(n,e),splitCell:()=>({state:n,dispatch:e})=>SO(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dd("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dd("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>j9(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>CO(n,e)?!0:SO(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>B9(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>NO(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>NO(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&xO(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=it.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:qm,"Mod-Backspace":qm,Delete:qm,"Mod-Delete":qm}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[V9({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Z9({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:Qe(xe(n,"tableRole",e))}}});function IO(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,i;for(i=0;i<r.length;i++)s=r[i],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}var LO=typeof window<"u"&&typeof document<"u";function Tv(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function _O(){return LO&&document.createElement("div")}function iW(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function BO(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!BO(n[t],e[t]))return!1}else return!1;return!0}else return!1}function oW(n){var e=[];return n.forEach(function(t){e.find(function(r){return BO(t,r)})||e.push(t)}),e}function aW(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:oW([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Nv=LO?L.useLayoutEffect:L.useEffect;function lW(n){var e=L.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function FO(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var cW={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var a;return!!((a=e.props.render)!=null&&a.$$tippy)};function s(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}FO(t,"add",e.props.className)}function i(){r()&&FO(t,"remove",e.props.className)}return{onCreate:s,onBeforeUpdate:i,onAfterUpdate:s}}};function uW(n){function e(t){var r=t.children,s=t.content,i=t.visible,o=t.singleton,a=t.render,l=t.reference,c=t.disabled,u=c===void 0?!1:c,f=t.ignoreAttributes,d=f===void 0?!0:f;t.__source,t.__self;var h=IO(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=i!==void 0,m=o!==void 0,y=L.useState(!1),b=y[0],x=y[1],v=L.useState({}),w=v[0],E=v[1],k=L.useState(),S=k[0],M=k[1],O=lW(function(){return{container:_O(),renders:1}}),R=Object.assign({ignoreAttributes:d},h,{content:O.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(K){R[K]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+K+"` prop in","controlled mode (`visible` prop)"].join(" "))}),R.trigger="manual",R.hideOnClick=!1),m&&(u=!0);var D=R,F=R.plugins||[];a&&(D=Object.assign({},R,{plugins:m&&o.data!=null?[].concat(F,[{fn:function(){return{onTrigger:function(G,Y){var re=o.data.children.find(function(Z){var me=Z.instance;return me.reference===Y.currentTarget});G.state.$$activeSingletonInstance=re.instance,M(re.content)}}}}]):F,render:function(){return{popper:O.container}}}));var U=[l].concat(r?[r.type]:[]);return Nv(function(){var K=l;l&&l.hasOwnProperty("current")&&(K=l.current);var _=n(K||O.ref||_O(),Object.assign({},D,{plugins:[cW].concat(R.plugins||[])}));return O.instance=_,u&&_.disable(),i&&_.show(),m&&o.hook({instance:_,content:s,props:D,setSingletonContent:M}),x(!0),function(){_.destroy(),o==null||o.cleanup(_)}},U),Nv(function(){var K;if(O.renders===1){O.renders++;return}var _=O.instance;_.setProps(aW(_.props,D)),(K=_.popperInstance)==null||K.forceUpdate(),u?_.disable():_.enable(),p&&(i?_.show():_.hide()),m&&o.hook({instance:_,content:s,props:D,setSingletonContent:M})}),Nv(function(){var K;if(a){var _=O.instance;_.setProps({popperOptions:Object.assign({},_.props.popperOptions,{modifiers:[].concat((((K=_.props.popperOptions)==null?void 0:K.modifiers)||[]).filter(function(G){var Y=G.name;return Y!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Y){var re,Z=Y.state,me=(re=Z.modifiersData)==null?void 0:re.hide;(w.placement!==Z.placement||w.referenceHidden!==(me==null?void 0:me.isReferenceHidden)||w.escaped!==(me==null?void 0:me.hasPopperEscaped))&&E({placement:Z.placement,referenceHidden:me==null?void 0:me.isReferenceHidden,escaped:me==null?void 0:me.hasPopperEscaped}),Z.attributes.popper={}}}])})})}},[w.placement,w.referenceHidden,w.escaped].concat(U)),L.createElement(L.Fragment,null,r?L.cloneElement(r,{ref:function(_){O.ref=_,Tv(r.ref,_)}}):null,b&&Et.createPortal(a?a(iW(w),S,O.instance):s,O.container))}return e}var fW=function(n,e){return L.forwardRef(function(r,s){var i=r.children,o=IO(r,["children"]);return L.createElement(n,Object.assign({},e,o),i?L.cloneElement(i,{ref:function(l){Tv(s,l),Tv(i.ref,l)}}):null)})},dW=fW(uW(fa));const hW=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:C.jsx("svg",{viewBox:"0 0 24 24",children:C.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],jO=({node:n,getPos:e,selected:t,editor:r})=>{const[s,i]=L.useState(!1),o=gp(),a=L.useRef(null),l=()=>{const{from:u,to:f}=r.state.selection,d=e(),h=d+n.nodeSize;i(d<=u&&f<=h)};L.useEffect(()=>(r.on("selectionUpdate",l),setTimeout(l,100),()=>{r.off("selectionUpdate",l)}));const c=()=>{var d,h;let u=(d=a.current)==null?void 0:d.clientTop;u&&(u+=5);let f=(h=a.current)==null?void 0:h.clientLeft;return f&&(f+=5),{top:`${u}px`,left:`${f}px`}};return C.jsxs(wf,{className:"group",children:[C.jsx(Ik,{as:"span"}),(s||t)&&C.jsx(dW,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:C.jsx("article",{className:"dropdown",contentEditable:!1,children:C.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:hW.map(u=>C.jsx("li",{children:C.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[C.jsx("span",{children:u.icon}),C.jsx("span",{children:u.name})]})},u.name))})}),children:C.jsx("label",{tabIndex:0,className:pe("trigger-button",{hidden:o}),contentEditable:!1,children:C.jsx(X3,{fontSize:"small"})})})]})},pW=vt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return da(jO,{as:"td",className:"relative"})}}),mW=vt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return da(jO,{as:"th",className:"relative"})}}),UO=n=>(n.stopPropagation(),n.preventDefault(),n),gW=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},HO=function(n){return!n||n===document.body?document.body:gW(n)?n:HO(n.parentNode)},Ov=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([s,i])=>r.setAttribute(s,i)),t&&Object.entries(t).forEach(([s,i])=>r.addEventListener(s,i)),r},yW=vt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",tt(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),s=HO(n.options.element);let i=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const b=r(),x=n.state.doc.resolve(b),v=new Ne(x);n.view.dispatch(n.state.tr.setSelection(v))}},a=()=>{i=!0},l=()=>{i=!1},c=Ov("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:b=>{b&&UO(b),o.selectRow()},mouseenter:()=>{a()},mouseover:()=>{a()},mouseleave:()=>{l(),d()}}),u=Ov("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:b=>{b&&UO(b),o.deleteRow()}}),f=()=>{m(),c.classList.remove("hidden")},d=()=>{setTimeout(()=>{i||c.classList.add("hidden")},100)},h=Ov("tr",{...e},{mouseenter:f,mouseover:f,mouseleave:d});c.append(u),document.body.append(c);let p="";const m=()=>{setTimeout(()=>{const b=h.getBoundingClientRect(),x=JSON.stringify(b);p!==x&&(c.style.top=`${b.top+document.documentElement.scrollTop}px`,c.style.left=`${b.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${b.height+1}px`,p=x)})};return setTimeout(()=>{m()},100),n.on("selectionUpdate",m),n.on("update",m),s==null||s.addEventListener("scroll",m),document.addEventListener("scroll",m),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",m),n.off("update",m),s==null||s.removeEventListener("scroll",m),document.removeEventListener("scroll",m)}}}}}),bW=[sW.configure({resizable:!0}),pW,mW,yW],wW=Y2.extend({content:"(dBlock|columns)+"});function zO({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const vW=St.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new Ot(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new bt({key:n,appendTransaction:(t,r,s)=>{const{doc:i,tr:o,schema:a}=s,l=n.getState(s),c=i.content.size,u=a.nodes[this.options.node];if(l)return o.insert(c,u.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!zO({node:s,types:e})},apply:(t,r)=>{var i,o,a;if(!t.docChanged)return r;const s=(a=(o=(i=t.doc.lastChild)==null?void 0:i.content)==null?void 0:o.content)==null?void 0:a[0];return!zO({node:s,types:e})}}})]}}),xW=({node:n,editor:e,getPos:t})=>{const[r,s]=L.useState(""),i=gp(),o=["https://twitter.com","https://x.com"],a=()=>{switch(n.attrs.data){case"twitter":return C.jsx(Gk,{});case"iframe":return C.jsx(Kk,{});default:return C.jsx(a4,{})}},l=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const v=r.match(/src="([^"]*)"/);v&&v.length>0&&(p=v[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://www.youtube.com/embed/${v[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://player.vimeo.com/video/${v[1]}`);break}default:{alert("Please enter a valid url");return}}const m=640,y=360,b=t(),x=b+n.nodeSize;p&&(e==null||e.chain().focus(b).deleteRange({from:b,to:x}).setIframe({src:p,width:m,height:y}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const m=o.some(w=>r.includes(w)),y=r.match(/\/status\/([0-9]*)/),b=y&&y.length>0;if(m&&b)p=y[1];else{alert("invalid url");return}const x=t(),v=x+n.nodeSize;p&&(e==null||e.chain().focus(x).deleteRange({from:x,to:v}).setTweetEmbed({tweetId:p}).run())},d=iv(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);L.useEffect(()=>{r&&d()},[r]),L.useEffect(()=>{e==null||e.chain().focus()},[]);const h=L.useRef(null);return L.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),C.jsx(wf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!i&&C.jsxs("div",{className:"relative w-full",children:[C.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:a()}),C.jsx("input",{ref:h,value:r,placeholder:l(),onChange:p=>s(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},AW=vt.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return da(xW)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return["div",tt(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),EW=[Pz,Mz.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-[#E8EBEC] p-5 font-serif italic text-black"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-black"},exitOnArrowDown:!0},code:{HTMLAttributes:{class:"rounded bg-transparent p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),Iz.configure({types:["heading","paragraph"]}),xV,rV.extend({exitable:!0}).configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),sV.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),aV.configure({multicolor:!0}),vV,fV.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),Dz,kV,lV.configure({HTMLAttributes:{class:"not-prose space-y-4 !ml-0"}}),uV.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),X2.configure({width:3,color:"#d1d5db"}),Z2,r9,vW,wW,...bW,PV.configure({uploadFn:m4}),EV,CV,OV,AW.extend({addInputRules(){return[VO(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),VO(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),AV],VO=(n,e,t)=>new of({find:n,handler:({state:r,range:s,commands:i})=>{const o={data:e},{tr:a}=r,l=s.from,c=s.to;a.insert(l-1,t.create(o)).delete(a.mapping.map(l),a.mapping.map(c)),i.focus(c-1)}}),kW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAYAAAD0f5bSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAE/SURBVHgBhVJBTsJQEH3zMcElR+gRuIF6gwYPAOwkLoQTUE6ArEA3xbWJ4gnQE8gNwBuwhMR2fPNLk9o0ZZImM/P/e39e3wgqojPXXiPFJnFovw1kWT53xSKca3C70LXlr/eySYFdZ6Fb61eCePnBCb6VF3P21UA+WX+wv+086fgfyMbh4aPlqWJSZH2/k6EINlBEJI6tdxHG2tIDrsUqxYzsO5Qi+UXfNfwUPT7w49wRU1EyZWNFqIgV9REw84Wga+P1Uj7PsW5QE9pEZMT8Aq+JQmNcYl8HwgEtEvf9fc3RR4zrMCRe84WA6dJRz8upPwyftV0FOP3ugHqu0iZGzsSbF3bYUMRlgDdWMcyE4WvVl73XRC9CNiaqaHMDpkUQrYh8kmKUmy5lVpvdBNs2mOk0tptk9a5AVKHhzML+AZaSjR/r++n9AAAAAElFTkSuQmCC",CW="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEjSURBVHgBjZJBToNQEIb/NzTeoMbGjTeoN5Au1S7wBrqwyk5OoD1B46pRF9UbsEBc9nmEHsI08QhGZnxMpaGUEv4EwoP/mxnyj0GNTp++AoPORA+Gx+mo91r1mOJh+LL0WYwDqC8i/obJGCuSfRJ1bHLdtWtQIaY5WoiYBknYtZQfmOGjpTIvC7TAahTvpMksmUQCvK0A6itzNl1egmi2k2K+2gPsD+mvHGkh4MIVoPuSLYbIYxOk3YAJVRuktwd3DhjvggqRB0Slc3D+/D1Lw95DE5Rnq3E487ySXeyu4zooz/R9tD/QUYV5Ufke1HbKvW4RdFS9icRoKeKO1c7Fi+HUbQ/BzzPdXjmxDCy8TOIk7G2CZf1nqzEJfqOPm8Otif4AFnp3K1F5HHAAAAAASUVORK5CYII=",SW=n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},TW=n=>{const e=document.createElement("span");e.classList.add("custom-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.classList.add("custom-cursor__label-container"),t.setAttribute("style",`border: 1px solid ${n.color}`);const r=document.createElement("img");r.src=kW,r.classList.add("custom-cursor__icon");const s=document.createElement("div");s.classList.add("custom-cursor__label");const i=document.createElement("span");i.classList.add("custom-cursor__text"),i.textContent=n.name;const o=document.createElement("img");return o.src=CW,o.classList.add("custom-cursor__badge"),s.appendChild(i),t.appendChild(r),t.appendChild(s),t.appendChild(o),e.appendChild(t),e},NW=n=>n.isEns?TW(n):SW(n),OW="6.13.1";function RW(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function An(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function Oe(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&RW(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function Ac(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ac).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Ac(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Ac(t)}: ${Ac(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function ln(n,e){return n&&n.code===e}function Rv(n){return ln(n,"CALL_EXCEPTION")}function Nt(n,e,t){let r=n;{const i=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ac(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];i.push(o+"="+Ac(a))}}i.push(`code=${e}`),i.push(`version=${OW}`),i.length&&(n+=" ("+i.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(n);break;default:s=new Error(n)}return Oe(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&Oe(s,{shortMessage:r}),s}function ee(n,e,t,r){if(!n)throw Nt(e,t,r)}function V(n,e,t,r){ee(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function $O(n,e,t){t==null&&(t=""),t&&(t=": "+t),ee(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),ee(n<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(e)}catch{}return n},[]);function Qm(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),ee(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function WO(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}V(!1,"invalid BytesLike value",e||"value",n)}function lt(n,e){return WO(n,e,!1)}function Pn(n,e){return WO(n,e,!0)}function At(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}function Mv(n){return At(n,!0)||n instanceof Uint8Array}const GO="0123456789abcdef";function we(n){const e=lt(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=GO[(s&240)>>4]+GO[s&15]}return t}function Ut(n){return"0x"+n.map(e=>we(e).substring(2)).join("")}function Ec(n){return At(n,!0)?(n.length-2)/2:lt(n).length}function Ft(n,e,t){const r=lt(n);return t!=null&&t>r.length&&ee(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),we(r.slice(e??0,t??r.length))}function KO(n,e,t){const r=lt(n);ee(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),we(s)}function Ia(n,e){return KO(n,e,!0)}function MW(n,e){return KO(n,e,!1)}const Ym=BigInt(0),ss=BigInt(1),kc=9007199254740991;function DW(n,e){const t=Xm(n,"value"),r=BigInt(Je(e,"width"));if(ee(t>>r===Ym,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-ss){const s=(ss<<r)-ss;return-((~t&s)+ss)}return t}function JO(n,e){let t=Ae(n,"value");const r=BigInt(Je(e,"width")),s=ss<<r-ss;if(t<Ym){t=-t,ee(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(ss<<r)-ss;return(~t&i)+ss}else ee(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function pd(n,e){const t=Xm(n,"value"),r=BigInt(Je(e,"bits"));return t&(ss<<r)-ss}function Ae(n,e){switch(typeof n){case"bigint":return n;case"number":return V(Number.isInteger(n),"underflow",e||"value",n),V(n>=-kc&&n<=kc,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){V(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}V(!1,"invalid BigNumberish value",e||"value",n)}function Xm(n,e){const t=Ae(n,e);return ee(t>=Ym,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const qO="0123456789abcdef";function Dv(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=qO[t>>4],e+=qO[t&15];return BigInt(e)}return Ae(n)}function Je(n,e){switch(typeof n){case"bigint":return V(n>=-kc&&n<=kc,"overflow",e||"value",n),Number(n);case"number":return V(Number.isInteger(n),"underflow",e||"value",n),V(n>=-kc&&n<=kc,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return Je(BigInt(n),e)}catch(t){V(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}V(!1,"invalid numeric value",e||"value",n)}function PW(n){return Je(Dv(n))}function bo(n,e){let r=Xm(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=Je(e,"width");for(ee(s*2>=r.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function In(n){const e=Xm(n,"value");if(e===Ym)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}function La(n){let e=we(Mv(n)?n:In(n)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const QO="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const YO=BigInt(58);function IW(n){const e=lt(n);let t=Dv(e),r="";for(;t;)r=QO[Number(t%YO)]+r,t/=YO;for(let s=0;s<e.length&&!e[s];s++)r=QO[0]+r;return r}function LW(n){n=atob(n);const e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return lt(e)}function _W(n){const e=lt(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}class XO{constructor(e,t,r){$(this,"filter");$(this,"emitter");q(this,$c);I(this,$c,t),Oe(this,{emitter:e,filter:r})}async removeListener(){T(this,$c)!=null&&await this.emitter.off(this.filter,T(this,$c))}}$c=new WeakMap;function BW(n,e,t,r,s){V(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function ZO(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function FW(n,e,t,r,s){return n==="OVERLONG"?(V(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),ZO(n,e,t))}const jW=Object.freeze({error:BW,ignore:ZO,replace:FW});function UW(n,e){e==null&&(e=jW.error);const t=lt(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let l=i&(1<<8-o-1)-1;for(let c=0;c<o;c++){let u=t[s];if((u&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),l=null;break}l=l<<6|u&63,s++}if(l!==null){if(l>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,l);continue}if(l>=55296&&l<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,l);continue}if(l<=a){s+=e("OVERLONG",s-1-o,t,r,l);continue}r.push(l)}}return r}function bi(n,e){V(typeof n=="string","invalid string value","str",n);let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);V(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function HW(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Cc(n,e){return HW(UW(n,e))}function eR(n){async function e(t,r){ee(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();ee(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),ee(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const o=new AbortController,a=setTimeout(()=>{i=Nt("request timeout","TIMEOUT"),o.abort()},t.timeout);r&&r.addListener(()=>{i=Nt("request cancelled","CANCELLED"),o.abort()});const l={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let c;try{c=await fetch(t.url,l)}catch(h){throw clearTimeout(a),i||h}clearTimeout(a);const u={};c.headers.forEach((h,p)=>{u[p.toLowerCase()]=h});const f=await c.arrayBuffer(),d=f==null?null:new Uint8Array(f);return{statusCode:c.status,statusMessage:c.statusText,headers:u,body:d}}return e}const zW=12,VW=250;let tR=eR();const $W=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),WW=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Pv=!1;async function nR(n,e){try{const t=n.match($W);if(!t)throw new Error("invalid data");return new wo(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?LW(t[3]):KW(t[3]))}catch{return new wo(599,"BAD REQUEST (invalid data: URI)",{},null,new Ln(n))}}function rR(n){async function e(t,r){try{const s=t.match(WW);if(!s)throw new Error("invalid link");return new Ln(`${n}${s[2]}`)}catch{return new wo(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Ln(t))}}return e}const Zm={data:nR,ipfs:rR("https://gateway.ipfs.io/ipfs/")},sR=new WeakMap;class GW{constructor(e){q(this,qa);q(this,To);I(this,qa,[]),I(this,To,!1),sR.set(e,()=>{if(!T(this,To)){I(this,To,!0);for(const t of T(this,qa))setTimeout(()=>{t()},0);I(this,qa,[])}})}addListener(e){ee(!T(this,To),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),T(this,qa).push(e)}get cancelled(){return T(this,To)}checkSignal(){ee(!this.cancelled,"cancelled","CANCELLED",{})}}qa=new WeakMap,To=new WeakMap;function eg(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}const $g=class $g{constructor(e){q(this,Za);q(this,Wc);q(this,Gc);q(this,us);q(this,Ti);q(this,Kc);q(this,Jc);q(this,fn);q(this,wr);q(this,Ni);q(this,Qa);q(this,Ya);q(this,Xa);q(this,$s);q(this,fs);q(this,No);I(this,Jc,String(e)),I(this,Wc,!1),I(this,Gc,!0),I(this,us,{}),I(this,Ti,""),I(this,Kc,3e5),I(this,fs,{slotInterval:VW,maxAttempts:zW}),I(this,No,null)}get url(){return T(this,Jc)}set url(e){I(this,Jc,String(e))}get body(){return T(this,fn)==null?null:new Uint8Array(T(this,fn))}set body(e){if(e==null)I(this,fn,void 0),I(this,wr,void 0);else if(typeof e=="string")I(this,fn,bi(e)),I(this,wr,"text/plain");else if(e instanceof Uint8Array)I(this,fn,e),I(this,wr,"application/octet-stream");else if(typeof e=="object")I(this,fn,bi(JSON.stringify(e))),I(this,wr,"application/json");else throw new Error("invalid body")}hasBody(){return T(this,fn)!=null}get method(){return T(this,Ti)?T(this,Ti):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),I(this,Ti,String(e).toUpperCase())}get headers(){const e=Object.assign({},T(this,us));return T(this,Ni)&&(e.authorization=`Basic ${_W(bi(T(this,Ni)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&T(this,wr)&&(e["content-type"]=T(this,wr)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){T(this,us)[String(e).toLowerCase()]=String(t)}clearHeaders(){I(this,us,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return T(this,Ni)||null}setCredentials(e,t){V(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),I(this,Ni,`${e}:${t}`)}get allowGzip(){return T(this,Gc)}set allowGzip(e){I(this,Gc,!!e)}get allowInsecureAuthentication(){return!!T(this,Wc)}set allowInsecureAuthentication(e){I(this,Wc,!!e)}get timeout(){return T(this,Kc)}set timeout(e){V(e>=0,"timeout must be non-zero","timeout",e),I(this,Kc,e)}get preflightFunc(){return T(this,Qa)||null}set preflightFunc(e){I(this,Qa,e)}get processFunc(){return T(this,Ya)||null}set processFunc(e){I(this,Ya,e)}get retryFunc(){return T(this,Xa)||null}set retryFunc(e){I(this,Xa,e)}get getUrlFunc(){return T(this,No)||tR}set getUrlFunc(e){I(this,No,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${T(this,fn)?we(T(this,fn)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(T(this,fs).slotInterval=e.slotInterval),e.maxAttempts!=null&&(T(this,fs).maxAttempts=e.maxAttempts)}send(){return ee(T(this,$s)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),I(this,$s,new GW(this)),fe(this,Za,eh).call(this,0,iR()+this.timeout,0,this,new wo(0,"",{},null,this))}cancel(){ee(T(this,$s)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=sR.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();ee(this.method==="GET"&&(t!=="https"||r!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new $g(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,I(s,us,Object.assign({},T(this,us))),T(this,fn)&&I(s,fn,new Uint8Array(T(this,fn))),I(s,wr,T(this,wr)),s}clone(){const e=new $g(this.url);return I(e,Ti,T(this,Ti)),T(this,fn)&&I(e,fn,T(this,fn)),I(e,wr,T(this,wr)),I(e,us,Object.assign({},T(this,us))),I(e,Ni,T(this,Ni)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),I(e,Qa,T(this,Qa)),I(e,Ya,T(this,Ya)),I(e,Xa,T(this,Xa)),I(e,fs,Object.assign({},T(this,fs))),I(e,No,T(this,No)),e}static lockConfig(){Pv=!0}static getGateway(e){return Zm[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Pv)throw new Error("gateways locked");Zm[e]=t}static registerGetUrl(e){if(Pv)throw new Error("gateways locked");tR=e}static createGetUrlFunc(e){return eR()}static createDataGateway(){return nR}static createIpfsGatewayFunc(e){return rR(e)}};Wc=new WeakMap,Gc=new WeakMap,us=new WeakMap,Ti=new WeakMap,Kc=new WeakMap,Jc=new WeakMap,fn=new WeakMap,wr=new WeakMap,Ni=new WeakMap,Qa=new WeakMap,Ya=new WeakMap,Xa=new WeakMap,$s=new WeakMap,fs=new WeakMap,No=new WeakMap,Za=new WeakSet,eh=async function(e,t,r,s,i){var u,f,d;if(e>=T(this,fs).maxAttempts)return i.makeServerError("exceeded maximum retry limit");ee(iR()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),r>0&&await JW(r);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Zm){const h=await Zm[a](o.url,eg(T(s,$s)));if(h instanceof wo){let p=h;if(this.processFunc){eg(T(s,$s));try{p=await this.processFunc(o,p)}catch(m){(m.throttle==null||typeof m.stall!="number")&&p.makeServerError("error in post-processing function",m).assertOk()}}return p}o=h}this.preflightFunc&&(o=await this.preflightFunc(o));const l=await this.getUrlFunc(o,eg(T(s,$s)));let c=new wo(l.statusCode,l.statusMessage,l.headers,l.body,s);if(c.statusCode===301||c.statusCode===302){try{const h=c.headers.location||"";return fe(u=o.redirect(h),Za,eh).call(u,e+1,t,0,s,c)}catch{}return c}else if(c.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,c,e))){const h=c.headers["retry-after"];let p=T(this,fs).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof h=="string"&&h.match(/^[1-9][0-9]*$/)&&(p=parseInt(h)),fe(f=o.clone(),Za,eh).call(f,e+1,t,p,s,c)}if(this.processFunc){eg(T(s,$s));try{c=await this.processFunc(o,c)}catch(h){(h.throttle==null||typeof h.stall!="number")&&c.makeServerError("error in post-processing function",h).assertOk();let p=T(this,fs).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return h.stall>=0&&(p=h.stall),fe(d=o.clone(),Za,eh).call(d,e+1,t,p,s,c)}}return c};let Ln=$g;const G1=class G1{constructor(e,t,r,s,i){q(this,Fd);q(this,jd);q(this,Ud);q(this,vr);q(this,qc);q(this,el);I(this,Fd,e),I(this,jd,t),I(this,Ud,Object.keys(r).reduce((o,a)=>(o[a.toLowerCase()]=String(r[a]),o),{})),I(this,vr,s==null?null:new Uint8Array(s)),I(this,qc,i||null),I(this,el,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${T(this,vr)?we(T(this,vr)):"null"}>`}get statusCode(){return T(this,Fd)}get statusMessage(){return T(this,jd)}get headers(){return Object.assign({},T(this,Ud))}get body(){return T(this,vr)==null?null:new Uint8Array(T(this,vr))}get bodyText(){try{return T(this,vr)==null?"":Cc(T(this,vr))}catch{ee(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{ee(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let r;e?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new G1(599,r,this.headers,this.body,T(this,qc)||void 0);return I(s,el,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:V(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const r=new Error(e||"throttling requests");throw Oe(r,{stall:t,throttle:!0}),r}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return T(this,vr)!=null}get request(){return T(this,qc)}ok(){return T(this,el).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=T(this,el);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let s=null;try{T(this,vr)&&(s=Cc(T(this,vr)))}catch{}ee(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:r,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};Fd=new WeakMap,jd=new WeakMap,Ud=new WeakMap,vr=new WeakMap,qc=new WeakMap,el=new WeakMap;let wo=G1;function iR(){return new Date().getTime()}function KW(n){return bi(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function JW(n){return new Promise(e=>setTimeout(e,n))}function qW(n){let e=n.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function oR(n,e,t){let r=0;for(let s=0;s<t;s++)r=r*256+n[e+s];return r}function aR(n,e,t,r){const s=[];for(;t<e+1+r;){const i=lR(n,t);s.push(i.result),t+=i.consumed,ee(t<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:e})}return{consumed:1+r,result:s}}function lR(n,e){ee(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const t=r=>{ee(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[e]>=248){const r=n[e]-247;t(e+1+r);const s=oR(n,e+1,r);return t(e+1+r+s),aR(n,e,e+1+r,r+s)}else if(n[e]>=192){const r=n[e]-192;return t(e+1+r),aR(n,e,e+1,r)}else if(n[e]>=184){const r=n[e]-183;t(e+1+r);const s=oR(n,e+1,r);t(e+1+r+s);const i=we(n.slice(e+1+r,e+1+r+s));return{consumed:1+r+s,result:i}}else if(n[e]>=128){const r=n[e]-128;t(e+1+r);const s=we(n.slice(e+1,e+1+r));return{consumed:1+r,result:s}}return{consumed:1,result:qW(n[e])}}function tg(n){const e=lt(n,"data"),t=lR(e,0);return V(t.consumed===e.length,"unexpected junk after rlp payload","data",n),t.result}function cR(n){const e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function uR(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(i){r=r.concat(uR(i))}),r.length<=55)return r.unshift(192+r.length),r;const s=cR(r.length);return s.unshift(247+s.length),s.concat(r)}const e=Array.prototype.slice.call(lt(n,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=cR(e.length);return t.unshift(183+t.length),t.concat(e)}const fR="0123456789abcdef";function _a(n){let e="0x";for(const t of uR(n))e+=fR[t>>4],e+=fR[t&15];return e}const _n=32,Iv=new Uint8Array(_n),QW=["then"],ng={},dR=new WeakMap;function Ba(n){return dR.get(n)}function hR(n,e){dR.set(n,e)}function md(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}function Lv(n,e,t){return n.indexOf(null)>=0?e.map((r,s)=>r instanceof Sc?Lv(Ba(r),r,t):r):n.reduce((r,s,i)=>{let o=e.getValue(s);return s in r||(t&&o instanceof Sc&&(o=Lv(Ba(o),o,t)),r[s]=o),r},{})}const Yc=class Yc extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==ng&&(s=t,i=[],o=!1);super(s.length);q(this,Qc);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(hR(this,Object.freeze(s.map((c,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null}))),I(this,Qc,[]),T(this,Qc)==null&&T(this,Qc),!o)return;Object.freeze(this);const l=new Proxy(this,{get:(c,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const h=Je(u,"%index");if(h<0||h>=this.length)throw new RangeError("out of result range");const p=c[h];return p instanceof Error&&md(`index ${h}`,p),p}if(QW.indexOf(u)>=0)return Reflect.get(c,u,f);const d=c[u];if(d instanceof Function)return function(...h){return d.apply(this===f?c:this,h)};if(!(u in c))return c.getValue.apply(this===f?c:this,[u])}return Reflect.get(c,u,f)}});return hR(l,Ba(this)),l}toArray(t){const r=[];return this.forEach((s,i)=>{s instanceof Error&&md(`index ${i}`,s),t&&s instanceof Yc&&(s=s.toArray(t)),r.push(s)}),r}toObject(t){const r=Ba(this);return r.reduce((s,i,o)=>(ee(i!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Lv(r,this,t)),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=Ba(this),i=[],o=[];for(let a=t;a<r;a++)i.push(this[a]),o.push(s[a]);return new Yc(ng,i,o)}filter(t,r){const s=Ba(this),i=[],o=[];for(let a=0;a<this.length;a++){const l=this[a];l instanceof Error&&md(`index ${a}`,l),t.call(r,l,a,this)&&(i.push(l),o.push(s[a]))}return new Yc(ng,i,o)}map(t,r){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&md(`index ${i}`,o),s.push(t.call(r,o,i,this))}return s}getValue(t){const r=Ba(this).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&md(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new Yc(ng,t,r)}};Qc=new WeakMap;let Sc=Yc;function pR(n){let e=In(n);return ee(e.length<=_n,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:_n,offset:e.length}),e.length!==_n&&(e=Pn(Ut([Iv.slice(e.length%_n),e]))),e}class wi{constructor(e,t,r,s){$(this,"name");$(this,"type");$(this,"localName");$(this,"dynamic");Oe(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){V(!1,e,this.localName,t)}}class _v{constructor(){q(this,Xc);q(this,Oi);q(this,tl);I(this,Oi,[]),I(this,tl,0)}get data(){return Ut(T(this,Oi))}get length(){return T(this,tl)}appendWriter(e){return fe(this,Xc,Yg).call(this,Pn(e.data))}writeBytes(e){let t=Pn(e);const r=t.length%_n;return r&&(t=Pn(Ut([t,Iv.slice(r)]))),fe(this,Xc,Yg).call(this,t)}writeValue(e){return fe(this,Xc,Yg).call(this,pR(e))}writeUpdatableValue(){const e=T(this,Oi).length;return T(this,Oi).push(Iv),I(this,tl,T(this,tl)+_n),t=>{T(this,Oi)[e]=pR(t)}}}Oi=new WeakMap,tl=new WeakMap,Xc=new WeakSet,Yg=function(e){return T(this,Oi).push(e),I(this,tl,T(this,tl)+e.length),e.length};const K1=class K1{constructor(e,t,r){q(this,sl);$(this,"allowLoose");q(this,er);q(this,xr);q(this,nl);q(this,rl);q(this,Oo);Oe(this,{allowLoose:!!t}),I(this,er,Pn(e)),I(this,nl,0),I(this,rl,null),I(this,Oo,r??1024),I(this,xr,0)}get data(){return we(T(this,er))}get dataLength(){return T(this,er).length}get consumed(){return T(this,xr)}get bytes(){return new Uint8Array(T(this,er))}subReader(e){const t=new K1(T(this,er).slice(T(this,xr)+e),this.allowLoose,T(this,Oo));return I(t,rl,this),t}readBytes(e,t){let r=fe(this,sl,eP).call(this,0,e,!!t);return fe(this,sl,nx).call(this,e),I(this,xr,T(this,xr)+r.length),r.slice(0,e)}readValue(){return Dv(this.readBytes(_n))}readIndex(){return PW(this.readBytes(_n))}};er=new WeakMap,xr=new WeakMap,nl=new WeakMap,rl=new WeakMap,Oo=new WeakMap,sl=new WeakSet,nx=function(e){var t;if(T(this,rl))return fe(t=T(this,rl),sl,nx).call(t,e);I(this,nl,T(this,nl)+e),ee(T(this,Oo)<1||T(this,nl)<=T(this,Oo)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${T(this,Oo)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Pn(T(this,er)),offset:T(this,xr),length:e,info:{bytesRead:T(this,nl),dataLength:this.dataLength}})},eP=function(e,t,r){let s=Math.ceil(t/_n)*_n;return T(this,xr)+s>T(this,er).length&&(this.allowLoose&&r&&T(this,xr)+t<=T(this,er).length?s=t:ee(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Pn(T(this,er)),length:T(this,er).length,offset:T(this,xr)+s})),T(this,er).slice(T(this,xr),T(this,xr)+s)};let Bv=K1;function rg(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Fv(n,...e){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function YW(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rg(n.outputLen),rg(n.blockLen)}function Tc(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function mR(n,e){Fv(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const jv=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gR=n=>n instanceof Uint8Array,XW=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Uv=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Hs=(n,e)=>n<<32-e|n>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function ZW(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function sg(n){if(typeof n=="string"&&(n=ZW(n)),!gR(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function e7(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!gR(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}class Hv{clone(){return this._cloneInto()}}function zv(n){const e=r=>n().update(sg(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function t7(n=32){if(jv&&typeof jv.getRandomValues=="function")return jv.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class yR extends Hv{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,YW(e);const r=sg(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Tc(this),this.iHash.update(e),this}digestInto(e){Tc(this),Fv(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bR=(n,e,t)=>new yR(n,e).update(t).digest();bR.create=(n,e)=>new yR(n,e);function n7(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),l=r?4:0,c=r?0:4;n.setUint32(e+l,o,r),n.setUint32(e+c,a,r)}class wR extends Hv{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Uv(this.buffer)}update(e){Tc(this);const{view:t,buffer:r,blockLen:s}=this;e=sg(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=Uv(e);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Tc(this),mR(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let f=o;f<s;f++)t[f]=0;n7(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Uv(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<c;f++)a.setUint32(4*f,u[f],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const r7=(n,e,t)=>n&e^~n&t,s7=(n,e,t)=>n&e^n&t^e&t,i7=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),vo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),xo=new Uint32Array(64);class o7 extends wR{constructor(){super(64,32,8,!1),this.A=vo[0]|0,this.B=vo[1]|0,this.C=vo[2]|0,this.D=vo[3]|0,this.E=vo[4]|0,this.F=vo[5]|0,this.G=vo[6]|0,this.H=vo[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[e,t,r,s,i,o,a,l]}set(e,t,r,s,i,o,a,l){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let f=0;f<16;f++,t+=4)xo[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const d=xo[f-15],h=xo[f-2],p=Hs(d,7)^Hs(d,18)^d>>>3,m=Hs(h,17)^Hs(h,19)^h>>>10;xo[f]=m+xo[f-7]+p+xo[f-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:c,H:u}=this;for(let f=0;f<64;f++){const d=Hs(a,6)^Hs(a,11)^Hs(a,25),h=u+d+r7(a,l,c)+i7[f]+xo[f]|0,m=(Hs(r,2)^Hs(r,13)^Hs(r,22))+s7(r,s,i)|0;u=c,c=l,l=a,a=o+h|0,o=i,i=s,s=r,r=h+m|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,s,i,o,a,l,c,u)}roundClean(){xo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const vR=zv(()=>new o7),ig=BigInt(2**32-1),Vv=BigInt(32);function xR(n,e=!1){return e?{h:Number(n&ig),l:Number(n>>Vv&ig)}:{h:Number(n>>Vv&ig)|0,l:Number(n&ig)|0}}function AR(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=xR(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const a7=(n,e)=>BigInt(n>>>0)<<Vv|BigInt(e>>>0),l7=(n,e,t)=>n>>>t,c7=(n,e,t)=>n<<32-t|e>>>t,u7=(n,e,t)=>n>>>t|e<<32-t,f7=(n,e,t)=>n<<32-t|e>>>t,d7=(n,e,t)=>n<<64-t|e>>>t-32,h7=(n,e,t)=>n>>>t-32|e<<64-t,p7=(n,e)=>e,m7=(n,e)=>n,ER=(n,e,t)=>n<<t|e>>>32-t,kR=(n,e,t)=>e<<t|n>>>32-t,CR=(n,e,t)=>e<<t-32|n>>>64-t,SR=(n,e,t)=>n<<t-32|e>>>64-t;function g7(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const Xe={fromBig:xR,split:AR,toBig:a7,shrSH:l7,shrSL:c7,rotrSH:u7,rotrSL:f7,rotrBH:d7,rotrBL:h7,rotr32H:p7,rotr32L:m7,rotlSH:ER,rotlSL:kR,rotlBH:CR,rotlBL:SR,add:g7,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[y7,b7]=Xe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),Ao=new Uint32Array(80),Eo=new Uint32Array(80);class w7 extends wR{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:c,El:u,Fh:f,Fl:d,Gh:h,Gl:p,Hh:m,Hl:y}=this;return[e,t,r,s,i,o,a,l,c,u,f,d,h,p,m,y]}set(e,t,r,s,i,o,a,l,c,u,f,d,h,p,m,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=l|0,this.Eh=c|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=p|0,this.Hh=m|0,this.Hl=y|0}process(e,t){for(let v=0;v<16;v++,t+=4)Ao[v]=e.getUint32(t),Eo[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){const w=Ao[v-15]|0,E=Eo[v-15]|0,k=Xe.rotrSH(w,E,1)^Xe.rotrSH(w,E,8)^Xe.shrSH(w,E,7),S=Xe.rotrSL(w,E,1)^Xe.rotrSL(w,E,8)^Xe.shrSL(w,E,7),M=Ao[v-2]|0,O=Eo[v-2]|0,R=Xe.rotrSH(M,O,19)^Xe.rotrBH(M,O,61)^Xe.shrSH(M,O,6),D=Xe.rotrSL(M,O,19)^Xe.rotrBL(M,O,61)^Xe.shrSL(M,O,6),F=Xe.add4L(S,D,Eo[v-7],Eo[v-16]),U=Xe.add4H(F,k,R,Ao[v-7],Ao[v-16]);Ao[v]=U|0,Eo[v]=F|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:l,Dh:c,Dl:u,Eh:f,El:d,Fh:h,Fl:p,Gh:m,Gl:y,Hh:b,Hl:x}=this;for(let v=0;v<80;v++){const w=Xe.rotrSH(f,d,14)^Xe.rotrSH(f,d,18)^Xe.rotrBH(f,d,41),E=Xe.rotrSL(f,d,14)^Xe.rotrSL(f,d,18)^Xe.rotrBL(f,d,41),k=f&h^~f&m,S=d&p^~d&y,M=Xe.add5L(x,E,S,b7[v],Eo[v]),O=Xe.add5H(M,b,w,k,y7[v],Ao[v]),R=M|0,D=Xe.rotrSH(r,s,28)^Xe.rotrBH(r,s,34)^Xe.rotrBH(r,s,39),F=Xe.rotrSL(r,s,28)^Xe.rotrBL(r,s,34)^Xe.rotrBL(r,s,39),U=r&i^r&a^i&a,K=s&o^s&l^o&l;b=m|0,x=y|0,m=h|0,y=p|0,h=f|0,p=d|0,{h:f,l:d}=Xe.add(c|0,u|0,O|0,R|0),c=a|0,u=l|0,a=i|0,l=o|0,i=r|0,o=s|0;const _=Xe.add3L(R,F,K);r=Xe.add3H(_,O,D,U),s=_|0}({h:r,l:s}=Xe.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=Xe.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l}=Xe.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:c,l:u}=Xe.add(this.Dh|0,this.Dl|0,c|0,u|0),{h:f,l:d}=Xe.add(this.Eh|0,this.El|0,f|0,d|0),{h,l:p}=Xe.add(this.Fh|0,this.Fl|0,h|0,p|0),{h:m,l:y}=Xe.add(this.Gh|0,this.Gl|0,m|0,y|0),{h:b,l:x}=Xe.add(this.Hh|0,this.Hl|0,b|0,x|0),this.set(r,s,i,o,a,l,c,u,f,d,h,p,m,y,b,x)}roundClean(){Ao.fill(0),Eo.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const v7=zv(()=>new w7);function x7(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const TR=x7();TR.crypto||TR.msCrypto;function A7(n){switch(n){case"sha256":return vR.create();case"sha512":return v7.create()}V(!1,"invalid hashing algorithm name","algorithm",n)}const[NR,OR,RR]=[[],[],[]],E7=BigInt(0),gd=BigInt(1),k7=BigInt(2),C7=BigInt(7),S7=BigInt(256),T7=BigInt(113);for(let n=0,e=gd,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],NR.push(2*(5*r+t)),OR.push((n+1)*(n+2)/2%64);let s=E7;for(let i=0;i<7;i++)e=(e<<gd^(e>>C7)*T7)%S7,e&k7&&(s^=gd<<(gd<<BigInt(i))-gd);RR.push(s)}const[N7,O7]=AR(RR,!0),MR=(n,e,t)=>t>32?CR(n,e,t):ER(n,e,t),DR=(n,e,t)=>t>32?SR(n,e,t):kR(n,e,t);function R7(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],u=t[l+1],f=MR(c,u,1)^t[a],d=DR(c,u,1)^t[a+1];for(let h=0;h<50;h+=10)n[o+h]^=f,n[o+h+1]^=d}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=OR[o],l=MR(s,i,a),c=DR(s,i,a),u=NR[o];s=n[u],i=n[u+1],n[u]=l,n[u+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=N7[r],n[1]^=O7[r]}t.fill(0)}class $v extends Hv{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rg(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=XW(this.state)}keccak(){R7(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Tc(this);const{blockLen:t,state:r}=this;e=sg(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Tc(this,!1),Fv(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rg(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(mR(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new $v(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const M7=((n,e,t)=>zv(()=>new $v(e,n,t)))(1,136,256/8);let PR=!1;const IR=function(n){return M7(n)};let LR=IR;function Jt(n){const e=lt(n,"data");return we(LR(e))}Jt._=IR,Jt.lock=function(){PR=!0},Jt.register=function(n){if(PR)throw new TypeError("keccak256 is locked");LR=n},Object.freeze(Jt);const _R=function(n){return A7("sha256").update(n).digest()};let BR=_R,FR=!1;function Nc(n){const e=lt(n,"data");return we(BR(e))}Nc._=_R,Nc.lock=function(){FR=!0},Nc.register=function(n){if(FR)throw new Error("sha256 is locked");BR=n},Object.freeze(Nc),Object.freeze(Nc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const jR=BigInt(0),og=BigInt(1),D7=BigInt(2),ag=n=>n instanceof Uint8Array,P7=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function Oc(n){if(!ag(n))throw new Error("Uint8Array expected");let e="";for(let t=0;t<n.length;t++)e+=P7[n[t]];return e}function UR(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Wv(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function Rc(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let r=0;r<t.length;r++){const s=r*2,i=n.slice(s,s+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function Fa(n){return Wv(Oc(n))}function Gv(n){if(!ag(n))throw new Error("Uint8Array expected");return Wv(Oc(Uint8Array.from(n).reverse()))}function Mc(n,e){return Rc(n.toString(16).padStart(e*2,"0"))}function Kv(n,e){return Mc(n,e).reverse()}function I7(n){return Rc(UR(n))}function is(n,e,t){let r;if(typeof e=="string")try{r=Rc(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(ag(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function yd(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!ag(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}function L7(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function _7(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function B7(n){let e;for(e=0;n>jR;n>>=og,e+=1);return e}function F7(n,e){return n>>BigInt(e)&og}const j7=(n,e,t)=>n|(t?og:jR)<<BigInt(e),Jv=n=>(D7<<BigInt(n-1))-og,qv=n=>new Uint8Array(n),HR=n=>Uint8Array.from(n);function zR(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=qv(n),s=qv(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...f)=>t(s,r,...f),l=(f=qv())=>{s=a(HR([0]),f),r=a(),f.length!==0&&(s=a(HR([1]),f),r=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const d=[];for(;f<e;){r=a();const h=r.slice();d.push(h),f+=r.length}return yd(...d)};return(f,d)=>{o(),l(f);let h;for(;!(h=d(c()));)l();return o(),h}}const U7={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function bd(n,e,t={}){const r=(s,i,o)=>{const a=U7[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const H7=Object.freeze(Object.defineProperty({__proto__:null,bitGet:F7,bitLen:B7,bitMask:Jv,bitSet:j7,bytesToHex:Oc,bytesToNumberBE:Fa,bytesToNumberLE:Gv,concatBytes:yd,createHmacDrbg:zR,ensureBytes:is,equalBytes:L7,hexToBytes:Rc,hexToNumber:Wv,numberToBytesBE:Mc,numberToBytesLE:Kv,numberToHexUnpadded:UR,numberToVarBytesBE:I7,utf8ToBytes:_7,validateObject:bd},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cn=BigInt(0),Ht=BigInt(1),ja=BigInt(2),z7=BigInt(3),Qv=BigInt(4),VR=BigInt(5),$R=BigInt(8);BigInt(9),BigInt(16);function Yn(n,e){const t=n%e;return t>=cn?t:e+t}function V7(n,e,t){if(t<=cn||e<cn)throw new Error("Expected power/modulo > 0");if(t===Ht)return cn;let r=Ht;for(;e>cn;)e&Ht&&(r=r*n%t),n=n*n%t,e>>=Ht;return r}function _r(n,e,t){let r=n;for(;e-- >cn;)r*=r,r%=t;return r}function Yv(n,e){if(n===cn||e<=cn)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Yn(n,e),r=e,s=cn,i=Ht;for(;t!==cn;){const a=r/t,l=r%t,c=s-i*a;r=t,t=l,s=i,i=c}if(r!==Ht)throw new Error("invert: does not exist");return Yn(s,e)}function $7(n){const e=(n-Ht)/ja;let t,r,s;for(t=n-Ht,r=0;t%ja===cn;t/=ja,r++);for(s=ja;s<n&&V7(s,e,n)!==n-Ht;s++);if(r===1){const o=(n+Ht)/Qv;return function(l,c){const u=l.pow(c,o);if(!l.eql(l.sqr(u),c))throw new Error("Cannot find square root");return u}}const i=(t+Ht)/ja;return function(a,l){if(a.pow(l,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let c=r,u=a.pow(a.mul(a.ONE,s),t),f=a.pow(l,i),d=a.pow(l,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let h=1;for(let m=a.sqr(d);h<c&&!a.eql(m,a.ONE);h++)m=a.sqr(m);const p=a.pow(u,Ht<<BigInt(c-h-1));u=a.sqr(p),f=a.mul(f,p),d=a.mul(d,u),c=h}return f}}function W7(n){if(n%Qv===z7){const e=(n+Ht)/Qv;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%$R===VR){const e=(n-VR)/$R;return function(r,s){const i=r.mul(s,ja),o=r.pow(i,e),a=r.mul(s,o),l=r.mul(r.mul(a,ja),o),c=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(c),s))throw new Error("Cannot find square root");return c}}return $7(n)}const G7=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function K7(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=G7.reduce((r,s)=>(r[s]="function",r),e);return bd(n,t)}function J7(n,e,t){if(t<cn)throw new Error("Expected power > 0");if(t===cn)return n.ONE;if(t===Ht)return e;let r=n.ONE,s=e;for(;t>cn;)t&Ht&&(r=n.mul(r,s)),s=n.sqr(s),t>>=Ht;return r}function q7(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function WR(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Q7(n,e,t=!1,r={}){if(n<=cn)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=WR(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=W7(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Jv(s),ZERO:cn,ONE:Ht,create:l=>Yn(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return cn<=l&&l<n},is0:l=>l===cn,isOdd:l=>(l&Ht)===Ht,neg:l=>Yn(-l,n),eql:(l,c)=>l===c,sqr:l=>Yn(l*l,n),add:(l,c)=>Yn(l+c,n),sub:(l,c)=>Yn(l-c,n),mul:(l,c)=>Yn(l*c,n),pow:(l,c)=>J7(a,l,c),div:(l,c)=>Yn(l*Yv(c,n),n),sqrN:l=>l*l,addN:(l,c)=>l+c,subN:(l,c)=>l-c,mulN:(l,c)=>l*c,inv:l=>Yv(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>q7(a,l),cmov:(l,c,u)=>u?c:l,toBytes:l=>t?Kv(l,i):Mc(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return t?Gv(l):Fa(l)}});return Object.freeze(a)}function GR(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function KR(n){const e=GR(n);return e+Math.ceil(e/2)}function Y7(n,e,t=!1){const r=n.length,s=GR(e),i=KR(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?Fa(n):Gv(n),a=Yn(o,e-Ht)+Ht;return t?Kv(a,s):Mc(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const X7=BigInt(0),Xv=BigInt(1);function Z7(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>X7;)i&Xv&&(o=o.add(a)),a=a.double(),i>>=Xv;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let c=s,u=c;for(let f=0;f<o;f++){u=c,l.push(u);for(let d=1;d<a;d++)u=u.add(c),l.push(u);c=u.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let c=n.ZERO,u=n.BASE;const f=BigInt(2**s-1),d=2**s,h=BigInt(s);for(let p=0;p<a;p++){const m=p*l;let y=Number(o&f);o>>=h,y>l&&(y-=d,o+=Xv);const b=m,x=m+Math.abs(y)-1,v=p%2!==0,w=y<0;y===0?u=u.add(t(v,i[b])):c=c.add(t(w,i[x]))}return{p:c,f:u}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let c=i.get(s);return c||(c=this.precomputeWindow(s,l),l!==1&&i.set(s,a(c))),this.wNAF(l,c,o)}}}function JR(n){return K7(n.Fp),bd(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...WR(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function eG(n){const e=JR(n);bd(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:tG,hexToBytes:nG}=H7,Ua={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=Ua;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:tG(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=Ua,t=typeof n=="string"?nG(n):n;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=Ua._parseInt(t.subarray(2)),{d:o,l:a}=Ua._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=c=>Number.parseInt(c[0],16)&8?"00"+c:c,t=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),l=t(o);return`30${t(o+i+4)}02${l}${s}02${a}${r}`}},vi=BigInt(0),Br=BigInt(1);BigInt(2);const qR=BigInt(3);BigInt(4);function rG(n){const e=eG(n),{Fp:t}=e,r=e.toBytes||((p,m,y)=>{const b=m.toAffine();return yd(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),s=e.fromBytes||(p=>{const m=p.subarray(1),y=t.fromBytes(m.subarray(0,t.BYTES)),b=t.fromBytes(m.subarray(t.BYTES,2*t.BYTES));return{x:y,y:b}});function i(p){const{a:m,b:y}=e,b=t.sqr(p),x=t.mul(b,p);return t.add(t.add(x,t.mul(p,m)),y)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(p){return typeof p=="bigint"&&vi<p&&p<e.n}function a(p){if(!o(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(p){const{allowedPrivateKeyLengths:m,nByteLength:y,wrapPrivateKey:b,n:x}=e;if(m&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=Oc(p)),typeof p!="string"||!m.includes(p.length))throw new Error("Invalid key");p=p.padStart(y*2,"0")}let v;try{v=typeof p=="bigint"?p:Fa(is("private key",p,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof p}`)}return b&&(v=Yn(v,x)),a(v),v}const c=new Map;function u(p){if(!(p instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(m,y,b){if(this.px=m,this.py=y,this.pz=b,m==null||!t.isValid(m))throw new Error("x required");if(y==null||!t.isValid(y))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required")}static fromAffine(m){const{x:y,y:b}=m||{};if(!m||!t.isValid(y)||!t.isValid(b))throw new Error("invalid affine point");if(m instanceof f)throw new Error("projective point not allowed");const x=v=>t.eql(v,t.ZERO);return x(y)&&x(b)?f.ZERO:new f(y,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){const y=t.invertBatch(m.map(b=>b.pz));return m.map((b,x)=>b.toAffine(y[x])).map(f.fromAffine)}static fromHex(m){const y=f.fromAffine(s(is("pointHex",m)));return y.assertValidity(),y}static fromPrivateKey(m){return f.BASE.multiply(l(m))}_setWindowSize(m){this._WINDOW_SIZE=m,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:m,y}=this.toAffine();if(!t.isValid(m)||!t.isValid(y))throw new Error("bad point: x or y not FE");const b=t.sqr(y),x=i(m);if(!t.eql(b,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:m}=this.toAffine();if(t.isOdd)return!t.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){u(m);const{px:y,py:b,pz:x}=this,{px:v,py:w,pz:E}=m,k=t.eql(t.mul(y,E),t.mul(v,x)),S=t.eql(t.mul(b,E),t.mul(w,x));return k&&S}negate(){return new f(this.px,t.neg(this.py),this.pz)}double(){const{a:m,b:y}=e,b=t.mul(y,qR),{px:x,py:v,pz:w}=this;let E=t.ZERO,k=t.ZERO,S=t.ZERO,M=t.mul(x,x),O=t.mul(v,v),R=t.mul(w,w),D=t.mul(x,v);return D=t.add(D,D),S=t.mul(x,w),S=t.add(S,S),E=t.mul(m,S),k=t.mul(b,R),k=t.add(E,k),E=t.sub(O,k),k=t.add(O,k),k=t.mul(E,k),E=t.mul(D,E),S=t.mul(b,S),R=t.mul(m,R),D=t.sub(M,R),D=t.mul(m,D),D=t.add(D,S),S=t.add(M,M),M=t.add(S,M),M=t.add(M,R),M=t.mul(M,D),k=t.add(k,M),R=t.mul(v,w),R=t.add(R,R),M=t.mul(R,D),E=t.sub(E,M),S=t.mul(R,O),S=t.add(S,S),S=t.add(S,S),new f(E,k,S)}add(m){u(m);const{px:y,py:b,pz:x}=this,{px:v,py:w,pz:E}=m;let k=t.ZERO,S=t.ZERO,M=t.ZERO;const O=e.a,R=t.mul(e.b,qR);let D=t.mul(y,v),F=t.mul(b,w),U=t.mul(x,E),K=t.add(y,b),_=t.add(v,w);K=t.mul(K,_),_=t.add(D,F),K=t.sub(K,_),_=t.add(y,x);let G=t.add(v,E);return _=t.mul(_,G),G=t.add(D,U),_=t.sub(_,G),G=t.add(b,x),k=t.add(w,E),G=t.mul(G,k),k=t.add(F,U),G=t.sub(G,k),M=t.mul(O,_),k=t.mul(R,U),M=t.add(k,M),k=t.sub(F,M),M=t.add(F,M),S=t.mul(k,M),F=t.add(D,D),F=t.add(F,D),U=t.mul(O,U),_=t.mul(R,_),F=t.add(F,U),U=t.sub(D,U),U=t.mul(O,U),_=t.add(_,U),D=t.mul(F,_),S=t.add(S,D),D=t.mul(G,_),k=t.mul(K,k),k=t.sub(k,D),D=t.mul(K,F),M=t.mul(G,M),M=t.add(M,D),new f(k,S,M)}subtract(m){return this.add(m.negate())}is0(){return this.equals(f.ZERO)}wNAF(m){return h.wNAFCached(this,c,m,y=>{const b=t.invertBatch(y.map(x=>x.pz));return y.map((x,v)=>x.toAffine(b[v])).map(f.fromAffine)})}multiplyUnsafe(m){const y=f.ZERO;if(m===vi)return y;if(a(m),m===Br)return this;const{endo:b}=e;if(!b)return h.unsafeLadder(this,m);let{k1neg:x,k1:v,k2neg:w,k2:E}=b.splitScalar(m),k=y,S=y,M=this;for(;v>vi||E>vi;)v&Br&&(k=k.add(M)),E&Br&&(S=S.add(M)),M=M.double(),v>>=Br,E>>=Br;return x&&(k=k.negate()),w&&(S=S.negate()),S=new f(t.mul(S.px,b.beta),S.py,S.pz),k.add(S)}multiply(m){a(m);let y=m,b,x;const{endo:v}=e;if(v){const{k1neg:w,k1:E,k2neg:k,k2:S}=v.splitScalar(y);let{p:M,f:O}=this.wNAF(E),{p:R,f:D}=this.wNAF(S);M=h.constTimeNegate(w,M),R=h.constTimeNegate(k,R),R=new f(t.mul(R.px,v.beta),R.py,R.pz),b=M.add(R),x=O.add(D)}else{const{p:w,f:E}=this.wNAF(y);b=w,x=E}return f.normalizeZ([b,x])[0]}multiplyAndAddUnsafe(m,y,b){const x=f.BASE,v=(E,k)=>k===vi||k===Br||!E.equals(x)?E.multiplyUnsafe(k):E.multiply(k),w=v(this,y).add(v(m,b));return w.is0()?void 0:w}toAffine(m){const{px:y,py:b,pz:x}=this,v=this.is0();m==null&&(m=v?t.ONE:t.inv(x));const w=t.mul(y,m),E=t.mul(b,m),k=t.mul(x,m);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(k,t.ONE))throw new Error("invZ was invalid");return{x:w,y:E}}isTorsionFree(){const{h:m,isTorsionFree:y}=e;if(m===Br)return!0;if(y)return y(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:m,clearCofactor:y}=e;return m===Br?this:y?y(f,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return this.assertValidity(),r(f,this,m)}toHex(m=!0){return Oc(this.toRawBytes(m))}}f.BASE=new f(e.Gx,e.Gy,t.ONE),f.ZERO=new f(t.ZERO,t.ONE,t.ZERO);const d=e.nBitLength,h=Z7(f,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function sG(n){const e=JR(n);return bd(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function iG(n){const e=sG(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(_){return vi<_&&_<t.ORDER}function a(_){return Yn(_,r)}function l(_){return Yv(_,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:d}=rG({...e,toBytes(_,G,Y){const re=G.toAffine(),Z=t.toBytes(re.x),me=yd;return Y?me(Uint8Array.from([G.hasEvenY()?2:3]),Z):me(Uint8Array.from([4]),Z,t.toBytes(re.y))},fromBytes(_){const G=_.length,Y=_[0],re=_.subarray(1);if(G===s&&(Y===2||Y===3)){const Z=Fa(re);if(!o(Z))throw new Error("Point is not on curve");const me=f(Z);let ke=t.sqrt(me);const Pe=(ke&Br)===Br;return(Y&1)===1!==Pe&&(ke=t.neg(ke)),{x:Z,y:ke}}else if(G===i&&Y===4){const Z=t.fromBytes(re.subarray(0,t.BYTES)),me=t.fromBytes(re.subarray(t.BYTES,2*t.BYTES));return{x:Z,y:me}}else throw new Error(`Point of length ${G} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),h=_=>Oc(Mc(_,e.nByteLength));function p(_){const G=r>>Br;return _>G}function m(_){return p(_)?a(-_):_}const y=(_,G,Y)=>Fa(_.slice(G,Y));class b{constructor(G,Y,re){this.r=G,this.s=Y,this.recovery=re,this.assertValidity()}static fromCompact(G){const Y=e.nByteLength;return G=is("compactSignature",G,Y*2),new b(y(G,0,Y),y(G,Y,2*Y))}static fromDER(G){const{r:Y,s:re}=Ua.toSig(is("DER",G));return new b(Y,re)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(G){return new b(this.r,this.s,G)}recoverPublicKey(G){const{r:Y,s:re,recovery:Z}=this,me=S(is("msgHash",G));if(Z==null||![0,1,2,3].includes(Z))throw new Error("recovery id invalid");const ke=Z===2||Z===3?Y+e.n:Y;if(ke>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const Pe=Z&1?"03":"02",Ce=c.fromHex(Pe+h(ke)),Ee=l(ke),Ue=a(-me*Ee),Fe=a(re*Ee),He=c.BASE.multiplyAndAddUnsafe(Ce,Ue,Fe);if(!He)throw new Error("point at infinify");return He.assertValidity(),He}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Rc(this.toDERHex())}toDERHex(){return Ua.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rc(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const x={isValidPrivateKey(_){try{return u(_),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const _=KR(e.n);return Y7(e.randomBytes(_),e.n)},precompute(_=8,G=c.BASE){return G._setWindowSize(_),G.multiply(BigInt(3)),G}};function v(_,G=!0){return c.fromPrivateKey(_).toRawBytes(G)}function w(_){const G=_ instanceof Uint8Array,Y=typeof _=="string",re=(G||Y)&&_.length;return G?re===s||re===i:Y?re===2*s||re===2*i:_ instanceof c}function E(_,G,Y=!0){if(w(_))throw new Error("first arg must be private key");if(!w(G))throw new Error("second arg must be public key");return c.fromHex(G).multiply(u(_)).toRawBytes(Y)}const k=e.bits2int||function(_){const G=Fa(_),Y=_.length*8-e.nBitLength;return Y>0?G>>BigInt(Y):G},S=e.bits2int_modN||function(_){return a(k(_))},M=Jv(e.nBitLength);function O(_){if(typeof _!="bigint")throw new Error("bigint expected");if(!(vi<=_&&_<M))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Mc(_,e.nByteLength)}function R(_,G,Y=D){if(["recovered","canonical"].some(Ze=>Ze in Y))throw new Error("sign() legacy options not supported");const{hash:re,randomBytes:Z}=e;let{lowS:me,prehash:ke,extraEntropy:Pe}=Y;me==null&&(me=!0),_=is("msgHash",_),ke&&(_=is("prehashed msgHash",re(_)));const Ce=S(_),Ee=u(G),Ue=[O(Ee),O(Ce)];if(Pe!=null){const Ze=Pe===!0?Z(t.BYTES):Pe;Ue.push(is("extraEntropy",Ze))}const Fe=yd(...Ue),He=Ce;function Le(Ze){const le=k(Ze);if(!d(le))return;const ze=l(le),ae=c.BASE.multiply(le).toAffine(),be=a(ae.x);if(be===vi)return;const _e=a(ze*a(He+be*Ee));if(_e===vi)return;let z=(ae.x===be?0:2)|Number(ae.y&Br),J=_e;return me&&p(_e)&&(J=m(_e),z^=1),new b(be,J,z)}return{seed:Fe,k2sig:Le}}const D={lowS:e.lowS,prehash:!1},F={lowS:e.lowS,prehash:!1};function U(_,G,Y=D){const{seed:re,k2sig:Z}=R(_,G,Y),me=e;return zR(me.hash.outputLen,me.nByteLength,me.hmac)(re,Z)}c.BASE._setWindowSize(8);function K(_,G,Y,re=F){var ae;const Z=_;if(G=is("msgHash",G),Y=is("publicKey",Y),"strict"in re)throw new Error("options.strict was renamed to lowS");const{lowS:me,prehash:ke}=re;let Pe,Ce;try{if(typeof Z=="string"||Z instanceof Uint8Array)try{Pe=b.fromDER(Z)}catch(be){if(!(be instanceof Ua.Err))throw be;Pe=b.fromCompact(Z)}else if(typeof Z=="object"&&typeof Z.r=="bigint"&&typeof Z.s=="bigint"){const{r:be,s:_e}=Z;Pe=new b(be,_e)}else throw new Error("PARSE");Ce=c.fromHex(Y)}catch(be){if(be.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(me&&Pe.hasHighS())return!1;ke&&(G=e.hash(G));const{r:Ee,s:Ue}=Pe,Fe=S(G),He=l(Ue),Le=a(Fe*He),Ze=a(Ee*He),le=(ae=c.BASE.multiplyAndAddUnsafe(Ce,Le,Ze))==null?void 0:ae.toAffine();return le?a(le.x)===Ee:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:E,sign:U,verify:K,ProjectivePoint:c,Signature:b,utils:x}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function oG(n){return{hash:n,hmac:(e,...t)=>bR(n,e,e7(...t)),randomBytes:t7}}function aG(n,e){const t=r=>iG({...n,...oG(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const QR=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),YR=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),lG=BigInt(1),Zv=BigInt(2),XR=(n,e)=>(n+e/Zv)/e;function cG(n){const e=QR,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=n*n*n%e,u=c*c*n%e,f=_r(u,t,e)*u%e,d=_r(f,t,e)*u%e,h=_r(d,Zv,e)*c%e,p=_r(h,s,e)*h%e,m=_r(p,i,e)*p%e,y=_r(m,a,e)*m%e,b=_r(y,l,e)*y%e,x=_r(b,a,e)*m%e,v=_r(x,t,e)*u%e,w=_r(v,o,e)*p%e,E=_r(w,r,e)*c%e,k=_r(E,Zv,e);if(!e1.eql(e1.sqr(k),n))throw new Error("Cannot find square root");return k}const e1=Q7(QR,void 0,void 0,{sqrt:cG}),ko=aG({a:BigInt(0),b:BigInt(7),Fp:e1,n:YR,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=YR,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-lG*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=XR(i*n,e),l=XR(-r*n,e);let c=Yn(n-a*t-l*s,e),u=Yn(-a*r-l*i,e);const f=c>o,d=u>o;if(f&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:f,k1:c,k2neg:d,k2:u}}}},vR);BigInt(0),ko.ProjectivePoint;const wd="0x0000000000000000000000000000000000000000",ZR="0x0000000000000000000000000000000000000000000000000000000000000000",eM=BigInt(0),tM=BigInt(1),nM=BigInt(2),rM=BigInt(27),sM=BigInt(28),lg=BigInt(35),Dc={};function iM(n){return Ia(In(n),32)}const ds=class ds{constructor(e,t,r,s){q(this,Zc);q(this,eu);q(this,tu);q(this,il);Qm(e,Dc,"Signature"),I(this,Zc,t),I(this,eu,r),I(this,tu,s),I(this,il,null)}get r(){return T(this,Zc)}set r(e){V(Ec(e)===32,"invalid r","value",e),I(this,Zc,we(e))}get s(){return T(this,eu)}set s(e){V(Ec(e)===32,"invalid s","value",e);const t=we(e);V(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),I(this,eu,t)}get v(){return T(this,tu)}set v(e){const t=Je(e,"value");V(t===27||t===28,"invalid v","v",e),I(this,tu,t)}get networkV(){return T(this,il)}get legacyChainId(){const e=this.networkV;return e==null?null:ds.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=lt(this.s);return this.yParity&&(e[0]|=128),we(e)}get compactSerialized(){return Ut([this.r,this.yParityAndS])}get serialized(){return Ut([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new ds(Dc,this.r,this.s,this.v);return this.networkV&&I(e,il,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=Ae(e,"v");return t==rM||t==sM?eM:(V(t>=lg,"invalid EIP-155 v","v",e),(t-lg)/nM)}static getChainIdV(e,t){return Ae(e)*nM+BigInt(35+t-27)}static getNormalizedV(e){const t=Ae(e);return t===eM||t===rM?27:t===tM||t===sM?28:(V(t>=lg,"invalid v","v",e),t&tM?27:28)}static from(e){function t(c,u){V(c,u,"signature",e)}if(e==null)return new ds(Dc,ZR,ZR,27);if(typeof e=="string"){const c=lt(e,"signature");if(c.length===64){const u=we(c.slice(0,32)),f=c.slice(32,64),d=f[0]&128?28:27;return f[0]&=127,new ds(Dc,u,we(f),d)}if(c.length===65){const u=we(c.slice(0,32)),f=c.slice(32,64);t((f[0]&128)===0,"non-canonical s");const d=ds.getNormalizedV(c[64]);return new ds(Dc,u,we(f),d)}t(!1,"invalid raw signature length")}if(e instanceof ds)return e.clone();const r=e.r;t(r!=null,"missing r");const s=iM(r),i=function(c,u){if(c!=null)return iM(c);if(u!=null){t(At(u,32),"invalid yParityAndS");const f=lt(u);return f[0]&=127,we(f)}t(!1,"missing s")}(e.s,e.yParityAndS);t((lt(i)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(c,u,f){if(c!=null){const d=Ae(c);return{networkV:d>=lg?d:void 0,v:ds.getNormalizedV(d)}}if(u!=null)return t(At(u,32),"invalid yParityAndS"),{v:lt(u)[0]&128?28:27};if(f!=null){switch(Je(f,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new ds(Dc,s,i,a);return o&&I(l,il,o),t(e.yParity==null||Je(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};Zc=new WeakMap,eu=new WeakMap,tu=new WeakMap,il=new WeakMap;let as=ds;const ol=class ol{constructor(e){q(this,Ri);V(Ec(e)===32,"invalid private key","privateKey","[REDACTED]"),I(this,Ri,we(e))}get privateKey(){return T(this,Ri)}get publicKey(){return ol.computePublicKey(T(this,Ri))}get compressedPublicKey(){return ol.computePublicKey(T(this,Ri),!0)}sign(e){V(Ec(e)===32,"invalid digest length","digest",e);const t=ko.sign(Pn(e),Pn(T(this,Ri)),{lowS:!0});return as.from({r:bo(t.r,32),s:bo(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=ol.computePublicKey(e);return we(ko.getSharedSecret(Pn(T(this,Ri)),lt(t),!1))}static computePublicKey(e,t){let r=lt(e,"key");if(r.length===32){const i=ko.getPublicKey(r,!!t);return we(i)}if(r.length===64){const i=new Uint8Array(65);i[0]=4,i.set(r,1),r=i}const s=ko.ProjectivePoint.fromHex(r);return we(s.toRawBytes(t))}static recoverPublicKey(e,t){V(Ec(e)===32,"invalid digest length","digest",e);const r=as.from(t);let s=ko.Signature.fromCompact(Pn(Ut([r.r,r.s])));s=s.addRecoveryBit(r.yParity);const i=s.recoverPublicKey(Pn(e));return V(i!=null,"invalid signautre for digest","signature",t),"0x"+i.toHex(!1)}static addPoints(e,t,r){const s=ko.ProjectivePoint.fromHex(ol.computePublicKey(e).substring(2)),i=ko.ProjectivePoint.fromHex(ol.computePublicKey(t).substring(2));return"0x"+s.add(i).toHex(!!r)}};Ri=new WeakMap;let vd=ol;const uG=BigInt(0),fG=BigInt(36);function oM(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=lt(Jt(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const t1={};for(let n=0;n<10;n++)t1[String(n)]=String(n);for(let n=0;n<26;n++)t1[String.fromCharCode(65+n)]=String(10+n);const aM=15;function dG(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>t1[r]).join("");for(;e.length>=aM;){let r=e.substring(0,aM);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const hG=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function pG(n){n=n.toLowerCase();let e=uG;for(let t=0;t<n.length;t++)e=e*fG+hG[n[t]];return e}function dt(n){if(V(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=oM(n);return V(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){V(n.substring(2,4)===dG(n),"bad icap checksum","address",n);let e=pG(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return oM("0x"+e)}V(!1,"invalid address","address",n)}function mG(n){const e=dt(n.from);let r=Ae(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,dt(Ft(Jt(_a([e,r])),12))}function lM(n){return n&&typeof n.getAddress=="function"}function gG(n){try{return dt(n),!0}catch{}return!1}async function n1(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(ee(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),V(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),dt(t)}function Bn(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?dt(n):(ee(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),n1(n,e.resolveName(n)));if(lM(n))return n1(n,n.getAddress());if(n&&typeof n.then=="function")return n1(n,n);V(!1,"unsupported addressable value","target",n)}const xi={};function ve(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new En(xi,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function ut(n,e){return new En(xi,`bytes${e||""}`,n,{size:e})}const cM=Symbol.for("_ethers_typed"),Mi=class Mi{constructor(e,t,r,s){$(this,"type");$(this,"value");q(this,al);$(this,"_typedSymbol");s==null&&(s=null),Qm(xi,e,"Typed"),Oe(this,{_typedSymbol:cM,type:t,value:r}),I(this,al,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return T(this,al)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return T(this,al)===!0?-1:T(this,al)===!1?this.value.length:null}static from(e,t){return new Mi(xi,e,t)}static uint8(e){return ve(e,8)}static uint16(e){return ve(e,16)}static uint24(e){return ve(e,24)}static uint32(e){return ve(e,32)}static uint40(e){return ve(e,40)}static uint48(e){return ve(e,48)}static uint56(e){return ve(e,56)}static uint64(e){return ve(e,64)}static uint72(e){return ve(e,72)}static uint80(e){return ve(e,80)}static uint88(e){return ve(e,88)}static uint96(e){return ve(e,96)}static uint104(e){return ve(e,104)}static uint112(e){return ve(e,112)}static uint120(e){return ve(e,120)}static uint128(e){return ve(e,128)}static uint136(e){return ve(e,136)}static uint144(e){return ve(e,144)}static uint152(e){return ve(e,152)}static uint160(e){return ve(e,160)}static uint168(e){return ve(e,168)}static uint176(e){return ve(e,176)}static uint184(e){return ve(e,184)}static uint192(e){return ve(e,192)}static uint200(e){return ve(e,200)}static uint208(e){return ve(e,208)}static uint216(e){return ve(e,216)}static uint224(e){return ve(e,224)}static uint232(e){return ve(e,232)}static uint240(e){return ve(e,240)}static uint248(e){return ve(e,248)}static uint256(e){return ve(e,256)}static uint(e){return ve(e,256)}static int8(e){return ve(e,-8)}static int16(e){return ve(e,-16)}static int24(e){return ve(e,-24)}static int32(e){return ve(e,-32)}static int40(e){return ve(e,-40)}static int48(e){return ve(e,-48)}static int56(e){return ve(e,-56)}static int64(e){return ve(e,-64)}static int72(e){return ve(e,-72)}static int80(e){return ve(e,-80)}static int88(e){return ve(e,-88)}static int96(e){return ve(e,-96)}static int104(e){return ve(e,-104)}static int112(e){return ve(e,-112)}static int120(e){return ve(e,-120)}static int128(e){return ve(e,-128)}static int136(e){return ve(e,-136)}static int144(e){return ve(e,-144)}static int152(e){return ve(e,-152)}static int160(e){return ve(e,-160)}static int168(e){return ve(e,-168)}static int176(e){return ve(e,-176)}static int184(e){return ve(e,-184)}static int192(e){return ve(e,-192)}static int200(e){return ve(e,-200)}static int208(e){return ve(e,-208)}static int216(e){return ve(e,-216)}static int224(e){return ve(e,-224)}static int232(e){return ve(e,-232)}static int240(e){return ve(e,-240)}static int248(e){return ve(e,-248)}static int256(e){return ve(e,-256)}static int(e){return ve(e,-256)}static bytes1(e){return ut(e,1)}static bytes2(e){return ut(e,2)}static bytes3(e){return ut(e,3)}static bytes4(e){return ut(e,4)}static bytes5(e){return ut(e,5)}static bytes6(e){return ut(e,6)}static bytes7(e){return ut(e,7)}static bytes8(e){return ut(e,8)}static bytes9(e){return ut(e,9)}static bytes10(e){return ut(e,10)}static bytes11(e){return ut(e,11)}static bytes12(e){return ut(e,12)}static bytes13(e){return ut(e,13)}static bytes14(e){return ut(e,14)}static bytes15(e){return ut(e,15)}static bytes16(e){return ut(e,16)}static bytes17(e){return ut(e,17)}static bytes18(e){return ut(e,18)}static bytes19(e){return ut(e,19)}static bytes20(e){return ut(e,20)}static bytes21(e){return ut(e,21)}static bytes22(e){return ut(e,22)}static bytes23(e){return ut(e,23)}static bytes24(e){return ut(e,24)}static bytes25(e){return ut(e,25)}static bytes26(e){return ut(e,26)}static bytes27(e){return ut(e,27)}static bytes28(e){return ut(e,28)}static bytes29(e){return ut(e,29)}static bytes30(e){return ut(e,30)}static bytes31(e){return ut(e,31)}static bytes32(e){return ut(e,32)}static address(e){return new Mi(xi,"address",e)}static bool(e){return new Mi(xi,"bool",!!e)}static bytes(e){return new Mi(xi,"bytes",e)}static string(e){return new Mi(xi,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Mi(xi,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===cM}static dereference(e,t){if(Mi.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};al=new WeakMap;let En=Mi;class yG extends wi{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=En.dereference(t,"string");try{r=dt(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return dt(bo(e.readValue(),20))}}class bG extends wi{constructor(t){super(t.name,t.type,"_",t.dynamic);$(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function uM(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let l={};r=e.map(c=>{const u=c.localName;return ee(u,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),ee(!l[u],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),l[u]=!0,t[u]})}else V(!1,"invalid tuple value","tuple",t);V(e.length===r.length,"types/value length mismatch","tuple",t);let s=new _v,i=new _v,o=[];e.forEach((l,c)=>{let u=r[c];if(l.dynamic){let f=i.length;l.encode(i,u);let d=s.writeUpdatableValue();o.push(h=>{d(h+f)})}else l.encode(s,u)}),o.forEach(l=>{l(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function fM(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),l=s.subReader(a);try{o=i.decode(l)}catch(c){if(ln(c,"BUFFER_OVERRUN"))throw c;o=c,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(ln(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),Sc.fromItems(t,r)}class wG extends wi{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);$(this,"coder");$(this,"length");Oe(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=En.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),$O(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return uM(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),ee(r*_n<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*_n,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new bG(this.coder));return fM(t,s)}}class vG extends wi{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=En.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class dM extends wi{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Pn(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class xG extends dM{constructor(e){super("bytes",e)}decode(e){return we(super.decode(e))}}class AG extends wi{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);$(this,"size");Oe(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Pn(En.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return we(t.readBytes(this.size))}}const EG=new Uint8Array([]);class kG extends wi{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(EG)}decode(e){return e.readBytes(0),null}}const CG=BigInt(0),SG=BigInt(1),TG=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class NG extends wi{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);$(this,"size");$(this,"signed");Oe(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=Ae(En.dereference(r,this.type)),i=pd(TG,_n*8);if(this.signed){let o=pd(i,this.size*8-1);(s>o||s<-(o+SG))&&this._throwError("value out-of-bounds",r),s=JO(s,8*_n)}else(s<CG||s>pd(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=pd(t.readValue(),this.size*8);return this.signed&&(r=DW(r,this.size*8)),r}}class OG extends dM{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,bi(En.dereference(t,"string")))}decode(e){return Cc(super.decode(e))}}class cg extends wi{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);$(this,"coders");Oe(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=En.dereference(r,"tuple");return uM(t,this.coders,s)}decode(t){return fM(t,this.coders)}}function Ha(n){return Jt(bi(n))}var RG="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";const hM=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),pM=4;function MG(n){let e=0;function t(){return n[e++]<<8|n[e++]}let r=t(),s=1,i=[0,1];for(let E=1;E<r;E++)i.push(s+=t());let o=t(),a=e;e+=o;let l=0,c=0;function u(){return l==0&&(c=c<<8|n[e++],l=8),c>>--l&1}const f=31,d=2**f,h=d>>>1,p=h>>1,m=d-1;let y=0;for(let E=0;E<f;E++)y=y<<1|u();let b=[],x=0,v=d;for(;;){let E=Math.floor(((y-x+1)*s-1)/v),k=0,S=r;for(;S-k>1;){let R=k+S>>>1;E<i[R]?S=R:k=R}if(k==0)break;b.push(k);let M=x+Math.floor(v*i[k]/s),O=x+Math.floor(v*i[k+1]/s)-1;for(;!((M^O)&h);)y=y<<1&m|u(),M=M<<1&m,O=O<<1&m|1;for(;M&~O&p;)y=y&h|y<<1&m>>>1|u(),M=M<<1^h,O=(O^h)<<1|h|1;x=M,v=1+O-M}let w=r-4;return b.map(E=>{switch(E-w){case 3:return w+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return w+256+(n[a++]<<8|n[a++]);case 1:return w+n[a++];default:return E-1}})}function DG(n){let e=0;return()=>n[e++]}function mM(n){return DG(MG(PG(n)))}function PG(n){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,i)=>e[s.charCodeAt(0)]=i);let t=n.length,r=new Uint8Array(6*t>>3);for(let s=0,i=0,o=0,a=0;s<t;s++)a=a<<6|e[n.charCodeAt(s)],o+=6,o>=8&&(r[i++]=a>>(o-=8));return r}function IG(n){return n&1?~n>>1:n>>1}function LG(n,e){let t=Array(n);for(let r=0,s=0;r<n;r++)t[r]=s+=IG(e());return t}function xd(n,e=0){let t=[];for(;;){let r=n(),s=n();if(!s)break;e+=r;for(let i=0;i<s;i++)t.push(e+i);e+=s+1}return t}function gM(n){return Ad(()=>{let e=xd(n);if(e.length)return e})}function yM(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(_G(t,n))}for(;;){let t=n()-1;if(t<0)break;e.push(BG(t,n))}return e.flat()}function Ad(n){let e=[];for(;;){let t=n(e.length);if(!t)break;e.push(t)}return e}function bM(n,e,t){let r=Array(n).fill().map(()=>[]);for(let s=0;s<e;s++)LG(n,t).forEach((i,o)=>r[o].push(i));return r}function _G(n,e){let t=1+e(),r=e(),s=Ad(e);return bM(s.length,1+n,e).flatMap((o,a)=>{let[l,...c]=o;return Array(s[a]).fill().map((u,f)=>{let d=f*r;return[l+f*t,c.map(h=>h+d)]})})}function BG(n,e){let t=1+e();return bM(t,1+n,e).map(s=>[s[0],s.slice(1)])}function FG(n){let e=[],t=xd(n);return s(r([]),[]),e;function r(i){let o=n(),a=Ad(()=>{let l=xd(n).map(c=>t[c]);if(l.length)return r(l)});return{S:o,B:a,Q:i}}function s({S:i,B:o},a,l){if(!(i&4&&l===a[a.length-1])){i&2&&(l=a[a.length-1]),i&1&&e.push(a);for(let c of o)for(let u of c.Q)s(c,[...a,u],l)}}}function jG(n){return n.toString(16).toUpperCase().padStart(2,"0")}function wM(n){return`{${jG(n)}}`}function UG(n){let e=[];for(let t=0,r=n.length;t<r;){let s=n.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function Pc(n){let t=n.length;if(t<4096)return String.fromCodePoint(...n);let r=[];for(let s=0;s<t;)r.push(String.fromCodePoint(...n.slice(s,s+=4096)));return r.join("")}function HG(n,e){let t=n.length,r=t-e.length;for(let s=0;r==0&&s<t;s++)r=n[s]-e[s];return r}var zG="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";const Ed=44032,ug=4352,fg=4449,dg=4519,vM=19,xM=21,Ic=28,hg=xM*Ic,VG=vM*hg,$G=Ed+VG,WG=ug+vM,GG=fg+xM,KG=dg+Ic;function kd(n){return n>>24&255}function AM(n){return n&16777215}let r1,EM,s1,pg;function JG(){let n=mM(zG);r1=new Map(gM(n).flatMap((e,t)=>e.map(r=>[r,t+1<<24]))),EM=new Set(xd(n)),s1=new Map,pg=new Map;for(let[e,t]of yM(n)){if(!EM.has(e)&&t.length==2){let[r,s]=t,i=pg.get(r);i||(i=new Map,pg.set(r,i)),i.set(s,e)}s1.set(e,t.reverse())}}function kM(n){return n>=Ed&&n<$G}function qG(n,e){if(n>=ug&&n<WG&&e>=fg&&e<GG)return Ed+(n-ug)*hg+(e-fg)*Ic;if(kM(n)&&e>dg&&e<KG&&(n-Ed)%Ic==0)return n+(e-dg);{let t=pg.get(n);return t&&(t=t.get(e),t)?t:-1}}function CM(n){r1||JG();let e=[],t=[],r=!1;function s(i){let o=r1.get(i);o&&(r=!0,i|=o),e.push(i)}for(let i of n)for(;;){if(i<128)e.push(i);else if(kM(i)){let o=i-Ed,a=o/hg|0,l=o%hg/Ic|0,c=o%Ic;s(ug+a),s(fg+l),c>0&&s(dg+c)}else{let o=s1.get(i);o?t.push(...o):s(i)}if(!t.length)break;i=t.pop()}if(r&&e.length>1){let i=kd(e[0]);for(let o=1;o<e.length;o++){let a=kd(e[o]);if(a==0||i<=a){i=a;continue}let l=o-1;for(;;){let c=e[l+1];if(e[l+1]=e[l],e[l]=c,!l||(i=kd(e[--l]),i<=a))break}i=kd(e[o])}}return e}function QG(n){let e=[],t=[],r=-1,s=0;for(let i of n){let o=kd(i),a=AM(i);if(r==-1)o==0?r=a:e.push(a);else if(s>0&&s>=o)o==0?(e.push(r,...t),t.length=0,r=a):t.push(a),s=o;else{let l=qG(r,a);l>=0?r=l:s==0&&o==0?(e.push(r),r=a):(t.push(a),s=o)}}return r>=0&&e.push(r,...t),e}function SM(n){return CM(n).map(AM)}function YG(n){return QG(CM(n))}const TM=45,NM=".",OM=65039,RM=1,mg=n=>Array.from(n);function Cd(n,e){return n.P.has(e)||n.Q.has(e)}class XG extends Array{get is_emoji(){return!0}}let i1,MM,za,o1,DM,Lc,a1,_c,Va,PM,l1;function c1(){if(i1)return;let n=mM(RG);const e=()=>xd(n),t=()=>new Set(e()),r=(u,f)=>f.forEach(d=>u.add(d));i1=new Map(yM(n)),MM=t(),za=e(),o1=new Set(e().map(u=>za[u])),za=new Set(za),DM=t(),t();let s=gM(n),i=n();const o=()=>{let u=new Set;return e().forEach(f=>r(u,s[f])),r(u,e()),u};Lc=Ad(u=>{let f=Ad(n).map(d=>d+96);if(f.length){let d=u>=i;f[0]-=32,f=Pc(f),d&&(f=`Restricted[${f}]`);let h=o(),p=o(),m=!n();return{N:f,P:h,Q:p,M:m,R:d}}}),a1=t(),_c=new Map;let a=e().concat(mg(a1)).sort((u,f)=>u-f);a.forEach((u,f)=>{let d=n(),h=a[f]=d?a[f-d]:{V:[],M:new Map};h.V.push(u),a1.has(u)||_c.set(u,h)});for(let{V:u,M:f}of new Set(_c.values())){let d=[];for(let p of u){let m=Lc.filter(b=>Cd(b,p)),y=d.find(({G:b})=>m.some(x=>b.has(x)));y||(y={G:new Set,V:[]},d.push(y)),y.V.push(p),r(y.G,m)}let h=d.flatMap(p=>mg(p.G));for(let{G:p,V:m}of d){let y=new Set(h.filter(b=>!p.has(b)));for(let b of m)f.set(b,y)}}Va=new Set;let l=new Set;const c=u=>Va.has(u)?l.add(u):Va.add(u);for(let u of Lc){for(let f of u.P)c(f);for(let f of u.Q)c(f)}for(let u of Va)!_c.has(u)&&!l.has(u)&&_c.set(u,RM);r(Va,SM(Va)),PM=FG(n).map(u=>XG.from(u)).sort(HG),l1=new Map;for(let u of PM){let f=[l1];for(let d of u){let h=f.map(p=>{let m=p.get(d);return m||(m=new Map,p.set(d,m)),m});d===OM?f.push(...h):f=h}for(let d of f)d.V=u}}function u1(n){return(IM(n)?"":`${f1(gg([n]))} `)+wM(n)}function f1(n){return`"${n}"‎`}function ZG(n){if(n.length>=4&&n[2]==TM&&n[3]==TM)throw new Error(`invalid label extension: "${Pc(n.slice(0,4))}"`)}function eK(n){for(let t=n.lastIndexOf(95);t>0;)if(n[--t]!==95)throw new Error("underscore allowed only at start")}function tK(n){let e=n[0],t=hM.get(e);if(t)throw Sd(`leading ${t}`);let r=n.length,s=-1;for(let i=1;i<r;i++){e=n[i];let o=hM.get(e);if(o){if(s==i)throw Sd(`${t} + ${o}`);s=i+1,t=o}}if(s==r)throw Sd(`trailing ${t}`)}function gg(n,e=1/0,t=wM){let r=[];nK(n[0])&&r.push("◌"),n.length>e&&(e>>=1,n=[...n.slice(0,e),8230,...n.slice(-e)]);let s=0,i=n.length;for(let o=0;o<i;o++){let a=n[o];IM(a)&&(r.push(Pc(n.slice(s,o))),r.push(t(a)),s=o+1)}return r.push(Pc(n.slice(s,i))),r.join("")}function nK(n){return c1(),za.has(n)}function IM(n){return c1(),DM.has(n)}function rK(n){return aK(sK(n,YG,uK))}function sK(n,e,t){if(!n)return[];c1();let r=0;return n.split(NM).map(s=>{let i=UG(s),o={input:i,offset:r};r+=i.length+1;try{let a=o.tokens=cK(i,e,t),l=a.length,c;if(!l)throw new Error("empty label");let u=o.output=a.flat();if(eK(u),!(o.emoji=l>1||a[0].is_emoji)&&u.every(d=>d<128))ZG(u),c="ASCII";else{let d=a.flatMap(h=>h.is_emoji?[]:h);if(!d.length)c="Emoji";else{if(za.has(u[0]))throw Sd("leading combining mark");for(let m=1;m<l;m++){let y=a[m];if(!y.is_emoji&&za.has(y[0]))throw Sd(`emoji + combining mark: "${Pc(a[m-1])} + ${gg([y[0]])}"`)}tK(u);let h=mg(new Set(d)),[p]=oK(h);lK(p,d),iK(p,h),c=p.N}}o.type=c}catch(a){o.error=a}return o})}function iK(n,e){let t,r=[];for(let s of e){let i=_c.get(s);if(i===RM)return;if(i){let o=i.M.get(s);if(t=t?t.filter(a=>o.has(a)):mg(o),!t.length)return}else r.push(s)}if(t){for(let s of t)if(r.every(i=>Cd(s,i)))throw new Error(`whole-script confusable: ${n.N}/${s.N}`)}}function oK(n){let e=Lc;for(let t of n){let r=e.filter(s=>Cd(s,t));if(!r.length)throw Lc.some(s=>Cd(s,t))?_M(e[0],t):LM(t);if(e=r,r.length==1)break}return e}function aK(n){return n.map(({input:e,error:t,output:r})=>{if(t){let s=t.message;throw new Error(n.length==1?s:`Invalid label ${f1(gg(e,63))}: ${s}`)}return Pc(r)}).join(NM)}function LM(n){return new Error(`disallowed character: ${u1(n)}`)}function _M(n,e){let t=u1(e),r=Lc.find(s=>s.P.has(e));return r&&(t=`${r.N} ${t}`),new Error(`illegal mixture: ${n.N} + ${t}`)}function Sd(n){return new Error(`illegal placement: ${n}`)}function lK(n,e){for(let t of e)if(!Cd(n,t))throw _M(n,t);if(n.M){let t=SM(e);for(let r=1,s=t.length;r<s;r++)if(o1.has(t[r])){let i=r+1;for(let o;i<s&&o1.has(o=t[i]);i++)for(let a=r;a<i;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${u1(o)}`);if(i-r>pM)throw new Error(`excessive non-spacing marks: ${f1(gg(t.slice(r-1,i)))} (${i-r}/${pM})`);r=i}}}function cK(n,e,t){let r=[],s=[];for(n=n.slice().reverse();n.length;){let i=fK(n);if(i)s.length&&(r.push(e(s)),s=[]),r.push(t(i));else{let o=n.pop();if(Va.has(o))s.push(o);else{let a=i1.get(o);if(a)s.push(...a);else if(!MM.has(o))throw LM(o)}}}return s.length&&r.push(e(s)),r}function uK(n){return n.filter(e=>e!=OM)}function fK(n,e){let t=l1,r,s=n.length;for(;s&&(t=t.get(n[--s]),!!t);){let{V:i}=t;i&&(r=i,n.length=s)}return r}const BM=new Uint8Array(32);BM.fill(0);function FM(n){return V(n.length!==0,"invalid ENS name; empty component","comp",n),n}function jM(n){const e=bi(dK(n)),t=[];if(n.length===0)return t;let r=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(FM(e.slice(r,s))),r=s+1);return V(r<e.length,"invalid ENS name; empty component","name",n),t.push(FM(e.slice(r))),t}function dK(n){try{if(n.length===0)throw new Error("empty label");return rK(n)}catch(e){V(!1,`invalid ENS name (${e.message})`,"name",n)}}function d1(n){V(typeof n=="string","invalid ENS name; not a string","name",n),V(n.length,"invalid ENS name (empty label)","name",n);let e=BM;const t=jM(n);for(;t.length;)e=Jt(Ut([e,Jt(t.pop())]));return we(e)}function hK(n,e){const t=e;return V(t<=255,"DNS encoded label cannot exceed 255","length",t),we(Ut(jM(n).map(r=>{V(r.length<=t,`label ${JSON.stringify(n)} exceeds ${t} bytes`,"name",n);const s=new Uint8Array(r.length+1);return s.set(r,1),s[0]=s.length-1,s})))+"00"}function h1(n,e){return{address:dt(n),storageKeys:e.map((t,r)=>(V(At(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function Co(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(V(t.length===2,"invalid slot set",`value[${r}]`,t),h1(t[0],t[1])):(V(t!=null&&typeof t=="object","invalid address-slot set","value",n),h1(t.address,t.storageKeys)));V(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return h1(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function pK(n){let e;return typeof n=="string"?e=vd.computePublicKey(n,!1):e=n.publicKey,dt(Jt("0x"+e.substring(4)).substring(26))}function mK(n,e){return pK(vd.recoverPublicKey(n,e))}const un=BigInt(0),gK=BigInt(2),yK=BigInt(27),bK=BigInt(28),wK=BigInt(35),vK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),p1=4096*32;function UM(n,e){let t=n.toString(16);for(;t.length<2;)t="0"+t;return t+=Nc(e).substring(4),"0x"+t}function yg(n){return n==="0x"?null:dt(n)}function m1(n,e){try{return Co(n)}catch(t){V(!1,t.message,e,n)}}function Td(n,e){return n==="0x"?0:Je(n,e)}function zt(n,e){if(n==="0x")return un;const t=Ae(n,e);return V(t<=vK,"value exceeds uint size",e,t),t}function Ct(n,e){const t=Ae(n,"value"),r=In(t);return V(r.length<=32,"value too large",`tx.${e}`,t),r}function g1(n){return Co(n).map(e=>[e.address,e.storageKeys])}function xK(n,e){V(Array.isArray(n),`invalid ${e}`,"value",n);for(let t=0;t<n.length;t++)V(At(n[t],32),"invalid ${ param } hash",`value[${t}]`,n[t]);return n}function AK(n){const e=tg(n);V(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",n);const t={type:0,nonce:Td(e[0],"nonce"),gasPrice:zt(e[1],"gasPrice"),gasLimit:zt(e[2],"gasLimit"),to:yg(e[3]),value:zt(e[4],"value"),data:we(e[5]),chainId:un};if(e.length===6)return t;const r=zt(e[6],"v"),s=zt(e[7],"r"),i=zt(e[8],"s");if(s===un&&i===un)t.chainId=r;else{let o=(r-wK)/gK;o<un&&(o=un),t.chainId=o,V(o!==un||r===yK||r===bK,"non-canonical legacy v","v",e[6]),t.signature=as.from({r:Ia(e[7],32),s:Ia(e[8],32),v:r})}return t}function EK(n,e){const t=[Ct(n.nonce,"nonce"),Ct(n.gasPrice||0,"gasPrice"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data];let r=un;if(n.chainId!=un)r=Ae(n.chainId,"tx.chainId"),V(!e||e.networkV==null||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(n.signature){const i=n.signature.legacyChainId;i!=null&&(r=i)}if(!e)return r!==un&&(t.push(In(r)),t.push("0x"),t.push("0x")),_a(t);let s=BigInt(27+e.yParity);return r!==un?s=as.getChainIdV(r,e.v):BigInt(e.v)!==s&&V(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(In(s)),t.push(In(e.r)),t.push(In(e.s)),_a(t)}function y1(n,e){let t;try{if(t=Td(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{V(!1,"invalid yParity","yParity",e[0])}const r=Ia(e[1],32),s=Ia(e[2],32),i=as.from({r,s,yParity:t});n.signature=i}function kK(n){const e=tg(lt(n).slice(1));V(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",we(n));const t={type:2,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),maxPriorityFeePerGas:zt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:zt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:zt(e[4],"gasLimit"),to:yg(e[5]),value:zt(e[6],"value"),data:we(e[7]),accessList:m1(e[8],"accessList")};return e.length===9||y1(t,e.slice(9)),t}function CK(n,e){const t=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ct(n.maxFeePerGas||0,"maxFeePerGas"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data,g1(n.accessList||[])];return e&&(t.push(Ct(e.yParity,"yParity")),t.push(In(e.r)),t.push(In(e.s))),Ut(["0x02",_a(t)])}function SK(n){const e=tg(lt(n).slice(1));V(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",we(n));const t={type:1,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),gasPrice:zt(e[2],"gasPrice"),gasLimit:zt(e[3],"gasLimit"),to:yg(e[4]),value:zt(e[5],"value"),data:we(e[6]),accessList:m1(e[7],"accessList")};return e.length===8||y1(t,e.slice(8)),t}function TK(n,e){const t=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.gasPrice||0,"gasPrice"),Ct(n.gasLimit,"gasLimit"),n.to||"0x",Ct(n.value,"value"),n.data,g1(n.accessList||[])];return e&&(t.push(Ct(e.yParity,"recoveryParam")),t.push(In(e.r)),t.push(In(e.s))),Ut(["0x01",_a(t)])}function NK(n){let e=tg(lt(n).slice(1)),t="3",r=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const i=e[1],o=e[2],a=e[3];V(Array.isArray(i),"invalid network format: blobs not an array","fields[1]",i),V(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),V(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),V(i.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),V(i.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),r=[];for(let l=0;l<e[1].length;l++)r.push({data:i[l],commitment:o[l],proof:a[l]});e=e[0]}V(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",we(n));const s={type:3,chainId:zt(e[0],"chainId"),nonce:Td(e[1],"nonce"),maxPriorityFeePerGas:zt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:zt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:zt(e[4],"gasLimit"),to:yg(e[5]),value:zt(e[6],"value"),data:we(e[7]),accessList:m1(e[8],"accessList"),maxFeePerBlobGas:zt(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};r&&(s.blobs=r),V(s.to!=null,`invalid address for transaction type: ${t}`,"data",n),V(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let i=0;i<s.blobVersionedHashes.length;i++)V(At(s.blobVersionedHashes[i],32),`invalid blobVersionedHash at index ${i}: must be length 32`,"data",n);return e.length===11||y1(s,e.slice(11)),s}function OK(n,e,t){const r=[Ct(n.chainId,"chainId"),Ct(n.nonce,"nonce"),Ct(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Ct(n.maxFeePerGas||0,"maxFeePerGas"),Ct(n.gasLimit,"gasLimit"),n.to||wd,Ct(n.value,"value"),n.data,g1(n.accessList||[]),Ct(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),xK(n.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(r.push(Ct(e.yParity,"yParity")),r.push(In(e.r)),r.push(In(e.s)),t)?Ut(["0x03",_a([r,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])]):Ut(["0x03",_a(r)])}const Pi=class Pi{constructor(){q(this,hu);q(this,Ws);q(this,nu);q(this,ru);q(this,su);q(this,iu);q(this,ou);q(this,au);q(this,lu);q(this,cu);q(this,uu);q(this,fu);q(this,du);q(this,ll);q(this,Ro);q(this,Di);q(this,Mo);I(this,Ws,null),I(this,nu,null),I(this,su,0),I(this,iu,un),I(this,ou,null),I(this,au,null),I(this,lu,null),I(this,ru,"0x"),I(this,cu,un),I(this,uu,un),I(this,fu,null),I(this,du,null),I(this,ll,null),I(this,Ro,null),I(this,Mo,null),I(this,Di,null)}get type(){return T(this,Ws)}set type(e){switch(e){case null:I(this,Ws,null);break;case 0:case"legacy":I(this,Ws,0);break;case 1:case"berlin":case"eip-2930":I(this,Ws,1);break;case 2:case"london":case"eip-1559":I(this,Ws,2);break;case 3:case"cancun":case"eip-4844":I(this,Ws,3);break;default:V(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=T(this,nu);return e==null&&this.type===3?wd:e}set to(e){I(this,nu,e==null?null:dt(e))}get nonce(){return T(this,su)}set nonce(e){I(this,su,Je(e,"value"))}get gasLimit(){return T(this,iu)}set gasLimit(e){I(this,iu,Ae(e))}get gasPrice(){const e=T(this,ou);return e==null&&(this.type===0||this.type===1)?un:e}set gasPrice(e){I(this,ou,e==null?null:Ae(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=T(this,au);return e??(this.type===2||this.type===3?un:null)}set maxPriorityFeePerGas(e){I(this,au,e==null?null:Ae(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=T(this,lu);return e??(this.type===2||this.type===3?un:null)}set maxFeePerGas(e){I(this,lu,e==null?null:Ae(e,"maxFeePerGas"))}get data(){return T(this,ru)}set data(e){I(this,ru,we(e))}get value(){return T(this,cu)}set value(e){I(this,cu,Ae(e,"value"))}get chainId(){return T(this,uu)}set chainId(e){I(this,uu,Ae(e))}get signature(){return T(this,fu)||null}set signature(e){I(this,fu,e==null?null:as.from(e))}get accessList(){const e=T(this,du)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){I(this,du,e==null?null:Co(e))}get maxFeePerBlobGas(){const e=T(this,ll);return e==null&&this.type===3?un:e}set maxFeePerBlobGas(e){I(this,ll,e==null?null:Ae(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=T(this,Ro);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){V(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)V(At(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}I(this,Ro,e)}get blobs(){return T(this,Mo)==null?null:T(this,Mo).map(e=>Object.assign({},e))}set blobs(e){if(e==null){I(this,Mo,null);return}const t=[],r=[];for(let s=0;s<e.length;s++){const i=e[s];if(Mv(i)){ee(T(this,Di),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=lt(i);if(V(o.length<=p1,"blob is too large",`blobs[${s}]`,i),o.length!==p1){const c=new Uint8Array(p1);c.set(o),o=c}const a=T(this,Di).blobToKzgCommitment(o),l=we(T(this,Di).computeBlobKzgProof(o,a));t.push({data:we(o),commitment:we(a),proof:l}),r.push(UM(1,a))}else{const o=we(i.commitment);t.push({data:we(i.data),commitment:o,proof:we(i.proof)}),r.push(UM(1,o))}}I(this,Mo,t),I(this,Ro,r)}get kzg(){return T(this,Di)}set kzg(e){I(this,Di,e)}get hash(){return this.signature==null?null:Jt(fe(this,hu,Xg).call(this,!0,!1))}get unsignedHash(){return Jt(this.unsignedSerialized)}get from(){return this.signature==null?null:mK(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:vd.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return fe(this,hu,Xg).call(this,!0,!0)}get unsignedSerialized(){return fe(this,hu,Xg).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,s=T(this,ll)!=null||T(this,Ro);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&ee(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),ee(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),ee(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):t?i.push(2):e?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(s&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return Pi.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new Pi;if(typeof e=="string"){const r=lt(e);if(r[0]>=127)return Pi.from(AK(r));switch(r[0]){case 1:return Pi.from(SK(r));case 2:return Pi.from(kK(r));case 3:return Pi.from(NK(r))}ee(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new Pi;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=as.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),V(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(V(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),V(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Ws=new WeakMap,nu=new WeakMap,ru=new WeakMap,su=new WeakMap,iu=new WeakMap,ou=new WeakMap,au=new WeakMap,lu=new WeakMap,cu=new WeakMap,uu=new WeakMap,fu=new WeakMap,du=new WeakMap,ll=new WeakMap,Ro=new WeakMap,Di=new WeakMap,Mo=new WeakMap,hu=new WeakSet,Xg=function(e,t){ee(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=e?this.signature:null;switch(this.inferType()){case 0:return EK(this,r);case 1:return TK(this,r);case 2:return CK(this,r);case 3:return OK(this,r,t?this.blobs:null)}ee(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let Nd=Pi;const HM=new Uint8Array(32);HM.fill(0);const RK=BigInt(-1),zM=BigInt(0),VM=BigInt(1),MK=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function DK(n){const e=lt(n),t=e.length%32;return t?Ut([e,HM.slice(t)]):we(e)}const PK=bo(VM,32),IK=bo(zM,32),$M={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},b1=["name","version","chainId","verifyingContract","salt"];function WM(n){return function(e){return V(typeof e=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,e),e}}const LK={name:WM("name"),version:WM("version"),chainId:function(n){const e=Ae(n,"domain.chainId");return V(e>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(e)?Number(e):La(e)},verifyingContract:function(n){try{return dt(n).toLowerCase()}catch{}V(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const e=lt(n,"domain.salt");return V(e.length===32,'invalid domain value "salt"',"domain.salt",n),we(e)}};function w1(n){{const e=n.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",r=parseInt(e[2]);V(r%8===0&&r!==0&&r<=256&&e[2]===String(r),"invalid numeric width","type",n);const s=pd(MK,t?r-1:r),i=t?(s+VM)*RK:zM;return function(o){const a=Ae(o,"value");return V(a>=i&&a<=s,`value out-of-bounds for ${n}`,"value",a),bo(t?JO(a,256):a,32)}}}{const e=n.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return V(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",n),function(r){const s=lt(r);return V(s.length===t,`invalid length for ${n}`,"value",r),DK(r)}}}switch(n){case"address":return function(e){return Ia(dt(e),32)};case"bool":return function(e){return e?PK:IK};case"bytes":return function(e){return Jt(e)};case"string":return function(e){return Ha(e)}}return null}function GM(n,e){return`${n}(${e.map(({name:t,type:r})=>r+" "+t).join(",")})`}function bg(n){const e=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:n}}const Fr=class Fr{constructor(e){q(this,Wg);$(this,"primaryType");q(this,Hd);q(this,Ii);q(this,pu);I(this,Ii,new Map),I(this,pu,new Map);const t=new Map,r=new Map,s=new Map,i={};Object.keys(e).forEach(l=>{i[l]=e[l].map(({name:c,type:u})=>{let{base:f,index:d}=bg(u);return f==="int"&&!e.int&&(f="int256"),f==="uint"&&!e.uint&&(f="uint256"),{name:c,type:f+(d||"")}}),t.set(l,new Set),r.set(l,[]),s.set(l,new Set)}),I(this,Hd,JSON.stringify(i));for(const l in i){const c=new Set;for(const u of i[l]){V(!c.has(u.name),`duplicate variable name ${JSON.stringify(u.name)} in ${JSON.stringify(l)}`,"types",e),c.add(u.name);const f=bg(u.type).base;V(f!==l,`circular type reference to ${JSON.stringify(f)}`,"types",e),!w1(f)&&(V(r.has(f),`unknown type ${JSON.stringify(f)}`,"types",e),r.get(f).push(l),t.get(l).add(f))}}const o=Array.from(r.keys()).filter(l=>r.get(l).length===0);V(o.length!==0,"missing primary type","types",e),V(o.length===1,`ambiguous primary types or unused types: ${o.map(l=>JSON.stringify(l)).join(", ")}`,"types",e),Oe(this,{primaryType:o[0]});function a(l,c){V(!c.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",e),c.add(l);for(const u of t.get(l))if(r.has(u)){a(u,c);for(const f of c)s.get(f).add(u)}c.delete(l)}a(this.primaryType,new Set);for(const[l,c]of s){const u=Array.from(c);u.sort(),T(this,Ii).set(l,GM(l,i[l])+u.map(f=>GM(f,i[f])).join(""))}}get types(){return JSON.parse(T(this,Hd))}getEncoder(e){let t=T(this,pu).get(e);return t||(t=fe(this,Wg,tP).call(this,e),T(this,pu).set(e,t)),t}encodeType(e){const t=T(this,Ii).get(e);return V(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Jt(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(w1(e))return r(e,t);const s=bg(e).array;if(s)return V(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(o=>this._visit(s.prefix,o,r));const i=this.types[e];if(i)return i.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,t[a],r),o),{});V(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Fr(e)}static getPrimaryType(e){return Fr.from(e).primaryType}static hashStruct(e,t,r){return Fr.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){if(e[r]==null)continue;const s=$M[r];V(s,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:s})}return t.sort((r,s)=>b1.indexOf(r.name)-b1.indexOf(s.name)),Fr.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return Ut(["0x1901",Fr.hashDomain(e),Fr.from(t).hash(r)])}static hash(e,t,r){return Jt(Fr.encode(e,t,r))}static async resolveNames(e,t,r,s){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const i={};e.verifyingContract&&!At(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=Fr.from(t);o.visit(r,(a,l)=>(a==="address"&&!At(l,20)&&(i[l]="0x"),l));for(const a in i)i[a]=await s(a);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),r=o.visit(r,(a,l)=>a==="address"&&i[l]?i[l]:l),{domain:e,value:r}}static getPayload(e,t,r){Fr.hashDomain(e);const s={},i=[];b1.forEach(l=>{const c=e[l];c!=null&&(s[l]=LK[l](c),i.push({name:l,type:$M[l]}))});const o=Fr.from(t);t=o.types;const a=Object.assign({},t);return V(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=i,o.encode(r),{types:a,domain:s,primaryType:o.primaryType,message:o.visit(r,(l,c)=>{if(l.match(/^bytes(\d*)/))return we(lt(c));if(l.match(/^u?int/))return Ae(c).toString();switch(l){case"address":return c.toLowerCase();case"bool":return!!c;case"string":return V(typeof c=="string","invalid string","value",c),c}V(!1,"unsupported type","type",l)})}}};Hd=new WeakMap,Ii=new WeakMap,pu=new WeakMap,Wg=new WeakSet,tP=function(e){{const s=w1(e);if(s)return s}const t=bg(e).array;if(t){const s=t.prefix,i=this.getEncoder(s);return o=>{V(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(i);return T(this,Ii).has(s)&&(a=a.map(Jt)),Jt(Ut(a))}}const r=this.types[e];if(r){const s=Ha(T(this,Ii).get(e));return i=>{const o=r.map(({name:a,type:l})=>{const c=this.getEncoder(l)(i[a]);return T(this,Ii).has(l)?Jt(c):c});return o.unshift(s),Ut(o)}}V(!1,`unknown type: ${e}`,"type",e)};let wg=Fr;function Fn(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const _K=Fn("external public payable override".split(" ")),KM="constant external internal payable private public pure view override",BK=Fn(KM.split(" ")),JM="constructor error event fallback function receive struct",qM=Fn(JM.split(" ")),QM="calldata memory storage payable indexed",FK=Fn(QM.split(" ")),jK=[JM,QM,"tuple returns",KM].join(" "),UK=Fn(jK.split(" ")),HK={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},zK=new RegExp("^(\\s*)"),VK=new RegExp("^([0-9]+)"),$K=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),YM=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),XM=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),Gg=class Gg{constructor(e){q(this,zd);q(this,bn);q(this,hs);I(this,bn,0),I(this,hs,e.slice())}get offset(){return T(this,bn)}get length(){return T(this,hs).length-T(this,bn)}clone(){return new Gg(T(this,hs))}reset(){I(this,bn,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=fe(this,zd,rx).call(this,T(this,bn)+1,e.match+1);return I(this,bn,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;T(this,bn)<e.match-1;){const r=this.peek().linkNext;t.push(fe(this,zd,rx).call(this,T(this,bn)+1,r)),I(this,bn,r)}return I(this,bn,e.match+1),t}peek(){if(T(this,bn)>=T(this,hs).length)throw new Error("out-of-bounds");return T(this,hs)[T(this,bn)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Zd(this,bn)._++,e}toString(){const e=[];for(let t=T(this,bn);t<T(this,hs).length;t++){const r=T(this,hs)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};bn=new WeakMap,hs=new WeakMap,zd=new WeakSet,rx=function(e=0,t=0){return new Gg(T(this,hs).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};let ls=Gg;function So(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(zK);a&&(i+=a[1].length,o=n.substring(i));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(l);let c=HK[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,c==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(c=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),l.match=r.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1;else if(c==="COMMA")l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(c==="OPEN_BRACKET")l.type="BRACKET";else if(c==="CLOSE_BRACKET"){let u=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const f=e.pop().text;u=f+u,e[e.length-1].value=Je(f)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=u}continue}if(a=o.match($K),a){if(l.text=a[1],i+=l.text.length,UK.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(XM)){l.type="TYPE";continue}l.type="ID";continue}if(a=o.match(VK),a){l.text=a[1],l.type="NUMBER",i+=l.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new ls(e.map(o=>Object.freeze(o)))}function ZM(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function vg(n,e){if(e.peekKeyword(qM)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function Ai(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function eD(n){let e=Ai(n,BK);return ZM(e,Fn("constant payable nonpayable".split(" "))),ZM(e,Fn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function Ei(n,e){return n.popParams().map(t=>gn.from(t,e))}function tD(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Ae(n.pop().text);throw new Error("invalid gas")}return null}function $a(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const WK=new RegExp(/^(.*)\[([0-9]*)\]$/);function nD(n){const e=n.match(XM);if(V(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);V(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);V(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const Pt={},Xn=Symbol.for("_ethers_internal"),rD="_ParamTypeInternal",sD="_ErrorInternal",iD="_EventInternal",oD="_ConstructorInternal",aD="_FallbackInternal",lD="_FunctionInternal",cD="_StructInternal",jr=class jr{constructor(e,t,r,s,i,o,a,l){q(this,mu);$(this,"name");$(this,"type");$(this,"baseType");$(this,"indexed");$(this,"components");$(this,"arrayLength");$(this,"arrayChildren");if(Qm(e,Pt,"ParamType"),Object.defineProperty(this,Xn,{value:rD}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||l==null)throw new Error("")}else if(a!=null||l!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");Oe(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:l})}format(e){if(e==null&&(e="sighash"),e==="json"){const r=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=r,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return fe(this,mu,Zg).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(jr.isParamType(e))return e;if(typeof e=="string")try{return jr.from(So(e),t)}catch{V(!1,"invalid param type","obj",e)}else if(e instanceof ls){let a="",l="",c=null;Ai(e,Fn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(l="tuple",c=e.popParams().map(m=>jr.from(m)),a=`tuple(${c.map(m=>m.format()).join(",")})`):(a=nD(e.popType("TYPE")),l=a);let u=null,f=null;for(;e.length&&e.peekType("BRACKET");){const m=e.pop();u=new jr(Pt,"",a,l,null,c,f,u),f=m.value,a+=m.text,l="array",c=null}let d=null;if(Ai(e,FK).has("indexed")){if(!t)throw new Error("");d=!0}const p=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new jr(Pt,p,a,l,d,c,f,u)}const r=e.name;V(!r||typeof r=="string"&&r.match(YM),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(V(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(WK);if(o){const a=parseInt(o[2]||"-1"),l=jr.from({type:o[1],components:e.components});return new jr(Pt,r||"",i,"array",s,null,a,l)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(c=>jr.from(c)):null;return new jr(Pt,r||"",i,"tuple",s,a,null,null)}return i=nD(e.type),new jr(Pt,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Xn]===rD}};mu=new WeakSet,Zg=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((l,c)=>{var u;fe(u=o,mu,Zg).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(l=>{if(!l.name)throw new Error("cannot use object value with unnamed components");if(!(l.name in t))throw new Error(`missing value for component ${l.name}`);return t[l.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((l,c)=>{var u;fe(u=o[c],mu,Zg).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};let gn=jr;class Wa{constructor(e,t,r){$(this,"type");$(this,"inputs");Qm(e,Pt,"Fragment"),r=Object.freeze(r.slice()),Oe(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{Wa.from(JSON.parse(e))}catch{}return Wa.from(So(e))}if(e instanceof ls)switch(e.peekKeyword(qM)){case"constructor":return ki.from(e);case"error":return Zn.from(e);case"event":return zs.from(e);case"fallback":case"receive":return Ci.from(e);case"function":return Vs.from(e);case"struct":return Ga.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return ki.from(e);case"error":return Zn.from(e);case"event":return zs.from(e);case"fallback":case"receive":return Ci.from(e);case"function":return Vs.from(e);case"struct":return Ga.from(e)}ee(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}V(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return ki.isFragment(e)}static isError(e){return Zn.isFragment(e)}static isEvent(e){return zs.isFragment(e)}static isFunction(e){return Vs.isFragment(e)}static isStruct(e){return Ga.isFragment(e)}}class xg extends Wa{constructor(t,r,s,i){super(t,r,i);$(this,"name");V(typeof s=="string"&&s.match(YM),"invalid identifier","name",s),i=Object.freeze(i.slice()),Oe(this,{name:s})}}function Od(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class Zn extends xg{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,Xn,{value:sD})}get selector(){return Ha(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+Od(e,this.inputs)),t.join(" ")}static from(e){if(Zn.isFragment(e))return e;if(typeof e=="string")return Zn.from(So(e));if(e instanceof ls){const t=vg("error",e),r=Ei(e);return $a(e),new Zn(Pt,t,r)}return new Zn(Pt,e.name,e.inputs?e.inputs.map(gn.from):[])}static isFragment(e){return e&&e[Xn]===sD}}class zs extends xg{constructor(t,r,s,i){super(t,"event",r,s);$(this,"anonymous");Object.defineProperty(this,Xn,{value:iD}),Oe(this,{anonymous:i})}get topicHash(){return Ha(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+Od(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>gn.from(i)),new zs(Pt,t,r,!1).topicHash}static from(t){if(zs.isFragment(t))return t;if(typeof t=="string")try{return zs.from(So(t))}catch{V(!1,"invalid event fragment","obj",t)}else if(t instanceof ls){const r=vg("event",t),s=Ei(t,!0),i=!!Ai(t,Fn(["anonymous"])).has("anonymous");return $a(t),new zs(Pt,r,s,i)}return new zs(Pt,t.name,t.inputs?t.inputs.map(r=>gn.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Xn]===iD}}class ki extends Wa{constructor(t,r,s,i,o){super(t,r,s);$(this,"payable");$(this,"gas");Object.defineProperty(this,Xn,{value:oD}),Oe(this,{payable:i,gas:o})}format(t){if(ee(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${Od(t,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(ki.isFragment(t))return t;if(typeof t=="string")try{return ki.from(So(t))}catch{V(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof ls){Ai(t,Fn(["constructor"]));const r=Ei(t),s=!!Ai(t,_K).has("payable"),i=tD(t);return $a(t),new ki(Pt,"constructor",r,s,i)}return new ki(Pt,"constructor",t.inputs?t.inputs.map(gn.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Xn]===oD}}class Ci extends Wa{constructor(t,r,s){super(t,"fallback",r);$(this,"payable");Object.defineProperty(this,Xn,{value:aD}),Oe(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(Ci.isFragment(t))return t;if(typeof t=="string")try{return Ci.from(So(t))}catch{V(!1,"invalid fallback fragment","obj",t)}else if(t instanceof ls){const r=t.toString(),s=t.peekKeyword(Fn(["fallback","receive"]));if(V(s,"type must be fallback or receive","obj",r),t.popKeyword(Fn(["fallback","receive"]))==="receive"){const l=Ei(t);return V(l.length===0,"receive cannot have arguments","obj.inputs",l),Ai(t,Fn(["payable"])),$a(t),new Ci(Pt,[],!0)}let o=Ei(t);o.length?V(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(l=>l.format("minimal")).join(", ")):o=[gn.from("bytes")];const a=eD(t);if(V(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),Ai(t,Fn(["returns"])).has("returns")){const l=Ei(t);V(l.length===1&&l[0].type==="bytes","invalid fallback outputs","obj.outputs",l.map(c=>c.format("minimal")).join(", "))}return $a(t),new Ci(Pt,o,a==="payable")}if(t.type==="receive")return new Ci(Pt,[],!0);if(t.type==="fallback"){const r=[gn.from("bytes")],s=t.stateMutability==="payable";return new Ci(Pt,r,s)}V(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Xn]===aD}}class Vs extends xg{constructor(t,r,s,i,o,a){super(t,"function",r,i);$(this,"constant");$(this,"outputs");$(this,"stateMutability");$(this,"payable");$(this,"gas");Object.defineProperty(this,Xn,{value:lD}),o=Object.freeze(o.slice()),Oe(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return Ha(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+Od(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(Od(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>gn.from(i)),new Vs(Pt,t,"view",r,[],null).selector}static from(t){if(Vs.isFragment(t))return t;if(typeof t=="string")try{return Vs.from(So(t))}catch{V(!1,"invalid function fragment","obj",t)}else if(t instanceof ls){const s=vg("function",t),i=Ei(t),o=eD(t);let a=[];Ai(t,Fn(["returns"])).has("returns")&&(a=Ei(t));const l=tD(t);return $a(t),new Vs(Pt,s,o,i,a,l)}let r=t.stateMutability;return r==null&&(r="payable",typeof t.constant=="boolean"?(r="view",t.constant||(r="payable",typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable")),new Vs(Pt,t.name,r,t.inputs?t.inputs.map(gn.from):[],t.outputs?t.outputs.map(gn.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Xn]===lD}}class Ga extends xg{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,Xn,{value:cD})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Ga.from(So(e))}catch{V(!1,"invalid struct fragment","obj",e)}else if(e instanceof ls){const t=vg("struct",e),r=Ei(e);return $a(e),new Ga(Pt,t,r)}return new Ga(Pt,e.name,e.inputs?e.inputs.map(gn.from):[])}static isFragment(e){return e&&e[Xn]===cD}}const cs=new Map;cs.set(0,"GENERIC_PANIC"),cs.set(1,"ASSERT_FALSE"),cs.set(17,"OVERFLOW"),cs.set(18,"DIVIDE_BY_ZERO"),cs.set(33,"ENUM_RANGE_ERROR"),cs.set(34,"BAD_STORAGE_DATA"),cs.set(49,"STACK_UNDERFLOW"),cs.set(50,"ARRAY_RANGE_ERROR"),cs.set(65,"OUT_OF_MEMORY"),cs.set(81,"UNINITIALIZED_FUNCTION_CALL");const GK=new RegExp(/^bytes([0-9]*)$/),KK=new RegExp(/^(u?int)([0-9]*)$/);let v1=null,uD=1024;function JK(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const c=lt(t);if(t=we(t),c.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(c.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(we(c.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],c.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(we(c.slice(0,4))==="0x4e487b71")try{const u=Number(r.decode(["uint256"],c.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[u]},i=`Panic due to ${cs.get(u)||"UNKNOWN"}(${u})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const l={to:e.to?dt(e.to):null,data:e.data||"0x"};return e.from&&(l.from=dt(e.from)),Nt(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:l,invocation:o,revert:a})}const Kg=class Kg{constructor(){q(this,Do)}getDefaultValue(e){const t=e.map(s=>fe(this,Do,Fu).call(this,gn.from(s)));return new cg(t,"_").defaultValue()}encode(e,t){$O(t.length,e.length,"types/values length mismatch");const r=e.map(o=>fe(this,Do,Fu).call(this,gn.from(o))),s=new cg(r,"_"),i=new _v;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>fe(this,Do,Fu).call(this,gn.from(o)));return new cg(s,"_").decode(new Bv(t,r,uD))}static _setDefaultMaxInflation(e){V(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),uD=e}static defaultAbiCoder(){return v1==null&&(v1=new Kg),v1}static getBuiltinCallException(e,t,r){return JK(e,t,r,Kg.defaultAbiCoder())}};Do=new WeakSet,Fu=function(e){if(e.isArray())return new wG(fe(this,Do,Fu).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new cg(e.components.map(r=>fe(this,Do,Fu).call(this,r)),e.name);switch(e.baseType){case"address":return new yG(e.name);case"bool":return new vG(e.name);case"string":return new OG(e.name);case"bytes":return new xG(e.name);case"":return new kG(e.name)}let t=e.type.match(KK);if(t){let r=parseInt(t[2]||"256");return V(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new NG(r/8,t[1]==="int",e.name)}if(t=e.type.match(GK),t){let r=parseInt(t[1]);return V(r!==0&&r<=32,"invalid bytes length","param",e),new AG(r,e.name)}V(!1,"invalid type","type",e.type)};let Bc=Kg;class qK{constructor(e,t,r){$(this,"fragment");$(this,"name");$(this,"signature");$(this,"topic");$(this,"args");const s=e.name,i=e.format();Oe(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class QK{constructor(e,t,r,s){$(this,"fragment");$(this,"name");$(this,"args");$(this,"signature");$(this,"selector");$(this,"value");const i=e.name,o=e.format();Oe(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class YK{constructor(e,t,r){$(this,"fragment");$(this,"name");$(this,"args");$(this,"signature");$(this,"selector");const s=e.name,i=e.format();Oe(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class fD{constructor(e){$(this,"hash");$(this,"_isIndexed");Oe(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const dD={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},hD={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&dD[n.toString()]&&(e=dD[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}},cl=class cl{constructor(e){q(this,qs);$(this,"fragments");$(this,"deploy");$(this,"fallback");$(this,"receive");q(this,Gs);q(this,Ks);q(this,Js);q(this,kn);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,I(this,Js,new Map),I(this,Gs,new Map),I(this,Ks,new Map);const r=[];for(const o of t)try{r.push(Wa.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}Oe(this,{fragments:Object.freeze(r)});let s=null,i=!1;I(this,kn,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let l;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}Oe(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(V(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":l=T(this,Js);break;case"event":l=T(this,Ks);break;case"error":l=T(this,Gs);break;default:return}const c=o.format();l.has(c)||l.set(c,o)}),this.deploy||Oe(this,{deploy:ki.from("constructor()")}),Oe(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Bc.defaultAbiCoder()}getFunctionName(e){const t=fe(this,qs,ey).call(this,e,null,!1);return V(t,"no matching function","key",e),t.name}hasFunction(e){return!!fe(this,qs,ey).call(this,e,null,!1)}getFunction(e,t){return fe(this,qs,ey).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(T(this,Js).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Js).get(s),r)}}getEventName(e){const t=fe(this,qs,ty).call(this,e,null,!1);return V(t,"no matching event","key",e),t.name}hasEvent(e){return!!fe(this,qs,ty).call(this,e,null,!1)}getEvent(e,t){return fe(this,qs,ty).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(T(this,Ks).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Ks).get(s),r)}}getError(e,t){if(At(e)){const s=e.toLowerCase();if(hD[s])return Zn.from(hD[s].signature);for(const i of T(this,Gs).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of T(this,Gs))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?Zn.from("error Error(string)"):e==="Panic"?Zn.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");V(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=Zn.from(e).format(),e==="Error(string)")return Zn.from("error Error(string)");if(e==="Panic(uint256)")return Zn.from("error Panic(uint256)");const r=T(this,Gs).get(e);return r||null}forEachError(e){const t=Array.from(T(this,Gs).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(T(this,Gs).get(s),r)}}_decodeParams(e,t){return T(this,kn).decode(e,t)}_encodeParams(e,t){return T(this,kn).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);V(r,"unknown error","fragment",e),e=r}return V(Ft(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Ft(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);V(r,"unknown error","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return V(Ft(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Ft(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);V(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Pn(t);if(s.length%32===0)try{return T(this,kn).decode(e.outputs,s)}catch{r="could not decode result data"}ee(!1,r,"BAD_DATA",{value:we(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=lt(e,"data"),s=Bc.getBuiltinCallException("call",t,r);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=we(r.slice(0,4)),l=this.getError(a);if(l)try{const c=T(this,kn).decode(l.inputs,r.slice(4));s.revert={name:l.name,signature:l.format(),args:c},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);V(r,"unknown function","fragment",e),e=r}return we(T(this,kn).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);V(i,"unknown event","eventFragment",e),e=i}ee(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?Ha(o):i.type==="bytes"?Jt(we(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=bo(o):i.type.match(/^bytes/)?o=MW(o,32):i.type==="address"&&T(this,kn).encode(["address"],[o]),Ia(we(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){V(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?V(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(l=>s(a,l))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);V(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),V(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const l=t[a];if(o.indexed)if(o.type==="string")r.push(Ha(l));else if(o.type==="bytes")r.push(Jt(l));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(T(this,kn).encode([o.type],[l]))}else s.push(o),i.push(l)}),{data:T(this,kn).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const h=this.getEvent(e);V(h,"unknown event","eventFragment",e),e=h}if(r!=null&&!e.anonymous){const h=e.topicHash;V(At(r[0],32)&&r[0].toLowerCase()===h,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((h,p)=>{h.indexed?h.type==="string"||h.type==="bytes"||h.baseType==="tuple"||h.baseType==="array"?(s.push(gn.from({type:"bytes32",name:h.name})),o.push(!0)):(s.push(h),o.push(!1)):(i.push(h),o.push(!1))});const a=r!=null?T(this,kn).decode(s,Ut(r)):null,l=T(this,kn).decode(i,t,!0),c=[],u=[];let f=0,d=0;return e.inputs.forEach((h,p)=>{let m=null;if(h.indexed)if(a==null)m=new fD(null);else if(o[p])m=new fD(a[d++]);else try{m=a[d++]}catch(y){m=y}else try{m=l[f++]}catch(y){m=y}c.push(m),u.push(h.name||null)}),Sc.fromItems(c,u)}parseTransaction(e){const t=lt(e.data,"tx.data"),r=Ae(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(we(t.slice(0,4)));if(!s)return null;const i=T(this,kn).decode(s.inputs,t.slice(4));return new QK(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new qK(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=we(e),r=this.getError(Ft(t,0,4));if(!r)return null;const s=T(this,kn).decode(r.inputs,Ft(t,4));return new YK(r,r.selector,s)}static from(e){return e instanceof cl?e:typeof e=="string"?new cl(JSON.parse(e)):typeof e.formatJson=="function"?new cl(e.formatJson()):typeof e.format=="function"?new cl(e.format("json")):new cl(e)}};Gs=new WeakMap,Ks=new WeakMap,Js=new WeakMap,kn=new WeakMap,qs=new WeakSet,ey=function(e,t,r){if(At(e)){const i=e.toLowerCase();for(const o of T(this,Js).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of T(this,Js))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,l=!0;En.isTyped(o)&&o.type==="overrides"&&(l=!1,a--);for(let c=i.length-1;c>=0;c--){const u=i[c].inputs.length;u!==a&&(!l||u!==a-1)&&i.splice(c,1)}for(let c=i.length-1;c>=0;c--){const u=i[c].inputs;for(let f=0;f<t.length;f++)if(En.isTyped(t[f])){if(f>=u.length){if(t[f].type==="overrides")continue;i.splice(c,1);break}if(t[f].type!==u[f].baseType){i.splice(c,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=T(this,Js).get(Vs.from(e).format());return s||null},ty=function(e,t,r){if(At(e)){const i=e.toLowerCase();for(const o of T(this,Ks).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of T(this,Ks))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let l=0;l<t.length;l++)if(En.isTyped(t[l])&&t[l].type!==a[l].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");V(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=T(this,Ks).get(zs.from(e).format());return s||null};let x1=cl;const pD=BigInt(0);function Fc(n){return n??null}function Vt(n){return n==null?null:n.toString()}class mD{constructor(e,t,r){$(this,"gasPrice");$(this,"maxFeePerGas");$(this,"maxPriorityFeePerGas");Oe(this,{gasPrice:Fc(e),maxFeePerGas:Fc(t),maxPriorityFeePerGas:Fc(r)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Vt(e),maxFeePerGas:Vt(t),maxPriorityFeePerGas:Vt(r)}}}function Ag(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=we(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=Ae(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=Je(n[s],`request.${s}`));return n.accessList&&(e.accessList=Co(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(e.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(e.kzg=n.kzg),"blobs"in n&&n.blobs&&(e.blobs=n.blobs.map(s=>Mv(s)?we(s):Object.assign({},s))),e}class XK{constructor(e,t){$(this,"provider");$(this,"number");$(this,"hash");$(this,"timestamp");$(this,"parentHash");$(this,"parentBeaconBlockRoot");$(this,"nonce");$(this,"difficulty");$(this,"gasLimit");$(this,"gasUsed");$(this,"stateRoot");$(this,"receiptsRoot");$(this,"blobGasUsed");$(this,"excessBlobGas");$(this,"miner");$(this,"prevRandao");$(this,"extraData");$(this,"baseFeePerGas");q(this,Li);I(this,Li,e.transactions.map(r=>typeof r!="string"?new Md(r,t):r)),Oe(this,{provider:t,hash:Fc(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:Fc(e.prevRandao),extraData:e.extraData,baseFeePerGas:Fc(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return T(this,Li).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=T(this,Li).slice();return e.length===0?[]:(ee(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:r,gasLimit:s,gasUsed:i,hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,timestamp:m,transactions:y}=this;return{_type:"Block",baseFeePerGas:Vt(e),difficulty:Vt(t),extraData:r,gasLimit:Vt(s),gasUsed:Vt(i),blobGasUsed:Vt(this.blobGasUsed),excessBlobGas:Vt(this.excessBlobGas),hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,timestamp:m,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,transactions:y}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return T(this,Li).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=T(this,Li)[e];else{const r=e.toLowerCase();for(const s of T(this,Li))if(typeof s=="string"){if(s!==r)continue;t=s;break}else{if(s.hash===r)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const r of t)if(r.hash===e)return r;V(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return ZK(this)}}Li=new WeakMap;class Rd{constructor(e,t){$(this,"provider");$(this,"transactionHash");$(this,"blockHash");$(this,"blockNumber");$(this,"removed");$(this,"address");$(this,"data");$(this,"topics");$(this,"index");$(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());Oe(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return ee(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return ee(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return ee(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return eJ(this)}}class gD{constructor(e,t){$(this,"provider");$(this,"to");$(this,"from");$(this,"contractAddress");$(this,"hash");$(this,"index");$(this,"blockHash");$(this,"blockNumber");$(this,"logsBloom");$(this,"gasUsed");$(this,"blobGasUsed");$(this,"cumulativeGasUsed");$(this,"gasPrice");$(this,"blobGasPrice");$(this,"type");$(this,"status");$(this,"root");q(this,Vd);I(this,Vd,Object.freeze(e.logs.map(s=>new Rd(s,t))));let r=pD;e.effectiveGasPrice!=null?r=e.effectiveGasPrice:e.gasPrice!=null&&(r=e.gasPrice),Oe(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:r,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return T(this,Vd)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:l,logs:c,status:u,root:f}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:Vt(this.cumulativeGasUsed),from:t,gasPrice:Vt(this.gasPrice),blobGasUsed:Vt(this.blobGasUsed),blobGasPrice:Vt(this.blobGasPrice),gasUsed:Vt(this.gasUsed),hash:s,index:i,logs:c,logsBloom:l,root:f,status:u,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return bD(this)}reorderedEvent(e){return ee(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),yD(this,e)}}Vd=new WeakMap;const J1=class J1{constructor(e,t){$(this,"provider");$(this,"blockNumber");$(this,"blockHash");$(this,"index");$(this,"hash");$(this,"type");$(this,"to");$(this,"from");$(this,"nonce");$(this,"gasLimit");$(this,"gasPrice");$(this,"maxPriorityFeePerGas");$(this,"maxFeePerGas");$(this,"maxFeePerBlobGas");$(this,"data");$(this,"value");$(this,"chainId");$(this,"signature");$(this,"accessList");$(this,"blobVersionedHashes");q(this,Po);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,I(this,Po,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:l,data:c,signature:u,accessList:f,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:f,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:Vt(this.chainId),data:c,from:a,gasLimit:Vt(this.gasLimit),gasPrice:Vt(this.gasPrice),hash:s,maxFeePerGas:Vt(this.maxFeePerGas),maxPriorityFeePerGas:Vt(this.maxPriorityFeePerGas),maxFeePerBlobGas:Vt(this.maxFeePerBlobGas),nonce:l,signature:u,to:o,index:r,type:i,value:Vt(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:r}=await An({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:r-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const r=e??1,s=t??0;let i=T(this,Po),o=-1,a=i===-1;const l=async()=>{if(a)return null;const{blockNumber:d,nonce:h}=await An({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(h<this.nonce){i=d;return}if(a)return null;const p=await this.getTransaction();if(!(p&&p.blockNumber!=null))for(o===-1&&(o=i-3,o<T(this,Po)&&(o=T(this,Po)));o<=d;){if(a)return null;const m=await this.provider.getBlock(o,!0);if(m==null)return;for(const y of m)if(y===this.hash)return;for(let y=0;y<m.length;y++){const b=await m.getTransaction(y);if(b.from===this.from&&b.nonce===this.nonce){if(a)return null;const x=await this.provider.getTransactionReceipt(b.hash);if(x==null||d-x.blockNumber+1<r)return;let v="replaced";b.data===this.data&&b.to===this.to&&b.value===this.value?v="repriced":b.data==="0x"&&b.from===b.to&&b.value===pD&&(v="cancelled"),ee(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:v==="replaced"||v==="cancelled",reason:v,replacement:b.replaceableTransaction(i),hash:b.hash,receipt:x})}}o++}},c=d=>{if(d==null||d.status!==0)return d;ee(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},u=await this.provider.getTransactionReceipt(this.hash);if(r===0)return c(u);if(u){if(await u.confirmations()>=r)return c(u)}else if(await l(),r===0)return null;return await new Promise((d,h)=>{const p=[],m=()=>{p.forEach(b=>b())};if(p.push(()=>{a=!0}),s>0){const b=setTimeout(()=>{m(),h(Nt("wait for transaction timeout","TIMEOUT"))},s);p.push(()=>{clearTimeout(b)})}const y=async b=>{if(await b.confirmations()>=r){m();try{d(c(b))}catch(x){h(x)}}};if(p.push(()=>{this.provider.off(this.hash,y)}),this.provider.on(this.hash,y),i>=0){const b=async()=>{try{await l()}catch(x){if(ln(x,"TRANSACTION_REPLACED")){m(),h(x);return}}a||this.provider.once("block",b)};p.push(()=>{this.provider.off("block",b)}),this.provider.once("block",b)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return ee(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),bD(this)}reorderedEvent(e){return ee(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ee(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),yD(this,e)}replaceableTransaction(e){V(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new J1(this,this.provider);return I(t,Po,e),t}};Po=new WeakMap;let Md=J1;function ZK(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function yD(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function bD(n){return{orphan:"drop-transaction",tx:n}}function eJ(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class A1 extends Rd{constructor(t,r,s){super(t,t.provider);$(this,"interface");$(this,"fragment");$(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);Oe(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class wD extends Rd{constructor(t,r){super(t,t.provider);$(this,"error");Oe(this,{error:r})}}class tJ extends gD{constructor(t,r,s){super(s,r);q(this,gu);I(this,gu,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?T(this,gu).getEvent(t.topics[0]):null;if(r)try{return new A1(t,T(this,gu),r)}catch(s){return new wD(t,s)}return t})}}gu=new WeakMap;class E1 extends Md{constructor(t,r,s){super(s,r);q(this,$d);I(this,$d,t)}async wait(t,r){const s=await super.wait(t,r);return s==null?null:new tJ(T(this,$d),this.provider,s)}}$d=new WeakMap;class vD extends XO{constructor(t,r,s,i){super(t,r,s);$(this,"log");Oe(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class nJ extends vD{constructor(e,t,r,s,i){super(e,t,r,new A1(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);Oe(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const xD=BigInt(0);function AD(n){return n&&typeof n.call=="function"}function ED(n){return n&&typeof n.estimateGas=="function"}function Eg(n){return n&&typeof n.resolveName=="function"}function kD(n){return n&&typeof n.sendTransaction=="function"}function CD(n){if(n!=null){if(Eg(n))return n;if(n.provider)return n.provider}}class rJ{constructor(e,t,r){q(this,Wd);$(this,"fragment");if(Oe(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=Ka(e.runner,"resolveName"),i=Eg(s)?s:null;I(this,Wd,async function(){const o=await Promise.all(t.inputs.map((a,l)=>r[l]==null?null:a.walkAsync(r[l],(u,f)=>u==="address"?Array.isArray(f)?Promise.all(f.map(d=>Bn(d,i))):Bn(f,i):f)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return T(this,Wd)}}Wd=new WeakMap;function Ka(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function Ja(n){return n==null?null:n.provider||null}async function SD(n,e){const t=En.dereference(n,"overrides");V(typeof t=="object","invalid overrides parameter","overrides",n);const r=Ag(t);return V(r.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),V(r.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function sJ(n,e,t){const r=Ka(n,"resolveName"),s=Eg(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,l)=>(l=En.dereference(l,a),a==="address"?Bn(l,s):l))))}function iJ(n){const e=async function(o){const a=await SD(o,["data"]);a.to=await n.getAddress(),a.from&&(a.from=await Bn(a.from,CD(n.runner)));const l=n.interface,c=Ae(a.value||xD,"overrides.value")===xD,u=(a.data||"0x")==="0x";l.fallback&&!l.fallback.payable&&l.receive&&!u&&!c&&V(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),V(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data);const f=l.receive||l.fallback&&l.fallback.payable;return V(f||c,"cannot send value to non-payable fallback","overrides.value",a.value),V(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=Ka(n.runner,"call");ee(AD(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const l=await e(o);try{return await a.call(l)}catch(c){throw Rv(c)&&c.data?n.interface.makeError(c.data,l):c}},r=async function(o){const a=n.runner;ee(kD(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const l=await a.sendTransaction(await e(o)),c=Ja(n.runner);return new E1(n.interface,c,l)},s=async function(o){const a=Ka(n.runner,"estimateGas");return ee(ED(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},i=async o=>await r(o);return Oe(i,{_contract:n,estimateGas:s,populateTransaction:e,send:r,staticCall:t}),i}function oJ(n,e){const t=function(...c){const u=n.interface.getFunction(e,c);return ee(u,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:c}}),u},r=async function(...c){const u=t(...c);let f={};if(u.inputs.length+1===c.length&&(f=await SD(c.pop()),f.from&&(f.from=await Bn(f.from,CD(n.runner)))),u.inputs.length!==c.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await sJ(n.runner,u.inputs,c);return Object.assign({},f,await An({to:n.getAddress(),data:n.interface.encodeFunctionData(u,d)}))},s=async function(...c){const u=await a(...c);return u.length===1?u[0]:u},i=async function(...c){const u=n.runner;ee(kD(u),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const f=await u.sendTransaction(await r(...c)),d=Ja(n.runner);return new E1(n.interface,d,f)},o=async function(...c){const u=Ka(n.runner,"estimateGas");return ee(ED(u),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await u.estimateGas(await r(...c))},a=async function(...c){const u=Ka(n.runner,"call");ee(AD(u),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const f=await r(...c);let d="0x";try{d=await u.call(f)}catch(p){throw Rv(p)&&p.data?n.interface.makeError(p.data,f):p}const h=t(...c);return n.interface.decodeFunctionResult(h,d)},l=async(...c)=>t(...c).constant?await s(...c):await i(...c);return Oe(l,{name:n.interface.getFunctionName(e),_contract:n,_key:e,getFragment:t,estimateGas:o,populateTransaction:r,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(l,"fragment",{configurable:!1,enumerable:!0,get:()=>{const c=n.interface.getFunction(e);return ee(c,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),c}}),l}function aJ(n,e){const t=function(...s){const i=n.interface.getEvent(e,s);return ee(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),i},r=function(...s){return new rJ(n,t(...s),s)};return Oe(r,{name:n.interface.getEventName(e),_contract:n,_key:e,getFragment:t}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=n.interface.getEvent(e);return ee(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),r}const kg=Symbol.for("_ethersInternal_contract"),TD=new WeakMap;function lJ(n,e){TD.set(n[kg],e)}function br(n){return TD.get(n[kg])}function cJ(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function k1(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(At(o,32))return o;const a=n.interface.getEvent(o);return V(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?At(e,32)?t=[e]:(r=n.interface.getEvent(e),V(r,"unknown fragment","event",e),t=[r.topicHash]):cJ(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):V(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function Dd(n,e){const{subs:t}=br(n);return t.get((await k1(n,e)).tag)||null}async function ND(n,e,t){const r=Ja(n.runner);ee(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await k1(n,t),{addr:a,subs:l}=br(n);let c=l.get(i);if(!c){const f={address:a||n,topics:o},d=y=>{let b=s;if(b==null)try{b=n.interface.getEvent(y.topics[0])}catch{}if(b){const x=b,v=s?n.interface.decodeEventLog(s,y.data,y.topics):[];S1(n,t,v,w=>new nJ(n,w,t,x,y))}else S1(n,t,[],x=>new vD(n,x,t,y))};let h=[];c={tag:i,listeners:[],start:()=>{h.length||h.push(r.on(f,d))},stop:async()=>{if(h.length==0)return;let y=h;h=[],await Promise.all(y),r.off(f,d)}},l.set(i,c)}return c}let C1=Promise.resolve();async function uJ(n,e,t,r){await C1;const s=await Dd(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const l=Array.from(t);r&&l.push(r(a?null:o));try{o.call(n,...l)}catch{}return!a}),s.listeners.length===0&&(s.stop(),br(n).subs.delete(s.tag)),i>0}async function S1(n,e,t,r){try{await C1}catch{}const s=uJ(n,e,t,r);return C1=s,await s}const Cg=["then"];qD=kg;const Gd=class Gd{constructor(e,t,r,s){$(this,"target");$(this,"interface");$(this,"runner");$(this,"filters");$(this,qD);$(this,"fallback");V(typeof e=="string"||lM(e),"invalid value for Contract target","target",e),r==null&&(r=null);const i=x1.from(t);Oe(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,kg,{value:{}});let o,a=null,l=null;if(s){const f=Ja(r);l=new E1(this.interface,f,s)}let c=new Map;if(typeof e=="string")if(At(e))a=e,o=Promise.resolve(e);else{const f=Ka(r,"resolveName");if(!Eg(f))throw Nt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=f.resolveName(e).then(d=>{if(d==null)throw Nt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return br(this).addr=d,d})}else o=e.getAddress().then(f=>{if(f==null)throw new Error("TODO");return br(this).addr=f,f});lJ(this,{addrPromise:o,addr:a,deployTx:l,subs:c});const u=new Proxy({},{get:(f,d,h)=>{if(typeof d=="symbol"||Cg.indexOf(d)>=0)return Reflect.get(f,d,h);try{return this.getEvent(d)}catch(p){if(!ln(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>Cg.indexOf(d)>=0?Reflect.has(f,d):Reflect.has(f,d)||this.interface.hasEvent(String(d))});return Oe(this,{filters:u}),Oe(this,{fallback:i.receive||i.fallback?iJ(this):null}),new Proxy(this,{get:(f,d,h)=>{if(typeof d=="symbol"||d in f||Cg.indexOf(d)>=0)return Reflect.get(f,d,h);try{return f.getFunction(d)}catch(p){if(!ln(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>typeof d=="symbol"||d in f||Cg.indexOf(d)>=0?Reflect.has(f,d):f.interface.hasFunction(d)})}connect(e){return new Gd(this.target,this.interface,e)}attach(e){return new Gd(e,this.interface,this.runner)}async getAddress(){return await br(this).addrPromise}async getDeployedCode(){const e=Ja(this.runner);ee(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Ja(this.runner);return ee(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return br(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),oJ(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),aJ(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=br(this),o=s||await i,{fragment:a,topics:l}=await k1(this,e),c={address:o,topics:l,fromBlock:t,toBlock:r},u=Ja(this.runner);return ee(u,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await u.getLogs(c)).map(f=>{let d=a;if(d==null)try{d=this.interface.getEvent(f.topics[0])}catch{}if(d)try{return new A1(f,this.interface,d)}catch(h){return new wD(f,h)}return new Rd(f,u)})}async on(e,t){const r=await ND(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await ND(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await S1(this,e,t,null)}async listenerCount(e){if(e){const s=await Dd(this,e);return s?s.listeners.length:0}const{subs:t}=br(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await Dd(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=br(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await Dd(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),br(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await Dd(this,e);if(!t)return this;t.stop(),br(this).subs.delete(t.tag)}else{const{subs:t}=br(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Gd{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};let T1=Gd;function fJ(){return T1}class jc extends fJ(){}function N1(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):V(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class dJ{constructor(e){$(this,"name");Oe(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const OD=new RegExp("^(ipfs)://(.*)$","i"),RD=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),OD,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],yu=class yu{constructor(e,t,r){q(this,Lo);$(this,"provider");$(this,"address");$(this,"name");q(this,Io);q(this,ul);Oe(this,{provider:e,address:t,name:r}),I(this,Io,null),I(this,ul,new jc(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return T(this,Io)==null&&I(this,Io,(async()=>{try{return await T(this,ul).supportsInterface("0x9061b923")}catch(e){if(ln(e,"CALL_EXCEPTION"))return!1;throw I(this,Io,null),e}})()),await T(this,Io)}async getAddress(e){if(e==null&&(e=60),e===60)try{const i=await fe(this,Lo,ju).call(this,"addr(bytes32)");return i==null||i===wd?null:i}catch(i){if(ln(i,"CALL_EXCEPTION"))return null;throw i}if(e>=0&&e<2147483648){let i=e+2147483648;const o=await fe(this,Lo,ju).call(this,"addr(bytes32,uint)",[i]);if(At(o,20))return dt(o)}let t=null;for(const i of this.provider.plugins)if(i instanceof dJ&&i.supportsCoinType(e)){t=i;break}if(t==null)return null;const r=await fe(this,Lo,ju).call(this,"addr(bytes32,uint)",[e]);if(r==null||r==="0x")return null;const s=await t.decodeAddress(e,r);if(s!=null)return s;ee(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:r}})}async getText(e){const t=await fe(this,Lo,ju).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await fe(this,Lo,ju).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",i=parseInt(t[4],16);if(t[5].length===i*2)return`${s}://${IW("0x"+t[2])}`}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;ee(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let r=0;r<RD.length;r++){const s=t.match(RD[r]);if(s==null)continue;const i=s[1].toLowerCase();switch(i){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=N1(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=i==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:i,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const l=(s[2]||"").split("/");if(l.length!==2)return e.push({type:`!${i}caip`,value:s[2]||""}),{url:null,linkage:e};const c=l[1],u=new jc(l[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(i==="erc721"){const m=await u.ownerOf(c);if(a!==m)return e.push({type:"!owner",value:m}),{url:null,linkage:e};e.push({type:"owner",value:m})}else if(i==="erc1155"){const m=await u.balanceOf(a,c);if(!m)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:m.toString()})}let f=await u[o](c);if(f==null||f==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:f}),i==="erc1155"&&(f=f.replace("{id}",bo(c,32).substring(2)),e.push({type:"metadata-url-expanded",value:f})),f.match(/^ipfs:/i)&&(f=N1(f)),e.push({type:"metadata-url",value:f});let d={};const h=await new Ln(f).send();h.assertOk();try{d=h.bodyJson}catch{try{e.push({type:"!metadata",value:h.bodyText})}catch{const b=h.body;return b&&e.push({type:"!metadata",value:we(b)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!d)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(d)});let p=d.image;if(typeof p!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!p.match(/^(https:\/\/|data:)/i)){if(p.match(OD)==null)return e.push({type:"!imageUrl-ipfs",value:p}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:p}),p=N1(p)}return e.push({type:"url",value:p}),{linkage:e,url:p}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),r=t.getPlugin("org.ethers.plugins.network.Ens");return ee(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),r.address}static async fromName(e,t){var s;let r=t;for(;;){if(r===""||r==="."||t!=="eth"&&r==="eth")return null;const i=await fe(s=yu,Jg,nP).call(s,e,r);if(i!=null){const o=new yu(e,i,t);return r!==t&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};Io=new WeakMap,ul=new WeakMap,Lo=new WeakSet,ju=async function(e,t){t=(t||[]).slice();const r=T(this,ul).interface;t.unshift(d1(this.name));let s=null;await this.supportsWildcard()&&(s=r.getFunction(e),ee(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[hK(this.name,255),r.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const i=await T(this,ul)[e](...t);return s?r.decodeFunctionResult(s,i)[0]:i}catch(i){if(!ln(i,"CALL_EXCEPTION"))throw i}return null},Jg=new WeakSet,nP=async function(e,t){const r=await yu.getEnsAddress(e);try{const i=await new jc(r,["function resolver(bytes32) view returns (address)"],e).resolver(d1(t),{enableCcipRead:!0});return i===wd?null:i}catch(s){throw s}return null},q(yu,Jg);let Sg=yu;const MD=BigInt(0);function ot(n,e){return function(t){return t==null?e:n(t)}}function Tg(n,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(r=>n(r))}}function Pd(n,e){return t=>{const r={};for(const s in n){let i=s;if(e&&s in e&&!(i in t)){for(const o of e[s])if(o in t){i=o;break}}try{const o=n[s](t[i]);o!==void 0&&(r[s]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";ee(!1,`invalid value for value.${s} (${a})`,"BAD_DATA",{value:t})}}return r}}function hJ(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}V(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Uc(n){return V(At(n,!0),"invalid data","value",n),n}function yn(n){return V(At(n,32),"invalid hash","value",n),n}const pJ=Pd({address:dt,blockHash:yn,blockNumber:Je,data:Uc,index:Je,removed:ot(hJ,!1),topics:Tg(yn),transactionHash:yn,transactionIndex:Je},{index:["logIndex"]});function mJ(n){return pJ(n)}const gJ=Pd({hash:ot(yn),parentHash:yn,parentBeaconBlockRoot:ot(yn,null),number:Je,timestamp:Je,nonce:ot(Uc),difficulty:Ae,gasLimit:Ae,gasUsed:Ae,stateRoot:ot(yn,null),receiptsRoot:ot(yn,null),blobGasUsed:ot(Ae,null),excessBlobGas:ot(Ae,null),miner:ot(dt),prevRandao:ot(yn,null),extraData:Uc,baseFeePerGas:ot(Ae)},{prevRandao:["mixHash"]});function yJ(n){const e=gJ(n);return e.transactions=n.transactions.map(t=>typeof t=="string"?t:DD(t)),e}const bJ=Pd({transactionIndex:Je,blockNumber:Je,transactionHash:yn,address:dt,topics:Tg(yn),data:Uc,index:Je,blockHash:yn},{index:["logIndex"]});function wJ(n){return bJ(n)}const vJ=Pd({to:ot(dt,null),from:ot(dt,null),contractAddress:ot(dt,null),index:Je,root:ot(we),gasUsed:Ae,blobGasUsed:ot(Ae,null),logsBloom:ot(Uc),blockHash:yn,hash:yn,logs:Tg(wJ),blockNumber:Je,cumulativeGasUsed:Ae,effectiveGasPrice:ot(Ae),blobGasPrice:ot(Ae,null),status:ot(Je),type:ot(Je,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function xJ(n){return vJ(n)}function DD(n){n.to&&Ae(n.to)===MD&&(n.to="0x0000000000000000000000000000000000000000");const e=Pd({hash:yn,index:ot(Je,void 0),type:t=>t==="0x"||t==null?0:Je(t),accessList:ot(Co,null),blobVersionedHashes:ot(Tg(yn,!0),null),blockHash:ot(yn,null),blockNumber:ot(Je,null),transactionIndex:ot(Je,null),from:dt,gasPrice:ot(Ae),maxPriorityFeePerGas:ot(Ae),maxFeePerGas:ot(Ae),maxFeePerBlobGas:ot(Ae,null),gasLimit:Ae,to:ot(dt,null),value:Ae,nonce:Je,data:Uc,creates:ot(dt,null),chainId:ot(Ae,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(e.to==null&&e.creates==null&&(e.creates=mG(e)),(n.type===1||n.type===2)&&n.accessList==null&&(e.accessList=[]),n.signature?e.signature=as.from(n.signature):e.signature=as.from(n),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&Ae(e.blockHash)===MD&&(e.blockHash=null),e}const AJ="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class Id{constructor(e){$(this,"name");Oe(this,{name:e})}clone(){return new Id(this.name)}}class Ng extends Id{constructor(t,r){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);$(this,"effectiveBlock");$(this,"txBase");$(this,"txCreate");$(this,"txDataZero");$(this,"txDataNonzero");$(this,"txAccessListStorageKey");$(this,"txAccessListAddress");const s={effectiveBlock:t};function i(o,a){let l=(r||{})[o];l==null&&(l=a),V(typeof l=="number",`invalud value for ${o}`,"costs",r),s[o]=l}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),Oe(this,s)}clone(){return new Ng(this.effectiveBlock,this)}}class Og extends Id{constructor(t,r){super("org.ethers.plugins.network.Ens");$(this,"address");$(this,"targetNetwork");Oe(this,{address:t||AJ,targetNetwork:r??1})}clone(){return new Og(this.address,this.targetNetwork)}}class EJ extends Id{constructor(t,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");q(this,Kd);q(this,Jd);I(this,Kd,t),I(this,Jd,r)}get url(){return T(this,Kd)}get processFunc(){return T(this,Jd)}clone(){return this}}Kd=new WeakMap,Jd=new WeakMap;const O1=new Map,vu=class vu{constructor(e,t){q(this,bu);q(this,wu);q(this,_o);I(this,bu,e),I(this,wu,Ae(t)),I(this,_o,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return T(this,bu)}set name(e){I(this,bu,e)}get chainId(){return T(this,wu)}set chainId(e){I(this,wu,Ae(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===Ae(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===Ae(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===Ae(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(T(this,_o).values())}attachPlugin(e){if(T(this,_o).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,_o).set(e.name,e.clone()),this}getPlugin(e){return T(this,_o).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new vu(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new Ng;let r=t.txBase;if(e.to==null&&(r+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?r+=t.txDataZero:r+=t.txDataNonzero;if(e.accessList){const s=Co(e.accessList);for(const i in s)r+=t.txAccessListAddress+t.txAccessListStorageKey*s[i].storageKeys.length}return r}static from(e){if(kJ(),e==null)return vu.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=O1.get(e);if(t)return t();if(typeof e=="bigint")return new vu("unknown",e);V(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){V(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new vu(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new Og(e.ensAddress,e.ensNetwork)),t}V(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const r=O1.get(e);r&&V(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",e),O1.set(e,t)}};bu=new WeakMap,wu=new WeakMap,_o=new WeakMap;let Yt=vu;function PD(n,e){const t=String(n);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=t.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<e;)r[1]+="0";if(r[1].length>9){let s=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||s++,r[1]=s.toString()}return BigInt(r[0]+r[1])}function ID(n){return new EJ(n,async(e,t,r)=>{r.setHeader("User-Agent","ethers");let s;try{const[i,o]=await Promise.all([r.send(),e()]);s=i;const a=s.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:PD(a.maxFee,9),maxPriorityFeePerGas:PD(a.maxPriorityFee,9)}}catch(i){ee(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:s,error:i})}})}let LD=!1;function kJ(){if(LD)return;LD=!0;function n(e,t,r){const s=function(){const i=new Yt(e,t);return r.ensNetwork!=null&&i.attachPlugin(new Og(null,r.ensNetwork)),i.attachPlugin(new Ng),(r.plugins||[]).forEach(o=>{i.attachPlugin(o)}),i};Yt.register(e,s),Yt.register(t,s),r.altNames&&r.altNames.forEach(i=>{Yt.register(i,s)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[ID("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[ID("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function R1(n){return JSON.parse(JSON.stringify(n))}class CJ{constructor(e){q(this,xu);q(this,_i);q(this,Ur);q(this,Bo);q(this,Qs);I(this,_i,e),I(this,Ur,null),I(this,Bo,4e3),I(this,Qs,-2)}get pollingInterval(){return T(this,Bo)}set pollingInterval(e){I(this,Bo,e)}start(){T(this,Ur)||(I(this,Ur,T(this,_i)._setTimeout(fe(this,xu,ny).bind(this),T(this,Bo))),fe(this,xu,ny).call(this))}stop(){T(this,Ur)&&(T(this,_i)._clearTimeout(T(this,Ur)),I(this,Ur,null))}pause(e){this.stop(),e&&I(this,Qs,-2)}resume(){this.start()}}_i=new WeakMap,Ur=new WeakMap,Bo=new WeakMap,Qs=new WeakMap,xu=new WeakSet,ny=async function(){try{const e=await T(this,_i).getBlockNumber();if(T(this,Qs)===-2){I(this,Qs,e);return}if(e!==T(this,Qs)){for(let t=T(this,Qs)+1;t<=e;t++){if(T(this,Ur)==null)return;await T(this,_i).emit("block",t)}I(this,Qs,e)}}catch{}T(this,Ur)!=null&&I(this,Ur,T(this,_i)._setTimeout(fe(this,xu,ny).bind(this),T(this,Bo)))};class M1{constructor(e){q(this,fl);q(this,dl);q(this,Fo);I(this,fl,e),I(this,Fo,!1),I(this,dl,t=>{this._poll(t,T(this,fl))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){T(this,Fo)||(I(this,Fo,!0),T(this,dl).call(this,-2),T(this,fl).on("block",T(this,dl)))}stop(){T(this,Fo)&&(I(this,Fo,!1),T(this,fl).off("block",T(this,dl)))}pause(e){this.stop()}resume(){this.start()}}fl=new WeakMap,dl=new WeakMap,Fo=new WeakMap;class SJ extends M1{constructor(t,r){super(t);q(this,Au);q(this,Bi);I(this,Au,r),I(this,Bi,-2)}pause(t){t&&I(this,Bi,-2),super.pause(t)}async _poll(t,r){const s=await r.getBlock(T(this,Au));s!=null&&(T(this,Bi)===-2?I(this,Bi,s.number):s.number>T(this,Bi)&&(r.emit(T(this,Au),s.number),I(this,Bi,s.number)))}}Au=new WeakMap,Bi=new WeakMap;class TJ extends M1{constructor(t,r){super(t);q(this,qg);I(this,qg,R1(r))}async _poll(t,r){throw new Error("@TODO")}}qg=new WeakMap;class NJ extends M1{constructor(t,r){super(t);q(this,Eu);I(this,Eu,r)}async _poll(t,r){const s=await r.getTransactionReceipt(T(this,Eu));s&&r.emit(T(this,Eu),s)}}Eu=new WeakMap;class D1{constructor(e,t){q(this,Qg);q(this,Fi);q(this,ku);q(this,Cu);q(this,jo);q(this,Hr);I(this,Fi,e),I(this,ku,R1(t)),I(this,Cu,fe(this,Qg,rP).bind(this)),I(this,jo,!1),I(this,Hr,-2)}start(){T(this,jo)||(I(this,jo,!0),T(this,Hr)===-2&&T(this,Fi).getBlockNumber().then(e=>{I(this,Hr,e)}),T(this,Fi).on("block",T(this,Cu)))}stop(){T(this,jo)&&(I(this,jo,!1),T(this,Fi).off("block",T(this,Cu)))}pause(e){this.stop(),e&&I(this,Hr,-2)}resume(){this.start()}}Fi=new WeakMap,ku=new WeakMap,Cu=new WeakMap,jo=new WeakMap,Hr=new WeakMap,Qg=new WeakSet,rP=async function(e){if(T(this,Hr)===-2)return;const t=R1(T(this,ku));t.fromBlock=T(this,Hr)+1,t.toBlock=e;const r=await T(this,Fi).getLogs(t);if(r.length===0){T(this,Hr)<e-60&&I(this,Hr,e-60);return}for(const s of r)T(this,Fi).emit(T(this,ku),s),I(this,Hr,s.blockNumber)};const OJ=BigInt(2),RJ=10;function Rg(n){return n&&typeof n.then=="function"}function Mg(n,e){return n+":"+JSON.stringify(e,(t,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const s=Object.keys(r);return s.sort(),s.reduce((i,o)=>(i[o]=r[o],i),{})}return r})}class Dg{constructor(e){$(this,"name");Oe(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function MJ(n){return JSON.parse(JSON.stringify(n))}function P1(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function I1(n,e){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(At(n,32)){const t=n.toLowerCase();return{type:"transaction",tag:Mg("tx",{hash:t}),hash:t}}if(n.orphan){const t=n;return{type:"orphan",tag:Mg("orphan",t),filter:MJ(t)}}if(n.address||n.topics){const t=n,r={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?P1(s.map(i=>i.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],i=[],o=a=>{At(a)?s.push(a):i.push((async()=>{s.push(await Bn(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),i.length&&await Promise.all(i),r.address=P1(s.map(a=>a.toLowerCase()))}return{filter:r,tag:Mg("event",r),type:"event"}}V(!1,"unknown ProviderEvent","event",n)}function L1(){return new Date().getTime()}const DJ={cacheTimeout:250,pollingInterval:4e3};class Pg{constructor(e,t){q(this,nt);q(this,Cn);q(this,Uo);q(this,Sn);q(this,Su);q(this,Ar);q(this,hl);q(this,Ho);q(this,ji);q(this,qd);q(this,zr);q(this,Tu);q(this,Nu);if(I(this,Nu,Object.assign({},DJ,t||{})),e==="any")I(this,hl,!0),I(this,Ar,null);else if(e){const r=Yt.from(e);I(this,hl,!1),I(this,Ar,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else I(this,hl,!1),I(this,Ar,null);I(this,ji,-1),I(this,Ho,new Map),I(this,Cn,new Map),I(this,Uo,new Map),I(this,Sn,null),I(this,Su,!1),I(this,qd,1),I(this,zr,new Map),I(this,Tu,!1)}get pollingInterval(){return T(this,Nu).pollingInterval}get provider(){return this}get plugins(){return Array.from(T(this,Uo).values())}attachPlugin(e){if(T(this,Uo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return T(this,Uo).set(e.name,e.connect(this)),this}getPlugin(e){return T(this,Uo).get(e)||null}get disableCcipRead(){return T(this,Tu)}set disableCcipRead(e){I(this,Tu,!!e)}async ccipReadFetch(e,t,r){if(this.disableCcipRead||r.length===0||e.to==null)return null;const s=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let a=0;a<r.length;a++){const l=r[a],c=l.replace("{sender}",s).replace("{data}",i),u=new Ln(c);l.indexOf("{data}")===-1&&(u.body={data:i,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:a,urls:r});let f="unknown error";const d=await u.send();try{const h=d.bodyJson;if(h.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:h}),h.data;h.message&&(f=h.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:h})}catch{}ee(d.statusCode<400||d.statusCode>=500,`response not found during CCIP fetch: ${f}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:l,errorMessage:f}}),o.push(f)}ee(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:r,errorMessages:o}})}_wrapBlock(e,t){return new XK(yJ(e),this)}_wrapLog(e,t){return new Rd(mJ(e),this)}_wrapTransactionReceipt(e,t){return new gD(xJ(e),this)}_wrapTransactionResponse(e,t){return new Md(DD(e),this)}_detectNetwork(){ee(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){ee(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=Je(await fe(this,nt,Er).call(this,{method:"getBlockNumber"}),"%response");return T(this,ji)>=0&&I(this,ji,e),e}_getAddress(e){return Bn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(At(e))return At(e,32)?e:La(e);if(typeof e=="bigint"&&(e=Je(e,"blockTag")),typeof e=="number")return e>=0?La(e):T(this,ji)>=0?La(T(this,ji)+e):this.getBlockNumber().then(t=>La(t+e));V(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(l=>l==null?null:Array.isArray(l)?P1(l.map(c=>c.toLowerCase())):l.toLowerCase()),r="blockHash"in e?e.blockHash:void 0,s=(l,c,u)=>{let f;switch(l.length){case 0:break;case 1:f=l[0];break;default:l.sort(),f=l}if(r&&(c!=null||u!=null))throw new Error("invalid filter");const d={};return f&&(d.address=f),t.length&&(d.topics=t),c&&(d.fromBlock=c),u&&(d.toBlock=u),r&&(d.blockHash=r),d};let i=[];if(e.address)if(Array.isArray(e.address))for(const l of e.address)i.push(this._getAddress(l));else i.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),i.filter(l=>typeof l!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(i),o,a]).then(l=>s(l[0],l[1],l[2])):s(i,o,a)}_getTransactionRequest(e){const t=Ag(e),r=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const i=Bn(t[s],this);Rg(i)?r.push(async function(){t[s]=await i}()):t[s]=i}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);Rg(s)?r.push(async function(){t.blockTag=await s}()):t.blockTag=s}return r.length?async function(){return await Promise.all(r),t}():t}async getNetwork(){if(T(this,Ar)==null){const s=(async()=>{try{const i=await this._detectNetwork();return this.emit("network",i,null),i}catch(i){throw T(this,Ar)===s&&I(this,Ar,null),i}})();return I(this,Ar,s),(await s).clone()}const e=T(this,Ar),[t,r]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==r.chainId&&(T(this,hl)?(this.emit("network",r,t),T(this,Ar)===e&&I(this,Ar,Promise.resolve(r))):ee(!1,`network changed: ${t.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:i,priorityFee:o}=await An({_block:fe(this,nt,ox).call(this,"latest",!1),gasPrice:(async()=>{try{const u=await fe(this,nt,Er).call(this,{method:"getGasPrice"});return Ae(u,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const u=await fe(this,nt,Er).call(this,{method:"getPriorityFee"});return Ae(u,"%response")}catch{}return null})()});let a=null,l=null;const c=this._wrapBlock(s,e);return c&&c.baseFeePerGas&&(l=o??BigInt("1000000000"),a=c.baseFeePerGas*OJ+l),new mD(i,a,l)},r=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const s=new Ln(r.url),i=await r.processFunc(t,this,s);return new mD(i.gasPrice,i.maxFeePerGas,i.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return Rg(t)&&(t=await t),Ae(await fe(this,nt,Er).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:r}=await An({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await fe(this,nt,ix).call(this,fe(this,nt,sx).call(this,t,r,e.enableCcipRead?0:-1))}async getBalance(e,t){return Ae(await fe(this,nt,th).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return Je(await fe(this,nt,th).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return we(await fe(this,nt,th).call(this,{method:"getCode"},e,t))}async getStorage(e,t,r){const s=Ae(t,"position");return we(await fe(this,nt,th).call(this,{method:"getStorage",position:s},e,r))}async broadcastTransaction(e){const{blockNumber:t,hash:r,network:s}=await An({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),i=Nd.from(e);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,s).replaceableTransaction(t)}async getBlock(e,t){const{network:r,params:s}=await An({network:this.getNetwork(),params:fe(this,nt,ox).call(this,e,!!t)});return s==null?null:this._wrapBlock(s,r)}async getTransaction(e){const{network:t,params:r}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getTransaction",hash:e})});return r==null?null:this._wrapTransactionResponse(r,t)}async getTransactionReceipt(e){const{network:t,params:r}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getTransactionReceipt",hash:e})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const s=await fe(this,nt,Er).call(this,{method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(r,t)}async getTransactionResult(e){const{result:t}=await An({network:this.getNetwork(),result:fe(this,nt,Er).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:we(t)}async getLogs(e){let t=this._getFilter(e);Rg(t)&&(t=await t);const{network:r,params:s}=await An({network:this.getNetwork(),params:fe(this,nt,Er).call(this,{method:"getLogs",filter:t})});return s.map(i=>this._wrapLog(i,r))}_getProvider(e){ee(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Sg.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=dt(e);const t=d1(e.substring(2).toLowerCase()+".addr.reverse");try{const r=await Sg.getEnsAddress(this),i=await new jc(r,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(i==null||i===wd)return null;const a=await new jc(i,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(r){if(ln(r,"BAD_DATA")&&r.value==="0x"||ln(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(e,t,r){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(i,o)=>{let a=null;const l=async c=>{try{const u=await this.getTransactionReceipt(e);if(u!=null&&c-u.blockNumber+1>=s){i(u),a&&(clearTimeout(a),a=null);return}}catch(u){console.log("EEE",u)}this.once("block",l)};r!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",l),o(Nt("timeout","TIMEOUT",{reason:"timeout"})))},r)),l(await this.getBlockNumber())})}async waitForBlock(e){ee(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=T(this,zr).get(e);t&&(t.timer&&clearTimeout(t.timer),T(this,zr).delete(e))}_setTimeout(e,t){t==null&&(t=0);const r=Zd(this,qd)._++,s=()=>{T(this,zr).delete(r),e()};if(this.paused)T(this,zr).set(r,{timer:null,func:s,time:t});else{const i=setTimeout(s,t);T(this,zr).set(r,{timer:i,func:s,time:L1()})}return r}_forEachSubscriber(e){for(const t of T(this,Cn).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new Dg(e.type);case"block":{const t=new CJ(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new SJ(this,e.type);case"event":return new D1(this,e.filter);case"transaction":return new NJ(this,e.hash);case"orphan":return new TJ(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const r of T(this,Cn).values())if(r.subscriber===e){r.started&&r.subscriber.stop(),r.subscriber=t,r.started&&t.start(),T(this,Sn)!=null&&t.pause(T(this,Sn));break}}async on(e,t){const r=await fe(this,nt,ry).call(this,e);return r.listeners.push({listener:t,once:!1}),r.started||(r.subscriber.start(),r.started=!0,T(this,Sn)!=null&&r.subscriber.pause(T(this,Sn))),this}async once(e,t){const r=await fe(this,nt,ry).call(this,e);return r.listeners.push({listener:t,once:!0}),r.started||(r.subscriber.start(),r.started=!0,T(this,Sn)!=null&&r.subscriber.pause(T(this,Sn))),this}async emit(e,...t){const r=await fe(this,nt,nh).call(this,e,t);if(!r||r.listeners.length===0)return!1;const s=r.listeners.length;return r.listeners=r.listeners.filter(({listener:i,once:o})=>{const a=new XO(this,o?null:i,e);try{i.call(this,...t,a)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),T(this,Cn).delete(r.tag)),s>0}async listenerCount(e){if(e){const r=await fe(this,nt,nh).call(this,e);return r?r.listeners.length:0}let t=0;for(const{listeners:r}of T(this,Cn).values())t+=r.length;return t}async listeners(e){if(e){const r=await fe(this,nt,nh).call(this,e);return r?r.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:r}of T(this,Cn).values())t=t.concat(r.map(({listener:s})=>s));return t}async off(e,t){const r=await fe(this,nt,nh).call(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(!t||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),T(this,Cn).delete(r.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:r,subscriber:s}=await fe(this,nt,ry).call(this,e);r&&s.stop(),T(this,Cn).delete(t)}else for(const[t,{started:r,subscriber:s}]of T(this,Cn))r&&s.stop(),T(this,Cn).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return T(this,Su)}destroy(){this.removeAllListeners();for(const e of T(this,zr).keys())this._clearTimeout(e);I(this,Su,!0)}get paused(){return T(this,Sn)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(I(this,ji,-1),T(this,Sn)!=null){if(T(this,Sn)==!!e)return;ee(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),I(this,Sn,!!e);for(const t of T(this,zr).values())t.timer&&clearTimeout(t.timer),t.time=L1()-t.time}resume(){if(T(this,Sn)!=null){this._forEachSubscriber(e=>e.resume()),I(this,Sn,null);for(const e of T(this,zr).values()){let t=e.time;t<0&&(t=0),e.time=L1(),setTimeout(e.func,t)}}}}Cn=new WeakMap,Uo=new WeakMap,Sn=new WeakMap,Su=new WeakMap,Ar=new WeakMap,hl=new WeakMap,Ho=new WeakMap,ji=new WeakMap,qd=new WeakMap,zr=new WeakMap,Tu=new WeakMap,Nu=new WeakMap,nt=new WeakSet,Er=async function(e){const t=T(this,Nu).cacheTimeout;if(t<0)return await this._perform(e);const r=Mg(e.method,e);let s=T(this,Ho).get(r);return s||(s=this._perform(e),T(this,Ho).set(r,s),setTimeout(()=>{T(this,Ho).get(r)===s&&T(this,Ho).delete(r)},t)),await s},sx=async function(e,t,r){ee(r<RJ,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=Ag(e);try{return we(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(i){if(!this.disableCcipRead&&Rv(i)&&i.data&&r>=0&&t==="latest"&&s.to!=null&&Ft(i.data,0,4)==="0x556f1830"){const o=i.data,a=await Bn(s.to,this);let l;try{l=BJ(Ft(i.data,4))}catch(f){ee(!1,f.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:o}})}ee(l.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:l.errorArgs}});const c=await this.ccipReadFetch(s,l.calldata,l.urls);ee(c!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:i.data,errorArgs:l.errorArgs}});const u={to:a,data:Ut([l.selector,_J([c,l.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const f=await fe(this,nt,sx).call(this,u,t,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:f}),f}catch(f){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:f}),f}}throw i}},ix=async function(e){const{value:t}=await An({network:this.getNetwork(),value:e});return t},th=async function(e,t,r){let s=this._getAddress(t),i=this._getBlockTag(r);return(typeof s!="string"||typeof i!="string")&&([s,i]=await Promise.all([s,i])),await fe(this,nt,ix).call(this,fe(this,nt,Er).call(this,Object.assign(e,{address:s,blockTag:i})))},ox=async function(e,t){if(At(e,32))return await fe(this,nt,Er).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let r=this._getBlockTag(e);return typeof r!="string"&&(r=await r),await fe(this,nt,Er).call(this,{method:"getBlock",blockTag:r,includeTransactions:t})},nh=async function(e,t){let r=await I1(e,this);return r.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(r=await I1({orphan:"drop-log",log:t[0]},this)),T(this,Cn).get(r.tag)||null},ry=async function(e){const t=await I1(e,this),r=t.tag;let s=T(this,Cn).get(r);return s||(s={subscriber:this._getSubscriber(t),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},T(this,Cn).set(r,s)),s};function PJ(n,e){try{const t=_1(n,e);if(t)return Cc(t)}catch{}return null}function _1(n,e){if(n==="0x")return null;try{const t=Je(Ft(n,e,e+32)),r=Je(Ft(n,t,t+32));return Ft(n,t+32,t+32+r)}catch{}return null}function _D(n){const e=In(n);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function IJ(n){if(n.length%32===0)return n;const e=new Uint8Array(Math.ceil(n.length/32)*32);return e.set(n),e}const LJ=new Uint8Array([]);function _J(n){const e=[];let t=0;for(let r=0;r<n.length;r++)e.push(LJ),t+=32;for(let r=0;r<n.length;r++){const s=lt(n[r]);e[r]=_D(t),e.push(_D(s.length)),e.push(IJ(s)),t+=32+Math.ceil(s.length/32)*32}return Ut(e)}const BD="0x0000000000000000000000000000000000000000000000000000000000000000";function BJ(n){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};ee(Ec(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=Ft(n,0,32);ee(Ft(t,0,12)===Ft(BD,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Ft(t,12);try{const r=[],s=Je(Ft(n,32,64)),i=Je(Ft(n,s,s+32)),o=Ft(n,s+32);for(let a=0;a<i;a++){const l=PJ(o,a*32);if(l==null)throw new Error("abort");r.push(l)}e.urls=r}catch{ee(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=_1(n,64);if(r==null)throw new Error("abort");e.calldata=r}catch{ee(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}ee(Ft(n,100,128)===Ft(BD,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Ft(n,96,100);try{const r=_1(n,128);if(r==null)throw new Error("abort");e.extraData=r}catch{ee(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>e[r]),e}function Hc(n,e){if(n.provider)return n.provider;ee(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function FD(n,e){let t=Ag(e);if(t.to!=null&&(t.to=Bn(t.to,n)),t.from!=null){const r=t.from;t.from=Promise.all([n.getAddress(),Bn(r,n)]).then(([s,i])=>(V(s.toLowerCase()===i.toLowerCase(),"transaction from mismatch","tx.from",i),s))}else t.from=n.getAddress();return await An(t)}class FJ{constructor(e){$(this,"provider");Oe(this,{provider:e||null})}async getNonce(e){return Hc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await FD(this,e)}async populateTransaction(e){const t=Hc(this,"populateTransaction"),r=await FD(this,e);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const s=await this.provider.getNetwork();if(r.chainId!=null){const o=Ae(r.chainId);V(o===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else r.chainId=s.chainId;const i=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||i)?V(!1,"eip-1559 transaction do not support gasPrice","tx",e):(r.type===0||r.type===1)&&i&&V(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await t.getFeeData();ee(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const a=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=a,r.maxPriorityFeePerGas=a}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(ee(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):ee(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await An(r)}async estimateGas(e){return Hc(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Hc(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Hc(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Hc(this,"sendTransaction"),r=await this.populateTransaction(e);delete r.from;const s=Nd.from(r);return await t.broadcastTransaction(await this.signTransaction(s))}}const jD=new Set;function zc(n){jD.has(n)||(jD.add(n),console.log("========= NOTICE ========="),console.log(`Request-Rate Exceeded for ${n} (this message will not be repeated)`),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.org/api-keys/"),console.log("=========================="))}function jJ(n){return JSON.parse(JSON.stringify(n))}class UD{constructor(e){q(this,Vo);q(this,jn);q(this,Ys);q(this,pl);q(this,zo);q(this,ml);q(this,Ou);I(this,jn,e),I(this,Ys,null),I(this,pl,fe(this,Vo,ax).bind(this)),I(this,zo,!1),I(this,ml,null),I(this,Ou,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){T(this,zo)||(I(this,zo,!0),fe(this,Vo,ax).call(this,-2))}stop(){T(this,zo)&&(I(this,zo,!1),I(this,Ou,!0),fe(this,Vo,lx).call(this),T(this,jn).off("block",T(this,pl)))}pause(e){e&&fe(this,Vo,lx).call(this),T(this,jn).off("block",T(this,pl))}resume(){this.start()}}jn=new WeakMap,Ys=new WeakMap,pl=new WeakMap,zo=new WeakMap,ml=new WeakMap,Ou=new WeakMap,Vo=new WeakSet,ax=async function(e){try{T(this,Ys)==null&&I(this,Ys,this._subscribe(T(this,jn)));let t=null;try{t=await T(this,Ys)}catch(i){if(!ln(i,"UNSUPPORTED_OPERATION")||i.operation!=="eth_newFilter")throw i}if(t==null){I(this,Ys,null),T(this,jn)._recoverSubscriber(this,this._recover(T(this,jn)));return}const r=await T(this,jn).getNetwork();if(T(this,ml)||I(this,ml,r),T(this,ml).chainId!==r.chainId)throw new Error("chaid changed");if(T(this,Ou))return;const s=await T(this,jn).send("eth_getFilterChanges",[t]);await this._emitResults(T(this,jn),s)}catch(t){console.log("@TODO",t)}T(this,jn).once("block",T(this,pl))},lx=function(){const e=T(this,Ys);e&&(I(this,Ys,null),e.then(t=>{T(this,jn).destroyed||T(this,jn).send("eth_uninstallFilter",[t])}))};class UJ extends UD{constructor(t,r){super(t);q(this,gl);I(this,gl,jJ(r))}_recover(t){return new D1(t,T(this,gl))}async _subscribe(t){return await t.send("eth_newFilter",[T(this,gl)])}async _emitResults(t,r){for(const s of r)t.emit(T(this,gl),t._wrapLog(s,t._network))}}gl=new WeakMap;class HJ extends UD{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const r of t)e.emit("pending",r)}}const zJ="bigint,boolean,function,number,string,symbol".split(/,/g);function Ig(n){if(n==null||zJ.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(Ig);if(typeof n=="object")return Object.keys(n).reduce((e,t)=>(e[t]=n[t],e),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function VJ(n){return new Promise(e=>{setTimeout(e,n)})}function Vc(n){return n&&n.toLowerCase()}function HD(n){return n&&typeof n.pollingInterval=="number"}const zD={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class B1 extends FJ{constructor(t,r){super(t);$(this,"address");r=dt(r),Oe(this,{address:r})}connect(t){ee(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const r=Ig(t),s=[];if(r.from){const o=r.from;s.push((async()=>{const a=await Bn(o,this.provider);V(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=a})())}else r.from=this.address;if(r.gasLimit==null&&s.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;s.push((async()=>{r.to=await Bn(o,this.provider)})())}s.length&&await Promise.all(s);const i=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const r=await this.provider.getBlockNumber(),s=await this.sendUncheckedTransaction(t);return await new Promise((i,o)=>{const a=[1e3,100];let l=0;const c=async()=>{try{const u=await this.provider.getTransaction(s);if(u!=null){i(u.replaceableTransaction(r));return}}catch(u){if(ln(u,"CANCELLED")||ln(u,"BAD_DATA")||ln(u,"NETWORK_ERROR")){u.info==null&&(u.info={}),u.info.sendTransactionHash=s,o(u);return}if(ln(u,"INVALID_ARGUMENT")&&(l++,u.info==null&&(u.info={}),u.info.sendTransactionHash=s,l>10)){o(u);return}this.provider.emit("error",Nt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:u}))}this.provider._setTimeout(()=>{c()},a.pop()||4e3)};c()})}async signTransaction(t){const r=Ig(t);if(r.from){const i=await Bn(r.from,this.provider);V(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=i}else r.from=this.address;const s=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[s])}async signMessage(t){const r=typeof t=="string"?bi(t):t;return await this.provider.send("personal_sign",[we(r),this.address.toLowerCase()])}async signTypedData(t,r,s){const i=Ig(s),o=await wg.resolveNames(t,r,i,async a=>{const l=await Bn(a);return V(l!=null,"TypedData does not support null address","value",a),l});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(wg.getPayload(o.domain,r,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const r=typeof t=="string"?bi(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),we(r)])}}class VD extends Pg{constructor(t,r){super(t,r);q(this,Qd);q(this,yl);q(this,Ru);q(this,Ui);q(this,Xs);q(this,ps);q(this,Vr);q(this,tr);I(this,Ru,1),I(this,yl,Object.assign({},zD,r||{})),I(this,Ui,[]),I(this,Xs,null),I(this,Vr,null),I(this,tr,null);{let i=null;const o=new Promise(a=>{i=a});I(this,ps,{promise:o,resolve:i})}const s=this._getOption("staticNetwork");typeof s=="boolean"?(V(!s||t!=="any","staticNetwork cannot be used on special network 'any'","options",r),s&&t!=null&&I(this,Vr,Yt.from(t))):s&&(V(t==null||s.matches(t),"staticNetwork MUST match network object","options",r),I(this,Vr,s))}_getOption(t){return T(this,yl)[t]}get _network(){return ee(T(this,Vr),"network is not available yet","NETWORK_ERROR"),T(this,Vr)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let s=t.transaction;if(s&&s.type!=null&&Ae(s.type)&&s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},s,{type:void 0})}))}}const r=this.getRpcRequest(t);return r!=null?await this.send(r.method,r.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(T(this,Vr))return T(this,Vr)}else return t;return T(this,tr)?await T(this,tr):this.ready?(I(this,tr,(async()=>{try{const r=Yt.from(Ae(await this.send("eth_chainId",[])));return I(this,tr,null),r}catch(r){throw I(this,tr,null),r}})()),await T(this,tr)):(I(this,tr,(async()=>{const r={id:Zd(this,Ru)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let s;try{s=(await this._send(r))[0],I(this,tr,null)}catch(i){throw I(this,tr,null),this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:s}),"result"in s)return Yt.from(Ae(s.result));throw this.getRpcError(r,s)})()),await T(this,tr))}_start(){T(this,ps)==null||T(this,ps).resolve==null||(T(this,ps).resolve(),I(this,ps,null),(async()=>{for(;T(this,Vr)==null&&!this.destroyed;)try{I(this,Vr,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",Nt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await VJ(1e3)}fe(this,Qd,cx).call(this)})())}async _waitUntilReady(){if(T(this,ps)!=null)return await T(this,ps).promise}_getSubscriber(t){return t.type==="pending"?new HJ(this):t.type==="event"?this._getOption("polling")?new D1(this,t.filter):new UJ(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new Dg("orphan"):super._getSubscriber(t)}get ready(){return T(this,ps)==null}getRpcTransaction(t){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(s=>{if(t[s]==null)return;let i=s;s==="gasLimit"&&(i="gas"),r[i]=La(Ae(t[s],`tx.${s}`))}),["from","to","data"].forEach(s=>{t[s]!=null&&(r[s]=we(t[s]))}),t.accessList&&(r.accessList=Co(t.accessList)),t.blobVersionedHashes&&(r.blobVersionedHashes=t.blobVersionedHashes.map(s=>s.toLowerCase())),r}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Vc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Vc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Vc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Vc(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Vc):t.filter.address=Vc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,r){const{method:s}=t,{error:i}=r;if(s==="eth_estimateGas"&&i.message){const l=i.message;if(!l.match(/revert/i)&&l.match(/insufficient funds/i))return Nt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(s==="eth_call"||s==="eth_estimateGas"){const l=F1(i),c=Bc.getBuiltinCallException(s==="eth_call"?"call":"estimateGas",t.params[0],l?l.data:null);return c.info={error:i,payload:t},c}const o=JSON.stringify(WJ(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return Nt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[s]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(s==="eth_sendRawTransaction"||s==="eth_sendTransaction"){const l=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return Nt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:l,info:{error:i}});if(o.match(/nonce/i)&&o.match(/too low/i))return Nt("nonce has already been used","NONCE_EXPIRED",{transaction:l,info:{error:i}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return Nt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:l,info:{error:i}});if(o.match(/only replay-protected/i))return Nt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:s,info:{transaction:l,info:{error:i}}})}let a=!!o.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?Nt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):Nt("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,r){if(this.destroyed)return Promise.reject(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const s=Zd(this,Ru)._++,i=new Promise((o,a)=>{T(this,Ui).push({resolve:o,reject:a,payload:{method:t,params:r,id:s,jsonrpc:"2.0"}})});return fe(this,Qd,cx).call(this),i}async getSigner(t){t==null&&(t=0);const r=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await r;if(t>=i.length)throw new Error("no such account");return new B1(this,i[t])}const{accounts:s}=await An({network:this.getNetwork(),accounts:r});t=dt(t);for(const i of s)if(dt(i)===t)return new B1(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new B1(this,r))}destroy(){T(this,Xs)&&(clearTimeout(T(this,Xs)),I(this,Xs,null));for(const{payload:t,reject:r}of T(this,Ui))r(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));I(this,Ui,[]),super.destroy()}}yl=new WeakMap,Ru=new WeakMap,Ui=new WeakMap,Xs=new WeakMap,ps=new WeakMap,Vr=new WeakMap,tr=new WeakMap,Qd=new WeakSet,cx=function(){if(T(this,Xs))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");I(this,Xs,setTimeout(()=>{I(this,Xs,null);const r=T(this,Ui);for(I(this,Ui,[]);r.length;){const s=[r.shift()];for(;r.length&&s.length!==T(this,yl).batchMaxCount;)if(s.push(r.shift()),JSON.stringify(s.map(o=>o.payload)).length>T(this,yl).batchMaxSize){r.unshift(s.pop());break}(async()=>{const i=s.length===1?s[0].payload:s.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const o=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:l,payload:c}of s){if(this.destroyed){l(Nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:c.method}));continue}const u=o.filter(f=>f.id===c.id)[0];if(u==null){const f=Nt("missing response for request","BAD_DATA",{value:o,info:{payload:c}});this.emit("error",f),l(f);continue}if("error"in u){l(this.getRpcError(c,u));continue}a(u.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of s)a(o)}})()}},t))};class $J extends VD{constructor(t,r){super(t,r);q(this,$o);let s=this._getOption("pollingInterval");s==null&&(s=zD.pollingInterval),I(this,$o,s)}_getSubscriber(t){const r=super._getSubscriber(t);return HD(r)&&(r.pollingInterval=T(this,$o)),r}get pollingInterval(){return T(this,$o)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");I(this,$o,t),this._forEachSubscriber(r=>{HD(r)&&(r.pollingInterval=T(this,$o))})}}$o=new WeakMap;class Si extends $J{constructor(t,r,s){t==null&&(t="http://localhost:8545");super(r,s);q(this,Mu);typeof t=="string"?I(this,Mu,new Ln(t)):I(this,Mu,t.clone())}_getConnection(){return T(this,Mu).clone()}async send(t,r){return await this._start(),await super.send(t,r)}async _send(t){const r=this._getConnection();r.body=JSON.stringify(t),r.setHeader("content-type","application/json");const s=await r.send();s.assertOk();let i=s.bodyJson;return Array.isArray(i)||(i=[i]),i}}Mu=new WeakMap;function F1(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&At(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const e in n){const t=F1(n[e]);if(t)return t}return null}if(typeof n=="string")try{return F1(JSON.parse(n))}catch{}return null}function j1(n,e){if(n!=null){if(typeof n.message=="string"&&e.push(n.message),typeof n=="object")for(const t in n)j1(n[t],e);if(typeof n=="string")try{return j1(JSON.parse(n),e)}catch{}}}function WJ(n){const e=[];return j1(n,e),e}const Lg="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function GJ(n){switch(n){case"mainnet":return"rpc.ankr.com/eth";case"goerli":return"rpc.ankr.com/eth_goerli";case"sepolia":return"rpc.ankr.com/eth_sepolia";case"arbitrum":return"rpc.ankr.com/arbitrum";case"base":return"rpc.ankr.com/base";case"base-goerli":return"rpc.ankr.com/base_goerli";case"base-sepolia":return"rpc.ankr.com/base_sepolia";case"bnb":return"rpc.ankr.com/bsc";case"bnbt":return"rpc.ankr.com/bsc_testnet_chapel";case"matic":return"rpc.ankr.com/polygon";case"matic-mumbai":return"rpc.ankr.com/polygon_mumbai";case"optimism":return"rpc.ankr.com/optimism";case"optimism-goerli":return"rpc.ankr.com/optimism_testnet";case"optimism-sepolia":return"rpc.ankr.com/optimism_sepolia"}V(!1,"unsupported network","network",n)}class _g extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Lg);const i={polling:!0,staticNetwork:s},o=_g.getRequest(s,r);super(o,s,i);$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new _g(t,this.apiKey)}catch{}return super._getProvider(t)}static getRequest(t,r){r==null&&(r=Lg);const s=new Ln(`https://${GJ(t.name)}/${r}`);return s.allowGzip=!0,r===Lg&&(s.retryFunc=async(i,o,a)=>(zc("AnkrProvider"),!0)),s}getRpcError(t,r){return t.method==="eth_sendRawTransaction"&&r&&r.error&&r.error.message==="INTERNAL_ERROR: could not replace existing tx"&&(r.error.message="replacement transaction underpriced"),super.getRpcError(t,r)}isCommunityResource(){return this.apiKey===Lg}}const Bg="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";function KJ(n){switch(n){case"mainnet":return"eth-mainnet.alchemyapi.io";case"goerli":return"eth-goerli.g.alchemy.com";case"sepolia":return"eth-sepolia.g.alchemy.com";case"arbitrum":return"arb-mainnet.g.alchemy.com";case"arbitrum-goerli":return"arb-goerli.g.alchemy.com";case"arbitrum-sepolia":return"arb-sepolia.g.alchemy.com";case"base":return"base-mainnet.g.alchemy.com";case"base-goerli":return"base-goerli.g.alchemy.com";case"base-sepolia":return"base-sepolia.g.alchemy.com";case"matic":return"polygon-mainnet.g.alchemy.com";case"matic-amoy":return"polygon-amoy.g.alchemy.com";case"matic-mumbai":return"polygon-mumbai.g.alchemy.com";case"optimism":return"opt-mainnet.g.alchemy.com";case"optimism-goerli":return"opt-goerli.g.alchemy.com";case"optimism-sepolia":return"opt-sepolia.g.alchemy.com"}V(!1,"unsupported network","network",n)}class Fg extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Bg);const i=Fg.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new Fg(t,this.apiKey)}catch{}return super._getProvider(t)}async _perform(t){if(t.method==="getTransactionResult"){const{trace:r,tx:s}=await An({trace:this.send("trace_transaction",[t.hash]),tx:this.getTransaction(t.hash)});if(r==null||s==null)return null;let i,o=!1;try{i=r[0].result.output,o=r[0].error==="Reverted"}catch{}if(i)return ee(!o,"an error occurred during transaction executions","CALL_EXCEPTION",{action:"getTransactionResult",data:i,reason:null,transaction:s,invocation:null,revert:null}),i;ee(!1,"could not parse trace result","BAD_DATA",{value:r})}return await super._perform(t)}isCommunityResource(){return this.apiKey===Bg}static getRequest(t,r){r==null&&(r=Bg);const s=new Ln(`https://${KJ(t.name)}/v2/${r}`);return s.allowGzip=!0,r===Bg&&(s.retryFunc=async(i,o,a)=>(zc("alchemy"),!0)),s}}function jg(n){switch(n){case"mainnet":return"39f1d67cedf8b7831010a665328c9197";case"arbitrum":return"0550c209db33c3abf4cc927e1e18cea1";case"bnb":return"98b5a77e531614387366f6fc5da097f8";case"matic":return"cd9d4d70377471aa7c142ec4a4205249"}V(!1,"unsupported network","network",n)}function JJ(n){switch(n){case"mainnet":return"ethereum-mainnet.core.chainstack.com";case"arbitrum":return"arbitrum-mainnet.core.chainstack.com";case"bnb":return"bsc-mainnet.core.chainstack.com";case"matic":return"polygon-mainnet.core.chainstack.com"}V(!1,"unsupported network","network",n)}class Ug extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=jg(s.name));const i=Ug.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"apiKey");Oe(this,{apiKey:r})}_getProvider(t){try{return new Ug(t,this.apiKey)}catch{}return super._getProvider(t)}isCommunityResource(){return this.apiKey===jg(this._network.name)}static getRequest(t,r){r==null&&(r=jg(t.name));const s=new Ln(`https://${JJ(t.name)}/${r}`);return s.allowGzip=!0,r===jg(t.name)&&(s.retryFunc=async(i,o,a)=>(zc("ChainstackProvider"),!0)),s}}class qJ extends Si{constructor(e){e==null&&(e="mainnet");const t=Yt.from(e);V(t.name==="mainnet","unsupported network","network",e),super("https://cloudflare-eth.com/",t,{staticNetwork:t})}}const $D=2e3;function QJ(n){return n&&typeof n.then=="function"}const YJ="org.ethers.plugins.provider.Etherscan",XJ=["enableCcipRead"];let ZJ=1;class eq extends Pg{constructor(t,r){const s=r??null;super();$(this,"network");$(this,"apiKey");q(this,Du);const i=Yt.from(t);I(this,Du,i.getPlugin(YJ)),Oe(this,{apiKey:s,network:i}),this.getBaseUrl()}getBaseUrl(){if(T(this,Du))return T(this,Du).baseUrl;switch(this.network.name){case"mainnet":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"holesky":return"https://api-holesky.etherscan.io";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"base":return"https://api.basescan.org";case"base-sepolia":return"https://api-sepolia.basescan.org";case"bnb":return"https://api.bscscan.com";case"bnbt":return"https://api-testnet.bscscan.com";case"matic":return"https://api.polygonscan.com";case"matic-amoy":return"https://api-amoy.polygonscan.com";case"matic-mumbai":return"https://api-testnet.polygonscan.com";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}V(!1,"unsupported network","network",this.network)}getUrl(t,r){const s=Object.keys(r).reduce((o,a)=>{const l=r[a];return l!=null&&(o+=`&${a}=${l}`),o},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.getBaseUrl()}/api?module=${t}${s}${i}`}getPostUrl(){return`${this.getBaseUrl()}/api`}getPostData(t,r){return r.module=t,r.apikey=this.apiKey,r}async detectNetwork(){return this.network}async fetch(t,r,s){const i=ZJ++,o=s?this.getPostUrl():this.getUrl(t,r),a=s?this.getPostData(t,r):null;this.emit("debug",{action:"sendRequest",id:i,url:o,payload:a});const l=new Ln(o);l.setThrottleParams({slotInterval:1e3}),l.retryFunc=(f,d,h)=>(this.isCommunityResource()&&zc("Etherscan"),Promise.resolve(!0)),l.processFunc=async(f,d)=>{const h=d.hasBody()?JSON.parse(Cc(d.body)):{},p=(typeof h.result=="string"?h.result:"").toLowerCase().indexOf("rate limit")>=0;return t==="proxy"?h&&h.status==0&&h.message=="NOTOK"&&p&&(this.emit("debug",{action:"receiveError",id:i,reason:"proxy-NOTOK",error:h}),d.throwThrottleError(h.result,$D)):p&&(this.emit("debug",{action:"receiveError",id:i,reason:"null result",error:h.result}),d.throwThrottleError(h.result,$D)),d},a&&(l.setHeader("content-type","application/x-www-form-urlencoded; charset=UTF-8"),l.body=Object.keys(a).map(f=>`${f}=${a[f]}`).join("&"));const c=await l.send();try{c.assertOk()}catch(f){this.emit("debug",{action:"receiveError",id:i,error:f,reason:"assertOk"}),ee(!1,"response error","SERVER_ERROR",{request:l,response:c})}c.hasBody()||(this.emit("debug",{action:"receiveError",id:i,error:"missing body",reason:"null body"}),ee(!1,"missing response","SERVER_ERROR",{request:l,response:c}));const u=JSON.parse(Cc(c.body));return t==="proxy"?(u.jsonrpc!="2.0"&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"invalid JSON-RPC"}),ee(!1,"invalid JSON-RPC response (missing jsonrpc='2.0')","SERVER_ERROR",{request:l,response:c,info:{result:u}})),u.error&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"JSON-RPC error"}),ee(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):u.status==0&&(u.message==="No records found"||u.message==="No transactions found")?(this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):((u.status!=1||typeof u.message=="string"&&!u.message.match(/^OK/))&&(this.emit("debug",{action:"receiveError",id:i,result:u}),ee(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result)}_getTransactionPostData(t){const r={};for(let s in t){if(XJ.indexOf(s)>=0||t[s]==null)continue;let i=t[s];if(!(s==="type"&&i===0)&&!(s==="blockTag"&&i==="latest")){if({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[s])i=La(i);else if(s==="accessList")i="["+Co(i).map(o=>`{address:"${o.address}",storageKeys:["${o.storageKeys.join('","')}"]}`).join(",")+"]";else if(s==="blobVersionedHashes"){if(i.length===0)continue;ee(!1,"Etherscan API does not support blobVersionedHashes","UNSUPPORTED_OPERATION",{operation:"_getTransactionPostData",info:{transaction:t}})}else i=we(i);r[s]=i}}return r}_checkError(t,r,s){let i="";if(ln(r,"SERVER_ERROR")){try{i=r.info.result.error.message}catch{}if(!i)try{i=r.info.message}catch{}}if(t.method==="estimateGas"&&!i.match(/revert/i)&&i.match(/insufficient funds/i)&&ee(!1,"insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.transaction}),(t.method==="call"||t.method==="estimateGas")&&i.match(/execution reverted/i)){let o="";try{o=r.info.result.error.data}catch{}const a=Bc.getBuiltinCallException(t.method,t.transaction,o);throw a.info={request:t,error:r},a}if(i&&t.method==="broadcastTransaction"){const o=Nd.from(t.signedTransaction);i.match(/replacement/i)&&i.match(/underpriced/i)&&ee(!1,"replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:o}),i.match(/insufficient funds/)&&ee(!1,"insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:o}),i.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&ee(!1,"nonce has already been used","NONCE_EXPIRED",{transaction:o})}throw r}async _detectNetwork(){return this.network}async _perform(t){switch(t.method){case"chainId":return this.network.chainId;case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getPriorityFee":if(this.network.name==="mainnet")return"1000000000";if(this.network.name==="optimism")return"1000000";throw new Error("fallback onto the AbstractProvider default");case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorage":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"broadcastTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch(r=>this._checkError(t,r,t.signedTransaction));case"getBlock":if("blockTag"in t)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});ee(!1,"getBlock by blockHash not supported by Etherscan","UNSUPPORTED_OPERATION",{operation:"getBlock(blockHash)"});case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.hash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.hash});case"call":{if(t.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_call";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}case"estimateGas":{const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_estimateGas";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}}return super._perform(t)}async getNetwork(){return this.network}async getEtherPrice(){return this.network.name!=="mainnet"?0:parseFloat((await this.fetch("stats",{action:"ethprice"})).ethusd)}async getContract(t){let r=this._getAddress(t);QJ(r)&&(r=await r);try{const s=await this.fetch("contract",{action:"getabi",address:r}),i=JSON.parse(s);return new jc(r,i,this)}catch{return null}}isCommunityResource(){return this.apiKey==null}}Du=new WeakMap;function tq(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const nq=tq().WebSocket;class U1{constructor(e,t){q(this,Zs);q(this,Yd);q(this,Wo);q(this,bl);q(this,Go);I(this,Zs,e),I(this,Yd,JSON.stringify(t)),I(this,Wo,null),I(this,bl,null),I(this,Go,null)}get filter(){return JSON.parse(T(this,Yd))}start(){I(this,Wo,T(this,Zs).send("eth_subscribe",this.filter).then(e=>(T(this,Zs)._register(e,this),e)))}stop(){T(this,Wo).then(e=>{T(this,Zs).destroyed||T(this,Zs).send("eth_unsubscribe",[e])}),I(this,Wo,null)}pause(e){ee(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),I(this,bl,!!e)}resume(){I(this,bl,null)}_handleMessage(e){if(T(this,Wo)!=null&&T(this,bl)===null){let t=T(this,Go);t==null?t=this._emit(T(this,Zs),e):t=t.then(async()=>{await this._emit(T(this,Zs),e)}),I(this,Go,t.then(()=>{T(this,Go)===t&&I(this,Go,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}Zs=new WeakMap,Yd=new WeakMap,Wo=new WeakMap,bl=new WeakMap,Go=new WeakMap;class rq extends U1{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class sq extends U1{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class iq extends U1{constructor(t,r){super(t,["logs",r]);q(this,Xd);I(this,Xd,JSON.stringify(r))}get logFilter(){return JSON.parse(T(this,Xd))}async _emit(t,r){t.emit(this.logFilter,t._wrapLog(r,t._network))}}Xd=new WeakMap;class oq extends VD{constructor(t,r){const s=Object.assign({},r??{});V(s.batchMaxCount==null||s.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),s.batchMaxCount=1,s.staticNetwork==null&&(s.staticNetwork=!0);super(t,s);q(this,wl);q(this,Pu);q(this,Ko);I(this,wl,new Map),I(this,Pu,new Map),I(this,Ko,new Map)}_getSubscriber(t){switch(t.type){case"close":return new Dg("close");case"block":return new rq(this);case"pending":return new sq(this);case"event":return new iq(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new Dg("drop-log")}return super._getSubscriber(t)}_register(t,r){T(this,Pu).set(t,r);const s=T(this,Ko).get(t);if(s){for(const i of s)r._handleMessage(i);T(this,Ko).delete(t)}}async _send(t){V(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const r=new Promise((s,i)=>{T(this,wl).set(t.id,{payload:t,resolve:s,reject:i})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await r]}async _processMessage(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&"id"in r){const s=T(this,wl).get(r.id);if(s==null){this.emit("error",Nt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}T(this,wl).delete(r.id),s.resolve(r)}else if(r&&r.method==="eth_subscription"){const s=r.params.subscription,i=T(this,Pu).get(s);if(i)i._handleMessage(r.params.result);else{let o=T(this,Ko).get(s);o==null&&(o=[],T(this,Ko).set(s,o)),o.push(r.params.result)}}else{this.emit("error",Nt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(t){throw new Error("sub-classes must override this")}}wl=new WeakMap,Pu=new WeakMap,Ko=new WeakMap;class WD extends oq{constructor(t,r,s){super(r,s);q(this,vl);q(this,ms);typeof t=="string"?(I(this,vl,()=>new nq(t)),I(this,ms,T(this,vl).call(this))):typeof t=="function"?(I(this,vl,t),I(this,ms,t())):(I(this,vl,null),I(this,ms,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(i){console.log("failed to start WebsocketProvider",i)}},this.websocket.onmessage=i=>{this._processMessage(i.data)}}get websocket(){if(T(this,ms)==null)throw new Error("websocket closed");return T(this,ms)}async _write(t){this.websocket.send(t)}async destroy(){T(this,ms)!=null&&(T(this,ms).close(),I(this,ms,null)),super.destroy()}}vl=new WeakMap,ms=new WeakMap;const Ld="84842078b09946638c03157f83405213";function aq(n){switch(n){case"mainnet":return"mainnet.infura.io";case"goerli":return"goerli.infura.io";case"sepolia":return"sepolia.infura.io";case"arbitrum":return"arbitrum-mainnet.infura.io";case"arbitrum-goerli":return"arbitrum-goerli.infura.io";case"arbitrum-sepolia":return"arbitrum-sepolia.infura.io";case"base":return"base-mainnet.infura.io";case"base-goerlia":return"base-goerli.infura.io";case"base-sepolia":return"base-sepolia.infura.io";case"bnb":return"bnbsmartchain-mainnet.infura.io";case"bnbt":return"bnbsmartchain-testnet.infura.io";case"linea":return"linea-mainnet.infura.io";case"linea-goerli":return"linea-goerli.infura.io";case"linea-sepolia":return"linea-sepolia.infura.io";case"matic":return"polygon-mainnet.infura.io";case"matic-amoy":return"polygon-amoy.infura.io";case"matic-mumbai":return"polygon-mumbai.infura.io";case"optimism":return"optimism-mainnet.infura.io";case"optimism-goerli":return"optimism-goerli.infura.io";case"optimism-sepolia":return"optimism-sepolia.infura.io"}V(!1,"unsupported network","network",n)}class lq extends WD{constructor(t,r){const s=new _d(t,r),i=s._getConnection();ee(!i.credentials,"INFURA WebSocket project secrets unsupported","UNSUPPORTED_OPERATION",{operation:"InfuraProvider.getWebSocketProvider()"});const o=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(o,s._network);$(this,"projectId");$(this,"projectSecret");Oe(this,{projectId:s.projectId,projectSecret:s.projectSecret})}isCommunityResource(){return this.projectId===Ld}}class _d extends Si{constructor(t,r,s){t==null&&(t="mainnet");const i=Yt.from(t);r==null&&(r=Ld),s==null&&(s=null);const o=_d.getRequest(i,r,s);super(o,i,{staticNetwork:i});$(this,"projectId");$(this,"projectSecret");Oe(this,{projectId:r,projectSecret:s})}_getProvider(t){try{return new _d(t,this.projectId,this.projectSecret)}catch{}return super._getProvider(t)}isCommunityResource(){return this.projectId===Ld}static getWebSocketProvider(t,r){return new lq(t,r)}static getRequest(t,r,s){r==null&&(r=Ld),s==null&&(s=null);const i=new Ln(`https://${aq(t.name)}/v3/${r}`);return i.allowGzip=!0,s&&i.setCredentials("",s),r===Ld&&(i.retryFunc=async(o,a,l)=>(zc("InfuraProvider"),!0)),i}}const Hg="919b412a057b5e9c9b6dce193c5a60242d6efadb";function cq(n){switch(n){case"mainnet":return"ethers.quiknode.pro";case"goerli":return"ethers.ethereum-goerli.quiknode.pro";case"sepolia":return"ethers.ethereum-sepolia.quiknode.pro";case"holesky":return"ethers.ethereum-holesky.quiknode.pro";case"arbitrum":return"ethers.arbitrum-mainnet.quiknode.pro";case"arbitrum-goerli":return"ethers.arbitrum-goerli.quiknode.pro";case"arbitrum-sepolia":return"ethers.arbitrum-sepolia.quiknode.pro";case"base":return"ethers.base-mainnet.quiknode.pro";case"base-goerli":return"ethers.base-goerli.quiknode.pro";case"base-spolia":return"ethers.base-sepolia.quiknode.pro";case"bnb":return"ethers.bsc.quiknode.pro";case"bnbt":return"ethers.bsc-testnet.quiknode.pro";case"matic":return"ethers.matic.quiknode.pro";case"matic-mumbai":return"ethers.matic-testnet.quiknode.pro";case"optimism":return"ethers.optimism.quiknode.pro";case"optimism-goerli":return"ethers.optimism-goerli.quiknode.pro";case"optimism-sepolia":return"ethers.optimism-sepolia.quiknode.pro";case"xdai":return"ethers.xdai.quiknode.pro"}V(!1,"unsupported network","network",n)}class zg extends Si{constructor(t,r){t==null&&(t="mainnet");const s=Yt.from(t);r==null&&(r=Hg);const i=zg.getRequest(s,r);super(i,s,{staticNetwork:s});$(this,"token");Oe(this,{token:r})}_getProvider(t){try{return new zg(t,this.token)}catch{}return super._getProvider(t)}isCommunityResource(){return this.token===Hg}static getRequest(t,r){r==null&&(r=Hg);const s=new Ln(`https://${cq(t.name)}/${r}`);return s.allowGzip=!0,r===Hg&&(s.retryFunc=async(i,o,a)=>(zc("QuickNodeProvider"),!0)),s}}const uq=BigInt("1"),fq=BigInt("2");function dq(n){for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}}function hq(n){return new Promise(e=>{setTimeout(e,n)})}function H1(){return new Date().getTime()}function z1(n){return JSON.stringify(n,(e,t)=>typeof t=="bigint"?{type:"bigint",value:t.toString()}:t)}const GD={stallTimeout:400,priority:1,weight:1},KD={blockNumber:-2,requests:0,lateResponses:0,errorResponses:0,outOfSync:-1,unsupportedEvents:0,rollingDuration:0,score:0,_network:null,_updateNumber:null,_totalTime:0,_lastFatalError:null,_lastFatalErrorTimestamp:0};async function pq(n,e){for(;(n.blockNumber<0||n.blockNumber<e)&&(n._updateNumber||(n._updateNumber=(async()=>{try{const t=await n.provider.getBlockNumber();t>n.blockNumber&&(n.blockNumber=t)}catch(t){n.blockNumber=-2,n._lastFatalError=t,n._lastFatalErrorTimestamp=H1()}n._updateNumber=null})()),await n._updateNumber,n.outOfSync++,!n._lastFatalError););}function Bd(n){if(n==null)return"null";if(Array.isArray(n))return"["+n.map(Bd).join(",")+"]";if(typeof n=="object"&&typeof n.toJSON=="function")return Bd(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":case"number":return BigInt(n).toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{"+e.map(t=>`${JSON.stringify(t)}:${Bd(n[t])}`).join(",")+"}"}}throw console.log("Could not serialize",n),new Error("Hmm...")}function V1(n){if("error"in n){const t=n.error;return{tag:Bd(t),value:t}}const e=n.result;return{tag:Bd(e),value:e}}function Vg(n,e){const t=new Map;for(const{value:s,tag:i,weight:o}of e){const a=t.get(i)||{value:s,weight:0};a.weight+=o,t.set(i,a)}let r=null;for(const s of t.values())s.weight>=n&&(!r||s.weight>r.weight)&&(r=s);if(r)return r.value}function $1(n,e){let t=0;const r=new Map;let s=null;const i=[];for(const{value:a,tag:l,weight:c}of e)if(a instanceof Error){const u=r.get(l)||{value:a,weight:0};u.weight+=c,r.set(l,u),(s==null||u.weight>s.weight)&&(s=u)}else i.push(BigInt(a)),t+=c;if(t<n)return s&&s.weight>=n?s.value:void 0;i.sort((a,l)=>a<l?-1:l>a?1:0);const o=Math.floor(i.length/2);return i.length%2?i[o]:(i[o-1]+i[o]+uq)/fq}function W1(n,e){const t=Vg(n,e);if(t!==void 0)return t;for(const r of e)if(r.value)return r.value}function mq(n,e){if(n===1)return Je($1(n,e),"%internal");const t=new Map,r=(o,a)=>{const l=t.get(o)||{result:o,weight:0};l.weight+=a,t.set(o,l)};for(const{weight:o,value:a}of e){const l=Je(a);r(l-1,o),r(l,o),r(l+1,o)}let s=0,i;for(const{weight:o,result:a}of t.values())o>=n&&(o>s||i!=null&&o===s&&a>i)&&(s=o,i=a);return i}class gq extends Pg{constructor(t,r,s){super(r,s);q(this,rr);$(this,"quorum");$(this,"eventQuorum");$(this,"eventWorkers");q(this,nr);q(this,Hi);q(this,Iu);I(this,nr,t.map(i=>i instanceof Pg?Object.assign({provider:i},GD,KD):Object.assign({},GD,i,KD))),I(this,Hi,-2),I(this,Iu,null),s&&s.quorum!=null?this.quorum=s.quorum:this.quorum=Math.ceil(T(this,nr).reduce((i,o)=>(i+=o.weight,i),0)/2),this.eventQuorum=1,this.eventWorkers=1,V(this.quorum<=T(this,nr).reduce((i,o)=>i+o.weight,0),"quorum exceed provider weight","quorum",this.quorum)}get providerConfigs(){return T(this,nr).map(t=>{const r=Object.assign({},t);for(const s in r)s[0]==="_"&&delete r[s];return r})}async _detectNetwork(){return Yt.from(Ae(await this._perform({method:"chainId"})))}async _translatePerform(t,r){switch(r.method){case"broadcastTransaction":return await t.broadcastTransaction(r.signedTransaction);case"call":return await t.call(Object.assign({},r.transaction,{blockTag:r.blockTag}));case"chainId":return(await t.getNetwork()).chainId;case"estimateGas":return await t.estimateGas(r.transaction);case"getBalance":return await t.getBalance(r.address,r.blockTag);case"getBlock":{const s="blockHash"in r?r.blockHash:r.blockTag;return await t.getBlock(s,r.includeTransactions)}case"getBlockNumber":return await t.getBlockNumber();case"getCode":return await t.getCode(r.address,r.blockTag);case"getGasPrice":return(await t.getFeeData()).gasPrice;case"getPriorityFee":return(await t.getFeeData()).maxPriorityFeePerGas;case"getLogs":return await t.getLogs(r.filter);case"getStorage":return await t.getStorage(r.address,r.position,r.blockTag);case"getTransaction":return await t.getTransaction(r.hash);case"getTransactionCount":return await t.getTransactionCount(r.address,r.blockTag);case"getTransactionReceipt":return await t.getTransactionReceipt(r.hash);case"getTransactionResult":return await t.getTransactionResult(r.hash)}}async _perform(t){if(t.method==="broadcastTransaction"){const o=T(this,nr).map(c=>null),a=T(this,nr).map(async({provider:c,weight:u},f)=>{try{const d=await c._perform(t);o[f]=Object.assign(V1({result:d}),{weight:u})}catch(d){o[f]=Object.assign(V1({error:d}),{weight:u})}});for(;;){const c=o.filter(d=>d!=null);for(const{value:d}of c)if(!(d instanceof Error))return d;const u=Vg(this.quorum,o.filter(d=>d!=null));if(ln(u,"INSUFFICIENT_FUNDS"))throw u;const f=a.filter((d,h)=>o[h]==null);if(f.length===0)break;await Promise.race(f)}const l=W1(this.quorum,o);if(ee(l!==void 0,"problem multi-broadcasting","SERVER_ERROR",{request:"%sub-requests",info:{request:t,results:o.map(z1)}}),l instanceof Error)throw l;return l}await fe(this,rr,iP).call(this);const r=new Set;let s=0;for(;;){const o=fe(this,rr,ux).call(this,r,t);if(o==null||(s+=o.config.weight,s>=this.quorum))break}const i=await fe(this,rr,fx).call(this,r,t);for(const o of r)o.perform&&o.result==null&&o.config.lateResponses++;return i}async destroy(){for(const{provider:t}of T(this,nr))t.destroy();super.destroy()}}nr=new WeakMap,Hi=new WeakMap,Iu=new WeakMap,rr=new WeakSet,sP=function(t){const r=Array.from(t).map(i=>i.config),s=T(this,nr).slice();dq(s),s.sort((i,o)=>i.priority-o.priority);for(const i of s)if(!i._lastFatalError&&r.indexOf(i)===-1)return i;return null},ux=function(t,r){const s=fe(this,rr,sP).call(this,t);if(s==null)return null;const i={config:s,result:null,didBump:!1,perform:null,staller:null},o=H1();return i.perform=(async()=>{try{s.requests++;const l=await this._translatePerform(s.provider,r);i.result={result:l}}catch(l){s.errorResponses++,i.result={error:l}}const a=H1()-o;s._totalTime+=a,s.rollingDuration=.95*s.rollingDuration+.05*a,i.perform=null})(),i.staller=(async()=>{await hq(s.stallTimeout),i.staller=null})(),t.add(i),i},iP=async function(){let t=T(this,Iu);if(!t){const r=[];T(this,nr).forEach(s=>{r.push((async()=>{await pq(s,0),s._lastFatalError||(s._network=await s.provider.getNetwork())})())}),I(this,Iu,t=(async()=>{await Promise.all(r);let s=null;for(const i of T(this,nr)){if(i._lastFatalError)continue;const o=i._network;s==null?s=o.chainId:o.chainId!==s&&ee(!1,"cannot mix providers on different networks","UNSUPPORTED_OPERATION",{operation:"new FallbackProvider"})}})())}await t},oP=async function(t,r){const s=[];for(const i of t)if(i.result!=null){const{tag:o,value:a}=V1(i.result);s.push({tag:o,value:a,weight:i.config.weight})}if(!(s.reduce((i,o)=>i+o.weight,0)<this.quorum)){switch(r.method){case"getBlockNumber":{T(this,Hi)===-2&&I(this,Hi,Math.ceil(Je($1(this.quorum,T(this,nr).filter(o=>!o._lastFatalError).map(o=>({value:o.blockNumber,tag:Je(o.blockNumber).toString(),weight:o.weight}))))));const i=mq(this.quorum,s);return i===void 0?void 0:(i>T(this,Hi)&&I(this,Hi,i),T(this,Hi))}case"getGasPrice":case"getPriorityFee":case"estimateGas":return $1(this.quorum,s);case"getBlock":return"blockTag"in r&&r.blockTag==="pending"?W1(this.quorum,s):Vg(this.quorum,s);case"call":case"chainId":case"getBalance":case"getTransactionCount":case"getCode":case"getStorage":case"getTransaction":case"getTransactionReceipt":case"getLogs":return Vg(this.quorum,s);case"broadcastTransaction":return W1(this.quorum,s)}ee(!1,"unsupported method","UNSUPPORTED_OPERATION",{operation:`_perform(${z1(r.method)})`})}},fx=async function(t,r){if(t.size===0)throw new Error("no runners?!");const s=[];let i=0;for(const a of t){if(a.perform&&s.push(a.perform),a.staller){s.push(a.staller);continue}a.didBump||(a.didBump=!0,i++)}const o=await fe(this,rr,oP).call(this,t,r);if(o!==void 0){if(o instanceof Error)throw o;return o}for(let a=0;a<i;a++)fe(this,rr,ux).call(this,t,r);return ee(s.length>0,"quorum not met","SERVER_ERROR",{request:"%sub-requests",info:{request:r,results:Array.from(t).map(a=>z1(a.result))}}),await Promise.race(s),await fe(this,rr,fx).call(this,t,r)};function yq(n){return n&&typeof n.send=="function"&&typeof n.close=="function"}const bq="goerli kovan sepolia classicKotti optimism-goerli arbitrum-goerli matic-mumbai bnbt".split(" ");function wq(n,e){e==null&&(e={});const t=o=>e[o]==="-"?!1:typeof e.exclusive=="string"?o===e.exclusive:Array.isArray(e.exclusive)?e.exclusive.indexOf(o)!==-1:!0;if(typeof n=="string"&&n.match(/^https?:/))return new Si(n);if(typeof n=="string"&&n.match(/^wss?:/)||yq(n))return new WD(n);let r=null;try{r=Yt.from(n)}catch{}const s=[];if(t("publicPolygon")&&r&&(r.name==="matic"?s.push(new Si("https://polygon-rpc.com/",r,{staticNetwork:r})):r.name==="matic-amoy"&&s.push(new Si("https://rpc-amoy.polygon.technology/",r,{staticNetwork:r}))),t("alchemy"))try{s.push(new Fg(n,e.alchemy))}catch{}if(t("ankr")&&e.ankr!=null)try{s.push(new _g(n,e.ankr))}catch{}if(t("chainstack"))try{s.push(new Ug(n,e.chainstack))}catch{}if(t("cloudflare"))try{s.push(new qJ(n))}catch{}if(t("etherscan"))try{s.push(new eq(n,e.etherscan))}catch{}if(t("infura"))try{let o=e.infura,a;typeof o=="object"&&(a=o.projectSecret,o=o.projectId),s.push(new _d(n,o,a))}catch{}if(t("quicknode"))try{let o=e.quicknode;s.push(new zg(n,o))}catch{}if(ee(s.length,"unsupported default network","UNSUPPORTED_OPERATION",{operation:"getDefaultProvider"}),s.length===1)return s[0];let i=Math.floor(s.length/2);return i>2&&(i=2),r&&bq.indexOf(r.name)!==-1&&(i=1),e&&e.quorum&&(i=e.quorum),new gq(s,void 0,{quorum:i})}const vq=async(n,e)=>{const t={name:n,isEns:!1};if(!e)throw new Error("cannot fetch ens name without a provider url");if(!gG(n))return t;try{const r=await xq(n,e);r&&(t.name=r,t.isEns=!0)}catch(r){console.log(r)}return t},xq=async(n,e)=>await Aq(e).lookupAddress(n),Aq=n=>wq(n),JD=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],Eq=({isPreviewMode:n,initialContent:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:s,username:i,onAutoSave:o,onChange:a})=>{const[l]=L.useState(new xa),[c,u]=L.useState(!1),[f,d]=L.useState([...EW]),h=Ok({extensions:f,editorProps:j2,autofocus:"start",onUpdate:k=>{x!=null&&x.isEmpty||a==null||a(k.editor.getJSON())}},[f]),p=Ok({extensions:f,editorProps:j2,autofocus:"start",onUpdate:k=>{x!=null&&x.isEmpty||a==null||a(k.editor.getJSON())}}),m=L.useRef(()=>{}),y=(k,S=!1)=>{if(!t||!r||!k)throw new Error("docId or username is not provided");u(!0);const M=new l6(r,l,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});d([...f,I6.configure({document:l}),L6.configure({provider:M,user:{name:k,color:JD[Math.floor(Math.random()*JD.length)],isEns:S},render:NW})]);const O=setTimeout(()=>{u(!1)},100);return m.current=()=>{clearTimeout(O),M.destroy(),l.destroy(),u(!1)},m.current},b=L.useRef(null),x=L.useMemo(()=>t&&r&&h&&!c?h:p,[h,p,c]),v=k=>{var S;(S=b.current)!=null&&S.contains(k.target)||x==null||x.chain().focus().run()};L.useEffect(()=>{x==null||x.chain().focus()},[]),L.useEffect(()=>{x==null||x.setEditable(!n)},[n,x]),L.useEffect(()=>{e&&x&&setTimeout(()=>{x==null||x.commands.setContent(e)})},[e,x]);const w=async()=>{if(!i)return;let k=i,S=!1;if(s){const{name:M,isEns:O}=await vq(i,s);k=M,S=O}y(k,S)};L.useEffect(()=>{t&&i?w():m.current()},[t]);const E=L.useMemo(()=>iv((k,S)=>{S({editorJSONData:k.getJSON()})},1e3),[o]);return L.useEffect(()=>{if(x&&o){const k=()=>{E(x,o)};return x.on("update",k),()=>{x.off("update",k)}}},[x,o,E]),{editor:x,focusEditor:v,ref:b,loading:c,connect:y}},kq=({title:n,content:e,contentClassName:t,open:r,onOpenChange:s,primaryAction:i,secondaryAction:o})=>C.jsx(uU,{open:r,onOpenChange:s,children:C.jsxs(fS,{className:"max-w-md sm:w-full w-[90%] z-20",children:[C.jsx(dS,{className:"px-4 pt-0 border-b-[1px]",children:C.jsx(pS,{className:"text-left text-base",children:n})}),C.jsx("div",{className:pe("flex flex-col gap-4 w-full h-full pb-4 text-base text-black",t),children:e&&e}),C.jsxs(hS,{className:"px-5 pb-5 justify-end sm:",children:[o&&C.jsx(hU,{asChild:!0,children:C.jsx(Pf,{disabled:o==null?void 0:o.isLoading,isLoading:o==null?void 0:o.isLoading,className:o==null?void 0:o.className,variant:(o==null?void 0:o.variant)||"ghost",onClick:o==null?void 0:o.onClick,children:o==null?void 0:o.label})}),i&&C.jsx(Pf,{disabled:i==null?void 0:i.isLoading,isLoading:i==null?void 0:i.isLoading,className:i==null?void 0:i.className,variant:(i==null?void 0:i.variant)||"primary",onClick:i==null?void 0:i.onClick,children:i==null?void 0:i.label})]})]})}),Cq=({editor:n})=>{const{toolVisibilty:e,setToolVisibility:t,bottomToolbar:r}=Sb({editor:n}),[s,i]=L.useState(""),[o,a]=L.useState(""),[l,c]=L.useState(!0),u=()=>{if(s===null){c(!1);return}if(s===""){n.chain().focus().extendMarkRange("link").unsetLink().run(),c(!1);return}let d=s;!s.startsWith("http://")&&!s.startsWith("https://")&&(d="https://"+s);try{d.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&n.chain().focus().extendMarkRange("link").setLink({href:d}).command(({tr:h})=>(h.insertText(o),!0)).run(),c(!0)}catch{console.error("Invalid URL"),c(!1);return}n.chain().focus().extendMarkRange("link").setLink({href:d}).command(({tr:h})=>(h.insertText(o),!0)).run(),c(!0),t(Re.NONE)},f=d=>{const{from:h,to:p}=d.state.selection;return d.state.doc.textBetween(h,p)};return C.jsxs(sS,{children:[C.jsx("div",{className:"flex w-full justify-between sm:justify-evenly",children:r.map(d=>{if(d)return C.jsx("div",{className:"flex items-center",children:d.title==="Text formating"||d.title==="Text color"?C.jsx(aU,{asChild:!0,children:C.jsx("button",{onClick:()=>d.onClick(),children:d.icon})}):C.jsx("button",{className:pe("flex items-center rounded px-2 py-1 text-black transition"),onClick:()=>d.onClick(),children:d.icon})},d.title)})}),e===Re.TEXT_FORMATING&&C.jsx(e8,{editor:n,setToolVisibility:t}),e===Re.TEXT_COLOR_PICKER&&C.jsx(t8,{editor:n,setToolVisibility:t}),e===Re.LINK_POPUP&&C.jsx(kq,{open:e===Re.LINK_POPUP,onOpenChange:()=>t(Re.NONE),title:"Link",content:C.jsxs("div",{className:"flex flex-col gap-4 w-full h-full px-4",children:[C.jsx(dp,{label:"Text",placeholder:"Link text",className:"w-full",defaultValue:f(n),onChange:d=>a(d.target.value)}),C.jsx(dp,{label:"Link",placeholder:"Paste URL",className:"w-full",defaultValue:n.getAttributes("link").href,onChange:d=>{i(d.target.value)},isValid:l,message:l?"":"Invalid URL"})]}),primaryAction:{label:"Save",onClick:()=>u(),isLoading:!1,className:"w-auto min-w-[80px]"},secondaryAction:{label:"Cancel",variant:"secondary",onClick:()=>t(Re.NONE),className:"w-auto min-w-[80px]"}})]})},Sq=({isPreviewMode:n=!1,initialContent:e,enableCollaboration:t,collaborationId:r,username:s,onAutoSave:i,renderToolRightSection:o,renderToolLeftSection:a,ensProviderUrl:l,onChange:c})=>{const{editor:u,focusEditor:f,ref:d,loading:h}=Eq({isPreviewMode:n,initialContent:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:l,username:s,onAutoSave:i,onChange:c});return!u||h?C.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[C.jsx(HS,{}),C.jsx("p",{children:"Loading Editor..."})]}):C.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f8f9fa]",children:C.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:C.jsxs("div",{className:"w-full h-full",children:[C.jsx("div",{className:"flex items-center w-full h-16 fixed z-10 px-4 bg-[#f8f9fa]",children:C.jsxs("div",{className:"flex items-center justify-between gap-2 w-full",children:[C.jsx("div",{className:"grow",children:a==null?void 0:a({editor:u.getJSON()})}),!n&&C.jsx("div",{className:"grow relative hidden xl:block",children:C.jsx(f8,{editor:u})}),o==null?void 0:o({editor:u.getJSON()})]})}),C.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:C.jsx("div",{onClick:f,className:"mt-8 lg:mt-[5rem] w-full flex justify-center relative",children:C.jsx("div",{className:"px-4 pt-12 sm:p-[88px] h-screen bg-white overflow-scroll no-scrollbar w-full sm:w-[70%] max-w-[856px]",children:C.jsxs("div",{ref:d,className:"w-full h-full",children:[!n&&C.jsxs("div",{children:[C.jsx(n8,{editor:u}),C.jsx(c8,{editor:u,appendTo:d})]}),C.jsx(u8,{isPreviewMode:n,children:C.jsx(j3,{editor:u})})]})})})}),!n&&C.jsx("div",{className:"flex xl:hidden items-center w-full h-16 fixed bottom-0 z-10 px-4 bg-[#f8f9fa]",children:C.jsx(Cq,{editor:u})})]})})})};st.DdocEditor=Sq,Object.defineProperty(st,Symbol.toStringTag,{value:"Module"})});