@gentbajko/slopify 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,14 +46,14 @@ Error generating stack: `+e.message+`
46
46
  `},kd=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Ad=function(){m.useEffect(function(){return document.body.setAttribute(Dd,(kd()+1).toString()),function(){var e=kd()-1;e<=0?document.body.removeAttribute(Dd):document.body.setAttribute(Dd,e.toString())}},[])},jd=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Ad();var a=m.useMemo(function(){return Td(i)},[i]);return m.createElement(Ed,{styles:Od(a,!t,i,n?``:`!important`)})},Md=!1;if(typeof window<`u`)try{var Nd=Object.defineProperty({},"passive",{get:function(){return Md=!0,!0}});window.addEventListener(`test`,Nd,Nd),window.removeEventListener(`test`,Nd,Nd)}catch{Md=!1}var Pd=Md?{passive:!1}:!1,Fd=function(e){return e.tagName===`TEXTAREA`},Id=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Fd(e)&&n[t]===`visible`)},Ld=function(e){return Id(e,`overflowY`)},Rd=function(e){return Id(e,`overflowX`)},zd=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Hd(e,r)){var i=Ud(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Bd=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Vd=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Hd=function(e,t){return e===`v`?Ld(t):Rd(t)},Ud=function(e,t){return e===`v`?Bd(t):Vd(t)},Wd=function(e,t){return e===`h`&&t===`rtl`?-1:1},Gd=function(e,t,n,r,i){var a=Wd(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Ud(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Hd(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Kd=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},qd=function(e){return[e.deltaX,e.deltaY]},Jd=function(e){return e&&`current`in e?e.current:e},Yd=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Xd=function(e){return`
47
47
  .block-interactivity-${e} {pointer-events: none;}
48
48
  .allow-interactivity-${e} {pointer-events: all;}
49
- `},Zd=0,Qd=[];function $d(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(Zd++)[0],a=m.useState(xd)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Zu([e.lockRef.current],(e.shards||[]).map(Jd),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Kd(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=zd(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=zd(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Gd(h,t,e,h===`h`?s:c,!0)},[]),c=m.useCallback(function(e){var n=e;if(Qd.length&&Qd[Qd.length-1]===a){var r=`deltaY`in n?qd(n):Kd(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Yd(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Jd).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=m.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ef(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=m.useCallback(function(e){n.current=Kd(e),r.current=void 0},[]),d=m.useCallback(function(t){l(t.type,qd(t),t.target,s(t,e.lockRef.current))},[]),f=m.useCallback(function(t){l(t.type,Kd(t),t.target,s(t,e.lockRef.current))},[]);m.useEffect(function(){return Qd.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Pd),document.addEventListener(`touchmove`,c,Pd),document.addEventListener(`touchstart`,u,Pd),function(){Qd=Qd.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Pd),document.removeEventListener(`touchmove`,c,Pd),document.removeEventListener(`touchstart`,u,Pd)}},[]);var p=e.removeScrollBar,h=e.inert;return m.createElement(m.Fragment,null,h?m.createElement(a,{styles:Xd(i)}):null,p?m.createElement(jd,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ef(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var tf=dd(fd,$d),nf=m.forwardRef(function(e,t){return m.createElement(md,Yu({},e,{ref:t,sideCar:tf}))});nf.classNames=md.classNames;var rf=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},af=new WeakMap,of=new WeakMap,sf={},cf=0,lf=function(e){return e&&(e.host||lf(e.parentNode))},uf=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=lf(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},df=function(e,t,n,r){var i=uf(t,Array.isArray(e)?e:[e]);sf[n]||(sf[n]=new WeakMap);var a=sf[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(af.get(e)||0)+1,l=(a.get(e)||0)+1;af.set(e,c),a.set(e,l),o.push(e),c===1&&i&&of.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),cf++,function(){o.forEach(function(e){var t=af.get(e)-1,i=a.get(e)-1;af.set(e,t),a.set(e,i),t||(of.has(e)||e.removeAttribute(r),of.delete(e)),i||e.removeAttribute(n)}),cf--,cf||(af=new WeakMap,af=new WeakMap,of=new WeakMap,sf={})}},ff=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||rf(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),df(r,i,n,`aria-hidden`)):function(){return null}},pf=Object.defineProperty,mf=(e,t)=>pf(e,`name`,{value:t,configurable:!0}),hf=`Dialog`,[gf,_f]=cl(hf),[vf,yf]=gf(hf),bf=mf(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=m.useRef(null),c=m.useRef(null),[l,u]=K({prop:r,defaultProp:i??!1,onChange:a,caller:hf}),[d,f]=m.useState(0),[p,g]=m.useState(0);return(0,h.jsx)(vf,{scope:t,triggerRef:s,contentRef:c,contentId:tu(),titleId:tu(),descriptionId:tu(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:g,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),xf=`DialogPortal`,[Sf,Cf]=gf(xf,{forceMount:void 0}),wf=mf(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=yf(xf,t);return(0,h.jsx)(Sf,{scope:t,forceMount:n,children:m.Children.map(r,e=>(0,h.jsx)(Gl,{present:n||a.open,children:(0,h.jsx)(Vu,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Tf=`DialogOverlay`,Ef=m.forwardRef(mf(function(e,t){let n=Cf(Tf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yf(Tf,e.__scopeDialog);return a.modal?(0,h.jsx)(Gl,{present:r||a.open,children:(0,h.jsx)(Of,{...i,ref:t})}):null},`DialogOverlay`)),Df=zc(`DialogOverlay.RemoveScroll`),Of=m.forwardRef(mf(function(e,t){let{__scopeDialog:n,...r}=e,i=yf(Tf,n),a=Ic(t,_u());return(0,h.jsx)(nf,{as:Df,allowPinchZoom:!0,shards:[i.contentRef],children:(0,h.jsx)(nl.div,{"data-state":Rf(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),kf=`DialogContent`,Af=m.forwardRef(mf(function(e,t){let n=Cf(kf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yf(kf,e.__scopeDialog);return(0,h.jsx)(Gl,{present:r||a.open,children:a.modal?(0,h.jsx)(jf,{...i,ref:t}):(0,h.jsx)(Mf,{...i,ref:t})})},`DialogContent`)),jf=m.forwardRef(mf(function(e,t){let n=yf(kf,e.__scopeDialog),r=m.useRef(null),i=Ic(t,n.contentRef,r);return m.useEffect(()=>{let e=r.current;if(e)return ff(e)},[]),(0,h.jsx)(Nf,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:G(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Mf=m.forwardRef(mf(function(e,t){let n=yf(kf,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(Nf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Nf=m.forwardRef(mf(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=yf(kf,n);return qu(),(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(Ou,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(gu,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Rf(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Pf=`DialogTitle`,Ff=m.forwardRef(mf(function(e,t){let{__scopeDialog:n,...r}=e,i=yf(Pf,n),{setTitleCount:a}=i;return Al(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,h.jsx)(nl.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),If=`DialogDescription`,Lf=m.forwardRef(mf(function(e,t){let{__scopeDialog:n,...r}=e,i=yf(If,n),{setDescriptionCount:a}=i;return Al(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,h.jsx)(nl.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`));function Rf(e){return e?`open`:`closed`}mf(Rf,`getState`);var zf=Object.defineProperty,Bf=(e,t)=>zf(e,`name`,{value:t,configurable:!0});function Vf(e){let[t,n]=m.useState(void 0);return Al(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}Bf(Vf,`useSize`);var Hf=[`top`,`right`,`bottom`,`left`],Uf=Math.min,Wf=Math.max,Gf=Math.round,Kf=Math.floor,qf=e=>({x:e,y:e}),Jf={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Yf(e,t,n){return Wf(e,Uf(t,n))}function Xf(e,t){return typeof e==`function`?e(t):e}function Zf(e){return e.split(`-`)[0]}function Qf(e){return e.split(`-`)[1]}function $f(e){return e===`x`?`y`:`x`}function ep(e){return e===`y`?`height`:`width`}function tp(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function np(e){return $f(tp(e))}function rp(e,t,n){n===void 0&&(n=!1);let r=Qf(e),i=np(e),a=ep(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=fp(o)),[o,fp(o)]}function ip(e){let t=fp(e);return[ap(e),t,ap(t)]}function ap(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var op=[`left`,`right`],sp=[`right`,`left`],cp=[`top`,`bottom`],lp=[`bottom`,`top`];function up(e,t,n){switch(e){case`top`:case`bottom`:return n?t?sp:op:t?op:sp;case`left`:case`right`:return t?cp:lp;default:return[]}}function dp(e,t,n,r){let i=Qf(e),a=up(Zf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ap)))),a}function fp(e){let t=Zf(e);return Jf[t]+e.slice(t.length)}function pp(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function mp(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:pp(e)}function hp(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function gp(e,t,n){let{reference:r,floating:i}=e,a=tp(t),o=np(t),s=ep(o),c=Zf(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Qf(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function _p(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Xf(t,e),p=mp(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=hp(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=hp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var vp=50,yp=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:_p},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=gp(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<vp&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=gp(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},bp=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Xf(e,t)||{};if(l==null)return{};let d=mp(u),f={x:n,y:r},p=np(i),m=ep(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Uf(d[_],T),D=Uf(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=Yf(E,k,O),j=!c.arrow&&Qf(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),xp=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Xf(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Zf(r),_=tp(o),v=Zf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[fp(o)]:ip(o)),x=p!==`none`;!d&&x&&b.push(...dp(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=rp(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===tp(t)||T.every(e=>tp(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=tp(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Sp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Cp(e){return Hf.some(t=>e[t]>=0)}var wp=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Xf(e,t);switch(i){case`referenceHidden`:{let e=Sp(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Cp(e)}}}case`escaped`:{let e=Sp(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Cp(e)}}}default:return{}}}}},Tp=new Set([`left`,`top`]);async function Ep(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Zf(n),s=Qf(n),c=tp(n)===`y`,l=Tp.has(o)?-1:1,u=a&&c?-1:1,d=Xf(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Dp=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Ep(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Op=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Xf(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=tp(i),p=$f(f),m=u[p],h=u[f],g=(e,t)=>Yf(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},kp=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Xf(e,t),u={x:n,y:r},d=tp(i),f=$f(d),p=u[f],m=u[d],h=Xf(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Tp.has(Zf(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Ap=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Xf(e,t),c=await i.detectOverflow(t,s),l=Zf(n),u=Qf(n),d=tp(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Uf(p-c[m],g),y=Uf(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Wf(c.left,c.right):S=p-2*Wf(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function jp(){return typeof window<`u`}function Mp(e){return Fp(e)?(e.nodeName||``).toLowerCase():`#document`}function Np(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Pp(e){return((Fp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Fp(e){return jp()?e instanceof Node||e instanceof Np(e).Node:!1}function Ip(e){return jp()?e instanceof Element||e instanceof Np(e).Element:!1}function Lp(e){return jp()?e instanceof HTMLElement||e instanceof Np(e).HTMLElement:!1}function Rp(e){return!jp()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Np(e).ShadowRoot}function zp(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Xp(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Bp(e){return/^(table|td|th)$/.test(Mp(e))}function Vp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Hp=/transform|translate|scale|rotate|perspective|filter/,Up=/paint|layout|strict|content/,Wp=e=>!!e&&e!==`none`,Gp;function Kp(e){let t=Ip(e)?Xp(e):e;return Wp(t.transform)||Wp(t.translate)||Wp(t.scale)||Wp(t.rotate)||Wp(t.perspective)||!Jp()&&(Wp(t.backdropFilter)||Wp(t.filter))||Hp.test(t.willChange||``)||Up.test(t.contain||``)}function qp(e){let t=Qp(e);for(;Lp(t)&&!Yp(t);){if(Kp(t))return t;if(Vp(t))return null;t=Qp(t)}return null}function Jp(){return Gp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Gp}function Yp(e){return/^(html|body|#document)$/.test(Mp(e))}function Xp(e){return Np(e).getComputedStyle(e)}function Zp(e){return Ip(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qp(e){if(Mp(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Rp(e)&&e.host||Pp(e);return Rp(t)?t.host:t}function $p(e){let t=Qp(e);return Yp(t)?(e.ownerDocument||e).body:Lp(t)&&zp(t)?t:$p(t)}function em(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=$p(e),i=r===e.ownerDocument?.body,a=Np(r);if(i){let e=tm(a);return t.concat(a,a.visualViewport||[],zp(r)?r:[],e&&n?em(e):[])}return t.concat(r,em(r,[],n))}function tm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nm(e){let t=Xp(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Lp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Gf(n)!==a||Gf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function rm(e){return Ip(e)?e:e.contextElement}function im(e){let t=rm(e);if(!Lp(t))return qf(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=nm(t),o=(a?Gf(n.width):n.width)/r,s=(a?Gf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var am=qf(0);function om(e){let t=Np(e);return!Jp()||!t.visualViewport?am:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sm(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Np(e)}function cm(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=rm(e),o=qf(1);t&&(r?Ip(r)&&(o=im(r)):o=im(e));let s=sm(a,n,r)?om(a):qf(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Np(a),t=Ip(r)?Np(r):r,n=e,i=tm(n);for(;i&&t!==n;){let e=im(i),t=i.getBoundingClientRect(),r=Xp(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Np(i),i=tm(n)}}return hp({width:u,height:d,x:c,y:l})}function lm(e,t){let n=Zp(e).scrollLeft;return t?t.left+n:cm(Pp(e)).left+n}function um(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-lm(e,n),y:n.top+t.scrollTop}}function dm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Pp(r),s=t?Vp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qf(1),u=qf(0),d=Lp(r);if((d||!a)&&((Mp(r)!==`body`||zp(o))&&(c=Zp(r)),d)){let e=cm(r);l=im(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?um(o,c):qf(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function fm(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function pm(e){let t=Zp(e),n=e.ownerDocument.body,r=Wf(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Wf(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+lm(e),o=-t.scrollTop;return Xp(n).direction===`rtl`&&(a+=Wf(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var mm=25;function hm(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Np(e),a=Pp(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Jp()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(lm(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=mm&&(s-=o)}return{width:s,height:c,x:l,y:u}}function gm(e,t){let n=cm(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=im(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function _m(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=hm(e,n,t);else if(t===`document`)r=pm(Pp(e));else if(Ip(t))r=gm(t,n);else{let n=om(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return hp(r)}function vm(e,t){let n=t.get(e);if(n)return n;let r=em(e,[],!1).filter(e=>Ip(e)&&Mp(e)!==`body`),i=null,a=Xp(e).position===`fixed`,o=a?Qp(e):e;for(;Ip(o)&&!Yp(o);){let e=Xp(o),t=Kp(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Qp(o)}return t.set(e,r),r}function ym(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Vp(t)?[]:vm(t,this._c):[].concat(n),r],o=_m(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=_m(t,a[e],i);s=Wf(n.top,s),c=Uf(n.right,c),l=Uf(n.bottom,l),u=Wf(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function bm(e){let{width:t,height:n}=nm(e);return{width:t,height:n}}function xm(e,t,n){let r=Lp(t),i=Pp(t),a=n===`fixed`,o=cm(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=qf(0);if((r||!a)&&((Mp(t)!==`body`||zp(i))&&(s=Zp(t)),r)){let e=cm(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=lm(i));let l=i&&!r&&!a?um(i,s):qf(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Sm(e){return Xp(e).position===`static`}function Cm(e,t){if(!Lp(e)||Xp(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Pp(e)===n&&(n=n.ownerDocument.body),n}function wm(e,t){let n=Np(e);if(Vp(e))return n;if(!Lp(e)){let t=Qp(e);for(;t&&!Yp(t);){if(Ip(t)&&!Sm(t))return t;t=Qp(t)}return n}let r=Cm(e,t);for(;r&&Bp(r)&&Sm(r);)r=Cm(r,t);return r&&Yp(r)&&Sm(r)&&!Kp(r)?n:r||qp(e)||n}var Tm=async function(e){let t=this.getOffsetParent||wm,n=this.getDimensions,r=await n(e.floating);return{reference:xm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Em(e){return Xp(e).direction===`rtl`}var Dm={convertOffsetParentRelativeRectToViewportRelativeRect:dm,getDocumentElement:Pp,getClippingRect:ym,getOffsetParent:wm,getElementRects:Tm,getClientRects:fm,getDimensions:bm,getScale:im,isElement:Ip,isRTL:Em};function Om(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function km(e,t,n){let r=null,i,a=Pp(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Kf(d),h=Kf(a.clientWidth-(u+f)),g=Kf(a.clientHeight-(d+p)),_=Kf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Wf(0,Uf(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Om(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Np(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Am(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=rm(e),u=i||a?[...l?em(l):[],...t?em(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?km(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?cm(e):null;c&&g();function g(){let t=cm(e);h&&!Om(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var jm=Dp,Mm=Op,Nm=xp,Pm=Ap,Fm=wp,Im=bp,Lm=kp,Rm=(e,t,n)=>{let r=new Map,i=n??{},a={...Dm,...i.platform,_c:r};return yp(e,t,{...i,platform:a})},zm=typeof document<`u`?m.useLayoutEffect:function(){};function Bm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Bm(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Bm(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Vm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hm(e,t){let n=Vm(e);return Math.round(t*n)/n}function Um(e){let t=m.useRef(e);return zm(()=>{t.current=e}),t}function Wm(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);Bm(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=Um(c),O=Um(i),k=Um(l),A=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Rm(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Bm(T.current,t)&&(T.current=t,$c.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);zm(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=m.useRef(!1);zm(()=>(j.current=!0,()=>{j.current=!1}),[]),zm(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=m.useMemo(()=>({reference:x,floating:S}),[x,S]),P=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Hm(N.floating,u.x),r=Hm(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Vm(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Gm=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Im({element:r.current,padding:i}).fn(n):r?Im({element:r,padding:i}).fn(n):{}}}},Km=(e,t)=>{let n=jm(e);return{name:n.name,fn:n.fn,options:[e,t]}},qm=(e,t)=>{let n=Mm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jm=(e,t)=>({fn:Lm(e).fn,options:[e,t]}),Ym=(e,t)=>{let n=Nm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xm=(e,t)=>{let n=Pm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zm=(e,t)=>{let n=Fm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qm=(e,t)=>{let n=Gm(e);return{name:n.name,fn:n.fn,options:[e,t]}},$m=Object.defineProperty,eh=(e,t)=>$m(e,`name`,{value:t,configurable:!0}),th=`Popper`,[nh,rh]=cl(th),[ih,ah]=nh(th),oh=eh(e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,h.jsx)(ih,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),sh=`PopperAnchor`,ch=m.forwardRef(eh(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=ah(sh,n),o=m.useRef(null),s=a.onAnchorChange,c=Ic(t,m.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&hh(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,h.jsx)(nl.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),lh=`PopperContent`,[uh,dh]=nh(lh),fh=m.forwardRef(eh(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:g,..._}=e,v=ah(lh,n),[y,b]=m.useState(null),x=Ic(t,b),[S,C]=m.useState(null),w=Vf(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(l)?l:[l],A=k.length>0,j={padding:O,boundary:k.filter(ph),altBoundary:A},{refs:M,floatingStyles:N,placement:P,isPositioned:F,middlewareData:I}=Wm({strategy:`fixed`,placement:D,whileElementsMounted:eh((...e)=>Am(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[Km({mainAxis:i+E,alignmentAxis:o}),c&&qm({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Jm():void 0,...j}),c&&Ym({...j}),Xm({...j,apply:eh(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&Qm({element:S,padding:s}),mh({arrowWidth:T,arrowHeight:E}),f&&Zm({strategy:`referenceHidden`,...j,boundary:A?j.boundary:void 0})]}),ee=v.setPlacementState;Al(()=>(ee(P),()=>{ee(void 0)}),[P,ee]);let[te,ne]=hh(P),L=cu(g);Al(()=>{F&&L?.()},[F,L]);let re=I.arrow?.x,ie=I.arrow?.y,ae=I.arrow?.centerOffset!==0,[oe,se]=m.useState();return Al(()=>{y&&se(window.getComputedStyle(y).zIndex)},[y]),(0,h.jsx)(`div`,{ref:M.setFloating,"data-radix-popper-content-wrapper":``,style:{...N,transform:F?N.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(` `),...I.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,h.jsx)(uh,{scope:n,placedSide:te,placedAlign:ne,onArrowChange:C,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,h.jsx)(nl.div,{"data-side":te,"data-align":ne,..._,ref:x,style:{..._.style,animation:F?_.style?.animation:`none`}})})})},`PopperContent`));function ph(e){return e!==null}eh(ph,`isNotNull`);var mh=eh(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=hh(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function hh(e){let[t,n=`center`]=e.split(`-`);return[t,n]}eh(hh,`getSideAndAlignFromPlacement`);var gh=oh,_h=ch,vh=fh,yh=Object.defineProperty,bh=(e,t)=>yh(e,`name`,{value:t,configurable:!0}),xh=!1;function Sh(){let[e,t]=m.useState(xh);return m.useEffect(()=>{xh||(xh=!0,t(!0))},[]),e}bh(Sh,`useIsHydrated`);var Ch=m.useSyncExternalStore;function wh(){return()=>{}}bh(wh,`subscribe`);function Th(){return Ch(wh,()=>!0,()=>!1)}bh(Th,`useIsHydratedModern`);var Eh=typeof Ch==`function`?Th:Sh,Dh=Object.defineProperty,Oh=(e,t)=>Dh(e,`name`,{value:t,configurable:!0}),kh=`rovingFocusGroup.onEntryFocus`,Ah={bubbles:!1,cancelable:!0},jh=`RovingFocusGroup`,[Mh,Nh,Ph]=fl(jh),[Fh,Ih]=cl(jh,[Ph]),[Lh,Rh]=Fh(jh),zh=m.forwardRef(Oh(function(e,t){return(0,h.jsx)(Mh.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,h.jsx)(Mh.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,h.jsx)(Bh,{...e,ref:t})})})},`RovingFocusGroup`)),Bh=m.forwardRef(Oh(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=m.useRef(null),p=Ic(t,f),g=au(a),[_,v]=K({prop:o,defaultProp:s??null,onChange:c,caller:jh}),[y,b]=m.useState(!1),x=cu(l),S=Nh(n),C=m.useRef(!1),[w,T]=m.useState(0);return m.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(kh,x),()=>e.removeEventListener(kh,x)},[x]),(0,h.jsx)(Lh,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:m.useCallback(e=>v(e),[v]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(e=>e+1),[]),onFocusableItemRemove:m.useCallback(()=>T(e=>e-1),[]),children:(0,h.jsx)(nl.div,{tabIndex:y||w===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:G(e.onMouseDown,()=>{C.current=!0}),onFocus:G(e.onFocus,e=>{let t=!C.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent(kh,Ah);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=S().filter(e=>e.focusable);Kh([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),u)}}C.current=!1}),onBlur:G(e.onBlur,()=>b(!1))})})},`RovingFocusGroupImpl`)),Vh=`RovingFocusGroupItem`,Hh=m.forwardRef(Oh(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=tu(),l=a||c,u=Rh(Vh,n),d=u.currentTabStopId===l,f=Nh(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:_}=u,v=Eh();return Al(()=>{if(v&&r)return p(),()=>g()},[v,r,p,g]),m.useEffect(()=>{if(!v&&r)return p(),()=>g()},[v,r,p,g]),(0,h.jsx)(Mh.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,h.jsx)(nl.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:G(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:G(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:G(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Gh(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?qh(n,r+1):n.slice(r+1)}setTimeout(()=>Kh(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:_!=null}):o})})},`RovingFocusGroupItem`)),Uh={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Wh(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}Oh(Wh,`getDirectionAwareKey`);function Gh(e,t,n){let r=Wh(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Uh[r]}Oh(Gh,`getFocusIntent`);function Kh(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Oh(Kh,`focusFirst`);function qh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Oh(qh,`wrapArray`);var Jh=zh,Yh=Hh,Xh=Object.defineProperty,Zh=(e,t)=>Xh(e,`name`,{value:t,configurable:!0}),Qh=[`Enter`,` `],$h=[`ArrowDown`,`PageUp`,`Home`],eg=[`ArrowUp`,`PageDown`,`End`],tg=[...$h,...eg];[...Qh],[...Qh];var ng=`Menu`,[rg,ig,ag]=fl(ng),[og,sg]=cl(ng,[ag,rh,Ih]),cg=rh(),lg=Ih(),[ug,dg]=og(ng),[fg,pg]=og(ng),mg=Zh(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=cg(t),[c,l]=m.useState(null),u=m.useRef(!1),d=cu(a),f=au(i);return m.useEffect(()=>{let e=Zh(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=Zh(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),m.useEffect(()=>{if(!n)return;let e=Zh(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,h.jsx)(gh,{...s,children:(0,h.jsx)(ug,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,h.jsx)(fg,{scope:t,onClose:m.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),hg=m.forwardRef(Zh(function(e,t){let{__scopeMenu:n,...r}=e,i=cg(n);return(0,h.jsx)(_h,{...i,...r,ref:t})},`MenuAnchor`)),gg=`MenuPortal`,[_g,vg]=og(gg,{forceMount:void 0}),yg=Zh(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=dg(gg,t);return(0,h.jsx)(_g,{scope:t,forceMount:n,children:(0,h.jsx)(Gl,{present:n||a.open,children:(0,h.jsx)(Vu,{asChild:!0,container:i,children:r})})})},`MenuPortal`),bg=`MenuContent`,[xg,Sg]=og(bg),Cg=m.forwardRef(Zh(function(e,t){let n=vg(bg,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=dg(bg,e.__scopeMenu),o=pg(bg,e.__scopeMenu);return(0,h.jsx)(rg.Provider,{scope:e.__scopeMenu,children:(0,h.jsx)(Gl,{present:r||a.open,children:(0,h.jsx)(rg.Slot,{scope:e.__scopeMenu,children:o.modal?(0,h.jsx)(wg,{...i,ref:t}):(0,h.jsx)(Tg,{...i,ref:t})})})})},`MenuContent`)),wg=m.forwardRef(Zh(function(e,t){let n=dg(bg,e.__scopeMenu),r=m.useRef(null),i=Ic(t,r);return m.useEffect(()=>{let e=r.current;if(e)return ff(e)},[]),(0,h.jsx)(Dg,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Tg=m.forwardRef(Zh(function(e,t){let n=dg(bg,e.__scopeMenu);return(0,h.jsx)(Dg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Eg=zc(`MenuContent.ScrollLock`),Dg=m.forwardRef(Zh(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:g,..._}=e,v=dg(bg,n),y=pg(bg,n),b=cg(n),x=lg(n),S=ig(n),[C,w]=m.useState(null),T=m.useRef(null),E=Ic(t,T,v.onContentChange),D=m.useRef(0),O=m.useRef(``),k=m.useRef(0),A=m.useRef(null),j=m.useRef(`right`),M=m.useRef(0),N=g?nf:m.Fragment,P=g?{as:Eg,allowPinchZoom:!0}:void 0,F=Zh(e=>{let t=O.current+e,n=S().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Ug(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;Zh((function e(t){O.current=t,window.clearTimeout(D.current),t!==``&&(D.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);m.useEffect(()=>()=>window.clearTimeout(D.current),[]),qu();let I=m.useCallback(e=>j.current===A.current?.side&&Gg(e,A.current?.area),[]);return(0,h.jsx)(xg,{scope:n,searchRef:O,onItemEnter:m.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:m.useCallback(e=>{I(e)||(T.current?.focus(),w(null))},[I]),onTriggerLeave:m.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:k,onPointerGraceIntentChange:m.useCallback(e=>{A.current=e},[]),children:(0,h.jsx)(N,{...P,children:(0,h.jsx)(Ou,{asChild:!0,trapped:i,onMountAutoFocus:G(a,e=>{e.preventDefault(),T.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,h.jsx)(gu,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,h.jsx)(Jh,{asChild:!0,...x,dir:y.dir,orientation:`vertical`,loop:r,currentTabStopId:C,onCurrentTabStopIdChange:w,onEntryFocus:G(c,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,h.jsx)(vh,{role:`menu`,"aria-orientation":`vertical`,"data-state":Rg(v.open),"data-radix-menu-content":``,dir:y.dir,...b,..._,ref:E,style:{outline:`none`,..._.style},onKeyDown:G(_.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&F(e.key));let i=T.current;if(e.target!==i||!tg.includes(e.key))return;e.preventDefault();let a=S().filter(e=>!e.disabled).map(e=>e.ref.current);eg.includes(e.key)&&a.reverse(),Vg(a)}),onBlur:G(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(D.current),O.current=``)}),onPointerMove:G(e.onPointerMove,Kg(e=>{let t=e.target,n=M.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>M.current?`right`:`left`;j.current=t,M.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),Og=`MenuItem`,kg=`menu.itemSelect`,Ag=m.forwardRef(Zh(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=m.useRef(null),o=pg(Og,e.__scopeMenu),s=Sg(Og,e.__scopeMenu),c=Ic(t,a),l=m.useRef(!1),u=Zh(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(kg,{bubbles:!0,cancelable:!0});e.addEventListener(kg,e=>r?.(e),{once:!0}),rl(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,h.jsx)(jg,{...i,ref:c,disabled:n,onClick:G(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:G(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:G(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&Qh.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),jg=m.forwardRef(Zh(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Sg(Og,n),s=lg(n),c=m.useRef(null),l=Ic(t,c),[u,d]=m.useState(!1),[f,p]=m.useState(``);return m.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,h.jsx)(rg.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,h.jsx)(Yh,{asChild:!0,...s,focusable:!r,children:(0,h.jsx)(nl.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:G(e.onPointerMove,Kg(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:G(e.onPointerLeave,Kg(e=>o.onItemLeave(e))),onFocus:G(e.onFocus,()=>d(!0)),onBlur:G(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Mg,Ng]=og(`MenuRadioGroup`,{value:void 0,onValueChange:Zh(()=>{},`onValueChange`)}),[Pg,Fg]=og(`MenuItemIndicator`,{checked:!1}),[Ig,Lg]=og(`MenuSub`);function Rg(e){return e?`open`:`closed`}Zh(Rg,`getOpenState`);function zg(e){return e===`indeterminate`}Zh(zg,`isIndeterminate`);function Bg(e){return zg(e)?`indeterminate`:e?`checked`:`unchecked`}Zh(Bg,`getCheckedState`);function Vg(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Zh(Vg,`focusFirst`);function Hg(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Zh(Hg,`wrapArray`);function Ug(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Hg(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}Zh(Ug,`getNextMatch`);function Wg(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Zh(Wg,`isPointInPolygon`);function Gg(e,t){return t?Wg({x:e.clientX,y:e.clientY},t):!1}Zh(Gg,`isPointerInGraceArea`);function Kg(e){return t=>t.pointerType===`mouse`?e(t):void 0}Zh(Kg,`whenMouse`);var qg=mg,Jg=hg,Yg=yg,Xg=Cg,Zg=Ag,Qg=Object.defineProperty,$g=(e,t)=>Qg(e,`name`,{value:t,configurable:!0}),e_=`DropdownMenu`,[t_,n_]=cl(e_,[sg]),r_=sg(),[i_,a_]=t_(e_),o_=$g(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=r_(t),l=m.useRef(null),[u,d]=K({prop:i,defaultProp:a??!1,onChange:o,caller:e_});return(0,h.jsx)(i_,{scope:t,triggerId:tu(),triggerRef:l,contentId:tu(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,h.jsx)(qg,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),s_=`DropdownMenuTrigger`,c_=m.forwardRef($g(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=a_(s_,n),o=r_(n),s=Ic(t,a.triggerRef);return(0,h.jsx)(Jg,{asChild:!0,...o,children:(0,h.jsx)(nl.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:G(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:G(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),l_=$g(e=>{let{__scopeDropdownMenu:t,...n}=e,r=r_(t);return(0,h.jsx)(Yg,{...r,...n})},`DropdownMenuPortal`),u_=`DropdownMenuContent`,d_=m.forwardRef($g(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=a_(u_,n),a=r_(n),o=m.useRef(!1);return(0,h.jsx)(Xg,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:G(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),f_=m.forwardRef($g(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=r_(n);return(0,h.jsx)(Zg,{...i,...r,ref:t})},`DropdownMenuItem`)),p_=o_,m_=c_,h_=l_,g_=d_,__=f_,v_=Object.defineProperty,y_=m.forwardRef(((e,t)=>v_(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,h.jsx)(nl.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),b_=Object.defineProperty,x_=(e,t)=>b_(e,`name`,{value:t,configurable:!0});function S_(e){let t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}x_(S_,`usePrevious`);var C_=Object.defineProperty,w_=(e,t)=>C_(e,`name`,{value:t,configurable:!0});function T_(e,[t,n]){return Math.min(n,Math.max(t,e))}w_(T_,`clamp`);var E_=Object.defineProperty,D_=(e,t)=>E_(e,`name`,{value:t,configurable:!0}),O_=`Popover`,[k_,A_]=cl(O_,[rh]),j_=rh(),[M_,N_]=k_(O_),P_=D_(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=j_(t),c=m.useRef(null),[l,u]=m.useState(!1),[d,f]=K({prop:r,defaultProp:i??!1,onChange:a,caller:O_});return(0,h.jsx)(gh,{...s,children:(0,h.jsx)(M_,{scope:t,contentId:tu(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:m.useCallback(()=>u(!0),[]),onCustomAnchorRemove:m.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),F_=`PopoverTrigger`,I_=m.forwardRef(D_(function(e,t){let{__scopePopover:n,...r}=e,i=N_(F_,n),a=j_(n),o=Ic(t,i.triggerRef),s=(0,h.jsx)(nl.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Y_(i.open),...r,ref:o,onClick:G(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,h.jsx)(_h,{asChild:!0,...a,children:s})},`PopoverTrigger`)),L_=`PopoverPortal`,[R_,z_]=k_(L_,{forceMount:void 0}),B_=D_(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=N_(L_,t);return(0,h.jsx)(R_,{scope:t,forceMount:n,children:(0,h.jsx)(Gl,{present:n||a.open,children:(0,h.jsx)(Vu,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),V_=`PopoverContent`,H_=m.forwardRef(D_(function(e,t){let n=z_(V_,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=N_(V_,e.__scopePopover);return(0,h.jsx)(Gl,{present:r||a.open,children:a.modal?(0,h.jsx)(W_,{...i,ref:t}):(0,h.jsx)(G_,{...i,ref:t})})},`PopoverContent`)),U_=zc(`PopoverContent.RemoveScroll`),W_=m.forwardRef(D_(function(e,t){let n=N_(V_,e.__scopePopover),r=m.useRef(null),i=Ic(t,r),a=m.useRef(!1);return m.useEffect(()=>{let e=r.current;if(e)return ff(e)},[]),(0,h.jsx)(nf,{as:U_,allowPinchZoom:!0,children:(0,h.jsx)(K_,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:G(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),G_=m.forwardRef(D_(function(e,t){let n=N_(V_,e.__scopePopover),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(K_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),K_=m.forwardRef(D_(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=N_(V_,n),p=j_(n);return qu(),(0,h.jsx)(Ou,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(gu,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,h.jsx)(vh,{"data-state":Y_(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.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)`}})})})},`PopoverContentImpl`)),q_=`PopoverClose`,J_=m.forwardRef(D_(function(e,t){let{__scopePopover:n,...r}=e,i=N_(q_,n);return(0,h.jsx)(nl.button,{type:`button`,...r,ref:t,onClick:G(e.onClick,()=>i.onOpenChange(!1))})},`PopoverClose`));function Y_(e){return e?`open`:`closed`}D_(Y_,`getState`);var X_=P_,Z_=I_,Q_=B_,$_=H_,ev=J_,tv=Object.defineProperty,nv=(e,t)=>tv(e,`name`,{value:t,configurable:!0}),rv=[` `,`Enter`,`ArrowUp`,`ArrowDown`],iv=[` `,`Enter`],av=`Select`,[ov,sv,cv]=fl(av),[lv,uv]=cl(av,[cv,rh]),dv=rh(),[fv,pv]=lv(av),[mv,hv]=lv(av);function gv(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:g,internal_do_not_use_render:_}=e,v=dv(t),[y,b]=m.useState(null),[x,S]=m.useState(null),[C,w]=m.useState(!1),T=au(l),[E,D]=K({prop:r,defaultProp:i??!1,onChange:a,caller:av}),[O,k]=K({prop:o,defaultProp:s,onChange:c,caller:av}),A=m.useRef(null),j=m.useRef(O);m.useEffect(()=>{let e=g?y?.ownerDocument.getElementById(g):y?.form;if(e instanceof HTMLFormElement){let t=nv(()=>k(j.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[g,y,k]);let M=!y||!!g||!!y.closest(`form`),[N,P]=m.useState(new Set),F=tu(),I=Array.from(N).map(e=>e.props.value).join(`;`),ee=m.useCallback(e=>{P(t=>new Set(t).add(e))},[]),te=m.useCallback(e=>{P(t=>{let n=new Set(t);return n.delete(e),n})},[]),ne={required:p,trigger:y,onTriggerChange:b,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:F,value:O,onValueChange:k,open:E,onOpenChange:D,dir:T,triggerPointerDownPosRef:A,disabled:f,name:u,autoComplete:d,form:g,nativeOptions:N,nativeSelectKey:I,isFormControl:M};return(0,h.jsx)(gh,{...v,children:(0,h.jsx)(fv,{scope:t,...ne,children:(0,h.jsx)(ov.Provider,{scope:t,children:(0,h.jsx)(mv,{scope:t,onNativeOptionAdd:ee,onNativeOptionRemove:te,children:Qv(_)?_(ne):n})})})})}nv(gv,`SelectProvider`);var _v=nv(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,h.jsx)(gv,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,h.jsxs)(h.Fragment,{children:[n,e?(0,h.jsx)(Zv,{__scopeSelect:t}):null]})})},`Select`),vv=`SelectTrigger`,yv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=dv(n),o=pv(vv,n),s=o.disabled||r,c=Ic(t,o.onTriggerChange),l=sv(n),u=m.useRef(`touch`),[d,f,p]=ey(e=>{let t=l().filter(e=>!e.disabled),n=ty(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),g=nv(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,h.jsx)(_h,{asChild:!0,...a,children:(0,h.jsx)(nl.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":$v(o.value)?``:void 0,...i,ref:c,onClick:G(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&g(e)}),onPointerDown:G(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(g(e),e.preventDefault())}),onKeyDown:G(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&rv.includes(e.key)&&(g(),e.preventDefault())})})})},`SelectTrigger`)),bv=`SelectValue`,xv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=pv(bv,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Ic(t,c.onValueNodeChange);Al(()=>{l(u)},[l,u]);let f=$v(c.value);return(0,h.jsx)(nl.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,h.jsx)(m.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),Sv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,h.jsx)(nl.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[Cv,wv]=lv(`SelectPortal`,{forceMount:void 0}),Tv=nv(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,h.jsx)(Cv,{scope:e.__scopeSelect,forceMount:n,children:(0,h.jsx)(Vu,{asChild:!0,...r})})},`SelectPortal`),Ev=`SelectContent`,Dv=m.forwardRef(nv(function(e,t){let n=wv(Ev,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=pv(Ev,e.__scopeSelect),[o,s]=m.useState();return Al(()=>{s(new DocumentFragment)},[]),(0,h.jsx)(Gl,{present:r||a.open,children:({present:e})=>e?(0,h.jsx)(Nv,{...i,ref:t}):(0,h.jsx)(Ov,{...i,fragment:o})})},`SelectContent`)),Ov=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?$c.createPortal((0,h.jsx)(Av,{scope:n,children:(0,h.jsx)(ov.Slot,{scope:n,children:(0,h.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),kv=10,[Av,jv]=lv(Ev),Mv=zc(`SelectContent.RemoveScroll`),Nv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:g,hideWhenDetached:_,avoidCollisions:v,...y}=e,b=pv(Ev,n),[x,S]=m.useState(null),[C,w]=m.useState(null),T=Ic(t,S),[E,D]=m.useState(null),[O,k]=m.useState(null),A=sv(n),[j,M]=m.useState(!1),N=m.useRef(!1);m.useEffect(()=>{if(x)return ff(x)},[x]),qu();let P=m.useCallback(e=>{let[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&C&&(C.scrollTop=0),n===r&&C&&(C.scrollTop=C.scrollHeight),n?.focus(),document.activeElement!==i))return},[A,C]),F=m.useCallback(()=>P([E,x]),[P,E,x]);m.useEffect(()=>{j&&F()},[j,F]);let{onOpenChange:I,triggerPointerDownPosRef:ee}=b;m.useEffect(()=>{if(x){let e={x:0,y:0},t=nv(t=>{e={x:Math.abs(Math.round(t.pageX)-(ee.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ee.current?.y??0))}},`handlePointerMove`),n=nv(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(x)||I(!1),document.removeEventListener(`pointermove`,t),ee.current=null},`handlePointerUp`);return ee.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[x,I,ee]),m.useEffect(()=>{let e=nv(()=>I(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[I]);let[te,ne]=ey(e=>{let t=A().filter(e=>!e.disabled),n=ty(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),L=m.useCallback((e,t,n)=>{let r=!N.current&&!n;(b.value!==void 0&&b.value===t||r)&&(D(e),r&&(N.current=!0))},[b.value]),re=m.useCallback(()=>x?.focus(),[x]),ie=m.useCallback((e,t,n)=>{let r=!N.current&&!n;(b.value!==void 0&&b.value===t||r)&&k(e)},[b.value]),ae=r===`popper`?Fv:Pv,oe=ae===Fv?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:g,hideWhenDetached:_,avoidCollisions:v}:{};return(0,h.jsx)(Av,{scope:n,content:x,viewport:C,onViewportChange:w,itemRefCallback:L,selectedItem:E,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:F,selectedItemText:O,position:r,isPositioned:j,searchRef:te,children:(0,h.jsx)(nf,{as:Mv,allowPinchZoom:!0,children:(0,h.jsx)(Ou,{asChild:!0,trapped:b.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:G(i,e=>{b.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,h.jsx)(gu,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:(0,h.jsx)(ae,{role:`listbox`,id:b.contentId,"data-state":b.open?`open`:`closed`,dir:b.dir,onContextMenu:e=>e.preventDefault(),...y,...oe,onPlaced:()=>M(!0),ref:T,style:{display:`flex`,flexDirection:`column`,outline:`none`,...y.style},onKeyDown:G(y.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>P(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Pv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=pv(Ev,n),o=jv(Ev,n),[s,c]=m.useState(null),[l,u]=m.useState(null),d=Ic(t,u),f=sv(n),p=m.useRef(!1),g=m.useRef(!0),{viewport:_,selectedItem:v,selectedItemText:y,focusSelectedItem:b}=o,x=m.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&_&&v&&y){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=y.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-kv,d=T_(a,[kv,Math.max(kv,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-kv,d=T_(a,[kv,Math.max(kv,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-kv*2,u=_.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),g=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+h+u+b+g,S=Math.min(v.offsetHeight*5,x),C=window.getComputedStyle(_),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-kv,D=c-E,O=v.offsetHeight/2,k=v.offsetTop+O,A=m+h+k,j=x-A;if(A<=E){let e=o.length>0&&v===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-_.offsetTop-_.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+g);s.style.height=n+`px`}else{let e=o.length>0&&v===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+_.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,_.scrollTop=A-E+_.offsetTop}s.style.margin=`${kv}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,_,v,y,a.dir,r]);Al(()=>x(),[x]);let[S,C]=m.useState();Al(()=>{l&&C(window.getComputedStyle(l).zIndex)},[l]);let w=m.useCallback(e=>{e&&g.current===!0&&(x(),b?.(),g.current=!1)},[x,b]);return(0,h.jsx)(Iv,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:w,children:(0,h.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:S},children:(0,h.jsx)(nl.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Fv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=kv,...a}=e,o=dv(n);return(0,h.jsx)(vh,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[Iv,Lv]=lv(Ev,{}),Rv=`SelectViewport`,zv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=jv(Rv,n),o=Lv(Rv,n),s=Ic(t,a.onViewportChange),c=m.useRef(0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,h.jsx)(ov.Slot,{scope:n,children:(0,h.jsx)(nl.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:G(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-kv*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[Bv,Vv]=lv(`SelectGroup`),Hv=`SelectItem`,[Uv,Wv]=lv(Hv),Gv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=pv(Hv,n),c=jv(Hv,n),l=s.value===r,[u,d]=m.useState(a??``),[f,p]=m.useState(!1),g=Ic(t,cu(e=>c.itemRefCallback?.(e,r,i))),_=tu(),v=m.useRef(`touch`),y=nv(()=>{i||(s.onValueChange(r),s.onOpenChange(!1))},`handleSelect`);return(0,h.jsx)(Uv,{scope:n,value:r,disabled:i,textId:_,isSelected:l,onItemTextChange:m.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,h.jsx)(ov.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,h.jsx)(nl.div,{role:`option`,"aria-labelledby":_,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:g,onFocus:G(o.onFocus,()=>p(!0)),onBlur:G(o.onBlur,()=>p(!1)),onClick:G(o.onClick,()=>{v.current!==`mouse`&&y()}),onPointerUp:G(o.onPointerUp,()=>{v.current===`mouse`&&y()}),onPointerDown:G(o.onPointerDown,e=>{v.current=e.pointerType}),onPointerMove:G(o.onPointerMove,e=>{v.current=e.pointerType,i?c.onItemLeave?.():v.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:G(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:G(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(iv.includes(e.key)&&y(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Kv=`SelectItemText`,qv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=pv(Kv,n),s=jv(Kv,n),c=Wv(Kv,n),l=hv(Kv,n),[u,d]=m.useState(null),f=cu(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=Ic(t,d,c.onItemTextChange,f),g=u?.textContent,_=m.useMemo(()=>(0,h.jsx)(`option`,{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:v,onNativeOptionRemove:y}=l;return Al(()=>(v(_),()=>y(_)),[v,y,_]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(nl.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!$v(o.value)?$c.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),Jv=`SelectItemIndicator`,Yv=m.forwardRef(nv(function(e,t){let{__scopeSelect:n,...r}=e;return Wv(Jv,n).isSelected?(0,h.jsx)(nl.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Xv=`SelectBubbleInput`,Zv=m.forwardRef(nv(function({__scopeSelect:e,...t},n){let r=pv(Xv,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=m.useRef(null),g=Ic(n,p),_=i??``,v=S_(_),y=Array.from(d).some(e=>(e.props.value??``)===``);return m.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(v!==_&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,_),e.dispatchEvent(t)}},[v,_]),(0,h.jsxs)(nl.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...il,...t.style},ref:g,defaultValue:_,children:[$v(i)&&!y?(0,h.jsx)(`option`,{value:``}):null,Array.from(d)]},f)},`SelectBubbleInput`));function Qv(e){return typeof e==`function`}nv(Qv,`isFunction`);function $v(e){return e===``||e===void 0}nv($v,`shouldShowPlaceholder`);function ey(e){let t=cu(e),n=m.useRef(``),r=m.useRef(0),i=m.useCallback(e=>{let i=n.current+e;t(i),nv((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=m.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}nv(ey,`useTypeaheadSearch`);function ty(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=ny(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}nv(ty,`findNextItem`);function ny(e,t){return e.map((n,r)=>e[(t+r)%e.length])}nv(ny,`wrapArray`);var ry=Object.defineProperty,iy=(e,t)=>ry(e,`name`,{value:t,configurable:!0}),ay=`Toggle`,oy=m.forwardRef(iy(function(e,t){let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=K({prop:n,onChange:i,defaultProp:r??!1,caller:ay});return(0,h.jsx)(nl.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:G(e.onClick,()=>{e.disabled||s(!o)})})},`Toggle`)),sy=Object.defineProperty,cy=(e,t)=>sy(e,`name`,{value:t,configurable:!0}),ly=`ToggleGroup`,[uy,dy]=cl(ly,[Ih]),fy=Ih(),py=m.forwardRef(cy(function(e,t){let{type:n,...r}=e;if(n===`single`)return(0,h.jsx)(gy,{role:`radiogroup`,...r,ref:t});if(n===`multiple`)return(0,h.jsx)(_y,{role:`toolbar`,...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${ly}\``)},`ToggleGroup`)),[my,hy]=uy(ly),gy=m.forwardRef(cy(function(e,t){let{value:n,defaultValue:r,onValueChange:i=cy(()=>{},`onValueChange`),...a}=e,[o,s]=K({prop:n,defaultProp:r??``,onChange:i,caller:ly});return(0,h.jsx)(my,{scope:e.__scopeToggleGroup,type:`single`,value:m.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:m.useCallback(()=>s(``),[s]),children:(0,h.jsx)(by,{...a,ref:t})})},`ToggleGroupImplSingle`)),_y=m.forwardRef(cy(function(e,t){let{value:n,defaultValue:r,onValueChange:i=cy(()=>{},`onValueChange`),...a}=e,[o,s]=K({prop:n,defaultProp:r??[],onChange:i,caller:ly}),c=m.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=m.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,h.jsx)(my,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,h.jsx)(by,{...a,ref:t})})},`ToggleGroupImplMultiple`)),[vy,yy]=uy(ly),by=m.forwardRef(cy(function(e,t){let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=fy(n),u=au(o),d={dir:u,...c};return(0,h.jsx)(vy,{scope:n,rovingFocus:i,disabled:r,children:i?(0,h.jsx)(Jh,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,h.jsx)(nl.div,{...d,ref:t})}):(0,h.jsx)(nl.div,{...d,ref:t})})},`ToggleGroupImpl`)),xy=`ToggleGroupItem`,Sy=m.forwardRef(cy(function(e,t){let n=hy(xy,e.__scopeToggleGroup),r=yy(xy,e.__scopeToggleGroup),i=fy(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=m.useRef(null);return r.rovingFocus?(0,h.jsx)(Yh,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,h.jsx)(Cy,{...s,ref:t})}):(0,h.jsx)(Cy,{...s,ref:t})},`ToggleGroupItem`)),Cy=m.forwardRef(cy(function(e,t){let{__scopeToggleGroup:n,value:r,...i}=e,a=hy(xy,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0},s=a.type===`single`?o:void 0;return(0,h.jsx)(oy,{...s,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})},`ToggleGroupItemImpl`)),wy=jc(`inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap font-sans transition-colors duration-150 ease-out motion-reduce:transition-none`,{variants:{variant:{outline:`rounded-control border border-line2 bg-panel2 text-ink hover:bg-panel2 hover:border-ink3`,accent:`rounded-control border border-accent bg-transparent text-run-text hover:bg-panel2`,primary:`rounded-control bg-accent px-[14px] font-semibold text-accent-ink hover:bg-accent-edge`,ghost:`rounded-control text-ink2 hover:bg-panel2 hover:text-ink`,danger:`rounded-control border border-red bg-transparent text-ink hover:bg-panel2`,play:`rounded-panel bg-accent text-accent-ink font-extrabold tracking-[0.02em] shadow-[0_4px_0_var(--color-accent-edge)] active:translate-y-[3px] active:shadow-[0_1px_0_var(--color-accent-edge)] motion-reduce:active:translate-y-0`},size:{default:`h-8 px-3 text-body`,play:`h-14 w-full px-4 text-row`}},defaultVariants:{variant:`outline`,size:`default`}});function J({className:e,variant:t,size:n,asChild:r=!1,...i}){let a=r?Bc:`button`;return(0,h.jsx)(a,{"data-slot":`button`,className:W(wy({variant:t,size:n}),e),...i})}var Ty=bf,Ey=wf;function Dy({className:e,...t}){return(0,h.jsx)(Ef,{"data-slot":`dialog-overlay`,className:W(`fixed inset-0 z-40 bg-scrim`,e),...t})}function Oy({className:e,children:t,...n}){return(0,h.jsxs)(Ey,{children:[(0,h.jsx)(Dy,{}),(0,h.jsx)(Af,{"data-slot":`dialog-content`,className:W(`fixed top-1/2 left-1/2 z-50 flex w-[calc(100%-2rem)] max-w-[480px] -translate-x-1/2 -translate-y-1/2 flex-col gap-4`,`rounded-panel border border-line bg-panel p-[18px] shadow-[0_8px_24px_var(--color-shadow)]`,`data-[state=open]:animate-dialog-in motion-reduce:animate-none`,e),...n,children:t})]})}function ky({className:e,...t}){return(0,h.jsx)(Ff,{"data-slot":`dialog-title`,className:W(`text-title font-bold tracking-[-0.01em] text-ink`,e),...t})}function Ay({className:e,...t}){return(0,h.jsx)(Lf,{"data-slot":`dialog-description`,className:W(`text-body text-ink2`,e),...t})}var jy={projects:[`projects`],project:e=>[`project`,e],article:e=>[`project`,e,`article`],file:(e,t)=>[`file`,e,t],staging:[`staging`],notice:[`notice`],usage:[`usage`],providers:[`providers`],voices:[`voices`],prompts:[`prompts`],entries:[`entries`],settings:[`settings`]};function My(e){return et({queryKey:jy.projects,queryFn:()=>io(e)})}function Ny(e,t){return et({queryKey:jy.project(t),queryFn:()=>ao(e,t)})}function Py(e){return et({queryKey:jy.notice,queryFn:()=>uo(e)})}function Fy(e){return et({queryKey:jy.usage,queryFn:()=>lo(e)})}function Iy(e){return et({queryKey:jy.providers,queryFn:()=>mo(e)})}function Ly(e){return et({queryKey:jy.voices,queryFn:()=>yo(e)})}function Ry(e){return et({queryKey:jy.prompts,queryFn:()=>wo(e)})}function zy(e){return et({queryKey:jy.entries,queryFn:()=>Do(e)})}function By(e){return et({queryKey:jy.settings,queryFn:()=>_o(e)})}var Vy=[`Tokens in and out per stage, with provider and model`,`Audio seconds per segment`,`Images made`,`Thumbnails made`,`Videos rendered`,`Projects created`,`That this machine installed Slopify`,`The time each of those happened`],Hy=[`API keys`,`Prompt bodies`,`Keyword values`,`Titles`,`Article or research text`,`Files and filenames`,`OS, locale, hardware`];function Uy(){let{api:e}=B(),t=_(),n=R(Py(e)),r=tt({mutationFn:()=>fo(e),onSuccess:e=>{t.setQueryData(jy.notice,e)}}),i=n.data?.seen===!1,a=n.data?.appVersion;return(0,h.jsx)(Ty,{open:i,children:(0,h.jsxs)(Oy,{onEscapeKeyDown:e=>{e.preventDefault()},onInteractOutside:e=>{e.preventDefault()},children:[(0,h.jsx)(ky,{children:`Anonymous usage stats`}),(0,h.jsx)(Ay,{children:`These numbers power the live counters on slopify.stream.`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,h.jsx)(Wy,{heading:`Tracked`,items:Vy}),(0,h.jsx)(Wy,{heading:`Never tracked`,items:Hy})]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Every event carries a random ID of its own and this machine's random ID, and nothing else. Nothing you write, upload, or paste ever leaves your machine.`}),a===void 0?null:(0,h.jsx)(`p`,{className:`engraved text-ink3`,children:`Slopify ${a} · this version is included in each report`}),(0,h.jsx)(J,{autoFocus:!0,variant:`play`,size:`play`,disabled:r.isPending,onClick:()=>{r.mutate()},children:`Got it`}),r.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:r.error.message})]})})}function Wy({heading:e,items:t}){let n=`notice-${e.replace(/\s+/g,`-`).toLowerCase()}`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-[6px]`,children:[(0,h.jsx)(`p`,{id:n,className:`engraved border-b border-line pb-1 text-ink3`,children:e}),(0,h.jsx)(`ul`,{"aria-labelledby":n,className:`m-0 flex list-none flex-col gap-[6px] p-0 text-small`,children:t.map(e=>(0,h.jsx)(`li`,{children:e},e))})]})}function Gy(e,t){if(t===`system`){e.removeAttribute(`data-theme`);return}e.setAttribute(`data-theme`,t)}function Ky(){let{api:e}=B(),t=R(By(e)).data?.appearance??`system`;return(0,m.useEffect)(()=>{Gy(document.documentElement,t)},[t]),null}function qy({reload:e}){let{version:t}=B(),n=(0,m.useSyncExternalStore)(t.subscribe,t.staleAt,t.staleAt);return(0,h.jsx)(Ty,{open:n!==void 0,children:(0,h.jsxs)(Oy,{onEscapeKeyDown:e=>{e.preventDefault()},onInteractOutside:e=>{e.preventDefault()},children:[(0,h.jsx)(ky,{children:`Slopify was updated`}),(0,h.jsx)(Ay,{children:`This tab was loaded before the update. Version ${n??``} is running now; reload to catch up.`}),(0,h.jsx)(J,{autoFocus:!0,variant:`play`,size:`play`,onClick:e,children:`Reload`})]})})}var Jy=[`stage.state`,`stage.progress`,`article.delta`,`llm.preview`,`image.landed`,`project.state`,`project.updated`],Yy=[`running.count`,`staging.progress`,`staging.failed`,`project.updated`,`project.state`];function Xy(e,t,n){return Qy(e,t,Jy,n.refetch,e=>{if(e.type===`llm.preview`){n.previewWriting?.(e);return}if(e.type===`article.delta`){n.appendArticle(e.text);return}if(e.type===`image.landed`||e.type===`project.updated`){n.refetch();return}n.patch(e),e.type===`stage.state`&&n.refetch()})}function Zy(e,t,n){return Qy(e,t,Yy,n.refetch,e=>{if(e.type===`running.count`){n.tally(e.count);return}if(e.type===`project.updated`||e.type===`project.state`){n.refetch(e.projectId);return}n.stagingChanged()})}function Qy(e,t,n,r,i){let a=e(t),o=!1;a.addEventListener(`open`,()=>{o&&r(),o=!0});for(let e of n)a.addEventListener(e,t=>{let n=$y(t.data);n.type===e&&i(n)});return()=>{a.close()}}function $y(e){return JSON.parse(e)}var eb=[`research`,`article`,`audio`,`images`,`thumbnail`,`video`],tb={research:[`off`,`generate`,`provide`],article:[`generate`,`provide`],audio:[`off`,`generate`,`provide`],images:[`off`,`generate`,`provide`],thumbnail:[`off`,`from_prompt`,`prompt_by_llm`,`provide`],video:[`off`,`generate`]};function nb(e){let t=[],n=rb(e.draft),{sources:r}=n;n.title===``?t.push({field:`title`,message:`A title is required.`}):n.title.length>200&&t.push({field:`title`,message:`A title is at most 200 characters.`});for(let e of eb)tb[e].includes(r[e])||t.push({field:`sources.${e}`,message:`The ${e} stage cannot be set to ${r[e]}.`});(r.research===`generate`||r.article===`generate`||r.thumbnail===`prompt_by_llm`||n.intro?.mode===`llm`||n.outro?.mode===`llm`)&&!lb(n.llm)&&t.push({field:`llm`,message:`Pick an LLM provider and model.`}),r.article===`generate`&&cb(n.articlePrompt)&&t.push({field:`articlePrompt`,message:`Pick an article prompt.`});let i=n.audio;return r.audio===`generate`&&(i===void 0||!lb(i)?t.push({field:`audio`,message:`Pick a narration provider and model.`}):i.voice.trim()===``&&t.push({field:`audio.voice`,message:`Pick a voice.`})),r.images===`generate`&&ib(n,t),(r.images===`generate`||r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&!lb(n.images)&&t.push({field:`images`,message:`Pick an image provider and model.`}),(r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&cb(n.thumbnailPrompt)&&t.push({field:`thumbnailPrompt`,message:`Pick a thumbnail prompt.`}),r.audio===`off`&&n.subtitles!==void 0&&n.subtitles.mode!==`off`&&t.push({field:`subtitles.mode`,message:`Subtitles need narration audio.`}),ab(n,e.staged,t),sb(n,e.requiredSlots,t),(!Number.isFinite(n.silenceGapSeconds)||n.silenceGapSeconds<0||n.silenceGapSeconds>30)&&t.push({field:`silenceGapSeconds`,message:`The silence gap is between 0 and 30 seconds.`}),t.length===0?{ok:!0,draft:n}:{ok:!1,fields:t}}function rb(e){let t={...e.sources};t.article===`provide`&&(t.research=`off`),t.images===`off`&&t.video===`generate`&&(t.video=`off`);let n=Object.create(null);for(let[t,r]of Object.entries(e.values))n[t]=r.trim();return{...e,title:e.title.trim(),subtitles:t.video===`off`&&e.subtitles?.mode===`burn-in`?{...e.subtitles,mode:`files`}:e.subtitles,sources:t,values:n,intro:t.audio===`generate`?e.intro:void 0,outro:t.audio===`generate`?e.outro:void 0}}function ib(e,t){if(e.imagePrompts.length===0){t.push({field:`imagePrompts`,message:`Tick at least one image prompt.`});return}let n=0;for(let[r,i]of e.imagePrompts.entries())n+=i.number,cb(i.name)&&t.push({field:`imagePrompts.${r}.name`,message:`Pick an image prompt.`}),(!Number.isInteger(i.number)||i.number<1||i.number>20)&&t.push({field:`imagePrompts.${r}.number`,message:`Number is between 1 and 20.`});n>60&&t.push({field:`imagePrompts`,message:`A run makes at most 60 images; this one asks for ${n}.`})}function ab(e,t,n){let{sources:r,provided:i}=e;if(r.research===`provide`&&cb(i.research)&&n.push({field:`provided.research`,message:`Paste the research notes.`}),r.article===`provide`&&cb(i.article)&&n.push({field:`provided.article`,message:`Paste the article.`}),r.audio===`provide`&&ob(t,i.audio,`audio`,`provided.audio`,`Pick an audio file.`,n),r.thumbnail===`provide`&&ob(t,i.thumbnail,`thumbnail`,`provided.thumbnail`,`Pick a thumbnail image.`,n),r.images===`provide`){let e=i.images??[];e.length===0?n.push({field:`provided.images`,message:`Pick at least one image.`}):e.length>60&&n.push({field:`provided.images`,message:`A run holds at most 60 images.`}),new Set(e).size!==e.length&&n.push({field:`provided.images`,message:`The same image was picked twice.`});for(let[r,i]of e.entries())ob(t,i,`images`,`provided.images.${r}`,`Pick an image.`,n)}}function ob(e,t,n,r,i,a){if(t===void 0||t===``){a.push({field:r,message:i});return}let o=e.find(e=>e.id===t);if(o===void 0||o.stageKind!==n){a.push({field:r,message:`That upload is no longer available; pick the file again.`});return}o.state!==`staged`&&a.push({field:r,message:`This upload is still copying.`})}function sb(e,t,n){for(let r of t){let t=Object.hasOwn(e.values,r)?e.values[r]:void 0;if(t===void 0||t===``){n.push({field:`values.${r}`,message:`This field is required.`});continue}t.length>200&&n.push({field:`values.${r}`,message:`A value is at most 200 characters.`}),/[\n\r]/.test(t)&&n.push({field:`values.${r}`,message:`A value is a single line.`})}}function cb(e){return e===void 0||e.trim()===``}function lb(e){return e!==void 0&&e.provider.trim()!==``&&e.model.trim()!==``}function ub(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function db(e,t=`|`){return e.map(e=>kb(e)).join(t)}function fb(e,t){return typeof t==`bigint`?t.toString():t}function pb(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function mb(e){return e==null}function hb(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function gb(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function _b(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function vb(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function yb(e){return JSON.stringify(e)}function bb(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var xb=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Sb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Cb=pb(()=>{if(mx.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function wb(e){if(Sb(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Sb(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Tb(e){return wb(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Eb=new Set([`string`,`number`,`symbol`]);function Db(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ob(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Y(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function kb(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Ab(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var jb={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Mb(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Ob(e,vb(e._zod.def,{get shape(){let e={};for(let r of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,r))throw Error(`Unrecognized key: "${String(r)}"`);t[r]&&_b(e,r,n.shape[r])}return _b(this,`shape`,e),e},checks:[]}))}function Nb(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Ob(e,vb(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete r[e]}return _b(this,`shape`,r),r},checks:[]}))}function Pb(e,t){if(!wb(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Ob(e,vb(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return _b(this,`shape`,n),n}}))}function Fb(e,t){if(!wb(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Ob(e,vb(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return _b(this,`shape`,n),n}}))}function Ib(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Ob(e,vb(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return _b(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Lb(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);return Ob(t,vb(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(r,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t of Reflect.ownKeys(r))i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return _b(this,`shape`,i),i},checks:[]}))}function Rb(e,t,n){return Ob(t,vb(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t of Reflect.ownKeys(r))i[t]=new e({type:`nonoptional`,innerType:r[t]});return _b(this,`shape`,i),i}}))}function zb(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Bb(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Vb(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Hb(e){return typeof e==`string`?e:e?.message}function Ub(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Wb(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Hb(e.inst?._zod.def?.error?.(e))??Hb(a?.(e))??Hb(t?.error?.(e))??Hb(n.customError?.(e))??Hb(n.localeError?.(e))??`Invalid input`,{inst:s,schema:c,continue:l,input:u,...d}=e;return d.path??=[],d.message=o,t?.reportInput&&(d.input=u),d}var Gb=/[\uD800-\uDBFF]/;function Kb(e){let t=e.length;if(!Gb.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function qb(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Jb(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Yb(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Xb(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):$b(e,n,r.value)}}function Zb(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Qb(e,t,n){return Zb(e,t,n,!1)}function $b(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Zb(this,t,n.bind(this))},set(e){Zb(this,t,e)}})}function ex(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var tx,nx=!1,rx={configurable:!0,get(){nx=!0}};function ix(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&tx!==e._zod){tx=void 0;return}tx=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,rx);let e=nx;nx=!1;try{let r=n(this);return nx?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),nx||=e,r}catch(n){throw delete this[t],nx||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function ax(e,t,n,r){let i=ex(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var ox=`~constantCatch`;function sx(e){let t=()=>e;return t[ox]=!0,t}var cx,lx={value:void 0,enumerable:!1},ux=`captureStackTrace`in Error?Error:null;function dx(e){let t=ux;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return ux=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function X(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){lx.value=new a(r);try{Object.defineProperty(n,"_zod",lx)}finally{lx.value=void 0}}if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Xb(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?dx(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var fx=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},px=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(cx=globalThis).__zod_globalConfig??(cx.__zod_globalConfig={});var mx=globalThis.__zod_globalConfig;function hx(e){return e&&Object.assign(mx,e),mx}function gx(){let e=this._zod;return e.message??=JSON.stringify(e.def,fb,2),e.message}function _x(e){this._zod.message=e}var vx={get:gx,set:_x,enumerable:!0,configurable:!0},yx={value:void 0,enumerable:!1},bx={value:void 0,enumerable:!1},xx=new WeakSet([Object.prototype,Error.prototype]),Sx=(e,t)=>{e.name=`$ZodError`,yx.value=e._zod,Object.defineProperty(e,"_zod",yx),bx.value=t,Object.defineProperty(e,"issues",bx),yx.value=void 0,bx.value=void 0,Object.defineProperty(e,"message",vx);let n=Object.getPrototypeOf(e);xx.has(n)||(xx.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Cx=X(`$ZodError`,Sx),wx=X(`$ZodError`,Sx,void 0,{Parent:Error});function Tx(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Ex(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Tx(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Dx(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Ox(e,t){return{callee:t?.callee??e,Err:t?.Err}}var kx=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new fx;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Wb(e,o,hx())));throw xb(n,a?.callee??t),n}return s.value};return t},Ax=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Wb(e,o,hx())));throw xb(n,a?.callee??t),n}return s.value};return t},jx=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new fx;return a.issues.length?{success:!1,error:new(e??Cx)(a.issues.map(e=>Wb(e,i,hx())))}:{success:!0,data:a.value}},Mx=jx(wx),Nx=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Wb(e,i,hx())))}:{success:!0,data:a.value}},Px=Nx(wx),Fx=e=>{let t=kx(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Ox(n,a))};return n},Ix=e=>{let t=kx(e),n=(e,r,i,a)=>t(e,r,i,Ox(n,a));return n},Lx=e=>{let t=Ax(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Ox(n,a))};return n},Rx=e=>{let t=Ax(e),n=async(e,r,i,a)=>await t(e,r,i,Ox(n,a));return n},zx=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return jx(e)(t,n,i)},Bx=e=>(t,n,r)=>jx(e)(t,n,r),Vx=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Nx(e)(t,n,i)},Hx=e=>async(t,n,r)=>Nx(e)(t,n,r),Ux=/^[cC][0-9a-z]{6,}$/,Wx=/^[0-9a-z]+$/,Gx=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Kx=/^[0-9a-vA-V]{20}$/,qx=/^[A-Za-z0-9]{27}$/,Jx=/^[a-zA-Z0-9_-]{21}$/;function Yx(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Xx=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zx=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Qx=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,$x=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,eS=`^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function tS(){return new RegExp(eS,`u`)}var nS=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,rS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,iS=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,aS=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,oS=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,sS=/^[A-Za-z0-9_-]*$/,cS=/^https?$/,lS=/^\+[1-9]\d{6,14}$/,uS=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function dS(e){return RegExp(`^${e}$`)}var fS=dS(uS);function pS(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function mS(e){return RegExp(`^${pS(e)}$`)}function hS(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${pS({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${pS({precision:e.precision})}`:n;return RegExp(`^${uS}T(?:${r})$`)}var gS=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},_S=/^-?\d+$/,vS=/^-?\d+(?:\.\d+)?$/,yS=/^[^A-Z]*$/,bS=/^[^a-z]*$/,xS=X(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),SS=e=>{let t=e.value;return!mb(t)&&t.length!==void 0},CS={number:`number`,bigint:`bigint`,object:`date`},wS=X(`$ZodCheckLessThan`,(e,t)=>{xS.init(e,t);let n=CS[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:CS[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),TS=X(`$ZodCheckGreaterThan`,(e,t)=>{xS.init(e,t);let n=CS[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:CS[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ES=X(`$ZodCheckMultipleOf`,(e,t)=>{xS.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):gb(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),DS=X(`$ZodCheckNumberFormat`,(e,t)=>{xS.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=jb[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=_S)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),OS=X(`$ZodCheckMaxLength`,(e,t)=>{var n;xS.init(e,t),(n=e._zod.def).when??(n.when=SS),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Kb(r):i)<=t.maximum)return;let a=qb(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),kS=X(`$ZodCheckMinLength`,(e,t)=>{var n;xS.init(e,t),(n=e._zod.def).when??(n.when=SS),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Kb(r):i)>=t.minimum)return;let a=qb(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),AS=X(`$ZodCheckLengthEquals`,(e,t)=>{var n;xS.init(e,t),(n=e._zod.def).when??(n.when=SS),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Kb(r):i;if(a===t.length)return;let o=qb(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),jS=X(`$ZodCheckStringFormat`,(e,t)=>{var n,r;xS.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),MS=X(`$ZodCheckRegex`,(e,t)=>{jS.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),NS=X(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=yS,jS.init(e,t)}),PS=X(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=bS,jS.init(e,t)}),FS=X(`$ZodCheckIncludes`,(e,t)=>{xS.init(e,t);let n=Db(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),IS=X(`$ZodCheckStartsWith`,(e,t)=>{xS.init(e,t);let n=RegExp(`^${Db(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),LS=X(`$ZodCheckEndsWith`,(e,t)=>{xS.init(e,t);let n=RegExp(`.*${Db(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),RS=X(`$ZodCheckOverwrite`,(e,t)=>{xS.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),zS=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
49
+ `},Zd=0,Qd=[];function $d(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(Zd++)[0],a=m.useState(xd)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Zu([e.lockRef.current],(e.shards||[]).map(Jd),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Kd(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=zd(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=zd(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Gd(h,t,e,h===`h`?s:c,!0)},[]),c=m.useCallback(function(e){var n=e;if(Qd.length&&Qd[Qd.length-1]===a){var r=`deltaY`in n?qd(n):Kd(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Yd(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Jd).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=m.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ef(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=m.useCallback(function(e){n.current=Kd(e),r.current=void 0},[]),d=m.useCallback(function(t){l(t.type,qd(t),t.target,s(t,e.lockRef.current))},[]),f=m.useCallback(function(t){l(t.type,Kd(t),t.target,s(t,e.lockRef.current))},[]);m.useEffect(function(){return Qd.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Pd),document.addEventListener(`touchmove`,c,Pd),document.addEventListener(`touchstart`,u,Pd),function(){Qd=Qd.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Pd),document.removeEventListener(`touchmove`,c,Pd),document.removeEventListener(`touchstart`,u,Pd)}},[]);var p=e.removeScrollBar,h=e.inert;return m.createElement(m.Fragment,null,h?m.createElement(a,{styles:Xd(i)}):null,p?m.createElement(jd,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ef(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var tf=dd(fd,$d),nf=m.forwardRef(function(e,t){return m.createElement(md,Yu({},e,{ref:t,sideCar:tf}))});nf.classNames=md.classNames;var rf=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},af=new WeakMap,of=new WeakMap,sf={},cf=0,lf=function(e){return e&&(e.host||lf(e.parentNode))},uf=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=lf(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},df=function(e,t,n,r){var i=uf(t,Array.isArray(e)?e:[e]);sf[n]||(sf[n]=new WeakMap);var a=sf[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(af.get(e)||0)+1,l=(a.get(e)||0)+1;af.set(e,c),a.set(e,l),o.push(e),c===1&&i&&of.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),cf++,function(){o.forEach(function(e){var t=af.get(e)-1,i=a.get(e)-1;af.set(e,t),a.set(e,i),t||(of.has(e)||e.removeAttribute(r),of.delete(e)),i||e.removeAttribute(n)}),cf--,cf||(af=new WeakMap,af=new WeakMap,of=new WeakMap,sf={})}},ff=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||rf(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),df(r,i,n,`aria-hidden`)):function(){return null}},pf=Object.defineProperty,mf=(e,t)=>pf(e,`name`,{value:t,configurable:!0}),hf=`Dialog`,[gf,_f]=cl(hf),[vf,yf]=gf(hf),bf=mf(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=m.useRef(null),c=m.useRef(null),[l,u]=K({prop:r,defaultProp:i??!1,onChange:a,caller:hf}),[d,f]=m.useState(0),[p,g]=m.useState(0);return(0,h.jsx)(vf,{scope:t,triggerRef:s,contentRef:c,contentId:tu(),titleId:tu(),descriptionId:tu(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:g,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),xf=`DialogPortal`,[Sf,Cf]=gf(xf,{forceMount:void 0}),wf=mf(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=yf(xf,t);return(0,h.jsx)(Sf,{scope:t,forceMount:n,children:m.Children.map(r,e=>(0,h.jsx)(Gl,{present:n||a.open,children:(0,h.jsx)(Vu,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Tf=`DialogOverlay`,Ef=m.forwardRef(mf(function(e,t){let n=Cf(Tf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yf(Tf,e.__scopeDialog);return a.modal?(0,h.jsx)(Gl,{present:r||a.open,children:(0,h.jsx)(Of,{...i,ref:t})}):null},`DialogOverlay`)),Df=zc(`DialogOverlay.RemoveScroll`),Of=m.forwardRef(mf(function(e,t){let{__scopeDialog:n,...r}=e,i=yf(Tf,n),a=Ic(t,_u());return(0,h.jsx)(nf,{as:Df,allowPinchZoom:!0,shards:[i.contentRef],children:(0,h.jsx)(nl.div,{"data-state":Rf(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),kf=`DialogContent`,Af=m.forwardRef(mf(function(e,t){let n=Cf(kf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yf(kf,e.__scopeDialog);return(0,h.jsx)(Gl,{present:r||a.open,children:a.modal?(0,h.jsx)(jf,{...i,ref:t}):(0,h.jsx)(Mf,{...i,ref:t})})},`DialogContent`)),jf=m.forwardRef(mf(function(e,t){let n=yf(kf,e.__scopeDialog),r=m.useRef(null),i=Ic(t,n.contentRef,r);return m.useEffect(()=>{let e=r.current;if(e)return ff(e)},[]),(0,h.jsx)(Nf,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:G(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Mf=m.forwardRef(mf(function(e,t){let n=yf(kf,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(Nf,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Nf=m.forwardRef(mf(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=yf(kf,n);return qu(),(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(Ou,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(gu,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Rf(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Pf=`DialogTitle`,Ff=m.forwardRef(mf(function(e,t){let{__scopeDialog:n,...r}=e,i=yf(Pf,n),{setTitleCount:a}=i;return Al(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,h.jsx)(nl.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),If=`DialogDescription`,Lf=m.forwardRef(mf(function(e,t){let{__scopeDialog:n,...r}=e,i=yf(If,n),{setDescriptionCount:a}=i;return Al(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,h.jsx)(nl.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`));function Rf(e){return e?`open`:`closed`}mf(Rf,`getState`);var zf=Object.defineProperty,Bf=(e,t)=>zf(e,`name`,{value:t,configurable:!0});function Vf(e){let[t,n]=m.useState(void 0);return Al(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}Bf(Vf,`useSize`);var Hf=[`top`,`right`,`bottom`,`left`],Uf=Math.min,Wf=Math.max,Gf=Math.round,Kf=Math.floor,qf=e=>({x:e,y:e}),Jf={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Yf(e,t,n){return Wf(e,Uf(t,n))}function Xf(e,t){return typeof e==`function`?e(t):e}function Zf(e){return e.split(`-`)[0]}function Qf(e){return e.split(`-`)[1]}function $f(e){return e===`x`?`y`:`x`}function ep(e){return e===`y`?`height`:`width`}function tp(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function np(e){return $f(tp(e))}function rp(e,t,n){n===void 0&&(n=!1);let r=Qf(e),i=np(e),a=ep(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=fp(o)),[o,fp(o)]}function ip(e){let t=fp(e);return[ap(e),t,ap(t)]}function ap(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var op=[`left`,`right`],sp=[`right`,`left`],cp=[`top`,`bottom`],lp=[`bottom`,`top`];function up(e,t,n){switch(e){case`top`:case`bottom`:return n?t?sp:op:t?op:sp;case`left`:case`right`:return t?cp:lp;default:return[]}}function dp(e,t,n,r){let i=Qf(e),a=up(Zf(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ap)))),a}function fp(e){let t=Zf(e);return Jf[t]+e.slice(t.length)}function pp(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function mp(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:pp(e)}function hp(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function gp(e,t,n){let{reference:r,floating:i}=e,a=tp(t),o=np(t),s=ep(o),c=Zf(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Qf(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function _p(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Xf(t,e),p=mp(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=hp(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=hp(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var vp=50,yp=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:_p},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=gp(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<vp&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=gp(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},bp=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Xf(e,t)||{};if(l==null)return{};let d=mp(u),f={x:n,y:r},p=np(i),m=ep(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Uf(d[_],T),D=Uf(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=Yf(E,k,O),j=!c.arrow&&Qf(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),xp=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Xf(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Zf(r),_=tp(o),v=Zf(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[fp(o)]:ip(o)),x=p!==`none`;!d&&x&&b.push(...dp(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=rp(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===tp(t)||T.every(e=>tp(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=tp(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Sp(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Cp(e){return Hf.some(t=>e[t]>=0)}var wp=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Xf(e,t);switch(i){case`referenceHidden`:{let e=Sp(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Cp(e)}}}case`escaped`:{let e=Sp(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Cp(e)}}}default:return{}}}}},Tp=new Set([`left`,`top`]);async function Ep(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Zf(n),s=Qf(n),c=tp(n)===`y`,l=Tp.has(o)?-1:1,u=a&&c?-1:1,d=Xf(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Dp=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Ep(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Op=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Xf(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=tp(i),p=$f(f),m=u[p],h=u[f],g=(e,t)=>Yf(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},kp=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Xf(e,t),u={x:n,y:r},d=tp(i),f=$f(d),p=u[f],m=u[d],h=Xf(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Tp.has(Zf(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Ap=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Xf(e,t),c=await i.detectOverflow(t,s),l=Zf(n),u=Qf(n),d=tp(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Uf(p-c[m],g),y=Uf(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Wf(c.left,c.right):S=p-2*Wf(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function jp(){return typeof window<`u`}function Mp(e){return Fp(e)?(e.nodeName||``).toLowerCase():`#document`}function Np(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Pp(e){return((Fp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Fp(e){return jp()?e instanceof Node||e instanceof Np(e).Node:!1}function Ip(e){return jp()?e instanceof Element||e instanceof Np(e).Element:!1}function Lp(e){return jp()?e instanceof HTMLElement||e instanceof Np(e).HTMLElement:!1}function Rp(e){return!jp()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Np(e).ShadowRoot}function zp(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Xp(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Bp(e){return/^(table|td|th)$/.test(Mp(e))}function Vp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Hp=/transform|translate|scale|rotate|perspective|filter/,Up=/paint|layout|strict|content/,Wp=e=>!!e&&e!==`none`,Gp;function Kp(e){let t=Ip(e)?Xp(e):e;return Wp(t.transform)||Wp(t.translate)||Wp(t.scale)||Wp(t.rotate)||Wp(t.perspective)||!Jp()&&(Wp(t.backdropFilter)||Wp(t.filter))||Hp.test(t.willChange||``)||Up.test(t.contain||``)}function qp(e){let t=Qp(e);for(;Lp(t)&&!Yp(t);){if(Kp(t))return t;if(Vp(t))return null;t=Qp(t)}return null}function Jp(){return Gp??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Gp}function Yp(e){return/^(html|body|#document)$/.test(Mp(e))}function Xp(e){return Np(e).getComputedStyle(e)}function Zp(e){return Ip(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Qp(e){if(Mp(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Rp(e)&&e.host||Pp(e);return Rp(t)?t.host:t}function $p(e){let t=Qp(e);return Yp(t)?(e.ownerDocument||e).body:Lp(t)&&zp(t)?t:$p(t)}function em(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=$p(e),i=r===e.ownerDocument?.body,a=Np(r);if(i){let e=tm(a);return t.concat(a,a.visualViewport||[],zp(r)?r:[],e&&n?em(e):[])}return t.concat(r,em(r,[],n))}function tm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function nm(e){let t=Xp(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Lp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Gf(n)!==a||Gf(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function rm(e){return Ip(e)?e:e.contextElement}function im(e){let t=rm(e);if(!Lp(t))return qf(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=nm(t),o=(a?Gf(n.width):n.width)/r,s=(a?Gf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var am=qf(0);function om(e){let t=Np(e);return!Jp()||!t.visualViewport?am:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function sm(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Np(e)}function cm(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=rm(e),o=qf(1);t&&(r?Ip(r)&&(o=im(r)):o=im(e));let s=sm(a,n,r)?om(a):qf(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Np(a),t=Ip(r)?Np(r):r,n=e,i=tm(n);for(;i&&t!==n;){let e=im(i),t=i.getBoundingClientRect(),r=Xp(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Np(i),i=tm(n)}}return hp({width:u,height:d,x:c,y:l})}function lm(e,t){let n=Zp(e).scrollLeft;return t?t.left+n:cm(Pp(e)).left+n}function um(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-lm(e,n),y:n.top+t.scrollTop}}function dm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Pp(r),s=t?Vp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=qf(1),u=qf(0),d=Lp(r);if((d||!a)&&((Mp(r)!==`body`||zp(o))&&(c=Zp(r)),d)){let e=cm(r);l=im(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?um(o,c):qf(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function fm(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function pm(e){let t=Zp(e),n=e.ownerDocument.body,r=Wf(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Wf(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+lm(e),o=-t.scrollTop;return Xp(n).direction===`rtl`&&(a+=Wf(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var mm=25;function hm(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Np(e),a=Pp(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Jp()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(lm(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=mm&&(s-=o)}return{width:s,height:c,x:l,y:u}}function gm(e,t){let n=cm(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=im(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function _m(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=hm(e,n,t);else if(t===`document`)r=pm(Pp(e));else if(Ip(t))r=gm(t,n);else{let n=om(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return hp(r)}function vm(e,t){let n=t.get(e);if(n)return n;let r=em(e,[],!1).filter(e=>Ip(e)&&Mp(e)!==`body`),i=null,a=Xp(e).position===`fixed`,o=a?Qp(e):e;for(;Ip(o)&&!Yp(o);){let e=Xp(o),t=Kp(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Qp(o)}return t.set(e,r),r}function ym(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Vp(t)?[]:vm(t,this._c):[].concat(n),r],o=_m(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=_m(t,a[e],i);s=Wf(n.top,s),c=Uf(n.right,c),l=Uf(n.bottom,l),u=Wf(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function bm(e){let{width:t,height:n}=nm(e);return{width:t,height:n}}function xm(e,t,n){let r=Lp(t),i=Pp(t),a=n===`fixed`,o=cm(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=qf(0);if((r||!a)&&((Mp(t)!==`body`||zp(i))&&(s=Zp(t)),r)){let e=cm(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=lm(i));let l=i&&!r&&!a?um(i,s):qf(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Sm(e){return Xp(e).position===`static`}function Cm(e,t){if(!Lp(e)||Xp(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Pp(e)===n&&(n=n.ownerDocument.body),n}function wm(e,t){let n=Np(e);if(Vp(e))return n;if(!Lp(e)){let t=Qp(e);for(;t&&!Yp(t);){if(Ip(t)&&!Sm(t))return t;t=Qp(t)}return n}let r=Cm(e,t);for(;r&&Bp(r)&&Sm(r);)r=Cm(r,t);return r&&Yp(r)&&Sm(r)&&!Kp(r)?n:r||qp(e)||n}var Tm=async function(e){let t=this.getOffsetParent||wm,n=this.getDimensions,r=await n(e.floating);return{reference:xm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Em(e){return Xp(e).direction===`rtl`}var Dm={convertOffsetParentRelativeRectToViewportRelativeRect:dm,getDocumentElement:Pp,getClippingRect:ym,getOffsetParent:wm,getElementRects:Tm,getClientRects:fm,getDimensions:bm,getScale:im,isElement:Ip,isRTL:Em};function Om(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function km(e,t,n){let r=null,i,a=Pp(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Kf(d),h=Kf(a.clientWidth-(u+f)),g=Kf(a.clientHeight-(d+p)),_=Kf(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Wf(0,Uf(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Om(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Np(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Am(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=rm(e),u=i||a?[...l?em(l):[],...t?em(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?km(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?cm(e):null;c&&g();function g(){let t=cm(e);h&&!Om(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var jm=Dp,Mm=Op,Nm=xp,Pm=Ap,Fm=wp,Im=bp,Lm=kp,Rm=(e,t,n)=>{let r=new Map,i=n??{},a={...Dm,...i.platform,_c:r};return yp(e,t,{...i,platform:a})},zm=typeof document<`u`?m.useLayoutEffect:function(){};function Bm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Bm(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Bm(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Vm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hm(e,t){let n=Vm(e);return Math.round(t*n)/n}function Um(e){let t=m.useRef(e);return zm(()=>{t.current=e}),t}function Wm(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);Bm(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=Um(c),O=Um(i),k=Um(l),A=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Rm(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Bm(T.current,t)&&(T.current=t,$c.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);zm(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=m.useRef(!1);zm(()=>(j.current=!0,()=>{j.current=!1}),[]),zm(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=m.useMemo(()=>({reference:x,floating:S}),[x,S]),P=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Hm(N.floating,u.x),r=Hm(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Vm(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Gm=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Im({element:r.current,padding:i}).fn(n):r?Im({element:r,padding:i}).fn(n):{}}}},Km=(e,t)=>{let n=jm(e);return{name:n.name,fn:n.fn,options:[e,t]}},qm=(e,t)=>{let n=Mm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jm=(e,t)=>({fn:Lm(e).fn,options:[e,t]}),Ym=(e,t)=>{let n=Nm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xm=(e,t)=>{let n=Pm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zm=(e,t)=>{let n=Fm(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qm=(e,t)=>{let n=Gm(e);return{name:n.name,fn:n.fn,options:[e,t]}},$m=Object.defineProperty,eh=(e,t)=>$m(e,`name`,{value:t,configurable:!0}),th=`Popper`,[nh,rh]=cl(th),[ih,ah]=nh(th),oh=eh(e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,h.jsx)(ih,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),sh=`PopperAnchor`,ch=m.forwardRef(eh(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=ah(sh,n),o=m.useRef(null),s=a.onAnchorChange,c=Ic(t,m.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&hh(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,h.jsx)(nl.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),lh=`PopperContent`,[uh,dh]=nh(lh),fh=m.forwardRef(eh(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:g,..._}=e,v=ah(lh,n),[y,b]=m.useState(null),x=Ic(t,b),[S,C]=m.useState(null),w=Vf(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(l)?l:[l],A=k.length>0,j={padding:O,boundary:k.filter(ph),altBoundary:A},{refs:M,floatingStyles:N,placement:P,isPositioned:F,middlewareData:I}=Wm({strategy:`fixed`,placement:D,whileElementsMounted:eh((...e)=>Am(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[Km({mainAxis:i+E,alignmentAxis:o}),c&&qm({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Jm():void 0,...j}),c&&Ym({...j}),Xm({...j,apply:eh(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&Qm({element:S,padding:s}),mh({arrowWidth:T,arrowHeight:E}),f&&Zm({strategy:`referenceHidden`,...j,boundary:A?j.boundary:void 0})]}),ee=v.setPlacementState;Al(()=>(ee(P),()=>{ee(void 0)}),[P,ee]);let[te,ne]=hh(P),L=cu(g);Al(()=>{F&&L?.()},[F,L]);let re=I.arrow?.x,ie=I.arrow?.y,ae=I.arrow?.centerOffset!==0,[oe,se]=m.useState();return Al(()=>{y&&se(window.getComputedStyle(y).zIndex)},[y]),(0,h.jsx)(`div`,{ref:M.setFloating,"data-radix-popper-content-wrapper":``,style:{...N,transform:F?N.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(` `),...I.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,h.jsx)(uh,{scope:n,placedSide:te,placedAlign:ne,onArrowChange:C,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,h.jsx)(nl.div,{"data-side":te,"data-align":ne,..._,ref:x,style:{..._.style,animation:F?_.style?.animation:`none`}})})})},`PopperContent`));function ph(e){return e!==null}eh(ph,`isNotNull`);var mh=eh(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=hh(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function hh(e){let[t,n=`center`]=e.split(`-`);return[t,n]}eh(hh,`getSideAndAlignFromPlacement`);var gh=oh,_h=ch,vh=fh,yh=Object.defineProperty,bh=(e,t)=>yh(e,`name`,{value:t,configurable:!0}),xh=!1;function Sh(){let[e,t]=m.useState(xh);return m.useEffect(()=>{xh||(xh=!0,t(!0))},[]),e}bh(Sh,`useIsHydrated`);var Ch=m.useSyncExternalStore;function wh(){return()=>{}}bh(wh,`subscribe`);function Th(){return Ch(wh,()=>!0,()=>!1)}bh(Th,`useIsHydratedModern`);var Eh=typeof Ch==`function`?Th:Sh,Dh=Object.defineProperty,Oh=(e,t)=>Dh(e,`name`,{value:t,configurable:!0}),kh=`rovingFocusGroup.onEntryFocus`,Ah={bubbles:!1,cancelable:!0},jh=`RovingFocusGroup`,[Mh,Nh,Ph]=fl(jh),[Fh,Ih]=cl(jh,[Ph]),[Lh,Rh]=Fh(jh),zh=m.forwardRef(Oh(function(e,t){return(0,h.jsx)(Mh.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,h.jsx)(Mh.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,h.jsx)(Bh,{...e,ref:t})})})},`RovingFocusGroup`)),Bh=m.forwardRef(Oh(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=m.useRef(null),p=Ic(t,f),g=au(a),[_,v]=K({prop:o,defaultProp:s??null,onChange:c,caller:jh}),[y,b]=m.useState(!1),x=cu(l),S=Nh(n),C=m.useRef(!1),[w,T]=m.useState(0);return m.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(kh,x),()=>e.removeEventListener(kh,x)},[x]),(0,h.jsx)(Lh,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:m.useCallback(e=>v(e),[v]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(e=>e+1),[]),onFocusableItemRemove:m.useCallback(()=>T(e=>e-1),[]),children:(0,h.jsx)(nl.div,{tabIndex:y||w===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:G(e.onMouseDown,()=>{C.current=!0}),onFocus:G(e.onFocus,e=>{let t=!C.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent(kh,Ah);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=S().filter(e=>e.focusable);Kh([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),u)}}C.current=!1}),onBlur:G(e.onBlur,()=>b(!1))})})},`RovingFocusGroupImpl`)),Vh=`RovingFocusGroupItem`,Hh=m.forwardRef(Oh(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=tu(),l=a||c,u=Rh(Vh,n),d=u.currentTabStopId===l,f=Nh(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:_}=u,v=Eh();return Al(()=>{if(v&&r)return p(),()=>g()},[v,r,p,g]),m.useEffect(()=>{if(!v&&r)return p(),()=>g()},[v,r,p,g]),(0,h.jsx)(Mh.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,h.jsx)(nl.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:G(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:G(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:G(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Gh(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?qh(n,r+1):n.slice(r+1)}setTimeout(()=>Kh(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:_!=null}):o})})},`RovingFocusGroupItem`)),Uh={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Wh(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}Oh(Wh,`getDirectionAwareKey`);function Gh(e,t,n){let r=Wh(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Uh[r]}Oh(Gh,`getFocusIntent`);function Kh(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Oh(Kh,`focusFirst`);function qh(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Oh(qh,`wrapArray`);var Jh=zh,Yh=Hh,Xh=Object.defineProperty,Zh=(e,t)=>Xh(e,`name`,{value:t,configurable:!0}),Qh=[`Enter`,` `],$h=[`ArrowDown`,`PageUp`,`Home`],eg=[`ArrowUp`,`PageDown`,`End`],tg=[...$h,...eg];[...Qh],[...Qh];var ng=`Menu`,[rg,ig,ag]=fl(ng),[og,sg]=cl(ng,[ag,rh,Ih]),cg=rh(),lg=Ih(),[ug,dg]=og(ng),[fg,pg]=og(ng),mg=Zh(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=cg(t),[c,l]=m.useState(null),u=m.useRef(!1),d=cu(a),f=au(i);return m.useEffect(()=>{let e=Zh(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=Zh(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),m.useEffect(()=>{if(!n)return;let e=Zh(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,h.jsx)(gh,{...s,children:(0,h.jsx)(ug,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,h.jsx)(fg,{scope:t,onClose:m.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),hg=m.forwardRef(Zh(function(e,t){let{__scopeMenu:n,...r}=e,i=cg(n);return(0,h.jsx)(_h,{...i,...r,ref:t})},`MenuAnchor`)),gg=`MenuPortal`,[_g,vg]=og(gg,{forceMount:void 0}),yg=Zh(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=dg(gg,t);return(0,h.jsx)(_g,{scope:t,forceMount:n,children:(0,h.jsx)(Gl,{present:n||a.open,children:(0,h.jsx)(Vu,{asChild:!0,container:i,children:r})})})},`MenuPortal`),bg=`MenuContent`,[xg,Sg]=og(bg),Cg=m.forwardRef(Zh(function(e,t){let n=vg(bg,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=dg(bg,e.__scopeMenu),o=pg(bg,e.__scopeMenu);return(0,h.jsx)(rg.Provider,{scope:e.__scopeMenu,children:(0,h.jsx)(Gl,{present:r||a.open,children:(0,h.jsx)(rg.Slot,{scope:e.__scopeMenu,children:o.modal?(0,h.jsx)(wg,{...i,ref:t}):(0,h.jsx)(Tg,{...i,ref:t})})})})},`MenuContent`)),wg=m.forwardRef(Zh(function(e,t){let n=dg(bg,e.__scopeMenu),r=m.useRef(null),i=Ic(t,r);return m.useEffect(()=>{let e=r.current;if(e)return ff(e)},[]),(0,h.jsx)(Dg,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:G(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Tg=m.forwardRef(Zh(function(e,t){let n=dg(bg,e.__scopeMenu);return(0,h.jsx)(Dg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Eg=zc(`MenuContent.ScrollLock`),Dg=m.forwardRef(Zh(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:g,..._}=e,v=dg(bg,n),y=pg(bg,n),b=cg(n),x=lg(n),S=ig(n),[C,w]=m.useState(null),T=m.useRef(null),E=Ic(t,T,v.onContentChange),D=m.useRef(0),O=m.useRef(``),k=m.useRef(0),A=m.useRef(null),j=m.useRef(`right`),M=m.useRef(0),N=g?nf:m.Fragment,P=g?{as:Eg,allowPinchZoom:!0}:void 0,F=Zh(e=>{let t=O.current+e,n=S().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Ug(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;Zh((function e(t){O.current=t,window.clearTimeout(D.current),t!==``&&(D.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);m.useEffect(()=>()=>window.clearTimeout(D.current),[]),qu();let I=m.useCallback(e=>j.current===A.current?.side&&Gg(e,A.current?.area),[]);return(0,h.jsx)(xg,{scope:n,searchRef:O,onItemEnter:m.useCallback(e=>{I(e)&&e.preventDefault()},[I]),onItemLeave:m.useCallback(e=>{I(e)||(T.current?.focus(),w(null))},[I]),onTriggerLeave:m.useCallback(e=>{I(e)&&e.preventDefault()},[I]),pointerGraceTimerRef:k,onPointerGraceIntentChange:m.useCallback(e=>{A.current=e},[]),children:(0,h.jsx)(N,{...P,children:(0,h.jsx)(Ou,{asChild:!0,trapped:i,onMountAutoFocus:G(a,e=>{e.preventDefault(),T.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,h.jsx)(gu,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,h.jsx)(Jh,{asChild:!0,...x,dir:y.dir,orientation:`vertical`,loop:r,currentTabStopId:C,onCurrentTabStopIdChange:w,onEntryFocus:G(c,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,h.jsx)(vh,{role:`menu`,"aria-orientation":`vertical`,"data-state":Rg(v.open),"data-radix-menu-content":``,dir:y.dir,...b,..._,ref:E,style:{outline:`none`,..._.style},onKeyDown:G(_.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&F(e.key));let i=T.current;if(e.target!==i||!tg.includes(e.key))return;e.preventDefault();let a=S().filter(e=>!e.disabled).map(e=>e.ref.current);eg.includes(e.key)&&a.reverse(),Vg(a)}),onBlur:G(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(D.current),O.current=``)}),onPointerMove:G(e.onPointerMove,Kg(e=>{let t=e.target,n=M.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>M.current?`right`:`left`;j.current=t,M.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),Og=`MenuItem`,kg=`menu.itemSelect`,Ag=m.forwardRef(Zh(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=m.useRef(null),o=pg(Og,e.__scopeMenu),s=Sg(Og,e.__scopeMenu),c=Ic(t,a),l=m.useRef(!1),u=Zh(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(kg,{bubbles:!0,cancelable:!0});e.addEventListener(kg,e=>r?.(e),{once:!0}),rl(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,h.jsx)(jg,{...i,ref:c,disabled:n,onClick:G(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:G(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:G(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&Qh.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),jg=m.forwardRef(Zh(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Sg(Og,n),s=lg(n),c=m.useRef(null),l=Ic(t,c),[u,d]=m.useState(!1),[f,p]=m.useState(``);return m.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,h.jsx)(rg.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,h.jsx)(Yh,{asChild:!0,...s,focusable:!r,children:(0,h.jsx)(nl.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:G(e.onPointerMove,Kg(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:G(e.onPointerLeave,Kg(e=>o.onItemLeave(e))),onFocus:G(e.onFocus,()=>d(!0)),onBlur:G(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Mg,Ng]=og(`MenuRadioGroup`,{value:void 0,onValueChange:Zh(()=>{},`onValueChange`)}),[Pg,Fg]=og(`MenuItemIndicator`,{checked:!1}),[Ig,Lg]=og(`MenuSub`);function Rg(e){return e?`open`:`closed`}Zh(Rg,`getOpenState`);function zg(e){return e===`indeterminate`}Zh(zg,`isIndeterminate`);function Bg(e){return zg(e)?`indeterminate`:e?`checked`:`unchecked`}Zh(Bg,`getCheckedState`);function Vg(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Zh(Vg,`focusFirst`);function Hg(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Zh(Hg,`wrapArray`);function Ug(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Hg(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}Zh(Ug,`getNextMatch`);function Wg(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Zh(Wg,`isPointInPolygon`);function Gg(e,t){return t?Wg({x:e.clientX,y:e.clientY},t):!1}Zh(Gg,`isPointerInGraceArea`);function Kg(e){return t=>t.pointerType===`mouse`?e(t):void 0}Zh(Kg,`whenMouse`);var qg=mg,Jg=hg,Yg=yg,Xg=Cg,Zg=Ag,Qg=Object.defineProperty,$g=(e,t)=>Qg(e,`name`,{value:t,configurable:!0}),e_=`DropdownMenu`,[t_,n_]=cl(e_,[sg]),r_=sg(),[i_,a_]=t_(e_),o_=$g(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=r_(t),l=m.useRef(null),[u,d]=K({prop:i,defaultProp:a??!1,onChange:o,caller:e_});return(0,h.jsx)(i_,{scope:t,triggerId:tu(),triggerRef:l,contentId:tu(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,h.jsx)(qg,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),s_=`DropdownMenuTrigger`,c_=m.forwardRef($g(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=a_(s_,n),o=r_(n),s=Ic(t,a.triggerRef);return(0,h.jsx)(Jg,{asChild:!0,...o,children:(0,h.jsx)(nl.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:G(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:G(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),l_=$g(e=>{let{__scopeDropdownMenu:t,...n}=e,r=r_(t);return(0,h.jsx)(Yg,{...r,...n})},`DropdownMenuPortal`),u_=`DropdownMenuContent`,d_=m.forwardRef($g(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=a_(u_,n),a=r_(n),o=m.useRef(!1);return(0,h.jsx)(Xg,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:G(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:G(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),f_=m.forwardRef($g(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=r_(n);return(0,h.jsx)(Zg,{...i,...r,ref:t})},`DropdownMenuItem`)),p_=o_,m_=c_,h_=l_,g_=d_,__=f_,v_=Object.defineProperty,y_=m.forwardRef(((e,t)=>v_(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,h.jsx)(nl.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),b_=Object.defineProperty,x_=(e,t)=>b_(e,`name`,{value:t,configurable:!0});function S_(e){let t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}x_(S_,`usePrevious`);var C_=Object.defineProperty,w_=(e,t)=>C_(e,`name`,{value:t,configurable:!0});function T_(e,[t,n]){return Math.min(n,Math.max(t,e))}w_(T_,`clamp`);var E_=Object.defineProperty,D_=(e,t)=>E_(e,`name`,{value:t,configurable:!0}),O_=[` `,`Enter`,`ArrowUp`,`ArrowDown`],k_=[` `,`Enter`],A_=`Select`,[j_,M_,N_]=fl(A_),[P_,F_]=cl(A_,[N_,rh]),I_=rh(),[L_,R_]=P_(A_),[z_,B_]=P_(A_);function V_(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:g,internal_do_not_use_render:_}=e,v=I_(t),[y,b]=m.useState(null),[x,S]=m.useState(null),[C,w]=m.useState(!1),T=au(l),[E,D]=K({prop:r,defaultProp:i??!1,onChange:a,caller:A_}),[O,k]=K({prop:o,defaultProp:s,onChange:c,caller:A_}),A=m.useRef(null),j=m.useRef(O);m.useEffect(()=>{let e=g?y?.ownerDocument.getElementById(g):y?.form;if(e instanceof HTMLFormElement){let t=D_(()=>k(j.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[g,y,k]);let M=!y||!!g||!!y.closest(`form`),[N,P]=m.useState(new Set),F=tu(),I=Array.from(N).map(e=>e.props.value).join(`;`),ee=m.useCallback(e=>{P(t=>new Set(t).add(e))},[]),te=m.useCallback(e=>{P(t=>{let n=new Set(t);return n.delete(e),n})},[]),ne={required:p,trigger:y,onTriggerChange:b,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:w,contentId:F,value:O,onValueChange:k,open:E,onOpenChange:D,dir:T,triggerPointerDownPosRef:A,disabled:f,name:u,autoComplete:d,form:g,nativeOptions:N,nativeSelectKey:I,isFormControl:M};return(0,h.jsx)(gh,{...v,children:(0,h.jsx)(L_,{scope:t,...ne,children:(0,h.jsx)(j_.Provider,{scope:t,children:(0,h.jsx)(z_,{scope:t,onNativeOptionAdd:ee,onNativeOptionRemove:te,children:Cv(_)?_(ne):n})})})})}D_(V_,`SelectProvider`);var H_=D_(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,h.jsx)(V_,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,h.jsxs)(h.Fragment,{children:[n,e?(0,h.jsx)(Sv,{__scopeSelect:t}):null]})})},`Select`),U_=`SelectTrigger`,W_=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=I_(n),o=R_(U_,n),s=o.disabled||r,c=Ic(t,o.onTriggerChange),l=M_(n),u=m.useRef(`touch`),[d,f,p]=Tv(e=>{let t=l().filter(e=>!e.disabled),n=Ev(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),g=D_(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,h.jsx)(_h,{asChild:!0,...a,children:(0,h.jsx)(nl.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":wv(o.value)?``:void 0,...i,ref:c,onClick:G(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&g(e)}),onPointerDown:G(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(g(e),e.preventDefault())}),onKeyDown:G(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&O_.includes(e.key)&&(g(),e.preventDefault())})})})},`SelectTrigger`)),G_=`SelectValue`,K_=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=R_(G_,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Ic(t,c.onValueNodeChange);Al(()=>{l(u)},[l,u]);let f=wv(c.value);return(0,h.jsx)(nl.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,h.jsx)(m.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),q_=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,h.jsx)(nl.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[J_,Y_]=P_(`SelectPortal`,{forceMount:void 0}),X_=D_(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,h.jsx)(J_,{scope:e.__scopeSelect,forceMount:n,children:(0,h.jsx)(Vu,{asChild:!0,...r})})},`SelectPortal`),Z_=`SelectContent`,Q_=m.forwardRef(D_(function(e,t){let n=Y_(Z_,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=R_(Z_,e.__scopeSelect),[o,s]=m.useState();return Al(()=>{s(new DocumentFragment)},[]),(0,h.jsx)(Gl,{present:r||a.open,children:({present:e})=>e?(0,h.jsx)(iv,{...i,ref:t}):(0,h.jsx)($_,{...i,fragment:o})})},`SelectContent`)),$_=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?$c.createPortal((0,h.jsx)(tv,{scope:n,children:(0,h.jsx)(j_.Slot,{scope:n,children:(0,h.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),ev=10,[tv,nv]=P_(Z_),rv=zc(`SelectContent.RemoveScroll`),iv=m.forwardRef(D_(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:g,hideWhenDetached:_,avoidCollisions:v,...y}=e,b=R_(Z_,n),[x,S]=m.useState(null),[C,w]=m.useState(null),T=Ic(t,S),[E,D]=m.useState(null),[O,k]=m.useState(null),A=M_(n),[j,M]=m.useState(!1),N=m.useRef(!1);m.useEffect(()=>{if(x)return ff(x)},[x]),qu();let P=m.useCallback(e=>{let[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&C&&(C.scrollTop=0),n===r&&C&&(C.scrollTop=C.scrollHeight),n?.focus(),document.activeElement!==i))return},[A,C]),F=m.useCallback(()=>P([E,x]),[P,E,x]);m.useEffect(()=>{j&&F()},[j,F]);let{onOpenChange:I,triggerPointerDownPosRef:ee}=b;m.useEffect(()=>{if(x){let e={x:0,y:0},t=D_(t=>{e={x:Math.abs(Math.round(t.pageX)-(ee.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(ee.current?.y??0))}},`handlePointerMove`),n=D_(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(x)||I(!1),document.removeEventListener(`pointermove`,t),ee.current=null},`handlePointerUp`);return ee.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[x,I,ee]),m.useEffect(()=>{let e=D_(()=>I(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[I]);let[te,ne]=Tv(e=>{let t=A().filter(e=>!e.disabled),n=Ev(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),L=m.useCallback((e,t,n)=>{let r=!N.current&&!n;(b.value!==void 0&&b.value===t||r)&&(D(e),r&&(N.current=!0))},[b.value]),re=m.useCallback(()=>x?.focus(),[x]),ie=m.useCallback((e,t,n)=>{let r=!N.current&&!n;(b.value!==void 0&&b.value===t||r)&&k(e)},[b.value]),ae=r===`popper`?ov:av,oe=ae===ov?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:g,hideWhenDetached:_,avoidCollisions:v}:{};return(0,h.jsx)(tv,{scope:n,content:x,viewport:C,onViewportChange:w,itemRefCallback:L,selectedItem:E,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:F,selectedItemText:O,position:r,isPositioned:j,searchRef:te,children:(0,h.jsx)(nf,{as:rv,allowPinchZoom:!0,children:(0,h.jsx)(Ou,{asChild:!0,trapped:b.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:G(i,e=>{b.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,h.jsx)(gu,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:(0,h.jsx)(ae,{role:`listbox`,id:b.contentId,"data-state":b.open?`open`:`closed`,dir:b.dir,onContextMenu:e=>e.preventDefault(),...y,...oe,onPlaced:()=>M(!0),ref:T,style:{display:`flex`,flexDirection:`column`,outline:`none`,...y.style},onKeyDown:G(y.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&ne(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>P(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),av=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=R_(Z_,n),o=nv(Z_,n),[s,c]=m.useState(null),[l,u]=m.useState(null),d=Ic(t,u),f=M_(n),p=m.useRef(!1),g=m.useRef(!0),{viewport:_,selectedItem:v,selectedItemText:y,focusSelectedItem:b}=o,x=m.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&_&&v&&y){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=y.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-ev,d=T_(a,[ev,Math.max(ev,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-ev,d=T_(a,[ev,Math.max(ev,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-ev*2,u=_.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),h=parseInt(d.paddingTop,10),g=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+h+u+b+g,S=Math.min(v.offsetHeight*5,x),C=window.getComputedStyle(_),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-ev,D=c-E,O=v.offsetHeight/2,k=v.offsetTop+O,A=m+h+k,j=x-A;if(A<=E){let e=o.length>0&&v===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-_.offsetTop-_.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+g);s.style.height=n+`px`}else{let e=o.length>0&&v===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+_.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,_.scrollTop=A-E+_.offsetTop}s.style.margin=`${ev}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,_,v,y,a.dir,r]);Al(()=>x(),[x]);let[S,C]=m.useState();Al(()=>{l&&C(window.getComputedStyle(l).zIndex)},[l]);let w=m.useCallback(e=>{e&&g.current===!0&&(x(),b?.(),g.current=!1)},[x,b]);return(0,h.jsx)(sv,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:w,children:(0,h.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:S},children:(0,h.jsx)(nl.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),ov=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=ev,...a}=e,o=I_(n);return(0,h.jsx)(vh,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[sv,cv]=P_(Z_,{}),lv=`SelectViewport`,uv=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=nv(lv,n),o=cv(lv,n),s=Ic(t,a.onViewportChange),c=m.useRef(0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,h.jsx)(j_.Slot,{scope:n,children:(0,h.jsx)(nl.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:G(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-ev*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[dv,fv]=P_(`SelectGroup`),pv=`SelectItem`,[mv,hv]=P_(pv),gv=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=R_(pv,n),c=nv(pv,n),l=s.value===r,[u,d]=m.useState(a??``),[f,p]=m.useState(!1),g=Ic(t,cu(e=>c.itemRefCallback?.(e,r,i))),_=tu(),v=m.useRef(`touch`),y=D_(()=>{i||(s.onValueChange(r),s.onOpenChange(!1))},`handleSelect`);return(0,h.jsx)(mv,{scope:n,value:r,disabled:i,textId:_,isSelected:l,onItemTextChange:m.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,h.jsx)(j_.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,h.jsx)(nl.div,{role:`option`,"aria-labelledby":_,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:g,onFocus:G(o.onFocus,()=>p(!0)),onBlur:G(o.onBlur,()=>p(!1)),onClick:G(o.onClick,()=>{v.current!==`mouse`&&y()}),onPointerUp:G(o.onPointerUp,()=>{v.current===`mouse`&&y()}),onPointerDown:G(o.onPointerDown,e=>{v.current=e.pointerType}),onPointerMove:G(o.onPointerMove,e=>{v.current=e.pointerType,i?c.onItemLeave?.():v.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:G(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:G(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(k_.includes(e.key)&&y(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),_v=`SelectItemText`,vv=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=R_(_v,n),s=nv(_v,n),c=hv(_v,n),l=B_(_v,n),[u,d]=m.useState(null),f=cu(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=Ic(t,d,c.onItemTextChange,f),g=u?.textContent,_=m.useMemo(()=>(0,h.jsx)(`option`,{value:c.value,disabled:c.disabled,children:g},c.value),[c.disabled,c.value,g]),{onNativeOptionAdd:v,onNativeOptionRemove:y}=l;return Al(()=>(v(_),()=>y(_)),[v,y,_]),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(nl.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!wv(o.value)?$c.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),yv=`SelectItemIndicator`,bv=m.forwardRef(D_(function(e,t){let{__scopeSelect:n,...r}=e;return hv(yv,n).isSelected?(0,h.jsx)(nl.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),xv=`SelectBubbleInput`,Sv=m.forwardRef(D_(function({__scopeSelect:e,...t},n){let r=R_(xv,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u}=r,{nativeOptions:d,nativeSelectKey:f}=r,p=m.useRef(null),g=Ic(n,p),_=i??``,v=S_(_),y=Array.from(d).some(e=>(e.props.value??``)===``);return m.useEffect(()=>{let e=p.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(v!==_&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,_),e.dispatchEvent(t)}},[v,_]),(0,h.jsxs)(nl.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>a(e.target.value),...t,style:{...il,...t.style},ref:g,defaultValue:_,children:[wv(i)&&!y?(0,h.jsx)(`option`,{value:``}):null,Array.from(d)]},f)},`SelectBubbleInput`));function Cv(e){return typeof e==`function`}D_(Cv,`isFunction`);function wv(e){return e===``||e===void 0}D_(wv,`shouldShowPlaceholder`);function Tv(e){let t=cu(e),n=m.useRef(``),r=m.useRef(0),i=m.useCallback(e=>{let i=n.current+e;t(i),D_((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=m.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}D_(Tv,`useTypeaheadSearch`);function Ev(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Dv(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}D_(Ev,`findNextItem`);function Dv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}D_(Dv,`wrapArray`);var Ov=Object.defineProperty,kv=(e,t)=>Ov(e,`name`,{value:t,configurable:!0}),Av=`Toggle`,jv=m.forwardRef(kv(function(e,t){let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=K({prop:n,onChange:i,defaultProp:r??!1,caller:Av});return(0,h.jsx)(nl.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:G(e.onClick,()=>{e.disabled||s(!o)})})},`Toggle`)),Mv=Object.defineProperty,Nv=(e,t)=>Mv(e,`name`,{value:t,configurable:!0}),Pv=`ToggleGroup`,[Fv,Iv]=cl(Pv,[Ih]),Lv=Ih(),Rv=m.forwardRef(Nv(function(e,t){let{type:n,...r}=e;if(n===`single`)return(0,h.jsx)(Vv,{role:`radiogroup`,...r,ref:t});if(n===`multiple`)return(0,h.jsx)(Hv,{role:`toolbar`,...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${Pv}\``)},`ToggleGroup`)),[zv,Bv]=Fv(Pv),Vv=m.forwardRef(Nv(function(e,t){let{value:n,defaultValue:r,onValueChange:i=Nv(()=>{},`onValueChange`),...a}=e,[o,s]=K({prop:n,defaultProp:r??``,onChange:i,caller:Pv});return(0,h.jsx)(zv,{scope:e.__scopeToggleGroup,type:`single`,value:m.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:m.useCallback(()=>s(``),[s]),children:(0,h.jsx)(Gv,{...a,ref:t})})},`ToggleGroupImplSingle`)),Hv=m.forwardRef(Nv(function(e,t){let{value:n,defaultValue:r,onValueChange:i=Nv(()=>{},`onValueChange`),...a}=e,[o,s]=K({prop:n,defaultProp:r??[],onChange:i,caller:Pv}),c=m.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=m.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,h.jsx)(zv,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,h.jsx)(Gv,{...a,ref:t})})},`ToggleGroupImplMultiple`)),[Uv,Wv]=Fv(Pv),Gv=m.forwardRef(Nv(function(e,t){let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=Lv(n),u=au(o),d={dir:u,...c};return(0,h.jsx)(Uv,{scope:n,rovingFocus:i,disabled:r,children:i?(0,h.jsx)(Jh,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,h.jsx)(nl.div,{...d,ref:t})}):(0,h.jsx)(nl.div,{...d,ref:t})})},`ToggleGroupImpl`)),Kv=`ToggleGroupItem`,qv=m.forwardRef(Nv(function(e,t){let n=Bv(Kv,e.__scopeToggleGroup),r=Wv(Kv,e.__scopeToggleGroup),i=Lv(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=m.useRef(null);return r.rovingFocus?(0,h.jsx)(Yh,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,h.jsx)(Jv,{...s,ref:t})}):(0,h.jsx)(Jv,{...s,ref:t})},`ToggleGroupItem`)),Jv=m.forwardRef(Nv(function(e,t){let{__scopeToggleGroup:n,value:r,...i}=e,a=Bv(Kv,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0},s=a.type===`single`?o:void 0;return(0,h.jsx)(jv,{...s,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})},`ToggleGroupItemImpl`)),Yv=jc(`inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap font-sans transition-colors duration-150 ease-out motion-reduce:transition-none`,{variants:{variant:{outline:`rounded-control border border-line2 bg-panel2 text-ink hover:bg-panel2 hover:border-ink3`,accent:`rounded-control border border-accent bg-transparent text-run-text hover:bg-panel2`,primary:`rounded-control bg-accent px-[14px] font-semibold text-accent-ink hover:bg-accent-edge`,ghost:`rounded-control text-ink2 hover:bg-panel2 hover:text-ink`,danger:`rounded-control border border-red bg-transparent text-ink hover:bg-panel2`,play:`rounded-panel bg-accent text-accent-ink font-extrabold tracking-[0.02em] shadow-[0_4px_0_var(--color-accent-edge)] active:translate-y-[3px] active:shadow-[0_1px_0_var(--color-accent-edge)] motion-reduce:active:translate-y-0`},size:{default:`h-8 px-3 text-body`,play:`h-14 w-full px-4 text-row`}},defaultVariants:{variant:`outline`,size:`default`}});function J({className:e,variant:t,size:n,asChild:r=!1,...i}){let a=r?Bc:`button`;return(0,h.jsx)(a,{"data-slot":`button`,className:W(Yv({variant:t,size:n}),e),...i})}var Xv=bf,Zv=wf;function Qv({className:e,...t}){return(0,h.jsx)(Ef,{"data-slot":`dialog-overlay`,className:W(`fixed inset-0 z-40 bg-scrim`,e),...t})}function $v({className:e,children:t,...n}){return(0,h.jsxs)(Zv,{children:[(0,h.jsx)(Qv,{}),(0,h.jsx)(Af,{"data-slot":`dialog-content`,className:W(`fixed top-1/2 left-1/2 z-50 flex w-[calc(100%-2rem)] max-w-[480px] -translate-x-1/2 -translate-y-1/2 flex-col gap-4`,`rounded-panel border border-line bg-panel p-[18px] shadow-[0_8px_24px_var(--color-shadow)]`,`data-[state=open]:animate-dialog-in motion-reduce:animate-none`,e),...n,children:t})]})}function ey({className:e,...t}){return(0,h.jsx)(Ff,{"data-slot":`dialog-title`,className:W(`text-title font-bold tracking-[-0.01em] text-ink`,e),...t})}function ty({className:e,...t}){return(0,h.jsx)(Lf,{"data-slot":`dialog-description`,className:W(`text-body text-ink2`,e),...t})}var ny={projects:[`projects`],project:e=>[`project`,e],article:e=>[`project`,e,`article`],file:(e,t)=>[`file`,e,t],staging:[`staging`],notice:[`notice`],usage:[`usage`],providers:[`providers`],voices:[`voices`],prompts:[`prompts`],entries:[`entries`],settings:[`settings`]};function ry(e){return et({queryKey:ny.projects,queryFn:()=>io(e)})}function iy(e,t){return et({queryKey:ny.project(t),queryFn:()=>ao(e,t)})}function ay(e){return et({queryKey:ny.notice,queryFn:()=>uo(e)})}function oy(e){return et({queryKey:ny.usage,queryFn:()=>lo(e)})}function sy(e){return et({queryKey:ny.providers,queryFn:()=>mo(e)})}function cy(e){return et({queryKey:ny.voices,queryFn:()=>yo(e)})}function ly(e){return et({queryKey:ny.prompts,queryFn:()=>wo(e)})}function uy(e){return et({queryKey:ny.entries,queryFn:()=>Do(e)})}function dy(e){return et({queryKey:ny.settings,queryFn:()=>_o(e)})}var fy=[`Tokens in and out per stage, with provider and model`,`Audio seconds per segment`,`Images made`,`Thumbnails made`,`Videos rendered`,`Projects created`,`That this machine installed Slopify`,`The time each of those happened`],py=[`API keys`,`Prompt bodies`,`Keyword values`,`Titles`,`Article or research text`,`Files and filenames`,`OS, locale, hardware`];function my(){let{api:e}=B(),t=_(),n=R(ay(e)),r=tt({mutationFn:()=>fo(e),onSuccess:e=>{t.setQueryData(ny.notice,e)}}),i=n.data?.seen===!1,a=n.data?.appVersion;return(0,h.jsx)(Xv,{open:i,children:(0,h.jsxs)($v,{onEscapeKeyDown:e=>{e.preventDefault()},onInteractOutside:e=>{e.preventDefault()},children:[(0,h.jsx)(ey,{children:`Anonymous usage stats`}),(0,h.jsx)(ty,{children:`These numbers power the live counters on slopify.stream.`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,h.jsx)(hy,{heading:`Tracked`,items:fy}),(0,h.jsx)(hy,{heading:`Never tracked`,items:py})]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Every event carries a random ID of its own and this machine's random ID, and nothing else. Nothing you write, upload, or paste ever leaves your machine.`}),a===void 0?null:(0,h.jsx)(`p`,{className:`engraved text-ink3`,children:`Slopify ${a} · this version is included in each report`}),(0,h.jsx)(J,{autoFocus:!0,variant:`play`,size:`play`,disabled:r.isPending,onClick:()=>{r.mutate()},children:`Got it`}),r.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:r.error.message})]})})}function hy({heading:e,items:t}){let n=`notice-${e.replace(/\s+/g,`-`).toLowerCase()}`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-[6px]`,children:[(0,h.jsx)(`p`,{id:n,className:`engraved border-b border-line pb-1 text-ink3`,children:e}),(0,h.jsx)(`ul`,{"aria-labelledby":n,className:`m-0 flex list-none flex-col gap-[6px] p-0 text-small`,children:t.map(e=>(0,h.jsx)(`li`,{children:e},e))})]})}function gy(e,t){if(t===`system`){e.removeAttribute(`data-theme`);return}e.setAttribute(`data-theme`,t)}function _y(){let{api:e}=B(),t=R(dy(e)).data?.appearance??`system`;return(0,m.useEffect)(()=>{gy(document.documentElement,t)},[t]),null}function vy({reload:e}){let{version:t}=B(),n=(0,m.useSyncExternalStore)(t.subscribe,t.staleAt,t.staleAt);return(0,h.jsx)(Xv,{open:n!==void 0,children:(0,h.jsxs)($v,{onEscapeKeyDown:e=>{e.preventDefault()},onInteractOutside:e=>{e.preventDefault()},children:[(0,h.jsx)(ey,{children:`Slopify was updated`}),(0,h.jsx)(ty,{children:`This tab was loaded before the update. Version ${n??``} is running now; reload to catch up.`}),(0,h.jsx)(J,{autoFocus:!0,variant:`play`,size:`play`,onClick:e,children:`Reload`})]})})}var yy=[`stage.state`,`stage.progress`,`article.delta`,`llm.preview`,`image.landed`,`project.state`,`project.updated`],by=[`running.count`,`staging.progress`,`staging.failed`,`project.updated`,`project.state`];function xy(e,t,n){return Cy(e,t,yy,n.refetch,e=>{if(e.type===`llm.preview`){n.previewWriting?.(e);return}if(e.type===`article.delta`){n.appendArticle(e.text);return}if(e.type===`image.landed`||e.type===`project.updated`){n.refetch();return}n.patch(e),e.type===`stage.state`&&n.refetch()})}function Sy(e,t,n){return Cy(e,t,by,n.refetch,e=>{if(e.type===`running.count`){n.tally(e.count);return}if(e.type===`project.updated`||e.type===`project.state`){n.refetch(e.projectId);return}n.stagingChanged()})}function Cy(e,t,n,r,i){let a=e(t),o=!1;a.addEventListener(`open`,()=>{o&&r(),o=!0});for(let e of n)a.addEventListener(e,t=>{let n=wy(t.data);n.type===e&&i(n)});return()=>{a.close()}}function wy(e){return JSON.parse(e)}var Ty=[`research`,`article`,`audio`,`images`,`thumbnail`,`video`],Ey={research:[`off`,`generate`,`provide`],article:[`generate`,`provide`],audio:[`off`,`generate`,`provide`],images:[`off`,`generate`,`provide`],thumbnail:[`off`,`from_prompt`,`prompt_by_llm`,`provide`],video:[`off`,`generate`]};function Dy(e){let t=[],n=Oy(e.draft),{sources:r}=n;n.title===``?t.push({field:`title`,message:`A title is required.`}):n.title.length>200&&t.push({field:`title`,message:`A title is at most 200 characters.`});for(let e of Ty)Ey[e].includes(r[e])||t.push({field:`sources.${e}`,message:`The ${e} stage cannot be set to ${r[e]}.`});(r.research===`generate`||r.article===`generate`||r.thumbnail===`prompt_by_llm`||n.intro?.mode===`llm`||n.outro?.mode===`llm`)&&!Py(n.llm)&&t.push({field:`llm`,message:`Pick an LLM provider and model.`}),r.article===`generate`&&Ny(n.articlePrompt)&&t.push({field:`articlePrompt`,message:`Pick an article prompt.`});let i=n.audio;return r.audio===`generate`&&(i===void 0||!Py(i)?t.push({field:`audio`,message:`Pick a narration provider and model.`}):i.voice.trim()===``&&t.push({field:`audio.voice`,message:`Pick a voice.`})),r.images===`generate`&&ky(n,t),(r.images===`generate`||r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&!Py(n.images)&&t.push({field:`images`,message:`Pick an image provider and model.`}),(r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&Ny(n.thumbnailPrompt)&&t.push({field:`thumbnailPrompt`,message:`Pick a thumbnail prompt.`}),r.audio===`off`&&n.subtitles!==void 0&&n.subtitles.mode!==`off`&&t.push({field:`subtitles.mode`,message:`Subtitles need narration audio.`}),Ay(n,e.staged,t),My(n,e.requiredSlots,t),(!Number.isFinite(n.silenceGapSeconds)||n.silenceGapSeconds<0||n.silenceGapSeconds>30)&&t.push({field:`silenceGapSeconds`,message:`The silence gap is between 0 and 30 seconds.`}),t.length===0?{ok:!0,draft:n}:{ok:!1,fields:t}}function Oy(e){let t={...e.sources};t.article===`provide`&&(t.research=`off`),t.images===`off`&&t.video===`generate`&&(t.video=`off`);let n=Object.create(null);for(let[t,r]of Object.entries(e.values))n[t]=r.trim();return{...e,title:e.title.trim(),subtitles:t.video===`off`&&e.subtitles?.mode===`burn-in`?{...e.subtitles,mode:`files`}:e.subtitles,sources:t,values:n,intro:t.audio===`generate`?e.intro:void 0,outro:t.audio===`generate`?e.outro:void 0}}function ky(e,t){if(e.imagePrompts.length===0){t.push({field:`imagePrompts`,message:`Tick at least one image prompt.`});return}let n=0;for(let[r,i]of e.imagePrompts.entries())n+=i.number,Ny(i.name)&&t.push({field:`imagePrompts.${r}.name`,message:`Pick an image prompt.`}),(!Number.isInteger(i.number)||i.number<1||i.number>20)&&t.push({field:`imagePrompts.${r}.number`,message:`Number is between 1 and 20.`});n>60&&t.push({field:`imagePrompts`,message:`A run makes at most 60 images; this one asks for ${n}.`})}function Ay(e,t,n){let{sources:r,provided:i}=e;if(r.research===`provide`&&Ny(i.research)&&n.push({field:`provided.research`,message:`Paste the research notes.`}),r.article===`provide`&&Ny(i.article)&&n.push({field:`provided.article`,message:`Paste the article.`}),r.audio===`provide`&&jy(t,i.audio,`audio`,`provided.audio`,`Pick an audio file.`,n),r.thumbnail===`provide`&&jy(t,i.thumbnail,`thumbnail`,`provided.thumbnail`,`Pick a thumbnail image.`,n),r.images===`provide`){let e=i.images??[];e.length===0?n.push({field:`provided.images`,message:`Pick at least one image.`}):e.length>60&&n.push({field:`provided.images`,message:`A run holds at most 60 images.`}),new Set(e).size!==e.length&&n.push({field:`provided.images`,message:`The same image was picked twice.`});for(let[r,i]of e.entries())jy(t,i,`images`,`provided.images.${r}`,`Pick an image.`,n)}}function jy(e,t,n,r,i,a){if(t===void 0||t===``){a.push({field:r,message:i});return}let o=e.find(e=>e.id===t);if(o===void 0||o.stageKind!==n){a.push({field:r,message:`That upload is no longer available; pick the file again.`});return}o.state!==`staged`&&a.push({field:r,message:`This upload is still copying.`})}function My(e,t,n){for(let r of t){let t=Object.hasOwn(e.values,r)?e.values[r]:void 0;if(t===void 0||t===``){n.push({field:`values.${r}`,message:`This field is required.`});continue}t.length>200&&n.push({field:`values.${r}`,message:`A value is at most 200 characters.`}),/[\n\r]/.test(t)&&n.push({field:`values.${r}`,message:`A value is a single line.`})}}function Ny(e){return e===void 0||e.trim()===``}function Py(e){return e!==void 0&&e.provider.trim()!==``&&e.model.trim()!==``}function Fy(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Iy(e,t=`|`){return e.map(e=>eb(e)).join(t)}function Ly(e,t){return typeof t==`bigint`?t.toString():t}function Ry(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function zy(e){return e==null}function By(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Vy(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Hy(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Uy(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Wy(e){return JSON.stringify(e)}function Gy(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Ky=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function qy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Jy=Ry(()=>{if(zb.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Yy(e){if(qy(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return qy(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Xy(e){return Yy(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Zy=new Set([`string`,`number`,`symbol`]);function Qy(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function $y(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Y(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function eb(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function tb(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var nb={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function rb(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return $y(e,Uy(e._zod.def,{get shape(){let e={};for(let r of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,r))throw Error(`Unrecognized key: "${String(r)}"`);t[r]&&Hy(e,r,n.shape[r])}return Hy(this,`shape`,e),e},checks:[]}))}function ib(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return $y(e,Uy(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete r[e]}return Hy(this,`shape`,r),r},checks:[]}))}function ab(e,t){if(!Yy(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return $y(e,Uy(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Hy(this,`shape`,n),n}}))}function ob(e,t){if(!Yy(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return $y(e,Uy(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Hy(this,`shape`,n),n}}))}function sb(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return $y(e,Uy(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Hy(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function cb(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);return $y(t,Uy(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(r,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t of Reflect.ownKeys(r))i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Hy(this,`shape`,i),i},checks:[]}))}function lb(e,t,n){return $y(t,Uy(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t of Reflect.ownKeys(r))i[t]=new e({type:`nonoptional`,innerType:r[t]});return Hy(this,`shape`,i),i}}))}function ub(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function db(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function fb(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function pb(e){return typeof e==`string`?e:e?.message}function mb(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function hb(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:pb(e.inst?._zod.def?.error?.(e))??pb(a?.(e))??pb(t?.error?.(e))??pb(n.customError?.(e))??pb(n.localeError?.(e))??`Invalid input`,{inst:s,schema:c,continue:l,input:u,...d}=e;return d.path??=[],d.message=o,t?.reportInput&&(d.input=u),d}var gb=/[\uD800-\uDBFF]/;function _b(e){let t=e.length;if(!gb.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function vb(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function yb(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function bb(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function xb(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):wb(e,n,r.value)}}function Sb(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Cb(e,t,n){return Sb(e,t,n,!1)}function wb(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Sb(this,t,n.bind(this))},set(e){Sb(this,t,e)}})}function Tb(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Eb,Db=!1,Ob={configurable:!0,get(){Db=!0}};function kb(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Eb!==e._zod){Eb=void 0;return}Eb=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Ob);let e=Db;Db=!1;try{let r=n(this);return Db?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Db||=e,r}catch(n){throw delete this[t],Db||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Ab(e,t,n,r){let i=Tb(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var jb=`~constantCatch`;function Mb(e){let t=()=>e;return t[jb]=!0,t}var Nb,Pb={value:void 0,enumerable:!1},Fb=`captureStackTrace`in Error?Error:null;function Ib(e){let t=Fb;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Fb=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function X(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Pb.value=new a(r);try{Object.defineProperty(n,"_zod",Pb)}finally{Pb.value=void 0}}if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),xb(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Ib(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Lb=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Rb=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Nb=globalThis).__zod_globalConfig??(Nb.__zod_globalConfig={});var zb=globalThis.__zod_globalConfig;function Bb(e){return e&&Object.assign(zb,e),zb}function Vb(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ly,2),e.message}function Hb(e){this._zod.message=e}var Ub={get:Vb,set:Hb,enumerable:!0,configurable:!0},Wb={value:void 0,enumerable:!1},Gb={value:void 0,enumerable:!1},Kb=new WeakSet([Object.prototype,Error.prototype]),qb=(e,t)=>{e.name=`$ZodError`,Wb.value=e._zod,Object.defineProperty(e,"_zod",Wb),Gb.value=t,Object.defineProperty(e,"issues",Gb),Wb.value=void 0,Gb.value=void 0,Object.defineProperty(e,"message",Ub);let n=Object.getPrototypeOf(e);Kb.has(n)||(Kb.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Jb=X(`$ZodError`,qb),Yb=X(`$ZodError`,qb,void 0,{Parent:Error});function Xb(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Zb(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Xb(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Qb(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function $b(e,t){return{callee:t?.callee??e,Err:t?.Err}}var ex=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Lb;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>hb(e,o,Bb())));throw Ky(n,a?.callee??t),n}return s.value};return t},tx=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>hb(e,o,Bb())));throw Ky(n,a?.callee??t),n}return s.value};return t},nx=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Lb;return a.issues.length?{success:!1,error:new(e??Jb)(a.issues.map(e=>hb(e,i,Bb())))}:{success:!0,data:a.value}},rx=nx(Yb),ix=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>hb(e,i,Bb())))}:{success:!0,data:a.value}},ax=ix(Yb),ox=e=>{let t=ex(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,$b(n,a))};return n},sx=e=>{let t=ex(e),n=(e,r,i,a)=>t(e,r,i,$b(n,a));return n},cx=e=>{let t=tx(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,$b(n,a))};return n},lx=e=>{let t=tx(e),n=async(e,r,i,a)=>await t(e,r,i,$b(n,a));return n},ux=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return nx(e)(t,n,i)},dx=e=>(t,n,r)=>nx(e)(t,n,r),fx=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ix(e)(t,n,i)},px=e=>async(t,n,r)=>ix(e)(t,n,r),mx=/^[cC][0-9a-z]{6,}$/,hx=/^[0-9a-z]+$/,gx=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_x=/^[0-9a-vA-V]{20}$/,vx=/^[A-Za-z0-9]{27}$/,yx=/^[a-zA-Z0-9_-]{21}$/;function bx(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var xx=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Sx=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Cx=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,wx=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Tx=`^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Ex(){return new RegExp(Tx,`u`)}var Dx=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ox=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,kx=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ax=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jx=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Mx=/^[A-Za-z0-9_-]*$/,Nx=/^https?$/,Px=/^\+[1-9]\d{6,14}$/,Fx=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Ix(e){return RegExp(`^${e}$`)}var Lx=Ix(Fx);function Rx(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function zx(e){return RegExp(`^${Rx(e)}$`)}function Bx(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Rx({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Rx({precision:e.precision})}`:n;return RegExp(`^${Fx}T(?:${r})$`)}var Vx=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Hx=/^-?\d+$/,Ux=/^-?\d+(?:\.\d+)?$/,Wx=/^[^A-Z]*$/,Gx=/^[^a-z]*$/,Kx=X(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),qx=e=>{let t=e.value;return!zy(t)&&t.length!==void 0},Jx={number:`number`,bigint:`bigint`,object:`date`},Yx=X(`$ZodCheckLessThan`,(e,t)=>{Kx.init(e,t);let n=Jx[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:Jx[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Xx=X(`$ZodCheckGreaterThan`,(e,t)=>{Kx.init(e,t);let n=Jx[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:Jx[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zx=X(`$ZodCheckMultipleOf`,(e,t)=>{Kx.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Vy(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Qx=X(`$ZodCheckNumberFormat`,(e,t)=>{Kx.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=nb[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Hx)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),$x=X(`$ZodCheckMaxLength`,(e,t)=>{var n;Kx.init(e,t),(n=e._zod.def).when??(n.when=qx),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?_b(r):i)<=t.maximum)return;let a=vb(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),eS=X(`$ZodCheckMinLength`,(e,t)=>{var n;Kx.init(e,t),(n=e._zod.def).when??(n.when=qx),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?_b(r):i)>=t.minimum)return;let a=vb(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),tS=X(`$ZodCheckLengthEquals`,(e,t)=>{var n;Kx.init(e,t),(n=e._zod.def).when??(n.when=qx),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?_b(r):i;if(a===t.length)return;let o=vb(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),nS=X(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Kx.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),rS=X(`$ZodCheckRegex`,(e,t)=>{nS.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),iS=X(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Wx,nS.init(e,t)}),aS=X(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Gx,nS.init(e,t)}),oS=X(`$ZodCheckIncludes`,(e,t)=>{Kx.init(e,t);let n=Qy(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),sS=X(`$ZodCheckStartsWith`,(e,t)=>{Kx.init(e,t);let n=RegExp(`^${Qy(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),cS=X(`$ZodCheckEndsWith`,(e,t)=>{Kx.init(e,t);let n=RegExp(`.*${Qy(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),lS=X(`$ZodCheckOverwrite`,(e,t)=>{Kx.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),uS=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
50
50
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
51
- `)}\n};`)(...Object.values(this.closed))}},BS={major:4,minor:5,patch:4},VS=X(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=BS;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=zb(t),a;for(let o of n){if(o._zod.def.when){if(Bb(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new fx;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Ub(t.issues,n,e),i||=zb(t,n))});else{if(t.issues.length===n)continue;Ub(t.issues,n,e),i||=zb(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(zb(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new fx;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new fx;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Qb(this,`~standard`,US(this))},set"~standard"(e){Zb(this,`~standard`,e)}}),HS=e=>e.success?{value:e.data}:{issues:e.error?.issues};function US(e){return{validate:t=>{try{return HS(Mx(e,t))}catch{return Px(e,t).then(HS)}},vendor:`zod`,version:1}}var WS=X(`$ZodString`,(e,t)=>{VS.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??gS(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),GS=X(`$ZodStringFormat`,(e,t)=>{jS.init(e,t),WS.init(e,t)}),KS=X(`$ZodGUID`,(e,t)=>{t.pattern??=Zx,GS.init(e,t)}),qS=X(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Qx(e)}else t.pattern??=Qx();GS.init(e,t)}),JS=X(`$ZodEmail`,(e,t)=>{t.pattern??=$x,GS.init(e,t)});function YS(e,t){if(!t.normalize&&t.protocol?.source===cS.source&&!/^https?:\/\//i.test(e))return 1;try{return new URL(e)}catch{return 2}}var XS=/[\t\n\r]/g;function ZS(e){return e.replace(XS,``)}function QS(e,t){return t.lastIndex=0,t.test(e.hostname)}function $S(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var eC=X(`$ZodURL`,(e,t)=>{GS.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=YS(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!QS(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!$S(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:ZS(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),tC=X(`$ZodEmoji`,(e,t)=>{t.pattern??=tS(),GS.init(e,t)}),nC=X(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Jx:Yx(t.length),GS.init(e,t)}),rC=X(`$ZodCUID`,(e,t)=>{t.pattern??=Ux,GS.init(e,t)}),iC=X(`$ZodCUID2`,(e,t)=>{t.pattern??=Wx,GS.init(e,t)}),aC=X(`$ZodULID`,(e,t)=>{t.pattern??=Gx,GS.init(e,t)}),oC=X(`$ZodXID`,(e,t)=>{t.pattern??=Kx,GS.init(e,t)}),sC=X(`$ZodKSUID`,(e,t)=>{t.pattern??=qx,GS.init(e,t)}),cC=X(`$ZodISODateTime`,(e,t)=>{t.pattern??=hS(t),GS.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(e=>{e._zod.bag.laxFormat=!0}))}),lC=X(`$ZodISODate`,(e,t)=>{t.pattern??=fS,GS.init(e,t)}),uC=X(`$ZodISOTime`,(e,t)=>{t.pattern??=mS(t),GS.init(e,t)}),dC=X(`$ZodISODuration`,(e,t)=>{t.pattern??=Xx,GS.init(e,t)}),fC=X(`$ZodIPv4`,(e,t)=>{t.pattern??=nS,GS.init(e,t),e._zod.bag.format=`ipv4`}),pC=/^[0-9a-fA-F:.]+$/;function mC(e){if(!pC.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}var hC=X(`$ZodIPv6`,(e,t)=>{t.pattern??=rS,GS.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{mC(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),gC=X(`$ZodCIDRv4`,(e,t)=>{t.pattern??=iS,GS.init(e,t)});function _C(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:mC(n)}var vC=X(`$ZodCIDRv6`,(e,t)=>{t.pattern??=aS,GS.init(e,t),e._zod.check=n=>{_C(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function yC(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var bC=X(`$ZodBase64`,(e,t)=>{t.pattern??=oS,GS.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{yC(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function xC(e){if(!sS.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return yC(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var SC=X(`$ZodBase64URL`,(e,t)=>{t.pattern??=sS,GS.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{xC(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),CC=X(`$ZodE164`,(e,t)=>{t.pattern??=lS,GS.init(e,t)});function wC(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var TC=X(`$ZodJWT`,(e,t)=>{GS.init(e,t),e._zod.check=n=>{wC(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),EC=X(`$ZodNumber`,(e,t)=>{VS.init(e,t),e._zod.pattern=e._zod.bag.pattern??vS,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),DC=X(`$ZodNumberFormat`,(e,t)=>{DS.init(e,t),EC.init(e,t)}),OC=X(`$ZodUnknown`,(e,t)=>{VS.init(e,t),e._zod.parse=e=>e}),kC=X(`$ZodNever`,(e,t)=>{VS.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function AC(e,t,n){e.issues.length&&t.issues.push(...Vb(n,e.issues)),t.value[n]=e.value}var jC=X(`$ZodArray`,(e,t)=>{VS.init(e,t);let n=mx.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[];for(let e=0;e<a.length;e++){let n=a[e],s=t.element._zod.run({value:n,issues:[]},i);s instanceof Promise?o.push(s.then(t=>AC(t,r,e))):AC(s,r,e)}return o.length?Promise.all(o).then(()=>r):r}});function MC(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Vb(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}}var NC=[];function PC(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:NC,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Ab(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function FC(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin,d=c.optout;for(let i in t){if(s.has(i))continue;if(i===`__proto__`){l===`never`&&o.push(i);continue}if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>MC(e,n,i,t,u,d))):MC(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var IC=new WeakMap,LC=X(`$ZodObject`,(e,t)=>{if(VS.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;IC.set(t,e),Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),IC.set(t,n),n}})}let n=pb(()=>PC(t));ix(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||_b(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let r=Sb,i=t.catchall,a,o=mx.memoizer;o?.attach(e),e._zod.parse=(t,s)=>{a??=n.value;let c=t.value;if(!r(c))return t.issues.push({expected:`object`,code:`invalid_type`,input:c,inst:e}),t;t.value=o?o.alloc(e,t,{},s):{};let l=[],u=a.shape;for(let e of a.allKeys){if(e===`__proto__`)continue;let n=u[e],r=n._zod.optin,i=n._zod.optout,a=n._zod.run({value:c[e],issues:[]},s);a instanceof Promise?l.push(a.then(n=>MC(n,t,e,c,r,i))):MC(a,t,e,c,r,i)}return i?FC(l,c,t,s,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),RC=X(`$ZodObjectJIT`,(e,t)=>{LC.init(e,t);let n=e._zod.parse,r=pb(()=>PC(t)),i=mx.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new zS([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
51
+ `)}\n};`)(...Object.values(this.closed))}},dS={major:4,minor:5,patch:4},fS=X(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=dS;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=ub(t),a;for(let o of n){if(o._zod.def.when){if(db(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Lb;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(mb(t.issues,n,e),i||=ub(t,n))});else{if(t.issues.length===n)continue;mb(t.issues,n,e),i||=ub(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(ub(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Lb;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Lb;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Cb(this,`~standard`,mS(this))},set"~standard"(e){Sb(this,`~standard`,e)}}),pS=e=>e.success?{value:e.data}:{issues:e.error?.issues};function mS(e){return{validate:t=>{try{return pS(rx(e,t))}catch{return ax(e,t).then(pS)}},vendor:`zod`,version:1}}var hS=X(`$ZodString`,(e,t)=>{fS.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Vx(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),gS=X(`$ZodStringFormat`,(e,t)=>{nS.init(e,t),hS.init(e,t)}),_S=X(`$ZodGUID`,(e,t)=>{t.pattern??=Sx,gS.init(e,t)}),vS=X(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Cx(e)}else t.pattern??=Cx();gS.init(e,t)}),yS=X(`$ZodEmail`,(e,t)=>{t.pattern??=wx,gS.init(e,t)});function bS(e,t){if(!t.normalize&&t.protocol?.source===Nx.source&&!/^https?:\/\//i.test(e))return 1;try{return new URL(e)}catch{return 2}}var xS=/[\t\n\r]/g;function SS(e){return e.replace(xS,``)}function CS(e,t){return t.lastIndex=0,t.test(e.hostname)}function wS(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var TS=X(`$ZodURL`,(e,t)=>{gS.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=bS(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!CS(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!wS(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:SS(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ES=X(`$ZodEmoji`,(e,t)=>{t.pattern??=Ex(),gS.init(e,t)}),DS=X(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?yx:bx(t.length),gS.init(e,t)}),OS=X(`$ZodCUID`,(e,t)=>{t.pattern??=mx,gS.init(e,t)}),kS=X(`$ZodCUID2`,(e,t)=>{t.pattern??=hx,gS.init(e,t)}),AS=X(`$ZodULID`,(e,t)=>{t.pattern??=gx,gS.init(e,t)}),jS=X(`$ZodXID`,(e,t)=>{t.pattern??=_x,gS.init(e,t)}),MS=X(`$ZodKSUID`,(e,t)=>{t.pattern??=vx,gS.init(e,t)}),NS=X(`$ZodISODateTime`,(e,t)=>{t.pattern??=Bx(t),gS.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(e=>{e._zod.bag.laxFormat=!0}))}),PS=X(`$ZodISODate`,(e,t)=>{t.pattern??=Lx,gS.init(e,t)}),FS=X(`$ZodISOTime`,(e,t)=>{t.pattern??=zx(t),gS.init(e,t)}),IS=X(`$ZodISODuration`,(e,t)=>{t.pattern??=xx,gS.init(e,t)}),LS=X(`$ZodIPv4`,(e,t)=>{t.pattern??=Dx,gS.init(e,t),e._zod.bag.format=`ipv4`}),RS=/^[0-9a-fA-F:.]+$/;function zS(e){if(!RS.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}var BS=X(`$ZodIPv6`,(e,t)=>{t.pattern??=Ox,gS.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{zS(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),VS=X(`$ZodCIDRv4`,(e,t)=>{t.pattern??=kx,gS.init(e,t)});function HS(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:zS(n)}var US=X(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ax,gS.init(e,t),e._zod.check=n=>{HS(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function WS(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var GS=X(`$ZodBase64`,(e,t)=>{t.pattern??=jx,gS.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{WS(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function KS(e){if(!Mx.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return WS(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var qS=X(`$ZodBase64URL`,(e,t)=>{t.pattern??=Mx,gS.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{KS(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),JS=X(`$ZodE164`,(e,t)=>{t.pattern??=Px,gS.init(e,t)});function YS(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var XS=X(`$ZodJWT`,(e,t)=>{gS.init(e,t),e._zod.check=n=>{YS(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ZS=X(`$ZodNumber`,(e,t)=>{fS.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ux,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),QS=X(`$ZodNumberFormat`,(e,t)=>{Qx.init(e,t),ZS.init(e,t)}),$S=X(`$ZodUnknown`,(e,t)=>{fS.init(e,t),e._zod.parse=e=>e}),eC=X(`$ZodNever`,(e,t)=>{fS.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function tC(e,t,n){e.issues.length&&t.issues.push(...fb(n,e.issues)),t.value[n]=e.value}var nC=X(`$ZodArray`,(e,t)=>{fS.init(e,t);let n=zb.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[];for(let e=0;e<a.length;e++){let n=a[e],s=t.element._zod.run({value:n,issues:[]},i);s instanceof Promise?o.push(s.then(t=>tC(t,r,e))):tC(s,r,e)}return o.length?Promise.all(o).then(()=>r):r}});function rC(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...fb(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}}var iC=[];function aC(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:iC,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=tb(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function oC(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin,d=c.optout;for(let i in t){if(s.has(i))continue;if(i===`__proto__`){l===`never`&&o.push(i);continue}if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>rC(e,n,i,t,u,d))):rC(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var sC=new WeakMap,cC=X(`$ZodObject`,(e,t)=>{if(fS.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;sC.set(t,e),Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),sC.set(t,n),n}})}let n=Ry(()=>aC(t));kb(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Hy(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let r=qy,i=t.catchall,a,o=zb.memoizer;o?.attach(e),e._zod.parse=(t,s)=>{a??=n.value;let c=t.value;if(!r(c))return t.issues.push({expected:`object`,code:`invalid_type`,input:c,inst:e}),t;t.value=o?o.alloc(e,t,{},s):{};let l=[],u=a.shape;for(let e of a.allKeys){if(e===`__proto__`)continue;let n=u[e],r=n._zod.optin,i=n._zod.optout,a=n._zod.run({value:c[e],issues:[]},s);a instanceof Promise?l.push(a.then(n=>rC(n,t,e,c,r,i))):rC(a,t,e,c,r,i)}return i?oC(l,c,t,s,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),lC=X(`$ZodObjectJIT`,(e,t)=>{cC.init(e,t);let n=e._zod.parse,r=Ry(()=>aC(t)),i=zb.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new uS([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
52
52
  for (let i = 0; i < ${e}.issues.length; i++) {
53
53
  const iss = ${e}.issues[i];
54
54
  iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
55
55
  payload.issues.push(iss);
56
- }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:yb(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
56
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Wy(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
57
57
  const ${n}_present = ${i};
58
58
  if (!${n}.issues.length || ${n}_present) {
59
59
  if (${n}.issues.length) {${c(n,r)}
@@ -93,38 +93,38 @@ Error generating stack: `+e.message+`
93
93
  newResult[${r}] = ${n}.value;
94
94
  }
95
95
 
96
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Sb,c=!mx.jitless,l=c&&Cb.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?FC([],p,i,f,d,e):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function zC(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!zb(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Wb(e,r,hx())))}),t)}var BC=X(`$ZodUnion`,(e,t)=>{VS.init(e,t),ix(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),ix(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),ix(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),ix(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>hb(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>zC(t,r,e,i)):zC(o,r,e,i)}}),VC=X(`$ZodIntersection`,(e,t)=>{VS.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>UC(e,t,n)):UC(e,i,a)}});function HC(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(wb(e)&&wb(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=HC(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=HC(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function UC(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=HC(t.value,n.value);if(!c.valid){if(zb(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var WC=X(`$ZodEnum`,(e,t)=>{VS.init(e,t);let n=ub(t.entries),r=new Set(n);e._zod.values=r;let i=n.filter(e=>Eb.has(typeof e));e._zod.pattern=RegExp(i.length?`^(${i.map(e=>Db(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),GC=X(`$ZodLiteral`,(e,t)=>{VS.init(e,t);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(t.values.length?`^(${t.values.map(e=>typeof e==`string`?Db(e):e?Db(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),KC=X(`$ZodTransform`,(e,t)=>{VS.init(e,t),e._zod.optin=`optional`,mx.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new px(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new fx;return n.value=i,n}});function qC(e,t){return e.value=t.issues.length?void 0:t.value,e}var JC=X(`$ZodOptional`,(e,t)=>{VS.init(e,t),ix(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,ix(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),ix(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${hb(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>qC(e,t)):qC(e,r)}return t.innerType._zod.run(e,n)}}),YC=X(`$ZodExactOptional`,(e,t)=>{JC.init(e,t),ix(e,`values`,e=>e.def.innerType._zod.values),ix(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),XC=X(`$ZodNullable`,(e,t)=>{VS.init(e,t),ix(e,`optin`,e=>e.def.innerType._zod.optin),ix(e,`optout`,e=>e.def.innerType._zod.optout),ix(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${hb(t.source)}|null)$`):void 0}),ix(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ZC=X(`$ZodDefault`,(e,t)=>{VS.init(e,t),e._zod.optin=`defaulted`,ix(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>QC(e,t)):QC(r,t)}});function QC(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var $C=X(`$ZodPrefault`,(e,t)=>{VS.init(e,t),e._zod.optin=`defaulted`,ix(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ew=X(`$ZodNonOptional`,(e,t)=>{VS.init(e,t),ix(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>tw(t,e)):tw(i,e)}});function tw(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function nw(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Wb(e,r,hx()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var rw=X(`$ZodCatch`,(e,t)=>{VS.init(e,t),ix(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),ix(e,`optout`,e=>e.def.innerType._zod.optout),ix(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>nw(e,r,t,n)):nw(e,r,t,n)}}),iw=X(`$ZodPipe`,(e,t)=>{VS.init(e,t),ix(e,`values`,e=>e.def.in._zod.values),ix(e,`optin`,e=>e.def.in._zod.optin),ix(e,`optout`,e=>e.def.out._zod.optout),ix(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>aw(e,t.in,n)):aw(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>aw(e,t.out,n)):aw(r,t.out,n)}});function aw(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var ow=X(`$ZodReadonly`,(e,t)=>{VS.init(e,t),ix(e,`propValues`,e=>e.def.innerType._zod.propValues),ix(e,`values`,e=>e.def.innerType._zod.values),ix(e,`optin`,e=>e.def.innerType?._zod?.optin),ix(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(sw):sw(r)}});function sw(e){return e.memo||(e.value=Object.freeze(e.value)),e}var cw=X(`$ZodCustom`,(e,t)=>{xS.init(e,t),VS.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>lw(t,n,r,e));lw(i,n,r,e)}});function lw(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Yb(e))}}var uw=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},dw=`~memo`,fw=[];function pw(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var mw=new WeakMap;function hw(e,t){let n=mw.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&hw(e,t)&&(r=!0)},a=e._zod.def;switch(a.type){case`object`:for(let e of Reflect.ownKeys(a.shape))i(a.shape[e]);i(a.catchall);break;case`array`:i(a.element);break;case`tuple`:for(let e of a.items)i(e);i(a.rest);break;case`record`:case`map`:i(a.keyType),i(a.valueType);break;case`set`:i(a.valueType);break;case`union`:for(let e of a.options)i(e);break;case`intersection`:i(a.left),i(a.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:i(a.innerType);break;case`pipe`:i(a.in),i(a.out);break;case`function`:i(a.input),i(a.output);break;case`lazy`:i(e._zod.innerType);break;case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)i(n);else if(Array.isArray(n))for(let e of n)i(e)}}}return t.delete(e),mw.set(e,r),r}function gw(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}var _w,vw=[],yw={alloc(e,t,n){let r=_w;if(!r)return n;_w=void 0;let i={value:n,issues:null};return r.set(t.value,i),vw.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&xw(n,e.value))throw new uw;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=hw(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[dw];l||(l={buckets:new Map,backEdges:void 0},s[dw]=l);let u;r===s?u=i:(u=gw(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...pw(d.issues)):(o.memo=!0,l.backEdges??(l.backEdges=new Set),l.backEdges.add(d.value)),o;_w=u;let f=vw.length,p=t(o,s);_w=void 0;let m=vw.length>f?vw.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?pw(e.issues):fw),e)):(m&&(m.issues=p.issues.length?pw(p.issues):fw),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function bw(){return yw}function xw(e,t){let n=e[dw]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}var Sw=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,credit_card:`credit card number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Jb(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${kb(e.values[0])}`:`Invalid option: expected one of ${db(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${db(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Cw(){return{localeError:Sw()}}var ww,Tw=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ew(){return new Tw}(ww=globalThis).__zod_globalRegistry??(ww.__zod_globalRegistry=Ew());var Dw=globalThis.__zod_globalRegistry;function Ow(e,t){return new e({type:`string`,...Y(t)})}function kw(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Y(t)})}function Aw(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Y(t)})}function jw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Y(t)})}function Mw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Y(t)})}function Nw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Y(t)})}function Pw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Y(t)})}function Fw(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Y(t)})}function Iw(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Y(t)})}function Lw(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Y(t)})}function Rw(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Y(t)})}function zw(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Y(t)})}function Bw(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Y(t)})}function Vw(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Y(t)})}function Hw(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Y(t)})}function Uw(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Y(t)})}function Ww(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Y(t)})}function Gw(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Y(t)})}function Kw(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Y(t)})}function qw(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Y(t)})}function Jw(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Y(t)})}function Yw(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Y(t)})}function Xw(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Y(t)})}function Zw(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Y(t)})}function Qw(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Y(t)})}function $w(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Y(t)})}function eT(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Y(t)})}function tT(e,t){return new e({type:`number`,checks:[],...Y(t)})}function nT(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Y(t)})}function rT(e){return new e({type:`unknown`})}function iT(e,t){return new e({type:`never`,...Y(t)})}function aT(e,t){return new wS({check:`less_than`,...Y(t),value:e,inclusive:!1})}function oT(e,t){return new wS({check:`less_than`,...Y(t),value:e,inclusive:!0})}function sT(e,t){return new TS({check:`greater_than`,...Y(t),value:e,inclusive:!1})}function cT(e,t){return new TS({check:`greater_than`,...Y(t),value:e,inclusive:!0})}function lT(e,t){return new ES({check:`multiple_of`,...Y(t),value:e})}function uT(e,t){return new OS({check:`max_length`,...Y(t),maximum:e})}function dT(e,t){return new kS({check:`min_length`,...Y(t),minimum:e})}function fT(e,t){return new AS({check:`length_equals`,...Y(t),length:e})}function pT(e,t){return new MS({check:`string_format`,format:`regex`,...Y(t),pattern:e})}function mT(e){return new NS({check:`string_format`,format:`lowercase`,...Y(e)})}function hT(e){return new PS({check:`string_format`,format:`uppercase`,...Y(e)})}function gT(e,t){return new FS({check:`string_format`,format:`includes`,...Y(t),includes:e})}function _T(e,t){return new IS({check:`string_format`,format:`starts_with`,...Y(t),prefix:e})}function vT(e,t){return new LS({check:`string_format`,format:`ends_with`,...Y(t),suffix:e})}function yT(e){return new RS({check:`overwrite`,tx:e})}function bT(e){return yT(t=>t.normalize(e))}function xT(){return yT(e=>e.trim())}function ST(){return yT(e=>e.toLowerCase())}function CT(){return yT(e=>e.toUpperCase())}function wT(){return yT(e=>bb(e))}function TT(e,t,n){return new e({type:`array`,element:t,...Y(n)})}function ET(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Y(n)})}function DT(e,t){let n=OT(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Yb(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Yb(r))}},e(t.value,t)),t);return n}function OT(e,t){let n=new xS({check:`custom`,...Y(t)});return n._zod.check=e,n}function kT(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&_b(e,t,n[t]);return e}function AT(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Dw,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function jT(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function MT(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,MT(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&kT(o.schema,c),t.io===`input`&&HT(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function NT(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function PT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${NT(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+NT(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
96
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=qy,c=!zb.jitless,l=c&&Jy.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?oC([],p,i,f,d,e):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function uC(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!ub(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>hb(e,r,Bb())))}),t)}var dC=X(`$ZodUnion`,(e,t)=>{fS.init(e,t),kb(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),kb(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),kb(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),kb(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>By(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>uC(t,r,e,i)):uC(o,r,e,i)}}),fC=X(`$ZodIntersection`,(e,t)=>{fS.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>mC(e,t,n)):mC(e,i,a)}});function pC(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Yy(e)&&Yy(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=pC(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=pC(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function mC(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=pC(t.value,n.value);if(!c.valid){if(ub(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var hC=X(`$ZodEnum`,(e,t)=>{fS.init(e,t);let n=Fy(t.entries),r=new Set(n);e._zod.values=r;let i=n.filter(e=>Zy.has(typeof e));e._zod.pattern=RegExp(i.length?`^(${i.map(e=>Qy(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),gC=X(`$ZodLiteral`,(e,t)=>{fS.init(e,t);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(t.values.length?`^(${t.values.map(e=>typeof e==`string`?Qy(e):e?Qy(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),_C=X(`$ZodTransform`,(e,t)=>{fS.init(e,t),e._zod.optin=`optional`,zb.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Rb(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Lb;return n.value=i,n}});function vC(e,t){return e.value=t.issues.length?void 0:t.value,e}var yC=X(`$ZodOptional`,(e,t)=>{fS.init(e,t),kb(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,kb(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),kb(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${By(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>vC(e,t)):vC(e,r)}return t.innerType._zod.run(e,n)}}),bC=X(`$ZodExactOptional`,(e,t)=>{yC.init(e,t),kb(e,`values`,e=>e.def.innerType._zod.values),kb(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),xC=X(`$ZodNullable`,(e,t)=>{fS.init(e,t),kb(e,`optin`,e=>e.def.innerType._zod.optin),kb(e,`optout`,e=>e.def.innerType._zod.optout),kb(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${By(t.source)}|null)$`):void 0}),kb(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),SC=X(`$ZodDefault`,(e,t)=>{fS.init(e,t),e._zod.optin=`defaulted`,kb(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>CC(e,t)):CC(r,t)}});function CC(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var wC=X(`$ZodPrefault`,(e,t)=>{fS.init(e,t),e._zod.optin=`defaulted`,kb(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),TC=X(`$ZodNonOptional`,(e,t)=>{fS.init(e,t),kb(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>EC(t,e)):EC(i,e)}});function EC(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function DC(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>hb(e,r,Bb()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var OC=X(`$ZodCatch`,(e,t)=>{fS.init(e,t),kb(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),kb(e,`optout`,e=>e.def.innerType._zod.optout),kb(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>DC(e,r,t,n)):DC(e,r,t,n)}}),kC=X(`$ZodPipe`,(e,t)=>{fS.init(e,t),kb(e,`values`,e=>e.def.in._zod.values),kb(e,`optin`,e=>e.def.in._zod.optin),kb(e,`optout`,e=>e.def.out._zod.optout),kb(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>AC(e,t.in,n)):AC(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>AC(e,t.out,n)):AC(r,t.out,n)}});function AC(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var jC=X(`$ZodReadonly`,(e,t)=>{fS.init(e,t),kb(e,`propValues`,e=>e.def.innerType._zod.propValues),kb(e,`values`,e=>e.def.innerType._zod.values),kb(e,`optin`,e=>e.def.innerType?._zod?.optin),kb(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(MC):MC(r)}});function MC(e){return e.memo||(e.value=Object.freeze(e.value)),e}var NC=X(`$ZodCustom`,(e,t)=>{Kx.init(e,t),fS.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>PC(t,n,r,e));PC(i,n,r,e)}});function PC(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(bb(e))}}var FC=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},IC=`~memo`,LC=[];function RC(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var zC=new WeakMap;function BC(e,t){let n=zC.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&BC(e,t)&&(r=!0)},a=e._zod.def;switch(a.type){case`object`:for(let e of Reflect.ownKeys(a.shape))i(a.shape[e]);i(a.catchall);break;case`array`:i(a.element);break;case`tuple`:for(let e of a.items)i(e);i(a.rest);break;case`record`:case`map`:i(a.keyType),i(a.valueType);break;case`set`:i(a.valueType);break;case`union`:for(let e of a.options)i(e);break;case`intersection`:i(a.left),i(a.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:i(a.innerType);break;case`pipe`:i(a.in),i(a.out);break;case`function`:i(a.input),i(a.output);break;case`lazy`:i(e._zod.innerType);break;case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)i(n);else if(Array.isArray(n))for(let e of n)i(e)}}}return t.delete(e),zC.set(e,r),r}function VC(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}var HC,UC=[],WC={alloc(e,t,n){let r=HC;if(!r)return n;HC=void 0;let i={value:n,issues:null};return r.set(t.value,i),UC.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&KC(n,e.value))throw new FC;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=BC(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[IC];l||(l={buckets:new Map,backEdges:void 0},s[IC]=l);let u;r===s?u=i:(u=VC(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...RC(d.issues)):(o.memo=!0,l.backEdges??(l.backEdges=new Set),l.backEdges.add(d.value)),o;HC=u;let f=UC.length,p=t(o,s);HC=void 0;let m=UC.length>f?UC.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?RC(e.issues):LC),e)):(m&&(m.issues=p.issues.length?RC(p.issues):LC),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function GC(){return WC}function KC(e,t){let n=e[IC]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}var qC=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,credit_card:`credit card number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(yb(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${eb(e.values[0])}`:`Invalid option: expected one of ${Iy(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Iy(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function JC(){return{localeError:qC()}}var YC,XC=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ZC(){return new XC}(YC=globalThis).__zod_globalRegistry??(YC.__zod_globalRegistry=ZC());var QC=globalThis.__zod_globalRegistry;function $C(e,t){return new e({type:`string`,...Y(t)})}function ew(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...Y(t)})}function tw(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...Y(t)})}function nw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...Y(t)})}function rw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...Y(t)})}function iw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...Y(t)})}function aw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...Y(t)})}function ow(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...Y(t)})}function sw(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...Y(t)})}function cw(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...Y(t)})}function lw(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...Y(t)})}function uw(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...Y(t)})}function dw(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...Y(t)})}function fw(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...Y(t)})}function pw(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...Y(t)})}function mw(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...Y(t)})}function hw(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...Y(t)})}function gw(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...Y(t)})}function _w(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...Y(t)})}function vw(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...Y(t)})}function yw(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...Y(t)})}function bw(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...Y(t)})}function xw(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...Y(t)})}function Sw(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...Y(t)})}function Cw(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...Y(t)})}function ww(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...Y(t)})}function Tw(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...Y(t)})}function Ew(e,t){return new e({type:`number`,checks:[],...Y(t)})}function Dw(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...Y(t)})}function Ow(e){return new e({type:`unknown`})}function kw(e,t){return new e({type:`never`,...Y(t)})}function Aw(e,t){return new Yx({check:`less_than`,...Y(t),value:e,inclusive:!1})}function jw(e,t){return new Yx({check:`less_than`,...Y(t),value:e,inclusive:!0})}function Mw(e,t){return new Xx({check:`greater_than`,...Y(t),value:e,inclusive:!1})}function Nw(e,t){return new Xx({check:`greater_than`,...Y(t),value:e,inclusive:!0})}function Pw(e,t){return new Zx({check:`multiple_of`,...Y(t),value:e})}function Fw(e,t){return new $x({check:`max_length`,...Y(t),maximum:e})}function Iw(e,t){return new eS({check:`min_length`,...Y(t),minimum:e})}function Lw(e,t){return new tS({check:`length_equals`,...Y(t),length:e})}function Rw(e,t){return new rS({check:`string_format`,format:`regex`,...Y(t),pattern:e})}function zw(e){return new iS({check:`string_format`,format:`lowercase`,...Y(e)})}function Bw(e){return new aS({check:`string_format`,format:`uppercase`,...Y(e)})}function Vw(e,t){return new oS({check:`string_format`,format:`includes`,...Y(t),includes:e})}function Hw(e,t){return new sS({check:`string_format`,format:`starts_with`,...Y(t),prefix:e})}function Uw(e,t){return new cS({check:`string_format`,format:`ends_with`,...Y(t),suffix:e})}function Ww(e){return new lS({check:`overwrite`,tx:e})}function Gw(e){return Ww(t=>t.normalize(e))}function Kw(){return Ww(e=>e.trim())}function qw(){return Ww(e=>e.toLowerCase())}function Jw(){return Ww(e=>e.toUpperCase())}function Yw(){return Ww(e=>Gy(e))}function Xw(e,t,n){return new e({type:`array`,element:t,...Y(n)})}function Zw(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...Y(n)})}function Qw(e,t){let n=$w(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(bb(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(bb(r))}},e(t.value,t)),t);return n}function $w(e,t){let n=new Kx({check:`custom`,...Y(t)});return n._zod.check=e,n}function eT(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Hy(e,t,n[t]);return e}function tT(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??QC,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function nT(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function rT(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,rT(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&eT(o.schema,c),t.io===`input`&&pT(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function iT(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function aT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${iT(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+iT(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
97
97
 
98
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function FT(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;FT(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var IT=new Set([`type`,`properties`,`required`,`additionalProperties`]),LT=[`oneOf`,`anyOf`];function RT(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function zT(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!IT.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??RT(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}_b(n,r,e.length===1?e[0]:zT(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=RT(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function BT(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of IT)if(t in e)return;let n=t.filter(e=>LT.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=zT(t);else{let e=n[0],i=LT.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>zT([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,kT(e,r))}function VT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):kT(i,s),kT(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())FT(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])BT(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}kT(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,_b(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:WT(t,`input`,e.processors),output:WT(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function HT(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return HT(r.element,n);if(r.type===`set`)return HT(r.valueType,n);if(r.type===`lazy`)return HT(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return HT(r.innerType,n);if(r.type===`intersection`)return HT(r.left,n)||HT(r.right,n);if(r.type===`record`||r.type===`map`)return HT(r.keyType,n)||HT(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:HT(r.in,n)||HT(r.out,n);if(r.type===`object`){for(let e in r.shape)if(HT(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(HT(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(HT(e,n))return!0;return!!(r.rest&&HT(r.rest,n))}return!1}var UT=(e,t={})=>n=>{let r=AT({...n,processors:t});return MT(e,r),PT(r,e),VT(r,e)},WT=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=AT({...i??{},target:a,io:t,processors:n});return MT(e,o),PT(o,e),VT(o,e)},GT={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},KT=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=GT[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},qT=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):jT(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},JT=(e,t,n,r)=>{n.not={}},YT=(e,t,n,r)=>{let i=e._zod.def,a=ub(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},XT=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(jT(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(jT(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},ZT=(e,t,n,r)=>{jT(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},QT=(e,t,n,r)=>{jT(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},$T=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=MT(a.element,t,{...r,path:[...r.path,`items`]})};function eE(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?eE(t.out):t.type===`catch`?eE(t.innerType):e._zod.optin}var tE=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&jT(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)_b(i.properties,e,MT(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?eE(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=MT(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},nE=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>MT(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},rE=(e,t,n,r)=>{let i=e._zod.def,a=MT(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=MT(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},iE=(e,t,n,r)=>{let i=e._zod.def,a=MT(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},aE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},oE=Symbol();function sE(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(jT(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),oE):JSON.parse(o)}var cE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=sE(i.defaultValue,e,t,n,r);o!==oE&&(n.default=o)},lE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=sE(i.defaultValue,e,t,n,r);o!==oE&&(n._prefault=o)},uE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{jT(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},dE=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;MT(o,t,r);let s=t.seen.get(e);s.ref=o},fE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},pE=(e,t,n,r)=>{let i=e._zod.def;MT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},mE=new WeakSet([Object.prototype,Error.prototype]);function hE(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var gE=X(`ZodError`,(e,t)=>{Cx.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);mE.has(n)||(mE.add(n),hE(n,`format`,e=>t=>Dx(e,t)),hE(n,`flatten`,e=>t=>Ex(e,t)),hE(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,fb,2)}),hE(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,fb,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),_E=kx(gE),vE=Ax(gE),yE=jx(gE),bE=Nx(gE),xE=Fx(gE),SE=Ix(gE),CE=Lx(gE),wE=Rx(gE),TE=zx(gE),EE=Bx(gE),DE=Vx(gE),OE=Hx(gE);function kE(){mx.localeError||hx(Cw())}function AE(){mx.memoizer||hx({memoizer:bw()})}var jE=X(`ZodType`,(e,t)=>(kE(),VS.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(vb(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Ob(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(KD(e,t))},superRefine(e,t){return this.check(qD(e,t))},overwrite(e){return this.check(yT(e))},optional(){return OD(this)},exactOptional(){return AD(this)},nullable(){return MD(this)},nullish(){return OD(MD(this))},nonoptional(e){return RD(this,e)},array(){return mD(this)},or(e){return vD([this,e])},and(e){return bD(this,e)},transform(e){return HD(this,ED(e))},default(e){return PD(this,e)},prefault(e){return ID(this,e)},catch(e){return BD(this,e)},pipe(e){return HD(this,e)},readonly(){return WD(this)},describe(e){let t=this.clone();return Dw.add(t,{description:e}),t},meta(...e){if(e.length===0)return Dw.get(this);let t=this.clone();return Dw.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Qb(this,`~standard`,{...US(this),jsonSchema:{input:WT(this,`input`),output:WT(this,`output`)}})},set"~standard"(e){Zb(this,`~standard`,e)},parse:function e(t,n){return _E(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await vE(this,t,n,{callee:e})},safeParse(e,t){return yE(this,e,t)},async safeParseAsync(e,t){return bE(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Zb(this,`spa`,e)},encode:function e(t,n){return xE(this,t,n,{callee:e})},decode:function e(t,n){return SE(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await CE(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await wE(this,t,n,{callee:e})},safeEncode(e,t){return TE(this,e,t)},safeDecode(e,t){return EE(this,e,t)},async safeEncodeAsync(e,t){return DE(this,e,t)},async safeDecodeAsync(e,t){return OE(this,e,t)},toJSONSchema(e){return UT(this,{})(e)},get description(){return Dw.get(this)?.description},get _def(){return this._zod.def}}),ME=X(`_ZodString`,(e,t)=>{WS.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>KT(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(pT(...e))},includes(...e){return this.check(gT(...e))},startsWith(...e){return this.check(_T(...e))},endsWith(...e){return this.check(vT(...e))},min(...e){return this.check(dT(...e))},max(...e){return this.check(uT(...e))},length(...e){return this.check(fT(...e))},nonempty(...e){return this.check(dT(1,...e))},lowercase(e){return this.check(mT(e))},uppercase(e){return this.check(hT(e))},trim(){return this.check(xT())},normalize(...e){return this.check(bT(...e))},toLowerCase(){return this.check(ST())},toUpperCase(){return this.check(CT())},slugify(){return this.check(wT())}}),NE=X(`ZodString`,(e,t)=>{WS.init(e,t),ME.init(e,t)},{email(e){return this.check(kw(BE,e))},url(e){return this.check(Fw(UE,e))},jwt(e){return this.check(Xw(iD,e))},emoji(e){return this.check(Iw(WE,e))},guid(e){return this.check(Aw(VE,e))},uuid(e){return this.check(jw(HE,e))},uuidv4(e){return this.check(Mw(HE,e))},uuidv6(e){return this.check(Nw(HE,e))},uuidv7(e){return this.check(Pw(HE,e))},nanoid(e){return this.check(Lw(GE,e))},cuid(e){return this.check(Rw(KE,e))},cuid2(e){return this.check(zw(qE,e))},ulid(e){return this.check(Bw(JE,e))},base64(e){return this.check(qw(tD,e))},base64url(e){return this.check(Jw(nD,e))},xid(e){return this.check(Vw(YE,e))},ksuid(e){return this.check(Hw(XE,e))},ipv4(e){return this.check(Uw(ZE,e))},ipv6(e){return this.check(Ww(QE,e))},cidrv4(e){return this.check(Gw($E,e))},cidrv6(e){return this.check(Kw(eD,e))},e164(e){return this.check(Yw(rD,e))},datetime(e){return this.check(Zw(IE,e))},date(e){return this.check(Qw(LE,e))},time(e){return this.check($w(RE,e))},duration(e){return this.check(eT(zE,e))}});function PE(e){return Ow(NE,e)}var FE=X(`ZodStringFormat`,(e,t)=>{GS.init(e,t),ME.init(e,t)}),IE=X(`ZodISODateTime`,(e,t)=>{cC.init(e,t),FE.init(e,t)}),LE=X(`ZodISODate`,(e,t)=>{lC.init(e,t),FE.init(e,t)}),RE=X(`ZodISOTime`,(e,t)=>{uC.init(e,t),FE.init(e,t)}),zE=X(`ZodISODuration`,(e,t)=>{dC.init(e,t),FE.init(e,t)}),BE=X(`ZodEmail`,(e,t)=>{JS.init(e,t),FE.init(e,t)}),VE=X(`ZodGUID`,(e,t)=>{KS.init(e,t),FE.init(e,t)}),HE=X(`ZodUUID`,(e,t)=>{qS.init(e,t),FE.init(e,t)}),UE=X(`ZodURL`,(e,t)=>{eC.init(e,t),FE.init(e,t)}),WE=X(`ZodEmoji`,(e,t)=>{tC.init(e,t),FE.init(e,t)}),GE=X(`ZodNanoID`,(e,t)=>{nC.init(e,t),FE.init(e,t)}),KE=X(`ZodCUID`,(e,t)=>{rC.init(e,t),FE.init(e,t)}),qE=X(`ZodCUID2`,(e,t)=>{iC.init(e,t),FE.init(e,t)}),JE=X(`ZodULID`,(e,t)=>{aC.init(e,t),FE.init(e,t)}),YE=X(`ZodXID`,(e,t)=>{oC.init(e,t),FE.init(e,t)}),XE=X(`ZodKSUID`,(e,t)=>{sC.init(e,t),FE.init(e,t)}),ZE=X(`ZodIPv4`,(e,t)=>{fC.init(e,t),FE.init(e,t)}),QE=X(`ZodIPv6`,(e,t)=>{hC.init(e,t),FE.init(e,t)}),$E=X(`ZodCIDRv4`,(e,t)=>{gC.init(e,t),FE.init(e,t)}),eD=X(`ZodCIDRv6`,(e,t)=>{vC.init(e,t),FE.init(e,t)}),tD=X(`ZodBase64`,(e,t)=>{bC.init(e,t),FE.init(e,t)}),nD=X(`ZodBase64URL`,(e,t)=>{SC.init(e,t),FE.init(e,t)}),rD=X(`ZodE164`,(e,t)=>{CC.init(e,t),FE.init(e,t)}),iD=X(`ZodJWT`,(e,t)=>{TC.init(e,t),FE.init(e,t)}),aD=X(`ZodNumber`,(e,t)=>{EC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qT(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(sT(e,t))},gte(e,t){return this.check(cT(e,t))},min(e,t){return this.check(cT(e,t))},lt(e,t){return this.check(aT(e,t))},lte(e,t){return this.check(oT(e,t))},max(e,t){return this.check(oT(e,t))},int(e){return this.check(cD(e))},safe(e){return this.check(cD(e))},positive(e){return this.check(sT(0,e))},nonnegative(e){return this.check(cT(0,e))},negative(e){return this.check(aT(0,e))},nonpositive(e){return this.check(oT(0,e))},multipleOf(e,t){return this.check(lT(e,t))},step(e,t){return this.check(lT(e,t))},finite(){return this}});function oD(e){return tT(aD,e)}var sD=X(`ZodNumberFormat`,(e,t)=>{DC.init(e,t),aD.init(e,t)});function cD(e){return nT(sD,e)}var lD=X(`ZodUnknown`,(e,t)=>{OC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function uD(){return rT(lD)}var dD=X(`ZodNever`,(e,t)=>{kC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JT(e,t,n,r)});function fD(e){return iT(dD,e)}var pD=X(`ZodArray`,(e,t)=>{AE(),jC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r),e.element=t.element},{min(e,t){return this.check(dT(e,t))},nonempty(e){return this.check(dT(1,e))},max(e,t){return this.check(uT(e,t))},length(e,t){return this.check(fT(e,t))},unwrap(){return this.element}});function mD(e,t){return TT(pD,e,t)}var hD=X(`ZodObject`,(e,t)=>{AE(),RC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tE(e,t,n,r),ax(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return SD(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:uD()})},loose(){return this.clone({...this._zod.def,catchall:uD()})},strict(){return this.clone({...this._zod.def,catchall:fD()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Pb(this,e)},safeExtend(e){return Fb(this,e)},merge(e){return Ib(this,e)},pick(e){return Mb(this,e)},omit(e){return Nb(this,e)},partial(...e){return Lb(DD,this,e[0])},exactPartial(...e){return Lb(kD,this,e[0],`exactPartial`)},required(...e){return Rb(LD,this,e[0])}});function gD(e,t){return new hD({type:`object`,shape:e??{},...Y(t)})}var _D=X(`ZodUnion`,(e,t)=>{BC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nE(e,t,n,r),e.options=t.options});function vD(e,t){return new _D({type:`union`,options:e,...Y(t)})}var yD=X(`ZodIntersection`,(e,t)=>{VC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rE(e,t,n,r)});function bD(e,t){return new yD({type:`intersection`,left:e,right:t})}var xD=X(`ZodEnum`,(e,t)=>{WC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>YT(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new xD({...t,checks:[],...Y(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new xD({...t,checks:[],...Y(r),entries:i})}});function SD(e,t){return new xD({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var CD=X(`ZodLiteral`,(e,t)=>{GC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XT(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function wD(e,t){return new CD({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var TD=X(`ZodTransform`,(e,t)=>{AE(),KC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QT(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new px(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Yb(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Yb(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ED(e){return new TD({type:`transform`,transform:e})}var DD=X(`ZodOptional`,(e,t)=>{JC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function OD(e){return new DD({type:`optional`,innerType:e})}var kD=X(`ZodExactOptional`,(e,t)=>{YC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function AD(e){return new kD({type:`optional`,innerType:e})}var jD=X(`ZodNullable`,(e,t)=>{XC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function MD(e){return new jD({type:`nullable`,innerType:e})}var ND=X(`ZodDefault`,(e,t)=>{ZC.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function PD(e,t){return new ND({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tb(t)}})}var FD=X(`ZodPrefault`,(e,t)=>{$C.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ID(e,t){return new FD({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Tb(t)}})}var LD=X(`ZodNonOptional`,(e,t)=>{ew.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function RD(e,t){return new LD({type:`nonoptional`,innerType:e,...Y(t)})}var zD=X(`ZodCatch`,(e,t)=>{rw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function BD(e,t){return new zD({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:sx(t)})}var VD=X(`ZodPipe`,(e,t)=>{iw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dE(e,t,n,r),e.in=t.in,e.out=t.out});function HD(e,t){return new VD({type:`pipe`,in:e,out:t})}var UD=X(`ZodReadonly`,(e,t)=>{ow.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fE(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function WD(e){return new UD({type:`readonly`,innerType:e})}var GD=X(`ZodCustom`,(e,t)=>{cw.init(e,t),jE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZT(e,t,n,r)});function KD(e,t={}){return ET(GD,e,t)}function qD(e,t){return DT(e,t)}var JD=[`off`,`files`,`burn-in`],YD=[`top`,`upper-middle`,`center`,`lower-middle`,`bottom`],XD=gD({mode:SD(JD),language:wD(`en`).default(`en`),fontId:PE().max(160).regex(/^[A-Za-z0-9_-]+$/).default(`default`),position:SD(YD).default(`bottom`),fontSize:oD().int().min(16).max(120).default(48)}),ZD={mode:`off`,language:`en`,fontId:`default`,fontSize:48,position:`bottom`};function QD(e,t){let n={...ZD,...e},r=t.audio===`off`?`off`:(t.video===`off`||t.images===`off`)&&n.mode===`burn-in`?`files`:n.mode;if(r!==`off`)return{...n,mode:r};let i=XD.shape.fontId.safeParse(n.fontId),a=XD.shape.fontSize.safeParse(n.fontSize);return{...n,mode:r,fontId:i.success?i.data:ZD.fontId,fontSize:a.success?a.data:ZD.fontSize}}function $D(e,t){return e.mode===t.mode&&e.language===t.language&&e.fontId===t.fontId&&e.fontSize===t.fontSize&&(e.position??`bottom`)===(t.position??`bottom`)}function eO(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}var tO={title:``,format:`16:9`,sources:{research:`off`,article:`generate`,audio:`generate`,images:`generate`,thumbnail:`off`,video:`generate`},llm:{provider:``,model:``},audio:{provider:``,model:``,voice:``},images:{provider:``,model:``},articlePrompt:``,imagePrompts:[],thumbnailPrompt:``,intro:``,outro:``,chunking:{mode:`whole`},subtitles:ZD,values:{},provided:{research:``,article:``,audio:void 0,images:[],thumbnail:void 0}},nO={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function rO(e){return tb[e].map(e=>({value:e,label:nO[e]}))}function iO(e,t){return e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||e.sources.audio===`generate`&&(aO(t,`intro`,e.intro)===`llm`||aO(t,`outro`,e.outro)===`llm`)}function aO(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function oO(e){return[e.audio,e.thumbnail,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function sO(e){let{form:t}=e;return{title:t.title,format:t.format,sources:{...t.sources,...t.sources.article===`provide`?{research:`off`}:{},...t.sources.images===`off`?{video:`off`}:{}},llm:t.llm,audio:t.audio,images:t.images,articlePrompt:t.articlePrompt,imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...cO(lO(e,`intro`),e=>({intro:e})),...cO(lO(e,`outro`),e=>({outro:e})),values:uO(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...cO(t.provided.audio?.file,e=>({audio:e.id})),...cO(t.provided.thumbnail?.file,e=>({thumbnail:e.id})),images:t.provided.images.flatMap(e=>e.file===void 0?[]:[e.file.id])},chunking:t.chunking,subtitles:QD(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds}}function cO(e,t){return e===void 0?{}:t(e)}function lO(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=aO(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function uO(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}var dO=(0,m.createContext)(void 0);function fO({children:e}){let[t,n]=(0,m.useState)(()=>new Map),[r,i]=(0,m.useState)(tO),a=(0,m.useCallback)((e,t)=>{n(n=>{let r=n.get(e),i=typeof t==`function`?t(r):t;if(r===i)return n;let a=new Map(n);return i===void 0?a.delete(e):a.set(e,i),a})},[]),o=(0,m.useMemo)(()=>({prompts:t,updatePrompt:a,play:r,updatePlay:i}),[t,a,r]);return(0,h.jsx)(dO.Provider,{value:o,children:e})}function pO(e){let t=(0,m.useContext)(dO),[n,r]=(0,m.useState)(void 0),i=t?.updatePrompt,a=(0,m.useCallback)(t=>{i?i(e,t):r(t)},[e,i]);return[t?t.prompts.get(e):n,a]}function mO(){let e=(0,m.useContext)(dO),[t,n]=(0,m.useState)(tO);return e?[e.play,e.updatePlay]:[t,n]}function hO(e,t){if(e===void 0)return;if(t.type===`project.state`)return{...e,project:{...e.project,status:t.state}};let n=e.stages.findIndex(e=>e.kind===t.stage),r=e.stages[n];return r===void 0?e:{...e,stages:e.stages.with(n,gO(r,t))}}function gO(e,t){return t.type===`stage.progress`?{...e,progressCurrent:t.current,progressTotal:t.total}:{...e,state:t.state,failureReason:t.failureReason??e.failureReason}}function _O(e,t){let n,r=!1,i=()=>{n=void 0,r&&(r=!1,e(),a())},a=()=>{n=setTimeout(i,t)};return{ask:()=>{if(n!==void 0){r=!0;return}e(),a()},stop:()=>{n!==void 0&&clearTimeout(n),n=void 0,r=!1}}}var vO=[{id:`text-key`,title:`1. Connect a text provider`,target:`keys-llm`,page:`settings`},{id:`audio-key`,title:`2. Connect a voice provider`,target:`keys-tts`,page:`settings`},{id:`image-key`,title:`3. Connect an image provider`,target:`keys-image`,page:`settings`},{id:`voice`,title:`4. Add a narration voice`,target:`voices`,page:`settings`},{id:`article-name`,title:`5. Name your article prompt`,target:`prompt-name`,page:`article`},{id:`article-body`,title:`6. Write instructions with keywords`,target:`prompt-body`,page:`article`},{id:`article-keywords`,title:`7. Check the detected keywords`,target:`prompt-slots`,page:`article`},{id:`article-save`,title:`8. Save your article prompt`,target:`prompt-save`,page:`article`},{id:`image-prompt`,title:`9. Create an image prompt`,target:`prompt-editor`,page:`image`},{id:`image-save`,title:`10. Save your image prompt`,target:`prompt-save`,page:`image`},{id:`play-article`,title:`11. Choose what to write`,target:`play-article`,page:`play`},{id:`play-audio`,title:`12. Choose the narration`,target:`play-audio`,page:`play`},{id:`play-images`,title:`13. Choose the images`,target:`play-images`,page:`play`},{id:`play-video`,title:`14. Choose your final output`,target:`play-video`,page:`play`},{id:`play-subtitles`,title:`15. Add optional subtitles`,target:`play-subtitles`,page:`play`},{id:`play-options`,title:`16. Name and configure your project`,target:`play-options`,page:`play`},{id:`play-keywords`,title:`17. Fill in your keywords`,target:`play-keywords`,page:`play`},{id:`play-start`,title:`18. Review and press PLAY`,target:`play-start`,page:`play`},{id:`project`,title:`19. Follow and control the run`,target:`project-controls`,page:`project`},{id:`download`,title:`20. Download your results`,target:`project-video`,page:`project`}];function yO(e,t){return e.active?t.type===`project-created`?{...e,projectId:t.id,step:vO.findIndex(e=>e.id===`project`)}:t.kind===`article`?{...e,articleId:t.id}:t.kind===`image`?{...e,imageId:t.id}:e:e}var bO={research:`Research`,article:`Article`,audio:`Audio`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`};function xO(e){return e.sources.video===`off`?e.sources.audio===`off`?`article`:`audio`:`video`}function SO(e,t){return e===`video`&&xO(t)===`audio`?`Audio export`:bO[e]}var CO={research:(e,t)=>`chapter ${String(e)} of ${String(t)}`,article:(e,t)=>`${String(e)} of ${String(t)}`,audio:(e,t)=>`chunk ${String(e)} of ${String(t)}`,images:(e,t)=>`image ${String(e)} of ${String(t)}`,thumbnail:(e,t)=>`${String(e)} of ${String(t)}`,video:(e,t)=>`${String(jO(e,t))}% rendered`},wO={audio_intro:`intro`,audio_body:`body`,audio_outro:`outro`};function TO(e,t,n){let r=t.filter(t=>t.stageKind===e.kind);switch(e.state){case`skipped`:return`Not part of this run`;case`pending`:return n.status===`paused`?`Waiting for Resume`:e.kind===`images`||e.kind===`thumbnail`&&e.source===`from_prompt`?`Ready to run`:`Waits for the stages above`;case`provided`:return OO(r)??`Provided`;case`failed`:return`Stopped after ${EO(e)}`;case`canceled`:return`Canceled by user`;case`running`:return e.kind===`video`&&xO(n.config)===`audio`?`Exporting combined audio`:e.progressTotal===null||e.progressTotal<=0?`Running`:CO[e.kind](e.progressCurrent??0,e.progressTotal);case`done`:return DO(e.kind,r,n)}}function EO(e){return e.attemptCount===1?`1 attempt`:`${String(e.attemptCount)} attempts`}function DO(e,t,n){switch(e){case`research`:return`Notes ready`;case`article`:{let e=t.filter(e=>e.role===`sources`||e.role===`glossary`);return e.length===0?`Article ready`:`Article and ${String(e.length)} end-matter files`}case`audio`:return FO([NO(t.flatMap(e=>{let t=wO[e.role];return t===void 0?[]:[t]})),AO(kO(t))]);case`images`:return MO(t.filter(e=>e.role===`image`).length,`image`);case`thumbnail`:return t.length===0?`Thumbnail ready`:`1 image`;case`video`:return FO([AO(kO(t)),xO(n.config)===`audio`?`WAV · stereo · 48 kHz`:n.format])}}function OO(e){let t=e.flatMap(e=>e.originalFilename===null?[]:[e.originalFilename]);return t.length===0?void 0:t.join(`, `)}function kO(e){let t=Math.max(0,...e.map(e=>e.durationMs??0));return t===0?void 0:t}function AO(e){if(e===void 0||!Number.isFinite(e)||e<=0)return;let t=Math.round(e/1e3),n=[Math.floor(t/60)%60,t%60].map(e=>String(e).padStart(2,`0`)),r=Math.floor(t/3600);return r===0?n.join(`:`):[String(r),...n].join(`:`)}function jO(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function MO(e,t){return e===1?`1 ${t}`:`${String(e)} ${t}s`}function NO(e){if(e.length!==0)return e.length===1?PO(e[0]??``):PO(`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]??``}`)}function PO(e){return e.charAt(0).toUpperCase()+e.slice(1)}function FO(e){return e.filter(e=>e!==void 0&&e!==``).join(` · `)}var IO=12,LO=16;function RO(e,t,n){return Math.max(t,Math.min(e,Math.max(t,n)))}function zO(e,t,n){let r=Math.min(n.width,t.width-24),i=RO(e?.left??(t.width-r)/2,IO,t.width-r-IO),a=RO((e?.top??0)+((e?.height??t.height)-n.height)/2,IO,t.height-n.height-IO),o=t.height-n.height-IO;if(!e)return{left:i,top:a,width:r,docked:!1};let s=e.left+e.width,c=e.top+e.height;return s+LO+r<=t.width-IO?{left:s+LO,top:a,width:r,docked:!1}:e.left-LO-r>=IO?{left:e.left-LO-r,top:a,width:r,docked:!1}:c>=IO&&c+LO+n.height<=t.height-IO?{left:i,top:c+LO,width:r,docked:!1}:e.top-LO-n.height>=IO&&e.top<=t.height-IO?{left:i,top:e.top-LO-n.height,width:r,docked:!1}:{left:t.width-r-IO,top:Math.max(IO,o),width:r,docked:!0}}function BO(e,t,n=t.height){let r=RO(e.left-6,0,t.width),i=RO(e.top-6,0,Math.min(n,t.height)),a=RO(e.left+e.width+6,0,t.width),o=RO(e.top+e.height+6,0,Math.min(n,t.height));return a>r&&o>i?{left:r,top:i,width:a-r,height:o-i}:null}var VO=`[data-slot="select-content"], [data-slot="dropdown-menu-content"]`;function HO(e){try{return document.querySelector(e)}catch{return null}}function UO(){return[...document.querySelectorAll(`[data-slot="dialog-content"][data-state="open"]`)].at(-1)??null}function WO(e){if(!e)return[];let t=[e,...e.querySelectorAll(`[aria-controls]`)],n=new Set(t.flatMap(e=>(e.getAttribute(`aria-controls`)??``).split(` `)));return[...document.querySelectorAll(VO)].filter(e=>n.has(e.id))}function GO(e){let t=e.getBoundingClientRect();return t.width>0&&t.height>0?{left:t.left,top:t.top,width:t.width,height:t.height}:null}var KO=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable="true"]`;function qO(e,t,n,r){let i=(0,m.useRef)(document.activeElement),a=(0,m.useRef)(t);a.current=t,(0,m.useEffect)(()=>{let e=i.current;return()=>{queueMicrotask(()=>{e instanceof HTMLElement&&e.isConnected&&!n.current&&e.focus({preventScroll:!0})})}},[n]),(0,m.useEffect)(()=>{let t=()=>{let t=HO(e);return[t,n.current,...WO(t)].filter(e=>e!==null)},i=e=>e instanceof Node&&t().some(t=>t.contains(e)),o=e=>{UO()||i(e.target)||(e.preventDefault(),e.stopImmediatePropagation())},s=e=>{UO()||i(e.target)||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-radix-focus-guard`)||r.current?.focus({preventScroll:!0})},c=n=>{if(UO())return;let r=WO(HO(e));if(n.key===`Escape`){if(r.length>0)return;n.preventDefault(),n.stopImmediatePropagation(),a.current();return}if(n.key!==`Tab`){i(n.target)||o(n);return}if(r.length>0)return;let s=t().flatMap(e=>[e,...e.querySelectorAll(KO)]).filter((e,t,n)=>n.indexOf(e)===t&&e.tabIndex>=0&&!e.matches(`:disabled, [hidden], [aria-hidden='true']`)&&!e.closest(`[hidden], [inert]`)&&(!e.closest(`details:not([open])`)||e.closest(`summary`)!==null));if(s.length===0)return;let c=s.indexOf(document.activeElement),l=c===-1?n.shiftKey?s.length-1:0:(c+(n.shiftKey?-1:1)+s.length)%s.length;n.preventDefault(),s[l]?.focus()},l=[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`click`,`dblclick`,`contextmenu`];for(let e of l)window.addEventListener(e,o,!0);return window.addEventListener(`keydown`,c,!0),window.addEventListener(`focusin`,s,!0),()=>{for(let e of l)window.removeEventListener(e,o,!0);window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`focusin`,s,!0)}},[e,n,r])}function JO(e,t,n,r,i,a){let[o,s]=(0,m.useState)(()=>({key:e,target:null,portals:[],width:window.innerWidth,height:window.innerHeight,cardHeight:260,modalOpen:UO()!==null}));return(0,m.useLayoutEffect)(()=>{let o=0,c=0,l=null,u=null,d=new Map,f=new ResizeObserver(()=>h()),p=e=>{for(let[t,n]of d)e.has(t)||(t.style.zIndex=n,d.delete(t))},m=()=>{o=0;let r=HO(t);r!==u&&(u&&f.unobserve(u),r&&f.observe(r),u=r);let i=r?GO(r):null;r&&i&&l!==r&&(l=r,cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,r.isConnected&&(r.scrollIntoView({block:`start`,inline:`nearest`,behavior:`instant`}),m())}));let a=WO(r),h=new Set;for(let e of a){let t=e.closest(`[data-radix-popper-content-wrapper]`)??e;h.add(t),d.has(t)||(d.set(t,t.style.zIndex),t.style.zIndex=`102`)}p(h);let g={key:e,target:i,portals:a.map(GO).filter(e=>e!==null),width:window.innerWidth,height:window.innerHeight,cardHeight:n.current?.getBoundingClientRect().height||260,modalOpen:UO()!==null};s(e=>JSON.stringify(e)===JSON.stringify(g)?e:g)};function h(){o||=requestAnimationFrame(m)}let g=new MutationObserver(e=>{e.some(e=>!i.current?.contains(e.target)&&e.target!==a.current)&&h()});return g.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`id`,`class`,`style`,`hidden`,`aria-controls`,`data-state`,`data-tour`]}),n.current&&f.observe(n.current),f.observe(document.documentElement),window.addEventListener(`resize`,h),window.addEventListener(`scroll`,h,!0),window.visualViewport?.addEventListener(`resize`,h),window.visualViewport?.addEventListener(`scroll`,h),m(),UO()||r.current?.focus({preventScroll:!0}),()=>{cancelAnimationFrame(o),cancelAnimationFrame(c),f.disconnect(),g.disconnect(),window.removeEventListener(`resize`,h),window.removeEventListener(`scroll`,h,!0),window.visualViewport?.removeEventListener(`resize`,h),window.visualViewport?.removeEventListener(`scroll`,h),p(new Set)}},[e,t,n,r,i,a]),o}function YO({stepId:e,target:t,title:n,children:r,progress:i,onNext:a,onBack:o,onClose:s,nextLabel:c=`Next`,nextDisabled:l=!1,onSkip:u,skipLabel:d=`Skip this step`}){let f=(0,m.useId)(),p=`${e}:${t}`,g=(0,m.useRef)(null),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=(0,m.useRef)(null),b=JO(p,t,g,_,v,y);qO(t,s,g,_);let[x,S]=(0,m.useState)({key:p,height:0}),C=b.key===p?b.target:null,w={width:b.width,height:b.height},T={width:Math.min(360,w.width-24),height:b.cardHeight},E=zO(C,w,T),D=C?BO(C,w,E.docked?E.top-12:w.height):null,O=b.key===p?b.portals.map(e=>BO(e,w)).filter(e=>e!==null):[],k=[...D?[D]:[],...O],A=`M0 0H${w.width}V${w.height}H0Z`+(D?`M${D.left} ${D.top}H${D.left+D.width}V${D.top+D.height}H${D.left}Z`:``);(0,m.useLayoutEffect)(()=>{S(e=>{let t=Math.max(e.key===p?e.height:0,E.docked?T.height+24:0);return e.key===p&&e.height===t?e:{key:p,height:t}})},[p,E.docked,T.height]);let j=x.key===p?x.height:0;return(0,m.useEffect)(()=>{let e=document.documentElement,t=e.style.scrollPaddingBottom;return e.style.scrollPaddingBottom=`${j}px`,()=>{e.style.scrollPaddingBottom=t}},[j]),(0,$c.createPortal)((0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{ref:y,"aria-hidden":`true`,style:{height:j}}),(0,h.jsxs)(`div`,{ref:v,hidden:b.modalOpen,"data-tutorial":`spotlight`,className:`pointer-events-none fixed inset-0 z-[100] font-sans`,children:[(0,h.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 h-full w-full`,width:w.width,height:w.height,children:[(0,h.jsx)(`defs`,{children:(0,h.jsxs)(`mask`,{id:`${f}-mask`,children:[(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`white`}),k.map(e=>(0,h.jsx)(`rect`,{x:e.left,y:e.top,width:e.width,height:e.height,rx:`6`,fill:`black`},`${e.left}:${e.top}:${e.width}:${e.height}`))]})}),(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`rgb(0 0 0 / 0.72)`,mask:`url(#${f}-mask)`}),(0,h.jsx)(`path`,{d:A,fill:`transparent`,fillRule:`evenodd`,pointerEvents:`fill`}),D&&(0,h.jsx)(`rect`,{"data-tutorial":`hole`,x:D.left,y:D.top,width:D.width,height:D.height,rx:`6`,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:`2`})]}),(0,h.jsxs)(`section`,{ref:g,"aria-label":`Interactive getting started guide`,"aria-describedby":`${f}-instructions`,"data-tutorial":`card`,className:`pointer-events-auto fixed z-[101] flex flex-col gap-3 rounded-panel border border-line2 bg-panel p-4 text-body text-ink shadow-[0_8px_24px_var(--color-shadow)]`,style:{left:E.left,top:E.top,width:E.width,maxHeight:Math.min(w.height-24,Math.max(160,Math.min(420,w.height*.48)))},children:[(0,h.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`engraved text-run-text`,children:[`Getting started · `,i]}),(0,h.jsx)(J,{variant:`ghost`,onClick:s,"aria-label":`Exit guide`,className:`h-7 px-2`,children:`Exit`})]}),(0,h.jsx)(`h2`,{ref:_,id:`${f}-title`,tabIndex:-1,className:`shrink-0 text-title font-bold outline-none`,children:n}),(0,h.jsxs)(`div`,{id:`${f}-instructions`,className:`min-h-0 overflow-y-auto text-ink2 [&_p+p]:mt-2 [&_code]:text-ink`,children:[r,!C&&(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-amber`,children:`This section is not available yet. Wait for the page to load, go back, or exit the guide.`}),E.docked&&C&&(0,h.jsx)(`p`,{className:`mt-3 text-small`,children:`Scroll the page to work through the highlighted section.`})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-line pt-3`,children:[o&&(0,h.jsx)(J,{onClick:o,children:`Back`}),u&&(0,h.jsx)(J,{variant:`ghost`,onClick:u,className:`px-2`,children:d}),(0,h.jsx)(J,{variant:`primary`,onClick:a,disabled:l||!C,className:`ml-auto`,children:c})]})]})]})]}),document.body)}function XO({href:e,children:t}){return(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-ink underline underline-offset-2`,children:t})}function ZO({text:e}){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{className:`select-text rounded-control border border-line2 bg-panel2 p-3 text-small leading-relaxed`,children:e}),(0,h.jsx)(J,{onClick:()=>{if(i(!1),!navigator.clipboard){i(!0);return}navigator.clipboard.writeText(e).then(()=>n(!0),()=>i(!0))},children:t?`Copied`:`Copy example`}),r?(0,h.jsx)(`p`,{role:`status`,children:`Select the example above and copy it manually.`}):null]})}function QO({step:e}){switch(e){case`text-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`First, choose what will write your scripts. You only need one text provider.`}),(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Sign in to `,(0,h.jsx)(XO,{href:`https://openrouter.ai/settings/keys`,children:`OpenRouter`}),`, create an API key, and make sure the account can use your chosen model.`]}),(0,h.jsxs)(`li`,{children:[`Paste it into OpenRouter’s `,(0,h.jsx)(`strong`,{children:`API key`}),` field here and press`,` `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]})]}),(0,h.jsx)(`p`,{children:`Already using Claude Code, Codex or Gemini CLI? You can use its existing CLI login instead. “Installed” means Slopify found the CLI; sign in through that CLI before generating. If it is missing, enter its executable path and save to check again.`}),(0,h.jsx)(`p`,{className:`text-ink3`,children:`These are the real Settings controls. The tutorial never reads your key. Skip any step you have already handled.`})]});case`audio-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The voice provider turns the finished article into audio. Choose`,` `,(0,h.jsx)(`strong`,{children:`ElevenLabs`}),`, `,(0,h.jsx)(`strong`,{children:`OpenAI`}),`, or `,(0,h.jsx)(`strong`,{children:`Cartesia`}),`; you do not need all three.`]}),(0,h.jsxs)(`p`,{children:[`Create a key in your provider’s account, enable the API access or credits it requires, then paste the key into its row and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(XO,{href:`https://elevenlabs.io/app/developers/api-keys`,children:`ElevenLabs keys`}),` `,`· `,(0,h.jsx)(XO,{href:`https://platform.openai.com/api-keys`,children:`OpenAI keys`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://play.cartesia.ai/keys`,children:`Cartesia keys`})]}),(0,h.jsx)(`p`,{children:`Next, you’ll add the exact voice that this provider should use. Skip voice setup if you plan to provide your own narration or turn Audio Off.`})]});case`image-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose one image provider, create a key in its dashboard, paste it into the matching row, and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(XO,{href:`https://fal.ai/dashboard/keys`,children:`fal.ai`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://replicate.com/account/api-tokens`,children:`Replicate`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://aistudio.google.com/apikey`,children:`Google AI Studio`}),` ·`,` `,(0,h.jsx)(XO,{href:`https://platform.openai.com/api-keys`,children:`OpenAI`})]}),(0,h.jsxs)(`p`,{children:[`A saved key is not a billing check. The selected image model needs available quota. If Google reports `,(0,h.jsx)(`strong`,{children:`limit: 0`}),`, check the key’s project, billing and image-model quota before retrying.`]}),(0,h.jsx)(`p`,{children:`OpenAI’s voice and image rows are saved separately, even when you use the same API key. Skip this step if you plan to provide your own images or turn Images and Thumbnail Off.`})]});case`voice`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Voice name`}),` you will recognize, such as “Travel narrator.”`]}),(0,h.jsxs)(`li`,{children:[`Select the `,(0,h.jsx)(`strong`,{children:`Provider`}),` whose voice key you saved.`]}),(0,h.jsxs)(`li`,{children:[`Copy the exact `,(0,h.jsx)(`strong`,{children:`Voice ID`}),` from that provider’s voice library or documentation.`]}),(0,h.jsxs)(`li`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Add voice`}),`.`]})]}),(0,h.jsx)(`p`,{children:`The name is your label; the ID tells the provider which voice to use. Slopify checks the ID with the provider when narration runs. A voice is only required when Audio is set to Generate.`})]})}}var $O=`Write a 150-word narration about {{topic}} for {{audience}}. Open with an interesting fact, explain three highlights, and end with one memorable takeaway. Use natural spoken English. Return only the narration, without headings or stage directions.`,ek=`A cinematic editorial photograph of {{topic}}, with natural light, a clear focal point, rich detail, and no text or logos. Compose it for a travel video.`;function tk({step:e,output:t=`video`}){switch(e){case`text-key`:case`audio-key`:case`image-key`:case`voice`:return(0,h.jsx)(QO,{step:e});case`article-name`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`A prompt is a reusable set of instructions. This one will write the narration for each video.`}),(0,h.jsxs)(`p`,{children:[`Give it a recognizable name, such as `,(0,h.jsx)(`strong`,{children:`Short travel narration`}),`. This is the prompt’s library name, not your video’s title.`]}),(0,h.jsx)(`p`,{children:`The next steps will add its instructions and reusable keywords.`})]});case`article-body`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Tell the model what to write, who it is for, the length, and the style. Put anything you want to change between runs inside double braces.`}),(0,h.jsx)(ZO,{text:$O}),(0,h.jsxs)(`p`,{children:[`Paste or write the instructions in `,(0,h.jsx)(`strong`,{children:`Body`}),`. `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` `,`and `,(0,h.jsx)(`strong`,{children:`{{audience}}`}),` will become fields on Play.`]})]});case`article-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`This panel detects your keywords as you type. With the example, it should list`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`{{topic}}`}),` is a field name, not the value. You will enter “Albania” on Play later. Repeated names use the same value; names are case-sensitive, so`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`Topic`}),` are different.`]}),(0,h.jsxs)(`p`,{children:[`There are no automatic keywords: `,(0,h.jsx)(`strong`,{children:`{{title}}`}),` would also ask you for a value. Fix any keyword warnings in Body before saving.`]})]});case`article-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press the highlighted `,(0,h.jsx)(`strong`,{children:`Save`}),` button in the editor. The prompt will appear in your Article library.`]}),(0,h.jsx)(`p`,{children:`The tour continues when the save succeeds and the editor returns to the prompt list. If a name is already taken, go Back and choose another.`})]});case`image-prompt`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Keep `,(0,h.jsx)(`strong`,{children:`Kind`}),` on `,(0,h.jsx)(`strong`,{children:`Image`}),`. Name this prompt`,` `,(0,h.jsx)(`strong`,{children:`Travel imagery`}),`, then enter this example or your own visual instructions.`]}),(0,h.jsx)(ZO,{text:ek}),(0,h.jsxs)(`p`,{children:[`Using `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` in both prompts creates one shared field on Play. Image prompts describe the picture directly; they do not automatically receive your article.`]})]});case`image-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Save`}),` to add this to your Image library. Next you will combine both prompts on Play.`]}),(0,h.jsx)(`p`,{children:`You can create more prompts later for different subjects, styles, lengths, or languages.`})]});case`play-article`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Play is where you configure one project. Leave `,(0,h.jsx)(`strong`,{children:`Article`}),` on`,` `,(0,h.jsx)(`strong`,{children:`Generate`}),`, then select the article prompt you saved.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Provide`}),` is for an article you already have. For this first run, use Generate and keep the script short. Article is required; every other stage can be Off.`]}),(0,h.jsx)(`p`,{children:`Research starts Off. You can turn it on in a later run for web-grounded notes that are automatically passed to the article writer.`})]});case`play-audio`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Audio`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Pick your voice`,` `,(0,h.jsx)(`strong`,{children:`TTS`}),` provider, a `,(0,h.jsx)(`strong`,{children:`TTS model`}),`, then the saved`,` `,(0,h.jsx)(`strong`,{children:`Voice`}),`.`]}),(0,h.jsxs)(`p`,{children:[`Keep chunking on `,(0,h.jsx)(`strong`,{children:`Whole`}),` for the short example: the narration is sent as one request. Other chunking modes split longer text into pieces.`]}),(0,h.jsx)(`p`,{children:`Use Provide to upload existing narration, including any intro and outro in that file, or Off to skip narration. Video can still run silently, with each image shown for 5 seconds.`})]});case`play-images`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Images`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Choose the image`,` `,(0,h.jsx)(`strong`,{children:`Provider`}),` and `,(0,h.jsx)(`strong`,{children:`Model`}),`, select your image prompt, and set`,` `,(0,h.jsx)(`strong`,{children:`Number`}),` to 2 for a small first run.`]}),(0,h.jsx)(`p`,{children:`Number means separate images made from that same prompt. It does not make one scene per article paragraph. Add more image prompts when you want different scenes.`}),(0,h.jsx)(`p`,{children:`Use Provide for your own images or Off to skip them. Turning Images Off also turns Video Off. Thumbnail remains independent; keep it Off for this first run.`})]});case`play-video`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Generate`}),` for an MP4 slideshow. It needs generated or provided images. With Audio Off, the video is silent and each image lasts 5 seconds.`]}),(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Off`}),` to skip video. If Audio is active, Slopify exports one combined `,(0,h.jsx)(`strong`,{children:`WAV`}),` with the intro, body, outro and configured gaps.`]}),(0,h.jsx)(`p`,{children:`If both Audio and Video are Off, download the article and any other enabled outputs individually.`})]});case`play-subtitles`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Subtitles are optional and start `,(0,h.jsx)(`strong`,{children:`Off`}),`. Choose`,` `,(0,h.jsx)(`strong`,{children:`Subtitle files`}),` for SRT and VTT downloads, or`,` `,(0,h.jsx)(`strong`,{children:`Burn into video + files`}),` to keep captions visible in an MP4.`]}),(0,h.jsxs)(`p`,{children:[`English captions are timed locally from your narration with no paid API. First use downloads an approximately `,(0,h.jsx)(`strong`,{children:`95 MB`}),` speech model. Audio must be active; WAV exports support separate subtitle files.`]}),(0,h.jsx)(`p`,{children:`Pick a font or upload a TTF/OTF file, then adjust its size in the preview. Styling applies to burned captions. You can also add or change subtitles on a completed project later without regenerating its narration.`})]});case`play-options`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Video title`}),`, such as “A quick trip to Albania.” Choose`,` `,(0,h.jsx)(`strong`,{children:`16:9`}),` for landscape or `,(0,h.jsx)(`strong`,{children:`9:16`}),` for portrait.`]}),(0,h.jsxs)(`p`,{children:[`Select the text `,(0,h.jsx)(`strong`,{children:`LLM`}),` and `,(0,h.jsx)(`strong`,{children:`Model`}),`. The model list loads for your provider. Use `,(0,h.jsx)(`strong`,{children:`Refresh`}),` for updated choices or`,` `,(0,h.jsx)(`strong`,{children:`Custom ID`}),`to enter an exact model ID when supported.`]}),(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Intro`}),` and `,(0,h.jsx)(`strong`,{children:`Outro`}),` Off for this first run. They are available only when Audio is Generate. The LLM controls appear only when an enabled stage needs text generation.`]})]});case`play-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The prompts you picked created these fields. For the examples, enter`,` `,(0,h.jsx)(`strong`,{children:`Albania`}),` for `,(0,h.jsx)(`strong`,{children:`topic`}),` and`,` `,(0,h.jsx)(`strong`,{children:`first-time travelers`}),` for `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[`A field under `,(0,h.jsx)(`strong`,{children:`Common`}),` feeds both the article and images. Changing it changes both prompts for this run.`]}),(0,h.jsx)(`p`,{children:`Fill every visible field. Each value must fit on one line and be no more than 200 characters. Your saved prompt keeps its braces so you can reuse it next time.`})]});case`play-start`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Check the hint above PLAY. If anything is missing, use Back to fix the highlighted section.`}),(0,h.jsxs)(`p`,{children:[`When ready, press the real `,(0,h.jsx)(`strong`,{children:`PLAY`}),` button. This creates a project and sends generation requests to your chosen providers, which may charge your account.`]}),(0,h.jsx)(`p`,{children:`The tour will follow you to the project. You can also finish the tutorial without generating anything.`})]});case`project`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Overall progress stays above the workspace. Select a stage from `,(0,h.jsx)(`strong`,{children:`Stages`}),` `,`to see its results or live writing. Press `,(0,h.jsx)(`strong`,{children:`Pause`}),` to stop active requests safely and keep finished work.`]}),(0,h.jsxs)(`p`,{children:[`While paused or failed, open `,(0,h.jsx)(`strong`,{children:`Run settings`}),` to change providers, models or voice. Press `,(0,h.jsx)(`strong`,{children:`Save providers`}),`, then `,(0,h.jsx)(`strong`,{children:`Resume`}),` `,`separately. Changing TTS choices restarts unfinished narration to avoid mixing voices; completed outputs stay unchanged.`]}),(0,h.jsxs)(`p`,{children:[`Select a failed stage and open `,(0,h.jsx)(`strong`,{children:`Error details`}),` to read the provider’s message. `,(0,h.jsx)(`strong`,{children:`Retry stage`}),` keeps completed outputs. Editing or rerunning earlier work updates only the enabled dependent outputs.`]})]});case`download`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[t===`audio`?(0,h.jsxs)(h.Fragment,{children:[`When Audio export finishes, press `,(0,h.jsx)(`strong`,{children:`Download .wav`}),` for the combined narration.`]}):t===`article`?(0,h.jsxs)(h.Fragment,{children:[`Use `,(0,h.jsx)(`strong`,{children:`Download`}),` here to save the article. Audio and Video are Off for this project.`]}):(0,h.jsxs)(h.Fragment,{children:[`When Video finishes, press `,(0,h.jsx)(`strong`,{children:`Download .mp4`}),`.`]}),` `,`The completed project stays in `,(0,h.jsx)(`strong`,{children:`Projects`}),` so you can return to it.`]}),(0,h.jsxs)(`p`,{children:[`Select Article, Audio or Images in `,(0,h.jsx)(`strong`,{children:`Stages`}),` to download their outputs.`,` `,(0,h.jsx)(`strong`,{children:`Download all`}),` under Images gives an image ZIP, not the video.`]}),(0,h.jsxs)(`p`,{children:[`If subtitles are enabled, download the `,(0,h.jsx)(`strong`,{children:`.srt`}),` or `,(0,h.jsx)(`strong`,{children:`.vtt`}),` `,`files beside the final export. File-mode captions are also available in the video player.`]}),(0,h.jsxs)(`p`,{children:[`You have reached the end. Open `,(0,h.jsx)(`strong`,{children:`Tutorial`}),` in the navigation anytime to walk through these steps again.`]})]})}}function nk(e){return e.readiness.kind===`cli`?e.readiness.installed:e.readiness.hasKey}function rk({session:e,progress:t,update:n}){let{api:r}=B(),i=Hi(),a=ka(),o=R(Py(r)),s=R(Iy(r)),c=R(Ly(r)),l=R({...Ny(r,e.projectId??``),enabled:e.projectId!==void 0}),u=(0,m.useRef)(null),d=vO[e.step],f=o.data?.seen===!0;if((0,m.useEffect)(()=>{if(f&&d&&u.current!==e.step){if(u.current=e.step,d.page===`settings`&&a.pathname!==`/settings`&&i({to:`/settings`}),d.page===`article`||d.page===`image`){let t=d.page===`article`?e.articleId:e.imageId,n=a.pathname===`/prompts/new`&&a.searchStr.includes(`kind=${d.page}`);t&&a.pathname!==`/prompts/${t}`?i({to:`/prompts/$promptId`,params:{promptId:t}}):!t&&!n&&i({to:`/prompts/new`,search:{kind:d.page}})}d.page===`play`&&a.pathname!==`/play`&&i({to:`/play`}),d.page===`project`&&e.projectId&&a.pathname!==`/projects/${e.projectId}`&&i({to:`/projects/$projectId`,params:{projectId:e.projectId}})}},[f,d,e.step,e.articleId,e.imageId,e.projectId,a.pathname,a.searchStr,i]),(0,m.useEffect)(()=>{a.pathname===`/prompts`&&(d?.id===`image-prompt`&&e.imageId?n(e=>({...e,step:vO.findIndex(e=>e.id===`play-article`)})):(d?.id===`article-save`&&e.articleId||d?.id===`image-save`&&e.imageId)&&n(e=>({...e,step:e.step+1})))},[a.pathname,d?.id,e.articleId,e.imageId,n]),!f||!d)return null;let p=s.data?.providers??[],g=e=>p.some(t=>t.family===e&&nk(t)),_=(c.data?.voices??[]).some(e=>p.some(t=>t.id===e.provider&&nk(t))),v={"text-key":g(`llm`),"audio-key":g(`tts`),"image-key":g(`image`),voice:_,"article-name":t.promptIsArticle===!0&&t.promptNamed===!0,"article-body":t.promptIsArticle===!0&&t.promptBodyReady===!0&&t.promptHasKeywords===!0,"article-keywords":t.promptHasKeywords===!0,"article-save":!1,"image-prompt":t.promptIsImage===!0&&t.promptSaveReady===!0&&t.promptHasKeywords===!0,"image-save":!1,"play-article":t.playArticleReady===!0,"play-audio":t.playAudioReady===!0,"play-images":t.playImagesReady===!0,"play-video":t.playVideoReady===!0,"play-subtitles":t.playSubtitlesReady===!0,"play-options":t.playOptionsReady===!0,"play-keywords":t.playKeywordsReady===!0,"play-start":!1},y=()=>n(e=>({...e,active:!1})),b=()=>{e.step===vO.length-1||d.id===`play-start`?y():n(e=>({...e,step:e.step+1}))},x=l.data?xO(l.data.project.config):`video`,S=d.id===`download`&&x===`article`?`project-article`:d.id===`play-keywords`&&t.playHasKeywords===!1?`play-options`:d.target,C=d.id===`article-save`||d.id===`image-save`,w=(d.page===`article`||d.page===`image`)&&t.promptSaving===!0;return(0,h.jsxs)(YO,{stepId:d.id,target:`[data-tour="${S}"]`,title:d.title,progress:`${e.step+1} of ${vO.length} · First project`,onClose:y,...e.step===0||d.id===`project`||w?{}:{onBack:()=>n(e=>({...e,step:e.step-1}))},onNext:b,nextDisabled:w||v[d.id]===!1,nextLabel:C?`Use Save in the editor`:d.id===`play-start`?`Use PLAY on the page`:d.id===`download`?`Finish tutorial`:`Next`,...w?{}:{onSkip:b},skipLabel:d.id===`play-start`?`Finish without generating`:C?`Skip without saving`:`Skip this step`,children:[(0,h.jsx)(tk,{step:d.id,output:x}),s.error||c.error?(0,h.jsx)(`p`,{className:`text-red`,children:s.error?.message??c.error?.message}):null]})}var ik=(0,m.createContext)(void 0);function ak({children:e}){let[t,n]=(0,m.useState)({active:!1,step:0}),[r,i]=(0,m.useState)({}),a=(0,m.useCallback)(()=>{n({active:!0,step:0})},[]),o=(0,m.useCallback)(e=>{i(t=>Object.entries(e).every(([e,n])=>t[e]===n)?t:{...t,...e})},[]),s=(0,m.useCallback)(e=>{i(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!e.includes(t))))},[]),c=(0,m.useCallback)(e=>{n(t=>yO(t,e))},[]),l=vO[t.step]?.id,u=t.active&&(l===`project`||l===`download`)?l:void 0,d=(0,m.useMemo)(()=>({active:t.active,projectId:t.projectId,projectStep:u,start:a,report:o,clear:s,event:c}),[t.active,t.projectId,u,a,o,s,c]);return(0,h.jsxs)(ik.Provider,{value:d,children:[e,t.active?(0,h.jsx)(rk,{session:t,progress:r,update:n}):null]})}function ok(){return(0,m.useContext)(ik)}function sk(e){let t=(0,m.useContext)(ik),n=t?.report,r=t?.clear,i=(0,m.useRef)(e);i.current=e,(0,m.useEffect)(()=>{n?.(e)},[n,e]),(0,m.useEffect)(()=>()=>{r?.(Object.keys(i.current))},[r])}function ck(){let e=(0,m.useContext)(ik);return(0,m.useCallback)(t=>{e?.event(t)},[e?.event])}function lk(e){let t=(0,m.useContext)(ik);return t?.projectId===e?t.projectStep:void 0}var uk=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),dk=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),fk=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),pk=e=>{let t=fk(e);return t.charAt(0).toUpperCase()+t.slice(1)},mk={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},hk=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},gk=(0,m.createContext)({}),_k=()=>(0,m.useContext)(gk),vk=(0,m.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=_k()??{},h=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,m.createElement)(`svg`,{ref:c,...mk,width:t??l??mk.width,height:t??l??mk.height,stroke:e??f,strokeWidth:h,className:uk(`lucide`,p,i),...!a&&!hk(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,m.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),yk=(e,t)=>{let n=(0,m.forwardRef)(({className:n,...r},i)=>(0,m.createElement)(vk,{ref:i,iconNode:t,className:uk(`lucide-${dk(pk(e))}`,`lucide-${e}`,n),...r}));return n.displayName=pk(e),n},bk=yk(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),xk=yk(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Sk=yk(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Ck=yk(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),wk=yk(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),Tk=yk(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ek=yk(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),Dk=yk(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),Ok=yk(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),kk=yk(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ak=yk(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),jk=yk(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Mk=yk(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Nk(){let e=ok();return e?(0,h.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,onClick:e.start,disabled:e.active,"aria-label":`Start interactive tutorial`,title:`Start interactive tutorial`,children:[(0,h.jsx)(Tk,{className:`size-4`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`sr-only min-[1280px]:not-sr-only`,children:`Tutorial`})]}):null}function Pk(){let e=ok();return!e||e.active?null:(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4 rounded-panel border border-line bg-panel px-4 py-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`font-semibold`,children:`Make your first video`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`An interactive walkthrough of API keys, reusable prompts, keywords, and Play. Each step highlights the real controls you will use.`})]}),(0,h.jsx)(J,{variant:`accent`,onClick:e.start,children:`Start tutorial`})]})}var Fk=[`app-update`],Ik=9e5,Lk=2e3;async function Rk(e,t=!1,n){let r=AbortSignal.timeout(2e4);return Za(await e.fetch(`${e.origin}/api/update${t?`?refresh=1`:``}`,{signal:n===void 0?r:AbortSignal.any([n,r]),cache:`no-store`}))}async function zk(e){return Za(await e.fetch(`${e.origin}/api/update`,{method:`POST`,signal:AbortSignal.timeout(2e4)}))}function Bk(e){let{api:t}=B(),n=_(),[r,i]=(0,m.useState)(null),a=(0,m.useRef)(!1),o=R({queryKey:Fk,queryFn:({signal:e})=>Rk(t,!1,e),staleTime:Ik,refetchOnWindowFocus:`always`,refetchInterval:e=>r!==null||e.state.data?.status===`checking`||e.state.data?.status===`installing`||e.state.data?.status===`restarting`?Lk:Ik,retry:!1}),s=tt({mutationFn:()=>Rk(t,!0),onMutate:()=>n.cancelQueries({queryKey:Fk}),onSuccess:e=>n.setQueryData(Fk,e),retry:!1}),c=tt({mutationFn:()=>zk(t),onMutate:()=>n.cancelQueries({queryKey:Fk}),onSuccess:e=>{i(e.currentVersion),n.setQueryData(Fk,e)},onError:()=>{n.invalidateQueries({queryKey:Fk})},retry:!1});(0,m.useEffect)(()=>{if(r===null||o.data===void 0)return;let t=o.data.status===`idle`||o.data.status===`error`;o.data.currentVersion!==r&&t&&!a.current?(a.current=!0,i(null),e()):t&&i(null)},[r,e,o.data]);let l=r!==null||o.data?.status===`installing`||o.data?.status===`restarting`,u=c.error?.message??s.error?.message??(l?void 0:o.error?.message??o.data?.error);return{info:o.data,updating:l,checking:o.isFetching||s.isPending||o.data?.status===`checking`,installing:c.isPending,reconnecting:l&&o.isError,error:u,inspect:()=>{o.refetch()},refresh:()=>{c.reset(),s.mutate()},install:()=>{s.reset(),c.mutate()}}}function Vk({reload:e}){let t=Bk(e),n=(0,m.useId)(),r=(0,m.useId)(),{info:i,updating:a,installing:o,reconnecting:s,checking:c,error:l}=t,u=a||o,d=u?`Slopify updates: Updating Slopify`:l?`Slopify updates: Update check failed`:i?.available?`Slopify updates: version ${i.latestVersion??`new`} available`:`Slopify updates`,f=i?.blockedReason??(i?.busy?`Pause running projects and wait for their active work to stop before updating.`:void 0);return(0,h.jsxs)(X_,{onOpenChange:e=>{e&&t.inspect()},children:[(0,h.jsx)(Z_,{asChild:!0,children:(0,h.jsxs)(`button`,{type:`button`,"aria-label":d,title:d,className:W(`fixed right-5 bottom-5 z-30 flex size-10 items-center justify-center rounded-full bg-transparent text-ink2 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,l&&`text-amber`),children:[(0,h.jsx)(Ak,{"aria-hidden":`true`,size:20,className:W(u&&`animate-spin motion-reduce:animate-none`)}),i?.available&&!u?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1 right-1 size-1.5 rounded-full bg-lamp-run`}):null]})}),(0,h.jsx)(Q_,{children:(0,h.jsxs)($_,{align:`end`,side:`top`,sideOffset:10,collisionPadding:16,"aria-labelledby":n,className:`z-50 w-[min(340px,calc(100vw-2rem))] rounded-panel border border-line bg-panel p-4 shadow-[0_8px_24px_var(--color-shadow)]`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-4`,children:[(0,h.jsx)(`h2`,{id:n,className:`text-row font-semibold text-ink`,children:`Slopify updates`}),(0,h.jsx)(ev,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`Close updates`,className:`size-8 p-0`,children:(0,h.jsx)(Mk,{"aria-hidden":`true`,size:16})})})]}),i?(0,h.jsxs)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-5 gap-y-1 text-small`,children:[(0,h.jsx)(`dt`,{className:`text-ink3`,children:`Installed`}),(0,h.jsx)(`dd`,{className:`text-ink`,children:i.currentVersion}),(0,h.jsx)(`dt`,{className:`text-ink3`,children:`Latest release`}),(0,h.jsx)(`dd`,{className:`text-ink`,children:i.latestVersion??`Not available`})]}):null,(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-small text-ink2`,children:s?`Reconnecting to Slopify after the update… This tab will reload when it is ready.`:u?i?.status===`restarting`?`Restarting Slopify… This tab will reload when it is ready.`:`Installing Slopify… You can close this panel while it finishes.`:c?`Checking for updates…`:l?`The update could not finish. You can check again.`:i?.available?`A new version is ready to install.`:i?`No newer release is available.`:`Check for the latest Slopify release.`}),l?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 break-words text-small text-red`,children:l}):null,f&&!u?(0,h.jsx)(`p`,{id:r,className:`mt-2 text-small text-ink2`,children:f}):null,i?.available&&!u&&!f?(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink3`,children:`Save any edits first. Updating restarts Slopify and reloads this tab.`}):null,(0,h.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[i?.available||u?(0,h.jsx)(J,{variant:`primary`,disabled:!i?.canUpdate||i.busy||u||c,"aria-describedby":f&&!u?r:void 0,onClick:t.install,children:u?`Updating…`:`Update Slopify`}):null,(0,h.jsxs)(J,{variant:`ghost`,disabled:u||c,onClick:t.refresh,children:[(0,h.jsx)(Ak,{"aria-hidden":`true`,size:14}),`Check again`]})]}),(0,h.jsx)(`p`,{className:`mt-3 text-label text-ink3`,children:`Checks every 15 minutes. Installs only when you choose.`})]})})]})}var Hk=[{to:`/`,label:`Projects`,exact:!0},{to:`/play`,label:`Play`,exact:!0},{to:`/prompts`,label:`Prompts`,exact:!1},{to:`/entries`,label:`Intros & Outros`,exact:!1},{to:`/settings`,label:`Settings`,exact:!0},{to:`/usage`,label:`Usage`,exact:!0}],Uk=[{href:`https://github.com/GentBajko/slopify`,label:`GitHub`,glyph:`github`,tone:``},{href:`https://www.patreon.com/cw/GentBajko`,label:`Patreon`,glyph:`patreon`,tone:`text-lamp-run`},{href:`https://buymeacoffee.com/gentbajko`,label:`Buy Me a Coffee`,glyph:`coffee`,tone:`text-lamp-run`}];function Wk(){return(0,h.jsx)(fO,{children:(0,h.jsx)(ak,{children:(0,h.jsx)(Gk,{})})})}function Gk(){let{api:e,openEvents:t}=B(),n=_(),[r,i]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let r=_O(()=>{n.invalidateQueries({queryKey:jy.projects})},200),a=Zy(t,Ao(e,`global`),{tally:i,stagingChanged:()=>{n.invalidateQueries({queryKey:jy.staging})},refetch:e=>{e===void 0?n.invalidateQueries():r.ask()}});return()=>{a(),r.stop()}},[e,t,n]),(0,h.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,h.jsxs)(`header`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 border-b border-line bg-panel px-4 min-[1280px]:flex min-[1280px]:h-14 min-[1280px]:gap-7 min-[1280px]:px-7`,children:[(0,h.jsxs)(ia,{to:`/`,className:`flex h-14 shrink-0 items-center gap-[10px] text-wordmark font-extrabold tracking-[-0.02em] text-ink`,children:[(0,h.jsx)(Ec,{className:`relative top-[3px] text-lamp-run`}),`Slopify`]}),(0,h.jsx)(`nav`,{"aria-label":`Main navigation`,className:`col-span-2 row-start-2 flex min-w-0 items-center gap-6 overflow-x-auto [scrollbar-width:thin] min-[1280px]:flex-1 min-[1280px]:gap-7`,children:Hk.map(e=>(0,h.jsx)(ia,{to:e.to,activeOptions:{exact:e.exact},className:`shrink-0 whitespace-nowrap border-b-2 border-transparent py-3 text-ink2 hover:text-ink focus-visible:outline-offset-[-3px] min-[1280px]:py-[18px]`,activeProps:{className:`!border-lamp-run !text-ink`},children:e.label},e.to))}),(0,h.jsxs)(`div`,{className:`col-start-2 row-start-1 ml-auto flex items-center gap-1 sm:gap-4 min-[1280px]:gap-7 [&_button]:min-h-8 [&_button]:min-w-8`,children:[(0,h.jsx)(Nk,{}),r===0?null:(0,h.jsxs)(ia,{to:`/`,"aria-label":`${String(r)} running`,title:`${String(r)} running`,className:`engraved flex min-h-8 items-center whitespace-nowrap text-ink3 hover:text-ink2`,children:[String(r),(0,h.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:`\xA0running`})]}),Uk.map(e=>(0,h.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,title:e.label,className:`flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,children:[(0,h.jsx)(Oc,{name:e.glyph,className:e.tone}),(0,h.jsx)(`span`,{className:`sr-only min-[1100px]:not-sr-only`,children:e.label})]},e.href))]})]}),(0,h.jsx)(`main`,{className:`min-w-0 flex-1 px-4 py-6 sm:px-7`,children:(0,h.jsx)(ya,{})}),(0,h.jsx)(`footer`,{className:`flex items-center gap-[18px] border-t border-line px-4 py-[14px] text-label sm:px-7 text-ink3`,children:(0,h.jsx)(`span`,{children:`Free. Your keys, your machine.`})}),(0,h.jsx)(Vk,{reload:()=>window.location.reload()}),(0,h.jsx)(Ky,{}),(0,h.jsx)(Uy,{}),(0,h.jsx)(qy,{reload:()=>{window.location.reload()}})]})}var Kk=[`text`,`llm`],qk=[`article`,`image`,`thumbnail`],Jk=[`intro`,`outro`],Yk=1e5,Xk=Jk.map(e=>({value:e,label:Qk(e)})),Zk=Kk.map(e=>({value:e,label:$k(e)}));function Qk(e){switch(e){case`intro`:return`Intro`;case`outro`:return`Outro`}}function $k(e){switch(e){case`text`:return`Text`;case`llm`:return`LLM`}}function eA(e){switch(e){case`text`:return`Text is narrated as written.`;case`llm`:return`LLM is an instruction whose answer is narrated.`}}function tA(e){switch(e){case`text`:return`No slots. This text is narrated as written.`;case`llm`:return`No slots. This instruction runs as written.`}}function nA(e){return Jk.find(t=>t===e)??`intro`}var rA=qk.map(e=>({value:e,label:iA(e)}));function iA(e){switch(e){case`article`:return`Article`;case`image`:return`Image`;case`thumbnail`:return`Thumbnail`}}function aA(e){return qk.find(t=>t===e)??`article`}function oA({open:e,title:t,consequence:n,verb:r,dismiss:i=`Cancel`,pending:a=!1,onConfirm:o,onCancel:s}){return(0,h.jsx)(Ty,{open:e,onOpenChange:e=>{e||s()},children:(0,h.jsxs)(Oy,{children:[(0,h.jsx)(ky,{children:t}),(0,h.jsx)(Ay,{children:n}),(0,h.jsxs)(`div`,{className:`flex justify-end gap-[10px]`,children:[(0,h.jsx)(J,{autoFocus:!0,onClick:s,children:i}),(0,h.jsx)(J,{variant:`danger`,disabled:a,onClick:o,children:r})]})]})})}function sA({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:W(`overflow-hidden rounded-panel border border-line bg-panel`,t),children:e})}function cA({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:W(`relative flex items-center gap-[14px] border-b border-line px-4 py-[14px] last:border-b-0`,t),children:e})}function lA({current:e,total:t}){let n=t<=0?0:Math.min(1,Math.max(0,e/t));return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-meter`,className:`absolute inset-x-0 bottom-0 h-[2px] bg-lamp-run transition-[width] duration-[250ms] ease-out motion-reduce:transition-none`,style:{width:`${String(Math.round(n*100))}%`}})}function uA({name:e,className:t}){return(0,h.jsx)(`span`,{"data-slot-chip":e,className:W(`engraved animate-tick-in rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] text-ink2 motion-reduce:animate-none`,t),children:e})}var dA=p_,fA=m_;function pA({className:e,sideOffset:t=4,align:n=`end`,...r}){return(0,h.jsx)(h_,{children:(0,h.jsx)(g_,{"data-slot":`dropdown-menu-content`,sideOffset:t,align:n,className:W(`z-50 min-w-[160px] overflow-hidden rounded-panel border border-line bg-panel p-1`,`shadow-[0_8px_24px_var(--color-shadow)]`,e),...r})})}function mA({className:e,...t}){return(0,h.jsx)(__,{"data-slot":`dropdown-menu-item`,className:W(`flex cursor-default items-center rounded-control px-[10px] py-[5px] text-small text-ink`,`outline-hidden select-none focus:bg-panel2 data-highlighted:bg-panel2`,e),...t})}function hA({className:e,...t}){return(0,h.jsx)(py,{"data-slot":`toggle-group`,className:W(`inline-flex w-fit items-stretch overflow-hidden rounded-control border border-line2`,e),...t})}function gA({className:e,...t}){return(0,h.jsx)(Sy,{"data-slot":`toggle-group-item`,className:W(`min-h-8 shrink-0 border-r border-line2 px-[10px] py-[5px] text-label text-ink2 last:border-r-0`,`transition-colors duration-150 ease-out motion-reduce:transition-none hover:bg-panel2 hover:text-ink`,`data-[state=on]:bg-panel2 data-[state=on]:text-ink data-[state=on]:shadow-[inset_0_-2px_0_var(--color-lamp-run)]`,`disabled:cursor-not-allowed disabled:opacity-40`,e),...t})}var _A=`grid grid-cols-[minmax(0,1fr)_auto_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_70px_minmax(0,1fr)_auto_32px]`,vA=`col-span-4 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1 md:col-start-3 md:row-start-1`;function yA({category:e,onCategory:t}){let{api:n}=B(),r=_(),i=R(zy(n)),[a,o]=(0,m.useState)(void 0),s=tt({mutationFn:e=>ko(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:jy.entries})}}),c=i.data?.entries.filter(t=>t.category===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Intros & Outros`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(hA,{type:`single`,value:e,"aria-label":`Entry category`,onValueChange:e=>{let n=Xk.find(t=>t.value===e);n!==void 0&&t(n.value)},children:Xk.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(J,{asChild:!0,children:(0,h.jsxs)(ia,{to:`/entries/new`,search:{category:e},children:[(0,h.jsx)(kk,{"aria-hidden":`true`,className:`size-[14px]`}),`New entry`]})})]}),i.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(CA,{}):null:c.length===0?(0,h.jsx)(xA,{category:e}):(0,h.jsx)(sA,{children:c.map(e=>(0,h.jsxs)(`div`,{className:_A,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(bA,{mode:e.mode}),(0,h.jsx)(`span`,{className:vA,children:e.slots.map(e=>(0,h.jsx)(uA,{name:e},e))}),(0,h.jsx)(J,{className:`col-start-3 row-start-1 md:col-start-4`,asChild:!0,children:(0,h.jsx)(ia,{to:`/entries/$entryId`,params:{entryId:e.id},children:`Edit`})}),(0,h.jsx)(SA,{entry:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(oA,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function bA({mode:e}){return(0,h.jsx)(`span`,{"data-entry-mode":e,className:`engraved col-start-2 row-start-1 justify-self-start rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] font-bold text-ink`,children:$k(e)})}function xA({category:e}){return(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`max-w-[75ch] px-4 py-7 text-ink2`,children:`No ${e}s yet. An ${e} is narrated ${e===`intro`?`before`:`after`} the body in the run's voice.`})})}function SA({entry:e,onDelete:t}){return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-4 row-start-1 size-8 p-0 md:col-start-5`,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(mA,{asChild:!0,children:(0,h.jsx)(ia,{to:`/entries/new`,search:{category:e.category,from:e.id},children:`Duplicate`})}),(0,h.jsx)(mA,{onSelect:t,children:`Delete`})]})]})}function CA(){return(0,h.jsx)(sA,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:_A,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-[18px] w-10 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:vA,children:(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`})}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-4`})]},e))})}function wA({slots:e,body:t,lint:n,lintId:r,noSlots:i=`No slots. This prompt runs as written.`}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Detected slots`}),e.length>0?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:e.map(e=>(0,h.jsx)(uA,{name:e,className:`px-2 py-[3px]`},e))}):t.trim()===``?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Slots appear here as you type {{name}}.`}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:i}),n.length===0?null:(0,h.jsxs)(`div`,{id:r,className:`flex flex-col gap-[6px] border-t border-line pt-3`,children:[(0,h.jsx)(`span`,{className:`engraved text-red`,children:n.length===1?`1 slot error`:`${String(n.length)} slot errors`}),n.map(e=>(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.message},e.message))]})]})}var TA=2e3;function EA(e,t){let n=(0,m.useRef)(t);(0,m.useEffect)(()=>{n.current=t}),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{n.current()},TA);return()=>{clearTimeout(t)}},[e])}function DA(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-done motion-reduce:animate-none`,children:[(0,h.jsx)(bk,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function OA({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px] border-t border-line pt-[14px]`,children:[e===void 0?null:(0,h.jsx)(J,{className:`bg-transparent`,onClick:e,children:`Delete`}),(0,h.jsx)(`span`,{className:`flex-1`}),i?(0,h.jsx)(DA,{}):null,t===void 0?null:(0,h.jsx)(`span`,{id:n,className:`text-small text-ink2`,children:t}),a,(0,h.jsx)(J,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,onClick:()=>{c||s()},children:`Save`}),o.map(e=>(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:e},e))]})}var kA=`rounded-panel border border-line bg-panel p-[18px]`;function AA(){return(0,h.jsxs)(`div`,{className:`mx-auto grid max-w-[1440px] grid-cols-[minmax(0,1fr)] gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${kA} flex flex-col gap-[14px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-panel2`})]}),(0,h.jsx)(`div`,{className:`${kA} flex flex-col gap-3`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-panel2`})})]})}function jA({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:e})}),t]})}var MA=`mt-[10px] inline-block text-small text-run-text underline`;function NA({className:e,...t}){return(0,h.jsx)(y_,{"data-slot":`label`,className:W(`engraved block select-none text-ink3`,e),...t})}function PA({label:e,value:t,options:n,describedBy:r,onPick:i}){let a=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{id:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(hA,{type:`single`,value:t,"aria-labelledby":a,"aria-describedby":r,onValueChange:e=>{let t=n.find(t=>t.value===e);t!==void 0&&i(t.value)},children:n.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))})]})}function FA({className:e,...t}){return(0,h.jsx)(`input`,{"data-slot":`input`,className:W(`h-8 w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}function IA({className:e,...t}){return(0,h.jsx)(`textarea`,{"data-slot":`textarea`,className:W(`w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}var LA=`{{`,RA=`}}`;function zA(e){let t=[],n=[],r=e.indexOf(LA);for(;r!==-1;){let i=e.indexOf(`
99
- `,r+2),a=i===-1?e.length:i,o=e.indexOf(RA,r+2);if(o===-1||o>a){n.push({kind:`unclosed`,at:r}),r=e.indexOf(LA,r+2);continue}let s=e.slice(r+2,o),c=s.trim();s.includes(`{`)||s.includes(`}`)?n.push({kind:`nested`,at:r}):c===``?n.push({kind:`empty`,at:r}):t.includes(c)||t.push(c),r=e.indexOf(LA,o+2)}return{names:t,errors:n}}function BA(e,t){let n=VA(e),r=VA(t),i=[];for(let e of[...n,...r]){if(i.some(t=>t.name===e))continue;let t=n.includes(e),a=r.includes(e);i.push({name:e,group:t&&a?`common`:t?`text`:`image`})}return i}function VA(e){let t=[];for(let n of e)for(let e of zA(n).names)t.includes(e)||t.push(e);return t}function HA(e){return WA(e.name,e.body)}function UA(e){return WA(e.name,e.body)}function WA(e,t){let n=[],r=e.trim();if(r===``?n.push({field:`name`,message:`A name is required.`}):r.length>200&&n.push({field:`name`,message:`A name is at most 200 characters.`}),t.trim()===``)return n.push({field:`body`,message:`A body is required.`}),n;if(t.length>1e5)return n.push({field:`body`,message:`A body is at most ${String(Yk)} characters.`}),n;for(let e of zA(t).errors)n.push({field:`body`,message:GA(e,t)});return n}function GA(e,t){let n=KA(t,e.at);switch(e.kind){case`unclosed`:return`The \`{{\` at ${n} is never closed.`;case`empty`:return`The slot at ${n} has no name.`;case`nested`:return`The slot at ${n} holds a brace; slots do not nest.`}}function KA(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`
98
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function oT(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;oT(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var sT=new Set([`type`,`properties`,`required`,`additionalProperties`]),cT=[`oneOf`,`anyOf`];function lT(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function uT(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!sT.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??lT(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Hy(n,r,e.length===1?e[0]:uT(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=lT(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function dT(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of sT)if(t in e)return;let n=t.filter(e=>cT.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=uT(t);else{let e=n[0],i=cT.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>uT([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,eT(e,r))}function fT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):eT(i,s),eT(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())oT(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])dT(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}eT(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Hy(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:hT(t,`input`,e.processors),output:hT(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function pT(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return pT(r.element,n);if(r.type===`set`)return pT(r.valueType,n);if(r.type===`lazy`)return pT(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return pT(r.innerType,n);if(r.type===`intersection`)return pT(r.left,n)||pT(r.right,n);if(r.type===`record`||r.type===`map`)return pT(r.keyType,n)||pT(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:pT(r.in,n)||pT(r.out,n);if(r.type===`object`){for(let e in r.shape)if(pT(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(pT(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(pT(e,n))return!0;return!!(r.rest&&pT(r.rest,n))}return!1}var mT=(e,t={})=>n=>{let r=tT({...n,processors:t});return rT(e,r),aT(r,e),fT(r,e)},hT=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=tT({...i??{},target:a,io:t,processors:n});return rT(e,o),aT(o,e),fT(o,e)},gT={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},_T=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=gT[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},vT=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):nT(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},yT=(e,t,n,r)=>{n.not={}},bT=(e,t,n,r)=>{let i=e._zod.def,a=Fy(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},xT=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(nT(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(nT(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},ST=(e,t,n,r)=>{nT(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},CT=(e,t,n,r)=>{nT(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},wT=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=rT(a.element,t,{...r,path:[...r.path,`items`]})};function TT(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?TT(t.out):t.type===`catch`?TT(t.innerType):e._zod.optin}var ET=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&nT(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Hy(i.properties,e,rT(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?TT(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=rT(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},DT=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>rT(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},OT=(e,t,n,r)=>{let i=e._zod.def,a=rT(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=rT(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},kT=(e,t,n,r)=>{let i=e._zod.def,a=rT(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},AT=(e,t,n,r)=>{let i=e._zod.def;rT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},jT=Symbol();function MT(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(nT(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),jT):JSON.parse(o)}var NT=(e,t,n,r)=>{let i=e._zod.def;rT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=MT(i.defaultValue,e,t,n,r);o!==jT&&(n.default=o)},PT=(e,t,n,r)=>{let i=e._zod.def;rT(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=MT(i.defaultValue,e,t,n,r);o!==jT&&(n._prefault=o)},FT=(e,t,n,r)=>{let i=e._zod.def;rT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{nT(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},IT=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;rT(o,t,r);let s=t.seen.get(e);s.ref=o},LT=(e,t,n,r)=>{let i=e._zod.def;rT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},RT=(e,t,n,r)=>{let i=e._zod.def;rT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},zT=new WeakSet([Object.prototype,Error.prototype]);function BT(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var VT=X(`ZodError`,(e,t)=>{Jb.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);zT.has(n)||(zT.add(n),BT(n,`format`,e=>t=>Qb(e,t)),BT(n,`flatten`,e=>t=>Zb(e,t)),BT(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ly,2)}),BT(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ly,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),HT=ex(VT),UT=tx(VT),WT=nx(VT),GT=ix(VT),KT=ox(VT),qT=sx(VT),JT=cx(VT),YT=lx(VT),XT=ux(VT),ZT=dx(VT),QT=fx(VT),$T=px(VT);function eE(){zb.localeError||Bb(JC())}function tE(){zb.memoizer||Bb({memoizer:GC()})}var nE=X(`ZodType`,(e,t)=>(eE(),fS.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Uy(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return $y(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(_D(e,t))},superRefine(e,t){return this.check(vD(e,t))},overwrite(e){return this.check(Ww(e))},optional(){return $E(this)},exactOptional(){return tD(this)},nullable(){return rD(this)},nullish(){return $E(rD(this))},nonoptional(e){return lD(this,e)},array(){return zE(this)},or(e){return UE([this,e])},and(e){return GE(this,e)},transform(e){return pD(this,ZE(e))},default(e){return aD(this,e)},prefault(e){return sD(this,e)},catch(e){return dD(this,e)},pipe(e){return pD(this,e)},readonly(){return hD(this)},describe(e){let t=this.clone();return QC.add(t,{description:e}),t},meta(...e){if(e.length===0)return QC.get(this);let t=this.clone();return QC.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Cb(this,`~standard`,{...mS(this),jsonSchema:{input:hT(this,`input`),output:hT(this,`output`)}})},set"~standard"(e){Sb(this,`~standard`,e)},parse:function e(t,n){return HT(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await UT(this,t,n,{callee:e})},safeParse(e,t){return WT(this,e,t)},async safeParseAsync(e,t){return GT(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Sb(this,`spa`,e)},encode:function e(t,n){return KT(this,t,n,{callee:e})},decode:function e(t,n){return qT(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await JT(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await YT(this,t,n,{callee:e})},safeEncode(e,t){return XT(this,e,t)},safeDecode(e,t){return ZT(this,e,t)},async safeEncodeAsync(e,t){return QT(this,e,t)},async safeDecodeAsync(e,t){return $T(this,e,t)},toJSONSchema(e){return mT(this,{})(e)},get description(){return QC.get(this)?.description},get _def(){return this._zod.def}}),rE=X(`_ZodString`,(e,t)=>{hS.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_T(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(Rw(...e))},includes(...e){return this.check(Vw(...e))},startsWith(...e){return this.check(Hw(...e))},endsWith(...e){return this.check(Uw(...e))},min(...e){return this.check(Iw(...e))},max(...e){return this.check(Fw(...e))},length(...e){return this.check(Lw(...e))},nonempty(...e){return this.check(Iw(1,...e))},lowercase(e){return this.check(zw(e))},uppercase(e){return this.check(Bw(e))},trim(){return this.check(Kw())},normalize(...e){return this.check(Gw(...e))},toLowerCase(){return this.check(qw())},toUpperCase(){return this.check(Jw())},slugify(){return this.check(Yw())}}),iE=X(`ZodString`,(e,t)=>{hS.init(e,t),rE.init(e,t)},{email(e){return this.check(ew(dE,e))},url(e){return this.check(ow(mE,e))},jwt(e){return this.check(xw(kE,e))},emoji(e){return this.check(sw(hE,e))},guid(e){return this.check(tw(fE,e))},uuid(e){return this.check(nw(pE,e))},uuidv4(e){return this.check(rw(pE,e))},uuidv6(e){return this.check(iw(pE,e))},uuidv7(e){return this.check(aw(pE,e))},nanoid(e){return this.check(cw(gE,e))},cuid(e){return this.check(lw(_E,e))},cuid2(e){return this.check(uw(vE,e))},ulid(e){return this.check(dw(yE,e))},base64(e){return this.check(vw(EE,e))},base64url(e){return this.check(yw(DE,e))},xid(e){return this.check(fw(bE,e))},ksuid(e){return this.check(pw(xE,e))},ipv4(e){return this.check(mw(SE,e))},ipv6(e){return this.check(hw(CE,e))},cidrv4(e){return this.check(gw(wE,e))},cidrv6(e){return this.check(_w(TE,e))},e164(e){return this.check(bw(OE,e))},datetime(e){return this.check(Sw(sE,e))},date(e){return this.check(Cw(cE,e))},time(e){return this.check(ww(lE,e))},duration(e){return this.check(Tw(uE,e))}});function aE(e){return $C(iE,e)}var oE=X(`ZodStringFormat`,(e,t)=>{gS.init(e,t),rE.init(e,t)}),sE=X(`ZodISODateTime`,(e,t)=>{NS.init(e,t),oE.init(e,t)}),cE=X(`ZodISODate`,(e,t)=>{PS.init(e,t),oE.init(e,t)}),lE=X(`ZodISOTime`,(e,t)=>{FS.init(e,t),oE.init(e,t)}),uE=X(`ZodISODuration`,(e,t)=>{IS.init(e,t),oE.init(e,t)}),dE=X(`ZodEmail`,(e,t)=>{yS.init(e,t),oE.init(e,t)}),fE=X(`ZodGUID`,(e,t)=>{_S.init(e,t),oE.init(e,t)}),pE=X(`ZodUUID`,(e,t)=>{vS.init(e,t),oE.init(e,t)}),mE=X(`ZodURL`,(e,t)=>{TS.init(e,t),oE.init(e,t)}),hE=X(`ZodEmoji`,(e,t)=>{ES.init(e,t),oE.init(e,t)}),gE=X(`ZodNanoID`,(e,t)=>{DS.init(e,t),oE.init(e,t)}),_E=X(`ZodCUID`,(e,t)=>{OS.init(e,t),oE.init(e,t)}),vE=X(`ZodCUID2`,(e,t)=>{kS.init(e,t),oE.init(e,t)}),yE=X(`ZodULID`,(e,t)=>{AS.init(e,t),oE.init(e,t)}),bE=X(`ZodXID`,(e,t)=>{jS.init(e,t),oE.init(e,t)}),xE=X(`ZodKSUID`,(e,t)=>{MS.init(e,t),oE.init(e,t)}),SE=X(`ZodIPv4`,(e,t)=>{LS.init(e,t),oE.init(e,t)}),CE=X(`ZodIPv6`,(e,t)=>{BS.init(e,t),oE.init(e,t)}),wE=X(`ZodCIDRv4`,(e,t)=>{VS.init(e,t),oE.init(e,t)}),TE=X(`ZodCIDRv6`,(e,t)=>{US.init(e,t),oE.init(e,t)}),EE=X(`ZodBase64`,(e,t)=>{GS.init(e,t),oE.init(e,t)}),DE=X(`ZodBase64URL`,(e,t)=>{qS.init(e,t),oE.init(e,t)}),OE=X(`ZodE164`,(e,t)=>{JS.init(e,t),oE.init(e,t)}),kE=X(`ZodJWT`,(e,t)=>{XS.init(e,t),oE.init(e,t)}),AE=X(`ZodNumber`,(e,t)=>{ZS.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vT(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(Mw(e,t))},gte(e,t){return this.check(Nw(e,t))},min(e,t){return this.check(Nw(e,t))},lt(e,t){return this.check(Aw(e,t))},lte(e,t){return this.check(jw(e,t))},max(e,t){return this.check(jw(e,t))},int(e){return this.check(NE(e))},safe(e){return this.check(NE(e))},positive(e){return this.check(Mw(0,e))},nonnegative(e){return this.check(Nw(0,e))},negative(e){return this.check(Aw(0,e))},nonpositive(e){return this.check(jw(0,e))},multipleOf(e,t){return this.check(Pw(e,t))},step(e,t){return this.check(Pw(e,t))},finite(){return this}});function jE(e){return Ew(AE,e)}var ME=X(`ZodNumberFormat`,(e,t)=>{QS.init(e,t),AE.init(e,t)});function NE(e){return Dw(ME,e)}var PE=X(`ZodUnknown`,(e,t)=>{$S.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function FE(){return Ow(PE)}var IE=X(`ZodNever`,(e,t)=>{eC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yT(e,t,n,r)});function LE(e){return kw(IE,e)}var RE=X(`ZodArray`,(e,t)=>{tE(),nC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wT(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Iw(e,t))},nonempty(e){return this.check(Iw(1,e))},max(e,t){return this.check(Fw(e,t))},length(e,t){return this.check(Lw(e,t))},unwrap(){return this.element}});function zE(e,t){return Xw(RE,e,t)}var BE=X(`ZodObject`,(e,t)=>{tE(),lC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ET(e,t,n,r),Ab(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return qE(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:FE()})},loose(){return this.clone({...this._zod.def,catchall:FE()})},strict(){return this.clone({...this._zod.def,catchall:LE()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ab(this,e)},safeExtend(e){return ob(this,e)},merge(e){return sb(this,e)},pick(e){return rb(this,e)},omit(e){return ib(this,e)},partial(...e){return cb(QE,this,e[0])},exactPartial(...e){return cb(eD,this,e[0],`exactPartial`)},required(...e){return lb(cD,this,e[0])}});function VE(e,t){return new BE({type:`object`,shape:e??{},...Y(t)})}var HE=X(`ZodUnion`,(e,t)=>{dC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>DT(e,t,n,r),e.options=t.options});function UE(e,t){return new HE({type:`union`,options:e,...Y(t)})}var WE=X(`ZodIntersection`,(e,t)=>{fC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>OT(e,t,n,r)});function GE(e,t){return new WE({type:`intersection`,left:e,right:t})}var KE=X(`ZodEnum`,(e,t)=>{hC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bT(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new KE({...t,checks:[],...Y(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new KE({...t,checks:[],...Y(r),entries:i})}});function qE(e,t){return new KE({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...Y(t)})}var JE=X(`ZodLiteral`,(e,t)=>{gC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xT(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function YE(e,t){return new JE({type:`literal`,values:Array.isArray(e)?e:[e],...Y(t)})}var XE=X(`ZodTransform`,(e,t)=>{tE(),_C.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>CT(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Rb(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(bb(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(bb(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ZE(e){return new XE({type:`transform`,transform:e})}var QE=X(`ZodOptional`,(e,t)=>{yC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>RT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $E(e){return new QE({type:`optional`,innerType:e})}var eD=X(`ZodExactOptional`,(e,t)=>{bC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>RT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function tD(e){return new eD({type:`optional`,innerType:e})}var nD=X(`ZodNullable`,(e,t)=>{xC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rD(e){return new nD({type:`nullable`,innerType:e})}var iD=X(`ZodDefault`,(e,t)=>{SC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>NT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function aD(e,t){return new iD({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Xy(t)}})}var oD=X(`ZodPrefault`,(e,t)=>{wC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>PT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sD(e,t){return new oD({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Xy(t)}})}var cD=X(`ZodNonOptional`,(e,t)=>{TC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>AT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lD(e,t){return new cD({type:`nonoptional`,innerType:e,...Y(t)})}var uD=X(`ZodCatch`,(e,t)=>{OC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>FT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function dD(e,t){return new uD({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Mb(t)})}var fD=X(`ZodPipe`,(e,t)=>{kC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>IT(e,t,n,r),e.in=t.in,e.out=t.out});function pD(e,t){return new fD({type:`pipe`,in:e,out:t})}var mD=X(`ZodReadonly`,(e,t)=>{jC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>LT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hD(e){return new mD({type:`readonly`,innerType:e})}var gD=X(`ZodCustom`,(e,t)=>{NC.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ST(e,t,n,r)});function _D(e,t={}){return Zw(gD,e,t)}function vD(e,t){return Qw(e,t)}var yD=[`off`,`files`,`burn-in`],bD=[`top`,`upper-middle`,`center`,`lower-middle`,`bottom`],xD=VE({mode:qE(yD),language:YE(`en`).default(`en`),fontId:aE().max(160).regex(/^[A-Za-z0-9_-]+$/).default(`default`),position:qE(bD).default(`bottom`),fontSize:jE().int().min(16).max(120).default(48)}),SD={mode:`off`,language:`en`,fontId:`default`,fontSize:48,position:`bottom`};function CD(e,t){let n={...SD,...e},r=t.audio===`off`?`off`:(t.video===`off`||t.images===`off`)&&n.mode===`burn-in`?`files`:n.mode;if(r!==`off`)return{...n,mode:r};let i=xD.shape.fontId.safeParse(n.fontId),a=xD.shape.fontSize.safeParse(n.fontSize);return{...n,mode:r,fontId:i.success?i.data:SD.fontId,fontSize:a.success?a.data:SD.fontSize}}function wD(e,t){return e.mode===t.mode&&e.language===t.language&&e.fontId===t.fontId&&e.fontSize===t.fontSize&&(e.position??`bottom`)===(t.position??`bottom`)}function TD(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}var ED={title:``,format:`16:9`,sources:{research:`off`,article:`generate`,audio:`generate`,images:`generate`,thumbnail:`off`,video:`generate`},llm:{provider:``,model:``},audio:{provider:``,model:``,voice:``},images:{provider:``,model:``},articlePrompt:``,imagePrompts:[],thumbnailPrompt:``,intro:``,outro:``,chunking:{mode:`whole`},subtitles:SD,values:{},provided:{research:``,article:``,audio:void 0,images:[],thumbnail:void 0}},DD={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function OD(e){return Ey[e].map(e=>({value:e,label:DD[e]}))}function kD(e,t){return e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||e.sources.audio===`generate`&&(AD(t,`intro`,e.intro)===`llm`||AD(t,`outro`,e.outro)===`llm`)}function AD(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function jD(e){return[e.audio,e.thumbnail,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function MD(e){let{form:t}=e;return{title:t.title,format:t.format,sources:{...t.sources,...t.sources.article===`provide`?{research:`off`}:{},...t.sources.images===`off`?{video:`off`}:{}},llm:t.llm,audio:t.audio,images:t.images,articlePrompt:t.articlePrompt,imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...ND(PD(e,`intro`),e=>({intro:e})),...ND(PD(e,`outro`),e=>({outro:e})),values:FD(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...ND(t.provided.audio?.file,e=>({audio:e.id})),...ND(t.provided.thumbnail?.file,e=>({thumbnail:e.id})),images:t.provided.images.flatMap(e=>e.file===void 0?[]:[e.file.id])},chunking:t.chunking,subtitles:CD(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds}}function ND(e,t){return e===void 0?{}:t(e)}function PD(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=AD(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function FD(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}var ID=(0,m.createContext)(void 0);function LD({children:e}){let[t,n]=(0,m.useState)(()=>new Map),[r,i]=(0,m.useState)(ED),a=(0,m.useCallback)((e,t)=>{n(n=>{let r=n.get(e),i=typeof t==`function`?t(r):t;if(r===i)return n;let a=new Map(n);return i===void 0?a.delete(e):a.set(e,i),a})},[]),o=(0,m.useMemo)(()=>({prompts:t,updatePrompt:a,play:r,updatePlay:i}),[t,a,r]);return(0,h.jsx)(ID.Provider,{value:o,children:e})}function RD(e){let t=(0,m.useContext)(ID),[n,r]=(0,m.useState)(void 0),i=t?.updatePrompt,a=(0,m.useCallback)(t=>{i?i(e,t):r(t)},[e,i]);return[t?t.prompts.get(e):n,a]}function zD(){let e=(0,m.useContext)(ID),[t,n]=(0,m.useState)(ED);return e?[e.play,e.updatePlay]:[t,n]}function BD(e,t){if(e===void 0)return;if(t.type===`project.state`)return{...e,project:{...e.project,status:t.state}};let n=e.stages.findIndex(e=>e.kind===t.stage),r=e.stages[n];return r===void 0?e:{...e,stages:e.stages.with(n,VD(r,t))}}function VD(e,t){return t.type===`stage.progress`?{...e,progressCurrent:t.current,progressTotal:t.total}:{...e,state:t.state,failureReason:t.failureReason??e.failureReason}}function HD(e,t){let n,r=!1,i=()=>{n=void 0,r&&(r=!1,e(),a())},a=()=>{n=setTimeout(i,t)};return{ask:()=>{if(n!==void 0){r=!0;return}e(),a()},stop:()=>{n!==void 0&&clearTimeout(n),n=void 0,r=!1}}}var UD=[{id:`text-key`,title:`1. Connect a text provider`,target:`keys-llm`,page:`settings`},{id:`audio-key`,title:`2. Connect a voice provider`,target:`keys-tts`,page:`settings`},{id:`image-key`,title:`3. Connect an image provider`,target:`keys-image`,page:`settings`},{id:`voice`,title:`4. Add a narration voice`,target:`voices`,page:`settings`},{id:`article-name`,title:`5. Name your article prompt`,target:`prompt-name`,page:`article`},{id:`article-body`,title:`6. Write instructions with keywords`,target:`prompt-body`,page:`article`},{id:`article-keywords`,title:`7. Check the detected keywords`,target:`prompt-slots`,page:`article`},{id:`article-save`,title:`8. Save your article prompt`,target:`prompt-save`,page:`article`},{id:`image-prompt`,title:`9. Create an image prompt`,target:`prompt-editor`,page:`image`},{id:`image-save`,title:`10. Save your image prompt`,target:`prompt-save`,page:`image`},{id:`play-article`,title:`11. Choose what to write`,target:`play-article`,page:`play`},{id:`play-audio`,title:`12. Choose the narration`,target:`play-audio`,page:`play`},{id:`play-images`,title:`13. Choose the images`,target:`play-images`,page:`play`},{id:`play-video`,title:`14. Choose your final output`,target:`play-video`,page:`play`},{id:`play-subtitles`,title:`15. Add optional subtitles`,target:`play-subtitles`,page:`play`},{id:`play-options`,title:`16. Name and configure your project`,target:`play-options`,page:`play`},{id:`play-keywords`,title:`17. Fill in your keywords`,target:`play-keywords`,page:`play`},{id:`play-start`,title:`18. Review and press PLAY`,target:`play-start`,page:`play`},{id:`project`,title:`19. Follow and control the run`,target:`project-controls`,page:`project`},{id:`download`,title:`20. Download your results`,target:`project-video`,page:`project`}];function WD(e,t){return e.active?t.type===`project-created`?{...e,projectId:t.id,step:UD.findIndex(e=>e.id===`project`)}:t.kind===`article`?{...e,articleId:t.id}:t.kind===`image`?{...e,imageId:t.id}:e:e}var GD={research:`Research`,article:`Article`,audio:`Audio`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`};function KD(e){return e.sources.video===`off`?e.sources.audio===`off`?`article`:`audio`:`video`}function qD(e,t){return e===`video`&&KD(t)===`audio`?`Audio export`:GD[e]}function JD(e,t){return e.kind===`video`&&e.state===`running`&&t.subtitles!==void 0&&t.subtitles.mode!==`off`&&e.progressTotal===100&&(e.progressCurrent??0)<=35}var YD={research:(e,t)=>`chapter ${String(e)} of ${String(t)}`,article:(e,t)=>`${String(e)} of ${String(t)}`,audio:(e,t)=>`chunk ${String(e)} of ${String(t)}`,images:(e,t)=>`image ${String(e)} of ${String(t)}`,thumbnail:(e,t)=>`${String(e)} of ${String(t)}`,video:(e,t)=>`${String(rO(e,t))}% rendered`},XD={audio_intro:`intro`,audio_body:`body`,audio_outro:`outro`};function ZD(e,t,n){let r=t.filter(t=>t.stageKind===e.kind);switch(e.state){case`skipped`:return`Not part of this run`;case`pending`:return n.status===`paused`?`Waiting for Resume`:e.kind===`images`||e.kind===`thumbnail`&&e.source===`from_prompt`?`Ready to run`:`Waits for the stages above`;case`provided`:return eO(r)??`Provided`;case`failed`:return`Stopped after ${QD(e)}`;case`canceled`:return`Canceled by user`;case`running`:return JD(e,n.config)?`Preparing subtitles · ${String(rO(e.progressCurrent??0,35))}%`:e.kind===`video`&&KD(n.config)===`audio`?`Exporting combined audio`:e.progressTotal===null||e.progressTotal<=0?`Running`:YD[e.kind](e.progressCurrent??0,e.progressTotal);case`done`:return $D(e.kind,r,n)}}function QD(e){return e.attemptCount===1?`1 attempt`:`${String(e.attemptCount)} attempts`}function $D(e,t,n){switch(e){case`research`:return`Notes ready`;case`article`:{let e=t.filter(e=>e.role===`sources`||e.role===`glossary`);return e.length===0?`Article ready`:`Article and ${String(e.length)} end-matter files`}case`audio`:return sO([aO(t.flatMap(e=>{let t=XD[e.role];return t===void 0?[]:[t]})),nO(tO(t))]);case`images`:return iO(t.filter(e=>e.role===`image`).length,`image`);case`thumbnail`:return t.length===0?`Thumbnail ready`:`1 image`;case`video`:return sO([nO(tO(t)),KD(n.config)===`audio`?`WAV · stereo · 48 kHz`:n.format])}}function eO(e){let t=e.flatMap(e=>e.originalFilename===null?[]:[e.originalFilename]);return t.length===0?void 0:t.join(`, `)}function tO(e){let t=Math.max(0,...e.map(e=>e.durationMs??0));return t===0?void 0:t}function nO(e){if(e===void 0||!Number.isFinite(e)||e<=0)return;let t=Math.round(e/1e3),n=[Math.floor(t/60)%60,t%60].map(e=>String(e).padStart(2,`0`)),r=Math.floor(t/3600);return r===0?n.join(`:`):[String(r),...n].join(`:`)}function rO(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function iO(e,t){return e===1?`1 ${t}`:`${String(e)} ${t}s`}function aO(e){if(e.length!==0)return e.length===1?oO(e[0]??``):oO(`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]??``}`)}function oO(e){return e.charAt(0).toUpperCase()+e.slice(1)}function sO(e){return e.filter(e=>e!==void 0&&e!==``).join(` · `)}var cO=12,lO=16;function uO(e,t,n){return Math.max(t,Math.min(e,Math.max(t,n)))}function dO(e,t,n){let r=Math.min(n.width,t.width-24),i=uO(e?.left??(t.width-r)/2,cO,t.width-r-cO),a=uO((e?.top??0)+((e?.height??t.height)-n.height)/2,cO,t.height-n.height-cO),o=t.height-n.height-cO;if(!e)return{left:i,top:a,width:r,docked:!1};let s=e.left+e.width,c=e.top+e.height;return s+lO+r<=t.width-cO?{left:s+lO,top:a,width:r,docked:!1}:e.left-lO-r>=cO?{left:e.left-lO-r,top:a,width:r,docked:!1}:c>=cO&&c+lO+n.height<=t.height-cO?{left:i,top:c+lO,width:r,docked:!1}:e.top-lO-n.height>=cO&&e.top<=t.height-cO?{left:i,top:e.top-lO-n.height,width:r,docked:!1}:{left:t.width-r-cO,top:Math.max(cO,o),width:r,docked:!0}}function fO(e,t,n=t.height){let r=uO(e.left-6,0,t.width),i=uO(e.top-6,0,Math.min(n,t.height)),a=uO(e.left+e.width+6,0,t.width),o=uO(e.top+e.height+6,0,Math.min(n,t.height));return a>r&&o>i?{left:r,top:i,width:a-r,height:o-i}:null}var pO=`[data-slot="select-content"], [data-slot="dropdown-menu-content"]`;function mO(e){try{return document.querySelector(e)}catch{return null}}function hO(){return[...document.querySelectorAll(`[data-slot="dialog-content"][data-state="open"]`)].at(-1)??null}function gO(e){if(!e)return[];let t=[e,...e.querySelectorAll(`[aria-controls]`)],n=new Set(t.flatMap(e=>(e.getAttribute(`aria-controls`)??``).split(` `)));return[...document.querySelectorAll(pO)].filter(e=>n.has(e.id))}function _O(e){let t=e.getBoundingClientRect();return t.width>0&&t.height>0?{left:t.left,top:t.top,width:t.width,height:t.height}:null}var vO=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable="true"]`;function yO(e,t,n,r){let i=(0,m.useRef)(document.activeElement),a=(0,m.useRef)(t);a.current=t,(0,m.useEffect)(()=>{let e=i.current;return()=>{queueMicrotask(()=>{e instanceof HTMLElement&&e.isConnected&&!n.current&&e.focus({preventScroll:!0})})}},[n]),(0,m.useEffect)(()=>{let t=()=>{let t=mO(e);return[t,n.current,...gO(t)].filter(e=>e!==null)},i=e=>e instanceof Node&&t().some(t=>t.contains(e)),o=e=>{hO()||i(e.target)||(e.preventDefault(),e.stopImmediatePropagation())},s=e=>{hO()||i(e.target)||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-radix-focus-guard`)||r.current?.focus({preventScroll:!0})},c=n=>{if(hO())return;let r=gO(mO(e));if(n.key===`Escape`){if(r.length>0)return;n.preventDefault(),n.stopImmediatePropagation(),a.current();return}if(n.key!==`Tab`){i(n.target)||o(n);return}if(r.length>0)return;let s=t().flatMap(e=>[e,...e.querySelectorAll(vO)]).filter((e,t,n)=>n.indexOf(e)===t&&e.tabIndex>=0&&!e.matches(`:disabled, [hidden], [aria-hidden='true']`)&&!e.closest(`[hidden], [inert]`)&&(!e.closest(`details:not([open])`)||e.closest(`summary`)!==null));if(s.length===0)return;let c=s.indexOf(document.activeElement),l=c===-1?n.shiftKey?s.length-1:0:(c+(n.shiftKey?-1:1)+s.length)%s.length;n.preventDefault(),s[l]?.focus()},l=[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`click`,`dblclick`,`contextmenu`];for(let e of l)window.addEventListener(e,o,!0);return window.addEventListener(`keydown`,c,!0),window.addEventListener(`focusin`,s,!0),()=>{for(let e of l)window.removeEventListener(e,o,!0);window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`focusin`,s,!0)}},[e,n,r])}function bO(e,t,n,r,i,a){let[o,s]=(0,m.useState)(()=>({key:e,target:null,portals:[],width:window.innerWidth,height:window.innerHeight,cardHeight:260,modalOpen:hO()!==null}));return(0,m.useLayoutEffect)(()=>{let o=0,c=0,l=null,u=null,d=new Map,f=new ResizeObserver(()=>h()),p=e=>{for(let[t,n]of d)e.has(t)||(t.style.zIndex=n,d.delete(t))},m=()=>{o=0;let r=mO(t);r!==u&&(u&&f.unobserve(u),r&&f.observe(r),u=r);let i=r?_O(r):null;r&&i&&l!==r&&(l=r,cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,r.isConnected&&(r.scrollIntoView({block:`start`,inline:`nearest`,behavior:`instant`}),m())}));let a=gO(r),h=new Set;for(let e of a){let t=e.closest(`[data-radix-popper-content-wrapper]`)??e;h.add(t),d.has(t)||(d.set(t,t.style.zIndex),t.style.zIndex=`102`)}p(h);let g={key:e,target:i,portals:a.map(_O).filter(e=>e!==null),width:window.innerWidth,height:window.innerHeight,cardHeight:n.current?.getBoundingClientRect().height||260,modalOpen:hO()!==null};s(e=>JSON.stringify(e)===JSON.stringify(g)?e:g)};function h(){o||=requestAnimationFrame(m)}let g=new MutationObserver(e=>{e.some(e=>!i.current?.contains(e.target)&&e.target!==a.current)&&h()});return g.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`id`,`class`,`style`,`hidden`,`aria-controls`,`data-state`,`data-tour`]}),n.current&&f.observe(n.current),f.observe(document.documentElement),window.addEventListener(`resize`,h),window.addEventListener(`scroll`,h,!0),window.visualViewport?.addEventListener(`resize`,h),window.visualViewport?.addEventListener(`scroll`,h),m(),hO()||r.current?.focus({preventScroll:!0}),()=>{cancelAnimationFrame(o),cancelAnimationFrame(c),f.disconnect(),g.disconnect(),window.removeEventListener(`resize`,h),window.removeEventListener(`scroll`,h,!0),window.visualViewport?.removeEventListener(`resize`,h),window.visualViewport?.removeEventListener(`scroll`,h),p(new Set)}},[e,t,n,r,i,a]),o}function xO({stepId:e,target:t,title:n,children:r,progress:i,onNext:a,onBack:o,onClose:s,nextLabel:c=`Next`,nextDisabled:l=!1,onSkip:u,skipLabel:d=`Skip this step`}){let f=(0,m.useId)(),p=`${e}:${t}`,g=(0,m.useRef)(null),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=(0,m.useRef)(null),b=bO(p,t,g,_,v,y);yO(t,s,g,_);let[x,S]=(0,m.useState)({key:p,height:0}),C=b.key===p?b.target:null,w={width:b.width,height:b.height},T={width:Math.min(360,w.width-24),height:b.cardHeight},E=dO(C,w,T),D=C?fO(C,w,E.docked?E.top-12:w.height):null,O=b.key===p?b.portals.map(e=>fO(e,w)).filter(e=>e!==null):[],k=[...D?[D]:[],...O],A=`M0 0H${w.width}V${w.height}H0Z`+(D?`M${D.left} ${D.top}H${D.left+D.width}V${D.top+D.height}H${D.left}Z`:``);(0,m.useLayoutEffect)(()=>{S(e=>{let t=Math.max(e.key===p?e.height:0,E.docked?T.height+24:0);return e.key===p&&e.height===t?e:{key:p,height:t}})},[p,E.docked,T.height]);let j=x.key===p?x.height:0;return(0,m.useEffect)(()=>{let e=document.documentElement,t=e.style.scrollPaddingBottom;return e.style.scrollPaddingBottom=`${j}px`,()=>{e.style.scrollPaddingBottom=t}},[j]),(0,$c.createPortal)((0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{ref:y,"aria-hidden":`true`,style:{height:j}}),(0,h.jsxs)(`div`,{ref:v,hidden:b.modalOpen,"data-tutorial":`spotlight`,className:`pointer-events-none fixed inset-0 z-[100] font-sans`,children:[(0,h.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 h-full w-full`,width:w.width,height:w.height,children:[(0,h.jsx)(`defs`,{children:(0,h.jsxs)(`mask`,{id:`${f}-mask`,children:[(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`white`}),k.map(e=>(0,h.jsx)(`rect`,{x:e.left,y:e.top,width:e.width,height:e.height,rx:`6`,fill:`black`},`${e.left}:${e.top}:${e.width}:${e.height}`))]})}),(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`rgb(0 0 0 / 0.72)`,mask:`url(#${f}-mask)`}),(0,h.jsx)(`path`,{d:A,fill:`transparent`,fillRule:`evenodd`,pointerEvents:`fill`}),D&&(0,h.jsx)(`rect`,{"data-tutorial":`hole`,x:D.left,y:D.top,width:D.width,height:D.height,rx:`6`,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:`2`})]}),(0,h.jsxs)(`section`,{ref:g,"aria-label":`Interactive getting started guide`,"aria-describedby":`${f}-instructions`,"data-tutorial":`card`,className:`pointer-events-auto fixed z-[101] flex flex-col gap-3 rounded-panel border border-line2 bg-panel p-4 text-body text-ink shadow-[0_8px_24px_var(--color-shadow)]`,style:{left:E.left,top:E.top,width:E.width,maxHeight:Math.min(w.height-24,Math.max(160,Math.min(420,w.height*.48)))},children:[(0,h.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`engraved text-run-text`,children:[`Getting started · `,i]}),(0,h.jsx)(J,{variant:`ghost`,onClick:s,"aria-label":`Exit guide`,className:`h-7 px-2`,children:`Exit`})]}),(0,h.jsx)(`h2`,{ref:_,id:`${f}-title`,tabIndex:-1,className:`shrink-0 text-title font-bold outline-none`,children:n}),(0,h.jsxs)(`div`,{id:`${f}-instructions`,className:`min-h-0 overflow-y-auto text-ink2 [&_p+p]:mt-2 [&_code]:text-ink`,children:[r,!C&&(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-amber`,children:`This section is not available yet. Wait for the page to load, go back, or exit the guide.`}),E.docked&&C&&(0,h.jsx)(`p`,{className:`mt-3 text-small`,children:`Scroll the page to work through the highlighted section.`})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-line pt-3`,children:[o&&(0,h.jsx)(J,{onClick:o,children:`Back`}),u&&(0,h.jsx)(J,{variant:`ghost`,onClick:u,className:`px-2`,children:d}),(0,h.jsx)(J,{variant:`primary`,onClick:a,disabled:l||!C,className:`ml-auto`,children:c})]})]})]})]}),document.body)}function SO({href:e,children:t}){return(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-ink underline underline-offset-2`,children:t})}function CO({text:e}){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{className:`select-text rounded-control border border-line2 bg-panel2 p-3 text-small leading-relaxed`,children:e}),(0,h.jsx)(J,{onClick:()=>{if(i(!1),!navigator.clipboard){i(!0);return}navigator.clipboard.writeText(e).then(()=>n(!0),()=>i(!0))},children:t?`Copied`:`Copy example`}),r?(0,h.jsx)(`p`,{role:`status`,children:`Select the example above and copy it manually.`}):null]})}function wO({step:e}){switch(e){case`text-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`First, choose what will write your scripts. You only need one text provider.`}),(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Sign in to `,(0,h.jsx)(SO,{href:`https://openrouter.ai/settings/keys`,children:`OpenRouter`}),`, create an API key, and make sure the account can use your chosen model.`]}),(0,h.jsxs)(`li`,{children:[`Paste it into OpenRouter’s `,(0,h.jsx)(`strong`,{children:`API key`}),` field here and press`,` `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]})]}),(0,h.jsx)(`p`,{children:`Already using Claude Code, Codex or Gemini CLI? You can use its existing CLI login instead. “Installed” means Slopify found the CLI; sign in through that CLI before generating. If it is missing, enter its executable path and save to check again.`}),(0,h.jsx)(`p`,{className:`text-ink3`,children:`These are the real Settings controls. The tutorial never reads your key. Skip any step you have already handled.`})]});case`audio-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The voice provider turns the finished article into audio. Choose`,` `,(0,h.jsx)(`strong`,{children:`ElevenLabs`}),`, `,(0,h.jsx)(`strong`,{children:`OpenAI`}),`, or `,(0,h.jsx)(`strong`,{children:`Cartesia`}),`; you do not need all three.`]}),(0,h.jsxs)(`p`,{children:[`Create a key in your provider’s account, enable the API access or credits it requires, then paste the key into its row and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(SO,{href:`https://elevenlabs.io/app/developers/api-keys`,children:`ElevenLabs keys`}),` `,`· `,(0,h.jsx)(SO,{href:`https://platform.openai.com/api-keys`,children:`OpenAI keys`}),` ·`,` `,(0,h.jsx)(SO,{href:`https://play.cartesia.ai/keys`,children:`Cartesia keys`})]}),(0,h.jsx)(`p`,{children:`Next, you’ll add the exact voice that this provider should use. Skip voice setup if you plan to provide your own narration or turn Audio Off.`})]});case`image-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose one image provider, create a key in its dashboard, paste it into the matching row, and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(SO,{href:`https://fal.ai/dashboard/keys`,children:`fal.ai`}),` ·`,` `,(0,h.jsx)(SO,{href:`https://replicate.com/account/api-tokens`,children:`Replicate`}),` ·`,` `,(0,h.jsx)(SO,{href:`https://aistudio.google.com/apikey`,children:`Google AI Studio`}),` ·`,` `,(0,h.jsx)(SO,{href:`https://platform.openai.com/api-keys`,children:`OpenAI`})]}),(0,h.jsxs)(`p`,{children:[`A saved key is not a billing check. The selected image model needs available quota. If Google reports `,(0,h.jsx)(`strong`,{children:`limit: 0`}),`, check the key’s project, billing and image-model quota before retrying.`]}),(0,h.jsx)(`p`,{children:`OpenAI’s voice and image rows are saved separately, even when you use the same API key. Skip this step if you plan to provide your own images or turn Images and Thumbnail Off.`})]});case`voice`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Voice name`}),` you will recognize, such as “Travel narrator.”`]}),(0,h.jsxs)(`li`,{children:[`Select the `,(0,h.jsx)(`strong`,{children:`Provider`}),` whose voice key you saved.`]}),(0,h.jsxs)(`li`,{children:[`Copy the exact `,(0,h.jsx)(`strong`,{children:`Voice ID`}),` from that provider’s voice library or documentation.`]}),(0,h.jsxs)(`li`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Add voice`}),`.`]})]}),(0,h.jsx)(`p`,{children:`The name is your label; the ID tells the provider which voice to use. Slopify checks the ID with the provider when narration runs. A voice is only required when Audio is set to Generate.`})]})}}var TO=`Write a 150-word narration about {{topic}} for {{audience}}. Open with an interesting fact, explain three highlights, and end with one memorable takeaway. Use natural spoken English. Return only the narration, without headings or stage directions.`,EO=`A cinematic editorial photograph of {{topic}}, with natural light, a clear focal point, rich detail, and no text or logos. Compose it for a travel video.`;function DO({step:e,output:t=`video`}){switch(e){case`text-key`:case`audio-key`:case`image-key`:case`voice`:return(0,h.jsx)(wO,{step:e});case`article-name`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`A prompt is a reusable set of instructions. This one will write the narration for each video.`}),(0,h.jsxs)(`p`,{children:[`Give it a recognizable name, such as `,(0,h.jsx)(`strong`,{children:`Short travel narration`}),`. This is the prompt’s library name, not your video’s title.`]}),(0,h.jsx)(`p`,{children:`The next steps will add its instructions and reusable keywords.`})]});case`article-body`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Tell the model what to write, who it is for, the length, and the style. Put anything you want to change between runs inside double braces.`}),(0,h.jsx)(CO,{text:TO}),(0,h.jsxs)(`p`,{children:[`Paste or write the instructions in `,(0,h.jsx)(`strong`,{children:`Body`}),`. `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` `,`and `,(0,h.jsx)(`strong`,{children:`{{audience}}`}),` will become fields on Play.`]})]});case`article-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`This panel detects your keywords as you type. With the example, it should list`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`{{topic}}`}),` is a field name, not the value. You will enter “Albania” on Play later. Repeated names use the same value; names are case-sensitive, so`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`Topic`}),` are different.`]}),(0,h.jsxs)(`p`,{children:[`There are no automatic keywords: `,(0,h.jsx)(`strong`,{children:`{{title}}`}),` would also ask you for a value. Fix any keyword warnings in Body before saving.`]})]});case`article-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press the highlighted `,(0,h.jsx)(`strong`,{children:`Save`}),` button in the editor. The prompt will appear in your Article library.`]}),(0,h.jsx)(`p`,{children:`The tour continues when the save succeeds and the editor returns to the prompt list. If a name is already taken, go Back and choose another.`})]});case`image-prompt`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Keep `,(0,h.jsx)(`strong`,{children:`Kind`}),` on `,(0,h.jsx)(`strong`,{children:`Image`}),`. Name this prompt`,` `,(0,h.jsx)(`strong`,{children:`Travel imagery`}),`, then enter this example or your own visual instructions.`]}),(0,h.jsx)(CO,{text:EO}),(0,h.jsxs)(`p`,{children:[`Using `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` in both prompts creates one shared field on Play. Image prompts describe the picture directly; they do not automatically receive your article.`]})]});case`image-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Save`}),` to add this to your Image library. Next you will combine both prompts on Play.`]}),(0,h.jsx)(`p`,{children:`You can create more prompts later for different subjects, styles, lengths, or languages.`})]});case`play-article`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Play is where you configure one project. Leave `,(0,h.jsx)(`strong`,{children:`Article`}),` on`,` `,(0,h.jsx)(`strong`,{children:`Generate`}),`, then select the article prompt you saved.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Provide`}),` is for an article you already have. For this first run, use Generate and keep the script short. Article is required; every other stage can be Off.`]}),(0,h.jsx)(`p`,{children:`Research starts Off. You can turn it on in a later run for web-grounded notes that are automatically passed to the article writer.`})]});case`play-audio`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Audio`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Pick your voice`,` `,(0,h.jsx)(`strong`,{children:`TTS`}),` provider, a `,(0,h.jsx)(`strong`,{children:`TTS model`}),`, then the saved`,` `,(0,h.jsx)(`strong`,{children:`Voice`}),`.`]}),(0,h.jsxs)(`p`,{children:[`Keep chunking on `,(0,h.jsx)(`strong`,{children:`Whole`}),` for the short example: the narration is sent as one request. Other chunking modes split longer text into pieces.`]}),(0,h.jsx)(`p`,{children:`Use Provide to upload existing narration, including any intro and outro in that file, or Off to skip narration. Video can still run silently, with each image shown for 5 seconds.`})]});case`play-images`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Images`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Choose the image`,` `,(0,h.jsx)(`strong`,{children:`Provider`}),` and `,(0,h.jsx)(`strong`,{children:`Model`}),`, select your image prompt, and set`,` `,(0,h.jsx)(`strong`,{children:`Number`}),` to 2 for a small first run.`]}),(0,h.jsx)(`p`,{children:`Number means separate images made from that same prompt. It does not make one scene per article paragraph. Add more image prompts when you want different scenes.`}),(0,h.jsx)(`p`,{children:`Use Provide for your own images or Off to skip them. Turning Images Off also turns Video Off. Thumbnail remains independent; keep it Off for this first run.`})]});case`play-video`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Generate`}),` for an MP4 slideshow. It needs generated or provided images. With Audio Off, the video is silent and each image lasts 5 seconds.`]}),(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Off`}),` to skip video. If Audio is active, Slopify exports one combined `,(0,h.jsx)(`strong`,{children:`WAV`}),` with the intro, body, outro and configured gaps.`]}),(0,h.jsx)(`p`,{children:`If both Audio and Video are Off, download the article and any other enabled outputs individually.`})]});case`play-subtitles`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Subtitles are optional and start `,(0,h.jsx)(`strong`,{children:`Off`}),`. Choose`,` `,(0,h.jsx)(`strong`,{children:`Subtitle files`}),` for SRT and VTT downloads, or`,` `,(0,h.jsx)(`strong`,{children:`Burn into video + files`}),` to keep captions visible in an MP4.`]}),(0,h.jsxs)(`p`,{children:[`English captions are timed locally from your narration with no paid API. First use downloads an approximately `,(0,h.jsx)(`strong`,{children:`95 MB`}),` speech model. Audio must be active; WAV exports support separate subtitle files.`]}),(0,h.jsx)(`p`,{children:`Pick a font or upload a TTF/OTF file, then adjust its size in the preview. Styling applies to burned captions. You can also add or change subtitles on a completed project later without regenerating its narration.`})]});case`play-options`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Video title`}),`, such as “A quick trip to Albania.” Choose`,` `,(0,h.jsx)(`strong`,{children:`16:9`}),` for landscape or `,(0,h.jsx)(`strong`,{children:`9:16`}),` for portrait.`]}),(0,h.jsxs)(`p`,{children:[`Select the text `,(0,h.jsx)(`strong`,{children:`LLM`}),` and `,(0,h.jsx)(`strong`,{children:`Model`}),`. The model list loads for your provider. Use `,(0,h.jsx)(`strong`,{children:`Refresh`}),` for updated choices or`,` `,(0,h.jsx)(`strong`,{children:`Custom ID`}),`to enter an exact model ID when supported.`]}),(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Intro`}),` and `,(0,h.jsx)(`strong`,{children:`Outro`}),` Off for this first run. They are available only when Audio is Generate. The LLM controls appear only when an enabled stage needs text generation.`]})]});case`play-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The prompts you picked created these fields. For the examples, enter`,` `,(0,h.jsx)(`strong`,{children:`Albania`}),` for `,(0,h.jsx)(`strong`,{children:`topic`}),` and`,` `,(0,h.jsx)(`strong`,{children:`first-time travelers`}),` for `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[`A field under `,(0,h.jsx)(`strong`,{children:`Common`}),` feeds both the article and images. Changing it changes both prompts for this run.`]}),(0,h.jsx)(`p`,{children:`Fill every visible field. Each value must fit on one line and be no more than 200 characters. Your saved prompt keeps its braces so you can reuse it next time.`})]});case`play-start`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Check the hint above PLAY. If anything is missing, use Back to fix the highlighted section.`}),(0,h.jsxs)(`p`,{children:[`When ready, press the real `,(0,h.jsx)(`strong`,{children:`PLAY`}),` button. This creates a project and sends generation requests to your chosen providers, which may charge your account.`]}),(0,h.jsx)(`p`,{children:`The tour will follow you to the project. You can also finish the tutorial without generating anything.`})]});case`project`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Overall progress stays above the workspace. Select a stage from `,(0,h.jsx)(`strong`,{children:`Stages`}),` `,`to see its results or live writing. Press `,(0,h.jsx)(`strong`,{children:`Pause`}),` to stop active requests safely and keep finished work.`]}),(0,h.jsxs)(`p`,{children:[`While paused or failed, open `,(0,h.jsx)(`strong`,{children:`Run settings`}),` to change providers, models or voice. Press `,(0,h.jsx)(`strong`,{children:`Save providers`}),`, then `,(0,h.jsx)(`strong`,{children:`Resume`}),` `,`separately. Changing TTS choices restarts unfinished narration to avoid mixing voices; completed outputs stay unchanged.`]}),(0,h.jsxs)(`p`,{children:[`Select a failed stage and open `,(0,h.jsx)(`strong`,{children:`Error details`}),` to read the provider’s message. `,(0,h.jsx)(`strong`,{children:`Retry stage`}),` keeps completed outputs. Editing or rerunning earlier work updates only the enabled dependent outputs.`]})]});case`download`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[t===`audio`?(0,h.jsxs)(h.Fragment,{children:[`When Audio export finishes, press `,(0,h.jsx)(`strong`,{children:`Download .wav`}),` for the combined narration.`]}):t===`article`?(0,h.jsxs)(h.Fragment,{children:[`Use `,(0,h.jsx)(`strong`,{children:`Download`}),` here to save the article. Audio and Video are Off for this project.`]}):(0,h.jsxs)(h.Fragment,{children:[`When Video finishes, press `,(0,h.jsx)(`strong`,{children:`Download .mp4`}),`.`]}),` `,`The completed project stays in `,(0,h.jsx)(`strong`,{children:`Projects`}),` so you can return to it.`]}),(0,h.jsxs)(`p`,{children:[`Select Article, Audio or Images in `,(0,h.jsx)(`strong`,{children:`Stages`}),` to download their outputs.`,` `,(0,h.jsx)(`strong`,{children:`Download all`}),` under Images gives an image ZIP, not the video.`]}),(0,h.jsxs)(`p`,{children:[`If subtitles are enabled, download the `,(0,h.jsx)(`strong`,{children:`.srt`}),` or `,(0,h.jsx)(`strong`,{children:`.vtt`}),` `,`files beside the final export. File-mode captions are also available in the video player.`]}),(0,h.jsxs)(`p`,{children:[`You have reached the end. Open `,(0,h.jsx)(`strong`,{children:`Tutorial`}),` in the navigation anytime to walk through these steps again.`]})]})}}function OO(e){return e.readiness.kind===`cli`?e.readiness.installed:e.readiness.hasKey}function kO({session:e,progress:t,update:n}){let{api:r}=B(),i=Hi(),a=ka(),o=R(ay(r)),s=R(sy(r)),c=R(cy(r)),l=R({...iy(r,e.projectId??``),enabled:e.projectId!==void 0}),u=(0,m.useRef)(null),d=UD[e.step],f=o.data?.seen===!0;if((0,m.useEffect)(()=>{if(f&&d&&u.current!==e.step){if(u.current=e.step,d.page===`settings`&&a.pathname!==`/settings`&&i({to:`/settings`}),d.page===`article`||d.page===`image`){let t=d.page===`article`?e.articleId:e.imageId,n=a.pathname===`/prompts/new`&&a.searchStr.includes(`kind=${d.page}`);t&&a.pathname!==`/prompts/${t}`?i({to:`/prompts/$promptId`,params:{promptId:t}}):!t&&!n&&i({to:`/prompts/new`,search:{kind:d.page}})}d.page===`play`&&a.pathname!==`/play`&&i({to:`/play`}),d.page===`project`&&e.projectId&&a.pathname!==`/projects/${e.projectId}`&&i({to:`/projects/$projectId`,params:{projectId:e.projectId}})}},[f,d,e.step,e.articleId,e.imageId,e.projectId,a.pathname,a.searchStr,i]),(0,m.useEffect)(()=>{a.pathname===`/prompts`&&(d?.id===`image-prompt`&&e.imageId?n(e=>({...e,step:UD.findIndex(e=>e.id===`play-article`)})):(d?.id===`article-save`&&e.articleId||d?.id===`image-save`&&e.imageId)&&n(e=>({...e,step:e.step+1})))},[a.pathname,d?.id,e.articleId,e.imageId,n]),!f||!d)return null;let p=s.data?.providers??[],g=e=>p.some(t=>t.family===e&&OO(t)),_=(c.data?.voices??[]).some(e=>p.some(t=>t.id===e.provider&&OO(t))),v={"text-key":g(`llm`),"audio-key":g(`tts`),"image-key":g(`image`),voice:_,"article-name":t.promptIsArticle===!0&&t.promptNamed===!0,"article-body":t.promptIsArticle===!0&&t.promptBodyReady===!0&&t.promptHasKeywords===!0,"article-keywords":t.promptHasKeywords===!0,"article-save":!1,"image-prompt":t.promptIsImage===!0&&t.promptSaveReady===!0&&t.promptHasKeywords===!0,"image-save":!1,"play-article":t.playArticleReady===!0,"play-audio":t.playAudioReady===!0,"play-images":t.playImagesReady===!0,"play-video":t.playVideoReady===!0,"play-subtitles":t.playSubtitlesReady===!0,"play-options":t.playOptionsReady===!0,"play-keywords":t.playKeywordsReady===!0,"play-start":!1},y=()=>n(e=>({...e,active:!1})),b=()=>{e.step===UD.length-1||d.id===`play-start`?y():n(e=>({...e,step:e.step+1}))},x=l.data?KD(l.data.project.config):`video`,S=d.id===`download`&&x===`article`?`project-article`:d.id===`play-keywords`&&t.playHasKeywords===!1?`play-options`:d.target,C=d.id===`article-save`||d.id===`image-save`,w=(d.page===`article`||d.page===`image`)&&t.promptSaving===!0;return(0,h.jsxs)(xO,{stepId:d.id,target:`[data-tour="${S}"]`,title:d.title,progress:`${e.step+1} of ${UD.length} · First project`,onClose:y,...e.step===0||d.id===`project`||w?{}:{onBack:()=>n(e=>({...e,step:e.step-1}))},onNext:b,nextDisabled:w||v[d.id]===!1,nextLabel:C?`Use Save in the editor`:d.id===`play-start`?`Use PLAY on the page`:d.id===`download`?`Finish tutorial`:`Next`,...w?{}:{onSkip:b},skipLabel:d.id===`play-start`?`Finish without generating`:C?`Skip without saving`:`Skip this step`,children:[(0,h.jsx)(DO,{step:d.id,output:x}),s.error||c.error?(0,h.jsx)(`p`,{className:`text-red`,children:s.error?.message??c.error?.message}):null]})}var AO=(0,m.createContext)(void 0);function jO({children:e}){let[t,n]=(0,m.useState)({active:!1,step:0}),[r,i]=(0,m.useState)({}),a=(0,m.useCallback)(()=>{n({active:!0,step:0})},[]),o=(0,m.useCallback)(e=>{i(t=>Object.entries(e).every(([e,n])=>t[e]===n)?t:{...t,...e})},[]),s=(0,m.useCallback)(e=>{i(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!e.includes(t))))},[]),c=(0,m.useCallback)(e=>{n(t=>WD(t,e))},[]),l=UD[t.step]?.id,u=t.active&&(l===`project`||l===`download`)?l:void 0,d=(0,m.useMemo)(()=>({active:t.active,projectId:t.projectId,projectStep:u,start:a,report:o,clear:s,event:c}),[t.active,t.projectId,u,a,o,s,c]);return(0,h.jsxs)(AO.Provider,{value:d,children:[e,t.active?(0,h.jsx)(kO,{session:t,progress:r,update:n}):null]})}function MO(){return(0,m.useContext)(AO)}function NO(e){let t=(0,m.useContext)(AO),n=t?.report,r=t?.clear,i=(0,m.useRef)(e);i.current=e,(0,m.useEffect)(()=>{n?.(e)},[n,e]),(0,m.useEffect)(()=>()=>{r?.(Object.keys(i.current))},[r])}function PO(){let e=(0,m.useContext)(AO);return(0,m.useCallback)(t=>{e?.event(t)},[e?.event])}function FO(e){let t=(0,m.useContext)(AO);return t?.projectId===e?t.projectStep:void 0}var IO=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),LO=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),RO=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),zO=e=>{let t=RO(e);return t.charAt(0).toUpperCase()+t.slice(1)},BO={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},VO=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},HO=(0,m.createContext)({}),UO=()=>(0,m.useContext)(HO),WO=(0,m.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=UO()??{},h=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,m.createElement)(`svg`,{ref:c,...BO,width:t??l??BO.width,height:t??l??BO.height,stroke:e??f,strokeWidth:h,className:IO(`lucide`,p,i),...!a&&!VO(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,m.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),GO=(e,t)=>{let n=(0,m.forwardRef)(({className:n,...r},i)=>(0,m.createElement)(WO,{ref:i,iconNode:t,className:IO(`lucide-${LO(zO(e))}`,`lucide-${e}`,n),...r}));return n.displayName=zO(e),n},KO=GO(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),qO=GO(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),JO=GO(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),YO=GO(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),XO=GO(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),ZO=GO(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),QO=GO(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),$O=GO(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ek=GO(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),tk=GO(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),nk=GO(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),rk=GO(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);function ik(){let e=MO();return e?(0,h.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,onClick:e.start,disabled:e.active,"aria-label":`Start interactive tutorial`,title:`Start interactive tutorial`,children:[(0,h.jsx)(ZO,{className:`size-4`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`sr-only min-[1280px]:not-sr-only`,children:`Tutorial`})]}):null}function ak(){let e=MO();return!e||e.active?null:(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4 rounded-panel border border-line bg-panel px-4 py-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`font-semibold`,children:`Make your first video`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`An interactive walkthrough of API keys, reusable prompts, keywords, and Play. Each step highlights the real controls you will use.`})]}),(0,h.jsx)(J,{variant:`accent`,onClick:e.start,children:`Start tutorial`})]})}function ok(){let[e,t]=(0,m.useState)(20);return(0,m.useEffect)(()=>{let e=0,n=()=>{let e=document.getElementById(`app-footer`)?.getBoundingClientRect();t(e!==void 0&&e.bottom>0?Math.max(20,window.innerHeight-e.top+12):20)},r=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(n)},i=new ResizeObserver(r);return i.observe(document.body),window.addEventListener(`scroll`,r,!0),window.addEventListener(`resize`,r),n(),()=>{cancelAnimationFrame(e),i.disconnect(),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`resize`,r)}},[]),e}var sk=[`app-update`],ck=9e5,lk=2e3;async function uk(e,t=!1,n){let r=AbortSignal.timeout(2e4);return Za(await e.fetch(`${e.origin}/api/update${t?`?refresh=1`:``}`,{signal:n===void 0?r:AbortSignal.any([n,r]),cache:`no-store`}))}async function dk(e){return Za(await e.fetch(`${e.origin}/api/update`,{method:`POST`,signal:AbortSignal.timeout(2e4)}))}function fk(e){let{api:t}=B(),n=_(),[r,i]=(0,m.useState)(null),a=(0,m.useRef)(!1),o=R({queryKey:sk,queryFn:({signal:e})=>uk(t,!1,e),staleTime:ck,refetchOnWindowFocus:`always`,refetchInterval:e=>r!==null||e.state.data?.status===`checking`||e.state.data?.status===`installing`||e.state.data?.status===`restarting`?lk:ck,retry:!1}),s=tt({mutationFn:()=>uk(t,!0),onMutate:()=>n.cancelQueries({queryKey:sk}),onSuccess:e=>n.setQueryData(sk,e),retry:!1}),c=tt({mutationFn:()=>dk(t),onMutate:()=>n.cancelQueries({queryKey:sk}),onSuccess:e=>{i(e.currentVersion),n.setQueryData(sk,e)},onError:()=>{n.invalidateQueries({queryKey:sk})},retry:!1});(0,m.useEffect)(()=>{if(r===null||o.data===void 0)return;let t=o.data.status===`idle`||o.data.status===`error`;o.data.currentVersion!==r&&t&&!a.current?(a.current=!0,i(null),e()):t&&i(null)},[r,e,o.data]);let l=r!==null||o.data?.status===`installing`||o.data?.status===`restarting`,u=c.error?.message??s.error?.message??(l?void 0:o.error?.message??o.data?.error);return{info:o.data,updating:l,checking:o.isFetching||s.isPending||o.data?.status===`checking`,installing:c.isPending,reconnecting:l&&o.isError,error:u,refresh:()=>{c.reset(),s.mutate()},install:()=>{s.reset(),c.mutate()}}}function pk({reload:e}){let t=fk(e),n=ok(),{info:r,updating:i,installing:a,reconnecting:o,checking:s,error:c}=t,l=i||a,u=r?.blockedReason??(r?.busy?`Pause running projects before updating.`:void 0),d=`Slopify updates: ${r?r.available?`Your version: ${r.currentVersion} · Newest: ${r.latestVersion}`:`Slopify ${r.currentVersion}`:`Slopify`}. ${o?`Reconnecting after update…`:l?`Updating…`:s?`Checking for updates…`:c??u??(r?.available?`Click to download and install the update.`:`Click to check for updates.`)}`;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d,title:d,disabled:l||s,style:{bottom:n},onClick:()=>{r?.available&&r.canUpdate&&!u?t.install():t.refresh()},className:W(`fixed right-5 z-30 flex size-10 items-center justify-center rounded-full bg-transparent text-ink2 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,c&&`text-amber`),children:[(0,h.jsx)(nk,{"aria-hidden":`true`,size:20,className:W((l||s)&&`animate-spin motion-reduce:animate-none`)}),r?.available&&!l?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1 right-1 size-1.5 rounded-full bg-lamp-run`}):null]}),(0,h.jsx)(`span`,{className:`sr-only`,role:c?`alert`:`status`,children:d})]})}var mk=[{to:`/`,label:`Projects`,exact:!0},{to:`/play`,label:`Play`,exact:!0},{to:`/prompts`,label:`Prompts`,exact:!1},{to:`/entries`,label:`Intros & Outros`,exact:!1},{to:`/settings`,label:`Settings`,exact:!0},{to:`/usage`,label:`Usage`,exact:!0}],hk=[{href:`https://github.com/GentBajko/slopify`,label:`GitHub`,glyph:`github`,tone:``},{href:`https://www.patreon.com/cw/GentBajko`,label:`Patreon`,glyph:`patreon`,tone:`text-lamp-run`},{href:`https://buymeacoffee.com/gentbajko`,label:`Buy Me a Coffee`,glyph:`coffee`,tone:`text-lamp-run`}];function gk(){return(0,h.jsx)(LD,{children:(0,h.jsx)(jO,{children:(0,h.jsx)(_k,{})})})}function _k(){let{api:e,openEvents:t}=B(),n=_(),[r,i]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let r=HD(()=>{n.invalidateQueries({queryKey:ny.projects})},200),a=Sy(t,Ao(e,`global`),{tally:i,stagingChanged:()=>{n.invalidateQueries({queryKey:ny.staging})},refetch:e=>{e===void 0?n.invalidateQueries():r.ask()}});return()=>{a(),r.stop()}},[e,t,n]),(0,h.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,h.jsxs)(`header`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 border-b border-line bg-panel px-4 min-[1280px]:flex min-[1280px]:h-14 min-[1280px]:gap-7 min-[1280px]:px-7`,children:[(0,h.jsxs)(ia,{to:`/`,className:`flex h-14 shrink-0 items-center gap-[10px] text-wordmark font-extrabold tracking-[-0.02em] text-ink`,children:[(0,h.jsx)(Ec,{className:`relative top-[3px] text-lamp-run`}),`Slopify`]}),(0,h.jsx)(`nav`,{"aria-label":`Main navigation`,className:`col-span-2 row-start-2 flex min-w-0 items-center gap-6 overflow-x-auto [scrollbar-width:thin] min-[1280px]:flex-1 min-[1280px]:gap-7`,children:mk.map(e=>(0,h.jsx)(ia,{to:e.to,activeOptions:{exact:e.exact},className:`shrink-0 whitespace-nowrap border-b-2 border-transparent py-3 text-ink2 hover:text-ink focus-visible:outline-offset-[-3px] min-[1280px]:py-[18px]`,activeProps:{className:`!border-lamp-run !text-ink`},children:e.label},e.to))}),(0,h.jsxs)(`div`,{className:`col-start-2 row-start-1 ml-auto flex items-center gap-1 sm:gap-4 min-[1280px]:gap-7 [&_button]:min-h-8 [&_button]:min-w-8`,children:[(0,h.jsx)(ik,{}),r===0?null:(0,h.jsxs)(ia,{to:`/`,"aria-label":`${String(r)} running`,title:`${String(r)} running`,className:`engraved flex min-h-8 items-center whitespace-nowrap text-ink3 hover:text-ink2`,children:[String(r),(0,h.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:`\xA0running`})]}),hk.map(e=>(0,h.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,title:e.label,className:`flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,children:[(0,h.jsx)(Oc,{name:e.glyph,className:e.tone}),(0,h.jsx)(`span`,{className:`sr-only min-[1100px]:not-sr-only`,children:e.label})]},e.href))]})]}),(0,h.jsx)(`main`,{className:`min-w-0 flex-1 px-4 py-6 pb-20 sm:px-7`,children:(0,h.jsx)(ya,{})}),(0,h.jsx)(`footer`,{id:`app-footer`,className:`flex items-center gap-[18px] border-t border-line px-4 py-[14px] text-label sm:px-7 text-ink3`,children:(0,h.jsx)(`span`,{children:`Free. Your keys, your machine.`})}),(0,h.jsx)(pk,{reload:()=>window.location.reload()}),(0,h.jsx)(_y,{}),(0,h.jsx)(my,{}),(0,h.jsx)(vy,{reload:()=>{window.location.reload()}})]})}var vk=[`text`,`llm`],yk=[`article`,`image`,`thumbnail`],bk=[`intro`,`outro`],xk=1e5,Sk=bk.map(e=>({value:e,label:wk(e)})),Ck=vk.map(e=>({value:e,label:Tk(e)}));function wk(e){switch(e){case`intro`:return`Intro`;case`outro`:return`Outro`}}function Tk(e){switch(e){case`text`:return`Text`;case`llm`:return`LLM`}}function Ek(e){switch(e){case`text`:return`Text is narrated as written.`;case`llm`:return`LLM is an instruction whose answer is narrated.`}}function Dk(e){switch(e){case`text`:return`No slots. This text is narrated as written.`;case`llm`:return`No slots. This instruction runs as written.`}}function Ok(e){return bk.find(t=>t===e)??`intro`}var kk=yk.map(e=>({value:e,label:Ak(e)}));function Ak(e){switch(e){case`article`:return`Article`;case`image`:return`Image`;case`thumbnail`:return`Thumbnail`}}function jk(e){return yk.find(t=>t===e)??`article`}function Mk({open:e,title:t,consequence:n,verb:r,dismiss:i=`Cancel`,pending:a=!1,onConfirm:o,onCancel:s}){return(0,h.jsx)(Xv,{open:e,onOpenChange:e=>{e||s()},children:(0,h.jsxs)($v,{children:[(0,h.jsx)(ey,{children:t}),(0,h.jsx)(ty,{children:n}),(0,h.jsxs)(`div`,{className:`flex justify-end gap-[10px]`,children:[(0,h.jsx)(J,{autoFocus:!0,onClick:s,children:i}),(0,h.jsx)(J,{variant:`danger`,disabled:a,onClick:o,children:r})]})]})})}function Nk({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:W(`overflow-hidden rounded-panel border border-line bg-panel`,t),children:e})}function Pk({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:W(`relative flex items-center gap-[14px] border-b border-line px-4 py-[14px] last:border-b-0`,t),children:e})}function Fk({current:e,total:t}){let n=t<=0?0:Math.min(1,Math.max(0,e/t));return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-meter`,className:`absolute inset-x-0 bottom-0 h-[2px] bg-lamp-run transition-[width] duration-[250ms] ease-out motion-reduce:transition-none`,style:{width:`${String(Math.round(n*100))}%`}})}function Ik({name:e,className:t}){return(0,h.jsx)(`span`,{"data-slot-chip":e,className:W(`engraved animate-tick-in rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] text-ink2 motion-reduce:animate-none`,t),children:e})}var Lk=p_,Rk=m_;function zk({className:e,sideOffset:t=4,align:n=`end`,...r}){return(0,h.jsx)(h_,{children:(0,h.jsx)(g_,{"data-slot":`dropdown-menu-content`,sideOffset:t,align:n,className:W(`z-50 min-w-[160px] overflow-hidden rounded-panel border border-line bg-panel p-1`,`shadow-[0_8px_24px_var(--color-shadow)]`,e),...r})})}function Bk({className:e,...t}){return(0,h.jsx)(__,{"data-slot":`dropdown-menu-item`,className:W(`flex cursor-default items-center rounded-control px-[10px] py-[5px] text-small text-ink`,`outline-hidden select-none focus:bg-panel2 data-highlighted:bg-panel2`,e),...t})}function Vk({className:e,...t}){return(0,h.jsx)(Rv,{"data-slot":`toggle-group`,className:W(`inline-flex w-fit items-stretch overflow-hidden rounded-control border border-line2`,e),...t})}function Hk({className:e,...t}){return(0,h.jsx)(qv,{"data-slot":`toggle-group-item`,className:W(`min-h-8 shrink-0 border-r border-line2 px-[10px] py-[5px] text-label text-ink2 last:border-r-0`,`transition-colors duration-150 ease-out motion-reduce:transition-none hover:bg-panel2 hover:text-ink`,`data-[state=on]:bg-panel2 data-[state=on]:text-ink data-[state=on]:shadow-[inset_0_-2px_0_var(--color-lamp-run)]`,`disabled:cursor-not-allowed disabled:opacity-40`,e),...t})}var Uk=`grid grid-cols-[minmax(0,1fr)_auto_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_70px_minmax(0,1fr)_auto_32px]`,Wk=`col-span-4 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1 md:col-start-3 md:row-start-1`;function Gk({category:e,onCategory:t}){let{api:n}=B(),r=_(),i=R(uy(n)),[a,o]=(0,m.useState)(void 0),s=tt({mutationFn:e=>ko(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:ny.entries})}}),c=i.data?.entries.filter(t=>t.category===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Intros & Outros`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(Vk,{type:`single`,value:e,"aria-label":`Entry category`,onValueChange:e=>{let n=Sk.find(t=>t.value===e);n!==void 0&&t(n.value)},children:Sk.map(e=>(0,h.jsx)(Hk,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(J,{asChild:!0,children:(0,h.jsxs)(ia,{to:`/entries/new`,search:{category:e},children:[(0,h.jsx)(tk,{"aria-hidden":`true`,className:`size-[14px]`}),`New entry`]})})]}),i.error===null?null:(0,h.jsx)(Nk,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(Yk,{}):null:c.length===0?(0,h.jsx)(qk,{category:e}):(0,h.jsx)(Nk,{children:c.map(e=>(0,h.jsxs)(`div`,{className:Uk,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(Kk,{mode:e.mode}),(0,h.jsx)(`span`,{className:Wk,children:e.slots.map(e=>(0,h.jsx)(Ik,{name:e},e))}),(0,h.jsx)(J,{className:`col-start-3 row-start-1 md:col-start-4`,asChild:!0,children:(0,h.jsx)(ia,{to:`/entries/$entryId`,params:{entryId:e.id},children:`Edit`})}),(0,h.jsx)(Jk,{entry:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(Mk,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function Kk({mode:e}){return(0,h.jsx)(`span`,{"data-entry-mode":e,className:`engraved col-start-2 row-start-1 justify-self-start rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] font-bold text-ink`,children:Tk(e)})}function qk({category:e}){return(0,h.jsx)(Nk,{children:(0,h.jsx)(`p`,{className:`max-w-[75ch] px-4 py-7 text-ink2`,children:`No ${e}s yet. An ${e} is narrated ${e===`intro`?`before`:`after`} the body in the run's voice.`})})}function Jk({entry:e,onDelete:t}){return(0,h.jsxs)(Lk,{children:[(0,h.jsx)(Rk,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-4 row-start-1 size-8 p-0 md:col-start-5`,children:(0,h.jsx)($O,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(zk,{children:[(0,h.jsx)(Bk,{asChild:!0,children:(0,h.jsx)(ia,{to:`/entries/new`,search:{category:e.category,from:e.id},children:`Duplicate`})}),(0,h.jsx)(Bk,{onSelect:t,children:`Delete`})]})]})}function Yk(){return(0,h.jsx)(Nk,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:Uk,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-[18px] w-10 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:Wk,children:(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`})}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-4`})]},e))})}function Xk({slots:e,body:t,lint:n,lintId:r,noSlots:i=`No slots. This prompt runs as written.`}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Detected slots`}),e.length>0?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:e.map(e=>(0,h.jsx)(Ik,{name:e,className:`px-2 py-[3px]`},e))}):t.trim()===``?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Slots appear here as you type {{name}}.`}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:i}),n.length===0?null:(0,h.jsxs)(`div`,{id:r,className:`flex flex-col gap-[6px] border-t border-line pt-3`,children:[(0,h.jsx)(`span`,{className:`engraved text-red`,children:n.length===1?`1 slot error`:`${String(n.length)} slot errors`}),n.map(e=>(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.message},e.message))]})]})}var Zk=2e3;function Qk(e,t){let n=(0,m.useRef)(t);(0,m.useEffect)(()=>{n.current=t}),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{n.current()},Zk);return()=>{clearTimeout(t)}},[e])}function $k(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-done motion-reduce:animate-none`,children:[(0,h.jsx)(KO,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function eA({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px] border-t border-line pt-[14px]`,children:[e===void 0?null:(0,h.jsx)(J,{className:`bg-transparent`,onClick:e,children:`Delete`}),(0,h.jsx)(`span`,{className:`flex-1`}),i?(0,h.jsx)($k,{}):null,t===void 0?null:(0,h.jsx)(`span`,{id:n,className:`text-small text-ink2`,children:t}),a,(0,h.jsx)(J,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,onClick:()=>{c||s()},children:`Save`}),o.map(e=>(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:e},e))]})}var tA=`rounded-panel border border-line bg-panel p-[18px]`;function nA(){return(0,h.jsxs)(`div`,{className:`mx-auto grid max-w-[1440px] grid-cols-[minmax(0,1fr)] gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${tA} flex flex-col gap-[14px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-panel2`})]}),(0,h.jsx)(`div`,{className:`${tA} flex flex-col gap-3`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-panel2`})})]})}function rA({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(Nk,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:e})}),t]})}var iA=`mt-[10px] inline-block text-small text-run-text underline`;function aA({className:e,...t}){return(0,h.jsx)(y_,{"data-slot":`label`,className:W(`engraved block select-none text-ink3`,e),...t})}function oA({label:e,value:t,options:n,describedBy:r,onPick:i}){let a=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(aA,{id:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(Vk,{type:`single`,value:t,"aria-labelledby":a,"aria-describedby":r,onValueChange:e=>{let t=n.find(t=>t.value===e);t!==void 0&&i(t.value)},children:n.map(e=>(0,h.jsx)(Hk,{value:e.value,children:e.label},e.value))})]})}function sA({className:e,...t}){return(0,h.jsx)(`input`,{"data-slot":`input`,className:W(`h-8 w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}function cA({className:e,...t}){return(0,h.jsx)(`textarea`,{"data-slot":`textarea`,className:W(`w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}var lA=`{{`,uA=`}}`;function dA(e){let t=[],n=[],r=e.indexOf(lA);for(;r!==-1;){let i=e.indexOf(`
99
+ `,r+2),a=i===-1?e.length:i,o=e.indexOf(uA,r+2);if(o===-1||o>a){n.push({kind:`unclosed`,at:r}),r=e.indexOf(lA,r+2);continue}let s=e.slice(r+2,o),c=s.trim();s.includes(`{`)||s.includes(`}`)?n.push({kind:`nested`,at:r}):c===``?n.push({kind:`empty`,at:r}):t.includes(c)||t.push(c),r=e.indexOf(lA,o+2)}return{names:t,errors:n}}function fA(e,t){let n=pA(e),r=pA(t),i=[];for(let e of[...n,...r]){if(i.some(t=>t.name===e))continue;let t=n.includes(e),a=r.includes(e);i.push({name:e,group:t&&a?`common`:t?`text`:`image`})}return i}function pA(e){let t=[];for(let n of e)for(let e of dA(n).names)t.includes(e)||t.push(e);return t}function mA(e){return gA(e.name,e.body)}function hA(e){return gA(e.name,e.body)}function gA(e,t){let n=[],r=e.trim();if(r===``?n.push({field:`name`,message:`A name is required.`}):r.length>200&&n.push({field:`name`,message:`A name is at most 200 characters.`}),t.trim()===``)return n.push({field:`body`,message:`A body is required.`}),n;if(t.length>1e5)return n.push({field:`body`,message:`A body is at most ${String(xk)} characters.`}),n;for(let e of dA(t).errors)n.push({field:`body`,message:_A(e,t)});return n}function _A(e,t){let n=vA(t,e.at);switch(e.kind){case`unclosed`:return`The \`{{\` at ${n} is never closed.`;case`empty`:return`The slot at ${n} has no name.`;case`nested`:return`The slot at ${n} holds a brace; slots do not nest.`}}function vA(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`
100
100
  `),i=n.split(`
101
- `).length,a=t-r;return`line ${String(i)}, column ${String(a)}`}function qA(e,t){return[...`kind`in e?HA(e):UA(e),...t]}function JA(e){return e[0]?.message}function YA(e){return e.filter(e=>e.field===`body`)}function XA(e){return e.filter(e=>e.field===`name`)}function ZA(e){return zA(e).names}function QA(e){let t=[],n=0;for(let r of zA(e).errors){if(r.at<n)continue;r.at>n&&t.push({start:n,text:e.slice(n,r.at),marked:!1});let i=Math.min(r.at+2,e.length);t.push({start:r.at,text:e.slice(r.at,i),marked:!0}),n=i}return n<e.length&&t.push({start:n,text:e.slice(n),marked:!1}),t}var $A=`px-3 py-[10px] font-sans text-body leading-[1.5] break-words [scrollbar-gutter:stable]`;function ej({id:e,value:t,invalid:n,describedBy:r,onChange:i}){let a=(0,m.useRef)(null);return(0,h.jsxs)(`div`,{className:`relative max-w-[75ch]`,children:[(0,h.jsxs)(`div`,{ref:a,"aria-hidden":`true`,"data-slot":`lint-overlay`,className:W($A,`pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap`,`rounded-control border border-transparent bg-panel2 text-ink`),children:[QA(t).map(e=>(0,h.jsx)(`span`,{"data-lint-mark":e.marked?e.start:void 0,className:e.marked?`text-red underline decoration-red decoration-2 underline-offset-[3px]`:void 0,children:e.text},e.start)),`
102
- `]}),(0,h.jsx)(IA,{id:e,rows:24,value:t,spellCheck:!1,"aria-invalid":n,"aria-describedby":r,className:W($A,`relative block min-h-[520px] resize-y overflow-auto bg-transparent text-transparent caret-ink`),onChange:e=>{i(e.target.value)},onScroll:e=>{let t=a.current;t!==null&&(t.scrollTop=e.currentTarget.scrollTop,t.scrollLeft=e.currentTarget.scrollLeft)}})]})}function tj({entryId:e,category:t,from:n,onLeave:r}){let{api:i}=B(),a=_(),o=R(zy(i)),s=(0,m.useId)(),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),w=o.data?.entries,T=e??n,E=T===void 0?void 0:w?.find(e=>e.id===T),D=E===void 0?{category:t,mode:`text`,name:``,body:``}:{category:E.category,mode:E.mode,name:e===void 0?`${E.name} copy`:E.name,body:E.body},O=p??D,k=tt({mutationFn:t=>Oo(i,t,e),onSuccess:async e=>{if(!e.ok){y(e.fields);return}x(!0),await a.invalidateQueries({queryKey:zy(i).queryKey})}}),A=tt({mutationFn:e=>ko(i,e),onSuccess:async()=>{C(!1),await a.invalidateQueries({queryKey:zy(i).queryKey}),r(O.category)}});EA(b,()=>{r(O.category)});let j=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},M=qA(O,v),N=JA(M),P=ZA(O.body),F=O.body.trim()===``?[]:YA(M),I=O.name.trim()===``?[]:XA(M);return o.error===null?T!==void 0&&w===void 0?(0,h.jsx)(AA,{}):T!==void 0&&E===void 0?(0,h.jsx)(nj,{category:t,children:`That entry is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(ia,{to:`/entries`,search:{category:O.category},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(Sk,{"aria-hidden":`true`,className:`size-[14px]`}),`Intros & Outros`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New entry`:`Edit entry`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${kA} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-[200px] flex-1`,children:[(0,h.jsx)(NA,{htmlFor:s,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(FA,{id:s,value:O.name,"aria-invalid":I.length>0,"aria-describedby":I.length===0?void 0:c,onChange:e=>{j({...O,name:e.target.value},`name`)}}),I.length===0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:I.map(e=>e.message).join(` `)})]}),(0,h.jsx)(PA,{label:`Category`,value:O.category,options:Xk,onPick:e=>{j({...O,category:e},`name`)}}),(0,h.jsx)(PA,{label:`Mode`,value:O.mode,options:Zk,describedBy:l,onPick:e=>{j({...O,mode:e},`mode`)}})]}),(0,h.jsx)(`p`,{id:l,className:`-mt-[6px] text-right text-small text-ink2`,children:eA(O.mode)}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(ej,{id:u,value:O.body,invalid:F.length>0,describedBy:F.length===0?void 0:d,onChange:e=>{j({...O,body:e},`body`)}})]}),(0,h.jsx)(OA,{onDelete:e===void 0?void 0:()=>{C(!0)},blocked:N,blockedId:f,pending:k.isPending,saved:b,cancel:(0,h.jsx)(J,{asChild:!0,children:(0,h.jsx)(ia,{to:`/entries`,search:{category:O.category},children:`Cancel`})}),errors:[k.error,A.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{k.mutate(O)}})]}),(0,h.jsx)(`div`,{className:`${kA} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(wA,{slots:P,body:O.body,lint:F,lintId:d,noSlots:tA(O.mode)})})]}),(0,h.jsx)(oA,{open:S,title:`Delete "${O.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:A.isPending,onConfirm:()=>{e!==void 0&&A.mutate(e)},onCancel:()=>{C(!1)}})]}):(0,h.jsx)(nj,{category:O.category,children:o.error.message})}function nj({category:e,children:t}){return(0,h.jsx)(jA,{back:(0,h.jsx)(ia,{to:`/entries`,search:{category:e},className:MA,children:`Back to Intros & Outros`}),children:t})}function rj(e){let{form:t}=e,n=[],r=[];if(t.sources.article===`generate`&&fj(n,uj(e.prompts,`article`,t.articlePrompt)),t.sources.audio===`generate`&&(fj(n,dj(e.entries,`intro`,t.intro)),fj(n,dj(e.entries,`outro`,t.outro))),t.sources.images===`generate`)for(let n of t.imagePrompts)fj(r,uj(e.prompts,`image`,n.name));return(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)&&fj(r,uj(e.prompts,`thumbnail`,t.thumbnailPrompt)),BA(n,r)}function ij(e){let t=rj(e),n={form:e.form,entries:e.entries,slots:t.map(e=>e.name),silenceGapSeconds:e.silenceGapSeconds},r=sO(n),i=nb({draft:r,staged:oO(e.form.provided),requiredSlots:n.slots}),a=eO(r.subtitles??e.form.subtitles)?i:{ok:!1,fields:[...i.ok?[]:i.fields,{field:`subtitles.fontSize`,message:`Choose a whole subtitle font size from 16 to 120.`}]};return{fields:t,draft:r,result:a,blocker:oj(e.form,a)}}var aj=[`sources`,`provided.research`,`articlePrompt`,`provided.article`,`audio`,`provided.audio`,`imagePrompts`,`images`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`subtitles`,`title`,`intro`,`outro`,`llm`,`values`,`silenceGapSeconds`];function oj(e,t){let n=sj(e);if(n!==void 0)return n;if(t.ok)return;let r=[...t.fields].sort((e,t)=>cj(e.field)-cj(t.field))[0];return r===void 0?void 0:{field:r.field,hint:lj(e,r)}}function sj(e){let{sources:t,provided:n}=e,r=[];if(t.audio===`provide`&&n.audio!==void 0&&r.push(n.audio),t.images===`provide`&&r.push(...n.images),t.thumbnail===`provide`&&n.thumbnail!==void 0&&r.push(n.thumbnail),r.some(e=>e.error!==void 0))return{field:`provided`,hint:`Remove the upload that failed to play`};if(r.some(e=>e.file===void 0))return{field:`provided`,hint:`Wait for the uploads to finish to play`}}function cj(e){let t=aj.length;for(let[n,r]of aj.entries())(e===r||e.startsWith(`${r}.`))&&n<t&&(t=n);return t}function lj(e,t){if(t.field.startsWith(`values.`))return`Fill ${t.field.slice(7)} to play`;if(t.field.startsWith(`imagePrompts.`))return t.field.endsWith(`.number`)?`Set a Number between 1 and 20 to play`:`Pick an image prompt to play`;switch(t.field){case`title`:return e.title.trim()===``?`Name the video to play`:`Shorten the title to 200 characters to play`;case`imagePrompts`:return e.imagePrompts.length===0?`Tick an image prompt to play`:`Lower the Numbers to play: a run makes at most 60 images`;case`llm`:return`Pick an LLM provider and model to play`;case`articlePrompt`:return`Pick an article prompt to play`;case`audio`:return`Pick a narration provider to play`;case`audio.voice`:return`Pick a voice to play`;case`images`:return`Pick an image provider and model to play`;case`thumbnailPrompt`:return`Pick a thumbnail prompt to play`;case`provided.research`:return`Paste the research notes to play`;case`provided.article`:return`Paste the article to play`;case`provided.audio`:return`Attach the narration audio to play`;case`provided.images`:return e.provided.images.length>60?`Remove images to play: a run holds at most 60`:`Attach at least one image to play`;case`provided.thumbnail`:return`Attach the thumbnail image to play`;default:return t.message}}function uj(e,t,n){if(n!==``)return e.find(e=>e.kind===t&&e.name===n)?.body}function dj(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.body}function fj(e,t){t!==void 0&&e.push(t)}function pj({value:e,onPick:t}){let n=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`w-full`,children:[(0,h.jsx)(NA,{id:n,className:`mb-2`,children:`Format`}),(0,h.jsx)(hA,{type:`single`,value:e,"aria-labelledby":n,className:`w-full`,onValueChange:e=>{(e===`16:9`||e===`9:16`)&&t(e)},children:[`16:9`,`9:16`].map(e=>(0,h.jsxs)(gA,{value:e,"aria-label":e,className:`flex h-24 min-w-0 flex-1 flex-col items-center justify-center gap-2 py-2`,children:[(0,h.jsx)(`span`,{className:`flex h-12 items-center justify-center`,"aria-hidden":`true`,children:(0,h.jsx)(`span`,{"data-format-shape":e,className:`block rounded-[2px] border-2 border-current`,style:{width:e===`16:9`?64:27,aspectRatio:e===`16:9`?`16 / 9`:`9 / 16`}})}),(0,h.jsx)(`span`,{children:e})]},e))})]})}function mj({fields:e,values:t,problem:n,onChange:r}){if(e.length===0)return null;let i=e.filter(e=>e.group===`common`),a=e.filter(e=>e.group===`text`),o=e.filter(e=>e.group===`image`);return(0,h.jsxs)(`div`,{"data-tour":`play-keywords`,className:`flex min-w-0 flex-col gap-[14px]`,children:[i.length===0?null:(0,h.jsxs)(`div`,{"data-keywords":`common`,className:`mt-[6px]`,children:[(0,h.jsx)(gj,{name:`Common`}),(0,h.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>(0,h.jsx)(_j,{name:e.name,value:t[e.name]??``,problem:n(`values.${e.name}`),onChange:r},e.name))})]}),a.length===0&&o.length===0?null:(0,h.jsxs)(`div`,{"data-keywords":`sides`,className:`mt-[6px] grid grid-cols-[minmax(0,1fr)_1px_minmax(0,1fr)] gap-x-4`,children:[(0,h.jsx)(hj,{group:`text`,name:`Text`,fields:a,values:t,problem:n,onChange:r}),(0,h.jsx)(`div`,{"aria-hidden":`true`,className:`bg-line2`}),(0,h.jsx)(hj,{group:`image`,name:`Image`,fields:o,values:t,problem:n,onChange:r})]})]})}function hj({group:e,name:t,fields:n,values:r,problem:i,onChange:a}){return(0,h.jsxs)(`div`,{"data-keywords":e,className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(gj,{name:t}),n.map(e=>(0,h.jsx)(_j,{name:e.name,value:r[e.name]??``,problem:i(`values.${e.name}`),onChange:a},e.name))]})}function gj({name:e}){return(0,h.jsxs)(`div`,{className:`mt-1 mb-[6px] flex items-center gap-3`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-line2`}),(0,h.jsx)(`h3`,{className:`font-condensed text-label font-bold text-ink uppercase tracking-[0.12em]`,children:e}),(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-line2`})]})}function _j({name:e,value:t,problem:n,onChange:r}){let i=(0,m.useId)(),a=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(NA,{htmlFor:i,className:`mb-[5px]`,children:e}),(0,h.jsx)(FA,{id:i,value:t,maxLength:200,spellCheck:!1,"aria-invalid":n!==void 0,"aria-describedby":n===void 0?void 0:a,onChange:t=>{r(e,t.target.value)}}),n===void 0?null:(0,h.jsx)(`p`,{id:a,className:`mt-1 text-label text-red`,children:n})]})}function vj({className:e,children:t,...n}){return(0,h.jsxs)(`span`,{className:`relative inline-flex min-w-0 items-center`,children:[(0,h.jsx)(`select`,{"data-slot":`picker`,className:W(`h-8 w-full min-w-0 appearance-none rounded-control border border-line2 bg-panel2`,`py-[5px] pr-[26px] pl-[10px] text-small text-ink aria-invalid:border-red`,e),...n,children:t}),(0,h.jsx)(xk,{"aria-hidden":`true`,className:`pointer-events-none absolute right-[8px] size-[14px] text-ink2`})]})}var yj=e=>[`provider-models`,e];async function bj(e,t,n=!1,r){let i=`${e.origin}/api/providers/${encodeURIComponent(t)}/models${n?`?refresh=1`:``}`;return Za(await e.fetch(i,r?{signal:r}:void 0))}function xj(e,t){return et({queryKey:yj(t),queryFn:({signal:n})=>bj(e,t,!1,n),enabled:t!==``,staleTime:3e4,refetchInterval:3e4,retry:!1})}function Sj(e){return e!==``&&e!==`fal`&&e!==`replicate`}function Cj({label:e,problem:t,inline:n=!1,children:r}){let i=(0,m.useId)(),a=(0,m.useId)();return(0,h.jsxs)(`div`,{className:W(n?`flex min-w-0 max-w-full items-center gap-[10px]`:`min-w-0`),children:[(0,h.jsx)(NA,{htmlFor:i,className:n?`shrink-0`:`mb-[5px]`,children:e}),r({id:i,describedBy:t===void 0?void 0:a}),t===void 0?null:(0,h.jsx)(`p`,{id:a,className:W(`text-label text-red`,n?``:`mt-1`),children:t})]})}function wj({label:e,value:t,problem:n,inline:r,placeholder:i,options:a,disabled:o=!1,onPick:s}){return(0,h.jsx)(Cj,{label:e,problem:n,inline:r,children:({id:e,describedBy:c})=>(0,h.jsxs)(vj,{id:e,value:t,disabled:o,"aria-invalid":n!==void 0,"aria-describedby":c,className:r===!0?`w-auto min-w-[120px]`:void 0,onChange:e=>{s(e.target.value)},children:[(0,h.jsx)(`option`,{value:``,children:i}),a.map(e=>(0,h.jsx)(`option`,{value:e.value,disabled:e.disabled===!0,children:e.label},e.value))]})})}function Tj(e,t){return e.filter(e=>e.family===t).map(e=>{let t=Ej(e);return{value:e.id,label:t===void 0?e.displayName:`${e.displayName} · ${t}`,disabled:t!==void 0}})}function Ej(e){let{readiness:t}=e;return t.kind===`cli`?t.installed?void 0:`CLI missing`:t.hasKey?void 0:`Key missing`}function Dj({label:e,family:t,providers:n,value:r,problem:i,inline:a,onPick:o}){return(0,h.jsx)(wj,{label:e,value:r,problem:i,inline:a,placeholder:`Pick a provider`,options:Tj(n,t),onPick:o})}function Oj(e){return(0,h.jsx)(kj,{...e},e.provider)}function kj({label:e,provider:t,value:n,problem:r,inline:i,onPick:a}){let{api:o}=B(),s=_(),c=R(xj(o,t)),[l,u]=(0,m.useState)(!1),d=(0,m.useId)(),f=(0,m.useId)(),p=tt({mutationFn:()=>bj(o,t,!0),onSuccess:e=>s.setQueryData(yj(t),e)}),g=c.data?.models??[],v=c.data?.allowsCustom??Sj(t),y=l&&v,b=c.isFetching||p.isPending,x=p.error?.message??c.error?.message??c.data?.warning,S=n!==``&&!g.some(e=>e.id===n);return(0,h.jsxs)(`div`,{className:`min-w-0 max-w-full`,children:[(0,h.jsx)(Cj,{label:e,problem:r,inline:i,children:({id:e,describedBy:o})=>{let s=[o,x?d:void 0,c.data?.notice?f:void 0].filter(Boolean).join(` `)||void 0;return(0,h.jsx)(`div`,{className:W(`min-w-0 [&>span]:w-full`,i?`max-w-[260px]`:`w-full`),children:y?(0,h.jsx)(FA,{id:e,value:n,spellCheck:!1,placeholder:`Type the model id`,"aria-invalid":r!==void 0,"aria-describedby":s,className:i?`w-[180px] max-w-full`:void 0,onChange:e=>a(e.target.value)}):(0,h.jsxs)(vj,{id:e,value:n,disabled:t===``,"aria-invalid":r!==void 0,"aria-describedby":s,className:i?`w-full min-w-[120px] max-w-[260px]`:void 0,onChange:e=>a(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:t===``?`Pick a provider first`:c.isPending?`Loading models…`:`Pick a model`}),S?(0,h.jsxs)(`option`,{value:n,children:[n,` (saved model)`]}):null,g.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})}}),t===``?null:(0,h.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(0,h.jsxs)(J,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":`Refresh ${e} list`,title:`Refresh models`,disabled:b,onClick:()=>p.mutate(),children:[(0,h.jsx)(Ak,{"aria-hidden":`true`,className:W(`size-3`,b&&`animate-spin motion-reduce:animate-none`)}),`Refresh`]}),v?(0,h.jsx)(J,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":y?`Choose ${e} from list`:`Enter ${e} ID`,onClick:()=>u(!y),children:y?`Use list`:`Custom ID`}):null]}),c.data?.notice?(0,h.jsx)(`p`,{id:f,className:`mt-1 max-w-[360px] text-label text-ink3`,children:c.data.notice}):null,x?(0,h.jsx)(`p`,{id:d,className:`mt-1 max-w-[360px] text-label text-ink3`,role:`status`,children:x}):null]})}function Aj({choice:e,onChange:t}){let{api:n}=B(),r=R(xj(n,e.provider)).data?.models.find(t=>t.id===e.model)?.thinkingModes??[];return!r.length&&!e.thinking?null:(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(wj,{label:`Thinking`,value:e.thinking??`default`,placeholder:`Model default`,problem:e.thinking&&!r.includes(e.thinking)?`Choose a supported thinking level.`:void 0,options:[{value:`default`,label:`Model default`},...r.map(e=>({value:e,label:e===`off`?`Off`:e.charAt(0).toUpperCase()+e.slice(1)}))],onPick:n=>{let i=r.find(e=>e===n);t({...e,thinking:i})}}),r.length&&!r.includes(`off`)?(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink3`,children:`This model does not support turning thinking off.`}):null]})}function jj({children:e,form:t,providers:n,entries:r,fields:i,problem:a,blocker:o,failure:s,pending:c,update:l,onPlay:u}){let d=(0,m.useId)(),f=(0,m.useId)(),p=o!==void 0||c;return(0,h.jsxs)(`aside`,{"data-play-cue":`true`,className:`flex h-fit min-w-0 flex-col gap-[14px] rounded-panel border border-line bg-panel p-[18px] min-[1180px]:sticky min-[1180px]:top-6`,children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Cue sheet`}),(0,h.jsxs)(`div`,{"data-tour":`play-options`,className:`flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{htmlFor:d,className:`mb-[5px]`,children:`Video title`}),(0,h.jsx)(FA,{id:d,value:t.title,maxLength:200,"aria-invalid":a(`title`)!==void 0,onChange:e=>{l({title:e.target.value})}}),(0,h.jsx)(Nj,{message:a(`title`)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-[10px]`,children:[(0,h.jsx)(pj,{value:t.format,onPick:e=>l({format:e})}),t.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`min-w-[120px] flex-1`,children:(0,h.jsx)(Mj,{label:`Intro`,category:`intro`,entries:r,value:t.intro,problem:a(`intro`),onPick:e=>{l({intro:e})}})}),(0,h.jsx)(`div`,{className:`min-w-[120px] flex-1`,children:(0,h.jsx)(Mj,{label:`Outro`,category:`outro`,entries:r,value:t.outro,problem:a(`outro`),onPick:e=>{l({outro:e})}})})]}):null]}),iO(t,r)?(0,h.jsxs)(`div`,{className:`flex gap-[10px]`,children:[(0,h.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,h.jsx)(Dj,{label:`LLM`,family:`llm`,providers:n,value:t.llm.provider,problem:a(`llm`),onPick:e=>{l({llm:{provider:e,model:``}})}})}),(0,h.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,h.jsx)(Oj,{label:`Model`,provider:t.llm.provider,value:t.llm.model,problem:void 0,onPick:e=>{l({llm:{...t.llm,model:e}})}})})]}):null]}),iO(t,r)?(0,h.jsx)(Aj,{choice:t.llm,onChange:e=>l({llm:e})}):null,e,(0,h.jsx)(mj,{fields:i,values:t.values,problem:a,onChange:(e,n)=>{l({values:{...t.values,[e]:n}})}}),s===void 0?null:(0,h.jsx)(`p`,{className:`text-small text-red`,role:`alert`,children:s}),o===void 0?null:(0,h.jsx)(`p`,{id:f,className:`mt-1 text-center text-small text-ink2`,children:o.hint}),(0,h.jsxs)(J,{"data-tour":`play-start`,variant:`play`,size:`play`,"aria-disabled":p,"aria-describedby":o===void 0?void 0:f,onClick:()=>{p||u()},children:[(0,h.jsx)(Ec,{className:`relative top-[2px] size-[22px]`}),`PLAY`]})]})}function Mj({label:e,category:t,entries:n,value:r,problem:i,onPick:a}){return(0,h.jsx)(wj,{label:e,value:r,placeholder:`Off`,options:n.filter(e=>e.category===t).map(e=>({value:e.name,label:e.name})),problem:i,onPick:a})}function Nj({message:e}){return e===void 0?null:(0,h.jsx)(`p`,{className:`mt-1 text-label text-red`,children:e})}function Pj({items:e,fields:t,title:n,values:r,onChange:i}){let a=(0,m.useId)();return(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-3`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-body font-medium`,children:[`Queue keyword variations `,e.length?`(${e.length+1} videos)`:``]}),(0,h.jsx)(`p`,{className:`my-3 text-small text-ink2`,children:`The setup above is video 1. Add videos with different titles and keywords. They run one at a time; a failed video releases the next, and a pause holds the queue.`}),e.map((n,o)=>(0,h.jsxs)(`fieldset`,{className:`mb-3 flex min-w-0 flex-col gap-2 border-t border-line pt-3`,children:[(0,h.jsxs)(`legend`,{className:`text-small text-ink2`,children:[`Video `,o+2]}),(0,h.jsxs)(`label`,{htmlFor:`${a}-${n.key}-title`,className:`text-small`,children:[`Title`,(0,h.jsx)(FA,{id:`${a}-${n.key}-title`,value:n.title,maxLength:200,onChange:t=>i(e.map(e=>e.key===n.key?{...e,title:t.target.value}:e))})]}),t.map(t=>(0,h.jsxs)(`label`,{htmlFor:`${a}-${n.key}-${encodeURIComponent(t.name)}`,className:`text-small`,children:[t.name,(0,h.jsx)(FA,{id:`${a}-${n.key}-${encodeURIComponent(t.name)}`,value:n.values[t.name]??r[t.name]??``,onChange:r=>i(e.map(e=>e.key===n.key?{...e,values:{...e.values,[t.name]:r.target.value}}:e))})]},t.name)),(0,h.jsxs)(J,{onClick:()=>i(e.filter(e=>e.key!==n.key)),children:[`Remove video `,o+2]})]},n.key)),(0,h.jsx)(J,{disabled:e.length>=49,onClick:()=>i([...e,{key:crypto.randomUUID(),title:`${n||`Video`} ${e.length+2}`,values:{...r}}]),children:`Add keyword variation`})]})}function Fj({draft:e,items:t,pending:n,failure:r,onStart:i,onClose:a}){let{api:o}=B(),s=(0,m.useId)(),[c,l]=(0,m.useState)(1500),u={draft:e,expectedWords:c,...t.length?{items:[{title:e.title,values:e.values},...t.map(({title:e,values:t})=>({title:e,values:t}))]}:{}},d=R({queryKey:[`run-estimate`,u],retry:!1,queryFn:async()=>Za(await o.fetch(`${o.origin}/api/projects/estimate`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(u)}))}),f=d.data?.estimates??[],p=f.reduce((e,t)=>e+t.low,0),g=f.reduce((e,t)=>e+t.high,0),_=f.reduce((e,t)=>e+t.unknown,0),v=f[0]?.rows.map((e,t)=>({...e,low:f.some(e=>e.rows[t]?.low===null)?null:f.reduce((e,n)=>e+(n.rows[t]?.low??0),0),high:f.some(e=>e.rows[t]?.high===null)?null:f.reduce((e,n)=>e+(n.rows[t]?.high??0),0)}))??[];return(0,h.jsx)(Ty,{open:!0,onOpenChange:e=>{!e&&!n&&a()},children:(0,h.jsxs)(Oy,{className:`max-h-[90dvh] overflow-y-auto sm:max-w-2xl`,children:[(0,h.jsxs)(ky,{children:[`Review `,t.length?`${t.length+1} queued videos`:`run cost`]}),(0,h.jsx)(Ay,{children:`Estimated provider charges in USD. Starting authorizes the selected jobs; this estimate does not cap spending.`}),e.sources.article===`generate`?(0,h.jsxs)(`label`,{htmlFor:s,className:`text-body`,children:[`Expected article words per video`,(0,h.jsx)(FA,{id:s,type:`number`,min:1,max:1e5,value:c,disabled:n,onChange:e=>l(Math.min(1e5,Math.max(1,Number(e.target.value)||1)))})]}):null,d.isFetching?(0,h.jsx)(`p`,{role:`status`,className:`text-body text-ink2`,children:`Calculating estimate…`}):null,d.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-body text-red`,children:d.error.message}):null,d.data?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{className:`text-title font-bold`,children:[_?`Known subtotal: `:`Estimated total: `,Ij(p,g)]}),_?(0,h.jsxs)(`p`,{className:`text-body text-ink2`,children:[`Plus `,_,` stage charge`,_===1?``:`s`,` with unavailable pricing.`]}):null,(0,h.jsx)(`div`,{className:`divide-y divide-line`,children:v.map(e=>(0,h.jsxs)(`div`,{className:`py-2`,children:[(0,h.jsxs)(`div`,{className:`flex justify-between gap-4 text-body`,children:[(0,h.jsx)(`span`,{children:e.stage}),(0,h.jsx)(`span`,{children:e.low===null||e.high===null?`Unknown`:Ij(e.low,e.high)})]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:e.detail})]},e.stage))}),f[0]?.assumptions.map(e=>(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e},e)),(0,h.jsxs)(`p`,{className:`text-small text-ink3`,children:[`Catalogue verified `,f[0]?.catalogueDate??`date unavailable`,`. Batch rows show combined costs.`]})]}):null,r?(0,h.jsx)(`p`,{role:`alert`,className:`text-body text-red`,children:r}):null,(0,h.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,h.jsx)(J,{disabled:n,onClick:a,children:`Back`}),(0,h.jsx)(J,{disabled:n||d.isFetching||!d.data||d.isError,onClick:i,children:n?`Starting…`:t.length?`Queue ${t.length+1} videos`:`Start run`})]})]})})}function Ij(e,t){let n=e=>e===0?`$0`:e<.01?`<$0.01`:`$${e.toFixed(2)}`;return e===t?n(e):`${n(e)} – ${n(t)}`}var Lj={mode:`whole`};function Rj(e,t){let n=e??Lj,r=t??Lj;return n.mode===r.mode?n.mode===`words`?(n.words??500)===(r.words??500):n.mode!==`characters`||(n.characters??3e3)===(r.characters??3e3):!1}function zj({label:e,hideLabel:t=!1,value:n,options:r,className:i,onPick:a}){let o=(0,m.useId)();return(0,h.jsxs)(`span`,{className:W(`inline-flex items-center gap-[10px]`,i),children:[(0,h.jsx)(NA,{id:o,className:t?`sr-only`:`shrink-0`,children:e}),(0,h.jsx)(hA,{type:`single`,value:n,"aria-labelledby":o,onValueChange:e=>{let t=r.find(t=>t.value===e);t!==void 0&&t.disabled!==!0&&a(t.value)},children:r.map(e=>(0,h.jsx)(gA,{value:e.value,disabled:e.disabled===!0,children:e.label},e.value))})]})}function Bj({value:e,onPick:t}){let n=e.words??500,r=e.characters??3e3,i=e.mode===`words`||e.mode===`characters`,a=e.mode===`characters`,o=a?e.characters:e.words;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(zj,{label:`Chunking`,className:`min-w-0 max-w-full flex-wrap [&_[data-slot=toggle-group]]:max-w-full [&_[data-slot=toggle-group]]:flex-wrap`,value:e.mode,options:[{value:`whole`,label:`Whole`},{value:`paragraph`,label:`Paragraph`},{value:`words`,label:`Every ${String(n)} words`},{value:`characters`,label:`Every ${String(r)} characters`}],onPick:e=>{t(e===`words`?{mode:e,words:n}:e===`characters`?{mode:e,characters:r}:{mode:e})}}),i?(0,h.jsx)(Cj,{label:a?`Characters`:`Words`,problem:void 0,inline:!0,children:({id:e})=>(0,h.jsx)(FA,{id:e,type:`number`,min:1,max:a?1e6:1e4,inputMode:`numeric`,className:`w-[100px] tabular-nums`,value:o===void 0?``:String(o),onChange:e=>{let n=Number.parseInt(e.target.value,10),r=Number.isFinite(n)&&n>0;t(a?r?{mode:`characters`,characters:Math.min(n,1e6)}:{mode:`characters`}:r?{mode:`words`,words:Math.min(n,1e4)}:{mode:`words`})}})}):null,a?(0,h.jsx)(`p`,{className:`basis-full text-small text-ink3`,children:`Ends at the last complete sentence within the character count, including spaces. A longer sentence stays whole; provider request limits still apply.`}):null]})}var Vj=1;function Hj({prompts:e,picked:t,problem:n,onPick:r}){let i=(0,m.useId)(),a=t.reduce((e,t)=>e+t.number,0);return e.length===0?(0,h.jsx)(`p`,{className:`basis-full text-right text-small text-ink3`,children:`No image prompts saved. Write one on Prompts.`}):(0,h.jsxs)(`div`,{className:`flex basis-full flex-col items-end gap-[6px]`,children:[(0,h.jsx)(`span`,{id:i,className:`engraved text-ink3`,children:`Image prompts`}),(0,h.jsx)(`ul`,{"aria-labelledby":i,className:`flex flex-wrap justify-end gap-x-4 gap-y-2`,children:e.map(e=>{let i=t.findIndex(t=>t.name===e.name),a=i===-1?void 0:t[i];return(0,h.jsx)(`li`,{children:(0,h.jsx)(Uj,{name:e.name,number:a?.number,problem:i===-1?void 0:n(`imagePrompts.${String(i)}.number`),onTick:n=>{r(n?[...t,{name:e.name,number:Vj}]:t.filter(t=>t.name!==e.name))},onNumber:n=>{r(t.map(t=>t.name===e.name?{name:t.name,number:n}:t))}})},e.id)})}),t.length===0?null:(0,h.jsx)(`span`,{className:`text-label text-ink3 tabular-nums`,children:`${String(a)} of 60 images`})]})}function Uj({name:e,number:t,problem:n,onTick:r,onNumber:i}){let a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)();return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{id:a,type:`checkbox`,checked:t!==void 0,className:`size-[14px] shrink-0 accent-accent`,onChange:e=>{r(e.target.checked)}}),(0,h.jsx)(`label`,{htmlFor:a,className:t===void 0?`text-ink3`:`text-ink`,children:e}),(0,h.jsx)(NA,{htmlFor:o,className:`sr-only`,children:`Number for ${e}`}),(0,h.jsx)(FA,{id:o,type:`number`,min:Vj,max:20,inputMode:`numeric`,disabled:t===void 0,"aria-invalid":n!==void 0,"aria-describedby":n===void 0?void 0:s,className:`w-[64px] tabular-nums`,value:t===void 0||t===0?``:String(t),onChange:e=>{let t=Number.parseInt(e.target.value,10);i(Number.isFinite(t)?t:0)}}),n===void 0?null:(0,h.jsx)(`span`,{id:s,className:`text-label text-red`,children:n})]})}var Wj=`text-small text-ink2 file:mr-3 file:h-8 file:rounded-control file:border file:border-line2 file:bg-panel2 file:px-3 file:text-ink`;function Gj({label:e,value:t,placeholder:n,problem:r,onChange:i}){let a=(0,m.useId)(),o=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{htmlFor:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(IA,{id:a,rows:6,value:t,placeholder:n,"aria-invalid":r!==void 0,"aria-describedby":r===void 0?void 0:o,onChange:e=>{i(e.target.value)}}),r===void 0?null:(0,h.jsx)(`p`,{id:o,className:`mt-1 text-label text-red`,children:r})]})}function Kj({label:e,accept:t,multiple:n=!1,uploads:r,problem:i,numbered:a=!1,onPick:o,onRemove:s}){let c=(0,m.useId)(),l=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{htmlFor:c,className:`mb-[5px]`,children:e}),(0,h.jsx)(`input`,{id:c,type:`file`,accept:t,multiple:n,"aria-invalid":i!==void 0,"aria-describedby":i===void 0?void 0:l,className:Wj,onChange:e=>{o([...e.target.files??[]])}}),i===void 0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:i}),r.length===0?null:(0,h.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:r.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex items-center gap-3`,children:[a?(0,h.jsx)(`span`,{className:`engraved w-6 text-ink3`,children:String(t+1)}):null,(0,h.jsx)(qj,{upload:e}),s===void 0?null:(0,h.jsx)(J,{variant:`ghost`,className:`ml-auto`,"aria-label":`Remove ${e.name}`,onClick:()=>{s(e.key)},children:`Remove`})]},e.key))})]})}function qj({upload:e}){return(0,h.jsxs)(`span`,{className:`flex items-center gap-3 text-small`,children:[(0,h.jsx)(`span`,{className:e.error===void 0?`text-ink`:`text-red`,children:e.name}),e.error===void 0?(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e.file===void 0?`Copying`:`Staged`}):(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.error})]})}var Jj={pending:`text-ink3`,running:`text-run-text`,done:`text-done`,failed:`text-red`,canceled:`text-amber`,paused:`text-amber`,provided:`text-ink2`,skipped:`text-ink3`};function Yj({state:e,announce:t,className:n}){return(0,h.jsxs)(`span`,{className:W(`inline-flex items-center`,n),children:[(0,h.jsx)(`span`,{"data-state":e,className:W(`engraved font-bold`,Jj[e]),children:e}),t===void 0?null:(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${t}: ${e}`})]})}var Xj={pending:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`,running:`bg-lamp-run shadow-[0_0_0_3px_var(--color-lamp-halo)] animate-lamp-pulse motion-reduce:animate-none`,done:`bg-done`,failed:`bg-red`,canceled:`bg-amber`,paused:`bg-amber`,provided:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`,skipped:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`};function Zj({state:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-lamp":e,className:W(`size-[10px] shrink-0 rounded-full`,Xj[e],t)})}var Qj=`grid grid-cols-[14px_24px_110px_auto_minmax(0,1fr)]`,$j=`col-start-5 flex flex-wrap items-center justify-end gap-[10px]`,eM=`col-span-4 col-start-2 mt-[10px]`;function tM({kind:e,name:t,dim:n,children:r}){return(0,h.jsxs)(cA,{"data-tour":`play-${e}`,className:Qj,children:[(0,h.jsx)(Zj,{state:`pending`}),(0,h.jsx)(Tc,{kind:e,className:n?`text-ink3`:`text-ink2`}),(0,h.jsx)(`span`,{className:W(`font-semibold`,n?`text-ink3`:void 0),children:t}),r]})}function nM({kind:e,form:t,update:n}){return(0,h.jsx)(zj,{label:`${e} source`,hideLabel:!0,value:t.sources[e],options:rO(e).map(n=>({...n,disabled:e===`video`&&n.value===`generate`&&t.sources.images===`off`})),onPick:r=>{n({sources:{...t.sources,[e]:r,...e===`images`&&r===`off`?{video:`off`}:{}}})}})}function rM(e,t){return e.filter(e=>e.kind===t).map(e=>({value:e.name,label:e.name}))}function iM({form:e,providers:t,voices:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o}){let s=n.filter(t=>t.provider===e.audio.provider);return(0,h.jsxs)(tM,{kind:`audio`,name:`Audio`,dim:e.sources.audio===`off`,children:[(0,h.jsx)(nM,{kind:`audio`,form:e,update:i}),(0,h.jsx)(`div`,{className:$j,children:e.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Dj,{label:`TTS`,inline:!0,family:`tts`,providers:t,value:e.audio.provider,problem:r(`audio`),onPick:e=>{i({audio:{provider:e,model:``,voice:``}})}}),(0,h.jsx)(Oj,{label:`TTS model`,inline:!0,provider:e.audio.provider,value:e.audio.model,problem:void 0,onPick:t=>i({audio:{...e.audio,model:t}})}),(0,h.jsx)(wj,{label:`Voice`,inline:!0,value:e.audio.voice,placeholder:s.length===0?`No voices. Add one in Settings.`:`Pick a voice`,options:s.map(e=>({value:e.voiceId,label:e.name})),problem:r(`audio.voice`),onPick:t=>{i({audio:{...e.audio,voice:t}})}}),(0,h.jsx)(Bj,{value:e.chunking,onPick:e=>{i({chunking:e})}})]}):null}),e.sources.audio===`provide`?(0,h.jsxs)(`div`,{className:eM,children:[(0,h.jsx)(Kj,{label:`Narration file`,accept:`audio/*`,uploads:e.provided.audio===void 0?[]:[e.provided.audio],problem:r(`provided.audio`),onPick:e=>{a(`audio`,e)},onRemove:e=>{o(`audio`,e)}}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:`Uploaded narration is used as-is; include any intro and outro in that file.`})]}):null]})}function aM({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o}){return(0,h.jsxs)(tM,{kind:`images`,name:`Images`,dim:e.sources.images===`off`,children:[(0,h.jsx)(nM,{kind:`images`,form:e,update:i}),(0,h.jsx)(`div`,{className:$j,children:e.sources.images===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(oM,{form:e,providers:t,problem:r,update:i}),(0,h.jsx)(Hj,{prompts:n.filter(e=>e.kind===`image`),picked:e.imagePrompts,problem:r,onPick:e=>{i({imagePrompts:e})}})]}):null}),e.sources.images===`provide`?(0,h.jsx)(`div`,{className:eM,children:(0,h.jsx)(Kj,{label:`Slideshow images`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,numbered:!0,uploads:e.provided.images,problem:r(`provided.images`),onPick:e=>{a(`images`,e)},onRemove:e=>{o(`images`,e)}})}):null]})}function oM({form:e,providers:t,problem:n,update:r}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Dj,{label:`Provider`,inline:!0,family:`image`,providers:t,value:e.images.provider,problem:n(`images`),onPick:e=>r({images:{provider:e,model:``}})}),(0,h.jsx)(Oj,{label:`Model`,inline:!0,provider:e.images.provider,value:e.images.model,problem:void 0,onPick:t=>r({images:{...e.images,model:t}})})]})}var sM=[`fonts`];async function cM(e){return Za(await e.fetch(`${e.origin}/api/fonts`))}async function lM(e,t){let n=new FormData;return n.set(`file`,t),Za(await e.fetch(`${e.origin}/api/fonts`,{method:`POST`,body:n}))}function uM(e,t){return`${e.origin}/api/fonts/${encodeURIComponent(t)}/file`}function dM({value:e,onPick:t,onUploading:n}){let{api:r}=B(),i=_(),a=(0,m.useId)(),o=(0,m.useId)(),s=R({queryKey:sM,queryFn:()=>cM(r),staleTime:6e4}),c=tt({mutationFn:e=>lM(r,e),onSuccess:({font:e})=>{i.setQueryData(sM,t=>({fonts:[...(t?.fonts??[]).filter(t=>t.id!==e.id),e]})),i.invalidateQueries({queryKey:sM})}}),l=(0,m.useRef)(t);l.current=t;let u=(0,m.useRef)(n);u.current=n,(0,m.useEffect)(()=>{u.current(c.isPending)},[c.isPending]),(0,m.useEffect)(()=>()=>u.current(!1),[]);let d=s.data?.fonts??[],f=e!=="default"&&!d.some(t=>t.id===e);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 basis-full`,children:[(0,h.jsx)(NA,{htmlFor:a,className:`mb-1`,children:`Subtitle font`}),(0,h.jsxs)(`select`,{id:a,value:e,disabled:c.isPending,onChange:e=>t(e.target.value),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:[d.some(e=>e.id==="default")?null:(0,h.jsx)(`option`,{value:`default`,children:`Default font · bundled`}),f?(0,h.jsxs)(`option`,{value:e,children:[e,` · saved font`]}):null,d.map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.source]},e.id))]})]}),(0,h.jsxs)(`div`,{className:`min-w-0 basis-full`,children:[(0,h.jsx)(NA,{htmlFor:o,className:`mb-1`,children:`Upload font (.ttf or .otf)`}),(0,h.jsx)(`input`,{id:o,type:`file`,accept:`.ttf,.otf,font/ttf,font/otf`,disabled:c.isPending,className:`w-full text-small text-ink2 file:mr-2 file:rounded-control file:border file:border-line2 file:bg-panel2 file:px-2 file:py-1 file:text-ink`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c.mutate(t,{onSuccess:({font:e})=>l.current(e.id)})}})]})]}),c.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-small text-ink2`,children:`Uploading font…`}):null,c.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:c.error.message}):null,s.error?(0,h.jsxs)(`p`,{role:`alert`,className:`text-small text-red`,children:[`Could not load fonts. `,s.error.message]}):null]})}function fM(e){return e===`9:16`?{width:1080,height:1920}:{width:1920,height:1080}}function pM(e,t){switch(e){case`top`:return{y:60,alignment:8,translateY:0};case`upper-middle`:return{y:t/4,alignment:5,translateY:-50};case`center`:return{y:t/2,alignment:5,translateY:-50};case`lower-middle`:return{y:t*3/4,alignment:5,translateY:-50};case`bottom`:return{y:t-60,alignment:2,translateY:-100}}}function mM({value:e,format:t}){let{api:n}=B(),r=uM(n,e.fontId),i=`subtitle-preview-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,[a,o]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(typeof FontFace>`u`||!document.fonts)return;let e=!0,t=new FontFace(i,`url(${JSON.stringify(r)})`);return o(!1),t.load().then(t=>{e&&document.fonts.add(t)}).catch(()=>{e&&o(!0)}),()=>{e=!1,document.fonts.delete(t)}},[i,r]);let s=fM(t),c=pM(e.position??`bottom`,s.height),l=Number.isFinite(e.fontSize)?Math.max(16,Math.min(120,e.fontSize)):48;return(0,h.jsxs)(`figure`,{className:`min-w-0 self-start`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-label text-ink2`,children:[(0,h.jsx)(`span`,{children:`Style preview`}),(0,h.jsx)(`span`,{children:t})]}),(0,h.jsx)(`div`,{role:`img`,"aria-label":`Subtitle style preview`,"data-format":t,"data-position":e.position??`bottom`,className:`relative mx-auto w-full overflow-hidden rounded-control border border-line2 bg-screen text-center text-white`,style:{aspectRatio:`${s.width} / ${s.height}`,maxWidth:t===`9:16`?240:480,containerType:`inline-size`},children:(0,h.jsx)(`span`,{style:{position:`absolute`,left:`50%`,top:`${c.y/s.height*100}%`,width:`${(s.width-120)/s.width*100}%`,transform:`translate(-50%, ${c.translateY}%)`,fontFamily:`"${i}", sans-serif`,fontSize:`${l/s.width*100}cqw`,lineHeight:1.2,overflowWrap:`anywhere`,WebkitTextStroke:`${2.5/s.width*100}cqw #101010`,paintOrder:`stroke fill`,textShadow:`0 ${100/s.width}cqw ${100/s.width}cqw #000`},children:`Every story begins with a word.`})}),(0,h.jsxs)(`figcaption`,{className:`mt-2 text-label text-ink3`,children:[s.width,` × `,s.height,` · Preview at reduced scale.`,a?` Font preview unavailable; showing a fallback.`:``]})]})}function hM({value:e,format:t=`16:9`,audioEnabled:n,videoEnabled:r,disabled:i=!1,onChange:a,onUploading:o,problem:s}){let c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),[f,p]=(0,m.useState)(!1),g=s?.(`subtitles.fontId`),_=s?.(`subtitles.fontSize`),v=s?.(`subtitles.mode`)??s?.(`subtitles`);return(0,h.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Subtitles`,children:[(0,h.jsxs)(`fieldset`,{disabled:i||!n,className:`flex min-w-0 flex-col gap-3 disabled:opacity-60`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(NA,{htmlFor:c,className:`mb-1`,children:`Subtitles`}),(0,h.jsxs)(`select`,{id:c,value:n?e.mode:`off`,disabled:f,"aria-describedby":u,"aria-invalid":v!==void 0,onChange:t=>a({...e,mode:t.target.value}),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:[(0,h.jsx)(`option`,{value:`off`,children:`Off`}),(0,h.jsx)(`option`,{value:`files`,children:`Subtitle files (.srt + .vtt)`}),(0,h.jsx)(`option`,{value:`burn-in`,disabled:!r,children:`Burn into video + files`})]})]}),(0,h.jsx)(`span`,{className:`pb-1 text-label text-ink3`,children:`English · local · no paid API`})]}),e.mode!==`off`&&n?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Timed from your narration on this computer. First use downloads an approximately 95 MB speech model. Review the subtitles before publishing.`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(min(100%, 240px), 1fr))`},children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(dM,{value:e.fontId,onPick:t=>a({...e,fontId:t}),onUploading:e=>{p(e),o?.(e)}}),(0,h.jsxs)(`div`,{className:`max-w-[180px]`,children:[(0,h.jsx)(NA,{htmlFor:l,className:`mb-1`,children:`Subtitle font size`}),(0,h.jsx)(FA,{id:l,type:`number`,min:16,max:120,step:1,value:e.fontSize,"aria-invalid":!eO(e)||_!==void 0,onChange:t=>a({...e,fontSize:Number(t.target.value)})}),!eO(e)||_?(0,h.jsx)(`p`,{role:`alert`,className:`mt-1 text-label text-red`,children:_??`Choose a whole font size from 16 to 120.`}):null]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{htmlFor:d,className:`mb-1`,children:`Subtitle position`}),(0,h.jsx)(`select`,{id:d,value:e.position??`bottom`,onChange:t=>{let n=YD.find(e=>e===t.target.value);n&&a({...e,position:n})},className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:YD.map(e=>(0,h.jsxs)(`option`,{value:e,children:[e[0]?.toUpperCase(),e.slice(1)]},e))})]})]}),(0,h.jsx)(mM,{value:e,format:t})]}),g?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:g}):null,e.mode===`files`?(0,h.jsx)(`p`,{className:`text-label text-ink3`,children:`Font, size and position apply to burned captions. SRT/VTT players choose their own styling.`}):null]}):null]}),v?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:v}):null,(0,h.jsx)(`p`,{id:u,className:`text-small text-ink2`,children:n?r?`Optional: download subtitles separately or keep them visible in the video.`:`Audio exports support separate subtitle files. Enable Video to burn captions into an MP4.`:`Turn Audio on to add subtitles.`})]})}function gM(e){let{form:t}=e;return(0,h.jsxs)(sA,{children:[t.sources.article===`provide`?null:(0,h.jsx)(_M,{...e}),(0,h.jsx)(vM,{...e}),(0,h.jsx)(iM,{...e}),(0,h.jsx)(aM,{...e}),(0,h.jsx)(yM,{...e}),(0,h.jsx)(bM,{...e})]})}function _M({form:e,problem:t,update:n}){return(0,h.jsxs)(tM,{kind:`research`,name:`Research`,dim:e.sources.research===`off`,children:[(0,h.jsx)(nM,{kind:`research`,form:e,update:n}),(0,h.jsx)(`div`,{className:$j,children:e.sources.research===`generate`?(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:`Runs through the LLM, one agent per chapter`}):null}),e.sources.research===`provide`?(0,h.jsx)(`div`,{className:eM,children:(0,h.jsx)(Gj,{label:`Research notes`,value:e.provided.research,placeholder:`Paste the notes the article will be written from.`,problem:t(`provided.research`),onChange:t=>{n({provided:{...e.provided,research:t}})}})}):null]})}function vM({form:e,prompts:t,problem:n,update:r}){return(0,h.jsxs)(tM,{kind:`article`,name:`Article`,dim:!1,children:[(0,h.jsx)(nM,{kind:`article`,form:e,update:r}),(0,h.jsx)(`div`,{className:$j,children:e.sources.article===`generate`?(0,h.jsx)(wj,{label:`Article prompt`,inline:!0,value:e.articlePrompt,placeholder:`Pick a prompt`,options:rM(t,`article`),problem:n(`articlePrompt`),onPick:e=>{r({articlePrompt:e})}}):null}),e.sources.article===`provide`?(0,h.jsx)(`div`,{className:eM,children:(0,h.jsx)(Gj,{label:`Article text`,value:e.provided.article,placeholder:`Paste the article that will be narrated.`,problem:n(`provided.article`),onChange:t=>{r({provided:{...e.provided,article:t}})}})}):null]})}function yM({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o}){let s=e.sources.thumbnail===`from_prompt`||e.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(tM,{kind:`thumbnail`,name:`Thumbnail`,dim:e.sources.thumbnail===`off`,children:[(0,h.jsx)(nM,{kind:`thumbnail`,form:e,update:i}),(0,h.jsxs)(`div`,{className:$j,children:[s&&e.sources.images!==`generate`?(0,h.jsx)(oM,{form:e,providers:t,problem:r,update:i}):null,s?(0,h.jsx)(wj,{label:`Thumbnail prompt`,inline:!0,value:e.thumbnailPrompt,placeholder:`Pick a prompt`,options:rM(n,`thumbnail`),problem:r(`thumbnailPrompt`),onPick:e=>{i({thumbnailPrompt:e})}}):null]}),e.sources.thumbnail===`provide`?(0,h.jsx)(`div`,{className:eM,children:(0,h.jsx)(Kj,{label:`Thumbnail image`,accept:`image/png,image/jpeg,image/webp`,uploads:e.provided.thumbnail===void 0?[]:[e.provided.thumbnail],problem:r(`provided.thumbnail`),onPick:e=>{a(`thumbnail`,e)},onRemove:e=>{o(`thumbnail`,e)}})}):null]})}function bM({form:e,silenceGapSeconds:t,update:n,onSubtitleUpload:r,problem:i}){let a=e.sources.video===`generate`?e.sources.audio===`off`?`Silent video · 5 seconds per image`:`Images and narration · ${String(t)} s segment gaps`:e.sources.audio===`off`?`Download each enabled stage separately`:`Combined WAV export with narration and segment gaps`;return(0,h.jsxs)(tM,{kind:`video`,name:`Video`,dim:e.sources.video===`off`,children:[(0,h.jsx)(nM,{kind:`video`,form:e,update:n}),(0,h.jsx)(`span`,{className:$j,children:(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:a})}),(0,h.jsx)(`div`,{"data-tour":`play-subtitles`,className:eM,children:(0,h.jsx)(hM,{value:QD(e.subtitles,e.sources),format:e.format,audioEnabled:e.sources.audio!==`off`,videoEnabled:e.sources.video===`generate`&&e.sources.images!==`off`,onChange:e=>n({subtitles:e}),problem:i,...r===void 0?{}:{onUploading:r}})}),e.sources.images===`off`?(0,h.jsx)(`p`,{className:`${eM} text-small text-ink2`,children:`Video is Off because Images is Off. Generate or provide images to enable video.`}):null]})}function xM(){let e=Hi();return(0,h.jsx)(SM,{onCreated:t=>{e({to:`/projects/$projectId`,params:{projectId:t}})}})}function SM({onCreated:e}){let{api:t}=B(),n=_(),r=ck(),i=R(Iy(t)),a=R(Ry(t)),o=R(zy(t)),s=R(Ly(t)),c=R(By(t)),[l,u]=mO(),[d,f]=(0,m.useState)([]),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(()=>crypto.randomUUID()),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)([]),[w,T]=(0,m.useState)(!1),E=e=>{u(t=>{let n={...t,...e};return{...n,subtitles:QD(n.subtitles,n.sources)}}),y(crypto.randomUUID()),T(!0),C([])},{fields:D,draft:O,result:k,blocker:A}=ij({form:l,prompts:a.data?.prompts??[],entries:o.data?.entries??[],silenceGapSeconds:c.data?.silenceGapSeconds??3}),j=b?{field:`subtitles.fontId`,hint:`Wait for the subtitle font upload to finish to play`}:A,M=tt({mutationFn:async()=>{if(!d.length)return so(t,O);let e=(await Za(await t.fetch(`${t.origin}/api/projects/batch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({requestId:v,draft:O,items:[{title:O.title,values:O.values},...d.map(({title:e,values:t})=>({title:e,values:t}))]})}))).queue[0];if(!e)throw Error(`No videos were queued.`);return{ok:!0,value:{project:{id:e.projectId}}}},onSuccess:t=>{if(!t.ok){C(t.fields),g(!1);return}n.invalidateQueries({queryKey:jy.projects}),n.invalidateQueries({queryKey:jy.staging}),u(tO),f([]),y(crypto.randomUUID()),g(!1),r({type:`project-created`,id:t.value.project.id}),e(t.value.project.id)}}),N=k.ok?S:[...k.fields,...S],P=(...e)=>!N.some(t=>e.some(e=>t.field===e||t.field.startsWith(`${e}.`))),F=(e,t)=>(a.data?.prompts??[]).some(n=>n.kind===e&&n.name===t),I=e=>e?.file!==void 0&&e.error===void 0;sk({playArticleReady:P(`sources.article`,`articlePrompt`,`provided.article`)&&(l.sources.article===`provide`||F(`article`,l.articlePrompt)),playAudioReady:l.sources.audio===`off`||P(`sources.audio`,`audio`,`provided.audio`)&&(l.sources.audio!==`provide`||I(l.provided.audio)),playImagesReady:l.sources.images===`off`||P(`sources.images`,`images`,`imagePrompts`,`provided.images`)&&(l.sources.images===`provide`?l.provided.images.every(I):l.imagePrompts.every(e=>F(`image`,e.name))),playVideoReady:P(`sources.video`),playSubtitlesReady:P(`subtitles`)&&!b,playOptionsReady:P(`title`,`format`,`llm`,`intro`,`outro`),playHasKeywords:D.length>0,playKeywordsReady:P(`values`),playReady:j===void 0&&!M.isPending});let ee=e=>{let t=S.find(t=>t.field===e);if(t!==void 0)return t.message;if(w&&j?.field===e&&!k.ok)return k.fields.find(t=>t.field===e)?.message},te=()=>{j===void 0&&!M.isPending&&g(!0)},ne=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),te())},L=async(e,n,r)=>{try{let i=await co(t,e,n);re(r,e=>({...e,file:i}))}catch(e){re(r,t=>({...t,error:wM(e)}))}},re=(e,t)=>{u(n=>({...n,provided:{...n.provided,audio:n.provided.audio?.key===e?t(n.provided.audio):n.provided.audio,thumbnail:n.provided.thumbnail?.key===e?t(n.provided.thumbnail):n.provided.thumbnail,images:n.provided.images.map(n=>n.key===e?t(n):n)}}))},ie=(e,t)=>{let n=t.map(CM),r=n[n.length-1];u(t=>({...t,provided:e===`images`?{...t.provided,images:[...t.provided.images,...n]}:e===`audio`?{...t.provided,audio:r}:{...t.provided,thumbnail:r}})),C([]);for(let[r,i]of n.entries()){let n=t[r];n!==void 0&&L(e,n,i.key)}},ae=(e,t)=>{u(n=>({...n,provided:e===`images`?{...n.provided,images:n.provided.images.filter(e=>e.key!==t)}:e===`audio`?{...n.provided,audio:void 0}:{...n.provided,thumbnail:void 0}}))},oe=[i,a,o,s,c].find(e=>e.error!==null)?.error?.message;return(0,h.jsxs)(`div`,{onKeyDown:ne,"data-play-grid":`true`,className:`mx-auto grid max-w-[1440px] grid-cols-1 items-start gap-6 min-[1180px]:grid-cols-[minmax(0,1fr)_480px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`h1`,{className:`mb-1 text-title font-bold tracking-[-0.01em]`,children:`New run`}),(0,h.jsx)(`p`,{className:`mb-4 text-body text-ink2`,children:`Generate or provide an Article. Every other stage can be Off. Choose narration, images, and a video or combined audio export to suit your project.`}),oe===void 0?null:(0,h.jsx)(`p`,{className:`mb-4 text-body text-red`,children:oe}),(0,h.jsx)(gM,{form:l,providers:i.data?.providers??[],prompts:a.data?.prompts??[],voices:s.data?.voices??[],silenceGapSeconds:c.data?.silenceGapSeconds??3,problem:ee,update:E,onPickFiles:ie,onRemoveFile:ae,onSubtitleUpload:x})]}),(0,h.jsx)(jj,{form:l,providers:i.data?.providers??[],entries:o.data?.entries??[],fields:D,problem:ee,blocker:j,failure:M.error===null?void 0:M.error.message,pending:M.isPending,update:E,onPlay:te,children:(0,h.jsx)(Pj,{items:d,fields:D,title:l.title,values:l.values,onChange:e=>{f(e),y(crypto.randomUUID())}})}),p?(0,h.jsx)(Fj,{draft:O,items:d,pending:M.isPending,failure:M.error?.message??S.map(e=>e.message).join(` `),onClose:()=>g(!1),onStart:()=>M.mutate()}):null]})}function CM(e){return{key:crypto.randomUUID(),name:e.name,file:void 0,error:void 0}}function wM(e){return e instanceof Error?e.message:String(e)}function TM(){let{api:e}=B(),t=R({queryKey:[`batch-queue`],queryFn:async()=>Za(await e.fetch(`${e.origin}/api/projects/queue`)),refetchInterval:2e3,retry:!1}),n=R(My(e));return t.data?.queue.length?(0,h.jsxs)(`details`,{className:`mb-4 rounded-panel border border-line bg-panel p-3`,open:!0,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-body font-semibold`,children:[`Video queue · `,t.data.queue.length,` remaining`]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`One batch video runs at a time. Pause holds the queue; failure or cancellation advances it.`}),(0,h.jsx)(`ol`,{className:`mt-2 max-h-40 overflow-y-auto`,children:t.data.queue.map((e,t)=>{let r=n.data?.projects.find(t=>t.id===e.projectId);return(0,h.jsxs)(`li`,{className:`flex justify-between gap-3 py-1 text-small`,children:[(0,h.jsxs)(ia,{className:`truncate underline`,to:`/projects/$projectId`,params:{projectId:e.projectId},children:[t+1,`. `,r?.title??`Video`]}),(0,h.jsx)(`span`,{className:`shrink-0 text-ink2`,children:r?.status===`paused`?`Paused`:e.state===`active`?`Active`:`Queued`})]},e.projectId)})})]}):null}function EM(e,t){return e.filter(e=>e.stageKind===t.kind)}function DM(e,t){return e.find(e=>e.role===t)}var OM={research:`Replaces the notes, then re-runs the enabled stages below.`,article:`Replaces the article, then re-runs the enabled stages below.`,audio:`Replaces the narration and refreshes the final audio or video export.`,images:`Replaces every image in this run and re-renders video when enabled.`,thumbnail:`Replaces the thumbnail.`,video:`Replaces the final audio or video export.`};function kM(e){switch(e.kind){case`cancel`:return{title:`Cancel this run?`,consequence:`Stops every running stage; finished outputs are kept.`,verb:`Cancel run`,dismiss:`Keep running`};case`rerun`:return{title:`Re-run this stage?`,consequence:OM[e.stage],verb:`Re-run`,dismiss:`Cancel`};case`delete-image`:return{title:`Delete this image?`,consequence:`Removes the image and re-renders video when enabled.`,verb:`Delete`,dismiss:`Cancel`};case`regenerate-image`:return{title:`Regenerate this image?`,consequence:`Replaces the image with a new one and re-renders video when enabled.`,verb:`Regenerate`,dismiss:`Cancel`};case`save-article`:return{title:`Save the edited article?`,consequence:`Replaces the article, then updates the enabled narration and final export.`,verb:`Save & update outputs`,dismiss:`Cancel`};case`discard-article`:return{title:`Discard these edits?`,consequence:`The article goes back to the text on disk.`,verb:`Discard`,dismiss:`Keep editing`}}}function AM({action:e,run:t,disabled:n=!1,pending:r=!1,variant:i=`outline`,className:a,children:o}){let[s,c]=(0,m.useState)(!1),l=kM(e);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(J,{type:`button`,variant:i,disabled:n,className:W(i===`ghost`?`px-2 text-small`:void 0,a),onClick:()=>{c(!0)},children:o}),(0,h.jsx)(oA,{open:s,title:l.title,consequence:l.consequence,verb:l.verb,dismiss:l.dismiss,pending:r,onConfirm:()=>{c(!1),t()},onCancel:()=>{c(!1)}})]})}var jM=e=>[`live-writing`,e];function MM(e,t){let n=e.find(e=>e.callId===t.callId),r=(t.reset?t.text:`${n?.text??``}${t.text}`).slice(-65536),i={stage:t.stage,callId:t.callId,...t.label===void 0?{}:{label:t.label},text:r};return(n?e.map(e=>e.callId===t.callId?i:e):[...e,i]).slice(-24)}function NM({projectId:e,stage:t}){let n=(R({queryKey:jM(e),queryFn:()=>[],enabled:!1}).data??[]).filter(e=>e.stage===t),[r,i]=(0,m.useState)(),a=n.find(e=>e.callId===r)??n.at(-1),[o,s]=(0,m.useState)(!0),c=(0,m.useRef)(null);return(0,m.useEffect)(()=>{a?.text&&o&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[o,a?.text]),n.length===0&&t!==`research`&&t!==`article`?null:(0,h.jsxs)(`div`,{className:`mx-5 mt-5 rounded-control border border-line2 bg-panel2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-run-text`,children:`Live writing`}),n.length>1?(0,h.jsx)(vj,{"aria-label":`Live writing task`,value:a?.callId??``,onChange:e=>i(e.target.value),className:`max-w-[280px]`,children:n.map((e,t)=>(0,h.jsxs)(`option`,{value:e.callId,children:[e.label??`Writing`,` · `,t+1]},e.callId))}):null,(0,h.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-label text-ink2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Follow output`]})]}),(0,h.jsx)(`section`,{ref:c,"aria-label":`Live writing preview`,tabIndex:0,className:`max-h-[360px] min-h-32 overflow-auto whitespace-pre-wrap break-words p-4 font-sans text-small leading-relaxed text-ink2`,children:a?.text||`Waiting for the provider's first text…`}),(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-2 text-label text-ink3`,children:`Live preview. The complete output is saved when this stage finishes.`})]})}function PM(e){let t=e.role.replaceAll(`_`,`-`);return e.role===`instructions`?`${e.stageKind}-${t}`:e.role===`image`&&e.meta.index!==void 0?`${t}-${String(e.meta.index)}`:t}function FM(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var IM=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,LM=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,RM={};function zM(e,t){return((t||RM).jsx?LM:IM).test(e)}var BM=/[ \t\n\f\r]/g;function VM(e){return typeof e==`object`?e.type===`text`&&HM(e.value):HM(e)}function HM(e){return e.replace(BM,``)===``}var UM=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};UM.prototype.normal={},UM.prototype.property={},UM.prototype.space=void 0;function WM(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new UM(n,r,t)}function GM(e){return e.toLowerCase()}var KM=class{constructor(e,t){this.attribute=t,this.property=e}};KM.prototype.attribute=``,KM.prototype.booleanish=!1,KM.prototype.boolean=!1,KM.prototype.commaOrSpaceSeparated=!1,KM.prototype.commaSeparated=!1,KM.prototype.defined=!1,KM.prototype.mustUseProperty=!1,KM.prototype.number=!1,KM.prototype.overloadedBoolean=!1,KM.prototype.property=``,KM.prototype.spaceSeparated=!1,KM.prototype.space=void 0;var qM=s({boolean:()=>Z,booleanish:()=>YM,commaOrSpaceSeparated:()=>$M,commaSeparated:()=>QM,number:()=>Q,overloadedBoolean:()=>XM,spaceSeparated:()=>ZM}),JM=0,Z=eN(),YM=eN(),XM=eN(),Q=eN(),ZM=eN(),QM=eN(),$M=eN();function eN(){return 2**++JM}var tN=Object.keys(qM),nN=class extends KM{constructor(e,t,n,r){let i=-1;if(super(e,t),rN(this,`space`,r),typeof n==`number`)for(;++i<tN.length;){let e=tN[i];rN(this,tN[i],(n&qM[e])===qM[e])}}};nN.prototype.defined=!0;function rN(e,t,n){n&&(e[t]=n)}function iN(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new nN(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[GM(r)]=r,n[GM(a.attribute)]=r}return new UM(t,n,e.space)}var aN=iN({properties:{ariaActiveDescendant:null,ariaAtomic:YM,ariaAutoComplete:null,ariaBusy:YM,ariaChecked:YM,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:ZM,ariaCurrent:null,ariaDescribedBy:ZM,ariaDetails:null,ariaDisabled:YM,ariaDropEffect:ZM,ariaErrorMessage:null,ariaExpanded:YM,ariaFlowTo:ZM,ariaGrabbed:YM,ariaHasPopup:null,ariaHidden:YM,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ZM,ariaLevel:Q,ariaLive:null,ariaModal:YM,ariaMultiLine:YM,ariaMultiSelectable:YM,ariaOrientation:null,ariaOwns:ZM,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:YM,ariaReadOnly:YM,ariaRelevant:null,ariaRequired:YM,ariaRoleDescription:ZM,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:YM,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function oN(e,t){return t in e?e[t]:t}function sN(e,t){return oN(e,t.toLowerCase())}var cN=iN({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:QM,acceptCharset:ZM,accessKey:ZM,action:null,allow:null,allowFullScreen:Z,allowPaymentRequest:Z,allowUserMedia:Z,alpha:Z,alt:null,as:null,async:Z,autoCapitalize:null,autoComplete:ZM,autoFocus:Z,autoPlay:Z,blocking:ZM,capture:null,charSet:null,checked:Z,cite:null,className:ZM,closedBy:null,colorSpace:null,cols:Q,colSpan:Q,command:null,commandFor:null,content:null,contentEditable:YM,controls:Z,controlsList:ZM,coords:Q|QM,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Z,defer:Z,dir:null,dirName:null,disabled:Z,download:XM,draggable:YM,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Z,formTarget:null,headers:ZM,height:Q,hidden:XM,high:Q,href:null,hrefLang:null,htmlFor:ZM,httpEquiv:ZM,id:null,imageSizes:null,imageSrcSet:null,inert:Z,inputMode:null,integrity:null,is:null,isMap:Z,itemId:null,itemProp:ZM,itemRef:ZM,itemScope:Z,itemType:ZM,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Z,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Z,muted:Z,name:null,nonce:null,noModule:Z,noValidate:Z,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Z,optimum:Q,pattern:null,ping:ZM,placeholder:null,playsInline:Z,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Z,referrerPolicy:null,rel:ZM,required:Z,reversed:Z,rows:Q,rowSpan:Q,sandbox:ZM,scope:null,scoped:Z,seamless:Z,selected:Z,shadowRootClonable:Z,shadowRootCustomElementRegistry:Z,shadowRootDelegatesFocus:Z,shadowRootMode:null,shadowRootSerializable:Z,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:YM,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Z,useMap:null,value:YM,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ZM,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Z,declare:Z,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Z,noHref:Z,noShade:Z,noWrap:Z,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:YM,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Z,disablePictureInPicture:Z,disableRemotePlayback:Z,exportParts:QM,part:ZM,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:sN}),lN=iN({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:$M,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:ZM,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Z,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:QM,g2:QM,glyphName:QM,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:$M,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ZM,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:$M,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:$M,rev:$M,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:$M,requiredFeatures:$M,requiredFonts:$M,requiredFormats:$M,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:$M,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:$M,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:$M,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:oN}),uN=iN({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),dN=iN({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:sN}),fN=iN({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),pN={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},mN=/[A-Z]/g,hN=/-[a-z]/g,gN=/^data[-\w.:]+$/i;function _N(e,t){let n=GM(t),r=t,i=KM;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&gN.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(hN,yN);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!hN.test(e)){let n=e.replace(mN,vN);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=nN}return new i(r,t)}function vN(e){return`-`+e.toLowerCase()}function yN(e){return e.charAt(1).toUpperCase()}var bN=WM([aN,cN,uN,dN,fN],`html`),xN=WM([aN,lN,uN,dN,fN],`svg`);function SN(e){return e.join(` `).trim()}var CN=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
103
- `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),wN=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(CN());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),TN=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),EN=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(wN()),r=TN();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),DN=kN(`end`),ON=kN(`start`);function kN(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function AN(e){let t=ON(e),n=DN(e);if(t&&n)return{start:t,end:n}}function jN(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?NN(e.position):`start`in e||`end`in e?NN(e):`line`in e||`column`in e?MN(e):``}function MN(e){return PN(e&&e.line)+`:`+PN(e&&e.column)}function NN(e){return MN(e&&e.start)+`-`+MN(e&&e.end)}function PN(e){return e&&typeof e==`number`?e:1}var FN=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=jN(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};FN.prototype.file=``,FN.prototype.name=``,FN.prototype.reason=``,FN.prototype.message=``,FN.prototype.stack=``,FN.prototype.column=void 0,FN.prototype.line=void 0,FN.prototype.ancestors=void 0,FN.prototype.cause=void 0,FN.prototype.fatal=void 0,FN.prototype.place=void 0,FN.prototype.ruleId=void 0,FN.prototype.source=void 0;var IN=l(EN(),1),LN={}.hasOwnProperty,RN=new Map,zN=/[A-Z]/g,BN=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),VN=new Set([`td`,`th`]),HN=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function UN(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=eP(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=$N(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?xN:bN,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=WN(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function WN(e,t,n){if(t.type===`element`)return GN(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return KN(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return JN(e,t,n);if(t.type===`mdxjsEsm`)return qN(e,t);if(t.type===`root`)return YN(e,t,n);if(t.type===`text`)return XN(e,t)}function GN(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=xN,e.schema=i),e.ancestors.push(t);let a=oP(e,t.tagName,!1),o=tP(e,t),s=rP(e,t);return BN.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!VM(e)})),ZN(e,o,a,t),QN(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function KN(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}sP(e,t.position)}function qN(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);sP(e,t.position)}function JN(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=xN,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:oP(e,t.name,!0),o=nP(e,t),s=rP(e,t);return ZN(e,o,a,t),QN(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function YN(e,t,n){let r={};return QN(r,rP(e,t)),e.create(t,e.Fragment,r,n)}function XN(e,t){return t.value}function ZN(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function QN(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function $N(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function eP(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=ON(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function tP(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&LN.call(t.properties,i)){let a=iP(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&VN.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function nP(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else sP(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else sP(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function rP(e,t){let n=[],r=-1,i=e.passKeys?new Map:RN;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=WN(e,a,o);s!==void 0&&n.push(s)}return n}function iP(e,t,n){let r=_N(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?FM(n):SN(n)),r.property===`style`){let t=typeof n==`object`?n:aP(e,String(n));return e.stylePropertyNameCase===`css`&&(t=cP(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?pN[r.property]||r.property:r.attribute,n]}}function aP(e,t){try{return(0,IN.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new FN("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=HN+`#cannot-parse-style-attribute`,r}}function oP(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=zM(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=zM(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return LN.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);sP(e)}function sP(e,t){let n=new FN("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=HN+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function cP(e){let t={},n;for(n in e)LN.call(e,n)&&(t[lP(n)]=e[n]);return t}function lP(e){let t=e.replace(zN,uP);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function uP(e){return`-`+e.toLowerCase()}var dP={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},fP={};function pP(e,t){let n=t||fP;return mP(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function mP(e,t,n){if(gP(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return hP(e.children,t,n)}return Array.isArray(e)?hP(e,t,n):``}function hP(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=mP(e[i],t,n);return r.join(``)}function gP(e){return!!(e&&typeof e==`object`)}var _P=document.createElement(`i`);function vP(e){let t=`&`+e+`;`;_P.innerHTML=t;let n=_P.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function yP(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function bP(e,t){return e.length>0?(yP(e,e.length,0,t),e):t}var xP={}.hasOwnProperty;function SP(e){let t={},n=-1;for(;++n<e.length;)CP(t,e[n]);return t}function CP(e,t){let n;for(n in t){let r=(xP.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){xP.call(r,a)||(r[a]=[]);let e=i[a];wP(r[a],Array.isArray(e)?e:e?[e]:[])}}}function wP(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);yP(e,0,0,r)}function TP(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function EP(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var DP=RP(/[A-Za-z]/),OP=RP(/[\dA-Za-z]/),kP=RP(/[#-'*+\--9=?A-Z^-~]/);function AP(e){return e!==null&&(e<32||e===127)}var jP=RP(/\d/),MP=RP(/[\dA-Fa-f]/),NP=RP(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function PP(e){return e!==null&&(e<0||e===32)}function FP(e){return e===-2||e===-1||e===32}var IP=RP(/\p{P}|\p{S}/u),LP=RP(/\s/);function RP(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function zP(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&OP(e.charCodeAt(n+1))&&OP(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function BP(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return FP(r)?(e.enter(n),s(r)):t(r)}function s(r){return FP(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var VP={tokenize:HP};function HP(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),BP(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return $(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var UP={tokenize:GP},WP={tokenize:KP};function GP(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return yP(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(WP,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(WP,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return $(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;yP(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function KP(e,t,n){return BP(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function qP(e){if(e===null||PP(e)||LP(e))return 1;if(IP(e))return 2}function JP(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var YP={name:`attention`,resolveAll:XP,tokenize:ZP};function XP(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};QP(d,-c),QP(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=bP(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=bP(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=bP(l,JP(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=bP(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=bP(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,yP(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function ZP(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=qP(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=qP(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function QP(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var $P={name:`autolink`,tokenize:eF};function eF(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return DP(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||OP(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||OP(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||AP(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):kP(t)?(e.consume(t),l):n(t)}function u(e){return OP(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||OP(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var tF={partial:!0,tokenize:nF};function nF(e,t,n){return r;function r(t){return FP(t)?BP(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$(e)?t(e):n(e)}}var rF={continuation:{tokenize:aF},exit:oF,name:`blockQuote`,tokenize:iF};function iF(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return FP(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function aF(e,t,n){let r=this;return i;function i(t){return FP(t)?BP(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(rF,t,n)(r)}}function oF(e){e.exit(`blockQuote`)}var sF={name:`characterEscape`,tokenize:cF};function cF(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return NP(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var lF={name:`characterReference`,tokenize:uF};function uF(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=OP,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=MP,u):(e.enter(`characterReferenceValue`),a=7,o=jP,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===OP&&!vP(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var dF={partial:!0,tokenize:mF},fF={concrete:!0,name:`codeFenced`,tokenize:pF};function pF(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),FP(t)?BP(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(dF,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):FP(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),BP(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&FP(t)?BP(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$(t)?e.check(dF,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),FP(t)?BP(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),FP(t)?BP(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function mF(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var hF={name:`codeIndented`,tokenize:_F},gF={partial:!0,tokenize:vF};function _F(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),BP(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):$(t)?e.attempt(gF,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||$(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function vF(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):BP(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):$(e)?i(e):n(e)}}var yF={name:`codeText`,previous:xF,resolve:bF,tokenize:SF};function bF(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function xF(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function SF(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||$(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var CF=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&wF(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),wF(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),wF(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);wF(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);wF(this.left,t.reverse())}}}};function wF(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function TF(e){let t={},n=-1,r,i,a,o,s,c,l,u=new CF(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,EF(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return yP(e,0,1/0,u.slice(0)),!l}function EF(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var DF={resolve:kF,tokenize:AF},OF={partial:!0,tokenize:jF};function kF(e){return TF(e),e}function AF(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):$(t)?e.check(OF,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function jF(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),BP(e,a,`linePrefix`)}function a(i){if(i===null||$(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function MF(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||AP(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||$(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||PP(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||AP(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function NF(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):$(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||$(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!FP(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function PF(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),BP(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function FF(e,t){let n;return r;function r(i){return $(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):FP(i)?BP(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var IF={name:`definition`,tokenize:RF},LF={partial:!0,tokenize:zF};function RF(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return NF.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=EP(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return PP(t)?FF(e,l)(t):l(t)}function l(t){return MF(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(LF,d,d)(t)}function d(t){return FP(t)?BP(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function zF(e,t,n){return r;function r(t){return PP(t)?FF(e,i)(t):n(t)}function i(t){return PF(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return FP(t)?BP(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$(e)?t(e):n(e)}}var BF={name:`hardBreakEscape`,tokenize:VF};function VF(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var HF={name:`headingAtx`,resolve:UF,tokenize:WF};function UF(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},yP(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function WF(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||PP(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$(n)?(e.exit(`atxHeading`),t(n)):FP(n)?BP(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||PP(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var GF=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),KF=[`pre`,`script`,`style`,`textarea`],qF={concrete:!0,name:`htmlFlow`,resolveTo:XF,tokenize:ZF},JF={partial:!0,tokenize:$F},YF={partial:!0,tokenize:QF};function XF(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function ZF(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):DP(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):DP(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return DP(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||PP(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&KF.includes(l)?(i=1,r.interrupt?t(s):O(s)):GF.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||OP(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return FP(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||DP(t)?(e.consume(t),b):FP(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||OP(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):FP(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):FP(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||PP(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||FP(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$(t)?O(t):FP(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),ee):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):$(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(JF,te,k)(t)):t===null||$(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(YF,A,te)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return KF.includes(n)?(e.consume(t),ee):O(t)}return DP(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),ee):t===45&&i===2?(e.consume(t),I):O(t)}function ee(t){return t===null||$(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),ee)}function te(n){return e.exit(`htmlFlow`),t(n)}}function QF(e,t,n){let r=this;return i;function i(t){return $(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function $F(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(tF,t,n)}}var eI={name:`htmlText`,tokenize:tI};function tI(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):DP(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):DP(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):$(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):$(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):$(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return DP(t)?(e.consume(t),S):n(t)}function S(t){return t===45||OP(t)?(e.consume(t),S):C(t)}function C(t){return $(t)?(o=C,N(t)):FP(t)?(e.consume(t),C):M(t)}function w(t){return t===45||OP(t)?(e.consume(t),w):t===47||t===62||PP(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||DP(t)?(e.consume(t),E):$(t)?(o=T,N(t)):FP(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||OP(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$(t)?(o=D,N(t)):FP(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):$(t)?(o=O,N(t)):FP(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):$(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||PP(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||PP(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return FP(t)?BP(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var nI={name:`labelEnd`,resolveAll:oI,resolveTo:sI,tokenize:cI},rI={tokenize:lI},iI={tokenize:uI},aI={tokenize:dI};function oI(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&yP(e,0,e.length,n),e}function sI(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=bP(s,e.slice(a+1,a+r+3)),s=bP(s,[[`enter`,u,t]]),s=bP(s,JP(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=bP(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=bP(s,e.slice(o+1)),s=bP(s,[[`exit`,c,t]]),yP(e,a,e.length,s),e}function cI(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(EP(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(rI,u,o?u:d)(t):t===91?e.attempt(iI,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(aI,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function lI(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return PP(t)?FF(e,a)(t):a(t)}function a(t){return t===41?u(t):MF(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return PP(t)?FF(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?PF(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return PP(t)?FF(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function uI(e,t,n){let r=this;return i;function i(t){return NF.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(EP(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function dI(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var fI={name:`labelStartImage`,resolveAll:nI.resolveAll,tokenize:pI};function pI(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var mI={name:`labelStartLink`,resolveAll:nI.resolveAll,tokenize:hI};function hI(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var gI={name:`lineEnding`,tokenize:_I};function _I(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),BP(e,t,`linePrefix`)}}var vI={name:`thematicBreak`,tokenize:yI};function yI(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||$(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),FP(t)?BP(e,s,`whitespace`)(t):s(t))}}var bI={continuation:{tokenize:wI},exit:EI,name:`list`,tokenize:CI},xI={partial:!0,tokenize:DI},SI={partial:!0,tokenize:TI};function CI(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:jP(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(vI,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return jP(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(tF,r.interrupt?n:u,e.attempt(xI,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return FP(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function wI(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(tF,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,BP(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!FP(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(SI,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,BP(e,e.attempt(bI,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function TI(e,t,n){let r=this;return BP(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function EI(e){e.exit(this.containerState.type)}function DI(e,t,n){let r=this;return BP(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!FP(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var OI={name:`setextUnderline`,resolveTo:kI,tokenize:AI};function kI(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function AI(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),FP(t)?BP(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var jI={tokenize:MI};function MI(e){let t=this,n=e.attempt(tF,r,e.attempt(this.parser.constructs.flowInitial,i,BP(e,e.attempt(this.parser.constructs.flow,i,e.attempt(DF,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var NI={resolveAll:LI()},PI=II(`string`),FI=II(`text`);function II(e){return{resolveAll:LI(e===`text`?RI:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function LI(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function RI(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var zI=s({attentionMarkers:()=>qI,contentInitial:()=>VI,disable:()=>JI,document:()=>BI,flow:()=>UI,flowInitial:()=>HI,insideSpan:()=>KI,string:()=>WI,text:()=>GI}),BI={42:bI,43:bI,45:bI,48:bI,49:bI,50:bI,51:bI,52:bI,53:bI,54:bI,55:bI,56:bI,57:bI,62:rF},VI={91:IF},HI={[-2]:hF,[-1]:hF,32:hF},UI={35:HF,42:vI,45:[OI,vI],60:qF,61:OI,95:vI,96:fF,126:fF},WI={38:lF,92:sF},GI={[-5]:gI,[-4]:gI,[-3]:gI,33:fI,38:lF,42:YP,60:[$P,eI],91:mI,92:[BF,sF],93:nI,95:YP,96:yF},KI={null:[YP,NI]},qI={null:[42,95]},JI={null:[]};function YI(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=bP(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=JP(a,l.events,l),l.events):[]}function f(e,t){return ZI(p(e),t)}function p(e){return XI(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){$(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&yP(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function XI(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function ZI(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
101
+ `).length,a=t-r;return`line ${String(i)}, column ${String(a)}`}function yA(e,t){return[...`kind`in e?mA(e):hA(e),...t]}function bA(e){return e[0]?.message}function xA(e){return e.filter(e=>e.field===`body`)}function SA(e){return e.filter(e=>e.field===`name`)}function CA(e){return dA(e).names}function wA(e){let t=[],n=0;for(let r of dA(e).errors){if(r.at<n)continue;r.at>n&&t.push({start:n,text:e.slice(n,r.at),marked:!1});let i=Math.min(r.at+2,e.length);t.push({start:r.at,text:e.slice(r.at,i),marked:!0}),n=i}return n<e.length&&t.push({start:n,text:e.slice(n),marked:!1}),t}var TA=`px-3 py-[10px] font-sans text-body leading-[1.5] break-words [scrollbar-gutter:stable]`;function EA({id:e,value:t,invalid:n,describedBy:r,onChange:i}){let a=(0,m.useRef)(null);return(0,h.jsxs)(`div`,{className:`relative max-w-[75ch]`,children:[(0,h.jsxs)(`div`,{ref:a,"aria-hidden":`true`,"data-slot":`lint-overlay`,className:W(TA,`pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap`,`rounded-control border border-transparent bg-panel2 text-ink`),children:[wA(t).map(e=>(0,h.jsx)(`span`,{"data-lint-mark":e.marked?e.start:void 0,className:e.marked?`text-red underline decoration-red decoration-2 underline-offset-[3px]`:void 0,children:e.text},e.start)),`
102
+ `]}),(0,h.jsx)(cA,{id:e,rows:24,value:t,spellCheck:!1,"aria-invalid":n,"aria-describedby":r,className:W(TA,`relative block min-h-[520px] resize-y overflow-auto bg-transparent text-transparent caret-ink`),onChange:e=>{i(e.target.value)},onScroll:e=>{let t=a.current;t!==null&&(t.scrollTop=e.currentTarget.scrollTop,t.scrollLeft=e.currentTarget.scrollLeft)}})]})}function DA({entryId:e,category:t,from:n,onLeave:r}){let{api:i}=B(),a=_(),o=R(uy(i)),s=(0,m.useId)(),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),w=o.data?.entries,T=e??n,E=T===void 0?void 0:w?.find(e=>e.id===T),D=E===void 0?{category:t,mode:`text`,name:``,body:``}:{category:E.category,mode:E.mode,name:e===void 0?`${E.name} copy`:E.name,body:E.body},O=p??D,k=tt({mutationFn:t=>Oo(i,t,e),onSuccess:async e=>{if(!e.ok){y(e.fields);return}x(!0),await a.invalidateQueries({queryKey:uy(i).queryKey})}}),A=tt({mutationFn:e=>ko(i,e),onSuccess:async()=>{C(!1),await a.invalidateQueries({queryKey:uy(i).queryKey}),r(O.category)}});Qk(b,()=>{r(O.category)});let j=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},M=yA(O,v),N=bA(M),P=CA(O.body),F=O.body.trim()===``?[]:xA(M),I=O.name.trim()===``?[]:SA(M);return o.error===null?T!==void 0&&w===void 0?(0,h.jsx)(nA,{}):T!==void 0&&E===void 0?(0,h.jsx)(OA,{category:t,children:`That entry is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(ia,{to:`/entries`,search:{category:O.category},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(JO,{"aria-hidden":`true`,className:`size-[14px]`}),`Intros & Outros`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New entry`:`Edit entry`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${tA} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-[200px] flex-1`,children:[(0,h.jsx)(aA,{htmlFor:s,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(sA,{id:s,value:O.name,"aria-invalid":I.length>0,"aria-describedby":I.length===0?void 0:c,onChange:e=>{j({...O,name:e.target.value},`name`)}}),I.length===0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:I.map(e=>e.message).join(` `)})]}),(0,h.jsx)(oA,{label:`Category`,value:O.category,options:Sk,onPick:e=>{j({...O,category:e},`name`)}}),(0,h.jsx)(oA,{label:`Mode`,value:O.mode,options:Ck,describedBy:l,onPick:e=>{j({...O,mode:e},`mode`)}})]}),(0,h.jsx)(`p`,{id:l,className:`-mt-[6px] text-right text-small text-ink2`,children:Ek(O.mode)}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(aA,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(EA,{id:u,value:O.body,invalid:F.length>0,describedBy:F.length===0?void 0:d,onChange:e=>{j({...O,body:e},`body`)}})]}),(0,h.jsx)(eA,{onDelete:e===void 0?void 0:()=>{C(!0)},blocked:N,blockedId:f,pending:k.isPending,saved:b,cancel:(0,h.jsx)(J,{asChild:!0,children:(0,h.jsx)(ia,{to:`/entries`,search:{category:O.category},children:`Cancel`})}),errors:[k.error,A.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{k.mutate(O)}})]}),(0,h.jsx)(`div`,{className:`${tA} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Xk,{slots:P,body:O.body,lint:F,lintId:d,noSlots:Dk(O.mode)})})]}),(0,h.jsx)(Mk,{open:S,title:`Delete "${O.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:A.isPending,onConfirm:()=>{e!==void 0&&A.mutate(e)},onCancel:()=>{C(!1)}})]}):(0,h.jsx)(OA,{category:O.category,children:o.error.message})}function OA({category:e,children:t}){return(0,h.jsx)(rA,{back:(0,h.jsx)(ia,{to:`/entries`,search:{category:e},className:iA,children:`Back to Intros & Outros`}),children:t})}function kA(e){let{form:t}=e,n=[],r=[];if(t.sources.article===`generate`&&RA(n,IA(e.prompts,`article`,t.articlePrompt)),t.sources.audio===`generate`&&(RA(n,LA(e.entries,`intro`,t.intro)),RA(n,LA(e.entries,`outro`,t.outro))),t.sources.images===`generate`)for(let n of t.imagePrompts)RA(r,IA(e.prompts,`image`,n.name));return(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)&&RA(r,IA(e.prompts,`thumbnail`,t.thumbnailPrompt)),fA(n,r)}function AA(e){let t=kA(e),n={form:e.form,entries:e.entries,slots:t.map(e=>e.name),silenceGapSeconds:e.silenceGapSeconds},r=MD(n),i=Dy({draft:r,staged:jD(e.form.provided),requiredSlots:n.slots}),a=TD(r.subtitles??e.form.subtitles)?i:{ok:!1,fields:[...i.ok?[]:i.fields,{field:`subtitles.fontSize`,message:`Choose a whole subtitle font size from 16 to 120.`}]};return{fields:t,draft:r,result:a,blocker:MA(e.form,a)}}var jA=[`sources`,`provided.research`,`articlePrompt`,`provided.article`,`audio`,`provided.audio`,`imagePrompts`,`images`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`subtitles`,`title`,`intro`,`outro`,`llm`,`values`,`silenceGapSeconds`];function MA(e,t){let n=NA(e);if(n!==void 0)return n;if(t.ok)return;let r=[...t.fields].sort((e,t)=>PA(e.field)-PA(t.field))[0];return r===void 0?void 0:{field:r.field,hint:FA(e,r)}}function NA(e){let{sources:t,provided:n}=e,r=[];if(t.audio===`provide`&&n.audio!==void 0&&r.push(n.audio),t.images===`provide`&&r.push(...n.images),t.thumbnail===`provide`&&n.thumbnail!==void 0&&r.push(n.thumbnail),r.some(e=>e.error!==void 0))return{field:`provided`,hint:`Remove the upload that failed to play`};if(r.some(e=>e.file===void 0))return{field:`provided`,hint:`Wait for the uploads to finish to play`}}function PA(e){let t=jA.length;for(let[n,r]of jA.entries())(e===r||e.startsWith(`${r}.`))&&n<t&&(t=n);return t}function FA(e,t){if(t.field.startsWith(`values.`))return`Fill ${t.field.slice(7)} to play`;if(t.field.startsWith(`imagePrompts.`))return t.field.endsWith(`.number`)?`Set a Number between 1 and 20 to play`:`Pick an image prompt to play`;switch(t.field){case`title`:return e.title.trim()===``?`Name the video to play`:`Shorten the title to 200 characters to play`;case`imagePrompts`:return e.imagePrompts.length===0?`Tick an image prompt to play`:`Lower the Numbers to play: a run makes at most 60 images`;case`llm`:return`Pick an LLM provider and model to play`;case`articlePrompt`:return`Pick an article prompt to play`;case`audio`:return`Pick a narration provider to play`;case`audio.voice`:return`Pick a voice to play`;case`images`:return`Pick an image provider and model to play`;case`thumbnailPrompt`:return`Pick a thumbnail prompt to play`;case`provided.research`:return`Paste the research notes to play`;case`provided.article`:return`Paste the article to play`;case`provided.audio`:return`Attach the narration audio to play`;case`provided.images`:return e.provided.images.length>60?`Remove images to play: a run holds at most 60`:`Attach at least one image to play`;case`provided.thumbnail`:return`Attach the thumbnail image to play`;default:return t.message}}function IA(e,t,n){if(n!==``)return e.find(e=>e.kind===t&&e.name===n)?.body}function LA(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.body}function RA(e,t){t!==void 0&&e.push(t)}function zA({value:e,onPick:t}){let n=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`w-full`,children:[(0,h.jsx)(aA,{id:n,className:`mb-2`,children:`Format`}),(0,h.jsx)(Vk,{type:`single`,value:e,"aria-labelledby":n,className:`w-full`,onValueChange:e=>{(e===`16:9`||e===`9:16`)&&t(e)},children:[`16:9`,`9:16`].map(e=>(0,h.jsxs)(Hk,{value:e,"aria-label":e,className:`flex h-24 min-w-0 flex-1 flex-col items-center justify-center gap-2 py-2`,children:[(0,h.jsx)(`span`,{className:`flex h-12 items-center justify-center`,"aria-hidden":`true`,children:(0,h.jsx)(`span`,{"data-format-shape":e,className:`block rounded-[2px] border-2 border-current`,style:{width:e===`16:9`?64:27,aspectRatio:e===`16:9`?`16 / 9`:`9 / 16`}})}),(0,h.jsx)(`span`,{children:e})]},e))})]})}function BA({fields:e,values:t,problem:n,onChange:r}){if(e.length===0)return null;let i=e.filter(e=>e.group===`common`),a=e.filter(e=>e.group===`text`),o=e.filter(e=>e.group===`image`);return(0,h.jsxs)(`div`,{"data-tour":`play-keywords`,className:`flex min-w-0 flex-col gap-[14px]`,children:[i.length===0?null:(0,h.jsxs)(`div`,{"data-keywords":`common`,className:`mt-[6px]`,children:[(0,h.jsx)(HA,{name:`Common`}),(0,h.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>(0,h.jsx)(UA,{name:e.name,value:t[e.name]??``,problem:n(`values.${e.name}`),onChange:r},e.name))})]}),a.length===0&&o.length===0?null:(0,h.jsxs)(`div`,{"data-keywords":`sides`,className:`mt-[6px] grid grid-cols-[minmax(0,1fr)_1px_minmax(0,1fr)] gap-x-4`,children:[(0,h.jsx)(VA,{group:`text`,name:`Text`,fields:a,values:t,problem:n,onChange:r}),(0,h.jsx)(`div`,{"aria-hidden":`true`,className:`bg-line2`}),(0,h.jsx)(VA,{group:`image`,name:`Image`,fields:o,values:t,problem:n,onChange:r})]})]})}function VA({group:e,name:t,fields:n,values:r,problem:i,onChange:a}){return(0,h.jsxs)(`div`,{"data-keywords":e,className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(HA,{name:t}),n.map(e=>(0,h.jsx)(UA,{name:e.name,value:r[e.name]??``,problem:i(`values.${e.name}`),onChange:a},e.name))]})}function HA({name:e}){return(0,h.jsxs)(`div`,{className:`mt-1 mb-[6px] flex items-center gap-3`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-line2`}),(0,h.jsx)(`h3`,{className:`font-condensed text-label font-bold text-ink uppercase tracking-[0.12em]`,children:e}),(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-line2`})]})}function UA({name:e,value:t,problem:n,onChange:r}){let i=(0,m.useId)(),a=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(aA,{htmlFor:i,className:`mb-[5px]`,children:e}),(0,h.jsx)(sA,{id:i,value:t,maxLength:200,spellCheck:!1,"aria-invalid":n!==void 0,"aria-describedby":n===void 0?void 0:a,onChange:t=>{r(e,t.target.value)}}),n===void 0?null:(0,h.jsx)(`p`,{id:a,className:`mt-1 text-label text-red`,children:n})]})}function WA({className:e,children:t,...n}){return(0,h.jsxs)(`span`,{className:`relative inline-flex min-w-0 items-center`,children:[(0,h.jsx)(`select`,{"data-slot":`picker`,className:W(`h-8 w-full min-w-0 appearance-none rounded-control border border-line2 bg-panel2`,`py-[5px] pr-[26px] pl-[10px] text-small text-ink aria-invalid:border-red`,e),...n,children:t}),(0,h.jsx)(qO,{"aria-hidden":`true`,className:`pointer-events-none absolute right-[8px] size-[14px] text-ink2`})]})}var GA=e=>[`provider-models`,e];async function KA(e,t,n=!1,r){let i=`${e.origin}/api/providers/${encodeURIComponent(t)}/models${n?`?refresh=1`:``}`;return Za(await e.fetch(i,r?{signal:r}:void 0))}function qA(e,t){return et({queryKey:GA(t),queryFn:({signal:n})=>KA(e,t,!1,n),enabled:t!==``,staleTime:3e4,refetchInterval:3e4,retry:!1})}function JA(e){return e!==``&&e!==`fal`&&e!==`replicate`}function YA({label:e,problem:t,inline:n=!1,children:r}){let i=(0,m.useId)(),a=(0,m.useId)();return(0,h.jsxs)(`div`,{className:W(n?`flex min-w-0 max-w-full items-center gap-[10px]`:`min-w-0`),children:[(0,h.jsx)(aA,{htmlFor:i,className:n?`shrink-0`:`mb-[5px]`,children:e}),r({id:i,describedBy:t===void 0?void 0:a}),t===void 0?null:(0,h.jsx)(`p`,{id:a,className:W(`text-label text-red`,n?``:`mt-1`),children:t})]})}function XA({label:e,value:t,problem:n,inline:r,placeholder:i,options:a,disabled:o=!1,onPick:s}){return(0,h.jsx)(YA,{label:e,problem:n,inline:r,children:({id:e,describedBy:c})=>(0,h.jsxs)(WA,{id:e,value:t,disabled:o,"aria-invalid":n!==void 0,"aria-describedby":c,className:r===!0?`w-auto min-w-[120px]`:void 0,onChange:e=>{s(e.target.value)},children:[(0,h.jsx)(`option`,{value:``,children:i}),a.map(e=>(0,h.jsx)(`option`,{value:e.value,disabled:e.disabled===!0,children:e.label},e.value))]})})}function ZA(e,t){return e.filter(e=>e.family===t).map(e=>{let t=QA(e);return{value:e.id,label:t===void 0?e.displayName:`${e.displayName} · ${t}`,disabled:t!==void 0}})}function QA(e){let{readiness:t}=e;return t.kind===`cli`?t.installed?void 0:`CLI missing`:t.hasKey?void 0:`Key missing`}function $A({label:e,family:t,providers:n,value:r,problem:i,inline:a,onPick:o}){return(0,h.jsx)(XA,{label:e,value:r,problem:i,inline:a,placeholder:`Pick a provider`,options:ZA(n,t),onPick:o})}function ej(e){return(0,h.jsx)(tj,{...e},e.provider)}function tj({label:e,provider:t,value:n,problem:r,inline:i,onPick:a}){let{api:o}=B(),s=_(),c=R(qA(o,t)),[l,u]=(0,m.useState)(!1),d=(0,m.useId)(),f=(0,m.useId)(),p=tt({mutationFn:()=>KA(o,t,!0),onSuccess:e=>s.setQueryData(GA(t),e)}),g=c.data?.models??[],v=c.data?.allowsCustom??JA(t),y=l&&v,b=c.isFetching||p.isPending,x=p.error?.message??c.error?.message??c.data?.warning,S=n!==``&&!g.some(e=>e.id===n);return(0,h.jsxs)(`div`,{className:`min-w-0 max-w-full`,children:[(0,h.jsx)(YA,{label:e,problem:r,inline:i,children:({id:e,describedBy:o})=>{let s=[o,x?d:void 0,c.data?.notice?f:void 0].filter(Boolean).join(` `)||void 0;return(0,h.jsx)(`div`,{className:W(`min-w-0 [&>span]:w-full`,i?`max-w-[260px]`:`w-full`),children:y?(0,h.jsx)(sA,{id:e,value:n,spellCheck:!1,placeholder:`Type the model id`,"aria-invalid":r!==void 0,"aria-describedby":s,className:i?`w-[180px] max-w-full`:void 0,onChange:e=>a(e.target.value)}):(0,h.jsxs)(WA,{id:e,value:n,disabled:t===``,"aria-invalid":r!==void 0,"aria-describedby":s,className:i?`w-full min-w-[120px] max-w-[260px]`:void 0,onChange:e=>a(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:t===``?`Pick a provider first`:c.isPending?`Loading models…`:`Pick a model`}),S?(0,h.jsxs)(`option`,{value:n,children:[n,` (saved model)`]}):null,g.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})}}),t===``?null:(0,h.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(0,h.jsxs)(J,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":`Refresh ${e} list`,title:`Refresh models`,disabled:b,onClick:()=>p.mutate(),children:[(0,h.jsx)(nk,{"aria-hidden":`true`,className:W(`size-3`,b&&`animate-spin motion-reduce:animate-none`)}),`Refresh`]}),v?(0,h.jsx)(J,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":y?`Choose ${e} from list`:`Enter ${e} ID`,onClick:()=>u(!y),children:y?`Use list`:`Custom ID`}):null]}),c.data?.notice?(0,h.jsx)(`p`,{id:f,className:`mt-1 max-w-[360px] text-label text-ink3`,children:c.data.notice}):null,x?(0,h.jsx)(`p`,{id:d,className:`mt-1 max-w-[360px] text-label text-ink3`,role:`status`,children:x}):null]})}function nj({choice:e,onChange:t}){let{api:n}=B(),r=R(qA(n,e.provider)).data?.models.find(t=>t.id===e.model)?.thinkingModes??[];return!r.length&&!e.thinking?null:(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(XA,{label:`Thinking`,value:e.thinking??`default`,placeholder:`Model default`,problem:e.thinking&&!r.includes(e.thinking)?`Choose a supported thinking level.`:void 0,options:[{value:`default`,label:`Model default`},...r.map(e=>({value:e,label:e===`off`?`Off`:e.charAt(0).toUpperCase()+e.slice(1)}))],onPick:n=>{let i=r.find(e=>e===n);t({...e,thinking:i})}}),r.length&&!r.includes(`off`)?(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink3`,children:`This model does not support turning thinking off.`}):null]})}function rj({children:e,form:t,providers:n,entries:r,fields:i,problem:a,blocker:o,failure:s,pending:c,update:l,onPlay:u}){let d=(0,m.useId)(),f=(0,m.useId)(),p=o!==void 0||c;return(0,h.jsxs)(`aside`,{"data-play-cue":`true`,className:`flex h-fit min-w-0 flex-col gap-[14px] rounded-panel border border-line bg-panel p-[18px] min-[1180px]:sticky min-[1180px]:top-6`,children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Cue sheet`}),(0,h.jsxs)(`div`,{"data-tour":`play-options`,className:`flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(aA,{htmlFor:d,className:`mb-[5px]`,children:`Video title`}),(0,h.jsx)(sA,{id:d,value:t.title,maxLength:200,"aria-invalid":a(`title`)!==void 0,onChange:e=>{l({title:e.target.value})}}),(0,h.jsx)(aj,{message:a(`title`)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-[10px]`,children:[(0,h.jsx)(zA,{value:t.format,onPick:e=>l({format:e})}),t.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{className:`min-w-[120px] flex-1`,children:(0,h.jsx)(ij,{label:`Intro`,category:`intro`,entries:r,value:t.intro,problem:a(`intro`),onPick:e=>{l({intro:e})}})}),(0,h.jsx)(`div`,{className:`min-w-[120px] flex-1`,children:(0,h.jsx)(ij,{label:`Outro`,category:`outro`,entries:r,value:t.outro,problem:a(`outro`),onPick:e=>{l({outro:e})}})})]}):null]}),kD(t,r)?(0,h.jsxs)(`div`,{className:`flex gap-[10px]`,children:[(0,h.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,h.jsx)($A,{label:`LLM`,family:`llm`,providers:n,value:t.llm.provider,problem:a(`llm`),onPick:e=>{l({llm:{provider:e,model:``}})}})}),(0,h.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,h.jsx)(ej,{label:`Model`,provider:t.llm.provider,value:t.llm.model,problem:void 0,onPick:e=>{l({llm:{...t.llm,model:e}})}})})]}):null]}),kD(t,r)?(0,h.jsx)(nj,{choice:t.llm,onChange:e=>l({llm:e})}):null,e,(0,h.jsx)(BA,{fields:i,values:t.values,problem:a,onChange:(e,n)=>{l({values:{...t.values,[e]:n}})}}),s===void 0?null:(0,h.jsx)(`p`,{className:`text-small text-red`,role:`alert`,children:s}),o===void 0?null:(0,h.jsx)(`p`,{id:f,className:`mt-1 text-center text-small text-ink2`,children:o.hint}),(0,h.jsxs)(J,{"data-tour":`play-start`,variant:`play`,size:`play`,"aria-disabled":p,"aria-describedby":o===void 0?void 0:f,onClick:()=>{p||u()},children:[(0,h.jsx)(Ec,{className:`relative top-[2px] size-[22px]`}),`PLAY`]})]})}function ij({label:e,category:t,entries:n,value:r,problem:i,onPick:a}){return(0,h.jsx)(XA,{label:e,value:r,placeholder:`Off`,options:n.filter(e=>e.category===t).map(e=>({value:e.name,label:e.name})),problem:i,onPick:a})}function aj({message:e}){return e===void 0?null:(0,h.jsx)(`p`,{className:`mt-1 text-label text-red`,children:e})}function oj({items:e,fields:t,title:n,values:r,onChange:i}){let a=(0,m.useId)();return(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-3`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-body font-medium`,children:[`Queue keyword variations `,e.length?`(${e.length+1} videos)`:``]}),(0,h.jsx)(`p`,{className:`my-3 text-small text-ink2`,children:`The setup above is video 1. Add videos with different titles and keywords. They run one at a time; a failed video releases the next, and a pause holds the queue.`}),e.map((n,o)=>(0,h.jsxs)(`fieldset`,{className:`mb-3 flex min-w-0 flex-col gap-2 border-t border-line pt-3`,children:[(0,h.jsxs)(`legend`,{className:`text-small text-ink2`,children:[`Video `,o+2]}),(0,h.jsxs)(`label`,{htmlFor:`${a}-${n.key}-title`,className:`text-small`,children:[`Title`,(0,h.jsx)(sA,{id:`${a}-${n.key}-title`,value:n.title,maxLength:200,onChange:t=>i(e.map(e=>e.key===n.key?{...e,title:t.target.value}:e))})]}),t.map(t=>(0,h.jsxs)(`label`,{htmlFor:`${a}-${n.key}-${encodeURIComponent(t.name)}`,className:`text-small`,children:[t.name,(0,h.jsx)(sA,{id:`${a}-${n.key}-${encodeURIComponent(t.name)}`,value:n.values[t.name]??r[t.name]??``,onChange:r=>i(e.map(e=>e.key===n.key?{...e,values:{...e.values,[t.name]:r.target.value}}:e))})]},t.name)),(0,h.jsxs)(J,{onClick:()=>i(e.filter(e=>e.key!==n.key)),children:[`Remove video `,o+2]})]},n.key)),(0,h.jsx)(J,{disabled:e.length>=49,onClick:()=>i([...e,{key:crypto.randomUUID(),title:`${n||`Video`} ${e.length+2}`,values:{...r}}]),children:`Add keyword variation`})]})}function sj({draft:e,items:t,pending:n,failure:r,onStart:i,onClose:a}){let{api:o}=B(),s=(0,m.useId)(),[c,l]=(0,m.useState)(1500),u={draft:e,expectedWords:c,...t.length?{items:[{title:e.title,values:e.values},...t.map(({title:e,values:t})=>({title:e,values:t}))]}:{}},d=R({queryKey:[`run-estimate`,u],retry:!1,queryFn:async()=>Za(await o.fetch(`${o.origin}/api/projects/estimate`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(u)}))}),f=d.data?.estimates??[],p=f.reduce((e,t)=>e+t.low,0),g=f.reduce((e,t)=>e+t.high,0),_=f.reduce((e,t)=>e+t.unknown,0),v=f[0]?.rows.map((e,t)=>({...e,low:f.some(e=>e.rows[t]?.low===null)?null:f.reduce((e,n)=>e+(n.rows[t]?.low??0),0),high:f.some(e=>e.rows[t]?.high===null)?null:f.reduce((e,n)=>e+(n.rows[t]?.high??0),0)}))??[];return(0,h.jsx)(Xv,{open:!0,onOpenChange:e=>{!e&&!n&&a()},children:(0,h.jsxs)($v,{className:`max-h-[90dvh] overflow-y-auto sm:max-w-2xl`,children:[(0,h.jsxs)(ey,{children:[`Review `,t.length?`${t.length+1} queued videos`:`run cost`]}),(0,h.jsx)(ty,{children:`Estimated provider charges in USD. Starting authorizes the selected jobs; this estimate does not cap spending.`}),e.sources.article===`generate`?(0,h.jsxs)(`label`,{htmlFor:s,className:`text-body`,children:[`Expected article words per video`,(0,h.jsx)(sA,{id:s,type:`number`,min:1,max:1e5,value:c,disabled:n,onChange:e=>l(Math.min(1e5,Math.max(1,Number(e.target.value)||1)))})]}):null,d.isFetching?(0,h.jsx)(`p`,{role:`status`,className:`text-body text-ink2`,children:`Calculating estimate…`}):null,d.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-body text-red`,children:d.error.message}):null,d.data?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{className:`text-title font-bold`,children:[_?`Known subtotal: `:`Estimated total: `,cj(p,g)]}),_?(0,h.jsxs)(`p`,{className:`text-body text-ink2`,children:[`Plus `,_,` stage charge`,_===1?``:`s`,` with unavailable pricing.`]}):null,(0,h.jsx)(`div`,{className:`divide-y divide-line`,children:v.map(e=>(0,h.jsxs)(`div`,{className:`py-2`,children:[(0,h.jsxs)(`div`,{className:`flex justify-between gap-4 text-body`,children:[(0,h.jsx)(`span`,{children:e.stage}),(0,h.jsx)(`span`,{children:e.low===null||e.high===null?`Unknown`:cj(e.low,e.high)})]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:e.detail})]},e.stage))}),f[0]?.assumptions.map(e=>(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e},e)),(0,h.jsxs)(`p`,{className:`text-small text-ink3`,children:[`Catalogue verified `,f[0]?.catalogueDate??`date unavailable`,`. Batch rows show combined costs.`]})]}):null,r?(0,h.jsx)(`p`,{role:`alert`,className:`text-body text-red`,children:r}):null,(0,h.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,h.jsx)(J,{disabled:n,onClick:a,children:`Back`}),(0,h.jsx)(J,{disabled:n||d.isFetching||!d.data||d.isError,onClick:i,children:n?`Starting…`:t.length?`Queue ${t.length+1} videos`:`Start run`})]})]})})}function cj(e,t){let n=e=>e===0?`$0`:e<.01?`<$0.01`:`$${e.toFixed(2)}`;return e===t?n(e):`${n(e)} – ${n(t)}`}var lj={mode:`whole`};function uj(e,t){let n=e??lj,r=t??lj;return n.mode===r.mode?n.mode===`words`?(n.words??500)===(r.words??500):n.mode!==`characters`||(n.characters??3e3)===(r.characters??3e3):!1}function dj({label:e,hideLabel:t=!1,value:n,options:r,className:i,onPick:a}){let o=(0,m.useId)();return(0,h.jsxs)(`span`,{className:W(`inline-flex items-center gap-[10px]`,i),children:[(0,h.jsx)(aA,{id:o,className:t?`sr-only`:`shrink-0`,children:e}),(0,h.jsx)(Vk,{type:`single`,value:n,"aria-labelledby":o,onValueChange:e=>{let t=r.find(t=>t.value===e);t!==void 0&&t.disabled!==!0&&a(t.value)},children:r.map(e=>(0,h.jsx)(Hk,{value:e.value,disabled:e.disabled===!0,children:e.label},e.value))})]})}function fj({value:e,onPick:t}){let n=e.words??500,r=e.characters??3e3,i=e.mode===`words`||e.mode===`characters`,a=e.mode===`characters`,o=a?e.characters:e.words;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(dj,{label:`Chunking`,className:`min-w-0 max-w-full flex-wrap [&_[data-slot=toggle-group]]:max-w-full [&_[data-slot=toggle-group]]:flex-wrap`,value:e.mode,options:[{value:`whole`,label:`Whole`},{value:`paragraph`,label:`Paragraph`},{value:`words`,label:`Every ${String(n)} words`},{value:`characters`,label:`Every ${String(r)} characters`}],onPick:e=>{t(e===`words`?{mode:e,words:n}:e===`characters`?{mode:e,characters:r}:{mode:e})}}),i?(0,h.jsx)(YA,{label:a?`Characters`:`Words`,problem:void 0,inline:!0,children:({id:e})=>(0,h.jsx)(sA,{id:e,type:`number`,min:1,max:a?1e6:1e4,inputMode:`numeric`,className:`w-[100px] tabular-nums`,value:o===void 0?``:String(o),onChange:e=>{let n=Number.parseInt(e.target.value,10),r=Number.isFinite(n)&&n>0;t(a?r?{mode:`characters`,characters:Math.min(n,1e6)}:{mode:`characters`}:r?{mode:`words`,words:Math.min(n,1e4)}:{mode:`words`})}})}):null,a?(0,h.jsx)(`p`,{className:`basis-full text-small text-ink3`,children:`Ends at the last complete sentence within the character count, including spaces. A longer sentence stays whole; provider request limits still apply.`}):null]})}var pj=1;function mj({prompts:e,picked:t,problem:n,onPick:r}){let i=(0,m.useId)(),a=t.reduce((e,t)=>e+t.number,0);return e.length===0?(0,h.jsx)(`p`,{className:`basis-full text-right text-small text-ink3`,children:`No image prompts saved. Write one on Prompts.`}):(0,h.jsxs)(`div`,{className:`flex basis-full flex-col items-end gap-[6px]`,children:[(0,h.jsx)(`span`,{id:i,className:`engraved text-ink3`,children:`Image prompts`}),(0,h.jsx)(`ul`,{"aria-labelledby":i,className:`flex flex-wrap justify-end gap-x-4 gap-y-2`,children:e.map(e=>{let i=t.findIndex(t=>t.name===e.name),a=i===-1?void 0:t[i];return(0,h.jsx)(`li`,{children:(0,h.jsx)(hj,{name:e.name,number:a?.number,problem:i===-1?void 0:n(`imagePrompts.${String(i)}.number`),onTick:n=>{r(n?[...t,{name:e.name,number:pj}]:t.filter(t=>t.name!==e.name))},onNumber:n=>{r(t.map(t=>t.name===e.name?{name:t.name,number:n}:t))}})},e.id)})}),t.length===0?null:(0,h.jsx)(`span`,{className:`text-label text-ink3 tabular-nums`,children:`${String(a)} of 60 images`})]})}function hj({name:e,number:t,problem:n,onTick:r,onNumber:i}){let a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)();return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{id:a,type:`checkbox`,checked:t!==void 0,className:`size-[14px] shrink-0 accent-accent`,onChange:e=>{r(e.target.checked)}}),(0,h.jsx)(`label`,{htmlFor:a,className:t===void 0?`text-ink3`:`text-ink`,children:e}),(0,h.jsx)(aA,{htmlFor:o,className:`sr-only`,children:`Number for ${e}`}),(0,h.jsx)(sA,{id:o,type:`number`,min:pj,max:20,inputMode:`numeric`,disabled:t===void 0,"aria-invalid":n!==void 0,"aria-describedby":n===void 0?void 0:s,className:`w-[64px] tabular-nums`,value:t===void 0||t===0?``:String(t),onChange:e=>{let t=Number.parseInt(e.target.value,10);i(Number.isFinite(t)?t:0)}}),n===void 0?null:(0,h.jsx)(`span`,{id:s,className:`text-label text-red`,children:n})]})}var gj=`text-small text-ink2 file:mr-3 file:h-8 file:rounded-control file:border file:border-line2 file:bg-panel2 file:px-3 file:text-ink`;function _j({label:e,value:t,placeholder:n,problem:r,onChange:i}){let a=(0,m.useId)(),o=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(aA,{htmlFor:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(cA,{id:a,rows:6,value:t,placeholder:n,"aria-invalid":r!==void 0,"aria-describedby":r===void 0?void 0:o,onChange:e=>{i(e.target.value)}}),r===void 0?null:(0,h.jsx)(`p`,{id:o,className:`mt-1 text-label text-red`,children:r})]})}function vj({label:e,accept:t,multiple:n=!1,uploads:r,problem:i,numbered:a=!1,onPick:o,onRemove:s}){let c=(0,m.useId)(),l=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(aA,{htmlFor:c,className:`mb-[5px]`,children:e}),(0,h.jsx)(`input`,{id:c,type:`file`,accept:t,multiple:n,"aria-invalid":i!==void 0,"aria-describedby":i===void 0?void 0:l,className:gj,onChange:e=>{o([...e.target.files??[]])}}),i===void 0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:i}),r.length===0?null:(0,h.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:r.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex items-center gap-3`,children:[a?(0,h.jsx)(`span`,{className:`engraved w-6 text-ink3`,children:String(t+1)}):null,(0,h.jsx)(yj,{upload:e}),s===void 0?null:(0,h.jsx)(J,{variant:`ghost`,className:`ml-auto`,"aria-label":`Remove ${e.name}`,onClick:()=>{s(e.key)},children:`Remove`})]},e.key))})]})}function yj({upload:e}){return(0,h.jsxs)(`span`,{className:`flex items-center gap-3 text-small`,children:[(0,h.jsx)(`span`,{className:e.error===void 0?`text-ink`:`text-red`,children:e.name}),e.error===void 0?(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e.file===void 0?`Copying`:`Staged`}):(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.error})]})}var bj={pending:`text-ink3`,running:`text-run-text`,done:`text-done`,failed:`text-red`,canceled:`text-amber`,paused:`text-amber`,provided:`text-ink2`,skipped:`text-ink3`};function xj({state:e,announce:t,className:n}){return(0,h.jsxs)(`span`,{className:W(`inline-flex items-center`,n),children:[(0,h.jsx)(`span`,{"data-state":e,className:W(`engraved font-bold`,bj[e]),children:e}),t===void 0?null:(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${t}: ${e}`})]})}var Sj={pending:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`,running:`bg-lamp-run shadow-[0_0_0_3px_var(--color-lamp-halo)] animate-lamp-pulse motion-reduce:animate-none`,done:`bg-done`,failed:`bg-red`,canceled:`bg-amber`,paused:`bg-amber`,provided:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`,skipped:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`};function Cj({state:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-lamp":e,className:W(`size-[10px] shrink-0 rounded-full`,Sj[e],t)})}var wj=`grid grid-cols-[14px_24px_110px_auto_minmax(0,1fr)]`,Tj=`col-start-5 flex flex-wrap items-center justify-end gap-[10px]`,Ej=`col-span-4 col-start-2 mt-[10px]`;function Dj({kind:e,name:t,dim:n,children:r}){return(0,h.jsxs)(Pk,{"data-tour":`play-${e}`,className:wj,children:[(0,h.jsx)(Cj,{state:`pending`}),(0,h.jsx)(Tc,{kind:e,className:n?`text-ink3`:`text-ink2`}),(0,h.jsx)(`span`,{className:W(`font-semibold`,n?`text-ink3`:void 0),children:t}),r]})}function Oj({kind:e,form:t,update:n}){return(0,h.jsx)(dj,{label:`${e} source`,hideLabel:!0,value:t.sources[e],options:OD(e).map(n=>({...n,disabled:e===`video`&&n.value===`generate`&&t.sources.images===`off`})),onPick:r=>{n({sources:{...t.sources,[e]:r,...e===`images`&&r===`off`?{video:`off`}:{}}})}})}function kj(e,t){return e.filter(e=>e.kind===t).map(e=>({value:e.name,label:e.name}))}function Aj({form:e,providers:t,voices:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o}){let s=n.filter(t=>t.provider===e.audio.provider);return(0,h.jsxs)(Dj,{kind:`audio`,name:`Audio`,dim:e.sources.audio===`off`,children:[(0,h.jsx)(Oj,{kind:`audio`,form:e,update:i}),(0,h.jsx)(`div`,{className:Tj,children:e.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)($A,{label:`TTS`,inline:!0,family:`tts`,providers:t,value:e.audio.provider,problem:r(`audio`),onPick:e=>{i({audio:{provider:e,model:``,voice:``}})}}),(0,h.jsx)(ej,{label:`TTS model`,inline:!0,provider:e.audio.provider,value:e.audio.model,problem:void 0,onPick:t=>i({audio:{...e.audio,model:t}})}),(0,h.jsx)(XA,{label:`Voice`,inline:!0,value:e.audio.voice,placeholder:s.length===0?`No voices. Add one in Settings.`:`Pick a voice`,options:s.map(e=>({value:e.voiceId,label:e.name})),problem:r(`audio.voice`),onPick:t=>{i({audio:{...e.audio,voice:t}})}}),(0,h.jsx)(fj,{value:e.chunking,onPick:e=>{i({chunking:e})}})]}):null}),e.sources.audio===`provide`?(0,h.jsxs)(`div`,{className:Ej,children:[(0,h.jsx)(vj,{label:`Narration file`,accept:`audio/*`,uploads:e.provided.audio===void 0?[]:[e.provided.audio],problem:r(`provided.audio`),onPick:e=>{a(`audio`,e)},onRemove:e=>{o(`audio`,e)}}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:`Uploaded narration is used as-is; include any intro and outro in that file.`})]}):null]})}function jj({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o}){return(0,h.jsxs)(Dj,{kind:`images`,name:`Images`,dim:e.sources.images===`off`,children:[(0,h.jsx)(Oj,{kind:`images`,form:e,update:i}),(0,h.jsx)(`div`,{className:Tj,children:e.sources.images===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Mj,{form:e,providers:t,problem:r,update:i}),(0,h.jsx)(mj,{prompts:n.filter(e=>e.kind===`image`),picked:e.imagePrompts,problem:r,onPick:e=>{i({imagePrompts:e})}})]}):null}),e.sources.images===`provide`?(0,h.jsx)(`div`,{className:Ej,children:(0,h.jsx)(vj,{label:`Slideshow images`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,numbered:!0,uploads:e.provided.images,problem:r(`provided.images`),onPick:e=>{a(`images`,e)},onRemove:e=>{o(`images`,e)}})}):null]})}function Mj({form:e,providers:t,problem:n,update:r}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)($A,{label:`Provider`,inline:!0,family:`image`,providers:t,value:e.images.provider,problem:n(`images`),onPick:e=>r({images:{provider:e,model:``}})}),(0,h.jsx)(ej,{label:`Model`,inline:!0,provider:e.images.provider,value:e.images.model,problem:void 0,onPick:t=>r({images:{...e.images,model:t}})})]})}var Nj=[`fonts`];async function Pj(e){return Za(await e.fetch(`${e.origin}/api/fonts`))}async function Fj(e,t){let n=new FormData;return n.set(`file`,t),Za(await e.fetch(`${e.origin}/api/fonts`,{method:`POST`,body:n}))}function Ij(e,t){return`${e.origin}/api/fonts/${encodeURIComponent(t)}/file`}function Lj({value:e,onPick:t,onUploading:n}){let{api:r}=B(),i=_(),a=(0,m.useId)(),o=(0,m.useId)(),s=R({queryKey:Nj,queryFn:()=>Pj(r),staleTime:6e4}),c=tt({mutationFn:e=>Fj(r,e),onSuccess:({font:e})=>{i.setQueryData(Nj,t=>({fonts:[...(t?.fonts??[]).filter(t=>t.id!==e.id),e]})),i.invalidateQueries({queryKey:Nj})}}),l=(0,m.useRef)(t);l.current=t;let u=(0,m.useRef)(n);u.current=n,(0,m.useEffect)(()=>{u.current(c.isPending)},[c.isPending]),(0,m.useEffect)(()=>()=>u.current(!1),[]);let d=s.data?.fonts??[],f=e!=="default"&&!d.some(t=>t.id===e);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 basis-full`,children:[(0,h.jsx)(aA,{htmlFor:a,className:`mb-1`,children:`Subtitle font`}),(0,h.jsxs)(`select`,{id:a,value:e,disabled:c.isPending,onChange:e=>t(e.target.value),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:[d.some(e=>e.id==="default")?null:(0,h.jsx)(`option`,{value:`default`,children:`Default font · bundled`}),f?(0,h.jsxs)(`option`,{value:e,children:[e,` · saved font`]}):null,d.map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.source]},e.id))]})]}),(0,h.jsxs)(`div`,{className:`min-w-0 basis-full`,children:[(0,h.jsx)(aA,{htmlFor:o,className:`mb-1`,children:`Upload font (.ttf or .otf)`}),(0,h.jsx)(`input`,{id:o,type:`file`,accept:`.ttf,.otf,font/ttf,font/otf`,disabled:c.isPending,className:`w-full text-small text-ink2 file:mr-2 file:rounded-control file:border file:border-line2 file:bg-panel2 file:px-2 file:py-1 file:text-ink`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&c.mutate(t,{onSuccess:({font:e})=>l.current(e.id)})}})]})]}),c.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-small text-ink2`,children:`Uploading font…`}):null,c.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:c.error.message}):null,s.error?(0,h.jsxs)(`p`,{role:`alert`,className:`text-small text-red`,children:[`Could not load fonts. `,s.error.message]}):null]})}function Rj(e){return e===`9:16`?{width:1080,height:1920}:{width:1920,height:1080}}function zj(e,t){switch(e){case`top`:return{y:60,alignment:8,translateY:0};case`upper-middle`:return{y:t/4,alignment:5,translateY:-50};case`center`:return{y:t/2,alignment:5,translateY:-50};case`lower-middle`:return{y:t*3/4,alignment:5,translateY:-50};case`bottom`:return{y:t-60,alignment:2,translateY:-100}}}function Bj({value:e,format:t}){let{api:n}=B(),r=Ij(n,e.fontId),i=`subtitle-preview-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,[a,o]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(typeof FontFace>`u`||!document.fonts)return;let e=!0,t=new FontFace(i,`url(${JSON.stringify(r)})`);return o(!1),t.load().then(t=>{e&&document.fonts.add(t)}).catch(()=>{e&&o(!0)}),()=>{e=!1,document.fonts.delete(t)}},[i,r]);let s=Rj(t),c=zj(e.position??`bottom`,s.height),l=Number.isFinite(e.fontSize)?Math.max(16,Math.min(120,e.fontSize)):48;return(0,h.jsxs)(`figure`,{className:`min-w-0 self-start`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-label text-ink2`,children:[(0,h.jsx)(`span`,{children:`Style preview`}),(0,h.jsx)(`span`,{children:t})]}),(0,h.jsx)(`div`,{role:`img`,"aria-label":`Subtitle style preview`,"data-format":t,"data-position":e.position??`bottom`,className:`relative mx-auto w-full overflow-hidden rounded-control border border-line2 bg-screen text-center text-white`,style:{aspectRatio:`${s.width} / ${s.height}`,maxWidth:t===`9:16`?240:480,containerType:`inline-size`},children:(0,h.jsx)(`span`,{style:{position:`absolute`,left:`50%`,top:`${c.y/s.height*100}%`,width:`${(s.width-120)/s.width*100}%`,transform:`translate(-50%, ${c.translateY}%)`,fontFamily:`"${i}", sans-serif`,fontSize:`${l/s.width*100}cqw`,lineHeight:1.2,overflowWrap:`anywhere`,WebkitTextStroke:`${2.5/s.width*100}cqw #101010`,paintOrder:`stroke fill`,textShadow:`0 ${100/s.width}cqw ${100/s.width}cqw #000`},children:`Every story begins with a word.`})}),(0,h.jsxs)(`figcaption`,{className:`mt-2 text-label text-ink3`,children:[s.width,` × `,s.height,` · Preview at reduced scale.`,a?` Font preview unavailable; showing a fallback.`:``]})]})}function Vj({value:e,format:t=`16:9`,audioEnabled:n,videoEnabled:r,disabled:i=!1,onChange:a,onUploading:o,problem:s}){let c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),[f,p]=(0,m.useState)(!1),g=s?.(`subtitles.fontId`),_=s?.(`subtitles.fontSize`),v=s?.(`subtitles.mode`)??s?.(`subtitles`);return(0,h.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Subtitles`,children:[(0,h.jsxs)(`fieldset`,{disabled:i||!n,className:`flex min-w-0 flex-col gap-3 disabled:opacity-60`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(aA,{htmlFor:c,className:`mb-1`,children:`Subtitles`}),(0,h.jsxs)(`select`,{id:c,value:n?e.mode:`off`,disabled:f,"aria-describedby":u,"aria-invalid":v!==void 0,onChange:t=>a({...e,mode:t.target.value}),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:[(0,h.jsx)(`option`,{value:`off`,children:`Off`}),(0,h.jsx)(`option`,{value:`files`,children:`Subtitle files (.srt + .vtt)`}),(0,h.jsx)(`option`,{value:`burn-in`,disabled:!r,children:`Burn into video + files`})]})]}),(0,h.jsx)(`span`,{className:`pb-1 text-label text-ink3`,children:`English · local · no paid API`})]}),e.mode!==`off`&&n?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Timed from your narration on this computer. First use downloads an approximately 95 MB speech model. Review the subtitles before publishing.`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(min(100%, 240px), 1fr))`},children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(Lj,{value:e.fontId,onPick:t=>a({...e,fontId:t}),onUploading:e=>{p(e),o?.(e)}}),(0,h.jsxs)(`div`,{className:`max-w-[180px]`,children:[(0,h.jsx)(aA,{htmlFor:l,className:`mb-1`,children:`Subtitle font size`}),(0,h.jsx)(sA,{id:l,type:`number`,min:16,max:120,step:1,value:e.fontSize,"aria-invalid":!TD(e)||_!==void 0,onChange:t=>a({...e,fontSize:Number(t.target.value)})}),!TD(e)||_?(0,h.jsx)(`p`,{role:`alert`,className:`mt-1 text-label text-red`,children:_??`Choose a whole font size from 16 to 120.`}):null]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(aA,{htmlFor:d,className:`mb-1`,children:`Subtitle position`}),(0,h.jsx)(`select`,{id:d,value:e.position??`bottom`,onChange:t=>{let n=bD.find(e=>e===t.target.value);n&&a({...e,position:n})},className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:bD.map(e=>(0,h.jsxs)(`option`,{value:e,children:[e[0]?.toUpperCase(),e.slice(1)]},e))})]})]}),(0,h.jsx)(Bj,{value:e,format:t})]}),g?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:g}):null,e.mode===`files`?(0,h.jsx)(`p`,{className:`text-label text-ink3`,children:`Font, size and position apply to burned captions. SRT/VTT players choose their own styling.`}):null]}):null]}),v?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:v}):null,(0,h.jsx)(`p`,{id:u,className:`text-small text-ink2`,children:n?r?`Optional: download subtitles separately or keep them visible in the video.`:`Audio exports support separate subtitle files. Enable Video to burn captions into an MP4.`:`Turn Audio on to add subtitles.`})]})}function Hj(e){let{form:t}=e;return(0,h.jsxs)(Nk,{children:[t.sources.article===`provide`?null:(0,h.jsx)(Uj,{...e}),(0,h.jsx)(Wj,{...e}),(0,h.jsx)(Aj,{...e}),(0,h.jsx)(jj,{...e}),(0,h.jsx)(Gj,{...e}),(0,h.jsx)(Kj,{...e})]})}function Uj({form:e,problem:t,update:n}){return(0,h.jsxs)(Dj,{kind:`research`,name:`Research`,dim:e.sources.research===`off`,children:[(0,h.jsx)(Oj,{kind:`research`,form:e,update:n}),(0,h.jsx)(`div`,{className:Tj,children:e.sources.research===`generate`?(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:`Runs through the LLM, one agent per chapter`}):null}),e.sources.research===`provide`?(0,h.jsx)(`div`,{className:Ej,children:(0,h.jsx)(_j,{label:`Research notes`,value:e.provided.research,placeholder:`Paste the notes the article will be written from.`,problem:t(`provided.research`),onChange:t=>{n({provided:{...e.provided,research:t}})}})}):null]})}function Wj({form:e,prompts:t,problem:n,update:r}){return(0,h.jsxs)(Dj,{kind:`article`,name:`Article`,dim:!1,children:[(0,h.jsx)(Oj,{kind:`article`,form:e,update:r}),(0,h.jsx)(`div`,{className:Tj,children:e.sources.article===`generate`?(0,h.jsx)(XA,{label:`Article prompt`,inline:!0,value:e.articlePrompt,placeholder:`Pick a prompt`,options:kj(t,`article`),problem:n(`articlePrompt`),onPick:e=>{r({articlePrompt:e})}}):null}),e.sources.article===`provide`?(0,h.jsx)(`div`,{className:Ej,children:(0,h.jsx)(_j,{label:`Article text`,value:e.provided.article,placeholder:`Paste the article that will be narrated.`,problem:n(`provided.article`),onChange:t=>{r({provided:{...e.provided,article:t}})}})}):null]})}function Gj({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o}){let s=e.sources.thumbnail===`from_prompt`||e.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(Dj,{kind:`thumbnail`,name:`Thumbnail`,dim:e.sources.thumbnail===`off`,children:[(0,h.jsx)(Oj,{kind:`thumbnail`,form:e,update:i}),(0,h.jsxs)(`div`,{className:Tj,children:[s&&e.sources.images!==`generate`?(0,h.jsx)(Mj,{form:e,providers:t,problem:r,update:i}):null,s?(0,h.jsx)(XA,{label:`Thumbnail prompt`,inline:!0,value:e.thumbnailPrompt,placeholder:`Pick a prompt`,options:kj(n,`thumbnail`),problem:r(`thumbnailPrompt`),onPick:e=>{i({thumbnailPrompt:e})}}):null]}),e.sources.thumbnail===`provide`?(0,h.jsx)(`div`,{className:Ej,children:(0,h.jsx)(vj,{label:`Thumbnail image`,accept:`image/png,image/jpeg,image/webp`,uploads:e.provided.thumbnail===void 0?[]:[e.provided.thumbnail],problem:r(`provided.thumbnail`),onPick:e=>{a(`thumbnail`,e)},onRemove:e=>{o(`thumbnail`,e)}})}):null]})}function Kj({form:e,silenceGapSeconds:t,update:n,onSubtitleUpload:r,problem:i}){let a=e.sources.video===`generate`?e.sources.audio===`off`?`Silent video · 5 seconds per image`:`Images and narration · ${String(t)} s segment gaps`:e.sources.audio===`off`?`Download each enabled stage separately`:`Combined WAV export with narration and segment gaps`;return(0,h.jsxs)(Dj,{kind:`video`,name:`Video`,dim:e.sources.video===`off`,children:[(0,h.jsx)(Oj,{kind:`video`,form:e,update:n}),(0,h.jsx)(`span`,{className:Tj,children:(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:a})}),(0,h.jsx)(`div`,{"data-tour":`play-subtitles`,className:Ej,children:(0,h.jsx)(Vj,{value:CD(e.subtitles,e.sources),format:e.format,audioEnabled:e.sources.audio!==`off`,videoEnabled:e.sources.video===`generate`&&e.sources.images!==`off`,onChange:e=>n({subtitles:e}),problem:i,...r===void 0?{}:{onUploading:r}})}),e.sources.images===`off`?(0,h.jsx)(`p`,{className:`${Ej} text-small text-ink2`,children:`Video is Off because Images is Off. Generate or provide images to enable video.`}):null]})}function qj(){let e=Hi();return(0,h.jsx)(Jj,{onCreated:t=>{e({to:`/projects/$projectId`,params:{projectId:t}})}})}function Jj({onCreated:e}){let{api:t}=B(),n=_(),r=PO(),i=R(sy(t)),a=R(ly(t)),o=R(uy(t)),s=R(cy(t)),c=R(dy(t)),[l,u]=zD(),[d,f]=(0,m.useState)([]),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(()=>crypto.randomUUID()),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)([]),[w,T]=(0,m.useState)(!1),E=e=>{u(t=>{let n={...t,...e};return{...n,subtitles:CD(n.subtitles,n.sources)}}),y(crypto.randomUUID()),T(!0),C([])},{fields:D,draft:O,result:k,blocker:A}=AA({form:l,prompts:a.data?.prompts??[],entries:o.data?.entries??[],silenceGapSeconds:c.data?.silenceGapSeconds??3}),j=b?{field:`subtitles.fontId`,hint:`Wait for the subtitle font upload to finish to play`}:A,M=tt({mutationFn:async()=>{if(!d.length)return so(t,O);let e=(await Za(await t.fetch(`${t.origin}/api/projects/batch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({requestId:v,draft:O,items:[{title:O.title,values:O.values},...d.map(({title:e,values:t})=>({title:e,values:t}))]})}))).queue[0];if(!e)throw Error(`No videos were queued.`);return{ok:!0,value:{project:{id:e.projectId}}}},onSuccess:t=>{if(!t.ok){C(t.fields),g(!1);return}n.invalidateQueries({queryKey:ny.projects}),n.invalidateQueries({queryKey:ny.staging}),u(ED),f([]),y(crypto.randomUUID()),g(!1),r({type:`project-created`,id:t.value.project.id}),e(t.value.project.id)}}),N=k.ok?S:[...k.fields,...S],P=(...e)=>!N.some(t=>e.some(e=>t.field===e||t.field.startsWith(`${e}.`))),F=(e,t)=>(a.data?.prompts??[]).some(n=>n.kind===e&&n.name===t),I=e=>e?.file!==void 0&&e.error===void 0;NO({playArticleReady:P(`sources.article`,`articlePrompt`,`provided.article`)&&(l.sources.article===`provide`||F(`article`,l.articlePrompt)),playAudioReady:l.sources.audio===`off`||P(`sources.audio`,`audio`,`provided.audio`)&&(l.sources.audio!==`provide`||I(l.provided.audio)),playImagesReady:l.sources.images===`off`||P(`sources.images`,`images`,`imagePrompts`,`provided.images`)&&(l.sources.images===`provide`?l.provided.images.every(I):l.imagePrompts.every(e=>F(`image`,e.name))),playVideoReady:P(`sources.video`),playSubtitlesReady:P(`subtitles`)&&!b,playOptionsReady:P(`title`,`format`,`llm`,`intro`,`outro`),playHasKeywords:D.length>0,playKeywordsReady:P(`values`),playReady:j===void 0&&!M.isPending});let ee=e=>{let t=S.find(t=>t.field===e);if(t!==void 0)return t.message;if(w&&j?.field===e&&!k.ok)return k.fields.find(t=>t.field===e)?.message},te=()=>{j===void 0&&!M.isPending&&g(!0)},ne=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),te())},L=async(e,n,r)=>{try{let i=await co(t,e,n);re(r,e=>({...e,file:i}))}catch(e){re(r,t=>({...t,error:Xj(e)}))}},re=(e,t)=>{u(n=>({...n,provided:{...n.provided,audio:n.provided.audio?.key===e?t(n.provided.audio):n.provided.audio,thumbnail:n.provided.thumbnail?.key===e?t(n.provided.thumbnail):n.provided.thumbnail,images:n.provided.images.map(n=>n.key===e?t(n):n)}}))},ie=(e,t)=>{let n=t.map(Yj),r=n[n.length-1];u(t=>({...t,provided:e===`images`?{...t.provided,images:[...t.provided.images,...n]}:e===`audio`?{...t.provided,audio:r}:{...t.provided,thumbnail:r}})),C([]);for(let[r,i]of n.entries()){let n=t[r];n!==void 0&&L(e,n,i.key)}},ae=(e,t)=>{u(n=>({...n,provided:e===`images`?{...n.provided,images:n.provided.images.filter(e=>e.key!==t)}:e===`audio`?{...n.provided,audio:void 0}:{...n.provided,thumbnail:void 0}}))},oe=[i,a,o,s,c].find(e=>e.error!==null)?.error?.message;return(0,h.jsxs)(`div`,{onKeyDown:ne,"data-play-grid":`true`,className:`mx-auto grid max-w-[1440px] grid-cols-1 items-start gap-6 min-[1180px]:grid-cols-[minmax(0,1fr)_480px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`h1`,{className:`mb-1 text-title font-bold tracking-[-0.01em]`,children:`New run`}),(0,h.jsx)(`p`,{className:`mb-4 text-body text-ink2`,children:`Generate or provide an Article. Every other stage can be Off. Choose narration, images, and a video or combined audio export to suit your project.`}),oe===void 0?null:(0,h.jsx)(`p`,{className:`mb-4 text-body text-red`,children:oe}),(0,h.jsx)(Hj,{form:l,providers:i.data?.providers??[],prompts:a.data?.prompts??[],voices:s.data?.voices??[],silenceGapSeconds:c.data?.silenceGapSeconds??3,problem:ee,update:E,onPickFiles:ie,onRemoveFile:ae,onSubtitleUpload:x})]}),(0,h.jsx)(rj,{form:l,providers:i.data?.providers??[],entries:o.data?.entries??[],fields:D,problem:ee,blocker:j,failure:M.error===null?void 0:M.error.message,pending:M.isPending,update:E,onPlay:te,children:(0,h.jsx)(oj,{items:d,fields:D,title:l.title,values:l.values,onChange:e=>{f(e),y(crypto.randomUUID())}})}),p?(0,h.jsx)(sj,{draft:O,items:d,pending:M.isPending,failure:M.error?.message??S.map(e=>e.message).join(` `),onClose:()=>g(!1),onStart:()=>M.mutate()}):null]})}function Yj(e){return{key:crypto.randomUUID(),name:e.name,file:void 0,error:void 0}}function Xj(e){return e instanceof Error?e.message:String(e)}function Zj(){let{api:e}=B(),t=R({queryKey:[`batch-queue`],queryFn:async()=>Za(await e.fetch(`${e.origin}/api/projects/queue`)),refetchInterval:2e3,retry:!1}),n=R(ry(e));return t.data?.queue.length?(0,h.jsxs)(`details`,{className:`mb-4 rounded-panel border border-line bg-panel p-3`,open:!0,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-body font-semibold`,children:[`Video queue · `,t.data.queue.length,` remaining`]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`One batch video runs at a time. Pause holds the queue; failure or cancellation advances it.`}),(0,h.jsx)(`ol`,{className:`mt-2 max-h-40 overflow-y-auto`,children:t.data.queue.map((e,t)=>{let r=n.data?.projects.find(t=>t.id===e.projectId);return(0,h.jsxs)(`li`,{className:`flex justify-between gap-3 py-1 text-small`,children:[(0,h.jsxs)(ia,{className:`truncate underline`,to:`/projects/$projectId`,params:{projectId:e.projectId},children:[t+1,`. `,r?.title??`Video`]}),(0,h.jsx)(`span`,{className:`shrink-0 text-ink2`,children:r?.status===`paused`?`Paused`:e.state===`active`?`Active`:`Queued`})]},e.projectId)})})]}):null}function Qj(e,t){return e.filter(e=>e.stageKind===t.kind)}function $j(e,t){return e.find(e=>e.role===t)}var eM={research:`Replaces the notes, then re-runs the enabled stages below.`,article:`Replaces the article, then re-runs the enabled stages below.`,audio:`Replaces the narration and refreshes the final audio or video export.`,images:`Replaces every image in this run and re-renders video when enabled.`,thumbnail:`Replaces the thumbnail.`,video:`Replaces the final audio or video export.`};function tM(e){switch(e.kind){case`cancel`:return{title:`Cancel this run?`,consequence:`Stops every running stage; finished outputs are kept.`,verb:`Cancel run`,dismiss:`Keep running`};case`rerun`:return{title:`Re-run this stage?`,consequence:eM[e.stage],verb:`Re-run`,dismiss:`Cancel`};case`delete-image`:return{title:`Delete this image?`,consequence:`Removes the image and re-renders video when enabled.`,verb:`Delete`,dismiss:`Cancel`};case`regenerate-image`:return{title:`Regenerate this image?`,consequence:`Replaces the image with a new one and re-renders video when enabled.`,verb:`Regenerate`,dismiss:`Cancel`};case`save-article`:return{title:`Save the edited article?`,consequence:`Replaces the article, then updates the enabled narration and final export.`,verb:`Save & update outputs`,dismiss:`Cancel`};case`discard-article`:return{title:`Discard these edits?`,consequence:`The article goes back to the text on disk.`,verb:`Discard`,dismiss:`Keep editing`}}}function nM({action:e,run:t,disabled:n=!1,pending:r=!1,variant:i=`outline`,className:a,children:o}){let[s,c]=(0,m.useState)(!1),l=tM(e);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(J,{type:`button`,variant:i,disabled:n,className:W(i===`ghost`?`px-2 text-small`:void 0,a),onClick:()=>{c(!0)},children:o}),(0,h.jsx)(Mk,{open:s,title:l.title,consequence:l.consequence,verb:l.verb,dismiss:l.dismiss,pending:r,onConfirm:()=>{c(!1),t()},onCancel:()=>{c(!1)}})]})}var rM=e=>[`live-writing`,e];function iM(e,t){let n=e.find(e=>e.callId===t.callId),r=(t.reset?t.text:`${n?.text??``}${t.text}`).slice(-65536),i={stage:t.stage,callId:t.callId,...t.label===void 0?{}:{label:t.label},text:r};return(n?e.map(e=>e.callId===t.callId?i:e):[...e,i]).slice(-24)}function aM({projectId:e,stage:t}){let n=(R({queryKey:rM(e),queryFn:()=>[],enabled:!1}).data??[]).filter(e=>e.stage===t),[r,i]=(0,m.useState)(),a=n.find(e=>e.callId===r)??n.at(-1),[o,s]=(0,m.useState)(!0),c=(0,m.useRef)(null);return(0,m.useEffect)(()=>{a?.text&&o&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[o,a?.text]),n.length===0&&t!==`research`&&t!==`article`?null:(0,h.jsxs)(`div`,{className:`mx-5 mt-5 rounded-control border border-line2 bg-panel2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-run-text`,children:`Live writing`}),n.length>1?(0,h.jsx)(WA,{"aria-label":`Live writing task`,value:a?.callId??``,onChange:e=>i(e.target.value),className:`max-w-[280px]`,children:n.map((e,t)=>(0,h.jsxs)(`option`,{value:e.callId,children:[e.label??`Writing`,` · `,t+1]},e.callId))}):null,(0,h.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-label text-ink2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Follow output`]})]}),(0,h.jsx)(`section`,{ref:c,"aria-label":`Live writing preview`,tabIndex:0,className:`max-h-[360px] min-h-32 overflow-auto whitespace-pre-wrap break-words p-4 font-sans text-small leading-relaxed text-ink2`,children:a?.text||`Waiting for the provider's first text…`}),(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-2 text-label text-ink3`,children:`Live preview. The complete output is saved when this stage finishes.`})]})}function oM(e){let t=e.role.replaceAll(`_`,`-`);return e.role===`instructions`?`${e.stageKind}-${t}`:e.role===`image`&&e.meta.index!==void 0?`${t}-${String(e.meta.index)}`:t}function sM(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var cM=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lM=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,uM={};function dM(e,t){return((t||uM).jsx?lM:cM).test(e)}var fM=/[ \t\n\f\r]/g;function pM(e){return typeof e==`object`?e.type===`text`&&mM(e.value):mM(e)}function mM(e){return e.replace(fM,``)===``}var hM=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};hM.prototype.normal={},hM.prototype.property={},hM.prototype.space=void 0;function gM(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new hM(n,r,t)}function _M(e){return e.toLowerCase()}var vM=class{constructor(e,t){this.attribute=t,this.property=e}};vM.prototype.attribute=``,vM.prototype.booleanish=!1,vM.prototype.boolean=!1,vM.prototype.commaOrSpaceSeparated=!1,vM.prototype.commaSeparated=!1,vM.prototype.defined=!1,vM.prototype.mustUseProperty=!1,vM.prototype.number=!1,vM.prototype.overloadedBoolean=!1,vM.prototype.property=``,vM.prototype.spaceSeparated=!1,vM.prototype.space=void 0;var yM=s({boolean:()=>Z,booleanish:()=>xM,commaOrSpaceSeparated:()=>TM,commaSeparated:()=>wM,number:()=>Q,overloadedBoolean:()=>SM,spaceSeparated:()=>CM}),bM=0,Z=EM(),xM=EM(),SM=EM(),Q=EM(),CM=EM(),wM=EM(),TM=EM();function EM(){return 2**++bM}var DM=Object.keys(yM),OM=class extends vM{constructor(e,t,n,r){let i=-1;if(super(e,t),kM(this,`space`,r),typeof n==`number`)for(;++i<DM.length;){let e=DM[i];kM(this,DM[i],(n&yM[e])===yM[e])}}};OM.prototype.defined=!0;function kM(e,t,n){n&&(e[t]=n)}function AM(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new OM(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[_M(r)]=r,n[_M(a.attribute)]=r}return new hM(t,n,e.space)}var jM=AM({properties:{ariaActiveDescendant:null,ariaAtomic:xM,ariaAutoComplete:null,ariaBusy:xM,ariaChecked:xM,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:CM,ariaCurrent:null,ariaDescribedBy:CM,ariaDetails:null,ariaDisabled:xM,ariaDropEffect:CM,ariaErrorMessage:null,ariaExpanded:xM,ariaFlowTo:CM,ariaGrabbed:xM,ariaHasPopup:null,ariaHidden:xM,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:CM,ariaLevel:Q,ariaLive:null,ariaModal:xM,ariaMultiLine:xM,ariaMultiSelectable:xM,ariaOrientation:null,ariaOwns:CM,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:xM,ariaReadOnly:xM,ariaRelevant:null,ariaRequired:xM,ariaRoleDescription:CM,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:xM,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function MM(e,t){return t in e?e[t]:t}function NM(e,t){return MM(e,t.toLowerCase())}var PM=AM({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:wM,acceptCharset:CM,accessKey:CM,action:null,allow:null,allowFullScreen:Z,allowPaymentRequest:Z,allowUserMedia:Z,alpha:Z,alt:null,as:null,async:Z,autoCapitalize:null,autoComplete:CM,autoFocus:Z,autoPlay:Z,blocking:CM,capture:null,charSet:null,checked:Z,cite:null,className:CM,closedBy:null,colorSpace:null,cols:Q,colSpan:Q,command:null,commandFor:null,content:null,contentEditable:xM,controls:Z,controlsList:CM,coords:Q|wM,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Z,defer:Z,dir:null,dirName:null,disabled:Z,download:SM,draggable:xM,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Z,formTarget:null,headers:CM,height:Q,hidden:SM,high:Q,href:null,hrefLang:null,htmlFor:CM,httpEquiv:CM,id:null,imageSizes:null,imageSrcSet:null,inert:Z,inputMode:null,integrity:null,is:null,isMap:Z,itemId:null,itemProp:CM,itemRef:CM,itemScope:Z,itemType:CM,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Z,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Z,muted:Z,name:null,nonce:null,noModule:Z,noValidate:Z,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Z,optimum:Q,pattern:null,ping:CM,placeholder:null,playsInline:Z,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Z,referrerPolicy:null,rel:CM,required:Z,reversed:Z,rows:Q,rowSpan:Q,sandbox:CM,scope:null,scoped:Z,seamless:Z,selected:Z,shadowRootClonable:Z,shadowRootCustomElementRegistry:Z,shadowRootDelegatesFocus:Z,shadowRootMode:null,shadowRootSerializable:Z,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:xM,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Z,useMap:null,value:xM,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:CM,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Z,declare:Z,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Z,noHref:Z,noShade:Z,noWrap:Z,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:xM,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Z,disablePictureInPicture:Z,disableRemotePlayback:Z,exportParts:wM,part:CM,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:NM}),FM=AM({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:TM,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:CM,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Z,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:wM,g2:wM,glyphName:wM,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:TM,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:CM,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:TM,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:TM,rev:TM,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:TM,requiredFeatures:TM,requiredFonts:TM,requiredFormats:TM,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:TM,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:TM,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:TM,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:MM}),IM=AM({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),LM=AM({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:NM}),RM=AM({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),zM={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},BM=/[A-Z]/g,VM=/-[a-z]/g,HM=/^data[-\w.:]+$/i;function UM(e,t){let n=_M(t),r=t,i=vM;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&HM.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(VM,GM);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!VM.test(e)){let n=e.replace(BM,WM);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=OM}return new i(r,t)}function WM(e){return`-`+e.toLowerCase()}function GM(e){return e.charAt(1).toUpperCase()}var KM=gM([jM,PM,IM,LM,RM],`html`),qM=gM([jM,FM,IM,LM,RM],`svg`);function JM(e){return e.join(` `).trim()}var YM=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
103
+ `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),XM=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(YM());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),ZM=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),QM=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(XM()),r=ZM();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),$M=tN(`end`),eN=tN(`start`);function tN(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function nN(e){let t=eN(e),n=$M(e);if(t&&n)return{start:t,end:n}}function rN(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?aN(e.position):`start`in e||`end`in e?aN(e):`line`in e||`column`in e?iN(e):``}function iN(e){return oN(e&&e.line)+`:`+oN(e&&e.column)}function aN(e){return iN(e&&e.start)+`-`+iN(e&&e.end)}function oN(e){return e&&typeof e==`number`?e:1}var sN=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=rN(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};sN.prototype.file=``,sN.prototype.name=``,sN.prototype.reason=``,sN.prototype.message=``,sN.prototype.stack=``,sN.prototype.column=void 0,sN.prototype.line=void 0,sN.prototype.ancestors=void 0,sN.prototype.cause=void 0,sN.prototype.fatal=void 0,sN.prototype.place=void 0,sN.prototype.ruleId=void 0,sN.prototype.source=void 0;var cN=l(QM(),1),lN={}.hasOwnProperty,uN=new Map,dN=/[A-Z]/g,fN=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),pN=new Set([`td`,`th`]),mN=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function hN(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=EN(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=TN(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?qM:KM,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=gN(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function gN(e,t,n){if(t.type===`element`)return _N(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return vN(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return bN(e,t,n);if(t.type===`mdxjsEsm`)return yN(e,t);if(t.type===`root`)return xN(e,t,n);if(t.type===`text`)return SN(e,t)}function _N(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=qM,e.schema=i),e.ancestors.push(t);let a=MN(e,t.tagName,!1),o=DN(e,t),s=kN(e,t);return fN.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!pM(e)})),CN(e,o,a,t),wN(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function vN(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}NN(e,t.position)}function yN(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);NN(e,t.position)}function bN(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=qM,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:MN(e,t.name,!0),o=ON(e,t),s=kN(e,t);return CN(e,o,a,t),wN(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function xN(e,t,n){let r={};return wN(r,kN(e,t)),e.create(t,e.Fragment,r,n)}function SN(e,t){return t.value}function CN(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function wN(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function TN(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function EN(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=eN(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function DN(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&lN.call(t.properties,i)){let a=AN(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&pN.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function ON(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else NN(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else NN(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function kN(e,t){let n=[],r=-1,i=e.passKeys?new Map:uN;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=gN(e,a,o);s!==void 0&&n.push(s)}return n}function AN(e,t,n){let r=UM(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?sM(n):JM(n)),r.property===`style`){let t=typeof n==`object`?n:jN(e,String(n));return e.stylePropertyNameCase===`css`&&(t=PN(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?zM[r.property]||r.property:r.attribute,n]}}function jN(e,t){try{return(0,cN.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new sN("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=mN+`#cannot-parse-style-attribute`,r}}function MN(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=dM(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=dM(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return lN.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);NN(e)}function NN(e,t){let n=new sN("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=mN+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function PN(e){let t={},n;for(n in e)lN.call(e,n)&&(t[FN(n)]=e[n]);return t}function FN(e){let t=e.replace(dN,IN);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function IN(e){return`-`+e.toLowerCase()}var LN={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},RN={};function zN(e,t){let n=t||RN;return BN(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function BN(e,t,n){if(HN(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return VN(e.children,t,n)}return Array.isArray(e)?VN(e,t,n):``}function VN(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=BN(e[i],t,n);return r.join(``)}function HN(e){return!!(e&&typeof e==`object`)}var UN=document.createElement(`i`);function WN(e){let t=`&`+e+`;`;UN.innerHTML=t;let n=UN.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function GN(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function KN(e,t){return e.length>0?(GN(e,e.length,0,t),e):t}var qN={}.hasOwnProperty;function JN(e){let t={},n=-1;for(;++n<e.length;)YN(t,e[n]);return t}function YN(e,t){let n;for(n in t){let r=(qN.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){qN.call(r,a)||(r[a]=[]);let e=i[a];XN(r[a],Array.isArray(e)?e:e?[e]:[])}}}function XN(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);GN(e,0,0,r)}function ZN(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function QN(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var $N=uP(/[A-Za-z]/),eP=uP(/[\dA-Za-z]/),tP=uP(/[#-'*+\--9=?A-Z^-~]/);function nP(e){return e!==null&&(e<32||e===127)}var rP=uP(/\d/),iP=uP(/[\dA-Fa-f]/),aP=uP(/[!-/:-@[-`{-~]/);function $(e){return e!==null&&e<-2}function oP(e){return e!==null&&(e<0||e===32)}function sP(e){return e===-2||e===-1||e===32}var cP=uP(/\p{P}|\p{S}/u),lP=uP(/\s/);function uP(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function dP(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&eP(e.charCodeAt(n+1))&&eP(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function fP(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return sP(r)?(e.enter(n),s(r)):t(r)}function s(r){return sP(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var pP={tokenize:mP};function mP(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),fP(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return $(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var hP={tokenize:_P},gP={tokenize:vP};function _P(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return GN(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(gP,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(gP,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return $(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;GN(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function vP(e,t,n){return fP(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function yP(e){if(e===null||oP(e)||lP(e))return 1;if(cP(e))return 2}function bP(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var xP={name:`attention`,resolveAll:SP,tokenize:CP};function SP(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};wP(d,-c),wP(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=KN(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=KN(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=KN(l,bP(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=KN(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=KN(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,GN(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function CP(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=yP(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=yP(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function wP(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var TP={name:`autolink`,tokenize:EP};function EP(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return $N(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||eP(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||eP(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||nP(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):tP(t)?(e.consume(t),l):n(t)}function u(e){return eP(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||eP(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var DP={partial:!0,tokenize:OP};function OP(e,t,n){return r;function r(t){return sP(t)?fP(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||$(e)?t(e):n(e)}}var kP={continuation:{tokenize:jP},exit:MP,name:`blockQuote`,tokenize:AP};function AP(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return sP(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function jP(e,t,n){let r=this;return i;function i(t){return sP(t)?fP(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(kP,t,n)(r)}}function MP(e){e.exit(`blockQuote`)}var NP={name:`characterEscape`,tokenize:PP};function PP(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return aP(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var FP={name:`characterReference`,tokenize:IP};function IP(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=eP,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=iP,u):(e.enter(`characterReferenceValue`),a=7,o=rP,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===eP&&!WN(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var LP={partial:!0,tokenize:BP},RP={concrete:!0,name:`codeFenced`,tokenize:zP};function zP(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),sP(t)?fP(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||$(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(LP,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):sP(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),fP(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||$(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||$(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&sP(t)?fP(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||$(t)?e.check(LP,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||$(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),sP(t)?fP(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),sP(t)?fP(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||$(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function BP(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var VP={name:`codeIndented`,tokenize:UP},HP={partial:!0,tokenize:WP};function UP(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),fP(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):$(t)?e.attempt(HP,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||$(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function WP(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):fP(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):$(e)?i(e):n(e)}}var GP={name:`codeText`,previous:qP,resolve:KP,tokenize:JP};function KP(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function qP(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function JP(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||$(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var YP=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&XP(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),XP(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),XP(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);XP(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);XP(this.left,t.reverse())}}}};function XP(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ZP(e){let t={},n=-1,r,i,a,o,s,c,l,u=new YP(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,QP(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return GN(e,0,1/0,u.slice(0)),!l}function QP(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var $P={resolve:tF,tokenize:nF},eF={partial:!0,tokenize:rF};function tF(e){return ZP(e),e}function nF(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):$(t)?e.check(eF,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function rF(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),fP(e,a,`linePrefix`)}function a(i){if(i===null||$(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function iF(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||nP(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||$(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||oP(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||nP(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function aF(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):$(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||$(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!sP(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function oF(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):$(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),fP(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||$(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function sF(e,t){let n;return r;function r(i){return $(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):sP(i)?fP(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var cF={name:`definition`,tokenize:uF},lF={partial:!0,tokenize:dF};function uF(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return aF.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=QN(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return oP(t)?sF(e,l)(t):l(t)}function l(t){return iF(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(lF,d,d)(t)}function d(t){return sP(t)?fP(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||$(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function dF(e,t,n){return r;function r(t){return oP(t)?sF(e,i)(t):n(t)}function i(t){return oF(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return sP(t)?fP(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||$(e)?t(e):n(e)}}var fF={name:`hardBreakEscape`,tokenize:pF};function pF(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return $(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var mF={name:`headingAtx`,resolve:hF,tokenize:gF};function hF(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},GN(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function gF(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||oP(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||$(n)?(e.exit(`atxHeading`),t(n)):sP(n)?fP(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||oP(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var _F=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),vF=[`pre`,`script`,`style`,`textarea`],yF={concrete:!0,name:`htmlFlow`,resolveTo:SF,tokenize:CF},bF={partial:!0,tokenize:TF},xF={partial:!0,tokenize:wF};function SF(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function CF(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):$N(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):$N(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return $N(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||oP(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&vF.includes(l)?(i=1,r.interrupt?t(s):O(s)):_F.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||eP(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return sP(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||$N(t)?(e.consume(t),b):sP(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||eP(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):sP(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):sP(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||$(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||oP(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||sP(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||$(t)?O(t):sP(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),ee):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):$(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(bF,te,k)(t)):t===null||$(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(xF,A,te)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||$(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return vF.includes(n)?(e.consume(t),ee):O(t)}return $N(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),ee):t===45&&i===2?(e.consume(t),I):O(t)}function ee(t){return t===null||$(t)?(e.exit(`htmlFlowData`),te(t)):(e.consume(t),ee)}function te(n){return e.exit(`htmlFlow`),t(n)}}function wF(e,t,n){let r=this;return i;function i(t){return $(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function TF(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(DP,t,n)}}var EF={name:`htmlText`,tokenize:DF};function DF(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):$N(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):$N(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):$(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):$(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):$(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):$(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return $N(t)?(e.consume(t),S):n(t)}function S(t){return t===45||eP(t)?(e.consume(t),S):C(t)}function C(t){return $(t)?(o=C,N(t)):sP(t)?(e.consume(t),C):M(t)}function w(t){return t===45||eP(t)?(e.consume(t),w):t===47||t===62||oP(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||$N(t)?(e.consume(t),E):$(t)?(o=T,N(t)):sP(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||eP(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):$(t)?(o=D,N(t)):sP(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):$(t)?(o=O,N(t)):sP(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):$(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||oP(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||oP(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return sP(t)?fP(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var OF={name:`labelEnd`,resolveAll:MF,resolveTo:NF,tokenize:PF},kF={tokenize:FF},AF={tokenize:IF},jF={tokenize:LF};function MF(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&GN(e,0,e.length,n),e}function NF(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=KN(s,e.slice(a+1,a+r+3)),s=KN(s,[[`enter`,u,t]]),s=KN(s,bP(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=KN(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=KN(s,e.slice(o+1)),s=KN(s,[[`exit`,c,t]]),GN(e,a,e.length,s),e}function PF(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(QN(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(kF,u,o?u:d)(t):t===91?e.attempt(AF,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(jF,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function FF(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return oP(t)?sF(e,a)(t):a(t)}function a(t){return t===41?u(t):iF(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return oP(t)?sF(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?oF(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return oP(t)?sF(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function IF(e,t,n){let r=this;return i;function i(t){return aF.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(QN(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function LF(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var RF={name:`labelStartImage`,resolveAll:OF.resolveAll,tokenize:zF};function zF(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var BF={name:`labelStartLink`,resolveAll:OF.resolveAll,tokenize:VF};function VF(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var HF={name:`lineEnding`,tokenize:UF};function UF(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),fP(e,t,`linePrefix`)}}var WF={name:`thematicBreak`,tokenize:GF};function GF(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||$(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),sP(t)?fP(e,s,`whitespace`)(t):s(t))}}var KF={continuation:{tokenize:XF},exit:QF,name:`list`,tokenize:YF},qF={partial:!0,tokenize:$F},JF={partial:!0,tokenize:ZF};function YF(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:rP(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(WF,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return rP(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(DP,r.interrupt?n:u,e.attempt(qF,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return sP(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function XF(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(DP,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,fP(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!sP(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(JF,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,fP(e,e.attempt(KF,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function ZF(e,t,n){let r=this;return fP(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function QF(e){e.exit(this.containerState.type)}function $F(e,t,n){let r=this;return fP(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!sP(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var eI={name:`setextUnderline`,resolveTo:tI,tokenize:nI};function tI(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function nI(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),sP(t)?fP(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||$(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var rI={tokenize:iI};function iI(e){let t=this,n=e.attempt(DP,r,e.attempt(this.parser.constructs.flowInitial,i,fP(e,e.attempt(this.parser.constructs.flow,i,e.attempt($P,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var aI={resolveAll:lI()},oI=cI(`string`),sI=cI(`text`);function cI(e){return{resolveAll:lI(e===`text`?uI:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function lI(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function uI(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var dI=s({attentionMarkers:()=>yI,contentInitial:()=>pI,disable:()=>bI,document:()=>fI,flow:()=>hI,flowInitial:()=>mI,insideSpan:()=>vI,string:()=>gI,text:()=>_I}),fI={42:KF,43:KF,45:KF,48:KF,49:KF,50:KF,51:KF,52:KF,53:KF,54:KF,55:KF,56:KF,57:KF,62:kP},pI={91:cF},mI={[-2]:VP,[-1]:VP,32:VP},hI={35:mF,42:WF,45:[eI,WF],60:yF,61:eI,95:WF,96:RP,126:RP},gI={38:FP,92:NP},_I={[-5]:HF,[-4]:HF,[-3]:HF,33:RF,38:FP,42:xP,60:[TP,EF],91:BF,92:[fF,NP],93:OF,95:xP,96:GP},vI={null:[xP,aI]},yI={null:[42,95]},bI={null:[]};function xI(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=KN(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=bP(a,l.events,l),l.events):[]}function f(e,t){return CI(p(e),t)}function p(e){return SI(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){$(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&GN(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function SI(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function CI(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
104
104
  `;break;case-3:o=`\r
105
- `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function QI(e){let t={constructs:SP([zI,...(e||{}).extensions||[]]),content:n(VP),defined:[],document:n(UP),flow:n(jI),lazy:{},string:n(PI),text:n(FI)};return t;function n(e){return n;function n(n){return YI(t,e,n)}}}function $I(e){for(;!TF(e););return e}var eL=/[\0\t\n\r]/g;function tL(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(eL.lastIndex=u,c=eL.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var nL=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function rL(e){return e.replace(nL,iL)}function iL(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return TP(n.slice(t?2:1),t?16:10)}return vP(n)||e}var aL={}.hasOwnProperty;function oL(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),sL(n)($I(QI(n).document().write(tL()(e,t,!0))))}function sL(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(_e),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(pe),blockQuote:a(ce),characterEscape:T,characterReference:T,codeFenced:a(le),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(le,o),codeText:a(ue,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(fe),hardBreakEscape:a(me),hardBreakTrailing:a(me),htmlFlow:a(he,o),htmlFlowData:T,htmlText:a(he,o),htmlTextData:T,image:a(ge),label:o,link:a(_e),listItem:a(ye),listItemValue:f,listOrdered:a(ve,d),listUnordered:a(ve),paragraph:a(be),reference:ne,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(pe),strong:a(xe),thematicBreak:a(Ce)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:se,autolinkProtocol:oe,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ie,characterReference:ae,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:L,resourceDestinationString:I,resourceTitleString:ee,resource:te,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};lL(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];aL.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||dL).call(a,void 0,e[0])}for(r.position={start:cL(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:cL(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:cL(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||dL).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+jN({start:e.start,end:e.end})+`): it’s not open`);n.position.end=cL(e.end)}function u(){return pP(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=EP(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Se(),n.position={start:cL(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=cL(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=cL(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=rL(t),n.identifier=EP(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function te(){this.data.inReference=void 0}function ne(){this.data.referenceType=`collapsed`}function L(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=EP(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function re(e){this.data.characterReferenceType=e.type}function ie(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=TP(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=vP(t);let i=this.stack[this.stack.length-1];i.value+=r}function ae(e){let t=this.stack.pop();t.position.end=cL(e.end)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function se(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ce(){return{type:`blockquote`,children:[]}}function le(){return{type:`code`,lang:null,meta:null,value:``}}function ue(){return{type:`inlineCode`,value:``}}function de(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function fe(){return{type:`emphasis`,children:[]}}function pe(){return{type:`heading`,depth:0,children:[]}}function me(){return{type:`break`}}function he(){return{type:`html`,value:``}}function ge(){return{type:`image`,title:null,url:``,alt:null}}function _e(){return{type:`link`,title:null,url:``,children:[]}}function ve(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ye(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function be(){return{type:`paragraph`,children:[]}}function xe(){return{type:`strong`,children:[]}}function Se(){return{type:`text`,value:``}}function Ce(){return{type:`thematicBreak`}}}function cL(e){return{line:e.line,column:e.column,offset:e.offset}}function lL(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?lL(e,r):uL(e,r)}}function uL(e,t){let n;for(n in t)if(aL.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function dL(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+jN({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+jN({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+jN({start:t.start,end:t.end})+`) is still open`)}function fL(e){let t=this;t.parser=n;function n(n){return oL(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function pL(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function mL(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
106
- `}]}function hL(e,t){let n=t.value?t.value+`
107
- `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function gL(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _L(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vL(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=zP(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function yL(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bL(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function xL(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function SL(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xL(e,t);let i={src:zP(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function CL(e,t){let n={src:zP(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function wL(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function TL(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xL(e,t);let i={href:zP(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function EL(e,t){let n={href:zP(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function DL(e,t,n){let r=e.all(t),i=n?OL(n):kL(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
105
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function wI(e){let t={constructs:JN([dI,...(e||{}).extensions||[]]),content:n(pP),defined:[],document:n(hP),flow:n(rI),lazy:{},string:n(oI),text:n(sI)};return t;function n(e){return n;function n(n){return xI(t,e,n)}}}function TI(e){for(;!ZP(e););return e}var EI=/[\0\t\n\r]/g;function DI(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(EI.lastIndex=u,c=EI.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var OI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function kI(e){return e.replace(OI,AI)}function AI(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return ZN(n.slice(t?2:1),t?16:10)}return WN(n)||e}var jI={}.hasOwnProperty;function MI(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),NI(n)(TI(wI(n).document().write(DI()(e,t,!0))))}function NI(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(_e),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(pe),blockQuote:a(ce),characterEscape:T,characterReference:T,codeFenced:a(le),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(le,o),codeText:a(ue,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(de),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(fe),hardBreakEscape:a(me),hardBreakTrailing:a(me),htmlFlow:a(he,o),htmlFlowData:T,htmlText:a(he,o),htmlTextData:T,image:a(ge),label:o,link:a(_e),listItem:a(ye),listItemValue:f,listOrdered:a(ve,d),listUnordered:a(ve),paragraph:a(be),reference:ne,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(pe),strong:a(xe),thematicBreak:a(Ce)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:se,autolinkProtocol:oe,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ie,characterReference:ae,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:L,resourceDestinationString:I,resourceTitleString:ee,resource:te,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};FI(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];jI.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||LI).call(a,void 0,e[0])}for(r.position={start:PI(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:PI(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:PI(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||LI).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+rN({start:e.start,end:e.end})+`): it’s not open`);n.position.end=PI(e.end)}function u(){return zN(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=QN(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Se(),n.position={start:PI(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=PI(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=PI(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=kI(t),n.identifier=QN(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function te(){this.data.inReference=void 0}function ne(){this.data.referenceType=`collapsed`}function L(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=QN(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function re(e){this.data.characterReferenceType=e.type}function ie(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=ZN(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=WN(t);let i=this.stack[this.stack.length-1];i.value+=r}function ae(e){let t=this.stack.pop();t.position.end=PI(e.end)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function se(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ce(){return{type:`blockquote`,children:[]}}function le(){return{type:`code`,lang:null,meta:null,value:``}}function ue(){return{type:`inlineCode`,value:``}}function de(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function fe(){return{type:`emphasis`,children:[]}}function pe(){return{type:`heading`,depth:0,children:[]}}function me(){return{type:`break`}}function he(){return{type:`html`,value:``}}function ge(){return{type:`image`,title:null,url:``,alt:null}}function _e(){return{type:`link`,title:null,url:``,children:[]}}function ve(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ye(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function be(){return{type:`paragraph`,children:[]}}function xe(){return{type:`strong`,children:[]}}function Se(){return{type:`text`,value:``}}function Ce(){return{type:`thematicBreak`}}}function PI(e){return{line:e.line,column:e.column,offset:e.offset}}function FI(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?FI(e,r):II(e,r)}}function II(e,t){let n;for(n in t)if(jI.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function LI(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+rN({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+rN({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+rN({start:t.start,end:t.end})+`) is still open`)}function RI(e){let t=this;t.parser=n;function n(n){return MI(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function zI(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function BI(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
106
+ `}]}function VI(e,t){let n=t.value?t.value+`
107
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function HI(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function UI(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function WI(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=dP(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function GI(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function KI(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function qI(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function JI(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return qI(e,t);let i={src:dP(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function YI(e,t){let n={src:dP(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function XI(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function ZI(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return qI(e,t);let i={href:dP(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function QI(e,t){let n={href:dP(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function $I(e,t,n){let r=e.all(t),i=n?eL(n):tL(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
108
108
  `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
109
- `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function OL(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=kL(n[r])}return t}function kL(e){return e.spread??e.children.length>1}function AL(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function jL(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ML(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function NL(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function PL(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=ON(t.children[1]),o=DN(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function FL(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function IL(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var LL=9,RL=32;function zL(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(BL(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(BL(t.slice(i),i>0,!1)),a.join(``)}function BL(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===LL||t===RL;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===LL||t===RL;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function VL(e,t){let n={type:`text`,value:zL(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function HL(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var UL={blockquote:pL,break:mL,code:hL,delete:gL,emphasis:_L,footnoteReference:vL,heading:yL,html:bL,imageReference:SL,image:CL,inlineCode:wL,linkReference:TL,link:EL,listItem:DL,list:AL,paragraph:jL,root:ML,strong:NL,table:PL,tableCell:IL,tableRow:FL,text:VL,thematicBreak:HL,toml:WL,yaml:WL,definition:WL,footnoteDefinition:WL};function WL(){}var{defineProperty:GL}=Object,KL=typeof self==`object`?self:globalThis,qL=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new KL[e](t)},JL=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?GL(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof KL[e]==`function`?qL(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(qL(a,o),i)};return r},YL=e=>JL(new Map,e)(0),XL=``,{toString:ZL}={},{keys:QL,is:$L}=Object,eR=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=ZL.call(e).slice(8,-1);switch(n){case`Array`:return[1,XL];case`Object`:return[2,XL];case`Date`:return[3,XL];case`RegExp`:return[4,XL];case`Map`:return[5,XL];case`Set`:return[6,XL];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},tR=([e,t])=>e===0&&(t===`function`||t===`symbol`),nR=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=eR(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&$L(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of QL(o))(e||!tR(eR(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?XL:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(tR(eR(n))||tR(eR(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!tR(eR(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},rR=(e,{json:t,lossy:n}={})=>{let r=[];return nR(!(t||n),!!t,new Map,r)(e),r},iR=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?YL(rR(e,t)):structuredClone(e):(e,t)=>YL(rR(e,t));function aR(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function oR(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function sR(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||aR,r=e.options.footnoteBackLabel||oR,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=zP(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...iR(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
109
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function eL(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=tL(n[r])}return t}function tL(e){return e.spread??e.children.length>1}function nL(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function rL(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function iL(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function aL(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function oL(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=eN(t.children[1]),o=$M(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function sL(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function cL(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var lL=9,uL=32;function dL(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(fL(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(fL(t.slice(i),i>0,!1)),a.join(``)}function fL(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===lL||t===uL;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===lL||t===uL;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function pL(e,t){let n={type:`text`,value:dL(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function mL(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var hL={blockquote:zI,break:BI,code:VI,delete:HI,emphasis:UI,footnoteReference:WI,heading:GI,html:KI,imageReference:JI,image:YI,inlineCode:XI,linkReference:ZI,link:QI,listItem:$I,list:nL,paragraph:rL,root:iL,strong:aL,table:oL,tableCell:cL,tableRow:sL,text:pL,thematicBreak:mL,toml:gL,yaml:gL,definition:gL,footnoteDefinition:gL};function gL(){}var{defineProperty:_L}=Object,vL=typeof self==`object`?self:globalThis,yL=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new vL[e](t)},bL=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?_L(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof vL[e]==`function`?yL(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(yL(a,o),i)};return r},xL=e=>bL(new Map,e)(0),SL=``,{toString:CL}={},{keys:wL,is:TL}=Object,EL=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=CL.call(e).slice(8,-1);switch(n){case`Array`:return[1,SL];case`Object`:return[2,SL];case`Date`:return[3,SL];case`RegExp`:return[4,SL];case`Map`:return[5,SL];case`Set`:return[6,SL];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},DL=([e,t])=>e===0&&(t===`function`||t===`symbol`),OL=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=EL(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&TL(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of wL(o))(e||!DL(EL(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?SL:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(DL(EL(n))||DL(EL(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!DL(EL(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},kL=(e,{json:t,lossy:n}={})=>{let r=[];return OL(!(t||n),!!t,new Map,r)(e),r},AL=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?xL(kL(e,t)):structuredClone(e):(e,t)=>xL(kL(e,t));function jL(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function ML(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function NL(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||jL,r=e.options.footnoteBackLabel||ML,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=dP(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...AL(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
110
110
  `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
111
- `}]}}var cR=(function(e){if(e==null)return pR;if(typeof e==`function`)return fR(e);if(typeof e==`object`)return Array.isArray(e)?lR(e):uR(e);if(typeof e==`string`)return dR(e);throw Error(`Expected function, string, or object as test`)});function lR(e){let t=[],n=-1;for(;++n<e.length;)t[n]=cR(e[n]);return fR(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function uR(e){let t=e;return fR(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function dR(e){return fR(t);function t(t){return t&&t.type===e}}function fR(e){return t;function t(t,n,r){return!!(mR(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function pR(){return!0}function mR(e){return typeof e==`object`&&!!e&&`type`in e}function hR(e){return e}var gR=[];function _R(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=cR(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+hR(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=gR,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=vR(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function vR(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?gR:[e]}function yR(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),_R(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var bR={}.hasOwnProperty,xR={};function SR(e,t){let n=t||xR,r=new Map,i=new Map,a={all:s,applyData:wR,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...UL,...n.handlers},one:o,options:n,patch:CR,wrap:ER};return yR(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(bR.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=iR(n);return r.children=a.all(e),r}return iR(e)}return(a.options.unknownHandler||TR)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=DR(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=DR(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function CR(e,t){e.position&&(t.position=AN(e))}function wR(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,iR(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function TR(e,t){let n=t.data||{},r=`value`in t&&!(bR.call(n,`hProperties`)||bR.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ER(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
111
+ `}]}}var PL=(function(e){if(e==null)return zL;if(typeof e==`function`)return RL(e);if(typeof e==`object`)return Array.isArray(e)?FL(e):IL(e);if(typeof e==`string`)return LL(e);throw Error(`Expected function, string, or object as test`)});function FL(e){let t=[],n=-1;for(;++n<e.length;)t[n]=PL(e[n]);return RL(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function IL(e){let t=e;return RL(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function LL(e){return RL(t);function t(t){return t&&t.type===e}}function RL(e){return t;function t(t,n,r){return!!(BL(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function zL(){return!0}function BL(e){return typeof e==`object`&&!!e&&`type`in e}function VL(e){return e}var HL=[];function UL(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=PL(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+VL(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=HL,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=WL(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function WL(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?HL:[e]}function GL(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),UL(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var KL={}.hasOwnProperty,qL={};function JL(e,t){let n=t||qL,r=new Map,i=new Map,a={all:s,applyData:XL,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...hL,...n.handlers},one:o,options:n,patch:YL,wrap:QL};return GL(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(KL.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=AL(n);return r.children=a.all(e),r}return AL(e)}return(a.options.unknownHandler||ZL)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=$L(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=$L(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function YL(e,t){e.position&&(t.position=nN(e))}function XL(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,AL(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function ZL(e,t){let n=t.data||{},r=`value`in t&&!(KL.call(n,`hProperties`)||KL.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function QL(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
112
112
  `});++r<e.length;)r&&n.push({type:`text`,value:`
113
113
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
114
- `}),n}function DR(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function OR(e,t){let n=SR(e,t),r=n.one(e,void 0),i=sR(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
115
- `},i)),a}function kR(e,t){return e&&`run`in e?async function(n,r){let i=OR(n,{file:r,...t});await e.run(i,r)}:function(n,r){return OR(n,{file:r,...e||t})}}function AR(e){if(e)throw e}var jR=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function MR(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function NR(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?PR(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function PR(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var FR={basename:IR,dirname:LR,extname:RR,join:zR,sep:`/`};function IR(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);HR(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function LR(e){if(HR(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function RR(e){HR(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function zR(...e){let t=-1,n;for(;++t<e.length;)HR(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:BR(n)}function BR(e){HR(e);let t=e.codePointAt(0)===47,n=VR(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function VR(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function HR(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var UR={cwd:WR};function WR(){return`/`}function GR(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function KR(e){if(typeof e==`string`)e=new URL(e);else if(!GR(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return qR(e)}function qR(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var JR=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],YR=class{constructor(e){let t;t=e?GR(e)?{path:e}:typeof e==`string`||$R(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:UR.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<JR.length;){let e=JR[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)JR.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?FR.basename(this.path):void 0}set basename(e){ZR(e,`basename`),XR(e,`basename`),this.path=FR.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?FR.dirname(this.path):void 0}set dirname(e){QR(this.basename,`dirname`),this.path=FR.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?FR.extname(this.path):void 0}set extname(e){if(XR(e,`extname`),QR(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=FR.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){GR(e)&&(e=KR(e)),ZR(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?FR.basename(this.path,this.extname):void 0}set stem(e){ZR(e,`stem`),XR(e,`stem`),this.path=FR.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new FN(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function XR(e,t){if(e&&e.includes(FR.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+FR.sep+"`")}function ZR(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function QR(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function $R(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var ez=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),tz=l(jR(),1),nz={}.hasOwnProperty,rz=new class e extends ez{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=NR()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,tz.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(oz(`data`,this.frozen),this.namespace[e]=t,this):nz.call(this.namespace,e)&&this.namespace[e]||void 0:e?(oz(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=lz(e),n=this.parser||this.Parser;return iz(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),iz(`process`,this.parser||this.Parser),az(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=lz(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);dz(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),iz(`processSync`,this.parser||this.Parser),az(`processSync`,this.compiler||this.Compiler),this.process(e,r),cz(`processSync`,`process`,t),n;function r(e,r){t=!0,AR(e),n=r}}run(e,t,n){sz(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=lz(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),cz(`runSync`,`run`,n),r;function i(e,t){AR(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=lz(t),r=this.compiler||this.Compiler;return az(`stringify`,r),sz(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(oz(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,tz.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];MR(o)&&MR(r)&&(r=(0,tz.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function iz(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function az(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function oz(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function sz(e){if(!MR(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function cz(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function lz(e){return uz(e)?e:new YR(e)}function uz(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function dz(e){return typeof e==`string`||fz(e)}function fz(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var pz=[],mz={allowDangerousHtml:!0},hz=/^(https?|ircs?|mailto|xmpp)$/i,gz=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function _z(e){let t=vz(e),n=yz(e);return bz(t.runSync(t.parse(n),n),e)}function vz(e){let t=e.rehypePlugins||pz,n=e.remarkPlugins||pz,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...mz}:mz;return rz().use(fL).use(n).use(kR,r).use(t)}function yz(e){let t=e.children||``,n=new YR;return typeof t==`string`?n.value=t:``+t,n}function bz(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||xz;for(let e of gz)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return yR(e,l),UN(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in dP)if(Object.hasOwn(dP,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=dP[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function xz(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||hz.test(e.slice(0,t))?e:``}function Sz(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Cz(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function wz(e,t,n){let r=cR((n||{}).ignore||[]),i=Tz(t),a=-1;for(;++a<i.length;)_R(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Tz(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Ez(e[0]),Dz(e[1])])}return t}function Ez(e){return typeof e==`string`?new RegExp(Cz(e),`g`):e}function Dz(e){return typeof e==`function`?e:function(){return e}}var Oz=`phrasing`,kz=[`autolink`,`link`,`image`,`label`];function Az(){return{transforms:[Rz],enter:{literalAutolink:Mz,literalAutolinkEmail:Nz,literalAutolinkHttp:Nz,literalAutolinkWww:Nz},exit:{literalAutolink:Lz,literalAutolinkEmail:Iz,literalAutolinkHttp:Pz,literalAutolinkWww:Fz}}}function jz(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:Oz,notInConstruct:kz},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:Oz,notInConstruct:kz},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:Oz,notInConstruct:kz}]}}function Mz(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Nz(e){this.config.enter.autolinkProtocol.call(this,e)}function Pz(e){this.config.exit.autolinkProtocol.call(this,e)}function Fz(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Iz(e){this.config.exit.autolinkEmail.call(this,e)}function Lz(e){this.exit(e)}function Rz(e){wz(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,zz],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Bz]],{ignore:[`link`,`linkReference`]})}function zz(e,t,n,r,i){let a=``;if(!Uz(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Vz(n)))return!1;let o=Hz(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Bz(e,t,n,r){return!Uz(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Vz(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Hz(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=Sz(e,`(`),a=Sz(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Uz(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||LP(n)||IP(n))&&(!t||n!==47)}$z.peek=Qz;function Wz(){this.buffer()}function Gz(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Kz(){this.buffer()}function qz(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Jz(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=EP(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Yz(e){this.exit(e)}function Xz(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=EP(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Zz(e){this.exit(e)}function Qz(){return`[`}function $z(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function eB(){return{enter:{gfmFootnoteCallString:Wz,gfmFootnoteCall:Gz,gfmFootnoteDefinitionLabelString:Kz,gfmFootnoteDefinition:qz},exit:{gfmFootnoteCallString:Jz,gfmFootnoteCall:Yz,gfmFootnoteDefinitionLabelString:Xz,gfmFootnoteDefinition:Zz}}}function tB(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:$z},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
116
- `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?rB:nB))),s(),o}}function nB(e,t,n){return t===0?e:rB(e,t,n)}function rB(e,t,n){return(n?``:` `)+e}var iB=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];lB.peek=uB;function aB(){return{canContainEols:[`delete`],enter:{strikethrough:sB},exit:{strikethrough:cB}}}function oB(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:iB}],handlers:{delete:lB}}}function sB(e){this.enter({type:`delete`,children:[]},e)}function cB(e){this.exit(e)}function lB(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function uB(){return`~`}function dB(e){return e.length}function fB(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||dB,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=pB(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=mB(r[d]);else{let e=mB(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
117
- `)}function pB(e){return e==null?``:String(e)}function mB(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function hB(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),gB);return i(),o}function gB(e,t,n){return`>`+(n?``:` `)+e}function _B(e,t){return vB(e,t.inConstruct,!0)&&!vB(e,t.notInConstruct,!1)}function vB(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function yB(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
118
- `&&_B(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
119
- `}function bB(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function xB(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function SB(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function CB(e,t,n,r){let i=SB(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(xB(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,wB);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(bB(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
114
+ `}),n}function $L(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function eR(e,t){let n=JL(e,t),r=n.one(e,void 0),i=NL(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
115
+ `},i)),a}function tR(e,t){return e&&`run`in e?async function(n,r){let i=eR(n,{file:r,...t});await e.run(i,r)}:function(n,r){return eR(n,{file:r,...e||t})}}function nR(e){if(e)throw e}var rR=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function iR(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function aR(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?oR(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function oR(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var sR={basename:cR,dirname:lR,extname:uR,join:dR,sep:`/`};function cR(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);mR(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function lR(e){if(mR(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function uR(e){mR(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function dR(...e){let t=-1,n;for(;++t<e.length;)mR(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:fR(n)}function fR(e){mR(e);let t=e.codePointAt(0)===47,n=pR(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function pR(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function mR(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var hR={cwd:gR};function gR(){return`/`}function _R(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function vR(e){if(typeof e==`string`)e=new URL(e);else if(!_R(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return yR(e)}function yR(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var bR=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],xR=class{constructor(e){let t;t=e?_R(e)?{path:e}:typeof e==`string`||TR(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:hR.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<bR.length;){let e=bR[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)bR.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?sR.basename(this.path):void 0}set basename(e){CR(e,`basename`),SR(e,`basename`),this.path=sR.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?sR.dirname(this.path):void 0}set dirname(e){wR(this.basename,`dirname`),this.path=sR.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?sR.extname(this.path):void 0}set extname(e){if(SR(e,`extname`),wR(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=sR.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){_R(e)&&(e=vR(e)),CR(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?sR.basename(this.path,this.extname):void 0}set stem(e){CR(e,`stem`),SR(e,`stem`),this.path=sR.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new sN(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function SR(e,t){if(e&&e.includes(sR.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+sR.sep+"`")}function CR(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function wR(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function TR(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var ER=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),DR=l(rR(),1),OR={}.hasOwnProperty,kR=new class e extends ER{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=aR()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,DR.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(MR(`data`,this.frozen),this.namespace[e]=t,this):OR.call(this.namespace,e)&&this.namespace[e]||void 0:e?(MR(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=FR(e),n=this.parser||this.Parser;return AR(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),AR(`process`,this.parser||this.Parser),jR(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=FR(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);LR(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),AR(`processSync`,this.parser||this.Parser),jR(`processSync`,this.compiler||this.Compiler),this.process(e,r),PR(`processSync`,`process`,t),n;function r(e,r){t=!0,nR(e),n=r}}run(e,t,n){NR(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=FR(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),PR(`runSync`,`run`,n),r;function i(e,t){nR(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=FR(t),r=this.compiler||this.Compiler;return jR(`stringify`,r),NR(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(MR(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,DR.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];iR(o)&&iR(r)&&(r=(0,DR.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function AR(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function jR(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function MR(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function NR(e){if(!iR(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function PR(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function FR(e){return IR(e)?e:new xR(e)}function IR(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function LR(e){return typeof e==`string`||RR(e)}function RR(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var zR=[],BR={allowDangerousHtml:!0},VR=/^(https?|ircs?|mailto|xmpp)$/i,HR=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function UR(e){let t=WR(e),n=GR(e);return KR(t.runSync(t.parse(n),n),e)}function WR(e){let t=e.rehypePlugins||zR,n=e.remarkPlugins||zR,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...BR}:BR;return kR().use(RI).use(n).use(tR,r).use(t)}function GR(e){let t=e.children||``,n=new xR;return typeof t==`string`?n.value=t:``+t,n}function KR(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||qR;for(let e of HR)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return GL(e,l),hN(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in LN)if(Object.hasOwn(LN,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=LN[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function qR(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||VR.test(e.slice(0,t))?e:``}function JR(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function YR(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function XR(e,t,n){let r=PL((n||{}).ignore||[]),i=ZR(t),a=-1;for(;++a<i.length;)UL(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function ZR(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([QR(e[0]),$R(e[1])])}return t}function QR(e){return typeof e==`string`?new RegExp(YR(e),`g`):e}function $R(e){return typeof e==`function`?e:function(){return e}}var ez=`phrasing`,tz=[`autolink`,`link`,`image`,`label`];function nz(){return{transforms:[uz],enter:{literalAutolink:iz,literalAutolinkEmail:az,literalAutolinkHttp:az,literalAutolinkWww:az},exit:{literalAutolink:lz,literalAutolinkEmail:cz,literalAutolinkHttp:oz,literalAutolinkWww:sz}}}function rz(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:ez,notInConstruct:tz},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:ez,notInConstruct:tz},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:ez,notInConstruct:tz}]}}function iz(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function az(e){this.config.enter.autolinkProtocol.call(this,e)}function oz(e){this.config.exit.autolinkProtocol.call(this,e)}function sz(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function cz(e){this.config.exit.autolinkEmail.call(this,e)}function lz(e){this.exit(e)}function uz(e){XR(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,dz],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,fz]],{ignore:[`link`,`linkReference`]})}function dz(e,t,n,r,i){let a=``;if(!hz(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!pz(n)))return!1;let o=mz(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function fz(e,t,n,r){return!hz(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function pz(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function mz(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=JR(e,`(`),a=JR(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function hz(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||lP(n)||cP(n))&&(!t||n!==47)}Tz.peek=wz;function gz(){this.buffer()}function _z(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function vz(){this.buffer()}function yz(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function bz(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=QN(this.sliceSerialize(e)).toLowerCase(),n.label=t}function xz(e){this.exit(e)}function Sz(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=QN(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Cz(e){this.exit(e)}function wz(){return`[`}function Tz(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Ez(){return{enter:{gfmFootnoteCallString:gz,gfmFootnoteCall:_z,gfmFootnoteDefinitionLabelString:vz,gfmFootnoteDefinition:yz},exit:{gfmFootnoteCallString:bz,gfmFootnoteCall:xz,gfmFootnoteDefinitionLabelString:Sz,gfmFootnoteDefinition:Cz}}}function Dz(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Tz},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
116
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?kz:Oz))),s(),o}}function Oz(e,t,n){return t===0?e:kz(e,t,n)}function kz(e,t,n){return(n?``:` `)+e}var Az=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Fz.peek=Iz;function jz(){return{canContainEols:[`delete`],enter:{strikethrough:Nz},exit:{strikethrough:Pz}}}function Mz(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Az}],handlers:{delete:Fz}}}function Nz(e){this.enter({type:`delete`,children:[]},e)}function Pz(e){this.exit(e)}function Fz(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function Iz(){return`~`}function Lz(e){return e.length}function Rz(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||Lz,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=zz(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=Bz(r[d]);else{let e=Bz(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
117
+ `)}function zz(e){return e==null?``:String(e)}function Bz(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function Vz(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),Hz);return i(),o}function Hz(e,t,n){return`>`+(n?``:` `)+e}function Uz(e,t){return Wz(e,t.inConstruct,!0)&&!Wz(e,t.notInConstruct,!1)}function Wz(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Gz(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
118
+ `&&Uz(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
119
+ `}function Kz(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function qz(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Jz(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Yz(e,t,n,r){let i=Jz(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(qz(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Xz);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(Kz(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
120
120
  `,encode:["`"],...s.current()})),t()}return u+=s.move(`
121
121
  `),a&&(u+=s.move(a+`
122
- `)),u+=s.move(c),l(),u}function wB(e,t,n){return(n?``:` `)+e}function TB(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function EB(e,t,n,r){let i=TB(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
123
- `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function DB(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function OB(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function kB(e,t,n){let r=qP(e),i=qP(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}AB.peek=jB;function AB(e,t,n,r){let i=DB(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=kB(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=OB(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=kB(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+OB(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function jB(e,t,n){return n.options.emphasis||`*`}function MB(e,t){let n=!1;return yR(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&pP(e)&&(t.options.setext||n))}function NB(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(MB(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
122
+ `)),u+=s.move(c),l(),u}function Xz(e,t,n){return(n?``:` `)+e}function Zz(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Qz(e,t,n,r){let i=Zz(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
123
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function $z(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function eB(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function tB(e,t,n){let r=yP(e),i=yP(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}nB.peek=rB;function nB(e,t,n,r){let i=$z(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=tB(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=eB(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=tB(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+eB(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function rB(e,t,n){return n.options.emphasis||`*`}function iB(e,t){let n=!1;return GL(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&zN(e)&&(t.options.setext||n))}function aB(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(iB(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
124
124
  `,after:`
125
125
  `});return r(),t(),o+`
126
126
  `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
127
127
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
128
- `,...a.current()});return/^[\t ]/.test(l)&&(l=OB(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}PB.peek=FB;function PB(e){return e.value||``}function FB(){return`<`}IB.peek=LB;function IB(e,t,n,r){let i=TB(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function LB(){return`!`}RB.peek=zB;function RB(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function zB(){return`!`}BB.peek=VB;function BB(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function VB(){return"`"}function HB(e,t){let n=pP(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}UB.peek=WB;function UB(e,t,n,r){let i=TB(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(HB(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function WB(e,t,n){return HB(e,n)?`<`:`[`}GB.peek=KB;function GB(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function KB(){return`[`}function qB(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function JB(e){let t=qB(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function YB(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function XB(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function ZB(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?YB(n):qB(n),s=e.ordered?o===`.`?`)`:`.`:JB(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),XB(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function QB(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function $B(e,t,n,r){let i=QB(n),a=n.bulletCurrent||qB(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function eV(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var tV=cR([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function nV(e,t,n,r){return(e.children.some(function(e){return tV(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function rV(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}iV.peek=aV;function iV(e,t,n,r){let i=rV(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=kB(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=OB(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=kB(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+OB(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function aV(e,t,n){return n.options.strong||`*`}function oV(e,t,n,r){return n.safe(e.value,r)}function sV(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function cV(e,t,n){let r=(XB(n)+(n.options.ruleSpaces?` `:``)).repeat(sV(n));return n.options.ruleSpaces?r.slice(0,-1):r}var lV={blockquote:hB,break:yB,code:CB,definition:EB,emphasis:AB,hardBreak:yB,heading:NB,html:PB,image:IB,imageReference:RB,inlineCode:BB,link:UB,linkReference:GB,list:ZB,listItem:$B,paragraph:eV,root:nV,strong:iV,text:oV,thematicBreak:cV};function uV(){return{enter:{table:dV,tableData:hV,tableHeader:hV,tableRow:pV},exit:{codeText:gV,table:fV,tableData:mV,tableHeader:mV,tableRow:mV}}}function dV(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function fV(e){this.exit(e),this.data.inTable=void 0}function pV(e){this.enter({type:`tableRow`,children:[]},e)}function mV(e){this.exit(e)}function hV(e){this.enter({type:`tableCell`,children:[]},e)}function gV(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,_V));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function _V(e,t){return t===`|`?t:e}function vV(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
128
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=eB(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}oB.peek=sB;function oB(e){return e.value||``}function sB(){return`<`}cB.peek=lB;function cB(e,t,n,r){let i=Zz(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function lB(){return`!`}uB.peek=dB;function uB(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function dB(){return`!`}fB.peek=pB;function fB(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function pB(){return"`"}function mB(e,t){let n=zN(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}hB.peek=gB;function hB(e,t,n,r){let i=Zz(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(mB(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function gB(e,t,n){return mB(e,n)?`<`:`[`}_B.peek=vB;function _B(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function vB(){return`[`}function yB(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function bB(e){let t=yB(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function xB(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function SB(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function CB(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?xB(n):yB(n),s=e.ordered?o===`.`?`)`:`.`:bB(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),SB(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function wB(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function TB(e,t,n,r){let i=wB(n),a=n.bulletCurrent||yB(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function EB(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var DB=PL([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function OB(e,t,n,r){return(e.children.some(function(e){return DB(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function kB(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}AB.peek=jB;function AB(e,t,n,r){let i=kB(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=tB(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=eB(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=tB(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+eB(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function jB(e,t,n){return n.options.strong||`*`}function MB(e,t,n,r){return n.safe(e.value,r)}function NB(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function PB(e,t,n){let r=(SB(n)+(n.options.ruleSpaces?` `:``)).repeat(NB(n));return n.options.ruleSpaces?r.slice(0,-1):r}var FB={blockquote:Vz,break:Gz,code:Yz,definition:Qz,emphasis:nB,hardBreak:Gz,heading:aB,html:oB,image:cB,imageReference:uB,inlineCode:fB,link:hB,linkReference:_B,list:CB,listItem:TB,paragraph:EB,root:OB,strong:AB,text:MB,thematicBreak:PB};function IB(){return{enter:{table:LB,tableData:VB,tableHeader:VB,tableRow:zB},exit:{codeText:HB,table:RB,tableData:BB,tableHeader:BB,tableRow:BB}}}function LB(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function RB(e){this.exit(e),this.data.inTable=void 0}function zB(e){this.enter({type:`tableRow`,children:[]},e)}function BB(e){this.exit(e)}function VB(e){this.enter({type:`tableCell`,children:[]},e)}function HB(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,UB));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function UB(e,t){return t===`|`?t:e}function WB(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
129
129
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
130
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return fB(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=lV.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function yV(){return{exit:{taskListCheckValueChecked:xV,taskListCheckValueUnchecked:xV,paragraph:SV}}}function bV(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:CV}}}function xV(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function SV(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function CV(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=lV.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function wV(){return[Az(),eB(),aB(),uV(),yV()]}function TV(e){return{extensions:[jz(),tB(e),oB(),vV(e),bV()]}}var EV={tokenize:BV,partial:!0},DV={tokenize:VV,partial:!0},OV={tokenize:HV,partial:!0},kV={tokenize:UV,partial:!0},AV={tokenize:WV,partial:!0},jV={name:`wwwAutolink`,tokenize:RV,previous:GV},MV={name:`protocolAutolink`,tokenize:zV,previous:KV},NV={name:`emailAutolink`,tokenize:LV,previous:qV},PV={};function FV(){return{text:PV}}for(var IV=48;IV<123;)PV[IV]=NV,IV++,IV===58?IV=65:IV===91&&(IV=97);PV[43]=NV,PV[45]=NV,PV[46]=NV,PV[95]=NV,PV[72]=[NV,MV],PV[104]=[NV,MV],PV[87]=[NV,jV],PV[119]=[NV,jV];function LV(e,t,n){let r=this,i,a;return o;function o(t){return!JV(t)||!qV.call(r,r.previous)||YV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return JV(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(AV,u,l)(t):t===45||t===95||OP(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&DP(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function RV(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!GV.call(r,r.previous)||YV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(EV,e.attempt(DV,e.attempt(OV,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function zV(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&KV.call(r,r.previous)&&!YV(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(DP(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||AP(t)||PP(t)||LP(t)||IP(t)?n(t):e.attempt(DV,e.attempt(OV,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function BV(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function VV(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(kV,c,s)(t):t===null||PP(t)||LP(t)||t!==45&&IP(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function HV(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(kV,t,a)(o):o===null||PP(o)||LP(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function UV(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||PP(o)||LP(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||PP(e)||LP(e)?t(e):r(e)}function a(e){return DP(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):DP(t)?(e.consume(t),o):n(t)}}function WV(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return OP(e)?n(e):t(e)}}function GV(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||PP(e)}function KV(e){return!DP(e)}function qV(e){return!(e===47||JV(e))}function JV(e){return e===43||e===45||e===46||e===95||OP(e)}function YV(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var XV={tokenize:iH,partial:!0};function ZV(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:tH,continuation:{tokenize:nH},exit:rH}},text:{91:{name:`gfmFootnoteCall`,tokenize:eH},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:QV,resolveTo:$V}}}}function QV(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=EP(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function $V(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function eH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||PP(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(EP(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return PP(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function tH(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||PP(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=EP(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return PP(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),BP(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function nH(e,t,n){return e.check(tF,t,e.attempt(XV,t,n))}function rH(e){e.exit(`gfmFootnoteDefinition`)}function iH(e,t,n){let r=this;return BP(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function aH(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&yP(o,o.length,0,JP(s,e.slice(r+1,n),t)),yP(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),yP(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=qP(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=qP(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var oH=class{constructor(){this.map=[]}add(e,t,n){sH(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function sH(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function cH(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function lH(){return{flow:{null:{name:`table`,tokenize:uH,resolveAll:dH}}}}function uH(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):FP(t)?BP(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||PP(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,FP(t)?BP(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return FP(t)?BP(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return FP(t)?BP(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):FP(n)?BP(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||PP(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function dH(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new oH;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(pH(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=fH(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=fH(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=fH(f,t,o,i,n,d)):(o[0]=o[1],d=fH(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&pH(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=cH(t.events,n))}return e}function fH(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},mH(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=mH(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=mH(t.events,n[2]),a=mH(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},mH(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function pH(e,t,n,r,i){let a=[],o=mH(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function mH(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var hH={name:`tasklistCheck`,tokenize:_H};function gH(){return{text:{91:hH}}}function _H(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return PP(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):FP(r)?e.check({tokenize:vH},t,n)(r):n(r)}}function vH(e,t,n){return BP(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function yH(e){return SP([FV(),ZV(),aH(e),lH(),gH()])}var bH={};function xH(e){let t=this,n=e||bH,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(yH(n)),a.push(wV()),o.push(TV(n))}var SH=new Set([400,404,409]);async function CH(e,t){return PH(await e.client.projects[`:id`].cancel.$post({param:{id:t}}))}async function wH(e,t){return PH(await e.client.projects[`:id`].pause.$post({param:{id:t}}))}async function TH(e,t){return PH(await e.client.projects[`:id`].resume.$post({param:{id:t}}))}async function EH(e,t,n){return PH(await e.client.projects[`:id`].providers.$patch({param:{id:t},json:n}))}async function DH(e,t,n){return PH(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function OH(e,t,n){return PH(await e.client.projects[`:id`].stages[`:kind`].retry.$post({param:{id:t,kind:n}}))}async function kH(e,t,n){return PH(await e.client.projects[`:id`].stages[`:kind`].rerun.$post({param:{id:t,kind:n}}))}async function AH(e,t,n){return PH(await e.client.projects[`:id`].article.$put({param:{id:t},json:{markdown:n}}))}async function jH(e,t,n){return PH(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function MH(e,t,n){return PH(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function NH(e,t,n){return Qa(await e.fetch(po(e,t,n)))}async function PH(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await no(e);if(t!==void 0&&SH.has(e.status))return{ok:!1,message:to(e,t).message};throw to(e,t)}function FH({projectId:e,asset:t}){let{api:n}=B(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)();async function s(){i(!0),o(void 0);try{let r=await n.client.projects[`:id`][`open-folder`].$post({param:{id:e},json:{asset:t}});if(!r.ok)throw to(r,await no(r))}catch(e){o(e instanceof Error?e.message:`Could not open the folder.`)}finally{i(!1)}}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>void s(),title:`Open the saved output folder on the machine running Slopify`,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink disabled:opacity-50`,children:[(0,h.jsx)(Ok,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),r?`Opening…`:`Open folder`]}),a!==void 0&&(0,h.jsx)(`span`,{role:`alert`,className:`basis-full text-small text-red`,children:a})]})}function IH({children:e,className:t}){return(0,h.jsx)(`div`,{className:W(`flex min-w-0 flex-col gap-4 p-5`,t),children:e})}function LH({children:e}){return(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 text-small`,children:e})}function RH({children:e}){return(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e})}var zH={h1:({children:e})=>(0,h.jsx)(VH,{size:`text-title`,children:e}),h2:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h3:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h4:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h5:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),h6:({children:e})=>(0,h.jsx)(VH,{size:`text-row`,children:e}),p:({children:e})=>(0,h.jsx)(`p`,{className:`m-0`,children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),ul:({children:e})=>(0,h.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-5`,children:e}),ol:({children:e})=>(0,h.jsx)(`ol`,{className:`m-0 flex list-decimal flex-col gap-1 pl-5`,children:e}),li:({children:e})=>(0,h.jsx)(`li`,{className:`m-0`,children:e}),a:({children:e,href:t})=>(0,h.jsx)(`a`,{href:t,className:`rounded-control text-run-text underline underline-offset-[3px]`,target:`_blank`,rel:`noreferrer`,children:e}),code:({children:e})=>(0,h.jsx)(`code`,{className:`rounded-control bg-panel2 px-[4px] py-[1px] font-sans text-small`,children:e}),pre:({children:e})=>(0,h.jsx)(`pre`,{className:`m-0 overflow-x-auto rounded-control bg-panel2 p-[10px] font-sans text-small`,children:e}),blockquote:({children:e})=>(0,h.jsx)(`blockquote`,{className:`m-0 flex flex-col gap-2 border-l-2 border-line2 pl-3 text-ink2`,children:e}),hr:()=>(0,h.jsx)(`hr`,{className:`my-2 border-line`}),table:({children:e})=>(0,h.jsx)(`table`,{className:`w-full border-collapse text-left text-small`,children:e}),th:({children:e})=>(0,h.jsx)(`th`,{className:`engraved border-b border-line py-[6px] pr-4 text-left text-ink3`,children:e}),td:({children:e})=>(0,h.jsx)(`td`,{className:`border-b border-line py-[6px] pr-4 align-top`,children:e})},BH={p:({children:e})=>(0,h.jsx)(h.Fragment,{children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),a:({children:e})=>(0,h.jsx)(h.Fragment,{children:e})};function VH({size:e,children:t}){return(0,h.jsx)(`h3`,{className:W(`mt-2 font-bold tracking-[-0.01em]`,e),children:t})}function HH({markdown:e}){return(0,h.jsx)(`div`,{className:`flex max-w-[75ch] flex-col gap-2 text-pretty text-body text-ink`,children:(0,h.jsx)(_z,{remarkPlugins:[xH],components:zH,children:e})})}function UH({markdown:e}){return(0,h.jsx)(_z,{remarkPlugins:[xH],components:BH,children:e})}var WH=/^#{1,6}[ \t]+(.*?)[ \t]*#*[ \t]*(?:\r?\n|$)/;function GH(e){let t=e.replace(/^[\s]*\n/,``),n=WH.exec(t);return n===null?{title:void 0,body:e.trim()}:{title:n[1]??``,body:t.slice(n[0].length).trim()}}function KH({message:e,onDismiss:t}){return(0,h.jsxs)(`div`,{className:`flex items-center gap-3 rounded-control bg-red-tint px-[10px] py-[6px] text-small text-red`,children:[(0,h.jsx)(`span`,{role:`alert`,className:`min-w-0 break-words`,children:e}),(0,h.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto shrink-0 rounded-control px-2 text-ink2 hover:text-ink`,children:`Dismiss`})]})}function qH({projectId:e,asset:t,label:n=`Download`}){let{api:r}=B();return(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsxs)(`a`,{href:po(r,e,t),download:!0,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(Ek,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),n]}),(0,h.jsx)(FH,{projectId:e,asset:t})]})}function JH({output:e,label:t}){return(0,h.jsx)(qH,{projectId:e.projectId,asset:PM(e),...t===void 0?{}:{label:t}})}function YH(e){let{api:t}=B();return R({queryKey:jy.file(e?.projectId??``,e?.id??``),queryFn:()=>e===void 0?``:NH(t,e.projectId,PM(e)),enabled:e!==void 0,staleTime:1/0})}function XH({output:e,as:t=`prose`}){let n=YH(e);return n.error===null?n.data===void 0?(0,h.jsx)(`span`,{className:`h-4 w-[40ch] max-w-full rounded-control bg-panel2`}):t===`prose`?(0,h.jsx)(HH,{markdown:n.data}):(0,h.jsx)(`pre`,{className:`max-w-[75ch] overflow-x-auto whitespace-pre-wrap font-sans text-small text-ink2`,children:n.data}):(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})}function ZH({output:e}){let[t,n]=(0,m.useState)(!1);return e===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>{n(!t)},className:`rounded-control text-small text-ink2 underline underline-offset-[3px] hover:text-ink`,children:t?`Hide instructions`:`Show instructions`}),t?(0,h.jsx)(XH,{output:e,as:`plain`}):null]})}function QH({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=EM(n,e),o=DM(a,`article_md`),s=DM(a,`sources`),c=DM(a,`glossary`),l=YH(o),u=R({queryKey:jM(t.id),queryFn:()=>[],enabled:!1}).data?.some(e=>e.stage===`article`)===!0,d=R({queryKey:jy.article(t.id),queryFn:()=>``,enabled:!1}),[f,p]=(0,m.useState)(void 0),[g,_]=(0,m.useState)(!1),v=l.data??``,y=GH(e.state===`running`?d.data??``:v),b=y.title??t.title,x=kM({kind:`discard-article`});return(0,h.jsxs)(IH,{children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-[14px] text-small text-ink2`,children:[(0,h.jsx)(`span`,{className:`text-row font-semibold text-ink`,children:(0,h.jsx)(UH,{markdown:b})}),s===void 0?null:(0,h.jsx)(JH,{output:s,label:`Sources`}),c===void 0?null:(0,h.jsx)(JH,{output:c,label:`Glossary`})]}),(0,h.jsx)(LH,{children:f===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(J,{type:`button`,disabled:i||o===void 0||l.data===void 0,onClick:()=>{p(v)},children:`Edit`}),(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),(0,h.jsx)(ZH,{output:DM(a,`instructions`)}),o===void 0?null:(0,h.jsx)(JH,{output:o})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(AM,{action:{kind:`save-article`,markdown:f},run:()=>{r.run({kind:`save-article`,markdown:f},()=>{p(void 0)})},disabled:i,pending:r.pending,children:`Save & update outputs`}),(0,h.jsx)(J,{type:`button`,onClick:()=>{_(!0)},children:`Discard`})]})}),l.error===null?null:(0,h.jsx)(`p`,{className:`text-body text-red`,children:l.error.message}),(0,h.jsx)(`section`,{"aria-label":`Article content`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:f===void 0?e.state===`running`&&u?(0,h.jsx)(NM,{projectId:t.id,stage:`article`}):(0,h.jsx)(HH,{markdown:y.body}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`label`,{htmlFor:`article-editor`,className:`engraved text-ink3`,children:`Article`}),(0,h.jsx)(`textarea`,{id:`article-editor`,value:f,onChange:e=>{p(e.target.value)},className:`h-[420px] w-full max-w-[75ch] resize-y rounded-control border border-line2 bg-panel2 p-[10px] font-sans text-body text-ink`})]})}),(0,h.jsx)(oA,{open:g,title:x.title,consequence:x.consequence,verb:x.verb,dismiss:x.dismiss,onConfirm:()=>{_(!1),p(void 0)},onCancel:()=>{_(!1)}})]})}function $H({projectId:e}){let{api:t}=B(),n=R({queryKey:[`audio-preview`,e],queryFn:async()=>Za(await t.client.projects[`:projectId`][`audio-preview`].$get({param:{projectId:e}})),refetchInterval:1e3,staleTime:0,gcTime:0,retry:!1}),r=n.data?.previews??[];return(0,h.jsxs)(`section`,{"aria-label":`Live narration`,className:`grid gap-3 rounded-control border border-line2 bg-panel2 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-ink`,children:`Listen while it generates`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Play any part. Each preview starts from its beginning.`})]}),n.error===null?null:(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Live preview is temporarily unavailable. Finished audio will still appear here.`}),r.length===0&&n.error===null?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Waiting for the first audio bytes…`}):null,(0,h.jsx)(`div`,{className:`grid max-h-[420px] gap-3 overflow-y-auto`,children:r.map(n=>(0,h.jsx)(eU,{preview:n,url:`${t.origin}/api/projects/${encodeURIComponent(e)}/audio-preview/${n.id}`},n.id))})]})}function eU({preview:e,url:t}){let[n,r]=(0,m.useState)(!1),i=(e.state===`streaming`||e.state===`ready`)&&e.bytes>0,a=e.state===`ready`?`Ready`:e.state===`streaming`?`Generating`:`Preview stopped`;return(0,h.jsxs)(`div`,{className:`grid gap-2 text-small`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink`,children:e.label}),(0,h.jsx)(`span`,{className:`text-ink2`,children:a})]}),i&&!n?(0,h.jsx)(tU,{label:e.label,url:t,onError:()=>r(!0)}):(0,h.jsx)(`p`,{className:`text-ink2`,children:e.state===`streaming`&&!n?`Waiting for audio…`:`This preview has stopped. The finished narration will be available when generation completes.`})]})}function tU({label:e,url:t,onError:n}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=r.current;return()=>{e!==null&&(e.pause(),e.removeAttribute(`src`),e.load())}},[]),(0,h.jsx)(`audio`,{ref:r,controls:!0,preload:`none`,"aria-label":`Live ${e} narration`,src:t,onError:n,className:`h-9 w-full max-w-[620px]`})}var nU=[{role:`audio_intro`,name:`Intro`},{role:`audio_body`,name:`Body`},{role:`audio_outro`,name:`Outro`}];function rU({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=B(),o=R(Ly(a)),s=EM(n,e),c=nU.flatMap(e=>{let t=DM(s,e.role);return t===void 0?[]:[{...e,output:t}]}),l=c.find(e=>e.output.meta.voice!==void 0)?.output.meta,u=c.length>0?l?.voice:t.config.audio?.voice,d=c.length>0?l?.provider:t.config.audio?.provider,f=o.data?.voices.find(e=>e.voiceId===u&&e.provider===d)?.name??u;return(0,h.jsxs)(IH,{children:[e.state===`running`?(0,h.jsx)($H,{projectId:t.id}):null,c.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No narration has landed yet.`}):c.map(e=>(0,h.jsx)(iU,{name:e.name,output:e.output},e.role)),(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),f===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(RH,{children:`Voice`}),(0,h.jsx)(`span`,{className:`text-small text-ink`,children:f})]}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Chunking: ${aU(t.config.chunking)}`})]})]})}function iU({name:e,output:t}){let{api:n}=B(),r=AO(t.durationMs??void 0);return(0,h.jsxs)(`div`,{className:`grid grid-cols-[60px_minmax(0,1fr)_auto] items-center gap-3 text-small`,children:[(0,h.jsx)(RH,{children:e}),(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`${e} narration`,src:po(n,t.projectId,PM(t)),className:`h-8 w-full max-w-[520px]`}),(0,h.jsxs)(`span`,{className:`flex items-center gap-4`,children:[r===void 0?null:(0,h.jsx)(`span`,{className:`text-ink2 tabular-nums`,children:r}),(0,h.jsx)(JH,{output:t})]})]})}function aU(e){return e===void 0||e.mode===`whole`?`the whole text as one request`:e.mode===`paragraph`?`one request per paragraph`:e.mode===`characters`?`every ${String(e.characters??3e3)} characters`:`every ${String(e.words??500)} words`}function oU(e,t){let n=e.filter(e=>e.role===`image`),r=new Map;for(let e of n){let t=e.meta.promptName??`Images`;r.set(t,[...r.get(t)??[],e])}let i=t.filter(e=>r.has(e)),a=[...r.keys()].filter(e=>!i.includes(e)).sort();return[...i,...a].flatMap(e=>{let t=r.get(e);return t===void 0?[]:[{name:e,images:[...t].sort(sU)}]})}function sU(e,t){return(e.meta.index??0)-(t.meta.index??0)}function cU(e){return e===`9:16`?`aspect-[9/16]`:`aspect-video`}function lU({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=oU(EM(n,e),t.config.imagePrompts?.map(e=>e.name)??[]);return(0,h.jsxs)(IH,{children:[(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run stage`}),(0,h.jsx)(qH,{projectId:t.id,asset:`images.zip`,label:`Download all`})]}),a.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No images have landed yet.`}):null,a.map(e=>(0,h.jsxs)(`section`,{className:`flex flex-col gap-[10px]`,children:[(0,h.jsx)(RH,{children:`${e.name} × ${String(e.images.length)}`}),(0,h.jsx)(`div`,{className:`grid grid-cols-3 gap-2 min-[900px]:grid-cols-6`,children:e.images.map(e=>(0,h.jsx)(uU,{image:e,format:t.format,actions:r,busy:i},e.id))})]},e.name))]})}function uU({image:e,format:t,actions:n,busy:r}){let{api:i}=B(),a=e.meta.index===void 0?``:` ${String(e.meta.index)}`;return(0,h.jsxs)(`figure`,{className:`group relative m-0 overflow-hidden rounded-control border border-line bg-panel2`,children:[(0,h.jsx)(`img`,{src:po(i,e.projectId,PM(e)),alt:e.meta.prompt??`Slideshow image${a}`,className:W(`block w-full object-cover animate-tick-in motion-reduce:animate-none`,cU(t))}),(0,h.jsxs)(`figcaption`,{className:`absolute inset-x-0 bottom-0 flex flex-wrap items-center justify-between gap-1 bg-panel/90 p-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 motion-reduce:transition-none`,children:[(0,h.jsx)(JH,{output:e}),(0,h.jsx)(AM,{action:{kind:`regenerate-image`,outputId:e.id},run:()=>{n.run({kind:`regenerate-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Regenerate`}),(0,h.jsx)(AM,{action:{kind:`delete-image`,outputId:e.id},run:()=>{n.run({kind:`delete-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Delete`})]})]})}function dU({stage:e,outputs:t,actions:n,busy:r}){let i=EM(t,e),a=DM(i,`notes`);return e.state===`running`&&a===void 0?null:(0,h.jsxs)(IH,{children:[(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{n.run({kind:`rerun`,stage:e.kind})},disabled:r,pending:n.pending,children:`Re-run`}),(0,h.jsx)(ZH,{output:DM(i,`instructions`)}),a===void 0?null:(0,h.jsx)(JH,{output:a})]}),(0,h.jsx)(`section`,{"aria-label":`Research notes`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:a===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.state===`running`?`Research notes will be saved when the writing above finishes.`:`No notes were written.`}):(0,h.jsx)(XH,{output:a})})]})}function fU({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=B(),o=EM(n,e),s=DM(o,`thumbnail`),c=t.config.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(IH,{className:`grid grid-cols-1 items-start gap-4 min-[900px]:grid-cols-[200px_minmax(0,1fr)]`,children:[s===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No thumbnail has landed yet.`}):(0,h.jsx)(`img`,{src:po(a,s.projectId,PM(s)),alt:s.meta.prompt??`Thumbnail`,className:W(`block w-full rounded-control border border-line bg-panel2 object-cover`,cU(t.format))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(RH,{children:c?`Prompt written by the LLM`:`Prompt`}),s?.meta.prompt===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`This run stored no prompt for the thumbnail.`}):(0,h.jsx)(`p`,{className:`max-w-[75ch] rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-pretty text-small text-ink`,children:s.meta.prompt}),(0,h.jsxs)(LH,{children:[(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Regenerate`}),(0,h.jsx)(ZH,{output:DM(o,`instructions`)}),s===void 0?null:(0,h.jsx)(JH,{output:s})]})]})]})}function pU({stage:e,project:t,outputs:n,actions:r,busy:i,subtitleControls:a}){let{api:o}=B(),s=t.config.sources.video===`off`&&t.config.sources.audio!==`off`,c=DM(EM(n,e),s?`audio_export`:`video`),l=EM(n,e),u=DM(l,`subtitles_srt`),d=DM(l,`subtitles_vtt`),f=c?.meta.subtitlesMode??t.config.subtitles?.mode,p=e.state===`running`,m=jO(e.progressCurrent??0,e.progressTotal??0);return t.config.sources.video===`off`&&!s?(0,h.jsx)(IH,{children:a}):(0,h.jsxs)(IH,{children:[p?(0,h.jsx)(`p`,{className:`text-small text-run-text`,children:s?`Exporting combined audio`:e.progressTotal===null?`Re-rendering`:`Re-rendering · ${String(m)}%`}):null,c===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:s?`No combined audio export has landed yet.`:`No render has landed yet.`}):s?(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`Combined narration`,src:po(o,c.projectId,PM(c)),className:`h-9 w-full max-w-[720px]`},c.id):(0,h.jsx)(`video`,{controls:!0,preload:`metadata`,src:po(o,c.projectId,PM(c)),"aria-label":`Generated video`,className:W(`mx-auto block max-h-[min(58vh,560px)] w-auto max-w-full rounded-control bg-screen`,t.format===`9:16`?`aspect-[9/16]`:`aspect-video`),children:f===`files`&&d?(0,h.jsx)(`track`,{kind:`captions`,srcLang:`en`,label:`English`,default:!0,src:po(o,t.id,`subtitles-vtt`)},d.id):null},c.id),(0,h.jsxs)(LH,{children:[c===void 0?null:(0,h.jsx)(JH,{output:c,label:s?`Download .wav`:`Download .mp4`}),e.state===`pending`||e.state===`skipped`?null:(0,h.jsx)(AM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i||![`done`,`failed`,`canceled`].includes(e.state),pending:r.pending,children:s?`Re-export`:`Re-render`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:[AO(c?.durationMs??void 0),s?`WAV · stereo · 48 kHz`:t.format].filter(e=>e!==void 0).join(` · `)})]}),c?.meta.subtitleOmissions?.length?(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-3 text-small`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold`,children:[`Subtitles recovered after missing narration (`,c.meta.subtitleOmissions.length,`)`]}),(0,h.jsx)(`p`,{className:`mt-2 text-ink2`,children:`These transcript passages could not be matched to the audio and were left out of the captions. The audio is unchanged. Review these passages before sharing.`}),(0,h.jsx)(`ul`,{className:`mt-2 space-y-2`,children:c.meta.subtitleOmissions.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:new Date(e.start*1e3).toISOString().slice(11,19)}),` —`,` `,e.text]},`${e.start}-${e.text}`))})]}):null,u||d?(0,h.jsxs)(LH,{children:[u?(0,h.jsx)(JH,{output:u,label:`Download .srt`}):null,d?(0,h.jsx)(JH,{output:d,label:`Download .vtt`}):null]}):null,a?(0,h.jsxs)(`details`,{className:`mt-2 rounded-control border border-line px-4 py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small font-semibold`,children:`Subtitles & fonts`}),a]}):null]})}function mU(e){switch(e.stage.kind){case`research`:return(0,h.jsx)(dU,{...e});case`article`:return(0,h.jsx)(QH,{...e});case`audio`:return(0,h.jsx)(rU,{...e});case`images`:return(0,h.jsx)(lU,{...e});case`thumbnail`:return(0,h.jsx)(fU,{...e});case`video`:return(0,h.jsx)(pU,{...e})}}function hU({project:e,prompts:t,actions:n,inFlight:r,unsavedProviders:i,settingsOpen:a,onToggleSettings:o,primaryOutput:s}){let c=e.status===`running`;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-5 py-2`,children:[(0,h.jsxs)(`div`,{className:`w-full min-w-0 sm:min-w-[220px] sm:flex-1`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,h.jsx)(Zj,{state:e.status}),(0,h.jsx)(Yj,{state:e.status,announce:`Project`})]}),(0,h.jsx)(`h1`,{className:`break-words text-[28px] font-bold leading-tight`,children:e.title}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:gU(e,t)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s?(0,h.jsx)(`span`,{className:`rounded-control border border-accent bg-accent px-4 py-2 [&_a]:font-semibold [&_a]:text-accent-ink`,children:(0,h.jsx)(JH,{output:s,label:s.role===`video`?`Download video`:s.role===`audio_export`?`Download audio`:`Download article`})}):null,(0,h.jsxs)(J,{"aria-expanded":a,onClick:o,children:[(0,h.jsx)(jk,{"aria-hidden":`true`,className:`mr-2 size-4`}),`Run settings`,i?` •`:``]}),c||e.status===`pending`?(0,h.jsx)(J,{disabled:n.pending,onClick:()=>n.run({kind:`pause`}),children:`Pause`}):null,e.status===`paused`||e.status===`failed`?(0,h.jsx)(J,{disabled:n.pending||r||i,onClick:()=>n.run({kind:`resume`}),children:`Resume`}):null,c?(0,h.jsx)(AM,{action:{kind:`cancel`},run:()=>{n.run({kind:`cancel`})},pending:n.pending,children:`Cancel run`}):null]}),i?(0,h.jsx)(`p`,{className:`w-full rounded-control border border-line2 bg-panel2 px-3 py-2 text-small text-ink2`,children:`You have unsaved changes. Save or discard them before resuming.`}):null]})}function gU(e,t){let n=e.config.articlePrompt,r=t===void 0||t.some(e=>e.name===n);return[n===void 0||n===``?void 0:r?n:`${n} (deleted)`,e.format,`started ${Sc(e.createdAt)}`].filter(e=>e!==void 0).join(` · `)}var _U=e=>e.state===`done`||e.state===`provided`;function vU(e){let t=e.filter(e=>e.state!==`skipped`),n=t.length,r=t.filter(_U).length,i=t.reduce((e,t)=>_U(t)?e+1:t.progressTotal===null||t.progressTotal<=0?e:e+Math.min(.99,Math.max(0,(t.progressCurrent??0)/t.progressTotal)),0);return{completed:r,total:n,percent:n===0?0:Math.min(r===n?100:99,Math.round(i/n*100))}}function yU(e){let t=e.find(e=>e.state===`failed`)??e.find(e=>e.state===`running`);if(t)return t.kind;let n=e.find(e=>e.kind===`video`&&_U(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&_U(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function bU({stages:e,project:t}){let n=vU(e);return(0,h.jsxs)(`div`,{className:`rounded-panel border border-line bg-panel px-5 py-4`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold`,children:`Overall progress`}),(0,h.jsxs)(`span`,{className:`text-small text-ink2`,children:[n.completed,` of `,n.total,` stages finished`]})]}),(0,h.jsxs)(`span`,{className:`text-small font-semibold tabular-nums`,children:[n.percent,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`Overall progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n.percent,"aria-valuetext":`${n.percent} percent; ${n.completed} of ${n.total} stages finished`,className:`h-2 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:W(`h-full origin-left bg-accent transition-transform duration-200 motion-reduce:transition-none`,t.status===`failed`&&`bg-red`),style:{transform:`scaleX(${n.percent/100})`}})}),(0,h.jsx)(`p`,{className:`mt-2 text-label text-ink3`,children:`Combines finished stages with progress reported by active stages.`})]})}function xU({stages:e,project:t,outputs:n,selected:r,onSelect:i}){return(0,h.jsxs)(`nav`,{"aria-label":`Project stages`,className:`h-fit rounded-panel border border-line bg-panel lg:sticky lg:top-6`,children:[(0,h.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Stages`})}),(0,h.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-1`,children:e.map(e=>{let a=e.kind===r,o=SO(e.kind,t.config),s=e.state===`done`||e.state===`provided`;return(0,h.jsxs)(`button`,{type:`button`,"aria-label":`${o}, ${e.state}`,"aria-current":a?`step`:void 0,onClick:()=>i(e.kind),className:W(`group relative flex min-w-0 items-start gap-2 border-b border-line px-3 py-4 sm:gap-3 sm:px-4 text-left transition-colors last:border-b-0 hover:bg-panel2`,a&&`bg-panel2 before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-accent`,e.state===`skipped`&&`text-ink3`),children:[(0,h.jsx)(Tc,{kind:e.kind,className:W(`mt-0.5 shrink-0 text-ink2`,a&&`text-run-text`)}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block text-body font-semibold`,children:o}),(0,h.jsx)(`span`,{className:`mt-1 block truncate text-label text-ink2`,children:TO(e,n,t)}),(0,h.jsxs)(`span`,{className:`mt-2 flex items-center gap-2`,children:[(0,h.jsx)(Zj,{state:e.state}),(0,h.jsx)(Yj,{state:e.state,announce:o})]})]}),s?(0,h.jsx)(bk,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):e.state===`canceled`?(0,h.jsx)(wk,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 sm:block`}):a?(0,h.jsx)(Ck,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):null]},e.id)})})]})}function SU({project:e,providers:t,actions:n,inFlight:r,edits:i,setEdits:a}){let{api:o}=B(),s=R(Ly(o)),{config:c}=e,l=i.llm??c.llm??{provider:``,model:``},u=i.audio??c.audio??{provider:``,model:``,voice:``},d=i.images??c.images??{provider:``,model:``},f=c.sources.research===`generate`||c.sources.article===`generate`||c.sources.thumbnail===`prompt_by_llm`||c.sources.audio===`generate`&&(c.intro?.mode===`llm`||c.outro?.mode===`llm`),p=c.sources.audio===`generate`,m=c.sources.images===`generate`||c.sources.thumbnail===`from_prompt`||c.sources.thumbnail===`prompt_by_llm`;if(!f&&!p&&!m)return null;let g=(e.status===`paused`||e.status===`failed`)&&!r,_=CU(c,i),v=Object.keys(_).length>0,y=e=>e.provider!==``&&e.model.trim()!==``&&t.some(t=>t.id===e.provider&&(t.readiness.kind===`keyed`?t.readiness.hasKey:t.readiness.installed)),b=(!_.llm||y(_.llm))&&(!_.images||y(_.images))&&(!_.audio||y(_.audio)&&(s.data?.voices??[]).some(e=>e.provider===_.audio?.provider&&e.voiceId===_.audio.voice));return(0,h.jsx)(cA,{className:`block py-3`,"data-tour":`project-providers`,children:(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-row font-semibold`,children:`Run providers`}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:g?`Save your choices, then press Resume when ready. Finished outputs stay as they are. Changing the voice, TTS model or chunking restarts unfinished narration to keep one voice throughout.`:r&&e.status===`paused`?`Pausing: waiting for active requests to stop before providers can be changed.`:e.status===`done`||e.status===`canceled`?`These are the saved providers for this run. Start a new run to choose different providers.`:`Pause the run to change providers, models or voice. These controls are also available after a failure.`}),(0,h.jsxs)(`fieldset`,{disabled:!g||n.pending,className:`mt-3 flex min-w-0 flex-col gap-3 disabled:opacity-60`,children:[f?(0,h.jsx)(wU,{label:`Text`,choice:l,family:`llm`,providers:t,onChange:e=>a(t=>({...t,llm:e}))}):null,p?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(wU,{label:`TTS`,choice:u,family:`tts`,providers:t,onChange:e=>a(t=>({...t,audio:{...e,voice:e.provider===u.provider?u.voice:``}}))}),(0,h.jsx)(wj,{label:`Narration voice`,inline:!0,value:u.voice,placeholder:`Pick a voice`,problem:void 0,options:(s.data?.voices??[]).filter(e=>e.provider===u.provider).map(e=>({value:e.voiceId,label:e.name})),onPick:e=>a(t=>({...t,audio:{...u,voice:e}}))})]}):null,p?(0,h.jsx)(Bj,{value:i.chunking??c.chunking??{mode:`whole`},onPick:e=>a(t=>({...t,chunking:e}))}):null,m?(0,h.jsx)(wU,{label:`Image`,choice:d,family:`image`,providers:t,onChange:e=>a(t=>({...t,images:e}))}):null,(0,h.jsx)(`div`,{children:(0,h.jsx)(J,{disabled:!g||n.pending||!b||!v,onClick:()=>n.run({kind:`providers`,choices:_},()=>a({})),children:`Save providers`})})]}),v?(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Save or discard provider changes before resuming.`}),(0,h.jsx)(J,{disabled:n.pending,onClick:()=>a({}),children:`Discard provider changes`})]}):null,s.error?(0,h.jsx)(`p`,{className:`mt-2 text-small text-red`,children:s.error.message}):null]})})}function CU(e,t){return{...t.chunking&&!Rj(t.chunking,e.chunking)?{chunking:t.chunking}:{},...t.llm&&!TU(t.llm,e.llm)?{llm:t.llm}:{},...t.audio&&!TU(t.audio,e.audio)?{audio:t.audio}:{},...t.images&&!TU(t.images,e.images)?{images:t.images}:{}}}function wU({label:e,choice:t,family:n,providers:r,onChange:i}){return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(Dj,{label:`${e} provider`,inline:!0,family:n,providers:r,value:t.provider,problem:void 0,onPick:e=>i({provider:e,model:``})}),(0,h.jsx)(Oj,{label:`${e} model`,inline:!0,provider:t.provider,value:t.model,problem:void 0,onPick:e=>i({...t,model:e})}),n===`llm`?(0,h.jsx)(Aj,{choice:t,onChange:i}):null]})}function TU(e,t){return e.provider===t?.provider&&e.model===t.model&&e.thinking===t.thinking&&(`voice`in e?e.voice:void 0)===(t&&`voice`in t?t.voice:void 0)}function EU(e,t){switch(e){case`research`:case`article`:return t.llm?.provider;case`audio`:return t.audio?.provider;case`images`:case`thumbnail`:return t.images?.provider;case`video`:return}}function DU(e,t,n){let r=EU(e,t);if(r===void 0||r===``)return;let i=n.find(e=>e.id===r);if(i!==void 0)return i.readiness.kind===`keyed`?i.readiness.hasKey?void 0:{label:`Key missing`,provider:r}:i.readiness.installed?void 0:{label:`CLI missing`,provider:r}}var OU={research:`Research notes`,article:`Article workspace`,audio:`Narration`,images:`Image library`,thumbnail:`Thumbnail preview`,video:`Preview & export`};function kU({stage:e,project:t,outputs:n,providers:r,actions:i,children:a,active:o=!0}){let s=SO(e.kind,t.config),c=t.status===`paused`?{...i,pending:!0}:i,l=DU(e.kind,t.config,r),u=i.refusal?.stage===e.kind?i.refusal.message:void 0,d=e.state===`failed`||e.state===`canceled`,f=n.some(t=>t.stageKind===e.kind&&t.role!==`instructions`)||e.state===`running`||e.state===`done`||e.state===`provided`||e.kind===`video`&&e.state!==`skipped`,p=e.progressTotal===null||e.progressTotal<=0?void 0:Math.min(100,Math.max(0,Math.round((e.progressCurrent??0)/e.progressTotal*100)));return(0,h.jsxs)(`section`,{"data-tour":`project-${e.kind}`,hidden:!o,"aria-label":`${s} workspace`,className:o?`min-w-0 rounded-panel border border-line bg-panel`:`hidden`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-line px-5 py-4`,children:[(0,h.jsx)(Tc,{kind:e.kind,className:`text-ink2`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`text-row font-bold`,children:e.kind===`video`&&s===`Audio export`?`Listen & export`:OU[e.kind]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:TO(e,n,t)})]}),(0,h.jsx)(Yj,{state:e.state})]}),e.state===`running`?(0,h.jsxs)(`div`,{className:`border-b border-line px-5 py-3`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex justify-between text-small text-run-text`,children:[(0,h.jsxs)(`span`,{children:[s,` in progress`]}),p===void 0?(0,h.jsx)(`span`,{children:`Waiting for provider progress`}):(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[p,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`${s} progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":p,className:`h-1.5 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:`h-full origin-left bg-accent`,style:{transform:`scaleX(${(p??0)/100})`}})})]}):null,d?(0,h.jsxs)(`div`,{className:`m-5 rounded-control border border-red/30 bg-red-tint p-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`min-w-0 flex-1 text-small text-red`,children:e.state===`failed`?`${s} needs attention.`:`${s} was canceled.`}),(0,h.jsx)(`span`,{className:`text-label text-ink2`,children:EO(e)}),(0,h.jsx)(`button`,{type:`button`,disabled:l!==void 0||c.pending,onClick:()=>c.run({kind:`retry`,stage:e.kind}),className:`rounded-control border border-red px-3 py-2 text-small text-ink hover:bg-panel2 disabled:opacity-50`,children:l?.label??`Retry stage`})]}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:t.status===`paused`?`Resume the project to continue with its saved settings.`:`Retry keeps completed outputs. To change the provider or model, open Run settings.`}),e.failureReason?(0,h.jsxs)(`details`,{className:`mt-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small text-red`,children:`Error details`}),(0,h.jsx)(`span`,{className:`mt-2 block max-h-48 overflow-auto whitespace-pre-wrap break-words text-label text-ink2`,children:e.failureReason})]}):null,l?(0,h.jsxs)(`p`,{className:`mt-3 text-small text-ink2`,children:[l.label,` for `,l.provider,`.`,` `,(0,h.jsx)(ia,{to:`/settings`,className:`underline underline-offset-4`,children:`Open Settings`})]}):null]}):null,u?(0,h.jsx)(`div`,{className:`px-5 pt-4`,children:(0,h.jsx)(KH,{message:u,onDismiss:i.dismissRefusal})}):null,e.state===`running`&&e.kind!==`article`&&e.kind!==`images`&&e.kind!==`video`?(0,h.jsx)(NM,{projectId:t.id,stage:e.kind}):null,f?a:d?null:(0,h.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,h.jsx)(Tc,{kind:e.kind,className:`size-8 text-ink3`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:e.state===`skipped`?`${s} was switched off for this run.`:t.status===`paused`?`Resume the project when you are ready to continue.`:`This stage will start when its inputs are ready.`}),(0,h.jsx)(`p`,{className:`max-w-md text-small text-ink3`,children:e.state===`skipped`?`The other stages are available from the list.`:`You can review completed outputs while the project runs.`})]})]})}function AU({project:e,actions:t,inFlight:n,value:r,uploading:i,onChange:a,onDiscard:o,onUploading:s}){let c=!$D(QD(e.config.subtitles,e.config.sources),r),l=e.status!==`running`&&!n,u=e.config.sources.audio!==`off`,d=e.config.sources.video!==`off`&&e.config.sources.images!==`off`;return(0,h.jsxs)(`div`,{"data-tour":`project-subtitles`,className:`mt-2 min-w-0 border-t border-line pt-4`,children:[(0,h.jsx)(hM,{value:r,format:e.format,audioEnabled:u,videoEnabled:d,disabled:!l||t.pending,onChange:a,onUploading:s}),(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:l?e.status===`paused`?`Save subtitles, then Resume to update the export. Existing narration and images are reused.`:`Saving updates only the local export using saved narration and images. No paid generation requests are made.`:`Pause the run and wait for active requests to stop before changing subtitles.`}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(J,{disabled:!l||t.pending||i||!u||!c||!eO(r),onClick:()=>t.run({kind:`subtitles`,subtitles:QD(r,e.config.sources)},o),children:`Save subtitles`}),c?(0,h.jsx)(J,{variant:`ghost`,disabled:t.pending||i,onClick:o,children:`Discard subtitle changes`}):null,c&&e.status===`paused`?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Save or discard subtitle changes before resuming.`}):null]})]})}function jU(e){let{api:t}=B(),n=_(),[r,i]=(0,m.useState)(void 0),a=tt({mutationFn:e=>NU(t,e.projectId,e.action),onMutate:()=>{i(void 0)},onSuccess:async(e,t)=>{if(!e.ok){i({message:e.message,stage:MU(t.action)});return}let{project:r,stages:a,outputs:o}=e.value;n.setQueryData(jy.project(t.projectId),{project:r,stages:a,outputs:o}),n.invalidateQueries({queryKey:jy.projects}),await n.invalidateQueries({queryKey:jy.project(t.projectId)})},onError:(e,t)=>{i({message:e.message,stage:MU(t.action)})}});return{run:(t,n)=>{a.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}})},pending:a.isPending,refusal:r,dismissRefusal:()=>{i(void 0)}}}function MU(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function NU(e,t,n){switch(n.kind){case`pause`:return wH(e,t);case`resume`:return TH(e,t);case`providers`:return EH(e,t,n.choices);case`subtitles`:return DH(e,t,n.subtitles);case`cancel`:return CH(e,t);case`retry`:return OH(e,t,n.stage);case`rerun`:return kH(e,t,n.stage);case`save-article`:return AH(e,t,n.markdown);case`delete-image`:return jH(e,t,n.outputId);case`regenerate-image`:return MH(e,t,n.outputId)}}var PU=200;function FU(e){let{api:t,openEvents:n}=B(),r=_();(0,m.useEffect)(()=>{let i=_O(()=>{r.invalidateQueries({queryKey:jy.project(e)}),r.invalidateQueries({queryKey:jy.projects})},PU),a=Xy(n,Ao(t,`projects/${e}`),{refetch:i.ask,previewWriting:t=>{r.setQueryData(jM(e),e=>MM(e??[],t))},appendArticle:t=>{r.setQueryData(jy.article(e),e=>`${e??``}${t}`)},patch:t=>{t.type===`stage.state`&&t.state===`running`&&(r.setQueryData(jM(e),e=>(e??[]).filter(e=>e.stage!==t.stage)),t.stage===`article`&&r.setQueryData(jy.article(e),``)),r.setQueryData(jy.project(e),e=>hO(e,t))}});return()=>{a(),i.stop()}},[t,n,r,e])}function IU({projectId:e}){return(0,h.jsx)(LU,{projectId:e},e)}function LU({projectId:e}){let{api:t}=B(),n=R(Ny(t,e)),r=R(Iy(t)),i=R(Ry(t)),a=jU(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)({}),[f,p]=(0,m.useState)(),[g,_]=(0,m.useState)(),v=lk(e),y=(0,m.useRef)(void 0);if((0,m.useEffect)(()=>{if(v===void 0){y.current=void 0;return}n.data!==void 0&&y.current!==v&&(y.current=v,v===`project`&&s(!0),v===`download`&&l({projectId:e,stage:xO(n.data.project.config)===`article`?`article`:`video`}))},[v,e,n.data]),FU(e),n.error!==null)return(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message});if(n.data===void 0)return(0,h.jsx)(RU,{});let{project:b,stages:x,outputs:S}=n.data,C=c?.projectId===e?c.stage:yU(x),w=t=>l({projectId:e,stage:t}),T=S.find(e=>e.role===`video`||e.role===`audio_export`)??(b.config.sources.video===`off`&&b.config.sources.audio===`off`?S.find(e=>e.role===`article_md`):void 0),E=x.some(e=>e.state===`running`),D=b.status===`running`||b.status===`paused`||E||a.pending,O=QD(b.config.subtitles,b.config.sources),k=f?.projectId===e?QD(f.value,b.config.sources):O,A=!$D(k,O),j=g?.projectId===e&&g.pending,M=()=>p(t=>t?.projectId===e?void 0:t);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,children:[(0,h.jsx)(ia,{to:`/`,className:`mb-[10px] block text-small text-ink2 hover:text-ink`,children:`< Projects`}),(0,h.jsxs)(`div`,{"data-tour":`project-controls`,children:[(0,h.jsx)(hU,{project:b,prompts:i.data?.prompts,actions:a,inFlight:E,settingsOpen:o,onToggleSettings:()=>s(!o),primaryOutput:T,unsavedProviders:Object.keys(CU(b.config,u)).length>0||A||j}),(0,h.jsx)(`div`,{hidden:!o,className:o?`mt-4 rounded-panel border border-line bg-panel`:`hidden`,children:(0,h.jsx)(SU,{project:b,providers:r.data?.providers??[],actions:a,inFlight:E,edits:u,setEdits:d})}),a.refusal===void 0||a.refusal.stage!==void 0?null:(0,h.jsx)(cA,{className:`py-[10px]`,children:(0,h.jsx)(KH,{message:a.refusal.message,onDismiss:a.dismissRefusal})})]}),(0,h.jsx)(TM,{}),(0,h.jsx)(bU,{stages:x,project:b}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(xU,{stages:x,project:b,outputs:S,selected:C,onSelect:w}),(0,h.jsx)(`div`,{className:`min-w-0`,children:x.map(t=>(0,h.jsx)(kU,{active:t.kind===C,stage:t,project:b,outputs:S,providers:r.data?.providers??[],actions:a,children:(0,h.jsx)(mU,{stage:t,project:b,outputs:S,actions:a,busy:D,...t.kind===`video`?{subtitleControls:(0,h.jsx)(AU,{project:b,actions:a,inFlight:E,value:k,uploading:j,onChange:t=>p({projectId:e,value:QD(t,b.config.sources)}),onDiscard:M,onUploading:t=>_(n=>n?.projectId===e&&n.pending===t?n:{projectId:e,pending:t})},e)}:{}})},t.id))})]})]})}function RU(){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,role:`status`,"aria-label":`Loading project`,children:[(0,h.jsx)(`div`,{className:`h-28 rounded-panel bg-panel`}),(0,h.jsx)(`div`,{className:`h-24 rounded-panel border border-line bg-panel`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(sA,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`h-4 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-16 rounded-control bg-panel2`})]},e))}),(0,h.jsx)(`div`,{className:`h-[560px] rounded-panel border border-line bg-panel`})]})]})}var zU=`relative grid grid-cols-[14px_minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[4px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[14px_minmax(0,1fr)_140px_100px_32px]`,BU=`col-start-2 row-start-2 text-small text-ink2 tabular-nums md:col-start-3 md:row-start-1`,VU=`col-start-3 row-start-1 justify-end md:col-start-4`,HU=`relative z-10 col-start-4 row-start-1 size-8 p-0 md:col-start-5`;function UU(){let{api:e}=B(),t=_(),n=R(My(e)),[r,i]=(0,m.useState)(void 0),a=tt({mutationFn:t=>oo(e,t),onSettled:async()=>{i(void 0),await t.invalidateQueries({queryKey:jy.projects})}});return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(`div`,{className:`mb-4 flex items-center`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Projects`}),(0,h.jsx)(J,{variant:`accent`,className:`ml-auto`,asChild:!0,children:(0,h.jsx)(ia,{to:`/play`,children:`New run`})})]}),(0,h.jsx)(TM,{}),n.data?.projects.length===0?(0,h.jsx)(Pk,{}):null,n.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:n.error.message})}),n.data===void 0?n.error===null?(0,h.jsx)(qU,{}):null:n.data.projects.length===0?(0,h.jsx)(sA,{children:(0,h.jsxs)(`p`,{className:`px-4 py-7 text-body text-ink2`,children:[`No projects yet. Set up a run on`,` `,(0,h.jsx)(ia,{to:`/play`,className:`rounded-control text-ink underline underline-offset-[3px]`,children:`Play`}),`.`]})}):(0,h.jsx)(sA,{children:n.data.projects.map(e=>(0,h.jsx)(WU,{project:e,onDelete:()=>{i(e)}},e.id))}),a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-[10px] text-label text-red`,children:a.error.message}),(0,h.jsx)(oA,{open:r!==void 0,title:r===void 0?``:`Delete "${r.title}"?`,consequence:`Deletes the project and every file it produced.`,verb:`Delete`,pending:a.isPending,onConfirm:()=>{r!==void 0&&a.mutate(r.id)},onCancel:()=>{i(void 0)}})]})}function WU({project:e,onDelete:t}){return(0,h.jsxs)(`div`,{className:zU,children:[(0,h.jsx)(Zj,{state:e.status,className:`col-start-1 row-start-1`}),(0,h.jsxs)(`span`,{className:`col-start-2 row-start-1 flex min-w-0 flex-wrap items-baseline gap-x-3`,children:[(0,h.jsx)(ia,{to:`/projects/$projectId`,params:{projectId:e.id},className:`rounded-control font-semibold after:absolute after:inset-0 after:content-['']`,children:e.title}),(0,h.jsx)(`span`,{className:`truncate text-small text-ink2`,children:GU(e)})]}),(0,h.jsx)(`span`,{className:BU,children:Sc(e.createdAt)}),(0,h.jsx)(Yj,{state:e.status,announce:e.title,className:VU}),(0,h.jsx)(KU,{project:e,onDelete:t}),e.status===`running`?(0,h.jsx)(lA,{current:e.progress,total:1}):null]})}function GU(e){let t=e.config.articlePrompt;return[t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function KU({project:e,onDelete:t}){let n=e.status===`running`;return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.title}`,className:HU,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(`span`,{title:n?`Cancel the run first`:void 0,children:(0,h.jsx)(mA,{disabled:n,onSelect:t,children:`Delete`})}),n?(0,h.jsx)(`p`,{className:`engraved px-[10px] py-[5px] text-ink3`,children:`Cancel the run first`}):null]})]})}function qU(){return(0,h.jsx)(sA,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`div`,{className:zU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-3 w-2/5 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-[10px] w-[90px] rounded-control bg-panel2 md:col-start-3`}),(0,h.jsx)(`span`,{className:`col-start-4 row-start-1 h-[10px] w-14 justify-self-end rounded-control bg-panel2 md:col-start-4`})]},e))})}function JU({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=B(),a=_(),o=ck(),s=R(Ry(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=pO(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(void 0),S=b!==void 0,[C,w]=(0,m.useState)(!1),T=s.data?.prompts,E=e??n,D=E===void 0?void 0:T?.find(e=>e.id===E),O=D===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:D.kind,name:`${D.name} copy`,body:D.body}:{kind:D.kind,name:D.name,body:D.body},k=p??b??O,A=tt({mutationFn:t=>To(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){y(e.fields);return}x(e.value),g(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:Ry(i).queryKey})}}),j=tt({mutationFn:e=>Eo(i,e),onSuccess:async()=>{w(!1),g(void 0),await a.invalidateQueries({queryKey:Ry(i).queryKey}),r(k.kind)}});EA(S,()=>{r(k.kind)});let M=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},N=qA(k,v),P=JA(N),F=ZA(k.body),I=k.body.trim()===``?[]:YA(N),ee=k.name.trim()===``?[]:XA(N);return sk({promptNamed:k.name.trim()!==``&&ee.length===0,promptBodyReady:k.body.trim()!==``&&I.length===0,promptHasKeywords:F.length>0&&I.length===0,promptSaveReady:P===void 0&&!A.isPending&&!S,promptSaving:A.isPending||S,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(AA,{}):E!==void 0&&D===void 0?(0,h.jsx)(YU,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(ia,{to:`/prompts`,search:{kind:k.kind},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(Sk,{"aria-hidden":`true`,className:`size-[14px]`}),`Prompts`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New prompt`:`Edit prompt`}),(0,h.jsxs)(`div`,{"data-tour":`prompt-editor`,className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${kA} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{"data-tour":`prompt-name`,className:`flex-1`,children:[(0,h.jsx)(NA,{htmlFor:c,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(FA,{id:c,value:k.name,"aria-invalid":ee.length>0,"aria-describedby":ee.length===0?void 0:l,onChange:e=>{M({...k,name:e.target.value},`name`)}}),ee.length===0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:ee.map(e=>e.message).join(` `)})]}),(0,h.jsx)(PA,{label:`Kind`,value:k.kind,options:rA,onPick:e=>{M({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,children:[(0,h.jsx)(NA,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(ej,{id:u,value:k.body,invalid:I.length>0,describedBy:I.length===0?void 0:d,onChange:e=>{M({...k,body:e},`body`)}})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(OA,{onDelete:e===void 0?void 0:()=>{w(!0)},blocked:P,blockedId:f,pending:A.isPending,saved:S,cancel:(0,h.jsx)(J,{asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{g(void 0)},children:`Cancel`})}),errors:[A.error,j.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{A.mutate(k)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:`${kA} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(wA,{slots:F,body:k.body,lint:I,lintId:d})})]}),(0,h.jsx)(oA,{open:C,title:`Delete "${k.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:j.isPending,onConfirm:()=>{e!==void 0&&j.mutate(e)},onCancel:()=>{w(!1)}})]}):(0,h.jsx)(YU,{kind:k.kind,children:s.error.message})}function YU({kind:e,children:t}){return(0,h.jsx)(jA,{back:(0,h.jsx)(ia,{to:`/prompts`,search:{kind:e},className:MA,children:`Back to Prompts`}),children:t})}var XU=`grid grid-cols-[minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_minmax(0,1fr)_auto_32px]`,ZU=`col-span-3 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1`,QU=`md:col-start-2 md:row-start-1`;function $U({kind:e,onKind:t}){let{api:n}=B(),r=_(),i=R(Ry(n)),[a,o]=(0,m.useState)(void 0),s=tt({mutationFn:e=>Eo(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:jy.prompts})}}),c=i.data?.prompts.filter(t=>t.kind===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Prompts`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(hA,{type:`single`,value:e,"aria-label":`Prompt kind`,onValueChange:e=>{let n=rA.find(t=>t.value===e);n!==void 0&&t(n.value)},children:rA.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(eW,{kind:e})]}),i.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(rW,{}):null:c.length===0?(0,h.jsx)(tW,{kind:e}):(0,h.jsx)(sA,{children:c.map(e=>(0,h.jsxs)(`div`,{className:XU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(`span`,{className:W(ZU,QU),children:e.slots.map(e=>(0,h.jsx)(uA,{name:e},e))}),(0,h.jsx)(J,{className:`col-start-2 row-start-1 md:col-start-3`,asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts/$promptId`,params:{promptId:e.id},children:`Edit`})}),(0,h.jsx)(nW,{prompt:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(oA,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function eW({kind:e}){return(0,h.jsx)(J,{asChild:!0,children:(0,h.jsxs)(ia,{to:`/prompts/new`,search:{kind:e},children:[(0,h.jsx)(kk,{"aria-hidden":`true`,className:`size-[14px]`}),`New prompt`]})})}function tW({kind:e}){return(0,h.jsx)(sA,{children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-7 text-ink2`,children:[(0,h.jsx)(`span`,{className:`max-w-[75ch]`,children:`No ${e} prompts yet. A prompt is text with {{keywords}}; each keyword becomes a field on Play.`}),(0,h.jsx)(eW,{kind:e})]})})}function nW({prompt:e,onDelete:t}){return(0,h.jsxs)(dA,{children:[(0,h.jsx)(fA,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-3 row-start-1 size-8 p-0 md:col-start-4`,children:(0,h.jsx)(Dk,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(pA,{children:[(0,h.jsx)(mA,{asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},children:`Duplicate`})}),(0,h.jsx)(mA,{onSelect:t,children:`Delete`})]})]})}function rW(){return(0,h.jsx)(sA,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:XU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsxs)(`span`,{className:W(ZU,QU),children:[(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[18px] w-[72px] rounded-control bg-panel2`})]}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-3`})]},e))})}function iW(){let{api:e}=B(),t=_(),n=R({queryKey:[`catalogue`],queryFn:async()=>Za(await e.fetch(`${e.origin}/api/providers/catalogue`)),refetchInterval:3e4}),r=tt({mutationFn:async()=>Za(await e.fetch(`${e.origin}/api/providers/catalogue/refresh`,{method:`POST`})),onSuccess:e=>{t.setQueryData([`catalogue`],e),t.invalidateQueries({queryKey:[`provider-models`]})}});return(0,h.jsxs)(`section`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Models and request limits`}),(0,h.jsx)(`p`,{className:`my-2 text-body text-ink2`,children:`The catalogue lists supported text, image and speech models, their prices and request limits. Local YAML edits load automatically; model pickers refresh every 30 seconds.`}),n.data?.path?(0,h.jsx)(`p`,{className:`my-2 break-all font-mono text-small`,children:n.data.path}):null,(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink2`,children:[`Verified `,n.data?.updatedAt??`date unavailable`,`. Refresh replaces your local file with the published catalogue and saves the previous file alongside it.`]}),(0,h.jsx)(J,{disabled:r.isPending||!n.data?.path,onClick:()=>r.mutate(),children:r.isPending?`Refreshing…`:`Refresh published catalogue`}),n.data?.warning||n.error||r.error?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 text-body text-red`,children:r.error?.message??n.error?.message??n.data?.warning}):null,r.isSuccess?(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-green`,children:`Catalogue updated.`}):null]})}function aW({provider:e,readiness:t}){let{api:n}=B(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(!1),p=e.cliPath?.configured??null,g=e.id===`claude-code`?`claude`:e.id,v=e.cliPath?.command??g,y=l??p??``,b=tt({mutationFn:t=>ho(n,e.id,t),onMutate:()=>f(!1),onSuccess:async e=>{r.setQueryData(jy.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),u(void 0),f(!0),await r.invalidateQueries({queryKey:jy.providers})}});return(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),TA);return()=>clearTimeout(e)},[d]),(0,h.jsxs)(`div`,{"data-ready":t.installed,className:`grid gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0 sm:grid-cols-[140px_1fr]`,children:[(0,h.jsx)(`span`,{id:i,className:W(`font-semibold`,t.installed?`text-ink`:`text-ink3`),children:e.displayName}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-ink2`,"aria-live":`polite`,children:[(0,h.jsx)(Zj,{state:t.installed?`done`:`pending`}),(0,h.jsx)(`span`,{children:oW(t,p)})]}),(0,h.jsxs)(`p`,{className:`mt-1 break-all text-label text-ink3`,children:[`Command: `,(0,h.jsx)(`code`,{children:v})]}),(0,h.jsxs)(`form`,{className:`mt-3`,onSubmit:e=>{e.preventDefault(),b.isPending||b.mutate(y)},children:[(0,h.jsx)(NA,{htmlFor:a,id:o,className:`mb-[5px]`,children:`Executable path`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(FA,{id:a,autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-labelledby":`${i} ${o}`,"aria-invalid":b.error!==null,"aria-describedby":`${s}${b.error?` ${c}`:``}`,placeholder:g,value:y,disabled:b.isPending,onChange:e=>{u(e.target.value),f(!1),b.reset()}}),(0,h.jsx)(J,{type:`submit`,"aria-label":`Save ${e.displayName} path`,disabled:b.isPending,children:b.isPending?`Checking…`:`Save path`}),d?(0,h.jsx)(DA,{}):null]}),(0,h.jsxs)(`p`,{id:s,className:`mt-1 text-label text-ink3`,children:[`Leave blank to find `,(0,h.jsx)(`code`,{children:g}),` on PATH. Use an absolute path without quotes or arguments.`]}),b.error?(0,h.jsx)(`p`,{id:c,role:`alert`,className:`mt-1 text-label text-red`,children:b.error.message}):null]}),(0,h.jsxs)(`p`,{className:`mt-2 text-label text-ink3`,children:[`Sign in through `,e.displayName,` itself before generating; Slopify uses that login.`]})]})]})}function oW(e,t){return e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found on PATH`:`Not found at saved path`}var sW=[`llm`,`tts`,`image`],cW={llm:`API keys · LLM`,tts:`API keys · Text to speech`,image:`API keys · Image generation`},lW=`••••••••••••`,uW=`grid grid-cols-[140px_1fr_auto] items-end gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0`,dW=`engraved border-t border-line px-4 py-3 text-ink3 first:border-t-0`;function fW(){let{api:e}=B(),t=R(Iy(e));if(t.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:t.error.message})})});if(t.data===void 0)return(0,h.jsx)(mW,{});let n=t.data.providers,r=n.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey);return(0,h.jsx)(sA,{children:sW.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,className:`border-t border-line first:border-t-0`,children:[(0,h.jsx)(`h2`,{className:dW,children:cW[e]}),n.filter(t=>t.family===e).map(e=>e.readiness.kind===`cli`?(0,h.jsx)(aW,{provider:e,readiness:e.readiness},e.id):(0,h.jsx)(pW,{provider:e,hasKey:e.readiness.hasKey},e.id)),e===`llm`&&r?(0,h.jsx)(`p`,{className:`border-t border-line px-4 pt-[10px] pb-[14px] text-small text-ink2`,children:`Paste a key to make its provider selectable on Play.`}):null]},e))})}function pW({provider:e,hasKey:t}){let{api:n}=B(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(!1),S=async()=>{f(!0),y(void 0);try{await z(n,e.id,l),u(``),g(!0),await r.invalidateQueries({queryKey:jy.providers})}catch(e){y(e instanceof Error?e.message:String(e))}finally{f(!1)}},C=tt({mutationFn:()=>go(n,e.id),onSuccess:async()=>{x(!1),y(void 0),await r.invalidateQueries({queryKey:jy.providers})},onError:e=>{x(!1),y(e.message)}});(0,m.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>{g(!1)},TA);return()=>{clearTimeout(e)}},[p]);let w=[t?s:void 0,v===void 0?void 0:c].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`div`,{"data-ready":t,className:uW,children:[(0,h.jsx)(`span`,{id:o,className:`pb-[7px] font-semibold`,children:e.displayName}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(NA,{htmlFor:i,id:a,className:`mb-[5px]`,children:`API key`}),(0,h.jsx)(FA,{id:i,type:`password`,autoComplete:`off`,spellCheck:!1,"aria-labelledby":`${o} ${a}`,"aria-invalid":v!==void 0,"aria-describedby":w===``?void 0:w,placeholder:t?lW:void 0,value:l,onChange:e=>{u(e.target.value)}}),e.id===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Paste the Base64 credentials from Inworld Settings → API Keys.`}):null,t?(0,h.jsx)(`span`,{id:s,className:`sr-only`,children:`A key is stored for this provider.`}):null,v===void 0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:v})]}),(0,h.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2`,children:[(0,h.jsx)(J,{"aria-label":`Save ${e.displayName} key`,disabled:l.trim()===``||d,onClick:()=>{S()},children:`Save`}),p?(0,h.jsx)(DA,{}):null,t?(0,h.jsx)(J,{className:`bg-transparent`,"aria-label":`Remove ${e.displayName} key`,onClick:()=>{x(!0)},children:`Remove`}):null]}),(0,h.jsx)(oA,{open:b,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,verb:`Remove`,pending:C.isPending,onConfirm:()=>{C.mutate()},onCancel:()=>{x(!1)}})]})}function mW(){return(0,h.jsx)(sA,{children:[0,1,2,3].map(e=>(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`h-4 w-28 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 flex-1 rounded-control bg-panel2`})]},e))})}var hW=_v,gW=xv;function _W({className:e,children:t,...n}){return(0,h.jsxs)(yv,{"data-slot":`select-trigger`,className:W(`flex h-8 w-full items-center justify-between gap-2 rounded-control border border-line2`,`bg-panel2 px-[10px] text-left text-small text-ink data-[placeholder]:text-ink3`,e),...n,children:[t,(0,h.jsx)(Sv,{asChild:!0,children:(0,h.jsx)(xk,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-ink2`})})]})}function vW({className:e,children:t,position:n=`popper`,...r}){return(0,h.jsx)(Tv,{children:(0,h.jsx)(Dv,{"data-slot":`select-content`,position:n,sideOffset:4,className:W(`z-50 min-w-[var(--radix-select-trigger-width)] overflow-hidden rounded-panel`,`border border-line bg-panel p-1 shadow-[0_8px_24px_var(--color-shadow)]`,e),...r,children:(0,h.jsx)(zv,{children:t})})})}function yW({className:e,children:t,...n}){return(0,h.jsxs)(Gv,{"data-slot":`select-item`,className:W(`relative flex cursor-default items-center rounded-control py-[5px] pr-8 pl-[10px]`,`text-small text-ink outline-hidden select-none`,`focus:bg-panel2 data-highlighted:bg-panel2`,e),...n,children:[(0,h.jsx)(qv,{children:t}),(0,h.jsx)(Yv,{className:`absolute right-[10px] flex items-center`,children:(0,h.jsx)(bk,{"aria-hidden":`true`,className:`size-[14px] text-done`})})]})}var bW=`px-4 align-top`;function xW(){let{api:e}=B(),t=_(),n=R(Ly(e)),r=R(Iy(e)),[i,a]=(0,m.useState)(void 0),o=tt({mutationFn:t=>xo(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:jy.voices})}}),s=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});let c=n.data?.voices;return(0,h.jsxs)(sA,{"data-tour":`voices`,children:[(0,h.jsxs)(`table`,{className:`w-full table-fixed border-collapse text-small`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`th`,{className:W(bW,`engraved w-[26%] py-3 text-left text-ink3`),children:`Voices · Name`}),(0,h.jsx)(`th`,{className:W(bW,`engraved w-[26%] py-3 text-left text-ink3`),children:`Provider`}),(0,h.jsx)(`th`,{className:W(bW,`engraved py-3 text-left text-ink3`),children:`Voice ID`}),(0,h.jsx)(`th`,{className:W(bW,`w-[104px] py-3`),children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:c===void 0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:W(bW,`py-4`),children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-panel2`})})}):c.length===0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:W(bW,`py-4 text-ink2`),children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):c.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`td`,{className:W(bW,`py-3 font-semibold`),children:e.name}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-ink2`),children:wW(s,e.provider)}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-ink2 tabular-nums`),children:e.voiceId}),(0,h.jsx)(`td`,{className:W(bW,`py-3 text-right`),children:(0,h.jsx)(J,{className:`bg-transparent`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))}),(0,h.jsx)(`tfoot`,{children:(0,h.jsx)(SW,{tts:s})})]}),o.error===null?null:(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-3 text-label text-red`,children:o.error.message}),(0,h.jsx)(oA,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,verb:`Remove`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function SW({tts:e}){let{api:t}=B(),n=_(),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(void 0),y=f??e[0]?.id,b=tt({mutationFn:e=>bo(t,e),onSuccess:async e=>{if(!e.ok){v(e.refusal);return}l(``),d(``),v(void 0),await n.invalidateQueries({queryKey:jy.voices})}}),x=(e,t)=>{t(),g?.field===e&&v(void 0)},S=e=>g?.field===e?g.message:void 0;return(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{htmlFor:r,className:`mb-[5px]`,children:`Voice name`}),(0,h.jsx)(FA,{id:r,value:c,"aria-invalid":S(`name`)!==void 0,onChange:e=>{let t=e.target.value;x(`name`,()=>{l(t)})}}),(0,h.jsx)(CW,{id:`${s}-name`,message:S(`name`)})]}),(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{id:a,className:`mb-[5px]`,children:`Provider`}),(0,h.jsxs)(hW,{value:y??``,onValueChange:t=>{let n=e.find(e=>e.id===t);n!==void 0&&x(`provider`,()=>{p(n.id)})},children:[(0,h.jsx)(_W,{id:i,"aria-labelledby":`${a} ${i}`,children:(0,h.jsx)(gW,{placeholder:`Pick a provider`})}),(0,h.jsx)(vW,{children:e.map(e=>(0,h.jsx)(yW,{value:e.id,children:e.displayName},e.id))})]}),(0,h.jsx)(CW,{id:`${s}-provider`,message:S(`provider`)})]}),(0,h.jsxs)(`td`,{className:W(bW,`py-[14px]`),children:[(0,h.jsx)(NA,{htmlFor:o,className:`mb-[5px]`,children:`Voice ID`}),(0,h.jsx)(FA,{id:o,className:`tabular-nums`,value:u,"aria-invalid":S(`voiceId`)!==void 0,"aria-describedby":S(`voiceId`)===void 0?void 0:`${s}-voiceId`,onChange:e=>{let t=e.target.value;x(`voiceId`,()=>{d(t)})}}),(0,h.jsx)(CW,{id:`${s}-voiceId`,message:S(`voiceId`)}),y===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}):null,b.error===null?null:(0,h.jsx)(`p`,{className:`mt-1 text-label text-red`,children:b.error.message})]}),(0,h.jsx)(`td`,{className:W(bW,`py-[14px] text-right`),children:(0,h.jsx)(J,{className:`mt-[22px]`,disabled:y===void 0||g!==void 0||b.isPending,onClick:()=>{y!==void 0&&b.mutate({provider:y,name:c,voiceId:u})},children:`Add voice`})})]})}function CW({id:e,message:t}){return t===void 0?null:(0,h.jsx)(`p`,{id:e,className:`mt-1 text-label text-red`,children:t})}function wW(e,t){return e.find(e=>e.id===t)?.displayName??t}var TW=30,EW=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function DW(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=TW?void 0:`The silence gap is a whole number of seconds between 0 and ${String(TW)}.`}function OW(){return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Settings`}),(0,h.jsx)(fW,{}),(0,h.jsx)(xW,{}),(0,h.jsx)(iW,{}),(0,h.jsx)(kW,{})]})}function kW(){let{api:e}=B(),t=_(),n=R(By(e)),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=tt({mutationFn:t=>vo(e,t),onMutate:e=>{let n=t.getQueryData(jy.settings);return t.setQueryData(jy.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(jy.settings,r.previous)},onSuccess:e=>{t.setQueryData(jy.settings,e)}});if((0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>{l(!1)},TA);return()=>{clearTimeout(e)}},[c]),n.error!==null)return(0,h.jsx)(sA,{children:(0,h.jsx)(cA,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});if(n.data===void 0)return(0,h.jsxs)(sA,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(cA,{children:[(0,h.jsx)(`span`,{className:`h-4 w-48 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 w-[72px] rounded-control bg-panel2`})]})]});let d=n.data,f=o??String(d.silenceGapSeconds),p=DW(f);return(0,h.jsxs)(sA,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] border-b border-line px-4 py-[14px]`,children:[(0,h.jsx)(`label`,{htmlFor:r,className:`font-semibold`,children:`Silence between segments`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px]`,children:[(0,h.jsx)(FA,{id:r,type:`number`,inputMode:`numeric`,min:0,max:TW,step:1,className:`w-[72px] tabular-nums`,value:f,"aria-invalid":p!==void 0,"aria-describedby":p===void 0?void 0:i,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`seconds`}),(0,h.jsx)(J,{className:`ml-[6px]`,disabled:p!==void 0||u.isPending,onClick:()=>{l(!1),u.mutate({silenceGapSeconds:Number(f.trim()),appearance:d.appearance},{onSuccess:()=>{s(void 0),l(!0)}})},children:`Save`}),c?(0,h.jsx)(DA,{}):null,p===void 0?null:(0,h.jsx)(`p`,{id:i,className:`basis-full text-label text-red`,children:p}),u.error===null?null:(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:u.error.message})]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] px-4 py-[14px]`,children:[(0,h.jsx)(`span`,{id:a,className:`font-semibold`,children:`Appearance`}),(0,h.jsx)(hA,{type:`single`,value:d.appearance,"aria-labelledby":a,className:`justify-self-start`,onValueChange:e=>{let t=EW.find(t=>t.value===e);t!==void 0&&u.mutate({silenceGapSeconds:d.silenceGapSeconds,appearance:t.value})},children:EW.map(e=>(0,h.jsx)(gA,{value:e.value,children:e.label},e.value))})]})]})}function AW({counters:e}){return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:e.map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col-reverse gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`dt`,{className:`engraved text-ink3`,children:e.label}),(0,h.jsx)(`dd`,{className:`m-0 text-counter font-bold tabular-nums tracking-[-0.01em]`,children:e.value})]},e.label))})}function jW({cells:e}){return(0,h.jsx)(`div`,{className:`grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`})]},e))})}function MW(){let{api:e}=B(),t=R(Fy(e));return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`mb-1 text-title font-bold tracking-[-0.01em]`,children:`Usage`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`This machine only. The same counters, anonymised, feed slopify.stream.`})]}),t.error===null?null:(0,h.jsx)(sA,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:t.error.message})}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(jW,{cells:5}),(0,h.jsx)(VW,{})]}):null:(0,h.jsx)(NW,{usage:t.data})]})}function NW({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(AW,{counters:BW(e)}),t?(0,h.jsx)(`p`,{className:`-mt-3 text-body text-ink2`,children:`Numbers appear after your first run.`}):null,(0,h.jsxs)(`div`,{className:`overflow-hidden rounded-panel border border-line bg-panel`,children:[(0,h.jsxs)(`table`,{"aria-label":`Tokens by stage`,className:`w-full table-fixed border-collapse`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(PW,{className:`w-[24%]`,children:`Tokens by stage`}),(0,h.jsx)(PW,{className:`w-[38%]`,children:`Provider · model`}),(0,h.jsx)(PW,{className:`w-[19%] text-right`,children:`Tokens in`}),(0,h.jsx)(PW,{className:`w-[19%] text-right`,children:`Tokens out`})]})}),(0,h.jsx)(`tbody`,{children:e.byStage.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line last:border-b-0`,children:[(0,h.jsx)(FW,{className:`truncate font-semibold`,children:bO[e.stage]}),(0,h.jsx)(FW,{className:`truncate text-ink2`,children:IW(e)}),(0,h.jsx)(FW,{className:`text-right tabular-nums`,children:LW.format(e.tokensIn)}),(0,h.jsx)(FW,{className:`text-right tabular-nums`,children:LW.format(e.tokensOut)})]},`${e.stage}/${e.provider}/${e.model??``}`))})]}),e.byStage.length===0?(0,h.jsx)(`p`,{className:`px-4 py-5 text-small text-ink3`,children:`No stages have run yet.`}):null]}),(0,h.jsx)(`p`,{className:`engraved text-ink3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]})}function PW({children:e,className:t}){return(0,h.jsx)(`th`,{className:`engraved px-4 py-3 text-left text-ink3 ${t}`,children:e})}function FW({children:e,className:t}){return(0,h.jsx)(`td`,{className:`px-4 py-3 align-top text-small ${t}`,children:e})}function IW(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var LW=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),RW=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),zW=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function BW(e){let t=e.counters;return[{label:`Videos made`,value:LW.format(t.videosMade)},{label:`Hours of audio`,value:RW.format(t.audioSeconds/3600)},{label:`Images made`,value:LW.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?LW.format(t.tokensUsed):zW.format(t.tokensUsed)},{label:`Projects`,value:LW.format(t.projects)}]}function VW(){return(0,h.jsx)(sA,{children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-[14px] border-b border-line px-4 py-3 last:border-b-0`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-56 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-panel2`})]},e))})}var HW=ca({component:Wk}),UW=oa({getParentRoute:()=>HW,path:`/`,component:UU}),WW=oa({getParentRoute:()=>HW,path:`play`,component:xM}),GW=oa({getParentRoute:()=>HW,path:`projects/$projectId`,component:eG}),KW=oa({getParentRoute:()=>HW,path:`prompts`,validateSearch:e=>({kind:aA(e.kind)}),component:tG}),qW=oa({getParentRoute:()=>HW,path:`prompts/new`,validateSearch:e=>{let t=aA(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:nG}),JW=oa({getParentRoute:()=>HW,path:`prompts/$promptId`,component:rG}),YW=oa({getParentRoute:()=>HW,path:`entries`,validateSearch:e=>({category:nA(e.category)}),component:aG}),XW=oa({getParentRoute:()=>HW,path:`entries/new`,validateSearch:e=>{let t=nA(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:oG}),ZW=oa({getParentRoute:()=>HW,path:`entries/$entryId`,component:sG}),QW=oa({getParentRoute:()=>HW,path:`settings`,component:OW}),$W=oa({getParentRoute:()=>HW,path:`usage`,component:MW});function eG(){let{projectId:e}=GW.useParams();return(0,h.jsx)(IU,{projectId:e},e)}function tG(){let{kind:e}=KW.useSearch(),t=Hi();return(0,h.jsx)($U,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})}})}function nG(){let{kind:e,from:t}=qW.useSearch(),n=iG();return(0,h.jsx)(JU,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function rG(){let{promptId:e}=JW.useParams(),t=iG();return(0,h.jsx)(JU,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function iG(){let e=Hi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function aG(){let{category:e}=YW.useSearch(),t=Hi();return(0,h.jsx)(yA,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})}})}function oG(){let{category:e,from:t}=XW.useSearch(),n=cG();return(0,h.jsx)(tj,{entryId:void 0,category:e,from:t,onLeave:n})}function sG(){let{entryId:e}=ZW.useParams(),t=cG();return(0,h.jsx)(tj,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function cG(){let e=Hi();return t=>{e({to:`/entries`,search:{category:t}})}}var lG=HW.addChildren({projectsRoute:UW,playRoute:WW,projectRoute:GW,promptsRoute:KW,newPromptRoute:qW,promptRoute:JW,entriesRoute:YW,newEntryRoute:XW,entryRoute:ZW,settingsRoute:QW,usageRoute:$W});function uG(){return Ta({routeTree:lG})}function dG(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;return}if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function fG(e,t){return async(n,r)=>{let i=await e(n,r),a=i.headers.get(`X-Slopify-Version`);return a!==null&&t.observe(a),i}}function pG(e){let t=dG(),n={api:ro(window.location.origin,fG(window.fetch.bind(window),t)),openEvents:e=>new EventSource(e),version:t};(0,Xa.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ve,children:(0,h.jsx)(Mo,{deps:n,children:(0,h.jsx)(Oa,{router:uG()})})})}))}var mG=document.getElementById(`root`);if(mG===null)throw Error(`index.html carries no #root element for the app to mount on`);pG(mG);
130
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Rz(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=FB.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function GB(){return{exit:{taskListCheckValueChecked:qB,taskListCheckValueUnchecked:qB,paragraph:JB}}}function KB(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:YB}}}function qB(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function JB(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function YB(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=FB.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function XB(){return[nz(),Ez(),jz(),IB(),GB()]}function ZB(e){return{extensions:[rz(),Dz(e),Mz(),WB(e),KB()]}}var QB={tokenize:fV,partial:!0},$B={tokenize:pV,partial:!0},eV={tokenize:mV,partial:!0},tV={tokenize:hV,partial:!0},nV={tokenize:gV,partial:!0},rV={name:`wwwAutolink`,tokenize:uV,previous:_V},iV={name:`protocolAutolink`,tokenize:dV,previous:vV},aV={name:`emailAutolink`,tokenize:lV,previous:yV},oV={};function sV(){return{text:oV}}for(var cV=48;cV<123;)oV[cV]=aV,cV++,cV===58?cV=65:cV===91&&(cV=97);oV[43]=aV,oV[45]=aV,oV[46]=aV,oV[95]=aV,oV[72]=[aV,iV],oV[104]=[aV,iV],oV[87]=[aV,rV],oV[119]=[aV,rV];function lV(e,t,n){let r=this,i,a;return o;function o(t){return!bV(t)||!yV.call(r,r.previous)||xV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return bV(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(nV,u,l)(t):t===45||t===95||eP(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&$N(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function uV(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!_V.call(r,r.previous)||xV(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(QB,e.attempt($B,e.attempt(eV,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function dV(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&vV.call(r,r.previous)&&!xV(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if($N(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||nP(t)||oP(t)||lP(t)||cP(t)?n(t):e.attempt($B,e.attempt(eV,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function fV(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function pV(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(tV,c,s)(t):t===null||oP(t)||lP(t)||t!==45&&cP(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function mV(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(tV,t,a)(o):o===null||oP(o)||lP(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function hV(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||oP(o)||lP(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||oP(e)||lP(e)?t(e):r(e)}function a(e){return $N(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):$N(t)?(e.consume(t),o):n(t)}}function gV(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return eP(e)?n(e):t(e)}}function _V(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||oP(e)}function vV(e){return!$N(e)}function yV(e){return!(e===47||bV(e))}function bV(e){return e===43||e===45||e===46||e===95||eP(e)}function xV(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var SV={tokenize:AV,partial:!0};function CV(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:DV,continuation:{tokenize:OV},exit:kV}},text:{91:{name:`gfmFootnoteCall`,tokenize:EV},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:wV,resolveTo:TV}}}}function wV(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=QN(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function TV(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function EV(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||oP(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(QN(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return oP(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function DV(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||oP(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=QN(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return oP(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),fP(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function OV(e,t,n){return e.check(DP,t,e.attempt(SV,t,n))}function kV(e){e.exit(`gfmFootnoteDefinition`)}function AV(e,t,n){let r=this;return fP(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function jV(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&GN(o,o.length,0,bP(s,e.slice(r+1,n),t)),GN(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),GN(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=yP(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=yP(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var MV=class{constructor(){this.map=[]}add(e,t,n){NV(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function NV(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function PV(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function FV(){return{flow:{null:{name:`table`,tokenize:IV,resolveAll:LV}}}}function IV(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):$(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):sP(t)?fP(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||oP(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,sP(t)?fP(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return sP(t)?fP(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||$(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return sP(t)?fP(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||$(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||$(n)?(e.exit(`tableRow`),t(n)):sP(n)?fP(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||oP(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function LV(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new MV;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(zV(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=RV(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=RV(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=RV(f,t,o,i,n,d)):(o[0]=o[1],d=RV(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&zV(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=PV(t.events,n))}return e}function RV(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},BV(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=BV(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=BV(t.events,n[2]),a=BV(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},BV(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function zV(e,t,n,r,i){let a=[],o=BV(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function BV(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var VV={name:`tasklistCheck`,tokenize:UV};function HV(){return{text:{91:VV}}}function UV(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return oP(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return $(r)?t(r):sP(r)?e.check({tokenize:WV},t,n)(r):n(r)}}function WV(e,t,n){return fP(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function GV(e){return JN([sV(),CV(),jV(e),FV(),HV()])}var KV={};function qV(e){let t=this,n=e||KV,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(GV(n)),a.push(XB()),o.push(ZB(n))}var JV=new Set([400,404,409]);async function YV(e,t){return oH(await e.client.projects[`:id`].cancel.$post({param:{id:t}}))}async function XV(e,t){return oH(await e.client.projects[`:id`].pause.$post({param:{id:t}}))}async function ZV(e,t){return oH(await e.client.projects[`:id`].resume.$post({param:{id:t}}))}async function QV(e,t,n){return oH(await e.client.projects[`:id`].providers.$patch({param:{id:t},json:n}))}async function $V(e,t,n){return oH(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function eH(e,t,n){return oH(await e.client.projects[`:id`].stages[`:kind`].retry.$post({param:{id:t,kind:n}}))}async function tH(e,t,n){return oH(await e.client.projects[`:id`].stages[`:kind`].rerun.$post({param:{id:t,kind:n}}))}async function nH(e,t,n){return oH(await e.client.projects[`:id`].article.$put({param:{id:t},json:{markdown:n}}))}async function rH(e,t,n){return oH(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function iH(e,t,n){return oH(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function aH(e,t,n){return Qa(await e.fetch(po(e,t,n)))}async function oH(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await no(e);if(t!==void 0&&JV.has(e.status))return{ok:!1,message:to(e,t).message};throw to(e,t)}function sH({projectId:e,asset:t}){let{api:n}=B(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)();async function s(){i(!0),o(void 0);try{let r=await n.client.projects[`:id`][`open-folder`].$post({param:{id:e},json:{asset:t}});if(!r.ok)throw to(r,await no(r))}catch(e){o(e instanceof Error?e.message:`Could not open the folder.`)}finally{i(!1)}}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,disabled:r,onClick:()=>void s(),title:`Open the saved output folder on the machine running Slopify`,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink disabled:opacity-50`,children:[(0,h.jsx)(ek,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),r?`Opening…`:`Open folder`]}),a!==void 0&&(0,h.jsx)(`span`,{role:`alert`,className:`basis-full text-small text-red`,children:a})]})}function cH({children:e,className:t}){return(0,h.jsx)(`div`,{className:W(`flex min-w-0 flex-col gap-4 p-5`,t),children:e})}function lH({children:e}){return(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 text-small`,children:e})}function uH({children:e}){return(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e})}var dH={h1:({children:e})=>(0,h.jsx)(pH,{size:`text-title`,children:e}),h2:({children:e})=>(0,h.jsx)(pH,{size:`text-row`,children:e}),h3:({children:e})=>(0,h.jsx)(pH,{size:`text-row`,children:e}),h4:({children:e})=>(0,h.jsx)(pH,{size:`text-row`,children:e}),h5:({children:e})=>(0,h.jsx)(pH,{size:`text-row`,children:e}),h6:({children:e})=>(0,h.jsx)(pH,{size:`text-row`,children:e}),p:({children:e})=>(0,h.jsx)(`p`,{className:`m-0`,children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),ul:({children:e})=>(0,h.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-5`,children:e}),ol:({children:e})=>(0,h.jsx)(`ol`,{className:`m-0 flex list-decimal flex-col gap-1 pl-5`,children:e}),li:({children:e})=>(0,h.jsx)(`li`,{className:`m-0`,children:e}),a:({children:e,href:t})=>(0,h.jsx)(`a`,{href:t,className:`rounded-control text-run-text underline underline-offset-[3px]`,target:`_blank`,rel:`noreferrer`,children:e}),code:({children:e})=>(0,h.jsx)(`code`,{className:`rounded-control bg-panel2 px-[4px] py-[1px] font-sans text-small`,children:e}),pre:({children:e})=>(0,h.jsx)(`pre`,{className:`m-0 overflow-x-auto rounded-control bg-panel2 p-[10px] font-sans text-small`,children:e}),blockquote:({children:e})=>(0,h.jsx)(`blockquote`,{className:`m-0 flex flex-col gap-2 border-l-2 border-line2 pl-3 text-ink2`,children:e}),hr:()=>(0,h.jsx)(`hr`,{className:`my-2 border-line`}),table:({children:e})=>(0,h.jsx)(`table`,{className:`w-full border-collapse text-left text-small`,children:e}),th:({children:e})=>(0,h.jsx)(`th`,{className:`engraved border-b border-line py-[6px] pr-4 text-left text-ink3`,children:e}),td:({children:e})=>(0,h.jsx)(`td`,{className:`border-b border-line py-[6px] pr-4 align-top`,children:e})},fH={p:({children:e})=>(0,h.jsx)(h.Fragment,{children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),a:({children:e})=>(0,h.jsx)(h.Fragment,{children:e})};function pH({size:e,children:t}){return(0,h.jsx)(`h3`,{className:W(`mt-2 font-bold tracking-[-0.01em]`,e),children:t})}function mH({markdown:e}){return(0,h.jsx)(`div`,{className:`flex max-w-[75ch] flex-col gap-2 text-pretty text-body text-ink`,children:(0,h.jsx)(UR,{remarkPlugins:[qV],components:dH,children:e})})}function hH({markdown:e}){return(0,h.jsx)(UR,{remarkPlugins:[qV],components:fH,children:e})}var gH=/^#{1,6}[ \t]+(.*?)[ \t]*#*[ \t]*(?:\r?\n|$)/;function _H(e){let t=e.replace(/^[\s]*\n/,``),n=gH.exec(t);return n===null?{title:void 0,body:e.trim()}:{title:n[1]??``,body:t.slice(n[0].length).trim()}}function vH({message:e,onDismiss:t}){return(0,h.jsxs)(`div`,{className:`flex items-center gap-3 rounded-control bg-red-tint px-[10px] py-[6px] text-small text-red`,children:[(0,h.jsx)(`span`,{role:`alert`,className:`min-w-0 break-words`,children:e}),(0,h.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto shrink-0 rounded-control px-2 text-ink2 hover:text-ink`,children:`Dismiss`})]})}function yH({projectId:e,asset:t,label:n=`Download`}){let{api:r}=B();return(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsxs)(`a`,{href:po(r,e,t),download:!0,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(QO,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),n]}),(0,h.jsx)(sH,{projectId:e,asset:t})]})}function bH({output:e,label:t}){return(0,h.jsx)(yH,{projectId:e.projectId,asset:oM(e),...t===void 0?{}:{label:t}})}function xH(e){let{api:t}=B();return R({queryKey:ny.file(e?.projectId??``,e?.id??``),queryFn:()=>e===void 0?``:aH(t,e.projectId,oM(e)),enabled:e!==void 0,staleTime:1/0})}function SH({output:e,as:t=`prose`}){let n=xH(e);return n.error===null?n.data===void 0?(0,h.jsx)(`span`,{className:`h-4 w-[40ch] max-w-full rounded-control bg-panel2`}):t===`prose`?(0,h.jsx)(mH,{markdown:n.data}):(0,h.jsx)(`pre`,{className:`max-w-[75ch] overflow-x-auto whitespace-pre-wrap font-sans text-small text-ink2`,children:n.data}):(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})}function CH({output:e}){let[t,n]=(0,m.useState)(!1);return e===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>{n(!t)},className:`rounded-control text-small text-ink2 underline underline-offset-[3px] hover:text-ink`,children:t?`Hide instructions`:`Show instructions`}),t?(0,h.jsx)(SH,{output:e,as:`plain`}):null]})}function wH({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=Qj(n,e),o=$j(a,`article_md`),s=$j(a,`sources`),c=$j(a,`glossary`),l=xH(o),u=R({queryKey:rM(t.id),queryFn:()=>[],enabled:!1}).data?.some(e=>e.stage===`article`)===!0,d=R({queryKey:ny.article(t.id),queryFn:()=>``,enabled:!1}),[f,p]=(0,m.useState)(void 0),[g,_]=(0,m.useState)(!1),v=l.data??``,y=_H(e.state===`running`?d.data??``:v),b=y.title??t.title,x=tM({kind:`discard-article`});return(0,h.jsxs)(cH,{children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-[14px] text-small text-ink2`,children:[(0,h.jsx)(`span`,{className:`text-row font-semibold text-ink`,children:(0,h.jsx)(hH,{markdown:b})}),s===void 0?null:(0,h.jsx)(bH,{output:s,label:`Sources`}),c===void 0?null:(0,h.jsx)(bH,{output:c,label:`Glossary`})]}),(0,h.jsx)(lH,{children:f===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(J,{type:`button`,disabled:i||o===void 0||l.data===void 0,onClick:()=>{p(v)},children:`Edit`}),(0,h.jsx)(nM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),(0,h.jsx)(CH,{output:$j(a,`instructions`)}),o===void 0?null:(0,h.jsx)(bH,{output:o})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(nM,{action:{kind:`save-article`,markdown:f},run:()=>{r.run({kind:`save-article`,markdown:f},()=>{p(void 0)})},disabled:i,pending:r.pending,children:`Save & update outputs`}),(0,h.jsx)(J,{type:`button`,onClick:()=>{_(!0)},children:`Discard`})]})}),l.error===null?null:(0,h.jsx)(`p`,{className:`text-body text-red`,children:l.error.message}),(0,h.jsx)(`section`,{"aria-label":`Article content`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:f===void 0?e.state===`running`&&u?(0,h.jsx)(aM,{projectId:t.id,stage:`article`}):(0,h.jsx)(mH,{markdown:y.body}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`label`,{htmlFor:`article-editor`,className:`engraved text-ink3`,children:`Article`}),(0,h.jsx)(`textarea`,{id:`article-editor`,value:f,onChange:e=>{p(e.target.value)},className:`h-[420px] w-full max-w-[75ch] resize-y rounded-control border border-line2 bg-panel2 p-[10px] font-sans text-body text-ink`})]})}),(0,h.jsx)(Mk,{open:g,title:x.title,consequence:x.consequence,verb:x.verb,dismiss:x.dismiss,onConfirm:()=>{_(!1),p(void 0)},onCancel:()=>{_(!1)}})]})}function TH({projectId:e}){let{api:t}=B(),n=R({queryKey:[`audio-preview`,e],queryFn:async()=>Za(await t.client.projects[`:projectId`][`audio-preview`].$get({param:{projectId:e}})),refetchInterval:1e3,staleTime:0,gcTime:0,retry:!1}),r=n.data?.previews??[];return(0,h.jsxs)(`section`,{"aria-label":`Live narration`,className:`grid gap-3 rounded-control border border-line2 bg-panel2 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-ink`,children:`Listen while it generates`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Play any part. Each preview starts from its beginning.`})]}),n.error===null?null:(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Live preview is temporarily unavailable. Finished audio will still appear here.`}),r.length===0&&n.error===null?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Waiting for the first audio bytes…`}):null,(0,h.jsx)(`div`,{className:`grid max-h-[420px] gap-3 overflow-y-auto`,children:r.map(n=>(0,h.jsx)(EH,{preview:n,url:`${t.origin}/api/projects/${encodeURIComponent(e)}/audio-preview/${n.id}`},n.id))})]})}function EH({preview:e,url:t}){let[n,r]=(0,m.useState)(!1),i=(e.state===`streaming`||e.state===`ready`)&&e.bytes>0,a=e.state===`ready`?`Ready`:e.state===`streaming`?`Generating`:`Preview stopped`;return(0,h.jsxs)(`div`,{className:`grid gap-2 text-small`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink`,children:e.label}),(0,h.jsx)(`span`,{className:`text-ink2`,children:a})]}),i&&!n?(0,h.jsx)(DH,{label:e.label,url:t,onError:()=>r(!0)}):(0,h.jsx)(`p`,{className:`text-ink2`,children:e.state===`streaming`&&!n?`Waiting for audio…`:`This preview has stopped. The finished narration will be available when generation completes.`})]})}function DH({label:e,url:t,onError:n}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=r.current;return()=>{e!==null&&(e.pause(),e.removeAttribute(`src`),e.load())}},[]),(0,h.jsx)(`audio`,{ref:r,controls:!0,preload:`none`,"aria-label":`Live ${e} narration`,src:t,onError:n,className:`h-9 w-full max-w-[620px]`})}var OH=[{role:`audio_intro`,name:`Intro`},{role:`audio_body`,name:`Body`},{role:`audio_outro`,name:`Outro`}];function kH({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=B(),o=R(cy(a)),s=Qj(n,e),c=OH.flatMap(e=>{let t=$j(s,e.role);return t===void 0?[]:[{...e,output:t}]}),l=c.find(e=>e.output.meta.voice!==void 0)?.output.meta,u=c.length>0?l?.voice:t.config.audio?.voice,d=c.length>0?l?.provider:t.config.audio?.provider,f=o.data?.voices.find(e=>e.voiceId===u&&e.provider===d)?.name??u;return(0,h.jsxs)(cH,{children:[e.state===`running`?(0,h.jsx)(TH,{projectId:t.id}):null,c.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No narration has landed yet.`}):c.map(e=>(0,h.jsx)(AH,{name:e.name,output:e.output},e.role)),(0,h.jsxs)(lH,{children:[(0,h.jsx)(nM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),f===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(uH,{children:`Voice`}),(0,h.jsx)(`span`,{className:`text-small text-ink`,children:f})]}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Chunking: ${jH(t.config.chunking)}`})]})]})}function AH({name:e,output:t}){let{api:n}=B(),r=nO(t.durationMs??void 0);return(0,h.jsxs)(`div`,{className:`grid grid-cols-[60px_minmax(0,1fr)_auto] items-center gap-3 text-small`,children:[(0,h.jsx)(uH,{children:e}),(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`${e} narration`,src:po(n,t.projectId,oM(t)),className:`h-8 w-full max-w-[520px]`}),(0,h.jsxs)(`span`,{className:`flex items-center gap-4`,children:[r===void 0?null:(0,h.jsx)(`span`,{className:`text-ink2 tabular-nums`,children:r}),(0,h.jsx)(bH,{output:t})]})]})}function jH(e){return e===void 0||e.mode===`whole`?`the whole text as one request`:e.mode===`paragraph`?`one request per paragraph`:e.mode===`characters`?`every ${String(e.characters??3e3)} characters`:`every ${String(e.words??500)} words`}function MH(e,t){let n=e.filter(e=>e.role===`image`),r=new Map;for(let e of n){let t=e.meta.promptName??`Images`;r.set(t,[...r.get(t)??[],e])}let i=t.filter(e=>r.has(e)),a=[...r.keys()].filter(e=>!i.includes(e)).sort();return[...i,...a].flatMap(e=>{let t=r.get(e);return t===void 0?[]:[{name:e,images:[...t].sort(NH)}]})}function NH(e,t){return(e.meta.index??0)-(t.meta.index??0)}function PH(e){return e===`9:16`?`aspect-[9/16]`:`aspect-video`}function FH({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=MH(Qj(n,e),t.config.imagePrompts?.map(e=>e.name)??[]);return(0,h.jsxs)(cH,{children:[(0,h.jsxs)(lH,{children:[(0,h.jsx)(nM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run stage`}),(0,h.jsx)(yH,{projectId:t.id,asset:`images.zip`,label:`Download all`})]}),a.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No images have landed yet.`}):null,a.map(e=>(0,h.jsxs)(`section`,{className:`flex flex-col gap-[10px]`,children:[(0,h.jsx)(uH,{children:`${e.name} × ${String(e.images.length)}`}),(0,h.jsx)(`div`,{className:`grid grid-cols-3 gap-2 min-[900px]:grid-cols-6`,children:e.images.map(e=>(0,h.jsx)(IH,{image:e,format:t.format,actions:r,busy:i},e.id))})]},e.name))]})}function IH({image:e,format:t,actions:n,busy:r}){let{api:i}=B(),a=e.meta.index===void 0?``:` ${String(e.meta.index)}`;return(0,h.jsxs)(`figure`,{className:`group relative m-0 overflow-hidden rounded-control border border-line bg-panel2`,children:[(0,h.jsx)(`img`,{src:po(i,e.projectId,oM(e)),alt:e.meta.prompt??`Slideshow image${a}`,className:W(`block w-full object-cover animate-tick-in motion-reduce:animate-none`,PH(t))}),(0,h.jsxs)(`figcaption`,{className:`absolute inset-x-0 bottom-0 flex flex-wrap items-center justify-between gap-1 bg-panel/90 p-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 motion-reduce:transition-none`,children:[(0,h.jsx)(bH,{output:e}),(0,h.jsx)(nM,{action:{kind:`regenerate-image`,outputId:e.id},run:()=>{n.run({kind:`regenerate-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Regenerate`}),(0,h.jsx)(nM,{action:{kind:`delete-image`,outputId:e.id},run:()=>{n.run({kind:`delete-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Delete`})]})]})}function LH({stage:e,outputs:t,actions:n,busy:r}){let i=Qj(t,e),a=$j(i,`notes`);return e.state===`running`&&a===void 0?null:(0,h.jsxs)(cH,{children:[(0,h.jsxs)(lH,{children:[(0,h.jsx)(nM,{action:{kind:`rerun`,stage:e.kind},run:()=>{n.run({kind:`rerun`,stage:e.kind})},disabled:r,pending:n.pending,children:`Re-run`}),(0,h.jsx)(CH,{output:$j(i,`instructions`)}),a===void 0?null:(0,h.jsx)(bH,{output:a})]}),(0,h.jsx)(`section`,{"aria-label":`Research notes`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:a===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.state===`running`?`Research notes will be saved when the writing above finishes.`:`No notes were written.`}):(0,h.jsx)(SH,{output:a})})]})}function RH({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=B(),o=Qj(n,e),s=$j(o,`thumbnail`),c=t.config.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(cH,{className:`grid grid-cols-1 items-start gap-4 min-[900px]:grid-cols-[200px_minmax(0,1fr)]`,children:[s===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No thumbnail has landed yet.`}):(0,h.jsx)(`img`,{src:po(a,s.projectId,oM(s)),alt:s.meta.prompt??`Thumbnail`,className:W(`block w-full rounded-control border border-line bg-panel2 object-cover`,PH(t.format))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(uH,{children:c?`Prompt written by the LLM`:`Prompt`}),s?.meta.prompt===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`This run stored no prompt for the thumbnail.`}):(0,h.jsx)(`p`,{className:`max-w-[75ch] rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-pretty text-small text-ink`,children:s.meta.prompt}),(0,h.jsxs)(lH,{children:[(0,h.jsx)(nM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Regenerate`}),(0,h.jsx)(CH,{output:$j(o,`instructions`)}),s===void 0?null:(0,h.jsx)(bH,{output:s})]})]})]})}function zH({stage:e,project:t,outputs:n,actions:r,busy:i,subtitleControls:a}){let{api:o}=B(),s=t.config.sources.video===`off`&&t.config.sources.audio!==`off`,c=$j(Qj(n,e),s?`audio_export`:`video`),l=Qj(n,e),u=$j(l,`subtitles_srt`),d=$j(l,`subtitles_vtt`),f=c?.meta.subtitlesMode??t.config.subtitles?.mode,p=e.state===`running`,m=rO(e.progressCurrent??0,e.progressTotal??0);return t.config.sources.video===`off`&&!s?(0,h.jsx)(cH,{children:a}):(0,h.jsxs)(cH,{children:[p?(0,h.jsx)(`p`,{className:`text-small text-run-text`,children:JD(e,t.config)?`Preparing subtitles · ${String(rO(e.progressCurrent??0,35))}%`:s?`Exporting combined audio`:e.progressTotal===null?`Re-rendering`:`Re-rendering · ${String(m)}%`}):null,c===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:s?`No combined audio export has landed yet.`:`No render has landed yet.`}):s?(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`Combined narration`,src:po(o,c.projectId,oM(c)),className:`h-9 w-full max-w-[720px]`},c.id):(0,h.jsx)(`video`,{controls:!0,preload:`metadata`,src:po(o,c.projectId,oM(c)),"aria-label":`Generated video`,className:W(`mx-auto block max-h-[min(58vh,560px)] w-auto max-w-full rounded-control bg-screen`,t.format===`9:16`?`aspect-[9/16]`:`aspect-video`),children:f===`files`&&d?(0,h.jsx)(`track`,{kind:`captions`,srcLang:`en`,label:`English`,default:!0,src:po(o,t.id,`subtitles-vtt`)},d.id):null},c.id),(0,h.jsxs)(lH,{children:[c===void 0?null:(0,h.jsx)(bH,{output:c,label:s?`Download .wav`:`Download .mp4`}),e.state===`pending`||e.state===`skipped`?null:(0,h.jsx)(nM,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i||![`done`,`failed`,`canceled`].includes(e.state),pending:r.pending,children:s?`Re-export`:`Re-render`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:[nO(c?.durationMs??void 0),s?`WAV · stereo · 48 kHz`:t.format].filter(e=>e!==void 0).join(` · `)})]}),c?.meta.subtitleOmissions?.length?(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-3 text-small`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold`,children:[`Subtitles recovered after missing narration (`,c.meta.subtitleOmissions.length,`)`]}),(0,h.jsx)(`p`,{className:`mt-2 text-ink2`,children:`These transcript passages could not be matched to the audio and were left out of the captions. The audio is unchanged. Review these passages before sharing.`}),(0,h.jsx)(`ul`,{className:`mt-2 space-y-2`,children:c.meta.subtitleOmissions.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:new Date(e.start*1e3).toISOString().slice(11,19)}),` —`,` `,e.text]},`${e.start}-${e.text}`))})]}):null,u||d?(0,h.jsxs)(lH,{children:[u?(0,h.jsx)(bH,{output:u,label:`Download .srt`}):null,d?(0,h.jsx)(bH,{output:d,label:`Download .vtt`}):null]}):null,a?(0,h.jsxs)(`details`,{className:`mt-2 rounded-control border border-line px-4 py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small font-semibold`,children:`Subtitles & fonts`}),a]}):null]})}function BH(e){switch(e.stage.kind){case`research`:return(0,h.jsx)(LH,{...e});case`article`:return(0,h.jsx)(wH,{...e});case`audio`:return(0,h.jsx)(kH,{...e});case`images`:return(0,h.jsx)(FH,{...e});case`thumbnail`:return(0,h.jsx)(RH,{...e});case`video`:return(0,h.jsx)(zH,{...e})}}function VH({project:e,prompts:t,actions:n,inFlight:r,unsavedProviders:i,settingsOpen:a,onToggleSettings:o,primaryOutput:s}){let c=e.status===`running`;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-5 py-2`,children:[(0,h.jsxs)(`div`,{className:`w-full min-w-0 sm:min-w-[220px] sm:flex-1`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,h.jsx)(Cj,{state:e.status}),(0,h.jsx)(xj,{state:e.status,announce:`Project`})]}),(0,h.jsx)(`h1`,{className:`break-words text-[28px] font-bold leading-tight`,children:e.title}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:HH(e,t)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s?(0,h.jsx)(`span`,{className:`rounded-control border border-accent bg-accent px-4 py-2 [&_a]:font-semibold [&_a]:text-accent-ink`,children:(0,h.jsx)(bH,{output:s,label:s.role===`video`?`Download video`:s.role===`audio_export`?`Download audio`:`Download article`})}):null,(0,h.jsxs)(J,{"aria-expanded":a,onClick:o,children:[(0,h.jsx)(rk,{"aria-hidden":`true`,className:`mr-2 size-4`}),`Run settings`,i?` •`:``]}),c||e.status===`pending`?(0,h.jsx)(J,{disabled:n.pending,onClick:()=>n.run({kind:`pause`}),children:`Pause`}):null,e.status===`paused`||e.status===`failed`?(0,h.jsx)(J,{disabled:n.pending||r||i,onClick:()=>n.run({kind:`resume`}),children:`Resume`}):null,c?(0,h.jsx)(nM,{action:{kind:`cancel`},run:()=>{n.run({kind:`cancel`})},pending:n.pending,children:`Cancel run`}):null]}),i?(0,h.jsx)(`p`,{className:`w-full rounded-control border border-line2 bg-panel2 px-3 py-2 text-small text-ink2`,children:`You have unsaved changes. Save or discard them before resuming.`}):null]})}function HH(e,t){let n=e.config.articlePrompt,r=t===void 0||t.some(e=>e.name===n);return[n===void 0||n===``?void 0:r?n:`${n} (deleted)`,e.format,`started ${Sc(e.createdAt)}`].filter(e=>e!==void 0).join(` · `)}var UH=e=>e.state===`done`||e.state===`provided`;function WH(e){let t=e.filter(e=>e.state!==`skipped`),n=t.length,r=t.filter(UH).length,i=t.reduce((e,t)=>UH(t)?e+1:t.progressTotal===null||t.progressTotal<=0?e:e+Math.min(.99,Math.max(0,(t.progressCurrent??0)/t.progressTotal)),0);return{completed:r,total:n,percent:n===0?0:Math.min(r===n?100:99,Math.round(i/n*100))}}function GH(e){let t=e.find(e=>e.state===`failed`)??e.find(e=>e.state===`running`);if(t)return t.kind;let n=e.find(e=>e.kind===`video`&&UH(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&UH(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function KH({stages:e,project:t}){let n=WH(e);return(0,h.jsxs)(`div`,{className:`rounded-panel border border-line bg-panel px-5 py-4`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold`,children:`Overall progress`}),(0,h.jsxs)(`span`,{className:`text-small text-ink2`,children:[n.completed,` of `,n.total,` stages finished`]})]}),(0,h.jsxs)(`span`,{className:`text-small font-semibold tabular-nums`,children:[n.percent,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`Overall progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n.percent,"aria-valuetext":`${n.percent} percent; ${n.completed} of ${n.total} stages finished`,className:`h-2 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:W(`h-full origin-left bg-accent transition-transform duration-200 motion-reduce:transition-none`,t.status===`failed`&&`bg-red`),style:{transform:`scaleX(${n.percent/100})`}})}),(0,h.jsx)(`p`,{className:`mt-2 text-label text-ink3`,children:`Combines finished stages with progress reported by active stages.`})]})}function qH({stages:e,project:t,outputs:n,selected:r,onSelect:i}){return(0,h.jsxs)(`nav`,{"aria-label":`Project stages`,className:`h-fit rounded-panel border border-line bg-panel lg:sticky lg:top-6`,children:[(0,h.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Stages`})}),(0,h.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-1`,children:e.map(e=>{let a=e.kind===r,o=qD(e.kind,t.config),s=e.state===`done`||e.state===`provided`;return(0,h.jsxs)(`button`,{type:`button`,"aria-label":`${o}, ${e.state}`,"aria-current":a?`step`:void 0,onClick:()=>i(e.kind),className:W(`group relative flex min-w-0 items-start gap-2 border-b border-line px-3 py-4 sm:gap-3 sm:px-4 text-left transition-colors last:border-b-0 hover:bg-panel2`,a&&`bg-panel2 before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-accent`,e.state===`skipped`&&`text-ink3`),children:[(0,h.jsx)(Tc,{kind:e.kind,className:W(`mt-0.5 shrink-0 text-ink2`,a&&`text-run-text`)}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block text-body font-semibold`,children:o}),(0,h.jsx)(`span`,{className:`mt-1 block truncate text-label text-ink2`,children:ZD(e,n,t)}),(0,h.jsxs)(`span`,{className:`mt-2 flex items-center gap-2`,children:[(0,h.jsx)(Cj,{state:e.state}),(0,h.jsx)(xj,{state:e.state,announce:o})]})]}),s?(0,h.jsx)(KO,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):e.state===`canceled`?(0,h.jsx)(XO,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 sm:block`}):a?(0,h.jsx)(YO,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):null]},e.id)})})]})}function JH({project:e,providers:t,actions:n,inFlight:r,edits:i,setEdits:a}){let{api:o}=B(),s=R(cy(o)),{config:c}=e,l=i.llm??c.llm??{provider:``,model:``},u=i.audio??c.audio??{provider:``,model:``,voice:``},d=i.images??c.images??{provider:``,model:``},f=c.sources.research===`generate`||c.sources.article===`generate`||c.sources.thumbnail===`prompt_by_llm`||c.sources.audio===`generate`&&(c.intro?.mode===`llm`||c.outro?.mode===`llm`),p=c.sources.audio===`generate`,m=c.sources.images===`generate`||c.sources.thumbnail===`from_prompt`||c.sources.thumbnail===`prompt_by_llm`;if(!f&&!p&&!m)return null;let g=(e.status===`paused`||e.status===`failed`)&&!r,_=YH(c,i),v=Object.keys(_).length>0,y=e=>e.provider!==``&&e.model.trim()!==``&&t.some(t=>t.id===e.provider&&(t.readiness.kind===`keyed`?t.readiness.hasKey:t.readiness.installed)),b=(!_.llm||y(_.llm))&&(!_.images||y(_.images))&&(!_.audio||y(_.audio)&&(s.data?.voices??[]).some(e=>e.provider===_.audio?.provider&&e.voiceId===_.audio.voice));return(0,h.jsx)(Pk,{className:`block py-3`,"data-tour":`project-providers`,children:(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-row font-semibold`,children:`Run providers`}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:g?`Save your choices, then press Resume when ready. Finished outputs stay as they are. Changing the voice, TTS model or chunking restarts unfinished narration to keep one voice throughout.`:r&&e.status===`paused`?`Pausing: waiting for active requests to stop before providers can be changed.`:e.status===`done`||e.status===`canceled`?`These are the saved providers for this run. Start a new run to choose different providers.`:`Pause the run to change providers, models or voice. These controls are also available after a failure.`}),(0,h.jsxs)(`fieldset`,{disabled:!g||n.pending,className:`mt-3 flex min-w-0 flex-col gap-3 disabled:opacity-60`,children:[f?(0,h.jsx)(XH,{label:`Text`,choice:l,family:`llm`,providers:t,onChange:e=>a(t=>({...t,llm:e}))}):null,p?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(XH,{label:`TTS`,choice:u,family:`tts`,providers:t,onChange:e=>a(t=>({...t,audio:{...e,voice:e.provider===u.provider?u.voice:``}}))}),(0,h.jsx)(XA,{label:`Narration voice`,inline:!0,value:u.voice,placeholder:`Pick a voice`,problem:void 0,options:(s.data?.voices??[]).filter(e=>e.provider===u.provider).map(e=>({value:e.voiceId,label:e.name})),onPick:e=>a(t=>({...t,audio:{...u,voice:e}}))})]}):null,p?(0,h.jsx)(fj,{value:i.chunking??c.chunking??{mode:`whole`},onPick:e=>a(t=>({...t,chunking:e}))}):null,m?(0,h.jsx)(XH,{label:`Image`,choice:d,family:`image`,providers:t,onChange:e=>a(t=>({...t,images:e}))}):null,(0,h.jsx)(`div`,{children:(0,h.jsx)(J,{disabled:!g||n.pending||!b||!v,onClick:()=>n.run({kind:`providers`,choices:_},()=>a({})),children:`Save providers`})})]}),v?(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Save or discard provider changes before resuming.`}),(0,h.jsx)(J,{disabled:n.pending,onClick:()=>a({}),children:`Discard provider changes`})]}):null,s.error?(0,h.jsx)(`p`,{className:`mt-2 text-small text-red`,children:s.error.message}):null]})})}function YH(e,t){return{...t.chunking&&!uj(t.chunking,e.chunking)?{chunking:t.chunking}:{},...t.llm&&!ZH(t.llm,e.llm)?{llm:t.llm}:{},...t.audio&&!ZH(t.audio,e.audio)?{audio:t.audio}:{},...t.images&&!ZH(t.images,e.images)?{images:t.images}:{}}}function XH({label:e,choice:t,family:n,providers:r,onChange:i}){return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)($A,{label:`${e} provider`,inline:!0,family:n,providers:r,value:t.provider,problem:void 0,onPick:e=>i({provider:e,model:``})}),(0,h.jsx)(ej,{label:`${e} model`,inline:!0,provider:t.provider,value:t.model,problem:void 0,onPick:e=>i({...t,model:e})}),n===`llm`?(0,h.jsx)(nj,{choice:t,onChange:i}):null]})}function ZH(e,t){return e.provider===t?.provider&&e.model===t.model&&e.thinking===t.thinking&&(`voice`in e?e.voice:void 0)===(t&&`voice`in t?t.voice:void 0)}function QH(e,t){switch(e){case`research`:case`article`:return t.llm?.provider;case`audio`:return t.audio?.provider;case`images`:case`thumbnail`:return t.images?.provider;case`video`:return}}function $H(e,t,n){let r=QH(e,t);if(r===void 0||r===``)return;let i=n.find(e=>e.id===r);if(i!==void 0)return i.readiness.kind===`keyed`?i.readiness.hasKey?void 0:{label:`Key missing`,provider:r}:i.readiness.installed?void 0:{label:`CLI missing`,provider:r}}var eU={research:`Research notes`,article:`Article workspace`,audio:`Narration`,images:`Image library`,thumbnail:`Thumbnail preview`,video:`Preview & export`};function tU({stage:e,project:t,outputs:n,providers:r,actions:i,children:a,active:o=!0}){let s=qD(e.kind,t.config),c=t.status===`paused`?{...i,pending:!0}:i,l=$H(e.kind,t.config,r),u=i.refusal?.stage===e.kind?i.refusal.message:void 0,d=e.state===`failed`||e.state===`canceled`,f=n.some(t=>t.stageKind===e.kind&&t.role!==`instructions`)||e.state===`running`||e.state===`done`||e.state===`provided`||e.kind===`video`&&e.state!==`skipped`,p=e.progressTotal===null||e.progressTotal<=0?void 0:Math.min(100,Math.max(0,Math.round((e.progressCurrent??0)/e.progressTotal*100)));return(0,h.jsxs)(`section`,{"data-tour":`project-${e.kind}`,hidden:!o,"aria-label":`${s} workspace`,className:o?`min-w-0 rounded-panel border border-line bg-panel`:`hidden`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-line px-5 py-4`,children:[(0,h.jsx)(Tc,{kind:e.kind,className:`text-ink2`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`text-row font-bold`,children:e.kind===`video`&&s===`Audio export`?`Listen & export`:eU[e.kind]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:ZD(e,n,t)})]}),(0,h.jsx)(xj,{state:e.state})]}),e.state===`running`?(0,h.jsxs)(`div`,{className:`border-b border-line px-5 py-3`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex justify-between text-small text-run-text`,children:[(0,h.jsxs)(`span`,{children:[s,` in progress`]}),p===void 0?(0,h.jsx)(`span`,{children:`Waiting for provider progress`}):(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[p,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`${s} progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":p,className:`h-1.5 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:`h-full origin-left bg-accent`,style:{transform:`scaleX(${(p??0)/100})`}})})]}):null,d?(0,h.jsxs)(`div`,{className:`m-5 rounded-control border border-red/30 bg-red-tint p-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`min-w-0 flex-1 text-small text-red`,children:e.state===`failed`?`${s} needs attention.`:`${s} was canceled.`}),(0,h.jsx)(`span`,{className:`text-label text-ink2`,children:QD(e)}),(0,h.jsx)(`button`,{type:`button`,disabled:l!==void 0||c.pending,onClick:()=>c.run({kind:`retry`,stage:e.kind}),className:`rounded-control border border-red px-3 py-2 text-small text-ink hover:bg-panel2 disabled:opacity-50`,children:l?.label??`Retry stage`})]}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:t.status===`paused`?`Resume the project to continue with its saved settings.`:`Retry keeps completed outputs. To change the provider or model, open Run settings.`}),e.failureReason?(0,h.jsxs)(`details`,{className:`mt-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small text-red`,children:`Error details`}),(0,h.jsx)(`span`,{className:`mt-2 block max-h-48 overflow-auto whitespace-pre-wrap break-words text-label text-ink2`,children:e.failureReason})]}):null,l?(0,h.jsxs)(`p`,{className:`mt-3 text-small text-ink2`,children:[l.label,` for `,l.provider,`.`,` `,(0,h.jsx)(ia,{to:`/settings`,className:`underline underline-offset-4`,children:`Open Settings`})]}):null]}):null,u?(0,h.jsx)(`div`,{className:`px-5 pt-4`,children:(0,h.jsx)(vH,{message:u,onDismiss:i.dismissRefusal})}):null,e.state===`running`&&e.kind!==`article`&&e.kind!==`images`&&e.kind!==`video`?(0,h.jsx)(aM,{projectId:t.id,stage:e.kind}):null,f?a:d?null:(0,h.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,h.jsx)(Tc,{kind:e.kind,className:`size-8 text-ink3`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:e.state===`skipped`?`${s} was switched off for this run.`:t.status===`paused`?`Resume the project when you are ready to continue.`:`This stage will start when its inputs are ready.`}),(0,h.jsx)(`p`,{className:`max-w-md text-small text-ink3`,children:e.state===`skipped`?`The other stages are available from the list.`:`You can review completed outputs while the project runs.`})]})]})}function nU({project:e,actions:t,inFlight:n,value:r,uploading:i,onChange:a,onDiscard:o,onUploading:s}){let c=!wD(CD(e.config.subtitles,e.config.sources),r),l=e.status!==`running`&&!n,u=e.config.sources.audio!==`off`,d=e.config.sources.video!==`off`&&e.config.sources.images!==`off`;return(0,h.jsxs)(`div`,{"data-tour":`project-subtitles`,className:`mt-2 min-w-0 border-t border-line pt-4`,children:[(0,h.jsx)(Vj,{value:r,format:e.format,audioEnabled:u,videoEnabled:d,disabled:!l||t.pending,onChange:a,onUploading:s}),(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:l?e.status===`paused`?`Save subtitles, then Resume to update the export. Existing narration and images are reused.`:`Saving updates only the local export using saved narration and images. No paid generation requests are made.`:`Pause the run and wait for active requests to stop before changing subtitles.`}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(J,{disabled:!l||t.pending||i||!u||!c||!TD(r),onClick:()=>t.run({kind:`subtitles`,subtitles:CD(r,e.config.sources)},o),children:`Save subtitles`}),c?(0,h.jsx)(J,{variant:`ghost`,disabled:t.pending||i,onClick:o,children:`Discard subtitle changes`}):null,c&&e.status===`paused`?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Save or discard subtitle changes before resuming.`}):null]})]})}function rU(e){let{api:t}=B(),n=_(),[r,i]=(0,m.useState)(void 0),a=tt({mutationFn:e=>aU(t,e.projectId,e.action),onMutate:()=>{i(void 0)},onSuccess:async(e,t)=>{if(!e.ok){i({message:e.message,stage:iU(t.action)});return}let{project:r,stages:a,outputs:o}=e.value;n.setQueryData(ny.project(t.projectId),{project:r,stages:a,outputs:o}),n.invalidateQueries({queryKey:ny.projects}),await n.invalidateQueries({queryKey:ny.project(t.projectId)})},onError:(e,t)=>{i({message:e.message,stage:iU(t.action)})}});return{run:(t,n)=>{a.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}})},pending:a.isPending,refusal:r,dismissRefusal:()=>{i(void 0)}}}function iU(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function aU(e,t,n){switch(n.kind){case`pause`:return XV(e,t);case`resume`:return ZV(e,t);case`providers`:return QV(e,t,n.choices);case`subtitles`:return $V(e,t,n.subtitles);case`cancel`:return YV(e,t);case`retry`:return eH(e,t,n.stage);case`rerun`:return tH(e,t,n.stage);case`save-article`:return nH(e,t,n.markdown);case`delete-image`:return rH(e,t,n.outputId);case`regenerate-image`:return iH(e,t,n.outputId)}}var oU=200;function sU(e){let{api:t,openEvents:n}=B(),r=_();(0,m.useEffect)(()=>{let i=HD(()=>{r.invalidateQueries({queryKey:ny.project(e)}),r.invalidateQueries({queryKey:ny.projects})},oU),a=xy(n,Ao(t,`projects/${e}`),{refetch:i.ask,previewWriting:t=>{r.setQueryData(rM(e),e=>iM(e??[],t))},appendArticle:t=>{r.setQueryData(ny.article(e),e=>`${e??``}${t}`)},patch:t=>{t.type===`stage.state`&&t.state===`running`&&(r.setQueryData(rM(e),e=>(e??[]).filter(e=>e.stage!==t.stage)),t.stage===`article`&&r.setQueryData(ny.article(e),``)),r.setQueryData(ny.project(e),e=>BD(e,t))}});return()=>{a(),i.stop()}},[t,n,r,e])}function cU({projectId:e}){return(0,h.jsx)(lU,{projectId:e},e)}function lU({projectId:e}){let{api:t}=B(),n=R(iy(t,e)),r=R(sy(t)),i=R(ly(t)),a=rU(e),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)({}),[f,p]=(0,m.useState)(),[g,_]=(0,m.useState)(),v=FO(e),y=(0,m.useRef)(void 0);if((0,m.useEffect)(()=>{if(v===void 0){y.current=void 0;return}n.data!==void 0&&y.current!==v&&(y.current=v,v===`project`&&s(!0),v===`download`&&l({projectId:e,stage:KD(n.data.project.config)===`article`?`article`:`video`}))},[v,e,n.data]),sU(e),n.error!==null)return(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message});if(n.data===void 0)return(0,h.jsx)(uU,{});let{project:b,stages:x,outputs:S}=n.data,C=c?.projectId===e?c.stage:GH(x),w=t=>l({projectId:e,stage:t}),T=S.find(e=>e.role===`video`||e.role===`audio_export`)??(b.config.sources.video===`off`&&b.config.sources.audio===`off`?S.find(e=>e.role===`article_md`):void 0),E=x.some(e=>e.state===`running`),D=b.status===`running`||b.status===`paused`||E||a.pending,O=CD(b.config.subtitles,b.config.sources),k=f?.projectId===e?CD(f.value,b.config.sources):O,A=!wD(k,O),j=g?.projectId===e&&g.pending,M=()=>p(t=>t?.projectId===e?void 0:t);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,children:[(0,h.jsx)(ia,{to:`/`,className:`mb-[10px] block text-small text-ink2 hover:text-ink`,children:`< Projects`}),(0,h.jsxs)(`div`,{"data-tour":`project-controls`,children:[(0,h.jsx)(VH,{project:b,prompts:i.data?.prompts,actions:a,inFlight:E,settingsOpen:o,onToggleSettings:()=>s(!o),primaryOutput:T,unsavedProviders:Object.keys(YH(b.config,u)).length>0||A||j}),(0,h.jsx)(`div`,{hidden:!o,className:o?`mt-4 rounded-panel border border-line bg-panel`:`hidden`,children:(0,h.jsx)(JH,{project:b,providers:r.data?.providers??[],actions:a,inFlight:E,edits:u,setEdits:d})}),a.refusal===void 0||a.refusal.stage!==void 0?null:(0,h.jsx)(Pk,{className:`py-[10px]`,children:(0,h.jsx)(vH,{message:a.refusal.message,onDismiss:a.dismissRefusal})})]}),(0,h.jsx)(Zj,{}),(0,h.jsx)(KH,{stages:x,project:b}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(qH,{stages:x,project:b,outputs:S,selected:C,onSelect:w}),(0,h.jsx)(`div`,{className:`min-w-0`,children:x.map(t=>(0,h.jsx)(tU,{active:t.kind===C,stage:t,project:b,outputs:S,providers:r.data?.providers??[],actions:a,children:(0,h.jsx)(BH,{stage:t,project:b,outputs:S,actions:a,busy:D,...t.kind===`video`?{subtitleControls:(0,h.jsx)(nU,{project:b,actions:a,inFlight:E,value:k,uploading:j,onChange:t=>p({projectId:e,value:CD(t,b.config.sources)}),onDiscard:M,onUploading:t=>_(n=>n?.projectId===e&&n.pending===t?n:{projectId:e,pending:t})},e)}:{}})},t.id))})]})]})}function uU(){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,role:`status`,"aria-label":`Loading project`,children:[(0,h.jsx)(`div`,{className:`h-28 rounded-panel bg-panel`}),(0,h.jsx)(`div`,{className:`h-24 rounded-panel border border-line bg-panel`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(Nk,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(Pk,{children:[(0,h.jsx)(`span`,{className:`size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`h-4 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-16 rounded-control bg-panel2`})]},e))}),(0,h.jsx)(`div`,{className:`h-[560px] rounded-panel border border-line bg-panel`})]})]})}var dU=`relative grid grid-cols-[14px_minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[4px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[14px_minmax(0,1fr)_140px_100px_32px]`,fU=`col-start-2 row-start-2 text-small text-ink2 tabular-nums md:col-start-3 md:row-start-1`,pU=`col-start-3 row-start-1 justify-end md:col-start-4`,mU=`relative z-10 col-start-4 row-start-1 size-8 p-0 md:col-start-5`;function hU(){let{api:e}=B(),t=_(),n=R(ry(e)),[r,i]=(0,m.useState)(void 0),a=tt({mutationFn:t=>oo(e,t),onSettled:async()=>{i(void 0),await t.invalidateQueries({queryKey:ny.projects})}});return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(`div`,{className:`mb-4 flex items-center`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Projects`}),(0,h.jsx)(J,{variant:`accent`,className:`ml-auto`,asChild:!0,children:(0,h.jsx)(ia,{to:`/play`,children:`New run`})})]}),(0,h.jsx)(Zj,{}),n.data?.projects.length===0?(0,h.jsx)(ak,{}):null,n.error===null?null:(0,h.jsx)(Nk,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:n.error.message})}),n.data===void 0?n.error===null?(0,h.jsx)(yU,{}):null:n.data.projects.length===0?(0,h.jsx)(Nk,{children:(0,h.jsxs)(`p`,{className:`px-4 py-7 text-body text-ink2`,children:[`No projects yet. Set up a run on`,` `,(0,h.jsx)(ia,{to:`/play`,className:`rounded-control text-ink underline underline-offset-[3px]`,children:`Play`}),`.`]})}):(0,h.jsx)(Nk,{children:n.data.projects.map(e=>(0,h.jsx)(gU,{project:e,onDelete:()=>{i(e)}},e.id))}),a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-[10px] text-label text-red`,children:a.error.message}),(0,h.jsx)(Mk,{open:r!==void 0,title:r===void 0?``:`Delete "${r.title}"?`,consequence:`Deletes the project and every file it produced.`,verb:`Delete`,pending:a.isPending,onConfirm:()=>{r!==void 0&&a.mutate(r.id)},onCancel:()=>{i(void 0)}})]})}function gU({project:e,onDelete:t}){return(0,h.jsxs)(`div`,{className:dU,children:[(0,h.jsx)(Cj,{state:e.status,className:`col-start-1 row-start-1`}),(0,h.jsxs)(`span`,{className:`col-start-2 row-start-1 flex min-w-0 flex-wrap items-baseline gap-x-3`,children:[(0,h.jsx)(ia,{to:`/projects/$projectId`,params:{projectId:e.id},className:`rounded-control font-semibold after:absolute after:inset-0 after:content-['']`,children:e.title}),(0,h.jsx)(`span`,{className:`truncate text-small text-ink2`,children:_U(e)})]}),(0,h.jsx)(`span`,{className:fU,children:Sc(e.createdAt)}),(0,h.jsx)(xj,{state:e.status,announce:e.title,className:pU}),(0,h.jsx)(vU,{project:e,onDelete:t}),e.status===`running`?(0,h.jsx)(Fk,{current:e.progress,total:1}):null]})}function _U(e){let t=e.config.articlePrompt;return[t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function vU({project:e,onDelete:t}){let n=e.status===`running`;return(0,h.jsxs)(Lk,{children:[(0,h.jsx)(Rk,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.title}`,className:mU,children:(0,h.jsx)($O,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(zk,{children:[(0,h.jsx)(`span`,{title:n?`Cancel the run first`:void 0,children:(0,h.jsx)(Bk,{disabled:n,onSelect:t,children:`Delete`})}),n?(0,h.jsx)(`p`,{className:`engraved px-[10px] py-[5px] text-ink3`,children:`Cancel the run first`}):null]})]})}function yU(){return(0,h.jsx)(Nk,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`div`,{className:dU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-3 w-2/5 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-[10px] w-[90px] rounded-control bg-panel2 md:col-start-3`}),(0,h.jsx)(`span`,{className:`col-start-4 row-start-1 h-[10px] w-14 justify-self-end rounded-control bg-panel2 md:col-start-4`})]},e))})}function bU({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=B(),a=_(),o=PO(),s=R(ly(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=RD(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(void 0),S=b!==void 0,[C,w]=(0,m.useState)(!1),T=s.data?.prompts,E=e??n,D=E===void 0?void 0:T?.find(e=>e.id===E),O=D===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:D.kind,name:`${D.name} copy`,body:D.body}:{kind:D.kind,name:D.name,body:D.body},k=p??b??O,A=tt({mutationFn:t=>To(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){y(e.fields);return}x(e.value),g(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:ly(i).queryKey})}}),j=tt({mutationFn:e=>Eo(i,e),onSuccess:async()=>{w(!1),g(void 0),await a.invalidateQueries({queryKey:ly(i).queryKey}),r(k.kind)}});Qk(S,()=>{r(k.kind)});let M=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},N=yA(k,v),P=bA(N),F=CA(k.body),I=k.body.trim()===``?[]:xA(N),ee=k.name.trim()===``?[]:SA(N);return NO({promptNamed:k.name.trim()!==``&&ee.length===0,promptBodyReady:k.body.trim()!==``&&I.length===0,promptHasKeywords:F.length>0&&I.length===0,promptSaveReady:P===void 0&&!A.isPending&&!S,promptSaving:A.isPending||S,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(nA,{}):E!==void 0&&D===void 0?(0,h.jsx)(xU,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(ia,{to:`/prompts`,search:{kind:k.kind},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(JO,{"aria-hidden":`true`,className:`size-[14px]`}),`Prompts`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New prompt`:`Edit prompt`}),(0,h.jsxs)(`div`,{"data-tour":`prompt-editor`,className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${tA} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{"data-tour":`prompt-name`,className:`flex-1`,children:[(0,h.jsx)(aA,{htmlFor:c,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(sA,{id:c,value:k.name,"aria-invalid":ee.length>0,"aria-describedby":ee.length===0?void 0:l,onChange:e=>{M({...k,name:e.target.value},`name`)}}),ee.length===0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:ee.map(e=>e.message).join(` `)})]}),(0,h.jsx)(oA,{label:`Kind`,value:k.kind,options:kk,onPick:e=>{M({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,children:[(0,h.jsx)(aA,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(EA,{id:u,value:k.body,invalid:I.length>0,describedBy:I.length===0?void 0:d,onChange:e=>{M({...k,body:e},`body`)}})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(eA,{onDelete:e===void 0?void 0:()=>{w(!0)},blocked:P,blockedId:f,pending:A.isPending,saved:S,cancel:(0,h.jsx)(J,{asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{g(void 0)},children:`Cancel`})}),errors:[A.error,j.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{A.mutate(k)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:`${tA} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Xk,{slots:F,body:k.body,lint:I,lintId:d})})]}),(0,h.jsx)(Mk,{open:C,title:`Delete "${k.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:j.isPending,onConfirm:()=>{e!==void 0&&j.mutate(e)},onCancel:()=>{w(!1)}})]}):(0,h.jsx)(xU,{kind:k.kind,children:s.error.message})}function xU({kind:e,children:t}){return(0,h.jsx)(rA,{back:(0,h.jsx)(ia,{to:`/prompts`,search:{kind:e},className:iA,children:`Back to Prompts`}),children:t})}var SU=`grid grid-cols-[minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_minmax(0,1fr)_auto_32px]`,CU=`col-span-3 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1`,wU=`md:col-start-2 md:row-start-1`;function TU({kind:e,onKind:t}){let{api:n}=B(),r=_(),i=R(ly(n)),[a,o]=(0,m.useState)(void 0),s=tt({mutationFn:e=>Eo(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:ny.prompts})}}),c=i.data?.prompts.filter(t=>t.kind===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Prompts`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(Vk,{type:`single`,value:e,"aria-label":`Prompt kind`,onValueChange:e=>{let n=kk.find(t=>t.value===e);n!==void 0&&t(n.value)},children:kk.map(e=>(0,h.jsx)(Hk,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(EU,{kind:e})]}),i.error===null?null:(0,h.jsx)(Nk,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(kU,{}):null:c.length===0?(0,h.jsx)(DU,{kind:e}):(0,h.jsx)(Nk,{children:c.map(e=>(0,h.jsxs)(`div`,{className:SU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(`span`,{className:W(CU,wU),children:e.slots.map(e=>(0,h.jsx)(Ik,{name:e},e))}),(0,h.jsx)(J,{className:`col-start-2 row-start-1 md:col-start-3`,asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts/$promptId`,params:{promptId:e.id},children:`Edit`})}),(0,h.jsx)(OU,{prompt:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(Mk,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function EU({kind:e}){return(0,h.jsx)(J,{asChild:!0,children:(0,h.jsxs)(ia,{to:`/prompts/new`,search:{kind:e},children:[(0,h.jsx)(tk,{"aria-hidden":`true`,className:`size-[14px]`}),`New prompt`]})})}function DU({kind:e}){return(0,h.jsx)(Nk,{children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-7 text-ink2`,children:[(0,h.jsx)(`span`,{className:`max-w-[75ch]`,children:`No ${e} prompts yet. A prompt is text with {{keywords}}; each keyword becomes a field on Play.`}),(0,h.jsx)(EU,{kind:e})]})})}function OU({prompt:e,onDelete:t}){return(0,h.jsxs)(Lk,{children:[(0,h.jsx)(Rk,{asChild:!0,children:(0,h.jsx)(J,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-3 row-start-1 size-8 p-0 md:col-start-4`,children:(0,h.jsx)($O,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(zk,{children:[(0,h.jsx)(Bk,{asChild:!0,children:(0,h.jsx)(ia,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},children:`Duplicate`})}),(0,h.jsx)(Bk,{onSelect:t,children:`Delete`})]})]})}function kU(){return(0,h.jsx)(Nk,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:SU,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsxs)(`span`,{className:W(CU,wU),children:[(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[18px] w-[72px] rounded-control bg-panel2`})]}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-3`})]},e))})}function AU(){let{api:e}=B(),t=_(),n=R({queryKey:[`catalogue`],queryFn:async()=>Za(await e.fetch(`${e.origin}/api/providers/catalogue`)),refetchInterval:3e4}),r=tt({mutationFn:async()=>Za(await e.fetch(`${e.origin}/api/providers/catalogue/refresh`,{method:`POST`})),onSuccess:e=>{t.setQueryData([`catalogue`],e),t.invalidateQueries({queryKey:[`provider-models`]})}});return(0,h.jsxs)(`section`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Models and request limits`}),(0,h.jsx)(`p`,{className:`my-2 text-body text-ink2`,children:`The catalogue lists supported text, image and speech models, their prices and request limits. Local YAML edits load automatically; model pickers refresh every 30 seconds.`}),n.data?.path?(0,h.jsx)(`p`,{className:`my-2 break-all font-mono text-small`,children:n.data.path}):null,(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink2`,children:[`Verified `,n.data?.updatedAt??`date unavailable`,`. Refresh replaces your local file with the published catalogue and saves the previous file alongside it.`]}),(0,h.jsx)(J,{disabled:r.isPending||!n.data?.path,onClick:()=>r.mutate(),children:r.isPending?`Refreshing…`:`Refresh published catalogue`}),n.data?.warning||n.error||r.error?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 text-body text-red`,children:r.error?.message??n.error?.message??n.data?.warning}):null,r.isSuccess?(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-green`,children:`Catalogue updated.`}):null]})}function jU({provider:e,readiness:t}){let{api:n}=B(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(!1),p=e.cliPath?.configured??null,g=e.id===`claude-code`?`claude`:e.id,v=e.cliPath?.command??g,y=l??p??``,b=tt({mutationFn:t=>ho(n,e.id,t),onMutate:()=>f(!1),onSuccess:async e=>{r.setQueryData(ny.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),u(void 0),f(!0),await r.invalidateQueries({queryKey:ny.providers})}});return(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),Zk);return()=>clearTimeout(e)},[d]),(0,h.jsxs)(`div`,{"data-ready":t.installed,className:`grid gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0 sm:grid-cols-[140px_1fr]`,children:[(0,h.jsx)(`span`,{id:i,className:W(`font-semibold`,t.installed?`text-ink`:`text-ink3`),children:e.displayName}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-ink2`,"aria-live":`polite`,children:[(0,h.jsx)(Cj,{state:t.installed?`done`:`pending`}),(0,h.jsx)(`span`,{children:MU(t,p)})]}),(0,h.jsxs)(`p`,{className:`mt-1 break-all text-label text-ink3`,children:[`Command: `,(0,h.jsx)(`code`,{children:v})]}),(0,h.jsxs)(`form`,{className:`mt-3`,onSubmit:e=>{e.preventDefault(),b.isPending||b.mutate(y)},children:[(0,h.jsx)(aA,{htmlFor:a,id:o,className:`mb-[5px]`,children:`Executable path`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(sA,{id:a,autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-labelledby":`${i} ${o}`,"aria-invalid":b.error!==null,"aria-describedby":`${s}${b.error?` ${c}`:``}`,placeholder:g,value:y,disabled:b.isPending,onChange:e=>{u(e.target.value),f(!1),b.reset()}}),(0,h.jsx)(J,{type:`submit`,"aria-label":`Save ${e.displayName} path`,disabled:b.isPending,children:b.isPending?`Checking…`:`Save path`}),d?(0,h.jsx)($k,{}):null]}),(0,h.jsxs)(`p`,{id:s,className:`mt-1 text-label text-ink3`,children:[`Leave blank to find `,(0,h.jsx)(`code`,{children:g}),` on PATH. Use an absolute path without quotes or arguments.`]}),b.error?(0,h.jsx)(`p`,{id:c,role:`alert`,className:`mt-1 text-label text-red`,children:b.error.message}):null]}),(0,h.jsxs)(`p`,{className:`mt-2 text-label text-ink3`,children:[`Sign in through `,e.displayName,` itself before generating; Slopify uses that login.`]})]})]})}function MU(e,t){return e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found on PATH`:`Not found at saved path`}var NU=[`llm`,`tts`,`image`],PU={llm:`API keys · LLM`,tts:`API keys · Text to speech`,image:`API keys · Image generation`},FU=`••••••••••••`,IU=`grid grid-cols-[140px_1fr_auto] items-end gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0`,LU=`engraved border-t border-line px-4 py-3 text-ink3 first:border-t-0`;function RU(){let{api:e}=B(),t=R(sy(e));if(t.error!==null)return(0,h.jsx)(Nk,{children:(0,h.jsx)(Pk,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:t.error.message})})});if(t.data===void 0)return(0,h.jsx)(BU,{});let n=t.data.providers,r=n.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey);return(0,h.jsx)(Nk,{children:NU.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,className:`border-t border-line first:border-t-0`,children:[(0,h.jsx)(`h2`,{className:LU,children:PU[e]}),n.filter(t=>t.family===e).map(e=>e.readiness.kind===`cli`?(0,h.jsx)(jU,{provider:e,readiness:e.readiness},e.id):(0,h.jsx)(zU,{provider:e,hasKey:e.readiness.hasKey},e.id)),e===`llm`&&r?(0,h.jsx)(`p`,{className:`border-t border-line px-4 pt-[10px] pb-[14px] text-small text-ink2`,children:`Paste a key to make its provider selectable on Play.`}):null]},e))})}function zU({provider:e,hasKey:t}){let{api:n}=B(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(!1),S=async()=>{f(!0),y(void 0);try{await z(n,e.id,l),u(``),g(!0),await r.invalidateQueries({queryKey:ny.providers})}catch(e){y(e instanceof Error?e.message:String(e))}finally{f(!1)}},C=tt({mutationFn:()=>go(n,e.id),onSuccess:async()=>{x(!1),y(void 0),await r.invalidateQueries({queryKey:ny.providers})},onError:e=>{x(!1),y(e.message)}});(0,m.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>{g(!1)},Zk);return()=>{clearTimeout(e)}},[p]);let w=[t?s:void 0,v===void 0?void 0:c].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`div`,{"data-ready":t,className:IU,children:[(0,h.jsx)(`span`,{id:o,className:`pb-[7px] font-semibold`,children:e.displayName}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(aA,{htmlFor:i,id:a,className:`mb-[5px]`,children:`API key`}),(0,h.jsx)(sA,{id:i,type:`password`,autoComplete:`off`,spellCheck:!1,"aria-labelledby":`${o} ${a}`,"aria-invalid":v!==void 0,"aria-describedby":w===``?void 0:w,placeholder:t?FU:void 0,value:l,onChange:e=>{u(e.target.value)}}),e.id===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Paste the Base64 credentials from Inworld Settings → API Keys.`}):null,t?(0,h.jsx)(`span`,{id:s,className:`sr-only`,children:`A key is stored for this provider.`}):null,v===void 0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:v})]}),(0,h.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2`,children:[(0,h.jsx)(J,{"aria-label":`Save ${e.displayName} key`,disabled:l.trim()===``||d,onClick:()=>{S()},children:`Save`}),p?(0,h.jsx)($k,{}):null,t?(0,h.jsx)(J,{className:`bg-transparent`,"aria-label":`Remove ${e.displayName} key`,onClick:()=>{x(!0)},children:`Remove`}):null]}),(0,h.jsx)(Mk,{open:b,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,verb:`Remove`,pending:C.isPending,onConfirm:()=>{C.mutate()},onCancel:()=>{x(!1)}})]})}function BU(){return(0,h.jsx)(Nk,{children:[0,1,2,3].map(e=>(0,h.jsxs)(Pk,{children:[(0,h.jsx)(`span`,{className:`h-4 w-28 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 flex-1 rounded-control bg-panel2`})]},e))})}var VU=H_,HU=K_;function UU({className:e,children:t,...n}){return(0,h.jsxs)(W_,{"data-slot":`select-trigger`,className:W(`flex h-8 w-full items-center justify-between gap-2 rounded-control border border-line2`,`bg-panel2 px-[10px] text-left text-small text-ink data-[placeholder]:text-ink3`,e),...n,children:[t,(0,h.jsx)(q_,{asChild:!0,children:(0,h.jsx)(qO,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-ink2`})})]})}function WU({className:e,children:t,position:n=`popper`,...r}){return(0,h.jsx)(X_,{children:(0,h.jsx)(Q_,{"data-slot":`select-content`,position:n,sideOffset:4,className:W(`z-50 min-w-[var(--radix-select-trigger-width)] overflow-hidden rounded-panel`,`border border-line bg-panel p-1 shadow-[0_8px_24px_var(--color-shadow)]`,e),...r,children:(0,h.jsx)(uv,{children:t})})})}function GU({className:e,children:t,...n}){return(0,h.jsxs)(gv,{"data-slot":`select-item`,className:W(`relative flex cursor-default items-center rounded-control py-[5px] pr-8 pl-[10px]`,`text-small text-ink outline-hidden select-none`,`focus:bg-panel2 data-highlighted:bg-panel2`,e),...n,children:[(0,h.jsx)(vv,{children:t}),(0,h.jsx)(bv,{className:`absolute right-[10px] flex items-center`,children:(0,h.jsx)(KO,{"aria-hidden":`true`,className:`size-[14px] text-done`})})]})}var KU=`px-4 align-top`;function qU(){let{api:e}=B(),t=_(),n=R(cy(e)),r=R(sy(e)),[i,a]=(0,m.useState)(void 0),o=tt({mutationFn:t=>xo(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:ny.voices})}}),s=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(Nk,{children:(0,h.jsx)(Pk,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});let c=n.data?.voices;return(0,h.jsxs)(Nk,{"data-tour":`voices`,children:[(0,h.jsxs)(`table`,{className:`w-full table-fixed border-collapse text-small`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`th`,{className:W(KU,`engraved w-[26%] py-3 text-left text-ink3`),children:`Voices · Name`}),(0,h.jsx)(`th`,{className:W(KU,`engraved w-[26%] py-3 text-left text-ink3`),children:`Provider`}),(0,h.jsx)(`th`,{className:W(KU,`engraved py-3 text-left text-ink3`),children:`Voice ID`}),(0,h.jsx)(`th`,{className:W(KU,`w-[104px] py-3`),children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:c===void 0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:W(KU,`py-4`),children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-panel2`})})}):c.length===0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:W(KU,`py-4 text-ink2`),children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):c.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`td`,{className:W(KU,`py-3 font-semibold`),children:e.name}),(0,h.jsx)(`td`,{className:W(KU,`py-3 text-ink2`),children:XU(s,e.provider)}),(0,h.jsx)(`td`,{className:W(KU,`py-3 text-ink2 tabular-nums`),children:e.voiceId}),(0,h.jsx)(`td`,{className:W(KU,`py-3 text-right`),children:(0,h.jsx)(J,{className:`bg-transparent`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))}),(0,h.jsx)(`tfoot`,{children:(0,h.jsx)(JU,{tts:s})})]}),o.error===null?null:(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-3 text-label text-red`,children:o.error.message}),(0,h.jsx)(Mk,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,verb:`Remove`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function JU({tts:e}){let{api:t}=B(),n=_(),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(void 0),y=f??e[0]?.id,b=tt({mutationFn:e=>bo(t,e),onSuccess:async e=>{if(!e.ok){v(e.refusal);return}l(``),d(``),v(void 0),await n.invalidateQueries({queryKey:ny.voices})}}),x=(e,t)=>{t(),g?.field===e&&v(void 0)},S=e=>g?.field===e?g.message:void 0;return(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:W(KU,`py-[14px]`),children:[(0,h.jsx)(aA,{htmlFor:r,className:`mb-[5px]`,children:`Voice name`}),(0,h.jsx)(sA,{id:r,value:c,"aria-invalid":S(`name`)!==void 0,onChange:e=>{let t=e.target.value;x(`name`,()=>{l(t)})}}),(0,h.jsx)(YU,{id:`${s}-name`,message:S(`name`)})]}),(0,h.jsxs)(`td`,{className:W(KU,`py-[14px]`),children:[(0,h.jsx)(aA,{id:a,className:`mb-[5px]`,children:`Provider`}),(0,h.jsxs)(VU,{value:y??``,onValueChange:t=>{let n=e.find(e=>e.id===t);n!==void 0&&x(`provider`,()=>{p(n.id)})},children:[(0,h.jsx)(UU,{id:i,"aria-labelledby":`${a} ${i}`,children:(0,h.jsx)(HU,{placeholder:`Pick a provider`})}),(0,h.jsx)(WU,{children:e.map(e=>(0,h.jsx)(GU,{value:e.id,children:e.displayName},e.id))})]}),(0,h.jsx)(YU,{id:`${s}-provider`,message:S(`provider`)})]}),(0,h.jsxs)(`td`,{className:W(KU,`py-[14px]`),children:[(0,h.jsx)(aA,{htmlFor:o,className:`mb-[5px]`,children:`Voice ID`}),(0,h.jsx)(sA,{id:o,className:`tabular-nums`,value:u,"aria-invalid":S(`voiceId`)!==void 0,"aria-describedby":S(`voiceId`)===void 0?void 0:`${s}-voiceId`,onChange:e=>{let t=e.target.value;x(`voiceId`,()=>{d(t)})}}),(0,h.jsx)(YU,{id:`${s}-voiceId`,message:S(`voiceId`)}),y===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}):null,b.error===null?null:(0,h.jsx)(`p`,{className:`mt-1 text-label text-red`,children:b.error.message})]}),(0,h.jsx)(`td`,{className:W(KU,`py-[14px] text-right`),children:(0,h.jsx)(J,{className:`mt-[22px]`,disabled:y===void 0||g!==void 0||b.isPending,onClick:()=>{y!==void 0&&b.mutate({provider:y,name:c,voiceId:u})},children:`Add voice`})})]})}function YU({id:e,message:t}){return t===void 0?null:(0,h.jsx)(`p`,{id:e,className:`mt-1 text-label text-red`,children:t})}function XU(e,t){return e.find(e=>e.id===t)?.displayName??t}var ZU=30,QU=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function $U(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=ZU?void 0:`The silence gap is a whole number of seconds between 0 and ${String(ZU)}.`}function eW(){return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Settings`}),(0,h.jsx)(RU,{}),(0,h.jsx)(qU,{}),(0,h.jsx)(AU,{}),(0,h.jsx)(tW,{})]})}function tW(){let{api:e}=B(),t=_(),n=R(dy(e)),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=tt({mutationFn:t=>vo(e,t),onMutate:e=>{let n=t.getQueryData(ny.settings);return t.setQueryData(ny.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(ny.settings,r.previous)},onSuccess:e=>{t.setQueryData(ny.settings,e)}});if((0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>{l(!1)},Zk);return()=>{clearTimeout(e)}},[c]),n.error!==null)return(0,h.jsx)(Nk,{children:(0,h.jsx)(Pk,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});if(n.data===void 0)return(0,h.jsxs)(Nk,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(Pk,{children:[(0,h.jsx)(`span`,{className:`h-4 w-48 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 w-[72px] rounded-control bg-panel2`})]})]});let d=n.data,f=o??String(d.silenceGapSeconds),p=$U(f);return(0,h.jsxs)(Nk,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] border-b border-line px-4 py-[14px]`,children:[(0,h.jsx)(`label`,{htmlFor:r,className:`font-semibold`,children:`Silence between segments`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px]`,children:[(0,h.jsx)(sA,{id:r,type:`number`,inputMode:`numeric`,min:0,max:ZU,step:1,className:`w-[72px] tabular-nums`,value:f,"aria-invalid":p!==void 0,"aria-describedby":p===void 0?void 0:i,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`seconds`}),(0,h.jsx)(J,{className:`ml-[6px]`,disabled:p!==void 0||u.isPending,onClick:()=>{l(!1),u.mutate({silenceGapSeconds:Number(f.trim()),appearance:d.appearance},{onSuccess:()=>{s(void 0),l(!0)}})},children:`Save`}),c?(0,h.jsx)($k,{}):null,p===void 0?null:(0,h.jsx)(`p`,{id:i,className:`basis-full text-label text-red`,children:p}),u.error===null?null:(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:u.error.message})]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] px-4 py-[14px]`,children:[(0,h.jsx)(`span`,{id:a,className:`font-semibold`,children:`Appearance`}),(0,h.jsx)(Vk,{type:`single`,value:d.appearance,"aria-labelledby":a,className:`justify-self-start`,onValueChange:e=>{let t=QU.find(t=>t.value===e);t!==void 0&&u.mutate({silenceGapSeconds:d.silenceGapSeconds,appearance:t.value})},children:QU.map(e=>(0,h.jsx)(Hk,{value:e.value,children:e.label},e.value))})]})]})}function nW({counters:e}){return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:e.map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col-reverse gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`dt`,{className:`engraved text-ink3`,children:e.label}),(0,h.jsx)(`dd`,{className:`m-0 text-counter font-bold tabular-nums tracking-[-0.01em]`,children:e.value})]},e.label))})}function rW({cells:e}){return(0,h.jsx)(`div`,{className:`grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`})]},e))})}function iW(){let{api:e}=B(),t=R(oy(e));return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`mb-1 text-title font-bold tracking-[-0.01em]`,children:`Usage`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`This machine only. The same counters, anonymised, feed slopify.stream.`})]}),t.error===null?null:(0,h.jsx)(Nk,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:t.error.message})}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(rW,{cells:5}),(0,h.jsx)(pW,{})]}):null:(0,h.jsx)(aW,{usage:t.data})]})}function aW({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(nW,{counters:fW(e)}),t?(0,h.jsx)(`p`,{className:`-mt-3 text-body text-ink2`,children:`Numbers appear after your first run.`}):null,(0,h.jsxs)(`div`,{className:`overflow-hidden rounded-panel border border-line bg-panel`,children:[(0,h.jsxs)(`table`,{"aria-label":`Tokens by stage`,className:`w-full table-fixed border-collapse`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(oW,{className:`w-[24%]`,children:`Tokens by stage`}),(0,h.jsx)(oW,{className:`w-[38%]`,children:`Provider · model`}),(0,h.jsx)(oW,{className:`w-[19%] text-right`,children:`Tokens in`}),(0,h.jsx)(oW,{className:`w-[19%] text-right`,children:`Tokens out`})]})}),(0,h.jsx)(`tbody`,{children:e.byStage.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line last:border-b-0`,children:[(0,h.jsx)(sW,{className:`truncate font-semibold`,children:GD[e.stage]}),(0,h.jsx)(sW,{className:`truncate text-ink2`,children:cW(e)}),(0,h.jsx)(sW,{className:`text-right tabular-nums`,children:lW.format(e.tokensIn)}),(0,h.jsx)(sW,{className:`text-right tabular-nums`,children:lW.format(e.tokensOut)})]},`${e.stage}/${e.provider}/${e.model??``}`))})]}),e.byStage.length===0?(0,h.jsx)(`p`,{className:`px-4 py-5 text-small text-ink3`,children:`No stages have run yet.`}):null]}),(0,h.jsx)(`p`,{className:`engraved text-ink3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]})}function oW({children:e,className:t}){return(0,h.jsx)(`th`,{className:`engraved px-4 py-3 text-left text-ink3 ${t}`,children:e})}function sW({children:e,className:t}){return(0,h.jsx)(`td`,{className:`px-4 py-3 align-top text-small ${t}`,children:e})}function cW(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var lW=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),uW=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),dW=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function fW(e){let t=e.counters;return[{label:`Videos made`,value:lW.format(t.videosMade)},{label:`Hours of audio`,value:uW.format(t.audioSeconds/3600)},{label:`Images made`,value:lW.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?lW.format(t.tokensUsed):dW.format(t.tokensUsed)},{label:`Projects`,value:lW.format(t.projects)}]}function pW(){return(0,h.jsx)(Nk,{children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-[14px] border-b border-line px-4 py-3 last:border-b-0`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-56 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-panel2`})]},e))})}var mW=ca({component:gk}),hW=oa({getParentRoute:()=>mW,path:`/`,component:hU}),gW=oa({getParentRoute:()=>mW,path:`play`,component:qj}),_W=oa({getParentRoute:()=>mW,path:`projects/$projectId`,component:EW}),vW=oa({getParentRoute:()=>mW,path:`prompts`,validateSearch:e=>({kind:jk(e.kind)}),component:DW}),yW=oa({getParentRoute:()=>mW,path:`prompts/new`,validateSearch:e=>{let t=jk(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:OW}),bW=oa({getParentRoute:()=>mW,path:`prompts/$promptId`,component:kW}),xW=oa({getParentRoute:()=>mW,path:`entries`,validateSearch:e=>({category:Ok(e.category)}),component:jW}),SW=oa({getParentRoute:()=>mW,path:`entries/new`,validateSearch:e=>{let t=Ok(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:MW}),CW=oa({getParentRoute:()=>mW,path:`entries/$entryId`,component:NW}),wW=oa({getParentRoute:()=>mW,path:`settings`,component:eW}),TW=oa({getParentRoute:()=>mW,path:`usage`,component:iW});function EW(){let{projectId:e}=_W.useParams();return(0,h.jsx)(cU,{projectId:e},e)}function DW(){let{kind:e}=vW.useSearch(),t=Hi();return(0,h.jsx)(TU,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})}})}function OW(){let{kind:e,from:t}=yW.useSearch(),n=AW();return(0,h.jsx)(bU,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function kW(){let{promptId:e}=bW.useParams(),t=AW();return(0,h.jsx)(bU,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function AW(){let e=Hi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function jW(){let{category:e}=xW.useSearch(),t=Hi();return(0,h.jsx)(Gk,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})}})}function MW(){let{category:e,from:t}=SW.useSearch(),n=PW();return(0,h.jsx)(DA,{entryId:void 0,category:e,from:t,onLeave:n})}function NW(){let{entryId:e}=CW.useParams(),t=PW();return(0,h.jsx)(DA,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function PW(){let e=Hi();return t=>{e({to:`/entries`,search:{category:t}})}}var FW=mW.addChildren({projectsRoute:hW,playRoute:gW,projectRoute:_W,promptsRoute:vW,newPromptRoute:yW,promptRoute:bW,entriesRoute:xW,newEntryRoute:SW,entryRoute:CW,settingsRoute:wW,usageRoute:TW});function IW(){return Ta({routeTree:FW})}function LW(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;return}if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function RW(e,t){return async(n,r)=>{let i=await e(n,r),a=i.headers.get(`X-Slopify-Version`);return a!==null&&t.observe(a),i}}function zW(e){let t=LW(),n={api:ro(window.location.origin,RW(window.fetch.bind(window),t)),openEvents:e=>new EventSource(e),version:t};(0,Xa.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ve,children:(0,h.jsx)(Mo,{deps:n,children:(0,h.jsx)(Oa,{router:IW()})})})}))}var BW=document.getElementById(`root`);if(BW===null)throw Error(`index.html carries no #root element for the app to mount on`);zW(BW);