"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["565"],{62372:function(e,t,r){r.d(t,{Eh:()=>G,XI:()=>$,md:()=>g,sJ:()=>W});var n,o,i=r(98661);function s(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e){var t=(0,i.useRef)(null);return function(r){r&&r!==t.current&&(t.current=r,e(r))}}var d="undefined"!=typeof window?i.useLayoutEffect:i.useEffect,h=2987==r.j?{top:0,left:0,right:1,bottom:1,width:1,height:1}:null;function g(e){var t=void 0===e?{}:e,r=t.enabled,n=void 0===r||r,o=t.preventDefault,s=void 0===o||o,u=(0,i.useRef)(null),a=(0,i.useState)(h),l=a[0],c=a[1];return{hasMousePosition:l!==h,resetMousePosition:function(){c(h)},handleMouseEvent:function(e){if(n){s&&e.preventDefault();var t=e.clientX,r=e.clientY;c({top:r,left:t,width:1,height:1,right:t+1,bottom:r+1})}},trigger:{getBounds:function(){return l},getParent:u.current?function(){return u.current}:void 0},parentRef:u}}function v(e){return parseFloat(e.replace("px",""))}function m(e,t,r){return er?r:e}function y(){for(var e=arguments.length,t=Array(e),r=0;r=0})}},{key:"negativeSides",get:function(){var e=this;return Object.fromEntries(j.filter(function(t){return e[t]<0}).map(function(t){return[t,e[t]]}))}}]),e}();function L(){for(var e=arguments.length,t=Array(e),r=0;rg?g-b:0;p[r.prop]=m(b+e+w,h,g),p[r.opposite.prop]=p[r.prop]+r.factor(i[l])}p.width=p.right-p.left,p.height=p.bottom-p.top;var C=H.create(p);return 0===e&&(this._cachedLayerBounds=C),C},t.getLayerCollisionBounds=function(){var e=this.offsets.container;return this.getLayerBounds().mapSides(function(t,r){return r-t.factor(e)}).merge(function(t){return{width:t.width+2*e,height:t.height+2*e}})},t.getContainerOffsets=function(e){if(this._cachedContainerOffsets&&!e)return this._cachedContainerOffsets;var t=this.subjectsBounds.merge({layer:e||this.getLayerCollisionBounds()}),r=k.mergeSmallestSides(t.layerOffsetsToScrollContainers);return e||(this._cachedContainerOffsets=r),r},u(e,[{key:"type",get:function(){return this.primary.prop+"-"+("center"===this.secondary.prop?"center":["bottom","right"].includes(this.secondary.prop)?"end":"start")}},{key:"triggerIsBigger",get:function(){var e=this.secondary.isHorizontal,t=this.subjectsBounds,r=t.triggerHasBiggerWidth,n=t.triggerHasBiggerHeight;return e&&r||!e&&n}},{key:"fitsContainer",get:function(){return this.getContainerOffsets().allSidesArePositive}},{key:"visibleSurface",get:function(){var e=this.getLayerBounds(),t=this.getContainerOffsets(e).negativeSides;for(var r in t)t[r]=-t[r];return e.substract(t).surface}},{key:"secondaryOffsetSide",get:function(){var e,t,r=this;return(null!=(e=null==(t=Object.entries(this.getContainerOffsets().negativeSides).map(function(e){var t=e[0],r=e[1];return[P[t],r]}).filter(function(e){var t=e[0];return r.primary.isOppositeDirection(t)}).sort(function(e,t){var r=e[1];return t[1]-r}))?void 0:t[0])?e:[])[0]||null}}]),e}(),M=function(e){function t(){return e.apply(this,arguments)||this}return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,l(t,e),t.prototype.getLayerBounds=function(){var e=this.subjectsBounds,t=e.trigger,r=e.layer,n=H.empty();return n.top=t.top+t.height/2-r.height/2,n.bottom=n.top+r.height,n.left=t.left+t.width/2-r.width/2,n.right=n.left+r.width,n.width=n.right-n.left,n.height=n.bottom-n.top,n},t}(z),I={position:"absolute",willChange:"top, left",left:null,right:null,top:null,bottom:null},x=function(){function e(e,t,r){this.placements=void 0,this.config=void 0,this.subjectsBounds=void 0,this.placements=e,this.config=t,this.subjectsBounds=r}e.getSidesFromPlacementType=function(e){var t,r=e.split("-"),n=r[0],o=r[1],i=P[n];return t="center"===o?B.center:i.isHorizontal?"start"===o?B.top:B.bottom:"start"===o?B.left:B.right,[i,t]},e.create=function(t,r){var n={arrow:r.arrowOffset,container:r.containerOffset,trigger:r.triggerOffset};function o(o){void 0===o&&(o=r.placement);var i=e.getSidesFromPlacementType(o),s=i[0],u=i[1],a=P[s.isHorizontal?r.preferY:r.preferX],l=!s.isHorizontal&&t.triggerHasBiggerWidth||s.isHorizontal&&t.triggerHasBiggerHeight;function c(e,o){return new z(e,o,t,r.layerDimensions,n)}var f=[];return f[0]=c(s,u),f[1]=c(s,u.isCenter?a:B.center),f[2]=c(s,B[(u.opposite.isCenter?a.opposite:u.opposite).prop]),f[3]=c(a,l?s:B[s.opposite.prop]),f[4]=c(a,B.center),f[5]=c(a,l?B[s.opposite.prop]:s),f[6]=c(P[a.opposite.prop],l?s:B[s.opposite.prop]),f[7]=c(P[a.opposite.prop],B.center),f[8]=c(P[a.opposite.prop],l?B[s.opposite.prop]:s),f[9]=c(P[s.opposite.prop],u),f[10]=c(P[s.opposite.prop],u.isCenter?a:B.center),f[11]=c(P[s.opposite.prop],B[(u.opposite.isCenter?a.opposite:u.opposite).prop]),f=f.filter(function(e){return e.type===r.placement||r.possiblePlacements.includes(e.type)})}return"center"===r.placement?new e([new M(B.center,B.center,t,r.layerDimensions,n)].concat(o(r.preferY+"-"+r.preferX)),r,t):new e(o(),r,t)};var t=e.prototype;return t.filterPlacementsBySide=function(e){return this.placements.filter(function(t){return t.primary===e})},t.findFirstPlacementThatFits=function(){return this.placements.find(function(e){return e.fitsContainer})},t.placementWithBiggestVisibleSurface=function(){return this.placements.map(function(e){return{placement:e,surface:e.visibleSurface}}).sort(function(e,t){return t.surface-e.surface})[0].placement},t.findSuitablePlacement=function(){return this.config.auto?this.findFirstPlacementThatFits()||this.placementWithBiggestVisibleSurface():this.placements[0]},t.getSecondaryOffset=function(e){var t,r=this.config,n=r.auto,o=r.snap;if(!n||o||e instanceof M)return 0;var i=this.filterPlacementsBySide(e.primary);if(0===i.indexOf(e)&&e.fitsContainer)return 0;var s=i.find(function(e){return!e.fitsContainer});if(!s)return 0;var u=s.secondaryOffsetSide;if(!u)return 0;var a=e.getContainerOffsets(),l=e.secondary;return t=e.triggerIsBigger||s===e?u.isPush?-1:1:l===B.left||[B.top,B.center].includes(l)&&u.isPush?-1:1,a[u.prop]*t},t.getStyles=function(e,t,r,n){var o={willChange:"top, left, width, height"};return{arrow:function(e,t,r){if(t.primary.isCenter)return I;var n,o,i,s,u,l,c,f,p,d,h=e.layer,g=e.trigger,v=e.arrow,y=t.primary.oppositeSizeProp,b=g[y]>h[y],w=r+v[y]/2,C=h[y]-v[y]/2-r,S=(n=e.layer,o=e.trigger,i=e.arrow,s=t.primary.oppositeSizeProp,l=(u=t.primary.isHorizontal?["top","bottom"]:["left","right"])[0],c=u[1],((f=n[l]+n[s]/2-o[l]-i[s]/2-r)<0?-f:0)+((p=n[c]-n[s]/2-o[c]+i[s]/2+r)>0?-p:0)),O=t.primary.prop,E=t.primary.oppositeCssProp,P=b?h[y]/2+S:g[E]+g[y]/2-h[E];return a({},I,((d={})[O]="100%",d[E]=m(P,w,C),d))}(this.subjectsBounds.merge({layer:e}),t,this.config.arrowOffset),layer:this.config.overflowContainer?a({},o,{position:"fixed",top:e.top,left:e.left}):a({},o,{position:"absolute",top:e.top-this.subjectsBounds.parent.top+r.top-n.top,left:e.left-this.subjectsBounds.parent.left+r.left-n.left})}},t.getHasDisappeared=function(e){var t=this.config.overflowContainer?this.subjectsBounds.trigger:e,r=k.mergeSmallestSides(this.subjectsBounds.offsetsToScrollContainers(t,!0));return Object.entries(r.negativeSides).some(function(e){var r=e[0];return e[1]<=-t[P[r].sizeProp]})?"full":r.allSidesArePositive?null:"partial"},t.result=function(e,t){var r=this.findSuitablePlacement(),n=this.getSecondaryOffset(r),o=r.getLayerBounds(n);return{styles:this.getStyles(o,r,e,t),layerSide:r.primary.prop,placement:r,layerBounds:o,hasDisappeared:this.getHasDisappeared(o)}},e}(),D=function(){function e(e,t){this.overflowContainer=void 0,this.trigger=void 0,this.layer=void 0,this.arrow=void 0,this.parent=void 0,this.window=void 0,this.scrollContainers=void 0,this.overflowContainer=t,Object.assign(this,e)}e.create=function(t,r,n,o,i,s,u,a){var l=H.fromWindow(t);return new e({layer:H.fromElement(r,{environment:t,withTransform:!1}),trigger:a?H.create(R(a())):H.fromElement(n),arrow:i?H.fromElement(i):H.empty(),parent:o?H.fromElement(o):l,window:l,scrollContainers:[l].concat(s.map(function(e){return H.fromElement(e,{withScrollbars:!1})}))},u)};var t=e.prototype;return t.merge=function(t){return new e(a({},this,t),this.overflowContainer)},t.offsetsToScrollContainers=function(e,t){return void 0===t&&(t=!1),(this.overflowContainer&&!t?[this.window]:this.scrollContainers).map(function(t){return t.offsetsTo(e)})},u(e,[{key:"layerOffsetsToScrollContainers",get:function(){return this.offsetsToScrollContainers(this.layer)}},{key:"triggerHasBiggerWidth",get:function(){return this.trigger.width>this.layer.width}},{key:"triggerHasBiggerHeight",get:function(){return this.trigger.height>this.layer.height}}]),e}(),A={auto:!1,arrowOffset:0,containerOffset:10,triggerOffset:0,overflowContainer:!0,placement:"top-center",possiblePlacements:["bottom-start","bottom-end","bottom-center","top-start","top-center","top-end","left-end","left-center","left-start","right-end","right-center","right-start","center"],preferX:"right",preferY:"bottom",snap:!1,container:void 0};function W(e){var t,r,n,o,s,u,l,c,h,g,m,S,O,E,P,B,j,k,L,R,T,H,z,M,I,W,N,_,X,V,F,G,$,Z,J,U,q,K,Q=e.isOpen,ee=void 0!==Q&&Q,et=e.overflowContainer,er=void 0===et?A.overflowContainer:et,en=e.environment,eo=void 0===en?"undefined"!=typeof window?window:void 0:en,ei=e.ResizeObserver,es=e.placement,eu=void 0===es?A.placement:es,ea=e.possiblePlacements,el=void 0===ea?A.possiblePlacements:ea,ec=e.preferX,ef=void 0===ec?A.preferX:ec,ep=e.preferY,ed=void 0===ep?A.preferY:ep,eh=e.auto,eg=void 0===eh?A.auto:eh,ev=e.snap,em=void 0===ev?A.snap:ev,ey=e.triggerOffset,eb=void 0===ey?A.triggerOffset:ey,ew=e.containerOffset,eC=void 0===ew?A.containerOffset:ew,eS=e.arrowOffset,eO=void 0===eS?A.arrowOffset:eS,eE=e.container,eP=void 0===eE?A.container:eE,eB=e.layerDimensions,ej=void 0===eB?null:eB,ek=e.onDisappear,eL=e.onOutsideClick,eR=e.onParentClose,eT=e.trigger,eH=(0,i.useState)(function(){return{layerSide:"center"===eu?"center":x.getSidesFromPlacementType(eu)[0].prop,styles:{layer:{position:er?"fixed":"absolute",top:0,left:0},arrow:{position:"absolute",top:0,left:0}}}}),ez=eH[0],eM=eH[1],eI=(0,i.useRef)(null),ex=(t=(0,i.useRef)(ez),ee?t.current=ez:t.current=null,t),eD=(0,i.useRef)({cancelled:!1});(0,i.useEffect)(function(){return function(){eD.current.cancelled=!0}},[]);var eA=(0,i.useCallback)(function(e,t,r){var n=e.arrow,o=e.layer,i=e.scrollContainers,s=e.trigger,u=i[0],a=D.create(eo,o,s,u,n,i,er,null==eT?void 0:eT.getBounds),l=x.create(a,{placement:eu,possiblePlacements:el,auto:eg,layerDimensions:ej,arrowOffset:eO,containerOffset:eC,triggerOffset:eb,preferX:ef,preferY:ed,snap:em,overflowContainer:er}).result(t,r),c=l.hasDisappeared,f={layerSide:l.layerSide,styles:l.styles};if(!ex.current||function(e,t){if(e.layerSide!==t.layerSide)return!0;for(var r=0,n=["position","top","left","right","bottom"];r0},removeAllEventSubscriptions:function(){for(var e,t=f(j.current);!(e=t()).done;)(0,e.value)();j.current=[]},addEventSubscription:function(e){j.current.push(e)}}},[])).hasEventSubscriptions,R=k.addEventSubscription,T=k.removeAllEventSubscriptions,H=(0,i.useCallback)(function(){var e=P(),t=e.layer,r=e.trigger,n=e.scrollContainers,i=n[0];if(!t)throw Error(b("layer"));if(!r&&!m)throw Error(b("trigger"));var u={top:0,left:0};if(i){var a=i.scrollLeft;u={top:i.scrollTop,left:a}}else{var l=s.scrollX;u={top:s.scrollY,left:l}}var c={left:0,top:0};if(i){var f=s.getComputedStyle(i),p=f.borderLeftWidth,d=f.borderTopWidth;c={left:v(p)||0,top:v(d)||0}}o({layer:t,trigger:r,scrollContainers:n,arrow:g.current},u,c)},[P,o,s,g,m]),z=(0,i.useCallback)(function(){var e=P(),t=e.trigger,r=e.layer,n=e.scrollContainers;if(!r)throw Error(b("layer"));if(!t&&!m)throw Error(b("trigger"));if(h){for(var o=!1,i=new h(function(){if(!o){o=!0;return}H()}),u=0,a=[t,r,document.body];u=0||(o[r]=e[r]);return o}(e,N);if("center"===M)return null;var D=P[M],A=2*F(B,O),W=Math.max(O,A);return(0,i.createElement)("svg",a({ref:t},x,{style:a({},void 0===I?{}:I,{transform:"translate"+(D.isHorizontal?"Y":"X")+"(-50%)"}),width:W,height:W,preserveAspectRatio:D.isPush?"xMinYMin":"xMaxYMax",viewBox:((r={})[X]="0 "+-k+" "+A+" "+O,r.top="0 0 "+A+" "+(O+k),r[V]=-k+" 0 "+O+" "+A,r[_]="0 0 "+(O+k)+" "+A,r)[D.prop]}),(0,i.createElement)("path",{fill:H,strokeWidth:k,stroke:void 0===L?"black":L,d:(u=(void 0===R?0:R)/10*O*2,l=((n={})[X]=[0,O],n.top=[0,0],n[V]=[O,A],n[_]=[0,A],n)[D.prop].join(" "),c=D.isHorizontal?"V 0":"H "+A,f=A/2,p=A/2+F(B,O/8),d=O/8,h=((o={})[X]=["C",p,d,f+u,0,f,0],o.top=["C",p,O-d,f+u,O,f,O],o[V]=["C",d,A-p,0,f-u,0,f],o[_]=["C",O-d,A-p,O,f-u,O,f],o)[D.prop].join(" "),g=A/2-F(B,O/8),v=O/8,m=((s={})[X]=["C",f-u,0,g,v,l],s.top=["C",f-u,O,g,O-v,l],s[V]=["C",0,f+u,v,A-g,l],s[_]=["C",O,f+u,O-v,A-g,l],s)[D.prop].join(" "),["M",l,c,h,m].join(" "))}),(0,i.createElement)("path",{fill:H,d:(y=F(B,k),w=(b=D.isPush?[0,k]:[O,O-k])[0],C=b[1],D.isHorizontal?["M",w,k,"V",A-k,"L",C,A-k-y,"V",y+k,"Z"].join(" "):["M",k,w,"H",A-k,"L",A-k-y,C,"H",y+k,"Z"].join(" "))}))}):null;function $(e){var t=void 0===e?{}:e,r=t.delayEnter,n=void 0===r?0:r,s=t.delayLeave,u=void 0===s?0:s,a=t.hideOnScroll,l=void 0===a||a,c=(0,i.useState)(!1),f=c[0],p=c[1],d=(0,i.useRef)(null),h=(0,i.useRef)(o.IDLE),g=(0,i.useRef)(!1),v=(0,i.useCallback)(function(){clearTimeout(d.current),d.current=null,h.current=o.IDLE},[]);function m(e,t){if(h.current===o.ENTERING&&d.current&&v(),f){if(t){p(!1),d.current=null,h.current=o.IDLE;return}h.current=o.LEAVING,d.current=window.setTimeout(function(){p(!1),d.current=null,h.current=o.IDLE},u)}}return(0,i.useEffect)(function(){function e(){f&&l&&(v(),p(!1))}return window.addEventListener("scroll",e,!0),function(){window.removeEventListener("scroll",e,!0),d.current&&clearTimeout(d.current)}},[f,l,v]),[f,{onMouseEnter:function(){h.current===o.LEAVING&&d.current&&v(),!f&&(h.current=o.ENTERING,d.current=window.setTimeout(function(){p(!0),d.current=null,h.current=o.IDLE},n))},onMouseLeave:m,onTouchStart:function(){g.current=!1},onTouchMove:function(){g.current=!0},onTouchEnd:function(){g.current||f||p(!0),g.current=!1}},function(){return m(null,!0)}]}(n=o||(o={}))[n.ENTERING=0]="ENTERING",n[n.LEAVING=1]="LEAVING",n[n.IDLE=2]="IDLE"}}]);