@valbuild/ui 0.120.0 → 0.120.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/dist/valbuild-ui.cjs.js +1 -1
- package/dist/valbuild-ui.esm.js +1 -1
- package/package.json +1 -1
- package/server/.tmp/assets/index-BvbzW5yN.css +1 -0
- package/server/.tmp/assets/{index-DK4jaz_h.js → index-QPnvX_pG.js} +29 -29
- package/server/.tmp/index.html +2 -2
- package/server/dist/valbuild-ui-server.cjs.js +4 -4
- package/server/dist/valbuild-ui-server.esm.js +4 -4
- package/server/.tmp/assets/index-CZMDJ2_V.css +0 -1
|
@@ -139,7 +139,7 @@ All routes will be filtered out due to malformed exclude pattern.`)}return e.fil
|
|
|
139
139
|
|
|
140
140
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
141
141
|
|
|
142
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Sme=`DialogDescriptionWarning`,Cme=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${RO(Sme).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},wme=CO,Tme=DO,Eme=kO,Dme=jO,zO=`[cmdk-group=""]`,BO=`[cmdk-group-items=""]`,Ome=`[cmdk-group-heading=""]`,VO=`[cmdk-item=""]`,HO=`${VO}:not([aria-disabled="true"])`,UO=`cmdk-item-select`,WO=`data-value`,kme=(e,t,n)=>Dpe(e,t,n),GO=b.createContext(void 0),KO=()=>b.useContext(GO),qO=b.createContext(void 0),JO=()=>b.useContext(qO),YO=b.createContext(void 0),XO=b.forwardRef((e,t)=>{let n=ek(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=ek(()=>new Set),i=ek(()=>new Map),a=ek(()=>new Map),o=ek(()=>new Set),s=QO(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Pm(),y=Pm(),x=Pm(),S=b.useRef(null),C=Bme();$O(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),$O(()=>{C(6,A)},[]);let w=b.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=b.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:x,labelId:y,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??kme;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(BO);t?t.appendChild(e.parentElement===t?e:e.closest(`${BO} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${BO} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${zO}[${WO}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(WO);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(zO)?.querySelector(Ome))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${VO}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(HO)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(WO))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(WO))}function F(e){let t=j()?.closest(zO),n;for(;t&&!n;)t=e>0?Rme(t,zO):zme(t,zO),n=t?.querySelector(HO);n?w.setState(`value`,n.getAttribute(WO)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return b.createElement(xm.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(UO);t.dispatchEvent(e)}}}}},b.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:Hme},c),rk(e,e=>b.createElement(qO.Provider,{value:w},b.createElement(GO.Provider,{value:T},e))))}),Ame=b.forwardRef((e,t)=>{let n=Pm(),r=b.useRef(null),i=b.useContext(YO),a=KO(),o=QO(e),s=o.current?.forceMount??i?.forceMount;$O(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=nk(n,r,[e.value,e.children,r],e.keywords),l=JO(),u=tk(e=>e.value&&e.value===c.current),d=tk(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);b.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(UO,f),()=>t.removeEventListener(UO,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return b.createElement(xm.div,{ref:im(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),jme=b.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Pm(),s=b.useRef(null),c=b.useRef(null),l=Pm(),u=KO(),d=tk(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));$O(()=>u.group(o),[]),nk(o,s,[e.value,e.heading,c]);let f=b.useMemo(()=>({id:o,forceMount:i}),[i]);return b.createElement(xm.div,{ref:im(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&b.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),rk(e,e=>b.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},b.createElement(YO.Provider,{value:f},e))))}),Mme=b.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=b.useRef(null),a=tk(e=>!e.search);return!n&&!a?null:b.createElement(xm.div,{ref:im(i,t),...r,"cmdk-separator":``,role:`separator`})}),Nme=b.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=JO(),o=tk(e=>e.search),s=tk(e=>e.selectedItemId),c=KO();return b.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),b.createElement(xm.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Pme=b.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=b.useRef(null),o=b.useRef(null),s=tk(e=>e.selectedItemId),c=KO();return b.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),b.createElement(xm.div,{ref:im(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},rk(e,e=>b.createElement(`div`,{ref:im(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Fme=b.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return b.createElement(wme,{open:n,onOpenChange:r},b.createElement(Tme,{container:o},b.createElement(Eme,{"cmdk-overlay":``,className:i}),b.createElement(Dme,{"aria-label":e.label,"cmdk-dialog":``,className:a},b.createElement(XO,{ref:t,...s}))))}),Ime=b.forwardRef((e,t)=>tk(e=>e.filtered.count===0)?b.createElement(xm.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Lme=b.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return b.createElement(xm.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},rk(e,e=>b.createElement(`div`,{"aria-hidden":!0},e)))}),ZO=Object.assign(XO,{List:Pme,Item:Ame,Input:Nme,Group:jme,Separator:Mme,Dialog:Fme,Empty:Ime,Loading:Lme});function Rme(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function zme(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function QO(e){let t=b.useRef(e);return $O(()=>{t.current=e}),t}var $O=typeof window>`u`?b.useEffect:b.useLayoutEffect;function ek(e){let t=b.useRef();return t.current===void 0&&(t.current=e()),t}function tk(e){let t=JO(),n=()=>e(t.snapshot());return b.useSyncExternalStore(t.subscribe,n,n)}function nk(e,t,n,r=[]){let i=b.useRef(),a=KO();return $O(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(WO,s),i.current=s}),i}var Bme=()=>{let[e,t]=b.useState(),n=ek(()=>new Map);return $O(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Vme(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function rk({asChild:e,children:t},n){return e&&b.isValidElement(t)?b.cloneElement(Vme(t),{ref:t.ref},n(t.props.children)):n(t)}var Hme={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},ik=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO,{ref:n,className:X(`flex h-full w-full flex-col overflow-hidden rounded-md bg-bg-primary text-fg-primary`,e),...t}));ik.displayName=ZO.displayName;var ak=b.forwardRef(({className:e,...t},n)=>(0,Y.jsxs)(`div`,{className:`flex items-center px-3`,"cmdk-input-wrapper":``,children:[(0,Y.jsx)(My,{className:`w-4 h-4 mr-2 opacity-50 shrink-0`}),(0,Y.jsx)(ZO.Input,{ref:n,className:X(`flex h-11 w-full rounded-md py-3 text-sm`,`placeholder:text-fg-secondary`,`bg-transparent rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]}));ak.displayName=ZO.Input.displayName;var ok=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO.List,{ref:n,className:X(`max-h-[300px] overflow-y-auto overflow-x-hidden`,e),...t}));ok.displayName=ZO.List.displayName;var sk=b.forwardRef((e,t)=>(0,Y.jsx)(ZO.Empty,{ref:t,className:`py-6 text-sm text-center`,...e}));sk.displayName=ZO.Empty.displayName;var ck=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO.Group,{ref:n,className:X(`overflow-hidden p-1 text-fg-primary [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-fg-secondary`,e),...t}));ck.displayName=ZO.Group.displayName;var lk=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO.Separator,{ref:n,className:X(`-mx-1 h-px bg-border-primary opacity-50`,e),...t}));lk.displayName=ZO.Separator.displayName;var uk=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO.Item,{ref:n,className:X(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-bg-primary-hover aria-selected:text-fg-primary data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,e),...t}));uk.displayName=ZO.Item.displayName;function dk({title:e,subtitle:t,image:n,className:r,imageSize:i=`md`}){let a=Ume(n);return(0,Y.jsxs)(`div`,{className:X(`flex min-w-0 flex-1 items-center gap-2`,r),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[e!=null&&e!==``&&(typeof e==`string`?(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e}):(0,Y.jsx)(`div`,{className:`font-medium`,children:e})),t!=null&&t!==``&&(typeof t==`string`?(0,Y.jsx)(`span`,{className:`truncate text-xs text-fg-secondary`,children:t}):(0,Y.jsx)(`div`,{className:`text-xs text-fg-secondary`,children:t}))]}),a&&(0,Y.jsx)(`div`,{className:X(`shrink-0 overflow-hidden rounded bg-bg-secondary`,i===`sm`?`h-7 w-7`:`h-8 w-8`),children:(0,Y.jsx)(`img`,{src:a,alt:typeof e==`string`?e:``,className:`h-full w-full object-cover`,loading:`lazy`})})]})}function Ume(e){return e==null?null:typeof e==`string`?e:H.mediaUrl(e)}function fk(e){let{path:t,schema:n}=TD(e),r=xb(t);return(0,b.useMemo)(()=>Wme(e,t,n,r),[e,t,n,r])}function Wme(e,t,n,r){if(t===e||!n||!r||!(`data`in r)||!r.data)return;let i=r.data,[,a]=H.splitModuleFilePathAndModulePath(e);if(!a)return;let o=H.splitModulePath(a),s=o[o.length-1];if(n.type===`array`&&i.parent===`array`){let e=Number(s),t=i.items.find(([t])=>t===e);if(!Number.isNaN(e)&&t)return t[1]}else if(n.type===`record`&&i.parent===`record`){let e=i.items.find(([e])=>e===s);if(e)return e[1]}}function Gme(e){let t=new Map;for(let n of e){let e=t.get(n.moduleFilePath);e?e.push(n):t.set(n.moduleFilePath,[n])}return Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,label:mk(e),items:t}))}function pk({refs:e,currentPath:t,onSelect:n,searchPlaceholder:r=`Filter`}){let i=wb(),a=i.status===`success`?i.data:void 0,o=Eb(),s=e.map(e=>{let t=Xme(e),n=a?.[t.moduleFilePath];return{...t,isRouter:n?.type===`record`&&!!n.router}});return(0,Y.jsxs)(ik,{children:[(0,Y.jsx)(ak,{placeholder:r}),(0,Y.jsx)(ok,{children:s.length===0?(0,Y.jsx)(sk,{children:`No references found.`}):Gme(s).map(e=>(0,Y.jsx)(ck,{heading:e.label,title:e.moduleFilePath,children:e.items.map(e=>(0,Y.jsx)(Kme,{item:e,isCurrent:t===e.path,onSelect:()=>{n(ob(e.path,o,a)??e.path,{scrollToPath:e.path})}},e.path))},e.moduleFilePath))})]})}function Kme({item:e,isCurrent:t,onSelect:n}){let r=fk(e.path);return(0,Y.jsx)(qme,{item:e,isCurrent:t,onSelect:n,image:r?.image??null})}function qme({item:e,isCurrent:t,onSelect:n,image:r}){let i=e.patchPath.length>0,a=mk(e.moduleFilePath);return(0,Y.jsx)(uk,{value:`${e.preview?.title??``} ${e.fallbackLabel}`,onSelect:n,className:X(`flex items-center gap-2 rounded-lg border px-2.5 py-2 text-[0.8125rem]`,t?`border-border-brand-primary bg-bg-float-raised`:`border-border-float`),title:e.path,children:(0,Y.jsx)(dk,{title:i?(0,Y.jsx)(Jme,{patchPath:e.patchPath,isRouter:e.isRouter??!1}):a,image:r,imageSize:`sm`})})}function Jme({patchPath:e,isRouter:t}){let[n,...r]=e;return(0,Y.jsxs)(`span`,{className:`block truncate`,children:[t?(0,Y.jsx)(Yme,{route:n}):(0,Y.jsx)(`span`,{className:`text-fg-primary`,children:n}),r.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Rv,{size:12,className:`mx-0.5 inline-block shrink-0 text-fg-tertiary align-[-1px]`}),r.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[t>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:` / `}),(0,Y.jsx)(`span`,{className:`text-fg-primary`,children:kC(e)})]},t))]})]})}function Yme({route:e}){let t=e.split(`/`).filter(e=>e.length>0);return t.length===0?(0,Y.jsx)(`span`,{className:`text-fg-primary`,children:e}):(0,Y.jsx)(`span`,{children:t.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`}),(0,Y.jsx)(`span`,{className:`text-fg-primary`,children:e})]},t))})}function mk(e){return H.splitModuleFilePath(e).map(kC).join(` / `)}function Xme(e){let[t,n]=H.splitModuleFilePathAndModulePath(e),r=H.createPatchPath(n),i=kC(H.splitModuleFilePath(t).pop()||``);return{path:e,moduleFilePath:t,patchPath:r,fallbackLabel:r.length?`${i} → ${r.join(` → `)}`:i}}function hk({path:e,variant:t}){let n=Cb(e),{path:r,schema:i}=TD(e),[a]=H.splitModuleFilePathAndModulePath(e),o=xk(e),s=o[o.length-1],c=spe(r,ED(e,r,i)?s?.part:void 0),l=lC(),u=b.useMemo(()=>DD(`data`in n?n.data:void 0)&&l.status===`success`&&l.data&&`data`in n&&n.data.type===`record`&&n.data.router?gk(a,l.data,n.data.router):null,[n,l,a]),d=b.useMemo(()=>ED(e,r,i)&&l.status===`success`&&l.data&&i&&i.type===`record`&&i.router?gk(a,l.data,i.router):null,[e,r,i,l,a]),f=d?.every(e=>e.type===`literal`)||!1,p=!d||!f,m=!d||!f,h=u?.every(e=>e.type===`literal`)||!1,g=!u||!h,_=ED(e,r,i)&&i&&i.type===`record`&&i.router,v=upe(_?s?.part:void 0),y=_?ope(c,v):c,x=i?.type===`record`?i.key?.description:void 0,S=`data`in n&&n.data.type===`record`?n.data.key?.description:void 0;return(0,Y.jsxs)(`span`,{className:`inline-flex gap-2 items-center`,children:[ED(e,r,i)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_k,{refs:y.refs,variant:t}),m&&(0,Y.jsx)(vpe,{defaultValue:s.text,path:e,parentPath:r,variant:bk(t),size:yk(t),routePattern:d,references:y,keyDescription:x,children:(0,Y.jsx)(Aae,{size:vk(t)})}),p&&(0,Y.jsx)(dpe,{path:e,parentPath:r,variant:bk(t),size:yk(t),references:y,confirmationMessage:`This will delete the ${s.text} record.`,children:(0,Y.jsx)(zae,{size:vk(t)})})]}),$fe(`data`in n?n.data:void 0)&&(0,Y.jsx)(Zme,{path:e,variant:t}),DD(`data`in n?n.data:void 0)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_k,{refs:c.refs,variant:t}),g&&(0,Y.jsx)(hpe,{path:e,variant:bk(t),size:yk(t),routePattern:u,keyDescription:S,children:(0,Y.jsx)(Oy,{size:vk(t)})})]})]})}function gk(e,t,n){return n===`next-app-router`?np(tp(e,t)):null}function _k({refs:e,variant:t}){let n=eb(),{navigate:r,currentSourcePath:i}=GC(),[a,o]=b.useState(!1);return e.length===0?null:(0,Y.jsxs)(SD,{open:a,onOpenChange:o,children:[(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsx)(t_,{variant:bk(t),size:yk(t),role:`combobox`,"aria-expanded":a,children:(0,Y.jsx)(dy,{size:vk(t)})})})}),(0,Y.jsx)(Xg,{side:`top`,children:`References to this record`})]}),(0,Y.jsx)(wD,{className:`w-[clamp(300px, 40vw, 400px)] p-0 z-[8999]`,container:n,children:(0,Y.jsx)(pk,{refs:e,currentPath:i,onSelect:(e,{scrollToPath:t})=>{r(e,{scrollToPath:t}),o(!1)}})})]})}function vk(e){return e===`module`?16:12}function yk(e){return`icon`}function bk(e){return e===`module`?`outline`:`ghost`}function Zme({path:e,variant:t}){let{navigate:n}=GC(),{addPatch:r,patchPath:i}=vb(e),a=Cb(e),o=Ob(e,`array`),[s]=H.splitModuleFilePathAndModulePath(e);if(!(`data`in o)||!o.data||!(`data`in a))return null;let c=a.data;if(c.type!==`array`)return console.error(`Cannot add to non-array`,o,{parentPath:e}),null;let l=o.data.length;return(0,Y.jsx)(t_,{title:`Add`,size:yk(t),variant:bk(t),onClick:()=>{let e=i.concat(l.toString());r([{op:`add`,path:e,value:Cp(c.item)}],c.type),xr(c.item)||n(H.joinModuleFilePathAndModulePath(s,H.patchPathToModulePath(e)))},children:(0,Y.jsx)(Oy,{size:vk(t)})})}function xk(e){let[t,n]=H.splitModuleFilePathAndModulePath(e),r=H.splitModuleFilePath(t),i=r.map((e,n)=>({text:kC(e),part:e,sourcePath:t,isDirectory:n<r.length-1}));if(!n)return i;let a=H.splitModulePath(n),o=[],s=``;for(let e=0;e<a.length;e++){let r=(s?s+`.`:``)+JSON.stringify(a[e]);n.startsWith(r)||(r=(s?s+`.`:``)+a[e]),s=r,o.push({text:a[e],part:a[e],sourcePath:H.joinModuleFilePathAndModulePath(t,r),isDirectory:!1})}return i.concat(o)}var Qme=Object.defineProperty,Sk=(e,t)=>Qme(e,`name`,{value:t,configurable:!0}),Ck=`Collapsible`,[$me,wk]=sm(Ck),[ehe,Tk]=$me(Ck),the=b.forwardRef(Sk(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=ng({prop:r,defaultProp:i??!1,onChange:o,caller:Ck});return(0,Y.jsx)(ehe,{scope:n,disabled:a,contentId:Pm(),open:c,onOpenToggle:b.useCallback(()=>l(e=>!e),[l]),children:(0,Y.jsx)(xm.div,{"data-state":Dk(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),nhe=`CollapsibleTrigger`,rhe=b.forwardRef(Sk(function(e,t){let{__scopeCollapsible:n,...r}=e,i=Tk(nhe,n);return(0,Y.jsx)(xm.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Dk(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:Qp(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),Ek=`CollapsibleContent`,ihe=b.forwardRef(Sk(function(e,t){let{forceMount:n,...r}=e,i=Tk(Ek,e.__scopeCollapsible);return(0,Y.jsx)(Jh,{present:n||i.open,children:({present:e})=>(0,Y.jsx)(ahe,{...r,ref:t,present:e})})},`CollapsibleContent`)),ahe=b.forwardRef(Sk(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Tk(Ek,n),[s,c]=b.useState(r),l=b.useRef(null),u=am(t,l),d=b.useRef(0),f=d.current,p=b.useRef(0),m=p.current,h=o.open||s,g=b.useRef(h),_=b.useRef(void 0);return b.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),Nm(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,Y.jsx)(xm.div,{"data-state":Dk(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})},`CollapsibleContentImpl`));function Dk(e){return e?`open`:`closed`}Sk(Dk,`getState`);var ohe=the,she=rhe,che=ihe,lhe=Object.defineProperty,Ok=(e,t)=>lhe(e,`name`,{value:t,configurable:!0}),kk=`Accordion`,uhe=[`Home`,`End`,`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`],[Ak,dhe,fhe]=KT(kk),[jk,phe]=sm(kk,[fhe,wk]),Mk=wk(),mhe=b.forwardRef(Ok(function(e,t){let{type:n,...r}=e,i=r,a=r;return(0,Y.jsx)(Ak.Provider,{scope:e.__scopeAccordion,children:n===`multiple`?(0,Y.jsx)(vhe,{...a,ref:t}):(0,Y.jsx)(_he,{...i,ref:t})})},`Accordion`)),[Nk,hhe]=jk(kk),[Pk,ghe]=jk(kk,{collapsible:!1}),_he=b.forwardRef(Ok(function(e,t){let{value:n,defaultValue:r,onValueChange:i=Ok(()=>{},`onValueChange`),collapsible:a=!1,...o}=e,[s,c]=ng({prop:n,defaultProp:r??``,onChange:i,caller:kk});return(0,Y.jsx)(Nk,{scope:e.__scopeAccordion,value:b.useMemo(()=>s?[s]:[],[s]),onItemOpen:c,onItemClose:b.useCallback(()=>a&&c(``),[a,c]),children:(0,Y.jsx)(Pk,{scope:e.__scopeAccordion,collapsible:a,children:(0,Y.jsx)(bhe,{...o,ref:t})})})},`AccordionImplSingle`)),vhe=b.forwardRef(Ok(function(e,t){let{value:n,defaultValue:r,onValueChange:i=Ok(()=>{},`onValueChange`),...a}=e,[o,s]=ng({prop:n,defaultProp:r??[],onChange:i,caller:kk}),c=b.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=b.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,Y.jsx)(Nk,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:l,children:(0,Y.jsx)(Pk,{scope:e.__scopeAccordion,collapsible:!0,children:(0,Y.jsx)(bhe,{...a,ref:t})})})},`AccordionImplMultiple`)),[yhe,Fk]=jk(kk),bhe=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,disabled:r,dir:i,orientation:a=`vertical`,...o}=e,s=am(b.useRef(null),t),c=dhe(n),l=nE(i)===`ltr`,u=Qp(e.onKeyDown,e=>{if(!uhe.includes(e.key))return;let t=e.target,n=c().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),i=n.length;if(r===-1)return;e.preventDefault();let o=r,s=i-1,u=Ok(()=>{o=r+1,o>s&&(o=0)},`moveNext`),d=Ok(()=>{o=r-1,o<0&&(o=s)},`movePrev`);switch(e.key){case`Home`:o=0;break;case`End`:o=s;break;case`ArrowRight`:a===`horizontal`&&(l?u():d());break;case`ArrowDown`:a===`vertical`&&u();break;case`ArrowLeft`:a===`horizontal`&&(l?d():u());break;case`ArrowUp`:a===`vertical`&&d()}n[o%i].ref.current?.focus()});return(0,Y.jsx)(yhe,{scope:n,disabled:r,direction:i,orientation:a,children:(0,Y.jsx)(Ak.Slot,{scope:n,children:(0,Y.jsx)(xm.div,{...o,"data-orientation":a,ref:s,onKeyDown:r?void 0:u})})})},`AccordionImpl`)),Ik=`AccordionItem`,[xhe,Lk]=jk(Ik),She=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,value:r,...i}=e,a=Fk(Ik,n),o=hhe(Ik,n),s=Mk(n),c=Pm(),l=r&&o.value.includes(r)||!1,u=a.disabled||e.disabled;return(0,Y.jsx)(xhe,{scope:n,open:l,disabled:u,triggerId:c,children:(0,Y.jsx)(ohe,{"data-orientation":a.orientation,"data-state":Rk(l),...s,...i,ref:t,disabled:u,open:l,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})},`AccordionItem`)),Che=`AccordionHeader`,whe=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,...r}=e,i=Fk(kk,n),a=Lk(Che,n);return(0,Y.jsx)(xm.h3,{"data-orientation":i.orientation,"data-state":Rk(a.open),"data-disabled":a.disabled?``:void 0,...r,ref:t})},`AccordionHeader`)),The=`AccordionTrigger`,Ehe=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,...r}=e,i=Fk(kk,n),a=Lk(The,n),o=ghe(The,n),s=Mk(n);return(0,Y.jsx)(Ak.ItemSlot,{scope:n,children:(0,Y.jsx)(she,{"aria-disabled":a.open&&!o.collapsible||void 0,"data-orientation":i.orientation,id:a.triggerId,...s,...r,ref:t})})},`AccordionTrigger`)),Dhe=`AccordionContent`,Ohe=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,...r}=e,i=Fk(kk,n),a=Lk(Dhe,n),o=Mk(n);return(0,Y.jsx)(che,{role:`region`,"aria-labelledby":a.triggerId,"data-orientation":i.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":`var(--radix-collapsible-content-height)`,"--radix-accordion-content-width":`var(--radix-collapsible-content-width)`,...e.style}})},`AccordionContent`));function Rk(e){return e?`open`:`closed`}Ok(Rk,`getState`);var khe=mhe,Ahe=She,jhe=whe,Mhe=Ehe,Nhe=Ohe,zk=khe,Bk=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Ahe,{ref:n,className:X(`border-b border-border-primary`,e),...t}));Bk.displayName=`AccordionItem`;var Vk=b.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsx)(jhe,{className:`flex`,children:(0,Y.jsxs)(Mhe,{ref:r,className:X(`flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,Y.jsx)(Iv,{className:`w-4 h-4 transition-transform duration-200 shrink-0`})]})}));Vk.displayName=Mhe.displayName;var Hk=b.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsx)(Nhe,{ref:r,className:X(`overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down`,e),...n,children:(0,Y.jsx)(`div`,{className:`pt-0 pb-4`,children:t})}));Hk.displayName=Nhe.displayName;function Phe({validationErrors:e,ariaLabel:t=`Validation errors for this field`,className:n}){return e.length===0?null:(0,Y.jsxs)(`div`,{className:(0,AC.default)(`relative pl-3`,n),children:[(0,Y.jsx)(`span`,{className:`absolute left-0 top-1 bottom-1 w-[2px] rounded bg-bg-warning-secondary`,"aria-hidden":!0}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-sm text-fg-warning-primary`,"aria-label":t,children:e.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-1.5`,children:[(0,Y.jsx)(Bv,{size:13,className:`mt-[3px] shrink-0 text-fg-warning-primary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e.message})]},t))})]})}function Uk({validationErrors:e}){return e.length===0?null:(0,Y.jsx)(`div`,{className:`w-full pt-2`,children:(0,Y.jsx)(Phe,{validationErrors:e})})}function Fhe({path:e}){let{navigate:t}=GC(),n=Db(),r=Fb(),i=!$ae(),a=[];if(r){for(let t in r)if(t.startsWith(e))for(let e of r[t]??[])a.push(e.message)}return a.length===0?(0,Y.jsx)(`div`,{className:`size-6 shrink-0`}):(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`button`,{onClick:()=>{let r=n(e);t(r??e,{scrollToPath:e})},className:(0,AC.default)(`inline-flex items-center justify-center size-6 rounded bg-bg-warning-secondary text-fg-warning-secondary hover:bg-bg-warning-secondary-hover transition-colors`,{"opacity-80":i}),"aria-label":`Go to validation error`,children:i?(0,Y.jsx)(hy,{size:16,className:`animate-spin`}):(0,Y.jsx)(Ly,{size:16})})}),(0,Y.jsx)(Xg,{side:`right`,className:`max-w-xs bg-bg-warning-secondary text-fg-warning-secondary border-fg-warning-secondary/20`,children:a.length===1?(0,Y.jsx)(`p`,{className:`text-xs`,children:a[0]}):(0,Y.jsx)(`ul`,{className:`text-xs list-disc pl-3 space-y-0.5`,children:a.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})})]})}var Ihe=(0,b.createContext)(!1);function Lhe({children:e}){return(0,Y.jsx)(Ihe.Provider,{value:!0,children:e})}function Rhe(){return(0,b.useContext)(Ihe)}function zhe(e){return!e||typeof e!=`string`?``:e.trim().normalize(`NFC`).split(/\s+/).filter(e=>e.length>0).map(e=>/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(e)?e[0]:e[0].toLocaleUpperCase()).join(``)}function Wk(e,t){let n=new Date(t).getTime(),r=e.getTime(),i=Math.floor((r-n)/1e3),a=Math.floor(i/60),o=Math.floor(i/3600),s=Math.floor(i/86400),c=Math.floor(s/30);return i<60?`just now`:a<60?`${a}m ago`:o<24?`${o}h ago`:s===1?`yesterday`:s<30?`${s}d ago`:`${c}mo ago`}function Bhe({op:e}){return e===`add`?(0,Y.jsx)(Oy,{size:12}):e===`remove`?(0,Y.jsx)(yy,{size:12}):e===`replace`?(0,Y.jsx)(ny,{size:12}):e===`move`?(0,Y.jsx)(Nie,{size:12}):e===`copy`?(0,Y.jsx)(qv,{size:12}):e===`file`?(0,Y.jsx)(ey,{size:12}):(0,Y.jsx)(Dy,{size:12})}function Vhe({profile:e,isFirst:t,stacked:n,mode:r}){let i=(0,AC.default)(`flex-shrink-0 w-6 h-6 rounded-full inline-flex items-center justify-center text-xs font-semibold overflow-hidden`,{"-ml-2":n&&!t});if(!e)return(0,Y.jsx)(`span`,{className:(0,AC.default)(i,`bg-bg-secondary text-fg-disabled`),children:r===`fs`?(0,Y.jsx)(jy,{size:12}):(0,Y.jsx)(Vy,{size:12})});if(e.avatar?.url)return(0,Y.jsx)(`img`,{src:e.avatar.url,alt:e.fullName,className:(0,AC.default)(i,`object-cover`)});let a=zhe(e.fullName);return(0,Y.jsx)(`span`,{className:(0,AC.default)(i,`bg-bg-brand-primary text-fg-brand-primary`),children:a})}function Hhe(e){return`opType`in e?e.opType:e.patch.length>0?e.patch[0].op:`replace`}function Uhe(e){let t=Object.values(e).flat();return t.reduce((e,t)=>new Date(t.createdAt)>new Date(e)?t.createdAt:e,t[0].createdAt)}function Gk({patchesByAuthorIds:e,profilesByAuthorIds:t,now:n,mode:r,showHistoryIcon:i}){let a=Object.keys(e);if(a.length===0)return null;let o=a.slice(0,3),s=a.length-o.length,c=Uhe(e);return(0,Y.jsxs)(Y.Fragment,{children:[i&&(0,Y.jsx)(Ay,{size:12,className:`text-fg-tertiary mr-0.5`}),(0,Y.jsx)(`span`,{className:`text-xs text-fg-tertiary mr-1`,children:Wk(n,c)}),(0,Y.jsxs)(`span`,{className:`flex items-center rounded-full`,children:[o.map((e,n)=>(0,Y.jsx)(Vhe,{profile:t[e]??null,isFirst:n===0,stacked:a.length>1,mode:r},e)),s>0&&(0,Y.jsxs)(`span`,{className:`flex-shrink-0 -ml-2 w-6 h-6 text-xs font-semibold rounded-full inline-flex items-center justify-center bg-bg-primary text-fg-primary border border-border-primary`,children:[`+`,s]})]})]})}function Whe({patchesByAuthorIds:e,profilesByAuthorIds:t,now:n,portalContainer:r,mode:i}){let a=Object.keys(e);return a.length===0?null:(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`xs`,"aria-label":`Change history`,children:(0,Y.jsx)(Gk,{patchesByAuthorIds:e,profilesByAuthorIds:t,now:n,mode:i,showHistoryIcon:!0})})}),(0,Y.jsxs)(wD,{container:r,align:`end`,className:`z-[9001] min-w-[220px] p-0`,children:[(0,Y.jsxs)(`div`,{className:`px-3 pt-2.5 pb-1.5 text-xs font-medium text-fg-secondary border-b border-border-primary flex items-center gap-1.5`,children:[(0,Y.jsx)(Ay,{size:12}),(0,Y.jsx)(`span`,{children:`Change history`})]}),(0,Y.jsx)(eD,{className:`h-40`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3 p-3`,children:a.map(r=>{let a=t[r]??null,o=a?.fullName??(i===`fs`?`Local changes`:`Unknown author`),s=[...e[r]].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-xs text-fg-secondary`,children:[(0,Y.jsx)(Vhe,{profile:a,isFirst:!0,stacked:!1,mode:i}),(0,Y.jsx)(`span`,{children:o})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-0 pl-8`,children:s.map((e,t)=>{let r=Hhe(e),i=t===s.length-1;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-tertiary`,children:[(0,Y.jsxs)(`span`,{className:`relative flex items-center justify-center w-3 h-5`,children:[!i&&(0,Y.jsx)(`span`,{className:`absolute top-1/2 bottom-0 left-1/2 w-px -translate-x-1/2 bg-border-secondary`}),t>0&&(0,Y.jsx)(`span`,{className:`absolute top-0 bottom-1/2 left-1/2 w-px -translate-x-1/2 bg-border-secondary`}),(0,Y.jsx)(`span`,{className:`relative text-fg-secondary`,children:(0,Y.jsx)(Bhe,{op:r})})]}),(0,Y.jsx)(`span`,{children:Wk(n,e.createdAt)})]},t)})})]},r)})})})]})]})}function Kk({patchesByAuthorIds:e,profilesByAuthorIds:t,sourcePath:n,navigable:r=!0}){let[i]=(0,b.useState)(()=>new Date),a=QS(),{navigate:o}=GC();if(Object.keys(e).length===0)return null;let s=r&&n?()=>o(`/val/compare`,{scrollToPath:n}):void 0;return s?(0,Y.jsxs)(t_,{variant:`ghost`,size:`xs`,"aria-label":`View in compare`,onClick:s,children:[(0,Y.jsx)(Gk,{patchesByAuthorIds:e,profilesByAuthorIds:t,now:i,mode:a}),(0,Y.jsx)(Fie,{size:12,className:`ml-1 text-fg-tertiary`})]}):(0,Y.jsx)(`span`,{className:`inline-flex items-center text-xs`,children:(0,Y.jsx)(Gk,{patchesByAuthorIds:e,profilesByAuthorIds:t,now:i,mode:a})})}function Ghe({path:e}){let t=XS(e),n=sC(),r=(0,b.useMemo)(()=>{let e={};for(let n of t||[]){let t=n.authorId??`unknown`;e[t]||(e[t]=[]),e[t].push(n)}return e},[t]);return t&&t.length>0?(0,Y.jsx)(Kk,{patchesByAuthorIds:r,profilesByAuthorIds:n,sourcePath:e}):null}function Khe(e,t,n,r=!0){let i=Pb(e),{patchPath:a,addPatch:o}=vb(e),s=Cb(e),c=Ob(e,t),l=s.status===`loading`||c.status===`loading`?`loading`:s.status===`error`||c.status===`error`?`error`:`success`,[u,d]=(0,b.useState)(r),[f,p]=(0,b.useState)(!1),m=`data`in c?c.data:void 0,h=`data`in s?s.data:void 0;(0,b.useEffect)(()=>{n||m===null&&h&&!h.opt&&(h.type===`image`||h.type===`file`)&&p(!0)},[m,h?.opt,h?.type,n]);let g=n?n.source:m,_=n?n.schema:h;return{loadingStatus:l,validationErrors:i,patchPath:a,addPatch:o,schemaAtPath:s,sourceAtPath:c,isExpanded:u,setIsExpanded:d,showEmptyFileOrImage:f,setShowEmptyFileOrImage:p,source:g,schema:_,isBoolean:_?.type===`boolean`,isNullable:_?.opt===!0}}function qk({label:e,description:t,children:n,path:r,transparent:i,type:a,readonly:o,compact:s,foldLevel:c=`1`,source:l,schema:u,initialExpanded:d,errorDisplay:f=`default`}){if(l!==void 0!=(u!==void 0))throw Error(`Field: source and schema must both be provided or both omitted`);let p=l!==void 0&&u!==void 0?{source:l,schema:u}:void 0,m=p!==void 0,{loadingStatus:h,validationErrors:g,patchPath:_,addPatch:v,isExpanded:y,setIsExpanded:b,showEmptyFileOrImage:x,setShowEmptyFileOrImage:S,source:C,schema:w,isBoolean:T,isNullable:E}=Khe(r,a,p,d),D=o||m,{navigate:O}=GC(),k=Db(),{canMentionField:A}=wS(),j=TS(),M=()=>{let e=k(r)??r;O(e,{scrollToPath:e===r?void 0:r})},N=f===`compact`;return(0,Y.jsxs)(`div`,{"data-val-studio-path":r,className:(0,AC.default)(`border`,{"px-4 pt-6 pb-4 rounded-lg":!s,"px-3 pt-2 pb-2 rounded-md":s,"bg-bg-tertiary":!i&&!s,"border-bg-warning-secondary":!m&&f==="default"&&g.length>0}),children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex justify-between items-center`,{"pb-2":!s,"pb-1.5":s}),children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex items-center`,{"gap-4":!s,"gap-3":s,"pt-2":s&&T}),children:[!m&&w&&!T&&(E||C===null)&&(0,Y.jsx)(UT,{disabled:D||h===`loading`,checked:C!==null||x,onCheckedChange:()=>{D||((w.type===`image`||w.type===`file`)&&C===null?S(!0):v(C===null?[{op:`replace`,path:_,value:Cp({...w,opt:!1})}]:[{op:`replace`,path:_,value:null}],w.type))}}),T&&(0,Y.jsx)(Sde,{path:r,isNullable:E,loadingStatus:D?`loading`:h,source:C}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[typeof e==`string`&&(N?(0,Y.jsx)(`button`,{onClick:M,className:`font-mono text-sm px-2 py-0.5 rounded bg-bg-secondary text-fg-primary truncate cursor-pointer hover:bg-bg-tertiary transition-colors min-w-0 block`,children:cD(e)}):(0,Y.jsx)(Pfe,{children:e})),e&&typeof e!=`string`&&e,t&&(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:t})]})]}),(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex items-center`,{"gap-2 min-h-8":!s,"gap-1.5":s}),children:[!m&&!s&&(0,Y.jsx)(Ghe,{path:r}),!m&&A&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>j(r),title:`Mention this field in AI chat`,"aria-label":`Mention this field in AI chat`,className:(0,AC.default)(`flex items-center justify-center rounded text-fg-secondary hover:text-fg-primary hover:bg-bg-secondary`,{"size-6":!s,"size-5":s,invisible:D}),children:[(0,Y.jsx)(Ny,{size:s?9:10}),(0,Y.jsx)(Oy,{size:s?7:8,className:`-ml-0.5`})]}),!m&&C!==null&&(0,Y.jsx)(`div`,{className:(0,AC.default)({invisible:D}),children:(0,Y.jsx)(hk,{path:r,variant:`field`})}),C!==null&&!T&&(0,Y.jsxs)(`button`,{onClick:()=>b(e=>!e),className:(0,AC.default)(`transform transition-transform flex items-center justify-center`,{"size-6 m-[1px]":!s,"size-5":s,"rotate-180":y}),children:[c===`1`&&(0,Y.jsx)(Iv,{size:s?14:16}),c===`2`&&(0,Y.jsx)(Rie,{size:s?14:16})]})]})]}),!T&&(0,Y.jsx)(zk,{type:`single`,collapsible:!0,value:y&&(C!==null||x)?`open`:`closed`,children:(0,Y.jsx)(Bk,{value:`open`,className:`w-full border-b-0`,children:(0,Y.jsx)(Hk,{children:(0,Y.jsx)(Lhe,{children:n})})})}),!m&&f==="default"&&g.length>0&&(0,Y.jsx)(`div`,{className:s?`pb-0`:`pb-2`,children:(0,Y.jsx)(Uk,{validationErrors:g})})]})}function qhe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`object`,o=Cb(e),s=Ob(e,a);if(o.status===`error`)return(0,Y.jsx)(NC,{path:e,error:o.error,type:a});if(s.status===`error`)return(0,Y.jsx)(FC,{path:e,error:s.error,schema:o});if(s.status==`not-found`||o.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(o.status===`loading`||!(`data`in s)||s.data===void 0)return(0,Y.jsx)(jC,{path:e,type:a});if(o.data.type!==a)return(0,Y.jsx)(PC,{path:e,expectedType:a,actualType:o.data.type});let c=o.data;return(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(`div`,{className:`flex flex-col ${n?`gap-3`:`gap-6`}`,children:Object.entries(c.items).map(([a,o])=>{if(o.hidden)return null;let s=sD(e,a),c=t||o.readonly;return(0,Y.jsx)(qk,{label:a,description:o.description,path:s,type:o.type,readonly:c,compact:n,errorDisplay:i,children:(0,Y.jsx)(r6,{path:s,schema:o,readonly:c,compact:n,inline:r,errorDisplay:i},s)},s)})})})}function Jhe({path:e,size:t}){let n=`object`,r=Cb(e);if(r.status===`error`)return(0,Y.jsx)(NC,{path:e,error:r.error,type:n});if(r.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:n});if(r.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(r.data.type!==`object`)return(0,Y.jsx)(PC,{path:e,expectedType:`object`,actualType:r.data.type});let i=r.data;return(0,Y.jsx)(Yhe,{path:e,schema:i,size:t})}function Yhe({path:e,schema:t,size:n}){return(0,Y.jsx)(`div`,{id:e,className:`grid grid-cols-[min-content,1fr] text-left gap-2 text-xs ${n===`compact`?`max-h-[60px] overflow-hidden`:``}`,children:Object.entries(t.items).map(([t,r])=>{if(r.hidden)return null;let i=sD(e,t);return(0,Y.jsx)(Xhe,{label:t,children:(0,Y.jsx)(q3,{path:i,size:n})},t)})})}function Xhe({label:e,children:t}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`flex whitespace-nowrap text-fg-disabled`,children:OC(e)}),t]})}function Jk(e){return typeof e.key!=`string`}function Zhe(e){return typeof e.key==`string`}function Qhe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`union`,o=Cb(e),s=Ob(e,a);if(o.status===`error`)return(0,Y.jsx)(NC,{path:e,error:o.error,type:a});if(s.status===`error`)return(0,Y.jsx)(FC,{path:e,error:s.error,schema:o});if(s.status==`not-found`||o.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(o.status===`loading`||!(`data`in s)||s.data===void 0)return(0,Y.jsx)(jC,{path:e,type:a});if(o.data.type!==a)return(0,Y.jsx)(PC,{path:e,expectedType:a,actualType:o.data.type});let c=s.data;if(Jk(o.data)){if(typeof c!=`string`&&c!==null)return(0,Y.jsx)(FC,{path:e,error:`Expected source to be a string, but found: `+typeof c,schema:o});let n=(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(nge,{path:e,source:c,readonly:t,options:o.data.items.concat(o.data.key).flatMap(e=>e?.type===`literal`?[e.value]:(console.warn(`Unexpected item in string union`,e),[]))})});return t?(0,Y.jsx)(NT,{children:n}):n}if(!Jk(o.data))return typeof c==`object`?Array.isArray(c)?(0,Y.jsx)(FC,{path:e,error:`Expected source to be an object, but found an array`,schema:o}):(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(tge,{path:e,schema:o.data,readonly:t,compact:n,inline:r,errorDisplay:i})}):(0,Y.jsx)(FC,{path:e,error:`Expected source to be an object, but found: `+typeof c,schema:o})}function $he(e,t){let n=Ab(e),{addPatch:r,patchPath:i}=vb(e),a=Ob(sD(e,t.key),`literal`),o=`data`in a?a.data:void 0,s=(0,b.useRef)({});(0,b.useEffect)(()=>{n!==void 0&&typeof o==`string`&&n.status===`success`&&(s.current[e]||(s.current[e]={}),s.current[e][o]=n.data)},[n,o,e]);let c=(0,b.useCallback)(n=>{let a=t.items.find(e=>{let r=e.items?.[t.key];return r.type===`literal`?r.value===n:(console.error(`Expected literal schema in object union`,r),!1)});if(a?.items===void 0){console.error(`Selected schema with ${t.key} = ${n} not found`);return}let o={...s.current[e]?.[n]??Cp(a),[t.key]:n};r([{op:`replace`,path:i,value:o}],t.type)},[r,i,e,t]),l=t.items.flatMap(e=>{let n=e.items?.[t.key];return n.type===`literal`?[n.value]:(console.error(`Expected literal schema in object union`,n),[])}),u=t.items.find(e=>{let n=e.items?.[t.key];return n.type===`literal`?n.value===o:(console.error(`Expected literal schema in object union`,n),!1)});return typeof o!=`string`||u===void 0||u.items===void 0?{status:`loading`}:{status:`ready`,selectedSchema:u,options:l,current:o,select:c}}function ege({state:e,readonly:t,className:n}){let r=eb();return(0,Y.jsxs)(nD,{disabled:t,value:e.current,onValueChange:n=>{t||e.select(n)},children:[(0,Y.jsx)(iD,{className:n,children:(0,Y.jsx)(rD,{children:e.current})}),(0,Y.jsx)(aD,{container:r,className:`w-32`,children:e.options.map(e=>(0,Y.jsx)(oD,{value:e,children:e},e))})]})}function tge({path:e,schema:t,readonly:n,compact:r,inline:i,errorDisplay:a=`default`}){let o=$he(e,t);if(o.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:`union`});let{selectedSchema:s}=o;return(0,Y.jsxs)(`div`,{className:`grid ${r?`gap-3`:`gap-4`}`,children:[(0,Y.jsx)(ege,{state:o,readonly:n}),Object.keys(s.items).filter(e=>e!==t?.key).map(t=>{let o=sD(e,t);return(0,Y.jsx)(qk,{path:o,foldLevel:`1`,label:t,description:s?.items?.[t]?.description,type:s?.items?.[t]?.type,readonly:n,compact:r,errorDisplay:a,children:(0,Y.jsx)(r6,{path:o,schema:s?.items?.[t],readonly:n,compact:r,inline:i,errorDisplay:a},t)},o)})]})}function nge({path:e,source:t,options:n,readonly:r}){let{addPatch:i,patchPath:a}=vb(e),o=eb();return(0,Y.jsxs)(nD,{disabled:r,value:t??``,onValueChange:e=>{r||i([{op:`replace`,path:a,value:e}],`union`)},children:[(0,Y.jsx)(iD,{children:(0,Y.jsx)(rD,{children:t})}),(0,Y.jsx)(aD,{className:`w-32`,container:o,children:n==null?(0,Y.jsx)(rge,{}):n.map(e=>(0,Y.jsx)(oD,{value:e,children:e},e))})]})}function rge(){return(0,Y.jsx)(`div`,{children:`Loading...`})}function ige({path:e}){let t=`union`,n=Ab(e),r=Cb(e);if(n.status===`error`)return(0,Y.jsx)(FC,{path:e,error:n.error,schema:r});if(!(`data`in n)||n.data===void 0||!(`data`in r)||r.data===void 0)return(0,Y.jsx)(J3,{path:e});if(n.data===null)return(0,Y.jsx)(Y3,{path:e});if(r.data.type!==t)return(0,Y.jsx)(PC,{path:e,expectedType:t,actualType:r.data.type});let i=r.data;if(Jk(i))return typeof n.data==`string`?(0,Y.jsx)(`div`,{className:`truncate`,children:n.data}):(0,Y.jsx)(FC,{path:e,error:`Expected source to be a string, but found: `+typeof n.data,schema:r});{let t=n.data;if(!t)return(0,Y.jsx)(Y3,{path:e});if(typeof t!=`object`&&!(typeof t==`object`&&i.key in t))return(0,Y.jsx)(FC,{path:e,error:`Expected source to be an object, but found: `+typeof t,schema:r});let a=i.items.find(e=>{let n=e.items?.[i.key];if(n?.type===`literal`&&typeof t==`object`&&t&&i.key in t&&!Wp(t))return n.value===t[i.key]});return a?(0,Y.jsx)(Yhe,{path:e,schema:a}):(0,Y.jsx)(FC,{path:e,error:`Expected source to have key `+i.key+` but it was not found`,schema:r})}}function age(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function Yk(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function oge(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var sge=(e,t)=>Math.abs(e-t)<1.01,cge=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},Xk,Zk=()=>{if(Xk!==void 0)return Xk;if(typeof navigator>`u`)return Xk=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Xk=!0;let e=navigator.maxTouchPoints;return Xk=navigator.platform===`MacIntel`&&e!==void 0&&e>0},lge=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},uge=e=>e,dge=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},fge=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(lge(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(lge(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Qk={passive:!0},pge=typeof window>`u`||`onscrollend`in window,mge=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&pge,o=0,s=a?null:cge(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Qk),a&&r.addEventListener(`scrollend`,u,Qk),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},hge=(e,t)=>mge(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),gge=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},_ge=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},vge=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:uge,rangeExtractor:dge,onChange:()=>{},measureElement:gge,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=Math.max(0,e.start+t);n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Yk(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!Zk()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Qk),e.addEventListener(`touchend`,n,Qk),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(Zk()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Yk(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=Yk(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=age(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Yk(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=bge(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Yk(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f)}},this.getVirtualItems=Yk(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return oge(t[$k(0,t.length-1,r?e=>n[e*2]:e=>oge(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){return e===0?!1:Zk()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=e,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&sge(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},$k=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function yge(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function bge(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=yge(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=$k(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var eA=typeof document<`u`?b.useLayoutEffect:b.useEffect;function xge({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=b.useReducer(e=>e+1,0)[1],a=b.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},s=e=>{let t=a.current;if(!t.enabled||!t.container)return;o(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let o=a.start-s,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==o&&(t.lastPositions.set(c,o),r?c.style.transform=n?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:c.style[i]=`${o}px`)}},c={...r,onChange:(t,n)=>{var o;let c=a.current,l=!0;if(c.enabled){s(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,lm.flushSync)(i):i()),(o=r.onChange)==null||o.call(r,t,n)}},[l]=b.useState(()=>{let e=new vge(c);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return l.setOptions(c),eA(()=>l._didMount(),[]),eA(()=>(o(l),l._willUpdate())),eA(()=>{s(l)}),l}function tA(e){return xge({observeElementRect:fge,observeElementOffset:hge,scrollToFn:_ge,...e})}function nA(e){let t=e.replace(/^\//,``).replace(/\.val\.(ts|js)$/,``).split(`/`);return t.length>1&&(t[0]===`content`||t[0]===`schema`)&&t.shift(),t.map(e=>e.replace(/[-_]/g,` `)).join(` / `)}function rA(e,t){let n=t.get(e);return H.mediaUrl({path:e,...n?{patch_id:n}:{}})}var Sge=``;function iA(e){let t=Ab(e??Sge),n=Mb(),r=(0,b.useCallback)(e=>rA(e,n),[n]);return!e||t.status!==`success`?{moduleEntries:void 0,getUrl:r,ready:!1}:{moduleEntries:{[e]:t.data},getUrl:r,ready:!0}}function aA(e){return e.startsWith(oA)?e.slice(oA.length):e}var oA=`/public`;function sA({hotspot:e,size:t=`md`}){let n=t===`sm`?14:20,r=t===`sm`?3:4,i=t===`sm`?1.5:2;return(0,Y.jsxs)(`div`,{className:`pointer-events-none absolute z-hover`,style:{top:`${e.y*100}%`,left:`${e.x*100}%`,transform:`translate(-50%, -50%)`},children:[(0,Y.jsx)(`div`,{style:{width:`${n}px`,height:`${n}px`,borderRadius:`50%`,border:`${i}px solid white`,boxShadow:`0 0 0 1px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(0,0,0,0.3)`}}),(0,Y.jsx)(`div`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,width:`${r}px`,height:`${r}px`,borderRadius:`50%`,backgroundColor:`white`,boxShadow:`0 0 2px rgba(0,0,0,0.5)`}})]})}var Cge=3,wge=400;function cA({url:e,alt:t=``,hotspot:n,className:r,imageClassName:i,onError:a,loading:o}){let[s,c]=(0,b.useState)(0),l=(0,b.useRef)(null);(0,b.useEffect)(()=>{c(0)},[e]),(0,b.useEffect)(()=>()=>{l.current!==null&&clearTimeout(l.current)},[]);let u=(0,b.useCallback)(()=>{if(s>=Cge){a?.();return}l.current!==null&&clearTimeout(l.current),l.current=setTimeout(()=>c(e=>e+1),wge*2**s)},[s,a]),d=s===0?e:`${e}${e.includes(`?`)?`&`:`?`}val_retry=${s}`;return(0,Y.jsx)(`span`,{className:X(`grid h-full w-full place-items-center overflow-hidden`,r),children:(0,Y.jsxs)(`span`,{className:`relative inline-flex max-h-full max-w-full`,children:[(0,Y.jsx)(`img`,{src:d,alt:t,draggable:!1,loading:o,decoding:`async`,onError:u,className:X(`max-h-full max-w-full object-contain`,i)}),n&&(0,Y.jsx)(sA,{hotspot:n})]})})}var lA=48;function Tge(e,t,n){let r=[],i=t.toLowerCase();for(let t of Object.keys(e)){let a=e[t],o=Object.keys(a).filter(e=>{if(!i)return!0;let t=e.split(`/`).pop()||e,n=typeof a[e].alt==`string`?a[e].alt:``;return t.toLowerCase().includes(i)||n.toLowerCase().includes(i)});if(o.length!==0){n&&r.push({kind:`heading`,modulePath:t});for(let e of o)r.push({kind:`entry`,filePath:e,metadata:a[e]||{},modulePath:t})}}return r}function uA({moduleEntries:e,selectedRef:t,onSelect:n,isImage:r=!1,getUrl:i,autoFocus:a=!1,maxHeight:o,onEscape:s}){let[c,l]=b.useState(``),[u,d]=b.useState(-1),f=b.useRef(null),p=b.useRef(null),m=Object.keys(e),h=m.length>1,g=b.useMemo(()=>Tge(e,c,h),[e,c,h]),_=b.useMemo(()=>g.reduce((e,t,n)=>(t.kind===`entry`&&e.push(n),e),[]),[g]),v=tA({count:g.length,getScrollElement:()=>p.current,estimateSize:e=>g[e].kind===`heading`?28:lA,overscan:10});b.useEffect(()=>{d(_.length>0?_[0]:-1)},[c,_]),b.useEffect(()=>{if(a){let e=setTimeout(()=>{f.current?.focus(),v.measure()},100);return()=>clearTimeout(e)}},[a,v]);let y=b.useCallback(e=>{let t=g[e];t?.kind===`entry`&&n({filePath:t.filePath,metadata:t.metadata,modulePath:t.modulePath})},[g,n]),x=b.useCallback(e=>{if(_.length===0)return;let t=_.indexOf(u);if(e.key===`ArrowDown`){e.preventDefault();let n=t<_.length-1?_[t+1]:_[0];d(n),v.scrollToIndex(n,{align:`auto`})}else if(e.key===`ArrowUp`){e.preventDefault();let n=t>0?_[t-1]:_[_.length-1];d(n),v.scrollToIndex(n,{align:`auto`})}else e.key===`Enter`?(e.preventDefault(),u>=0&&y(u)):e.key===`Escape`&&s?.()},[_,u,v,y,s]);if(m.length===0)return null;let S=Object.values(e).reduce((e,t)=>e+Object.keys(t).length,0),C=o??Math.min(S*lA+60,320);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center border-b border-border-primary px-3`,children:[(0,Y.jsx)(My,{className:`mr-2 h-4 w-4 shrink-0 opacity-50`}),(0,Y.jsx)(`input`,{ref:f,value:c,onChange:e=>l(e.target.value),onKeyDown:x,placeholder:r?`Search images...`:`Search files...`,className:`flex h-10 w-full bg-transparent py-3 text-sm outline-none placeholder:text-fg-secondary disabled:cursor-not-allowed disabled:opacity-50`})]}),g.length===0?(0,Y.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-secondary`,children:r?`No images found.`:`No files found.`}):(0,Y.jsx)(`div`,{ref:p,className:`overflow-auto`,style:{maxHeight:C},children:(0,Y.jsx)(`div`,{style:{height:`${v.getTotalSize()}px`,width:`100%`,position:`relative`},children:v.getVirtualItems().map(e=>{let n=g[e.index];if(n.kind===`heading`)return(0,Y.jsx)(`div`,{className:`absolute left-0 top-0 w-full px-3 py-1 text-xs font-medium text-fg-secondary`,style:{transform:`translateY(${e.start}px)`,height:`${e.size}px`},children:nA(n.modulePath)},`heading-${n.modulePath}`);let a=n.filePath.split(`/`).pop()||n.filePath,o=t===n.filePath,s=e.index===u,c=typeof n.metadata.alt==`string`?n.metadata.alt:void 0,l=typeof n.metadata.mimeType==`string`?n.metadata.mimeType:void 0;return(0,Y.jsxs)(`div`,{className:X(`absolute left-0 top-0 flex w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm`,s&&`bg-bg-primary-hover text-fg-primary`),style:{transform:`translateY(${e.start}px)`,height:`${e.size}px`},onMouseEnter:()=>d(e.index),onClick:()=>y(e.index),children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,o?`opacity-100`:`opacity-0`)}),r&&l?.startsWith(`image/`)?(0,Y.jsx)(cA,{url:i?i(n.filePath):aA(n.filePath),alt:c||a,loading:`lazy`,className:`h-8 w-8 shrink-0 rounded bg-bg-secondary`}):(0,Y.jsx)(`div`,{className:`h-8 w-8 shrink-0 flex items-center justify-center rounded bg-bg-secondary`,children:r?(0,Y.jsx)(sy,{className:`h-4 w-4 text-fg-secondary`}):(0,Y.jsx)(ey,{className:`h-4 w-4 text-fg-secondary`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:a}),c&&(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary truncate`,children:c})]})]},n.filePath)})})})]})}function Ege({disabled:e=!1,portalContainer:t,selectedRef:n,isImage:r=!1,moduleEntries:i,onSelect:a,getUrl:o,compact:s,footer:c}){let[l,u]=b.useState(!1);if(Object.keys(i).length===0)return null;let d=n?n.split(`/`).pop()||n:null;return(0,Y.jsxs)(SD,{open:l,onOpenChange:u,children:[(0,Y.jsx)(CD,{asChild:!0,children:s?(0,Y.jsxs)(t_,{variant:`outline`,size:`sm`,role:`combobox`,"aria-label":`Choose asset`,"aria-expanded":l,disabled:e,children:[(0,Y.jsx)(cae,{className:`mr-1.5 h-3.5 w-3.5 shrink-0`}),`Choose asset`]}):(0,Y.jsxs)(t_,{variant:`outline`,role:`combobox`,"aria-expanded":l,className:`w-full justify-between`,disabled:e,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:d||(r?`Select from gallery...`:`Select from files...`)}),(0,Y.jsx)(zv,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,Y.jsxs)(wD,{className:s?`w-[22rem] p-0`:`w-[var(--radix-popover-trigger-width)] p-0`,container:t,children:[(0,Y.jsx)(uA,{moduleEntries:i,selectedRef:n,isImage:r,getUrl:o,autoFocus:l,onSelect:e=>{a(e),u(!1)},onEscape:()=>u(!1)}),c&&(0,Y.jsx)(`div`,{className:`border-t border-border-primary p-2`,children:c})]})]})}function dA({modulePath:e,...t}){let{moduleEntries:n,getUrl:r,ready:i}=iA(e);return!i||!n?null:(0,Y.jsx)(Ege,{moduleEntries:n,getUrl:r,...t})}var fA={quality:.8,maxWidth:2560,maxHeight:2560},Dge={webp:`image/webp`},pA=[`image/svg+xml`,`image/gif`,`image/avif`];function mA(e,t){return e!==void 0&&Number.isFinite(e)&&e>0?e:t}function hA(e,t){let n=e===void 0?t:e;if(!n)return null;let r=n.quality;return{type:n.type,quality:r!==void 0&&Number.isFinite(r)&&r>0?Math.min(r,1):fA.quality,maxWidth:mA(n.maxWidth,fA.maxWidth),maxHeight:mA(n.maxHeight,fA.maxHeight)}}function Oge(e,t,n,r){if(!(e>0)||!(t>0)||!(n>0)||!(r>0)||e<=n&&t<=r)return null;let i=Math.min(n/e,r/t);return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}function kge(e,t){return!t||t.split(`,`).map(e=>e.trim()).some(t=>t===`*/*`?!0:t.endsWith(`/*`)?e.startsWith(t.slice(0,-2)):t===e)}function Age(e,t,n){return pA.includes(e)?!0:e===t&&!n}function jge(e){return e.encodedSize===null||e.encodedType!==e.targetMimeType?!1:e.needsDownscale?!0:e.encodedSize<e.originalSize}function Mge(e,t){return`${e.split(`.`).slice(0,-1).join(`.`)||e}.${t}`}function Nge(e,t,n){return new Promise(r=>e.toBlob(r,t,n))}async function Pge(e,t,n){if(t===null)return e;let r=Dge[t.type];if(pA.includes(e.type)||!kge(r,n)||typeof createImageBitmap!=`function`)return e;let i;try{i=await createImageBitmap(e,{imageOrientation:`from-image`});let n=Oge(i.width,i.height,t.maxWidth,t.maxHeight),a=n!==null;if(Age(e.type,r,a))return e;let o=document.createElement(`canvas`);o.width=n?.width??i.width,o.height=n?.height??i.height;let s=o.getContext(`2d`);if(!s)return e;s.drawImage(i,0,0,o.width,o.height);let c=await Nge(o,r,t.quality);return!c||!jge({originalSize:e.size,encodedSize:c.size,encodedType:c.type,targetMimeType:r,needsDownscale:a})?e:new File([c],Mge(e.name,t.type),{type:r})}catch(t){return console.error(`Could not re-encode image, uploading the original`,t),e}finally{i?.close()}}function gA(e,t){return!t||t.settings===null?_A(e):Pge(e,t.settings,t.accept).then(_A)}function _A(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`load`,()=>{let i=r.result;if(typeof i==`string`){let n=new Image;n.addEventListener(`load`,()=>{let r=Xr(i),a=H.getSHA256Hash(r);if(n.naturalWidth&&n.naturalHeight){let r=H.getMimeType(i);t({src:i,width:n.naturalWidth,height:n.naturalHeight,filename:e.name,fileHash:a,mimeType:r,fileExt:r&&H.mimeTypeToFileExt(r)})}else t({src:i,filename:e.name,fileHash:a})}),n.src=i}else n(i?{message:`Unexpected image result type`,result:i}:{message:`Empty result`})}),r.readAsDataURL(e)})}function Fge(e,t){return new Promise((n,r)=>{let i=e.currentTarget.files?.[0];if(!i){r({message:`No file selected`});return}gA(i,t).then(n).catch(r)})}function vA(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`load`,()=>{let i=r.result;if(typeof i==`string`){let n=Xr(i),r=H.getSHA256Hash(n),a=H.getMimeType(i);t({src:i,filename:e.name,fileHash:r,mimeType:a,fileExt:a&&H.mimeTypeToFileExt(a)})}else n(i?{message:`Unexpected file result type`,result:i}:{message:`Empty result`})}),r.readAsDataURL(e)})}function yA(e){return new Promise((t,n)=>{let r=e.currentTarget.files?.[0];if(!r){n({message:`No file selected`});return}vA(r).then(t).catch(n)})}function bA(e){return e.split(`.`).pop()||``}function xA({url:e,name:t,detail:n,hotspot:r,actions:i,uploading:a,progressPercentage:o,isImage:s=!0,onOpenPreview:c}){let l=s?sy:ey,u=X(`relative grid h-[4.5rem] w-[7.5rem] shrink-0 place-items-center`,`overflow-hidden rounded-md border border-border-primary bg-bg-secondary`,c&&`cursor-zoom-in hover:border-border-focus`),d=(0,Y.jsxs)(Y.Fragment,{children:[s&&e?(0,Y.jsx)(cA,{url:e,hotspot:r}):(0,Y.jsx)(l,{size:20,strokeWidth:1.5,className:`text-fg-secondary-alt`}),a&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 grid place-items-center bg-bg-secondary/70`,children:[(0,Y.jsx)(hy,{size:18,className:`animate-spin text-fg-primary`}),o!=null&&(0,Y.jsxs)(`span`,{className:`absolute bottom-1 text-[0.625rem] tabular-nums text-fg-primary`,children:[o,`%`]})]})]});return(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[c?(0,Y.jsx)(`button`,{type:`button`,onClick:c,"aria-label":s?`View image`:`View file`,className:u,children:d}):(0,Y.jsx)(`div`,{className:u,children:d}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-2`,children:[t?(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`truncate text-xs font-medium text-fg-primary`,children:t}),n&&(0,Y.jsx)(`p`,{className:`mt-0.5 truncate text-[0.6875rem] text-fg-secondary-alt`,children:n})]}):(0,Y.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:s?`No image yet`:`No file yet`}),(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:i})]})]})}function SA({label:e,hint:t,summary:n,collapsible:r,children:i}){let[a,o]=(0,b.useState)(!1);return r?(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-1.5 text-left`,children:[(0,Y.jsx)(Rv,{size:13,className:X(`shrink-0 text-fg-secondary-alt transition-transform`,a&&`rotate-90`)}),(0,Y.jsx)(`h3`,{className:`text-xs font-medium text-fg-primary`,children:e}),n&&!a&&(0,Y.jsx)(`span`,{className:`ml-auto truncate text-[0.6875rem] text-fg-secondary-alt`,children:n})]}),a&&(0,Y.jsxs)(`div`,{className:`mt-2`,children:[t&&(0,Y.jsx)(`p`,{className:`mb-2 text-[0.6875rem] text-fg-secondary-alt`,children:t}),i]})]}):(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{className:`text-xs font-medium text-fg-primary`,children:e}),t&&(0,Y.jsx)(`p`,{className:`mb-2 mt-0.5 text-[0.6875rem] text-fg-secondary-alt`,children:t}),i]})}function Ige(e){return e.replace(/\.[^.]+$/,``).replace(/_[0-9a-f]{5}$/,``).replace(/[-_]+/g,` `).trim()}var Lge=new TextEncoder;async function CA(e,t,n,r,i,a,o,s=`/public/val`,c=!1){let l=H.createFilename(t,n,i,r);if(!l||!i)return{patch:[],filePath:``};let u=`${s}/${l}`,d=H.remote.hashToRemoteFileHash(r),f=o?H.remote.createRemoteRef(o.remoteHost,{publicProjectId:o.publicProjectId,coreVersion:o.coreVersion,bucket:o.bucket,validationHash:H.remote.getValidationHash(o.coreVersion,o.schema,bA(l),i,d,Lge),fileHash:d,filePath:`${(s??`/public/val`).slice(1)}/${l}`}):u;return{patch:[{value:{path:f,...c?{}:i},op:`replace`,path:e},{value:t,metadata:i,op:`file`,path:e,filePath:f,remote:o!==null}],filePath:u}}function Rge({path:e,readonly:t}){let n=`file`,r=bb(),i=SS(),a=xS(),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(!1),{source:m,schema:h,addPatch:g,patchPath:_,addAndUploadPatchWithFileOps:v,addModuleFilePatch:y}=yb(e,n),x=eb(),S=(0,b.useRef)(null),[C,w]=(0,b.useState)(null),T=Mb(),E=`data`in m&&m.data,D=m.status===`success`&&m.clientSideOnly;(0,b.useEffect)(()=>{if(E&&!D){let e=T.get(E.path);d(H.mediaUrl({path:E.path,...e?{patch_id:e}:{}})),p(!1)}},[m,T]),(0,b.useEffect)(()=>{h.status===`success`&&h.data.type===`file`&&h.data.options?.accept?.startsWith(`video/`)&&s(!0),E&&typeof E.mimeType==`string`&&(E.mimeType.startsWith(`video/`)?s(!0):s(!1))},[h,E]);let O=h.status===`success`&&h.data.type===`file`?h.data:void 0,k=O?.referencedModule,A=Tb(k),j=(0,b.useMemo)(()=>{if(O){if(O.options?.accept)return O.options.accept;if(k&&A?.type===`record`&&A.accept)return A.accept}},[O,k,A]),M=(0,b.useMemo)(()=>A?.type===`record`?A.directory:void 0,[A]);if(h.status===`error`)return(0,Y.jsx)(NC,{path:e,error:h.error,type:n});if(m.status===`error`)return(0,Y.jsx)(FC,{path:e,error:m.error,schema:h});if(m.status==`not-found`||h.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(h.status===`loading`||r===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(h.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:h.data.type});let N=m.data;if(N===void 0)return(0,Y.jsx)(MC,{path:e,type:n});let P=h.data.type===`file`&&h.data.remote&&a.status!==`ready`,F=k&&A===void 0?[k]:[],I=t||P||F.length>0,L=h.data.remote&&a.status===`ready`&&i?{publicProjectId:a.publicProjectId,coreVersion:a.coreVersion,bucket:i,schema:h.data,remoteHost:r.remoteHost}:null,R=null;if(N?.path){if(h.data.remote){let e=H.remote.splitRemoteRef(N.path);e.status===`success`&&(R=e.filePath)}else R=N.path}let ee=null;R&&(ee=R.split(`/`).slice(-1)[0]);let te=typeof N?.mimeType==`string`?N.mimeType:null;return(0,Y.jsxs)(`div`,{id:e,children:[F.length>0&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:F.length===1?`The module '${F[0]}' is referenced by this field but is not added to val.modules. Add it to val.modules to enable uploads.`:`The following modules are referenced by this field but are not added to val.modules: ${F.join(`, `)}. Add them to val.modules to enable uploads.`}),c&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:c}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsx)(xA,{url:u,name:ee,detail:te,isImage:!1,uploading:f,progressPercentage:C,actions:(0,Y.jsxs)(Y.Fragment,{children:[!k&&(0,Y.jsxs)(t_,{variant:`outline`,size:`sm`,disabled:I,onClick:()=>S.current?.click(),children:[(0,Y.jsx)(By,{className:`mr-1.5 h-3.5 w-3.5`}),N?`Replace`:`Choose asset`]}),N&&(0,Y.jsxs)(`a`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-secondary underline underline-offset-2 hover:text-fg-primary`,target:`_blank`,rel:`noopener noreferrer`,download:ee??void 0,href:H.mediaUrl(N),children:[`Open file`,(0,Y.jsx)(kae,{size:12})]}),k&&(0,Y.jsx)(dA,{compact:!0,footer:(0,Y.jsxs)(`button`,{type:`button`,disabled:I,onClick:()=>S.current?.click(),className:X(`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-xs`,`text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Y.jsx)(By,{size:13}),`Upload into `,nA(k)]}),modulePath:k,selectedRef:N?.path??null,onSelect:e=>{g([{op:`replace`,path:_,value:{path:e.filePath}}],`file`)},isImage:!1,disabled:I,portalContainer:x})]})}),N&&o&&(0,Y.jsx)(`video`,{className:`w-full h-auto rounded-lg`,controls:!0,src:H.mediaUrl(N)}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(`input`,{disabled:I,hidden:!0,ref:S,id:`file_input:${e}`,type:`file`,accept:j,onChange:e=>{yA(e).then(t=>{let n=`file`,r=u;d(t.src),p(!0);let i={src:t.src,filename:t.filename},a;t.mimeType&&(a={mimeType:t.mimeType}),l(null),CA(_,i.src,i.filename??null,t.fileHash,a,n,L,M,!!k).then(({patch:e,filePath:t})=>{p(!0),w(0);let i=!1;v(e,n,e=>{i=!0,d(r),l(e)},(e,t,n,r)=>{let i=e*(n+1)/(t*r);w(Math.round(i*100))}).then(()=>{!i&&k&&t&&a?.mimeType&&y(k,[{op:`add`,path:[t],value:{mimeType:a.mimeType}}],`record`)}).finally(()=>{w(null),p(!1)})}).catch(e=>{console.error(`Failed to create file patch`,e),p(!1),d(r),l(`Could not upload file. Please try again later`)}),e.target.value=``})}})})]})]})}function zge({path:e}){let t=Ob(e,`image`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(ey,{size:12})}function Bge(e){let[t,n]=(0,b.useState)(!1),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null);return{uploadImage:(0,b.useCallback)(async t=>{i(null),n(!0),o(0);try{let r=await gA(t,e.encode),a;r.width&&r.height&&r.mimeType&&(a={width:r.width,height:r.height,mimeType:r.mimeType,alt:e.existingAlt});let{patch:s,filePath:c}=await CA(e.patchPath,r.src,r.filename??null,r.fileHash,a,`image`,e.remoteData,e.directory,!!e.referencedModule);if(s.length===0)return n(!1),o(null),i(`Could not process image file`),null;let l=s[0]&&`value`in s[0]&&typeof s[0].value==`object`&&s[0].value!==null&&`path`in s[0].value?s[0].value.path:c,u=e.fileUploadOnly?s.filter(e=>e.op===`file`):s;return await new Promise(t=>{let r=!1;e.addAndUploadPatchWithFileOps(u,`image`,e=>{r=!0,i(e),n(!1),o(null),t(null)},(e,t,n,r)=>{let i=(n*t+e)/(r*t);o(Math.round(i*100))}).then(()=>{r||(e.referencedModule&&c&&a?.mimeType&&a.width!==void 0&&a.height!==void 0&&e.addModuleFilePatch(e.referencedModule,[{op:`add`,path:[c],value:{width:a.width,height:a.height,mimeType:a.mimeType,alt:typeof a.alt==`string`?a.alt:null}}],`record`),t({filePath:c,ref:l}))}).finally(()=>{o(null),n(!1)})})}catch(e){return console.error(`Failed to upload image`,e),n(!1),o(null),i(`Could not upload file. Please try again later`),null}},[e]),loading:t,error:r,progressPercentage:a}}function Vge({path:e,readonly:t,hideUpload:n}){let r=`image`,i=bb(),a=xS(),o=SS(),{source:s,schema:c,addPatch:l,patchPath:u,addAndUploadPatchWithFileOps:d,addModuleFilePatch:f}=yb(e,r),[p,m]=(0,b.useState)(void 0),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(!1),y=eb(),x=(0,b.useRef)(null),S=Mb(),C=`data`in s&&s.data,w=s.status===`success`&&s.clientSideOnly;(0,b.useEffect)(()=>{if(C){if(!w){let e=S.get(C.path);g(H.mediaUrl({path:C.path,...e?{patch_id:e}:{}}))}let e=C.hotspot;e?typeof e.x==`number`&&typeof e.y==`number`?m({x:e.x,y:e.y}):console.warn(`Expected hotspot to have x and y as numbers but x was: ${typeof e.x} and y: ${typeof e.y}`):m(void 0)}},[s,S]);let T=c.status===`success`&&c.data.type===`image`?c.data:void 0,E=T?.referencedModule,D=Tb(E),O=(0,b.useMemo)(()=>{if(T){if(T.options?.accept)return T.options.accept;if(E&&D?.type===`record`&&D.accept)return D.accept}},[T,E,D]),k=(0,b.useMemo)(()=>T?.options?.directory?T.options.directory:D?.type===`record`?D.directory:void 0,[T,D]),A=(0,b.useMemo)(()=>{let e=D?.type===`record`?D.encode:void 0;return{settings:hA(T?.options?.encode,e),accept:O}},[T,D,O]),j=C&&typeof C.alt==`string`?C.alt:void 0,{uploadImage:M,loading:N,error:P,progressPercentage:F}=Bge({patchPath:u,addAndUploadPatchWithFileOps:d,addModuleFilePatch:f,remoteData:T?.remote&&a.status===`ready`&&o&&i?{publicProjectId:a.publicProjectId,bucket:o,coreVersion:a.coreVersion,schema:T,remoteHost:i.remoteHost}:null,directory:k,referencedModule:E,existingAlt:j,encode:A});if(c.status===`error`)return(0,Y.jsx)(NC,{path:e,error:c.error,type:r});if(s.status===`error`)return(0,Y.jsx)(FC,{path:e,error:s.error,schema:c});if(s.status==`not-found`||c.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:r});if(c.status===`loading`||i===void 0)return(0,Y.jsx)(jC,{path:e,type:r});if(c.data.type!==r)return(0,Y.jsx)(PC,{path:e,expectedType:r,actualType:c.data.type});let I=s.data;if(I===void 0)return(0,Y.jsx)(MC,{path:e,type:r});let L=c.data.type===`image`&&c.data.remote&&a.status!==`ready`,R=E&&D===void 0?[E]:[],ee=t||L||R.length>0,te=I?I.path.split(`/`).pop()??I.path:null,ne=(()=>{if(!I)return null;let{width:e,height:t,mimeType:n}=I,r=[];return typeof e==`number`&&typeof t==`number`&&r.push(`${e} × ${t}`),typeof n==`string`&&r.push(n),r.length>0?r.join(` · `):null})(),re=typeof I?.alt==`string`?I.alt:``,ie=e=>{I&&l([{op:`add`,value:e,path:u.concat([`alt`])}],`string`)},ae=H.createValPathOfItem(e,`alt`),oe=H.createValPathOfItem(e,`hotspot`);return(0,Y.jsxs)(`div`,{id:e,children:[R.length>0&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:R.length===1?`The module '${R[0]}' is referenced by this field but is not added to val.modules. Add it to val.modules to enable uploads.`:`The following modules are referenced by this field but are not added to val.modules: ${R.join(`, `)}. Add them to val.modules to enable uploads.`}),P&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:P}),c.data.type===`image`&&c.data.remote&&a.status===`inactive`&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:Hge(a.reason)}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsx)(xA,{url:h,name:te,detail:ne,hotspot:p,onOpenPreview:h?()=>v(!0):void 0,uploading:N,progressPercentage:F,actions:(0,Y.jsxs)(Y.Fragment,{children:[!n&&E&&(0,Y.jsx)(dA,{compact:!0,footer:(0,Y.jsxs)(`button`,{type:`button`,disabled:ee,onClick:()=>x.current?.click(),className:X(`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-xs`,`text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Y.jsx)(By,{size:13}),`Upload into `,nA(E)]}),modulePath:E,selectedRef:I?.path??null,onSelect:e=>{l([{op:`replace`,path:u,value:{path:e.filePath}}],`image`)},isImage:!0,disabled:ee,portalContainer:y}),!n&&(0,Y.jsxs)(Y.Fragment,{children:[!E&&(0,Y.jsxs)(t_,{variant:`outline`,size:`sm`,disabled:ee,onClick:()=>x.current?.click(),children:[(0,Y.jsx)(By,{className:`mr-1.5 h-3.5 w-3.5`}),h?`Replace`:`Choose asset`]}),(0,Y.jsx)(`input`,{disabled:ee,hidden:!0,ref:x,id:`img_input:${e}`,type:`file`,accept:O??`image/*`,onChange:e=>{let t=e.currentTarget.files?.[0];if(!t)return;let n=h;M(t).then(e=>{e||g(n)}),e.target.value=``}})]})]})}),I&&!E&&(0,Y.jsxs)(SA,{label:`Description`,hint:`What the image shows, for people who cannot see it.`,children:[(0,Y.jsx)(`span`,{id:ae,className:`sr-only`,children:`Description`}),(0,Y.jsx)(MT,{value:re,disabled:ee,onChange:e=>ie(e.target.value)}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[re===``&&(0,Y.jsx)(`span`,{className:`text-[0.6875rem] text-fg-error-on-surface`,children:`Missing`}),!ee&&te&&re===``&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ie(Ige(te)),className:`text-[0.6875rem] text-fg-secondary underline underline-offset-2 hover:text-fg-primary`,children:`Use the filename`})]})]}),I&&h&&(0,Y.jsxs)(SA,{label:`Focal point`,hint:`Click the image to say what must stay in frame when the page crops it.`,collapsible:!0,summary:p?`${Math.round(p.x*100)}%, ${Math.round(p.y*100)}%`:`Not set`,children:[I&&h&&(0,Y.jsxs)(`div`,{className:`relative rounded-lg bg-bg-secondary`,children:[N&&(0,Y.jsxs)(`div`,{className:`flex absolute inset-0 flex-col justify-center items-center`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 w-full h-full opacity-50 bg-bg-secondary`}),(0,Y.jsx)(hy,{size:24,className:`animate-spin`}),(0,Y.jsx)(`div`,{className:`mt-2 text-xs font-thin text-[white] z-5`,children:F===null?``:`${F}%`})]}),(0,Y.jsx)(`img`,{src:h,draggable:!1,className:`object-contain max-h-[500px] w-full`,style:{cursor:t?`default`:`crosshair`},id:oe,onClick:e=>{if(t)return;let{width:n,height:r,left:i,top:a}=e.currentTarget.getBoundingClientRect(),o={x:Math.max((e.clientX-6-i)/n,0),y:Math.max((e.clientY-6-a)/r,0)};l([{op:`add`,path:u.concat([`hotspot`]),value:o}],`object`)}}),p&&(0,Y.jsx)(sA,{hotspot:p})]}),I&&h&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(UT,{id:`hotspot_toggle:${e}`,checked:!!p,disabled:ee,onCheckedChange:e=>{e?l([{op:`add`,path:u.concat([`hotspot`]),value:{x:.5,y:.5}}],`object`):I.hotspot&&l([{op:`remove`,path:u.concat([`hotspot`])}],`object`)}}),(0,Y.jsxs)(`label`,{htmlFor:`hotspot_toggle:${e}`,className:`text-xs text-fg-secondary select-none`,children:[`Hotspot`,p&&(0,Y.jsxs)(`span`,{className:`ml-1 text-fg-tertiary`,children:[`(`,Math.round(p.x*100),`%,`,` `,Math.round(p.y*100),`%)`]})]})]})]})]}),h&&(0,Y.jsx)(Uy,{open:_,onOpenChange:v,children:(0,Y.jsxs)(Ky,{container:y,className:`max-h-[90vh] max-w-[90vw] overflow-hidden p-0`,children:[(0,Y.jsx)(Yy,{className:`sr-only`,children:te??`Image`}),(0,Y.jsxs)(`div`,{className:`relative inline-flex bg-bg-secondary`,children:[(0,Y.jsx)(`img`,{src:h,alt:re,className:`max-h-[85vh] max-w-full object-contain`}),p&&(0,Y.jsx)(sA,{hotspot:p})]})]})})]})}function Hge(e){switch(e){case`api-key-missing`:return`Val is running in production mode. To upload remote files and images, the VAL_API_KEY env must be set. Contact a developer to fix this issue.`;case`error-could-not-get-settings`:return`Could not get settings from the Val remote server. This means that updating or changing certain types of files and images might not work. Check your internet connection and try again. (Error code: ${e})`;case`no-internet-connection`:return`Cannot upload remote files and images, since this requires an internet connection`;case`pat-error`:return"Val is running in development mode. To upload remote files and images, you must either login (by running `npx -p @valbuild/cli val login`) or set the VAL_API_KEY env";case`project-not-configured`:return`Project is not configured. To upload remote files and images, the val.config must contain a project id that is obtained from https://admin.val.build. Contact a developer to fix this issue.`;case`unauthorized`:return`Cannot upload remote files and images since you are unauthorized`;case`unauthorized-personal-access-token-error`:return"Cannot upload remote files and images since the personal access token is unauthorized. Try to login again by running `npx -p @valbuild/cli val login`";case`unknown-error`:return`Unknown error`;default:return e}}function Uge({path:e}){let t=Ob(e,`image`);if(t.status===`error`)return(0,Y.jsx)(FC,{path:e,error:t.error});if(!(`data`in t)||t.data===void 0)return(0,Y.jsx)(J3,{path:e});if(t.data===null)return(0,Y.jsx)(Y3,{path:e});let n=t.data;return(0,Y.jsx)(`img`,{src:H.mediaUrl(n),draggable:!1,className:`object-contain max-w-[60px] max-h-[60px] rounded-lg`})}function Wge({keys:e,previews:t,value:n,onChange:r,placeholder:i=`Select key...`,className:a,portalContainer:o,isLoading:s=!1}){let[c,l]=b.useState(!1),u=n?t?.[n]:void 0;return(0,Y.jsxs)(SD,{open:c,onOpenChange:l,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,role:`combobox`,"aria-expanded":c,className:X(`w-full justify-start text-left border border-border-primary bg-bg-primary hover:bg-bg-primary-hover h-auto py-1.5`,a),children:[n?u?(0,Y.jsx)(dk,{title:u.title,subtitle:u.subtitle??null,image:u.image??null}):(0,Y.jsx)(`span`,{className:`truncate flex-1`,children:n}):(0,Y.jsx)(`span`,{className:`truncate flex-1`,children:i}),(0,Y.jsx)(zv,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,Y.jsx)(wD,{className:`w-[var(--radix-popover-trigger-width)] p-0`,container:o,children:(0,Y.jsxs)(ik,{children:[(0,Y.jsx)(ak,{placeholder:`Search key...`}),(0,Y.jsx)(ok,{children:s?(0,Y.jsx)(`div`,{className:`py-6 text-center text-sm`,children:`Loading...`}):e.length===0?(0,Y.jsx)(sk,{children:`No keys found.`}):(0,Y.jsx)(ck,{children:e.map(e=>{let i=t?.[e],a=i?`${e} ${i.title}`:e;return(0,Y.jsxs)(uk,{value:a,onSelect:()=>{r(e),l(!1)},className:`flex items-center gap-2`,children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,n===e?`opacity-100`:`opacity-0`)}),i?(0,Y.jsx)(dk,{title:i.title,subtitle:i.subtitle??null,image:i.image??null}):(0,Y.jsx)(`span`,{className:`truncate`,children:e})]},e)})})})]})})]})}function Gge({path:e,readonly:t}){let n=`keyOf`,{navigate:r}=GC(),i=Cb(e),a=`data`in i&&i.data&&i.data.type===`keyOf`?{type:i.data.schema?.type,path:i.data.path}:void 0,o=Ob(a?.path,a?.type),s=xb(a?.path??e),c=`data`in i&&i.data?.type===`keyOf`&&i.data.render?.as===`inline`,l=Cb(a?.path??e),u=Ob(e,n),{patchPath:d,addPatch:f}=vb(e),p=eb();if(i.status===`error`)return(0,Y.jsx)(NC,{path:e,error:i.error,type:n});if(u.status===`error`)return(0,Y.jsx)(FC,{path:e,error:u.error,schema:i});if(o.status===`error`)return(0,Y.jsx)(FC,{path:e,error:o.error,schema:i});if(u.status==`not-found`||i.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(a!==void 0&&a.type!==`record`&&a.type!==`object`)return(0,Y.jsx)(NC,{path:a.path,error:`Cannot refer to keyOf type: ${a.type}. Must refer to be record or object`});if(a!==void 0&&o.status===`not-found`)return(0,Y.jsx)(NC,{path:a.path,error:`Referenced source not found`,type:a.type});if(!(`data`in u)||u.data===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(`data`in i&&i.data&&i.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:i.data.type});if(!o)return(0,Y.jsx)(NC,{path:a?.path,error:`Referenced source not found`,type:`keyOf`});if(`data`in o&&o.data===null)return(0,Y.jsx)(NC,{path:a?.path,error:`Referenced source is null`,type:`keyOf`});let m=`data`in o&&o.data?Object.keys(o.data):void 0,h=u.data,g=Kge(s),_=i.status===`loading`||a===void 0||m===void 0,v=c&&`data`in l?l.data?.type===`record`?l.data.item:l.data?.type===`object`&&h!==null?l.data.items[h]:void 0:void 0,y=c&&a?.path&&h!==null?H.createValPathOfItem(a.path,h):void 0,b=(0,Y.jsxs)(`div`,{id:e,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Y.jsx)(Wge,{keys:m??[],previews:g,value:h,onChange:e=>{f([{op:`replace`,path:d,value:e}],n)},portalContainer:p,isLoading:_}),h&&a?.path&&(0,Y.jsx)(`button`,{title:`Go to reference`,className:`px-2`,onClick:()=>{r(H.createValPathOfItem(a.path,h))},children:(0,Y.jsx)(dy,{size:16})})]}),c&&y!==void 0&&v!==void 0&&(0,Y.jsxs)(`div`,{className:`mt-2 rounded-md border border-border-primary p-3`,children:[(0,Y.jsx)(`div`,{className:`pb-2 text-xs text-fg-quaternary truncate`,children:h}),(0,Y.jsx)(r6,{path:y,schema:v,readonly:t===!0,compact:!0})]})]});return t?(0,Y.jsx)(NT,{children:b}):b}function Kge(e){if(!e||!(`data`in e)||!e.data)return;let t=e.data;if(t.parent!==`record`)return;let n={};for(let[e,r]of t.items)n[e]={title:r.title,subtitle:r.subtitle??null,image:r.image??null};return n}function qge({path:e}){let t=Ob(e,`keyOf`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{className:`truncate`,children:t.data})}var wA=new WeakMap;function Jge(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].route!==t[n].route||e[n].moduleFilePath!==t[n].moduleFilePath)return!1;return!0}var Yge=[];function Xge(e){if(e===null)return Yge;let t=e.system.sourceStore.sourcesVersion(),n=e.system.schemaStore.all(),r=Object.keys(n).length,i=wA.get(e.system);if(i!==void 0&&i.version===t&&i.schemas===r)return i.routes;let a=sp(n,e.system.sourceStore.allSources()),o=i!==void 0&&Jge(i.routes,a)?i.routes:a;return wA.set(e.system,{version:t,schemas:r,routes:o}),o}function Zge(){let e=nb(),t=(0,b.useCallback)(t=>{if(e===null)return()=>{};let n=e.system.sourceStore.events.on(`source:change`,t),r=e.system.schemaStore.events.on(`schema:init`,t);return()=>{n(),r()}},[e]),n=(0,b.useCallback)(()=>Xge(e),[e]);return(0,b.useSyncExternalStore)(t,n,n)}function TA(){return Zge()}var Qge=`external-url-router`;function $ge(e){return e?.type===`record`&&typeof e.router==`string`}function e_e(e){return e.length===0?`/`:e.map(e=>e.type===`literal`?`/${e.name}`:e.type===`array-param`?`/[...${e.paramName}]`:`/[${e.paramName}]`).join(``)}function t_e(e){return e.replace(/^\/(src\/)?app/,``).replace(/\/page\.val\.[tj]sx?$/,``).replace(/\.val\.[tj]sx?$/,``)}function n_e(e,t){let n=[],r=null;for(let i in e){let a=i,o=e[a];if(!$ge(o))continue;let s=t[a],c=s&&typeof s==`object`&&!Array.isArray(s)?Object.keys(s):[],l=np(t_e(a)),u={moduleFilePath:a,routerId:o.router,routePattern:l,patternString:e_e(l),existingKeys:c,keyDescription:o.key?.description};o.router===Qge?r??=u:n.push(u)}return n.sort((e,t)=>e.patternString.localeCompare(t.patternString)),{pageRouters:n,externalRouter:r}}function r_e(){let e=wb(),t=Eb();return(0,b.useMemo)(()=>!(`data`in e)||e.data===void 0?{pageRouters:[],externalRouter:null}:n_e(e.data,t),[e,t])}function i_e(){let{addModuleFilePatch:e}=LS(),t=wb();return(0,b.useCallback)((n,r)=>{if(!(`data`in t)||t.data===void 0)return console.error(`Cannot create route entry: schemas are not loaded`),null;let i=t.data[n.moduleFilePath];return i?.type===`record`?(e(n.moduleFilePath,[{op:`add`,path:H.createPatchPath(``).concat(r),value:Cp(i.item)}],`record`),r):(console.error(`Cannot create route entry: not a record`,{moduleFilePath:n.moduleFilePath,schema:i}),null)},[e,t])}function EA({routes:e,onSubmit:t,onCancel:n,currentPage:r}){let i=(0,b.useMemo)(()=>a_e(e,r),[e,r]),[a,o]=(0,b.useState)(null),s=(0,b.useMemo)(()=>e.find(e=>DA(e)===a)??i??null,[e,a,i]),c=s?DA(s):``,[l,u]=(0,b.useState)({}),[d,f]=(0,b.useState)({}),p=s?l[DA(s)]??{}:{},m=s?d[DA(s)]??{}:{},h=(0,b.useMemo)(()=>s?s_e(s.routePattern,p):``,[s,p]),g=(0,b.useMemo)(()=>s?s.routePattern.every(e=>e.type===`string-param`||e.type===`array-param`?p[e.paramName]?!m[e.paramName]:e.optional:!0):!1,[s,p,m]),_=!!s&&s.existingKeys.includes(h),v=!g||_,y=s?DA(s):``;return s?(0,Y.jsxs)(`form`,{className:`p-3 space-y-3`,onSubmit:e=>{e.preventDefault(),!v&&t(s.moduleFilePath,h)},children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg-primary`,children:`New page`}),e.length>1?(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`label`,{className:`text-xs text-fg-secondary`,children:`Route`}),(0,Y.jsx)(p_e,{routes:e,value:c,onChange:o})]}):(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Route`}),(0,Y.jsx)(c_e,{pattern:s.routePattern})]}),s.keyDescription&&(0,Y.jsx)(`div`,{className:`max-w-[240px] text-pretty text-xs text-fg-tertiary`,children:s.keyDescription}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`URL`}),(0,Y.jsx)(l_e,{pattern:s.routePattern,params:p,errors:m,onChange:(e,t,n)=>{let r=DA(s);u(n=>({...n,[r]:{...n[r]??{},[e]:t}})),f(t=>({...t,[r]:{...t[r]??{},[e]:n}}))}},y),(0,Y.jsx)(f_e,{pattern:s.routePattern})]}),_&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-error-on-surface`,children:`A page with this path already exists`}),(0,Y.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[(0,Y.jsx)(t_,{size:`sm`,variant:`ghost`,type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsx)(t_,{size:`sm`,disabled:v,type:`submit`,children:`Create`})]})]}):(0,Y.jsx)(`div`,{className:`p-3 text-sm text-fg-secondary`,children:`No routes accept new pages.`})}function DA(e){return e?`${e.moduleFilePath}::${e.patternString}`:``}function a_e(e,t){if(!t)return e[0];let n=e[0],r=0;for(let i of e){let e=i.moduleFilePath===t.moduleFilePath,a=(o_e(i.routePattern,t.urlPath)?2:0)+ +!!e;a>r&&(n=i,r=a)}return n}function o_e(e,t){let n=t.split(`/`).filter(e=>e!==``),r=0;for(let t of e){if(t.type===`array-param`)return n.length-r!==0||t.optional;if(t.type===`string-param`){if(r>=n.length){if(!t.optional)return!1;continue}r++;continue}if(n[r]!==t.name)return!1;r++}return r===n.length}function s_e(e,t){let n=[];for(let r of e){if(r.type===`string-param`||r.type===`array-param`){let e=t[r.paramName];if(!e){if(r.optional)continue;n.push(``);continue}n.push(e);continue}n.push(r.name)}return n.length===0?`/`:`/`+n.join(`/`)}function c_e({pattern:e}){return(0,Y.jsxs)(`div`,{className:`flex items-center flex-wrap gap-0 px-2 py-1.5 rounded-md bg-bg-secondary font-mono text-xs text-fg-primary`,children:[(0,Y.jsx)(`span`,{className:`text-fg-secondary`,children:`/`}),e.map((t,n)=>(0,Y.jsxs)(`span`,{className:`flex items-center`,children:[t.type===`literal`?(0,Y.jsx)(`span`,{children:t.name}):(0,Y.jsx)(d_e,{part:t}),n<e.length-1&&(0,Y.jsx)(`span`,{className:`text-fg-secondary`,children:`/`})]},n))]})}function l_e({pattern:e,params:t,errors:n,onChange:r}){let i=(0,b.useMemo)(()=>u_e(e),[e]),a=(0,b.useMemo)(()=>i.findIndex(e=>e.type!==`literal-run`),[i]);return(0,Y.jsx)(`div`,{className:`flex items-stretch flex-wrap gap-1 font-mono text-xs`,children:i.map((e,o)=>{if(e.type===`literal-run`)return(0,Y.jsxs)(`span`,{className:`inline-flex items-center px-2 rounded-md bg-bg-secondary text-fg-secondary`,children:[`/`,e.parts.map(e=>e.name).join(`/`),o<i.length-1?`/`:``]},o);let s=e.part,c=t[s.paramName]||``,l=n[s.paramName],u=s.type===`array-param`;return(0,Y.jsxs)(`span`,{className:`inline-flex flex-col`,children:[(0,Y.jsx)(`input`,{autoFocus:o===a,className:X(`h-7 px-2 rounded-md bg-bg-primary border border-border-primary text-fg-primary font-mono text-xs`,`focus:outline-none focus:ring-1 focus:ring-border-focus`,u?`min-w-[16ch]`:`min-w-[10ch]`,{"border-fg-error":!!l}),placeholder:s.paramName,value:c,onChange:e=>{let t=e.target.value,n=u?t.replace(/\//g,``):t,i=t.length>0&&encodeURIComponent(n)!==n;r(s.paramName,t,i?`Invalid characters`:void 0)}}),l&&(0,Y.jsx)(`span`,{className:`mt-0.5 text-[10px] text-fg-error-on-surface`,children:l})]},o)})})}function u_e(e){let t=[],n=null;for(let r of e)r.type===`literal`?(n||(n=[],t.push({type:`literal-run`,parts:n})),n.push({name:r.name})):(n=null,t.push({type:`dynamic`,part:r}));return t}function d_e({part:e}){let t=e.type===`array-param`?`...${e.paramName}`:e.paramName;return(0,Y.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0 rounded text-[11px] bg-bg-brand-secondary text-fg-brand-secondary`,children:[`[`,t,`]`]})}function f_e({pattern:e}){let t=e.some(e=>e.type===`array-param`),n=e.filter(e=>e.type===`string-param`||e.type===`array-param`).length;return t?(0,Y.jsxs)(`p`,{className:`text-[11px] text-fg-secondary`,children:[`Catch-all segments can contain `,(0,Y.jsx)(`code`,{children:`/`}),` for nested paths.`]}):n>1?(0,Y.jsx)(`p`,{className:`text-[11px] text-fg-secondary`,children:`Fill in each segment. Slashes will be added automatically.`}):(0,Y.jsx)(`p`,{className:`text-[11px] text-fg-secondary`,children:`Use lowercase letters, numbers, and hyphens.`})}function p_e({routes:e,value:t,onChange:n}){return(0,Y.jsx)(`select`,{"aria-label":`Route`,className:X(`w-full h-8 px-2 rounded-md bg-bg-primary border border-border-primary`,`font-mono text-xs text-fg-primary`,`focus:outline-none focus:ring-1 focus:ring-border-focus`),value:t,onChange:e=>n(e.target.value),children:e.map(e=>(0,Y.jsx)(`option`,{value:DA(e),children:e.patternString},DA(e)))})}function m_e({routes:e,value:t,onChange:n,includePattern:r,excludePattern:i,placeholder:a=`Select route...`,className:o,portalContainer:s,isLoading:c=!1,zIndex:l,readonly:u,allowCreate:d=!1}){let[f,p]=b.useState(!1),[m,h]=b.useState(null),{pageRouters:g,externalRouter:_}=r_e(),v=i_e(),y=()=>{p(!1),h(null)},x=d&&!u&&g.length>0,S=d&&!u&&_!==null,C=e.filter(e=>!(r&&!r.test(e.route)||i&&i.test(e.route))),w=t?C.find(e=>e.route===t):void 0;return(0,Y.jsxs)(SD,{open:!u&&f,onOpenChange:u?void 0:p,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,role:`combobox`,"aria-expanded":f,className:X(`w-full justify-start text-left border border-border-primary bg-bg-primary hover:bg-bg-primary-hover h-auto py-1.5`,o),children:[w&&w.preview?(0,Y.jsx)(dk,{title:w.preview.title,subtitle:w.preview.subtitle??null,image:w.preview.image??null}):(0,Y.jsx)(`span`,{className:`truncate flex-1`,children:t||a}),(0,Y.jsx)(zv,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,Y.jsxs)(wD,{className:`w-[var(--radix-popover-trigger-width)] p-0`,style:{zIndex:l},container:s,children:[m===`page`&&(0,Y.jsx)(EA,{routes:g.map(g_e),onSubmit:(e,t)=>{let r=g.find(t=>t.moduleFilePath===e);r&&(v(r,t)!==null&&n(t),y())},onCancel:()=>h(null)}),m===`external`&&_&&(0,Y.jsx)(h_e,{existingKeys:_.existingKeys,onSubmit:e=>{v(_,e)!==null&&n(e),y()},onCancel:()=>h(null)}),m===null&&(0,Y.jsxs)(ik,{children:[(0,Y.jsx)(ak,{placeholder:a}),(0,Y.jsxs)(ok,{children:[c?(0,Y.jsx)(`div`,{className:`py-6 text-center text-sm`,children:`Loading...`}):C.length===0?(0,Y.jsx)(sk,{children:`No routes found.`}):(0,Y.jsx)(ck,{children:C.map(e=>{let r=e.preview,i=r?`${e.route} ${r.title}`:e.route;return(0,Y.jsxs)(uk,{value:i,onSelect:()=>{n(e.route),p(!1)},className:`flex items-center gap-2`,children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,t===e.route?`opacity-100`:`opacity-0`)}),r?(0,Y.jsx)(dk,{title:r.title,subtitle:r.subtitle??null,image:r.image??null}):(0,Y.jsx)(`span`,{className:`truncate`,children:e.route})]},e.route)})}),(x||S)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(lk,{}),(0,Y.jsxs)(ck,{children:[x&&(0,Y.jsxs)(uk,{value:`__val_new_page__`,onSelect:()=>h(`page`),className:`flex items-center gap-2`,children:[(0,Y.jsx)(Oy,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{children:`New page`})]}),S&&(0,Y.jsxs)(uk,{value:`__val_new_external_page__`,onSelect:()=>h(`external`),className:`flex items-center gap-2`,children:[(0,Y.jsx)(Wie,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{children:`New external page`})]})]})]})]})]})]})]})}function h_e({existingKeys:e,onSubmit:t,onCancel:n}){let[r,i]=b.useState(``),a=r.trim(),o=e.includes(a),s=a.startsWith(`https://`)||a.startsWith(`http://`),c=a?s?o?`This external page already exists`:null:`Must start with https:// or http://`:null,l=!a||c!==null;return(0,Y.jsxs)(`form`,{className:`p-3 space-y-3`,onSubmit:e=>{e.preventDefault(),!l&&t(a)},children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg-primary`,children:`New external page`}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`input`,{autoFocus:!0,className:X(`w-full p-1 bg-bg-secondary border border-border-primary rounded text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,{"border-fg-error":c!==null}),placeholder:`https://example.com`,value:r,onChange:e=>i(e.target.value)}),c&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-error`,children:c})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[(0,Y.jsx)(t_,{size:`sm`,variant:`ghost`,type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsx)(t_,{size:`sm`,type:`submit`,disabled:l,children:`Create`})]})]})}function g_e(e){return{moduleFilePath:e.moduleFilePath,routePattern:e.routePattern,patternString:e.patternString,existingKeys:e.existingKeys,keyDescription:e.keyDescription}}function __e(e){let t=ooe();return b.useMemo(()=>{let n=new Map;return e.map(({route:e,moduleFilePath:r})=>{if(!n.has(r)){let e=new Map,i=t[r];if(i){let t=i[r];if(t&&`data`in t&&t.data&&t.data.parent===`record`)for(let[n,r]of t.data.items)e.set(n,{title:r.title,subtitle:r.subtitle??null,image:r.image??null})}n.set(r,e)}return{route:e,moduleFilePath:r,preview:n.get(r)?.get(e)??null}})},[e,t])}function v_e({path:e,readonly:t}){let n=`route`,{navigate:r}=GC(),i=Cb(e),a=Ob(e,n),{patchPath:o,addPatch:s}=vb(e),c=eb(),l=TA(),u=__e(l);if(i.status===`error`)return(0,Y.jsx)(NC,{path:e,error:i.error,type:n});if(a.status===`error`)return(0,Y.jsx)(FC,{path:e,error:a.error,schema:i});if(a.status==`not-found`||i.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(!(`data`in a)||a.data===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(`data`in i&&i.data&&i.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:i.data.type});let d=a.data,f=`data`in i&&i.data?.type===`route`?i.data:void 0,p=f?.options?.include?new RegExp(f.options.include.source,f.options.include.flags):void 0,m=f?.options?.exclude?new RegExp(f.options.exclude.source,f.options.exclude.flags):void 0,h=d?l.find(e=>e.route===d):void 0,g=i.status===`loading`,_=(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Y.jsx)(m_e,{routes:u,value:d,onChange:e=>{t||s([{op:`replace`,path:o,value:e}],n)},includePattern:p,excludePattern:m,portalContainer:c,isLoading:g,readonly:t,allowCreate:!0}),d&&h&&(0,Y.jsx)(`button`,{title:`Go to reference`,className:`px-2`,onClick:()=>{r(H.joinModuleFilePathAndModulePath(h.moduleFilePath,JSON.stringify(d)))},children:(0,Y.jsx)(dy,{size:16})})]})});return t?(0,Y.jsx)(NT,{children:_}):_}function y_e({path:e}){let t=Ob(e,`route`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{className:`truncate`,children:t.data})}var b_e=365.2425,OA=6048e5,x_e=864e5,kA=86400;kA*7,kA*b_e/12*3;var AA=Symbol.for(`constructDateFrom`);function jA(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&AA in e?e[AA](t):e instanceof Date?new e.constructor(t):new Date(t)}function MA(e,t){return jA(t||e,e)}function NA(e,t,n){let r=MA(e,n?.in);return isNaN(t)?jA(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function PA(e,t,n){let r=MA(e,n?.in);if(isNaN(t))return jA(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=jA(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}var S_e={};function FA(){return S_e}function IA(e,t){let n=FA(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=MA(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function LA(e,t){return IA(e,{...t,weekStartsOn:1})}function RA(e,t){let n=MA(e,t?.in),r=n.getFullYear(),i=jA(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=LA(i),o=jA(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=LA(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function zA(e){let t=MA(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-n}function BA(e,...t){let n=jA.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function VA(e,t){let n=MA(e,t?.in);return n.setHours(0,0,0,0),n}function HA(e,t,n){let[r,i]=BA(n?.in,e,t),a=VA(r),o=VA(i),s=+a-zA(a),c=+o-zA(o);return Math.round((s-c)/x_e)}function C_e(e,t){let n=RA(e,t),r=jA(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),LA(r)}function w_e(e,t,n){return NA(e,t*7,n)}function T_e(e,t,n){return PA(e,t*12,n)}function E_e(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=jA.bind(null,e));let t=MA(e,r);(!n||n<t||isNaN(+t))&&(n=t)}),jA(r,n||NaN)}function D_e(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=jA.bind(null,e));let t=MA(e,r);(!n||n>t||isNaN(+t))&&(n=t)}),jA(r,n||NaN)}function O_e(e,t,n){let[r,i]=BA(n?.in,e,t);return+VA(r)==+VA(i)}function UA(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function k_e(e){return!(!UA(e)&&typeof e!=`number`||isNaN(+MA(e)))}function WA(e,t,n){let[r,i]=BA(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function A_e(e,t){let n=MA(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function GA(e,t){let[n,r]=BA(e,t.start,t.end);return{start:n,end:r}}function j_e(e,t){let{start:n,end:r}=GA(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setDate(1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(jA(n,o)),o.setMonth(o.getMonth()+s);return i?c.reverse():c}function M_e(e,t){let n=MA(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function N_e(e,t){let n=MA(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function KA(e,t){let n=MA(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function P_e(e,t){let{start:n,end:r}=GA(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setMonth(0,1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(jA(n,o)),o.setFullYear(o.getFullYear()+s);return i?c.reverse():c}function qA(e,t){let n=FA(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=MA(e,t?.in),a=i.getDay(),o=(a<r?-7:0)+6-(a-r);return i.setDate(i.getDate()+o),i.setHours(23,59,59,999),i}function F_e(e,t){return qA(e,{...t,weekStartsOn:1})}var I_e={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},L_e=(e,t,n)=>{let r,i=I_e[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function JA(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var R_e={date:JA({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:JA({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:JA({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},z_e={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},B_e=(e,t,n,r)=>z_e[e];function YA(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var V_e={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:YA({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:YA({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:YA({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:YA({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:YA({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function XA(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?U_e(s,e=>e.test(o)):H_e(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function H_e(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function U_e(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function W_e(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var ZA={code:`en-US`,formatDistance:L_e,formatLong:R_e,formatRelative:B_e,localize:V_e,match:{ordinalNumber:W_e({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:XA({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:XA({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:XA({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:XA({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:XA({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function G_e(e,t){let n=MA(e,t?.in);return HA(n,KA(n))+1}function QA(e,t){let n=MA(e,t?.in),r=+LA(n)-C_e(n);return Math.round(r/OA)+1}function $A(e,t){let n=MA(e,t?.in),r=n.getFullYear(),i=FA(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=jA(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=IA(o,t),c=jA(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=IA(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function K_e(e,t){let n=FA(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=$A(e,t),a=jA(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),IA(a,t)}function ej(e,t){let n=MA(e,t?.in),r=+IA(n,t)-K_e(n,t);return Math.round(r/OA)+1}function tj(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var nj={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return tj(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):tj(n+1,2)},d(e,t){return tj(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return tj(e.getHours()%12||12,t.length)},H(e,t){return tj(e.getHours(),t.length)},m(e,t){return tj(e.getMinutes(),t.length)},s(e,t){return tj(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return tj(Math.trunc(r*10**(n-3)),t.length)}},rj={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},ij={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return nj.y(e,t)},Y:function(e,t,n,r){let i=$A(e,r),a=i>0?i:1-i;return t===`YY`?tj(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):tj(a,t.length)},R:function(e,t){return tj(RA(e),t.length)},u:function(e,t){return tj(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return tj(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return tj(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return nj.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return tj(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=ej(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):tj(i,t.length)},I:function(e,t,n){let r=QA(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):tj(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):nj.d(e,t)},D:function(e,t,n){let r=G_e(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):tj(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return tj(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return tj(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return tj(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?rj.noon:r===0?rj.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?rj.evening:r>=12?rj.afternoon:r>=4?rj.morning:rj.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return nj.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):nj.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):tj(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):tj(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):nj.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):nj.s(e,t)},S:function(e,t){return nj.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return oj(r);case`XXXX`:case`XX`:return sj(r);default:return sj(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return oj(r);case`xxxx`:case`xx`:return sj(r);default:return sj(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+aj(r,`:`);default:return`GMT`+sj(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+aj(r,`:`);default:return`GMT`+sj(r,`:`)}},t:function(e,t,n){return tj(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return tj(+e,t.length)}};function aj(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+tj(a,2)}function oj(e,t){return e%60==0?(e>0?`-`:`+`)+tj(Math.abs(e)/60,2):sj(e,t)}function sj(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=tj(Math.trunc(r/60),2),a=tj(r%60,2);return n+i+t+a}var cj=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},lj=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},q_e={p:lj,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return cj(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`})}return a.replace(`{{date}}`,cj(r,t)).replace(`{{time}}`,lj(i,t))}},J_e=/^D+$/,Y_e=/^Y+$/,X_e=[`D`,`DD`,`YY`,`YYYY`];function Z_e(e){return J_e.test(e)}function Q_e(e){return Y_e.test(e)}function $_e(e,t,n){let r=eve(e,t,n);if(console.warn(r),X_e.includes(e))throw RangeError(r)}function eve(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var tve=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,nve=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,rve=/^'([^]*?)'?$/,ive=/''/g,ave=/[a-zA-Z]/;function uj(e,t,n){let r=FA(),i=n?.locale??r.locale??ZA,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=MA(e,n?.in);if(!k_e(s))throw RangeError(`Invalid time value`);let c=t.match(nve).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=q_e[t];return n(e,i.formatLong)}return e}).join(``).match(tve).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:ove(e)};if(ij[t])return{isToken:!0,value:e};if(t.match(ave))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&Q_e(a)||!n?.useAdditionalDayOfYearTokens&&Z_e(a))&&$_e(a,t,String(e));let o=ij[a[0]];return o(s,a,i.localize,l)}).join(``)}function ove(e){let t=e.match(rve);return t?t[1].replace(ive,`'`):e}function sve(e,t){let n=MA(e,t?.in),r=n.getFullYear(),i=n.getMonth(),a=jA(n,0);return a.setFullYear(r,i+1,0),a.setHours(0,0,0,0),a.getDate()}function cve(e,t){return MA(e,t?.in).getMonth()}function lve(e,t){return MA(e,t?.in).getFullYear()}function uve(e,t){return+MA(e)>+MA(t)}function dve(e,t){return+MA(e)<+MA(t)}function fve(e,t,n){let[r,i]=BA(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function pve(e,t,n){let[r,i]=BA(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function mve(e,t,n){let r=MA(e,n?.in),i=r.getFullYear(),a=r.getDate(),o=jA(n?.in||e,0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);let s=sve(o);return r.setMonth(t,Math.min(a,s)),r}function hve(e,t,n){let r=MA(e,n?.in);return isNaN(+r)?jA(n?.in||e,NaN):(r.setFullYear(t),r)}function gve(e,t,n=`long`){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(` `)}var _ve={},dj={};function fj(e,t){try{let n=(_ve[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format)(t).split(`GMT`)[1];return n in dj?dj[n]:pj(n,n.split(`:`))}catch{if(e in dj)return dj[e];let t=e?.match(vve);return t?pj(e,t.slice(1)):NaN}}var vve=/([+-]\d\d):?(\d\d)?/;function pj(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return dj[e]=n*60+r>0?n*60+r+i:n*60-r-i}var mj=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(fj(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),_j(this,NaN),gj(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-fj(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),gj(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},hj=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!hj.test(e))return;let t=e.replace(hj,`$1UTC`);mj.prototype[t]&&(e.startsWith(`get`)?mj.prototype[e]=function(){return this.internal[t]()}:(mj.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),yve(this),+this},mj.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),gj(this),+this}))});function gj(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-fj(e.timeZone,e)*60))}function yve(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),_j(e)}function _j(e){let t=fj(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);let i=-new Date(+e).getTimezoneOffset(),a=i- -new Date(+r).getTimezoneOffset(),o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);let s=i-n;s&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+s);let c=new Date(+e);c.setUTCSeconds(0);let l=i>0?c.getSeconds():(c.getSeconds()-60)%60,u=Math.round(-(fj(e.timeZone,e)*60))%60;(u||l)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+l));let d=fj(e.timeZone,e),f=d>0?Math.floor(d):Math.ceil(d),p=-new Date(+e).getTimezoneOffset()-f,m=f!==n,h=p-s;if(m&&h){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+h);let t=fj(e.timeZone,e),n=f-(t>0?Math.floor(t):Math.ceil(t));n&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+n),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n))}}var vj=class e extends mj{static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}toISOString(){let[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[e,t,n,r]=this.internal.toUTCString().split(` `);return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){let e=this.internal.toUTCString().split(` `)[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${gve(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){let e=this.getTimezoneOffset();return[e>0?`-`:`+`,String(Math.floor(Math.abs(e)/60)).padStart(2,`0`),String(Math.abs(e)%60).padStart(2,`0`)]}withTimeZone(t){return new e(+this,t)}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},bve=5,xve=4;function Sve(e,t){let n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),a=t.addDays(i,34);return t.getMonth(e)===t.getMonth(a)?bve:xve}function yj(e,t){let n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function Cve(e,t){let n=yj(e,t),r=Sve(e,t);return t.addDays(n,r*7-1)}var bj={...ZA,labels:{labelDayButton:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>uj(e,t,{locale:ZA,...n});let a=i(e,`PPPP`);return t.today&&(a=`Today, ${a}`),t.selected&&(a=`${a}, selected`),a},labelMonthDropdown:`Choose the Month`,labelNext:`Go to the Next Month`,labelPrevious:`Go to the Previous Month`,labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:`Choose the Year`,labelGrid:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>uj(e,n,{locale:ZA,...t}),r(e,`LLLL yyyy`)},labelGridcell:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>uj(e,t,{locale:ZA,...n});let a=i(e,`PPPP`);return t?.today&&(a=`Today, ${a}`),a},labelNav:`Navigation bar`,labelWeekNumberHeader:`Week Number`,labelWeekday:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>uj(e,n,{locale:ZA,...t}),r(e,`cccc`)}}},xj=class e{constructor(e,t){this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?vj.tz(this.options.timeZone):new(this.options.Date??Date),this.newDate=(e,t,n)=>this.overrides?.newDate?this.overrides.newDate(e,t,n):this.options.timeZone?new vj(e,t,n,this.options.timeZone):new Date(e,t,n),this.addDays=(e,t)=>this.overrides?.addDays?this.overrides.addDays(e,t):NA(e,t),this.addMonths=(e,t)=>this.overrides?.addMonths?this.overrides.addMonths(e,t):PA(e,t),this.addWeeks=(e,t)=>this.overrides?.addWeeks?this.overrides.addWeeks(e,t):w_e(e,t),this.addYears=(e,t)=>this.overrides?.addYears?this.overrides.addYears(e,t):T_e(e,t),this.differenceInCalendarDays=(e,t)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(e,t):HA(e,t),this.differenceInCalendarMonths=(e,t)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(e,t):WA(e,t),this.eachMonthOfInterval=e=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(e):j_e(e),this.eachYearOfInterval=e=>{let t=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(e):P_e(e),n=new Set(t.map(e=>this.getYear(e)));if(n.size===t.length)return t;let r=[];return n.forEach(e=>{r.push(new Date(e,0,1))}),r},this.endOfBroadcastWeek=e=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(e):Cve(e,this),this.endOfISOWeek=e=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(e):F_e(e),this.endOfMonth=e=>this.overrides?.endOfMonth?this.overrides.endOfMonth(e):A_e(e),this.endOfWeek=(e,t)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(e,t):qA(e,this.options),this.endOfYear=e=>this.overrides?.endOfYear?this.overrides.endOfYear(e):N_e(e),this.format=(e,t,n)=>{let r=this.overrides?.format?this.overrides.format(e,t,this.options):uj(e,t,this.options);return this.options.numerals&&this.options.numerals!==`latn`?this.replaceDigits(r):r},this.getISOWeek=e=>this.overrides?.getISOWeek?this.overrides.getISOWeek(e):QA(e),this.getMonth=(e,t)=>this.overrides?.getMonth?this.overrides.getMonth(e,this.options):cve(e,this.options),this.getYear=(e,t)=>this.overrides?.getYear?this.overrides.getYear(e,this.options):lve(e,this.options),this.getWeek=(e,t)=>this.overrides?.getWeek?this.overrides.getWeek(e,this.options):ej(e,this.options),this.isAfter=(e,t)=>this.overrides?.isAfter?this.overrides.isAfter(e,t):uve(e,t),this.isBefore=(e,t)=>this.overrides?.isBefore?this.overrides.isBefore(e,t):dve(e,t),this.isDate=e=>this.overrides?.isDate?this.overrides.isDate(e):UA(e),this.isSameDay=(e,t)=>this.overrides?.isSameDay?this.overrides.isSameDay(e,t):O_e(e,t),this.isSameMonth=(e,t)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(e,t):fve(e,t),this.isSameYear=(e,t)=>this.overrides?.isSameYear?this.overrides.isSameYear(e,t):pve(e,t),this.max=e=>this.overrides?.max?this.overrides.max(e):E_e(e),this.min=e=>this.overrides?.min?this.overrides.min(e):D_e(e),this.setMonth=(e,t)=>this.overrides?.setMonth?this.overrides.setMonth(e,t):mve(e,t),this.setYear=(e,t)=>this.overrides?.setYear?this.overrides.setYear(e,t):hve(e,t),this.startOfBroadcastWeek=(e,t)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(e,this):yj(e,this),this.startOfDay=e=>this.overrides?.startOfDay?this.overrides.startOfDay(e):VA(e),this.startOfISOWeek=e=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(e):LA(e),this.startOfMonth=e=>this.overrides?.startOfMonth?this.overrides.startOfMonth(e):M_e(e),this.startOfWeek=(e,t)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(e,this.options):IA(e,this.options),this.startOfYear=e=>this.overrides?.startOfYear?this.overrides.startOfYear(e):KA(e),this.options={locale:bj,...e},this.overrides=t}getDigitMap(){let{numerals:e=`latn`}=this.options,t=new Intl.NumberFormat(`en-US`,{numberingSystem:e}),n={};for(let e=0;e<10;e++)n[e.toString()]=t.format(e);return n}replaceDigits(e){let t=this.getDigitMap();return e.replace(/\d/g,e=>t[e]||e)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){let t=this.options.locale?.code;return t&&e.yearFirstLocales.has(t)?`year-first`:`month-first`}formatMonthYear(t){let{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&e.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:`long`,year:`numeric`,timeZone:r,numberingSystem:i}).format(t)}catch{}let o=this.getMonthYearOrder()===`year-first`?`y LLLL`:`LLLL y`;return this.format(t,o)}};xj.yearFirstLocales=new Set([`eu`,`hu`,`ja`,`ja-Hira`,`ja-JP`,`ko`,`ko-KR`,`lt`,`lt-LT`,`lv`,`lv-LV`,`mn`,`mn-MN`,`zh`,`zh-CN`,`zh-HK`,`zh-TW`]);var Sj=new xj,Cj=class{constructor(e,t,n=Sj){this.date=e,this.displayMonth=t,this.outside=!!(t&&!n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,`yyyy-MM-dd`),this.displayMonthId=n.format(t,`yyyy-MM`),this.dateMonthId=n.format(e,`yyyy-MM`)}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}},wve=class{constructor(e,t){this.date=e,this.weeks=t}},Tve=class{constructor(e,t){this.days=t,this.weekNumber=e}};function Eve(e){return b.createElement(`span`,{...e})}function Dve(e){let{size:t=24,orientation:n=`left`,className:r,style:i}=e;return b.createElement(`svg`,{className:r,style:i,width:t,height:t,viewBox:`0 0 24 24`},n===`up`&&b.createElement(`polygon`,{points:`6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28`}),n===`down`&&b.createElement(`polygon`,{points:`6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72`}),n===`left`&&b.createElement(`polygon`,{points:`16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20`}),n===`right`&&b.createElement(`polygon`,{points:`8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20`}))}function Ove(e){let{day:t,modifiers:n,...r}=e;return b.createElement(`td`,{...r})}function kve(e){let{day:t,modifiers:n,...r}=e,i=b.useRef(null);return b.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),b.createElement(`button`,{ref:i,...r})}var wj;(function(e){e.Root=`root`,e.Chevron=`chevron`,e.Day=`day`,e.DayButton=`day_button`,e.CaptionLabel=`caption_label`,e.Dropdowns=`dropdowns`,e.Dropdown=`dropdown`,e.DropdownRoot=`dropdown_root`,e.Footer=`footer`,e.MonthGrid=`month_grid`,e.MonthCaption=`month_caption`,e.MonthsDropdown=`months_dropdown`,e.Month=`month`,e.Months=`months`,e.Nav=`nav`,e.NextMonthButton=`button_next`,e.PreviousMonthButton=`button_previous`,e.Week=`week`,e.Weeks=`weeks`,e.Weekday=`weekday`,e.Weekdays=`weekdays`,e.WeekNumber=`week_number`,e.WeekNumberHeader=`week_number_header`,e.YearsDropdown=`years_dropdown`})(wj||={});var Tj;(function(e){e.disabled=`disabled`,e.hidden=`hidden`,e.outside=`outside`,e.focused=`focused`,e.today=`today`})(Tj||={});var Ej;(function(e){e.range_end=`range_end`,e.range_middle=`range_middle`,e.range_start=`range_start`,e.selected=`selected`})(Ej||={});var Dj;(function(e){e.weeks_before_enter=`weeks_before_enter`,e.weeks_before_exit=`weeks_before_exit`,e.weeks_after_enter=`weeks_after_enter`,e.weeks_after_exit=`weeks_after_exit`,e.caption_after_enter=`caption_after_enter`,e.caption_after_exit=`caption_after_exit`,e.caption_before_enter=`caption_before_enter`,e.caption_before_exit=`caption_before_exit`})(Dj||={});var Oj=(0,b.createContext)(void 0);function kj(){let e=(0,b.useContext)(Oj);if(e===void 0)throw Error(`useDayPicker() must be used within a custom component.`);return e}function Ave(e){let{options:t,className:n,...r}=e,{classNames:i,components:a,styles:o}=kj(),s=[i[wj.Dropdown],n].join(` `),c=t?.find(({value:e})=>e===r.value);return b.createElement(`span`,{"data-disabled":r.disabled,className:i[wj.DropdownRoot],style:o?.[wj.DropdownRoot]},b.createElement(a.Select,{className:s,...r},t?.map(({value:e,label:t,disabled:n})=>b.createElement(a.Option,{key:e,value:e,disabled:n},t))),b.createElement(`span`,{className:i[wj.CaptionLabel],style:o?.[wj.CaptionLabel],"aria-hidden":!0},c?.label,b.createElement(a.Chevron,{orientation:`down`,size:18,className:i[wj.Chevron],style:o?.[wj.Chevron]})))}function jve(e){return b.createElement(`div`,{...e})}function Mve(e){return b.createElement(`div`,{...e})}function Nve(e){let{calendarMonth:t,displayIndex:n,...r}=e;return b.createElement(`div`,{...r},e.children)}function Pve(e){let{calendarMonth:t,displayIndex:n,...r}=e;return b.createElement(`div`,{...r})}function Fve(e){return b.createElement(`table`,{...e})}function Ive(e){return b.createElement(`div`,{...e})}function Lve(e){let{components:t}=kj();return b.createElement(t.Dropdown,{...e})}function Rve(e){let{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...a}=e,{components:o,classNames:s,styles:c,labels:{labelPrevious:l,labelNext:u}}=kj(),d=(0,b.useCallback)(e=>{i&&n?.(e)},[i,n]),f=(0,b.useCallback)(e=>{r&&t?.(e)},[r,t]);return b.createElement(`nav`,{...a},b.createElement(o.PreviousMonthButton,{type:`button`,className:s[wj.PreviousMonthButton],style:c?.[wj.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":!r||void 0,"aria-label":l(r),onClick:f},b.createElement(o.Chevron,{disabled:!r||void 0,className:s[wj.Chevron],style:c?.[wj.Chevron],orientation:`left`})),b.createElement(o.NextMonthButton,{type:`button`,className:s[wj.NextMonthButton],style:c?.[wj.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":!i||void 0,"aria-label":u(i),onClick:d},b.createElement(o.Chevron,{disabled:!i||void 0,orientation:`right`,className:s[wj.Chevron],style:c?.[wj.Chevron]})))}function zve(e){return b.createElement(`button`,{...e})}function Bve(e){return b.createElement(`option`,{...e})}function Vve(e){return b.createElement(`button`,{...e})}function Hve(e){let{rootRef:t,...n}=e;return b.createElement(`div`,{...n,ref:t})}function Uve(e){return b.createElement(`select`,{...e})}function Wve(e){let{week:t,...n}=e;return b.createElement(`tr`,{...n})}function Gve(e){return b.createElement(`th`,{...e})}function Kve(e){return b.createElement(`thead`,{"aria-hidden":!0},b.createElement(`tr`,{...e}))}function qve(e){let{week:t,...n}=e;return b.createElement(`th`,{...n})}function Jve(e){return b.createElement(`th`,{...e})}function Yve(e){return b.createElement(`tbody`,{...e})}function Xve(e){let{components:t}=kj();return b.createElement(t.Dropdown,{...e})}var Zve=c({CaptionLabel:()=>Eve,Chevron:()=>Dve,Day:()=>Ove,DayButton:()=>kve,Dropdown:()=>Ave,DropdownNav:()=>jve,Footer:()=>Mve,Month:()=>Nve,MonthCaption:()=>Pve,MonthGrid:()=>Fve,Months:()=>Ive,MonthsDropdown:()=>Lve,Nav:()=>Rve,NextMonthButton:()=>zve,Option:()=>Bve,PreviousMonthButton:()=>Vve,Root:()=>Hve,Select:()=>Uve,Week:()=>Wve,WeekNumber:()=>qve,WeekNumberHeader:()=>Jve,Weekday:()=>Gve,Weekdays:()=>Kve,Weeks:()=>Yve,YearsDropdown:()=>Xve});function Aj(e,t,n=!1,r=Sj){let{from:i,to:a}=e,{differenceInCalendarDays:o,isSameDay:s}=r;return i&&a?(o(a,i)<0&&([i,a]=[a,i]),o(t,i)>=+!!n&&o(a,t)>=+!!n):!n&&a?s(a,t):!n&&i?s(i,t):!1}function jj(e){return!!(e&&typeof e==`object`&&`before`in e&&`after`in e)}function Mj(e){return!!(e&&typeof e==`object`&&`from`in e)}function Nj(e){return!!(e&&typeof e==`object`&&`after`in e)}function Pj(e){return!!(e&&typeof e==`object`&&`before`in e)}function Fj(e){return!!(e&&typeof e==`object`&&`dayOfWeek`in e)}function Ij(e,t){return Array.isArray(e)&&e.every(t.isDate)}function Lj(e,t,n=Sj){let r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:a,isAfter:o}=n;return r.some(t=>{if(typeof t==`boolean`)return t;if(n.isDate(t))return i(e,t);if(Ij(t,n))return t.some(t=>i(e,t));if(Mj(t))return Aj(t,e,!1,n);if(Fj(t))return Array.isArray(t.dayOfWeek)?t.dayOfWeek.includes(e.getDay()):t.dayOfWeek===e.getDay();if(jj(t)){let n=a(t.before,e),r=a(t.after,e),i=n>0,s=r<0;return o(t.before,t.after)?s&&i:i||s}return Nj(t)?a(e,t.after)>0:Pj(t)?a(t.before,e)>0:typeof t==`function`&&t(e)})}function Qve(e,t,n,r,i){let{disabled:a,hidden:o,modifiers:s,showOutsideDays:c,broadcastCalendar:l,today:u=i.today()}=t,{isSameDay:d,isSameMonth:f,startOfMonth:p,isBefore:m,endOfMonth:h,isAfter:g}=i,_=n&&p(n),v=r&&h(r),y={[Tj.focused]:[],[Tj.outside]:[],[Tj.disabled]:[],[Tj.hidden]:[],[Tj.today]:[]},b={};for(let t of e){let{date:e,displayMonth:n}=t,r=!!(n&&!f(e,n)),p=!!(_&&m(e,_)),h=!!(v&&g(e,v)),x=!!(a&&Lj(e,a,i)),S=!!(o&&Lj(e,o,i))||p||h||!l&&!c&&r||l&&c===!1&&r,C=d(e,u);r&&y.outside.push(t),x&&y.disabled.push(t),S&&y.hidden.push(t),C&&y.today.push(t),s&&Object.keys(s).forEach(n=>{let r=s?.[n];r&&Lj(e,r,i)&&(b[n]?b[n].push(t):b[n]=[t])})}return e=>{let t={[Tj.focused]:!1,[Tj.disabled]:!1,[Tj.hidden]:!1,[Tj.outside]:!1,[Tj.today]:!1},n={};for(let n in y)t[n]=y[n].some(t=>t===e);for(let t in b)n[t]=b[t].some(t=>t===e);return{...t,...n}}}function $ve(e,t,n={}){return Object.entries(e).filter(([,e])=>e===!0).reduce((e,[r])=>(n[r]?e.push(n[r]):t[Tj[r]]?e.push(t[Tj[r]]):t[Ej[r]]&&e.push(t[Ej[r]]),e),[t[wj.Day]])}function eye(e){return{...Zve,...e}}function tye(e){let t={"data-mode":e.mode??void 0,"data-required":`required`in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([e,n])=>{e.startsWith(`data-`)&&(t[e]=n)}),t}function Rj(){let e={};for(let t in wj)e[wj[t]]=`rdp-${wj[t]}`;for(let t in Tj)e[Tj[t]]=`rdp-${Tj[t]}`;for(let t in Ej)e[Ej[t]]=`rdp-${Ej[t]}`;for(let t in Dj)e[Dj[t]]=`rdp-${Dj[t]}`;return e}function nye(e,t,n){return(n??new xj(t)).formatMonthYear(e)}function rye(e,t,n){return(n??new xj(t)).format(e,`d`)}function iye(e,t=Sj){return t.format(e,`LLLL`)}function aye(e,t,n){return(n??new xj(t)).format(e,`cccccc`)}function oye(e,t=Sj){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function sye(){return``}function cye(e,t=Sj){return t.format(e,`yyyy`)}var lye=c({formatCaption:()=>nye,formatDay:()=>rye,formatMonthDropdown:()=>iye,formatWeekNumber:()=>oye,formatWeekNumberHeader:()=>sye,formatWeekdayName:()=>aye,formatYearDropdown:()=>cye});function uye(e){return{...lye,...e}}function zj(e,t,n,r){let i=(r??new xj(n)).format(e,`PPPP`);return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}function Bj(e,t,n){return(n??new xj(t)).formatMonthYear(e)}function Vj(e,t,n,r){let i=(r??new xj(n)).format(e,`PPPP`);return t?.today&&(i=`Today, ${i}`),i}function Hj(e){return`Choose the Month`}function Uj(){return``}var dye=`Go to the Next Month`;function Wj(e,t){return dye}function Gj(e){return`Go to the Previous Month`}function Kj(e,t,n){return(n??new xj(t)).format(e,`cccc`)}function qj(e,t){return`Week ${e}`}function Jj(e){return`Week Number`}function Yj(e){return`Choose the Year`}var fye=c({labelDayButton:()=>zj,labelGrid:()=>Bj,labelGridcell:()=>Vj,labelMonthDropdown:()=>Hj,labelNav:()=>Uj,labelNext:()=>Wj,labelPrevious:()=>Gj,labelWeekNumber:()=>qj,labelWeekNumberHeader:()=>Jj,labelWeekday:()=>Kj,labelYearDropdown:()=>Yj}),Xj=(e,t,n)=>t||(n?typeof n==`function`?n:(...e)=>n:e);function pye(e,t){let n=t.locale?.labels??{};return{...fye,...e??{},labelDayButton:Xj(zj,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Xj(Hj,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Xj(Wj,e?.labelNext,n.labelNext),labelPrevious:Xj(Gj,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Xj(qj,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Xj(Yj,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Xj(Bj,e?.labelGrid,n.labelGrid),labelGridcell:Xj(Vj,e?.labelGridcell,n.labelGridcell),labelNav:Xj(Uj,e?.labelNav,n.labelNav),labelWeekNumberHeader:Xj(Jj,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Xj(Kj,e?.labelWeekday,n.labelWeekday)}}function mye(e,t,n,r,i){let{startOfMonth:a,startOfYear:o,endOfYear:s,eachMonthOfInterval:c,getMonth:l}=i;return c({start:o(e),end:s(e)}).map(e=>{let o=r.formatMonthDropdown(e,i);return{value:l(e),label:o,disabled:t&&e<a(t)||n&&e>a(n)||!1}})}function hye(e,t={},n={}){let r={...t?.[wj.Day]};return Object.entries(e).filter(([,e])=>e===!0).forEach(([e])=>{r={...r,...n?.[e]}}),r}function gye(e,t,n,r){let i=r??e.today(),a=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),o=[];for(let t=0;t<7;t++){let n=e.addDays(a,t);o.push(n)}return o}function _ye(e,t,n,r,i=!1){if(!e||!t)return;let{startOfYear:a,endOfYear:o,eachYearOfInterval:s,getYear:c}=r,l=s({start:a(e),end:o(t)});return i&&l.reverse(),l.map(e=>{let t=n.formatYearDropdown(e,r);return{value:c(e),label:t,disabled:!1}})}function vye(e,t={}){let{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,a=t=>{let n=typeof t==`number`||typeof t==`string`?new Date(t):t;return new vj(n.getFullYear(),n.getMonth(),n.getDate(),12,0,0,e)},o=e=>{let t=a(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0)};return{today:()=>a(vj.tz(e)),newDate:(t,n,r)=>new vj(t,n,r,12,0,0,e),startOfDay:e=>a(e),startOfWeek:(e,t)=>{let n=a(e),r=t?.weekStartsOn??i,o=(n.getDay()-r+7)%7;return n.setDate(n.getDate()-o),n},startOfISOWeek:e=>{let t=a(e),n=(t.getDay()-1+7)%7;return t.setDate(t.getDate()-n),t},startOfMonth:e=>{let t=a(e);return t.setDate(1),t},startOfYear:e=>{let t=a(e);return t.setMonth(0,1),t},endOfWeek:(e,t)=>{let n=a(e),r=(((t?.weekStartsOn??i)+6)%7-n.getDay()+7)%7;return n.setDate(n.getDate()+r),n},endOfISOWeek:e=>{let t=a(e),n=(7-t.getDay())%7;return t.setDate(t.getDate()+n),t},endOfMonth:e=>{let t=a(e);return t.setMonth(t.getMonth()+1,0),t},endOfYear:e=>{let t=a(e);return t.setMonth(11,31),t},eachMonthOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new vj(n.getFullYear(),n.getMonth(),1,12,0,0,e),s=r.getFullYear()*12+r.getMonth();for(;o.getFullYear()*12+o.getMonth()<=s;)i.push(new vj(o,e)),o.setMonth(o.getMonth()+1,1);return i},addDays:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t),n},addWeeks:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t*7),n},addMonths:(e,t)=>{let n=a(e);return n.setMonth(n.getMonth()+t),n},addYears:(e,t)=>{let n=a(e);return n.setFullYear(n.getFullYear()+t),n},eachYearOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new vj(n.getFullYear(),0,1,12,0,0,e);for(;o.getFullYear()<=r.getFullYear();)i.push(new vj(o,e)),o.setFullYear(o.getFullYear()+1,0,1);return i},getWeek:(e,t)=>ej(o(e),{weekStartsOn:t?.weekStartsOn??i,firstWeekContainsDate:t?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1}),getISOWeek:e=>QA(o(e)),differenceInCalendarDays:(e,t)=>HA(o(e),o(t)),differenceInCalendarMonths:(e,t)=>WA(o(e),o(t))}}var Zj=e=>e instanceof HTMLElement?e:null,Qj=e=>[...e.querySelectorAll(`[data-animated-month]`)??[]],yye=e=>Zj(e.querySelector(`[data-animated-month]`)),$j=e=>Zj(e.querySelector(`[data-animated-caption]`)),eM=e=>Zj(e.querySelector(`[data-animated-weeks]`)),bye=e=>Zj(e.querySelector(`[data-animated-nav]`)),xye=e=>Zj(e.querySelector(`[data-animated-weekdays]`));function Sye(e,t,{classNames:n,months:r,focused:i,dateLib:a}){let o=(0,b.useRef)(null),s=(0,b.useRef)(r),c=(0,b.useRef)(!1);(0,b.useLayoutEffect)(()=>{let l=s.current;if(s.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||l.length===0||r.length!==l.length)return;let u=a.isSameMonth(r[0].date,l[0].date),d=a.isAfter(r[0].date,l[0].date),f=d?n[Dj.caption_after_enter]:n[Dj.caption_before_enter],p=d?n[Dj.weeks_after_enter]:n[Dj.weeks_before_enter],m=o.current,h=e.current.cloneNode(!0);if(h instanceof HTMLElement?(Qj(h).forEach(e=>{if(!(e instanceof HTMLElement))return;let t=yye(e);t&&e.contains(t)&&e.removeChild(t);let n=$j(e);n&&n.classList.remove(f);let r=eM(e);r&&r.classList.remove(p)}),o.current=h):o.current=null,c.current||u||i)return;let g=m instanceof HTMLElement?Qj(m):[],_=Qj(e.current);if(_?.every(e=>e instanceof HTMLElement)&&g?.every(e=>e instanceof HTMLElement)){c.current=!0;let t=[];e.current.style.isolation=`isolate`;let r=bye(e.current);r&&(r.style.zIndex=`1`),_.forEach((i,a)=>{let o=g[a];if(!o)return;i.style.position=`relative`,i.style.overflow=`hidden`;let s=$j(i);s&&s.classList.add(f);let l=eM(i);l&&l.classList.add(p);let u=()=>{c.current=!1,e.current&&(e.current.style.isolation=``),r&&(r.style.zIndex=``),s&&s.classList.remove(f),l&&l.classList.remove(p),i.style.position=``,i.style.overflow=``,i.contains(o)&&i.removeChild(o)};t.push(u),o.style.pointerEvents=`none`,o.style.position=`absolute`,o.style.overflow=`hidden`,o.setAttribute(`aria-hidden`,`true`);let m=xye(o);m&&(m.style.opacity=`0`);let h=$j(o);h&&(h.classList.add(d?n[Dj.caption_before_exit]:n[Dj.caption_after_exit]),h.addEventListener(`animationend`,u));let _=eM(o);_&&_.classList.add(d?n[Dj.weeks_before_exit]:n[Dj.weeks_after_exit]),i.insertBefore(o,i.firstChild)})}})}function Cye(e,t,n,r){let i=e[0],a=e[e.length-1],{ISOWeek:o,fixedWeeks:s,broadcastCalendar:c}=n??{},{addDays:l,differenceInCalendarDays:u,differenceInCalendarMonths:d,endOfBroadcastWeek:f,endOfISOWeek:p,endOfMonth:m,endOfWeek:h,isAfter:g,startOfBroadcastWeek:_,startOfISOWeek:v,startOfWeek:y}=r,b=c?_(i,r):o?v(i):y(i),x=c?f(a):o?p(m(a)):h(m(a)),S=t&&(c?f(t):o?p(t):h(t)),C=u(S&&g(x,S)?S:x,b),w=d(a,i)+1,T=[];for(let e=0;e<=C;e++){let t=l(b,e);T.push(t)}let E=(c?35:42)*w;if(s&&T.length<E){let e=E-T.length;for(let t=0;t<e;t++){let e=l(T[T.length-1],1);T.push(e)}}return T}function wye(e){let t=[];return e.reduce((e,n)=>{let r=n.weeks.reduce((e,t)=>e.concat(t.days.slice()),t.slice());return e.concat(r.slice())},t.slice())}function Tye(e,t,n,r){let{numberOfMonths:i=1}=n,a=[];for(let n=0;n<i;n++){let i=r.addMonths(e,n);if(t&&i>t)break;a.push(i)}return a}function tM(e,t,n,r){let{month:i,defaultMonth:a,today:o=r.today(),numberOfMonths:s=1}=e,c=i||a||o,{differenceInCalendarMonths:l,addMonths:u,startOfMonth:d}=r;return n&&l(n,c)<s-1&&(c=u(n,-1*(s-1))),t&&l(c,t)<0&&(c=t),d(c)}function Eye(e,t,n,r){let{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:o,endOfMonth:s,endOfWeek:c,getISOWeek:l,getWeek:u,startOfBroadcastWeek:d,startOfISOWeek:f,startOfWeek:p}=r,m=e.reduce((e,m)=>{let h=n.broadcastCalendar?d(m,r):n.ISOWeek?f(m):p(m),g=n.broadcastCalendar?a(m):n.ISOWeek?o(s(m)):c(s(m)),_=t.filter(e=>e>=h&&e<=g),v=n.broadcastCalendar?35:42;if(n.fixedWeeks&&_.length<v){let e=t.filter(e=>{let t=v-_.length;return e>g&&e<=i(g,t)});_.push(...e)}let y=new wve(m,_.reduce((e,t)=>{let i=n.ISOWeek?l(t):u(t),a=e.find(e=>e.weekNumber===i),o=new Cj(t,m,r);return a?a.days.push(o):e.push(new Tve(i,[o])),e},[]));return e.push(y),e},[]);return n.reverseMonths?m.reverse():m}function Dye(e,t){let{startMonth:n,endMonth:r}=e,{startOfYear:i,startOfDay:a,startOfMonth:o,endOfMonth:s,addYears:c,endOfYear:l,today:u}=t,d=e.captionLayout===`dropdown`||e.captionLayout===`dropdown-years`;return n?n=o(n):!n&&d&&(n=i(c(e.today??u(),-100))),r?r=s(r):!r&&d&&(r=l(e.today??u())),[n&&a(n),r&&a(r)]}function Oye(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a:1,u=o(e);if(!t||!(c(t,e)<a))return s(u,l)}function kye(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a??1:1,u=o(e);if(!t||!(c(u,t)<=0))return s(u,-l)}function Aye(e){return e.reduce((e,t)=>e.concat(t.weeks.slice()),[].slice())}function nM(e,t){let[n,r]=(0,b.useState)(e);return[t===void 0?n:t,r]}function jye(e,t){let[n,r]=Dye(e,t),{startOfMonth:i,endOfMonth:a}=t,o=tM(e,n,r,t),[s,c]=nM(o,e.month?o:void 0);(0,b.useEffect)(()=>{let i=tM(e,n,r,t);c(i)},[e.timeZone]);let{months:l,weeks:u,days:d,previousMonth:f,nextMonth:p}=(0,b.useMemo)(()=>{let i=Tye(s,r,{numberOfMonths:e.numberOfMonths},t),o=Eye(i,Cye(i,e.endMonth?a(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t);return{months:o,weeks:Aye(o),days:wye(o),previousMonth:kye(s,n,e,t),nextMonth:Oye(s,r,e,t)}},[t,s.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:m,onMonthChange:h}=e,g=e=>u.some(t=>t.days.some(t=>t.isEqualTo(e))),_=e=>{if(m)return;let t=i(e);n&&t<i(n)&&(t=i(n)),r&&t>i(r)&&(t=i(r)),c(t),h?.(t)};return{months:l,weeks:u,days:d,navStart:n,navEnd:r,previousMonth:f,nextMonth:p,goToMonth:_,goToDay:e=>{g(e)||_(e.date)}}}var rM;(function(e){e[e.Today=0]=`Today`,e[e.Selected=1]=`Selected`,e[e.LastFocused=2]=`LastFocused`,e[e.FocusedModifier=3]=`FocusedModifier`})(rM||={});function iM(e){return!e[Tj.disabled]&&!e[Tj.hidden]&&!e[Tj.outside]}function Mye(e,t,n,r){let i,a=-1;for(let o of e){let e=t(o);iM(e)&&(e[Tj.focused]&&a<rM.FocusedModifier?(i=o,a=rM.FocusedModifier):r?.isEqualTo(o)&&a<rM.LastFocused?(i=o,a=rM.LastFocused):n(o.date)&&a<rM.Selected?(i=o,a=rM.Selected):e[Tj.today]&&a<rM.Today&&(i=o,a=rM.Today))}return i||=e.find(e=>iM(t(e))),i}function Nye(e,t,n,r,i,a,o){let{ISOWeek:s,broadcastCalendar:c}=a,{addDays:l,addMonths:u,addWeeks:d,addYears:f,endOfBroadcastWeek:p,endOfISOWeek:m,endOfWeek:h,max:g,min:_,startOfBroadcastWeek:v,startOfISOWeek:y,startOfWeek:b}=o,x={day:l,week:d,month:u,year:f,startOfWeek:e=>c?v(e,o):s?y(e):b(e),endOfWeek:e=>c?p(e):s?m(e):h(e)}[e](n,t===`after`?1:-1);return t===`before`&&r?x=g([r,x]):t===`after`&&i&&(x=_([i,x])),x}function aM(e,t,n,r,i,a,o,s=0){if(s>365)return;let c=Nye(e,t,n.date,r,i,a,o),l=!!(a.disabled&&Lj(c,a.disabled,o)),u=!!(a.hidden&&Lj(c,a.hidden,o)),d=new Cj(c,c,o);return!l&&!u?d:aM(e,t,d,r,i,a,o,s+1)}function Pye(e,t,n,r,i){let{autoFocus:a}=e,[o,s]=(0,b.useState)(),c=Mye(t.days,n,r||(()=>!1),o),[l,u]=(0,b.useState)(a?c:void 0);return{isFocusTarget:e=>!!c?.isEqualTo(e),setFocused:u,focused:l,blur:()=>{s(l),u(void 0)},moveFocus:(n,r)=>{if(!l)return;let a=aM(n,r,l,t.navStart,t.navEnd,e,i);a&&(e.disableNavigation&&!t.days.some(e=>e.isEqualTo(a))||(t.goToDay(a),u(a)))}}}function Fye(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=nM(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t,l=e=>s?.some(t=>c(t,e))??!1,{min:u,max:d}=e;return{selected:s,select:(e,t,n)=>{let a=[...s??[]];if(l(e)){if(s?.length===u||r&&s?.length===1)return;a=s?.filter(t=>!c(t,e))}else a=s?.length===d?[e]:[...a,e];return i||o(a),i?.(a,e,t,n),a},isSelected:l}}function Iye(e,t,n=0,r=0,i=!1,a=Sj){let{from:o,to:s}=t||{},{isSameDay:c,isAfter:l,isBefore:u}=a,d;if(!o&&!s)d={from:e,to:n>0?void 0:e};else if(o&&!s)d=c(o,e)?n===0?{from:o,to:e}:i?{from:o,to:void 0}:void 0:u(e,o)?{from:e,to:o}:{from:o,to:e};else if(o&&s){if(c(o,e)&&c(s,e))d=i?{from:o,to:s}:void 0;else if(c(o,e))d={from:o,to:n>0?void 0:e};else if(c(s,e))d={from:e,to:n>0?void 0:e};else if(u(e,o))d={from:e,to:s};else if(l(e,o))d={from:o,to:e};else if(l(e,s))d={from:o,to:e};else throw Error(`Invalid range`)}if(d?.from&&d?.to){let t=a.differenceInCalendarDays(d.to,d.from);(r>0&&t>r||n>1&&t<n)&&(d={from:e,to:void 0})}return d}function Lye(e,t,n=Sj){let r=Array.isArray(t)?t:[t],i=e.from,a=n.differenceInCalendarDays(e.to,e.from),o=Math.min(a,6);for(let e=0;e<=o;e++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function oM(e,t,n=Sj){return Aj(e,t.from,!1,n)||Aj(e,t.to,!1,n)||Aj(t,e.from,!1,n)||Aj(t,e.to,!1,n)}function Rye(e,t,n=Sj){let r=Array.isArray(t)?t:[t];if(r.filter(e=>typeof e!=`function`).some(t=>typeof t==`boolean`?t:n.isDate(t)?Aj(e,t,!1,n):Ij(t,n)?t.some(t=>Aj(e,t,!1,n)):Mj(t)?t.from&&t.to?oM(e,{from:t.from,to:t.to},n):!1:Fj(t)?Lye(e,t.dayOfWeek,n):jj(t)?n.isAfter(t.before,t.after)?oM(e,{from:n.addDays(t.after,1),to:n.addDays(t.before,-1)},n):Lj(e.from,t,n)||Lj(e.to,t,n):Nj(t)||Pj(t)?Lj(e.from,t,n)||Lj(e.to,t,n):!1))return!0;let i=r.filter(e=>typeof e==`function`);if(i.length){let t=e.from,r=n.differenceInCalendarDays(e.to,e.from);for(let e=0;e<=r;e++){if(i.some(e=>e(t)))return!0;t=n.addDays(t,1)}}return!1}function zye(e,t){let{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:o,onSelect:s}=e,[c,l]=nM(a,s?a:void 0),u=s?a:c;return{selected:u,select:(a,c,d)=>{let{min:f,max:p}=e,m;if(a){let e=u?.from,n=u?.to,r=!!e&&!!n,s=!!e&&!!n&&t.isSameDay(e,n)&&t.isSameDay(a,e);m=i&&(r||!u?.from)?!o&&s?void 0:{from:a,to:void 0}:Iye(a,u,f,p,o,t)}return r&&n&&m?.from&&m.to&&Rye({from:m.from,to:m.to},n,t)&&(m.from=a,m.to=void 0),s||l(m),s?.(m,a,c,d),m},isSelected:e=>u&&Aj(u,e,!1,t)}}function Bye(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=nM(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t;return{selected:s,select:(e,t,n)=>{let a=e;return!r&&s&&s&&c(e,s)&&(a=void 0),i||o(a),i?.(a,e,t,n),a},isSelected:e=>s?c(s,e):!1}}function Vye(e,t){let n=Bye(e,t),r=Fye(e,t),i=zye(e,t);switch(e.mode){case`single`:return n;case`multiple`:return r;case`range`:return i;default:return}}function sM(e,t){return e instanceof vj&&e.timeZone===t?e:new vj(e,t)}function cM(e,t,n){if(!n)return sM(e,t);let r=sM(e,t),i=new vj(r.getFullYear(),r.getMonth(),r.getDate(),12,0,0,t);return new Date(i.getTime())}function lM(e,t,n){return typeof e==`boolean`||typeof e==`function`?e:e instanceof Date?cM(e,t,n):Array.isArray(e)?e.map(e=>e instanceof Date?cM(e,t,n):e):Mj(e)?{...e,from:e.from?sM(e.from,t):e.from,to:e.to?sM(e.to,t):e.to}:jj(e)?{before:cM(e.before,t,n),after:cM(e.after,t,n)}:Nj(e)?{after:cM(e.after,t,n)}:Pj(e)?{before:cM(e.before,t,n)}:e}function uM(e,t,n){return e&&(Array.isArray(e)?e.map(e=>lM(e,t,n)):lM(e,t,n))}function Hye(e){let t=e,n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=sM(t.today,n)),t.month&&(t.month=sM(t.month,n)),t.defaultMonth&&(t.defaultMonth=sM(t.defaultMonth,n)),t.startMonth&&(t.startMonth=sM(t.startMonth,n)),t.endMonth&&(t.endMonth=sM(t.endMonth,n)),t.mode===`single`&&t.selected?t.selected=sM(t.selected,n):t.mode===`multiple`&&t.selected?t.selected=t.selected?.map(e=>sM(e,n)):t.mode===`range`&&t.selected&&(t.selected={from:t.selected.from?sM(t.selected.from,n):t.selected.from,to:t.selected.to?sM(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=uM(t.disabled,n)),t.hidden!==void 0&&(t.hidden=uM(t.hidden,n)),t.modifiers)){let e={};Object.keys(t.modifiers).forEach(r=>{e[r]=uM(t.modifiers?.[r],n)}),t.modifiers=e}let{components:r,formatters:i,labels:a,dateLib:o,locale:s,classNames:c}=(0,b.useMemo)(()=>{let e={...bj,...t.locale},n=t.broadcastCalendar?1:t.weekStartsOn,r=t.noonSafe&&t.timeZone?vye(t.timeZone,{weekStartsOn:n,locale:e}):void 0,i=t.dateLib&&r?{...r,...t.dateLib}:t.dateLib??r,a=new xj({locale:e,weekStartsOn:n,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},i);return{dateLib:a,components:eye(t.components),formatters:uye(t.formatters),labels:pye(t.labels,a.options),locale:e,classNames:{...Rj(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:o.today()});let{captionLayout:l,mode:u,navLayout:d,numberOfMonths:f=1,onDayBlur:p,onDayClick:m,onDayFocus:h,onDayKeyDown:g,onDayMouseEnter:_,onDayMouseLeave:v,onNextClick:y,onPrevClick:x,showWeekNumber:S,styles:C}=t,{formatCaption:w,formatDay:T,formatMonthDropdown:E,formatWeekNumber:D,formatWeekNumberHeader:O,formatWeekdayName:k,formatYearDropdown:A}=i,j=jye(t,o),{days:M,months:N,navStart:P,navEnd:F,previousMonth:I,nextMonth:L,goToMonth:R}=j,ee=Qve(M,t,P,F,o),{isSelected:te,select:ne,selected:re}=Vye(t,o)??{},{blur:ie,focused:ae,isFocusTarget:oe,moveFocus:se,setFocused:ce}=Pye(t,j,ee,te??(()=>!1),o),{labelDayButton:le,labelGridcell:ue,labelGrid:de,labelMonthDropdown:fe,labelNav:pe,labelPrevious:me,labelNext:he,labelWeekday:ge,labelWeekNumber:_e,labelWeekNumberHeader:ve,labelYearDropdown:ye}=a,be=(0,b.useMemo)(()=>gye(o,t.ISOWeek,t.broadcastCalendar,t.today),[o,t.ISOWeek,t.broadcastCalendar,t.today]),xe=u!==void 0||m!==void 0,Se=(0,b.useCallback)(()=>{I&&(R(I),x?.(I))},[I,R,x]),Ce=(0,b.useCallback)(()=>{L&&(R(L),y?.(L))},[R,L,y]),we=(0,b.useCallback)((e,t)=>n=>{n.preventDefault(),n.stopPropagation(),ce(e),!t.disabled&&(ne?.(e.date,t,n),m?.(e.date,t,n))},[ne,m,ce]),z=(0,b.useCallback)((e,t)=>n=>{ce(e),h?.(e.date,t,n)},[h,ce]),B=(0,b.useCallback)((e,t)=>n=>{ie(),p?.(e.date,t,n)},[ie,p]),Te=(0,b.useCallback)((e,n)=>r=>{let i={ArrowLeft:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`after`:`before`],ArrowRight:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`before`:`after`],ArrowDown:[r.shiftKey?`year`:`week`,`after`],ArrowUp:[r.shiftKey?`year`:`week`,`before`],PageUp:[r.shiftKey?`year`:`month`,`before`],PageDown:[r.shiftKey?`year`:`month`,`after`],Home:[`startOfWeek`,`before`],End:[`endOfWeek`,`after`]};if(i[r.key]){r.preventDefault(),r.stopPropagation();let[e,t]=i[r.key];se(e,t)}g?.(e.date,n,r)},[se,g,t.dir]),Ee=(0,b.useCallback)((e,t)=>n=>{_?.(e.date,t,n)},[_]),V=(0,b.useCallback)((e,t)=>n=>{v?.(e.date,t,n)},[v]),De=(0,b.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setMonth(o.startOfMonth(e),r);R(o.addMonths(i,-t))},[o,R]),Oe=(0,b.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setYear(o.startOfMonth(e),r);R(o.addMonths(i,-t))},[o,R]),{className:ke,style:Ae}=(0,b.useMemo)(()=>({className:[c[wj.Root],t.className].filter(Boolean).join(` `),style:{...C?.[wj.Root],...t.style}}),[c,t.className,t.style,C]),je=tye(t),Me=e=>{let t=C?.[wj.Dropdown],n=C?.[e];if(!(!t&&!n))return{...t,...n}},Ne=(0,b.useRef)(null);Sye(Ne,!!t.animate,{classNames:c,months:N,focused:ae,dateLib:o});let Pe={dayPickerProps:t,selected:re,select:ne,isSelected:te,months:N,nextMonth:L,previousMonth:I,goToMonth:R,getModifiers:ee,components:r,classNames:c,styles:C,labels:a,formatters:i};return b.createElement(Oj.Provider,{value:Pe},b.createElement(r.Root,{rootRef:t.animate?Ne:void 0,className:ke,style:Ae,dir:t.dir,id:t.id,lang:t.lang??s.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t[`aria-label`],"aria-labelledby":t[`aria-labelledby`],...je},b.createElement(r.Months,{className:c[wj.Months],style:C?.[wj.Months]},!t.hideNavigation&&!d&&b.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[wj.Nav],style:C?.[wj.Nav],"aria-label":pe(),onPreviousClick:Se,onNextClick:Ce,previousMonth:I,nextMonth:L}),N.map((e,n)=>{let a=t.reverseMonths?N.length-1-n:n;return b.createElement(r.Month,{"data-animated-month":t.animate?`true`:void 0,className:c[wj.Month],style:C?.[wj.Month],key:n,displayIndex:n,calendarMonth:e},d===`around`&&!t.hideNavigation&&n===0&&b.createElement(r.PreviousMonthButton,{type:`button`,className:c[wj.PreviousMonthButton],style:C?.[wj.PreviousMonthButton],tabIndex:I?void 0:-1,"aria-disabled":!I||void 0,"aria-label":me(I),onClick:Se,"data-animated-button":t.animate?`true`:void 0},b.createElement(r.Chevron,{disabled:!I||void 0,className:c[wj.Chevron],style:C?.[wj.Chevron],orientation:t.dir===`rtl`?`right`:`left`})),b.createElement(r.MonthCaption,{"data-animated-caption":t.animate?`true`:void 0,className:c[wj.MonthCaption],style:C?.[wj.MonthCaption],calendarMonth:e,displayIndex:n},l?.startsWith(`dropdown`)?b.createElement(r.DropdownNav,{className:c[wj.Dropdowns],style:C?.[wj.Dropdowns]},(()=>{let n=l===`dropdown`||l===`dropdown-months`?b.createElement(r.MonthsDropdown,{key:`month`,className:c[wj.MonthsDropdown],"aria-label":fe(),disabled:!!t.disableNavigation,onChange:De(e.date,a),options:mye(e.date,P,F,i,o),style:Me(wj.MonthsDropdown),value:o.getMonth(e.date)}):b.createElement(`span`,{key:`month`},E(e.date,o)),s=l===`dropdown`||l===`dropdown-years`?b.createElement(r.YearsDropdown,{key:`year`,className:c[wj.YearsDropdown],"aria-label":ye(o.options),disabled:!!t.disableNavigation,onChange:Oe(e.date,a),options:_ye(P,F,i,o,!!t.reverseYears),style:Me(wj.YearsDropdown),value:o.getYear(e.date)}):b.createElement(`span`,{key:`year`},A(e.date,o));return o.getMonthYearOrder()===`year-first`?[s,n]:[n,s]})(),b.createElement(`span`,{role:`status`,"aria-live":`polite`,style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}},w(e.date,o.options,o))):b.createElement(r.CaptionLabel,{className:c[wj.CaptionLabel],style:C?.[wj.CaptionLabel],role:`status`,"aria-live":`polite`},w(e.date,o.options,o))),d===`around`&&!t.hideNavigation&&n===f-1&&b.createElement(r.NextMonthButton,{type:`button`,className:c[wj.NextMonthButton],style:C?.[wj.NextMonthButton],tabIndex:L?void 0:-1,"aria-disabled":!L||void 0,"aria-label":he(L),onClick:Ce,"data-animated-button":t.animate?`true`:void 0},b.createElement(r.Chevron,{disabled:!L||void 0,className:c[wj.Chevron],style:C?.[wj.Chevron],orientation:t.dir===`rtl`?`left`:`right`})),n===f-1&&d===`after`&&!t.hideNavigation&&b.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[wj.Nav],style:C?.[wj.Nav],"aria-label":pe(),onPreviousClick:Se,onNextClick:Ce,previousMonth:I,nextMonth:L}),b.createElement(r.MonthGrid,{role:`grid`,"aria-multiselectable":u===`multiple`||u===`range`,"aria-label":de(e.date,o.options,o)||void 0,className:c[wj.MonthGrid],style:C?.[wj.MonthGrid]},!t.hideWeekdays&&b.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?`true`:void 0,className:c[wj.Weekdays],style:C?.[wj.Weekdays]},S&&b.createElement(r.WeekNumberHeader,{"aria-label":ve(o.options),className:c[wj.WeekNumberHeader],style:C?.[wj.WeekNumberHeader],scope:`col`},O()),be.map(e=>b.createElement(r.Weekday,{"aria-label":ge(e,o.options,o),className:c[wj.Weekday],key:String(e),style:C?.[wj.Weekday],scope:`col`},k(e,o.options,o)))),b.createElement(r.Weeks,{"data-animated-weeks":t.animate?`true`:void 0,className:c[wj.Weeks],style:C?.[wj.Weeks]},e.weeks.map(e=>b.createElement(r.Week,{className:c[wj.Week],key:e.weekNumber,style:C?.[wj.Week],week:e},S&&b.createElement(r.WeekNumber,{week:e,style:C?.[wj.WeekNumber],"aria-label":_e(e.weekNumber,{locale:s}),className:c[wj.WeekNumber],scope:`row`,role:`rowheader`},D(e.weekNumber,o)),e.days.map(e=>{let{date:n}=e,i=ee(e);if(i[Tj.focused]=!i.hidden&&!!ae?.isEqualTo(e),i[Ej.selected]=te?.(n)||i.selected,Mj(re)){let{from:e,to:t}=re;i[Ej.range_start]=!!(e&&t&&o.isSameDay(n,e)),i[Ej.range_end]=!!(e&&t&&o.isSameDay(n,t)),i[Ej.range_middle]=Aj(re,n,!0,o)}let a=hye(i,C,t.modifiersStyles),s=$ve(i,c,t.modifiersClassNames),l=!xe&&!i.hidden?ue(n,i,o.options,o):void 0;return b.createElement(r.Day,{key:`${e.isoDate}_${e.displayMonthId}`,day:e,modifiers:i,className:s.join(` `),style:a,role:`gridcell`,"aria-selected":i.selected||void 0,"aria-label":l,"data-day":e.isoDate,"data-month":e.outside?e.dateMonthId:void 0,"data-selected":i.selected||void 0,"data-disabled":i.disabled||void 0,"data-hidden":i.hidden||void 0,"data-outside":e.outside||void 0,"data-focused":i.focused||void 0,"data-today":i.today||void 0},!i.hidden&&xe?b.createElement(r.DayButton,{className:c[wj.DayButton],style:C?.[wj.DayButton],type:`button`,day:e,modifiers:i,disabled:!i.focused&&i.disabled||void 0,"aria-disabled":i.focused&&i.disabled||void 0,tabIndex:oe(e)?0:-1,"aria-label":le(n,i,o.options,o),onClick:we(e,i),onBlur:B(e,i),onFocus:z(e,i),onKeyDown:Te(e,i),onMouseEnter:Ee(e,i),onMouseLeave:V(e,i)},T(n,o.options,o)):!i.hidden&&T(e.date,o.options,o))}))))))})),t.footer&&b.createElement(r.Footer,{className:c[wj.Footer],style:C?.[wj.Footer],role:`status`,"aria-live":`polite`},t.footer)))}function dM({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r=`label`,buttonVariant:i=`ghost`,formatters:a,components:o,...s}){let c=Rj();return(0,Y.jsx)(Hye,{showOutsideDays:n,className:X(`bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent`,String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:e=>e.toLocaleString(`default`,{month:`short`}),...a},classNames:{root:X(`w-fit`,c.root),months:X(`relative flex flex-col gap-4 md:flex-row`,c.months),month:X(`flex w-full flex-col gap-4`,c.month),nav:X(`absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1`,c.nav),button_previous:X(e_({variant:i}),`h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50`,c.button_previous),button_next:X(e_({variant:i}),`h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50`,c.button_next),month_caption:X(`flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]`,c.month_caption),dropdowns:X(`flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium`,c.dropdowns),dropdown_root:X(`has-focus:border-border-focus border-input shadow-xs has-focus:ring-border-focus has-focus:ring-[3px] relative rounded-md border`,c.dropdown_root),dropdown:X(`bg-popover absolute inset-0 opacity-0`,c.dropdown),caption_label:X(`select-none font-medium`,r===`label`?`text-sm`:`[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5`,c.caption_label),month_grid:`w-full border-collapse`,weekdays:X(`flex`,c.weekdays),weekday:X(`text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal`,c.weekday),week:X(`mt-2 flex w-full`,c.week),week_number_header:X(`w-[--cell-size] select-none`,c.week_number_header),week_number:X(`text-muted-foreground select-none text-[0.8rem]`,c.week_number),day:X(`group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md`,c.day),range_start:X(`bg-accent rounded-l-md`,c.range_start),range_middle:X(`rounded-none`,c.range_middle),range_end:X(`bg-accent rounded-r-md`,c.range_end),today:X(`bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none`,c.today),outside:X(`text-muted-foreground aria-selected:text-muted-foreground`,c.outside),disabled:X(`text-muted-foreground opacity-50`,c.disabled),hidden:X(`invisible`,c.hidden),...t},components:{Root:({className:e,rootRef:t,...n})=>(0,Y.jsx)(`div`,{"data-slot":`calendar`,ref:t,className:X(e),...n}),Chevron:({className:e,orientation:t,...n})=>t===`left`?(0,Y.jsx)(Lv,{className:X(`size-4`,e),...n}):t===`right`?(0,Y.jsx)(Rv,{className:X(`size-4`,e),...n}):(0,Y.jsx)(Iv,{className:X(`size-4`,e),...n}),DayButton:Uye,WeekNumber:({children:e,...t})=>(0,Y.jsx)(`td`,{...t,children:(0,Y.jsx)(`div`,{className:`flex size-[--cell-size] items-center justify-center text-center`,children:e})}),...o},...s})}function Uye({className:e,day:t,modifiers:n,...r}){let i=Rj(),a=b.useRef(null);return b.useEffect(()=>{n.focused&&a.current?.focus()},[n.focused]),(0,Y.jsx)(t_,{ref:a,variant:`ghost`,size:`icon`,"data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:X(`data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-border-focus group-data-[focused=true]/day:ring-border-focus flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70`,i.day,e),...r})}var Wye=/^(\d{4})-(\d{2})-(\d{2})$/,Gye=/^(\d{4})-(\d{2})-(\d{2})T/;function fM(e){return`${String(e.getFullYear()).padStart(4,`0`)}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function pM(e){let t=Wye.exec(e)??Gye.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i);return a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a}function Kye({path:e,readonly:t}){let n=`date`,r=Cb(e),i=Ob(e,n),{patchPath:a,addPatch:o}=vb(e),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(!1),d=eb();if((0,b.useEffect)(()=>{if(`data`in i&&i.data!==void 0){if(i.data===null)c(i.data);else{let e=pM(i.data);e===null&&console.error(`Cannot parse invalid date:`,i.data),c(e)}}},[i]),r.status===`error`)return(0,Y.jsx)(NC,{path:e,error:r.error,type:n});if(i.status===`error`)return(0,Y.jsx)(FC,{path:e,error:i.error,schema:r});if(i.status==`not-found`||r.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(r.status===`loading`||!(`data`in i)||i.data===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(r.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:r.data.type});let f=r.data,p=f.options?.from?pM(f.options.from):null,m=f.options?.to?pM(f.options.to):null,h=s==null?null:p&&s<p?p:m&&s>m?m:s,g=(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsxs)(SD,{open:!t&&l,onOpenChange:e=>{t||u(e)},children:[(0,Y.jsx)(CD,{asChild:!0,onClick:()=>{t||u(!0)},children:(0,Y.jsxs)(t_,{variant:`outline`,disabled:t,className:(0,AC.default)(`w-[280px] justify-start text-left font-normal bg-bg-primary hover:bg-bg-secondary`),children:[(0,Y.jsx)(Pv,{className:`w-4 h-4 mr-2`}),h?uj(h,`PPP`):(0,Y.jsx)(`span`,{children:`Pick a date`})]})}),(0,Y.jsx)(wD,{className:`w-auto p-0`,container:d,children:(0,Y.jsx)(dM,{mode:`single`,captionLayout:`dropdown`,defaultMonth:h??void 0,weekStartsOn:1,startMonth:p??void 0,endMonth:m??void 0,disabled:[...p?[{before:p}]:[],...m?[{after:m}]:[]],selected:h||void 0,onSelect:e=>{e&&(c(e),o([{op:`replace`,value:fM(e),path:a}],f.type),u(!1))}})})]})});return t?(0,Y.jsx)(NT,{children:g}):g}function qye({path:e}){let t=Ob(e,`date`);if(t.status===`error`)return(0,Y.jsx)(FC,{path:e,error:t.error});if(!(`data`in t)||t.data===void 0)return(0,Y.jsx)(J3,{path:e});if(t.data===null)return(0,Y.jsx)(Y3,{path:e});let n=pM(t.data);return(0,Y.jsx)(`div`,{className:`truncate`,children:n?n.toLocaleDateString():t.data})}var mM=`val:datetime:tz`,Jye=[`UTC`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`Europe/Madrid`,`Europe/Oslo`,`Europe/Stockholm`,`Europe/Moscow`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`America/Sao_Paulo`,`America/Mexico_City`,`Asia/Tokyo`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Asia/Jerusalem`,`Australia/Sydney`,`Australia/Melbourne`,`Pacific/Auckland`];function hM(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function Yye(){try{let e=Intl;if(typeof e.supportedValuesOf==`function`)return e.supportedValuesOf(`timeZone`)}catch{}return Jye}function Xye(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).formatToParts(e),r=e=>Number(n.find(t=>t.type===e)?.value),i=r(`year`),a=r(`month`),o=r(`day`),s=r(`hour`),c=r(`minute`),l=r(`second`);s===24&&(s=0);let u=Date.UTC(i,a-1,o,s,c,l);return Math.round((u-e.getTime())/6e4)}function Zye(e,t,n,r,i,a,o){let s=Date.UTC(e,t-1,n,r,i,a),c=s;for(let e=0;e<3;e++){let e=s-Xye(new Date(c),o)*6e4;if(e===c)break;c=e}return new Date(c)}function Qye(e,t){try{return new Intl.DateTimeFormat(void 0,{timeZone:t,dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}function $ye(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).formatToParts(e),r=e=>n.find(t=>t.type===e)?.value??`00`,i=r(`hour`);return i===`24`&&(i=`00`),{date:`${r(`year`)}-${r(`month`)}-${r(`day`)}`,time:`${i}:${r(`minute`)}:${r(`second`)}`}}function ebe({value:e,onChange:t,from:n,to:r,defaultTimezone:i,availableTimezones:a,persistTimezone:o=!1,portalContainer:s=null,id:c,readonly:l}){let[u,d]=(0,b.useState)(!1),f=(0,b.useMemo)(()=>hM(),[]),[p,m]=(0,b.useState)(()=>i||f),h=(0,b.useMemo)(()=>{if(a)return a;let e=Yye();return[f,...e.filter(e=>e!==f)]},[a,f]),g=n?new Date(n):null,_=r?new Date(r):null,v=e==null?null:g&&e<g?g:_&&e>_?_:e,y=v?$ye(v,p):{date:``,time:``},x=(e,n,r)=>{if(!e)return;let[i,a,o]=e.split(`-`).map(e=>Number(e)),s=n.split(`:`).map(e=>Number(e)),c=s[0]||0,l=s[1]||0,u=s[2]||0;[i,a,o,c,l,u].some(e=>Number.isNaN(e))||t(Zye(i,a,o,c,l,u,r).toISOString())},S=e=>{if(m(e),o)try{localStorage.setItem(mM,e)}catch{}};return(0,Y.jsx)(`div`,{id:c,children:(0,Y.jsxs)(SD,{open:!l&&u,onOpenChange:e=>{l||d(e)},children:[(0,Y.jsx)(CD,{asChild:!0,onClick:()=>{l||d(!0)},children:(0,Y.jsxs)(t_,{variant:`outline`,disabled:l,className:(0,AC.default)(`w-[280px] justify-start text-left font-normal bg-bg-primary hover:bg-bg-secondary`),children:[(0,Y.jsx)(Pv,{className:`w-4 h-4 mr-2`}),v?(0,Y.jsx)(`span`,{className:`truncate`,children:Qye(v,p)}):(0,Y.jsx)(`span`,{children:`Pick a date & time`})]})}),(0,Y.jsxs)(wD,{className:`w-auto p-0`,container:s,children:[(0,Y.jsx)(dM,{mode:`single`,captionLayout:`dropdown`,defaultMonth:v??void 0,weekStartsOn:1,startMonth:g??void 0,endMonth:_??void 0,disabled:[...g?[{before:g}]:[],..._?[{after:_}]:[]],selected:v||void 0,onSelect:e=>{if(e){let t=y.time||`12:00:00`;x(fM(e),t,p)}}}),(0,Y.jsxs)(`div`,{className:`p-3 pt-0 flex flex-col gap-2`,children:[(0,Y.jsx)(MT,{type:`time`,step:1,disabled:l,className:`[color-scheme:light] dark:[color-scheme:dark]`,value:y.time||`12:00:00`,onChange:e=>{let t=y.date||fM(new Date);x(t,e.target.value,p)}}),(0,Y.jsxs)(nD,{value:p,disabled:l,onValueChange:e=>{S(e)},children:[(0,Y.jsx)(iD,{className:`text-xs text-fg-tertiary h-7`,children:(0,Y.jsx)(rD,{placeholder:`Timezone`})}),(0,Y.jsx)(aD,{container:s,children:h.map(e=>(0,Y.jsxs)(oD,{value:e,children:[e,e===f?` (browser)`:``]},e))})]})]})]})]})})}function tbe({path:e,readonly:t}){let n=`dateTime`,r=Cb(e),i=Ob(e,n),{patchPath:a,addPatch:o}=vb(e),[s,c]=(0,b.useState)(null),l=eb(),u=(0,b.useMemo)(()=>{try{return localStorage.getItem(mM)||hM()}catch{return hM()}},[]);if((0,b.useEffect)(()=>{if(`data`in i&&i.data!==void 0){if(i.data===null)c(null);else{let e=new Date(i.data);Number.isNaN(e.getTime())?console.error(`Cannot parse invalid datetime:`,i.data):c(e)}}},[i]),r.status===`error`)return(0,Y.jsx)(NC,{path:e,error:r.error,type:n});if(i.status===`error`)return(0,Y.jsx)(FC,{path:e,error:i.error,schema:r});if(i.status==`not-found`||r.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(r.status===`loading`||!(`data`in i)||i.data===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(r.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:r.data.type});let d=r.data,f=(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(ebe,{value:s,onChange:e=>{c(new Date(e)),o([{op:`replace`,value:e,path:a}],d.type)},from:d.options?.from,to:d.options?.to,defaultTimezone:u,persistTimezone:!0,portalContainer:l,readonly:t})});return t?(0,Y.jsx)(NT,{children:f}):f}function nbe({path:e}){let t=Ob(e,`dateTime`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{className:`truncate`,children:new Date(t.data).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})})}function gM(){return gM=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gM.apply(null,arguments)}function rbe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var _M=[],vM=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?vM:_M).push(n+=e[t])})();function ibe(e){if(e<768)return!1;for(let t=0,n=_M.length;;){let r=t+n>>1;if(e<_M[r])n=r;else if(e>=vM[r])t=r+1;else return!0;if(t==n)return!1}}function yM(e){return e>=127462&&e<=127487}var bM=8205;function abe(e,t,n=!0,r=!0){return(n?xM:obe)(e,t,r)}function xM(e,t,n){if(t==e.length)return t;t&&CM(e.charCodeAt(t))&&wM(e.charCodeAt(t-1))&&t--;let r=SM(e,t);for(t+=TM(r);t<e.length;){let i=SM(e,t);if(r==bM||i==bM||n&&ibe(i))t+=TM(i),r=i;else if(yM(i)){let n=0,r=t-2;for(;r>=0&&yM(SM(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function obe(e,t,n){for(;t>0;){let r=xM(e,t-2,n);if(r<t)return r;t--}return 0}function SM(e,t){let n=e.charCodeAt(t);if(!wM(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return CM(r)?(n-55296<<10)+(r-56320)+65536:n}function CM(e){return e>=56320&&e<57344}function wM(e){return e>=55296&&e<56320}function TM(e){return e<65536?1:2}var EM=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=PM(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),OM.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=PM(this,e,t);let n=[];return this.decompose(e,t,n,0),OM.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new jM(this),i=new jM(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new jM(this,e)}iterRange(e,t=this.length){return new MM(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new NM(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new DM(t):OM.from(DM.split(t,[]))}},DM=class e extends EM{constructor(e,t=sbe(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new cbe(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(AM(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=kM(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=PM(this,t,n);let i=kM(this.text,kM(r.text,AM(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):OM.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
142
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Sme=`DialogDescriptionWarning`,Cme=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${RO(Sme).contentName}}.`;return b.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},wme=CO,Tme=DO,Eme=kO,Dme=jO,zO=`[cmdk-group=""]`,BO=`[cmdk-group-items=""]`,Ome=`[cmdk-group-heading=""]`,VO=`[cmdk-item=""]`,HO=`${VO}:not([aria-disabled="true"])`,UO=`cmdk-item-select`,WO=`data-value`,kme=(e,t,n)=>Dpe(e,t,n),GO=b.createContext(void 0),KO=()=>b.useContext(GO),qO=b.createContext(void 0),JO=()=>b.useContext(qO),YO=b.createContext(void 0),XO=b.forwardRef((e,t)=>{let n=ek(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=ek(()=>new Set),i=ek(()=>new Map),a=ek(()=>new Map),o=ek(()=>new Set),s=QO(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Pm(),y=Pm(),x=Pm(),S=b.useRef(null),C=Bme();$O(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),$O(()=>{C(6,A)},[]);let w=b.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=b.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:x,labelId:y,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??kme;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(BO);t?t.appendChild(e.parentElement===t?e:e.closest(`${BO} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${BO} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${zO}[${WO}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(WO);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(zO)?.querySelector(Ome))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${VO}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(HO)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(WO))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(WO))}function F(e){let t=j()?.closest(zO),n;for(;t&&!n;)t=e>0?Rme(t,zO):zme(t,zO),n=t?.querySelector(HO);n?w.setState(`value`,n.getAttribute(WO)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return b.createElement(xm.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(UO);t.dispatchEvent(e)}}}}},b.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:Hme},c),rk(e,e=>b.createElement(qO.Provider,{value:w},b.createElement(GO.Provider,{value:T},e))))}),Ame=b.forwardRef((e,t)=>{let n=Pm(),r=b.useRef(null),i=b.useContext(YO),a=KO(),o=QO(e),s=o.current?.forceMount??i?.forceMount;$O(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=nk(n,r,[e.value,e.children,r],e.keywords),l=JO(),u=tk(e=>e.value&&e.value===c.current),d=tk(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);b.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(UO,f),()=>t.removeEventListener(UO,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return b.createElement(xm.div,{ref:im(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),jme=b.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Pm(),s=b.useRef(null),c=b.useRef(null),l=Pm(),u=KO(),d=tk(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));$O(()=>u.group(o),[]),nk(o,s,[e.value,e.heading,c]);let f=b.useMemo(()=>({id:o,forceMount:i}),[i]);return b.createElement(xm.div,{ref:im(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&b.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),rk(e,e=>b.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},b.createElement(YO.Provider,{value:f},e))))}),Mme=b.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=b.useRef(null),a=tk(e=>!e.search);return!n&&!a?null:b.createElement(xm.div,{ref:im(i,t),...r,"cmdk-separator":``,role:`separator`})}),Nme=b.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=JO(),o=tk(e=>e.search),s=tk(e=>e.selectedItemId),c=KO();return b.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),b.createElement(xm.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),Pme=b.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=b.useRef(null),o=b.useRef(null),s=tk(e=>e.selectedItemId),c=KO();return b.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),b.createElement(xm.div,{ref:im(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},rk(e,e=>b.createElement(`div`,{ref:im(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Fme=b.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return b.createElement(wme,{open:n,onOpenChange:r},b.createElement(Tme,{container:o},b.createElement(Eme,{"cmdk-overlay":``,className:i}),b.createElement(Dme,{"aria-label":e.label,"cmdk-dialog":``,className:a},b.createElement(XO,{ref:t,...s}))))}),Ime=b.forwardRef((e,t)=>tk(e=>e.filtered.count===0)?b.createElement(xm.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),Lme=b.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return b.createElement(xm.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},rk(e,e=>b.createElement(`div`,{"aria-hidden":!0},e)))}),ZO=Object.assign(XO,{List:Pme,Item:Ame,Input:Nme,Group:jme,Separator:Mme,Dialog:Fme,Empty:Ime,Loading:Lme});function Rme(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function zme(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function QO(e){let t=b.useRef(e);return $O(()=>{t.current=e}),t}var $O=typeof window>`u`?b.useEffect:b.useLayoutEffect;function ek(e){let t=b.useRef();return t.current===void 0&&(t.current=e()),t}function tk(e){let t=JO(),n=()=>e(t.snapshot());return b.useSyncExternalStore(t.subscribe,n,n)}function nk(e,t,n,r=[]){let i=b.useRef(),a=KO();return $O(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(WO,s),i.current=s}),i}var Bme=()=>{let[e,t]=b.useState(),n=ek(()=>new Map);return $O(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function Vme(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function rk({asChild:e,children:t},n){return e&&b.isValidElement(t)?b.cloneElement(Vme(t),{ref:t.ref},n(t.props.children)):n(t)}var Hme={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},ik=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO,{ref:n,className:X(`flex h-full w-full flex-col overflow-hidden rounded-md bg-bg-primary text-fg-primary`,e),...t}));ik.displayName=ZO.displayName;var ak=b.forwardRef(({className:e,...t},n)=>(0,Y.jsxs)(`div`,{className:`flex items-center px-3`,"cmdk-input-wrapper":``,children:[(0,Y.jsx)(My,{className:`w-4 h-4 mr-2 opacity-50 shrink-0`}),(0,Y.jsx)(ZO.Input,{ref:n,className:X(`flex h-11 w-full rounded-md py-3 text-sm`,`placeholder:text-fg-secondary`,`bg-transparent rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]}));ak.displayName=ZO.Input.displayName;var ok=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO.List,{ref:n,className:X(`max-h-[300px] overflow-y-auto overflow-x-hidden`,e),...t}));ok.displayName=ZO.List.displayName;var sk=b.forwardRef((e,t)=>(0,Y.jsx)(ZO.Empty,{ref:t,className:`py-6 text-sm text-center`,...e}));sk.displayName=ZO.Empty.displayName;var ck=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO.Group,{ref:n,className:X(`overflow-hidden p-1 text-fg-primary [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-fg-secondary`,e),...t}));ck.displayName=ZO.Group.displayName;var lk=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO.Separator,{ref:n,className:X(`-mx-1 h-px bg-border-primary opacity-50`,e),...t}));lk.displayName=ZO.Separator.displayName;var uk=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(ZO.Item,{ref:n,className:X(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-bg-primary-hover aria-selected:text-fg-primary data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,e),...t}));uk.displayName=ZO.Item.displayName;function dk({title:e,subtitle:t,image:n,className:r,imageSize:i=`md`}){let a=Ume(n);return(0,Y.jsxs)(`div`,{className:X(`flex min-w-0 flex-1 items-center gap-2`,r),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[e!=null&&e!==``&&(typeof e==`string`?(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e}):(0,Y.jsx)(`div`,{className:`font-medium`,children:e})),t!=null&&t!==``&&(typeof t==`string`?(0,Y.jsx)(`span`,{className:`truncate text-xs text-fg-secondary`,children:t}):(0,Y.jsx)(`div`,{className:`text-xs text-fg-secondary`,children:t}))]}),a&&(0,Y.jsx)(`div`,{className:X(`shrink-0 overflow-hidden rounded bg-bg-secondary`,i===`sm`?`h-7 w-7`:`h-8 w-8`),children:(0,Y.jsx)(`img`,{src:a,alt:typeof e==`string`?e:``,className:`h-full w-full object-cover`,loading:`lazy`})})]})}function Ume(e){return e==null?null:typeof e==`string`?e:H.mediaUrl(e)}function fk(e){let{path:t,schema:n}=TD(e),r=xb(t);return(0,b.useMemo)(()=>Wme(e,t,n,r),[e,t,n,r])}function Wme(e,t,n,r){if(t===e||!n||!r||!(`data`in r)||!r.data)return;let i=r.data,[,a]=H.splitModuleFilePathAndModulePath(e);if(!a)return;let o=H.splitModulePath(a),s=o[o.length-1];if(n.type===`array`&&i.parent===`array`){let e=Number(s),t=i.items.find(([t])=>t===e);if(!Number.isNaN(e)&&t)return t[1]}else if(n.type===`record`&&i.parent===`record`){let e=i.items.find(([e])=>e===s);if(e)return e[1]}}function Gme(e){let t=new Map;for(let n of e){let e=t.get(n.moduleFilePath);e?e.push(n):t.set(n.moduleFilePath,[n])}return Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,label:mk(e),items:t}))}function pk({refs:e,currentPath:t,onSelect:n,searchPlaceholder:r=`Filter`}){let i=wb(),a=i.status===`success`?i.data:void 0,o=Eb(),s=e.map(e=>{let t=Xme(e),n=a?.[t.moduleFilePath];return{...t,isRouter:n?.type===`record`&&!!n.router}});return(0,Y.jsxs)(ik,{children:[(0,Y.jsx)(ak,{placeholder:r}),(0,Y.jsx)(ok,{children:s.length===0?(0,Y.jsx)(sk,{children:`No references found.`}):Gme(s).map(e=>(0,Y.jsx)(ck,{heading:e.label,title:e.moduleFilePath,children:e.items.map(e=>(0,Y.jsx)(Kme,{item:e,isCurrent:t===e.path,onSelect:()=>{n(ob(e.path,o,a)??e.path,{scrollToPath:e.path})}},e.path))},e.moduleFilePath))})]})}function Kme({item:e,isCurrent:t,onSelect:n}){let r=fk(e.path);return(0,Y.jsx)(qme,{item:e,isCurrent:t,onSelect:n,image:r?.image??null})}function qme({item:e,isCurrent:t,onSelect:n,image:r}){let i=e.patchPath.length>0,a=mk(e.moduleFilePath);return(0,Y.jsx)(uk,{value:`${e.preview?.title??``} ${e.fallbackLabel}`,onSelect:n,className:X(`flex items-center gap-2 rounded-lg border px-2.5 py-2 text-[0.8125rem]`,t?`border-border-brand-primary bg-bg-float-raised`:`border-border-float`),title:e.path,children:(0,Y.jsx)(dk,{title:i?(0,Y.jsx)(Jme,{patchPath:e.patchPath,isRouter:e.isRouter??!1}):a,image:r,imageSize:`sm`})})}function Jme({patchPath:e,isRouter:t}){let[n,...r]=e;return(0,Y.jsxs)(`span`,{className:`block truncate`,children:[t?(0,Y.jsx)(Yme,{route:n}):(0,Y.jsx)(`span`,{className:`text-fg-primary`,children:n}),r.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Rv,{size:12,className:`mx-0.5 inline-block shrink-0 text-fg-tertiary align-[-1px]`}),r.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[t>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:` / `}),(0,Y.jsx)(`span`,{className:`text-fg-primary`,children:kC(e)})]},t))]})]})}function Yme({route:e}){let t=e.split(`/`).filter(e=>e.length>0);return t.length===0?(0,Y.jsx)(`span`,{className:`text-fg-primary`,children:e}):(0,Y.jsx)(`span`,{children:t.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`}),(0,Y.jsx)(`span`,{className:`text-fg-primary`,children:e})]},t))})}function mk(e){return H.splitModuleFilePath(e).map(kC).join(` / `)}function Xme(e){let[t,n]=H.splitModuleFilePathAndModulePath(e),r=H.createPatchPath(n),i=kC(H.splitModuleFilePath(t).pop()||``);return{path:e,moduleFilePath:t,patchPath:r,fallbackLabel:r.length?`${i} → ${r.join(` → `)}`:i}}function hk({path:e,variant:t}){let n=Cb(e),{path:r,schema:i}=TD(e),[a]=H.splitModuleFilePathAndModulePath(e),o=xk(e),s=o[o.length-1],c=spe(r,ED(e,r,i)?s?.part:void 0),l=lC(),u=b.useMemo(()=>DD(`data`in n?n.data:void 0)&&l.status===`success`&&l.data&&`data`in n&&n.data.type===`record`&&n.data.router?gk(a,l.data,n.data.router):null,[n,l,a]),d=b.useMemo(()=>ED(e,r,i)&&l.status===`success`&&l.data&&i&&i.type===`record`&&i.router?gk(a,l.data,i.router):null,[e,r,i,l,a]),f=d?.every(e=>e.type===`literal`)||!1,p=!d||!f,m=!d||!f,h=u?.every(e=>e.type===`literal`)||!1,g=!u||!h,_=ED(e,r,i)&&i&&i.type===`record`&&i.router,v=upe(_?s?.part:void 0),y=_?ope(c,v):c,x=i?.type===`record`?i.key?.description:void 0,S=`data`in n&&n.data.type===`record`?n.data.key?.description:void 0;return(0,Y.jsxs)(`span`,{className:`inline-flex gap-2 items-center`,children:[ED(e,r,i)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_k,{refs:y.refs,variant:t}),m&&(0,Y.jsx)(vpe,{defaultValue:s.text,path:e,parentPath:r,variant:bk(t),size:yk(t),routePattern:d,references:y,keyDescription:x,children:(0,Y.jsx)(Aae,{size:vk(t)})}),p&&(0,Y.jsx)(dpe,{path:e,parentPath:r,variant:bk(t),size:yk(t),references:y,confirmationMessage:`This will delete the ${s.text} record.`,children:(0,Y.jsx)(zae,{size:vk(t)})})]}),$fe(`data`in n?n.data:void 0)&&(0,Y.jsx)(Zme,{path:e,variant:t}),DD(`data`in n?n.data:void 0)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_k,{refs:c.refs,variant:t}),g&&(0,Y.jsx)(hpe,{path:e,variant:bk(t),size:yk(t),routePattern:u,keyDescription:S,children:(0,Y.jsx)(Oy,{size:vk(t)})})]})]})}function gk(e,t,n){return n===`next-app-router`?np(tp(e,t)):null}function _k({refs:e,variant:t}){let n=eb(),{navigate:r,currentSourcePath:i}=GC(),[a,o]=b.useState(!1);return e.length===0?null:(0,Y.jsxs)(SD,{open:a,onOpenChange:o,children:[(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsx)(t_,{variant:bk(t),size:yk(t),role:`combobox`,"aria-expanded":a,children:(0,Y.jsx)(dy,{size:vk(t)})})})}),(0,Y.jsx)(Xg,{side:`top`,children:`References to this record`})]}),(0,Y.jsx)(wD,{className:`w-[clamp(300px, 40vw, 400px)] p-0 z-[8999]`,container:n,children:(0,Y.jsx)(pk,{refs:e,currentPath:i,onSelect:(e,{scrollToPath:t})=>{r(e,{scrollToPath:t}),o(!1)}})})]})}function vk(e){return e===`module`?16:12}function yk(e){return`icon`}function bk(e){return e===`module`?`outline`:`ghost`}function Zme({path:e,variant:t}){let{navigate:n}=GC(),{addPatch:r,patchPath:i}=vb(e),a=Cb(e),o=Ob(e,`array`),[s]=H.splitModuleFilePathAndModulePath(e);if(!(`data`in o)||!o.data||!(`data`in a))return null;let c=a.data;if(c.type!==`array`)return console.error(`Cannot add to non-array`,o,{parentPath:e}),null;let l=o.data.length;return(0,Y.jsx)(t_,{title:`Add`,size:yk(t),variant:bk(t),onClick:()=>{let e=i.concat(l.toString());r([{op:`add`,path:e,value:Cp(c.item)}],c.type),xr(c.item)||n(H.joinModuleFilePathAndModulePath(s,H.patchPathToModulePath(e)))},children:(0,Y.jsx)(Oy,{size:vk(t)})})}function xk(e){let[t,n]=H.splitModuleFilePathAndModulePath(e),r=H.splitModuleFilePath(t),i=r.map((e,n)=>({text:kC(e),part:e,sourcePath:t,isDirectory:n<r.length-1}));if(!n)return i;let a=H.splitModulePath(n),o=[],s=``;for(let e=0;e<a.length;e++){let r=(s?s+`.`:``)+JSON.stringify(a[e]);n.startsWith(r)||(r=(s?s+`.`:``)+a[e]),s=r,o.push({text:a[e],part:a[e],sourcePath:H.joinModuleFilePathAndModulePath(t,r),isDirectory:!1})}return i.concat(o)}var Qme=Object.defineProperty,Sk=(e,t)=>Qme(e,`name`,{value:t,configurable:!0}),Ck=`Collapsible`,[$me,wk]=sm(Ck),[ehe,Tk]=$me(Ck),the=b.forwardRef(Sk(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=ng({prop:r,defaultProp:i??!1,onChange:o,caller:Ck});return(0,Y.jsx)(ehe,{scope:n,disabled:a,contentId:Pm(),open:c,onOpenToggle:b.useCallback(()=>l(e=>!e),[l]),children:(0,Y.jsx)(xm.div,{"data-state":Dk(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),nhe=`CollapsibleTrigger`,rhe=b.forwardRef(Sk(function(e,t){let{__scopeCollapsible:n,...r}=e,i=Tk(nhe,n);return(0,Y.jsx)(xm.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Dk(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:Qp(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),Ek=`CollapsibleContent`,ihe=b.forwardRef(Sk(function(e,t){let{forceMount:n,...r}=e,i=Tk(Ek,e.__scopeCollapsible);return(0,Y.jsx)(Jh,{present:n||i.open,children:({present:e})=>(0,Y.jsx)(ahe,{...r,ref:t,present:e})})},`CollapsibleContent`)),ahe=b.forwardRef(Sk(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Tk(Ek,n),[s,c]=b.useState(r),l=b.useRef(null),u=am(t,l),d=b.useRef(0),f=d.current,p=b.useRef(0),m=p.current,h=o.open||s,g=b.useRef(h),_=b.useRef(void 0);return b.useEffect(()=>{let e=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(e)},[]),Nm(()=>{let e=l.current;if(e){_.current=_.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();d.current=t.height,p.current=t.width,g.current||(e.style.transitionDuration=_.current.transitionDuration,e.style.animationName=_.current.animationName),c(r)}},[o.open,r]),(0,Y.jsx)(xm.div,{"data-state":Dk(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!h,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:h&&i})},`CollapsibleContentImpl`));function Dk(e){return e?`open`:`closed`}Sk(Dk,`getState`);var ohe=the,she=rhe,che=ihe,lhe=Object.defineProperty,Ok=(e,t)=>lhe(e,`name`,{value:t,configurable:!0}),kk=`Accordion`,uhe=[`Home`,`End`,`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`],[Ak,dhe,fhe]=KT(kk),[jk,phe]=sm(kk,[fhe,wk]),Mk=wk(),mhe=b.forwardRef(Ok(function(e,t){let{type:n,...r}=e,i=r,a=r;return(0,Y.jsx)(Ak.Provider,{scope:e.__scopeAccordion,children:n===`multiple`?(0,Y.jsx)(vhe,{...a,ref:t}):(0,Y.jsx)(_he,{...i,ref:t})})},`Accordion`)),[Nk,hhe]=jk(kk),[Pk,ghe]=jk(kk,{collapsible:!1}),_he=b.forwardRef(Ok(function(e,t){let{value:n,defaultValue:r,onValueChange:i=Ok(()=>{},`onValueChange`),collapsible:a=!1,...o}=e,[s,c]=ng({prop:n,defaultProp:r??``,onChange:i,caller:kk});return(0,Y.jsx)(Nk,{scope:e.__scopeAccordion,value:b.useMemo(()=>s?[s]:[],[s]),onItemOpen:c,onItemClose:b.useCallback(()=>a&&c(``),[a,c]),children:(0,Y.jsx)(Pk,{scope:e.__scopeAccordion,collapsible:a,children:(0,Y.jsx)(bhe,{...o,ref:t})})})},`AccordionImplSingle`)),vhe=b.forwardRef(Ok(function(e,t){let{value:n,defaultValue:r,onValueChange:i=Ok(()=>{},`onValueChange`),...a}=e,[o,s]=ng({prop:n,defaultProp:r??[],onChange:i,caller:kk}),c=b.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=b.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,Y.jsx)(Nk,{scope:e.__scopeAccordion,value:o,onItemOpen:c,onItemClose:l,children:(0,Y.jsx)(Pk,{scope:e.__scopeAccordion,collapsible:!0,children:(0,Y.jsx)(bhe,{...a,ref:t})})})},`AccordionImplMultiple`)),[yhe,Fk]=jk(kk),bhe=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,disabled:r,dir:i,orientation:a=`vertical`,...o}=e,s=am(b.useRef(null),t),c=dhe(n),l=nE(i)===`ltr`,u=Qp(e.onKeyDown,e=>{if(!uhe.includes(e.key))return;let t=e.target,n=c().filter(e=>!e.ref.current?.disabled),r=n.findIndex(e=>e.ref.current===t),i=n.length;if(r===-1)return;e.preventDefault();let o=r,s=i-1,u=Ok(()=>{o=r+1,o>s&&(o=0)},`moveNext`),d=Ok(()=>{o=r-1,o<0&&(o=s)},`movePrev`);switch(e.key){case`Home`:o=0;break;case`End`:o=s;break;case`ArrowRight`:a===`horizontal`&&(l?u():d());break;case`ArrowDown`:a===`vertical`&&u();break;case`ArrowLeft`:a===`horizontal`&&(l?d():u());break;case`ArrowUp`:a===`vertical`&&d()}n[o%i].ref.current?.focus()});return(0,Y.jsx)(yhe,{scope:n,disabled:r,direction:i,orientation:a,children:(0,Y.jsx)(Ak.Slot,{scope:n,children:(0,Y.jsx)(xm.div,{...o,"data-orientation":a,ref:s,onKeyDown:r?void 0:u})})})},`AccordionImpl`)),Ik=`AccordionItem`,[xhe,Lk]=jk(Ik),She=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,value:r,...i}=e,a=Fk(Ik,n),o=hhe(Ik,n),s=Mk(n),c=Pm(),l=r&&o.value.includes(r)||!1,u=a.disabled||e.disabled;return(0,Y.jsx)(xhe,{scope:n,open:l,disabled:u,triggerId:c,children:(0,Y.jsx)(ohe,{"data-orientation":a.orientation,"data-state":Rk(l),...s,...i,ref:t,disabled:u,open:l,onOpenChange:e=>{e?o.onItemOpen(r):o.onItemClose(r)}})})},`AccordionItem`)),Che=`AccordionHeader`,whe=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,...r}=e,i=Fk(kk,n),a=Lk(Che,n);return(0,Y.jsx)(xm.h3,{"data-orientation":i.orientation,"data-state":Rk(a.open),"data-disabled":a.disabled?``:void 0,...r,ref:t})},`AccordionHeader`)),The=`AccordionTrigger`,Ehe=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,...r}=e,i=Fk(kk,n),a=Lk(The,n),o=ghe(The,n),s=Mk(n);return(0,Y.jsx)(Ak.ItemSlot,{scope:n,children:(0,Y.jsx)(she,{"aria-disabled":a.open&&!o.collapsible||void 0,"data-orientation":i.orientation,id:a.triggerId,...s,...r,ref:t})})},`AccordionTrigger`)),Dhe=`AccordionContent`,Ohe=b.forwardRef(Ok(function(e,t){let{__scopeAccordion:n,...r}=e,i=Fk(kk,n),a=Lk(Dhe,n),o=Mk(n);return(0,Y.jsx)(che,{role:`region`,"aria-labelledby":a.triggerId,"data-orientation":i.orientation,...o,...r,ref:t,style:{"--radix-accordion-content-height":`var(--radix-collapsible-content-height)`,"--radix-accordion-content-width":`var(--radix-collapsible-content-width)`,...e.style}})},`AccordionContent`));function Rk(e){return e?`open`:`closed`}Ok(Rk,`getState`);var khe=mhe,Ahe=She,jhe=whe,Mhe=Ehe,Nhe=Ohe,zk=khe,Bk=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(Ahe,{ref:n,className:X(`border-b border-border-primary`,e),...t}));Bk.displayName=`AccordionItem`;var Vk=b.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsx)(jhe,{className:`flex`,children:(0,Y.jsxs)(Mhe,{ref:r,className:X(`flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,Y.jsx)(Iv,{className:`w-4 h-4 transition-transform duration-200 shrink-0`})]})}));Vk.displayName=Mhe.displayName;var Hk=b.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsx)(Nhe,{ref:r,className:X(`overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down`,e),...n,children:(0,Y.jsx)(`div`,{className:`pt-0 pb-4`,children:t})}));Hk.displayName=Nhe.displayName;function Phe({validationErrors:e,ariaLabel:t=`Validation errors for this field`,className:n}){return e.length===0?null:(0,Y.jsxs)(`div`,{className:(0,AC.default)(`relative pl-3`,n),children:[(0,Y.jsx)(`span`,{className:`absolute left-0 top-1 bottom-1 w-[2px] rounded bg-bg-warning-secondary`,"aria-hidden":!0}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1.5 text-sm text-fg-warning-primary`,"aria-label":t,children:e.map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-1.5`,children:[(0,Y.jsx)(Bv,{size:13,className:`mt-[3px] shrink-0 text-fg-warning-primary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e.message})]},t))})]})}function Uk({validationErrors:e}){return e.length===0?null:(0,Y.jsx)(`div`,{className:`w-full pt-2`,children:(0,Y.jsx)(Phe,{validationErrors:e})})}function Fhe({path:e}){let{navigate:t}=GC(),n=Db(),r=Fb(),i=!$ae(),a=[];if(r){for(let t in r)if(t.startsWith(e))for(let e of r[t]??[])a.push(e.message)}return a.length===0?(0,Y.jsx)(`div`,{className:`size-6 shrink-0`}):(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`button`,{onClick:()=>{let r=n(e);t(r??e,{scrollToPath:e})},className:(0,AC.default)(`inline-flex items-center justify-center size-6 rounded bg-bg-warning-secondary text-fg-warning-secondary hover:bg-bg-warning-secondary-hover transition-colors`,{"opacity-80":i}),"aria-label":`Go to validation error`,children:i?(0,Y.jsx)(hy,{size:16,className:`animate-spin`}):(0,Y.jsx)(Ly,{size:16})})}),(0,Y.jsx)(Xg,{side:`right`,className:`max-w-xs bg-bg-warning-secondary text-fg-warning-secondary border-fg-warning-secondary/20`,children:a.length===1?(0,Y.jsx)(`p`,{className:`text-xs`,children:a[0]}):(0,Y.jsx)(`ul`,{className:`text-xs list-disc pl-3 space-y-0.5`,children:a.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})})]})}var Ihe=(0,b.createContext)(!1);function Lhe({children:e}){return(0,Y.jsx)(Ihe.Provider,{value:!0,children:e})}function Rhe(){return(0,b.useContext)(Ihe)}function zhe(e){return!e||typeof e!=`string`?``:e.trim().normalize(`NFC`).split(/\s+/).filter(e=>e.length>0).map(e=>/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(e)?e[0]:e[0].toLocaleUpperCase()).join(``)}function Wk(e,t){let n=new Date(t).getTime(),r=e.getTime(),i=Math.floor((r-n)/1e3),a=Math.floor(i/60),o=Math.floor(i/3600),s=Math.floor(i/86400),c=Math.floor(s/30);return i<60?`just now`:a<60?`${a}m ago`:o<24?`${o}h ago`:s===1?`yesterday`:s<30?`${s}d ago`:`${c}mo ago`}function Bhe({op:e}){return e===`add`?(0,Y.jsx)(Oy,{size:12}):e===`remove`?(0,Y.jsx)(yy,{size:12}):e===`replace`?(0,Y.jsx)(ny,{size:12}):e===`move`?(0,Y.jsx)(Nie,{size:12}):e===`copy`?(0,Y.jsx)(qv,{size:12}):e===`file`?(0,Y.jsx)(ey,{size:12}):(0,Y.jsx)(Dy,{size:12})}function Vhe({profile:e,isFirst:t,stacked:n,mode:r}){let i=(0,AC.default)(`flex-shrink-0 w-6 h-6 rounded-full inline-flex items-center justify-center text-xs font-semibold overflow-hidden`,{"-ml-2":n&&!t});if(!e)return(0,Y.jsx)(`span`,{className:(0,AC.default)(i,`bg-bg-secondary text-fg-disabled`),children:r===`fs`?(0,Y.jsx)(jy,{size:12}):(0,Y.jsx)(Vy,{size:12})});if(e.avatar?.url)return(0,Y.jsx)(`img`,{src:e.avatar.url,alt:e.fullName,className:(0,AC.default)(i,`object-cover`)});let a=zhe(e.fullName);return(0,Y.jsx)(`span`,{className:(0,AC.default)(i,`bg-bg-brand-primary text-fg-brand-primary`),children:a})}function Hhe(e){return`opType`in e?e.opType:e.patch.length>0?e.patch[0].op:`replace`}function Uhe(e){let t=Object.values(e).flat();return t.reduce((e,t)=>new Date(t.createdAt)>new Date(e)?t.createdAt:e,t[0].createdAt)}function Gk({patchesByAuthorIds:e,profilesByAuthorIds:t,now:n,mode:r,showHistoryIcon:i}){let a=Object.keys(e);if(a.length===0)return null;let o=a.slice(0,3),s=a.length-o.length,c=Uhe(e);return(0,Y.jsxs)(Y.Fragment,{children:[i&&(0,Y.jsx)(Ay,{size:12,className:`text-fg-tertiary mr-0.5`}),(0,Y.jsx)(`span`,{className:`text-xs text-fg-tertiary mr-1`,children:Wk(n,c)}),(0,Y.jsxs)(`span`,{className:`flex items-center rounded-full`,children:[o.map((e,n)=>(0,Y.jsx)(Vhe,{profile:t[e]??null,isFirst:n===0,stacked:a.length>1,mode:r},e)),s>0&&(0,Y.jsxs)(`span`,{className:`flex-shrink-0 -ml-2 w-6 h-6 text-xs font-semibold rounded-full inline-flex items-center justify-center bg-bg-primary text-fg-primary border border-border-primary`,children:[`+`,s]})]})]})}function Whe({patchesByAuthorIds:e,profilesByAuthorIds:t,now:n,portalContainer:r,mode:i}){let a=Object.keys(e);return a.length===0?null:(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`xs`,"aria-label":`Change history`,children:(0,Y.jsx)(Gk,{patchesByAuthorIds:e,profilesByAuthorIds:t,now:n,mode:i,showHistoryIcon:!0})})}),(0,Y.jsxs)(wD,{container:r,align:`end`,className:`z-[9001] min-w-[220px] p-0`,children:[(0,Y.jsxs)(`div`,{className:`px-3 pt-2.5 pb-1.5 text-xs font-medium text-fg-secondary border-b border-border-primary flex items-center gap-1.5`,children:[(0,Y.jsx)(Ay,{size:12}),(0,Y.jsx)(`span`,{children:`Change history`})]}),(0,Y.jsx)(eD,{className:`h-40`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3 p-3`,children:a.map(r=>{let a=t[r]??null,o=a?.fullName??(i===`fs`?`Local changes`:`Unknown author`),s=[...e[r]].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 font-semibold text-xs text-fg-secondary`,children:[(0,Y.jsx)(Vhe,{profile:a,isFirst:!0,stacked:!1,mode:i}),(0,Y.jsx)(`span`,{children:o})]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-0 pl-8`,children:s.map((e,t)=>{let r=Hhe(e),i=t===s.length-1;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-tertiary`,children:[(0,Y.jsxs)(`span`,{className:`relative flex items-center justify-center w-3 h-5`,children:[!i&&(0,Y.jsx)(`span`,{className:`absolute top-1/2 bottom-0 left-1/2 w-px -translate-x-1/2 bg-border-secondary`}),t>0&&(0,Y.jsx)(`span`,{className:`absolute top-0 bottom-1/2 left-1/2 w-px -translate-x-1/2 bg-border-secondary`}),(0,Y.jsx)(`span`,{className:`relative text-fg-secondary`,children:(0,Y.jsx)(Bhe,{op:r})})]}),(0,Y.jsx)(`span`,{children:Wk(n,e.createdAt)})]},t)})})]},r)})})})]})]})}function Kk({patchesByAuthorIds:e,profilesByAuthorIds:t,sourcePath:n,navigable:r=!0}){let[i]=(0,b.useState)(()=>new Date),a=QS(),{navigate:o}=GC();if(Object.keys(e).length===0)return null;let s=r&&n?()=>o(`/val/compare`,{scrollToPath:n}):void 0;return s?(0,Y.jsxs)(t_,{variant:`ghost`,size:`xs`,"aria-label":`View in compare`,onClick:s,children:[(0,Y.jsx)(Gk,{patchesByAuthorIds:e,profilesByAuthorIds:t,now:i,mode:a}),(0,Y.jsx)(Fie,{size:12,className:`ml-1 text-fg-tertiary`})]}):(0,Y.jsx)(`span`,{className:`inline-flex items-center text-xs`,children:(0,Y.jsx)(Gk,{patchesByAuthorIds:e,profilesByAuthorIds:t,now:i,mode:a})})}function Ghe({path:e}){let t=XS(e),n=sC(),r=(0,b.useMemo)(()=>{let e={};for(let n of t||[]){let t=n.authorId??`unknown`;e[t]||(e[t]=[]),e[t].push(n)}return e},[t]);return t&&t.length>0?(0,Y.jsx)(Kk,{patchesByAuthorIds:r,profilesByAuthorIds:n,sourcePath:e}):null}function Khe(e,t,n,r=!0){let i=Pb(e),{patchPath:a,addPatch:o}=vb(e),s=Cb(e),c=Ob(e,t),l=s.status===`loading`||c.status===`loading`?`loading`:s.status===`error`||c.status===`error`?`error`:`success`,[u,d]=(0,b.useState)(r),[f,p]=(0,b.useState)(!1),m=`data`in c?c.data:void 0,h=`data`in s?s.data:void 0;(0,b.useEffect)(()=>{n||m===null&&h&&!h.opt&&(h.type===`image`||h.type===`file`)&&p(!0)},[m,h?.opt,h?.type,n]);let g=n?n.source:m,_=n?n.schema:h;return{loadingStatus:l,validationErrors:i,patchPath:a,addPatch:o,schemaAtPath:s,sourceAtPath:c,isExpanded:u,setIsExpanded:d,showEmptyFileOrImage:f,setShowEmptyFileOrImage:p,source:g,schema:_,isBoolean:_?.type===`boolean`,isNullable:_?.opt===!0}}function qk({label:e,description:t,children:n,path:r,transparent:i,type:a,readonly:o,compact:s,foldLevel:c=`1`,source:l,schema:u,initialExpanded:d,errorDisplay:f=`default`}){if(l!==void 0!=(u!==void 0))throw Error(`Field: source and schema must both be provided or both omitted`);let p=l!==void 0&&u!==void 0?{source:l,schema:u}:void 0,m=p!==void 0,{loadingStatus:h,validationErrors:g,patchPath:_,addPatch:v,isExpanded:y,setIsExpanded:b,showEmptyFileOrImage:x,setShowEmptyFileOrImage:S,source:C,schema:w,isBoolean:T,isNullable:E}=Khe(r,a,p,d),D=o||m,{navigate:O}=GC(),k=Db(),{canMentionField:A}=wS(),j=TS(),M=()=>{let e=k(r)??r;O(e,{scrollToPath:e===r?void 0:r})},N=f===`compact`;return(0,Y.jsxs)(`div`,{"data-val-studio-path":r,className:(0,AC.default)(`border`,{"px-4 pt-6 pb-4 rounded-lg":!s,"px-3 pt-2 pb-2 rounded-md":s,"bg-bg-tertiary":!i&&!s,"border-bg-warning-secondary":!m&&f==="default"&&g.length>0}),children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex justify-between items-center`,{"pb-2":!s,"pb-1.5":s}),children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex items-center`,{"gap-4":!s,"gap-3":s,"pt-2":s&&T}),children:[!m&&w&&!T&&(E||C===null)&&(0,Y.jsx)(UT,{disabled:D||h===`loading`,checked:C!==null||x,onCheckedChange:()=>{D||((w.type===`image`||w.type===`file`)&&C===null?S(!0):v(C===null?[{op:`replace`,path:_,value:Cp({...w,opt:!1})}]:[{op:`replace`,path:_,value:null}],w.type))}}),T&&(0,Y.jsx)(Sde,{path:r,isNullable:E,loadingStatus:D?`loading`:h,source:C}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[typeof e==`string`&&(N?(0,Y.jsx)(`button`,{onClick:M,className:`font-mono text-sm px-2 py-0.5 rounded bg-bg-secondary text-fg-primary truncate cursor-pointer hover:bg-bg-tertiary transition-colors min-w-0 block`,children:cD(e)}):(0,Y.jsx)(Pfe,{children:e})),e&&typeof e!=`string`&&e,t&&(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:t})]})]}),(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex items-center`,{"gap-2 min-h-8":!s,"gap-1.5":s}),children:[!m&&!s&&(0,Y.jsx)(Ghe,{path:r}),!m&&A&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>j(r),title:`Mention this field in AI chat`,"aria-label":`Mention this field in AI chat`,className:(0,AC.default)(`flex items-center justify-center rounded text-fg-secondary hover:text-fg-primary hover:bg-bg-secondary`,{"size-6":!s,"size-5":s,invisible:D}),children:[(0,Y.jsx)(Ny,{size:s?9:10}),(0,Y.jsx)(Oy,{size:s?7:8,className:`-ml-0.5`})]}),!m&&C!==null&&(0,Y.jsx)(`div`,{className:(0,AC.default)({invisible:D}),children:(0,Y.jsx)(hk,{path:r,variant:`field`})}),C!==null&&!T&&(0,Y.jsxs)(`button`,{onClick:()=>b(e=>!e),className:(0,AC.default)(`transform transition-transform flex items-center justify-center`,{"size-6 m-[1px]":!s,"size-5":s,"rotate-180":y}),children:[c===`1`&&(0,Y.jsx)(Iv,{size:s?14:16}),c===`2`&&(0,Y.jsx)(Rie,{size:s?14:16})]})]})]}),!T&&(0,Y.jsx)(zk,{type:`single`,collapsible:!0,value:y&&(C!==null||x)?`open`:`closed`,children:(0,Y.jsx)(Bk,{value:`open`,className:`w-full border-b-0`,children:(0,Y.jsx)(Hk,{children:(0,Y.jsx)(Lhe,{children:n})})})}),!m&&f==="default"&&g.length>0&&(0,Y.jsx)(`div`,{className:s?`pb-0`:`pb-2`,children:(0,Y.jsx)(Uk,{validationErrors:g})})]})}function qhe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`object`,o=Cb(e),s=Ob(e,a);if(o.status===`error`)return(0,Y.jsx)(NC,{path:e,error:o.error,type:a});if(s.status===`error`)return(0,Y.jsx)(FC,{path:e,error:s.error,schema:o});if(s.status==`not-found`||o.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(o.status===`loading`||!(`data`in s)||s.data===void 0)return(0,Y.jsx)(jC,{path:e,type:a});if(o.data.type!==a)return(0,Y.jsx)(PC,{path:e,expectedType:a,actualType:o.data.type});let c=o.data;return(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(`div`,{className:`flex flex-col ${n?`gap-3`:`gap-6`}`,children:Object.entries(c.items).map(([a,o])=>{if(o.hidden)return null;let s=sD(e,a),c=t||o.readonly;return(0,Y.jsx)(qk,{label:a,description:o.description,path:s,type:o.type,readonly:c,compact:n,errorDisplay:i,children:(0,Y.jsx)(a6,{path:s,schema:o,readonly:c,compact:n,inline:r,errorDisplay:i},s)},s)})})})}function Jhe({path:e,size:t}){let n=`object`,r=Cb(e);if(r.status===`error`)return(0,Y.jsx)(NC,{path:e,error:r.error,type:n});if(r.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:n});if(r.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(r.data.type!==`object`)return(0,Y.jsx)(PC,{path:e,expectedType:`object`,actualType:r.data.type});let i=r.data;return(0,Y.jsx)(Yhe,{path:e,schema:i,size:t})}function Yhe({path:e,schema:t,size:n}){return(0,Y.jsx)(`div`,{id:e,className:`grid grid-cols-[min-content,1fr] text-left gap-2 text-xs ${n===`compact`?`max-h-[60px] overflow-hidden`:``}`,children:Object.entries(t.items).map(([t,r])=>{if(r.hidden)return null;let i=sD(e,t);return(0,Y.jsx)(Xhe,{label:t,children:(0,Y.jsx)(q3,{path:i,size:n})},t)})})}function Xhe({label:e,children:t}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`flex whitespace-nowrap text-fg-disabled`,children:OC(e)}),t]})}function Jk(e){return typeof e.key!=`string`}function Zhe(e){return typeof e.key==`string`}function Qhe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`union`,o=Cb(e),s=Ob(e,a);if(o.status===`error`)return(0,Y.jsx)(NC,{path:e,error:o.error,type:a});if(s.status===`error`)return(0,Y.jsx)(FC,{path:e,error:s.error,schema:o});if(s.status==`not-found`||o.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(o.status===`loading`||!(`data`in s)||s.data===void 0)return(0,Y.jsx)(jC,{path:e,type:a});if(o.data.type!==a)return(0,Y.jsx)(PC,{path:e,expectedType:a,actualType:o.data.type});let c=s.data;if(Jk(o.data)){if(typeof c!=`string`&&c!==null)return(0,Y.jsx)(FC,{path:e,error:`Expected source to be a string, but found: `+typeof c,schema:o});let n=(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(nge,{path:e,source:c,readonly:t,options:o.data.items.concat(o.data.key).flatMap(e=>e?.type===`literal`?[e.value]:(console.warn(`Unexpected item in string union`,e),[]))})});return t?(0,Y.jsx)(NT,{children:n}):n}if(!Jk(o.data))return typeof c==`object`?Array.isArray(c)?(0,Y.jsx)(FC,{path:e,error:`Expected source to be an object, but found an array`,schema:o}):(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(tge,{path:e,schema:o.data,readonly:t,compact:n,inline:r,errorDisplay:i})}):(0,Y.jsx)(FC,{path:e,error:`Expected source to be an object, but found: `+typeof c,schema:o})}function $he(e,t){let n=Ab(e),{addPatch:r,patchPath:i}=vb(e),a=Ob(sD(e,t.key),`literal`),o=`data`in a?a.data:void 0,s=(0,b.useRef)({});(0,b.useEffect)(()=>{n!==void 0&&typeof o==`string`&&n.status===`success`&&(s.current[e]||(s.current[e]={}),s.current[e][o]=n.data)},[n,o,e]);let c=(0,b.useCallback)(n=>{let a=t.items.find(e=>{let r=e.items?.[t.key];return r.type===`literal`?r.value===n:(console.error(`Expected literal schema in object union`,r),!1)});if(a?.items===void 0){console.error(`Selected schema with ${t.key} = ${n} not found`);return}let o={...s.current[e]?.[n]??Cp(a),[t.key]:n};r([{op:`replace`,path:i,value:o}],t.type)},[r,i,e,t]),l=t.items.flatMap(e=>{let n=e.items?.[t.key];return n.type===`literal`?[n.value]:(console.error(`Expected literal schema in object union`,n),[])}),u=t.items.find(e=>{let n=e.items?.[t.key];return n.type===`literal`?n.value===o:(console.error(`Expected literal schema in object union`,n),!1)});return typeof o!=`string`||u===void 0||u.items===void 0?{status:`loading`}:{status:`ready`,selectedSchema:u,options:l,current:o,select:c}}function ege({state:e,readonly:t,className:n}){let r=eb();return(0,Y.jsxs)(nD,{disabled:t,value:e.current,onValueChange:n=>{t||e.select(n)},children:[(0,Y.jsx)(iD,{className:n,children:(0,Y.jsx)(rD,{children:e.current})}),(0,Y.jsx)(aD,{container:r,className:`w-32`,children:e.options.map(e=>(0,Y.jsx)(oD,{value:e,children:e},e))})]})}function tge({path:e,schema:t,readonly:n,compact:r,inline:i,errorDisplay:a=`default`}){let o=$he(e,t);if(o.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:`union`});let{selectedSchema:s}=o;return(0,Y.jsxs)(`div`,{className:`grid ${r?`gap-3`:`gap-4`}`,children:[(0,Y.jsx)(ege,{state:o,readonly:n}),Object.keys(s.items).filter(e=>e!==t?.key).map(t=>{let o=sD(e,t);return(0,Y.jsx)(qk,{path:o,foldLevel:`1`,label:t,description:s?.items?.[t]?.description,type:s?.items?.[t]?.type,readonly:n,compact:r,errorDisplay:a,children:(0,Y.jsx)(a6,{path:o,schema:s?.items?.[t],readonly:n,compact:r,inline:i,errorDisplay:a},t)},o)})]})}function nge({path:e,source:t,options:n,readonly:r}){let{addPatch:i,patchPath:a}=vb(e),o=eb();return(0,Y.jsxs)(nD,{disabled:r,value:t??``,onValueChange:e=>{r||i([{op:`replace`,path:a,value:e}],`union`)},children:[(0,Y.jsx)(iD,{children:(0,Y.jsx)(rD,{children:t})}),(0,Y.jsx)(aD,{className:`w-32`,container:o,children:n==null?(0,Y.jsx)(rge,{}):n.map(e=>(0,Y.jsx)(oD,{value:e,children:e},e))})]})}function rge(){return(0,Y.jsx)(`div`,{children:`Loading...`})}function ige({path:e}){let t=`union`,n=Ab(e),r=Cb(e);if(n.status===`error`)return(0,Y.jsx)(FC,{path:e,error:n.error,schema:r});if(!(`data`in n)||n.data===void 0||!(`data`in r)||r.data===void 0)return(0,Y.jsx)(J3,{path:e});if(n.data===null)return(0,Y.jsx)(Y3,{path:e});if(r.data.type!==t)return(0,Y.jsx)(PC,{path:e,expectedType:t,actualType:r.data.type});let i=r.data;if(Jk(i))return typeof n.data==`string`?(0,Y.jsx)(`div`,{className:`truncate`,children:n.data}):(0,Y.jsx)(FC,{path:e,error:`Expected source to be a string, but found: `+typeof n.data,schema:r});{let t=n.data;if(!t)return(0,Y.jsx)(Y3,{path:e});if(typeof t!=`object`&&!(typeof t==`object`&&i.key in t))return(0,Y.jsx)(FC,{path:e,error:`Expected source to be an object, but found: `+typeof t,schema:r});let a=i.items.find(e=>{let n=e.items?.[i.key];if(n?.type===`literal`&&typeof t==`object`&&t&&i.key in t&&!Wp(t))return n.value===t[i.key]});return a?(0,Y.jsx)(Yhe,{path:e,schema:a}):(0,Y.jsx)(FC,{path:e,error:`Expected source to have key `+i.key+` but it was not found`,schema:r})}}function age(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function Yk(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function oge(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var sge=(e,t)=>Math.abs(e-t)<1.01,cge=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})},Xk,Zk=()=>{if(Xk!==void 0)return Xk;if(typeof navigator>`u`)return Xk=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Xk=!0;let e=navigator.maxTouchPoints;return Xk=navigator.platform===`MacIntel`&&e!==void 0&&e>0},lge=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},uge=e=>e,dge=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},fge=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(lge(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(lge(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Qk={passive:!0},pge=typeof window>`u`||`onscrollend`in window,mge=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&pge,o=0,s=a?null:cge(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Qk),a&&r.addEventListener(`scrollend`,u,Qk),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u),s?.cancel()}},hge=(e,t)=>mge(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),gge=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},_ge=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},vge=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.isIndexInRange(n)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:uge,rangeExtractor:dge,onChange:()=>{},measureElement:gge,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=Math.max(0,e.start+t);n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Yk(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!Zk()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Qk),e.addEventListener(`touchend`,n,Qk),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(Zk()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Yk(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.isIndexInRange=e=>e>=0&&e<this.options.count,this.getMeasurements=Yk(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=age(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Yk(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=bge(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Yk(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e);if(!this.isIndexInRange(t))return;let n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(!this.isIndexInRange(e))return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f)}},this.getVirtualItems=Yk(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return oge(t[$k(0,t.length-1,r?e=>n[e*2]:e=>oge(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){return e===0?!1:Zk()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=e,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&sge(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},$k=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function yge(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function bge(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=yge(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=$k(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var eA=typeof document<`u`?b.useLayoutEffect:b.useEffect;function xge({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=b.useReducer(e=>e+1,0)[1],a=b.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},s=e=>{let t=a.current;if(!t.enabled||!t.container)return;o(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let o=a.start-s,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==o&&(t.lastPositions.set(c,o),r?c.style.transform=n?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:c.style[i]=`${o}px`)}},c={...r,onChange:(t,n)=>{var o;let c=a.current,l=!0;if(c.enabled){s(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,lm.flushSync)(i):i()),(o=r.onChange)==null||o.call(r,t,n)}},[l]=b.useState(()=>{let e=new vge(c);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return l.setOptions(c),eA(()=>l._didMount(),[]),eA(()=>(o(l),l._willUpdate())),eA(()=>{s(l)}),l}function tA(e){return xge({observeElementRect:fge,observeElementOffset:hge,scrollToFn:_ge,...e})}function nA(e){let t=e.replace(/^\//,``).replace(/\.val\.(ts|js)$/,``).split(`/`);return t.length>1&&(t[0]===`content`||t[0]===`schema`)&&t.shift(),t.map(e=>e.replace(/[-_]/g,` `)).join(` / `)}function rA(e,t){let n=t.get(e);return H.mediaUrl({path:e,...n?{patch_id:n}:{}})}var Sge=``;function iA(e){let t=Ab(e??Sge),n=Mb(),r=(0,b.useCallback)(e=>rA(e,n),[n]);return!e||t.status!==`success`?{moduleEntries:void 0,getUrl:r,ready:!1}:{moduleEntries:{[e]:t.data},getUrl:r,ready:!0}}function aA(e){return e.startsWith(oA)?e.slice(oA.length):e}var oA=`/public`;function sA({hotspot:e,size:t=`md`}){let n=t===`sm`?14:20,r=t===`sm`?3:4,i=t===`sm`?1.5:2;return(0,Y.jsxs)(`div`,{className:`pointer-events-none absolute z-hover`,style:{top:`${e.y*100}%`,left:`${e.x*100}%`,transform:`translate(-50%, -50%)`},children:[(0,Y.jsx)(`div`,{style:{width:`${n}px`,height:`${n}px`,borderRadius:`50%`,border:`${i}px solid white`,boxShadow:`0 0 0 1px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(0,0,0,0.3)`}}),(0,Y.jsx)(`div`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,width:`${r}px`,height:`${r}px`,borderRadius:`50%`,backgroundColor:`white`,boxShadow:`0 0 2px rgba(0,0,0,0.5)`}})]})}var Cge=3,wge=400;function cA({url:e,alt:t=``,hotspot:n,className:r,imageClassName:i,onError:a,loading:o}){let[s,c]=(0,b.useState)(0),l=(0,b.useRef)(null);(0,b.useEffect)(()=>{c(0)},[e]),(0,b.useEffect)(()=>()=>{l.current!==null&&clearTimeout(l.current)},[]);let u=(0,b.useCallback)(()=>{if(s>=Cge){a?.();return}l.current!==null&&clearTimeout(l.current),l.current=setTimeout(()=>c(e=>e+1),wge*2**s)},[s,a]),d=s===0?e:`${e}${e.includes(`?`)?`&`:`?`}val_retry=${s}`;return(0,Y.jsx)(`span`,{className:X(`grid h-full w-full place-items-center overflow-hidden`,r),children:(0,Y.jsxs)(`span`,{className:`relative inline-flex max-h-full max-w-full`,children:[(0,Y.jsx)(`img`,{src:d,alt:t,draggable:!1,loading:o,decoding:`async`,onError:u,className:X(`max-h-full max-w-full object-contain`,i)}),n&&(0,Y.jsx)(sA,{hotspot:n})]})})}var lA=48;function Tge(e,t,n){let r=[],i=t.toLowerCase();for(let t of Object.keys(e)){let a=e[t],o=Object.keys(a).filter(e=>{if(!i)return!0;let t=e.split(`/`).pop()||e,n=typeof a[e].alt==`string`?a[e].alt:``;return t.toLowerCase().includes(i)||n.toLowerCase().includes(i)});if(o.length!==0){n&&r.push({kind:`heading`,modulePath:t});for(let e of o)r.push({kind:`entry`,filePath:e,metadata:a[e]||{},modulePath:t})}}return r}function uA({moduleEntries:e,selectedRef:t,onSelect:n,isImage:r=!1,getUrl:i,autoFocus:a=!1,maxHeight:o,onEscape:s}){let[c,l]=b.useState(``),[u,d]=b.useState(-1),f=b.useRef(null),p=b.useRef(null),m=Object.keys(e),h=m.length>1,g=b.useMemo(()=>Tge(e,c,h),[e,c,h]),_=b.useMemo(()=>g.reduce((e,t,n)=>(t.kind===`entry`&&e.push(n),e),[]),[g]),v=tA({count:g.length,getScrollElement:()=>p.current,estimateSize:e=>g[e].kind===`heading`?28:lA,overscan:10});b.useEffect(()=>{d(_.length>0?_[0]:-1)},[c,_]),b.useEffect(()=>{if(a){let e=setTimeout(()=>{f.current?.focus(),v.measure()},100);return()=>clearTimeout(e)}},[a,v]);let y=b.useCallback(e=>{let t=g[e];t?.kind===`entry`&&n({filePath:t.filePath,metadata:t.metadata,modulePath:t.modulePath})},[g,n]),x=b.useCallback(e=>{if(_.length===0)return;let t=_.indexOf(u);if(e.key===`ArrowDown`){e.preventDefault();let n=t<_.length-1?_[t+1]:_[0];d(n),v.scrollToIndex(n,{align:`auto`})}else if(e.key===`ArrowUp`){e.preventDefault();let n=t>0?_[t-1]:_[_.length-1];d(n),v.scrollToIndex(n,{align:`auto`})}else e.key===`Enter`?(e.preventDefault(),u>=0&&y(u)):e.key===`Escape`&&s?.()},[_,u,v,y,s]);if(m.length===0)return null;let S=Object.values(e).reduce((e,t)=>e+Object.keys(t).length,0),C=o??Math.min(S*lA+60,320);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center border-b border-border-primary px-3`,children:[(0,Y.jsx)(My,{className:`mr-2 h-4 w-4 shrink-0 opacity-50`}),(0,Y.jsx)(`input`,{ref:f,value:c,onChange:e=>l(e.target.value),onKeyDown:x,placeholder:r?`Search images...`:`Search files...`,className:`flex h-10 w-full bg-transparent py-3 text-sm outline-none placeholder:text-fg-secondary disabled:cursor-not-allowed disabled:opacity-50`})]}),g.length===0?(0,Y.jsx)(`div`,{className:`py-6 text-center text-sm text-fg-secondary`,children:r?`No images found.`:`No files found.`}):(0,Y.jsx)(`div`,{ref:p,className:`overflow-auto`,style:{maxHeight:C},children:(0,Y.jsx)(`div`,{style:{height:`${v.getTotalSize()}px`,width:`100%`,position:`relative`},children:v.getVirtualItems().map(e=>{let n=g[e.index];if(n.kind===`heading`)return(0,Y.jsx)(`div`,{className:`absolute left-0 top-0 w-full px-3 py-1 text-xs font-medium text-fg-secondary`,style:{transform:`translateY(${e.start}px)`,height:`${e.size}px`},children:nA(n.modulePath)},`heading-${n.modulePath}`);let a=n.filePath.split(`/`).pop()||n.filePath,o=t===n.filePath,s=e.index===u,c=typeof n.metadata.alt==`string`?n.metadata.alt:void 0,l=typeof n.metadata.mimeType==`string`?n.metadata.mimeType:void 0;return(0,Y.jsxs)(`div`,{className:X(`absolute left-0 top-0 flex w-full cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm`,s&&`bg-bg-primary-hover text-fg-primary`),style:{transform:`translateY(${e.start}px)`,height:`${e.size}px`},onMouseEnter:()=>d(e.index),onClick:()=>y(e.index),children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,o?`opacity-100`:`opacity-0`)}),r&&l?.startsWith(`image/`)?(0,Y.jsx)(cA,{url:i?i(n.filePath):aA(n.filePath),alt:c||a,loading:`lazy`,className:`h-8 w-8 shrink-0 rounded bg-bg-secondary`}):(0,Y.jsx)(`div`,{className:`h-8 w-8 shrink-0 flex items-center justify-center rounded bg-bg-secondary`,children:r?(0,Y.jsx)(sy,{className:`h-4 w-4 text-fg-secondary`}):(0,Y.jsx)(ey,{className:`h-4 w-4 text-fg-secondary`})}),(0,Y.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:a}),c&&(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary truncate`,children:c})]})]},n.filePath)})})})]})}function Ege({disabled:e=!1,portalContainer:t,selectedRef:n,isImage:r=!1,moduleEntries:i,onSelect:a,getUrl:o,compact:s,footer:c}){let[l,u]=b.useState(!1);if(Object.keys(i).length===0)return null;let d=n?n.split(`/`).pop()||n:null;return(0,Y.jsxs)(SD,{open:l,onOpenChange:u,children:[(0,Y.jsx)(CD,{asChild:!0,children:s?(0,Y.jsxs)(t_,{variant:`outline`,size:`sm`,role:`combobox`,"aria-label":`Choose asset`,"aria-expanded":l,disabled:e,children:[(0,Y.jsx)(cae,{className:`mr-1.5 h-3.5 w-3.5 shrink-0`}),`Choose asset`]}):(0,Y.jsxs)(t_,{variant:`outline`,role:`combobox`,"aria-expanded":l,className:`w-full justify-between`,disabled:e,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:d||(r?`Select from gallery...`:`Select from files...`)}),(0,Y.jsx)(zv,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,Y.jsxs)(wD,{className:s?`w-[22rem] p-0`:`w-[var(--radix-popover-trigger-width)] p-0`,container:t,children:[(0,Y.jsx)(uA,{moduleEntries:i,selectedRef:n,isImage:r,getUrl:o,autoFocus:l,onSelect:e=>{a(e),u(!1)},onEscape:()=>u(!1)}),c&&(0,Y.jsx)(`div`,{className:`border-t border-border-primary p-2`,children:c})]})]})}function dA({modulePath:e,...t}){let{moduleEntries:n,getUrl:r,ready:i}=iA(e);return!i||!n?null:(0,Y.jsx)(Ege,{moduleEntries:n,getUrl:r,...t})}var fA={quality:.8,maxWidth:2560,maxHeight:2560},Dge={webp:`image/webp`},pA=[`image/svg+xml`,`image/gif`,`image/avif`];function mA(e,t){return e!==void 0&&Number.isFinite(e)&&e>0?e:t}function hA(e,t){let n=e===void 0?t:e;if(!n)return null;let r=n.quality;return{type:n.type,quality:r!==void 0&&Number.isFinite(r)&&r>0?Math.min(r,1):fA.quality,maxWidth:mA(n.maxWidth,fA.maxWidth),maxHeight:mA(n.maxHeight,fA.maxHeight)}}function Oge(e,t,n,r){if(!(e>0)||!(t>0)||!(n>0)||!(r>0)||e<=n&&t<=r)return null;let i=Math.min(n/e,r/t);return{width:Math.max(1,Math.round(e*i)),height:Math.max(1,Math.round(t*i))}}function kge(e,t){return!t||t.split(`,`).map(e=>e.trim()).some(t=>t===`*/*`?!0:t.endsWith(`/*`)?e.startsWith(t.slice(0,-2)):t===e)}function Age(e,t,n){return pA.includes(e)?!0:e===t&&!n}function jge(e){return e.encodedSize===null||e.encodedType!==e.targetMimeType?!1:e.needsDownscale?!0:e.encodedSize<e.originalSize}function Mge(e,t){return`${e.split(`.`).slice(0,-1).join(`.`)||e}.${t}`}function Nge(e,t,n){return new Promise(r=>e.toBlob(r,t,n))}async function Pge(e,t,n){if(t===null)return e;let r=Dge[t.type];if(pA.includes(e.type)||!kge(r,n)||typeof createImageBitmap!=`function`)return e;let i;try{i=await createImageBitmap(e,{imageOrientation:`from-image`});let n=Oge(i.width,i.height,t.maxWidth,t.maxHeight),a=n!==null;if(Age(e.type,r,a))return e;let o=document.createElement(`canvas`);o.width=n?.width??i.width,o.height=n?.height??i.height;let s=o.getContext(`2d`);if(!s)return e;s.drawImage(i,0,0,o.width,o.height);let c=await Nge(o,r,t.quality);return!c||!jge({originalSize:e.size,encodedSize:c.size,encodedType:c.type,targetMimeType:r,needsDownscale:a})?e:new File([c],Mge(e.name,t.type),{type:r})}catch(t){return console.error(`Could not re-encode image, uploading the original`,t),e}finally{i?.close()}}function gA(e,t){return!t||t.settings===null?_A(e):Pge(e,t.settings,t.accept).then(_A)}function _A(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`load`,()=>{let i=r.result;if(typeof i==`string`){let n=new Image;n.addEventListener(`load`,()=>{let r=Xr(i),a=H.getSHA256Hash(r);if(n.naturalWidth&&n.naturalHeight){let r=H.getMimeType(i);t({src:i,width:n.naturalWidth,height:n.naturalHeight,filename:e.name,fileHash:a,mimeType:r,fileExt:r&&H.mimeTypeToFileExt(r)})}else t({src:i,filename:e.name,fileHash:a})}),n.src=i}else n(i?{message:`Unexpected image result type`,result:i}:{message:`Empty result`})}),r.readAsDataURL(e)})}function Fge(e,t){return new Promise((n,r)=>{let i=e.currentTarget.files?.[0];if(!i){r({message:`No file selected`});return}gA(i,t).then(n).catch(r)})}function vA(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`load`,()=>{let i=r.result;if(typeof i==`string`){let n=Xr(i),r=H.getSHA256Hash(n),a=H.getMimeType(i);t({src:i,filename:e.name,fileHash:r,mimeType:a,fileExt:a&&H.mimeTypeToFileExt(a)})}else n(i?{message:`Unexpected file result type`,result:i}:{message:`Empty result`})}),r.readAsDataURL(e)})}function yA(e){return new Promise((t,n)=>{let r=e.currentTarget.files?.[0];if(!r){n({message:`No file selected`});return}vA(r).then(t).catch(n)})}function bA(e){return e.split(`.`).pop()||``}function xA({url:e,name:t,detail:n,hotspot:r,actions:i,uploading:a,progressPercentage:o,isImage:s=!0,onOpenPreview:c}){let l=s?sy:ey,u=X(`relative grid h-[4.5rem] w-[7.5rem] shrink-0 place-items-center`,`overflow-hidden rounded-md border border-border-primary bg-bg-secondary`,c&&`cursor-zoom-in hover:border-border-focus`),d=(0,Y.jsxs)(Y.Fragment,{children:[s&&e?(0,Y.jsx)(cA,{url:e,hotspot:r}):(0,Y.jsx)(l,{size:20,strokeWidth:1.5,className:`text-fg-secondary-alt`}),a&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 grid place-items-center bg-bg-secondary/70`,children:[(0,Y.jsx)(hy,{size:18,className:`animate-spin text-fg-primary`}),o!=null&&(0,Y.jsxs)(`span`,{className:`absolute bottom-1 text-[0.625rem] tabular-nums text-fg-primary`,children:[o,`%`]})]})]});return(0,Y.jsxs)(`div`,{className:`flex gap-3`,children:[c?(0,Y.jsx)(`button`,{type:`button`,onClick:c,"aria-label":s?`View image`:`View file`,className:u,children:d}):(0,Y.jsx)(`div`,{className:u,children:d}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-2`,children:[t?(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`truncate text-xs font-medium text-fg-primary`,children:t}),n&&(0,Y.jsx)(`p`,{className:`mt-0.5 truncate text-[0.6875rem] text-fg-secondary-alt`,children:n})]}):(0,Y.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:s?`No image yet`:`No file yet`}),(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:i})]})]})}function SA({label:e,hint:t,summary:n,collapsible:r,children:i}){let[a,o]=(0,b.useState)(!1);return r?(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-1.5 text-left`,children:[(0,Y.jsx)(Rv,{size:13,className:X(`shrink-0 text-fg-secondary-alt transition-transform`,a&&`rotate-90`)}),(0,Y.jsx)(`h3`,{className:`text-xs font-medium text-fg-primary`,children:e}),n&&!a&&(0,Y.jsx)(`span`,{className:`ml-auto truncate text-[0.6875rem] text-fg-secondary-alt`,children:n})]}),a&&(0,Y.jsxs)(`div`,{className:`mt-2`,children:[t&&(0,Y.jsx)(`p`,{className:`mb-2 text-[0.6875rem] text-fg-secondary-alt`,children:t}),i]})]}):(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{className:`text-xs font-medium text-fg-primary`,children:e}),t&&(0,Y.jsx)(`p`,{className:`mb-2 mt-0.5 text-[0.6875rem] text-fg-secondary-alt`,children:t}),i]})}function Ige(e){return e.replace(/\.[^.]+$/,``).replace(/_[0-9a-f]{5}$/,``).replace(/[-_]+/g,` `).trim()}var Lge=new TextEncoder;async function CA(e,t,n,r,i,a,o,s=`/public/val`,c=!1){let l=H.createFilename(t,n,i,r);if(!l||!i)return{patch:[],filePath:``};let u=`${s}/${l}`,d=H.remote.hashToRemoteFileHash(r),f=o?H.remote.createRemoteRef(o.remoteHost,{publicProjectId:o.publicProjectId,coreVersion:o.coreVersion,bucket:o.bucket,validationHash:H.remote.getValidationHash(o.coreVersion,o.schema,bA(l),i,d,Lge),fileHash:d,filePath:`${(s??`/public/val`).slice(1)}/${l}`}):u;return{patch:[{value:{path:f,...c?{}:i},op:`replace`,path:e},{value:t,metadata:i,op:`file`,path:e,filePath:f,remote:o!==null}],filePath:u}}function Rge({path:e,readonly:t}){let n=`file`,r=bb(),i=SS(),a=xS(),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(null),[u,d]=(0,b.useState)(null),[f,p]=(0,b.useState)(!1),{source:m,schema:h,addPatch:g,patchPath:_,addAndUploadPatchWithFileOps:v,addModuleFilePatch:y}=yb(e,n),x=eb(),S=(0,b.useRef)(null),[C,w]=(0,b.useState)(null),T=Mb(),E=`data`in m&&m.data,D=m.status===`success`&&m.clientSideOnly;(0,b.useEffect)(()=>{if(E&&!D){let e=T.get(E.path);d(H.mediaUrl({path:E.path,...e?{patch_id:e}:{}})),p(!1)}},[m,T]),(0,b.useEffect)(()=>{h.status===`success`&&h.data.type===`file`&&h.data.options?.accept?.startsWith(`video/`)&&s(!0),E&&typeof E.mimeType==`string`&&(E.mimeType.startsWith(`video/`)?s(!0):s(!1))},[h,E]);let O=h.status===`success`&&h.data.type===`file`?h.data:void 0,k=O?.referencedModule,A=Tb(k),j=(0,b.useMemo)(()=>{if(O){if(O.options?.accept)return O.options.accept;if(k&&A?.type===`record`&&A.accept)return A.accept}},[O,k,A]),M=(0,b.useMemo)(()=>A?.type===`record`?A.directory:void 0,[A]);if(h.status===`error`)return(0,Y.jsx)(NC,{path:e,error:h.error,type:n});if(m.status===`error`)return(0,Y.jsx)(FC,{path:e,error:m.error,schema:h});if(m.status==`not-found`||h.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(h.status===`loading`||r===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(h.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:h.data.type});let N=m.data;if(N===void 0)return(0,Y.jsx)(MC,{path:e,type:n});let P=h.data.type===`file`&&h.data.remote&&a.status!==`ready`,F=k&&A===void 0?[k]:[],I=t||P||F.length>0,L=h.data.remote&&a.status===`ready`&&i?{publicProjectId:a.publicProjectId,coreVersion:a.coreVersion,bucket:i,schema:h.data,remoteHost:r.remoteHost}:null,R=null;if(N?.path){if(h.data.remote){let e=H.remote.splitRemoteRef(N.path);e.status===`success`&&(R=e.filePath)}else R=N.path}let ee=null;R&&(ee=R.split(`/`).slice(-1)[0]);let te=typeof N?.mimeType==`string`?N.mimeType:null;return(0,Y.jsxs)(`div`,{id:e,children:[F.length>0&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:F.length===1?`The module '${F[0]}' is referenced by this field but is not added to val.modules. Add it to val.modules to enable uploads.`:`The following modules are referenced by this field but are not added to val.modules: ${F.join(`, `)}. Add them to val.modules to enable uploads.`}),c&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:c}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsx)(xA,{url:u,name:ee,detail:te,isImage:!1,uploading:f,progressPercentage:C,actions:(0,Y.jsxs)(Y.Fragment,{children:[!k&&(0,Y.jsxs)(t_,{variant:`outline`,size:`sm`,disabled:I,onClick:()=>S.current?.click(),children:[(0,Y.jsx)(By,{className:`mr-1.5 h-3.5 w-3.5`}),N?`Replace`:`Choose asset`]}),N&&(0,Y.jsxs)(`a`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-secondary underline underline-offset-2 hover:text-fg-primary`,target:`_blank`,rel:`noopener noreferrer`,download:ee??void 0,href:H.mediaUrl(N),children:[`Open file`,(0,Y.jsx)(kae,{size:12})]}),k&&(0,Y.jsx)(dA,{compact:!0,footer:(0,Y.jsxs)(`button`,{type:`button`,disabled:I,onClick:()=>S.current?.click(),className:X(`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-xs`,`text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Y.jsx)(By,{size:13}),`Upload into `,nA(k)]}),modulePath:k,selectedRef:N?.path??null,onSelect:e=>{g([{op:`replace`,path:_,value:{path:e.filePath}}],`file`)},isImage:!1,disabled:I,portalContainer:x})]})}),N&&o&&(0,Y.jsx)(`video`,{className:`w-full h-auto rounded-lg`,controls:!0,src:H.mediaUrl(N)}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(`input`,{disabled:I,hidden:!0,ref:S,id:`file_input:${e}`,type:`file`,accept:j,onChange:e=>{yA(e).then(t=>{let n=`file`,r=u;d(t.src),p(!0);let i={src:t.src,filename:t.filename},a;t.mimeType&&(a={mimeType:t.mimeType}),l(null),CA(_,i.src,i.filename??null,t.fileHash,a,n,L,M,!!k).then(({patch:e,filePath:t})=>{p(!0),w(0);let i=!1;v(e,n,e=>{i=!0,d(r),l(e)},(e,t,n,r)=>{let i=e*(n+1)/(t*r);w(Math.round(i*100))}).then(()=>{!i&&k&&t&&a?.mimeType&&y(k,[{op:`add`,path:[t],value:{mimeType:a.mimeType}}],`record`)}).finally(()=>{w(null),p(!1)})}).catch(e=>{console.error(`Failed to create file patch`,e),p(!1),d(r),l(`Could not upload file. Please try again later`)}),e.target.value=``})}})})]})]})}function zge({path:e}){let t=Ob(e,`image`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(ey,{size:12})}function Bge(e){let[t,n]=(0,b.useState)(!1),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null);return{uploadImage:(0,b.useCallback)(async t=>{i(null),n(!0),o(0);try{let r=await gA(t,e.encode),a;r.width&&r.height&&r.mimeType&&(a={width:r.width,height:r.height,mimeType:r.mimeType,alt:e.existingAlt});let{patch:s,filePath:c}=await CA(e.patchPath,r.src,r.filename??null,r.fileHash,a,`image`,e.remoteData,e.directory,!!e.referencedModule);if(s.length===0)return n(!1),o(null),i(`Could not process image file`),null;let l=s[0]&&`value`in s[0]&&typeof s[0].value==`object`&&s[0].value!==null&&`path`in s[0].value?s[0].value.path:c,u=e.fileUploadOnly?s.filter(e=>e.op===`file`):s;return await new Promise(t=>{let r=!1;e.addAndUploadPatchWithFileOps(u,`image`,e=>{r=!0,i(e),n(!1),o(null),t(null)},(e,t,n,r)=>{let i=(n*t+e)/(r*t);o(Math.round(i*100))}).then(()=>{r||(e.referencedModule&&c&&a?.mimeType&&a.width!==void 0&&a.height!==void 0&&e.addModuleFilePatch(e.referencedModule,[{op:`add`,path:[c],value:{width:a.width,height:a.height,mimeType:a.mimeType,alt:typeof a.alt==`string`?a.alt:null}}],`record`),t({filePath:c,ref:l}))}).finally(()=>{o(null),n(!1)})})}catch(e){return console.error(`Failed to upload image`,e),n(!1),o(null),i(`Could not upload file. Please try again later`),null}},[e]),loading:t,error:r,progressPercentage:a}}function Vge({path:e,readonly:t,hideUpload:n}){let r=`image`,i=bb(),a=xS(),o=SS(),{source:s,schema:c,addPatch:l,patchPath:u,addAndUploadPatchWithFileOps:d,addModuleFilePatch:f}=yb(e,r),[p,m]=(0,b.useState)(void 0),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(!1),y=eb(),x=(0,b.useRef)(null),S=Mb(),C=`data`in s&&s.data,w=s.status===`success`&&s.clientSideOnly;(0,b.useEffect)(()=>{if(C){if(!w){let e=S.get(C.path);g(H.mediaUrl({path:C.path,...e?{patch_id:e}:{}}))}let e=C.hotspot;e?typeof e.x==`number`&&typeof e.y==`number`?m({x:e.x,y:e.y}):console.warn(`Expected hotspot to have x and y as numbers but x was: ${typeof e.x} and y: ${typeof e.y}`):m(void 0)}},[s,S]);let T=c.status===`success`&&c.data.type===`image`?c.data:void 0,E=T?.referencedModule,D=Tb(E),O=(0,b.useMemo)(()=>{if(T){if(T.options?.accept)return T.options.accept;if(E&&D?.type===`record`&&D.accept)return D.accept}},[T,E,D]),k=(0,b.useMemo)(()=>T?.options?.directory?T.options.directory:D?.type===`record`?D.directory:void 0,[T,D]),A=(0,b.useMemo)(()=>{let e=D?.type===`record`?D.encode:void 0;return{settings:hA(T?.options?.encode,e),accept:O}},[T,D,O]),j=C&&typeof C.alt==`string`?C.alt:void 0,{uploadImage:M,loading:N,error:P,progressPercentage:F}=Bge({patchPath:u,addAndUploadPatchWithFileOps:d,addModuleFilePatch:f,remoteData:T?.remote&&a.status===`ready`&&o&&i?{publicProjectId:a.publicProjectId,bucket:o,coreVersion:a.coreVersion,schema:T,remoteHost:i.remoteHost}:null,directory:k,referencedModule:E,existingAlt:j,encode:A});if(c.status===`error`)return(0,Y.jsx)(NC,{path:e,error:c.error,type:r});if(s.status===`error`)return(0,Y.jsx)(FC,{path:e,error:s.error,schema:c});if(s.status==`not-found`||c.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:r});if(c.status===`loading`||i===void 0)return(0,Y.jsx)(jC,{path:e,type:r});if(c.data.type!==r)return(0,Y.jsx)(PC,{path:e,expectedType:r,actualType:c.data.type});let I=s.data;if(I===void 0)return(0,Y.jsx)(MC,{path:e,type:r});let L=c.data.type===`image`&&c.data.remote&&a.status!==`ready`,R=E&&D===void 0?[E]:[],ee=t||L||R.length>0,te=I?I.path.split(`/`).pop()??I.path:null,ne=(()=>{if(!I)return null;let{width:e,height:t,mimeType:n}=I,r=[];return typeof e==`number`&&typeof t==`number`&&r.push(`${e} × ${t}`),typeof n==`string`&&r.push(n),r.length>0?r.join(` · `):null})(),re=typeof I?.alt==`string`?I.alt:``,ie=e=>{I&&l([{op:`add`,value:e,path:u.concat([`alt`])}],`string`)},ae=H.createValPathOfItem(e,`alt`),oe=H.createValPathOfItem(e,`hotspot`);return(0,Y.jsxs)(`div`,{id:e,children:[R.length>0&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:R.length===1?`The module '${R[0]}' is referenced by this field but is not added to val.modules. Add it to val.modules to enable uploads.`:`The following modules are referenced by this field but are not added to val.modules: ${R.join(`, `)}. Add them to val.modules to enable uploads.`}),P&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:P}),c.data.type===`image`&&c.data.remote&&a.status===`inactive`&&(0,Y.jsx)(`div`,{className:`p-4 rounded bg-bg-error-primary text-fg-error-primary`,children:Hge(a.reason)}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Y.jsx)(xA,{url:h,name:te,detail:ne,hotspot:p,onOpenPreview:h?()=>v(!0):void 0,uploading:N,progressPercentage:F,actions:(0,Y.jsxs)(Y.Fragment,{children:[!n&&E&&(0,Y.jsx)(dA,{compact:!0,footer:(0,Y.jsxs)(`button`,{type:`button`,disabled:ee,onClick:()=>x.current?.click(),className:X(`flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-xs`,`text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary`,`disabled:pointer-events-none disabled:opacity-50`),children:[(0,Y.jsx)(By,{size:13}),`Upload into `,nA(E)]}),modulePath:E,selectedRef:I?.path??null,onSelect:e=>{l([{op:`replace`,path:u,value:{path:e.filePath}}],`image`)},isImage:!0,disabled:ee,portalContainer:y}),!n&&(0,Y.jsxs)(Y.Fragment,{children:[!E&&(0,Y.jsxs)(t_,{variant:`outline`,size:`sm`,disabled:ee,onClick:()=>x.current?.click(),children:[(0,Y.jsx)(By,{className:`mr-1.5 h-3.5 w-3.5`}),h?`Replace`:`Choose asset`]}),(0,Y.jsx)(`input`,{disabled:ee,hidden:!0,ref:x,id:`img_input:${e}`,type:`file`,accept:O??`image/*`,onChange:e=>{let t=e.currentTarget.files?.[0];if(!t)return;let n=h;M(t).then(e=>{e||g(n)}),e.target.value=``}})]})]})}),I&&!E&&(0,Y.jsxs)(SA,{label:`Description`,hint:`What the image shows, for people who cannot see it.`,children:[(0,Y.jsx)(`span`,{id:ae,className:`sr-only`,children:`Description`}),(0,Y.jsx)(MT,{value:re,disabled:ee,onChange:e=>ie(e.target.value)}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-3`,children:[re===``&&(0,Y.jsx)(`span`,{className:`text-[0.6875rem] text-fg-error-on-surface`,children:`Missing`}),!ee&&te&&re===``&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ie(Ige(te)),className:`text-[0.6875rem] text-fg-secondary underline underline-offset-2 hover:text-fg-primary`,children:`Use the filename`})]})]}),I&&h&&(0,Y.jsxs)(SA,{label:`Focal point`,hint:`Click the image to say what must stay in frame when the page crops it.`,collapsible:!0,summary:p?`${Math.round(p.x*100)}%, ${Math.round(p.y*100)}%`:`Not set`,children:[I&&h&&(0,Y.jsxs)(`div`,{className:`relative rounded-lg bg-bg-secondary`,children:[N&&(0,Y.jsxs)(`div`,{className:`flex absolute inset-0 flex-col justify-center items-center`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 w-full h-full opacity-50 bg-bg-secondary`}),(0,Y.jsx)(hy,{size:24,className:`animate-spin`}),(0,Y.jsx)(`div`,{className:`mt-2 text-xs font-thin text-[white] z-5`,children:F===null?``:`${F}%`})]}),(0,Y.jsx)(`img`,{src:h,draggable:!1,className:`object-contain max-h-[500px] w-full`,style:{cursor:t?`default`:`crosshair`},id:oe,onClick:e=>{if(t)return;let{width:n,height:r,left:i,top:a}=e.currentTarget.getBoundingClientRect(),o={x:Math.max((e.clientX-6-i)/n,0),y:Math.max((e.clientY-6-a)/r,0)};l([{op:`add`,path:u.concat([`hotspot`]),value:o}],`object`)}}),p&&(0,Y.jsx)(sA,{hotspot:p})]}),I&&h&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(UT,{id:`hotspot_toggle:${e}`,checked:!!p,disabled:ee,onCheckedChange:e=>{e?l([{op:`add`,path:u.concat([`hotspot`]),value:{x:.5,y:.5}}],`object`):I.hotspot&&l([{op:`remove`,path:u.concat([`hotspot`])}],`object`)}}),(0,Y.jsxs)(`label`,{htmlFor:`hotspot_toggle:${e}`,className:`text-xs text-fg-secondary select-none`,children:[`Hotspot`,p&&(0,Y.jsxs)(`span`,{className:`ml-1 text-fg-tertiary`,children:[`(`,Math.round(p.x*100),`%,`,` `,Math.round(p.y*100),`%)`]})]})]})]})]}),h&&(0,Y.jsx)(Uy,{open:_,onOpenChange:v,children:(0,Y.jsxs)(Ky,{container:y,className:`max-h-[90vh] max-w-[90vw] overflow-hidden p-0`,children:[(0,Y.jsx)(Yy,{className:`sr-only`,children:te??`Image`}),(0,Y.jsxs)(`div`,{className:`relative inline-flex bg-bg-secondary`,children:[(0,Y.jsx)(`img`,{src:h,alt:re,className:`max-h-[85vh] max-w-full object-contain`}),p&&(0,Y.jsx)(sA,{hotspot:p})]})]})})]})}function Hge(e){switch(e){case`api-key-missing`:return`Val is running in production mode. To upload remote files and images, the VAL_API_KEY env must be set. Contact a developer to fix this issue.`;case`error-could-not-get-settings`:return`Could not get settings from the Val remote server. This means that updating or changing certain types of files and images might not work. Check your internet connection and try again. (Error code: ${e})`;case`no-internet-connection`:return`Cannot upload remote files and images, since this requires an internet connection`;case`pat-error`:return"Val is running in development mode. To upload remote files and images, you must either login (by running `npx -p @valbuild/cli val login`) or set the VAL_API_KEY env";case`project-not-configured`:return`Project is not configured. To upload remote files and images, the val.config must contain a project id that is obtained from https://admin.val.build. Contact a developer to fix this issue.`;case`unauthorized`:return`Cannot upload remote files and images since you are unauthorized`;case`unauthorized-personal-access-token-error`:return"Cannot upload remote files and images since the personal access token is unauthorized. Try to login again by running `npx -p @valbuild/cli val login`";case`unknown-error`:return`Unknown error`;default:return e}}function Uge({path:e}){let t=Ob(e,`image`);if(t.status===`error`)return(0,Y.jsx)(FC,{path:e,error:t.error});if(!(`data`in t)||t.data===void 0)return(0,Y.jsx)(J3,{path:e});if(t.data===null)return(0,Y.jsx)(Y3,{path:e});let n=t.data;return(0,Y.jsx)(`img`,{src:H.mediaUrl(n),draggable:!1,className:`object-contain max-w-[60px] max-h-[60px] rounded-lg`})}function Wge({keys:e,previews:t,value:n,onChange:r,placeholder:i=`Select key...`,className:a,portalContainer:o,isLoading:s=!1}){let[c,l]=b.useState(!1),u=n?t?.[n]:void 0;return(0,Y.jsxs)(SD,{open:c,onOpenChange:l,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,role:`combobox`,"aria-expanded":c,className:X(`w-full justify-start text-left border border-border-primary bg-bg-primary hover:bg-bg-primary-hover h-auto py-1.5`,a),children:[n?u?(0,Y.jsx)(dk,{title:u.title,subtitle:u.subtitle??null,image:u.image??null}):(0,Y.jsx)(`span`,{className:`truncate flex-1`,children:n}):(0,Y.jsx)(`span`,{className:`truncate flex-1`,children:i}),(0,Y.jsx)(zv,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,Y.jsx)(wD,{className:`w-[var(--radix-popover-trigger-width)] p-0`,container:o,children:(0,Y.jsxs)(ik,{children:[(0,Y.jsx)(ak,{placeholder:`Search key...`}),(0,Y.jsx)(ok,{children:s?(0,Y.jsx)(`div`,{className:`py-6 text-center text-sm`,children:`Loading...`}):e.length===0?(0,Y.jsx)(sk,{children:`No keys found.`}):(0,Y.jsx)(ck,{children:e.map(e=>{let i=t?.[e],a=i?`${e} ${i.title}`:e;return(0,Y.jsxs)(uk,{value:a,onSelect:()=>{r(e),l(!1)},className:`flex items-center gap-2`,children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,n===e?`opacity-100`:`opacity-0`)}),i?(0,Y.jsx)(dk,{title:i.title,subtitle:i.subtitle??null,image:i.image??null}):(0,Y.jsx)(`span`,{className:`truncate`,children:e})]},e)})})})]})})]})}function Gge({path:e,readonly:t}){let n=`keyOf`,{navigate:r}=GC(),i=Cb(e),a=`data`in i&&i.data&&i.data.type===`keyOf`?{type:i.data.schema?.type,path:i.data.path}:void 0,o=Ob(a?.path,a?.type),s=xb(a?.path??e),c=`data`in i&&i.data?.type===`keyOf`&&i.data.render?.as===`inline`,l=Cb(a?.path??e),u=Ob(e,n),{patchPath:d,addPatch:f}=vb(e),p=eb();if(i.status===`error`)return(0,Y.jsx)(NC,{path:e,error:i.error,type:n});if(u.status===`error`)return(0,Y.jsx)(FC,{path:e,error:u.error,schema:i});if(o.status===`error`)return(0,Y.jsx)(FC,{path:e,error:o.error,schema:i});if(u.status==`not-found`||i.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(a!==void 0&&a.type!==`record`&&a.type!==`object`)return(0,Y.jsx)(NC,{path:a.path,error:`Cannot refer to keyOf type: ${a.type}. Must refer to be record or object`});if(a!==void 0&&o.status===`not-found`)return(0,Y.jsx)(NC,{path:a.path,error:`Referenced source not found`,type:a.type});if(!(`data`in u)||u.data===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(`data`in i&&i.data&&i.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:i.data.type});if(!o)return(0,Y.jsx)(NC,{path:a?.path,error:`Referenced source not found`,type:`keyOf`});if(`data`in o&&o.data===null)return(0,Y.jsx)(NC,{path:a?.path,error:`Referenced source is null`,type:`keyOf`});let m=`data`in o&&o.data?Object.keys(o.data):void 0,h=u.data,g=Kge(s),_=i.status===`loading`||a===void 0||m===void 0,v=c&&`data`in l?l.data?.type===`record`?l.data.item:l.data?.type===`object`&&h!==null?l.data.items[h]:void 0:void 0,y=c&&a?.path&&h!==null?H.createValPathOfItem(a.path,h):void 0,b=(0,Y.jsxs)(`div`,{id:e,children:[(0,Y.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Y.jsx)(Wge,{keys:m??[],previews:g,value:h,onChange:e=>{f([{op:`replace`,path:d,value:e}],n)},portalContainer:p,isLoading:_}),h&&a?.path&&(0,Y.jsx)(`button`,{title:`Go to reference`,className:`px-2`,onClick:()=>{r(H.createValPathOfItem(a.path,h))},children:(0,Y.jsx)(dy,{size:16})})]}),c&&y!==void 0&&v!==void 0&&(0,Y.jsxs)(`div`,{className:`mt-2 rounded-md border border-border-primary p-3`,children:[(0,Y.jsx)(`div`,{className:`pb-2 text-xs text-fg-quaternary truncate`,children:h}),(0,Y.jsx)(a6,{path:y,schema:v,readonly:t===!0,compact:!0})]})]});return t?(0,Y.jsx)(NT,{children:b}):b}function Kge(e){if(!e||!(`data`in e)||!e.data)return;let t=e.data;if(t.parent!==`record`)return;let n={};for(let[e,r]of t.items)n[e]={title:r.title,subtitle:r.subtitle??null,image:r.image??null};return n}function qge({path:e}){let t=Ob(e,`keyOf`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{className:`truncate`,children:t.data})}var wA=new WeakMap;function Jge(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].route!==t[n].route||e[n].moduleFilePath!==t[n].moduleFilePath)return!1;return!0}var Yge=[];function Xge(e){if(e===null)return Yge;let t=e.system.sourceStore.sourcesVersion(),n=e.system.schemaStore.all(),r=Object.keys(n).length,i=wA.get(e.system);if(i!==void 0&&i.version===t&&i.schemas===r)return i.routes;let a=sp(n,e.system.sourceStore.allSources()),o=i!==void 0&&Jge(i.routes,a)?i.routes:a;return wA.set(e.system,{version:t,schemas:r,routes:o}),o}function Zge(){let e=nb(),t=(0,b.useCallback)(t=>{if(e===null)return()=>{};let n=e.system.sourceStore.events.on(`source:change`,t),r=e.system.schemaStore.events.on(`schema:init`,t);return()=>{n(),r()}},[e]),n=(0,b.useCallback)(()=>Xge(e),[e]);return(0,b.useSyncExternalStore)(t,n,n)}function TA(){return Zge()}var Qge=`external-url-router`;function $ge(e){return e?.type===`record`&&typeof e.router==`string`}function e_e(e){return e.length===0?`/`:e.map(e=>e.type===`literal`?`/${e.name}`:e.type===`array-param`?`/[...${e.paramName}]`:`/[${e.paramName}]`).join(``)}function t_e(e){return e.replace(/^\/(src\/)?app/,``).replace(/\/page\.val\.[tj]sx?$/,``).replace(/\.val\.[tj]sx?$/,``)}function n_e(e,t){let n=[],r=null;for(let i in e){let a=i,o=e[a];if(!$ge(o))continue;let s=t[a],c=s&&typeof s==`object`&&!Array.isArray(s)?Object.keys(s):[],l=np(t_e(a)),u={moduleFilePath:a,routerId:o.router,routePattern:l,patternString:e_e(l),existingKeys:c,keyDescription:o.key?.description};o.router===Qge?r??=u:n.push(u)}return n.sort((e,t)=>e.patternString.localeCompare(t.patternString)),{pageRouters:n,externalRouter:r}}function r_e(){let e=wb(),t=Eb();return(0,b.useMemo)(()=>!(`data`in e)||e.data===void 0?{pageRouters:[],externalRouter:null}:n_e(e.data,t),[e,t])}function i_e(){let{addModuleFilePatch:e}=LS(),t=wb();return(0,b.useCallback)((n,r)=>{if(!(`data`in t)||t.data===void 0)return console.error(`Cannot create route entry: schemas are not loaded`),null;let i=t.data[n.moduleFilePath];return i?.type===`record`?(e(n.moduleFilePath,[{op:`add`,path:H.createPatchPath(``).concat(r),value:Cp(i.item)}],`record`),r):(console.error(`Cannot create route entry: not a record`,{moduleFilePath:n.moduleFilePath,schema:i}),null)},[e,t])}function EA({routes:e,onSubmit:t,onCancel:n,currentPage:r}){let i=(0,b.useMemo)(()=>a_e(e,r),[e,r]),[a,o]=(0,b.useState)(null),s=(0,b.useMemo)(()=>e.find(e=>DA(e)===a)??i??null,[e,a,i]),c=s?DA(s):``,[l,u]=(0,b.useState)({}),[d,f]=(0,b.useState)({}),p=s?l[DA(s)]??{}:{},m=s?d[DA(s)]??{}:{},h=(0,b.useMemo)(()=>s?s_e(s.routePattern,p):``,[s,p]),g=(0,b.useMemo)(()=>s?s.routePattern.every(e=>e.type===`string-param`||e.type===`array-param`?p[e.paramName]?!m[e.paramName]:e.optional:!0):!1,[s,p,m]),_=!!s&&s.existingKeys.includes(h),v=!g||_,y=s?DA(s):``;return s?(0,Y.jsxs)(`form`,{className:`p-3 space-y-3`,onSubmit:e=>{e.preventDefault(),!v&&t(s.moduleFilePath,h)},children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg-primary`,children:`New page`}),e.length>1?(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`label`,{className:`text-xs text-fg-secondary`,children:`Route`}),(0,Y.jsx)(p_e,{routes:e,value:c,onChange:o})]}):(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Route`}),(0,Y.jsx)(c_e,{pattern:s.routePattern})]}),s.keyDescription&&(0,Y.jsx)(`div`,{className:`max-w-[240px] text-pretty text-xs text-fg-tertiary`,children:s.keyDescription}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`URL`}),(0,Y.jsx)(l_e,{pattern:s.routePattern,params:p,errors:m,onChange:(e,t,n)=>{let r=DA(s);u(n=>({...n,[r]:{...n[r]??{},[e]:t}})),f(t=>({...t,[r]:{...t[r]??{},[e]:n}}))}},y),(0,Y.jsx)(f_e,{pattern:s.routePattern})]}),_&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-error-on-surface`,children:`A page with this path already exists`}),(0,Y.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[(0,Y.jsx)(t_,{size:`sm`,variant:`ghost`,type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsx)(t_,{size:`sm`,disabled:v,type:`submit`,children:`Create`})]})]}):(0,Y.jsx)(`div`,{className:`p-3 text-sm text-fg-secondary`,children:`No routes accept new pages.`})}function DA(e){return e?`${e.moduleFilePath}::${e.patternString}`:``}function a_e(e,t){if(!t)return e[0];let n=e[0],r=0;for(let i of e){let e=i.moduleFilePath===t.moduleFilePath,a=(o_e(i.routePattern,t.urlPath)?2:0)+ +!!e;a>r&&(n=i,r=a)}return n}function o_e(e,t){let n=t.split(`/`).filter(e=>e!==``),r=0;for(let t of e){if(t.type===`array-param`)return n.length-r!==0||t.optional;if(t.type===`string-param`){if(r>=n.length){if(!t.optional)return!1;continue}r++;continue}if(n[r]!==t.name)return!1;r++}return r===n.length}function s_e(e,t){let n=[];for(let r of e){if(r.type===`string-param`||r.type===`array-param`){let e=t[r.paramName];if(!e){if(r.optional)continue;n.push(``);continue}n.push(e);continue}n.push(r.name)}return n.length===0?`/`:`/`+n.join(`/`)}function c_e({pattern:e}){return(0,Y.jsxs)(`div`,{className:`flex items-center flex-wrap gap-0 px-2 py-1.5 rounded-md bg-bg-secondary font-mono text-xs text-fg-primary`,children:[(0,Y.jsx)(`span`,{className:`text-fg-secondary`,children:`/`}),e.map((t,n)=>(0,Y.jsxs)(`span`,{className:`flex items-center`,children:[t.type===`literal`?(0,Y.jsx)(`span`,{children:t.name}):(0,Y.jsx)(d_e,{part:t}),n<e.length-1&&(0,Y.jsx)(`span`,{className:`text-fg-secondary`,children:`/`})]},n))]})}function l_e({pattern:e,params:t,errors:n,onChange:r}){let i=(0,b.useMemo)(()=>u_e(e),[e]),a=(0,b.useMemo)(()=>i.findIndex(e=>e.type!==`literal-run`),[i]);return(0,Y.jsx)(`div`,{className:`flex items-stretch flex-wrap gap-1 font-mono text-xs`,children:i.map((e,o)=>{if(e.type===`literal-run`)return(0,Y.jsxs)(`span`,{className:`inline-flex items-center px-2 rounded-md bg-bg-secondary text-fg-secondary`,children:[`/`,e.parts.map(e=>e.name).join(`/`),o<i.length-1?`/`:``]},o);let s=e.part,c=t[s.paramName]||``,l=n[s.paramName],u=s.type===`array-param`;return(0,Y.jsxs)(`span`,{className:`inline-flex flex-col`,children:[(0,Y.jsx)(`input`,{autoFocus:o===a,className:X(`h-7 px-2 rounded-md bg-bg-primary border border-border-primary text-fg-primary font-mono text-xs`,`focus:outline-none focus:ring-1 focus:ring-border-focus`,u?`min-w-[16ch]`:`min-w-[10ch]`,{"border-fg-error":!!l}),placeholder:s.paramName,value:c,onChange:e=>{let t=e.target.value,n=u?t.replace(/\//g,``):t,i=t.length>0&&encodeURIComponent(n)!==n;r(s.paramName,t,i?`Invalid characters`:void 0)}}),l&&(0,Y.jsx)(`span`,{className:`mt-0.5 text-[10px] text-fg-error-on-surface`,children:l})]},o)})})}function u_e(e){let t=[],n=null;for(let r of e)r.type===`literal`?(n||(n=[],t.push({type:`literal-run`,parts:n})),n.push({name:r.name})):(n=null,t.push({type:`dynamic`,part:r}));return t}function d_e({part:e}){let t=e.type===`array-param`?`...${e.paramName}`:e.paramName;return(0,Y.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0 rounded text-[11px] bg-bg-brand-secondary text-fg-brand-secondary`,children:[`[`,t,`]`]})}function f_e({pattern:e}){let t=e.some(e=>e.type===`array-param`),n=e.filter(e=>e.type===`string-param`||e.type===`array-param`).length;return t?(0,Y.jsxs)(`p`,{className:`text-[11px] text-fg-secondary`,children:[`Catch-all segments can contain `,(0,Y.jsx)(`code`,{children:`/`}),` for nested paths.`]}):n>1?(0,Y.jsx)(`p`,{className:`text-[11px] text-fg-secondary`,children:`Fill in each segment. Slashes will be added automatically.`}):(0,Y.jsx)(`p`,{className:`text-[11px] text-fg-secondary`,children:`Use lowercase letters, numbers, and hyphens.`})}function p_e({routes:e,value:t,onChange:n}){return(0,Y.jsx)(`select`,{"aria-label":`Route`,className:X(`w-full h-8 px-2 rounded-md bg-bg-primary border border-border-primary`,`font-mono text-xs text-fg-primary`,`focus:outline-none focus:ring-1 focus:ring-border-focus`),value:t,onChange:e=>n(e.target.value),children:e.map(e=>(0,Y.jsx)(`option`,{value:DA(e),children:e.patternString},DA(e)))})}function m_e({routes:e,value:t,onChange:n,includePattern:r,excludePattern:i,placeholder:a=`Select route...`,className:o,portalContainer:s,isLoading:c=!1,zIndex:l,readonly:u,allowCreate:d=!1}){let[f,p]=b.useState(!1),[m,h]=b.useState(null),{pageRouters:g,externalRouter:_}=r_e(),v=i_e(),y=()=>{p(!1),h(null)},x=d&&!u&&g.length>0,S=d&&!u&&_!==null,C=e.filter(e=>!(r&&!r.test(e.route)||i&&i.test(e.route))),w=t?C.find(e=>e.route===t):void 0;return(0,Y.jsxs)(SD,{open:!u&&f,onOpenChange:u?void 0:p,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,role:`combobox`,"aria-expanded":f,className:X(`w-full justify-start text-left border border-border-primary bg-bg-primary hover:bg-bg-primary-hover h-auto py-1.5`,o),children:[w&&w.preview?(0,Y.jsx)(dk,{title:w.preview.title,subtitle:w.preview.subtitle??null,image:w.preview.image??null}):(0,Y.jsx)(`span`,{className:`truncate flex-1`,children:t||a}),(0,Y.jsx)(zv,{className:`ml-2 h-4 w-4 shrink-0 opacity-50`})]})}),(0,Y.jsxs)(wD,{className:`w-[var(--radix-popover-trigger-width)] p-0`,style:{zIndex:l},container:s,children:[m===`page`&&(0,Y.jsx)(EA,{routes:g.map(g_e),onSubmit:(e,t)=>{let r=g.find(t=>t.moduleFilePath===e);r&&(v(r,t)!==null&&n(t),y())},onCancel:()=>h(null)}),m===`external`&&_&&(0,Y.jsx)(h_e,{existingKeys:_.existingKeys,onSubmit:e=>{v(_,e)!==null&&n(e),y()},onCancel:()=>h(null)}),m===null&&(0,Y.jsxs)(ik,{children:[(0,Y.jsx)(ak,{placeholder:a}),(0,Y.jsxs)(ok,{children:[c?(0,Y.jsx)(`div`,{className:`py-6 text-center text-sm`,children:`Loading...`}):C.length===0?(0,Y.jsx)(sk,{children:`No routes found.`}):(0,Y.jsx)(ck,{children:C.map(e=>{let r=e.preview,i=r?`${e.route} ${r.title}`:e.route;return(0,Y.jsxs)(uk,{value:i,onSelect:()=>{n(e.route),p(!1)},className:`flex items-center gap-2`,children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,t===e.route?`opacity-100`:`opacity-0`)}),r?(0,Y.jsx)(dk,{title:r.title,subtitle:r.subtitle??null,image:r.image??null}):(0,Y.jsx)(`span`,{className:`truncate`,children:e.route})]},e.route)})}),(x||S)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(lk,{}),(0,Y.jsxs)(ck,{children:[x&&(0,Y.jsxs)(uk,{value:`__val_new_page__`,onSelect:()=>h(`page`),className:`flex items-center gap-2`,children:[(0,Y.jsx)(Oy,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{children:`New page`})]}),S&&(0,Y.jsxs)(uk,{value:`__val_new_external_page__`,onSelect:()=>h(`external`),className:`flex items-center gap-2`,children:[(0,Y.jsx)(Wie,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{children:`New external page`})]})]})]})]})]})]})]})}function h_e({existingKeys:e,onSubmit:t,onCancel:n}){let[r,i]=b.useState(``),a=r.trim(),o=e.includes(a),s=a.startsWith(`https://`)||a.startsWith(`http://`),c=a?s?o?`This external page already exists`:null:`Must start with https:// or http://`:null,l=!a||c!==null;return(0,Y.jsxs)(`form`,{className:`p-3 space-y-3`,onSubmit:e=>{e.preventDefault(),!l&&t(a)},children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-fg-primary`,children:`New external page`}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`input`,{autoFocus:!0,className:X(`w-full p-1 bg-bg-secondary border border-border-primary rounded text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,{"border-fg-error":c!==null}),placeholder:`https://example.com`,value:r,onChange:e=>i(e.target.value)}),c&&(0,Y.jsx)(`p`,{className:`text-xs text-fg-error`,children:c})]}),(0,Y.jsxs)(`div`,{className:`flex gap-2 justify-end pt-1`,children:[(0,Y.jsx)(t_,{size:`sm`,variant:`ghost`,type:`button`,onClick:n,children:`Cancel`}),(0,Y.jsx)(t_,{size:`sm`,type:`submit`,disabled:l,children:`Create`})]})]})}function g_e(e){return{moduleFilePath:e.moduleFilePath,routePattern:e.routePattern,patternString:e.patternString,existingKeys:e.existingKeys,keyDescription:e.keyDescription}}function __e(e){let t=ooe();return b.useMemo(()=>{let n=new Map;return e.map(({route:e,moduleFilePath:r})=>{if(!n.has(r)){let e=new Map,i=t[r];if(i){let t=i[r];if(t&&`data`in t&&t.data&&t.data.parent===`record`)for(let[n,r]of t.data.items)e.set(n,{title:r.title,subtitle:r.subtitle??null,image:r.image??null})}n.set(r,e)}return{route:e,moduleFilePath:r,preview:n.get(r)?.get(e)??null}})},[e,t])}function v_e({path:e,readonly:t}){let n=`route`,{navigate:r}=GC(),i=Cb(e),a=Ob(e,n),{patchPath:o,addPatch:s}=vb(e),c=eb(),l=TA(),u=__e(l);if(i.status===`error`)return(0,Y.jsx)(NC,{path:e,error:i.error,type:n});if(a.status===`error`)return(0,Y.jsx)(FC,{path:e,error:a.error,schema:i});if(a.status==`not-found`||i.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(!(`data`in a)||a.data===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(`data`in i&&i.data&&i.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:i.data.type});let d=a.data,f=`data`in i&&i.data?.type===`route`?i.data:void 0,p=f?.options?.include?new RegExp(f.options.include.source,f.options.include.flags):void 0,m=f?.options?.exclude?new RegExp(f.options.exclude.source,f.options.exclude.flags):void 0,h=d?l.find(e=>e.route===d):void 0,g=i.status===`loading`,_=(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,Y.jsx)(m_e,{routes:u,value:d,onChange:e=>{t||s([{op:`replace`,path:o,value:e}],n)},includePattern:p,excludePattern:m,portalContainer:c,isLoading:g,readonly:t,allowCreate:!0}),d&&h&&(0,Y.jsx)(`button`,{title:`Go to reference`,className:`px-2`,onClick:()=>{r(H.joinModuleFilePathAndModulePath(h.moduleFilePath,JSON.stringify(d)))},children:(0,Y.jsx)(dy,{size:16})})]})});return t?(0,Y.jsx)(NT,{children:_}):_}function y_e({path:e}){let t=Ob(e,`route`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{className:`truncate`,children:t.data})}var b_e=365.2425,OA=6048e5,x_e=864e5,kA=86400;kA*7,kA*b_e/12*3;var AA=Symbol.for(`constructDateFrom`);function jA(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&AA in e?e[AA](t):e instanceof Date?new e.constructor(t):new Date(t)}function MA(e,t){return jA(t||e,e)}function NA(e,t,n){let r=MA(e,n?.in);return isNaN(t)?jA(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function PA(e,t,n){let r=MA(e,n?.in);if(isNaN(t))return jA(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=jA(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}var S_e={};function FA(){return S_e}function IA(e,t){let n=FA(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=MA(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function LA(e,t){return IA(e,{...t,weekStartsOn:1})}function RA(e,t){let n=MA(e,t?.in),r=n.getFullYear(),i=jA(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=LA(i),o=jA(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=LA(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function zA(e){let t=MA(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-n}function BA(e,...t){let n=jA.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function VA(e,t){let n=MA(e,t?.in);return n.setHours(0,0,0,0),n}function HA(e,t,n){let[r,i]=BA(n?.in,e,t),a=VA(r),o=VA(i),s=+a-zA(a),c=+o-zA(o);return Math.round((s-c)/x_e)}function C_e(e,t){let n=RA(e,t),r=jA(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),LA(r)}function w_e(e,t,n){return NA(e,t*7,n)}function T_e(e,t,n){return PA(e,t*12,n)}function E_e(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=jA.bind(null,e));let t=MA(e,r);(!n||n<t||isNaN(+t))&&(n=t)}),jA(r,n||NaN)}function D_e(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=jA.bind(null,e));let t=MA(e,r);(!n||n>t||isNaN(+t))&&(n=t)}),jA(r,n||NaN)}function O_e(e,t,n){let[r,i]=BA(n?.in,e,t);return+VA(r)==+VA(i)}function UA(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function k_e(e){return!(!UA(e)&&typeof e!=`number`||isNaN(+MA(e)))}function WA(e,t,n){let[r,i]=BA(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function A_e(e,t){let n=MA(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function GA(e,t){let[n,r]=BA(e,t.start,t.end);return{start:n,end:r}}function j_e(e,t){let{start:n,end:r}=GA(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setDate(1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(jA(n,o)),o.setMonth(o.getMonth()+s);return i?c.reverse():c}function M_e(e,t){let n=MA(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function N_e(e,t){let n=MA(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function KA(e,t){let n=MA(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function P_e(e,t){let{start:n,end:r}=GA(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setMonth(0,1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(jA(n,o)),o.setFullYear(o.getFullYear()+s);return i?c.reverse():c}function qA(e,t){let n=FA(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=MA(e,t?.in),a=i.getDay(),o=(a<r?-7:0)+6-(a-r);return i.setDate(i.getDate()+o),i.setHours(23,59,59,999),i}function F_e(e,t){return qA(e,{...t,weekStartsOn:1})}var I_e={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},L_e=(e,t,n)=>{let r,i=I_e[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function JA(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var R_e={date:JA({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:JA({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:JA({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},z_e={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},B_e=(e,t,n,r)=>z_e[e];function YA(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var V_e={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:YA({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:YA({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:YA({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:YA({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:YA({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function XA(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?U_e(s,e=>e.test(o)):H_e(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function H_e(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function U_e(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function W_e(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var ZA={code:`en-US`,formatDistance:L_e,formatLong:R_e,formatRelative:B_e,localize:V_e,match:{ordinalNumber:W_e({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:XA({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:XA({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:XA({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:XA({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:XA({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function G_e(e,t){let n=MA(e,t?.in);return HA(n,KA(n))+1}function QA(e,t){let n=MA(e,t?.in),r=+LA(n)-C_e(n);return Math.round(r/OA)+1}function $A(e,t){let n=MA(e,t?.in),r=n.getFullYear(),i=FA(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=jA(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=IA(o,t),c=jA(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=IA(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function K_e(e,t){let n=FA(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=$A(e,t),a=jA(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),IA(a,t)}function ej(e,t){let n=MA(e,t?.in),r=+IA(n,t)-K_e(n,t);return Math.round(r/OA)+1}function tj(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var nj={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return tj(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):tj(n+1,2)},d(e,t){return tj(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return tj(e.getHours()%12||12,t.length)},H(e,t){return tj(e.getHours(),t.length)},m(e,t){return tj(e.getMinutes(),t.length)},s(e,t){return tj(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return tj(Math.trunc(r*10**(n-3)),t.length)}},rj={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},ij={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return nj.y(e,t)},Y:function(e,t,n,r){let i=$A(e,r),a=i>0?i:1-i;return t===`YY`?tj(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):tj(a,t.length)},R:function(e,t){return tj(RA(e),t.length)},u:function(e,t){return tj(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return tj(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return tj(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return nj.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return tj(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=ej(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):tj(i,t.length)},I:function(e,t,n){let r=QA(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):tj(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):nj.d(e,t)},D:function(e,t,n){let r=G_e(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):tj(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return tj(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return tj(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return tj(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?rj.noon:r===0?rj.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?rj.evening:r>=12?rj.afternoon:r>=4?rj.morning:rj.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return nj.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):nj.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):tj(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):tj(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):nj.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):nj.s(e,t)},S:function(e,t){return nj.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return oj(r);case`XXXX`:case`XX`:return sj(r);default:return sj(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return oj(r);case`xxxx`:case`xx`:return sj(r);default:return sj(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+aj(r,`:`);default:return`GMT`+sj(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+aj(r,`:`);default:return`GMT`+sj(r,`:`)}},t:function(e,t,n){return tj(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return tj(+e,t.length)}};function aj(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+tj(a,2)}function oj(e,t){return e%60==0?(e>0?`-`:`+`)+tj(Math.abs(e)/60,2):sj(e,t)}function sj(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=tj(Math.trunc(r/60),2),a=tj(r%60,2);return n+i+t+a}var cj=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},lj=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},q_e={p:lj,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return cj(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`})}return a.replace(`{{date}}`,cj(r,t)).replace(`{{time}}`,lj(i,t))}},J_e=/^D+$/,Y_e=/^Y+$/,X_e=[`D`,`DD`,`YY`,`YYYY`];function Z_e(e){return J_e.test(e)}function Q_e(e){return Y_e.test(e)}function $_e(e,t,n){let r=eve(e,t,n);if(console.warn(r),X_e.includes(e))throw RangeError(r)}function eve(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var tve=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,nve=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,rve=/^'([^]*?)'?$/,ive=/''/g,ave=/[a-zA-Z]/;function uj(e,t,n){let r=FA(),i=n?.locale??r.locale??ZA,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=MA(e,n?.in);if(!k_e(s))throw RangeError(`Invalid time value`);let c=t.match(nve).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=q_e[t];return n(e,i.formatLong)}return e}).join(``).match(tve).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:ove(e)};if(ij[t])return{isToken:!0,value:e};if(t.match(ave))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&Q_e(a)||!n?.useAdditionalDayOfYearTokens&&Z_e(a))&&$_e(a,t,String(e));let o=ij[a[0]];return o(s,a,i.localize,l)}).join(``)}function ove(e){let t=e.match(rve);return t?t[1].replace(ive,`'`):e}function sve(e,t){let n=MA(e,t?.in),r=n.getFullYear(),i=n.getMonth(),a=jA(n,0);return a.setFullYear(r,i+1,0),a.setHours(0,0,0,0),a.getDate()}function cve(e,t){return MA(e,t?.in).getMonth()}function lve(e,t){return MA(e,t?.in).getFullYear()}function uve(e,t){return+MA(e)>+MA(t)}function dve(e,t){return+MA(e)<+MA(t)}function fve(e,t,n){let[r,i]=BA(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function pve(e,t,n){let[r,i]=BA(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function mve(e,t,n){let r=MA(e,n?.in),i=r.getFullYear(),a=r.getDate(),o=jA(n?.in||e,0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);let s=sve(o);return r.setMonth(t,Math.min(a,s)),r}function hve(e,t,n){let r=MA(e,n?.in);return isNaN(+r)?jA(n?.in||e,NaN):(r.setFullYear(t),r)}function gve(e,t,n=`long`){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(` `)}var _ve={},dj={};function fj(e,t){try{let n=(_ve[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format)(t).split(`GMT`)[1];return n in dj?dj[n]:pj(n,n.split(`:`))}catch{if(e in dj)return dj[e];let t=e?.match(vve);return t?pj(e,t.slice(1)):NaN}}var vve=/([+-]\d\d):?(\d\d)?/;function pj(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return dj[e]=n*60+r>0?n*60+r+i:n*60-r-i}var mj=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(fj(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),_j(this,NaN),gj(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-fj(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),gj(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},hj=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!hj.test(e))return;let t=e.replace(hj,`$1UTC`);mj.prototype[t]&&(e.startsWith(`get`)?mj.prototype[e]=function(){return this.internal[t]()}:(mj.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),yve(this),+this},mj.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),gj(this),+this}))});function gj(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-fj(e.timeZone,e)*60))}function yve(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),_j(e)}function _j(e){let t=fj(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);let i=-new Date(+e).getTimezoneOffset(),a=i- -new Date(+r).getTimezoneOffset(),o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);let s=i-n;s&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+s);let c=new Date(+e);c.setUTCSeconds(0);let l=i>0?c.getSeconds():(c.getSeconds()-60)%60,u=Math.round(-(fj(e.timeZone,e)*60))%60;(u||l)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+l));let d=fj(e.timeZone,e),f=d>0?Math.floor(d):Math.ceil(d),p=-new Date(+e).getTimezoneOffset()-f,m=f!==n,h=p-s;if(m&&h){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+h);let t=fj(e.timeZone,e),n=f-(t>0?Math.floor(t):Math.ceil(t));n&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+n),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n))}}var vj=class e extends mj{static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}toISOString(){let[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[e,t,n,r]=this.internal.toUTCString().split(` `);return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){let e=this.internal.toUTCString().split(` `)[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${gve(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){let e=this.getTimezoneOffset();return[e>0?`-`:`+`,String(Math.floor(Math.abs(e)/60)).padStart(2,`0`),String(Math.abs(e)%60).padStart(2,`0`)]}withTimeZone(t){return new e(+this,t)}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},bve=5,xve=4;function Sve(e,t){let n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),a=t.addDays(i,34);return t.getMonth(e)===t.getMonth(a)?bve:xve}function yj(e,t){let n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function Cve(e,t){let n=yj(e,t),r=Sve(e,t);return t.addDays(n,r*7-1)}var bj={...ZA,labels:{labelDayButton:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>uj(e,t,{locale:ZA,...n});let a=i(e,`PPPP`);return t.today&&(a=`Today, ${a}`),t.selected&&(a=`${a}, selected`),a},labelMonthDropdown:`Choose the Month`,labelNext:`Go to the Next Month`,labelPrevious:`Go to the Previous Month`,labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:`Choose the Year`,labelGrid:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>uj(e,n,{locale:ZA,...t}),r(e,`LLLL yyyy`)},labelGridcell:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>uj(e,t,{locale:ZA,...n});let a=i(e,`PPPP`);return t?.today&&(a=`Today, ${a}`),a},labelNav:`Navigation bar`,labelWeekNumberHeader:`Week Number`,labelWeekday:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>uj(e,n,{locale:ZA,...t}),r(e,`cccc`)}}},xj=class e{constructor(e,t){this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?vj.tz(this.options.timeZone):new(this.options.Date??Date),this.newDate=(e,t,n)=>this.overrides?.newDate?this.overrides.newDate(e,t,n):this.options.timeZone?new vj(e,t,n,this.options.timeZone):new Date(e,t,n),this.addDays=(e,t)=>this.overrides?.addDays?this.overrides.addDays(e,t):NA(e,t),this.addMonths=(e,t)=>this.overrides?.addMonths?this.overrides.addMonths(e,t):PA(e,t),this.addWeeks=(e,t)=>this.overrides?.addWeeks?this.overrides.addWeeks(e,t):w_e(e,t),this.addYears=(e,t)=>this.overrides?.addYears?this.overrides.addYears(e,t):T_e(e,t),this.differenceInCalendarDays=(e,t)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(e,t):HA(e,t),this.differenceInCalendarMonths=(e,t)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(e,t):WA(e,t),this.eachMonthOfInterval=e=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(e):j_e(e),this.eachYearOfInterval=e=>{let t=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(e):P_e(e),n=new Set(t.map(e=>this.getYear(e)));if(n.size===t.length)return t;let r=[];return n.forEach(e=>{r.push(new Date(e,0,1))}),r},this.endOfBroadcastWeek=e=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(e):Cve(e,this),this.endOfISOWeek=e=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(e):F_e(e),this.endOfMonth=e=>this.overrides?.endOfMonth?this.overrides.endOfMonth(e):A_e(e),this.endOfWeek=(e,t)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(e,t):qA(e,this.options),this.endOfYear=e=>this.overrides?.endOfYear?this.overrides.endOfYear(e):N_e(e),this.format=(e,t,n)=>{let r=this.overrides?.format?this.overrides.format(e,t,this.options):uj(e,t,this.options);return this.options.numerals&&this.options.numerals!==`latn`?this.replaceDigits(r):r},this.getISOWeek=e=>this.overrides?.getISOWeek?this.overrides.getISOWeek(e):QA(e),this.getMonth=(e,t)=>this.overrides?.getMonth?this.overrides.getMonth(e,this.options):cve(e,this.options),this.getYear=(e,t)=>this.overrides?.getYear?this.overrides.getYear(e,this.options):lve(e,this.options),this.getWeek=(e,t)=>this.overrides?.getWeek?this.overrides.getWeek(e,this.options):ej(e,this.options),this.isAfter=(e,t)=>this.overrides?.isAfter?this.overrides.isAfter(e,t):uve(e,t),this.isBefore=(e,t)=>this.overrides?.isBefore?this.overrides.isBefore(e,t):dve(e,t),this.isDate=e=>this.overrides?.isDate?this.overrides.isDate(e):UA(e),this.isSameDay=(e,t)=>this.overrides?.isSameDay?this.overrides.isSameDay(e,t):O_e(e,t),this.isSameMonth=(e,t)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(e,t):fve(e,t),this.isSameYear=(e,t)=>this.overrides?.isSameYear?this.overrides.isSameYear(e,t):pve(e,t),this.max=e=>this.overrides?.max?this.overrides.max(e):E_e(e),this.min=e=>this.overrides?.min?this.overrides.min(e):D_e(e),this.setMonth=(e,t)=>this.overrides?.setMonth?this.overrides.setMonth(e,t):mve(e,t),this.setYear=(e,t)=>this.overrides?.setYear?this.overrides.setYear(e,t):hve(e,t),this.startOfBroadcastWeek=(e,t)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(e,this):yj(e,this),this.startOfDay=e=>this.overrides?.startOfDay?this.overrides.startOfDay(e):VA(e),this.startOfISOWeek=e=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(e):LA(e),this.startOfMonth=e=>this.overrides?.startOfMonth?this.overrides.startOfMonth(e):M_e(e),this.startOfWeek=(e,t)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(e,this.options):IA(e,this.options),this.startOfYear=e=>this.overrides?.startOfYear?this.overrides.startOfYear(e):KA(e),this.options={locale:bj,...e},this.overrides=t}getDigitMap(){let{numerals:e=`latn`}=this.options,t=new Intl.NumberFormat(`en-US`,{numberingSystem:e}),n={};for(let e=0;e<10;e++)n[e.toString()]=t.format(e);return n}replaceDigits(e){let t=this.getDigitMap();return e.replace(/\d/g,e=>t[e]||e)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){let t=this.options.locale?.code;return t&&e.yearFirstLocales.has(t)?`year-first`:`month-first`}formatMonthYear(t){let{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&e.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:`long`,year:`numeric`,timeZone:r,numberingSystem:i}).format(t)}catch{}let o=this.getMonthYearOrder()===`year-first`?`y LLLL`:`LLLL y`;return this.format(t,o)}};xj.yearFirstLocales=new Set([`eu`,`hu`,`ja`,`ja-Hira`,`ja-JP`,`ko`,`ko-KR`,`lt`,`lt-LT`,`lv`,`lv-LV`,`mn`,`mn-MN`,`zh`,`zh-CN`,`zh-HK`,`zh-TW`]);var Sj=new xj,Cj=class{constructor(e,t,n=Sj){this.date=e,this.displayMonth=t,this.outside=!!(t&&!n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,`yyyy-MM-dd`),this.displayMonthId=n.format(t,`yyyy-MM`),this.dateMonthId=n.format(e,`yyyy-MM`)}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}},wve=class{constructor(e,t){this.date=e,this.weeks=t}},Tve=class{constructor(e,t){this.days=t,this.weekNumber=e}};function Eve(e){return b.createElement(`span`,{...e})}function Dve(e){let{size:t=24,orientation:n=`left`,className:r,style:i}=e;return b.createElement(`svg`,{className:r,style:i,width:t,height:t,viewBox:`0 0 24 24`},n===`up`&&b.createElement(`polygon`,{points:`6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28`}),n===`down`&&b.createElement(`polygon`,{points:`6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72`}),n===`left`&&b.createElement(`polygon`,{points:`16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20`}),n===`right`&&b.createElement(`polygon`,{points:`8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20`}))}function Ove(e){let{day:t,modifiers:n,...r}=e;return b.createElement(`td`,{...r})}function kve(e){let{day:t,modifiers:n,...r}=e,i=b.useRef(null);return b.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),b.createElement(`button`,{ref:i,...r})}var wj;(function(e){e.Root=`root`,e.Chevron=`chevron`,e.Day=`day`,e.DayButton=`day_button`,e.CaptionLabel=`caption_label`,e.Dropdowns=`dropdowns`,e.Dropdown=`dropdown`,e.DropdownRoot=`dropdown_root`,e.Footer=`footer`,e.MonthGrid=`month_grid`,e.MonthCaption=`month_caption`,e.MonthsDropdown=`months_dropdown`,e.Month=`month`,e.Months=`months`,e.Nav=`nav`,e.NextMonthButton=`button_next`,e.PreviousMonthButton=`button_previous`,e.Week=`week`,e.Weeks=`weeks`,e.Weekday=`weekday`,e.Weekdays=`weekdays`,e.WeekNumber=`week_number`,e.WeekNumberHeader=`week_number_header`,e.YearsDropdown=`years_dropdown`})(wj||={});var Tj;(function(e){e.disabled=`disabled`,e.hidden=`hidden`,e.outside=`outside`,e.focused=`focused`,e.today=`today`})(Tj||={});var Ej;(function(e){e.range_end=`range_end`,e.range_middle=`range_middle`,e.range_start=`range_start`,e.selected=`selected`})(Ej||={});var Dj;(function(e){e.weeks_before_enter=`weeks_before_enter`,e.weeks_before_exit=`weeks_before_exit`,e.weeks_after_enter=`weeks_after_enter`,e.weeks_after_exit=`weeks_after_exit`,e.caption_after_enter=`caption_after_enter`,e.caption_after_exit=`caption_after_exit`,e.caption_before_enter=`caption_before_enter`,e.caption_before_exit=`caption_before_exit`})(Dj||={});var Oj=(0,b.createContext)(void 0);function kj(){let e=(0,b.useContext)(Oj);if(e===void 0)throw Error(`useDayPicker() must be used within a custom component.`);return e}function Ave(e){let{options:t,className:n,...r}=e,{classNames:i,components:a,styles:o}=kj(),s=[i[wj.Dropdown],n].join(` `),c=t?.find(({value:e})=>e===r.value);return b.createElement(`span`,{"data-disabled":r.disabled,className:i[wj.DropdownRoot],style:o?.[wj.DropdownRoot]},b.createElement(a.Select,{className:s,...r},t?.map(({value:e,label:t,disabled:n})=>b.createElement(a.Option,{key:e,value:e,disabled:n},t))),b.createElement(`span`,{className:i[wj.CaptionLabel],style:o?.[wj.CaptionLabel],"aria-hidden":!0},c?.label,b.createElement(a.Chevron,{orientation:`down`,size:18,className:i[wj.Chevron],style:o?.[wj.Chevron]})))}function jve(e){return b.createElement(`div`,{...e})}function Mve(e){return b.createElement(`div`,{...e})}function Nve(e){let{calendarMonth:t,displayIndex:n,...r}=e;return b.createElement(`div`,{...r},e.children)}function Pve(e){let{calendarMonth:t,displayIndex:n,...r}=e;return b.createElement(`div`,{...r})}function Fve(e){return b.createElement(`table`,{...e})}function Ive(e){return b.createElement(`div`,{...e})}function Lve(e){let{components:t}=kj();return b.createElement(t.Dropdown,{...e})}function Rve(e){let{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...a}=e,{components:o,classNames:s,styles:c,labels:{labelPrevious:l,labelNext:u}}=kj(),d=(0,b.useCallback)(e=>{i&&n?.(e)},[i,n]),f=(0,b.useCallback)(e=>{r&&t?.(e)},[r,t]);return b.createElement(`nav`,{...a},b.createElement(o.PreviousMonthButton,{type:`button`,className:s[wj.PreviousMonthButton],style:c?.[wj.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":!r||void 0,"aria-label":l(r),onClick:f},b.createElement(o.Chevron,{disabled:!r||void 0,className:s[wj.Chevron],style:c?.[wj.Chevron],orientation:`left`})),b.createElement(o.NextMonthButton,{type:`button`,className:s[wj.NextMonthButton],style:c?.[wj.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":!i||void 0,"aria-label":u(i),onClick:d},b.createElement(o.Chevron,{disabled:!i||void 0,orientation:`right`,className:s[wj.Chevron],style:c?.[wj.Chevron]})))}function zve(e){return b.createElement(`button`,{...e})}function Bve(e){return b.createElement(`option`,{...e})}function Vve(e){return b.createElement(`button`,{...e})}function Hve(e){let{rootRef:t,...n}=e;return b.createElement(`div`,{...n,ref:t})}function Uve(e){return b.createElement(`select`,{...e})}function Wve(e){let{week:t,...n}=e;return b.createElement(`tr`,{...n})}function Gve(e){return b.createElement(`th`,{...e})}function Kve(e){return b.createElement(`thead`,{"aria-hidden":!0},b.createElement(`tr`,{...e}))}function qve(e){let{week:t,...n}=e;return b.createElement(`th`,{...n})}function Jve(e){return b.createElement(`th`,{...e})}function Yve(e){return b.createElement(`tbody`,{...e})}function Xve(e){let{components:t}=kj();return b.createElement(t.Dropdown,{...e})}var Zve=c({CaptionLabel:()=>Eve,Chevron:()=>Dve,Day:()=>Ove,DayButton:()=>kve,Dropdown:()=>Ave,DropdownNav:()=>jve,Footer:()=>Mve,Month:()=>Nve,MonthCaption:()=>Pve,MonthGrid:()=>Fve,Months:()=>Ive,MonthsDropdown:()=>Lve,Nav:()=>Rve,NextMonthButton:()=>zve,Option:()=>Bve,PreviousMonthButton:()=>Vve,Root:()=>Hve,Select:()=>Uve,Week:()=>Wve,WeekNumber:()=>qve,WeekNumberHeader:()=>Jve,Weekday:()=>Gve,Weekdays:()=>Kve,Weeks:()=>Yve,YearsDropdown:()=>Xve});function Aj(e,t,n=!1,r=Sj){let{from:i,to:a}=e,{differenceInCalendarDays:o,isSameDay:s}=r;return i&&a?(o(a,i)<0&&([i,a]=[a,i]),o(t,i)>=+!!n&&o(a,t)>=+!!n):!n&&a?s(a,t):!n&&i?s(i,t):!1}function jj(e){return!!(e&&typeof e==`object`&&`before`in e&&`after`in e)}function Mj(e){return!!(e&&typeof e==`object`&&`from`in e)}function Nj(e){return!!(e&&typeof e==`object`&&`after`in e)}function Pj(e){return!!(e&&typeof e==`object`&&`before`in e)}function Fj(e){return!!(e&&typeof e==`object`&&`dayOfWeek`in e)}function Ij(e,t){return Array.isArray(e)&&e.every(t.isDate)}function Lj(e,t,n=Sj){let r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:a,isAfter:o}=n;return r.some(t=>{if(typeof t==`boolean`)return t;if(n.isDate(t))return i(e,t);if(Ij(t,n))return t.some(t=>i(e,t));if(Mj(t))return Aj(t,e,!1,n);if(Fj(t))return Array.isArray(t.dayOfWeek)?t.dayOfWeek.includes(e.getDay()):t.dayOfWeek===e.getDay();if(jj(t)){let n=a(t.before,e),r=a(t.after,e),i=n>0,s=r<0;return o(t.before,t.after)?s&&i:i||s}return Nj(t)?a(e,t.after)>0:Pj(t)?a(t.before,e)>0:typeof t==`function`&&t(e)})}function Qve(e,t,n,r,i){let{disabled:a,hidden:o,modifiers:s,showOutsideDays:c,broadcastCalendar:l,today:u=i.today()}=t,{isSameDay:d,isSameMonth:f,startOfMonth:p,isBefore:m,endOfMonth:h,isAfter:g}=i,_=n&&p(n),v=r&&h(r),y={[Tj.focused]:[],[Tj.outside]:[],[Tj.disabled]:[],[Tj.hidden]:[],[Tj.today]:[]},b={};for(let t of e){let{date:e,displayMonth:n}=t,r=!!(n&&!f(e,n)),p=!!(_&&m(e,_)),h=!!(v&&g(e,v)),x=!!(a&&Lj(e,a,i)),S=!!(o&&Lj(e,o,i))||p||h||!l&&!c&&r||l&&c===!1&&r,C=d(e,u);r&&y.outside.push(t),x&&y.disabled.push(t),S&&y.hidden.push(t),C&&y.today.push(t),s&&Object.keys(s).forEach(n=>{let r=s?.[n];r&&Lj(e,r,i)&&(b[n]?b[n].push(t):b[n]=[t])})}return e=>{let t={[Tj.focused]:!1,[Tj.disabled]:!1,[Tj.hidden]:!1,[Tj.outside]:!1,[Tj.today]:!1},n={};for(let n in y)t[n]=y[n].some(t=>t===e);for(let t in b)n[t]=b[t].some(t=>t===e);return{...t,...n}}}function $ve(e,t,n={}){return Object.entries(e).filter(([,e])=>e===!0).reduce((e,[r])=>(n[r]?e.push(n[r]):t[Tj[r]]?e.push(t[Tj[r]]):t[Ej[r]]&&e.push(t[Ej[r]]),e),[t[wj.Day]])}function eye(e){return{...Zve,...e}}function tye(e){let t={"data-mode":e.mode??void 0,"data-required":`required`in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([e,n])=>{e.startsWith(`data-`)&&(t[e]=n)}),t}function Rj(){let e={};for(let t in wj)e[wj[t]]=`rdp-${wj[t]}`;for(let t in Tj)e[Tj[t]]=`rdp-${Tj[t]}`;for(let t in Ej)e[Ej[t]]=`rdp-${Ej[t]}`;for(let t in Dj)e[Dj[t]]=`rdp-${Dj[t]}`;return e}function nye(e,t,n){return(n??new xj(t)).formatMonthYear(e)}function rye(e,t,n){return(n??new xj(t)).format(e,`d`)}function iye(e,t=Sj){return t.format(e,`LLLL`)}function aye(e,t,n){return(n??new xj(t)).format(e,`cccccc`)}function oye(e,t=Sj){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function sye(){return``}function cye(e,t=Sj){return t.format(e,`yyyy`)}var lye=c({formatCaption:()=>nye,formatDay:()=>rye,formatMonthDropdown:()=>iye,formatWeekNumber:()=>oye,formatWeekNumberHeader:()=>sye,formatWeekdayName:()=>aye,formatYearDropdown:()=>cye});function uye(e){return{...lye,...e}}function zj(e,t,n,r){let i=(r??new xj(n)).format(e,`PPPP`);return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}function Bj(e,t,n){return(n??new xj(t)).formatMonthYear(e)}function Vj(e,t,n,r){let i=(r??new xj(n)).format(e,`PPPP`);return t?.today&&(i=`Today, ${i}`),i}function Hj(e){return`Choose the Month`}function Uj(){return``}var dye=`Go to the Next Month`;function Wj(e,t){return dye}function Gj(e){return`Go to the Previous Month`}function Kj(e,t,n){return(n??new xj(t)).format(e,`cccc`)}function qj(e,t){return`Week ${e}`}function Jj(e){return`Week Number`}function Yj(e){return`Choose the Year`}var fye=c({labelDayButton:()=>zj,labelGrid:()=>Bj,labelGridcell:()=>Vj,labelMonthDropdown:()=>Hj,labelNav:()=>Uj,labelNext:()=>Wj,labelPrevious:()=>Gj,labelWeekNumber:()=>qj,labelWeekNumberHeader:()=>Jj,labelWeekday:()=>Kj,labelYearDropdown:()=>Yj}),Xj=(e,t,n)=>t||(n?typeof n==`function`?n:(...e)=>n:e);function pye(e,t){let n=t.locale?.labels??{};return{...fye,...e??{},labelDayButton:Xj(zj,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Xj(Hj,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Xj(Wj,e?.labelNext,n.labelNext),labelPrevious:Xj(Gj,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Xj(qj,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Xj(Yj,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Xj(Bj,e?.labelGrid,n.labelGrid),labelGridcell:Xj(Vj,e?.labelGridcell,n.labelGridcell),labelNav:Xj(Uj,e?.labelNav,n.labelNav),labelWeekNumberHeader:Xj(Jj,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Xj(Kj,e?.labelWeekday,n.labelWeekday)}}function mye(e,t,n,r,i){let{startOfMonth:a,startOfYear:o,endOfYear:s,eachMonthOfInterval:c,getMonth:l}=i;return c({start:o(e),end:s(e)}).map(e=>{let o=r.formatMonthDropdown(e,i);return{value:l(e),label:o,disabled:t&&e<a(t)||n&&e>a(n)||!1}})}function hye(e,t={},n={}){let r={...t?.[wj.Day]};return Object.entries(e).filter(([,e])=>e===!0).forEach(([e])=>{r={...r,...n?.[e]}}),r}function gye(e,t,n,r){let i=r??e.today(),a=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),o=[];for(let t=0;t<7;t++){let n=e.addDays(a,t);o.push(n)}return o}function _ye(e,t,n,r,i=!1){if(!e||!t)return;let{startOfYear:a,endOfYear:o,eachYearOfInterval:s,getYear:c}=r,l=s({start:a(e),end:o(t)});return i&&l.reverse(),l.map(e=>{let t=n.formatYearDropdown(e,r);return{value:c(e),label:t,disabled:!1}})}function vye(e,t={}){let{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,a=t=>{let n=typeof t==`number`||typeof t==`string`?new Date(t):t;return new vj(n.getFullYear(),n.getMonth(),n.getDate(),12,0,0,e)},o=e=>{let t=a(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0)};return{today:()=>a(vj.tz(e)),newDate:(t,n,r)=>new vj(t,n,r,12,0,0,e),startOfDay:e=>a(e),startOfWeek:(e,t)=>{let n=a(e),r=t?.weekStartsOn??i,o=(n.getDay()-r+7)%7;return n.setDate(n.getDate()-o),n},startOfISOWeek:e=>{let t=a(e),n=(t.getDay()-1+7)%7;return t.setDate(t.getDate()-n),t},startOfMonth:e=>{let t=a(e);return t.setDate(1),t},startOfYear:e=>{let t=a(e);return t.setMonth(0,1),t},endOfWeek:(e,t)=>{let n=a(e),r=(((t?.weekStartsOn??i)+6)%7-n.getDay()+7)%7;return n.setDate(n.getDate()+r),n},endOfISOWeek:e=>{let t=a(e),n=(7-t.getDay())%7;return t.setDate(t.getDate()+n),t},endOfMonth:e=>{let t=a(e);return t.setMonth(t.getMonth()+1,0),t},endOfYear:e=>{let t=a(e);return t.setMonth(11,31),t},eachMonthOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new vj(n.getFullYear(),n.getMonth(),1,12,0,0,e),s=r.getFullYear()*12+r.getMonth();for(;o.getFullYear()*12+o.getMonth()<=s;)i.push(new vj(o,e)),o.setMonth(o.getMonth()+1,1);return i},addDays:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t),n},addWeeks:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t*7),n},addMonths:(e,t)=>{let n=a(e);return n.setMonth(n.getMonth()+t),n},addYears:(e,t)=>{let n=a(e);return n.setFullYear(n.getFullYear()+t),n},eachYearOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new vj(n.getFullYear(),0,1,12,0,0,e);for(;o.getFullYear()<=r.getFullYear();)i.push(new vj(o,e)),o.setFullYear(o.getFullYear()+1,0,1);return i},getWeek:(e,t)=>ej(o(e),{weekStartsOn:t?.weekStartsOn??i,firstWeekContainsDate:t?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1}),getISOWeek:e=>QA(o(e)),differenceInCalendarDays:(e,t)=>HA(o(e),o(t)),differenceInCalendarMonths:(e,t)=>WA(o(e),o(t))}}var Zj=e=>e instanceof HTMLElement?e:null,Qj=e=>[...e.querySelectorAll(`[data-animated-month]`)??[]],yye=e=>Zj(e.querySelector(`[data-animated-month]`)),$j=e=>Zj(e.querySelector(`[data-animated-caption]`)),eM=e=>Zj(e.querySelector(`[data-animated-weeks]`)),bye=e=>Zj(e.querySelector(`[data-animated-nav]`)),xye=e=>Zj(e.querySelector(`[data-animated-weekdays]`));function Sye(e,t,{classNames:n,months:r,focused:i,dateLib:a}){let o=(0,b.useRef)(null),s=(0,b.useRef)(r),c=(0,b.useRef)(!1);(0,b.useLayoutEffect)(()=>{let l=s.current;if(s.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||l.length===0||r.length!==l.length)return;let u=a.isSameMonth(r[0].date,l[0].date),d=a.isAfter(r[0].date,l[0].date),f=d?n[Dj.caption_after_enter]:n[Dj.caption_before_enter],p=d?n[Dj.weeks_after_enter]:n[Dj.weeks_before_enter],m=o.current,h=e.current.cloneNode(!0);if(h instanceof HTMLElement?(Qj(h).forEach(e=>{if(!(e instanceof HTMLElement))return;let t=yye(e);t&&e.contains(t)&&e.removeChild(t);let n=$j(e);n&&n.classList.remove(f);let r=eM(e);r&&r.classList.remove(p)}),o.current=h):o.current=null,c.current||u||i)return;let g=m instanceof HTMLElement?Qj(m):[],_=Qj(e.current);if(_?.every(e=>e instanceof HTMLElement)&&g?.every(e=>e instanceof HTMLElement)){c.current=!0;let t=[];e.current.style.isolation=`isolate`;let r=bye(e.current);r&&(r.style.zIndex=`1`),_.forEach((i,a)=>{let o=g[a];if(!o)return;i.style.position=`relative`,i.style.overflow=`hidden`;let s=$j(i);s&&s.classList.add(f);let l=eM(i);l&&l.classList.add(p);let u=()=>{c.current=!1,e.current&&(e.current.style.isolation=``),r&&(r.style.zIndex=``),s&&s.classList.remove(f),l&&l.classList.remove(p),i.style.position=``,i.style.overflow=``,i.contains(o)&&i.removeChild(o)};t.push(u),o.style.pointerEvents=`none`,o.style.position=`absolute`,o.style.overflow=`hidden`,o.setAttribute(`aria-hidden`,`true`);let m=xye(o);m&&(m.style.opacity=`0`);let h=$j(o);h&&(h.classList.add(d?n[Dj.caption_before_exit]:n[Dj.caption_after_exit]),h.addEventListener(`animationend`,u));let _=eM(o);_&&_.classList.add(d?n[Dj.weeks_before_exit]:n[Dj.weeks_after_exit]),i.insertBefore(o,i.firstChild)})}})}function Cye(e,t,n,r){let i=e[0],a=e[e.length-1],{ISOWeek:o,fixedWeeks:s,broadcastCalendar:c}=n??{},{addDays:l,differenceInCalendarDays:u,differenceInCalendarMonths:d,endOfBroadcastWeek:f,endOfISOWeek:p,endOfMonth:m,endOfWeek:h,isAfter:g,startOfBroadcastWeek:_,startOfISOWeek:v,startOfWeek:y}=r,b=c?_(i,r):o?v(i):y(i),x=c?f(a):o?p(m(a)):h(m(a)),S=t&&(c?f(t):o?p(t):h(t)),C=u(S&&g(x,S)?S:x,b),w=d(a,i)+1,T=[];for(let e=0;e<=C;e++){let t=l(b,e);T.push(t)}let E=(c?35:42)*w;if(s&&T.length<E){let e=E-T.length;for(let t=0;t<e;t++){let e=l(T[T.length-1],1);T.push(e)}}return T}function wye(e){let t=[];return e.reduce((e,n)=>{let r=n.weeks.reduce((e,t)=>e.concat(t.days.slice()),t.slice());return e.concat(r.slice())},t.slice())}function Tye(e,t,n,r){let{numberOfMonths:i=1}=n,a=[];for(let n=0;n<i;n++){let i=r.addMonths(e,n);if(t&&i>t)break;a.push(i)}return a}function tM(e,t,n,r){let{month:i,defaultMonth:a,today:o=r.today(),numberOfMonths:s=1}=e,c=i||a||o,{differenceInCalendarMonths:l,addMonths:u,startOfMonth:d}=r;return n&&l(n,c)<s-1&&(c=u(n,-1*(s-1))),t&&l(c,t)<0&&(c=t),d(c)}function Eye(e,t,n,r){let{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:o,endOfMonth:s,endOfWeek:c,getISOWeek:l,getWeek:u,startOfBroadcastWeek:d,startOfISOWeek:f,startOfWeek:p}=r,m=e.reduce((e,m)=>{let h=n.broadcastCalendar?d(m,r):n.ISOWeek?f(m):p(m),g=n.broadcastCalendar?a(m):n.ISOWeek?o(s(m)):c(s(m)),_=t.filter(e=>e>=h&&e<=g),v=n.broadcastCalendar?35:42;if(n.fixedWeeks&&_.length<v){let e=t.filter(e=>{let t=v-_.length;return e>g&&e<=i(g,t)});_.push(...e)}let y=new wve(m,_.reduce((e,t)=>{let i=n.ISOWeek?l(t):u(t),a=e.find(e=>e.weekNumber===i),o=new Cj(t,m,r);return a?a.days.push(o):e.push(new Tve(i,[o])),e},[]));return e.push(y),e},[]);return n.reverseMonths?m.reverse():m}function Dye(e,t){let{startMonth:n,endMonth:r}=e,{startOfYear:i,startOfDay:a,startOfMonth:o,endOfMonth:s,addYears:c,endOfYear:l,today:u}=t,d=e.captionLayout===`dropdown`||e.captionLayout===`dropdown-years`;return n?n=o(n):!n&&d&&(n=i(c(e.today??u(),-100))),r?r=s(r):!r&&d&&(r=l(e.today??u())),[n&&a(n),r&&a(r)]}function Oye(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a:1,u=o(e);if(!t||!(c(t,e)<a))return s(u,l)}function kye(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a??1:1,u=o(e);if(!t||!(c(u,t)<=0))return s(u,-l)}function Aye(e){return e.reduce((e,t)=>e.concat(t.weeks.slice()),[].slice())}function nM(e,t){let[n,r]=(0,b.useState)(e);return[t===void 0?n:t,r]}function jye(e,t){let[n,r]=Dye(e,t),{startOfMonth:i,endOfMonth:a}=t,o=tM(e,n,r,t),[s,c]=nM(o,e.month?o:void 0);(0,b.useEffect)(()=>{let i=tM(e,n,r,t);c(i)},[e.timeZone]);let{months:l,weeks:u,days:d,previousMonth:f,nextMonth:p}=(0,b.useMemo)(()=>{let i=Tye(s,r,{numberOfMonths:e.numberOfMonths},t),o=Eye(i,Cye(i,e.endMonth?a(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t);return{months:o,weeks:Aye(o),days:wye(o),previousMonth:kye(s,n,e,t),nextMonth:Oye(s,r,e,t)}},[t,s.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:m,onMonthChange:h}=e,g=e=>u.some(t=>t.days.some(t=>t.isEqualTo(e))),_=e=>{if(m)return;let t=i(e);n&&t<i(n)&&(t=i(n)),r&&t>i(r)&&(t=i(r)),c(t),h?.(t)};return{months:l,weeks:u,days:d,navStart:n,navEnd:r,previousMonth:f,nextMonth:p,goToMonth:_,goToDay:e=>{g(e)||_(e.date)}}}var rM;(function(e){e[e.Today=0]=`Today`,e[e.Selected=1]=`Selected`,e[e.LastFocused=2]=`LastFocused`,e[e.FocusedModifier=3]=`FocusedModifier`})(rM||={});function iM(e){return!e[Tj.disabled]&&!e[Tj.hidden]&&!e[Tj.outside]}function Mye(e,t,n,r){let i,a=-1;for(let o of e){let e=t(o);iM(e)&&(e[Tj.focused]&&a<rM.FocusedModifier?(i=o,a=rM.FocusedModifier):r?.isEqualTo(o)&&a<rM.LastFocused?(i=o,a=rM.LastFocused):n(o.date)&&a<rM.Selected?(i=o,a=rM.Selected):e[Tj.today]&&a<rM.Today&&(i=o,a=rM.Today))}return i||=e.find(e=>iM(t(e))),i}function Nye(e,t,n,r,i,a,o){let{ISOWeek:s,broadcastCalendar:c}=a,{addDays:l,addMonths:u,addWeeks:d,addYears:f,endOfBroadcastWeek:p,endOfISOWeek:m,endOfWeek:h,max:g,min:_,startOfBroadcastWeek:v,startOfISOWeek:y,startOfWeek:b}=o,x={day:l,week:d,month:u,year:f,startOfWeek:e=>c?v(e,o):s?y(e):b(e),endOfWeek:e=>c?p(e):s?m(e):h(e)}[e](n,t===`after`?1:-1);return t===`before`&&r?x=g([r,x]):t===`after`&&i&&(x=_([i,x])),x}function aM(e,t,n,r,i,a,o,s=0){if(s>365)return;let c=Nye(e,t,n.date,r,i,a,o),l=!!(a.disabled&&Lj(c,a.disabled,o)),u=!!(a.hidden&&Lj(c,a.hidden,o)),d=new Cj(c,c,o);return!l&&!u?d:aM(e,t,d,r,i,a,o,s+1)}function Pye(e,t,n,r,i){let{autoFocus:a}=e,[o,s]=(0,b.useState)(),c=Mye(t.days,n,r||(()=>!1),o),[l,u]=(0,b.useState)(a?c:void 0);return{isFocusTarget:e=>!!c?.isEqualTo(e),setFocused:u,focused:l,blur:()=>{s(l),u(void 0)},moveFocus:(n,r)=>{if(!l)return;let a=aM(n,r,l,t.navStart,t.navEnd,e,i);a&&(e.disableNavigation&&!t.days.some(e=>e.isEqualTo(a))||(t.goToDay(a),u(a)))}}}function Fye(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=nM(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t,l=e=>s?.some(t=>c(t,e))??!1,{min:u,max:d}=e;return{selected:s,select:(e,t,n)=>{let a=[...s??[]];if(l(e)){if(s?.length===u||r&&s?.length===1)return;a=s?.filter(t=>!c(t,e))}else a=s?.length===d?[e]:[...a,e];return i||o(a),i?.(a,e,t,n),a},isSelected:l}}function Iye(e,t,n=0,r=0,i=!1,a=Sj){let{from:o,to:s}=t||{},{isSameDay:c,isAfter:l,isBefore:u}=a,d;if(!o&&!s)d={from:e,to:n>0?void 0:e};else if(o&&!s)d=c(o,e)?n===0?{from:o,to:e}:i?{from:o,to:void 0}:void 0:u(e,o)?{from:e,to:o}:{from:o,to:e};else if(o&&s){if(c(o,e)&&c(s,e))d=i?{from:o,to:s}:void 0;else if(c(o,e))d={from:o,to:n>0?void 0:e};else if(c(s,e))d={from:e,to:n>0?void 0:e};else if(u(e,o))d={from:e,to:s};else if(l(e,o))d={from:o,to:e};else if(l(e,s))d={from:o,to:e};else throw Error(`Invalid range`)}if(d?.from&&d?.to){let t=a.differenceInCalendarDays(d.to,d.from);(r>0&&t>r||n>1&&t<n)&&(d={from:e,to:void 0})}return d}function Lye(e,t,n=Sj){let r=Array.isArray(t)?t:[t],i=e.from,a=n.differenceInCalendarDays(e.to,e.from),o=Math.min(a,6);for(let e=0;e<=o;e++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function oM(e,t,n=Sj){return Aj(e,t.from,!1,n)||Aj(e,t.to,!1,n)||Aj(t,e.from,!1,n)||Aj(t,e.to,!1,n)}function Rye(e,t,n=Sj){let r=Array.isArray(t)?t:[t];if(r.filter(e=>typeof e!=`function`).some(t=>typeof t==`boolean`?t:n.isDate(t)?Aj(e,t,!1,n):Ij(t,n)?t.some(t=>Aj(e,t,!1,n)):Mj(t)?t.from&&t.to?oM(e,{from:t.from,to:t.to},n):!1:Fj(t)?Lye(e,t.dayOfWeek,n):jj(t)?n.isAfter(t.before,t.after)?oM(e,{from:n.addDays(t.after,1),to:n.addDays(t.before,-1)},n):Lj(e.from,t,n)||Lj(e.to,t,n):Nj(t)||Pj(t)?Lj(e.from,t,n)||Lj(e.to,t,n):!1))return!0;let i=r.filter(e=>typeof e==`function`);if(i.length){let t=e.from,r=n.differenceInCalendarDays(e.to,e.from);for(let e=0;e<=r;e++){if(i.some(e=>e(t)))return!0;t=n.addDays(t,1)}}return!1}function zye(e,t){let{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:o,onSelect:s}=e,[c,l]=nM(a,s?a:void 0),u=s?a:c;return{selected:u,select:(a,c,d)=>{let{min:f,max:p}=e,m;if(a){let e=u?.from,n=u?.to,r=!!e&&!!n,s=!!e&&!!n&&t.isSameDay(e,n)&&t.isSameDay(a,e);m=i&&(r||!u?.from)?!o&&s?void 0:{from:a,to:void 0}:Iye(a,u,f,p,o,t)}return r&&n&&m?.from&&m.to&&Rye({from:m.from,to:m.to},n,t)&&(m.from=a,m.to=void 0),s||l(m),s?.(m,a,c,d),m},isSelected:e=>u&&Aj(u,e,!1,t)}}function Bye(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=nM(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t;return{selected:s,select:(e,t,n)=>{let a=e;return!r&&s&&s&&c(e,s)&&(a=void 0),i||o(a),i?.(a,e,t,n),a},isSelected:e=>s?c(s,e):!1}}function Vye(e,t){let n=Bye(e,t),r=Fye(e,t),i=zye(e,t);switch(e.mode){case`single`:return n;case`multiple`:return r;case`range`:return i;default:return}}function sM(e,t){return e instanceof vj&&e.timeZone===t?e:new vj(e,t)}function cM(e,t,n){if(!n)return sM(e,t);let r=sM(e,t),i=new vj(r.getFullYear(),r.getMonth(),r.getDate(),12,0,0,t);return new Date(i.getTime())}function lM(e,t,n){return typeof e==`boolean`||typeof e==`function`?e:e instanceof Date?cM(e,t,n):Array.isArray(e)?e.map(e=>e instanceof Date?cM(e,t,n):e):Mj(e)?{...e,from:e.from?sM(e.from,t):e.from,to:e.to?sM(e.to,t):e.to}:jj(e)?{before:cM(e.before,t,n),after:cM(e.after,t,n)}:Nj(e)?{after:cM(e.after,t,n)}:Pj(e)?{before:cM(e.before,t,n)}:e}function uM(e,t,n){return e&&(Array.isArray(e)?e.map(e=>lM(e,t,n)):lM(e,t,n))}function Hye(e){let t=e,n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=sM(t.today,n)),t.month&&(t.month=sM(t.month,n)),t.defaultMonth&&(t.defaultMonth=sM(t.defaultMonth,n)),t.startMonth&&(t.startMonth=sM(t.startMonth,n)),t.endMonth&&(t.endMonth=sM(t.endMonth,n)),t.mode===`single`&&t.selected?t.selected=sM(t.selected,n):t.mode===`multiple`&&t.selected?t.selected=t.selected?.map(e=>sM(e,n)):t.mode===`range`&&t.selected&&(t.selected={from:t.selected.from?sM(t.selected.from,n):t.selected.from,to:t.selected.to?sM(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=uM(t.disabled,n)),t.hidden!==void 0&&(t.hidden=uM(t.hidden,n)),t.modifiers)){let e={};Object.keys(t.modifiers).forEach(r=>{e[r]=uM(t.modifiers?.[r],n)}),t.modifiers=e}let{components:r,formatters:i,labels:a,dateLib:o,locale:s,classNames:c}=(0,b.useMemo)(()=>{let e={...bj,...t.locale},n=t.broadcastCalendar?1:t.weekStartsOn,r=t.noonSafe&&t.timeZone?vye(t.timeZone,{weekStartsOn:n,locale:e}):void 0,i=t.dateLib&&r?{...r,...t.dateLib}:t.dateLib??r,a=new xj({locale:e,weekStartsOn:n,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},i);return{dateLib:a,components:eye(t.components),formatters:uye(t.formatters),labels:pye(t.labels,a.options),locale:e,classNames:{...Rj(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:o.today()});let{captionLayout:l,mode:u,navLayout:d,numberOfMonths:f=1,onDayBlur:p,onDayClick:m,onDayFocus:h,onDayKeyDown:g,onDayMouseEnter:_,onDayMouseLeave:v,onNextClick:y,onPrevClick:x,showWeekNumber:S,styles:C}=t,{formatCaption:w,formatDay:T,formatMonthDropdown:E,formatWeekNumber:D,formatWeekNumberHeader:O,formatWeekdayName:k,formatYearDropdown:A}=i,j=jye(t,o),{days:M,months:N,navStart:P,navEnd:F,previousMonth:I,nextMonth:L,goToMonth:R}=j,ee=Qve(M,t,P,F,o),{isSelected:te,select:ne,selected:re}=Vye(t,o)??{},{blur:ie,focused:ae,isFocusTarget:oe,moveFocus:se,setFocused:ce}=Pye(t,j,ee,te??(()=>!1),o),{labelDayButton:le,labelGridcell:ue,labelGrid:de,labelMonthDropdown:fe,labelNav:pe,labelPrevious:me,labelNext:he,labelWeekday:ge,labelWeekNumber:_e,labelWeekNumberHeader:ve,labelYearDropdown:ye}=a,be=(0,b.useMemo)(()=>gye(o,t.ISOWeek,t.broadcastCalendar,t.today),[o,t.ISOWeek,t.broadcastCalendar,t.today]),xe=u!==void 0||m!==void 0,Se=(0,b.useCallback)(()=>{I&&(R(I),x?.(I))},[I,R,x]),Ce=(0,b.useCallback)(()=>{L&&(R(L),y?.(L))},[R,L,y]),we=(0,b.useCallback)((e,t)=>n=>{n.preventDefault(),n.stopPropagation(),ce(e),!t.disabled&&(ne?.(e.date,t,n),m?.(e.date,t,n))},[ne,m,ce]),z=(0,b.useCallback)((e,t)=>n=>{ce(e),h?.(e.date,t,n)},[h,ce]),B=(0,b.useCallback)((e,t)=>n=>{ie(),p?.(e.date,t,n)},[ie,p]),Te=(0,b.useCallback)((e,n)=>r=>{let i={ArrowLeft:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`after`:`before`],ArrowRight:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`before`:`after`],ArrowDown:[r.shiftKey?`year`:`week`,`after`],ArrowUp:[r.shiftKey?`year`:`week`,`before`],PageUp:[r.shiftKey?`year`:`month`,`before`],PageDown:[r.shiftKey?`year`:`month`,`after`],Home:[`startOfWeek`,`before`],End:[`endOfWeek`,`after`]};if(i[r.key]){r.preventDefault(),r.stopPropagation();let[e,t]=i[r.key];se(e,t)}g?.(e.date,n,r)},[se,g,t.dir]),Ee=(0,b.useCallback)((e,t)=>n=>{_?.(e.date,t,n)},[_]),V=(0,b.useCallback)((e,t)=>n=>{v?.(e.date,t,n)},[v]),De=(0,b.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setMonth(o.startOfMonth(e),r);R(o.addMonths(i,-t))},[o,R]),Oe=(0,b.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setYear(o.startOfMonth(e),r);R(o.addMonths(i,-t))},[o,R]),{className:ke,style:Ae}=(0,b.useMemo)(()=>({className:[c[wj.Root],t.className].filter(Boolean).join(` `),style:{...C?.[wj.Root],...t.style}}),[c,t.className,t.style,C]),je=tye(t),Me=e=>{let t=C?.[wj.Dropdown],n=C?.[e];if(!(!t&&!n))return{...t,...n}},Ne=(0,b.useRef)(null);Sye(Ne,!!t.animate,{classNames:c,months:N,focused:ae,dateLib:o});let Pe={dayPickerProps:t,selected:re,select:ne,isSelected:te,months:N,nextMonth:L,previousMonth:I,goToMonth:R,getModifiers:ee,components:r,classNames:c,styles:C,labels:a,formatters:i};return b.createElement(Oj.Provider,{value:Pe},b.createElement(r.Root,{rootRef:t.animate?Ne:void 0,className:ke,style:Ae,dir:t.dir,id:t.id,lang:t.lang??s.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t[`aria-label`],"aria-labelledby":t[`aria-labelledby`],...je},b.createElement(r.Months,{className:c[wj.Months],style:C?.[wj.Months]},!t.hideNavigation&&!d&&b.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[wj.Nav],style:C?.[wj.Nav],"aria-label":pe(),onPreviousClick:Se,onNextClick:Ce,previousMonth:I,nextMonth:L}),N.map((e,n)=>{let a=t.reverseMonths?N.length-1-n:n;return b.createElement(r.Month,{"data-animated-month":t.animate?`true`:void 0,className:c[wj.Month],style:C?.[wj.Month],key:n,displayIndex:n,calendarMonth:e},d===`around`&&!t.hideNavigation&&n===0&&b.createElement(r.PreviousMonthButton,{type:`button`,className:c[wj.PreviousMonthButton],style:C?.[wj.PreviousMonthButton],tabIndex:I?void 0:-1,"aria-disabled":!I||void 0,"aria-label":me(I),onClick:Se,"data-animated-button":t.animate?`true`:void 0},b.createElement(r.Chevron,{disabled:!I||void 0,className:c[wj.Chevron],style:C?.[wj.Chevron],orientation:t.dir===`rtl`?`right`:`left`})),b.createElement(r.MonthCaption,{"data-animated-caption":t.animate?`true`:void 0,className:c[wj.MonthCaption],style:C?.[wj.MonthCaption],calendarMonth:e,displayIndex:n},l?.startsWith(`dropdown`)?b.createElement(r.DropdownNav,{className:c[wj.Dropdowns],style:C?.[wj.Dropdowns]},(()=>{let n=l===`dropdown`||l===`dropdown-months`?b.createElement(r.MonthsDropdown,{key:`month`,className:c[wj.MonthsDropdown],"aria-label":fe(),disabled:!!t.disableNavigation,onChange:De(e.date,a),options:mye(e.date,P,F,i,o),style:Me(wj.MonthsDropdown),value:o.getMonth(e.date)}):b.createElement(`span`,{key:`month`},E(e.date,o)),s=l===`dropdown`||l===`dropdown-years`?b.createElement(r.YearsDropdown,{key:`year`,className:c[wj.YearsDropdown],"aria-label":ye(o.options),disabled:!!t.disableNavigation,onChange:Oe(e.date,a),options:_ye(P,F,i,o,!!t.reverseYears),style:Me(wj.YearsDropdown),value:o.getYear(e.date)}):b.createElement(`span`,{key:`year`},A(e.date,o));return o.getMonthYearOrder()===`year-first`?[s,n]:[n,s]})(),b.createElement(`span`,{role:`status`,"aria-live":`polite`,style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}},w(e.date,o.options,o))):b.createElement(r.CaptionLabel,{className:c[wj.CaptionLabel],style:C?.[wj.CaptionLabel],role:`status`,"aria-live":`polite`},w(e.date,o.options,o))),d===`around`&&!t.hideNavigation&&n===f-1&&b.createElement(r.NextMonthButton,{type:`button`,className:c[wj.NextMonthButton],style:C?.[wj.NextMonthButton],tabIndex:L?void 0:-1,"aria-disabled":!L||void 0,"aria-label":he(L),onClick:Ce,"data-animated-button":t.animate?`true`:void 0},b.createElement(r.Chevron,{disabled:!L||void 0,className:c[wj.Chevron],style:C?.[wj.Chevron],orientation:t.dir===`rtl`?`left`:`right`})),n===f-1&&d===`after`&&!t.hideNavigation&&b.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[wj.Nav],style:C?.[wj.Nav],"aria-label":pe(),onPreviousClick:Se,onNextClick:Ce,previousMonth:I,nextMonth:L}),b.createElement(r.MonthGrid,{role:`grid`,"aria-multiselectable":u===`multiple`||u===`range`,"aria-label":de(e.date,o.options,o)||void 0,className:c[wj.MonthGrid],style:C?.[wj.MonthGrid]},!t.hideWeekdays&&b.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?`true`:void 0,className:c[wj.Weekdays],style:C?.[wj.Weekdays]},S&&b.createElement(r.WeekNumberHeader,{"aria-label":ve(o.options),className:c[wj.WeekNumberHeader],style:C?.[wj.WeekNumberHeader],scope:`col`},O()),be.map(e=>b.createElement(r.Weekday,{"aria-label":ge(e,o.options,o),className:c[wj.Weekday],key:String(e),style:C?.[wj.Weekday],scope:`col`},k(e,o.options,o)))),b.createElement(r.Weeks,{"data-animated-weeks":t.animate?`true`:void 0,className:c[wj.Weeks],style:C?.[wj.Weeks]},e.weeks.map(e=>b.createElement(r.Week,{className:c[wj.Week],key:e.weekNumber,style:C?.[wj.Week],week:e},S&&b.createElement(r.WeekNumber,{week:e,style:C?.[wj.WeekNumber],"aria-label":_e(e.weekNumber,{locale:s}),className:c[wj.WeekNumber],scope:`row`,role:`rowheader`},D(e.weekNumber,o)),e.days.map(e=>{let{date:n}=e,i=ee(e);if(i[Tj.focused]=!i.hidden&&!!ae?.isEqualTo(e),i[Ej.selected]=te?.(n)||i.selected,Mj(re)){let{from:e,to:t}=re;i[Ej.range_start]=!!(e&&t&&o.isSameDay(n,e)),i[Ej.range_end]=!!(e&&t&&o.isSameDay(n,t)),i[Ej.range_middle]=Aj(re,n,!0,o)}let a=hye(i,C,t.modifiersStyles),s=$ve(i,c,t.modifiersClassNames),l=!xe&&!i.hidden?ue(n,i,o.options,o):void 0;return b.createElement(r.Day,{key:`${e.isoDate}_${e.displayMonthId}`,day:e,modifiers:i,className:s.join(` `),style:a,role:`gridcell`,"aria-selected":i.selected||void 0,"aria-label":l,"data-day":e.isoDate,"data-month":e.outside?e.dateMonthId:void 0,"data-selected":i.selected||void 0,"data-disabled":i.disabled||void 0,"data-hidden":i.hidden||void 0,"data-outside":e.outside||void 0,"data-focused":i.focused||void 0,"data-today":i.today||void 0},!i.hidden&&xe?b.createElement(r.DayButton,{className:c[wj.DayButton],style:C?.[wj.DayButton],type:`button`,day:e,modifiers:i,disabled:!i.focused&&i.disabled||void 0,"aria-disabled":i.focused&&i.disabled||void 0,tabIndex:oe(e)?0:-1,"aria-label":le(n,i,o.options,o),onClick:we(e,i),onBlur:B(e,i),onFocus:z(e,i),onKeyDown:Te(e,i),onMouseEnter:Ee(e,i),onMouseLeave:V(e,i)},T(n,o.options,o)):!i.hidden&&T(e.date,o.options,o))}))))))})),t.footer&&b.createElement(r.Footer,{className:c[wj.Footer],style:C?.[wj.Footer],role:`status`,"aria-live":`polite`},t.footer)))}function dM({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r=`label`,buttonVariant:i=`ghost`,formatters:a,components:o,...s}){let c=Rj();return(0,Y.jsx)(Hye,{showOutsideDays:n,className:X(`bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent`,String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:e=>e.toLocaleString(`default`,{month:`short`}),...a},classNames:{root:X(`w-fit`,c.root),months:X(`relative flex flex-col gap-4 md:flex-row`,c.months),month:X(`flex w-full flex-col gap-4`,c.month),nav:X(`absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1`,c.nav),button_previous:X(e_({variant:i}),`h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50`,c.button_previous),button_next:X(e_({variant:i}),`h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50`,c.button_next),month_caption:X(`flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]`,c.month_caption),dropdowns:X(`flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium`,c.dropdowns),dropdown_root:X(`has-focus:border-border-focus border-input shadow-xs has-focus:ring-border-focus has-focus:ring-[3px] relative rounded-md border`,c.dropdown_root),dropdown:X(`bg-popover absolute inset-0 opacity-0`,c.dropdown),caption_label:X(`select-none font-medium`,r===`label`?`text-sm`:`[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5`,c.caption_label),month_grid:`w-full border-collapse`,weekdays:X(`flex`,c.weekdays),weekday:X(`text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal`,c.weekday),week:X(`mt-2 flex w-full`,c.week),week_number_header:X(`w-[--cell-size] select-none`,c.week_number_header),week_number:X(`text-muted-foreground select-none text-[0.8rem]`,c.week_number),day:X(`group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md`,c.day),range_start:X(`bg-accent rounded-l-md`,c.range_start),range_middle:X(`rounded-none`,c.range_middle),range_end:X(`bg-accent rounded-r-md`,c.range_end),today:X(`bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none`,c.today),outside:X(`text-muted-foreground aria-selected:text-muted-foreground`,c.outside),disabled:X(`text-muted-foreground opacity-50`,c.disabled),hidden:X(`invisible`,c.hidden),...t},components:{Root:({className:e,rootRef:t,...n})=>(0,Y.jsx)(`div`,{"data-slot":`calendar`,ref:t,className:X(e),...n}),Chevron:({className:e,orientation:t,...n})=>t===`left`?(0,Y.jsx)(Lv,{className:X(`size-4`,e),...n}):t===`right`?(0,Y.jsx)(Rv,{className:X(`size-4`,e),...n}):(0,Y.jsx)(Iv,{className:X(`size-4`,e),...n}),DayButton:Uye,WeekNumber:({children:e,...t})=>(0,Y.jsx)(`td`,{...t,children:(0,Y.jsx)(`div`,{className:`flex size-[--cell-size] items-center justify-center text-center`,children:e})}),...o},...s})}function Uye({className:e,day:t,modifiers:n,...r}){let i=Rj(),a=b.useRef(null);return b.useEffect(()=>{n.focused&&a.current?.focus()},[n.focused]),(0,Y.jsx)(t_,{ref:a,variant:`ghost`,size:`icon`,"data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:X(`data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-border-focus group-data-[focused=true]/day:ring-border-focus flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70`,i.day,e),...r})}var Wye=/^(\d{4})-(\d{2})-(\d{2})$/,Gye=/^(\d{4})-(\d{2})-(\d{2})T/;function fM(e){return`${String(e.getFullYear()).padStart(4,`0`)}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function pM(e){let t=Wye.exec(e)??Gye.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i);return a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a}function Kye({path:e,readonly:t}){let n=`date`,r=Cb(e),i=Ob(e,n),{patchPath:a,addPatch:o}=vb(e),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(!1),d=eb();if((0,b.useEffect)(()=>{if(`data`in i&&i.data!==void 0){if(i.data===null)c(i.data);else{let e=pM(i.data);e===null&&console.error(`Cannot parse invalid date:`,i.data),c(e)}}},[i]),r.status===`error`)return(0,Y.jsx)(NC,{path:e,error:r.error,type:n});if(i.status===`error`)return(0,Y.jsx)(FC,{path:e,error:i.error,schema:r});if(i.status==`not-found`||r.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(r.status===`loading`||!(`data`in i)||i.data===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(r.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:r.data.type});let f=r.data,p=f.options?.from?pM(f.options.from):null,m=f.options?.to?pM(f.options.to):null,h=s==null?null:p&&s<p?p:m&&s>m?m:s,g=(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsxs)(SD,{open:!t&&l,onOpenChange:e=>{t||u(e)},children:[(0,Y.jsx)(CD,{asChild:!0,onClick:()=>{t||u(!0)},children:(0,Y.jsxs)(t_,{variant:`outline`,disabled:t,className:(0,AC.default)(`w-[280px] justify-start text-left font-normal bg-bg-primary hover:bg-bg-secondary`),children:[(0,Y.jsx)(Pv,{className:`w-4 h-4 mr-2`}),h?uj(h,`PPP`):(0,Y.jsx)(`span`,{children:`Pick a date`})]})}),(0,Y.jsx)(wD,{className:`w-auto p-0`,container:d,children:(0,Y.jsx)(dM,{mode:`single`,captionLayout:`dropdown`,defaultMonth:h??void 0,weekStartsOn:1,startMonth:p??void 0,endMonth:m??void 0,disabled:[...p?[{before:p}]:[],...m?[{after:m}]:[]],selected:h||void 0,onSelect:e=>{e&&(c(e),o([{op:`replace`,value:fM(e),path:a}],f.type),u(!1))}})})]})});return t?(0,Y.jsx)(NT,{children:g}):g}function qye({path:e}){let t=Ob(e,`date`);if(t.status===`error`)return(0,Y.jsx)(FC,{path:e,error:t.error});if(!(`data`in t)||t.data===void 0)return(0,Y.jsx)(J3,{path:e});if(t.data===null)return(0,Y.jsx)(Y3,{path:e});let n=pM(t.data);return(0,Y.jsx)(`div`,{className:`truncate`,children:n?n.toLocaleDateString():t.data})}var mM=`val:datetime:tz`,Jye=[`UTC`,`Europe/London`,`Europe/Paris`,`Europe/Berlin`,`Europe/Madrid`,`Europe/Oslo`,`Europe/Stockholm`,`Europe/Moscow`,`America/New_York`,`America/Chicago`,`America/Denver`,`America/Los_Angeles`,`America/Sao_Paulo`,`America/Mexico_City`,`Asia/Tokyo`,`Asia/Shanghai`,`Asia/Hong_Kong`,`Asia/Singapore`,`Asia/Kolkata`,`Asia/Dubai`,`Asia/Jerusalem`,`Australia/Sydney`,`Australia/Melbourne`,`Pacific/Auckland`];function hM(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function Yye(){try{let e=Intl;if(typeof e.supportedValuesOf==`function`)return e.supportedValuesOf(`timeZone`)}catch{}return Jye}function Xye(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).formatToParts(e),r=e=>Number(n.find(t=>t.type===e)?.value),i=r(`year`),a=r(`month`),o=r(`day`),s=r(`hour`),c=r(`minute`),l=r(`second`);s===24&&(s=0);let u=Date.UTC(i,a-1,o,s,c,l);return Math.round((u-e.getTime())/6e4)}function Zye(e,t,n,r,i,a,o){let s=Date.UTC(e,t-1,n,r,i,a),c=s;for(let e=0;e<3;e++){let e=s-Xye(new Date(c),o)*6e4;if(e===c)break;c=e}return new Date(c)}function Qye(e,t){try{return new Intl.DateTimeFormat(void 0,{timeZone:t,dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}function $ye(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hour12:!1,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).formatToParts(e),r=e=>n.find(t=>t.type===e)?.value??`00`,i=r(`hour`);return i===`24`&&(i=`00`),{date:`${r(`year`)}-${r(`month`)}-${r(`day`)}`,time:`${i}:${r(`minute`)}:${r(`second`)}`}}function ebe({value:e,onChange:t,from:n,to:r,defaultTimezone:i,availableTimezones:a,persistTimezone:o=!1,portalContainer:s=null,id:c,readonly:l}){let[u,d]=(0,b.useState)(!1),f=(0,b.useMemo)(()=>hM(),[]),[p,m]=(0,b.useState)(()=>i||f),h=(0,b.useMemo)(()=>{if(a)return a;let e=Yye();return[f,...e.filter(e=>e!==f)]},[a,f]),g=n?new Date(n):null,_=r?new Date(r):null,v=e==null?null:g&&e<g?g:_&&e>_?_:e,y=v?$ye(v,p):{date:``,time:``},x=(e,n,r)=>{if(!e)return;let[i,a,o]=e.split(`-`).map(e=>Number(e)),s=n.split(`:`).map(e=>Number(e)),c=s[0]||0,l=s[1]||0,u=s[2]||0;[i,a,o,c,l,u].some(e=>Number.isNaN(e))||t(Zye(i,a,o,c,l,u,r).toISOString())},S=e=>{if(m(e),o)try{localStorage.setItem(mM,e)}catch{}};return(0,Y.jsx)(`div`,{id:c,children:(0,Y.jsxs)(SD,{open:!l&&u,onOpenChange:e=>{l||d(e)},children:[(0,Y.jsx)(CD,{asChild:!0,onClick:()=>{l||d(!0)},children:(0,Y.jsxs)(t_,{variant:`outline`,disabled:l,className:(0,AC.default)(`w-[280px] justify-start text-left font-normal bg-bg-primary hover:bg-bg-secondary`),children:[(0,Y.jsx)(Pv,{className:`w-4 h-4 mr-2`}),v?(0,Y.jsx)(`span`,{className:`truncate`,children:Qye(v,p)}):(0,Y.jsx)(`span`,{children:`Pick a date & time`})]})}),(0,Y.jsxs)(wD,{className:`w-auto p-0`,container:s,children:[(0,Y.jsx)(dM,{mode:`single`,captionLayout:`dropdown`,defaultMonth:v??void 0,weekStartsOn:1,startMonth:g??void 0,endMonth:_??void 0,disabled:[...g?[{before:g}]:[],..._?[{after:_}]:[]],selected:v||void 0,onSelect:e=>{if(e){let t=y.time||`12:00:00`;x(fM(e),t,p)}}}),(0,Y.jsxs)(`div`,{className:`p-3 pt-0 flex flex-col gap-2`,children:[(0,Y.jsx)(MT,{type:`time`,step:1,disabled:l,className:`[color-scheme:light] dark:[color-scheme:dark]`,value:y.time||`12:00:00`,onChange:e=>{let t=y.date||fM(new Date);x(t,e.target.value,p)}}),(0,Y.jsxs)(nD,{value:p,disabled:l,onValueChange:e=>{S(e)},children:[(0,Y.jsx)(iD,{className:`text-xs text-fg-tertiary h-7`,children:(0,Y.jsx)(rD,{placeholder:`Timezone`})}),(0,Y.jsx)(aD,{container:s,children:h.map(e=>(0,Y.jsxs)(oD,{value:e,children:[e,e===f?` (browser)`:``]},e))})]})]})]})]})})}function tbe({path:e,readonly:t}){let n=`dateTime`,r=Cb(e),i=Ob(e,n),{patchPath:a,addPatch:o}=vb(e),[s,c]=(0,b.useState)(null),l=eb(),u=(0,b.useMemo)(()=>{try{return localStorage.getItem(mM)||hM()}catch{return hM()}},[]);if((0,b.useEffect)(()=>{if(`data`in i&&i.data!==void 0){if(i.data===null)c(null);else{let e=new Date(i.data);Number.isNaN(e.getTime())?console.error(`Cannot parse invalid datetime:`,i.data):c(e)}}},[i]),r.status===`error`)return(0,Y.jsx)(NC,{path:e,error:r.error,type:n});if(i.status===`error`)return(0,Y.jsx)(FC,{path:e,error:i.error,schema:r});if(i.status==`not-found`||r.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:n});if(r.status===`loading`||!(`data`in i)||i.data===void 0)return(0,Y.jsx)(jC,{path:e,type:n});if(r.data.type!==n)return(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:r.data.type});let d=r.data,f=(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(ebe,{value:s,onChange:e=>{c(new Date(e)),o([{op:`replace`,value:e,path:a}],d.type)},from:d.options?.from,to:d.options?.to,defaultTimezone:u,persistTimezone:!0,portalContainer:l,readonly:t})});return t?(0,Y.jsx)(NT,{children:f}):f}function nbe({path:e}){let t=Ob(e,`dateTime`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{className:`truncate`,children:new Date(t.data).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})})}function gM(){return gM=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gM.apply(null,arguments)}function rbe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var _M=[],vM=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?vM:_M).push(n+=e[t])})();function ibe(e){if(e<768)return!1;for(let t=0,n=_M.length;;){let r=t+n>>1;if(e<_M[r])n=r;else if(e>=vM[r])t=r+1;else return!0;if(t==n)return!1}}function yM(e){return e>=127462&&e<=127487}var bM=8205;function abe(e,t,n=!0,r=!0){return(n?xM:obe)(e,t,r)}function xM(e,t,n){if(t==e.length)return t;t&&CM(e.charCodeAt(t))&&wM(e.charCodeAt(t-1))&&t--;let r=SM(e,t);for(t+=TM(r);t<e.length;){let i=SM(e,t);if(r==bM||i==bM||n&&ibe(i))t+=TM(i),r=i;else if(yM(i)){let n=0,r=t-2;for(;r>=0&&yM(SM(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function obe(e,t,n){for(;t>0;){let r=xM(e,t-2,n);if(r<t)return r;t--}return 0}function SM(e,t){let n=e.charCodeAt(t);if(!wM(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return CM(r)?(n-55296<<10)+(r-56320)+65536:n}function CM(e){return e>=56320&&e<57344}function wM(e){return e>=55296&&e<56320}function TM(e){return e<65536?1:2}var EM=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=PM(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),OM.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=PM(this,e,t);let n=[];return this.decompose(e,t,n,0),OM.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new jM(this),i=new jM(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new jM(this,e)}iterRange(e,t=this.length){return new MM(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new NM(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new DM(t):OM.from(DM.split(t,[]))}},DM=class e extends EM{constructor(e,t=sbe(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new cbe(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(AM(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=kM(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=PM(this,t,n);let i=kM(this.text,kM(r.text,AM(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):OM.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
|
|
143
143
|
`){[e,t]=PM(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},OM=class e extends EM{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=PM(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
|
|
144
144
|
`){[e,t]=PM(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new DM(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof DM&&c&&(n=u[u.length-1])instanceof DM&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new DM(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};EM.empty=new DM([``],0);function sbe(e){let t=-1;for(let n of e)t+=n.length+1;return t}function kM(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function AM(e,t,n){return kM(e,[``],t,n)}var jM=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof DM?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof DM?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
|
|
145
145
|
`,this;e--}else if(r instanceof DM){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof DM?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},MM=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new jM(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},NM=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(EM.prototype[Symbol.iterator]=function(){return this.iter()},jM.prototype[Symbol.iterator]=MM.prototype[Symbol.iterator]=NM.prototype[Symbol.iterator]=function(){return this});var cbe=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function PM(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function FM(e,t,n=!0,r=!0){return abe(e,t,n,r)}function lbe(e){return e>=56320&&e<57344}function ube(e){return e>=55296&&e<56320}function IM(e,t){let n=e.charCodeAt(t);if(!ube(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return lbe(r)?(n-55296<<10)+(r-56320)+65536:n}function LM(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function RM(e){return e<65536?1:2}var zM=/\r\n?|\n/,BM=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(BM||={}),VM=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){GM(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:qM(this,e)}mapDesc(e,t=!1){return e.empty?this:KM(this,e,t)}mapPos(e,t=-1,n=BM.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=BM.Simple&&c>=e&&(n==BM.TrackDel&&r<e&&c>e||n==BM.TrackBefore&&r<e||n==BM.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},HM=class e extends VM{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return GM(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return KM(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(EM.empty);r.push(a?t.slice(i,i+a):EM.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:qM(this,e,!0)}map(e,t=!1){return e.empty?this:KM(this,e,t,!0)}iterChanges(e,t=!1){GM(this,e,t)}get desc(){return VM.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new JM(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);UM(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;UM(n,e,t),t>0&&WM(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);UM(n,e,-1),UM(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:VM.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&UM(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?EM.of(l.split(r||zM)):l:EM.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&UM(i,e-o,-1),UM(i,s-e,d),WM(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(EM.empty);r[e]=EM.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function UM(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function WM(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(EM.empty);e.push(n)}}function GM(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=EM.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function KM(e,t,n,r=!1){let i=[],a=r?[]:null,o=new JM(e),s=new JM(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);UM(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(UM(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(UM(i,0,o.ins),a&&WM(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;UM(i,t,e<o.i?o.ins:0),a&&e<o.i&&WM(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?HM.createSet(i,a):VM.create(i);else throw Error(`Mismatched change set lengths`)}function qM(e,t,n=!1){let r=[],i=n?[]:null,a=new JM(e),o=new JM(t);for(let e=!1;;)if(a.done&&o.done)return i?HM.createSet(r,i):VM.create(r);else if(a.ins==0)UM(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)UM(r,0,o.ins,e),i&&WM(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;UM(r,t,n,e),i&&n&&WM(i,r,o.text)}else o.ins==-1?(UM(r,a.off?0:a.len,t,e),i&&WM(i,r,a.textBit(t))):(UM(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&WM(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var JM=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?EM.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?EM.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},YM=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return Q.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Q.range(this.anchor,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return Q.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},Q=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>YM.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return YM.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r){let i=(n??16777215)<<6|(r==null?7:Math.min(6,r));return t<e?YM.create(t,e,48|i):YM.create(e,t,(t>e?8:0)|i)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function XM(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var ZM=0,QM=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=ZM++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:$M),!!t.static,t.enables)}of(e){return new eN([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new eN(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new eN(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function $M(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var eN=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=ZM++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||nN(e,c)){let r=t(e);if(a?!tN(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=pN(o,c);if(this.dependencies.every(t=>t instanceof QM?o.facet(t)===e.facet(t):t instanceof iN?o.field(t,!1)==e.field(t,!1):!0)||(a?tN(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function tN(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function nN(e,t){let n=!1;for(let r of t)fN(e,r)&1&&(n=!0);return n}function dbe(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=pN(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)fN(e,t);return e.values[o]=s(e),1},update(e,n){if(!nN(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=nN(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&$M(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var rN=QM.define({static:!0}),iN=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(ZM++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(rN).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(rN),i=n.facet(rN),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,rN.of({field:this,create:e})]}get extension(){return this}},aN={lowest:4,low:3,default:2,high:1,highest:0};function oN(e){return t=>new cN(t,e)}var sN={highest:oN(aN.highest),high:oN(aN.high),default:oN(aN.default),low:oN(aN.low),lowest:oN(aN.lowest)},cN=class{constructor(e,t){this.inner=e,this.prec=t}},lN=class e{of(e){return new uN(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},uN=class{constructor(e,t){this.compartment=e,this.inner=t}},dN=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of fbe(t,n,o))e instanceof iN?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,$M(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>dbe(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function fbe(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof uN&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof uN){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof cN)a(e.inner,e.prec);else if(e instanceof iN)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof eN)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,aN.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,aN.default),r.reduce((e,t)=>e.concat(t))}function fN(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function pN(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var mN=QM.define(),hN=QM.define({combine:e=>e.some(e=>e),static:!0}),gN=QM.define({combine:e=>e.length?e[0]:void 0,static:!0}),_N=QM.define(),vN=QM.define(),yN=QM.define(),bN=QM.define({combine:e=>e.length?e[0]:!1}),xN=class{constructor(e,t){this.type=e,this.value=t}static define(){return new pbe}},pbe=class{of(e){return new xN(this,e)}},mbe=class{constructor(e){this.map=e}of(e){return new SN(this,e)}},SN=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new mbe(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};SN.reconfigure=SN.define(),SN.appendConfig=SN.define();var CN=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&XM(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};CN.time=xN.define(),CN.userEvent=xN.define(),CN.addToHistory=xN.define(),CN.remote=xN.define();function hbe(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function wN(e,t,n){let r,i,a;return n?(r=t.changes,i=HM.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:SN.mapEffects(e.effects,r).concat(SN.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function TN(e,t,n){let r=t.selection,i=DN(t.annotations);return t.userEvent&&(i=i.concat(CN.userEvent.of(t.userEvent))),{changes:t.changes instanceof HM?t.changes:HM.of(t.changes||[],n,e.facet(gN)),selection:r&&(r instanceof Q?r:Q.single(r.anchor,r.head)),effects:DN(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function EN(e,t,n){let r=TN(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=wN(r,TN(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=CN.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return _be(n?gbe(i):i)}function gbe(e){let t=e.startState,n=!0;for(let r of t.facet(_N)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:hbe(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=HM.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=CN.create(t,r,e.selection&&e.selection.map(i),SN.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(vN);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof CN?i:Array.isArray(i)&&i.length==1&&i[0]instanceof CN?i[0]:EN(t,DN(i),!1)}return e}function _be(e){let t=e.startState,n=t.facet(yN),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=wN(r,TN(t,a,e.changes.newLength),!0))}return r==e?e:CN.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var vbe=[];function DN(e){return e==null?vbe:Array.isArray(e)?e:[e]}var ON=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(ON||={}),ybe=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,kN;try{kN=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function bbe(e){if(kN)return kN.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||ybe.test(n)))return!0}return!1}function xbe(e){return t=>{if(!/\S/.test(t))return ON.Space;if(bbe(t))return ON.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return ON.Word;return ON.Other}}var AN=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)fN(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return fN(this,n),pN(this,n)}update(...e){return EN(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(lN.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(SN.reconfigure)?(n=null,r=e.value):e.is(SN.appendConfig)&&(n=null,r=DN(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=dN.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(hN)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Q.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=DN(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=SN.mapEffects(a,c).concat(SN.mapEffects(DN(o.effects),l))}return{changes:r,selection:Q.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof HM?t:HM.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return EM.of(t.split(this.facet(e.lineSeparator)||zM))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(fN(this,t),pN(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof iN&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:Q.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=dN.resolve(t.extensions||[],new Map),r=t.doc instanceof EM?t.doc:EM.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||zM)),i=t.selection?t.selection instanceof Q?t.selection:Q.single(t.selection.anchor,t.selection.head):Q.single(0);return XM(i,r.length),n.staticFacet(hN)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
|
|
@@ -202,7 +202,7 @@ else:
|
|
|
202
202
|
- less than the value passed to \`max\` (or ${WY} if no \`max\` prop is set)
|
|
203
203
|
- \`null\` or \`undefined\` if the progress is indeterminate.
|
|
204
204
|
|
|
205
|
-
Defaulting to \`null\`.`}HY(ZY,`getInvalidValueError`);var QY=mRe,_Re=gRe,$Y=b.forwardRef(({className:e,value:t,...n},r)=>(0,Y.jsx)(QY,{ref:r,className:X(`relative h-4 w-full overflow-hidden rounded-full bg-bg-secondary`,e),...n,children:(0,Y.jsx)(_Re,{className:`flex-1 w-full h-full transition-all bg-fg-brand-primary`,style:{transform:`translateX(-${100-(t||0)}%)`}})}));$Y.displayName=QY.displayName;function eX({className:e,...t}){return(0,Y.jsx)(`div`,{className:X(`animate-pulse rounded-md bg-muted`,e),...t})}function vRe(e){let[t]=e.split(`/`);return t}function tX({file:e,className:t}){let n=vRe(e.metadata.mimeType);return n===`image`?(0,Y.jsx)(cA,{url:e.url,alt:e.metadata.alt||e.filename,hotspot:e.metadata.hotspot,className:t}):n===`video`?(0,Y.jsxs)(`div`,{className:X(`relative h-full w-full bg-bg-secondary`,t),children:[(0,Y.jsx)(`video`,{src:e.url,className:`h-full w-full object-cover`,muted:!0,preload:`metadata`}),(0,Y.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/20`,children:(0,Y.jsx)(Yie,{className:`h-8 w-8 text-white`})})]}):n===`audio`?(0,Y.jsx)(`div`,{className:X(`flex h-full w-full items-center justify-center bg-bg-secondary`,t),children:(0,Y.jsx)(Jie,{className:`h-12 w-12 text-fg-secondary`})}):n===`text`||e.metadata.mimeType===`application/json`?(0,Y.jsx)(`div`,{className:X(`flex h-full w-full items-center justify-center bg-bg-secondary`,t),children:(0,Y.jsx)($v,{className:`h-12 w-12 text-fg-secondary`})}):(0,Y.jsx)(`div`,{className:X(`flex h-full w-full items-center justify-center bg-bg-secondary`,t),children:(0,Y.jsx)(ey,{className:`h-12 w-12 text-fg-secondary`})})}function nX({file:e,onClick:t,viewMode:n,imageMode:r}){let i=e.metadata.width>0&&e.metadata.height>0?e.metadata.width/e.metadata.height:1,a=e.validationErrors&&e.validationErrors.length>0||e.fieldSpecificErrors&&Object.values(e.fieldSpecificErrors).some(e=>e&&e.length>0),o=(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:X(`group flex w-full flex-col overflow-hidden rounded border bg-bg-primary transition-all`,`hover:shadow-md`,`focus:outline-none focus:ring-2`,a?`border-bg-error-primary ring-bg-error-primary/50 hover:border-bg-error-primary-hover focus:ring-bg-error-primary`:`border-border-secondary hover:border-border-primary focus:ring-border-focus`),title:a?e.validationErrors?.join(`, `):void 0,children:[(0,Y.jsx)(`div`,{className:X(`relative w-full overflow-hidden bg-bg-secondary`),style:{aspectRatio:n===`masonry`?i:1},children:(0,Y.jsx)(tX,{file:e})}),(0,Y.jsxs)(`div`,{className:`p-1.5`,children:[(0,Y.jsx)(`p`,{className:`truncate text-xs font-medium text-fg-primary`,title:e.filename,children:e.filename}),r&&e.metadata.mimeType.startsWith(`image/`)&&e.metadata.alt&&(0,Y.jsx)(`p`,{className:`truncate text-xs text-fg-secondary`,title:e.metadata.alt,children:e.metadata.alt})]})]});return n===`masonry`?(0,Y.jsx)(`div`,{className:`mb-2 break-inside-avoid`,children:o}):o}var rX=50;function iX({field:e,currentField:t,direction:n}){return e===t?n===`asc`?(0,Y.jsx)(jv,{className:`h-3 w-3`}):(0,Y.jsx)(kv,{className:`h-3 w-3`}):(0,Y.jsx)(Pie,{className:`h-3 w-3 opacity-50`})}function yRe(e){let[,t]=e.split(`/`);return t?.toUpperCase()??e}function bRe({files:e,onItemClick:t,sortField:n,sortDirection:r,onSort:i}){let a=b.useRef(null),o=tA({count:e.length,getScrollElement:()=>a.current,estimateSize:()=>rX,overscan:10}),s=e.some(e=>e.metadata.alt!==void 0),c=e.some(e=>e.patchesByAuthorIds&&Object.keys(e.patchesByAuthorIds).length>0),l=s&&c?`grid-cols-[56px_1fr_120px_192px_96px]`:s?`grid-cols-[56px_1fr_192px_96px]`:c?`grid-cols-[56px_120px_1fr_96px]`:`grid-cols-[56px_1fr_96px]`;return(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-lg`,children:[(0,Y.jsx)(`div`,{className:`rounded-t-lg border border-border-secondary bg-bg-secondary text-left text-xs font-medium text-fg-secondary`,children:(0,Y.jsxs)(`div`,{className:X(`grid`,l),children:[(0,Y.jsx)(`div`,{className:`px-3 py-2`}),s&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(`description`),className:`flex items-center gap-1 hover:text-fg-primary`,children:[`Description`,(0,Y.jsx)(iX,{field:`description`,currentField:n,direction:r})]})}),c&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:`Last change`}),(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(`name`),className:`flex items-center gap-1 hover:text-fg-primary`,children:[`Name`,(0,Y.jsx)(iX,{field:`name`,currentField:n,direction:r})]})}),(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(`type`),className:`flex items-center gap-1 hover:text-fg-primary`,children:[`Type`,(0,Y.jsx)(iX,{field:`type`,currentField:n,direction:r})]})})]})}),(0,Y.jsx)(`div`,{ref:a,className:`overflow-auto`,style:{contain:`strict`,height:Math.min(e.length*rX,600)},children:(0,Y.jsx)(`div`,{style:{height:`${o.getTotalSize()}px`,width:`100%`,position:`relative`},children:o.getVirtualItems().map(n=>{let r=e[n.index],i=r.validationErrors&&r.validationErrors.length>0||r.fieldSpecificErrors&&Object.values(r.fieldSpecificErrors).some(e=>e&&e.length>0),a=n.index===0,u=n.index===e.length-1,d=i&&(n.index===0||!(e[n.index-1].validationErrors&&e[n.index-1].validationErrors.length>0));return(0,Y.jsxs)(`div`,{"data-index":n.index,ref:o.measureElement,onClick:()=>t(n.index),className:X(`absolute left-0 top-0 grid w-full cursor-pointer border border-b-0 transition-colors`,a&&`border-t-0`,u&&`border-b`,l,`border-border-secondary hover:bg-bg-secondary`,i&&`border border-bg-error-primary hover:border-bg-error-primary-hover`,!d&&i&&`border-t-0`,u&&`rounded-b-lg`),style:{transform:`translateY(${n.start}px)`},title:i?r.validationErrors?.join(`, `):void 0,children:[(0,Y.jsx)(`div`,{className:`flex items-center px-3 py-2`,children:(0,Y.jsx)(`div`,{className:`h-8 w-8 overflow-hidden rounded bg-bg-secondary`,children:(0,Y.jsx)(tX,{file:r})})}),s&&(0,Y.jsx)(`div`,{className:`flex items-center overflow-hidden px-3 py-2`,children:(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium text-fg-primary`,children:r.metadata.alt??``})}),c&&(0,Y.jsx)(`div`,{className:`flex items-center px-3 py-2`,children:r.patchesByAuthorIds&&r.profilesByAuthorIds&&Object.keys(r.patchesByAuthorIds).length>0&&(0,Y.jsx)(Kk,{patchesByAuthorIds:r.patchesByAuthorIds,profilesByAuthorIds:r.profilesByAuthorIds,sourcePath:r.sourcePath,navigable:!1})}),(0,Y.jsx)(`div`,{className:`flex items-center overflow-hidden px-3 py-2`,children:(0,Y.jsx)(`span`,{className:X(`truncate text-sm`,s?`text-fg-secondary`:`font-medium text-fg-primary`),children:r.filename})}),(0,Y.jsx)(`div`,{className:`flex items-center px-3 py-2`,children:(0,Y.jsx)(`span`,{className:`text-sm text-fg-secondary`,children:yRe(r.metadata.mimeType)})})]},n.key)})})})]})}function aX(e){let t=e.lastIndexOf(`.`);return t<=0?[e,``]:[e.slice(0,t),e.slice(t)]}function xRe({filename:e,onSave:t,disabled:n=!1,className:r}){let[i,a]=b.useState(!1),[o,s]=aX(e),[c,l]=b.useState(o);b.useEffect(()=>{let[t]=aX(e);l(t),a(!1)},[e]);let u=()=>{let e=c.trim();e&&e!==o&&t(e+s),a(!1)},d=()=>{l(o),a(!1)};return i?(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1`,r),children:[(0,Y.jsxs)(`div`,{className:`flex flex-1 items-center`,children:[(0,Y.jsx)(MT,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`?u():e.key===`Escape`&&d()},autoFocus:!0,className:`h-8 flex-1 rounded-r-none text-sm`}),s&&(0,Y.jsx)(`span`,{className:`flex h-8 items-center rounded-r-md border border-l-0 border-border-primary bg-bg-secondary px-2 text-sm text-fg-secondary`,children:s})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:u,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-bg-secondary hover:text-fg-primary`,title:`Save`,children:(0,Y.jsx)(Fv,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:d,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-bg-secondary hover:text-fg-primary`,title:`Cancel`,children:(0,Y.jsx)(Hy,{className:`h-4 w-4`})})]}):(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1`,r),children:[(0,Y.jsx)(`span`,{className:`flex-1 truncate rounded px-2 py-1.5 text-sm text-fg-primary`,title:e,children:e}),!n&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-bg-secondary hover:text-fg-primary`,title:`Rename`,children:(0,Y.jsx)(Dy,{className:`h-4 w-4`})})]})}function SRe(e,t,n,r){let i=[];return OD(e,t,(e,t,a)=>{(t.type===`image`||t.type===`file`)&&t.referencedModule===n?(r===void 0||typeof a==`object`&&a&&!Array.isArray(a)&&`path`in a&&a.path===r)&&(i.includes(e)||i.push(e)):t.type===`string`||t.type===`number`||t.type===`boolean`||t.type===`literal`||t.type===`date`||t.type===`dateTime`||t.type===`color`||t.type===`code`||t.type===`keyOf`||t.type===`image`||t.type===`file`||t.type===`richtext`||t.type===`route`||console.error(`Could not get referenced files. Unhandled schema type`,t)}),i}function CRe(e,t){let n=wb(),r=_b(),i=Eb();return ID(ND((0,b.useMemo)(()=>e===void 0?null:{kind:`file`,module:e},[e])),(0,b.useMemo)(()=>e!==void 0&&`data`in n&&n.data!==void 0?SRe(n.data,i,e,t):[],[r,i,`data`in n&&n.data,e,t]))}function wRe({file:e,fileIndex:t,open:n,onOpenChange:r,onFileRename:i,onAltTextChange:a,onFileDelete:o,parentPath:s,imageMode:c,loading:l,disabled:u,container:d}){let f=CRe(s,e?.ref),p=f.refs,m=f.status===`success`,{navigate:h,currentSourcePath:g}=GC(),[_,v]=b.useState(!1);if(!e||t===null)return null;let y=e=>{i?.(t,e)},x=e.metadata.mimeType.startsWith(`image/`);return(0,Y.jsx)(Uy,{open:n,onOpenChange:r,children:(0,Y.jsxs)(Ky,{className:`max-w-2xl`,container:d,children:[(0,Y.jsx)(qy,{children:(0,Y.jsx)(Yy,{children:`File Properties`})}),(0,Y.jsxs)(`div`,{className:`flex gap-6`,children:[(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsx)(`div`,{className:`h-32 w-32 overflow-hidden rounded-lg border border-border-secondary bg-bg-secondary`,children:(0,Y.jsx)(tX,{file:e})})}),(0,Y.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[i&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-fg-secondary`,children:`Filename`}),(0,Y.jsx)(xRe,{filename:e.filename,onSave:y,disabled:u||l})]}),c&&x&&a&&(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1`,{"border-[red] border p-2 rounded":e.fieldSpecificErrors?.alt&&e.fieldSpecificErrors.alt.length>0}),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-fg-secondary`,children:`Description`}),e.patchesByAuthorIds&&e.profilesByAuthorIds&&Object.keys(e.patchesByAuthorIds).length>0&&(0,Y.jsx)(Kk,{patchesByAuthorIds:e.patchesByAuthorIds,profilesByAuthorIds:e.profilesByAuthorIds,sourcePath:e.sourcePath})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(MT,{value:e.metadata.alt??``,onChange:e=>{a?.(t,e.target.value)},autoFocus:!0,placeholder:`Describe this image...`}),e.fieldSpecificErrors?.alt&&e.fieldSpecificErrors.alt.length>0&&(0,Y.jsx)(`ul`,{className:`list-none p-0 text-sm`,children:e.fieldSpecificErrors.alt.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(Uk,{validationErrors:[{message:e}]})},t))})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-secondary`,children:`Folder`}),(0,Y.jsx)(`span`,{className:`truncate text-sm text-fg-primary`,title:e.folder,children:e.folder})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-secondary`,children:`Type`}),(0,Y.jsx)(`span`,{className:`text-sm text-fg-primary`,children:e.metadata.mimeType})]}),(e.metadata.width>0||e.metadata.height>0)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-secondary`,children:`Dimensions`}),(0,Y.jsxs)(`span`,{className:`text-sm text-fg-primary`,children:[e.metadata.width,` × `,e.metadata.height,` px`]})]})]}),e.validationErrors&&e.validationErrors.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Validation Errors`}),(0,Y.jsx)(`ul`,{className:`list-inside list-disc text-sm text-destructive`,children:e.validationErrors.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})]})]})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 border-t border-border-secondary pt-4`,children:[(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 rounded-md bg-bg-secondary px-3 py-2 text-sm font-medium text-fg-primary transition-colors hover:bg-bg-tertiary`,children:[(0,Y.jsx)(Zv,{className:`h-4 w-4`}),`Open in New Tab`]}),e.sourcePath&&e.patchesByAuthorIds&&Object.keys(e.patchesByAuthorIds).length>0&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{h(`/val/compare`,{scrollToPath:e.sourcePath})},className:`inline-flex items-center gap-2 rounded-md bg-bg-secondary px-3 py-2 text-sm font-medium text-fg-primary transition-colors hover:bg-bg-tertiary`,children:[(0,Y.jsx)(ny,{className:`h-4 w-4`}),`View in Compare`]}),o&&t!==null&&(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[p.length>0&&(0,Y.jsxs)(SD,{open:_,onOpenChange:v,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-2 rounded-md bg-bg-secondary px-3 py-2 text-sm font-medium text-fg-primary transition-colors hover:bg-bg-tertiary`,children:[(0,Y.jsx)(dy,{className:`h-4 w-4`}),p.length,` reference`,p.length===1?``:`s`]})}),(0,Y.jsx)(wD,{className:`w-[clamp(260px,32vw,360px)] p-0 z-[8999]`,container:d,children:(0,Y.jsx)(pk,{refs:p,currentPath:g,onSelect:(e,{scrollToPath:t})=>{h(e,{scrollToPath:t}),v(!1)}})})]}),(0,Y.jsx)(qg,{children:(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{o(t),r(!1)},disabled:u||l||p.length>0||!m,className:`inline-flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium text-destructive transition-colors hover:bg-bg-error-primary disabled:opacity-50`,children:[(0,Y.jsx)(Iy,{className:`h-4 w-4`}),`Delete`]})})}),p.length>0?(0,Y.jsxs)(Xg,{children:[`Cannot delete: referenced in `,p.length,` `,p.length===1?`place`:`places`]}):f.status===`loading`?(0,Y.jsxs)(Xg,{children:[`Checking references`,f.percentage>0?` (${f.percentage}%)`:``,`…`]}):f.status===`error`?(0,Y.jsx)(Xg,{children:`Cannot delete: references could not be checked`}):null]})})]})]})]})})}function TRe({files:e,parentPath:t,onFileRename:n,onAltTextChange:r,onFileDelete:i,className:a,defaultViewMode:o=`list`,showSearch:s=!0,imageMode:c=!1,loading:l=!1,disabled:u=!1,onUploadClick:d,uploading:f=!1,defaultOpenFileRef:p,isDraggingOver:m=!1}){let h=GC(),g=eb(),[_,v]=b.useState(null),[y,x]=b.useState(!1);b.useEffect(()=>{if(p){let t=e.findIndex(e=>e.ref===p);t!==-1&&(v(t),x(!0))}},[p,e]);let[S,C]=b.useState(o),[w,T]=b.useState(``),[E,D]=b.useState(`name`),[O,k]=b.useState(`asc`),A=b.useMemo(()=>{let t=e;if(w.trim()){let e=w.toLowerCase();t=t.filter(t=>t.filename.toLowerCase().includes(e)||(t.metadata.alt??``).toLowerCase().includes(e))}return S===`list`&&(t=[...t].sort((e,t)=>{let n=0;switch(E){case`name`:n=e.filename.localeCompare(t.filename);break;case`description`:n=(e.metadata.alt??``).localeCompare(t.metadata.alt??``);break;case`type`:n=e.metadata.mimeType.localeCompare(t.metadata.mimeType)}return O===`asc`?n:-n})),t},[e,w,S,E,O]),j=b.useCallback(t=>{let n=A[t];return e.findIndex(e=>e.ref===n.ref)},[e,A]),M=e=>{E===e?k(e=>e===`asc`?`desc`:`asc`):(D(e),k(`asc`))},N=_===null?null:e[_]??null,P=n=>{let r=j(n);if(r!==-1&&(v(r),x(!0),t)){let n=t,i=e[r].ref,a=H.createValPathOfItem(n,i);a&&h.navigate(a)}},F=(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-12`,children:(0,Y.jsxs)(`div`,{className:`flex max-w-md flex-col items-center justify-center gap-4 rounded-lg border border-dashed border-border-secondary bg-bg-secondary p-12`,children:[(0,Y.jsx)(Qie,{className:`h-16 w-16 text-fg-secondary`}),(0,Y.jsxs)(`div`,{className:`text-center`,children:[(0,Y.jsx)(`p`,{className:`text-lg font-medium text-fg-primary`,children:`No files`}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`There are no files to display`})]})]})}),I=(0,Y.jsx)(`div`,{className:`columns-3 gap-2 sm:columns-4 md:columns-5 lg:columns-6 xl:columns-8`,children:Array.from({length:24}).map((e,t)=>(0,Y.jsx)(`div`,{className:`mb-2 break-inside-avoid`,children:(0,Y.jsxs)(`div`,{className:`flex w-full flex-col overflow-hidden rounded border border-border-secondary bg-bg-primary`,children:[(0,Y.jsx)(eX,{className:`w-full`,style:{aspectRatio:1+Math.random()*.5}}),(0,Y.jsx)(`div`,{className:`p-1.5`,children:(0,Y.jsx)(eX,{className:`h-4 w-3/4`})})]})},t))});return(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-4`,a),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,Y.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,Y.jsx)(My,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-fg-secondary`}),(0,Y.jsx)(MT,{type:`text`,placeholder:`Filter`,value:w,onChange:e=>T(e.target.value),className:`pl-8`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[d&&(0,Y.jsx)(`button`,{type:`button`,onClick:d,disabled:f,className:`rounded p-1.5 transition-colors text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary disabled:opacity-50`,title:`Upload file`,children:f?(0,Y.jsx)(hy,{className:`size-5 animate-spin`}):(0,Y.jsx)(Oy,{className:`size-5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>C(`grid`),className:X(`rounded p-1.5 transition-colors`,S===`grid`?`bg-bg-secondary text-fg-primary`:`text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary`),title:`Grid view`,children:(0,Y.jsx)(eae,{className:`size-5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>C(`list`),className:X(`rounded p-1.5 transition-colors`,S===`list`?`bg-bg-secondary text-fg-primary`:`text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary`),title:`List view`,children:(0,Y.jsx)(my,{className:`size-5`})})]})]}),(0,Y.jsxs)(`div`,{className:`relative`,children:[m&&(0,Y.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-lg border-2 border-dashed border-border-primary bg-bg-primary/80 pointer-events-none`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-fg-secondary`,children:[(0,Y.jsx)(Gv,{className:`size-10`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:`Drop files here`})]})}),l?I:e.length===0?F:A.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-12 text-center`,children:[(0,Y.jsx)(My,{className:`h-8 w-8 text-fg-secondary`}),(0,Y.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No files match "`,w,`"`]})]}):S===`masonry`?(0,Y.jsx)(`div`,{className:`columns-3 gap-2 sm:columns-4 md:columns-5 lg:columns-6 xl:columns-8`,children:A.map((e,t)=>(0,Y.jsx)(nX,{file:e,onClick:()=>P(t),viewMode:S,imageMode:c},`${e.folder}/${e.filename}`))}):S===`grid`?(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5`,children:A.map((e,t)=>(0,Y.jsx)(nX,{file:e,onClick:()=>P(t),viewMode:S,imageMode:c},`${e.folder}/${e.filename}`))}):(0,Y.jsx)(bRe,{files:A,onItemClick:P,sortField:E,sortDirection:O,onSort:M})]}),(0,Y.jsx)(wRe,{file:N,fileIndex:_,open:y,onOpenChange:e=>{x(e),!e&&t&&(v(null),h.navigate(t))},onFileRename:n,onAltTextChange:r,onFileDelete:i,parentPath:t,imageMode:c,loading:l,disabled:u,container:g})]})}var oX=(0,b.createContext)({request:null,requestUpload:()=>void 0,clearRequest:()=>void 0});function ERe({children:e}){let[t,n]=(0,b.useState)(null),r=(0,b.useRef)(0),i=(0,b.useCallback)(e=>{r.current+=1,n({moduleFilePath:e,nonce:r.current})},[]),a=(0,b.useCallback)(()=>n(null),[]),o=(0,b.useMemo)(()=>({request:t,requestUpload:i,clearRequest:a}),[t,i,a]);return(0,Y.jsx)(oX.Provider,{value:o,children:e})}function DRe(){return(0,b.useContext)(oX).requestUpload}function ORe(e,t){let{request:n,clearRequest:r}=(0,b.useContext)(oX),i=(0,b.useRef)(t);i.current=t,(0,b.useEffect)(()=>{n!==null&&n.moduleFilePath===e&&(r(),i.current())},[n,e,r])}var kRe=new TextEncoder;function sX({path:e,showChildPath:t,readonly:n}){let[r]=H.splitModuleFilePathAndModulePath(e),i=Ab(e),a=Cb(e),o=Mb(),{addPatch:s,patchPath:c,addAndUploadPatchWithFileOps:l}=vb(e),u=Tce(r),d=sC(),f=Fb()||{},p=bb(),m=xS(),h=SS(),g=b.useRef(null);ORe(r,()=>g.current?.click());let _=b.useRef(0),[v,y]=b.useState(!1),[x,S]=b.useState(!1),[C,w]=b.useState(null),[T,E]=b.useState(null),D=b.useCallback((e,t,n,r)=>{let i=Math.round((n*t+e)/(r*t)*100);E(i),i===100&&setTimeout(()=>{E(null)},1e3)},[]),O=i.status===`success`?i.data:null,k=a.status===`success`&&a.data.type===`record`?a.data:null,A=k?.mediaType===`images`,j=k?.directory??`/public/val`,M=k?.accept,N=b.useMemo(()=>({settings:hA(void 0,k?.encode),accept:M}),[k,M]),P=k?.remote,F=k?.remote&&m.status===`ready`&&h&&p?{publicProjectId:m.publicProjectId,bucket:h,coreVersion:m.coreVersion,remoteHost:p.remoteHost}:null,I=O?Object.entries(O).map(([t,n])=>{let r=typeof n.mimeType==`string`?n.mimeType:``,i=typeof n.width==`number`?n.width:0,a=typeof n.height==`number`?n.height:0,s=typeof n.alt==`string`?n.alt:void 0,l=typeof n.hotspot==`object`&&n.hotspot!==null&&`x`in n.hotspot&&`y`in n.hotspot&&typeof n.hotspot.x==`number`&&typeof n.hotspot.y==`number`?{x:n.hotspot.x,y:n.hotspot.y}:void 0,p=sD(e,t),m=[],h=[];for(let[e,t]of Object.entries(f))e.startsWith(p)&&(e===H.createValPathOfItem(p,`alt`)?h.push(...t.map(e=>e.message)):m.push(...t.map(e=>e.message)));let g=H.patchPathToModulePath([...c,t]),_=u.filter(e=>e.patch.some(e=>H.patchPathToModulePath(e.path)===g)),v={};for(let e of _){let t=e.authorId??`unknown`;v[t]||(v[t]=[]),v[t].push(e)}let{filename:y,folder:b}=pS(t);return{ref:t,url:rA(t,o),filename:y,folder:b,metadata:{mimeType:r,width:i,height:a,alt:s,hotspot:l},fieldSpecificErrors:{alt:h.length>0?h:void 0},validationErrors:m.length>0?m:void 0,patchesByAuthorIds:v,profilesByAuthorIds:d,sourcePath:p}}):[],L=b.useCallback(e=>{if(!O)return;let t=Object.keys(O)[e];if(!t)return;let n=[{op:`remove`,path:[...c,t]},{op:`file`,path:[...c,t],filePath:t,value:null,remote:H.remote.splitRemoteRef(t).status===`success`}];S(!0),l(n,A?`image`:`file`,e=>w(e),()=>{}).finally(()=>S(!1))},[O,c,A,l]),R=b.useCallback((e,t)=>{if(!O)return;let n=Object.keys(O)[e];if(!n)return;let r=[{op:`add`,path:[...c,n,`alt`],value:t}];s(r,`record`)},[O,c,s]),ee=b.useCallback((e,t,n)=>{let r=H.createFilename(e.src,e.filename??null,n,e.fileHash);if(!r)return{status:`error`,error:`Failed to create filename for the uploaded file.`};let i=`${j}/${r}`,a,o;if(P){if(!F)return{status:`error`,error:`Remote uploads are not available. Please try again later. This could be a temporary issue with the Val server. If the problem persists, please contact support.`};let i=H.remote.hashToRemoteFileHash(e.fileHash),s=H.remote.getValidationHash(F.coreVersion,t,bA(r),n,i,kRe);a=H.remote.createRemoteRef(F.remoteHost,{publicProjectId:F.publicProjectId,coreVersion:F.coreVersion,bucket:F.bucket,validationHash:s,fileHash:i,filePath:`${j.slice(1)}/${r}`}),o=!0}else a=i,o=!1;return{status:`success`,ref:a,isRemote:o}},[j,P,F]),te=b.useCallback(e=>{if(w(null),P&&(!F||!h)){if(!h){console.error(`Current remote file bucket is not available`,{remoteFiles:m,currentRemoteFileBucket:h}),w(`Remote uploads are not available. Please try again later. Val server responded with result, but no remote file buckets were available. This could be a temporary issue with the Val server. If the problem persists, please contact support.`),e.target.value=``;return}w(`Remote uploads are not available. Please try again later.`),e.target.value=``;return}A?Fge(e,N).then(async e=>{if(!e.width||!e.height||!e.mimeType)return;let t={width:e.width,height:e.height,mimeType:e.mimeType},n=ee(e,{type:`image`,opt:!1,options:k?.accept?{accept:k.accept}:void 0},t);if(n.status===`error`){w(n.error);return}let{ref:r,isRemote:i}=n,a=[{op:`add`,path:[...c,r],value:{width:t.width,height:t.height,mimeType:t.mimeType,alt:null}},{op:`file`,path:[...c,r],filePath:r,value:e.src,metadata:t,remote:i}];S(!0),await l(a,`image`,e=>w(e),D)}).catch(()=>w(`Could not upload image. Please try again.`)).finally(()=>{S(!1),E(null)}):yA(e).then(async e=>{if(!e.mimeType)return;let t={mimeType:e.mimeType};if(!H.createFilename(e.src,e.filename??null,t,e.fileHash))return;let n=ee(e,{type:`file`,opt:!1,options:k?.accept?{accept:k.accept}:void 0},t);if(n.status===`error`){w(n.error);return}let{ref:r,isRemote:i}=n,a=[{op:`add`,path:[...c,r],value:{mimeType:t.mimeType}},{op:`file`,path:[...c,r],filePath:r,value:e.src,metadata:t,remote:i}];S(!0),await l(a,`file`,e=>w(e),D)}).catch(()=>w(`Could not upload file. Please try again.`)).finally(()=>{S(!1),E(null)}),e.target.value=``},[A,j,c,l,P,F,h,k,m,N]),ne=b.useCallback(e=>{if(e.preventDefault(),_.current=0,y(!1),P&&(!F||!h)){w(`Remote uploads are not available. Please try again later.`);return}let t=Array.from(e.dataTransfer.files).filter(e=>!M||M.split(`,`).map(e=>e.trim()).some(t=>t.endsWith(`/*`)?e.type.startsWith(t.slice(0,-1)):e.type===t));t.length!==0&&(w(null),S(!0),(async()=>{for(let e of t)if(A){let t=await gA(e,N).catch(()=>null);if(!t||!t.width||!t.height||!t.mimeType)continue;let n={width:t.width,height:t.height,mimeType:t.mimeType},r=ee(t,{type:`image`,opt:!1,options:k?.accept?{accept:k.accept}:void 0},n);if(r.status===`error`){w(r.error);continue}let{ref:i,isRemote:a}=r,o=[{op:`add`,path:[...c,i],value:{width:n.width,height:n.height,mimeType:n.mimeType,alt:null}},{op:`file`,path:[...c,i],filePath:i,value:t.src,metadata:n,remote:a}];await l(o,`image`,e=>w(e),D)}else{let t=await vA(e).catch(()=>null);if(!t||!t.mimeType)continue;let n={mimeType:t.mimeType},r=ee(t,{type:`file`,opt:!1,options:k?.accept?{accept:k.accept}:void 0},n);if(r.status===`error`){w(r.error);continue}let{ref:i,isRemote:a}=r,o=[{op:`add`,path:[...c,i],value:{mimeType:n.mimeType}},{op:`file`,path:[...c,i],filePath:i,value:t.src,metadata:n,remote:a}];await l(o,`file`,e=>w(e),D)}})().finally(()=>{S(!1),E(null)}))},[A,c,l,P,F,h,M,k,ee,D,N]),re=b.useMemo(()=>{if(!t)return null;let[,e]=H.splitModuleFilePathAndModulePath(t),n=H.splitModulePath(e)[0];return typeof n==`string`?n:null},[t]);return i.status===`success`?(0,Y.jsxs)(`div`,{id:e,onDragEnter:e=>{e.preventDefault(),_.current++,y(!0)},onDragLeave:()=>{_.current--,_.current===0&&y(!1)},onDragOver:e=>e.preventDefault(),onDrop:ne,children:[C&&(0,Y.jsx)(`div`,{className:`mb-2 rounded p-3 bg-bg-error-primary text-fg-error-primary text-sm`,children:C}),T===null?(0,Y.jsx)(`div`,{className:`h-[2px] mb-2`}):(0,Y.jsx)($Y,{className:`h-[2px] mb-2 transition-opacity duration-300 z-[1000]`,style:{opacity:1},value:T??0}),(0,Y.jsx)(`input`,{ref:g,type:`file`,hidden:!0,accept:M,onChange:te}),(0,Y.jsx)(TRe,{files:I,parentPath:r,imageMode:A,onAltTextChange:A&&!n?R:void 0,onFileDelete:n?void 0:L,onUploadClick:n?void 0:()=>g.current?.click(),uploading:x,defaultOpenFileRef:re??void 0,isDraggingOver:v})]}):(0,Y.jsx)(jC,{path:e,type:`record`})}function cX(e,t){for(let n in t)if(n.startsWith(e))return!0;return!1}function lX(){return(0,Y.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bg-error-secondary`})}function uX({error:e}){return(0,Y.jsx)(`div`,{className:`p-4 text-fg-error-primary bg-bg-error-primary`,children:(0,Y.jsxs)(`div`,{children:[`Preview error: `,e]})})}function ARe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`record`,o=Fb()||{},s=Cb(e),c=xb(e),l=Ob(e,a);if(s.status===`error`)return(0,Y.jsx)(NC,{path:e,error:s.error,type:a});if(l.status===`error`)return(0,Y.jsx)(FC,{path:e,error:l.error,schema:s});if(l.status==`not-found`||s.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(s.status===`loading`||!(`data`in l)||l.data===void 0)return(0,Y.jsx)(jC,{path:e,type:a});if(s.data.type!==a)return(0,Y.jsx)(PC,{path:e,expectedType:a,actualType:s.data.type});if(s.data.mediaType)return(0,Y.jsx)(sX,{path:e});let u=l.data,d=s.data;if(r||xr(d.item)){let a=u;return a===null?null:(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(`div`,{className:`flex flex-col ${n?`gap-3`:`gap-4`}`,children:d.item.hidden?null:Object.entries(a).map(([e,a])=>(0,Y.jsx)(qk,{label:e,path:a,type:d.item.type,readonly:t||d.item.readonly,compact:n,errorDisplay:i,children:(0,Y.jsx)(r6,{path:a,schema:d.item,readonly:t||d.item.readonly,compact:n,inline:r,errorDisplay:i})},a))})})}let f=c&&`data`in c&&c.data&&c.data.parent===`record`?c.data:void 0;return(0,Y.jsxs)(`div`,{id:e,children:[c?.status===`error`&&(0,Y.jsx)(uX,{error:c.message,path:e}),f&&u&&(0,Y.jsx)(PRe,{path:e,keys:Object.keys(u),jsonValues:d.jsonValues===!0}),!f&&u&&(0,Y.jsx)(NRe,{path:e,keys:Object.keys(u),jsonValues:d.jsonValues===!0,validationErrors:o})]})}var jRe=146,MRe=74,dX=56;function NRe({path:e,keys:t,jsonValues:n,validationErrors:r}){let{navigate:i}=GC(),a=nb(),[o]=H.splitModuleFilePathAndModulePath(e),{unloadedKeys:s,errorByKey:c}=fX(o,n);return(0,Y.jsx)(zY,{moduleFilePath:o,keys:t,estimatedRowHeight:jRe,jsonValues:n,className:`grid grid-cols-1`,renderRow:t=>{let n=c.get(t);return n===void 0?(0,Y.jsx)(`div`,{className:`pb-4`,children:(0,Y.jsxs)(`div`,{onClick:()=>i(sD(e,t)),className:(0,AC.default)(`bg-primary-foreground cursor-pointer min-w-[320px] max-h-[170px] overflow-hidden rounded-md border border-border-primary p-4`,`hover:bg-bg-secondary-hover`),children:[(0,Y.jsxs)(`div`,{className:`flex justify-between items-start`,children:[(0,Y.jsx)(`div`,{className:`pb-4 font-semibold text-md`,children:t}),cX(sD(e,t),r)&&(0,Y.jsx)(lX,{})]}),(0,Y.jsx)(`div`,{children:s.has(t)?(0,Y.jsx)(BY,{path:sD(e,t),height:dX}):(0,Y.jsx)(X3,{path:sD(e,t)})})]})}):(0,Y.jsx)(`div`,{className:`pb-4`,children:(0,Y.jsx)(VY,{path:sD(e,t),label:t,message:n,height:96,onRetry:()=>void a?.system.sourceStore.retryEntry(o,t)})})}})}function fX(e,t){let n=nb(),r=Ab(e),i=`data`in r?r.data:void 0;return(0,b.useMemo)(()=>{let r=new Set,a=new Map;if(!t||typeof i!=`object`||!i||Array.isArray(i))return{unloadedKeys:r,errorByKey:a};for(let[t,o]of Object.entries(i)){if(!H.isJson(o))continue;let i=n?.system.sourceStore.entryError(e,t);i===void 0?r.add(t):a.set(t,i)}return{unloadedKeys:r,errorByKey:a}},[t,i,n,e])}function PRe({path:e,keys:t,jsonValues:n}){let{navigate:r}=GC(),i=nb(),[a]=H.splitModuleFilePathAndModulePath(e),{unloadedKeys:o,errorByKey:s}=fX(a,n);return(0,Y.jsx)(zY,{moduleFilePath:a,keys:t,estimatedRowHeight:MRe,jsonValues:n,className:`flex flex-col w-full`,renderRow:t=>{let n=s.get(t);return n===void 0?(0,Y.jsx)(`div`,{className:`pb-4`,children:(0,Y.jsx)(`button`,{onClick:()=>r(sD(e,t)),className:(0,AC.default)(`w-full hover:bg-bg-secondary-hover`,`border rounded-lg cursor-pointer border-border-primary`),children:o.has(t)?(0,Y.jsx)(BY,{path:sD(e,t),height:dX}):(0,Y.jsx)(X3,{path:sD(e,t)})})}):(0,Y.jsx)(`div`,{className:`pb-4`,children:(0,Y.jsx)(VY,{path:sD(e,t),label:t,message:n,height:72,onRetry:()=>void i?.system.sourceStore.retryEntry(a,t)})})}})}function FRe({path:e,size:t}){let n=Ob(e,`record`);if(n.status===`error`)return(0,Y.jsx)(FC,{path:e,error:n.error});if(!(`data`in n)||n.data===void 0)return(0,Y.jsx)(J3,{path:e});if(n.data===null)return(0,Y.jsx)(Y3,{path:e});let r=Object.keys(n.data);return(0,Y.jsxs)(`div`,{className:`text-left ${t===`compact`?`max-h-[60px] overflow-hidden`:``}`,children:[(0,Y.jsx)(`span`,{className:`text-fg-brand-primary`,children:r.length}),(0,Y.jsx)(`span`,{className:`mr-1`,children:` item${r.length===1?``:`s`}:`}),r.map((e,t)=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-fg-brand-primary`,children:e},e),t<r.length-1?`, `:``]}))]})}function pX(e){this.content=e}pX.prototype={constructor:pX,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new pX(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new pX(n)},addToStart:function(e,t){return new pX([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new pX(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new pX(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=pX.from(e),e.size?new pX(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=pX.from(e),e.size?new pX(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=pX.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},pX.from=function(e){if(e instanceof pX)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new pX(t)};function mX(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&_X(e.charCodeAt(r-1))&&gX(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=mX(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function hX(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&_X(e.charCodeAt(i-1))&&gX(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=hX(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function gX(e){return e>=56320&&e<57344}function _X(e){return e>=55296&&e<56320}var vX=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return mX(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return hX(this,e,t,n)}findIndex(e){if(e==0)return bX(0,e);if(e==this.size)return bX(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?bX(t+1,i):bX(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};vX.empty=new vX([],0);var yX={index:0,offset:0};function bX(e,t){return yX.index=e,yX.offset=t,yX}function xX(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!xX(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!xX(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var SX=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&xX(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};SX.none=[];var CX=class extends Error{},wX=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=EX(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(TX(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(vX.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};wX.empty=new wX(vX.empty,0,0);function TX(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(TX(a.content,t-i-1,n-i-1)))}function EX(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=EX(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function IRe(e,t,n){if(n.openStart>e.depth)throw new CX(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new CX(`Inconsistent open depths`);return DX(e,t,n,0)}function DX(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=DX(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}if(!n.content.size)return MX(a,PX(e,t,r));if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return MX(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}{let{start:i,end:o}=LRe(n,e);return MX(a,NX(e,i,o,t,r))}}function OX(e,t){if(!t.type.compatibleContent(e.type))throw new CX(`Cannot join `+t.type.name+` onto `+e.type.name)}function kX(e,t,n){let r=e.node(n);return OX(r,t.node(n)),r}function AX(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function jX(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(AX(e.nodeAfter,r),a++));for(let e=a;e<o;e++)AX(i.child(e),r);t&&t.depth==n&&t.textOffset&&AX(t.nodeBefore,r)}function MX(e,t){if(!e.type.validContent(t))throw new CX(`Invalid content for node `+e.type.name);return e.copy(t)}function NX(e,t,n,r,i){let a=e.depth>i&&kX(e,t,i+1),o=r.depth>i&&kX(n,r,i+1),s=[];return jX(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(OX(a,o),AX(MX(a,NX(e,t,n,r,i+1)),s)):(a&&AX(MX(a,PX(e,t,i+1)),s),jX(t,n,i,s),o&&AX(MX(o,PX(n,r,i+1)),s)),jX(r,null,i,s),new vX(s)}function PX(e,t,n){let r=[];return jX(null,e,n,r),e.depth>n&&AX(MX(kX(e,t,n+1),PX(e,t,n+1)),r),jX(t,null,n,r),new vX(r)}function LRe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(vX.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var FX=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return SX.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new LX(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=IX.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else IX.set(t,r=new RRe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%zRe,i}},RRe=class{constructor(){this.elts=[],this.i=0}},zRe=12,IX=new WeakMap,LX=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},BRe=Object.create(null),RX=class e{constructor(e,t,n,r=SX.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||vX.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&xX(this.attrs,t||e.defaultAttrs||BRe)&&SX.sameSet(this.marks,n||SX.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return wX.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new wX(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return IRe(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return FX.resolveCached(this,e)}resolveNoCache(e){return FX.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),zX(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=vX.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=SX.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!SX.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=vX.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};RX.prototype.text=void 0;var VRe=class e extends RX{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):zX(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function zX(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var BX=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new HRe(t,n);if(r.next==null)return e.empty;let i=VX(r);r.next&&r.err(`Unexpected trailing text`);let a=YRe(JRe(i));return XRe(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return vX.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
205
|
+
Defaulting to \`null\`.`}HY(ZY,`getInvalidValueError`);var QY=mRe,_Re=gRe,$Y=b.forwardRef(({className:e,value:t,...n},r)=>(0,Y.jsx)(QY,{ref:r,className:X(`relative h-4 w-full overflow-hidden rounded-full bg-bg-secondary`,e),...n,children:(0,Y.jsx)(_Re,{className:`flex-1 w-full h-full transition-all bg-fg-brand-primary`,style:{transform:`translateX(-${100-(t||0)}%)`}})}));$Y.displayName=QY.displayName;function eX({className:e,...t}){return(0,Y.jsx)(`div`,{className:X(`animate-pulse rounded-md bg-muted`,e),...t})}function vRe(e){let[t]=e.split(`/`);return t}function tX({file:e,className:t}){let n=vRe(e.metadata.mimeType);return n===`image`?(0,Y.jsx)(cA,{url:e.url,alt:e.metadata.alt||e.filename,hotspot:e.metadata.hotspot,className:t}):n===`video`?(0,Y.jsxs)(`div`,{className:X(`relative h-full w-full bg-bg-secondary`,t),children:[(0,Y.jsx)(`video`,{src:e.url,className:`h-full w-full object-cover`,muted:!0,preload:`metadata`}),(0,Y.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/20`,children:(0,Y.jsx)(Yie,{className:`h-8 w-8 text-white`})})]}):n===`audio`?(0,Y.jsx)(`div`,{className:X(`flex h-full w-full items-center justify-center bg-bg-secondary`,t),children:(0,Y.jsx)(Jie,{className:`h-12 w-12 text-fg-secondary`})}):n===`text`||e.metadata.mimeType===`application/json`?(0,Y.jsx)(`div`,{className:X(`flex h-full w-full items-center justify-center bg-bg-secondary`,t),children:(0,Y.jsx)($v,{className:`h-12 w-12 text-fg-secondary`})}):(0,Y.jsx)(`div`,{className:X(`flex h-full w-full items-center justify-center bg-bg-secondary`,t),children:(0,Y.jsx)(ey,{className:`h-12 w-12 text-fg-secondary`})})}function nX({file:e,onClick:t,viewMode:n,imageMode:r}){let i=e.metadata.width>0&&e.metadata.height>0?e.metadata.width/e.metadata.height:1,a=e.validationErrors&&e.validationErrors.length>0||e.fieldSpecificErrors&&Object.values(e.fieldSpecificErrors).some(e=>e&&e.length>0),o=(0,Y.jsxs)(`button`,{type:`button`,onClick:t,className:X(`group flex w-full flex-col overflow-hidden rounded border bg-bg-primary transition-all`,`hover:shadow-md`,`focus:outline-none focus:ring-2`,a?`border-bg-error-primary ring-bg-error-primary/50 hover:border-bg-error-primary-hover focus:ring-bg-error-primary`:`border-border-secondary hover:border-border-primary focus:ring-border-focus`),title:a?e.validationErrors?.join(`, `):void 0,children:[(0,Y.jsx)(`div`,{className:X(`relative w-full overflow-hidden bg-bg-secondary`),style:{aspectRatio:n===`masonry`?i:1},children:(0,Y.jsx)(tX,{file:e})}),(0,Y.jsxs)(`div`,{className:`p-1.5`,children:[(0,Y.jsx)(`p`,{className:`truncate text-xs font-medium text-fg-primary`,title:e.filename,children:e.filename}),r&&e.metadata.mimeType.startsWith(`image/`)&&e.metadata.alt&&(0,Y.jsx)(`p`,{className:`truncate text-xs text-fg-secondary`,title:e.metadata.alt,children:e.metadata.alt})]})]});return n===`masonry`?(0,Y.jsx)(`div`,{className:`mb-2 break-inside-avoid`,children:o}):o}var rX=50;function iX({field:e,currentField:t,direction:n}){return e===t?n===`asc`?(0,Y.jsx)(jv,{className:`h-3 w-3`}):(0,Y.jsx)(kv,{className:`h-3 w-3`}):(0,Y.jsx)(Pie,{className:`h-3 w-3 opacity-50`})}function yRe(e){let[,t]=e.split(`/`);return t?.toUpperCase()??e}function bRe({files:e,onItemClick:t,sortField:n,sortDirection:r,onSort:i}){let a=b.useRef(null),o=tA({count:e.length,getScrollElement:()=>a.current,estimateSize:()=>rX,overscan:10}),s=e.some(e=>e.metadata.alt!==void 0),c=e.some(e=>e.patchesByAuthorIds&&Object.keys(e.patchesByAuthorIds).length>0),l=s&&c?`grid-cols-[56px_1fr_120px_192px_96px]`:s?`grid-cols-[56px_1fr_192px_96px]`:c?`grid-cols-[56px_120px_1fr_96px]`:`grid-cols-[56px_1fr_96px]`;return(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-lg`,children:[(0,Y.jsx)(`div`,{className:`rounded-t-lg border border-border-secondary bg-bg-secondary text-left text-xs font-medium text-fg-secondary`,children:(0,Y.jsxs)(`div`,{className:X(`grid`,l),children:[(0,Y.jsx)(`div`,{className:`px-3 py-2`}),s&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(`description`),className:`flex items-center gap-1 hover:text-fg-primary`,children:[`Description`,(0,Y.jsx)(iX,{field:`description`,currentField:n,direction:r})]})}),c&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:`Last change`}),(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(`name`),className:`flex items-center gap-1 hover:text-fg-primary`,children:[`Name`,(0,Y.jsx)(iX,{field:`name`,currentField:n,direction:r})]})}),(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>i(`type`),className:`flex items-center gap-1 hover:text-fg-primary`,children:[`Type`,(0,Y.jsx)(iX,{field:`type`,currentField:n,direction:r})]})})]})}),(0,Y.jsx)(`div`,{ref:a,className:`overflow-auto`,style:{contain:`strict`,height:Math.min(e.length*rX,600)},children:(0,Y.jsx)(`div`,{style:{height:`${o.getTotalSize()}px`,width:`100%`,position:`relative`},children:o.getVirtualItems().map(n=>{let r=e[n.index],i=r.validationErrors&&r.validationErrors.length>0||r.fieldSpecificErrors&&Object.values(r.fieldSpecificErrors).some(e=>e&&e.length>0),a=n.index===0,u=n.index===e.length-1,d=i&&(n.index===0||!(e[n.index-1].validationErrors&&e[n.index-1].validationErrors.length>0));return(0,Y.jsxs)(`div`,{"data-index":n.index,ref:o.measureElement,onClick:()=>t(n.index),className:X(`absolute left-0 top-0 grid w-full cursor-pointer border border-b-0 transition-colors`,a&&`border-t-0`,u&&`border-b`,l,`border-border-secondary hover:bg-bg-secondary`,i&&`border border-bg-error-primary hover:border-bg-error-primary-hover`,!d&&i&&`border-t-0`,u&&`rounded-b-lg`),style:{transform:`translateY(${n.start}px)`},title:i?r.validationErrors?.join(`, `):void 0,children:[(0,Y.jsx)(`div`,{className:`flex items-center px-3 py-2`,children:(0,Y.jsx)(`div`,{className:`h-8 w-8 overflow-hidden rounded bg-bg-secondary`,children:(0,Y.jsx)(tX,{file:r})})}),s&&(0,Y.jsx)(`div`,{className:`flex items-center overflow-hidden px-3 py-2`,children:(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium text-fg-primary`,children:r.metadata.alt??``})}),c&&(0,Y.jsx)(`div`,{className:`flex items-center px-3 py-2`,children:r.patchesByAuthorIds&&r.profilesByAuthorIds&&Object.keys(r.patchesByAuthorIds).length>0&&(0,Y.jsx)(Kk,{patchesByAuthorIds:r.patchesByAuthorIds,profilesByAuthorIds:r.profilesByAuthorIds,sourcePath:r.sourcePath,navigable:!1})}),(0,Y.jsx)(`div`,{className:`flex items-center overflow-hidden px-3 py-2`,children:(0,Y.jsx)(`span`,{className:X(`truncate text-sm`,s?`text-fg-secondary`:`font-medium text-fg-primary`),children:r.filename})}),(0,Y.jsx)(`div`,{className:`flex items-center px-3 py-2`,children:(0,Y.jsx)(`span`,{className:`text-sm text-fg-secondary`,children:yRe(r.metadata.mimeType)})})]},n.key)})})})]})}function aX(e){let t=e.lastIndexOf(`.`);return t<=0?[e,``]:[e.slice(0,t),e.slice(t)]}function xRe({filename:e,onSave:t,disabled:n=!1,className:r}){let[i,a]=b.useState(!1),[o,s]=aX(e),[c,l]=b.useState(o);b.useEffect(()=>{let[t]=aX(e);l(t),a(!1)},[e]);let u=()=>{let e=c.trim();e&&e!==o&&t(e+s),a(!1)},d=()=>{l(o),a(!1)};return i?(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1`,r),children:[(0,Y.jsxs)(`div`,{className:`flex flex-1 items-center`,children:[(0,Y.jsx)(MT,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`?u():e.key===`Escape`&&d()},autoFocus:!0,className:`h-8 flex-1 rounded-r-none text-sm`}),s&&(0,Y.jsx)(`span`,{className:`flex h-8 items-center rounded-r-md border border-l-0 border-border-primary bg-bg-secondary px-2 text-sm text-fg-secondary`,children:s})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:u,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-bg-secondary hover:text-fg-primary`,title:`Save`,children:(0,Y.jsx)(Fv,{className:`h-4 w-4`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:d,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-bg-secondary hover:text-fg-primary`,title:`Cancel`,children:(0,Y.jsx)(Hy,{className:`h-4 w-4`})})]}):(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-1`,r),children:[(0,Y.jsx)(`span`,{className:`flex-1 truncate rounded px-2 py-1.5 text-sm text-fg-primary`,title:e,children:e}),!n&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-bg-secondary hover:text-fg-primary`,title:`Rename`,children:(0,Y.jsx)(Dy,{className:`h-4 w-4`})})]})}function SRe(e,t,n,r){let i=[];return OD(e,t,(e,t,a)=>{(t.type===`image`||t.type===`file`)&&t.referencedModule===n?(r===void 0||typeof a==`object`&&a&&!Array.isArray(a)&&`path`in a&&a.path===r)&&(i.includes(e)||i.push(e)):t.type===`string`||t.type===`number`||t.type===`boolean`||t.type===`literal`||t.type===`date`||t.type===`dateTime`||t.type===`color`||t.type===`code`||t.type===`keyOf`||t.type===`image`||t.type===`file`||t.type===`richtext`||t.type===`route`||console.error(`Could not get referenced files. Unhandled schema type`,t)}),i}function CRe(e,t){let n=wb(),r=_b(),i=Eb();return ID(ND((0,b.useMemo)(()=>e===void 0?null:{kind:`file`,module:e},[e])),(0,b.useMemo)(()=>e!==void 0&&`data`in n&&n.data!==void 0?SRe(n.data,i,e,t):[],[r,i,`data`in n&&n.data,e,t]))}function wRe({file:e,fileIndex:t,open:n,onOpenChange:r,onFileRename:i,onAltTextChange:a,onFileDelete:o,parentPath:s,imageMode:c,loading:l,disabled:u,container:d}){let f=CRe(s,e?.ref),p=f.refs,m=f.status===`success`,{navigate:h,currentSourcePath:g}=GC(),[_,v]=b.useState(!1);if(!e||t===null)return null;let y=e=>{i?.(t,e)},x=e.metadata.mimeType.startsWith(`image/`);return(0,Y.jsx)(Uy,{open:n,onOpenChange:r,children:(0,Y.jsxs)(Ky,{className:`max-w-2xl`,container:d,children:[(0,Y.jsx)(qy,{children:(0,Y.jsx)(Yy,{children:`File Properties`})}),(0,Y.jsxs)(`div`,{className:`flex gap-6`,children:[(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsx)(`div`,{className:`h-32 w-32 overflow-hidden rounded-lg border border-border-secondary bg-bg-secondary`,children:(0,Y.jsx)(tX,{file:e})})}),(0,Y.jsxs)(`div`,{className:`flex-1 space-y-4`,children:[i&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-fg-secondary`,children:`Filename`}),(0,Y.jsx)(xRe,{filename:e.filename,onSave:y,disabled:u||l})]}),c&&x&&a&&(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1`,{"border-[red] border p-2 rounded":e.fieldSpecificErrors?.alt&&e.fieldSpecificErrors.alt.length>0}),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`label`,{className:`text-xs font-medium text-fg-secondary`,children:`Description`}),e.patchesByAuthorIds&&e.profilesByAuthorIds&&Object.keys(e.patchesByAuthorIds).length>0&&(0,Y.jsx)(Kk,{patchesByAuthorIds:e.patchesByAuthorIds,profilesByAuthorIds:e.profilesByAuthorIds,sourcePath:e.sourcePath})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(MT,{value:e.metadata.alt??``,onChange:e=>{a?.(t,e.target.value)},autoFocus:!0,placeholder:`Describe this image...`}),e.fieldSpecificErrors?.alt&&e.fieldSpecificErrors.alt.length>0&&(0,Y.jsx)(`ul`,{className:`list-none p-0 text-sm`,children:e.fieldSpecificErrors.alt.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(Uk,{validationErrors:[{message:e}]})},t))})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-secondary`,children:`Folder`}),(0,Y.jsx)(`span`,{className:`truncate text-sm text-fg-primary`,title:e.folder,children:e.folder})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-secondary`,children:`Type`}),(0,Y.jsx)(`span`,{className:`text-sm text-fg-primary`,children:e.metadata.mimeType})]}),(e.metadata.width>0||e.metadata.height>0)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-secondary`,children:`Dimensions`}),(0,Y.jsxs)(`span`,{className:`text-sm text-fg-primary`,children:[e.metadata.width,` × `,e.metadata.height,` px`]})]})]}),e.validationErrors&&e.validationErrors.length>0&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-destructive`,children:`Validation Errors`}),(0,Y.jsx)(`ul`,{className:`list-inside list-disc text-sm text-destructive`,children:e.validationErrors.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})]})]})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 border-t border-border-secondary pt-4`,children:[(0,Y.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 rounded-md bg-bg-secondary px-3 py-2 text-sm font-medium text-fg-primary transition-colors hover:bg-bg-tertiary`,children:[(0,Y.jsx)(Zv,{className:`h-4 w-4`}),`Open in New Tab`]}),e.sourcePath&&e.patchesByAuthorIds&&Object.keys(e.patchesByAuthorIds).length>0&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{h(`/val/compare`,{scrollToPath:e.sourcePath})},className:`inline-flex items-center gap-2 rounded-md bg-bg-secondary px-3 py-2 text-sm font-medium text-fg-primary transition-colors hover:bg-bg-tertiary`,children:[(0,Y.jsx)(ny,{className:`h-4 w-4`}),`View in Compare`]}),o&&t!==null&&(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[p.length>0&&(0,Y.jsxs)(SD,{open:_,onOpenChange:v,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-2 rounded-md bg-bg-secondary px-3 py-2 text-sm font-medium text-fg-primary transition-colors hover:bg-bg-tertiary`,children:[(0,Y.jsx)(dy,{className:`h-4 w-4`}),p.length,` reference`,p.length===1?``:`s`]})}),(0,Y.jsx)(wD,{className:`w-[clamp(260px,32vw,360px)] p-0 z-[8999]`,container:d,children:(0,Y.jsx)(pk,{refs:p,currentPath:g,onSelect:(e,{scrollToPath:t})=>{h(e,{scrollToPath:t}),v(!1)}})})]}),(0,Y.jsx)(qg,{children:(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`span`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{o(t),r(!1)},disabled:u||l||p.length>0||!m,className:`inline-flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium text-destructive transition-colors hover:bg-bg-error-primary disabled:opacity-50`,children:[(0,Y.jsx)(Iy,{className:`h-4 w-4`}),`Delete`]})})}),p.length>0?(0,Y.jsxs)(Xg,{children:[`Cannot delete: referenced in `,p.length,` `,p.length===1?`place`:`places`]}):f.status===`loading`?(0,Y.jsxs)(Xg,{children:[`Checking references`,f.percentage>0?` (${f.percentage}%)`:``,`…`]}):f.status===`error`?(0,Y.jsx)(Xg,{children:`Cannot delete: references could not be checked`}):null]})})]})]})]})})}function TRe({files:e,parentPath:t,onFileRename:n,onAltTextChange:r,onFileDelete:i,className:a,defaultViewMode:o=`list`,showSearch:s=!0,imageMode:c=!1,loading:l=!1,disabled:u=!1,onUploadClick:d,uploading:f=!1,uploadDisabled:p=!1,defaultOpenFileRef:m,isDraggingOver:h=!1}){let g=GC(),_=eb(),[v,y]=b.useState(null),[x,S]=b.useState(!1);b.useEffect(()=>{if(m){let t=e.findIndex(e=>e.ref===m);t!==-1&&(y(t),S(!0))}},[m,e]);let[C,w]=b.useState(o),[T,E]=b.useState(``),[D,O]=b.useState(`name`),[k,A]=b.useState(`asc`),j=b.useMemo(()=>{let t=e;if(T.trim()){let e=T.toLowerCase();t=t.filter(t=>t.filename.toLowerCase().includes(e)||(t.metadata.alt??``).toLowerCase().includes(e))}return C===`list`&&(t=[...t].sort((e,t)=>{let n=0;switch(D){case`name`:n=e.filename.localeCompare(t.filename);break;case`description`:n=(e.metadata.alt??``).localeCompare(t.metadata.alt??``);break;case`type`:n=e.metadata.mimeType.localeCompare(t.metadata.mimeType)}return k===`asc`?n:-n})),t},[e,T,C,D,k]),M=b.useCallback(t=>{let n=j[t];return e.findIndex(e=>e.ref===n.ref)},[e,j]),N=e=>{D===e?A(e=>e===`asc`?`desc`:`asc`):(O(e),A(`asc`))},P=v===null?null:e[v]??null,F=n=>{let r=M(n);if(r!==-1&&(y(r),S(!0),t)){let n=t,i=e[r].ref,a=H.createValPathOfItem(n,i);a&&g.navigate(a)}},I=(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-12`,children:(0,Y.jsxs)(`div`,{className:`flex max-w-md flex-col items-center justify-center gap-4 rounded-lg border border-dashed border-border-secondary bg-bg-secondary p-12`,children:[(0,Y.jsx)(Qie,{className:`h-16 w-16 text-fg-secondary`}),(0,Y.jsxs)(`div`,{className:`text-center`,children:[(0,Y.jsx)(`p`,{className:`text-lg font-medium text-fg-primary`,children:`No files`}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`There are no files to display`})]})]})}),L=(0,Y.jsx)(`div`,{className:`columns-3 gap-2 sm:columns-4 md:columns-5 lg:columns-6 xl:columns-8`,children:Array.from({length:24}).map((e,t)=>(0,Y.jsx)(`div`,{className:`mb-2 break-inside-avoid`,children:(0,Y.jsxs)(`div`,{className:`flex w-full flex-col overflow-hidden rounded border border-border-secondary bg-bg-primary`,children:[(0,Y.jsx)(eX,{className:`w-full`,style:{aspectRatio:1+Math.random()*.5}}),(0,Y.jsx)(`div`,{className:`p-1.5`,children:(0,Y.jsx)(eX,{className:`h-4 w-3/4`})})]})},t))});return(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-4`,a),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s&&(0,Y.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,Y.jsx)(My,{className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-fg-secondary`}),(0,Y.jsx)(MT,{type:`text`,placeholder:`Filter`,value:T,onChange:e=>E(e.target.value),className:`pl-8`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 ml-auto`,children:[d&&(0,Y.jsx)(`button`,{type:`button`,onClick:d,disabled:f||p,className:`rounded p-1.5 transition-colors text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary disabled:opacity-50`,title:`Upload file`,children:f?(0,Y.jsx)(hy,{className:`size-5 animate-spin`}):(0,Y.jsx)(Oy,{className:`size-5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(`grid`),className:X(`rounded p-1.5 transition-colors`,C===`grid`?`bg-bg-secondary text-fg-primary`:`text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary`),title:`Grid view`,children:(0,Y.jsx)(eae,{className:`size-5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(`list`),className:X(`rounded p-1.5 transition-colors`,C===`list`?`bg-bg-secondary text-fg-primary`:`text-fg-secondary hover:bg-bg-secondary hover:text-fg-primary`),title:`List view`,children:(0,Y.jsx)(my,{className:`size-5`})})]})]}),(0,Y.jsxs)(`div`,{className:`relative`,children:[h&&(0,Y.jsx)(`div`,{className:`absolute inset-0 z-10 flex items-center justify-center rounded-lg border-2 border-dashed border-border-primary bg-bg-primary/80 pointer-events-none`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-fg-secondary`,children:[(0,Y.jsx)(Gv,{className:`size-10`}),(0,Y.jsx)(`p`,{className:`text-sm font-medium`,children:`Drop files here`})]})}),l?L:e.length===0?I:j.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-12 text-center`,children:[(0,Y.jsx)(My,{className:`h-8 w-8 text-fg-secondary`}),(0,Y.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No files match "`,T,`"`]})]}):C===`masonry`?(0,Y.jsx)(`div`,{className:`columns-3 gap-2 sm:columns-4 md:columns-5 lg:columns-6 xl:columns-8`,children:j.map((e,t)=>(0,Y.jsx)(nX,{file:e,onClick:()=>F(t),viewMode:C,imageMode:c},`${e.folder}/${e.filename}`))}):C===`grid`?(0,Y.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5`,children:j.map((e,t)=>(0,Y.jsx)(nX,{file:e,onClick:()=>F(t),viewMode:C,imageMode:c},`${e.folder}/${e.filename}`))}):(0,Y.jsx)(bRe,{files:j,onItemClick:F,sortField:D,sortDirection:k,onSort:N})]}),(0,Y.jsx)(wRe,{file:P,fileIndex:v,open:x,onOpenChange:e=>{S(e),!e&&t&&(y(null),g.navigate(t))},onFileRename:n,onAltTextChange:r,onFileDelete:i,parentPath:t,imageMode:c,loading:l,disabled:u,container:_})]})}var oX=(0,b.createContext)({request:null,requestUpload:()=>void 0,clearRequest:()=>void 0});function ERe({children:e}){let[t,n]=(0,b.useState)(null),r=(0,b.useRef)(0),i=(0,b.useCallback)(e=>{r.current+=1,n({moduleFilePath:e,nonce:r.current})},[]),a=(0,b.useCallback)(()=>n(null),[]),o=(0,b.useMemo)(()=>({request:t,requestUpload:i,clearRequest:a}),[t,i,a]);return(0,Y.jsx)(oX.Provider,{value:o,children:e})}function DRe(){return(0,b.useContext)(oX).requestUpload}function ORe(e,t){let{request:n,clearRequest:r}=(0,b.useContext)(oX),i=(0,b.useRef)(t);i.current=t,(0,b.useEffect)(()=>{n!==null&&n.moduleFilePath===e&&(r(),i.current())},[n,e,r])}var kRe=new TextEncoder;function sX({path:e,showChildPath:t,readonly:n}){let[r]=H.splitModuleFilePathAndModulePath(e),i=Ab(e),a=Cb(e),o=Mb(),{addPatch:s,patchPath:c,addAndUploadPatchWithFileOps:l}=vb(e),u=Tce(r),d=sC(),f=Fb()||{},p=bb(),m=xS(),h=SS(),g=b.useRef(null);ORe(r,()=>g.current?.click());let _=b.useRef(0),[v,y]=b.useState(!1),[x,S]=b.useState(!1),[C,w]=b.useState(null),[T,E]=b.useState(null),D=b.useCallback((e,t,n,r)=>{let i=Math.round((n*t+e)/(r*t)*100);E(i),i===100&&setTimeout(()=>{E(null)},1e3)},[]),O=i.status===`success`?i.data:null,k=a.status===`success`&&a.data.type===`record`?a.data:null,A=k?.mediaType===`images`,j=k?.directory??`/public/val`,M=k?.accept,N=b.useMemo(()=>({settings:hA(void 0,k?.encode),accept:M}),[k,M]),P=k?.remote,F=k?.remote&&m.status===`ready`&&h&&p?{publicProjectId:m.publicProjectId,bucket:h,coreVersion:m.coreVersion,remoteHost:p.remoteHost}:null,I=!P||F!==null,L=P===!0&&(m.status===`loading`||m.status===`not-asked`),R=O?Object.entries(O).map(([t,n])=>{let r=typeof n.mimeType==`string`?n.mimeType:``,i=typeof n.width==`number`?n.width:0,a=typeof n.height==`number`?n.height:0,s=typeof n.alt==`string`?n.alt:void 0,l=typeof n.hotspot==`object`&&n.hotspot!==null&&`x`in n.hotspot&&`y`in n.hotspot&&typeof n.hotspot.x==`number`&&typeof n.hotspot.y==`number`?{x:n.hotspot.x,y:n.hotspot.y}:void 0,p=sD(e,t),m=[],h=[];for(let[e,t]of Object.entries(f))e.startsWith(p)&&(e===H.createValPathOfItem(p,`alt`)?h.push(...t.map(e=>e.message)):m.push(...t.map(e=>e.message)));let g=H.patchPathToModulePath([...c,t]),_=u.filter(e=>e.patch.some(e=>H.patchPathToModulePath(e.path)===g)),v={};for(let e of _){let t=e.authorId??`unknown`;v[t]||(v[t]=[]),v[t].push(e)}let{filename:y,folder:b}=pS(t);return{ref:t,url:rA(t,o),filename:y,folder:b,metadata:{mimeType:r,width:i,height:a,alt:s,hotspot:l},fieldSpecificErrors:{alt:h.length>0?h:void 0},validationErrors:m.length>0?m:void 0,patchesByAuthorIds:v,profilesByAuthorIds:d,sourcePath:p}}):[],ee=b.useCallback(e=>{if(!O)return;let t=Object.keys(O)[e];if(!t)return;let n=[{op:`remove`,path:[...c,t]},{op:`file`,path:[...c,t],filePath:t,value:null,remote:H.remote.splitRemoteRef(t).status===`success`}];S(!0),l(n,A?`image`:`file`,e=>w(e),()=>{}).finally(()=>S(!1))},[O,c,A,l]),te=b.useCallback((e,t)=>{if(!O)return;let n=Object.keys(O)[e];if(!n)return;let r=[{op:`add`,path:[...c,n,`alt`],value:t}];s(r,`record`)},[O,c,s]),ne=b.useCallback((e,t,n)=>{let r=H.createFilename(e.src,e.filename??null,n,e.fileHash);if(!r)return{status:`error`,error:`Failed to create filename for the uploaded file.`};let i=`${j}/${r}`,a,o;if(P){if(!F)return{status:`error`,error:`Remote uploads are not available. Please try again later. This could be a temporary issue with the Val server. If the problem persists, please contact support.`};let i=H.remote.hashToRemoteFileHash(e.fileHash),s=H.remote.getValidationHash(F.coreVersion,t,bA(r),n,i,kRe);a=H.remote.createRemoteRef(F.remoteHost,{publicProjectId:F.publicProjectId,coreVersion:F.coreVersion,bucket:F.bucket,validationHash:s,fileHash:i,filePath:`${j.slice(1)}/${r}`}),o=!0}else a=i,o=!1;return{status:`success`,ref:a,isRemote:o}},[j,P,F]),re=b.useCallback(e=>{if(w(null),P&&(!F||!h)){if(!h){if(L){w(`Preparing remote uploads - try again in a moment.`),e.target.value=``;return}console.error(`Current remote file bucket is not available`,{remoteFiles:m,currentRemoteFileBucket:h}),w(`Remote uploads are not available. Please try again later. Val server responded with result, but no remote file buckets were available. This could be a temporary issue with the Val server. If the problem persists, please contact support.`),e.target.value=``;return}w(`Remote uploads are not available. Please try again later.`),e.target.value=``;return}A?Fge(e,N).then(async e=>{if(!e.width||!e.height||!e.mimeType)return;let t={width:e.width,height:e.height,mimeType:e.mimeType},n=ne(e,{type:`image`,opt:!1,options:k?.accept?{accept:k.accept}:void 0},t);if(n.status===`error`){w(n.error);return}let{ref:r,isRemote:i}=n,a=[{op:`add`,path:[...c,r],value:{width:t.width,height:t.height,mimeType:t.mimeType,alt:null}},{op:`file`,path:[...c,r],filePath:r,value:e.src,metadata:t,remote:i}];S(!0),await l(a,`image`,e=>w(e),D)}).catch(()=>w(`Could not upload image. Please try again.`)).finally(()=>{S(!1),E(null)}):yA(e).then(async e=>{if(!e.mimeType)return;let t={mimeType:e.mimeType};if(!H.createFilename(e.src,e.filename??null,t,e.fileHash))return;let n=ne(e,{type:`file`,opt:!1,options:k?.accept?{accept:k.accept}:void 0},t);if(n.status===`error`){w(n.error);return}let{ref:r,isRemote:i}=n,a=[{op:`add`,path:[...c,r],value:{mimeType:t.mimeType}},{op:`file`,path:[...c,r],filePath:r,value:e.src,metadata:t,remote:i}];S(!0),await l(a,`file`,e=>w(e),D)}).catch(()=>w(`Could not upload file. Please try again.`)).finally(()=>{S(!1),E(null)}),e.target.value=``},[A,j,c,l,P,F,h,k,m,N,L]),ie=b.useCallback(e=>{if(e.preventDefault(),_.current=0,y(!1),P&&(!F||!h)){w(L?`Preparing remote uploads - try again in a moment.`:`Remote uploads are not available. Please try again later.`);return}let t=Array.from(e.dataTransfer.files).filter(e=>!M||M.split(`,`).map(e=>e.trim()).some(t=>t.endsWith(`/*`)?e.type.startsWith(t.slice(0,-1)):e.type===t));t.length!==0&&(w(null),S(!0),(async()=>{for(let e of t)if(A){let t=await gA(e,N).catch(()=>null);if(!t||!t.width||!t.height||!t.mimeType)continue;let n={width:t.width,height:t.height,mimeType:t.mimeType},r=ne(t,{type:`image`,opt:!1,options:k?.accept?{accept:k.accept}:void 0},n);if(r.status===`error`){w(r.error);continue}let{ref:i,isRemote:a}=r,o=[{op:`add`,path:[...c,i],value:{width:n.width,height:n.height,mimeType:n.mimeType,alt:null}},{op:`file`,path:[...c,i],filePath:i,value:t.src,metadata:n,remote:a}];await l(o,`image`,e=>w(e),D)}else{let t=await vA(e).catch(()=>null);if(!t||!t.mimeType)continue;let n={mimeType:t.mimeType},r=ne(t,{type:`file`,opt:!1,options:k?.accept?{accept:k.accept}:void 0},n);if(r.status===`error`){w(r.error);continue}let{ref:i,isRemote:a}=r,o=[{op:`add`,path:[...c,i],value:{mimeType:n.mimeType}},{op:`file`,path:[...c,i],filePath:i,value:t.src,metadata:n,remote:a}];await l(o,`file`,e=>w(e),D)}})().finally(()=>{S(!1),E(null)}))},[A,c,l,P,F,h,M,k,ne,D,N,L]),ae=b.useMemo(()=>{if(!t)return null;let[,e]=H.splitModuleFilePathAndModulePath(t),n=H.splitModulePath(e)[0];return typeof n==`string`?n:null},[t]);return i.status===`success`?(0,Y.jsxs)(`div`,{id:e,onDragEnter:e=>{e.preventDefault(),_.current++,y(!0)},onDragLeave:()=>{_.current--,_.current===0&&y(!1)},onDragOver:e=>e.preventDefault(),onDrop:ie,children:[C&&(0,Y.jsx)(`div`,{className:`mb-2 rounded p-3 bg-bg-error-primary text-fg-error-primary text-sm`,children:C}),T===null?(0,Y.jsx)(`div`,{className:`h-[2px] mb-2`}):(0,Y.jsx)($Y,{className:`h-[2px] mb-2 transition-opacity duration-300 z-[1000]`,style:{opacity:1},value:T??0}),(0,Y.jsx)(`input`,{ref:g,type:`file`,hidden:!0,accept:M,onChange:re}),(0,Y.jsx)(TRe,{files:R,parentPath:r,imageMode:A,onAltTextChange:A&&!n?te:void 0,onFileDelete:n?void 0:ee,onUploadClick:n?void 0:()=>g.current?.click(),uploadDisabled:!I,uploading:x,defaultOpenFileRef:ae??void 0,isDraggingOver:v})]}):(0,Y.jsx)(jC,{path:e,type:`record`})}function cX(e,t){for(let n in t)if(n.startsWith(e))return!0;return!1}function lX(){return(0,Y.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bg-error-secondary`})}function uX({error:e}){return(0,Y.jsx)(`div`,{className:`p-4 text-fg-error-primary bg-bg-error-primary`,children:(0,Y.jsxs)(`div`,{children:[`Preview error: `,e]})})}function ARe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`record`,o=Fb()||{},s=Cb(e),c=xb(e),l=Ob(e,a);if(s.status===`error`)return(0,Y.jsx)(NC,{path:e,error:s.error,type:a});if(l.status===`error`)return(0,Y.jsx)(FC,{path:e,error:l.error,schema:s});if(l.status==`not-found`||s.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(s.status===`loading`||!(`data`in l)||l.data===void 0)return(0,Y.jsx)(jC,{path:e,type:a});if(s.data.type!==a)return(0,Y.jsx)(PC,{path:e,expectedType:a,actualType:s.data.type});if(s.data.mediaType)return(0,Y.jsx)(sX,{path:e});let u=l.data,d=s.data;if(r||xr(d.item)){let a=u;return a===null?null:(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(`div`,{className:`flex flex-col ${n?`gap-3`:`gap-4`}`,children:d.item.hidden?null:Object.entries(a).map(([e,a])=>(0,Y.jsx)(qk,{label:e,path:a,type:d.item.type,readonly:t||d.item.readonly,compact:n,errorDisplay:i,children:(0,Y.jsx)(a6,{path:a,schema:d.item,readonly:t||d.item.readonly,compact:n,inline:r,errorDisplay:i})},a))})})}let f=c&&`data`in c&&c.data&&c.data.parent===`record`?c.data:void 0;return(0,Y.jsxs)(`div`,{id:e,children:[c?.status===`error`&&(0,Y.jsx)(uX,{error:c.message,path:e}),f&&u&&(0,Y.jsx)(PRe,{path:e,keys:Object.keys(u),jsonValues:d.jsonValues===!0}),!f&&u&&(0,Y.jsx)(NRe,{path:e,keys:Object.keys(u),jsonValues:d.jsonValues===!0,validationErrors:o})]})}var jRe=146,MRe=74,dX=56;function NRe({path:e,keys:t,jsonValues:n,validationErrors:r}){let{navigate:i}=GC(),a=nb(),[o]=H.splitModuleFilePathAndModulePath(e),{unloadedKeys:s,errorByKey:c}=fX(o,n);return(0,Y.jsx)(zY,{moduleFilePath:o,keys:t,estimatedRowHeight:jRe,jsonValues:n,className:`grid grid-cols-1`,renderRow:t=>{let n=c.get(t);return n===void 0?(0,Y.jsx)(`div`,{className:`pb-4`,children:(0,Y.jsxs)(`div`,{onClick:()=>i(sD(e,t)),className:(0,AC.default)(`bg-primary-foreground cursor-pointer min-w-[320px] max-h-[170px] overflow-hidden rounded-md border border-border-primary p-4`,`hover:bg-bg-secondary-hover`),children:[(0,Y.jsxs)(`div`,{className:`flex justify-between items-start`,children:[(0,Y.jsx)(`div`,{className:`pb-4 font-semibold text-md`,children:t}),cX(sD(e,t),r)&&(0,Y.jsx)(lX,{})]}),(0,Y.jsx)(`div`,{children:s.has(t)?(0,Y.jsx)(BY,{path:sD(e,t),height:dX}):(0,Y.jsx)(X3,{path:sD(e,t)})})]})}):(0,Y.jsx)(`div`,{className:`pb-4`,children:(0,Y.jsx)(VY,{path:sD(e,t),label:t,message:n,height:96,onRetry:()=>void a?.system.sourceStore.retryEntry(o,t)})})}})}function fX(e,t){let n=nb(),r=Ab(e),i=`data`in r?r.data:void 0;return(0,b.useMemo)(()=>{let r=new Set,a=new Map;if(!t||typeof i!=`object`||!i||Array.isArray(i))return{unloadedKeys:r,errorByKey:a};for(let[t,o]of Object.entries(i)){if(!H.isJson(o))continue;let i=n?.system.sourceStore.entryError(e,t);i===void 0?r.add(t):a.set(t,i)}return{unloadedKeys:r,errorByKey:a}},[t,i,n,e])}function PRe({path:e,keys:t,jsonValues:n}){let{navigate:r}=GC(),i=nb(),[a]=H.splitModuleFilePathAndModulePath(e),{unloadedKeys:o,errorByKey:s}=fX(a,n);return(0,Y.jsx)(zY,{moduleFilePath:a,keys:t,estimatedRowHeight:MRe,jsonValues:n,className:`flex flex-col w-full`,renderRow:t=>{let n=s.get(t);return n===void 0?(0,Y.jsx)(`div`,{className:`pb-4`,children:(0,Y.jsx)(`button`,{onClick:()=>r(sD(e,t)),className:(0,AC.default)(`w-full hover:bg-bg-secondary-hover`,`border rounded-lg cursor-pointer border-border-primary`),children:o.has(t)?(0,Y.jsx)(BY,{path:sD(e,t),height:dX}):(0,Y.jsx)(X3,{path:sD(e,t)})})}):(0,Y.jsx)(`div`,{className:`pb-4`,children:(0,Y.jsx)(VY,{path:sD(e,t),label:t,message:n,height:72,onRetry:()=>void i?.system.sourceStore.retryEntry(a,t)})})}})}function FRe({path:e,size:t}){let n=Ob(e,`record`);if(n.status===`error`)return(0,Y.jsx)(FC,{path:e,error:n.error});if(!(`data`in n)||n.data===void 0)return(0,Y.jsx)(J3,{path:e});if(n.data===null)return(0,Y.jsx)(Y3,{path:e});let r=Object.keys(n.data);return(0,Y.jsxs)(`div`,{className:`text-left ${t===`compact`?`max-h-[60px] overflow-hidden`:``}`,children:[(0,Y.jsx)(`span`,{className:`text-fg-brand-primary`,children:r.length}),(0,Y.jsx)(`span`,{className:`mr-1`,children:` item${r.length===1?``:`s`}:`}),r.map((e,t)=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-fg-brand-primary`,children:e},e),t<r.length-1?`, `:``]}))]})}function pX(e){this.content=e}pX.prototype={constructor:pX,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new pX(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new pX(n)},addToStart:function(e,t){return new pX([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new pX(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new pX(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=pX.from(e),e.size?new pX(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=pX.from(e),e.size?new pX(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=pX.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},pX.from=function(e){if(e instanceof pX)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new pX(t)};function mX(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&_X(e.charCodeAt(r-1))&&gX(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=mX(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function hX(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&_X(e.charCodeAt(i-1))&&gX(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=hX(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function gX(e){return e>=56320&&e<57344}function _X(e){return e>=55296&&e<56320}var vX=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return mX(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return hX(this,e,t,n)}findIndex(e){if(e==0)return bX(0,e);if(e==this.size)return bX(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?bX(t+1,i):bX(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};vX.empty=new vX([],0);var yX={index:0,offset:0};function bX(e,t){return yX.index=e,yX.offset=t,yX}function xX(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!xX(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!xX(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var SX=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&xX(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};SX.none=[];var CX=class extends Error{},wX=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=EX(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(TX(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(vX.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};wX.empty=new wX(vX.empty,0,0);function TX(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(TX(a.content,t-i-1,n-i-1)))}function EX(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=EX(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function IRe(e,t,n){if(n.openStart>e.depth)throw new CX(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new CX(`Inconsistent open depths`);return DX(e,t,n,0)}function DX(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=DX(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}if(!n.content.size)return MX(a,PX(e,t,r));if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return MX(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}{let{start:i,end:o}=LRe(n,e);return MX(a,NX(e,i,o,t,r))}}function OX(e,t){if(!t.type.compatibleContent(e.type))throw new CX(`Cannot join `+t.type.name+` onto `+e.type.name)}function kX(e,t,n){let r=e.node(n);return OX(r,t.node(n)),r}function AX(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function jX(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(AX(e.nodeAfter,r),a++));for(let e=a;e<o;e++)AX(i.child(e),r);t&&t.depth==n&&t.textOffset&&AX(t.nodeBefore,r)}function MX(e,t){if(!e.type.validContent(t))throw new CX(`Invalid content for node `+e.type.name);return e.copy(t)}function NX(e,t,n,r,i){let a=e.depth>i&&kX(e,t,i+1),o=r.depth>i&&kX(n,r,i+1),s=[];return jX(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(OX(a,o),AX(MX(a,NX(e,t,n,r,i+1)),s)):(a&&AX(MX(a,PX(e,t,i+1)),s),jX(t,n,i,s),o&&AX(MX(o,PX(n,r,i+1)),s)),jX(r,null,i,s),new vX(s)}function PX(e,t,n){let r=[];return jX(null,e,n,r),e.depth>n&&AX(MX(kX(e,t,n+1),PX(e,t,n+1)),r),jX(t,null,n,r),new vX(r)}function LRe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(vX.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var FX=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return SX.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new LX(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=IX.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else IX.set(t,r=new RRe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%zRe,i}},RRe=class{constructor(){this.elts=[],this.i=0}},zRe=12,IX=new WeakMap,LX=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},BRe=Object.create(null),RX=class e{constructor(e,t,n,r=SX.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||vX.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&xX(this.attrs,t||e.defaultAttrs||BRe)&&SX.sameSet(this.marks,n||SX.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return wX.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new wX(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return IRe(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return FX.resolveCached(this,e)}resolveNoCache(e){return FX.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),zX(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=vX.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=SX.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!SX.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=vX.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};RX.prototype.text=void 0;var VRe=class e extends RX{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):zX(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function zX(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var BX=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new HRe(t,n);if(r.next==null)return e.empty;let i=VX(r);r.next&&r.err(`Unexpected trailing text`);let a=YRe(JRe(i));return XRe(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return vX.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
206
206
|
`)}};BX.empty=new BX(!0);var HRe=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function VX(e){let t=[];do t.push(URe(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function URe(e){let t=[];do t.push(WRe(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function WRe(e){let t=qRe(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=GRe(e,t);else break;return t}function HX(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function GRe(e,t){let n=HX(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:HX(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function KRe(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function qRe(e){if(e.eat(`(`)){let t=VX(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=KRe(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function JRe(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function UX(e,t){return t-e}function WX(e,t){let n=[];return r(t),n.sort(UX);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function YRe(e){let t=Object.create(null);return n(WX(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);WX(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new BX(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(UX);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function XRe(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function GX(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function KX(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function qX(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function JX(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new QRe(e,r,t[r]);return n}var YX=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=JX(e,n.attrs),this.defaultAttrs=GX(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==BX.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:KX(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new RX(this,this.computeAttrs(e),vX.from(t),SX.setFrom(n))}createChecked(e=null,t,n){return t=vX.from(t),this.checkContent(t),new RX(this,this.computeAttrs(e),t,SX.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=vX.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(vX.empty,!0);return i?new RX(this,e,t.append(i),SX.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){qX(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:SX.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function ZRe(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var QRe=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?ZRe(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},XX=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=JX(e,r.attrs),this.excluded=null;let i=GX(this.attrs);this.instance=i?new SX(this,i):null}create(e=null){return!e&&this.instance?this.instance:new SX(this,KX(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){qX(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},ZX=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=pX.from(e.nodes),t.marks=pX.from(e.marks||{}),this.nodes=YX.compile(this.spec.nodes,this),this.marks=XX.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=BX.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?QX(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:QX(this,n.split(` `))}this.nodeFromJSON=e=>RX.fromJSON(this,e),this.markFromJSON=e=>SX.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof YX))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new VRe(n,n.defaultAttrs,e,SX.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function QX(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function $Re(e){return e.tag!=null}function eze(e){return e.style!=null}var $X=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if($Re(e))this.tags.push(e);else if(eze(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new sZ(this,t,!1);return n.addAll(e,SX.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new sZ(this,t,!0);return n.addAll(e,SX.none,t.from,t.to),wX.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(rze(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=cZ(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=cZ(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},eZ={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},tze={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},tZ={ol:!0,ul:!0},nZ=1,rZ=2,iZ=4;function aZ(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?nZ:0)|(t===`full`?rZ:0)}var oZ=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=SX.none,this.match=i||(a&iZ?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(vX.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&nZ)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=vX.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(vX.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!eZ.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},sZ=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=aZ(null,t.preserveWhitespace,0)|(n?iZ:0);i=r?new oZ(r.type,r.attrs,SX.none,!0,t.topMatch||r.type.contentMatch,a):n?new oZ(null,null,SX.none,!0,null,a):new oZ(e.schema.topNodeType,null,SX.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&rZ?`full`:this.localPreserveWS||(r.options&nZ)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
207
207
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;tZ.hasOwnProperty(a)&&this.parser.normalizeLists&&nze(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:tze.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(eZ.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
208
208
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=SX.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):lZ(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=aZ(e,i,a.options);a.options&iZ&&a.content.length==0&&(o|=iZ);let s=SX.none;return n=n.filter(t=>!(a.type?a.type.allowsMarkType(t.type):lZ(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new oZ(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=nZ);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function nze(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&tZ.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function rze(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function cZ(e){let t={};for(let n in e)t[n]=e[n];return t}function lZ(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var uZ=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=fZ(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return fZ(t).createTextNode(e.text);let{dom:n,contentDOM:r}=mZ(fZ(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&mZ(fZ(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:mZ(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=dZ(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return dZ(e.marks)}};function dZ(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function fZ(e){return e.document||window.document}var pZ=new WeakMap;function ize(e){let t=pZ.get(e);return t===void 0&&pZ.set(e,t=aze(e)),t}function aze(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t])}else for(let t in e)n(e[t])}}return n(e),t}function mZ(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=ize(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=mZ(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var hZ=65535,gZ=2**16;function oze(e,t){return e+t*gZ}function _Z(e){return e&hZ}function sze(e){return(e-(e&hZ))/gZ}var cze=1,lze=2,vZ=4,yZ=8,bZ=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&yZ)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&vZ)>0}},xZ=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=_Z(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+sze(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:oze(o/3,e-s),f=e==s?lze:e==u?cze:vZ;return(t<0?e!=s:e!=u)&&(f|=yZ),new bZ(a,f,d)}r+=l-c}return n?e+r:new bZ(e+r,0,null)}touches(e,t){let n=0,r=_Z(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};xZ.empty=new xZ([]);var SZ=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new bZ(e,r,null)}},CZ=Object.create(null),wZ=class{getMap(){return xZ.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=CZ[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in CZ)throw RangeError(`Duplicate use of step JSON ID `+e);return CZ[e]=t,t.prototype.jsonID=e,t}},TZ=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof CX)return e.fail(t.message);throw t}}};function EZ(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(EZ(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return vX.fromArray(r)}var DZ=class e extends wZ{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new wX(EZ(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return TZ.fromReplace(e,this.from,this.to,i)}invert(){return new OZ(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};wZ.jsonID(`addMark`,DZ);var OZ=class e extends wZ{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new wX(EZ(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return TZ.fromReplace(e,this.from,this.to,n)}invert(){return new DZ(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};wZ.jsonID(`removeMark`,OZ);var kZ=class e extends wZ{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return TZ.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return TZ.fromReplace(e,this.pos,this.pos+1,new wX(vX.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new AZ(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};wZ.jsonID(`addNodeMark`,kZ);var AZ=class e extends wZ{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return TZ.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return TZ.fromReplace(e,this.pos,this.pos+1,new wX(vX.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new kZ(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};wZ.jsonID(`removeNodeMark`,AZ);var jZ=class e extends wZ{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&NZ(e,this.from,this.to)?TZ.fail(`Structure replace would overwrite content`):TZ.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xZ([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?wX.empty:new wX(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?wX.empty:new wX(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,wX.fromJSON(t,n.slice),!!n.structure)}};jZ.MAP_BIAS=1,wZ.jsonID(`replace`,jZ);var MZ=class e extends wZ{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(NZ(e,this.from,this.gapFrom)||NZ(e,this.gapTo,this.to)))return TZ.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return TZ.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?TZ.fromReplace(e,this.from,this.to,n):TZ.fail(`Content does not fit in gap`)}getMap(){return new xZ([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,wX.fromJSON(t,n.slice),n.insert,!!n.structure)}};wZ.jsonID(`replaceAround`,MZ);function NZ(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function uze(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new OZ(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new DZ(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function dze(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof XX){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new OZ(t.from,t.to,t.style)))}function PZ(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new jZ(s,l,wX.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new OZ(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new wX(vX.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new jZ(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(vX.empty,!0);e.replace(s,s,new wX(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function fze(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function FZ(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!fze(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function pze(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=vX.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=vX.from(r.node(e).copy(u)),d++):c--;let f=vX.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=vX.from(i.node(e).copy(f)),p++):l++;e.step(new MZ(c,l,o,s,new wX(u.append(f),d,p),u.size-d,!0))}function IZ(e,t,n=null,r=e){let i=mze(e,t),a=i&&hze(r,t);return a?i.map(LZ).concat({type:t,attrs:n}).concat(a.map(LZ)):null}function LZ(e){return{type:e,attrs:null}}function mze(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function hze(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function gze(e,t,n){let r=vX.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=vX.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new MZ(i,a,i,a,new wX(r,0,0),n.length,!0))}function _ze(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&vze(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&zZ(e,t,n,a),PZ(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new MZ(c,l,c+1,l-1,new wX(vX.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&RZ(e,t,n,a),!1}})}function RZ(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function zZ(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
@@ -212,17 +212,17 @@ Defaulting to \`null\`.`}HY(ZY,`getInvalidValueError`);var QY=mRe,_Re=gRe,$Y=b.f
|
|
|
212
212
|
`),slice:t}}function o1(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new wX(vX.from(e.state.schema.text(t.replace(/\r\n?/g,`
|
|
213
213
|
`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=uZ.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=DBe(n),ZQ&&OBe(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||$X.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!wBe.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=kBe(d1(s,+u[1],+u[2]),u[4]);else if(s=wX.maxOpen(TBe(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=d1(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var wBe=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function TBe(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&c1(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=l1(a[a.length-1],i.length));let n=s1(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return vX.from(a)}return e}function s1(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,vX.from(e));return e}function c1(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=c1(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(vX.from(s1(n,e,i+1))))}}function l1(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,l1(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(vX.empty,!0);return e.copy(n.append(r))}function u1(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=u1(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(vX.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function d1(e,t,n){return t<e.openStart&&(e=new wX(u1(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new wX(u1(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var f1={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]};function p1(){return document.implementation.createHTMLDocument(`title`)}var m1=null;function EBe(e){let t=window.trustedTypes;if(!t)return e;if(!m1){if(m1=t.defaultPolicy)try{return m1.createHTML(e)}catch{}m1=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return m1.createHTML(e)}function DBe(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=p1(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&f1[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=EBe(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function OBe(e){let t=e.querySelectorAll(WQ?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function kBe(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{t.checkAttrs(r[e+1])}catch{break}i=vX.from(t.create(r[e+1],i)),a++,o++}return new wX(i,a,o)}var h1={},g1={},ABe={touchstart:!0,touchmove:!0},jBe=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function MBe(e){for(let t in h1){let n=h1[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{PBe(e,t)&&!y1(e,t)&&(e.editable||!(t.type in g1))&&n(e,t)},ABe[t]?{passive:!0}:void 0)}KQ&&e.dom.addEventListener(`input`,()=>null),v1(e)}function _1(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function NBe(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function v1(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>y1(e,t))})}function y1(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function PBe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function FBe(e,t){!y1(e,t)&&h1[t.type]&&(e.editable||!(t.type in g1))&&h1[t.type](e,t)}g1.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!D1(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(XQ&&WQ&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),qQ&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,NQ(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||CBe(e,n)?n.preventDefault():_1(e,`key`)}},g1.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},g1.keypress=(e,t)=>{let n=t;if(D1(e)||!n.charCode||n.ctrlKey&&!n.altKey||JQ&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof oQ)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function b1(e){return{left:e.clientX,top:e.clientY}}function IBe(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function x1(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function S1(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function LBe(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&cQ.isSelectable(r)?(S1(e,new cQ(n),`pointer`),!0):!1}function RBe(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof cQ&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(cQ.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(S1(e,cQ.create(e.state.doc,i),`pointer`),!0)}function zBe(e,t,n,r,i){return x1(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?RBe(e,n):LBe(e,n))}function BBe(e,t,n,r){return x1(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function VBe(e,t,n,r){return x1(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||HBe(e,n,r)}function HBe(e,t,n){if(n.button!=0)return!1;let r=C1(e,t,!0),i=e.state.doc;return r?(S1(e,r,`pointer`),r instanceof oQ&&i.eq(e.state.doc)&&(e.input.mouseDown=new WBe(e,r)),!0):!1}function C1(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?oQ.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return oQ.create(r,a+1,a+1+t.content.size);if(n&&cQ.isSelectable(t))return cQ.create(r,a)}return null}function w1(e){return A1(e)}var T1=JQ?`metaKey`:`ctrlKey`;h1.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=w1(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&IBe(n,e.input.lastClick)&&!n[T1]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(b1(n));o&&(a==`singleClick`?e.input.mouseDown=new UBe(e,o,n,!!r):(a==`doubleClick`?BBe:VBe)(e,o.pos,o.inside,n)?n.preventDefault():_1(e,`pointer`))};var E1=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},UBe=class extends E1{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[T1],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof cQ&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&HQ&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),_1(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||L$(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(b1(e))),this.updateAllowDefault(e),this.allowDefault||!t?_1(this.view,`pointer`):zBe(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||KQ&&this.mightDrag&&!this.mightDrag.node.isAtom||WQ&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(S1(this.view,nQ.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):_1(this.view,`pointer`)}move(e){this.updateAllowDefault(e),_1(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},WBe=class extends E1{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),_1(this.view,`pointer`);let t=this.view.posAtCoords(b1(e)),n=t&&C1(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from<i.from?[i.to,n.from]:[i.from,n.to];S1(this.view,oQ.create(r,a,o),`pointer`)}};h1.touchstart=e=>{e.input.lastTouch=Date.now(),w1(e),_1(e,`pointer`)},h1.touchmove=e=>{e.input.lastTouch=Date.now(),_1(e,`pointer`)},h1.contextmenu=e=>w1(e);function D1(e,t){return e.composing?!0:KQ&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var GBe=XQ?5e3:-1;g1.compositionstart=g1.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof oQ&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||WQ&&YQ&&KBe(e)))e.markCursor=e.state.storedMarks||n.marks(),A1(e,!0),e.markCursor=null;else if(A1(e,!t.selection.empty),HQ&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}O1(e,GBe)};function KBe(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}g1.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,O1(e,20))};function O1(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>A1(e),t))}function k1(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function qBe(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Rze(t.focusNode,t.focusOffset),r=zze(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function A1(e,t=!1){if(!(XQ&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),k1(e),t||e.docView&&e.docView.dirty){let n=F$(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function JBe(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var j1=BQ&&VQ<15||qQ&&Uze<604;h1.copy=g1.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=j1?null:n.clipboardData,{dom:o,text:s}=a1(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):JBe(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function YBe(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function XBe(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?M1(e,r.value,null,i,t):M1(e,r.textContent,r.innerHTML,i,t)},50)}function M1(e,t,n,r,i){let a=o1(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||wX.empty)))return!0;if(!a)return!1;let o=YBe(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function N1(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}g1.paste=(e,t)=>{let n=t;if(e.composing&&!XQ)return;let r=j1?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&M1(e,N1(r),r.getData(`text/html`),i,n)?n.preventDefault():XBe(e,n)};var P1=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},ZBe=JQ?`altKey`:`ctrlKey`;function F1(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[ZBe]:!n}h1.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(b1(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof cQ?i.to-1:i.to))){if(r&&r.mightDrag)o=cQ.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=cQ.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=a1(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!WQ||GQ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(j1?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,j1||n.dataTransfer.setData(`text/plain`,c),e.dragging=new P1(l,F1(e,n),o)},h1.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},g1.dragover=g1.dragenter=(e,t)=>t.preventDefault(),g1.drop=(e,t)=>{try{QBe(e,t,e.dragging)}finally{e.dragging=null}};function QBe(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(b1(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=o1(e,N1(t.dataTransfer),j1?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&F1(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||wX.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?HZ(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&cQ.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new cQ(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(W$(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}h1.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&L$(e)},20))},h1.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},h1.beforeinput=(e,t)=>{if(XQ&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,NQ(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in g1)h1[e]=g1[e];function I1(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var L1=class e{constructor(e,t){this.toDOM=e,this.spec=t||V1,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new z1(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&I1(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},R1=class e{constructor(e,t){this.attrs=e,this.spec=t||V1}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new z1(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&I1(this.attrs,t.attrs)&&I1(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},$Be=class e{constructor(e,t){this.attrs=e,this.spec=t||V1}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new z1(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&I1(this.attrs,t.attrs)&&I1(this.spec,t.spec)}destroy(){}},z1=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new L1(n,r))}static inline(t,n,r,i){return new e(t,n,new R1(r,i))}static node(t,n,r,i){return new e(t,n,new $Be(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof R1}get widget(){return this.type instanceof L1}},B1=[],V1={},H1=class e{constructor(e,t){this.local=e.length?e:B1,this.children=t.length?t:B1}static create(e,t){return t.length?J1(t,e,0,V1):U1}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==U1||e.maps.length==0?this:this.mapInner(e,t,0,0,n||V1)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?eVe(this.children,o||[],t,n,r,i,a):o?new e(o.sort(Y1),B1):U1}add(t,n){return n.length?this==U1?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=K1(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,J1(s,e,o+1,V1)),a+=3}});let o=G1(a?q1(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(Y1):this.local,i||this.children)}remove(e){return e.length==0||this==U1?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==U1?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):U1}forChild(t,n){if(this==U1)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof R1){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(Y1),B1);return r?new W1([t,r]):t}return r||U1}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return X1(this.localsInner(e))}localsInner(e){if(this==U1)return B1;if(e.inlineContent||!this.local.some(R1.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof R1||t.push(this.local[e]);return t}forEachSet(e){e(this)}};H1.empty=new H1([],[]),H1.removeOverlap=X1;var U1=H1.empty,W1=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,V1));return e.from(r)}forChild(t,n){if(n.isLeaf)return H1.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=U1&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length){if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}}return t?X1(n?t:t.sort(Y1)):B1}static from(t){switch(t.length){case 0:return U1;case 1:return t[0];default:return new e(t.every(e=>e instanceof H1)?t:t.reduce((e,t)=>e.concat(t instanceof H1?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function eVe(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==U1?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=J1(tVe(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new H1(t.sort(Y1),s)}function G1(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new z1(i.from+t,i.to+t,i.type))}return n}function tVe(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function K1(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function q1(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function J1(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=K1(e,t,o+n);if(s){a=!0;let e=J1(s,t,n+o+1,r);e!=U1&&i.push(o,o+t.nodeSize,e)}});let o=G1(a?q1(e):e,-n).sort(Y1);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new H1(o,i):U1}function Y1(e,t){return e.from-t.from||e.to-t.to}function X1(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),Z1(t,i+1,a.copy(r.to,a.to)));continue}a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),Z1(t,i,r.copy(a.from,r.to)));break}}return t}function Z1(e,t,n){for(;t<e.length&&Y1(n,e[t])>0;)t++;e.splice(t,0,n)}function Q1(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=U1&&t.push(r)}),e.cursorWrapper&&t.push(H1.create(e.state.doc,[e.cursorWrapper.deco])),W1.from(t)}var nVe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rVe=BQ&&VQ<=11,iVe=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},aVe=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new iVe,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);BQ&&VQ<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():KQ&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),rVe&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,nVe)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(G$(this.view)){if(this.suppressingSelectionUpdates)return L$(this.view);if(BQ&&VQ<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&OQ(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=TQ(n))t.add(n);for(let r=e.anchorNode;r;r=TQ(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&G$(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||WQ&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&t.nodeType==1;){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(HQ&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||cVe(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&MQ(n)&&(c=F$(e))&&c.eq(nQ.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,L$(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),oVe(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,lVe(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||L$(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(BQ&&VQ<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?wQ(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?wQ(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}return e.type==`attributes`?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},$1=new WeakMap,e0=!1;function oVe(e){if(!$1.has(e)&&($1.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=HQ,e0)return;console.warn(`ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.`),e0=!0}}function t0(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return OQ(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function sVe(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return t0(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?t0(e,n):null}function cVe(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function lVe(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function uVe(e,t,n,r){let{node:i,fromOffset:a,toOffset:o,from:s,to:c}=e.docView.parseRange(t,n),l=e.domSelectionRange(),u,d=l.anchorNode;if(d&&e.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:l.anchorOffset}],MQ(l)||u.push({node:l.focusNode,offset:l.focusOffset})),WQ&&e.input.lastKeyCode===8)for(let e=o;e>a;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||$X.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:dVe(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var dVe=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(KQ&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||KQ&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},fVe=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function pVe(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=F$(e,t);if(n&&!e.state.selection.eq(n)){if(WQ&&XQ&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,NQ(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=uVe(e,t,n,i),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=gVe(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(qQ&&e.input.lastIOSEnter>Date.now()-225||XQ)&&i.some(e=>e.nodeType==1&&!fVe.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,NQ(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof oQ&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=n0(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof oQ&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),BQ&&VQ<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((qQ&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,NQ(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&hVe(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,NQ(8,`Backspace`)))){XQ&&WQ&&e.domObserver.suppressSelectionUpdates();return}WQ&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),XQ&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,NQ(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=n0(e,n.doc,l.sel);t&&!(WQ&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==y||t.head==n.mapping.map(b)-1)||BQ&&t.empty&&t.head==y)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},S;if(v){if(h.pos==g.pos){BQ&&VQ<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>L$(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=mVe(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function n0(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:W$(e,t.resolve(n.anchor),t.resolve(n.head))}function mVe(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(vX.from(l).eq(e))return{mark:s,type:o}}function hVe(e,t,n,r,i){if(n-t<=i.pos-r.pos||r0(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(r0(a,!0,!0));return!o.parent.isTextblock||o.pos>n||r0(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function r0(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function gVe(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c<a&&o<s){let e=r<=a&&r>=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l<a){let e=r<=a&&r>=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var i0=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new jBe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(l0),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=s0(this),o0(this),this.nodeViews=c0(this),this.docView=C$(this.state.doc,a0(this),Q1(this),this.dom,this),this.domObserver=new aVe(this,(e,t,n,r)=>pVe(this,e,t,n,r)),this.domObserver.start(),MBe(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&v1(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(l0),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(k1(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=c0(this);vVe(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&v1(this),this.editable=s0(this),o0(this);let o=Q1(this),s=a0(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&Kze(this);if(i){this.domObserver.stop();let t=l&&(BQ||WQ)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&_Ve(n.selection,e.selection);if(l){let n=WQ?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qBe(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=C$(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&gBe(this)&&i.delaySelUpdate())?L$(this,t):(H$(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&qze(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof cQ){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&$Q(this,t.getBoundingClientRect(),e)}else $Q(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new P1(e.slice,e.move,r<0?void 0:cQ.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(BQ){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Jze(this.dom),L$(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return $ze(this,e)}coordsAtPos(e,t=1){return c$(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return iBe(this,t||this.state,e)}pasteHTML(e,t){return M1(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return M1(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return a1(this,e)}destroy(){this.docView&&(NBe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Q1(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ize())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return FBe(this,e)}domSelectionRange(){let e=this.domSelection();return e?KQ&&this.root.nodeType===11&&Vze(this.dom.ownerDocument)==this.dom&&sVe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};i0.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function a0(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[z1.node(0,e.state.doc.content.size,t)]}function o0(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:z1.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function s0(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function _Ve(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function c0(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function vVe(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function l0(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}var u0=200,d0=function(){};d0.prototype.append=function(e){return e.length?(e=d0.from(e),!this.length&&e||e.length<u0&&this.leafAppend(e)||this.length<u0&&e.leafPrepend(this)||this.appendInner(e)):this},d0.prototype.prepend=function(e){return e.length?d0.from(e).append(this):this},d0.prototype.appendInner=function(e){return new yVe(this,e)},d0.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?d0.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},d0.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},d0.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},d0.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},d0.from=function(e){return e instanceof d0?e:e&&e.length?new f0(e):d0.empty};var f0=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=u0)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=u0)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(d0);d0.empty=new f0([]);var yVe=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(d0),bVe=500,p0=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new m0(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new m0(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new m0(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>SVe&&(s=xVe(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new SZ;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new m0(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new m0(i,o,l))}else r.push(new m0(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new m0(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>bVe&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new m0(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(d0.from(i.reverse()),a)}};p0.empty=new p0(d0.empty,0);function xVe(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var m0=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},h0=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},SVe=20;function CVe(e,t,n,r){let i=n.getMeta(x0),a;if(i)return i.historyState;n.getMeta(EVe)&&(e=new h0(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(x0))return o.getMeta(x0).redo?new h0(e.done.addTransform(n,void 0,r,b0(t)),e.undone,g0(n.mapping.maps),e.prevTime,e.prevComposition):new h0(e.done,e.undone.addTransform(n,void 0,r,b0(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!wVe(n,e.prevRanges)),s=o?_0(e.prevRanges,n.mapping):g0(n.mapping.maps);return new h0(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,b0(t)),p0.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new h0(e.done.rebased(n,a),e.undone.rebased(n,a),_0(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new h0(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),_0(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function wVe(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function g0(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function _0(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function TVe(e,t,n){let r=b0(t),i=x0.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new h0(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(x0,{redo:n,historyState:c})}var v0=!1,y0=null;function b0(e){let t=e.plugins;if(y0!=t){v0=!1,y0=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){v0=!0;break}}return v0}var x0=new CQ(`history`),EVe=new CQ(`closeHistory`);function S0(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new bQ({key:x0,state:{init(){return new h0(p0.empty,p0.empty,null,0,-1)},apply(t,n,r){return CVe(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?w0:n==`historyRedo`?T0:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function C0(e,t){return(n,r)=>{let i=x0.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=TVe(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var w0=C0(!1,!0),T0=C0(!0,!0);function E0(e={}){return new bQ({view(t){return new DVe(t,e)}})}var DVe=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=HZ(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},OVe=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),kVe=typeof navigator<`u`&&/Win/.test(navigator.platform);function AVe(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))OVe?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function jVe(e){let t=Object.create(null);for(let n in e)t[AVe(n)]=e[n];return t}function D0(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function O0(e){return new bQ({props:{handleKeyDown:k0(e)}})}function k0(e){let t=jVe(e);return function(e,n){let r=oP(n),i,a=t[D0(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[D0(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(kVe&&n.ctrlKey&&n.altKey)&&(i=nP[n.keyCode])&&i!=r){let r=t[D0(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var A0=class e extends nQ{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):nQ.near(r)}content(){return wX.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new MVe(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!NVe(e)||!PVe(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!cQ.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};A0.prototype.visible=!1,A0.findFrom=A0.findGapCursorFrom,nQ.jsonID(`gapcursor`,A0);var MVe=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return A0.valid(t)?new A0(t):nQ.near(t)}};function j0(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function NVe(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||j0(e.type))return!0;if(e.inlineContent)return!1}}return!0}function PVe(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||j0(e.type))return!0;if(e.inlineContent)return!1}}return!0}function M0(){return new bQ({props:{decorations:RVe,createSelectionBetween(e,t,n){return t.pos==n.pos&&A0.valid(n)?new A0(n):null},handleClick:IVe,handleKeyDown:FVe,handleDOMEvents:{beforeinput:LVe}}})}var FVe=k0({ArrowLeft:N0(`horiz`,-1),ArrowRight:N0(`horiz`,1),ArrowUp:N0(`vert`,-1),ArrowDown:N0(`vert`,1)});function N0(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof oQ){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=A0.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new A0(c))),!0):!1}}function IVe(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!A0.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&cQ.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new A0(r))),!0)}function LVe(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof A0))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=vX.empty;for(let e=r.length-1;e>=0;e--)i=vX.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new wX(i,0,0));return a.setSelection(oQ.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function RVe(e){if(!(e.selection instanceof A0))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,H1.create(e.doc,[z1.widget(e.selection.head,t,{key:`gapcursor`})])}var zVe=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),BVe=Object.prototype.hasOwnProperty;function P0(e,t){return BVe.call(e,t)}function F0(e){if(Array.isArray(e)){for(var t=Array(e.length),n=0;n<t.length;n++)t[n]=``+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var i in e)P0(e,i)&&r.push(i);return r}function I0(e){switch(typeof e){case`object`:return JSON.parse(JSON.stringify(e));case`undefined`:return null;default:return e}}function L0(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function R0(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function z0(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function B0(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(B0(e[t]))return!0}else if(typeof e==`object`){for(var r=F0(e),i=r.length,a=0;a<i;a++)if(B0(e[r[a]]))return!0}}return!1}function V0(e,t){var n=[e];for(var r in t){var i=typeof t[r]==`object`?JSON.stringify(t[r],null,2):t[r];i!==void 0&&n.push(r+`: `+i)}return n.join(`
|
|
214
214
|
`)}var H0=function(e){zVe(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,V0(t,{name:n,index:r,operation:i,tree:a}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=a,Object.setPrototypeOf(s,o.prototype),s.message=V0(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),VVe=c({JsonPatchError:()=>U0,_areEquals:()=>X0,applyOperation:()=>K0,applyPatch:()=>q0,applyReducer:()=>WVe,deepClone:()=>HVe,getValueByPointer:()=>G0,validate:()=>Y0,validator:()=>J0}),U0=H0,HVe=I0,W0={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=G0(n,this.path);r&&=I0(r);var i=K0(n,{op:`remove`,path:this.from}).removed;return K0(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=G0(n,this.from);return K0(n,{op:`add`,path:this.path,value:I0(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:X0(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},UVe={add:function(e,t,n){return L0(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:W0.move,copy:W0.copy,test:W0.test,_get:W0._get};function G0(e,t){if(t==``)return e;var n={op:`_get`,path:t};return K0(e,n),n.value}function K0(e,t,n,r,i,a){if(n===void 0&&(n=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),a===void 0&&(a=0),n&&(typeof n==`function`?n(t,0,e,t.path):J0(t,0)),t.path===``){var o={newDocument:e};if(t.op===`add`)return o.newDocument=t.value,o;if(t.op===`replace`)return o.newDocument=t.value,o.removed=e,o;if(t.op===`move`||t.op===`copy`)return o.newDocument=G0(e,t.from),t.op===`move`&&(o.removed=e),o;if(t.op===`test`){if(o.test=X0(e,t.value),o.test===!1)throw new U0(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o.newDocument=e,o}if(t.op===`remove`)return o.removed=e,o.newDocument=null,o;if(t.op===`_get`)return t.value=e,o;if(n)throw new U0("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,a,t,e);return o}r||(e=I0(e));var s=(t.path||``).split(`/`),c=e,l=1,u=s.length,d=void 0,f=void 0,p=void 0;for(p=typeof n==`function`?n:J0;;){if(f=s[l],f&&f.indexOf(`~`)!=-1&&(f=z0(f)),i&&(f==`__proto__`||f==`prototype`&&l>0&&s[l-1]==`constructor`))throw TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(c[f]===void 0?d=s.slice(0,l).join(`/`):l==u-1&&(d=t.path),d!==void 0&&p(t,0,e,d)),l++,Array.isArray(c)){if(f===`-`)f=c.length;else if(n&&!L0(f))throw new U0(`Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index`,`OPERATION_PATH_ILLEGAL_ARRAY_INDEX`,a,t,e);else L0(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new U0(`The specified index MUST NOT be greater than the number of elements in the array`,`OPERATION_VALUE_OUT_OF_BOUNDS`,a,t,e);var o=UVe[t.op].call(t,c,f,e);if(o.test===!1)throw new U0(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=W0[t.op].call(t,c,f,e);if(o.test===!1)throw new U0(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l<u&&(!c||typeof c!=`object`))throw new U0(`Cannot perform operation at the desired path`,`OPERATION_PATH_UNRESOLVABLE`,a,t,e)}}function q0(e,t,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(t))throw new U0(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);r||(e=I0(e));for(var a=Array(t.length),o=0,s=t.length;o<s;o++)a[o]=K0(e,t[o],n,!0,i,o),e=a[o].newDocument;return a.newDocument=e,a}function WVe(e,t,n){var r=K0(e,t);if(r.test===!1)throw new U0(`Test operation failed`,`TEST_OPERATION_FAILED`,n,t,e);return r.newDocument}function J0(e,t,n,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new U0(`Operation is not an object`,`OPERATION_NOT_AN_OBJECT`,t,e,n);if(!W0[e.op])throw new U0("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,t,e,n);if(typeof e.path!=`string`)throw new U0("Operation `path` property is not a string",`OPERATION_PATH_INVALID`,t,e,n);if(e.path.indexOf(`/`)!==0&&e.path.length>0)throw new U0('Operation `path` property must start with "/"',`OPERATION_PATH_INVALID`,t,e,n);if((e.op===`move`||e.op===`copy`)&&typeof e.from!=`string`)throw new U0("Operation `from` property is not present (applicable in `move` and `copy` operations)",`OPERATION_FROM_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&e.value===void 0)throw new U0("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&B0(e.value))throw new U0("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED`,t,e,n);if(n){if(e.op==`add`){var i=e.path.split(`/`).length,a=r.split(`/`).length;if(i!==a+1&&i!==a)throw new U0("Cannot perform an `add` operation at the desired path",`OPERATION_PATH_CANNOT_ADD`,t,e,n)}else if(e.op===`replace`||e.op===`remove`||e.op===`_get`){if(e.path!==r)throw new U0(`Cannot perform the operation at a path that does not exist`,`OPERATION_PATH_UNRESOLVABLE`,t,e,n)}else if(e.op===`move`||e.op===`copy`){var o=Y0([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new U0(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}function Y0(e,t,n){try{if(!Array.isArray(e))throw new U0(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)q0(I0(t),I0(e),n||!0);else{n||=J0;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(e){if(e instanceof U0)return e;throw e}}function X0(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){var n=Array.isArray(e),r=Array.isArray(t),i,a,o;if(n&&r){if(a=e.length,a!=t.length)return!1;for(i=a;i--!==0;)if(!X0(e[i],t[i]))return!1;return!0}if(n!=r)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(i=a;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=a;i--!==0;)if(o=s[i],!X0(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}var GVe=c({compare:()=>e2,generate:()=>Q0,observe:()=>QVe,unobserve:()=>ZVe}),Z0=new WeakMap,KVe=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),qVe=function(){function e(e,t){this.callback=e,this.observer=t}return e}();function JVe(e){return Z0.get(e)}function YVe(e,t){return e.observers.get(t)}function XVe(e,t){e.observers.delete(t.callback)}function ZVe(e,t){t.unobserve()}function QVe(e,t){var n=[],r,i=JVe(e);if(!i)i=new KVe(e),Z0.set(e,i);else{var a=YVe(i,t);r=a&&a.observer}if(r)return r;if(r={},i.value=I0(e),t){r.callback=t,r.next=null;var o=function(){Q0(r)},s=function(){clearTimeout(r.next),r.next=setTimeout(o)};typeof window<`u`&&(window.addEventListener(`mouseup`,s),window.addEventListener(`keyup`,s),window.addEventListener(`mousedown`,s),window.addEventListener(`keydown`,s),window.addEventListener(`change`,s))}return r.patches=n,r.object=e,r.unobserve=function(){Q0(r),clearTimeout(r.next),XVe(i,r),typeof window<`u`&&(window.removeEventListener(`mouseup`,s),window.removeEventListener(`keyup`,s),window.removeEventListener(`mousedown`,s),window.removeEventListener(`keydown`,s),window.removeEventListener(`change`,s))},i.observers.set(t,new qVe(t,r)),r}function Q0(e,t){t===void 0&&(t=!1);var n=Z0.get(e.object);$0(n.value,e.object,e.patches,``,t),e.patches.length&&q0(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function $0(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=F0(t),o=F0(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(P0(t,l)&&(t[l]!==void 0||u===void 0||Array.isArray(t)!==!1)){var d=t[l];typeof u==`object`&&u&&typeof d==`object`&&d&&Array.isArray(u)===Array.isArray(d)?$0(u,d,n,r+`/`+R0(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+R0(l),value:I0(u)}),n.push({op:`replace`,path:r+`/`+R0(l),value:I0(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+R0(l),value:I0(u)}),n.push({op:`remove`,path:r+`/`+R0(l)}),s=!0):(i&&n.push({op:`test`,path:r,value:e}),n.push({op:`replace`,path:r,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var l=a[c];!P0(e,l)&&t[l]!==void 0&&n.push({op:`add`,path:r+`/`+R0(l),value:I0(t[l])})}}}function e2(e,t,n){n===void 0&&(n=!1);var r=[];return $0(e,t,r,``,n),r}Object.assign({},VVe,GVe,{JsonPatchError:H0,deepClone:I0,escapePathComponent:R0,unescapePathComponent:z0});var $Ve=`custom_style_`;function eHe(e){return Object.entries(e).map(([e,t])=>`${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t}`).join(`; `)}function tHe(e,t){let n=new Map((t??[]).map(e=>[e.variant,e.label])),r={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}},text:{group:`inline`},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}},heading:{attrs:{level:{default:1}},content:`inline*`,group:`block`,defining:!0,parseDOM:[1,2,3,4,5,6].map(e=>({tag:`h${e}`,attrs:{level:e}})),toDOM(e){return[`h${e.attrs.level}`,0]}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return[`blockquote`,0]}},code_block:{content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`}],toDOM(){return[`pre`,[`code`,0]]}},list_item:{content:`paragraph block*`,parseDOM:[{tag:`li`}],toDOM(){return[`li`,0]},defining:!0},bullet_list:{content:`list_item+`,group:`block`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}},ordered_list:{attrs:{order:{default:1}},content:`list_item+`,group:`block`,parseDOM:[{tag:`ol`,getAttrs(e){let t=e;return{order:t.hasAttribute(`start`)?+(t.getAttribute(`start`)||1):1}}}],toDOM(e){return e.attrs.order===1?[`ol`,0]:[`ol`,{start:e.attrs.order},0]}},image:{inline:!0,attrs:{src:{},alt:{default:null},previewUrl:{default:null},width:{default:null},height:{default:null},mimeType:{default:null}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){let t=e;return{src:t.getAttribute(`src`),alt:t.getAttribute(`alt`)}}}],toDOM(e){return[`img`,{src:e.attrs.src,alt:e.attrs.alt}]}}};return e.button&&(r.button_atom={inline:!0,atom:!0,group:`inline`,attrs:{variant:{default:`default`}},parseDOM:[{tag:`button[data-variant][data-atom]`,getAttrs(e){return{variant:e.getAttribute(`data-variant`)}}}],toDOM(e){let t=e.attrs.variant,r=n.get(t)??t;return[`button`,{"data-variant":t,"data-atom":`true`,class:`inline-flex items-center rounded bg-bg-brand-secondary px-2 py-0.5 text-sm font-medium text-fg-brand-secondary cursor-default`,contenteditable:`false`},r]}},r.button_editable={inline:!0,content:`text*`,group:`inline`,attrs:{variant:{default:`default`},href:{default:null}},parseDOM:[{tag:`button[data-variant]:not([data-atom])`,getAttrs(e){let t=e;return{variant:t.getAttribute(`data-variant`),href:t.getAttribute(`data-href`)||null}}}],toDOM(e){let t={"data-variant":e.attrs.variant,class:`inline-flex items-center rounded bg-bg-brand-secondary px-2 py-0.5 text-sm font-medium text-fg-brand-secondary`};return e.attrs.href&&(t[`data-href`]=e.attrs.href),[`button`,t,0]}}),e.details&&(r.details_summary={content:`inline*`,defining:!0,parseDOM:[{tag:`summary`}],toDOM(){return[`summary`,0]}},r.details={attrs:{variant:{default:`details`}},content:`details_summary block+`,group:`block`,defining:!0,parseDOM:[{tag:`details`,getAttrs(e){return{variant:e.getAttribute(`data-variant`)||`details`}}}],toDOM(e){let t=e.attrs.variant,n={open:``};return t!==`details`&&(n[`data-variant`]=t),[`details`,n,0]}}),r}function nHe(e,t){let n={};if(n.bold={parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=bold`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return[`strong`,0]}},n.italic={parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`}],toDOM(){return[`em`,0]}},n.strikethrough={parseDOM:[{tag:`s`},{tag:`del`},{style:`text-decoration=line-through`}],toDOM(){return[`del`,0]}},n.code={parseDOM:[{tag:`code`}],toDOM(){return[`code`,0]}},n.link={attrs:{href:{}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`)||``}}}],toDOM(e){return[`a`,{href:e.attrs.href,rel:`noopener noreferrer`},0]}},t)for(let[e,r]of Object.entries(t)){let t=`${$Ve}${e}`,i=eHe(r.css);n[t]={parseDOM:[{tag:`span[data-style="${e}"]`}],toDOM(){return[`span`,{"data-style":e,style:i},0]}}}return n}function rHe(e={}){let t=`features`in e||`buttonVariants`in e||`detailsVariants`in e||`styleConfig`in e,n=t?e.features??{}:e,r=t?e.buttonVariants:void 0,i=t?e.styleConfig??n.styles:n.styles,a={bold:n.bold??!0,italic:n.italic??!0,strikethrough:n.strikethrough??!0,code:n.code??!0,link:n.link??!0,image:n.image??!0,h1:n.h1??!0,h2:n.h2??!0,h3:n.h3??!0,h4:n.h4??!0,h5:n.h5??!0,h6:n.h6??!0,bulletList:n.bulletList??!0,orderedList:n.orderedList??!0,blockquote:n.blockquote??!0,details:n.details??!1,codeBlock:n.codeBlock??!0,hardBreak:n.hardBreak??!0,button:n.button??!1,fixedToolbar:n.fixedToolbar??!0,floatingToolbar:n.floatingToolbar??!0,gutter:n.gutter??!0,styles:n.styles};return new ZX({nodes:tHe(a,r),marks:nHe(a,i)})}var iHe=`custom_style_`,aHe={bold:`bold`,italic:`italic`,"line-through":`strikethrough`,code:`code`};function t2(e,t){let n=aHe[e];if(n){let e=t.marks[n];return e?e.create():null}let r=`${iHe}${e}`,i=t.marks[r];return i?i.create():null}function n2(e,t){let n=e.map(e=>r2(e,t));return n.length===0&&n.push(t.node(`paragraph`)),t.node(`doc`,null,n)}function r2(e,t){switch(e.tag){case`p`:return t.node(`paragraph`,null,a2(e.children,t));case`h1`:case`h2`:case`h3`:case`h4`:case`h5`:case`h6`:{let n=parseInt(e.tag[1],10);return t.node(`heading`,{level:n},a2(e.children,t))}case`ul`:return t.node(`bullet_list`,null,e.children.map(e=>i2(e,t)));case`ol`:return t.node(`ordered_list`,null,e.children.map(e=>i2(e,t)));case`blockquote`:return t.node(`blockquote`,null,e.children.map(e=>r2(e,t)));case`pre`:return t.node(`code_block`,null,e.children[0]?[t.text(e.children[0])]:[]);case`details`:{let n=e.children[0],r=t.node(`details_summary`,null,a2(n.children,t)),i=e.children.slice(1).map(e=>r2(e,t)),a=e.variant??`details`;return t.node(`details`,{variant:a},[r,...i])}}}function i2(e,t){let n=e.children.map(e=>r2(e,t));return t.node(`list_item`,null,n)}function a2(e,t){let n=[];for(let r of e)if(typeof r==`string`)r.length>0&&n.push(t.text(r));else if(r.tag===`br`)t.nodes.hard_break&&n.push(t.node(`hard_break`));else if(r.tag===`span`){let e=r.styles.map(e=>t2(e,t)).filter(e=>e!==null);r.children[0].length>0&&n.push(t.text(r.children[0],e))}else if(r.tag===`a`){if(t.marks.link){let e=t.marks.link.create({href:r.href});for(let i of r.children)if(typeof i==`string`)i.length>0&&n.push(t.text(i,[e]));else if(i.tag===`span`){let r=i.styles.map(e=>t2(e,t)).filter(e=>e!==null);i.children[0].length>0&&n.push(t.text(i.children[0],[e,...r]))}}}else if(r.tag===`img`){if(t.nodes.image){let e=typeof r.src==`string`?null:r.src;n.push(t.node(`image`,{src:e?e.path:r.src,alt:r.alt??null,width:e?.width??null,height:e?.height??null,mimeType:e?.mimeType??null}))}}else if(r.tag===`button`){if(r.children===!1)t.nodes.button_atom&&n.push(t.node(`button_atom`,{variant:r.variant}));else if(t.nodes.button_editable){let e=r.children[0];n.push(t.node(`button_editable`,{variant:r.variant,href:r.href??null},e.length>0?[t.text(e)]:[]))}}return n}function o2(e){let t=[];return e.forEach(e=>{let n=s2(e);n&&t.push(n)}),t}function s2(e){switch(e.type.name){case`paragraph`:return{tag:`p`,children:l2(e)};case`heading`:return{tag:`h${e.attrs.level}`,children:l2(e)};case`bullet_list`:return{tag:`ul`,children:c2(e)};case`ordered_list`:return{tag:`ol`,children:c2(e)};case`blockquote`:{let t=[];return e.forEach(e=>{let n=s2(e);n&&t.push(n)}),{tag:`blockquote`,children:t}}case`code_block`:return{tag:`pre`,children:[e.textContent]};case`details`:{let t=e.attrs.variant,n={tag:`summary`,children:[]},r=[];e.forEach(e=>{if(e.type.name===`details_summary`)n={tag:`summary`,children:l2(e)};else{let t=s2(e);t&&r.push(t)}});let i={tag:`details`,children:[n,...r]};return t!==`details`&&(i.variant=t),i}default:return null}}function c2(e){let t=[];return e.forEach(e=>{if(e.type.name===`list_item`){let n=[];e.forEach(e=>{let t=s2(e);t&&n.push(t)}),t.push({tag:`li`,children:n})}}),t}function l2(e){let t=[];return e.forEach(e=>{if(e.isText){let n=e.text||``,r=e.marks;if(r.length===0)t.push(n);else{let e=r.find(e=>e.type.name===`link`),i=r.filter(e=>e.type.name!==`link`);if(e){let r=e.attrs.href;if(i.length===0)oHe(t,r,n);else{let e={tag:`span`,styles:u2(i),children:[n]};sHe(t,r,e)}}else{let e=u2(i);e.length>0?t.push({tag:`span`,styles:e,children:[n]}):t.push(n)}}}else if(e.type.name===`hard_break`)t.push({tag:`br`});else if(e.type.name===`image`){let n=e.attrs.src,r=e.attrs.width,i=e.attrs.height,a=e.attrs.mimeType,o={tag:`img`,src:{path:n,...r!==null&&i!==null&&a!==null?{width:r,height:i,mimeType:a}:{}},...e.attrs.alt?{alt:e.attrs.alt}:{}};t.push(o)}else if(e.type.name===`button_atom`)t.push({tag:`button`,variant:e.attrs.variant,children:!1});else if(e.type.name===`button_editable`){let n={tag:`button`,variant:e.attrs.variant,children:[e.textContent]};e.attrs.href&&(n.href=e.attrs.href),t.push(n)}}),t}function oHe(e,t,n){let r=e[e.length-1];r&&typeof r==`object`&&r.tag===`a`&&r.href===t?r.children.push(n):e.push({tag:`a`,href:t,children:[n]})}function sHe(e,t,n){let r=e[e.length-1];r&&typeof r==`object`&&r.tag===`a`&&r.href===t?r.children.push(n):e.push({tag:`a`,href:t,children:[n]})}var cHe=`custom_style_`;function u2(e){let t=[];for(let n of e)switch(n.type.name){case`bold`:t.push(`bold`);break;case`italic`:t.push(`italic`);break;case`strikethrough`:t.push(`line-through`);break;case`code`:t.push(`code`);break;default:n.type.name.startsWith(cHe)&&t.push(n.type.name.slice(13))}return t}var d2=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function lHe(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var uHe=(e,t,n)=>{let r=lHe(e,n);if(!r)return!1;let i=p2(r);if(!i){let n=r.blockRange(),i=n&&FZ(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(g2(e,i,t,-1))return!0;if(r.parent.content.size==0&&(f2(a,`end`)||cQ.isSelectable(a)))for(let n=r.depth;;n--){let o=UZ(e.doc,r.before(n),r.after(n),wX.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(f2(a,`end`)?nQ.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):cQ.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1};function f2(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var dHe=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=p2(r)}let o=a&&a.nodeBefore;return!o||!cQ.isSelectable(o)?!1:(t&&t(e.tr.setSelection(cQ.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function p2(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function fHe(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var pHe=(e,t,n)=>{let r=fHe(e,n);if(!r)return!1;let i=m2(r);if(!i)return!1;let a=i.nodeAfter;if(g2(e,i,t,1))return!0;if(r.parent.content.size==0&&(f2(a,`start`)||cQ.isSelectable(a))){let n=UZ(e.doc,r.before(),r.after(),wX.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(f2(a,`start`)?nQ.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):cQ.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},mHe=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=m2(r)}let o=a&&a.nodeAfter;return!o||!cQ.isSelectable(o)?!1:(t&&t(e.tr.setSelection(cQ.create(e.doc,a.pos)).scrollIntoView()),!0)};function m2(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var hHe=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&FZ(i);return a!=null&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},gHe=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
|
|
215
|
-
`).scrollIntoView()),!0)};function h2(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var _He=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=h2(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(nQ.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},vHe=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof lQ||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=h2(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(oQ.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},yHe=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(BZ(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&FZ(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function bHe(e){return(t,n)=>{if(t.selection instanceof cQ&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!BZ(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof oQ||t.selection instanceof lQ)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=h2(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=BZ(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,BZ(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var xHe=bHe(),SHe=(e,t)=>(t&&t(e.tr.setSelection(new lQ(e.doc))),!0);function CHe(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||VZ(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function g2(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&CHe(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=vX.empty;for(let e=o.length-1;e>=0;e--)s=vX.from(o[e].create(null,s));s=vX.from(i.copy(s));let c=e.tr.step(new MZ(t.pos-1,r,t.pos,r,new wX(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&VZ(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:nQ.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&FZ(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&f2(a,`start`,!0)&&f2(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=vX.empty;for(let e=o.length-1;e>=0;e--)r=vX.from(o[e].copy(r));n(e.tr.step(new MZ(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new wX(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function _2(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(oQ.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var wHe=_2(-1),THe=_2(1);function v2(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&IZ(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function y2(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t))){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function EHe(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function DHe(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new rQ(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new rQ(r,i))}return t}function b2(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!EHe(n.doc,l,e,i))return!1;if(o){if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=DHe(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}}return!0}}function x2(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var S2=x2(d2,uHe,dHe),C2=x2(d2,pHe,mHe),w2={Enter:x2(gHe,vHe,yHe,xHe),"Mod-Enter":_He,Backspace:S2,"Mod-Backspace":S2,"Shift-Backspace":S2,Delete:C2,"Mod-Delete":C2,"Mod-a":SHe},T2={"Ctrl-h":w2.Backspace,"Alt-Backspace":w2[`Mod-Backspace`],"Ctrl-d":w2.Delete,"Ctrl-Alt-Backspace":w2[`Mod-Delete`],"Alt-Delete":w2[`Mod-Delete`],"Alt-d":w2[`Mod-Delete`],"Ctrl-a":wHe,"Ctrl-e":THe};for(let e in w2)T2[e]=w2[e];var E2=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?T2:w2;function D2(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return OHe(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function OHe(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new LX(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new LX(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=IZ(a,n,r,t);return s?(e&&kHe(e,t,s,i,n),!0):!1}function kHe(e,t,n,r,i){let a=vX.empty;for(let e=n.length-1;e>=0;e--)a=vX.from(n[e].type.create(n[e].attrs,a));e.step(new MZ(t.start-(r?2:0),t.end,t.start,t.end,new wX(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&BZ(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function O2(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=vX.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=vX.from(i.node(e).copy(t));let o=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(vX.from(e.createAndFill()));let s=i.before(i.depth-(a-1)),c=n.tr.replace(s,i.after(-o),new wX(t,4-a,0)),l=-1;c.doc.nodesBetween(s,c.doc.content.size,(e,t)=>{if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(nQ.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return BZ(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function k2(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?AHe(t,n,e,a):jHe(t,n,a):!0:!1}}function AHe(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new MZ(a-1,o,a,o,new wX(vX.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new LX(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=FZ(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return VZ(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function jHe(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?vX.empty:vX.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new MZ(d-+!!s,f+ +!!c,d+1,f-1,new wX((s?vX.empty:vX.from(i.copy(vX.empty))).append(c?vX.empty:vX.from(i.copy(vX.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function A2(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=vX.from(r?e.create():null),o=new wX(vX.from(e.create(null,vX.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new MZ(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var j2=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`];function M2(e){return e.h1||e.h2||e.h3||e.h4||e.h5||e.h6}var MHe={bold:!0,italic:!0,strikethrough:!0,code:!0,link:!0,image:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,bulletList:!0,orderedList:!0,blockquote:!0,details:!1,codeBlock:!0,hardBreak:!0,button:!1,fixedToolbar:!0,floatingToolbar:!0,gutter:!0};function NHe(e,t){let n={};if(n[`Mod-z`]=w0,n[`Mod-y`]=T0,n[`Mod-Shift-z`]=T0,e.marks.bold&&(!t||t.bold)&&(n[`Mod-b`]=b2(e.marks.bold)),e.marks.italic&&(!t||t.italic)&&(n[`Mod-i`]=b2(e.marks.italic)),e.marks.strikethrough&&(!t||t.strikethrough)&&(n[`Mod-Shift-x`]=b2(e.marks.strikethrough)),e.marks.code&&(!t||t.code)&&(n[`Mod-e`]=b2(e.marks.code)),e.nodes.hard_break&&(!t||t.hardBreak)){let t=e.nodes.hard_break;n[`Shift-Enter`]=(e,n)=>(n&&n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)}if(e.nodes.heading){for(let r=1;r<=6;r++)(!t||t[j2[r-1]])&&(n[`Mod-Alt-${r}`]=y2(e.nodes.heading,{level:r}));(!t||M2(t))&&(n[`Mod-Alt-0`]=y2(e.nodes.paragraph))}return e.nodes.blockquote&&(!t||t.blockquote)&&(n[`Mod-Shift-b`]=v2(e.nodes.blockquote)),e.nodes.code_block&&(!t||t.codeBlock)&&(n[`Mod-Alt-c`]=y2(e.nodes.code_block)),e.nodes.bullet_list&&(!t||t.bulletList)&&(n[`Mod-Shift-8`]=D2(e.nodes.bullet_list)),e.nodes.ordered_list&&(!t||t.orderedList)&&(n[`Mod-Shift-9`]=D2(e.nodes.ordered_list)),e.nodes.list_item&&(!t||t.bulletList||t.orderedList)&&(n.Enter=O2(e.nodes.list_item),n[`Mod-[`]=k2(e.nodes.list_item),n[`Mod-]`]=A2(e.nodes.list_item)),[O0(n),O0(E2)]}var N2=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?PHe(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function PHe(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var FHe=500;function P2({rules:e}){let t=new bQ({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return F2(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&F2(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function F2(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-FHe),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}new N2(/--$/,`—`,{inCodeMark:!1}),new N2(/\.\.\.$/,`…`,{inCodeMark:!1}),new N2(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new N2(/"$/,`”`,{inCodeMark:!1}),new N2(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new N2(/'$/,`’`,{inCodeMark:!1});function I2(e,t,n=null,r){return new N2(e,(e,i,a,o)=>{let s=n instanceof Function?n(i):n,c=e.tr.delete(a,o),l=c.doc.resolve(a).blockRange(),u=l&&IZ(l,t,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(a-1).nodeBefore;return d&&d.type==t&&VZ(c.doc,a-1)&&(!r||r(i,d))&&c.join(a-1),c})}function L2(e,t,n=null){return new N2(e,(e,r,i,a)=>{let o=e.doc.resolve(i),s=n instanceof Function?n(r):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t)?e.tr.delete(i,a).setBlockType(i,i,t,s):null})}function IHe(e,t){let n=[];return e.nodes.heading&&(!t||M2(t))&&n.push(L2(/^(#{1,6})\s$/,e.nodes.heading,e=>{let n=e[1].length;return t&&!t[j2[n-1]]?!1:{level:n}})),e.nodes.blockquote&&(!t||t.blockquote)&&n.push(I2(/^\s*>\s$/,e.nodes.blockquote)),e.nodes.bullet_list&&(!t||t.bulletList)&&n.push(I2(/^\s*([-+*])\s$/,e.nodes.bullet_list)),e.nodes.ordered_list&&(!t||t.orderedList)&&n.push(I2(/^(\d+)\.\s$/,e.nodes.ordered_list,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order===+e[1])),e.nodes.code_block&&(!t||t.codeBlock)&&n.push(L2(/^```$/,e.nodes.code_block)),P2({rules:n})}function LHe(e){let t=e.schema.cached.changeSetIDs||(e.schema.cached.changeSetIDs=Object.create(null)),n=t[e.name];return n??(t[e.name]=n=Object.keys(e.schema.nodes).indexOf(e.name)+1),n}var R2={encodeCharacter:e=>e,encodeNodeStart:e=>e.type.name,encodeNodeEnd:e=>-LHe(e.type),compareTokens:(e,t)=>e===t};function z2(e,t,n,r,i){for(let a=0,o=0;a<e.childCount;a++){let s=e.child(a),c=o+s.nodeSize,l=Math.max(o,n),u=Math.min(c,r);if(l<u){if(s.isText)for(let e=l;e<u;e++)i.push(t.encodeCharacter(s.text.charCodeAt(e-o),s.marks));else s.isLeaf?i.push(t.encodeNodeStart(s)):(l==o&&i.push(t.encodeNodeStart(s)),z2(s.content,t,Math.max(o+1,l)-o-1,Math.min(c-1,u)-o-1,i),u==c&&i.push(t.encodeNodeEnd(s)))}o=c}return i}var B2=2500;function RHe(e,t){return Math.min(15,Math.max(2,Math.floor(Math.max(e,t)/10)))}function V2(e,t,n,r=R2){return Math.max(n.toA-n.fromA,n.toB,n.fromB)>B2?[n]:zHe(z2(e,r,n.fromA,n.toA,[]),z2(t,r,n.fromB,n.toB,[]),n,r.compareTokens)}function zHe(e,t,n,r){let i=0,a=e.length,o=t.length;for(;i<e.length&&i<t.length&&r(e[i],t[i]);)i++;if(i==e.length&&i==t.length)return[];for(;a>i&&o>i&&r(e[a-1],t[o-1]);)a--,o--;if(a==i||o==i||a==o&&a==i+1)return[n.slice(i,a,i,o)];let s=a-i,c=o-i,l=Math.min(B2,s+c),u=[],d=new Int16Array((l+1)*2).fill(-1);for(let f=0;f<=l;f++){for(let p=-f;p<=f;p+=2){let m=d[p+1+l],h=d[p-1+l],g=m<h?h:m+1,_=g+p;for(;g<s&&_<c&&r(e[i+g],t[i+_]);)g++,_++;if(d[p+l]=g,g>=s&&_>=c){let e=[],t=RHe(a-i,o-i),r=-1,s=-1,c=-1,m=-1,h=(i,a,o,l)=>{r>-1&&r<a+t?(r=i,c=o):(r>-1&&e.push(n.slice(r,s,c,m)),r=i,s=a,c=o,m=l)};for(let e=f-1;e>=0;e--){let t=d[p+1+l],n=d[p-1+l];t<n?(p--,g=n+i,_=g+p,h(g,g,_,_+1)):(p++,g=t+i,_=g+p,h(g,g+1,_,_)),d=u[e>>1]}return r>-1&&e.push(n.slice(r,s,c,m)),e.reverse()}}f%2==0&&u.push(d.slice())}return[n]}var H2=class e{constructor(e,t){this.length=e,this.data=t}cut(t){return t==this.length?this:new e(t,this.data)}static slice(t,n,r){if(n==r)return e.none;if(n==0&&r==e.len(t))return t;let i=[];for(let e=0,a=0;a<r;e++){let o=t[e],s=a+o.length,c=Math.min(r,s)-Math.max(n,a);c>0&&i.push(o.cut(c)),a=s}return i}static join(t,n,r){if(t.length==0)return n;if(n.length==0)return t;let i=r(t[t.length-1].data,n[0].data);if(i==null)return t.concat(n);let a=t.slice(0,t.length-1);a.push(new e(t[t.length-1].length+n[0].length,i));for(let e=1;e<n.length;e++)a.push(n[e]);return a}static len(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;return t}};H2.none=[];var U2=class e{constructor(e,t,n,r,i,a){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r,this.deleted=i,this.inserted=a}get lenA(){return this.toA-this.fromA}get lenB(){return this.toB-this.fromB}slice(t,n,r,i){return t==0&&r==0&&n==this.toA-this.fromA&&i==this.toB-this.fromB?this:new e(this.fromA+t,this.fromA+n,this.fromB+r,this.fromB+i,H2.slice(this.deleted,t,n),H2.slice(this.inserted,r,i))}static merge(t,n,r){if(t.length==0)return n;if(n.length==0)return t;let i=[];for(let a=0,o=0,s=t[0],c=n[0];;)if(!s&&!c)return i;else if(s&&(!c||s.toB<c.fromA)){let r=o?n[o-1].toB-n[o-1].toA:0;i.push(r==0?s:new e(s.fromA,s.toA,s.fromB+r,s.toB+r,s.deleted,s.inserted)),s=a++==t.length?null:t[a]}else if(c&&(!s||c.toA<s.fromB)){let r=a?t[a-1].toB-t[a-1].toA:0;i.push(r==0?c:new e(c.fromA-r,c.toA-r,c.fromB,c.toB,c.deleted,c.inserted)),c=o++==n.length?null:n[o]}else{let l=Math.min(s.fromB,c.fromA),u=Math.min(s.fromA,c.fromA-(a?t[a-1].toB-t[a-1].toA:0)),d=u,f=Math.min(c.fromB,s.fromB+(o?n[o-1].toB-n[o-1].toA:0)),p=f,m=H2.none,h=H2.none,g=!1,_=!1;for(;;){let e=s?l>=s.fromB?s.toB:s.fromB:2e8,i=c?l>=c.fromA?c.toA:c.fromA:2e8,u=Math.min(e,i),f=s&&l>=s.fromB,v=c&&l>=c.fromA;if(!f&&!v)break;f&&l==s.fromB&&!g&&(m=H2.join(m,s.deleted,r),d+=s.lenA,g=!0),f&&!v&&(h=H2.join(h,H2.slice(s.inserted,l-s.fromB,u-s.fromB),r),p+=u-l),v&&l==c.fromA&&!_&&(h=H2.join(h,c.inserted,r),p+=c.lenB,_=!0),v&&!f&&(m=H2.join(m,H2.slice(c.deleted,l-c.fromA,u-c.fromA),r),d+=u-l),f&&u==s.toB&&(s=a++==t.length?null:t[a],g=!1),v&&u==c.toA&&(c=o++==n.length?null:n[o],_=!1),l=u}(u<d||f<p)&&i.push(new e(u,d,f,p,m,h))}}static fromJSON(t){return new e(t.fromA,t.toA,t.fromB,t.toB,t.deleted.map(e=>new H2(e.length,e.data)),t.inserted.map(e=>new H2(e.length,e.data)))}toJSON(){return this}},W2=class e{constructor(e,t){this.config=e,this.changes=t}addSteps(t,n,r){let i=[];for(let e=0;e<n.length;e++){let t=Array.isArray(r)?r[e]:r,a=0;n[e].forEach((e,n,r,o)=>{i.push(new U2(e+a,n+a,r,o,e==n?H2.none:[new H2(n-e,t)],r==o?H2.none:[new H2(o-r,t)])),a=o-r-(n-e)})}if(i.length==0)return this;let a=G2(i,this.config.combine),o=U2.merge(this.changes,a,this.config.combine),s=o;for(let e=0;e<s.length;e++){let n=s[e];if(n.fromA==n.toA||n.fromB==n.toB||!a.some(e=>e.toB>n.fromB&&e.fromB<n.toB))continue;let r=V2(this.config.doc.content,t.content,n,this.config.encoder);(r.length!=1||r[0].fromB!=0||r[0].toB!=n.toB-n.fromB)&&(s==o&&(s=o.slice()),r.length==1?s[e]=r[0]:(s.splice(e,1,...r),e+=r.length-1))}return new e(this.config,s)}get startDoc(){return this.config.doc}map(t){let n=e=>{let n=t(e);return n===e.data?e:new H2(e.length,n)};return new e(this.config,this.changes.map(e=>new U2(e.fromA,e.toA,e.fromB,e.toB,e.deleted.map(n),e.inserted.map(n))))}changedRange(e,t){if(e==this)return null;let n=t&&BHe(t),r=n?n.toB-n.fromB-(n.toA-n.fromA):0;function i(e){return!n||e<=n.fromA?e:e+r}let a=n?n.fromB:2e8,o=n?n.toB:-2e8;function s(e,t=e){a=Math.min(e,a),o=Math.max(t,o)}let c=this.changes,l=e.changes;for(let e=0,t=0;e<c.length&&t<l.length;){let n=c[e],r=l[t];n&&r&&VHe(n,r,i)?(e++,t++):r&&(!n||i(n.fromB)>=r.fromB)?(s(r.fromB,r.toB),t++):(s(i(n.fromB),i(n.toB)),e++)}return a<=o?{from:a,to:o}:null}static create(t,n=(e,t)=>e===t?e:null,r=R2,i=[]){return new e({combine:n,doc:t,encoder:r},i)}};W2.computeDiff=V2;function G2(e,t,n=0,r=e.length){if(r==n+1)return[e[n]];let i=n+r>>1;return U2.merge(G2(e,t,n,i),G2(e,t,i,r),t)}function K2(e){let t=2e8,n=-2e8;for(let r=0;r<e.length;r++){let i=e[r];t!=2e8&&(t=i.map(t,-1),n=i.map(n,1)),i.forEach((e,r,i,a)=>{t=Math.min(t,i),n=Math.max(n,a)})}return t==2e8?null:{from:t,to:n}}function BHe(e){let t=K2(e);if(!t)return null;let n=K2(e.map(e=>e.invert()).reverse());return{fromA:n.from,toA:n.to,fromB:t.from,toB:t.to}}function VHe(e,t,n){return n(e.fromB)==t.fromB&&n(e.toB)==t.toB&&q2(e.deleted,t.deleted)&&q2(e.inserted,t.inserted)}function q2(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].length!=t[n].length||e[n].data!==t[n].data)return!1;return!0}var J2=new CQ(`diff`);function HHe(){return new bQ({key:J2,state:{init(){return{baseDoc:null,changeSet:null,decorations:H1.empty}},apply(e,t,n,r){let i=e.getMeta(J2)?.baseDoc;if(i!==void 0){if(i===null)return{baseDoc:null,changeSet:null,decorations:H1.empty};let e=W2.create(i),t=[];UHe(i,r.doc,t);let n=t.length>0?e.addSteps(r.doc,t,null):e;return{baseDoc:i,changeSet:n,decorations:Y2(n,r.doc,i)}}if(!t.baseDoc||!t.changeSet)return t;if(!e.docChanged)return{...t,decorations:t.decorations.map(e.mapping,e.doc)};let a=e.steps.map(e=>e.getMap()),o=t.changeSet.addSteps(e.doc,a,null);return{...t,changeSet:o,decorations:Y2(o,e.doc,t.baseDoc)}}},props:{decorations(e){return J2.getState(e)?.decorations??H1.empty}}})}function UHe(e,t,n){let r=e.content.size,i=t.content.size;(r!==i||!e.eq(t))&&n.push(new xZ([0,r,i]))}function Y2(e,t,n){let r=[];for(let i of e.changes){if(i.fromB<i.toB){let e=Math.max(0,i.fromB),n=Math.min(t.content.size,i.toB);e<n&&r.push(z1.inline(e,n,{class:`bg-bg-brand-primary/30`}))}if(i.fromA<i.toA&&i.deleted.length>0){let e=Math.min(i.fromB,t.content.size),a=Math.max(0,i.fromA),o=Math.min(n.content.size,i.toA),s=a<o?n.textBetween(a,o,` `):``;if(s.length>0){let t=document.createElement(`span`);t.className=`bg-bg-error-primary line-through text-fg-error-primary opacity-60`,t.textContent=s,r.push(z1.widget(e,t,{side:-1}))}}}return H1.create(t,r)}function X2(e,t){let n=e.split(`/`).filter(e=>e.length>0).map(e=>{let t=parseInt(e,10);return isNaN(t)?e:t});if(n.length===0)return null;let r=t,i=0;for(let e=0;e<n.length;e++){let t=n[e];if(typeof t==`number`){let a=0,o=!1;if(r.forEach((s,c)=>{o||(a===t&&(e===n.length-1?(i+=c,r=s):(i+=c+1,r=s),o=!0),a++)}),!o)return null}else if(t===`children`)continue;else return null}let a=i,o=a+r.nodeSize;return{from:Math.max(0,a),to:Math.min(t.content.size,o)}}var Z2=new CQ(`schemaValidation`),WHe={bullet_list:`bulletList`,ordered_list:`orderedList`,blockquote:`blockquote`,code_block:`codeBlock`,details:`details`,details_summary:`details`,hard_break:`hardBreak`,button_atom:`button`,button_editable:`button`,image:`image`},GHe={bold:`bold`,italic:`italic`,strikethrough:`strikethrough`,code:`code`,link:`link`},KHe={heading:`Heading`,bullet_list:`Bullet list`,ordered_list:`Ordered list`,blockquote:`Blockquote`,code_block:`Code block`,details:`Details`,details_summary:`Details`,hard_break:`Hard break`,button_atom:`Button`,button_editable:`Button`,image:`Image`},qHe={bold:`Bold`,italic:`Italic`,strikethrough:`Strikethrough`,code:`Code`,link:`Link`},Q2={heading:[{id:`schema.convert-to-paragraph`,label:`Convert to paragraph`}],bullet_list:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],ordered_list:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],blockquote:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],code_block:[{id:`schema.convert-to-paragraph`,label:`Convert to paragraph`}],details:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}]},JHe={bold:[{id:`schema.remove-formatting`,label:`Remove formatting`}],italic:[{id:`schema.remove-formatting`,label:`Remove formatting`}],strikethrough:[{id:`schema.remove-formatting`,label:`Remove formatting`}],code:[{id:`schema.remove-formatting`,label:`Remove formatting`}],link:[{id:`schema.remove-link`,label:`Remove link`}]};function $2(e){return`/`+e.join(`/children/`)}function e4(e,t,n,r){e.forEach((e,i,a)=>{let o=[...n,a];if(e.type.name===`heading`){let n=e.attrs.level,i=j2[n-1];if(i&&!t[i]){let t=Q2[e.type.name];r.push({path:$2(o),message:`Heading ${n} is not allowed by the current schema`,kind:`schema.violation`,...t&&{fixes:t}});return}}let s=WHe[e.type.name];if(s&&!t[s]){let t=KHe[e.type.name]??e.type.name,n=Q2[e.type.name];r.push({path:$2(o),message:`${t} is not allowed by the current schema`,kind:`schema.violation`,...n&&{fixes:n}});return}if(e.isText&&e.marks.length>0){let n=$2(o);for(let i of e.marks){let e=GHe[i.type.name];if(e&&!t[e]){let e=qHe[i.type.name]??i.type.name,t=JHe[i.type.name];r.push({path:n,message:`${e} is not allowed by the current schema`,kind:`schema.violation`,...t&&{fixes:t}})}}return}e.childCount>0&&e4(e,t,o,r)})}function t4(e,t){let n=[];return e4(e,t,[],n),n}function YHe(e,t,n){let{state:r}=e,{doc:i,schema:a}=r,o=X2(t,i);if(!o)return!1;let{from:s,to:c}=o,l=i.nodeAt(s);return l?n===`schema.convert-to-paragraph`?XHe(e,l,s,c,a):n===`schema.convert-to-paragraphs`?ZHe(e,l,s,c,a):n===`schema.remove-formatting`||n===`schema.remove-link`?QHe(e,s,c):!1:!1}function XHe(e,t,n,r,i){let a=r4(t),o=i.node(`paragraph`,null,a.length>0?[i.text(a)]:[]),s=e.state.tr.replaceWith(n,r,o);return e.dispatch(s),!0}function ZHe(e,t,n,r,i){let a=[];n4(t,i,a),a.length===0&&a.push(i.node(`paragraph`));let o=e.state.tr.replaceWith(n,r,a);return e.dispatch(o),!0}function n4(e,t,n){if(e.isTextblock){let r=r4(e);n.push(t.node(`paragraph`,null,r.length>0?[t.text(r)]:[]));return}e.forEach(e=>{n4(e,t,n)})}function QHe(e,t,n){let r=e.state.tr,i=e.state.doc.nodeAt(t);if(!i||!i.isText)return!1;for(let e of i.marks)r=r.removeMark(t,n,e.type);return e.dispatch(r),!0}function r4(e){return e.textContent}function $He(e){return new bQ({key:Z2,state:{init(t,n){return{errors:t4(n.doc,e)}},apply(t,n,r,i){return t.docChanged?{errors:t4(i.doc,e)}:n}}})}var i4=new CQ(`errors`);function a4(e){return Z2.getState(e)?.errors??[]}function eUe(){return new bQ({key:i4,state:{init(e,t){let n=a4(t);return{externalErrors:[],errors:n,errorKindClassName:{},decorations:o4(n,t.doc,{})}},apply(e,t,n,r){let i=e.getMeta(i4);if(i){let e=i.errors??t.externalErrors,n=i.errorKindClassName??t.errorKindClassName,a=a4(r),o=[...e,...a];return{externalErrors:e,errors:o,errorKindClassName:n,decorations:o4(o,r.doc,n)}}if(e.docChanged){let e=a4(r),n=[...t.externalErrors,...e];return{...t,errors:n,decorations:o4(n,r.doc,t.errorKindClassName)}}return t}},props:{decorations(e){return i4.getState(e)?.decorations??H1.empty}}})}function o4(e,t,n){if(e.length===0)return H1.empty;let r=[];for(let i of e){let e=X2(i.path,t);if(!e)continue;let{from:a,to:o}=e,s=n[i.kind]??``,c=`border-b-2 border-border-error-primary bg-bg-error-secondary/20`,l=s?`${c} ${s}`:c;r.push(z1.inline(a,o,{class:l,title:i.message,"data-error-kind":i.kind,"data-error-path":i.path}))}return H1.create(t,r)}function s4(e,t){try{let n=e.resolve(t),r=[];for(let e=1;e<=n.depth;e++){let t=n.node(e-1),i=n.index(e-1);t.type.name!==`doc`&&r.push(`children`),r.push(String(i))}let i=e.nodeAt(t);if(i){let e=n.node(n.depth);e.type.name===`doc`&&n.depth===0?r.push(String(n.index(0))):c4(e)&&!c4(i)&&(r.push(`children`),r.push(String(n.index(n.depth))))}return r.length>0?r:null}catch{return null}}function c4(e){let t=e.type.name;return t===`paragraph`||t===`heading`||t===`details_summary`}var tUe=`custom_style_`;function l4(e,t){let n=[];return e.marks.bold&&(!t||t.bold)&&n.push({label:`B`,title:`Bold (Ctrl+B)`,markType:e.marks.bold}),e.marks.italic&&(!t||t.italic)&&n.push({label:`I`,title:`Italic (Ctrl+I)`,markType:e.marks.italic}),e.marks.strikethrough&&(!t||t.strikethrough)&&n.push({label:`S`,title:`Strikethrough (Ctrl+Shift+X)`,markType:e.marks.strikethrough}),e.marks.code&&(!t||t.code)&&n.push({label:`<>`,title:`Code (Ctrl+E)`,markType:e.marks.code}),e.marks.link&&(!t||t.link)&&n.push({label:`🔗`,title:`Link`,markType:e.marks.link}),n}function u4(e,t){if(!t)return[];let n=[];for(let[r,i]of Object.entries(t)){let t=`${tUe}${r}`,a=e.marks[t];a&&n.push({label:i.label,title:i.label,markType:a})}return n}function d4(e,t){let n=[];return e.nodes.bullet_list&&(!t||t.bulletList)&&n.push({label:`•`,title:`Bullet list (Ctrl+Shift+8)`,nodeType:e.nodes.bullet_list}),e.nodes.ordered_list&&(!t||t.orderedList)&&n.push({label:`1.`,title:`Ordered list (Ctrl+Shift+9)`,nodeType:e.nodes.ordered_list}),n}function f4(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--)if(n.node(e).type===t)return!0;return!1}function nUe(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let r=n.node(e);if(r.type===t.nodes.bullet_list||r.type===t.nodes.ordered_list)return{depth:e,node:r}}return null}function rUe(e,t){let{state:n}=e,{$from:r}=n.selection,i=r.parent;i.type!==t.nodes.paragraph&&i.type.isTextblock&&y2(t.nodes.paragraph)(n,e.dispatch,e)}function iUe(e,t){return(n,r,i)=>{if(f4(n,e)){let e=t.nodes.list_item;return e?k2(e)(n,r):!1}let a=nUe(n,t);if(a){if(r){let{$from:t}=n.selection,i=t.before(a.depth);r(n.tr.setNodeMarkup(i,e))}return!0}if(i){let{$from:r}=n.selection,a=r.parent;if(a.type!==t.nodes.paragraph&&a.type.isTextblock)return rUe(i,t),D2(e)(i.state,i.dispatch)}return D2(e)(n,r)}}function p4(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}function m4(e,t){let n=[];if(n.push({value:`paragraph`,label:`Normal`,nodeType:e.nodes.paragraph}),e.nodes.heading)for(let r=1;r<=3;r++)(!t||t[j2[r-1]])&&n.push({value:`heading${r}`,label:`Heading ${r}`,nodeType:e.nodes.heading,attrs:{level:r}});return e.nodes.code_block&&(!t||t.codeBlock)&&n.push({value:`code_block`,label:`Code`,nodeType:e.nodes.code_block}),e.nodes.blockquote&&(!t||t.blockquote)&&n.push({value:`blockquote`,label:`Quote`,nodeType:e.nodes.blockquote}),e.nodes.details&&(!t||t.details)&&n.push({value:`details`,label:`Details`,nodeType:e.nodes.details}),n}function aUe(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name===`details`)return`details`;if(t.type.name===`blockquote`)return`blockquote`}let r=n.parent;if(r.type.name===`heading`){let e=r.attrs.level,n=t.find(t=>t.value===`heading${e}`);if(n)return n.value}return r.type.name===`code_block`?`code_block`:`paragraph`}function oUe(e,t,n){let{state:r,dispatch:i}=e;if(n.value===`blockquote`){v2(t.nodes.blockquote)(r,i);return}if(n.value===`details`){y4(e,t,`details`);return}let{$from:a}=r.selection,o=!1;for(let e=a.depth;e>0;e--){let t=a.node(e).type.name;if(t===`blockquote`||t===`details`){o=!0;break}}if(o){hHe(r,t=>{let r=e.state.apply(t);e.updateState(r),y2(n.nodeType,n.attrs)(e.state,e.dispatch,e)});return}y2(n.nodeType,n.attrs)(r,i,e)}function h4(e,t,n){let r=e.coordsAtPos(t);if(n)return{left:Math.max(0,r.left),top:r.bottom+4};let i=e.dom.parentElement;if(!i)return null;let a=i.getBoundingClientRect();return{left:Math.max(0,r.left-a.left),top:r.bottom-a.top+4}}function sUe(e){function t(){e.onPickerStateChange(null)}function n(t,n,r){let{$from:i,from:a,to:o}=t.state.selection,s=n.isInSet(i.marks())??(i.nodeAfter?n.isInSet(i.nodeAfter.marks):null),c=s?s.attrs.href.trim():null,l=h4(t,a,!!e.getPortalContainer?.());l&&e.onPickerStateChange({kind:`catalog`,anchorRect:l,savedFrom:a,savedTo:o,currentHref:c,catalog:r})}function r(t,n){let{$from:r,from:i,to:a}=t.state.selection,o=n.isInSet(r.marks())??(r.nodeAfter?n.isInSet(r.nodeAfter.marks):null),s=o?o.attrs.href.trim():null,c=h4(t,i,!!e.getPortalContainer?.());c&&e.onPickerStateChange({kind:`url`,anchorRect:c,savedFrom:i,savedTo:a,currentHref:s,isNewLink:!o})}function i(i,a){let{state:o}=i,s=e.getLinkCatalog?.();if(s&&s.length>0){if(e.isPickerOpen()){t();return}n(i,a,s);return}if(p4(o,a)){b2(a)(o,i.dispatch,i);return}if(e.isPickerOpen()){t();return}r(i,a)}return{handleLinkToggle:i,showCatalogPicker:n,showUrlEditor:r,closePicker:t,isPickerOpen:()=>e.isPickerOpen(),destroy:t}}function g4(e){return e?.type.name===`button_atom`||e?.type.name===`button_editable`}function cUe(e){let{$from:t}=e.selection;return e.selection instanceof cQ&&g4(e.selection.node)?{pos:e.selection.from,node:e.selection.node}:g4(t.parent)?{pos:t.before(t.depth),node:t.parent}:g4(t.nodeBefore)?{pos:t.pos-t.nodeBefore.nodeSize,node:t.nodeBefore}:g4(t.nodeAfter)?{pos:t.pos,node:t.nodeAfter}:null}function _4(e,t,n,r){let i=n.children===!1,a=i?t.nodes.button_atom:t.nodes.button_editable;if(!a)return;let o={variant:n.variant};!i&&r&&(o.href=r);let s=i?a.create(o):a.create(o,n.label?[t.text(n.label)]:[]),c=cUe(e.state);if(c&&c.node){let t=e.state.tr.replaceWith(c.pos,c.pos+c.node.nodeSize,s);e.dispatch(t)}else{let{from:t}=e.state.selection,n=e.state.tr.insert(t,s);e.dispatch(n)}}function v4(e,t,n,r){let i=t.nodes.image;if(!i)return null;let a=i.create({src:n,alt:``,previewUrl:r?.previewUrl??null,width:r?.width??null,height:r?.height??null,mimeType:r?.mimeType??null}),{from:o}=e.state.selection,s=e.state.tr.insert(o,a);e.dispatch(s);let c=s4(e.state.doc,o);return c?[...c,`src`]:null}function y4(e,t,n){let r=t.nodes.details,i=t.nodes.details_summary;if(!r||!i)return;let{state:a}=e,{$from:o}=a.selection,s=i.create(null,[]),c=t.nodes.paragraph.create(),l=r.create({variant:n},[s,c]),u=o.end(o.depth===0?1:o.depth)+1,d=a.tr.insert(u,l);e.dispatch(d),e.focus()}function lUe({schema:e,features:t,styleConfig:n,canInsertImage:r,buttonVariants:i,detailsVariants:a}){return!!(l4(e,t).length>0||u4(e,n).length>0||d4(e,t).length>0||m4(e,t).length>1||e.nodes.image&&(!t||t.image)&&r||i!==void 0&&i.length>0&&(!t||t.button)||a!==void 0&&a.length>0&&(!t||t.details))}var uUe=Object.defineProperty,b4=(e,t)=>uUe(e,`name`,{value:t,configurable:!0}),x4=!1;function S4(){let[e,t]=b.useState(x4);return b.useEffect(()=>{x4||(x4=!0,t(!0))},[]),e}b4(S4,`useIsHydrated`);var C4=b.useSyncExternalStore;function w4(){return()=>{}}b4(w4,`subscribe`);function T4(){return C4(w4,()=>!0,()=>!1)}b4(T4,`useIsHydratedModern`);var dUe=typeof C4==`function`?T4:S4,fUe=Object.defineProperty,E4=(e,t)=>fUe(e,`name`,{value:t,configurable:!0}),D4=`rovingFocusGroup.onEntryFocus`,pUe={bubbles:!1,cancelable:!0},O4=`RovingFocusGroup`,[k4,A4,mUe]=KT(O4),[hUe,j4]=sm(O4,[mUe]),[gUe,_Ue]=hUe(O4),vUe=b.forwardRef(E4(function(e,t){return(0,Y.jsx)(k4.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(k4.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(yUe,{...e,ref:t})})})},`RovingFocusGroup`)),yUe=b.forwardRef(E4(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=b.useRef(null),p=am(t,f),m=nE(a),[h,g]=ng({prop:o,defaultProp:s??null,onChange:c,caller:O4}),[_,v]=b.useState(!1),y=Cm(l),x=A4(n),S=b.useRef(!1),[C,w]=b.useState(0);return b.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(D4,y),()=>e.removeEventListener(D4,y)},[y]),(0,Y.jsx)(gUe,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:b.useCallback(e=>g(e),[g]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:b.useCallback(()=>w(e=>e-1),[]),children:(0,Y.jsx)(xm.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:Qp(e.onMouseDown,()=>{S.current=!0}),onFocus:Qp(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(D4,pUe);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);P4([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:Qp(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),bUe=`RovingFocusGroupItem`,xUe=b.forwardRef(E4(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Pm(),l=a||c,u=_Ue(bUe,n),d=u.currentTabStopId===l,f=A4(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=dUe();return Nm(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),b.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,Y.jsx)(k4.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,Y.jsx)(xm.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Qp(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Qp(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Qp(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=N4(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?F4(n,r+1):n.slice(r+1)}setTimeout(()=>P4(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),SUe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function M4(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}E4(M4,`getDirectionAwareKey`);function N4(e,t,n){let r=M4(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return SUe[r]}E4(N4,`getFocusIntent`);function P4(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}E4(P4,`focusFirst`);function F4(e,t){return e.map((n,r)=>e[(t+r)%e.length])}E4(F4,`wrapArray`);var CUe=vUe,wUe=xUe,TUe=Object.defineProperty,I4=(e,t)=>TUe(e,`name`,{value:t,configurable:!0}),L4=[`Enter`,` `],EUe=[`ArrowDown`,`PageUp`,`Home`],R4=[`ArrowUp`,`PageDown`,`End`],DUe=[...EUe,...R4],OUe={ltr:[...L4,`ArrowRight`],rtl:[...L4,`ArrowLeft`]},kUe={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},z4=`Menu`,[B4,AUe,jUe]=KT(z4),[V4,H4]=sm(z4,[jUe,Vh,j4]),U4=Vh(),W4=j4(),[MUe,G4]=V4(z4),[NUe,K4]=V4(z4),PUe=I4(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=U4(t),[c,l]=b.useState(null),u=b.useRef(!1),d=Cm(a),f=nE(i);return b.useEffect(()=>{let e=I4(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=I4(()=>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})}},[]),b.useEffect(()=>{if(!n)return;let e=I4(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,Y.jsx)(Uh,{...s,children:(0,Y.jsx)(MUe,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,Y.jsx)(NUe,{scope:t,onClose:b.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),q4=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e,i=U4(n);return(0,Y.jsx)(Wh,{...i,...r,ref:t})},`MenuAnchor`)),J4=`MenuPortal`,[FUe,Y4]=V4(J4,{forceMount:void 0}),IUe=I4(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=G4(J4,t);return(0,Y.jsx)(FUe,{scope:t,forceMount:n,children:(0,Y.jsx)(Jh,{present:n||a.open,children:(0,Y.jsx)(Kh,{asChild:!0,container:i,children:r})})})},`MenuPortal`),X4=`MenuContent`,[LUe,Z4]=V4(X4),RUe=b.forwardRef(I4(function(e,t){let n=Y4(X4,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=G4(X4,e.__scopeMenu),o=K4(X4,e.__scopeMenu);return(0,Y.jsx)(B4.Provider,{scope:e.__scopeMenu,children:(0,Y.jsx)(Jh,{present:r||a.open,children:(0,Y.jsx)(B4.Slot,{scope:e.__scopeMenu,children:o.modal?(0,Y.jsx)(zUe,{...i,ref:t}):(0,Y.jsx)(BUe,{...i,ref:t})})})})},`MenuContent`)),zUe=b.forwardRef(I4(function(e,t){let n=G4(X4,e.__scopeMenu),r=b.useRef(null),i=am(t,r);return b.useEffect(()=>{let e=r.current;if(e)return ev(e)},[]),(0,Y.jsx)(Q4,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Qp(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),BUe=b.forwardRef(I4(function(e,t){let n=G4(X4,e.__scopeMenu);return(0,Y.jsx)(Q4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),VUe=dm(`MenuContent.ScrollLock`),Q4=b.forwardRef(I4(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:m,...h}=e,g=G4(X4,n),_=K4(X4,n),v=U4(n),y=W4(n),x=AUe(n),[S,C]=b.useState(null),w=b.useRef(null),T=am(t,w,g.onContentChange),E=b.useRef(0),D=b.useRef(``),O=b.useRef(0),k=b.useRef(null),A=b.useRef(`right`),j=b.useRef(0),M=m?J_:b.Fragment,N=m?{as:VUe,allowPinchZoom:!0}:void 0,P=I4(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=f3(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;I4((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);b.useEffect(()=>()=>window.clearTimeout(E.current),[]),x_();let F=b.useCallback(e=>A.current===k.current?.side&&m3(e,k.current?.area),[]);return(0,Y.jsx)(LUe,{scope:n,searchRef:D,onItemEnter:b.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:b.useCallback(e=>{F(e)||(w.current?.focus(),C(null))},[F]),onTriggerLeave:b.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:O,onPointerGraceIntentChange:b.useCallback(e=>{k.current=e},[]),children:(0,Y.jsx)(M,{...N,children:(0,Y.jsx)(o_,{asChild:!0,trapped:i,onMountAutoFocus:Qp(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,Y.jsx)(Om,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,Y.jsx)(CUe,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Qp(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,Y.jsx)(Gh,{role:`menu`,"aria-orientation":`vertical`,"data-state":s3(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:T,style:{outline:`none`,...h.style},onKeyDown:Qp(h.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&&P(e.key));let i=w.current;if(e.target!==i||!DUe.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);R4.includes(e.key)&&a.reverse(),u3(a)}),onBlur:Qp(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:Qp(e.onPointerMove,h3(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),HUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e;return(0,Y.jsx)(xm.div,{...r,ref:t})},`MenuLabel`)),$4=`MenuItem`,e3=`menu.itemSelect`,t3=b.forwardRef(I4(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=b.useRef(null),o=K4($4,e.__scopeMenu),s=Z4($4,e.__scopeMenu),c=am(t,a),l=b.useRef(!1),u=I4(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(e3,{bubbles:!0,cancelable:!0});e.addEventListener(e3,e=>r?.(e),{once:!0}),Sm(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,Y.jsx)(n3,{...i,ref:c,disabled:n,onClick:Qp(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Qp(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Qp(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&L4.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),n3=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Z4($4,n),s=W4(n),c=b.useRef(null),l=am(t,c),[u,d]=b.useState(!1),[f,p]=b.useState(``);return b.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,Y.jsx)(B4.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,Y.jsx)(wUe,{asChild:!0,...s,focusable:!r,children:(0,Y.jsx)(xm.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Qp(e.onPointerMove,h3(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Qp(e.onPointerLeave,h3(e=>o.onItemLeave(e))),onFocus:Qp(e.onFocus,()=>d(!0)),onBlur:Qp(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),UUe=b.forwardRef(I4(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,Y.jsx)(i3,{scope:e.__scopeMenu,checked:n,children:(0,Y.jsx)(t3,{role:`menuitemcheckbox`,"aria-checked":c3(n)?`mixed`:n,...i,ref:t,"data-state":l3(n),onSelect:Qp(i.onSelect,()=>r?.(c3(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[WUe,GUe]=V4(`MenuRadioGroup`,{value:void 0,onValueChange:I4(()=>{},`onValueChange`)}),KUe=`MenuRadioItem`,qUe=b.forwardRef(I4(function(e,t){let{value:n,...r}=e,i=GUe(KUe,e.__scopeMenu),a=n===i.value;return(0,Y.jsx)(i3,{scope:e.__scopeMenu,checked:a,children:(0,Y.jsx)(t3,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":l3(a),onSelect:Qp(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),r3=`MenuItemIndicator`,[i3,JUe]=V4(r3,{checked:!1}),YUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=JUe(r3,n);return(0,Y.jsx)(Jh,{present:r||c3(a.checked)||a.checked===!0,children:(0,Y.jsx)(xm.span,{...i,ref:t,"data-state":l3(a.checked)})})},`MenuItemIndicator`)),XUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e;return(0,Y.jsx)(xm.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[ZUe,a3]=V4(`MenuSub`),o3=`MenuSubTrigger`,QUe=b.forwardRef(I4(function(e,t){let n=G4(o3,e.__scopeMenu),r=K4(o3,e.__scopeMenu),i=a3(o3,e.__scopeMenu),a=Z4(o3,e.__scopeMenu),o=b.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=b.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);b.useEffect(()=>u,[u]),b.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let d=am(t,i.onTriggerChange);return(0,Y.jsx)(q4,{asChild:!0,...l,children:(0,Y.jsx)(n3,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":s3(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Qp(e.onPointerMove,h3(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Qp(e.onPointerLeave,h3(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Qp(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&OUe[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),$Ue=`MenuSubContent`,eWe=b.forwardRef(I4(function(e,t){let n=Y4(X4,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=G4(X4,e.__scopeMenu),s=K4(X4,e.__scopeMenu),c=a3($Ue,e.__scopeMenu),l=b.useRef(null),u=am(t,l);return(0,Y.jsx)(B4.Provider,{scope:e.__scopeMenu,children:(0,Y.jsx)(Jh,{present:r||o.open,children:(0,Y.jsx)(B4.Slot,{scope:e.__scopeMenu,children:(0,Y.jsx)(Q4,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Qp(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Qp(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:Qp(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=kUe[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function s3(e){return e?`open`:`closed`}I4(s3,`getOpenState`);function c3(e){return e===`indeterminate`}I4(c3,`isIndeterminate`);function l3(e){return c3(e)?`indeterminate`:e?`checked`:`unchecked`}I4(l3,`getCheckedState`);function u3(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}I4(u3,`focusFirst`);function d3(e,t){return e.map((n,r)=>e[(t+r)%e.length])}I4(d3,`wrapArray`);function f3(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=d3(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}I4(f3,`getNextMatch`);function p3(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}I4(p3,`isPointInPolygon`);function m3(e,t){return t?p3({x:e.clientX,y:e.clientY},t):!1}I4(m3,`isPointerInGraceArea`);function h3(e){return t=>t.pointerType===`mouse`?e(t):void 0}I4(h3,`whenMouse`);var tWe=PUe,nWe=q4,rWe=IUe,iWe=RUe,aWe=HUe,oWe=t3,sWe=UUe,cWe=qUe,lWe=YUe,uWe=XUe,dWe=QUe,fWe=eWe,pWe=Object.defineProperty,g3=(e,t)=>pWe(e,`name`,{value:t,configurable:!0}),_3=`DropdownMenu`,[mWe,hWe]=sm(_3,[H4]),v3=H4(),[gWe,y3]=mWe(_3),_We=g3(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=v3(t),l=b.useRef(null),[u,d]=ng({prop:i,defaultProp:a??!1,onChange:o,caller:_3});return(0,Y.jsx)(gWe,{scope:t,triggerId:Pm(),triggerRef:l,contentId:Pm(),open:u,onOpenChange:d,onOpenToggle:b.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,Y.jsx)(tWe,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),vWe=`DropdownMenuTrigger`,yWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=y3(vWe,n),o=v3(n),s=am(t,a.triggerRef);return(0,Y.jsx)(nWe,{asChild:!0,...o,children:(0,Y.jsx)(xm.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:Qp(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Qp(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),bWe=g3(e=>{let{__scopeDropdownMenu:t,...n}=e,r=v3(t);return(0,Y.jsx)(rWe,{...r,...n})},`DropdownMenuPortal`),xWe=`DropdownMenuContent`,SWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=y3(xWe,n),a=v3(n),o=b.useRef(!1);return(0,Y.jsx)(iWe,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Qp(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Qp(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`)),CWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(aWe,{...i,...r,ref:t})},`DropdownMenuLabel`)),wWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(oWe,{...i,...r,ref:t})},`DropdownMenuItem`)),TWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(sWe,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),EWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(cWe,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),DWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(lWe,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),OWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(uWe,{...i,...r,ref:t})},`DropdownMenuSeparator`)),kWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(dWe,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),AWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(fWe,{...i,...r,ref:t,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)`}})},`DropdownMenuSubContent`)),jWe=_We,MWe=yWe,NWe=bWe,b3=SWe,x3=CWe,S3=wWe,C3=TWe,w3=EWe,T3=DWe,E3=OWe,D3=kWe,O3=AWe,k3=jWe,A3=MWe,PWe=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Y.jsxs)(D3,{ref:i,className:X(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-bg-brand-primary data-[state=open]:bg-bg-brand-primary`,t&&`pl-8`,e),...r,children:[n,(0,Y.jsx)(Rv,{className:`ml-auto w-4 h-4`})]}));PWe.displayName=D3.displayName;var FWe=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(O3,{ref:n,className:X(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-bg-secondary p-1 text-fg-secondary shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));FWe.displayName=O3.displayName;var j3=b.forwardRef(({className:e,sideOffset:t=4,container:n,...r},i)=>(0,Y.jsx)(NWe,{container:n,children:(0,Y.jsx)(b3,{ref:i,sideOffset:t,className:X(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-bg-secondary p-1 text-fg-secondary shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r})}));j3.displayName=b3.displayName;var M3=b.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(S3,{ref:r,className:X(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-bg-brand-primary focus:text-fg-brand-primary data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,t&&`pl-8`,e),...n}));M3.displayName=S3.displayName;var IWe=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Y.jsxs)(C3,{ref:i,className:X(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(T3,{children:(0,Y.jsx)(Fv,{className:`w-4 h-4`})})}),t]}));IWe.displayName=C3.displayName;var LWe=b.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(w3,{ref:r,className:X(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(T3,{children:(0,Y.jsx)(Bie,{className:`w-2 h-2 fill-current`})})}),t]}));LWe.displayName=w3.displayName;var RWe=b.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(x3,{ref:r,className:X(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));RWe.displayName=x3.displayName;var zWe=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(E3,{ref:n,className:X(`-mx-1 my-1 h-px bg-muted`,e),...t}));zWe.displayName=E3.displayName;function N3({images:e,currentSrc:t,onSelect:n}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-secondary`,children:`Select an image:`}),(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:e.map((e,r)=>{let i=`Select image ${r+1}`;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e.url),"aria-label":i,className:[`overflow-hidden rounded border-2 transition-all`,t===e.url?`border-border-brand-primary ring-2 ring-border-brand-primary`:`border-border-primary hover:border-border-brand-primary`].join(` `),children:(0,Y.jsx)(`img`,{src:e.url,alt:``,className:`h-16 w-full object-cover`})},e.url)})})]})}function P3({catalog:e,currentHref:t,onApplyLink:n,onRemoveLink:r,onClose:i}){let a=new Map(e.map(e=>[e.href.trim(),e])),o=(0,b.useCallback)(e=>{let t=a.get(e);t&&n(t)},[a,n]);return(0,Y.jsxs)(ik,{filter:(e,t)=>{let n=a.get(e);if(!n)return 0;let r=t.toLowerCase();return n.title.toLowerCase().includes(r)||n.subtitle.toLowerCase().includes(r)||n.href.trim().toLowerCase().includes(r)?1:0},children:[(0,Y.jsx)(ak,{placeholder:`Filter...`,onKeyDown:e=>{e.key===`Escape`&&i()}}),(0,Y.jsxs)(ok,{children:[(0,Y.jsx)(sk,{children:`No matches`}),(0,Y.jsx)(ck,{children:e.map(e=>{let n=e.href.trim(),r=t!==null&&n===t;return(0,Y.jsxs)(uk,{value:n,onSelect:o,className:`flex items-center gap-2`,children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,r?`opacity-100`:`opacity-0`)}),(0,Y.jsx)(dk,{title:e.title,subtitle:e.subtitle,image:e.image??null,className:X(r&&`text-fg-brand-primary`)})]},n)})})]}),r&&(0,Y.jsx)(`div`,{className:`border-t border-border-primary p-1`,children:(0,Y.jsx)(`button`,{type:`button`,className:X(`w-full rounded px-2 py-1.5 text-left text-sm text-fg-secondary`,`transition-colors hover:bg-bg-secondary-hover`),onMouseDown:r,children:`Remove link`})})]})}function F3({currentHref:e,isNewLink:t,onApply:n,onUnlink:r,onClose:i}){let[a,o]=(0,b.useState)(e),s=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=s.current;e&&(e.focus(),e.select())},[]);let c=(0,b.useCallback)(()=>{let e=a.trim();e&&n(e)},[a,n]),l=(0,b.useCallback)(e=>{if(e.key===`Escape`){i();return}e.key===`Enter`&&(e.preventDefault(),c())},[i,c]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(MT,{ref:s,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:l,"aria-label":`URL`,placeholder:`https://…`,className:X(`h-8 m-0 min-w-[220px] w-auto text-sm`)}),(0,Y.jsx)(t_,{size:`xs`,onMouseDown:c,children:t?`Apply`:`Update`}),!t&&(0,Y.jsx)(t_,{variant:`ghost`,size:`xs`,onMouseDown:r,children:`Unlink`})]})}var BWe={bold:Mv,italic:ly,strikethrough:Fy,code:Kv,link:dy},VWe={bullet_list:my,ordered_list:fy},I3={1:tae,2:nae,3:iae,4:rae,5:aae,6:oae};function L3(){return(0,Y.jsx)(`div`,{className:`mx-0.5 w-px self-stretch bg-border-primary`,role:`separator`})}var R3=`disabled:bg-transparent disabled:border-transparent aria-disabled:bg-transparent aria-disabled:border-transparent`;function z3({view:e,schema:t,features:n,linkHelper:r,options:i,images:a,imageModuleEntries:o,imageGetUrl:s,onImageUpload:c,imageAccept:l,uploadProgress:u,buttonVariants:d,detailsVariants:f,linkCatalog:p,styleConfig:m,readOnly:h}){let g=l4(t,n),_=u4(t,m),v=d4(t,n),y=i?.showBlockTypeSelect?m4(t,n):[],x=y.length>1,S=x?aUe(e.state,y):`paragraph`,C=(0,b.useRef)(null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-0`,ref:C}),x&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:`xs`,className:X(`min-w-[3.5rem]`,R3),disabled:h,children:[S.startsWith(`heading`)&&(()=>{let e=I3[Number(S.replace(`heading`,``))];return e?(0,Y.jsx)(e,{size:16}):S})(),!S.startsWith(`heading`)&&(y.find(e=>e.value===S)?.label??`Normal`)]})}),(0,Y.jsx)(j3,{container:C.current,children:y.map(n=>{let r=n.attrs?.level,i=r?I3[r]:void 0;return(0,Y.jsx)(M3,{onClick:()=>{oUe(e,t,n),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):n.label},n.value)})})]}),(0,Y.jsx)(L3,{})]}),g.map(t=>{let n=p4(e.state,t.markType),i=BWe[t.markType.name];return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:t.title,disabled:h,className:X(R3,{"text-accent":n,"stroke-[3px]":n}),onClick:n=>{n.preventDefault(),t.markType.name===`link`?r.handleLinkToggle(e,t.markType):b2(t.markType)(e.state,e.dispatch,e),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):t.label},t.markType.name)}),_.length>0&&g.length>0&&(0,Y.jsx)(L3,{}),_.map(t=>{let n=p4(e.state,t.markType);return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:t.title,disabled:h,className:X(R3,{"text-accent":n,"stroke-[3px]":n}),onClick:n=>{n.preventDefault(),b2(t.markType)(e.state,e.dispatch,e),e.focus()},children:t.label},t.markType.name)}),v.length>0&&(g.length>0||_.length>0)&&(0,Y.jsx)(L3,{}),v.map(n=>{let r=f4(e.state,n.nodeType),i=VWe[n.nodeType.name];return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:n.title,disabled:h,className:X(R3,{"text-accent":r,"stroke-[3px]":r}),onClick:r=>{r.preventDefault(),iUe(n.nodeType,t)(e.state,e.dispatch,e),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):n.label},n.nodeType.name)}),t.nodes.image&&(!n||n.image)&&(a&&a.length>0||o||c)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(HWe,{view:e,schema:t,images:a,imageModuleEntries:o,imageGetUrl:s,onImageUpload:c,imageAccept:l,uploadProgress:u,readOnly:h})]}),d&&d.length>0&&(!n||n.button)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(GWe,{view:e,schema:t,variants:d,linkHelper:r,linkCatalog:p,dropdownContainer:C.current,readOnly:h})]}),f&&f.length>0&&(!n||n.details)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(UWe,{view:e,schema:t,variants:f,dropdownContainer:C.current,readOnly:h})]})]})}function HWe({view:e,schema:t,images:n,imageModuleEntries:r,imageGetUrl:i,onImageUpload:a,imageAccept:o,uploadProgress:s,readOnly:c}){let[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),p=(0,b.useRef)(null),m=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!l)return;function e(e){let t=e.target;(!p.current||!p.current.contains(t))&&u(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let h=!!r||n&&n.length>0;function g(n){a&&(f(!0),a(n,(n,r)=>v4(e,t,n,r)).then(t=>{f(!1),t&&(u(!1),e.focus())}))}return(0,Y.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert image`,disabled:d||c,className:X(R3,{"text-accent stroke-[3px]":l}),onClick:e=>{e.preventDefault(),!h&&a?m.current?.click():u(e=>!e)},children:d?(0,Y.jsx)(hy,{size:16,className:`animate-spin`}):(0,Y.jsx)(sy,{size:16})}),d&&s!=null&&(0,Y.jsxs)(`span`,{className:`text-[10px] font-medium tabular-nums text-fg-secondary select-none`,children:[s,`%`]}),(0,Y.jsx)(`input`,{ref:m,hidden:!0,type:`file`,accept:o??`image/*`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&g(t),e.target.value=``}}),l&&(0,Y.jsxs)(`div`,{ref:p,className:X(`absolute left-0 top-full z-window mt-1 rounded-md`,`border border-border-primary bg-bg-primary shadow-xl`,r?`min-w-[280px] p-0`:`min-w-[240px] p-2`),onMouseDown:e=>{e.stopPropagation()},children:[r?(0,Y.jsx)(uA,{moduleEntries:r,isImage:!0,getUrl:i,autoFocus:!0,maxHeight:280,onSelect:n=>{v4(e,t,n.filePath),u(!1),e.focus()},onEscape:()=>u(!1)}):n&&n.length>0?(0,Y.jsx)(N3,{images:n,currentSrc:``,onSelect:n=>{v4(e,t,n),u(!1),e.focus()}}):null,a&&(0,Y.jsxs)(Y.Fragment,{children:[h&&(0,Y.jsx)(`div`,{className:`mx-2 my-1 border-t border-border-primary`}),(0,Y.jsx)(`div`,{className:X(`flex items-center gap-2`,h?`px-2 pb-2`:``),children:(0,Y.jsxs)(t_,{variant:`secondary`,size:`sm`,className:`w-full`,disabled:d,onClick:e=>{e.preventDefault(),m.current?.click()},children:[d?(0,Y.jsx)(hy,{size:14,className:`mr-1.5 animate-spin`}):(0,Y.jsx)(By,{size:14,className:`mr-1.5`}),d?s==null?`Uploading...`:`Uploading ${s}%`:`Upload image`]})})]})]})]})}function UWe({view:e,schema:t,variants:n,dropdownContainer:r,readOnly:i}){return(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert details`,disabled:i,className:R3,children:(0,Y.jsx)(wy,{size:16})})}),(0,Y.jsx)(j3,{container:r,children:n.map(n=>(0,Y.jsx)(M3,{onClick:()=>{y4(e,t,n.variant),e.focus()},children:n.label},n.variant))})]})}function WWe(e){if(Array.isArray(e.link))return e.link}function GWe({view:e,schema:t,variants:n,dropdownContainer:r,readOnly:i}){let[a,o]=(0,b.useState)(null),s=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!a)return;function e(e){let t=e.target;(!s.current||!s.current.contains(t))&&o(null)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);function c(e){o(e)}function l(n){a&&(_4(e,t,a,n),o(null),e.focus())}function u(){o(null),e.focus()}return(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert button`,disabled:i,className:X(R3,{"text-accent stroke-[3px]":!!a}),children:(0,Y.jsx)(by,{size:16})})}),(0,Y.jsx)(j3,{container:r,children:n.map(n=>(0,Y.jsxs)(M3,{onClick:()=>{n.link?c(n):(_4(e,t,n),e.focus())},children:[n.label,n.link&&(0,Y.jsx)(`span`,{className:`ml-1.5 text-xs text-fg-secondary-alt`,children:`(link)`})]},n.variant))})]}),a&&(0,Y.jsx)(KWe,{ref:s,linkCatalog:WWe(a),onSelectHref:l,onClose:u})]})}var KWe=(0,b.forwardRef)(function({linkCatalog:e,onSelectHref:t,onClose:n},r){let i=e&&e.length>0;return(0,Y.jsx)(`div`,{ref:r,className:X(`absolute left-0 top-full z-window mt-1 rounded-md`,`border border-border-primary bg-bg-primary shadow-xl`,i?`min-w-[280px] flex flex-col`:`flex items-center gap-1.5 p-1.5`),onMouseDown:e=>{e.stopPropagation()},children:i?(0,Y.jsx)(P3,{catalog:e,currentHref:null,onApplyLink:e=>t(e.href.trim()),onRemoveLink:null,onClose:n}):(0,Y.jsx)(F3,{currentHref:``,isNewLink:!0,onApply:e=>t(e),onUnlink:n,onClose:n})})}),qWe=new CQ(`fixedToolbar`);function JWe(e,t){let n=null,r=null;if(!t.linkHelper)throw Error(`fixedToolbar requires a linkHelper instance`);let i=t.linkHelper,a={showBlockTypeSelect:!0};function o(n){r&&r.render((0,b.createElement)(z3,{view:n,schema:e,features:t.features,linkHelper:i,options:a,images:t.getImages?.(),imageModuleEntries:t.getImageModuleEntries?.(),imageGetUrl:t.getImageGetUrl?.(),onImageUpload:t.getOnImageUpload?.(),imageAccept:t.getImageAccept?.(),uploadProgress:t.getUploadProgress?.()??null,buttonVariants:t.getButtonVariants?.(),detailsVariants:t.getDetailsVariants?.(),linkCatalog:t.getLinkCatalog?.(),styleConfig:t.styleConfig,readOnly:t.readOnly}))}return new bQ({key:qWe,view(e){let i=t.getMount();return i&&(n=document.createElement(`div`),n.className=`flex flex-row items-center justify-start px-2 py-1 gap-x-1`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Formatting`),n.addEventListener(`mousedown`,e=>{e.target.tagName!==`SELECT`&&e.preventDefault()},!0),i.appendChild(n),r=(0,x.createRoot)(n),o(e)),{update:o,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}var YWe=new CQ(`floatingToolbar`);function XWe(e,t){let n=null,r=null;if(!t?.linkHelper)throw Error(`floatingToolbar requires a linkHelper instance`);let i=t.linkHelper;function a(a){if(!n||!r)return;let{selection:o}=a.state,{empty:s,from:c,to:l}=o,{$from:u}=o,d=u.parent.type.name===`button_editable`||o instanceof cQ&&o.node.type.name===`button_editable`;if(s||d||!a.hasFocus()&&!i.isPickerOpen()){n.style.display=`none`,i.isPickerOpen()||i.closePicker();return}r.render((0,b.createElement)(z3,{view:a,schema:e,features:t?.features,linkHelper:i,images:t?.getImages?.(),imageModuleEntries:t?.getImageModuleEntries?.(),imageGetUrl:t?.getImageGetUrl?.(),onImageUpload:t?.getOnImageUpload?.(),imageAccept:t?.getImageAccept?.(),uploadProgress:t?.getUploadProgress?.()??null,buttonVariants:t?.getButtonVariants?.(),detailsVariants:t?.getDetailsVariants?.(),linkCatalog:t?.getLinkCatalog?.(),styleConfig:t?.styleConfig}));let f=a.coordsAtPos(c),p=a.coordsAtPos(l);if(t?.getPortalContainer?.()){let e=(f.left+p.left)/2,t=f.top-40;n.style.display=`flex`,n.style.left=`${Math.max(0,e-60)}px`,n.style.top=`${Math.max(0,t)}px`}else{let e=a.dom.parentElement?.getBoundingClientRect();if(!e)return;let t=(f.left+p.left)/2-e.left,r=f.top-e.top-40;n.style.display=`flex`,n.style.left=`${Math.max(0,t-60)}px`,n.style.top=`${Math.max(0,r)}px`}}return new bQ({key:YWe,view(e){n=document.createElement(`div`);let i=t?.getPortalContainer?.();return n.className=[`${i?`fixed`:`absolute`} z-window flex items-center gap-x-1 rounded-md border border-border-primary`,`bg-bg-primary px-2 py-1 shadow-lg transition-opacity`].join(` `),n.style.display=`none`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Formatting (selection)`),n.addEventListener(`mousedown`,e=>e.preventDefault(),!0),(i??e.dom.parentElement)?.appendChild(n),r=(0,x.createRoot)(n),{update:a,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}var ZWe=new CQ(`gutter`);function QWe(e,t,n){let r=null,i=null;function a(e){let t=document.createElement(`div`);return t.className=`absolute left-0 top-0 w-8 pointer-events-none`,t.style.height=`100%`,e.dom.parentElement?.appendChild(t),t}function o(e){let t=document.createElement(`div`);return t.className=[`${e?`fixed`:`absolute`} z-window flex flex-col rounded-md border border-border-primary`,`bg-bg-primary p-1 shadow-lg text-sm min-w-[140px]`].join(` `),t.style.display=`none`,t}function s(e,t){let n=0;for(let r=0;r<=t;r++)n+=e.child(r).nodeSize;return n}function c(e,t,n){let{doc:r}=e.state;if(t<0||t>=r.childCount)return;let i=s(r,t),a=e.state.tr.insert(i,n);a.setSelection(oQ.near(a.doc.resolve(i+1),1)),e.dispatch(a),e.focus()}function l(e,n){let r=[];if(r.push({label:`Paragraph`,action:t=>{c(t,n,e.nodes.paragraph.create())}}),e.nodes.heading)for(let i=1;i<=3;i++)(!t||t[j2[i-1]])&&r.push({label:`Heading ${i}`,action:t=>{c(t,n,e.nodes.heading.create({level:i}))}});return e.nodes.code_block&&(!t||t.codeBlock)&&r.push({label:`Code Block`,action:t=>{c(t,n,e.nodes.code_block.create())}}),e.nodes.details&&e.nodes.details_summary&&(!t||t.details)&&r.push({label:`Details`,action:t=>{let r=e.nodes.details_summary.create(null,[]),i=e.nodes.paragraph.create();c(t,n,e.nodes.details.create({variant:`details`},[r,i]))}}),r}function u(e){if(!r)return;r.innerHTML=``;let t=e.dom.parentElement?.getBoundingClientRect();if(!t)return;let{doc:n}=e.state;n.forEach((n,i,a)=>{let o=e.coordsAtPos(i+1).top-t.top,s=document.createElement(`button`);s.type=`button`,s.className=[`pointer-events-auto absolute left-1 flex h-6 w-6 items-center justify-center`,`rounded text-fg-secondary-alt opacity-0 transition-opacity hover:opacity-100`,`hover:bg-bg-secondary-hover`].join(` `),s.style.top=`${o}px`,s.textContent=`+`,s.title=`Add block below`,s.addEventListener(`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),d(e,s,a)}),r.appendChild(s)})}function d(t,r,a){let s=n?.getPortalContainer?.();i||(i=o(!!s),(s??t.dom.parentElement)?.appendChild(i)),i.innerHTML=``;let c=l(e,a);for(let e of c){let n=document.createElement(`button`);n.type=`button`,n.className=`px-3 py-1 text-left text-fg-secondary hover:bg-bg-secondary-hover rounded`,n.textContent=e.label,n.addEventListener(`mousedown`,n=>{n.preventDefault(),e.action(t),i.style.display=`none`}),i.appendChild(n)}let u=r.getBoundingClientRect();if(s)i.style.display=`flex`,i.style.left=`${u.right+4}px`,i.style.top=`${u.top}px`;else{let e=t.dom.parentElement?.getBoundingClientRect();if(!e)return;i.style.display=`flex`,i.style.left=`${u.right-e.left+4}px`,i.style.top=`${u.top-e.top}px`}let d=e=>{i?.contains(e.target)||(i.style.display=`none`,document.removeEventListener(`mousedown`,d))};setTimeout(()=>document.addEventListener(`mousedown`,d),0)}return new bQ({key:ZWe,view(e){return r=a(e),u(e),{update:u,destroy(){r?.remove(),i?.remove(),r=null,i=null}}}})}function $We({error:e,onApplyFix:t}){let n=e.fixes;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`div`,{className:`text-fg-error-primary font-medium text-sm`,children:e.message}),n&&n.length>0&&(0,Y.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:n.map(n=>(0,Y.jsx)(`button`,{type:`button`,className:[`rounded px-2 py-0.5 text-xs font-medium`,`border border-border-error-primary text-fg-error-primary`,`hover:bg-bg-error-secondary-hover`].join(` `),onClick:r=>{r.preventDefault(),t?.({path:e.path,kind:e.kind,fixId:n.id})},children:n.label},n.id))})]})}var eGe=new CQ(`errorTooltip`);function tGe(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=null,c=null;function l(){c!==null&&(clearTimeout(c),c=null)}function u(){l(),c=setTimeout(()=>{p(),c=null},150)}function d(t){let n=e.getPortalContainer?.(),r=document.createElement(`div`);return r.className=[`${n?`fixed`:`absolute`} z-window max-w-xs rounded-md border border-border-error-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `),r.style.display=`none`,(n??t.dom.parentElement)?.appendChild(r),r}function f(i,a,o){if(!t)return;l(),r=a.path,n||=(0,x.createRoot)(t),n.render((0,Y.jsx)($We,{error:a,onApplyFix:t=>{e.onApplyErrorFix?.(t),p()}}));let s=o.getBoundingClientRect();if(e.getPortalContainer?.())t.style.display=`block`,t.style.left=`${s.left}px`,t.style.top=`${s.bottom+4}px`;else{let e=i.dom.parentElement?.getBoundingClientRect();if(!e)return;t.style.display=`block`,t.style.left=`${s.left-e.left}px`,t.style.top=`${s.bottom-e.top+4}px`}}function p(){l(),t&&(t.style.display=`none`),r=null}function m(e,t){let n=t.closest(`[data-error-path]`);if(!n)return null;let r=n.getAttribute(`data-error-path`);if(!r)return null;let i=(i4.getState(e.state)?.errors??[]).find(e=>e.path===r);return i?{error:i,target:n}:{error:{path:r,kind:n.getAttribute(`data-error-kind`)??``,message:n.getAttribute(`title`)??``},target:n}}return new bQ({key:eGe,view(e){return t=d(e),o=()=>l(),s=()=>u(),t.addEventListener(`mouseenter`,o),t.addEventListener(`mouseleave`,s),i=t=>{let n=t.target;if(!(n instanceof Element))return;let i=m(e,n);i&&i.error.path!==r&&f(e,i.error,i.target)},a=e=>{let n=e.relatedTarget;n instanceof Node&&t?.contains(n)||u()},e.dom.addEventListener(`mouseover`,i),e.dom.addEventListener(`mouseout`,a),{update(){},destroy(){l(),i&&e.dom.removeEventListener(`mouseover`,i),a&&e.dom.removeEventListener(`mouseout`,a),n&&=(n.unmount(),null),t?.remove(),t=null,r=null}}}})}var nGe=new CQ(`linkCatalog`);function rGe(e){return new bQ({key:nGe,appendTransaction(t,n,r){if(!t.some(e=>e.docChanged))return null;let i=e.getLinkCatalog();if(!i||i.length===0)return null;let a=r.schema.marks.link;if(!a)return null;let o=new Set(i.map(e=>e.href.trim())),s=r.tr,c=!1;return r.doc.descendants((e,t)=>{if(!e.isInline||!e.isText)return;let n=a.isInSet(e.marks);if(!n)return;let r=n.attrs.href.trim();o.has(r)||(s=s.removeMark(t,t+e.nodeSize,a),c=!0)}),c?s:null}})}var iGe=new CQ(`linkClick`);function aGe(e,t){let n=e;for(;n&&n!==t;){if(n.nodeName===`A`)return n;n=n.parentElement}return null}function oGe(e,t){let{linkHelper:n,getLinkCatalog:r}=t;return new bQ({key:iGe,props:{handleDOMEvents:{dblclick(t,i){let a=e.marks.link;if(!a)return!1;let o=aGe(i.target,t.dom);if(!o)return!1;i.preventDefault();let s=t.posAtDOM(o.firstChild??o,0);if(s<0)return!1;let c=t.state.doc.resolve(s),l=a.isInSet(c.marks())??(c.nodeAfter&&a.isInSet(c.nodeAfter.marks)||null);if(!l)return!1;let u=l.attrs.href,d=c.parent,f=c.start(c.depth),p=s,m=s,h=0;for(let e=0;e<d.childCount;e++){let t=d.child(e),n=t.isText?a.isInSet(t.marks):null;if(n&&n.attrs.href===u){let n=f+h,r=n+t.nodeSize;if(r>p&&n<=s){p=n,m=r;for(let t=e+1;t<d.childCount;t++){let e=d.child(t),n=e.isText?a.isInSet(e.marks):null;if(!n||n.attrs.href!==u)break;m+=e.nodeSize}for(let t=e-1;t>=0;t--){let e=d.child(t),n=e.isText?a.isInSet(e.marks):null;if(!n||n.attrs.href!==u)break;p-=e.nodeSize}break}}h+=t.nodeSize}if(p>=m)return!1;let g=t.state.tr.setSelection(oQ.create(t.state.doc,p,m));t.dispatch(g);let _=r?.();return _&&_.length>0?n.showCatalogPicker(t,a,_):n.showUrlEditor(t,a),!0}}}})}function sGe({onUpload:e,accept:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null);return(0,b.createElement)(`div`,{style:{marginTop:`6px`}},(0,b.createElement)(`input`,{ref:i,type:`file`,accept:t,hidden:!0,onChange:t=>{let n=t.currentTarget.files?.[0];n&&(r(!0),e(n).finally(()=>r(!1)),t.target.value=``)}}),(0,b.createElement)(`button`,{type:`button`,disabled:n,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,width:`100%`,padding:`4px 8px`,fontSize:`12px`,borderRadius:`4px`,border:`1px solid var(--border-primary, #ccc)`,background:`var(--bg-secondary, #f5f5f5)`,cursor:n?`wait`:`pointer`,opacity:n?.6:1},onClick:e=>{e.preventDefault(),e.stopPropagation(),i.current?.click()}},n?`Uploading...`:`Upload image`))}function cGe(e,t){let n=t?.inline??!1,r=e=>{let n=t?.getUrl?.();return n?n(e):e};return(i,a,o)=>{let s=document.createElement(n?`span`:`figure`);n?(s.style.position=`relative`,s.style.display=`inline-block`):(s.style.margin=`0.5em 0`,s.style.position=`relative`);let c=document.createElement(`img`);if(c.src=i.attrs.previewUrl||r(i.attrs.src),i.attrs.alt&&(c.alt=i.attrs.alt),c.style.maxWidth=`100%`,c.style.cursor=`pointer`,n||(c.style.display=`block`,c.style.borderRadius=`var(--radius, 0.25rem)`),s.appendChild(c),!n&&i.attrs.caption){let e=document.createElement(`figcaption`);e.textContent=i.attrs.caption,e.style.fontSize=`0.85em`,e.style.color=`var(--fg-secondary-alt)`,e.style.marginTop=`0.3em`,e.style.textAlign=`center`,s.appendChild(e)}let l=null,u=null,d=!1,f=null;function p(){u&&=(u.unmount(),null),l?.remove(),l=null,d=!1,f&&=(document.removeEventListener(`mousedown`,f,!0),null)}function m(){let n=e.current,r=t?.getOnImageUpload?.();if(!n&&!r)return;p(),d=!0,l=document.createElement(`div`),l.style.minWidth=`200px`,l.addEventListener(`mousedown`,e=>{e.stopPropagation()});let m=t?.getPortalContainer?.();if(m){l.className=[`fixed z-window rounded-md border border-border-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `);let e=c.getBoundingClientRect();l.style.left=`${e.left}px`,l.style.top=`${e.bottom+4}px`,m.appendChild(l)}else l.className=[`absolute z-window rounded-md border border-border-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `),l.style.left=`0`,l.style.top=`${c.offsetHeight+4}px`,s.appendChild(l);let h=i.attrs.src;function g(e){let t=o();if(t===void 0)return null;let n=a.state.tr.setNodeMarkup(t,void 0,{...i.attrs,src:e});a.dispatch(n),p(),a.focus();let r=s4(a.state.doc,t);return r?[...r,`src`]:null}u=(0,x.createRoot)(l);let _=[];if(n&&_.push((0,b.createElement)(()=>n(h,g))),r){let e=r,n=t?.getImageAccept?.()??`image/*`;_.push((0,b.createElement)(sGe,{key:`upload`,accept:n,onUpload:async t=>await e(t,g)}))}u.render((0,b.createElement)(`div`,null,..._)),f=e=>{l&&!l.contains(e.target)&&!c.contains(e.target)&&p()},setTimeout(()=>document.addEventListener(`mousedown`,f,!0),0)}return c.addEventListener(`mousedown`,n=>{!e.current&&!t?.getOnImageUpload?.()||(n.preventDefault(),n.stopPropagation(),d?p():m())}),{dom:s,stopEvent:()=>!1,update(e){return e.type===i.type&&(i=e,c.src=i.attrs.previewUrl||r(i.attrs.src),i.attrs.alt?c.alt=i.attrs.alt:c.removeAttribute(`alt`),!0)},destroy(){p()}}}}function lGe(e,t){let n=e.find(e=>e.variant===t);if(n&&Array.isArray(n.link))return n.link}function uGe({variants:e,currentVariant:t,currentHref:n,onSelectVariant:r}){let[i,a]=(0,b.useState)(null);if(i){let t=lGe(e,i),o=t&&t.length>0;return(0,Y.jsx)(`div`,{className:o?`min-w-[280px] flex flex-col`:`flex items-center gap-1.5 p-1.5`,children:o?(0,Y.jsx)(P3,{catalog:t,currentHref:n,onApplyLink:e=>r(i,e.href.trim()),onRemoveLink:null,onClose:()=>a(null)}):(0,Y.jsx)(F3,{currentHref:n??``,isNewLink:!n,onApply:e=>r(i,e),onUnlink:()=>{r(i,``),a(null)},onClose:()=>a(null)})})}return(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.map(e=>{let n=e.variant===t;return(0,Y.jsxs)(`button`,{type:`button`,className:[`flex items-center gap-2 rounded px-3 py-1.5 text-left text-sm`,`transition-colors w-full`,n?`bg-bg-secondary-hover font-medium`:`hover:bg-bg-secondary-hover`].join(` `),onMouseDown:t=>{t.preventDefault(),e.link?a(e.variant):r(e.variant)},children:[n&&(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-brand-primary text-xs`,"aria-hidden":`true`,children:`✓`}),(0,Y.jsx)(`span`,{className:n?`text-fg-brand-primary`:`text-fg-secondary`,children:e.label}),e.link&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-fg-secondary-alt`,children:`link`})]},e.variant)})})}var B3=[`inline-flex items-center rounded px-2 py-0.5 text-sm font-medium`,`bg-bg-brand-secondary text-fg-brand-secondary cursor-pointer`].join(` `);function V3(e,t,n,r,i,a){let o=null,s=null,c=!1,l=null;function u(){s&&=(s.unmount(),null),o?.remove(),o=null,c=!1,l&&=(document.removeEventListener(`mousedown`,l,!0),null)}function d(t){if(!o)return;let r=e.getBoundingClientRect();if(t)o.style.left=`${r.left}px`,o.style.top=`${r.bottom+4}px`;else{let e=n.dom.parentElement,t=e?.offsetParent?.getBoundingClientRect()??e?.parentElement?.getBoundingClientRect();if(!t)return;o.style.left=`${r.left-t.left}px`,o.style.top=`${r.bottom-t.top+4}px`}}function f(){let f=t.variantsRef.current;if(!f||f.length===0)return;let p=n.dom.parentElement;if(!p)return;u(),c=!0,o=document.createElement(`div`),o.style.minWidth=`180px`,o.addEventListener(`mousedown`,e=>{e.stopPropagation()});let m=a?.getPortalContainer?.(),h=!!m;o.className=[`${h?`fixed`:`absolute`} z-window rounded-md border border-border-primary`,`bg-bg-primary p-1 shadow-lg`].join(` `),(m??p).appendChild(o),d(h);let g=i(),_=g.attrs.variant,v=g.attrs.href??null;function y(e,a){let o=r();if(o===void 0)return;let s=t.variantsRef.current?.find(t=>t.variant===e);if(!s)return;let{schema:c}=n.state,l=s.children===!1,d=l?c.nodes.button_atom:c.nodes.button_editable;if(!d)return;let f={variant:e};l||(f.href=a||null);let p=i();if(l===(p.type.name===`button_atom`)){let e=n.state.tr.setNodeMarkup(o,void 0,f);n.dispatch(e)}else{let e=l?d.create(f):d.create(f,s.label?[c.text(s.label)]:[]),t=n.state.tr.replaceWith(o,o+p.nodeSize,e);n.dispatch(t)}u(),n.focus()}s=(0,x.createRoot)(o),s.render((0,b.createElement)(uGe,{variants:f,currentVariant:_,currentHref:v,onSelectVariant:y,onClose:()=>{u(),n.focus()}})),l=t=>{o&&!o.contains(t.target)&&!e.contains(t.target)&&u()},setTimeout(()=>document.addEventListener(`mousedown`,l,!0),0)}function p(){c?u():f()}return{toggle:p,closeOverlay:u,isOpen:()=>c}}function dGe(e,t){return(n,r,i)=>{let a=document.createElement(`span`);a.style.position=`relative`,a.style.display=`inline-block`;let o=document.createElement(`button`);o.setAttribute(`type`,`button`),o.className=`${B3} cursor-default`,o.contentEditable=`false`;let s=n,c=n.attrs.variant;o.setAttribute(`data-variant`,c),o.setAttribute(`data-atom`,`true`),o.textContent=e.current?.find(e=>e.variant===c)?.label??c,a.appendChild(o);let l=V3(o,{variantsRef:e},r,i,()=>s,t);return o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),l.toggle()}),{dom:a,stopEvent:()=>!0,update(t){if(t.type.name!==`button_atom`)return!1;s=t;let n=t.attrs.variant;o.setAttribute(`data-variant`,n);let r=e.current?.find(e=>e.variant===n)?.label??n;return o.textContent=r,!0},destroy(){l.closeOverlay()}}}}function fGe(e,t){return(n,r,i)=>{let a=document.createElement(`span`);a.style.position=`relative`,a.style.display=`inline-block`;let o=document.createElement(`button`);o.setAttribute(`type`,`button`),o.className=B3;let s=n,c=n.attrs.variant;o.setAttribute(`data-variant`,c);function l(e){e?(o.setAttribute(`data-href`,e),o.title=e):(o.removeAttribute(`data-href`),o.removeAttribute(`title`))}l(n.attrs.href);let u=document.createElement(`span`);o.appendChild(u),a.appendChild(o);let d=V3(o,{variantsRef:e},r,i,()=>s,t);return o.addEventListener(`dblclick`,e=>{e.preventDefault(),d.toggle()}),{dom:a,contentDOM:u,update(e){return e.type.name===`button_editable`&&(s=e,o.setAttribute(`data-variant`,e.attrs.variant),l(e.attrs.href),!0)},destroy(){d.closeOverlay()}}}}function H3({schema:e,initialDoc:t,viewRef:n,label:r,minHeight:i,allowEnter:a=!0}){let o=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!o.current)return;let e=()=>!0,r=a?[O0(E2),S0()]:[O0({Enter:e,"Shift-Enter":e}),O0(E2),S0()],i=vQ.create({doc:t,plugins:r}),s=new i0(o.current,{state:i,editable:()=>!0});return n.current=s,()=>{s.destroy(),n.current=null}},[e,t,n,a]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-secondary`,children:r}),(0,Y.jsx)(`div`,{ref:o,className:[`prose-editor overflow-y-auto rounded-md`,`border border-border-primary bg-bg-primary p-2`,`text-fg-primary caret-fg-primary`,`focus-within:ring-2 focus-within:ring-border-brand-primary`].join(` `),style:{minHeight:i}})]})}function pGe({schema:e,summaryContent:t,bodyNodes:n,onSave:r,onCancel:i}){let a=(0,b.useRef)(null),o=(0,b.useRef)(null),s=e.node(`doc`,null,[e.node(`paragraph`,null,t)]),c=n.length>0?n:[e.node(`paragraph`)],l=e.node(`doc`,null,c),u=(0,b.useCallback)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=[],i=e.state.doc.firstChild;i&&i.forEach(e=>n.push(e));let s=[];t.state.doc.forEach(e=>s.push(e)),r(n,s)},[r]),d=(0,b.useCallback)(e=>{e.target===e.currentTarget&&i()},[i]);return(0,b.useEffect)(()=>{function e(e){e.key===`Escape`&&i()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),(0,Y.jsx)(`div`,{className:`fixed inset-0 z-overlay flex items-center justify-center bg-black/40`,onMouseDown:d,children:(0,Y.jsxs)(`div`,{className:[`flex w-full max-w-2xl flex-col rounded-lg border border-border-primary`,`bg-bg-primary shadow-2xl`].join(` `),onMouseDown:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border-primary px-4 py-3`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg-primary`,children:`Edit Details`}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded p-1 text-fg-secondary hover:bg-bg-secondary-hover`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,Y.jsx)(H3,{schema:e,initialDoc:s,viewRef:a,label:`Summary`,minHeight:`40px`,allowEnter:!1}),(0,Y.jsx)(H3,{schema:e,initialDoc:l,viewRef:o,label:`Hidden content`,minHeight:`120px`})]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border-primary px-4 py-3`,children:[(0,Y.jsx)(`button`,{type:`button`,className:[`rounded-md px-3 py-1.5 text-sm font-medium`,`text-fg-secondary hover:bg-bg-secondary-hover`].join(` `),onClick:i,children:`Cancel`}),(0,Y.jsx)(`button`,{type:`button`,className:[`rounded-md px-3 py-1.5 text-sm font-medium`,`bg-bg-brand-primary text-fg-brand-primary`,`hover:opacity-90`].join(` `),onClick:u,children:`Save`})]})]})})}function U3(e){let t=``;return e.forEach((e,n,r)=>{r===0&&e.type.name===`details_summary`&&(t=e.textContent)}),t||`Details`}function mGe(e){let t=[];return e.forEach((e,n,r)=>{r===0&&e.type.name===`details_summary`&&e.forEach(e=>t.push(e))}),t}function hGe(e){let t=[],n=!0;return e.forEach(e=>{if(n){n=!1;return}t.push(e)}),t}function gGe(e){return(t,n,r)=>{let i=t.attrs.variant,a=document.createElement(`div`);a.className=`details-collapsed group my-1 select-none`,a.style.cursor=`pointer`,i!==`details`&&a.setAttribute(`data-variant`,i);let o=document.createElement(`div`);o.style.display=`flex`,o.style.alignItems=`center`,o.style.gap=`6px`,o.style.padding=`4px 6px`,o.style.borderRadius=`4px`,o.style.transition=`background 100ms ease`,o.addEventListener(`mouseenter`,()=>{o.style.background=`var(--bg-secondary-hover, #f5f5f5)`}),o.addEventListener(`mouseleave`,()=>{o.style.background=``}),a.appendChild(o);let s=document.createElement(`span`);s.textContent=`▶`,s.style.fontSize=`0.65em`,s.style.color=`var(--fg-secondary-alt, #888)`,s.style.userSelect=`none`,s.style.flexShrink=`0`,s.style.transition=`transform 120ms ease`,o.appendChild(s);let c=document.createElement(`span`);c.style.fontSize=`inherit`,c.style.color=`var(--fg-primary, #333)`,c.textContent=U3(t),o.appendChild(c);let l=null,u=null;function d(){l&&=(l.unmount(),null),u?.remove(),u=null,s.style.transform=``}function f(){d(),s.style.transform=`rotate(90deg)`;let t=r();if(t===void 0)return;let i=n.state.doc.nodeAt(t);if(!i||i.type.name!==`details`)return;let a=mGe(i),o=hGe(i);u=document.createElement(`div`),document.body.appendChild(u),l=(0,x.createRoot)(u),l.render((0,b.createElement)(pGe,{schema:e,summaryContent:a,bodyNodes:o,onSave:(t,i)=>{let a=r();if(a===void 0)return;let o=n.state.doc.nodeAt(a);if(!o||o.type.name!==`details`)return;let s=e.nodes.details_summary.create(null,t),l=i.length>0?i:[e.nodes.paragraph.create()],u=o.type.create(o.attrs,[s,...l]),f=n.state.tr.replaceWith(a,a+o.nodeSize,u);n.dispatch(f),d(),c.textContent=s.textContent||`Details`,n.focus()},onCancel:()=>{d(),n.focus()}}))}return o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),f()}),{dom:a,update(e){if(e.type.name!==`details`)return!1;let t=e.attrs.variant;return t===`details`?a.removeAttribute(`data-variant`):a.setAttribute(`data-variant`,t),c.textContent=U3(e),!0},stopEvent(){return!0},ignoreMutation(){return!0},destroy(){d()}}}}function W3({state:e,useFixedPosition:t,onApplyLink:n,onRemoveLink:r,onApplyUrl:i,onUnlink:a,onClose:o}){let s=(0,b.useRef)(null);(0,b.useEffect)(()=>{function e(e){let t=e.target;s.current&&!s.current.contains(t)&&o()}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let c=e.kind===`catalog`,l=t?`fixed`:`absolute`;return(0,Y.jsx)(`div`,{ref:s,className:c?`${l} z-window flex flex-col rounded-md border border-border-primary bg-bg-primary shadow-xl min-w-[280px]`:`${l} z-window flex items-center gap-1.5 rounded-md border border-border-primary bg-bg-primary p-1.5 shadow-xl`,style:{left:e.anchorRect.left,top:e.anchorRect.top},onMouseDown:e=>{e.stopPropagation()},children:c&&e.catalog?(0,Y.jsx)(P3,{catalog:e.catalog,currentHref:e.currentHref,onApplyLink:n,onRemoveLink:e.currentHref===null?null:r,onClose:o}):(0,Y.jsx)(F3,{currentHref:e.currentHref??``,isNewLink:e.isNewLink??!0,onApply:i,onUnlink:a,onClose:o})})}function G3(e,t){let n=t.content.size,r=Math.min(e.anchor,n);try{return nQ.near(t.resolve(r))}catch{return nQ.atStart(t)}}var _Ge=(0,b.forwardRef)(function(e,t){let{value:n,defaultValue:r,onChange:i,onDirty:a,readOnly:o=!1,features:s,diffBase:c,errors:l,errorKindClassName:u,onApplyErrorFix:d,linkCatalog:f,images:p,imageModulePath:m,onImageUpload:h,imageAccept:g,uploadProgress:_,buttonVariants:v,detailsVariants:y,className:x,portalContainer:S}=e,{moduleEntries:C,getUrl:w,ready:T}=iA(m),E=T&&!!C,D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=(0,b.useRef)(null),A=(0,b.useRef)(null),j=(0,b.useRef)([]),M=(0,b.useRef)(i),N=(0,b.useRef)(a),P=(0,b.useRef)(d),F=(0,b.useRef)(f),I=(0,b.useRef)(p),L=(0,b.useRef)(C),R=(0,b.useRef)(w),[ee,te]=(0,b.useState)(null),ne=(0,b.useRef)(ee);ne.current=ee;let re=(0,b.useRef)(void 0),ie=(0,b.useRef)(h),ae=(0,b.useRef)(g),oe=(0,b.useRef)(_),se=(0,b.useRef)(v),ce=(0,b.useRef)(y),le=(0,b.useRef)(S),ue=(0,b.useRef)(null),de=n!==void 0;(0,b.useEffect)(()=>{M.current=i,N.current=a,P.current=d,F.current=f,I.current=p,L.current=C,R.current=w,ie.current=h,ae.current=g,oe.current=_,se.current=v,ce.current=y,le.current=S,E?re.current=(e,t)=>(0,Y.jsx)(uA,{moduleEntries:L.current,selectedRef:e,isImage:!0,getUrl:R.current,autoFocus:!0,maxHeight:280,onSelect:e=>{t(e.filePath)}}):p&&p.length>0?re.current=(e,t)=>(0,Y.jsx)(N3,{images:I.current,currentSrc:e,onSelect:t}):re.current=void 0});let fe={...MHe,...s},pe=fe.styles,me=(0,b.useMemo)(()=>rHe({features:fe,buttonVariants:v,detailsVariants:y,styleConfig:pe}),[]);A.current=me.marks.link??null;let he=fe.fixedToolbar&&lUe({schema:me,features:fe,styleConfig:pe,canInsertImage:!!h||!!p?.length||!!m,buttonVariants:v,detailsVariants:y});(0,b.useLayoutEffect)(()=>{if(!D.current)return;let e=de?n:r??[],t,i=ue.current;if(ue.current=null,i!==null&&i.type.schema===me)t=i;else{try{t=n2(e??[],me)}catch{t=me.node(`doc`,null,[me.node(`paragraph`)])}j.current=e??[]}let a=()=>le.current??null,s=[...NHe(me,fe),IHe(me,fe),S0(),E0(),M0(),HHe(),$He(fe),eUe(),tGe({getPortalContainer:a,onApplyErrorFix:e=>{if(e.kind===`schema.violation`&&k.current){YHe(k.current,e.path,e.fixId);return}P.current?.(e)}})],c=()=>F.current,l=()=>se.current,u=()=>ce.current,d=sUe({getLinkCatalog:c,getPortalContainer:a,onPickerStateChange:e=>{te(e)},isPickerOpen:()=>ne.current!==null});s.push(rGe({getLinkCatalog:c})),!o&&fe.link&&s.push(oGe(me,{getLinkCatalog:c,linkHelper:d}));let f=()=>I.current,p=()=>L.current,m=()=>R.current,h=()=>ie.current,g=()=>ae.current,_=()=>oe.current;fe.fixedToolbar&&s.push(JWe(me,{getMount:()=>O.current,getLinkCatalog:c,getImages:f,getImageModuleEntries:p,getImageGetUrl:m,getOnImageUpload:h,getImageAccept:g,getUploadProgress:_,getButtonVariants:l,getDetailsVariants:u,linkHelper:d,styleConfig:pe,features:fe,readOnly:o})),fe.floatingToolbar&&!o&&s.push(XWe(me,{getPortalContainer:a,getLinkCatalog:c,getImages:f,getImageModuleEntries:p,getImageGetUrl:m,getOnImageUpload:h,getImageAccept:g,getUploadProgress:_,getButtonVariants:l,getDetailsVariants:u,linkHelper:d,styleConfig:pe,features:fe})),fe.gutter&&!o&&s.push(QWe(me,fe,{getPortalContainer:a}));let v={};me.nodes.image&&(v.image=cGe(re,{inline:!0,getPortalContainer:a,getUrl:m,getOnImageUpload:h,getImageAccept:g})),me.nodes.button_atom&&(v.button_atom=dGe(se,{getPortalContainer:a})),me.nodes.button_editable&&(v.button_editable=fGe(se,{getPortalContainer:a})),me.nodes.details&&(v.details=gGe(me));let y=vQ.create({doc:t,plugins:s}),b=new i0(D.current,{state:y,editable:()=>!o,nodeViews:v,dispatchTransaction(e){let t=b.state.apply(e);if(b.updateState(t),e.docChanged&&(N.current?.(),M.current)){let e=o2(t.doc),n=e2(j.current,e);j.current=e,M.current({value:e,patches:n})}}});return k.current=b,()=>{ue.current=b.state.doc,d.destroy(),b.destroy(),k.current=null}},[me,o,he,fe.floatingToolbar,fe.gutter]),(0,b.useEffect)(()=>{let e=k.current;e&&e.dispatch(e.state.tr)},[C,p,h,v,y]),(0,b.useEffect)(()=>{let e=k.current;if(!e||!de||!n)return;let t=o2(e.state.doc);if(JSON.stringify(t)!==JSON.stringify(n))try{let t=n2(n,me),r=e.state.selection,i=vQ.create({doc:t,plugins:e.state.plugins,selection:G3(r,t)});e.updateState(i),j.current=n}catch(e){console.error(e)}},[n,de,me]),(0,b.useEffect)(()=>{let e=k.current;if(e){if(c)try{let t=n2(c,me),n=e.state.tr.setMeta(J2,{baseDoc:t});e.dispatch(n)}catch{}else{let t=e.state.tr.setMeta(J2,{baseDoc:null});e.dispatch(t)}}},[c,me]),(0,b.useEffect)(()=>{let e=k.current;if(!e)return;let t=e.state.tr.setMeta(i4,{errors:l??[],errorKindClassName:u??{}});e.dispatch(t)},[l,u]);let ge=(0,b.useCallback)(()=>k.current?o2(k.current.state.doc):[],[]),_e=(0,b.useCallback)(e=>e2(e,k.current?o2(k.current.state.doc):[]),[]),ve=(0,b.useCallback)(e=>{let t=k.current;if(!t)return;let n=e?n2(e,me):me.node(`doc`,null,[me.node(`paragraph`)]),r=t.state.selection,i=vQ.create({doc:n,plugins:t.state.plugins,selection:G3(r,n)});t.updateState(i),j.current=e??[]},[me]);(0,b.useImperativeHandle)(t,()=>({getDocument:ge,getPatches:_e,reset:ve}),[ge,_e,ve]);let ye=(0,b.useCallback)(e=>{let t=k.current,n=A.current,r=ne.current;if(!t||!n||!r)return;let{state:i,dispatch:a}=t,o=i.tr;e?(o=o.removeMark(r.savedFrom,r.savedTo,n),o=o.addMark(r.savedFrom,r.savedTo,n.create({href:e}))):o=o.removeMark(r.savedFrom,r.savedTo,n),a(o),te(null),t.focus()},[]),be=(0,b.useCallback)(e=>{ye(e.href.trim())},[ye]),xe=(0,b.useCallback)(()=>{ye(null)},[ye]),Se=(0,b.useCallback)(e=>{ye(e)},[ye]),Ce=(0,b.useCallback)(()=>{ye(null)},[ye]),we=(0,b.useCallback)(()=>{te(null),k.current?.focus()},[]);return(0,Y.jsxs)(`div`,{className:[`rich-text-editor relative flex flex-col`,o?`cursor-default`:``,x??``].filter(Boolean).join(` `),children:[he&&(0,Y.jsx)(`div`,{ref:O,className:[`rounded-t-md border border-border-primary`,`bg-bg-secondary absolute left-0 top-0 z-hover w-full`].join(` `)}),(0,Y.jsx)(`div`,{ref:D,className:[`prose-editor relative min-h-10 border border-border-primary`,`bg-bg-primary text-fg-primary caret-fg-primary`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-border-focus rounded-md`,`px-3 py-2`,he?`pt-14`:``,o?`opacity-80`:``].join(` `)}),ee&&(S?(0,lm.createPortal)((0,Y.jsx)(W3,{state:ee,useFixedPosition:!0,onApplyLink:be,onRemoveLink:xe,onApplyUrl:Se,onUnlink:Ce,onClose:we}),S):(0,Y.jsx)(W3,{state:ee,onApplyLink:be,onRemoveLink:xe,onApplyUrl:Se,onUnlink:Ce,onClose:we}))]})});function vGe(e){if(!e)return{};let t={};return t.bold=e.bold??!1,t.italic=e.italic??!1,t.strikethrough=e.lineThrough??!1,t.h1=e.h1??!1,t.h2=e.h2??!1,t.h3=e.h3??!1,t.h4=e.h4??!1,t.h5=e.h5??!1,t.h6=e.h6??!1,t.bulletList=e.ul??!1,t.orderedList=e.ol??!1,t.link=!!e.a,t.image=!!e.img,t.hardBreak=!0,t.fixedToolbar=!0,t.floatingToolbar=!1,t.gutter=!1,t.code=!1,t.blockquote=!1,t.codeBlock=!1,t.details=!1,t.button=!1,t}function yGe(e){if(!(!e||typeof e.path!=`string`))return H.mediaUrl({path:e.path})}function bGe(e){let t=(0,b.useMemo)(()=>vGe(e),[e]),n=e?.a===!0||typeof e?.a==`object`&&`type`in e.a&&e.a.type===`route`,r=n&&e?.a&&typeof e.a==`object`&&`type`in e.a&&e.a.type===`route`?e.a:void 0,i=(0,b.useMemo)(()=>r?.options?.include?new RegExp(r.options.include.source,r.options.include.flags):void 0,[r?.options?.include?.source,r?.options?.include?.flags]),a=(0,b.useMemo)(()=>r?.options?.exclude?new RegExp(r.options.exclude.source,r.options.exclude.flags):void 0,[r?.options?.exclude?.source,r?.options?.exclude?.flags]),o=TA(),s=ooe();return{features:t,linkCatalog:(0,b.useMemo)(()=>{if(!n)return;let e=new Map;return o.filter(({route:e})=>!(i&&!i.test(e)||a&&a.test(e))).map(({route:t,moduleFilePath:n})=>{if(!e.has(n)){let t=new Map,r=s[n];if(r){let e=r[n];if(e&&`data`in e&&e.data&&e.data.parent===`record`)for(let[n,r]of e.data.items)t.set(n,{title:r.title,subtitle:r.subtitle,image:yGe(r.image)})}e.set(n,t)}let r=e.get(n)?.get(t);return r?{title:r.title,subtitle:r.subtitle??n,href:t,image:r.image}:{title:t,subtitle:n,href:t}})},[n,o,i,a,s]),imageModulePath:(0,b.useMemo)(()=>{let t=e?.img;if(t&&typeof t==`object`&&`type`in t&&t.type===`image`&&`referencedModule`in t&&typeof t.referencedModule==`string`)return t.referencedModule},[e]),imageSchema:(0,b.useMemo)(()=>{let t=e?.img;if(t&&typeof t==`object`&&`type`in t&&t.type===`image`)return t},[e])}}var xGe=400;function SGe({path:e,readonly:t}){let n=`richtext`,r=bb(),i=xS(),a=SS(),{source:o,schema:s,patchPath:c,addPatch:l,addAndUploadPatchWithFileOps:u,addModuleFilePatch:d}=yb(e,n),f=`data`in o?o.data:void 0,p=(0,b.useRef)(null),m=(0,b.useRef)(f??[]),h=(0,b.useRef)(null),g=(0,b.useRef)(!1),_=(0,b.useRef)(!1),v=(0,b.useRef)(!1),y=(0,b.useRef)(null),[x,S]=(0,b.useState)(null),C=`clientSideOnly`in o&&o.clientSideOnly;(0,b.useEffect)(()=>{if(C!==!1||!f||v.current)return;let e=f,t=p.current?.getDocument();t&&!Mr(t,e)&&(p.current?.reset(e),m.current=e)},[f,C]);let w=eb(),T=`data`in s&&s.data.type===`richtext`?s.data.options:void 0,{features:E,linkCatalog:D,imageModulePath:O,imageSchema:k}=bGe(T),A=!!T?.img,j=k?.referencedModule,M=Tb(j),N=(0,b.useMemo)(()=>{if(A){if(k?.options?.accept)return k.options.accept;if(M?.type===`record`&&M.accept)return M.accept}},[A,k,M]),P=(0,b.useMemo)(()=>M?.type===`record`?M.directory:void 0,[M]),F=(0,b.useMemo)(()=>{let e=M?.type===`record`?M.encode:void 0;return{settings:hA(k?.options?.encode,e),accept:N}},[k,M,N]),I=(0,b.useMemo)(()=>!A||!k?.remote||i.status!==`ready`||!a||!r?.remoteHost?null:{publicProjectId:i.publicProjectId,bucket:a,coreVersion:i.coreVersion,schema:k,remoteHost:r.remoteHost},[A,k,i,a,r]),L=(0,b.useMemo)(()=>{if(A)return async(e,t)=>{try{let n=await gA(e,F),r;n.width&&n.height&&n.mimeType&&(r={width:n.width,height:n.height,mimeType:n.mimeType});let{patch:i,filePath:a}=await CA(c,n.src,n.filename??null,n.fileHash,r,`image`,I,P,!!j);if(i.length===0)return null;let o=i[0]&&`value`in i[0]&&typeof i[0].value==`object`&&i[0].value!==null&&`path`in i[0].value?i[0].value.path:a,s=i.filter(e=>e.op===`file`);_.current=!0;let l=t(o,{previewUrl:n.src,width:r?.width,height:r?.height,mimeType:r?.mimeType});h.current&&=(clearTimeout(h.current),null),v.current=!1;let f=p.current?.getDocument();if(!f)return null;let g=K3(c,f);m.current=f;let y=s.map(e=>({...e,...l?{nestedFilePath:l}:{}})),b=[...g,...y],x=[];j&&a&&r?.mimeType&&r.width!==void 0&&r.height!==void 0&&x.push({moduleFilePath:j,patch:[{op:`add`,path:[a],value:{width:r.width,height:r.height,mimeType:r.mimeType,alt:null}}]}),S(0),await u(b,`image`,e=>{console.error(`Failed to upload image in richtext:`,e),S(null)},(e,t,n,r)=>{let i=t>0?Math.round(e*(n+1)/(t*r)*100):0;S(Math.min(i,100))}),S(null);for(let e of x)d(e.moduleFilePath,e.patch,`record`);return{filePath:a,ref:o}}catch(e){return console.error(`Failed to prepare image for upload`,e),S(null),null}}},[A,c,I,P,j,u,d,F]),R=(0,b.useCallback)(()=>{if(!g.current){if(_.current){_.current=!1;return}v.current=!0,y.current=p.current?.getDocument()??null,h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,ee.current()},xGe)}},[]),ee=(0,b.useRef)(()=>void 0);return ee.current=()=>{let e=y.current??p.current?.getDocument();if(!e)return;y.current=null;let t=K3(c,e);m.current=e,l(t,`richtext`),v.current=!1},(0,b.useEffect)(()=>()=>{h.current&&(clearTimeout(h.current),h.current=null,ee.current()),v.current=!1},[]),s.status===`error`?(0,Y.jsx)(NC,{path:e,error:s.error,type:n}):o.status===`error`?(0,Y.jsx)(FC,{path:e,error:o.error,schema:s}):o.status===`not-found`||s.status===`not-found`?(0,Y.jsx)(MC,{path:e,type:n}):s.status===`loading`||!(`data`in o)||o.data===void 0?(0,Y.jsx)(jC,{path:e,type:n}):s.data.type===n?(r?.remoteHost||console.warn(`RichTextField: config.remoteHost is not set. Remote images will not work.`),(0,Y.jsx)(`div`,{id:e,className:`m-1`,children:(0,Y.jsx)(_Ge,{ref:p,defaultValue:f??[],features:E,linkCatalog:D,readOnly:t||g.current,onDirty:R,imageModulePath:O,onImageUpload:L,imageAccept:N,uploadProgress:x,portalContainer:w})})):(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:s.data.type})}function K3(e,t){return[{op:`replace`,path:e,value:t}]}function CGe({path:e}){let t=Ob(e,`richtext`);if(t.status===`error`)return(0,Y.jsx)(FC,{path:e,error:t.error});if(t.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:`richtext`});if(!(`data`in t)||t.data===void 0)return(0,Y.jsx)(J3,{path:e});if(t.data===null)return(0,Y.jsx)(Y3,{path:e});let n=wGe(t.data);return n.status===`error`?(0,Y.jsx)(FC,{path:e,error:n.error}):(0,Y.jsx)(`div`,{className:`truncate`,children:n.value})}function wGe(e){let t;function n(e){if(t)return t;if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(`children`in e&&Array.isArray(e.children))return e.children.map(n).join(` `);if(`tag`in e&&typeof e.tag==`string`)return``}return t=`Invalid richtext node: `+JSON.stringify(e),JSON.stringify(e)}let r=e.map(n).join(` `);return t?{status:`error`,error:t}:{status:`ok`,value:r}}function q3({path:e,size:t}){let n=Cb(e),r=Ob(e,`data`in n&&n.data.type?n.data.type:void 0);if(!(`data`in n)||n.data===void 0)return(0,Y.jsx)(J3,{path:e});let i=n.data.type;return`data`in r&&r.data===null?(0,Y.jsx)(Y3,{path:e}):i===`string`?(0,Y.jsx)(ude,{path:e}):i===`array`?(0,Y.jsx)(FGe,{path:e}):i===`boolean`?(0,Y.jsx)(Cde,{path:e}):i===`number`?(0,Y.jsx)(Tde,{path:e}):i===`union`?(0,Y.jsx)(ige,{path:e}):i===`object`?(0,Y.jsx)(Jhe,{path:e,size:t}):i===`image`?(0,Y.jsx)(Uge,{path:e}):i===`keyOf`?(0,Y.jsx)(qge,{path:e}):i===`route`?(0,Y.jsx)(y_e,{path:e}):i===`date`?(0,Y.jsx)(qye,{path:e}):i===`dateTime`?(0,Y.jsx)(nbe,{path:e}):i===`color`?(0,Y.jsx)(nRe,{path:e}):i===`code`?(0,Y.jsx)($Le,{path:e}):i===`literal`?(0,Y.jsx)(rRe,{path:e}):i===`record`?(0,Y.jsx)(FRe,{path:e,size:t}):i===`richtext`?(0,Y.jsx)(CGe,{path:e}):i===`file`?(0,Y.jsx)(zge,{path:e}):(0,Y.jsxs)(`div`,{children:[`Cannot preview: `,i]})}function J3({path:e}){return(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(hy,{size:12,className:`animate-spin`})},e+`-loading`)}function Y3({path:e}){return(0,Y.jsx)(`div`,{id:e,className:`text-fg-quaternary`,children:`<empty>`},e+`-null`)}function X3({path:e,className:t,size:n}){let r=fk(e);return r?(0,Y.jsx)(ode,{title:r.title,image:r.image,subtitle:r.subtitle??null,className:t,size:n}):(0,Y.jsx)(`div`,{className:X(`p-2`,t),children:(0,Y.jsx)(q3,{path:e,size:n})})}function Z3({source:e,disabled:t,onMove:n,renderItem:r,className:i}){let[a,o]=(0,b.useState)([]);(0,b.useEffect)(()=>{let t=[],n=1;for(let r of e)t.push({path:r,id:n}),n++;o(t)},[e]);let s=bw(yw(nT),yw(iT),yw(Xw,{coordinateGetter:AT})),[c,l]=(0,b.useState)(null),u=c===null?void 0:a.find(e=>e.id===c),d=(0,b.useCallback)(e=>{let{active:t,over:r}=e;if(t?.id!==r?.id){let e=a.findIndex(e=>e.id===Number(t?.id)),i=a.findIndex(e=>e.id===Number(r?.id));o(t=>TT(t,e,i)),n(e,i)}l(null)},[a,n]);return(0,Y.jsxs)(bue,{sensors:s,collisionDetection:Dw,onDragStart:e=>l(Number(e.active.id)),onDragEnd:d,onDragCancel:()=>l(null),children:[(0,Y.jsx)(Yue,{items:a,strategy:Gue,disabled:t,children:(0,Y.jsx)(`div`,{className:i??`flex flex-col gap-y-4 w-full`,children:a.map(({path:e,id:t},n)=>(0,Y.jsx)(`div`,{style:{opacity:t===c?.3:void 0},children:r({path:e,id:t,index:n})},t))})}),(0,Y.jsx)(Bue,{dropAnimation:null,children:u?r({path:u.path,id:u.id,index:a.indexOf(u)}):null})]})}function TGe({source:e,disabled:t,onClick:n,onMove:r,onDelete:i,onDuplicate:a}){return(0,Y.jsx)(Z3,{source:e,disabled:t,onMove:r,renderItem:({path:e,id:r})=>(0,Y.jsx)(EGe,{id:r,disabled:t,path:e,onClick:n,onDelete:e=>{i(e-1)},onDuplicate:e=>{a(e-1)}})})}function EGe({id:e,path:t,disabled:n,onClick:r,onDelete:i,onDuplicate:a}){let o=eb(),s=(0,b.useRef)(null),[c,l]=(0,b.useState)(!1);(0,b.useEffect)(()=>{s.current&&(s.current.getBoundingClientRect().height>=170?l(!0):l(!1))},[e,t]);let{attributes:u,listeners:d,setNodeRef:f,transform:p,transition:m}=OT({id:e,disabled:n===!0}),h=Fb()||{},g={transform:mw.Transform.toString(p),transition:m},_=!(h[t]?.length>0);return(0,Y.jsxs)(`div`,{"touch-action":`manipulation`,ref:f,style:g,className:X(`relative flex disabled:opacity-55 flex-1`,{"items-start":!_,"items-center":_}),children:[(0,Y.jsx)(`button`,{...u,...d,className:X(`pb-1 pr-2 rounded-sm text-fg-secondary hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,{"opacity-30":n,"mt-2.5":!_}),disabled:n,onClick:()=>{r(t)},children:(0,Y.jsx)(ay,{})}),(0,Y.jsxs)(`button`,{className:X(`flex-grow`,`relative flex text-left border rounded-lg border-border bg-card gap-y-2 bg-bg-primary`,`hover:bg-bg-secondary-hover`,`overflow-y-clip`),style:{maxHeight:170},ref:s,disabled:n,onClick:()=>{r(t)},children:[(0,Y.jsx)(X3,{path:t,className:`flex-grow w-full`}),c&&(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full bg-gradient-to-b via-50% from-transparent via-card/90 to-card`,style:{height:40}})]}),cX(t,h)&&(0,Y.jsx)(`div`,{className:X(`absolute right-3`,{"top-2":_,"top-0":!_}),children:(0,Y.jsx)(lX,{})}),(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{className:X(`flex hover:bg-bg-secondary-hover px-2 hover:rounded-lg`,{"items-start mt-4":!_,"items-center py-2":_}),children:(0,Y.jsx)(Yv,{size:16})}),(0,Y.jsxs)(wD,{className:`p-2`,container:o,side:`top`,children:[(0,Y.jsxs)(`button`,{className:X(`flex items-center gap-x-2`),onClick:()=>{i(e)},children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(Iy,{className:`w-4 h-4`})}),(0,Y.jsx)(`span`,{children:`Delete`})]}),(0,Y.jsxs)(`button`,{className:X(`flex items-center gap-x-2`),onClick:()=>{a(e)},children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(qv,{className:`w-4 h-4`})}),(0,Y.jsx)(`span`,{children:`Duplicate`})]})]})]})]})}var DGe=X(`[&_input]:h-7 [&_input]:m-0 [&_input]:w-full [&_input]:px-2 [&_input]:py-1 [&_input]:text-[13px]`,`[&_textarea]:min-h-0 [&_textarea]:m-0 [&_textarea]:px-2 [&_textarea]:py-1 [&_textarea]:text-[13px] [&_textarea]:leading-5 [&_textarea]:[field-sizing:content]`,`[&_[data-testid=auto-growing-textarea-ghost]]:m-0 [&_[data-testid=auto-growing-textarea-ghost]]:px-2 [&_[data-testid=auto-growing-textarea-ghost]]:py-1 [&_[data-testid=auto-growing-textarea-ghost]]:text-[13px] [&_[data-testid=auto-growing-textarea-ghost]]:leading-5`,`[&_.rich-text-editor:not(:focus-within)_.prose-editor]:p-2 [&_.rich-text-editor:not(:focus-within)_.prose-editor]:min-h-0`,`[&_.rich-text-editor:not(:focus-within)>.absolute]:hidden`,`[&_.prose-editor]:text-[13px]`);function Q3({path:e,readonly:t,depth:n=0}){let r=`array`,{navigate:i}=GC(),a=Ab(e),{source:o,schema:s,addPatch:c,patchPath:l}=yb(e,r,{watchUnsaved:!0}),[u,d]=(0,b.useState)([]),f=`data`in o&&o.data?o.data:null;(0,b.useEffect)(()=>{let e=[],t=1;for(let n of f??[])e.push({path:n,id:t}),t++;d(e)},[f]);let p=bw(yw(nT),yw(iT),yw(Xw,{coordinateGetter:AT})),[m,h]=(0,b.useState)(null),g=m===null?void 0:u.find(e=>e.id===m),_=(0,b.useCallback)((e,t)=>{c([{op:`move`,from:l.concat(e.toString()),path:l.concat(t.toString())}],r)},[c,l]),v=(0,b.useCallback)(e=>{let{active:t,over:n}=e;if(t?.id!==n?.id){let e=u.findIndex(e=>e.id===Number(t?.id)),r=u.findIndex(e=>e.id===Number(n?.id));d(t=>TT(t,e,r)),_(e,r)}h(null)},[u,_]);if(s.status===`error`||s.status===`not-found`||s.status===`loading`||f===null||s.data.type!==`array`)return null;let y=s.data,x=(e,o)=>(0,Y.jsx)(OGe,{id:e.id,index:o,path:e.path,itemSchema:y.item,depth:n,readonly:t,onNavigate:e=>i(e),onDelete:()=>{c([{op:`remove`,path:l.concat(o.toString())}],r)},onDuplicate:()=>{`data`in a&&a.data&&Array.isArray(a.data)&&c([{op:`add`,path:l.concat(o.toString()),value:a.data[o]??null}],r)}},e.id);return(0,Y.jsxs)(`div`,{id:e,className:X(`w-full`,{[DGe]:n===0}),children:[(0,Y.jsxs)(bue,{sensors:p,collisionDetection:Dw,onDragStart:e=>h(Number(e.active.id)),onDragEnd:v,onDragCancel:()=>h(null),children:[(0,Y.jsx)(Yue,{items:u,strategy:Gue,disabled:t,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:u.map((e,t)=>(0,Y.jsx)(`div`,{style:{opacity:e.id===m?.3:void 0},children:x(e,t)},e.id))})}),(0,Y.jsx)(Bue,{dropAnimation:null,children:g?x(g,u.indexOf(g)):null})]}),!t&&(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 h-6 mt-0.5 px-1 text-xs text-fg-tertiary hover:text-fg-primary`,onClick:()=>{c([{op:`add`,path:l.concat(u.length.toString()),value:Cp(y.item)}],r)},children:[(0,Y.jsx)(Oy,{size:12}),(0,Y.jsx)(`span`,{children:`Add`})]})]})}function OGe({id:e,index:t,path:n,itemSchema:r,depth:i,readonly:a,onNavigate:o,onDelete:s,onDuplicate:c}){let{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p}=OT({id:e,disabled:a===!0}),[m,h]=(0,b.useState)(!1),g=Pb(n),_={transform:mw.Transform.toString(f),transition:p},v=xr(r),y=v&&(r.type===`object`||r.type===`union`&&Zhe(r)),x=(0,Y.jsx)(`button`,{...l,...u,className:X(`cursor-grab text-fg-quaternary hover:text-fg-primary`,{"opacity-30":a}),disabled:a,children:(0,Y.jsx)(ay,{size:14})}),S=a?null:(0,Y.jsx)(MGe,{onDelete:s,onDuplicate:c});return(0,Y.jsxs)(`div`,{"touch-action":`manipulation`,"data-val-studio-path":n,ref:d,style:_,className:X(`border bg-bg-primary`,i===0?`rounded-md`:`rounded-r-md border-l-0`,{"border-border-primary":g.length===0,"border-bg-warning-secondary":g.length>0}),children:[y&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 h-7 px-1.5`,children:[x,(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 flex-1 min-w-0 text-left`,onClick:()=>h(e=>!e),children:[(0,Y.jsx)(Rv,{size:12,className:X(`shrink-0 text-fg-quaternary transition-transform`,{"rotate-90":!m})}),(0,Y.jsx)(`span`,{className:`w-4 shrink-0 text-[10px] text-fg-quaternary`,children:t+1}),(0,Y.jsx)(jGe,{path:n})]}),S]}),y&&!m&&(0,Y.jsx)(`div`,{className:`pr-1.5 pb-1.5 pt-0.5`,children:r.type===`union`?(0,Y.jsx)(kGe,{path:n,itemSchema:r,depth:i,readonly:a}):(0,Y.jsx)($3,{path:n,itemSchema:r,depth:i,readonly:a})}),v&&!y&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 px-1.5 py-1`,children:[(0,Y.jsx)(`div`,{className:`pt-2`,children:x}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(r6,{path:n,schema:r,readonly:a===!0||r.readonly===!0,compact:!0,errorDisplay:`none`})}),S]}),!v&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 py-1`,children:[x,(0,Y.jsx)(`button`,{className:`flex-1 min-w-0 overflow-y-clip rounded text-left text-xs hover:bg-bg-secondary-hover`,style:{maxHeight:96},onClick:()=>o(n),children:(0,Y.jsx)(X3,{path:n,className:`w-full`})}),S]}),g.length>0&&(0,Y.jsx)(`div`,{className:`px-2.5 pb-1.5`,children:(0,Y.jsx)(Uk,{validationErrors:g})})]})}function kGe({path:e,itemSchema:t,depth:n,readonly:r}){return Zhe(t)?(0,Y.jsx)(AGe,{path:e,itemSchema:t,depth:n,readonly:r}):null}function AGe({path:e,itemSchema:t,depth:n,readonly:r}){let i=$he(e,t);return i.status===`loading`?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{className:`pl-2`,children:(0,Y.jsx)(ege,{state:i,readonly:r,className:`h-7 w-auto min-w-24 px-2 py-1 text-[13px]`})}),(0,Y.jsx)($3,{path:e,itemSchema:i.selectedSchema,depth:n,readonly:r,omitKeys:[t.key]})]})}function $3({path:e,itemSchema:t,depth:n,readonly:r,omitKeys:i}){let[a,o]=(0,b.useState)({});return t.type===`object`?(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:Object.entries(t.items).map(([t,s])=>{if(s.hidden||i?.includes(t))return null;let c=sD(e,t),l=r===!0||s.readonly===!0;if(s.type===`array`&&xr(s.item)){let e=a[t]===!0;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 pl-2 text-left`,onClick:()=>o(n=>({...n,[t]:!e})),children:[(0,Y.jsx)(Rv,{size:10,className:X(`shrink-0 text-fg-quaternary transition-transform`,{"rotate-90":!e})}),(0,Y.jsx)(e6,{label:t})]}),!e&&(0,Y.jsx)(Q3,{path:c,depth:n+1,readonly:l})]},t)}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2`,children:[(0,Y.jsx)(e6,{label:t}),(0,Y.jsx)(r6,{path:c,schema:s,readonly:l,compact:!0,errorDisplay:`compact`})]},t)})}):null}function e6({label:e}){return(0,Y.jsx)(`span`,{className:`text-[11px] leading-4 text-fg-tertiary`,children:e})}function jGe({path:e}){let t=fk(e),n=Ab(e),r=(0,b.useMemo)(()=>t?.title?t.title:`data`in n&&n.data!==void 0?t6(n.data):null,[t,n]);return(0,Y.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-xs text-fg-tertiary`,children:r??``})}function t6(e){if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=t6(t);if(e!==null)return e}return null}if(typeof e==`object`&&e)for(let[t,n]of Object.entries(e)){if(t===`type`||t===`_type`||t===`tag`||n===void 0)continue;let e=t6(n);if(e!==null)return e}return null}function MGe({onDelete:e,onDuplicate:t}){let n=eb();return(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{className:`shrink-0 rounded px-0.5 py-1 text-fg-quaternary hover:text-fg-primary hover:bg-bg-secondary-hover`,children:(0,Y.jsx)(Yv,{size:14})}),(0,Y.jsxs)(wD,{className:`p-2 w-auto`,container:n,side:`top`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-x-2 text-sm`,onClick:e,children:[(0,Y.jsx)(Iy,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:`Delete`})]}),(0,Y.jsxs)(`button`,{className:`flex items-center gap-x-2 text-sm`,onClick:t,children:[(0,Y.jsx)(qv,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:`Duplicate`})]})]})]})}function NGe({id:e,disabled:t,children:n}){let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s}=OT({id:e,disabled:t===!0}),c={transform:mw.Transform.toString(o),transition:s};return(0,Y.jsxs)(`div`,{ref:a,style:c,className:`flex items-start gap-2`,children:[(0,Y.jsx)(`button`,{...r,...i,className:X(`pt-4 pr-1`,{invisible:t}),disabled:t,children:(0,Y.jsx)(ay,{size:16})}),(0,Y.jsx)(`div`,{className:`flex-1`,children:n})]})}function PGe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`array`,{navigate:o}=GC(),s=xb(e),c=Ab(e),{source:l,schema:u,addPatch:d,patchPath:f,hasUnsavedOwnEdit:p}=yb(e,a,{watchUnsaved:!0});if(u.status===`error`)return(0,Y.jsx)(NC,{path:e,error:u.error,type:a});if(l.status===`error`)return(0,Y.jsx)(FC,{path:e,error:l.error,schema:u});if(l.status==`not-found`||u.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(u.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:a});if(u.data.type!==`array`)return(0,Y.jsx)(PC,{path:e,expectedType:`array`,actualType:u.data.type});let m=u.data,h=(s&&`data`in s?s.data:void 0)!==void 0&&(p||l.status===`loading`);if(xr(m.item))return(0,Y.jsxs)(`div`,{className:`relative w-full`,children:[s?.status===`error`&&(0,Y.jsx)(uX,{error:s.message,path:e}),(0,Y.jsx)(Q3,{path:e,readonly:t})]});if(r){let a=l.data;return a===null?null:(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(Z3,{source:a,disabled:t,onMove:(e,t)=>{d([{op:`move`,from:f.concat(e.toString()),path:f.concat(t.toString())}],m.type)},className:`flex flex-col ${n?`gap-3`:`gap-4`}`,renderItem:({path:e,id:a})=>m.item.hidden?null:(0,Y.jsx)(NGe,{id:a,disabled:t,children:(0,Y.jsx)(qk,{path:e,type:m.item.type,readonly:t||m.item.readonly,compact:n,errorDisplay:i,children:(0,Y.jsx)(r6,{path:e,schema:m.item,readonly:t||m.item.readonly,compact:n,inline:r,errorDisplay:i})})})})})}return(0,Y.jsxs)(`div`,{id:e,className:`relative w-full`,children:[s?.status===`error`&&(0,Y.jsx)(uX,{error:s.message,path:e}),h&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-[40] flex items-center text-fg-secondary`,children:(0,Y.jsx)(hy,{className:`animate-spin h-4 w-4`})}),(0,Y.jsx)(TGe,{path:e,disabled:t,onClick:e=>{o(e)},onDelete:async e=>{d([{op:`remove`,path:f.concat(e.toString())}],m.type)},onDuplicate:async e=>{`data`in c&&c.data&&Array.isArray(c.data)&&d([{op:`add`,path:f.concat(e.toString()),value:c.data?.[e]??null}],m.type)},onMove:async(e,t)=>{d([{op:`move`,from:f.concat(e.toString()),path:f.concat(t.toString())}],m.type)},source:l.data||[]})]})}function FGe({path:e}){let t=Ob(e,`array`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{children:`${t.data.length} items`})}function IGe({path:e}){let t=Pb(e)??[];return(0,Y.jsx)(Uk,{validationErrors:t})}var n6=(0,b.createContext)(!1);function LGe({held:e,children:t}){return(0,Y.jsx)(n6.Provider,{value:e,children:t})}function RGe(){return(0,b.useContext)(n6)}function r6({path:e,schema:t,autoFocus:n,readonly:r,compact:i,inline:a,hideUpload:o,errorDisplay:s=`default`}){let c=RGe();if(t.hidden)return null;let l=r||t.readonly||c,u={readonly:l,compact:i},d;if(t.type===`string`)d=(0,Y.jsx)(lde,{path:e,autoFocus:n,...u},e);else if(t.type===`number`)d=(0,Y.jsx)(wde,{path:e,...u},e);else if(t.type===`boolean`)d=(0,Y.jsx)(xde,{path:e,...u},e);else if(t.type===`image`)d=(0,Y.jsx)(Vge,{path:e,...u,hideUpload:o},e);else if(t.type===`object`)return(0,Y.jsx)(qhe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`array`)return(0,Y.jsx)(PGe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`record`)return(0,Y.jsx)(ARe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`union`)return(0,Y.jsx)(Qhe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else d=t.type===`keyOf`?(0,Y.jsx)(Gge,{path:e,...u},e):t.type===`route`?(0,Y.jsx)(v_e,{path:e,...u},e):t.type===`richtext`?(0,Y.jsx)(SGe,{path:e,autoFocus:n,...u},e):t.type===`date`?(0,Y.jsx)(Kye,{path:e,...u},e):t.type===`dateTime`?(0,Y.jsx)(tbe,{path:e,...u},e):t.type===`color`?(0,Y.jsx)(tRe,{path:e,...u},e):t.type===`code`?(0,Y.jsx)(QLe,{path:e,...u},e):t.type===`file`?(0,Y.jsx)(Rge,{path:e,...u},e):t.type===`literal`?(0,Y.jsx)(NC,{path:e,error:`Literal fields are not editable`}):(0,Y.jsx)(NC,{path:e,error:`Unexpected field schema: `+JSON.stringify(t)});return s===`compact`?(0,Y.jsxs)(`div`,{className:`flex items-stretch gap-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:d}),(0,Y.jsx)(`div`,{className:`flex items-center px-1`,children:(0,Y.jsx)(Fhe,{path:e})})]}):(0,Y.jsxs)(Y.Fragment,{children:[d,s==="default"&&(0,Y.jsx)(zGe,{path:e})]})}function zGe({path:e}){return Rhe()?null:(0,Y.jsx)(IGe,{path:e})}var BGe=8,VGe=1200;function HGe({paths:e,selectedPath:t,onSelect:n}){let[r,i]=(0,b.useState)(``),a=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=a.current;if(!t||!e)return;let n=()=>{let n=e.querySelector(`[data-canvas-field="${CSS.escape(t)}"]`);if(!(n instanceof HTMLElement))return;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();i.top>=r.top&&i.bottom<=r.bottom||(e.scrollTop+=i.top-r.top-BGe)};n();let r=new ResizeObserver(n);r.observe(e);for(let t of Array.from(e.children))r.observe(t);let i=setTimeout(()=>r.disconnect(),VGe);return()=>{clearTimeout(i),r.disconnect()}},[t,e]);let o=(0,b.useMemo)(()=>{let t=new Map;for(let n of e){let[e]=H.splitModuleFilePathAndModulePath(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,label:kC(e.split(`/`).pop()??e),entries:t}))},[e]),s=(0,b.useMemo)(()=>{let e=r.trim().toLowerCase();return e?o.map(t=>({...t,entries:t.entries.filter(t=>t.toLowerCase().includes(e))})).filter(e=>e.entries.length>0):o},[o,r]);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-xl border border-border-float bg-bg-float`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-border-float px-3 py-2.5`,children:[(0,Y.jsxs)(`h2`,{className:`text-[0.8125rem] font-medium text-fg-primary`,children:[`On this page`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal text-fg-secondary-alt`,children:e.length})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-[0.6875rem] leading-relaxed text-fg-secondary-alt`,children:`Edit here, or click an element on the page.`})]}),(0,Y.jsx)(`div`,{className:`shrink-0 border-b border-border-float px-2 py-2`,children:(0,Y.jsxs)(`div`,{className:`flex h-7 items-center gap-1.5 rounded-md bg-bg-float-raised px-2 focus-within:ring-2 focus-within:ring-border-focus`,children:[(0,Y.jsx)(My,{size:12,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Filter fields…`,"aria-label":`Filter fields`,className:`min-w-0 flex-1 bg-transparent text-xs text-fg-primary placeholder:text-fg-secondary-alt focus:outline-none`})]})}),(0,Y.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto scrollbar-slim px-2 py-2`,children:s.length===0?(0,Y.jsx)(`p`,{className:`px-1 py-6 text-center text-xs text-fg-secondary-alt`,children:r?`No fields match this filter.`:`The page reported no editable content.`}):s.map(e=>(0,Y.jsxs)(`section`,{className:`mb-3`,children:[(0,Y.jsx)(`h3`,{title:e.moduleFilePath,className:`truncate px-1 pb-1.5 text-[0.625rem] font-medium uppercase tracking-wide text-fg-secondary-alt`,children:e.label}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:e.entries.map(e=>(0,Y.jsx)(UGe,{path:e,selected:t===e,onSelect:n},e))})]},e.moduleFilePath))})]})}function UGe({path:e,selected:t,onSelect:n}){let r=Cb(e);return(0,Y.jsxs)(`div`,{"data-canvas-field":e,onFocusCapture:()=>n?.(e),className:X(`rounded-lg border px-2.5 py-2`,t?`border-border-brand-primary bg-bg-float-raised`:`border-border-float`),children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n?.(e),title:e,className:`mb-1.5 block max-w-full truncate text-left text-[0.8125rem] font-medium text-fg-primary`,children:WGe(e)}),r.status===`error`?(0,Y.jsx)(NC,{path:e,error:r.error,type:`module`}):r.status===`loading`?(0,Y.jsx)(jC,{path:e,type:`module`}):r.status===`not-found`?(0,Y.jsx)(MC,{path:e,type:`module`}):(0,Y.jsx)(r6,{path:e,schema:r.data,compact:!0})]})}function WGe(e){let[,t]=H.splitModuleFilePathAndModulePath(e);if(!t)return e;let n=H.splitModulePath(t),r=n.length>1&&n[0].startsWith(`/`)?n.slice(1):n;return r.length===0?n.join(` › `):r.join(` › `)}function i6(e,t,n){(0,b.useEffect)(()=>{if(!t)return;let r=t=>{let r=e.current;r&&t.composedPath().includes(r)||n()};return document.addEventListener(`pointerdown`,r),()=>document.removeEventListener(`pointerdown`,r)},[t,n,e])}var a6=12;function GGe({value:e,routes:t,onChange:n,className:r}){let[i,a]=(0,b.useState)(e),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(0),u=(0,b.useRef)(null);(0,b.useEffect)(()=>{o||a(e)},[e,o]);let d=(0,b.useMemo)(()=>{let e=i.trim().toLowerCase();if(!e)return t.slice(0,a6);let n=t=>{let n=t.toLowerCase();return n===e?0:n.startsWith(e)?1:2};return t.filter(t=>t.toLowerCase().includes(e)).map((e,t)=>({route:e,index:t,rank:n(e)})).sort((e,t)=>e.rank-t.rank||e.index-t.index).slice(0,a6).map(e=>e.route)},[t,i]),f=(0,b.useMemo)(()=>{let e=i.trim().toLowerCase(),n=e?t.filter(t=>t.toLowerCase().includes(e)).length:t.length;return Math.max(0,n-d.length)},[t,i,d.length]);(0,b.useEffect)(()=>l(0),[i]),i6(u,o,(0,b.useCallback)(()=>{s(!1),a(e)},[e]));let p=t=>{let r=KGe(t);s(!1),a(r),r!==e&&n(r)};return(0,Y.jsxs)(`div`,{ref:u,className:X(`relative`,r),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 h-8 pl-2 pr-1 rounded-md border border-border-float bg-bg-float`,children:[(0,Y.jsx)(uy,{size:13,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:t=>{if(t.key===`Escape`){t.preventDefault(),s(!1),a(e),t.currentTarget.blur();return}if(t.key===`Enter`){t.preventDefault();let e=o?d[c]:void 0;p(e??i),t.currentTarget.blur();return}(t.key===`ArrowDown`||t.key===`ArrowUp`)&&d.length>0&&(t.preventDefault(),s(!0),l(e=>((t.key===`ArrowDown`?e+1:e-1)+d.length)%d.length))},spellCheck:!1,"aria-label":`Canvas route`,placeholder:`/`,className:`min-w-0 flex-1 bg-transparent font-mono text-[0.6875rem] text-fg-primary placeholder:text-fg-secondary-alt focus:outline-none`}),i!==e&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Discard the typed route`,onClick:()=>{a(e),s(!1)},className:`grid h-6 w-6 shrink-0 place-items-center rounded text-fg-secondary-alt hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:12})})]}),o&&d.length>0&&(0,Y.jsxs)(`ul`,{role:`listbox`,"aria-label":`Tracked routes`,className:`absolute left-0 right-0 top-full z-window mt-1 max-h-56 overflow-y-auto rounded-md border border-border-float bg-bg-float py-1 shadow-lg scrollbar-slim`,children:[d.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t===c,onMouseMove:()=>l(t),onMouseDown:t=>{t.preventDefault(),p(e)},className:X(`block w-full truncate px-2.5 py-1 text-left font-mono text-[0.6875rem]`,t===c?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary`),children:e})},`${t}-${e}`)),f>0&&(0,Y.jsxs)(`li`,{"aria-hidden":!0,className:`px-2.5 py-1 text-[0.625rem] text-fg-secondary-alt`,children:[f,` more — keep typing to narrow`]})]})]})}function KGe(e){let t=e.trim();if(t===``)return`/`;if(/^[a-z][a-z0-9+.-]*:\/\//i.test(t))try{let e=new URL(t);return`${e.pathname}${e.search}${e.hash}`||`/`}catch{}return t.startsWith(`/`)?t:`/${t}`}var qGe={desktop:1280,tablet:834,mobile:390},JGe={desktop:800,tablet:1112,mobile:844},YGe=`clamp(340px, 34%, 520px)`,o6=320,XGe=280,ZGe=.72,QGe=24,$Ge=`4.5rem`,eKe=`8.25rem`,s6=`2.125rem`,tKe=320,c6=200,l6=`cubic-bezier(0.4, 0, 0.2, 1)`;function nKe({children:e,breakpoint:t,page:n,renderCanvas:r,canvasPaths:i,onSelectCanvasPath:a,selectedCanvasPath:o,canvasRoute:s,onCanvasRouteChange:c,canvasRoutes:l,initialTransform:u,onTransformChange:d,isCanvasOpen:f,onCloseCanvas:p,view:m,onViewChange:h,pane:g,onPaneChange:_,isDevMode:v,onAttachToChat:y,skipTransition:x}){let S=t===`mobile`,C=CC(),w=f&&(n!==void 0||r!==void 0),T=e=>C||x?void 0:e.map(e=>`${e} ${tKe}ms ${l6}`).join(`, `),[E,D]=(0,b.useState)(S?`mobile`:`desktop`),[O,k]=(0,b.useState)(()=>u?.scale??1),A=(0,b.useRef)(O);A.current=O;let j=(0,b.useRef)({x:u?.x??0,y:u?.y??0});(0,b.useEffect)(()=>{d?.({scale:O,...j.current})},[O,d]);let M=(0,b.useCallback)(e=>{j.current=e,d?.({scale:A.current,...e})},[d]),[N,P]=(0,b.useState)(null),[F,I]=(0,b.useState)([]);(0,b.useEffect)(()=>{w||(P(null),I(e=>e.length===0?e:[]))},[w]);let L=(0,b.useRef)(null),R=(0,b.useRef)(null),[ee,te]=(0,b.useState)(null),[ne,re]=(0,b.useState)(0),[ie,ae]=(0,b.useState)(!1),[oe,se]=(0,b.useState)(0);(0,b.useEffect)(()=>{let e=R.current;if(!e)return;let t=new ResizeObserver(()=>se(e.clientWidth));return t.observe(e),se(e.clientWidth),()=>t.disconnect()},[]);let ce=(0,b.useMemo)(()=>{if(oe===0)return{min:o6,max:o6};let e=Math.max(o6,Math.min(oe*ZGe,oe-XGe));return{min:Math.min(o6,e),max:e}},[oe]),le=(0,b.useCallback)(e=>Math.round(Math.min(ce.max,Math.max(ce.min,e))),[ce]);(0,b.useEffect)(()=>{if(ee===null)return;let e=le(ee);e!==ee&&te(e)},[ee,le]);let ue=(0,b.useCallback)(e=>{if(e.button!==0)return;let t=R.current;if(!t)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),ae(!0);let n=t.getBoundingClientRect().left,r=e=>{te(le(e.clientX-n))},i=()=>{ae(!1),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),window.removeEventListener(`pointercancel`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i),window.addEventListener(`pointercancel`,i)},[le]),de=(0,b.useCallback)(e=>{let t=R.current,n=ee??t?.firstElementChild?.clientWidth??o6;te(le(n+e))},[ee,le]),fe=qGe[E],[pe,me]=(0,b.useState)(u==null),he=(0,b.useRef)({device:E,open:w});(0,b.useEffect)(()=>{(he.current.device!==E||he.current.open!==w)&&(he.current={device:E,open:w},me(!0))},[E,w]);let ge=(0,b.useCallback)(()=>{re(e=>e+1),me(!0)},[]),_e=(0,b.useCallback)(()=>me(!1),[]),ve=(0,b.useCallback)((e,t)=>{L.current?.zoomBy(e,t)},[]),ye=(0,b.useCallback)(e=>{L.current?.pinch(e)},[]),be=(0,b.useCallback)(e=>{I(t=>t.includes(e)?t:[...t,e]);let t=n?.fields[e];t&&y?.(t.sourcePath)},[n,y]),[xe,Se]=Qce(m),Ce=(0,b.useCallback)(()=>{xe&&(h(`fields`),S&&_(`editor`))},[xe,h,S,_]),[we,z]=(0,b.useState)(!1),B=t===`desktop`&&w?{paddingLeft:`5.5rem`}:void 0,Te=i??[],Ee=n?Object.keys(n.fields).length:Te.length,V=(0,Y.jsx)(oKe,{view:m,onChange:h,fieldCount:Ee>0?Ee:void 0,animate:!C}),De=g===`canvas`?`preview`:m===`fields`?`fields`:`normal`,Oe=(0,b.useCallback)(e=>{if(e===`preview`){_(`canvas`);return}_(`editor`),h(e)},[_,h]),ke=w&&!S,Ae=!ke&&!(w&&S),je=(0,Y.jsx)(`div`,{id:`val-content-area`,"data-scroll-clearance":ke?16:96,className:`h-full overflow-y-auto scrollbar-slim`,children:(0,Y.jsx)(`div`,{style:{maxWidth:qce,...B},className:X(`w-full mx-auto px-4 md:px-6 pb-24`,Ae?`pt-20 desktop:pt-24`:`pt-1`),children:e})}),Me=(0,Y.jsx)(`div`,{style:B,className:`h-full px-4 md:px-6 pt-1 pb-14`,children:n?(0,Y.jsx)(ole,{page:n,selectedFieldId:N,onSelectField:P,onChangeField:()=>void 0,onAttachField:be,attachedFieldIds:F,isDevMode:v}):Te.length>0?(0,Y.jsx)(HGe,{paths:Te,selectedPath:o,onSelect:a}):(0,Y.jsx)(rKe,{onGoToPreview:S?()=>_(`canvas`):void 0})}),Ne=(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[ke&&(0,Y.jsx)(`div`,{style:B,className:`shrink-0 px-4 md:px-6 pt-20 pb-2.5`,children:V}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1`,children:m===`fields`&&w?Me:je})]}),Pe=s!==void 0&&c&&(0,Y.jsx)(GGe,{value:s,routes:l??[],onChange:c,className:`min-w-0 flex-1 md:max-w-[28rem]`}),Fe=w&&(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2`,children:[(Pe||!S)&&(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[Pe,!S&&(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Exit Preview`,onClick:p,className:X(`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md pl-2.5 pr-3`,`border border-border-float bg-bg-float text-fg-secondary`,`hover:text-fg-primary`),children:[(0,Y.jsx)(Hy,{size:15}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:`Exit Preview`})]})]}),(0,Y.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border-float bg-bg-float-raised`,children:(0,Y.jsx)(nle,{ref:L,pageWidth:fe,scale:O,onScaleChange:k,autoFit:pe,onUserZoom:_e,initialScroll:u&&{x:u.x,y:u.y},onScrollChange:M,className:`h-full`,children:(0,Y.jsx)(`div`,{className:`shadow-2xl`,onClick:()=>P(null),children:r?.({device:E,width:fe,height:JGe[E],reloadKey:ne,isPicking:xe,onRequestReload:ge,onRefreshingChange:z,onPinch:ye,onZoom:(e,t)=>ve(e,t),onPicked:Ce})??(n&&(0,Y.jsx)($ce,{page:n,device:E,selectedFieldId:xe?N:null,attachedFieldIds:xe?F:[],onSelectField:e=>{xe&&(P(e),Ce())},isSelectMode:xe}))})})}),(0,Y.jsx)(`div`,{className:`flex shrink-0 justify-center`,children:(0,Y.jsx)(ele,{className:`max-w-full`,device:E,onDeviceChange:D,scale:O,onZoomIn:()=>ve(1.2,null),onZoomOut:()=>ve(1/1.2,null),onFit:()=>me(!0),isPicking:xe,onPickingChange:Ee>0?Se:void 0,isRefreshing:we,onReload:r&&ge})})]});return S?(0,Y.jsxs)(`div`,{className:`absolute inset-0 bg-bg-canvas`,children:[(0,Y.jsx)(`div`,{className:`h-full overflow-clip`,style:w?{paddingTop:eKe}:void 0,children:(0,Y.jsxs)(`div`,{className:`flex h-full w-full`,style:{transform:`translateX(${w&&g===`canvas`?`-100%`:`0%`})`,transition:T([`transform`])},children:[(0,Y.jsx)(`div`,{className:`h-full w-full shrink-0`,children:Ne}),w&&(0,Y.jsx)(`div`,{className:`h-full w-full shrink-0 p-3 pb-14`,children:Fe})]})}),w&&(0,Y.jsxs)(`div`,{className:`absolute inset-x-3 z-window flex items-center gap-2`,style:{top:$Ge},children:[(0,Y.jsx)(aKe,{mode:De,onChange:Oe,fieldCount:Ee>0?Ee:void 0,animate:!C}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Exit Preview`,onClick:p,style:{height:s6,width:s6},className:X(`ml-auto grid shrink-0 place-items-center rounded-md`,`border border-border-float bg-bg-float text-fg-secondary`),children:(0,Y.jsx)(Hy,{size:15})})]})]}):(0,Y.jsxs)(`div`,{ref:R,className:`absolute inset-0 flex overflow-hidden bg-bg-canvas`,children:[(0,Y.jsx)(`div`,{style:{width:w?ee===null?YGe:`${ee}px`:`100%`,transition:ie?void 0:T([`width`])},className:`relative h-full min-w-0 shrink-0`,children:Ne}),w&&(0,Y.jsx)(iKe,{isDragging:ie,onPointerDown:ue,onNudge:de}),(0,Y.jsx)(`div`,{style:{transition:T([`opacity`,`transform`])},className:X(`min-w-0 flex-1 pt-20 pb-14 pr-3`,w?`scale-100 opacity-100`:`invisible pointer-events-none scale-95 opacity-0`),children:Fe})]})}function rKe({onGoToPreview:e}){return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 rounded-xl border border-border-float bg-bg-float px-6 text-center`,children:[(0,Y.jsx)(py,{size:20,className:`text-fg-secondary-alt`}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`h2`,{className:`text-[0.8125rem] font-medium text-fg-primary`,children:`Nothing reported yet`}),(0,Y.jsx)(`p`,{className:`text-[0.6875rem] leading-relaxed text-fg-secondary-alt`,children:`Usually that means preview mode is off: without it the page mounts none of Val's client code and tags nothing, and the Preview has the button that turns it on. A page that is already in preview mode and simply has no Val content on it looks the same from here.`})]}),e&&(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`inline-flex h-8 items-center gap-1.5 rounded-md px-3`,`border border-border-float bg-bg-float-raised text-xs font-medium`,`text-fg-secondary hover:text-fg-primary`),children:[(0,Y.jsx)(Qv,{size:13}),`Go to Preview`]})]})}function iKe({isDragging:e,onPointerDown:t,onNudge:n}){return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the editor and canvas`,tabIndex:0,onPointerDown:t,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),n(-24)):e.key===`ArrowRight`&&(e.preventDefault(),n(QGe))},className:X(`group relative z-hover w-3 shrink-0 cursor-col-resize self-stretch`,`focus-visible:outline-none`),children:(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-y-14 left-1/2 w-px -translate-x-1/2 rounded-full`,`transition-colors`,e?`bg-fg-brand-primary`:`bg-border-float group-hover:bg-fg-secondary group-focus-visible:bg-fg-brand-primary`)})})}function u6({label:e,value:t,onChange:n,options:r,animate:i,compact:a}){let o=Math.max(0,r.findIndex(e=>e.value===t)),s=(0,b.useRef)(null),[c,l]=(0,b.useState)(null);return(0,b.useLayoutEffect)(()=>{let e=s.current;if(e===null)return;let t=()=>{let t=e.querySelectorAll(`button`)[o];if(t===void 0)return;let n=t.getBoundingClientRect().left-e.getBoundingClientRect().left-e.clientLeft,r=t.getBoundingClientRect().width;l(e=>e!==null&&e.left===n&&e.width===r?e:{left:n,width:r})};t();let n=new ResizeObserver(t);return n.observe(e),e.querySelectorAll(`button`).forEach(e=>n.observe(e)),()=>n.disconnect()},[o,r.length]),(0,Y.jsxs)(`div`,{ref:s,role:`tablist`,"aria-label":e,className:`relative inline-flex rounded-md border border-border-float bg-bg-float p-0.5`,children:[c!==null&&(0,Y.jsx)(`span`,{"aria-hidden":!0,style:{width:c.width,transform:`translateX(${c.left}px)`,transition:i?`transform ${c6}ms ${l6}, width ${c6}ms ${l6}`:void 0},className:`absolute inset-y-0.5 left-0 rounded bg-bg-float-raised shadow-sm`}),r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:X(`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded text-[0.6875rem] transition-colors`,a?`px-2.5`:`px-4`,t===e.value?`font-medium text-fg-primary`:`text-fg-secondary hover:text-fg-primary`),children:[(0,Y.jsx)(e.icon,{size:12}),e.label,e.badge!==void 0&&(0,Y.jsx)(`span`,{className:`tabular-nums text-fg-secondary-alt`,children:e.badge})]},e.value))]})}function aKe({mode:e,onChange:t,fieldCount:n,animate:r}){return(0,Y.jsx)(u6,{label:`Workspace view`,value:e,onChange:t,animate:r,options:[{value:`normal`,label:`Normal`,icon:Py},{value:`fields`,label:`Fields`,icon:py,badge:n},{value:`preview`,label:`Preview`,icon:Qv}],compact:!0})}function oKe({view:e,onChange:t,fieldCount:n,animate:r}){return(0,Y.jsx)(u6,{label:`Preview view`,value:e,onChange:t,animate:r,options:[{value:`normal`,label:`Normal`,icon:Py},{value:`fields`,label:`Fields`,icon:py,badge:n}]})}function sKe({selectionKind:e,editedPath:t,canvasModules:n}){if(e===`page`)return!0;if(t===null)return!1;let[r]=H.splitModuleFilePathAndModulePath(t);return n.has(r)?!0:n.size===0&&e===null}function cKe(e){let t=new Set;for(let n of e??[])t.add(H.splitModuleFilePathAndModulePath(n)[0]);return Array.from(t).sort().join(`
|
|
215
|
+
`).scrollIntoView()),!0)};function h2(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var _He=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=h2(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(nQ.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},vHe=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof lQ||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=h2(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(oQ.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},yHe=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(BZ(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&FZ(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function bHe(e){return(t,n)=>{if(t.selection instanceof cQ&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!BZ(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof oQ||t.selection instanceof lQ)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=h2(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=BZ(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,BZ(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var xHe=bHe(),SHe=(e,t)=>(t&&t(e.tr.setSelection(new lQ(e.doc))),!0);function CHe(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||VZ(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function g2(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&CHe(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=vX.empty;for(let e=o.length-1;e>=0;e--)s=vX.from(o[e].create(null,s));s=vX.from(i.copy(s));let c=e.tr.step(new MZ(t.pos-1,r,t.pos,r,new wX(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&VZ(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:nQ.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&FZ(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&f2(a,`start`,!0)&&f2(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=vX.empty;for(let e=o.length-1;e>=0;e--)r=vX.from(o[e].copy(r));n(e.tr.step(new MZ(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new wX(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function _2(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(oQ.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var wHe=_2(-1),THe=_2(1);function v2(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&IZ(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function y2(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t))){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function EHe(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function DHe(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new rQ(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new rQ(r,i))}return t}function b2(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!EHe(n.doc,l,e,i))return!1;if(o){if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=DHe(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}}return!0}}function x2(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var S2=x2(d2,uHe,dHe),C2=x2(d2,pHe,mHe),w2={Enter:x2(gHe,vHe,yHe,xHe),"Mod-Enter":_He,Backspace:S2,"Mod-Backspace":S2,"Shift-Backspace":S2,Delete:C2,"Mod-Delete":C2,"Mod-a":SHe},T2={"Ctrl-h":w2.Backspace,"Alt-Backspace":w2[`Mod-Backspace`],"Ctrl-d":w2.Delete,"Ctrl-Alt-Backspace":w2[`Mod-Delete`],"Alt-Delete":w2[`Mod-Delete`],"Alt-d":w2[`Mod-Delete`],"Ctrl-a":wHe,"Ctrl-e":THe};for(let e in w2)T2[e]=w2[e];var E2=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?T2:w2;function D2(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return OHe(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function OHe(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new LX(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new LX(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=IZ(a,n,r,t);return s?(e&&kHe(e,t,s,i,n),!0):!1}function kHe(e,t,n,r,i){let a=vX.empty;for(let e=n.length-1;e>=0;e--)a=vX.from(n[e].type.create(n[e].attrs,a));e.step(new MZ(t.start-(r?2:0),t.end,t.start,t.end,new wX(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&BZ(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function O2(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(s.type!=e)return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||i.node(-3).type!=e||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let t=vX.empty,a=i.index(-1)?1:i.index(-2)?2:3;for(let e=i.depth-a;e>=i.depth-3;e--)t=vX.from(i.node(e).copy(t));let o=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;t=t.append(vX.from(e.createAndFill()));let s=i.before(i.depth-(a-1)),c=n.tr.replace(s,i.after(-o),new wX(t,4-a,0)),l=-1;c.doc.nodesBetween(s,c.doc.content.size,(e,t)=>{if(l>-1)return!1;e.isTextblock&&e.content.size==0&&(l=t+1)}),l>-1&&c.setSelection(nQ.near(c.doc.resolve(l))),r(c.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return BZ(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function k2(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?AHe(t,n,e,a):jHe(t,n,a):!0:!1}}function AHe(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new MZ(a-1,o,a,o,new wX(vX.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new LX(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));let s=FZ(r);if(s==null)return!1;i.lift(r,s);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return VZ(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),t(i.scrollIntoView()),!0}function jHe(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?vX.empty:vX.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new MZ(d-+!!s,f+ +!!c,d+1,f-1,new wX((s?vX.empty:vX.from(i.copy(vX.empty))).append(c?vX.empty:vX.from(i.copy(vX.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function A2(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=vX.from(r?e.create():null),o=new wX(vX.from(e.create(null,vX.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new MZ(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var j2=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`];function M2(e){return e.h1||e.h2||e.h3||e.h4||e.h5||e.h6}var MHe={bold:!0,italic:!0,strikethrough:!0,code:!0,link:!0,image:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,bulletList:!0,orderedList:!0,blockquote:!0,details:!1,codeBlock:!0,hardBreak:!0,button:!1,fixedToolbar:!0,floatingToolbar:!0,gutter:!0};function NHe(e,t){let n={};if(n[`Mod-z`]=w0,n[`Mod-y`]=T0,n[`Mod-Shift-z`]=T0,e.marks.bold&&(!t||t.bold)&&(n[`Mod-b`]=b2(e.marks.bold)),e.marks.italic&&(!t||t.italic)&&(n[`Mod-i`]=b2(e.marks.italic)),e.marks.strikethrough&&(!t||t.strikethrough)&&(n[`Mod-Shift-x`]=b2(e.marks.strikethrough)),e.marks.code&&(!t||t.code)&&(n[`Mod-e`]=b2(e.marks.code)),e.nodes.hard_break&&(!t||t.hardBreak)){let t=e.nodes.hard_break;n[`Shift-Enter`]=(e,n)=>(n&&n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)}if(e.nodes.heading){for(let r=1;r<=6;r++)(!t||t[j2[r-1]])&&(n[`Mod-Alt-${r}`]=y2(e.nodes.heading,{level:r}));(!t||M2(t))&&(n[`Mod-Alt-0`]=y2(e.nodes.paragraph))}return e.nodes.blockquote&&(!t||t.blockquote)&&(n[`Mod-Shift-b`]=v2(e.nodes.blockquote)),e.nodes.code_block&&(!t||t.codeBlock)&&(n[`Mod-Alt-c`]=y2(e.nodes.code_block)),e.nodes.bullet_list&&(!t||t.bulletList)&&(n[`Mod-Shift-8`]=D2(e.nodes.bullet_list)),e.nodes.ordered_list&&(!t||t.orderedList)&&(n[`Mod-Shift-9`]=D2(e.nodes.ordered_list)),e.nodes.list_item&&(!t||t.bulletList||t.orderedList)&&(n.Enter=O2(e.nodes.list_item),n[`Mod-[`]=k2(e.nodes.list_item),n[`Mod-]`]=A2(e.nodes.list_item)),[O0(n),O0(E2)]}var N2=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?PHe(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function PHe(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var FHe=500;function P2({rules:e}){let t=new bQ({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return F2(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&F2(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function F2(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-FHe),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}new N2(/--$/,`—`,{inCodeMark:!1}),new N2(/\.\.\.$/,`…`,{inCodeMark:!1}),new N2(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new N2(/"$/,`”`,{inCodeMark:!1}),new N2(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new N2(/'$/,`’`,{inCodeMark:!1});function I2(e,t,n=null,r){return new N2(e,(e,i,a,o)=>{let s=n instanceof Function?n(i):n,c=e.tr.delete(a,o),l=c.doc.resolve(a).blockRange(),u=l&&IZ(l,t,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(a-1).nodeBefore;return d&&d.type==t&&VZ(c.doc,a-1)&&(!r||r(i,d))&&c.join(a-1),c})}function L2(e,t,n=null){return new N2(e,(e,r,i,a)=>{let o=e.doc.resolve(i),s=n instanceof Function?n(r):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t)?e.tr.delete(i,a).setBlockType(i,i,t,s):null})}function IHe(e,t){let n=[];return e.nodes.heading&&(!t||M2(t))&&n.push(L2(/^(#{1,6})\s$/,e.nodes.heading,e=>{let n=e[1].length;return t&&!t[j2[n-1]]?!1:{level:n}})),e.nodes.blockquote&&(!t||t.blockquote)&&n.push(I2(/^\s*>\s$/,e.nodes.blockquote)),e.nodes.bullet_list&&(!t||t.bulletList)&&n.push(I2(/^\s*([-+*])\s$/,e.nodes.bullet_list)),e.nodes.ordered_list&&(!t||t.orderedList)&&n.push(I2(/^(\d+)\.\s$/,e.nodes.ordered_list,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order===+e[1])),e.nodes.code_block&&(!t||t.codeBlock)&&n.push(L2(/^```$/,e.nodes.code_block)),P2({rules:n})}function LHe(e){let t=e.schema.cached.changeSetIDs||(e.schema.cached.changeSetIDs=Object.create(null)),n=t[e.name];return n??(t[e.name]=n=Object.keys(e.schema.nodes).indexOf(e.name)+1),n}var R2={encodeCharacter:e=>e,encodeNodeStart:e=>e.type.name,encodeNodeEnd:e=>-LHe(e.type),compareTokens:(e,t)=>e===t};function z2(e,t,n,r,i){for(let a=0,o=0;a<e.childCount;a++){let s=e.child(a),c=o+s.nodeSize,l=Math.max(o,n),u=Math.min(c,r);if(l<u){if(s.isText)for(let e=l;e<u;e++)i.push(t.encodeCharacter(s.text.charCodeAt(e-o),s.marks));else s.isLeaf?i.push(t.encodeNodeStart(s)):(l==o&&i.push(t.encodeNodeStart(s)),z2(s.content,t,Math.max(o+1,l)-o-1,Math.min(c-1,u)-o-1,i),u==c&&i.push(t.encodeNodeEnd(s)))}o=c}return i}var B2=2500;function RHe(e,t){return Math.min(15,Math.max(2,Math.floor(Math.max(e,t)/10)))}function V2(e,t,n,r=R2){return Math.max(n.toA-n.fromA,n.toB,n.fromB)>B2?[n]:zHe(z2(e,r,n.fromA,n.toA,[]),z2(t,r,n.fromB,n.toB,[]),n,r.compareTokens)}function zHe(e,t,n,r){let i=0,a=e.length,o=t.length;for(;i<e.length&&i<t.length&&r(e[i],t[i]);)i++;if(i==e.length&&i==t.length)return[];for(;a>i&&o>i&&r(e[a-1],t[o-1]);)a--,o--;if(a==i||o==i||a==o&&a==i+1)return[n.slice(i,a,i,o)];let s=a-i,c=o-i,l=Math.min(B2,s+c),u=[],d=new Int16Array((l+1)*2).fill(-1);for(let f=0;f<=l;f++){for(let p=-f;p<=f;p+=2){let m=d[p+1+l],h=d[p-1+l],g=m<h?h:m+1,_=g+p;for(;g<s&&_<c&&r(e[i+g],t[i+_]);)g++,_++;if(d[p+l]=g,g>=s&&_>=c){let e=[],t=RHe(a-i,o-i),r=-1,s=-1,c=-1,m=-1,h=(i,a,o,l)=>{r>-1&&r<a+t?(r=i,c=o):(r>-1&&e.push(n.slice(r,s,c,m)),r=i,s=a,c=o,m=l)};for(let e=f-1;e>=0;e--){let t=d[p+1+l],n=d[p-1+l];t<n?(p--,g=n+i,_=g+p,h(g,g,_,_+1)):(p++,g=t+i,_=g+p,h(g,g+1,_,_)),d=u[e>>1]}return r>-1&&e.push(n.slice(r,s,c,m)),e.reverse()}}f%2==0&&u.push(d.slice())}return[n]}var H2=class e{constructor(e,t){this.length=e,this.data=t}cut(t){return t==this.length?this:new e(t,this.data)}static slice(t,n,r){if(n==r)return e.none;if(n==0&&r==e.len(t))return t;let i=[];for(let e=0,a=0;a<r;e++){let o=t[e],s=a+o.length,c=Math.min(r,s)-Math.max(n,a);c>0&&i.push(o.cut(c)),a=s}return i}static join(t,n,r){if(t.length==0)return n;if(n.length==0)return t;let i=r(t[t.length-1].data,n[0].data);if(i==null)return t.concat(n);let a=t.slice(0,t.length-1);a.push(new e(t[t.length-1].length+n[0].length,i));for(let e=1;e<n.length;e++)a.push(n[e]);return a}static len(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n].length;return t}};H2.none=[];var U2=class e{constructor(e,t,n,r,i,a){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r,this.deleted=i,this.inserted=a}get lenA(){return this.toA-this.fromA}get lenB(){return this.toB-this.fromB}slice(t,n,r,i){return t==0&&r==0&&n==this.toA-this.fromA&&i==this.toB-this.fromB?this:new e(this.fromA+t,this.fromA+n,this.fromB+r,this.fromB+i,H2.slice(this.deleted,t,n),H2.slice(this.inserted,r,i))}static merge(t,n,r){if(t.length==0)return n;if(n.length==0)return t;let i=[];for(let a=0,o=0,s=t[0],c=n[0];;)if(!s&&!c)return i;else if(s&&(!c||s.toB<c.fromA)){let r=o?n[o-1].toB-n[o-1].toA:0;i.push(r==0?s:new e(s.fromA,s.toA,s.fromB+r,s.toB+r,s.deleted,s.inserted)),s=a++==t.length?null:t[a]}else if(c&&(!s||c.toA<s.fromB)){let r=a?t[a-1].toB-t[a-1].toA:0;i.push(r==0?c:new e(c.fromA-r,c.toA-r,c.fromB,c.toB,c.deleted,c.inserted)),c=o++==n.length?null:n[o]}else{let l=Math.min(s.fromB,c.fromA),u=Math.min(s.fromA,c.fromA-(a?t[a-1].toB-t[a-1].toA:0)),d=u,f=Math.min(c.fromB,s.fromB+(o?n[o-1].toB-n[o-1].toA:0)),p=f,m=H2.none,h=H2.none,g=!1,_=!1;for(;;){let e=s?l>=s.fromB?s.toB:s.fromB:2e8,i=c?l>=c.fromA?c.toA:c.fromA:2e8,u=Math.min(e,i),f=s&&l>=s.fromB,v=c&&l>=c.fromA;if(!f&&!v)break;f&&l==s.fromB&&!g&&(m=H2.join(m,s.deleted,r),d+=s.lenA,g=!0),f&&!v&&(h=H2.join(h,H2.slice(s.inserted,l-s.fromB,u-s.fromB),r),p+=u-l),v&&l==c.fromA&&!_&&(h=H2.join(h,c.inserted,r),p+=c.lenB,_=!0),v&&!f&&(m=H2.join(m,H2.slice(c.deleted,l-c.fromA,u-c.fromA),r),d+=u-l),f&&u==s.toB&&(s=a++==t.length?null:t[a],g=!1),v&&u==c.toA&&(c=o++==n.length?null:n[o],_=!1),l=u}(u<d||f<p)&&i.push(new e(u,d,f,p,m,h))}}static fromJSON(t){return new e(t.fromA,t.toA,t.fromB,t.toB,t.deleted.map(e=>new H2(e.length,e.data)),t.inserted.map(e=>new H2(e.length,e.data)))}toJSON(){return this}},W2=class e{constructor(e,t){this.config=e,this.changes=t}addSteps(t,n,r){let i=[];for(let e=0;e<n.length;e++){let t=Array.isArray(r)?r[e]:r,a=0;n[e].forEach((e,n,r,o)=>{i.push(new U2(e+a,n+a,r,o,e==n?H2.none:[new H2(n-e,t)],r==o?H2.none:[new H2(o-r,t)])),a=o-r-(n-e)})}if(i.length==0)return this;let a=G2(i,this.config.combine),o=U2.merge(this.changes,a,this.config.combine),s=o;for(let e=0;e<s.length;e++){let n=s[e];if(n.fromA==n.toA||n.fromB==n.toB||!a.some(e=>e.toB>n.fromB&&e.fromB<n.toB))continue;let r=V2(this.config.doc.content,t.content,n,this.config.encoder);(r.length!=1||r[0].fromB!=0||r[0].toB!=n.toB-n.fromB)&&(s==o&&(s=o.slice()),r.length==1?s[e]=r[0]:(s.splice(e,1,...r),e+=r.length-1))}return new e(this.config,s)}get startDoc(){return this.config.doc}map(t){let n=e=>{let n=t(e);return n===e.data?e:new H2(e.length,n)};return new e(this.config,this.changes.map(e=>new U2(e.fromA,e.toA,e.fromB,e.toB,e.deleted.map(n),e.inserted.map(n))))}changedRange(e,t){if(e==this)return null;let n=t&&BHe(t),r=n?n.toB-n.fromB-(n.toA-n.fromA):0;function i(e){return!n||e<=n.fromA?e:e+r}let a=n?n.fromB:2e8,o=n?n.toB:-2e8;function s(e,t=e){a=Math.min(e,a),o=Math.max(t,o)}let c=this.changes,l=e.changes;for(let e=0,t=0;e<c.length&&t<l.length;){let n=c[e],r=l[t];n&&r&&VHe(n,r,i)?(e++,t++):r&&(!n||i(n.fromB)>=r.fromB)?(s(r.fromB,r.toB),t++):(s(i(n.fromB),i(n.toB)),e++)}return a<=o?{from:a,to:o}:null}static create(t,n=(e,t)=>e===t?e:null,r=R2,i=[]){return new e({combine:n,doc:t,encoder:r},i)}};W2.computeDiff=V2;function G2(e,t,n=0,r=e.length){if(r==n+1)return[e[n]];let i=n+r>>1;return U2.merge(G2(e,t,n,i),G2(e,t,i,r),t)}function K2(e){let t=2e8,n=-2e8;for(let r=0;r<e.length;r++){let i=e[r];t!=2e8&&(t=i.map(t,-1),n=i.map(n,1)),i.forEach((e,r,i,a)=>{t=Math.min(t,i),n=Math.max(n,a)})}return t==2e8?null:{from:t,to:n}}function BHe(e){let t=K2(e);if(!t)return null;let n=K2(e.map(e=>e.invert()).reverse());return{fromA:n.from,toA:n.to,fromB:t.from,toB:t.to}}function VHe(e,t,n){return n(e.fromB)==t.fromB&&n(e.toB)==t.toB&&q2(e.deleted,t.deleted)&&q2(e.inserted,t.inserted)}function q2(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].length!=t[n].length||e[n].data!==t[n].data)return!1;return!0}var J2=new CQ(`diff`);function HHe(){return new bQ({key:J2,state:{init(){return{baseDoc:null,changeSet:null,decorations:H1.empty}},apply(e,t,n,r){let i=e.getMeta(J2)?.baseDoc;if(i!==void 0){if(i===null)return{baseDoc:null,changeSet:null,decorations:H1.empty};let e=W2.create(i),t=[];UHe(i,r.doc,t);let n=t.length>0?e.addSteps(r.doc,t,null):e;return{baseDoc:i,changeSet:n,decorations:Y2(n,r.doc,i)}}if(!t.baseDoc||!t.changeSet)return t;if(!e.docChanged)return{...t,decorations:t.decorations.map(e.mapping,e.doc)};let a=e.steps.map(e=>e.getMap()),o=t.changeSet.addSteps(e.doc,a,null);return{...t,changeSet:o,decorations:Y2(o,e.doc,t.baseDoc)}}},props:{decorations(e){return J2.getState(e)?.decorations??H1.empty}}})}function UHe(e,t,n){let r=e.content.size,i=t.content.size;(r!==i||!e.eq(t))&&n.push(new xZ([0,r,i]))}function Y2(e,t,n){let r=[];for(let i of e.changes){if(i.fromB<i.toB){let e=Math.max(0,i.fromB),n=Math.min(t.content.size,i.toB);e<n&&r.push(z1.inline(e,n,{class:`bg-bg-brand-primary/30`}))}if(i.fromA<i.toA&&i.deleted.length>0){let e=Math.min(i.fromB,t.content.size),a=Math.max(0,i.fromA),o=Math.min(n.content.size,i.toA),s=a<o?n.textBetween(a,o,` `):``;if(s.length>0){let t=document.createElement(`span`);t.className=`bg-bg-error-primary line-through text-fg-error-primary opacity-60`,t.textContent=s,r.push(z1.widget(e,t,{side:-1}))}}}return H1.create(t,r)}function X2(e,t){let n=e.split(`/`).filter(e=>e.length>0).map(e=>{let t=parseInt(e,10);return isNaN(t)?e:t});if(n.length===0)return null;let r=t,i=0;for(let e=0;e<n.length;e++){let t=n[e];if(typeof t==`number`){let a=0,o=!1;if(r.forEach((s,c)=>{o||(a===t&&(e===n.length-1?(i+=c,r=s):(i+=c+1,r=s),o=!0),a++)}),!o)return null}else if(t===`children`)continue;else return null}let a=i,o=a+r.nodeSize;return{from:Math.max(0,a),to:Math.min(t.content.size,o)}}var Z2=new CQ(`schemaValidation`),WHe={bullet_list:`bulletList`,ordered_list:`orderedList`,blockquote:`blockquote`,code_block:`codeBlock`,details:`details`,details_summary:`details`,hard_break:`hardBreak`,button_atom:`button`,button_editable:`button`,image:`image`},GHe={bold:`bold`,italic:`italic`,strikethrough:`strikethrough`,code:`code`,link:`link`},KHe={heading:`Heading`,bullet_list:`Bullet list`,ordered_list:`Ordered list`,blockquote:`Blockquote`,code_block:`Code block`,details:`Details`,details_summary:`Details`,hard_break:`Hard break`,button_atom:`Button`,button_editable:`Button`,image:`Image`},qHe={bold:`Bold`,italic:`Italic`,strikethrough:`Strikethrough`,code:`Code`,link:`Link`},Q2={heading:[{id:`schema.convert-to-paragraph`,label:`Convert to paragraph`}],bullet_list:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],ordered_list:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],blockquote:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}],code_block:[{id:`schema.convert-to-paragraph`,label:`Convert to paragraph`}],details:[{id:`schema.convert-to-paragraphs`,label:`Convert to paragraphs`}]},JHe={bold:[{id:`schema.remove-formatting`,label:`Remove formatting`}],italic:[{id:`schema.remove-formatting`,label:`Remove formatting`}],strikethrough:[{id:`schema.remove-formatting`,label:`Remove formatting`}],code:[{id:`schema.remove-formatting`,label:`Remove formatting`}],link:[{id:`schema.remove-link`,label:`Remove link`}]};function $2(e){return`/`+e.join(`/children/`)}function e4(e,t,n,r){e.forEach((e,i,a)=>{let o=[...n,a];if(e.type.name===`heading`){let n=e.attrs.level,i=j2[n-1];if(i&&!t[i]){let t=Q2[e.type.name];r.push({path:$2(o),message:`Heading ${n} is not allowed by the current schema`,kind:`schema.violation`,...t&&{fixes:t}});return}}let s=WHe[e.type.name];if(s&&!t[s]){let t=KHe[e.type.name]??e.type.name,n=Q2[e.type.name];r.push({path:$2(o),message:`${t} is not allowed by the current schema`,kind:`schema.violation`,...n&&{fixes:n}});return}if(e.isText&&e.marks.length>0){let n=$2(o);for(let i of e.marks){let e=GHe[i.type.name];if(e&&!t[e]){let e=qHe[i.type.name]??i.type.name,t=JHe[i.type.name];r.push({path:n,message:`${e} is not allowed by the current schema`,kind:`schema.violation`,...t&&{fixes:t}})}}return}e.childCount>0&&e4(e,t,o,r)})}function t4(e,t){let n=[];return e4(e,t,[],n),n}function YHe(e,t,n){let{state:r}=e,{doc:i,schema:a}=r,o=X2(t,i);if(!o)return!1;let{from:s,to:c}=o,l=i.nodeAt(s);return l?n===`schema.convert-to-paragraph`?XHe(e,l,s,c,a):n===`schema.convert-to-paragraphs`?ZHe(e,l,s,c,a):n===`schema.remove-formatting`||n===`schema.remove-link`?QHe(e,s,c):!1:!1}function XHe(e,t,n,r,i){let a=r4(t),o=i.node(`paragraph`,null,a.length>0?[i.text(a)]:[]),s=e.state.tr.replaceWith(n,r,o);return e.dispatch(s),!0}function ZHe(e,t,n,r,i){let a=[];n4(t,i,a),a.length===0&&a.push(i.node(`paragraph`));let o=e.state.tr.replaceWith(n,r,a);return e.dispatch(o),!0}function n4(e,t,n){if(e.isTextblock){let r=r4(e);n.push(t.node(`paragraph`,null,r.length>0?[t.text(r)]:[]));return}e.forEach(e=>{n4(e,t,n)})}function QHe(e,t,n){let r=e.state.tr,i=e.state.doc.nodeAt(t);if(!i||!i.isText)return!1;for(let e of i.marks)r=r.removeMark(t,n,e.type);return e.dispatch(r),!0}function r4(e){return e.textContent}function $He(e){return new bQ({key:Z2,state:{init(t,n){return{errors:t4(n.doc,e)}},apply(t,n,r,i){return t.docChanged?{errors:t4(i.doc,e)}:n}}})}var i4=new CQ(`errors`);function a4(e){return Z2.getState(e)?.errors??[]}function eUe(){return new bQ({key:i4,state:{init(e,t){let n=a4(t);return{externalErrors:[],errors:n,errorKindClassName:{},decorations:o4(n,t.doc,{})}},apply(e,t,n,r){let i=e.getMeta(i4);if(i){let e=i.errors??t.externalErrors,n=i.errorKindClassName??t.errorKindClassName,a=a4(r),o=[...e,...a];return{externalErrors:e,errors:o,errorKindClassName:n,decorations:o4(o,r.doc,n)}}if(e.docChanged){let e=a4(r),n=[...t.externalErrors,...e];return{...t,errors:n,decorations:o4(n,r.doc,t.errorKindClassName)}}return t}},props:{decorations(e){return i4.getState(e)?.decorations??H1.empty}}})}function o4(e,t,n){if(e.length===0)return H1.empty;let r=[];for(let i of e){let e=X2(i.path,t);if(!e)continue;let{from:a,to:o}=e,s=n[i.kind]??``,c=`border-b-2 border-border-error-primary bg-bg-error-secondary/20`,l=s?`${c} ${s}`:c;r.push(z1.inline(a,o,{class:l,title:i.message,"data-error-kind":i.kind,"data-error-path":i.path}))}return H1.create(t,r)}function s4(e,t){try{let n=e.resolve(t),r=[];for(let e=1;e<=n.depth;e++){let t=n.node(e-1),i=n.index(e-1);t.type.name!==`doc`&&r.push(`children`),r.push(String(i))}let i=e.nodeAt(t);if(i){let e=n.node(n.depth);e.type.name===`doc`&&n.depth===0?r.push(String(n.index(0))):c4(e)&&!c4(i)&&(r.push(`children`),r.push(String(n.index(n.depth))))}return r.length>0?r:null}catch{return null}}function c4(e){let t=e.type.name;return t===`paragraph`||t===`heading`||t===`details_summary`}var tUe=`custom_style_`;function l4(e,t){let n=[];return e.marks.bold&&(!t||t.bold)&&n.push({label:`B`,title:`Bold (Ctrl+B)`,markType:e.marks.bold}),e.marks.italic&&(!t||t.italic)&&n.push({label:`I`,title:`Italic (Ctrl+I)`,markType:e.marks.italic}),e.marks.strikethrough&&(!t||t.strikethrough)&&n.push({label:`S`,title:`Strikethrough (Ctrl+Shift+X)`,markType:e.marks.strikethrough}),e.marks.code&&(!t||t.code)&&n.push({label:`<>`,title:`Code (Ctrl+E)`,markType:e.marks.code}),e.marks.link&&(!t||t.link)&&n.push({label:`🔗`,title:`Link`,markType:e.marks.link}),n}function u4(e,t){if(!t)return[];let n=[];for(let[r,i]of Object.entries(t)){let t=`${tUe}${r}`,a=e.marks[t];a&&n.push({label:i.label,title:i.label,markType:a})}return n}function d4(e,t){let n=[];return e.nodes.bullet_list&&(!t||t.bulletList)&&n.push({label:`•`,title:`Bullet list (Ctrl+Shift+8)`,nodeType:e.nodes.bullet_list}),e.nodes.ordered_list&&(!t||t.orderedList)&&n.push({label:`1.`,title:`Ordered list (Ctrl+Shift+9)`,nodeType:e.nodes.ordered_list}),n}function f4(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--)if(n.node(e).type===t)return!0;return!1}function nUe(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let r=n.node(e);if(r.type===t.nodes.bullet_list||r.type===t.nodes.ordered_list)return{depth:e,node:r}}return null}function rUe(e,t){let{state:n}=e,{$from:r}=n.selection,i=r.parent;i.type!==t.nodes.paragraph&&i.type.isTextblock&&y2(t.nodes.paragraph)(n,e.dispatch,e)}function iUe(e,t){return(n,r,i)=>{if(f4(n,e)){let e=t.nodes.list_item;return e?k2(e)(n,r):!1}let a=nUe(n,t);if(a){if(r){let{$from:t}=n.selection,i=t.before(a.depth);r(n.tr.setNodeMarkup(i,e))}return!0}if(i){let{$from:r}=n.selection,a=r.parent;if(a.type!==t.nodes.paragraph&&a.type.isTextblock)return rUe(i,t),D2(e)(i.state,i.dispatch)}return D2(e)(n,r)}}function p4(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}function m4(e,t){let n=[];if(n.push({value:`paragraph`,label:`Normal`,nodeType:e.nodes.paragraph}),e.nodes.heading)for(let r=1;r<=3;r++)(!t||t[j2[r-1]])&&n.push({value:`heading${r}`,label:`Heading ${r}`,nodeType:e.nodes.heading,attrs:{level:r}});return e.nodes.code_block&&(!t||t.codeBlock)&&n.push({value:`code_block`,label:`Code`,nodeType:e.nodes.code_block}),e.nodes.blockquote&&(!t||t.blockquote)&&n.push({value:`blockquote`,label:`Quote`,nodeType:e.nodes.blockquote}),e.nodes.details&&(!t||t.details)&&n.push({value:`details`,label:`Details`,nodeType:e.nodes.details}),n}function aUe(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name===`details`)return`details`;if(t.type.name===`blockquote`)return`blockquote`}let r=n.parent;if(r.type.name===`heading`){let e=r.attrs.level,n=t.find(t=>t.value===`heading${e}`);if(n)return n.value}return r.type.name===`code_block`?`code_block`:`paragraph`}function oUe(e,t,n){let{state:r,dispatch:i}=e;if(n.value===`blockquote`){v2(t.nodes.blockquote)(r,i);return}if(n.value===`details`){y4(e,t,`details`);return}let{$from:a}=r.selection,o=!1;for(let e=a.depth;e>0;e--){let t=a.node(e).type.name;if(t===`blockquote`||t===`details`){o=!0;break}}if(o){hHe(r,t=>{let r=e.state.apply(t);e.updateState(r),y2(n.nodeType,n.attrs)(e.state,e.dispatch,e)});return}y2(n.nodeType,n.attrs)(r,i,e)}function h4(e,t,n){let r=e.coordsAtPos(t);if(n)return{left:Math.max(0,r.left),top:r.bottom+4};let i=e.dom.parentElement;if(!i)return null;let a=i.getBoundingClientRect();return{left:Math.max(0,r.left-a.left),top:r.bottom-a.top+4}}function sUe(e){function t(){e.onPickerStateChange(null)}function n(t,n,r){let{$from:i,from:a,to:o}=t.state.selection,s=n.isInSet(i.marks())??(i.nodeAfter?n.isInSet(i.nodeAfter.marks):null),c=s?s.attrs.href.trim():null,l=h4(t,a,!!e.getPortalContainer?.());l&&e.onPickerStateChange({kind:`catalog`,anchorRect:l,savedFrom:a,savedTo:o,currentHref:c,catalog:r})}function r(t,n){let{$from:r,from:i,to:a}=t.state.selection,o=n.isInSet(r.marks())??(r.nodeAfter?n.isInSet(r.nodeAfter.marks):null),s=o?o.attrs.href.trim():null,c=h4(t,i,!!e.getPortalContainer?.());c&&e.onPickerStateChange({kind:`url`,anchorRect:c,savedFrom:i,savedTo:a,currentHref:s,isNewLink:!o})}function i(i,a){let{state:o}=i,s=e.getLinkCatalog?.();if(s&&s.length>0){if(e.isPickerOpen()){t();return}n(i,a,s);return}if(p4(o,a)){b2(a)(o,i.dispatch,i);return}if(e.isPickerOpen()){t();return}r(i,a)}return{handleLinkToggle:i,showCatalogPicker:n,showUrlEditor:r,closePicker:t,isPickerOpen:()=>e.isPickerOpen(),destroy:t}}function g4(e){return e?.type.name===`button_atom`||e?.type.name===`button_editable`}function cUe(e){let{$from:t}=e.selection;return e.selection instanceof cQ&&g4(e.selection.node)?{pos:e.selection.from,node:e.selection.node}:g4(t.parent)?{pos:t.before(t.depth),node:t.parent}:g4(t.nodeBefore)?{pos:t.pos-t.nodeBefore.nodeSize,node:t.nodeBefore}:g4(t.nodeAfter)?{pos:t.pos,node:t.nodeAfter}:null}function _4(e,t,n,r){let i=n.children===!1,a=i?t.nodes.button_atom:t.nodes.button_editable;if(!a)return;let o={variant:n.variant};!i&&r&&(o.href=r);let s=i?a.create(o):a.create(o,n.label?[t.text(n.label)]:[]),c=cUe(e.state);if(c&&c.node){let t=e.state.tr.replaceWith(c.pos,c.pos+c.node.nodeSize,s);e.dispatch(t)}else{let{from:t}=e.state.selection,n=e.state.tr.insert(t,s);e.dispatch(n)}}function v4(e,t,n,r){let i=t.nodes.image;if(!i)return null;let a=i.create({src:n,alt:``,previewUrl:r?.previewUrl??null,width:r?.width??null,height:r?.height??null,mimeType:r?.mimeType??null}),{from:o}=e.state.selection,s=e.state.tr.insert(o,a);e.dispatch(s);let c=s4(e.state.doc,o);return c?[...c,`src`]:null}function y4(e,t,n){let r=t.nodes.details,i=t.nodes.details_summary;if(!r||!i)return;let{state:a}=e,{$from:o}=a.selection,s=i.create(null,[]),c=t.nodes.paragraph.create(),l=r.create({variant:n},[s,c]),u=o.end(o.depth===0?1:o.depth)+1,d=a.tr.insert(u,l);e.dispatch(d),e.focus()}function lUe({schema:e,features:t,styleConfig:n,canInsertImage:r,buttonVariants:i,detailsVariants:a}){return!!(l4(e,t).length>0||u4(e,n).length>0||d4(e,t).length>0||m4(e,t).length>1||e.nodes.image&&(!t||t.image)&&r||i!==void 0&&i.length>0&&(!t||t.button)||a!==void 0&&a.length>0&&(!t||t.details))}var uUe=Object.defineProperty,b4=(e,t)=>uUe(e,`name`,{value:t,configurable:!0}),x4=!1;function S4(){let[e,t]=b.useState(x4);return b.useEffect(()=>{x4||(x4=!0,t(!0))},[]),e}b4(S4,`useIsHydrated`);var C4=b.useSyncExternalStore;function w4(){return()=>{}}b4(w4,`subscribe`);function T4(){return C4(w4,()=>!0,()=>!1)}b4(T4,`useIsHydratedModern`);var dUe=typeof C4==`function`?T4:S4,fUe=Object.defineProperty,E4=(e,t)=>fUe(e,`name`,{value:t,configurable:!0}),D4=`rovingFocusGroup.onEntryFocus`,pUe={bubbles:!1,cancelable:!0},O4=`RovingFocusGroup`,[k4,A4,mUe]=KT(O4),[hUe,j4]=sm(O4,[mUe]),[gUe,_Ue]=hUe(O4),vUe=b.forwardRef(E4(function(e,t){return(0,Y.jsx)(k4.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(k4.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,Y.jsx)(yUe,{...e,ref:t})})})},`RovingFocusGroup`)),yUe=b.forwardRef(E4(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=b.useRef(null),p=am(t,f),m=nE(a),[h,g]=ng({prop:o,defaultProp:s??null,onChange:c,caller:O4}),[_,v]=b.useState(!1),y=Cm(l),x=A4(n),S=b.useRef(!1),[C,w]=b.useState(0);return b.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(D4,y),()=>e.removeEventListener(D4,y)},[y]),(0,Y.jsx)(gUe,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:b.useCallback(e=>g(e),[g]),onItemShiftTab:b.useCallback(()=>v(!0),[]),onFocusableItemAdd:b.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:b.useCallback(()=>w(e=>e-1),[]),children:(0,Y.jsx)(xm.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:Qp(e.onMouseDown,()=>{S.current=!0}),onFocus:Qp(e.onFocus,e=>{let t=!S.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(D4,pUe);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=x().filter(e=>e.focusable);P4([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}S.current=!1}),onBlur:Qp(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),bUe=`RovingFocusGroupItem`,xUe=b.forwardRef(E4(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Pm(),l=a||c,u=_Ue(bUe,n),d=u.currentTabStopId===l,f=A4(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=dUe();return Nm(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),b.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,Y.jsx)(k4.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,Y.jsx)(xm.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Qp(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Qp(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Qp(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=N4(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?F4(n,r+1):n.slice(r+1)}setTimeout(()=>P4(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),SUe={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function M4(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}E4(M4,`getDirectionAwareKey`);function N4(e,t,n){let r=M4(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return SUe[r]}E4(N4,`getFocusIntent`);function P4(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}E4(P4,`focusFirst`);function F4(e,t){return e.map((n,r)=>e[(t+r)%e.length])}E4(F4,`wrapArray`);var CUe=vUe,wUe=xUe,TUe=Object.defineProperty,I4=(e,t)=>TUe(e,`name`,{value:t,configurable:!0}),L4=[`Enter`,` `],EUe=[`ArrowDown`,`PageUp`,`Home`],R4=[`ArrowUp`,`PageDown`,`End`],DUe=[...EUe,...R4],OUe={ltr:[...L4,`ArrowRight`],rtl:[...L4,`ArrowLeft`]},kUe={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},z4=`Menu`,[B4,AUe,jUe]=KT(z4),[V4,H4]=sm(z4,[jUe,Vh,j4]),U4=Vh(),W4=j4(),[MUe,G4]=V4(z4),[NUe,K4]=V4(z4),PUe=I4(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=U4(t),[c,l]=b.useState(null),u=b.useRef(!1),d=Cm(a),f=nE(i);return b.useEffect(()=>{let e=I4(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=I4(()=>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})}},[]),b.useEffect(()=>{if(!n)return;let e=I4(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,Y.jsx)(Uh,{...s,children:(0,Y.jsx)(MUe,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,Y.jsx)(NUe,{scope:t,onClose:b.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),q4=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e,i=U4(n);return(0,Y.jsx)(Wh,{...i,...r,ref:t})},`MenuAnchor`)),J4=`MenuPortal`,[FUe,Y4]=V4(J4,{forceMount:void 0}),IUe=I4(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=G4(J4,t);return(0,Y.jsx)(FUe,{scope:t,forceMount:n,children:(0,Y.jsx)(Jh,{present:n||a.open,children:(0,Y.jsx)(Kh,{asChild:!0,container:i,children:r})})})},`MenuPortal`),X4=`MenuContent`,[LUe,Z4]=V4(X4),RUe=b.forwardRef(I4(function(e,t){let n=Y4(X4,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=G4(X4,e.__scopeMenu),o=K4(X4,e.__scopeMenu);return(0,Y.jsx)(B4.Provider,{scope:e.__scopeMenu,children:(0,Y.jsx)(Jh,{present:r||a.open,children:(0,Y.jsx)(B4.Slot,{scope:e.__scopeMenu,children:o.modal?(0,Y.jsx)(zUe,{...i,ref:t}):(0,Y.jsx)(BUe,{...i,ref:t})})})})},`MenuContent`)),zUe=b.forwardRef(I4(function(e,t){let n=G4(X4,e.__scopeMenu),r=b.useRef(null),i=am(t,r);return b.useEffect(()=>{let e=r.current;if(e)return ev(e)},[]),(0,Y.jsx)(Q4,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Qp(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),BUe=b.forwardRef(I4(function(e,t){let n=G4(X4,e.__scopeMenu);return(0,Y.jsx)(Q4,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),VUe=dm(`MenuContent.ScrollLock`),Q4=b.forwardRef(I4(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:m,...h}=e,g=G4(X4,n),_=K4(X4,n),v=U4(n),y=W4(n),x=AUe(n),[S,C]=b.useState(null),w=b.useRef(null),T=am(t,w,g.onContentChange),E=b.useRef(0),D=b.useRef(``),O=b.useRef(0),k=b.useRef(null),A=b.useRef(`right`),j=b.useRef(0),M=m?J_:b.Fragment,N=m?{as:VUe,allowPinchZoom:!0}:void 0,P=I4(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=f3(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;I4((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);b.useEffect(()=>()=>window.clearTimeout(E.current),[]),x_();let F=b.useCallback(e=>A.current===k.current?.side&&m3(e,k.current?.area),[]);return(0,Y.jsx)(LUe,{scope:n,searchRef:D,onItemEnter:b.useCallback(e=>{F(e)&&e.preventDefault()},[F]),onItemLeave:b.useCallback(e=>{F(e)||(w.current?.focus(),C(null))},[F]),onTriggerLeave:b.useCallback(e=>{F(e)&&e.preventDefault()},[F]),pointerGraceTimerRef:O,onPointerGraceIntentChange:b.useCallback(e=>{k.current=e},[]),children:(0,Y.jsx)(M,{...N,children:(0,Y.jsx)(o_,{asChild:!0,trapped:i,onMountAutoFocus:Qp(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,Y.jsx)(Om,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,Y.jsx)(CUe,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Qp(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,Y.jsx)(Gh,{role:`menu`,"aria-orientation":`vertical`,"data-state":s3(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:T,style:{outline:`none`,...h.style},onKeyDown:Qp(h.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&&P(e.key));let i=w.current;if(e.target!==i||!DUe.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);R4.includes(e.key)&&a.reverse(),u3(a)}),onBlur:Qp(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:Qp(e.onPointerMove,h3(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),HUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e;return(0,Y.jsx)(xm.div,{...r,ref:t})},`MenuLabel`)),$4=`MenuItem`,e3=`menu.itemSelect`,t3=b.forwardRef(I4(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=b.useRef(null),o=K4($4,e.__scopeMenu),s=Z4($4,e.__scopeMenu),c=am(t,a),l=b.useRef(!1),u=I4(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(e3,{bubbles:!0,cancelable:!0});e.addEventListener(e3,e=>r?.(e),{once:!0}),Sm(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,Y.jsx)(n3,{...i,ref:c,disabled:n,onClick:Qp(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Qp(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Qp(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&L4.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),n3=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Z4($4,n),s=W4(n),c=b.useRef(null),l=am(t,c),[u,d]=b.useState(!1),[f,p]=b.useState(``);return b.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,Y.jsx)(B4.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,Y.jsx)(wUe,{asChild:!0,...s,focusable:!r,children:(0,Y.jsx)(xm.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Qp(e.onPointerMove,h3(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Qp(e.onPointerLeave,h3(e=>o.onItemLeave(e))),onFocus:Qp(e.onFocus,()=>d(!0)),onBlur:Qp(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),UUe=b.forwardRef(I4(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,Y.jsx)(i3,{scope:e.__scopeMenu,checked:n,children:(0,Y.jsx)(t3,{role:`menuitemcheckbox`,"aria-checked":c3(n)?`mixed`:n,...i,ref:t,"data-state":l3(n),onSelect:Qp(i.onSelect,()=>r?.(c3(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[WUe,GUe]=V4(`MenuRadioGroup`,{value:void 0,onValueChange:I4(()=>{},`onValueChange`)}),KUe=`MenuRadioItem`,qUe=b.forwardRef(I4(function(e,t){let{value:n,...r}=e,i=GUe(KUe,e.__scopeMenu),a=n===i.value;return(0,Y.jsx)(i3,{scope:e.__scopeMenu,checked:a,children:(0,Y.jsx)(t3,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":l3(a),onSelect:Qp(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),r3=`MenuItemIndicator`,[i3,JUe]=V4(r3,{checked:!1}),YUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=JUe(r3,n);return(0,Y.jsx)(Jh,{present:r||c3(a.checked)||a.checked===!0,children:(0,Y.jsx)(xm.span,{...i,ref:t,"data-state":l3(a.checked)})})},`MenuItemIndicator`)),XUe=b.forwardRef(I4(function(e,t){let{__scopeMenu:n,...r}=e;return(0,Y.jsx)(xm.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[ZUe,a3]=V4(`MenuSub`),o3=`MenuSubTrigger`,QUe=b.forwardRef(I4(function(e,t){let n=G4(o3,e.__scopeMenu),r=K4(o3,e.__scopeMenu),i=a3(o3,e.__scopeMenu),a=Z4(o3,e.__scopeMenu),o=b.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=b.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);b.useEffect(()=>u,[u]),b.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let d=am(t,i.onTriggerChange);return(0,Y.jsx)(q4,{asChild:!0,...l,children:(0,Y.jsx)(n3,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":s3(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Qp(e.onPointerMove,h3(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Qp(e.onPointerLeave,h3(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:Qp(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&OUe[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),$Ue=`MenuSubContent`,eWe=b.forwardRef(I4(function(e,t){let n=Y4(X4,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=G4(X4,e.__scopeMenu),s=K4(X4,e.__scopeMenu),c=a3($Ue,e.__scopeMenu),l=b.useRef(null),u=am(t,l);return(0,Y.jsx)(B4.Provider,{scope:e.__scopeMenu,children:(0,Y.jsx)(Jh,{present:r||o.open,children:(0,Y.jsx)(B4.Slot,{scope:e.__scopeMenu,children:(0,Y.jsx)(Q4,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:Qp(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Qp(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:Qp(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=kUe[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function s3(e){return e?`open`:`closed`}I4(s3,`getOpenState`);function c3(e){return e===`indeterminate`}I4(c3,`isIndeterminate`);function l3(e){return c3(e)?`indeterminate`:e?`checked`:`unchecked`}I4(l3,`getCheckedState`);function u3(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}I4(u3,`focusFirst`);function d3(e,t){return e.map((n,r)=>e[(t+r)%e.length])}I4(d3,`wrapArray`);function f3(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=d3(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}I4(f3,`getNextMatch`);function p3(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}I4(p3,`isPointInPolygon`);function m3(e,t){return t?p3({x:e.clientX,y:e.clientY},t):!1}I4(m3,`isPointerInGraceArea`);function h3(e){return t=>t.pointerType===`mouse`?e(t):void 0}I4(h3,`whenMouse`);var tWe=PUe,nWe=q4,rWe=IUe,iWe=RUe,aWe=HUe,oWe=t3,sWe=UUe,cWe=qUe,lWe=YUe,uWe=XUe,dWe=QUe,fWe=eWe,pWe=Object.defineProperty,g3=(e,t)=>pWe(e,`name`,{value:t,configurable:!0}),_3=`DropdownMenu`,[mWe,hWe]=sm(_3,[H4]),v3=H4(),[gWe,y3]=mWe(_3),_We=g3(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=v3(t),l=b.useRef(null),[u,d]=ng({prop:i,defaultProp:a??!1,onChange:o,caller:_3});return(0,Y.jsx)(gWe,{scope:t,triggerId:Pm(),triggerRef:l,contentId:Pm(),open:u,onOpenChange:d,onOpenToggle:b.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,Y.jsx)(tWe,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),vWe=`DropdownMenuTrigger`,yWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=y3(vWe,n),o=v3(n),s=am(t,a.triggerRef);return(0,Y.jsx)(nWe,{asChild:!0,...o,children:(0,Y.jsx)(xm.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:Qp(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Qp(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),bWe=g3(e=>{let{__scopeDropdownMenu:t,...n}=e,r=v3(t);return(0,Y.jsx)(rWe,{...r,...n})},`DropdownMenuPortal`),xWe=`DropdownMenuContent`,SWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=y3(xWe,n),a=v3(n),o=b.useRef(!1);return(0,Y.jsx)(iWe,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Qp(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Qp(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`)),CWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(aWe,{...i,...r,ref:t})},`DropdownMenuLabel`)),wWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(oWe,{...i,...r,ref:t})},`DropdownMenuItem`)),TWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(sWe,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),EWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(cWe,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),DWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(lWe,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),OWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(uWe,{...i,...r,ref:t})},`DropdownMenuSeparator`)),kWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(dWe,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),AWe=b.forwardRef(g3(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=v3(n);return(0,Y.jsx)(fWe,{...i,...r,ref:t,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)`}})},`DropdownMenuSubContent`)),jWe=_We,MWe=yWe,NWe=bWe,b3=SWe,x3=CWe,S3=wWe,C3=TWe,w3=EWe,T3=DWe,E3=OWe,D3=kWe,O3=AWe,k3=jWe,A3=MWe,PWe=b.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Y.jsxs)(D3,{ref:i,className:X(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-bg-brand-primary data-[state=open]:bg-bg-brand-primary`,t&&`pl-8`,e),...r,children:[n,(0,Y.jsx)(Rv,{className:`ml-auto w-4 h-4`})]}));PWe.displayName=D3.displayName;var FWe=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(O3,{ref:n,className:X(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-bg-secondary p-1 text-fg-secondary shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));FWe.displayName=O3.displayName;var j3=b.forwardRef(({className:e,sideOffset:t=4,container:n,...r},i)=>{let a=(0,Y.jsx)(b3,{ref:i,sideOffset:t,className:X(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-bg-secondary p-1 text-fg-secondary shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...r});return n?(0,Y.jsx)(NWe,{container:n,children:a}):a});j3.displayName=b3.displayName;var M3=b.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(S3,{ref:r,className:X(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-bg-brand-primary focus:text-fg-brand-primary data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,t&&`pl-8`,e),...n}));M3.displayName=S3.displayName;var IWe=b.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Y.jsxs)(C3,{ref:i,className:X(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(T3,{children:(0,Y.jsx)(Fv,{className:`w-4 h-4`})})}),t]}));IWe.displayName=C3.displayName;var LWe=b.forwardRef(({className:e,children:t,...n},r)=>(0,Y.jsxs)(w3,{ref:r,className:X(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,Y.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,Y.jsx)(T3,{children:(0,Y.jsx)(Bie,{className:`w-2 h-2 fill-current`})})}),t]}));LWe.displayName=w3.displayName;var RWe=b.forwardRef(({className:e,inset:t,...n},r)=>(0,Y.jsx)(x3,{ref:r,className:X(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));RWe.displayName=x3.displayName;var zWe=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(E3,{ref:n,className:X(`-mx-1 my-1 h-px bg-muted`,e),...t}));zWe.displayName=E3.displayName;function N3({images:e,currentSrc:t,onSelect:n}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-secondary`,children:`Select an image:`}),(0,Y.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:e.map((e,r)=>{let i=`Select image ${r+1}`;return(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e.url),"aria-label":i,className:[`overflow-hidden rounded border-2 transition-all`,t===e.url?`border-border-brand-primary ring-2 ring-border-brand-primary`:`border-border-primary hover:border-border-brand-primary`].join(` `),children:(0,Y.jsx)(`img`,{src:e.url,alt:``,className:`h-16 w-full object-cover`})},e.url)})})]})}function P3({catalog:e,currentHref:t,onApplyLink:n,onRemoveLink:r,onClose:i}){let a=new Map(e.map(e=>[e.href.trim(),e])),o=(0,b.useCallback)(e=>{let t=a.get(e);t&&n(t)},[a,n]);return(0,Y.jsxs)(ik,{filter:(e,t)=>{let n=a.get(e);if(!n)return 0;let r=t.toLowerCase();return n.title.toLowerCase().includes(r)||n.subtitle.toLowerCase().includes(r)||n.href.trim().toLowerCase().includes(r)?1:0},children:[(0,Y.jsx)(ak,{placeholder:`Filter...`,onKeyDown:e=>{e.key===`Escape`&&i()}}),(0,Y.jsxs)(ok,{children:[(0,Y.jsx)(sk,{children:`No matches`}),(0,Y.jsx)(ck,{children:e.map(e=>{let n=e.href.trim(),r=t!==null&&n===t;return(0,Y.jsxs)(uk,{value:n,onSelect:o,className:`flex items-center gap-2`,children:[(0,Y.jsx)(Fv,{className:X(`h-4 w-4 shrink-0`,r?`opacity-100`:`opacity-0`)}),(0,Y.jsx)(dk,{title:e.title,subtitle:e.subtitle,image:e.image??null,className:X(r&&`text-fg-brand-primary`)})]},n)})})]}),r&&(0,Y.jsx)(`div`,{className:`border-t border-border-primary p-1`,children:(0,Y.jsx)(`button`,{type:`button`,className:X(`w-full rounded px-2 py-1.5 text-left text-sm text-fg-secondary`,`transition-colors hover:bg-bg-secondary-hover`),onMouseDown:r,children:`Remove link`})})]})}function F3({currentHref:e,isNewLink:t,onApply:n,onUnlink:r,onClose:i}){let[a,o]=(0,b.useState)(e),s=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=s.current;e&&(e.focus(),e.select())},[]);let c=(0,b.useCallback)(()=>{let e=a.trim();e&&n(e)},[a,n]),l=(0,b.useCallback)(e=>{if(e.key===`Escape`){i();return}e.key===`Enter`&&(e.preventDefault(),c())},[i,c]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(MT,{ref:s,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:l,"aria-label":`URL`,placeholder:`https://…`,className:X(`h-8 m-0 min-w-[220px] w-auto text-sm`)}),(0,Y.jsx)(t_,{size:`xs`,onMouseDown:c,children:t?`Apply`:`Update`}),!t&&(0,Y.jsx)(t_,{variant:`ghost`,size:`xs`,onMouseDown:r,children:`Unlink`})]})}var BWe={bold:Mv,italic:ly,strikethrough:Fy,code:Kv,link:dy},VWe={bullet_list:my,ordered_list:fy},I3={1:tae,2:nae,3:iae,4:rae,5:aae,6:oae};function L3(){return(0,Y.jsx)(`div`,{className:`mx-0.5 w-px self-stretch bg-border-primary`,role:`separator`})}var R3=`disabled:bg-transparent disabled:border-transparent aria-disabled:bg-transparent aria-disabled:border-transparent`;function z3({view:e,schema:t,features:n,linkHelper:r,options:i,images:a,imageModuleEntries:o,imageGetUrl:s,onImageUpload:c,imageAccept:l,uploadProgress:u,buttonVariants:d,detailsVariants:f,linkCatalog:p,styleConfig:m,readOnly:h}){let g=l4(t,n),_=u4(t,m),v=d4(t,n),y=i?.showBlockTypeSelect?m4(t,n):[],x=y.length>1,S=x?aUe(e.state,y):`paragraph`,C=(0,b.useRef)(null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-0`,ref:C}),x&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:`xs`,className:X(`min-w-[3.5rem]`,R3),disabled:h,children:[S.startsWith(`heading`)&&(()=>{let e=I3[Number(S.replace(`heading`,``))];return e?(0,Y.jsx)(e,{size:16}):S})(),!S.startsWith(`heading`)&&(y.find(e=>e.value===S)?.label??`Normal`)]})}),(0,Y.jsx)(j3,{container:C.current,children:y.map(n=>{let r=n.attrs?.level,i=r?I3[r]:void 0;return(0,Y.jsx)(M3,{onClick:()=>{oUe(e,t,n),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):n.label},n.value)})})]}),(0,Y.jsx)(L3,{})]}),g.map(t=>{let n=p4(e.state,t.markType),i=BWe[t.markType.name];return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:t.title,disabled:h,className:X(R3,{"text-accent":n,"stroke-[3px]":n}),onClick:n=>{n.preventDefault(),t.markType.name===`link`?r.handleLinkToggle(e,t.markType):b2(t.markType)(e.state,e.dispatch,e),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):t.label},t.markType.name)}),_.length>0&&g.length>0&&(0,Y.jsx)(L3,{}),_.map(t=>{let n=p4(e.state,t.markType);return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:t.title,disabled:h,className:X(R3,{"text-accent":n,"stroke-[3px]":n}),onClick:n=>{n.preventDefault(),b2(t.markType)(e.state,e.dispatch,e),e.focus()},children:t.label},t.markType.name)}),v.length>0&&(g.length>0||_.length>0)&&(0,Y.jsx)(L3,{}),v.map(n=>{let r=f4(e.state,n.nodeType),i=VWe[n.nodeType.name];return(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:n.title,disabled:h,className:X(R3,{"text-accent":r,"stroke-[3px]":r}),onClick:r=>{r.preventDefault(),iUe(n.nodeType,t)(e.state,e.dispatch,e),e.focus()},children:i?(0,Y.jsx)(i,{size:16}):n.label},n.nodeType.name)}),t.nodes.image&&(!n||n.image)&&(a&&a.length>0||o||c)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(HWe,{view:e,schema:t,images:a,imageModuleEntries:o,imageGetUrl:s,onImageUpload:c,imageAccept:l,uploadProgress:u,readOnly:h})]}),d&&d.length>0&&(!n||n.button)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(GWe,{view:e,schema:t,variants:d,linkHelper:r,linkCatalog:p,dropdownContainer:C.current,readOnly:h})]}),f&&f.length>0&&(!n||n.details)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L3,{}),(0,Y.jsx)(UWe,{view:e,schema:t,variants:f,dropdownContainer:C.current,readOnly:h})]})]})}function HWe({view:e,schema:t,images:n,imageModuleEntries:r,imageGetUrl:i,onImageUpload:a,imageAccept:o,uploadProgress:s,readOnly:c}){let[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),p=(0,b.useRef)(null),m=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!l)return;function e(e){let t=e.target;(!p.current||!p.current.contains(t))&&u(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let h=!!r||n&&n.length>0;function g(n){a&&(f(!0),a(n,(n,r)=>v4(e,t,n,r)).then(t=>{f(!1),t&&(u(!1),e.focus())}))}return(0,Y.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert image`,disabled:d||c,className:X(R3,{"text-accent stroke-[3px]":l}),onClick:e=>{e.preventDefault(),!h&&a?m.current?.click():u(e=>!e)},children:d?(0,Y.jsx)(hy,{size:16,className:`animate-spin`}):(0,Y.jsx)(sy,{size:16})}),d&&s!=null&&(0,Y.jsxs)(`span`,{className:`text-[10px] font-medium tabular-nums text-fg-secondary select-none`,children:[s,`%`]}),(0,Y.jsx)(`input`,{ref:m,hidden:!0,type:`file`,accept:o??`image/*`,onChange:e=>{let t=e.currentTarget.files?.[0];t&&g(t),e.target.value=``}}),l&&(0,Y.jsxs)(`div`,{ref:p,className:X(`absolute left-0 top-full z-window mt-1 rounded-md`,`border border-border-primary bg-bg-primary shadow-xl`,r?`min-w-[280px] p-0`:`min-w-[240px] p-2`),onMouseDown:e=>{e.stopPropagation()},children:[r?(0,Y.jsx)(uA,{moduleEntries:r,isImage:!0,getUrl:i,autoFocus:!0,maxHeight:280,onSelect:n=>{v4(e,t,n.filePath),u(!1),e.focus()},onEscape:()=>u(!1)}):n&&n.length>0?(0,Y.jsx)(N3,{images:n,currentSrc:``,onSelect:n=>{v4(e,t,n),u(!1),e.focus()}}):null,a&&(0,Y.jsxs)(Y.Fragment,{children:[h&&(0,Y.jsx)(`div`,{className:`mx-2 my-1 border-t border-border-primary`}),(0,Y.jsx)(`div`,{className:X(`flex items-center gap-2`,h?`px-2 pb-2`:``),children:(0,Y.jsxs)(t_,{variant:`secondary`,size:`sm`,className:`w-full`,disabled:d,onClick:e=>{e.preventDefault(),m.current?.click()},children:[d?(0,Y.jsx)(hy,{size:14,className:`mr-1.5 animate-spin`}):(0,Y.jsx)(By,{size:14,className:`mr-1.5`}),d?s==null?`Uploading...`:`Uploading ${s}%`:`Upload image`]})})]})]})]})}function UWe({view:e,schema:t,variants:n,dropdownContainer:r,readOnly:i}){return(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert details`,disabled:i,className:R3,children:(0,Y.jsx)(wy,{size:16})})}),(0,Y.jsx)(j3,{container:r,children:n.map(n=>(0,Y.jsx)(M3,{onClick:()=>{y4(e,t,n.variant),e.focus()},children:n.label},n.variant))})]})}function WWe(e){if(Array.isArray(e.link))return e.link}function GWe({view:e,schema:t,variants:n,dropdownContainer:r,readOnly:i}){let[a,o]=(0,b.useState)(null),s=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!a)return;function e(e){let t=e.target;(!s.current||!s.current.contains(t))&&o(null)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]);function c(e){o(e)}function l(n){a&&(_4(e,t,a,n),o(null),e.focus())}function u(){o(null),e.focus()}return(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,title:`Insert button`,disabled:i,className:X(R3,{"text-accent stroke-[3px]":!!a}),children:(0,Y.jsx)(by,{size:16})})}),(0,Y.jsx)(j3,{container:r,children:n.map(n=>(0,Y.jsxs)(M3,{onClick:()=>{n.link?c(n):(_4(e,t,n),e.focus())},children:[n.label,n.link&&(0,Y.jsx)(`span`,{className:`ml-1.5 text-xs text-fg-secondary-alt`,children:`(link)`})]},n.variant))})]}),a&&(0,Y.jsx)(KWe,{ref:s,linkCatalog:WWe(a),onSelectHref:l,onClose:u})]})}var KWe=(0,b.forwardRef)(function({linkCatalog:e,onSelectHref:t,onClose:n},r){let i=e&&e.length>0;return(0,Y.jsx)(`div`,{ref:r,className:X(`absolute left-0 top-full z-window mt-1 rounded-md`,`border border-border-primary bg-bg-primary shadow-xl`,i?`min-w-[280px] flex flex-col`:`flex items-center gap-1.5 p-1.5`),onMouseDown:e=>{e.stopPropagation()},children:i?(0,Y.jsx)(P3,{catalog:e,currentHref:null,onApplyLink:e=>t(e.href.trim()),onRemoveLink:null,onClose:n}):(0,Y.jsx)(F3,{currentHref:``,isNewLink:!0,onApply:e=>t(e),onUnlink:n,onClose:n})})}),qWe=new CQ(`fixedToolbar`);function JWe(e,t){let n=null,r=null;if(!t.linkHelper)throw Error(`fixedToolbar requires a linkHelper instance`);let i=t.linkHelper,a={showBlockTypeSelect:!0};function o(n){r&&r.render((0,b.createElement)(z3,{view:n,schema:e,features:t.features,linkHelper:i,options:a,images:t.getImages?.(),imageModuleEntries:t.getImageModuleEntries?.(),imageGetUrl:t.getImageGetUrl?.(),onImageUpload:t.getOnImageUpload?.(),imageAccept:t.getImageAccept?.(),uploadProgress:t.getUploadProgress?.()??null,buttonVariants:t.getButtonVariants?.(),detailsVariants:t.getDetailsVariants?.(),linkCatalog:t.getLinkCatalog?.(),styleConfig:t.styleConfig,readOnly:t.readOnly}))}return new bQ({key:qWe,view(e){let i=t.getMount();return i&&(n=document.createElement(`div`),n.className=`flex flex-row items-center justify-start px-2 py-1 gap-x-1`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Formatting`),n.addEventListener(`mousedown`,e=>{e.target.tagName!==`SELECT`&&e.preventDefault()},!0),i.appendChild(n),r=(0,x.createRoot)(n),o(e)),{update:o,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}var YWe=new CQ(`floatingToolbar`);function XWe(e,t){let n=null,r=null;if(!t?.linkHelper)throw Error(`floatingToolbar requires a linkHelper instance`);let i=t.linkHelper;function a(a){if(!n||!r)return;let{selection:o}=a.state,{empty:s,from:c,to:l}=o,{$from:u}=o,d=u.parent.type.name===`button_editable`||o instanceof cQ&&o.node.type.name===`button_editable`;if(s||d||!a.hasFocus()&&!i.isPickerOpen()){n.style.display=`none`,i.isPickerOpen()||i.closePicker();return}r.render((0,b.createElement)(z3,{view:a,schema:e,features:t?.features,linkHelper:i,images:t?.getImages?.(),imageModuleEntries:t?.getImageModuleEntries?.(),imageGetUrl:t?.getImageGetUrl?.(),onImageUpload:t?.getOnImageUpload?.(),imageAccept:t?.getImageAccept?.(),uploadProgress:t?.getUploadProgress?.()??null,buttonVariants:t?.getButtonVariants?.(),detailsVariants:t?.getDetailsVariants?.(),linkCatalog:t?.getLinkCatalog?.(),styleConfig:t?.styleConfig}));let f=a.coordsAtPos(c),p=a.coordsAtPos(l);if(t?.getPortalContainer?.()){let e=(f.left+p.left)/2,t=f.top-40;n.style.display=`flex`,n.style.left=`${Math.max(0,e-60)}px`,n.style.top=`${Math.max(0,t)}px`}else{let e=a.dom.parentElement?.getBoundingClientRect();if(!e)return;let t=(f.left+p.left)/2-e.left,r=f.top-e.top-40;n.style.display=`flex`,n.style.left=`${Math.max(0,t-60)}px`,n.style.top=`${Math.max(0,r)}px`}}return new bQ({key:YWe,view(e){n=document.createElement(`div`);let i=t?.getPortalContainer?.();return n.className=[`${i?`fixed`:`absolute`} z-window flex items-center gap-x-1 rounded-md border border-border-primary`,`bg-bg-primary px-2 py-1 shadow-lg transition-opacity`].join(` `),n.style.display=`none`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Formatting (selection)`),n.addEventListener(`mousedown`,e=>e.preventDefault(),!0),(i??e.dom.parentElement)?.appendChild(n),r=(0,x.createRoot)(n),{update:a,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}var ZWe=new CQ(`gutter`);function QWe(e,t,n){let r=null,i=null;function a(e){let t=document.createElement(`div`);return t.className=`absolute left-0 top-0 w-8 pointer-events-none`,t.style.height=`100%`,e.dom.parentElement?.appendChild(t),t}function o(e){let t=document.createElement(`div`);return t.className=[`${e?`fixed`:`absolute`} z-window flex flex-col rounded-md border border-border-primary`,`bg-bg-primary p-1 shadow-lg text-sm min-w-[140px]`].join(` `),t.style.display=`none`,t}function s(e,t){let n=0;for(let r=0;r<=t;r++)n+=e.child(r).nodeSize;return n}function c(e,t,n){let{doc:r}=e.state;if(t<0||t>=r.childCount)return;let i=s(r,t),a=e.state.tr.insert(i,n);a.setSelection(oQ.near(a.doc.resolve(i+1),1)),e.dispatch(a),e.focus()}function l(e,n){let r=[];if(r.push({label:`Paragraph`,action:t=>{c(t,n,e.nodes.paragraph.create())}}),e.nodes.heading)for(let i=1;i<=3;i++)(!t||t[j2[i-1]])&&r.push({label:`Heading ${i}`,action:t=>{c(t,n,e.nodes.heading.create({level:i}))}});return e.nodes.code_block&&(!t||t.codeBlock)&&r.push({label:`Code Block`,action:t=>{c(t,n,e.nodes.code_block.create())}}),e.nodes.details&&e.nodes.details_summary&&(!t||t.details)&&r.push({label:`Details`,action:t=>{let r=e.nodes.details_summary.create(null,[]),i=e.nodes.paragraph.create();c(t,n,e.nodes.details.create({variant:`details`},[r,i]))}}),r}function u(e){if(!r)return;r.innerHTML=``;let t=e.dom.parentElement?.getBoundingClientRect();if(!t)return;let{doc:n}=e.state;n.forEach((n,i,a)=>{let o=e.coordsAtPos(i+1).top-t.top,s=document.createElement(`button`);s.type=`button`,s.className=[`pointer-events-auto absolute left-1 flex h-6 w-6 items-center justify-center`,`rounded text-fg-secondary-alt opacity-0 transition-opacity hover:opacity-100`,`hover:bg-bg-secondary-hover`].join(` `),s.style.top=`${o}px`,s.textContent=`+`,s.title=`Add block below`,s.addEventListener(`mousedown`,t=>{t.preventDefault(),t.stopPropagation(),d(e,s,a)}),r.appendChild(s)})}function d(t,r,a){let s=n?.getPortalContainer?.();i||(i=o(!!s),(s??t.dom.parentElement)?.appendChild(i)),i.innerHTML=``;let c=l(e,a);for(let e of c){let n=document.createElement(`button`);n.type=`button`,n.className=`px-3 py-1 text-left text-fg-secondary hover:bg-bg-secondary-hover rounded`,n.textContent=e.label,n.addEventListener(`mousedown`,n=>{n.preventDefault(),e.action(t),i.style.display=`none`}),i.appendChild(n)}let u=r.getBoundingClientRect();if(s)i.style.display=`flex`,i.style.left=`${u.right+4}px`,i.style.top=`${u.top}px`;else{let e=t.dom.parentElement?.getBoundingClientRect();if(!e)return;i.style.display=`flex`,i.style.left=`${u.right-e.left+4}px`,i.style.top=`${u.top-e.top}px`}let d=e=>{i?.contains(e.target)||(i.style.display=`none`,document.removeEventListener(`mousedown`,d))};setTimeout(()=>document.addEventListener(`mousedown`,d),0)}return new bQ({key:ZWe,view(e){return r=a(e),u(e),{update:u,destroy(){r?.remove(),i?.remove(),r=null,i=null}}}})}function $We({error:e,onApplyFix:t}){let n=e.fixes;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`div`,{className:`text-fg-error-primary font-medium text-sm`,children:e.message}),n&&n.length>0&&(0,Y.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:n.map(n=>(0,Y.jsx)(`button`,{type:`button`,className:[`rounded px-2 py-0.5 text-xs font-medium`,`border border-border-error-primary text-fg-error-primary`,`hover:bg-bg-error-secondary-hover`].join(` `),onClick:r=>{r.preventDefault(),t?.({path:e.path,kind:e.kind,fixId:n.id})},children:n.label},n.id))})]})}var eGe=new CQ(`errorTooltip`);function tGe(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=null,c=null;function l(){c!==null&&(clearTimeout(c),c=null)}function u(){l(),c=setTimeout(()=>{p(),c=null},150)}function d(t){let n=e.getPortalContainer?.(),r=document.createElement(`div`);return r.className=[`${n?`fixed`:`absolute`} z-window max-w-xs rounded-md border border-border-error-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `),r.style.display=`none`,(n??t.dom.parentElement)?.appendChild(r),r}function f(i,a,o){if(!t)return;l(),r=a.path,n||=(0,x.createRoot)(t),n.render((0,Y.jsx)($We,{error:a,onApplyFix:t=>{e.onApplyErrorFix?.(t),p()}}));let s=o.getBoundingClientRect();if(e.getPortalContainer?.())t.style.display=`block`,t.style.left=`${s.left}px`,t.style.top=`${s.bottom+4}px`;else{let e=i.dom.parentElement?.getBoundingClientRect();if(!e)return;t.style.display=`block`,t.style.left=`${s.left-e.left}px`,t.style.top=`${s.bottom-e.top+4}px`}}function p(){l(),t&&(t.style.display=`none`),r=null}function m(e,t){let n=t.closest(`[data-error-path]`);if(!n)return null;let r=n.getAttribute(`data-error-path`);if(!r)return null;let i=(i4.getState(e.state)?.errors??[]).find(e=>e.path===r);return i?{error:i,target:n}:{error:{path:r,kind:n.getAttribute(`data-error-kind`)??``,message:n.getAttribute(`title`)??``},target:n}}return new bQ({key:eGe,view(e){return t=d(e),o=()=>l(),s=()=>u(),t.addEventListener(`mouseenter`,o),t.addEventListener(`mouseleave`,s),i=t=>{let n=t.target;if(!(n instanceof Element))return;let i=m(e,n);i&&i.error.path!==r&&f(e,i.error,i.target)},a=e=>{let n=e.relatedTarget;n instanceof Node&&t?.contains(n)||u()},e.dom.addEventListener(`mouseover`,i),e.dom.addEventListener(`mouseout`,a),{update(){},destroy(){l(),i&&e.dom.removeEventListener(`mouseover`,i),a&&e.dom.removeEventListener(`mouseout`,a),n&&=(n.unmount(),null),t?.remove(),t=null,r=null}}}})}var nGe=new CQ(`linkCatalog`);function rGe(e){return new bQ({key:nGe,appendTransaction(t,n,r){if(!t.some(e=>e.docChanged))return null;let i=e.getLinkCatalog();if(!i||i.length===0)return null;let a=r.schema.marks.link;if(!a)return null;let o=new Set(i.map(e=>e.href.trim())),s=r.tr,c=!1;return r.doc.descendants((e,t)=>{if(!e.isInline||!e.isText)return;let n=a.isInSet(e.marks);if(!n)return;let r=n.attrs.href.trim();o.has(r)||(s=s.removeMark(t,t+e.nodeSize,a),c=!0)}),c?s:null}})}var iGe=new CQ(`linkClick`);function aGe(e,t){let n=e;for(;n&&n!==t;){if(n.nodeName===`A`)return n;n=n.parentElement}return null}function oGe(e,t){let{linkHelper:n,getLinkCatalog:r}=t;return new bQ({key:iGe,props:{handleDOMEvents:{dblclick(t,i){let a=e.marks.link;if(!a)return!1;let o=aGe(i.target,t.dom);if(!o)return!1;i.preventDefault();let s=t.posAtDOM(o.firstChild??o,0);if(s<0)return!1;let c=t.state.doc.resolve(s),l=a.isInSet(c.marks())??(c.nodeAfter&&a.isInSet(c.nodeAfter.marks)||null);if(!l)return!1;let u=l.attrs.href,d=c.parent,f=c.start(c.depth),p=s,m=s,h=0;for(let e=0;e<d.childCount;e++){let t=d.child(e),n=t.isText?a.isInSet(t.marks):null;if(n&&n.attrs.href===u){let n=f+h,r=n+t.nodeSize;if(r>p&&n<=s){p=n,m=r;for(let t=e+1;t<d.childCount;t++){let e=d.child(t),n=e.isText?a.isInSet(e.marks):null;if(!n||n.attrs.href!==u)break;m+=e.nodeSize}for(let t=e-1;t>=0;t--){let e=d.child(t),n=e.isText?a.isInSet(e.marks):null;if(!n||n.attrs.href!==u)break;p-=e.nodeSize}break}}h+=t.nodeSize}if(p>=m)return!1;let g=t.state.tr.setSelection(oQ.create(t.state.doc,p,m));t.dispatch(g);let _=r?.();return _&&_.length>0?n.showCatalogPicker(t,a,_):n.showUrlEditor(t,a),!0}}}})}function sGe({onUpload:e,accept:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null);return(0,b.createElement)(`div`,{style:{marginTop:`6px`}},(0,b.createElement)(`input`,{ref:i,type:`file`,accept:t,hidden:!0,onChange:t=>{let n=t.currentTarget.files?.[0];n&&(r(!0),e(n).finally(()=>r(!1)),t.target.value=``)}}),(0,b.createElement)(`button`,{type:`button`,disabled:n,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`4px`,width:`100%`,padding:`4px 8px`,fontSize:`12px`,borderRadius:`4px`,border:`1px solid var(--border-primary, #ccc)`,background:`var(--bg-secondary, #f5f5f5)`,cursor:n?`wait`:`pointer`,opacity:n?.6:1},onClick:e=>{e.preventDefault(),e.stopPropagation(),i.current?.click()}},n?`Uploading...`:`Upload image`))}function cGe(e,t){let n=t?.inline??!1,r=e=>{let n=t?.getUrl?.();return n?n(e):e};return(i,a,o)=>{let s=document.createElement(n?`span`:`figure`);n?(s.style.position=`relative`,s.style.display=`inline-block`):(s.style.margin=`0.5em 0`,s.style.position=`relative`);let c=document.createElement(`img`);if(c.src=i.attrs.previewUrl||r(i.attrs.src),i.attrs.alt&&(c.alt=i.attrs.alt),c.style.maxWidth=`100%`,c.style.cursor=`pointer`,n||(c.style.display=`block`,c.style.borderRadius=`var(--radius, 0.25rem)`),s.appendChild(c),!n&&i.attrs.caption){let e=document.createElement(`figcaption`);e.textContent=i.attrs.caption,e.style.fontSize=`0.85em`,e.style.color=`var(--fg-secondary-alt)`,e.style.marginTop=`0.3em`,e.style.textAlign=`center`,s.appendChild(e)}let l=null,u=null,d=!1,f=null;function p(){u&&=(u.unmount(),null),l?.remove(),l=null,d=!1,f&&=(document.removeEventListener(`mousedown`,f,!0),null)}function m(){let n=e.current,r=t?.getOnImageUpload?.();if(!n&&!r)return;p(),d=!0,l=document.createElement(`div`),l.style.minWidth=`200px`,l.addEventListener(`mousedown`,e=>{e.stopPropagation()});let m=t?.getPortalContainer?.();if(m){l.className=[`fixed z-window rounded-md border border-border-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `);let e=c.getBoundingClientRect();l.style.left=`${e.left}px`,l.style.top=`${e.bottom+4}px`,m.appendChild(l)}else l.className=[`absolute z-window rounded-md border border-border-primary`,`bg-bg-primary p-2 shadow-lg`].join(` `),l.style.left=`0`,l.style.top=`${c.offsetHeight+4}px`,s.appendChild(l);let h=i.attrs.src;function g(e){let t=o();if(t===void 0)return null;let n=a.state.tr.setNodeMarkup(t,void 0,{...i.attrs,src:e});a.dispatch(n),p(),a.focus();let r=s4(a.state.doc,t);return r?[...r,`src`]:null}u=(0,x.createRoot)(l);let _=[];if(n&&_.push((0,b.createElement)(()=>n(h,g))),r){let e=r,n=t?.getImageAccept?.()??`image/*`;_.push((0,b.createElement)(sGe,{key:`upload`,accept:n,onUpload:async t=>await e(t,g)}))}u.render((0,b.createElement)(`div`,null,..._)),f=e=>{l&&!l.contains(e.target)&&!c.contains(e.target)&&p()},setTimeout(()=>document.addEventListener(`mousedown`,f,!0),0)}return c.addEventListener(`mousedown`,n=>{!e.current&&!t?.getOnImageUpload?.()||(n.preventDefault(),n.stopPropagation(),d?p():m())}),{dom:s,stopEvent:()=>!1,update(e){return e.type===i.type&&(i=e,c.src=i.attrs.previewUrl||r(i.attrs.src),i.attrs.alt?c.alt=i.attrs.alt:c.removeAttribute(`alt`),!0)},destroy(){p()}}}}function lGe(e,t){let n=e.find(e=>e.variant===t);if(n&&Array.isArray(n.link))return n.link}function uGe({variants:e,currentVariant:t,currentHref:n,onSelectVariant:r}){let[i,a]=(0,b.useState)(null);if(i){let t=lGe(e,i),o=t&&t.length>0;return(0,Y.jsx)(`div`,{className:o?`min-w-[280px] flex flex-col`:`flex items-center gap-1.5 p-1.5`,children:o?(0,Y.jsx)(P3,{catalog:t,currentHref:n,onApplyLink:e=>r(i,e.href.trim()),onRemoveLink:null,onClose:()=>a(null)}):(0,Y.jsx)(F3,{currentHref:n??``,isNewLink:!n,onApply:e=>r(i,e),onUnlink:()=>{r(i,``),a(null)},onClose:()=>a(null)})})}return(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.map(e=>{let n=e.variant===t;return(0,Y.jsxs)(`button`,{type:`button`,className:[`flex items-center gap-2 rounded px-3 py-1.5 text-left text-sm`,`transition-colors w-full`,n?`bg-bg-secondary-hover font-medium`:`hover:bg-bg-secondary-hover`].join(` `),onMouseDown:t=>{t.preventDefault(),e.link?a(e.variant):r(e.variant)},children:[n&&(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-brand-primary text-xs`,"aria-hidden":`true`,children:`✓`}),(0,Y.jsx)(`span`,{className:n?`text-fg-brand-primary`:`text-fg-secondary`,children:e.label}),e.link&&(0,Y.jsx)(`span`,{className:`ml-auto text-xs text-fg-secondary-alt`,children:`link`})]},e.variant)})})}var B3=[`inline-flex items-center rounded px-2 py-0.5 text-sm font-medium`,`bg-bg-brand-secondary text-fg-brand-secondary cursor-pointer`].join(` `);function V3(e,t,n,r,i,a){let o=null,s=null,c=!1,l=null;function u(){s&&=(s.unmount(),null),o?.remove(),o=null,c=!1,l&&=(document.removeEventListener(`mousedown`,l,!0),null)}function d(t){if(!o)return;let r=e.getBoundingClientRect();if(t)o.style.left=`${r.left}px`,o.style.top=`${r.bottom+4}px`;else{let e=n.dom.parentElement,t=e?.offsetParent?.getBoundingClientRect()??e?.parentElement?.getBoundingClientRect();if(!t)return;o.style.left=`${r.left-t.left}px`,o.style.top=`${r.bottom-t.top+4}px`}}function f(){let f=t.variantsRef.current;if(!f||f.length===0)return;let p=n.dom.parentElement;if(!p)return;u(),c=!0,o=document.createElement(`div`),o.style.minWidth=`180px`,o.addEventListener(`mousedown`,e=>{e.stopPropagation()});let m=a?.getPortalContainer?.(),h=!!m;o.className=[`${h?`fixed`:`absolute`} z-window rounded-md border border-border-primary`,`bg-bg-primary p-1 shadow-lg`].join(` `),(m??p).appendChild(o),d(h);let g=i(),_=g.attrs.variant,v=g.attrs.href??null;function y(e,a){let o=r();if(o===void 0)return;let s=t.variantsRef.current?.find(t=>t.variant===e);if(!s)return;let{schema:c}=n.state,l=s.children===!1,d=l?c.nodes.button_atom:c.nodes.button_editable;if(!d)return;let f={variant:e};l||(f.href=a||null);let p=i();if(l===(p.type.name===`button_atom`)){let e=n.state.tr.setNodeMarkup(o,void 0,f);n.dispatch(e)}else{let e=l?d.create(f):d.create(f,s.label?[c.text(s.label)]:[]),t=n.state.tr.replaceWith(o,o+p.nodeSize,e);n.dispatch(t)}u(),n.focus()}s=(0,x.createRoot)(o),s.render((0,b.createElement)(uGe,{variants:f,currentVariant:_,currentHref:v,onSelectVariant:y,onClose:()=>{u(),n.focus()}})),l=t=>{o&&!o.contains(t.target)&&!e.contains(t.target)&&u()},setTimeout(()=>document.addEventListener(`mousedown`,l,!0),0)}function p(){c?u():f()}return{toggle:p,closeOverlay:u,isOpen:()=>c}}function dGe(e,t){return(n,r,i)=>{let a=document.createElement(`span`);a.style.position=`relative`,a.style.display=`inline-block`;let o=document.createElement(`button`);o.setAttribute(`type`,`button`),o.className=`${B3} cursor-default`,o.contentEditable=`false`;let s=n,c=n.attrs.variant;o.setAttribute(`data-variant`,c),o.setAttribute(`data-atom`,`true`),o.textContent=e.current?.find(e=>e.variant===c)?.label??c,a.appendChild(o);let l=V3(o,{variantsRef:e},r,i,()=>s,t);return o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),l.toggle()}),{dom:a,stopEvent:()=>!0,update(t){if(t.type.name!==`button_atom`)return!1;s=t;let n=t.attrs.variant;o.setAttribute(`data-variant`,n);let r=e.current?.find(e=>e.variant===n)?.label??n;return o.textContent=r,!0},destroy(){l.closeOverlay()}}}}function fGe(e,t){return(n,r,i)=>{let a=document.createElement(`span`);a.style.position=`relative`,a.style.display=`inline-block`;let o=document.createElement(`button`);o.setAttribute(`type`,`button`),o.className=B3;let s=n,c=n.attrs.variant;o.setAttribute(`data-variant`,c);function l(e){e?(o.setAttribute(`data-href`,e),o.title=e):(o.removeAttribute(`data-href`),o.removeAttribute(`title`))}l(n.attrs.href);let u=document.createElement(`span`);o.appendChild(u),a.appendChild(o);let d=V3(o,{variantsRef:e},r,i,()=>s,t);return o.addEventListener(`dblclick`,e=>{e.preventDefault(),d.toggle()}),{dom:a,contentDOM:u,update(e){return e.type.name===`button_editable`&&(s=e,o.setAttribute(`data-variant`,e.attrs.variant),l(e.attrs.href),!0)},destroy(){d.closeOverlay()}}}}function H3({schema:e,initialDoc:t,viewRef:n,label:r,minHeight:i,allowEnter:a=!0}){let o=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!o.current)return;let e=()=>!0,r=a?[O0(E2),S0()]:[O0({Enter:e,"Shift-Enter":e}),O0(E2),S0()],i=vQ.create({doc:t,plugins:r}),s=new i0(o.current,{state:i,editable:()=>!0});return n.current=s,()=>{s.destroy(),n.current=null}},[e,t,n,a]),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-secondary`,children:r}),(0,Y.jsx)(`div`,{ref:o,className:[`prose-editor overflow-y-auto rounded-md`,`border border-border-primary bg-bg-primary p-2`,`text-fg-primary caret-fg-primary`,`focus-within:ring-2 focus-within:ring-border-brand-primary`].join(` `),style:{minHeight:i}})]})}function pGe({schema:e,summaryContent:t,bodyNodes:n,onSave:r,onCancel:i}){let a=(0,b.useRef)(null),o=(0,b.useRef)(null),s=e.node(`doc`,null,[e.node(`paragraph`,null,t)]),c=n.length>0?n:[e.node(`paragraph`)],l=e.node(`doc`,null,c),u=(0,b.useCallback)(()=>{let e=a.current,t=o.current;if(!e||!t)return;let n=[],i=e.state.doc.firstChild;i&&i.forEach(e=>n.push(e));let s=[];t.state.doc.forEach(e=>s.push(e)),r(n,s)},[r]),d=(0,b.useCallback)(e=>{e.target===e.currentTarget&&i()},[i]);return(0,b.useEffect)(()=>{function e(e){e.key===`Escape`&&i()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]),(0,Y.jsx)(`div`,{className:`fixed inset-0 z-overlay flex items-center justify-center bg-black/40`,onMouseDown:d,children:(0,Y.jsxs)(`div`,{className:[`flex w-full max-w-2xl flex-col rounded-lg border border-border-primary`,`bg-bg-primary shadow-2xl`].join(` `),onMouseDown:e=>e.stopPropagation(),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border-primary px-4 py-3`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-fg-primary`,children:`Edit Details`}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded p-1 text-fg-secondary hover:bg-bg-secondary-hover`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,Y.jsx)(H3,{schema:e,initialDoc:s,viewRef:a,label:`Summary`,minHeight:`40px`,allowEnter:!1}),(0,Y.jsx)(H3,{schema:e,initialDoc:l,viewRef:o,label:`Hidden content`,minHeight:`120px`})]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border-primary px-4 py-3`,children:[(0,Y.jsx)(`button`,{type:`button`,className:[`rounded-md px-3 py-1.5 text-sm font-medium`,`text-fg-secondary hover:bg-bg-secondary-hover`].join(` `),onClick:i,children:`Cancel`}),(0,Y.jsx)(`button`,{type:`button`,className:[`rounded-md px-3 py-1.5 text-sm font-medium`,`bg-bg-brand-primary text-fg-brand-primary`,`hover:opacity-90`].join(` `),onClick:u,children:`Save`})]})]})})}function U3(e){let t=``;return e.forEach((e,n,r)=>{r===0&&e.type.name===`details_summary`&&(t=e.textContent)}),t||`Details`}function mGe(e){let t=[];return e.forEach((e,n,r)=>{r===0&&e.type.name===`details_summary`&&e.forEach(e=>t.push(e))}),t}function hGe(e){let t=[],n=!0;return e.forEach(e=>{if(n){n=!1;return}t.push(e)}),t}function gGe(e){return(t,n,r)=>{let i=t.attrs.variant,a=document.createElement(`div`);a.className=`details-collapsed group my-1 select-none`,a.style.cursor=`pointer`,i!==`details`&&a.setAttribute(`data-variant`,i);let o=document.createElement(`div`);o.style.display=`flex`,o.style.alignItems=`center`,o.style.gap=`6px`,o.style.padding=`4px 6px`,o.style.borderRadius=`4px`,o.style.transition=`background 100ms ease`,o.addEventListener(`mouseenter`,()=>{o.style.background=`var(--bg-secondary-hover, #f5f5f5)`}),o.addEventListener(`mouseleave`,()=>{o.style.background=``}),a.appendChild(o);let s=document.createElement(`span`);s.textContent=`▶`,s.style.fontSize=`0.65em`,s.style.color=`var(--fg-secondary-alt, #888)`,s.style.userSelect=`none`,s.style.flexShrink=`0`,s.style.transition=`transform 120ms ease`,o.appendChild(s);let c=document.createElement(`span`);c.style.fontSize=`inherit`,c.style.color=`var(--fg-primary, #333)`,c.textContent=U3(t),o.appendChild(c);let l=null,u=null;function d(){l&&=(l.unmount(),null),u?.remove(),u=null,s.style.transform=``}function f(){d(),s.style.transform=`rotate(90deg)`;let t=r();if(t===void 0)return;let i=n.state.doc.nodeAt(t);if(!i||i.type.name!==`details`)return;let a=mGe(i),o=hGe(i);u=document.createElement(`div`),document.body.appendChild(u),l=(0,x.createRoot)(u),l.render((0,b.createElement)(pGe,{schema:e,summaryContent:a,bodyNodes:o,onSave:(t,i)=>{let a=r();if(a===void 0)return;let o=n.state.doc.nodeAt(a);if(!o||o.type.name!==`details`)return;let s=e.nodes.details_summary.create(null,t),l=i.length>0?i:[e.nodes.paragraph.create()],u=o.type.create(o.attrs,[s,...l]),f=n.state.tr.replaceWith(a,a+o.nodeSize,u);n.dispatch(f),d(),c.textContent=s.textContent||`Details`,n.focus()},onCancel:()=>{d(),n.focus()}}))}return o.addEventListener(`mousedown`,e=>{e.preventDefault(),e.stopPropagation(),f()}),{dom:a,update(e){if(e.type.name!==`details`)return!1;let t=e.attrs.variant;return t===`details`?a.removeAttribute(`data-variant`):a.setAttribute(`data-variant`,t),c.textContent=U3(e),!0},stopEvent(){return!0},ignoreMutation(){return!0},destroy(){d()}}}}function W3({state:e,useFixedPosition:t,onApplyLink:n,onRemoveLink:r,onApplyUrl:i,onUnlink:a,onClose:o}){let s=(0,b.useRef)(null);(0,b.useEffect)(()=>{function e(e){let t=e.target;s.current&&!s.current.contains(t)&&o()}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let c=e.kind===`catalog`,l=t?`fixed`:`absolute`;return(0,Y.jsx)(`div`,{ref:s,className:c?`${l} z-window flex flex-col rounded-md border border-border-primary bg-bg-primary shadow-xl min-w-[280px]`:`${l} z-window flex items-center gap-1.5 rounded-md border border-border-primary bg-bg-primary p-1.5 shadow-xl`,style:{left:e.anchorRect.left,top:e.anchorRect.top},onMouseDown:e=>{e.stopPropagation()},children:c&&e.catalog?(0,Y.jsx)(P3,{catalog:e.catalog,currentHref:e.currentHref,onApplyLink:n,onRemoveLink:e.currentHref===null?null:r,onClose:o}):(0,Y.jsx)(F3,{currentHref:e.currentHref??``,isNewLink:e.isNewLink??!0,onApply:i,onUnlink:a,onClose:o})})}function G3(e,t){let n=t.content.size,r=Math.min(e.anchor,n);try{return nQ.near(t.resolve(r))}catch{return nQ.atStart(t)}}var _Ge=(0,b.forwardRef)(function(e,t){let{value:n,defaultValue:r,onChange:i,onDirty:a,readOnly:o=!1,features:s,diffBase:c,errors:l,errorKindClassName:u,onApplyErrorFix:d,linkCatalog:f,images:p,imageModulePath:m,onImageUpload:h,imageAccept:g,uploadProgress:_,buttonVariants:v,detailsVariants:y,className:x,portalContainer:S}=e,{moduleEntries:C,getUrl:w,ready:T}=iA(m),E=T&&!!C,D=(0,b.useRef)(null),O=(0,b.useRef)(null),k=(0,b.useRef)(null),A=(0,b.useRef)(null),j=(0,b.useRef)([]),M=(0,b.useRef)(i),N=(0,b.useRef)(a),P=(0,b.useRef)(d),F=(0,b.useRef)(f),I=(0,b.useRef)(p),L=(0,b.useRef)(C),R=(0,b.useRef)(w),[ee,te]=(0,b.useState)(null),ne=(0,b.useRef)(ee);ne.current=ee;let re=(0,b.useRef)(void 0),ie=(0,b.useRef)(h),ae=(0,b.useRef)(g),oe=(0,b.useRef)(_),se=(0,b.useRef)(v),ce=(0,b.useRef)(y),le=(0,b.useRef)(S),ue=(0,b.useRef)(null),de=n!==void 0;(0,b.useEffect)(()=>{M.current=i,N.current=a,P.current=d,F.current=f,I.current=p,L.current=C,R.current=w,ie.current=h,ae.current=g,oe.current=_,se.current=v,ce.current=y,le.current=S,E?re.current=(e,t)=>(0,Y.jsx)(uA,{moduleEntries:L.current,selectedRef:e,isImage:!0,getUrl:R.current,autoFocus:!0,maxHeight:280,onSelect:e=>{t(e.filePath)}}):p&&p.length>0?re.current=(e,t)=>(0,Y.jsx)(N3,{images:I.current,currentSrc:e,onSelect:t}):re.current=void 0});let fe={...MHe,...s},pe=fe.styles,me=(0,b.useMemo)(()=>rHe({features:fe,buttonVariants:v,detailsVariants:y,styleConfig:pe}),[]);A.current=me.marks.link??null;let he=fe.fixedToolbar&&lUe({schema:me,features:fe,styleConfig:pe,canInsertImage:!!h||!!p?.length||!!m,buttonVariants:v,detailsVariants:y});(0,b.useLayoutEffect)(()=>{if(!D.current)return;let e=de?n:r??[],t,i=ue.current;if(ue.current=null,i!==null&&i.type.schema===me)t=i;else{try{t=n2(e??[],me)}catch{t=me.node(`doc`,null,[me.node(`paragraph`)])}j.current=e??[]}let a=()=>le.current??null,s=[...NHe(me,fe),IHe(me,fe),S0(),E0(),M0(),HHe(),$He(fe),eUe(),tGe({getPortalContainer:a,onApplyErrorFix:e=>{if(e.kind===`schema.violation`&&k.current){YHe(k.current,e.path,e.fixId);return}P.current?.(e)}})],c=()=>F.current,l=()=>se.current,u=()=>ce.current,d=sUe({getLinkCatalog:c,getPortalContainer:a,onPickerStateChange:e=>{te(e)},isPickerOpen:()=>ne.current!==null});s.push(rGe({getLinkCatalog:c})),!o&&fe.link&&s.push(oGe(me,{getLinkCatalog:c,linkHelper:d}));let f=()=>I.current,p=()=>L.current,m=()=>R.current,h=()=>ie.current,g=()=>ae.current,_=()=>oe.current;fe.fixedToolbar&&s.push(JWe(me,{getMount:()=>O.current,getLinkCatalog:c,getImages:f,getImageModuleEntries:p,getImageGetUrl:m,getOnImageUpload:h,getImageAccept:g,getUploadProgress:_,getButtonVariants:l,getDetailsVariants:u,linkHelper:d,styleConfig:pe,features:fe,readOnly:o})),fe.floatingToolbar&&!o&&s.push(XWe(me,{getPortalContainer:a,getLinkCatalog:c,getImages:f,getImageModuleEntries:p,getImageGetUrl:m,getOnImageUpload:h,getImageAccept:g,getUploadProgress:_,getButtonVariants:l,getDetailsVariants:u,linkHelper:d,styleConfig:pe,features:fe})),fe.gutter&&!o&&s.push(QWe(me,fe,{getPortalContainer:a}));let v={};me.nodes.image&&(v.image=cGe(re,{inline:!0,getPortalContainer:a,getUrl:m,getOnImageUpload:h,getImageAccept:g})),me.nodes.button_atom&&(v.button_atom=dGe(se,{getPortalContainer:a})),me.nodes.button_editable&&(v.button_editable=fGe(se,{getPortalContainer:a})),me.nodes.details&&(v.details=gGe(me));let y=vQ.create({doc:t,plugins:s}),b=new i0(D.current,{state:y,editable:()=>!o,nodeViews:v,dispatchTransaction(e){let t=b.state.apply(e);if(b.updateState(t),e.docChanged&&(N.current?.(),M.current)){let e=o2(t.doc),n=e2(j.current,e);j.current=e,M.current({value:e,patches:n})}}});return k.current=b,()=>{ue.current=b.state.doc,d.destroy(),b.destroy(),k.current=null}},[me,o,he,fe.floatingToolbar,fe.gutter]),(0,b.useEffect)(()=>{let e=k.current;e&&e.dispatch(e.state.tr)},[C,p,h,v,y]),(0,b.useEffect)(()=>{let e=k.current;if(!e||!de||!n)return;let t=o2(e.state.doc);if(JSON.stringify(t)!==JSON.stringify(n))try{let t=n2(n,me),r=e.state.selection,i=vQ.create({doc:t,plugins:e.state.plugins,selection:G3(r,t)});e.updateState(i),j.current=n}catch(e){console.error(e)}},[n,de,me]),(0,b.useEffect)(()=>{let e=k.current;if(e){if(c)try{let t=n2(c,me),n=e.state.tr.setMeta(J2,{baseDoc:t});e.dispatch(n)}catch{}else{let t=e.state.tr.setMeta(J2,{baseDoc:null});e.dispatch(t)}}},[c,me]),(0,b.useEffect)(()=>{let e=k.current;if(!e)return;let t=e.state.tr.setMeta(i4,{errors:l??[],errorKindClassName:u??{}});e.dispatch(t)},[l,u]);let ge=(0,b.useCallback)(()=>k.current?o2(k.current.state.doc):[],[]),_e=(0,b.useCallback)(e=>e2(e,k.current?o2(k.current.state.doc):[]),[]),ve=(0,b.useCallback)(e=>{let t=k.current;if(!t)return;let n=e?n2(e,me):me.node(`doc`,null,[me.node(`paragraph`)]),r=t.state.selection,i=vQ.create({doc:n,plugins:t.state.plugins,selection:G3(r,n)});t.updateState(i),j.current=e??[]},[me]);(0,b.useImperativeHandle)(t,()=>({getDocument:ge,getPatches:_e,reset:ve}),[ge,_e,ve]);let ye=(0,b.useCallback)(e=>{let t=k.current,n=A.current,r=ne.current;if(!t||!n||!r)return;let{state:i,dispatch:a}=t,o=i.tr;e?(o=o.removeMark(r.savedFrom,r.savedTo,n),o=o.addMark(r.savedFrom,r.savedTo,n.create({href:e}))):o=o.removeMark(r.savedFrom,r.savedTo,n),a(o),te(null),t.focus()},[]),be=(0,b.useCallback)(e=>{ye(e.href.trim())},[ye]),xe=(0,b.useCallback)(()=>{ye(null)},[ye]),Se=(0,b.useCallback)(e=>{ye(e)},[ye]),Ce=(0,b.useCallback)(()=>{ye(null)},[ye]),we=(0,b.useCallback)(()=>{te(null),k.current?.focus()},[]);return(0,Y.jsxs)(`div`,{className:[`rich-text-editor relative flex flex-col`,o?`cursor-default`:``,x??``].filter(Boolean).join(` `),children:[he&&(0,Y.jsx)(`div`,{ref:O,className:[`rounded-t-md border border-border-primary`,`bg-bg-secondary absolute left-0 top-0 z-hover w-full`].join(` `)}),(0,Y.jsx)(`div`,{ref:D,className:[`prose-editor relative min-h-10 border border-border-primary`,`bg-bg-primary text-fg-primary caret-fg-primary`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-border-focus rounded-md`,`px-3 py-2`,he?`pt-14`:``,o?`opacity-80`:``].join(` `)}),ee&&(S?(0,lm.createPortal)((0,Y.jsx)(W3,{state:ee,useFixedPosition:!0,onApplyLink:be,onRemoveLink:xe,onApplyUrl:Se,onUnlink:Ce,onClose:we}),S):(0,Y.jsx)(W3,{state:ee,onApplyLink:be,onRemoveLink:xe,onApplyUrl:Se,onUnlink:Ce,onClose:we}))]})});function vGe(e){if(!e)return{};let t={};return t.bold=e.bold??!1,t.italic=e.italic??!1,t.strikethrough=e.lineThrough??!1,t.h1=e.h1??!1,t.h2=e.h2??!1,t.h3=e.h3??!1,t.h4=e.h4??!1,t.h5=e.h5??!1,t.h6=e.h6??!1,t.bulletList=e.ul??!1,t.orderedList=e.ol??!1,t.link=!!e.a,t.image=!!e.img,t.hardBreak=!0,t.fixedToolbar=!0,t.floatingToolbar=!1,t.gutter=!1,t.code=!1,t.blockquote=!1,t.codeBlock=!1,t.details=!1,t.button=!1,t}function yGe(e){if(!(!e||typeof e.path!=`string`))return H.mediaUrl({path:e.path})}function bGe(e){let t=(0,b.useMemo)(()=>vGe(e),[e]),n=e?.a===!0||typeof e?.a==`object`&&`type`in e.a&&e.a.type===`route`,r=n&&e?.a&&typeof e.a==`object`&&`type`in e.a&&e.a.type===`route`?e.a:void 0,i=(0,b.useMemo)(()=>r?.options?.include?new RegExp(r.options.include.source,r.options.include.flags):void 0,[r?.options?.include?.source,r?.options?.include?.flags]),a=(0,b.useMemo)(()=>r?.options?.exclude?new RegExp(r.options.exclude.source,r.options.exclude.flags):void 0,[r?.options?.exclude?.source,r?.options?.exclude?.flags]),o=TA(),s=ooe();return{features:t,linkCatalog:(0,b.useMemo)(()=>{if(!n)return;let e=new Map;return o.filter(({route:e})=>!(i&&!i.test(e)||a&&a.test(e))).map(({route:t,moduleFilePath:n})=>{if(!e.has(n)){let t=new Map,r=s[n];if(r){let e=r[n];if(e&&`data`in e&&e.data&&e.data.parent===`record`)for(let[n,r]of e.data.items)t.set(n,{title:r.title,subtitle:r.subtitle,image:yGe(r.image)})}e.set(n,t)}let r=e.get(n)?.get(t);return r?{title:r.title,subtitle:r.subtitle??n,href:t,image:r.image}:{title:t,subtitle:n,href:t}})},[n,o,i,a,s]),imageModulePath:(0,b.useMemo)(()=>{let t=e?.img;if(t&&typeof t==`object`&&`type`in t&&t.type===`image`&&`referencedModule`in t&&typeof t.referencedModule==`string`)return t.referencedModule},[e]),imageSchema:(0,b.useMemo)(()=>{let t=e?.img;if(t&&typeof t==`object`&&`type`in t&&t.type===`image`)return t},[e])}}var xGe=400;function SGe({path:e,readonly:t}){let n=`richtext`,r=bb(),i=xS(),a=SS(),{source:o,schema:s,patchPath:c,addPatch:l,addAndUploadPatchWithFileOps:u,addModuleFilePatch:d}=yb(e,n),f=`data`in o?o.data:void 0,p=(0,b.useRef)(null),m=(0,b.useRef)(f??[]),h=(0,b.useRef)(null),g=(0,b.useRef)(!1),_=(0,b.useRef)(!1),v=(0,b.useRef)(!1),y=(0,b.useRef)(null),[x,S]=(0,b.useState)(null),C=`clientSideOnly`in o&&o.clientSideOnly;(0,b.useEffect)(()=>{if(C!==!1||!f||v.current)return;let e=f,t=p.current?.getDocument();t&&!Mr(t,e)&&(p.current?.reset(e),m.current=e)},[f,C]);let w=eb(),T=`data`in s&&s.data.type===`richtext`?s.data.options:void 0,{features:E,linkCatalog:D,imageModulePath:O,imageSchema:k}=bGe(T),A=!!T?.img,j=k?.referencedModule,M=Tb(j),N=(0,b.useMemo)(()=>{if(A){if(k?.options?.accept)return k.options.accept;if(M?.type===`record`&&M.accept)return M.accept}},[A,k,M]),P=(0,b.useMemo)(()=>M?.type===`record`?M.directory:void 0,[M]),F=(0,b.useMemo)(()=>{let e=M?.type===`record`?M.encode:void 0;return{settings:hA(k?.options?.encode,e),accept:N}},[k,M,N]),I=(0,b.useMemo)(()=>!A||!k?.remote||i.status!==`ready`||!a||!r?.remoteHost?null:{publicProjectId:i.publicProjectId,bucket:a,coreVersion:i.coreVersion,schema:k,remoteHost:r.remoteHost},[A,k,i,a,r]),L=(0,b.useMemo)(()=>{if(A)return async(e,t)=>{try{let n=await gA(e,F),r;n.width&&n.height&&n.mimeType&&(r={width:n.width,height:n.height,mimeType:n.mimeType});let{patch:i,filePath:a}=await CA(c,n.src,n.filename??null,n.fileHash,r,`image`,I,P,!!j);if(i.length===0)return null;let o=i[0]&&`value`in i[0]&&typeof i[0].value==`object`&&i[0].value!==null&&`path`in i[0].value?i[0].value.path:a,s=i.filter(e=>e.op===`file`);_.current=!0;let l=t(o,{previewUrl:n.src,width:r?.width,height:r?.height,mimeType:r?.mimeType});h.current&&=(clearTimeout(h.current),null),v.current=!1;let f=p.current?.getDocument();if(!f)return null;let g=K3(c,f);m.current=f;let y=s.map(e=>({...e,...l?{nestedFilePath:l}:{}})),b=[...g,...y],x=[];j&&a&&r?.mimeType&&r.width!==void 0&&r.height!==void 0&&x.push({moduleFilePath:j,patch:[{op:`add`,path:[a],value:{width:r.width,height:r.height,mimeType:r.mimeType,alt:null}}]}),S(0),await u(b,`image`,e=>{console.error(`Failed to upload image in richtext:`,e),S(null)},(e,t,n,r)=>{let i=t>0?Math.round(e*(n+1)/(t*r)*100):0;S(Math.min(i,100))}),S(null);for(let e of x)d(e.moduleFilePath,e.patch,`record`);return{filePath:a,ref:o}}catch(e){return console.error(`Failed to prepare image for upload`,e),S(null),null}}},[A,c,I,P,j,u,d,F]),R=(0,b.useCallback)(()=>{if(!g.current){if(_.current){_.current=!1;return}v.current=!0,y.current=p.current?.getDocument()??null,h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,ee.current()},xGe)}},[]),ee=(0,b.useRef)(()=>void 0);return ee.current=()=>{let e=y.current??p.current?.getDocument();if(!e)return;y.current=null;let t=K3(c,e);m.current=e,l(t,`richtext`),v.current=!1},(0,b.useEffect)(()=>()=>{h.current&&(clearTimeout(h.current),h.current=null,ee.current()),v.current=!1},[]),s.status===`error`?(0,Y.jsx)(NC,{path:e,error:s.error,type:n}):o.status===`error`?(0,Y.jsx)(FC,{path:e,error:o.error,schema:s}):o.status===`not-found`||s.status===`not-found`?(0,Y.jsx)(MC,{path:e,type:n}):s.status===`loading`||!(`data`in o)||o.data===void 0?(0,Y.jsx)(jC,{path:e,type:n}):s.data.type===n?(r?.remoteHost||console.warn(`RichTextField: config.remoteHost is not set. Remote images will not work.`),(0,Y.jsx)(`div`,{id:e,className:`m-1`,children:(0,Y.jsx)(_Ge,{ref:p,defaultValue:f??[],features:E,linkCatalog:D,readOnly:t||g.current,onDirty:R,imageModulePath:O,onImageUpload:L,imageAccept:N,uploadProgress:x,portalContainer:w})})):(0,Y.jsx)(PC,{path:e,expectedType:n,actualType:s.data.type})}function K3(e,t){return[{op:`replace`,path:e,value:t}]}function CGe({path:e}){let t=Ob(e,`richtext`);if(t.status===`error`)return(0,Y.jsx)(FC,{path:e,error:t.error});if(t.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:`richtext`});if(!(`data`in t)||t.data===void 0)return(0,Y.jsx)(J3,{path:e});if(t.data===null)return(0,Y.jsx)(Y3,{path:e});let n=wGe(t.data);return n.status===`error`?(0,Y.jsx)(FC,{path:e,error:n.error}):(0,Y.jsx)(`div`,{className:`truncate`,children:n.value})}function wGe(e){let t;function n(e){if(t)return t;if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(`children`in e&&Array.isArray(e.children))return e.children.map(n).join(` `);if(`tag`in e&&typeof e.tag==`string`)return``}return t=`Invalid richtext node: `+JSON.stringify(e),JSON.stringify(e)}let r=e.map(n).join(` `);return t?{status:`error`,error:t}:{status:`ok`,value:r}}function q3({path:e,size:t}){let n=Cb(e),r=Ob(e,`data`in n&&n.data.type?n.data.type:void 0);if(!(`data`in n)||n.data===void 0)return(0,Y.jsx)(J3,{path:e});let i=n.data.type;return`data`in r&&r.data===null?(0,Y.jsx)(Y3,{path:e}):i===`string`?(0,Y.jsx)(ude,{path:e}):i===`array`?(0,Y.jsx)(FGe,{path:e}):i===`boolean`?(0,Y.jsx)(Cde,{path:e}):i===`number`?(0,Y.jsx)(Tde,{path:e}):i===`union`?(0,Y.jsx)(ige,{path:e}):i===`object`?(0,Y.jsx)(Jhe,{path:e,size:t}):i===`image`?(0,Y.jsx)(Uge,{path:e}):i===`keyOf`?(0,Y.jsx)(qge,{path:e}):i===`route`?(0,Y.jsx)(y_e,{path:e}):i===`date`?(0,Y.jsx)(qye,{path:e}):i===`dateTime`?(0,Y.jsx)(nbe,{path:e}):i===`color`?(0,Y.jsx)(nRe,{path:e}):i===`code`?(0,Y.jsx)($Le,{path:e}):i===`literal`?(0,Y.jsx)(rRe,{path:e}):i===`record`?(0,Y.jsx)(FRe,{path:e,size:t}):i===`richtext`?(0,Y.jsx)(CGe,{path:e}):i===`file`?(0,Y.jsx)(zge,{path:e}):(0,Y.jsxs)(`div`,{children:[`Cannot preview: `,i]})}function J3({path:e}){return(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)(hy,{size:12,className:`animate-spin`})},e+`-loading`)}function Y3({path:e}){return(0,Y.jsx)(`div`,{id:e,className:`text-fg-quaternary`,children:`<empty>`},e+`-null`)}function X3({path:e,className:t,size:n}){let r=fk(e);return r?(0,Y.jsx)(ode,{title:r.title,image:r.image,subtitle:r.subtitle??null,className:t,size:n}):(0,Y.jsx)(`div`,{className:X(`p-2`,t),children:(0,Y.jsx)(q3,{path:e,size:n})})}var Z3=`touch-none`,Q3=`touch-manipulation`;function $3({source:e,disabled:t,onMove:n,renderItem:r,className:i}){let[a,o]=(0,b.useState)([]);(0,b.useEffect)(()=>{let t=[],n=1;for(let r of e)t.push({path:r,id:n}),n++;o(t)},[e]);let s=bw(yw(nT),yw(iT),yw(Xw,{coordinateGetter:AT})),[c,l]=(0,b.useState)(null),u=c===null?void 0:a.find(e=>e.id===c),d=(0,b.useCallback)(e=>{let{active:t,over:r}=e;if(t?.id!==r?.id){let e=a.findIndex(e=>e.id===Number(t?.id)),i=a.findIndex(e=>e.id===Number(r?.id));o(t=>TT(t,e,i)),n(e,i)}l(null)},[a,n]);return(0,Y.jsxs)(bue,{sensors:s,collisionDetection:Dw,onDragStart:e=>l(Number(e.active.id)),onDragEnd:d,onDragCancel:()=>l(null),children:[(0,Y.jsx)(Yue,{items:a,strategy:Gue,disabled:t,children:(0,Y.jsx)(`div`,{className:i??`flex flex-col gap-y-4 w-full`,children:a.map(({path:e,id:t},n)=>(0,Y.jsx)(`div`,{style:{opacity:t===c?.3:void 0},children:r({path:e,id:t,index:n})},t))})}),(0,Y.jsx)(Bue,{dropAnimation:null,children:u?r({path:u.path,id:u.id,index:a.indexOf(u)}):null})]})}function TGe({source:e,disabled:t,onClick:n,onMove:r,onDelete:i,onDuplicate:a}){return(0,Y.jsx)($3,{source:e,disabled:t,onMove:r,renderItem:({path:e,id:r})=>(0,Y.jsx)(EGe,{id:r,disabled:t,path:e,onClick:n,onDelete:e=>{i(e-1)},onDuplicate:e=>{a(e-1)}})})}function EGe({id:e,path:t,disabled:n,onClick:r,onDelete:i,onDuplicate:a}){let o=eb(),s=(0,b.useRef)(null),[c,l]=(0,b.useState)(!1);(0,b.useEffect)(()=>{s.current&&(s.current.getBoundingClientRect().height>=170?l(!0):l(!1))},[e,t]);let{attributes:u,listeners:d,setNodeRef:f,transform:p,transition:m}=OT({id:e,disabled:n===!0}),h=Fb()||{},g={transform:mw.Transform.toString(p),transition:m},_=!(h[t]?.length>0);return(0,Y.jsxs)(`div`,{ref:f,style:g,className:X(`relative flex disabled:opacity-55 flex-1`,Q3,{"items-start":!_,"items-center":_}),children:[(0,Y.jsx)(`button`,{...u,...d,className:X(`pb-1 pr-2 rounded-sm text-fg-secondary hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,Z3,{"opacity-30":n,"mt-2.5":!_}),disabled:n,onClick:()=>{r(t)},children:(0,Y.jsx)(ay,{})}),(0,Y.jsxs)(`button`,{className:X(`flex-grow`,`relative flex text-left border rounded-lg border-border bg-card gap-y-2 bg-bg-primary`,`hover:bg-bg-secondary-hover`,`overflow-y-clip`),style:{maxHeight:170},ref:s,disabled:n,onClick:()=>{r(t)},children:[(0,Y.jsx)(X3,{path:t,className:`flex-grow w-full`}),c&&(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full bg-gradient-to-b via-50% from-transparent via-card/90 to-card`,style:{height:40}})]}),cX(t,h)&&(0,Y.jsx)(`div`,{className:X(`absolute right-3`,{"top-2":_,"top-0":!_}),children:(0,Y.jsx)(lX,{})}),(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{className:X(`flex hover:bg-bg-secondary-hover px-2 hover:rounded-lg`,{"items-start mt-4":!_,"items-center py-2":_}),children:(0,Y.jsx)(Yv,{size:16})}),(0,Y.jsxs)(wD,{className:`p-2`,container:o,side:`top`,children:[(0,Y.jsxs)(`button`,{className:X(`flex items-center gap-x-2`),onClick:()=>{i(e)},children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(Iy,{className:`w-4 h-4`})}),(0,Y.jsx)(`span`,{children:`Delete`})]}),(0,Y.jsxs)(`button`,{className:X(`flex items-center gap-x-2`),onClick:()=>{a(e)},children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(qv,{className:`w-4 h-4`})}),(0,Y.jsx)(`span`,{children:`Duplicate`})]})]})]})]})}var DGe=X(`[&_input]:h-7 [&_input]:m-0 [&_input]:w-full [&_input]:px-2 [&_input]:py-1 [&_input]:text-[13px]`,`[&_textarea]:min-h-0 [&_textarea]:m-0 [&_textarea]:px-2 [&_textarea]:py-1 [&_textarea]:text-[13px] [&_textarea]:leading-5 [&_textarea]:[field-sizing:content]`,`[&_[data-testid=auto-growing-textarea-ghost]]:m-0 [&_[data-testid=auto-growing-textarea-ghost]]:px-2 [&_[data-testid=auto-growing-textarea-ghost]]:py-1 [&_[data-testid=auto-growing-textarea-ghost]]:text-[13px] [&_[data-testid=auto-growing-textarea-ghost]]:leading-5`,`[&_.rich-text-editor:not(:focus-within)_.prose-editor]:p-2 [&_.rich-text-editor:not(:focus-within)_.prose-editor]:min-h-0`,`[&_.rich-text-editor:not(:focus-within)>.absolute]:hidden`,`[&_.prose-editor]:text-[13px]`);function e6({path:e,readonly:t,depth:n=0}){let r=`array`,{navigate:i}=GC(),a=Ab(e),{source:o,schema:s,addPatch:c,patchPath:l}=yb(e,r,{watchUnsaved:!0}),[u,d]=(0,b.useState)([]),f=`data`in o&&o.data?o.data:null;(0,b.useEffect)(()=>{let e=[],t=1;for(let n of f??[])e.push({path:n,id:t}),t++;d(e)},[f]);let p=bw(yw(nT),yw(iT),yw(Xw,{coordinateGetter:AT})),[m,h]=(0,b.useState)(null),g=m===null?void 0:u.find(e=>e.id===m),_=(0,b.useCallback)((e,t)=>{c([{op:`move`,from:l.concat(e.toString()),path:l.concat(t.toString())}],r)},[c,l]),v=(0,b.useCallback)(e=>{let{active:t,over:n}=e;if(t?.id!==n?.id){let e=u.findIndex(e=>e.id===Number(t?.id)),r=u.findIndex(e=>e.id===Number(n?.id));d(t=>TT(t,e,r)),_(e,r)}h(null)},[u,_]);if(s.status===`error`||s.status===`not-found`||s.status===`loading`||f===null||s.data.type!==`array`)return null;let y=s.data,x=(e,o)=>(0,Y.jsx)(OGe,{id:e.id,index:o,path:e.path,itemSchema:y.item,depth:n,readonly:t,onNavigate:e=>i(e),onDelete:()=>{c([{op:`remove`,path:l.concat(o.toString())}],r)},onDuplicate:()=>{`data`in a&&a.data&&Array.isArray(a.data)&&c([{op:`add`,path:l.concat(o.toString()),value:a.data[o]??null}],r)}},e.id);return(0,Y.jsxs)(`div`,{id:e,className:X(`w-full`,{[DGe]:n===0}),children:[(0,Y.jsxs)(bue,{sensors:p,collisionDetection:Dw,onDragStart:e=>h(Number(e.active.id)),onDragEnd:v,onDragCancel:()=>h(null),children:[(0,Y.jsx)(Yue,{items:u,strategy:Gue,disabled:t,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1 w-full`,children:u.map((e,t)=>(0,Y.jsx)(`div`,{style:{opacity:e.id===m?.3:void 0},children:x(e,t)},e.id))})}),(0,Y.jsx)(Bue,{dropAnimation:null,children:g?x(g,u.indexOf(g)):null})]}),!t&&(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 h-6 mt-0.5 px-1 text-xs text-fg-tertiary hover:text-fg-primary`,onClick:()=>{c([{op:`add`,path:l.concat(u.length.toString()),value:Cp(y.item)}],r)},children:[(0,Y.jsx)(Oy,{size:12}),(0,Y.jsx)(`span`,{children:`Add`})]})]})}function OGe({id:e,index:t,path:n,itemSchema:r,depth:i,readonly:a,onNavigate:o,onDelete:s,onDuplicate:c}){let{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p}=OT({id:e,disabled:a===!0}),[m,h]=(0,b.useState)(!1),g=Pb(n),_={transform:mw.Transform.toString(f),transition:p},v=xr(r),y=v&&(r.type===`object`||r.type===`union`&&Zhe(r)),x=(0,Y.jsx)(`button`,{...l,...u,className:X(`cursor-grab text-fg-quaternary hover:text-fg-primary`,Z3,{"opacity-30":a}),disabled:a,children:(0,Y.jsx)(ay,{size:14})}),S=a?null:(0,Y.jsx)(MGe,{onDelete:s,onDuplicate:c});return(0,Y.jsxs)(`div`,{"data-val-studio-path":n,ref:d,style:_,className:X(`border bg-bg-primary`,Q3,i===0?`rounded-md`:`rounded-r-md border-l-0`,{"border-border-primary":g.length===0,"border-bg-warning-secondary":g.length>0}),children:[y&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 h-7 px-1.5`,children:[x,(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 flex-1 min-w-0 text-left`,onClick:()=>h(e=>!e),children:[(0,Y.jsx)(Rv,{size:12,className:X(`shrink-0 text-fg-quaternary transition-transform`,{"rotate-90":!m})}),(0,Y.jsx)(`span`,{className:`w-4 shrink-0 text-[10px] text-fg-quaternary`,children:t+1}),(0,Y.jsx)(jGe,{path:n})]}),S]}),y&&!m&&(0,Y.jsx)(`div`,{className:`pr-1.5 pb-1.5 pt-0.5`,children:r.type===`union`?(0,Y.jsx)(kGe,{path:n,itemSchema:r,depth:i,readonly:a}):(0,Y.jsx)(t6,{path:n,itemSchema:r,depth:i,readonly:a})}),v&&!y&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-1.5 px-1.5 py-1`,children:[(0,Y.jsx)(`div`,{className:`pt-2`,children:x}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(a6,{path:n,schema:r,readonly:a===!0||r.readonly===!0,compact:!0,errorDisplay:`none`})}),S]}),!v&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 px-1.5 py-1`,children:[x,(0,Y.jsx)(`button`,{className:`flex-1 min-w-0 overflow-y-clip rounded text-left text-xs hover:bg-bg-secondary-hover`,style:{maxHeight:96},onClick:()=>o(n),children:(0,Y.jsx)(X3,{path:n,className:`w-full`})}),S]}),g.length>0&&(0,Y.jsx)(`div`,{className:`px-2.5 pb-1.5`,children:(0,Y.jsx)(Uk,{validationErrors:g})})]})}function kGe({path:e,itemSchema:t,depth:n,readonly:r}){return Zhe(t)?(0,Y.jsx)(AGe,{path:e,itemSchema:t,depth:n,readonly:r}):null}function AGe({path:e,itemSchema:t,depth:n,readonly:r}){let i=$he(e,t);return i.status===`loading`?null:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`div`,{className:`pl-2`,children:(0,Y.jsx)(ege,{state:i,readonly:r,className:`h-7 w-auto min-w-24 px-2 py-1 text-[13px]`})}),(0,Y.jsx)(t6,{path:e,itemSchema:i.selectedSchema,depth:n,readonly:r,omitKeys:[t.key]})]})}function t6({path:e,itemSchema:t,depth:n,readonly:r,omitKeys:i}){let[a,o]=(0,b.useState)({});return t.type===`object`?(0,Y.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:Object.entries(t.items).map(([t,s])=>{if(s.hidden||i?.includes(t))return null;let c=sD(e,t),l=r===!0||s.readonly===!0;if(s.type===`array`&&xr(s.item)){let e=a[t]===!0;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-1 pl-2 text-left`,onClick:()=>o(n=>({...n,[t]:!e})),children:[(0,Y.jsx)(Rv,{size:10,className:X(`shrink-0 text-fg-quaternary transition-transform`,{"rotate-90":!e})}),(0,Y.jsx)(n6,{label:t})]}),!e&&(0,Y.jsx)(e6,{path:c,depth:n+1,readonly:l})]},t)}return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2`,children:[(0,Y.jsx)(n6,{label:t}),(0,Y.jsx)(a6,{path:c,schema:s,readonly:l,compact:!0,errorDisplay:`compact`})]},t)})}):null}function n6({label:e}){return(0,Y.jsx)(`span`,{className:`text-[11px] leading-4 text-fg-tertiary`,children:e})}function jGe({path:e}){let t=fk(e),n=Ab(e),r=(0,b.useMemo)(()=>t?.title?t.title:`data`in n&&n.data!==void 0?r6(n.data):null,[t,n]);return(0,Y.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-xs text-fg-tertiary`,children:r??``})}function r6(e){if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=r6(t);if(e!==null)return e}return null}if(typeof e==`object`&&e)for(let[t,n]of Object.entries(e)){if(t===`type`||t===`_type`||t===`tag`||n===void 0)continue;let e=r6(n);if(e!==null)return e}return null}function MGe({onDelete:e,onDuplicate:t}){let n=eb();return(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(CD,{className:`shrink-0 rounded px-0.5 py-1 text-fg-quaternary hover:text-fg-primary hover:bg-bg-secondary-hover`,children:(0,Y.jsx)(Yv,{size:14})}),(0,Y.jsxs)(wD,{className:`p-2 w-auto`,container:n,side:`top`,children:[(0,Y.jsxs)(`button`,{className:`flex items-center gap-x-2 text-sm`,onClick:e,children:[(0,Y.jsx)(Iy,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:`Delete`})]}),(0,Y.jsxs)(`button`,{className:`flex items-center gap-x-2 text-sm`,onClick:t,children:[(0,Y.jsx)(qv,{className:`w-3.5 h-3.5`}),(0,Y.jsx)(`span`,{children:`Duplicate`})]})]})]})}function NGe({id:e,disabled:t,children:n}){let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s}=OT({id:e,disabled:t===!0}),c={transform:mw.Transform.toString(o),transition:s};return(0,Y.jsxs)(`div`,{ref:a,style:c,className:`flex items-start gap-2`,children:[(0,Y.jsx)(`button`,{...r,...i,className:X(`pt-4 pr-1`,Z3,{invisible:t}),disabled:t,children:(0,Y.jsx)(ay,{size:16})}),(0,Y.jsx)(`div`,{className:`flex-1`,children:n})]})}function PGe({path:e,readonly:t,compact:n,inline:r,errorDisplay:i=`default`}){let a=`array`,{navigate:o}=GC(),s=xb(e),c=Ab(e),{source:l,schema:u,addPatch:d,patchPath:f,hasUnsavedOwnEdit:p}=yb(e,a,{watchUnsaved:!0});if(u.status===`error`)return(0,Y.jsx)(NC,{path:e,error:u.error,type:a});if(l.status===`error`)return(0,Y.jsx)(FC,{path:e,error:l.error,schema:u});if(l.status==`not-found`||u.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:a});if(u.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:a});if(u.data.type!==`array`)return(0,Y.jsx)(PC,{path:e,expectedType:`array`,actualType:u.data.type});let m=u.data,h=(s&&`data`in s?s.data:void 0)!==void 0&&(p||l.status===`loading`);if(xr(m.item))return(0,Y.jsxs)(`div`,{className:`relative w-full`,children:[s?.status===`error`&&(0,Y.jsx)(uX,{error:s.message,path:e}),(0,Y.jsx)(e6,{path:e,readonly:t})]});if(r){let a=l.data;return a===null?null:(0,Y.jsx)(`div`,{id:e,children:(0,Y.jsx)($3,{source:a,disabled:t,onMove:(e,t)=>{d([{op:`move`,from:f.concat(e.toString()),path:f.concat(t.toString())}],m.type)},className:`flex flex-col ${n?`gap-3`:`gap-4`}`,renderItem:({path:e,id:a})=>m.item.hidden?null:(0,Y.jsx)(NGe,{id:a,disabled:t,children:(0,Y.jsx)(qk,{path:e,type:m.item.type,readonly:t||m.item.readonly,compact:n,errorDisplay:i,children:(0,Y.jsx)(a6,{path:e,schema:m.item,readonly:t||m.item.readonly,compact:n,inline:r,errorDisplay:i})})})})})}return(0,Y.jsxs)(`div`,{id:e,className:`relative w-full`,children:[s?.status===`error`&&(0,Y.jsx)(uX,{error:s.message,path:e}),h&&(0,Y.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 z-[40] flex items-center text-fg-secondary`,children:(0,Y.jsx)(hy,{className:`animate-spin h-4 w-4`})}),(0,Y.jsx)(TGe,{path:e,disabled:t,onClick:e=>{o(e)},onDelete:async e=>{d([{op:`remove`,path:f.concat(e.toString())}],m.type)},onDuplicate:async e=>{`data`in c&&c.data&&Array.isArray(c.data)&&d([{op:`add`,path:f.concat(e.toString()),value:c.data?.[e]??null}],m.type)},onMove:async(e,t)=>{d([{op:`move`,from:f.concat(e.toString()),path:f.concat(t.toString())}],m.type)},source:l.data||[]})]})}function FGe({path:e}){let t=Ob(e,`array`);return t.status===`error`?(0,Y.jsx)(FC,{path:e,error:t.error}):!(`data`in t)||t.data===void 0?(0,Y.jsx)(J3,{path:e}):t.data===null?(0,Y.jsx)(Y3,{path:e}):(0,Y.jsx)(`div`,{children:`${t.data.length} items`})}function IGe({path:e}){let t=Pb(e)??[];return(0,Y.jsx)(Uk,{validationErrors:t})}var i6=(0,b.createContext)(!1);function LGe({held:e,children:t}){return(0,Y.jsx)(i6.Provider,{value:e,children:t})}function RGe(){return(0,b.useContext)(i6)}function a6({path:e,schema:t,autoFocus:n,readonly:r,compact:i,inline:a,hideUpload:o,errorDisplay:s=`default`}){let c=RGe();if(t.hidden)return null;let l=r||t.readonly||c,u={readonly:l,compact:i},d;if(t.type===`string`)d=(0,Y.jsx)(lde,{path:e,autoFocus:n,...u},e);else if(t.type===`number`)d=(0,Y.jsx)(wde,{path:e,...u},e);else if(t.type===`boolean`)d=(0,Y.jsx)(xde,{path:e,...u},e);else if(t.type===`image`)d=(0,Y.jsx)(Vge,{path:e,...u,hideUpload:o},e);else if(t.type===`object`)return(0,Y.jsx)(qhe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`array`)return(0,Y.jsx)(PGe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`record`)return(0,Y.jsx)(ARe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else if(t.type===`union`)return(0,Y.jsx)(Qhe,{path:e,readonly:l,compact:i,inline:a,errorDisplay:s},e);else d=t.type===`keyOf`?(0,Y.jsx)(Gge,{path:e,...u},e):t.type===`route`?(0,Y.jsx)(v_e,{path:e,...u},e):t.type===`richtext`?(0,Y.jsx)(SGe,{path:e,autoFocus:n,...u},e):t.type===`date`?(0,Y.jsx)(Kye,{path:e,...u},e):t.type===`dateTime`?(0,Y.jsx)(tbe,{path:e,...u},e):t.type===`color`?(0,Y.jsx)(tRe,{path:e,...u},e):t.type===`code`?(0,Y.jsx)(QLe,{path:e,...u},e):t.type===`file`?(0,Y.jsx)(Rge,{path:e,...u},e):t.type===`literal`?(0,Y.jsx)(NC,{path:e,error:`Literal fields are not editable`}):(0,Y.jsx)(NC,{path:e,error:`Unexpected field schema: `+JSON.stringify(t)});return s===`compact`?(0,Y.jsxs)(`div`,{className:`flex items-stretch gap-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:d}),(0,Y.jsx)(`div`,{className:`flex items-center px-1`,children:(0,Y.jsx)(Fhe,{path:e})})]}):(0,Y.jsxs)(Y.Fragment,{children:[d,s==="default"&&(0,Y.jsx)(zGe,{path:e})]})}function zGe({path:e}){return Rhe()?null:(0,Y.jsx)(IGe,{path:e})}var BGe=8,VGe=1200;function HGe({paths:e,selectedPath:t,onSelect:n}){let[r,i]=(0,b.useState)(``),a=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=a.current;if(!t||!e)return;let n=()=>{let n=e.querySelector(`[data-canvas-field="${CSS.escape(t)}"]`);if(!(n instanceof HTMLElement))return;let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();i.top>=r.top&&i.bottom<=r.bottom||(e.scrollTop+=i.top-r.top-BGe)};n();let r=new ResizeObserver(n);r.observe(e);for(let t of Array.from(e.children))r.observe(t);let i=setTimeout(()=>r.disconnect(),VGe);return()=>{clearTimeout(i),r.disconnect()}},[t,e]);let o=(0,b.useMemo)(()=>{let t=new Map;for(let n of e){let[e]=H.splitModuleFilePathAndModulePath(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,label:kC(e.split(`/`).pop()??e),entries:t}))},[e]),s=(0,b.useMemo)(()=>{let e=r.trim().toLowerCase();return e?o.map(t=>({...t,entries:t.entries.filter(t=>t.toLowerCase().includes(e))})).filter(e=>e.entries.length>0):o},[o,r]);return(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col rounded-xl border border-border-float bg-bg-float`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 border-b border-border-float px-3 py-2.5`,children:[(0,Y.jsxs)(`h2`,{className:`text-[0.8125rem] font-medium text-fg-primary`,children:[`On this page`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal text-fg-secondary-alt`,children:e.length})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-[0.6875rem] leading-relaxed text-fg-secondary-alt`,children:`Edit here, or click an element on the page.`})]}),(0,Y.jsx)(`div`,{className:`shrink-0 border-b border-border-float px-2 py-2`,children:(0,Y.jsxs)(`div`,{className:`flex h-7 items-center gap-1.5 rounded-md bg-bg-float-raised px-2 focus-within:ring-2 focus-within:ring-border-focus`,children:[(0,Y.jsx)(My,{size:12,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`Filter fields…`,"aria-label":`Filter fields`,className:`min-w-0 flex-1 bg-transparent text-xs text-fg-primary placeholder:text-fg-secondary-alt focus:outline-none`})]})}),(0,Y.jsx)(`div`,{ref:a,className:`min-h-0 flex-1 overflow-y-auto scrollbar-slim px-2 py-2`,children:s.length===0?(0,Y.jsx)(`p`,{className:`px-1 py-6 text-center text-xs text-fg-secondary-alt`,children:r?`No fields match this filter.`:`The page reported no editable content.`}):s.map(e=>(0,Y.jsxs)(`section`,{className:`mb-3`,children:[(0,Y.jsx)(`h3`,{title:e.moduleFilePath,className:`truncate px-1 pb-1.5 text-[0.625rem] font-medium uppercase tracking-wide text-fg-secondary-alt`,children:e.label}),(0,Y.jsx)(`div`,{className:`space-y-2`,children:e.entries.map(e=>(0,Y.jsx)(UGe,{path:e,selected:t===e,onSelect:n},e))})]},e.moduleFilePath))})]})}function UGe({path:e,selected:t,onSelect:n}){let r=Cb(e);return(0,Y.jsxs)(`div`,{"data-canvas-field":e,onFocusCapture:()=>n?.(e),className:X(`rounded-lg border px-2.5 py-2`,t?`border-border-brand-primary bg-bg-float-raised`:`border-border-float`),children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n?.(e),title:e,className:`mb-1.5 block max-w-full truncate text-left text-[0.8125rem] font-medium text-fg-primary`,children:WGe(e)}),r.status===`error`?(0,Y.jsx)(NC,{path:e,error:r.error,type:`module`}):r.status===`loading`?(0,Y.jsx)(jC,{path:e,type:`module`}):r.status===`not-found`?(0,Y.jsx)(MC,{path:e,type:`module`}):(0,Y.jsx)(a6,{path:e,schema:r.data,compact:!0})]})}function WGe(e){let[,t]=H.splitModuleFilePathAndModulePath(e);if(!t)return e;let n=H.splitModulePath(t),r=n.length>1&&n[0].startsWith(`/`)?n.slice(1):n;return r.length===0?n.join(` › `):r.join(` › `)}function o6(e,t,n){(0,b.useEffect)(()=>{if(!t)return;let r=t=>{let r=e.current;r&&t.composedPath().includes(r)||n()};return document.addEventListener(`pointerdown`,r),()=>document.removeEventListener(`pointerdown`,r)},[t,n,e])}var s6=12;function GGe({value:e,routes:t,onChange:n,className:r}){let[i,a]=(0,b.useState)(e),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(0),u=(0,b.useRef)(null);(0,b.useEffect)(()=>{o||a(e)},[e,o]);let d=(0,b.useMemo)(()=>{let e=i.trim().toLowerCase();if(!e)return t.slice(0,s6);let n=t=>{let n=t.toLowerCase();return n===e?0:n.startsWith(e)?1:2};return t.filter(t=>t.toLowerCase().includes(e)).map((e,t)=>({route:e,index:t,rank:n(e)})).sort((e,t)=>e.rank-t.rank||e.index-t.index).slice(0,s6).map(e=>e.route)},[t,i]),f=(0,b.useMemo)(()=>{let e=i.trim().toLowerCase(),n=e?t.filter(t=>t.toLowerCase().includes(e)).length:t.length;return Math.max(0,n-d.length)},[t,i,d.length]);(0,b.useEffect)(()=>l(0),[i]),o6(u,o,(0,b.useCallback)(()=>{s(!1),a(e)},[e]));let p=t=>{let r=KGe(t);s(!1),a(r),r!==e&&n(r)};return(0,Y.jsxs)(`div`,{ref:u,className:X(`relative`,r),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 h-8 pl-2 pr-1 rounded-md border border-border-float bg-bg-float`,children:[(0,Y.jsx)(uy,{size:13,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{value:i,onChange:e=>{a(e.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:t=>{if(t.key===`Escape`){t.preventDefault(),s(!1),a(e),t.currentTarget.blur();return}if(t.key===`Enter`){t.preventDefault();let e=o?d[c]:void 0;p(e??i),t.currentTarget.blur();return}(t.key===`ArrowDown`||t.key===`ArrowUp`)&&d.length>0&&(t.preventDefault(),s(!0),l(e=>((t.key===`ArrowDown`?e+1:e-1)+d.length)%d.length))},spellCheck:!1,"aria-label":`Canvas route`,placeholder:`/`,className:`min-w-0 flex-1 bg-transparent font-mono text-[0.6875rem] text-fg-primary placeholder:text-fg-secondary-alt focus:outline-none`}),i!==e&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Discard the typed route`,onClick:()=>{a(e),s(!1)},className:`grid h-6 w-6 shrink-0 place-items-center rounded text-fg-secondary-alt hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:12})})]}),o&&d.length>0&&(0,Y.jsxs)(`ul`,{role:`listbox`,"aria-label":`Tracked routes`,className:`absolute left-0 right-0 top-full z-window mt-1 max-h-56 overflow-y-auto rounded-md border border-border-float bg-bg-float py-1 shadow-lg scrollbar-slim`,children:[d.map((e,t)=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t===c,onMouseMove:()=>l(t),onMouseDown:t=>{t.preventDefault(),p(e)},className:X(`block w-full truncate px-2.5 py-1 text-left font-mono text-[0.6875rem]`,t===c?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary`),children:e})},`${t}-${e}`)),f>0&&(0,Y.jsxs)(`li`,{"aria-hidden":!0,className:`px-2.5 py-1 text-[0.625rem] text-fg-secondary-alt`,children:[f,` more — keep typing to narrow`]})]})]})}function KGe(e){let t=e.trim();if(t===``)return`/`;if(/^[a-z][a-z0-9+.-]*:\/\//i.test(t))try{let e=new URL(t);return`${e.pathname}${e.search}${e.hash}`||`/`}catch{}return t.startsWith(`/`)?t:`/${t}`}var qGe={desktop:1280,tablet:834,mobile:390},JGe={desktop:800,tablet:1112,mobile:844},YGe=`clamp(340px, 34%, 520px)`,c6=320,XGe=280,ZGe=.72,QGe=24,$Ge=`4.5rem`,eKe=`8.25rem`,l6=`2.125rem`,tKe=320,u6=200,d6=`cubic-bezier(0.4, 0, 0.2, 1)`;function nKe({children:e,breakpoint:t,page:n,renderCanvas:r,canvasPaths:i,onSelectCanvasPath:a,selectedCanvasPath:o,canvasRoute:s,onCanvasRouteChange:c,canvasRoutes:l,initialTransform:u,onTransformChange:d,isCanvasOpen:f,onCloseCanvas:p,view:m,onViewChange:h,pane:g,onPaneChange:_,isDevMode:v,onAttachToChat:y,skipTransition:x}){let S=t===`mobile`,C=CC(),w=f&&(n!==void 0||r!==void 0),T=e=>C||x?void 0:e.map(e=>`${e} ${tKe}ms ${d6}`).join(`, `),[E,D]=(0,b.useState)(S?`mobile`:`desktop`),[O,k]=(0,b.useState)(()=>u?.scale??1),A=(0,b.useRef)(O);A.current=O;let j=(0,b.useRef)({x:u?.x??0,y:u?.y??0});(0,b.useEffect)(()=>{d?.({scale:O,...j.current})},[O,d]);let M=(0,b.useCallback)(e=>{j.current=e,d?.({scale:A.current,...e})},[d]),[N,P]=(0,b.useState)(null),[F,I]=(0,b.useState)([]);(0,b.useEffect)(()=>{w||(P(null),I(e=>e.length===0?e:[]))},[w]);let L=(0,b.useRef)(null),R=(0,b.useRef)(null),[ee,te]=(0,b.useState)(null),[ne,re]=(0,b.useState)(0),[ie,ae]=(0,b.useState)(!1),[oe,se]=(0,b.useState)(0);(0,b.useEffect)(()=>{let e=R.current;if(!e)return;let t=new ResizeObserver(()=>se(e.clientWidth));return t.observe(e),se(e.clientWidth),()=>t.disconnect()},[]);let ce=(0,b.useMemo)(()=>{if(oe===0)return{min:c6,max:c6};let e=Math.max(c6,Math.min(oe*ZGe,oe-XGe));return{min:Math.min(c6,e),max:e}},[oe]),le=(0,b.useCallback)(e=>Math.round(Math.min(ce.max,Math.max(ce.min,e))),[ce]);(0,b.useEffect)(()=>{if(ee===null)return;let e=le(ee);e!==ee&&te(e)},[ee,le]);let ue=(0,b.useCallback)(e=>{if(e.button!==0)return;let t=R.current;if(!t)return;e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),ae(!0);let n=t.getBoundingClientRect().left,r=e=>{te(le(e.clientX-n))},i=()=>{ae(!1),window.removeEventListener(`pointermove`,r),window.removeEventListener(`pointerup`,i),window.removeEventListener(`pointercancel`,i)};window.addEventListener(`pointermove`,r),window.addEventListener(`pointerup`,i),window.addEventListener(`pointercancel`,i)},[le]),de=(0,b.useCallback)(e=>{let t=R.current,n=ee??t?.firstElementChild?.clientWidth??c6;te(le(n+e))},[ee,le]),fe=qGe[E],[pe,me]=(0,b.useState)(u==null),he=(0,b.useRef)({device:E,open:w});(0,b.useEffect)(()=>{(he.current.device!==E||he.current.open!==w)&&(he.current={device:E,open:w},me(!0))},[E,w]);let ge=(0,b.useCallback)(()=>{re(e=>e+1),me(!0)},[]),_e=(0,b.useCallback)(()=>me(!1),[]),ve=(0,b.useCallback)((e,t)=>{L.current?.zoomBy(e,t)},[]),ye=(0,b.useCallback)(e=>{L.current?.pinch(e)},[]),be=(0,b.useCallback)(e=>{I(t=>t.includes(e)?t:[...t,e]);let t=n?.fields[e];t&&y?.(t.sourcePath)},[n,y]),[xe,Se]=Qce(m),Ce=(0,b.useCallback)(()=>{xe&&(h(`fields`),S&&_(`editor`))},[xe,h,S,_]),[we,z]=(0,b.useState)(!1),B=t===`desktop`&&w?{paddingLeft:`5.5rem`}:void 0,Te=i??[],Ee=n?Object.keys(n.fields).length:Te.length,V=(0,Y.jsx)(oKe,{view:m,onChange:h,fieldCount:Ee>0?Ee:void 0,animate:!C}),De=g===`canvas`?`preview`:m===`fields`?`fields`:`normal`,Oe=(0,b.useCallback)(e=>{if(e===`preview`){_(`canvas`);return}_(`editor`),h(e)},[_,h]),ke=w&&!S,Ae=!ke&&!(w&&S),je=(0,Y.jsx)(`div`,{id:`val-content-area`,"data-scroll-clearance":ke?16:96,className:`h-full overflow-y-auto scrollbar-slim`,children:(0,Y.jsx)(`div`,{style:{maxWidth:qce,...B},className:X(`w-full mx-auto px-4 md:px-6 pb-24`,Ae?`pt-20 desktop:pt-24`:`pt-1`),children:e})}),Me=(0,Y.jsx)(`div`,{style:B,className:`h-full px-4 md:px-6 pt-1 pb-14`,children:n?(0,Y.jsx)(ole,{page:n,selectedFieldId:N,onSelectField:P,onChangeField:()=>void 0,onAttachField:be,attachedFieldIds:F,isDevMode:v}):Te.length>0?(0,Y.jsx)(HGe,{paths:Te,selectedPath:o,onSelect:a}):(0,Y.jsx)(rKe,{onGoToPreview:S?()=>_(`canvas`):void 0})}),Ne=(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[ke&&(0,Y.jsx)(`div`,{style:B,className:`shrink-0 px-4 md:px-6 pt-20 pb-2.5`,children:V}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1`,children:m===`fields`&&w?Me:je})]}),Pe=s!==void 0&&c&&(0,Y.jsx)(GGe,{value:s,routes:l??[],onChange:c,className:`min-w-0 flex-1 md:max-w-[28rem]`}),Fe=w&&(0,Y.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-2`,children:[(Pe||!S)&&(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[Pe,!S&&(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Exit Preview`,onClick:p,className:X(`ml-auto inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md pl-2.5 pr-3`,`border border-border-float bg-bg-float text-fg-secondary`,`hover:text-fg-primary`),children:[(0,Y.jsx)(Hy,{size:15}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:`Exit Preview`})]})]}),(0,Y.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden rounded-xl border border-border-float bg-bg-float-raised`,children:(0,Y.jsx)(nle,{ref:L,pageWidth:fe,scale:O,onScaleChange:k,autoFit:pe,onUserZoom:_e,initialScroll:u&&{x:u.x,y:u.y},onScrollChange:M,className:`h-full`,children:(0,Y.jsx)(`div`,{className:`shadow-2xl`,onClick:()=>P(null),children:r?.({device:E,width:fe,height:JGe[E],reloadKey:ne,isPicking:xe,onRequestReload:ge,onRefreshingChange:z,onPinch:ye,onZoom:(e,t)=>ve(e,t),onPicked:Ce})??(n&&(0,Y.jsx)($ce,{page:n,device:E,selectedFieldId:xe?N:null,attachedFieldIds:xe?F:[],onSelectField:e=>{xe&&(P(e),Ce())},isSelectMode:xe}))})})}),(0,Y.jsx)(`div`,{className:`flex shrink-0 justify-center`,children:(0,Y.jsx)(ele,{className:`max-w-full`,device:E,onDeviceChange:D,scale:O,onZoomIn:()=>ve(1.2,null),onZoomOut:()=>ve(1/1.2,null),onFit:()=>me(!0),isPicking:xe,onPickingChange:Ee>0?Se:void 0,isRefreshing:we,onReload:r&&ge})})]});return S?(0,Y.jsxs)(`div`,{className:`absolute inset-0 bg-bg-canvas`,children:[(0,Y.jsx)(`div`,{className:`h-full overflow-clip`,style:w?{paddingTop:eKe}:void 0,children:(0,Y.jsxs)(`div`,{className:`flex h-full w-full isolate`,style:{...w&&g===`canvas`?{transform:`translateX(-100%)`}:{},transition:T([`transform`])},children:[(0,Y.jsx)(`div`,{className:`h-full w-full shrink-0`,children:Ne}),w&&(0,Y.jsx)(`div`,{className:`h-full w-full shrink-0 p-3 pb-14`,children:Fe})]})}),w&&(0,Y.jsxs)(`div`,{className:`absolute inset-x-3 z-window flex items-center gap-2`,style:{top:$Ge},children:[(0,Y.jsx)(aKe,{mode:De,onChange:Oe,fieldCount:Ee>0?Ee:void 0,animate:!C}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Exit Preview`,onClick:p,style:{height:l6,width:l6},className:X(`ml-auto grid shrink-0 place-items-center rounded-md`,`border border-border-float bg-bg-float text-fg-secondary`),children:(0,Y.jsx)(Hy,{size:15})})]})]}):(0,Y.jsxs)(`div`,{ref:R,className:`absolute inset-0 flex overflow-hidden bg-bg-canvas`,children:[(0,Y.jsx)(`div`,{style:{width:w?ee===null?YGe:`${ee}px`:`100%`,transition:ie?void 0:T([`width`])},className:`relative h-full min-w-0 shrink-0`,children:Ne}),w&&(0,Y.jsx)(iKe,{isDragging:ie,onPointerDown:ue,onNudge:de}),(0,Y.jsx)(`div`,{style:{transition:T([`opacity`,`transform`])},className:X(`min-w-0 flex-1 pt-20 pb-14 pr-3`,w?`scale-100 opacity-100`:`invisible pointer-events-none scale-95 opacity-0`),children:Fe})]})}function rKe({onGoToPreview:e}){return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 rounded-xl border border-border-float bg-bg-float px-6 text-center`,children:[(0,Y.jsx)(py,{size:20,className:`text-fg-secondary-alt`}),(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(`h2`,{className:`text-[0.8125rem] font-medium text-fg-primary`,children:`Nothing reported yet`}),(0,Y.jsx)(`p`,{className:`text-[0.6875rem] leading-relaxed text-fg-secondary-alt`,children:`Usually that means preview mode is off: without it the page mounts none of Val's client code and tags nothing, and the Preview has the button that turns it on. A page that is already in preview mode and simply has no Val content on it looks the same from here.`})]}),e&&(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`inline-flex h-8 items-center gap-1.5 rounded-md px-3`,`border border-border-float bg-bg-float-raised text-xs font-medium`,`text-fg-secondary hover:text-fg-primary`),children:[(0,Y.jsx)(Qv,{size:13}),`Go to Preview`]})]})}function iKe({isDragging:e,onPointerDown:t,onNudge:n}){return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the editor and canvas`,tabIndex:0,onPointerDown:t,onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),n(-24)):e.key===`ArrowRight`&&(e.preventDefault(),n(QGe))},className:X(`group relative z-hover w-3 shrink-0 cursor-col-resize self-stretch`,`focus-visible:outline-none`),children:(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`pointer-events-none absolute inset-y-14 left-1/2 w-px -translate-x-1/2 rounded-full`,`transition-colors`,e?`bg-fg-brand-primary`:`bg-border-float group-hover:bg-fg-secondary group-focus-visible:bg-fg-brand-primary`)})})}function f6({label:e,value:t,onChange:n,options:r,animate:i,compact:a}){let o=Math.max(0,r.findIndex(e=>e.value===t)),s=(0,b.useRef)(null),[c,l]=(0,b.useState)(null);return(0,b.useLayoutEffect)(()=>{let e=s.current;if(e===null)return;let t=()=>{let t=e.querySelectorAll(`button`)[o];if(t===void 0)return;let n=t.getBoundingClientRect().left-e.getBoundingClientRect().left-e.clientLeft,r=t.getBoundingClientRect().width;l(e=>e!==null&&e.left===n&&e.width===r?e:{left:n,width:r})};t();let n=new ResizeObserver(t);return n.observe(e),e.querySelectorAll(`button`).forEach(e=>n.observe(e)),()=>n.disconnect()},[o,r.length]),(0,Y.jsxs)(`div`,{ref:s,role:`tablist`,"aria-label":e,className:`relative inline-flex rounded-md border border-border-float bg-bg-float p-0.5`,children:[c!==null&&(0,Y.jsx)(`span`,{"aria-hidden":!0,style:{width:c.width,transform:`translateX(${c.left}px)`,transition:i?`transform ${u6}ms ${d6}, width ${u6}ms ${d6}`:void 0},className:`absolute inset-y-0.5 left-0 rounded bg-bg-float-raised shadow-sm`}),r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e.value,onClick:()=>n(e.value),className:X(`relative inline-flex h-7 shrink-0 items-center justify-center gap-1.5 rounded text-[0.6875rem] transition-colors`,a?`px-2.5`:`px-4`,t===e.value?`font-medium text-fg-primary`:`text-fg-secondary hover:text-fg-primary`),children:[(0,Y.jsx)(e.icon,{size:12}),e.label,e.badge!==void 0&&(0,Y.jsx)(`span`,{className:`tabular-nums text-fg-secondary-alt`,children:e.badge})]},e.value))]})}function aKe({mode:e,onChange:t,fieldCount:n,animate:r}){return(0,Y.jsx)(f6,{label:`Workspace view`,value:e,onChange:t,animate:r,options:[{value:`normal`,label:`Normal`,icon:Py},{value:`fields`,label:`Fields`,icon:py,badge:n},{value:`preview`,label:`Preview`,icon:Qv}],compact:!0})}function oKe({view:e,onChange:t,fieldCount:n,animate:r}){return(0,Y.jsx)(f6,{label:`Preview view`,value:e,onChange:t,animate:r,options:[{value:`normal`,label:`Normal`,icon:Py},{value:`fields`,label:`Fields`,icon:py,badge:n}]})}function sKe({selectionKind:e,editedPath:t,canvasModules:n}){if(e===`page`)return!0;if(t===null)return!1;let[r]=H.splitModuleFilePathAndModulePath(t);return n.has(r)?!0:n.size===0&&e===null}function cKe(e){let t=new Set;for(let n of e??[])t.add(H.splitModuleFilePathAndModulePath(n)[0]);return Array.from(t).sort().join(`
|
|
216
216
|
`)}function lKe(e){return new Set(e===``?[]:e.split(`
|
|
217
|
-
`))}var uKe={page:$v,external:Zv,media:sy,data:Nv,content:Lae,recent:Ay},dKe={page:`Pages`,external:`External pages`,media:`Media`,data:`Data`,content:`In content`,recent:`Recently changed`},fKe=[`page`,`data`,`media`,`external`];function pKe(e){let t=[],n=e=>{for(let r of e)t.push({id:r.id,kind:`page`,label:r.name,detail:r.urlPath}),n(r.children??[])};n(e.pages);for(let n of e.data)t.push({id:n.id,kind:`data`,label:n.name,detail:n.moduleFilePath});for(let n of e.media)t.push({id:n.id,kind:`media`,label:n.name,detail:n.directory});for(let n of e.externalPages)t.push({id:n.id,kind:`external`,label:n.name,detail:n.url});return t}function mKe({results:e,contentResults:t,recentResults:n,isSearchingContent:r,onQueryChange:i,onSelect:a,onClose:o}){let[s,c]=(0,b.useState)(``);(0,b.useEffect)(()=>{i?.(s)},[s,i]);let[l,u]=(0,b.useState)(0),d=(0,b.useRef)(null),f=(0,b.useMemo)(()=>{let r=s.trim().toLowerCase(),i=r?e.filter(e=>e.label.toLowerCase().includes(r)||e.detail.toLowerCase().includes(r)):e,a=fKe.flatMap(e=>i.filter(t=>t.kind===e)),o=new Set(a.map(e=>e.id)),c=(r?t??[]:[]).filter(e=>!o.has(e.id));return[...r?[]:n??[],...a,...c].slice(0,40)},[e,t,n,s]);(0,b.useEffect)(()=>u(0),[s]),(0,b.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),o();return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),u(t=>f.length===0?0:((e.key===`ArrowDown`?t+1:t-1)+f.length)%f.length);return}if(e.key===`Enter`){e.preventDefault();let t=f[l];t&&a(t)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f,l,a,o]),(0,b.useEffect)(()=>{d.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})},[l]);let p=null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{onClick:o,"aria-hidden":!0,className:`absolute inset-0 z-overlay bg-black/50`}),(0,Y.jsxs)(`div`,{role:`dialog`,"aria-label":`Search`,className:`absolute z-overlay left-1/2 -translate-x-1/2 top-[12svh] w-[min(34rem,calc(100vw-1.5rem))] max-h-[70svh] flex flex-col rounded-xl bg-bg-float border border-border-float shadow-xl overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 h-11 px-3 border-b border-border-float shrink-0`,children:[(0,Y.jsx)(My,{size:15,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:s,onChange:e=>c(e.target.value),placeholder:`Search pages, media and data…`,"aria-label":`Search the project`,className:`flex-1 min-w-0 rounded-sm bg-transparent text-sm placeholder:text-fg-secondary-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`}),(0,Y.jsx)(`kbd`,{className:`shrink-0 px-1.5 py-0.5 rounded border border-border-float text-[0.625rem] text-fg-secondary-alt font-sans`,children:`esc`})]}),(0,Y.jsxs)(`div`,{ref:d,className:`flex-1 min-h-0 overflow-y-auto py-1.5 scrollbar-slim`,children:[f.length===0?(0,Y.jsx)(`p`,{className:`px-4 py-6 text-xs text-fg-secondary-alt`,children:r?`Searching…`:`Nothing matches “${s}”.`}):f.map((e,t)=>{let n=uKe[e.kind],r=e.kind!==p;return p=e.kind,(0,Y.jsxs)(`div`,{children:[r&&(0,Y.jsx)(`div`,{className:`px-4 pt-2.5 pb-1 text-[0.6875rem] font-semibold uppercase tracking-wider text-fg-secondary-alt`,children:dKe[e.kind]}),(0,Y.jsxs)(`button`,{type:`button`,"data-active":t===l,onMouseMove:()=>u(t),onClick:()=>a(e),className:X(`flex items-center gap-2.5 w-full px-3 py-1.5 mx-1.5 rounded-md text-left`,`w-[calc(100%-0.75rem)]`,t===l?`bg-bg-float-raised`:`hover:bg-bg-float-raised`),children:[(0,Y.jsx)(n,{size:14,className:X(`shrink-0`,t===l?`text-fg-primary`:`text-fg-secondary-alt`)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary truncate`,children:e.label}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt truncate`,children:e.detail})]})]})]},`${e.kind}-${e.id}`)}),r&&f.length>0&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 px-4 py-2 text-[0.6875rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(hy,{size:11,className:`animate-spin`}),`Still searching content…`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 h-8 px-3 shrink-0 border-t border-border-float text-[0.625rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(`span`,{children:`↑↓ to navigate`}),(0,Y.jsx)(`span`,{children:`↵ to open`})]})]})]})}function hKe(e){(0,b.useEffect)(()=>{let t=t=>{if(t.key!==`k`||!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return;let n=t.target;n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable)||(t.preventDefault(),e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function d6({className:e,blinking:t}){let n=CC(),r=t&&!n;return(0,Y.jsxs)(`svg`,{viewBox:`0 0 105 149`,fill:`none`,role:`img`,"aria-label":`Val`,className:X(`w-full h-full`,e),children:[(0,Y.jsxs)(`defs`,{children:[(0,Y.jsxs)(`mask`,{id:`val-mark-hole`,children:[(0,Y.jsx)(`rect`,{x:`0`,y:`0`,width:`105`,height:`149`,fill:`white`}),(0,Y.jsx)(`circle`,{cx:`49.9`,cy:`104.2`,r:`9.61`,fill:`black`,children:r&&(0,Y.jsx)(`animate`,{attributeName:`fill`,values:`black;black;white;white`,dur:`1.06s`,calcMode:`discrete`,repeatCount:`indefinite`})})]}),(0,Y.jsxs)(`filter`,{id:`val-mark-glow`,x:`0`,y:`0`,width:`105`,height:`149`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Y.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`10.72`}),(0,Y.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`out`}),(0,Y.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0.219608 0 0 0 0 0.803922 0 0 0 0 0.501961 0 0 0 0.3 0`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in2:`SourceGraphic`})]}),(0,Y.jsx)(`filter`,{id:`val-mark-hole-shadow`,x:`35`,y:`90`,width:`30`,height:`30`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`2.4`})})]}),(0,Y.jsx)(`g`,{filter:`url(#val-mark-glow)`,children:(0,Y.jsx)(`path`,{d:`M21.4768 23.3474C21.4768 22.4628 22.1939 21.7457 23.0785 21.7457H77.1357C78.0203 21.7457 78.7374 22.4628 78.7374 23.3474V125.055C78.7374 125.94 78.0203 126.657 77.1357 126.657H23.0785C22.1939 126.657 21.4768 125.94 21.4768 125.055V23.3474Z`,fill:f6,mask:`url(#val-mark-hole)`})}),(0,Y.jsx)(`circle`,{cx:`49.9`,cy:`104.2`,r:`9.61`,fill:`none`,stroke:f6,strokeWidth:`3`,strokeOpacity:`0.3`,filter:`url(#val-mark-hole-shadow)`})]})}var f6=`var(--colors-brand-green-400)`;function p6({initials:e,size:t=`md`,className:n}){return(0,Y.jsx)(`span`,{className:X(`grid place-items-center rounded-full bg-bg-float-raised text-fg-primary border border-border-float font-medium select-none`,t===`sm`?`w-7 h-7 text-[0.625rem]`:`w-8 h-8 text-[0.6875rem]`,n),children:e})}function m6({className:e}){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full`,`bg-fg-error-on-surface ring-2 ring-bg-float`,e)})}function gKe({error:e}){return(0,Y.jsxs)(`div`,{className:`mx-4 my-3 rounded-md border border-border-error-primary bg-bg-error-secondary p-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Ly,{size:13,className:`mt-0.5 shrink-0 text-fg-error-on-surface`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-fg-error-on-surface`,children:`Could not load your account`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[0.6875rem] text-fg-secondary`,children:e.message})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:e.onRetry,className:X(`mt-2 inline-flex h-7 items-center rounded-md px-2.5 text-xs font-medium`,`border border-border-primary text-fg-primary hover:bg-bg-float-raised`),children:`Try again`})]})}var h6=[{panel:`pages`,label:`Pages`,icon:$v},{panel:`media`,label:`Media`,icon:sy},{panel:`data`,label:`Data`,icon:Nv}];function g6(e){return e===void 0?h6:h6.filter(t=>e.includes(t.panel))}function _Ke({openPanel:e,onSelect:t,destinations:n,user:r,hasDraftChanges:i,accountError:a,isLoading:o}){let s=g6(n);return(0,Y.jsxs)(`nav`,{"aria-label":`Main`,className:`absolute left-3 top-3 bottom-3 z-full w-12 flex flex-col items-center py-2 gap-1 rounded-lg bg-bg-float border border-border-float shadow-sm`,children:[(0,Y.jsx)(`div`,{className:`grid place-items-center w-8 h-8 mb-1 shrink-0 text-fg-primary`,children:(0,Y.jsx)(d6,{className:`h-6`,blinking:o})}),s.map(({panel:n,label:r,icon:i})=>(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":r,"aria-current":e===n?`true`:void 0,onClick:()=>t(n),className:X(`grid place-items-center w-8 h-8 rounded-md shrink-0 transition-colors`,e===n?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:(0,Y.jsx)(i,{size:17})})}),(0,Y.jsx)(Xg,{side:`right`,children:r})]},n)),(0,Y.jsx)(`div`,{className:`mt-auto shrink-0`,children:r?(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Account: ${r.name}`,"aria-current":e===`settings`?`true`:void 0,onClick:()=>t(`settings`),className:`relative grid place-items-center w-8 h-8 rounded-full`,children:[(0,Y.jsx)(p6,{initials:r.initials,size:`sm`}),a&&(0,Y.jsx)(m6,{}),i&&(0,Y.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 w-2 h-2 rounded-full bg-fg-secondary ring-2 ring-bg-float`})]})}),(0,Y.jsx)(Xg,{side:`right`,children:a?a.message:r.name})]}):(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Settings`,"aria-current":e===`settings`?`true`:void 0,onClick:()=>t(`settings`),className:X(`relative grid place-items-center w-8 h-8 rounded-md transition-colors`,e===`settings`?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:[(0,Y.jsx)(Tae,{size:17}),a&&(0,Y.jsx)(m6,{}),i&&(0,Y.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 w-2 h-2 rounded-full bg-fg-secondary ring-2 ring-bg-float`})]})}),(0,Y.jsx)(Xg,{side:`right`,children:a?a.message:`Settings`})]})})]})}var _6=40;function vKe({breakpoint:e,media:t,selectedId:n,onSelect:r,onSelectFile:i,getFileUrl:a,onUpload:o,onClose:s,navSwitcher:c,isLoading:l,loadError:u,onRetryLoad:d}){let[f,p]=(0,b.useState)(``),[m,h]=(0,b.useState)(()=>new Set),g=f.trim().toLowerCase(),_=(0,b.useMemo)(()=>g?t.map(e=>{let t=e.name.toLowerCase().includes(g)||e.directory.toLowerCase().includes(g);return{gallery:e,files:(e.files??[]).filter(e=>e.ref.toLowerCase().includes(g)),galleryMatches:t}}).filter(({files:e,galleryMatches:t})=>t||e.length>0).map(({gallery:e,files:t,galleryMatches:n})=>({gallery:e,files:n&&t.length===0?e.files:t})):t.map(e=>({gallery:e,files:e.files})),[t,g]),v=e=>g?!0:m.has(e),y=e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,Y.jsx)(pC,{side:`left`,width:300,title:`Media`,mobileVariant:`sheet`,breakpoint:e,onClose:s,subheader:c,headerAction:o&&t.length>0?(0,Y.jsx)(CKe,{media:t,onUpload:o}):void 0,sticky:l||u?void 0:(0,Y.jsx)(gC,{value:f,onChange:p,placeholder:`Filter media…`}),children:(0,Y.jsx)(`div`,{className:`py-2`,children:l?(0,Y.jsx)(vC,{}):u?(0,Y.jsx)(yC,{message:u,onRetry:d}):_.length===0?(0,Y.jsx)(hC,{children:f?`Nothing matches this filter.`:`No galleries yet.`}):_.map(({gallery:e,files:t})=>{let o=v(e.id);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_C,{selected:n===e.id,title:e.moduleFilePath,expanded:o,onClick:()=>{g||y(e.id)},action:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(e),title:`Open in the editor`,"aria-label":`Open ${e.name} in the editor`,className:X(`ml-1 shrink-0 rounded px-1.5 h-6 text-[0.6875rem] text-fg-secondary`,`hover:bg-bg-float-raised hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,`opacity-0 transition-opacity`,`group-hover/row:opacity-100 focus-visible:opacity-100`,`[@media(hover:none)]:opacity-100`,n===e.id&&`opacity-100`),children:`Open`}),leading:(0,Y.jsx)(`span`,{className:`text-fg-secondary-alt`,children:o?(0,Y.jsx)(Iv,{size:13}):(0,Y.jsx)(Rv,{size:13})}),label:e.name,meta:aA(e.directory),trailing:(0,Y.jsx)(`span`,{className:`text-[0.6875rem] tabular-nums text-fg-secondary-alt`,children:e.itemCount})}),o&&(0,Y.jsx)(yKe,{gallery:e,files:t,selectedId:n,onSelectFile:i,getFileUrl:a})]},e.id)})})})}function yKe({gallery:e,files:t,selectedId:n,onSelectFile:r,getFileUrl:i}){let[a,o]=(0,b.useState)(_6),s=t?.length??-1;if((0,b.useEffect)(()=>o(_6),[s]),t===void 0)return(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 pl-8 py-1.5 text-[0.6875rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(hy,{size:11,className:`animate-spin`}),`Loading files…`]});if(t.length===0)return(0,Y.jsx)(`p`,{className:`pl-8 py-1.5 text-[0.6875rem] text-fg-secondary-alt`,children:`No files in this gallery yet.`});let c=t.slice(0,a),l=t.length-c.length,u=wKe(c,e.directory);return(0,Y.jsxs)(`div`,{children:[u.map(t=>(0,Y.jsxs)(`div`,{children:[u.length>1&&(0,Y.jsx)(`p`,{title:aA(t.directory),className:`truncate pl-8 pr-3 pt-1.5 pb-0.5 text-[0.625rem] uppercase tracking-wide text-fg-secondary-alt`,children:t.label}),t.files.map(t=>(0,Y.jsx)(bKe,{gallery:e,file:t,selected:n===t.sourcePath,onSelect:r,getFileUrl:i},t.ref))]},t.directory)),l>0&&(0,Y.jsx)(xKe,{remaining:l,onShowMore:()=>o(e=>e+_6)})]})}function bKe({gallery:e,file:t,selected:n,onSelect:r,getFileUrl:i}){let[a,o]=(0,b.useState)(!1),s=i?.(t.ref)??null,c=e.mediaType===`images`&&s!==null&&!a;return(0,Y.jsx)(`div`,{className:`flex items-center pl-5 pr-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r?.(e,t),title:aA(t.ref),"aria-current":n?`true`:void 0,className:X(`group flex items-center gap-2 min-w-0 flex-1 h-8 px-1.5 rounded-md text-xs text-left`,n?`bg-bg-float-raised text-fg-primary font-medium`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:[(0,Y.jsx)(`span`,{className:`grid place-items-center w-6 h-6 shrink-0 overflow-hidden rounded bg-bg-float-raised`,children:c?(0,Y.jsx)(cA,{url:s,loading:`lazy`,onError:()=>o(!0)}):e.mediaType===`images`?(0,Y.jsx)(sy,{size:12,className:`text-fg-secondary-alt`}):(0,Y.jsx)($v,{size:12,className:`text-fg-secondary-alt`})}),(0,Y.jsx)(`span`,{className:`truncate`,children:SKe(t.ref)})]})})}function xKe({remaining:e,onShowMore:t}){let n=(0,b.useRef)(null);return(0,b.useEffect)(()=>{let e=n.current;if(!e||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&t()});return r.observe(e),()=>r.disconnect()},[t]),(0,Y.jsxs)(`button`,{ref:n,type:`button`,onClick:t,className:`block w-full pl-8 pr-3 py-1.5 text-left text-[0.6875rem] text-fg-secondary-alt hover:text-fg-primary`,children:[`Show `,Math.min(e,_6),` more (`,e,` left)`]})}function SKe(e){let t=e.split(`/`);return t[t.length-1]||e}function CKe({media:e,onUpload:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null);i6(i,n,(0,b.useCallback)(()=>r(!1),[]));let a=e.length===1?e[0]:null;return(0,Y.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-haspopup":a?void 0:`menu`,"aria-expanded":a?void 0:n,title:a?`Upload into ${aA(a.directory)}`:`Choose where to upload`,onClick:()=>a?t(a):r(e=>!e),className:`inline-flex items-center gap-1 h-7 px-2 rounded-md text-xs font-medium text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(Oy,{size:13}),`Upload`,!a&&(0,Y.jsx)(Iv,{size:12})]}),n&&!a&&(0,Y.jsx)(`div`,{role:`menu`,className:`absolute right-0 top-full z-window mt-1 w-64 rounded-md border border-border-float bg-bg-float py-1 shadow-lg`,children:e.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(!1),t(e)},className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:[e.mediaType===`images`?(0,Y.jsx)(sy,{size:13,className:`mt-0.5 shrink-0`}):(0,Y.jsx)($v,{size:13,className:`mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-xs`,children:aA(e.directory)}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:e.mediaType===`images`?`Images`:`Files`})]})]},e.id))})]})}function wKe(e,t){let n=new Map;for(let t of e){let e=t.ref.slice(0,t.ref.lastIndexOf(`/`))||`/`,r=n.get(e);r?r.push(t):n.set(e,[t])}return Array.from(n.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>({directory:e,label:TKe(e,t),files:n}))}function TKe(e,t){if(e===t)return`In this folder`;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)?e.slice(n.length):aA(e)}function EKe({breakpoint:e,projectName:t,projectHref:n,openPanel:r,onTogglePanel:i,onOpenMenu:a,unreadNotifications:o,user:s,onOpenSearch:c,onPreview:l,onToggleCanvas:u,isCanvasOpen:d,onPublish:f,publishSlot:p,pendingChanges:m,onCompare:h,reviewCount:g,publishState:_=`idle`,accountError:v,isLoading:y,aiEnabled:b=!1,previewHref:x}){let S=e===`mobile`,C=e===`desktop`;return(0,Y.jsxs)(`header`,{className:X(`absolute z-full top-3 h-11 flex items-center gap-1.5 px-2 rounded-lg`,`bg-bg-float border border-border-float shadow-sm`,C?`left-[4.75rem] right-3`:`left-3 right-3`),children:[!C&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,onClick:a,className:`grid place-items-center w-8 h-8 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary shrink-0`,children:(0,Y.jsx)(mae,{size:17})}),!C&&(0,Y.jsx)(`div`,{className:`grid place-items-center w-7 h-7 shrink-0 text-fg-primary`,children:(0,Y.jsx)(d6,{className:`h-5`,blinking:y})}),(0,Y.jsx)(OKe,{projectName:t,projectHref:n}),(0,Y.jsx)(kKe,{breakpoint:e,onClick:c}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[!S&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(v6,{onPreview:l,previewHref:x,onToggleCanvas:u,isCanvasOpen:d}),(0,Y.jsx)(DKe,{onCompare:h,pendingChanges:m,reviewCount:g}),p??(0,Y.jsx)(S6,{pendingChanges:m,onPublish:f,publishState:_}),(0,Y.jsx)(b6,{})]}),b&&(0,Y.jsx)(x6,{label:`AI assistant`,active:r===`ai`,onClick:()=>i(`ai`),children:(0,Y.jsx)(Ny,{size:16})}),!S&&(0,Y.jsx)(x6,{label:`Quick actions`,active:r===`utility`,onClick:()=>i(`utility`),children:(0,Y.jsx)(Cy,{size:16})}),o!==void 0&&(0,Y.jsxs)(x6,{label:o>0?`Notifications (${o} unread)`:`Notifications`,active:r===`notifications`,onClick:()=>i(`notifications`),children:[(0,Y.jsx)(Iie,{size:16}),o>0&&(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[1rem] h-4 px-1 grid place-items-center rounded-full bg-fg-primary text-bg-float text-[0.625rem] font-semibold tabular-nums`,children:o>9?`9+`:o})]}),(s||v)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(b6,{}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":v?`Account: ${v.message}`:`Account: ${s?.name}`,title:v?.message,onClick:()=>i(`settings`),className:`relative shrink-0 rounded-full`,children:[s?(0,Y.jsx)(p6,{initials:s.initials,size:`sm`}):(0,Y.jsx)(`span`,{className:`grid h-6 w-6 place-items-center rounded-full text-fg-secondary`,children:(0,Y.jsx)(Bae,{size:15})}),v&&(0,Y.jsx)(m6,{})]})]})]})]})}function v6({onPreview:e,previewHref:t,onToggleCanvas:n,isCanvasOpen:r,canvasActionLabel:i,onExitCanvas:a,className:o,menuPlacement:s=`below`,alwaysShowLabel:c}){let[l,u]=(0,b.useState)(!1),d=(0,b.useRef)(null);i6(d,l,(0,b.useCallback)(()=>u(!1),[])),(0,b.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[l]);let f=c?void 0:`hidden md:inline`;return n?(0,Y.jsxs)(`div`,{ref:d,className:X(`relative h-8`,o),children:[(0,Y.jsxs)(`div`,{className:X(`inline-flex h-full w-full items-stretch overflow-hidden rounded-md border`,r?`border-border-float bg-bg-float-raised text-fg-primary`:`border-border-float text-fg-secondary`),children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-label":i??(r?`Close the canvas`:`Open the canvas`),"aria-pressed":i===void 0?r:void 0,onClick:n,className:`inline-flex flex-1 items-center justify-center gap-1.5 px-2.5 text-xs font-medium hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(Hie,{size:14}),(0,Y.jsx)(`span`,{className:f,children:`Preview`})]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-px self-stretch bg-border-float`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Other ways to preview`,"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(e=>!e),className:`grid w-6 place-items-center hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(Iv,{size:13})})]}),l&&(0,Y.jsxs)(`div`,{role:`menu`,className:X(`absolute right-0 z-full w-56 rounded-md border border-border-float bg-bg-float py-1 shadow-lg`,s===`above`?`bottom-full mb-1`:`top-full mt-1`),children:[a?(0,Y.jsx)(y6,{icon:Hy,label:`Exit Preview`,detail:`Back to the editor, and stop the page`,onClick:()=>{u(!1),a()}}):(0,Y.jsx)(y6,{icon:Hie,label:r?`Close the canvas`:`Open the canvas`,detail:`Beside the editor, in the studio`,onClick:()=>{u(!1),n()}}),(0,Y.jsx)(y6,{icon:uy,label:`Open in a new tab`,detail:`The page with your unpublished changes`,href:t,onClick:()=>{u(!1),t===void 0&&e()}})]})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`inline-flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-md text-xs font-medium text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,o),children:[(0,Y.jsx)(Qv,{size:14}),(0,Y.jsx)(`span`,{className:f,children:`Preview`})]})}function y6({icon:e,label:t,detail:n,onClick:r,href:i}){let a=`flex w-full items-start gap-2 px-2.5 py-1.5 text-left text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,o=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(e,{size:14,className:`mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs`,children:t}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:n})]})]});return i===void 0?(0,Y.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:r,className:a,children:o}):(0,Y.jsx)(`a`,{role:`menuitem`,href:i,target:`_blank`,rel:`noopener noreferrer`,onClick:r,className:a,children:o})}function b6(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-px h-5 mx-0.5 bg-border-float`})}function DKe({onCompare:e,pendingChanges:t,reviewCount:n}){if(!e)return null;let r=t>0,i=r&&n!==void 0&&n>0;return(0,Y.jsxs)(`button`,{type:`button`,onClick:e,...r?{}:{"aria-hidden":!0,tabIndex:-1},"aria-label":i?`Review ${n} ${n===1?`change`:`changes`}`:`Review changes`,className:X(`relative inline-flex items-center gap-1.5 h-8 px-2.5 rounded-md shrink-0`,`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,!r&&`invisible`),children:[(0,Y.jsx)(ny,{size:15}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem]`,children:`Review`}),i&&(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[1rem] h-4 px-1 grid place-items-center rounded-full bg-fg-primary text-bg-float text-[0.625rem] font-semibold tabular-nums`,children:n>9?`9+`:n})]})}function x6({label:e,active:t,onClick:n,children:r}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,onClick:n,className:X(`relative grid place-items-center w-8 h-8 rounded-md shrink-0`,t?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:r})}function S6({pendingChanges:e,onPublish:t,publishState:n=`idle`,className:r}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,disabled:e===0||n===`publishing`||n===`blocked`,title:n===`blocked`?`Fix the validation errors before publishing`:void 0,className:X(`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium`,n===`error`?`bg-bg-error-primary text-fg-error-primary hover:bg-bg-error-primary-hover`:`bg-bg-brand-primary text-fg-brand-primary border border-border-brand-primary hover:bg-bg-brand-primary-hover`,`disabled:bg-bg-disabled disabled:text-fg-disabled`,r),children:[n===`publishing`?(0,Y.jsx)(hy,{size:14,className:`animate-spin`}):n===`error`?(0,Y.jsx)(Ly,{size:14}):(0,Y.jsx)(By,{size:14}),n===`publishing`?`Publishing…`:n===`error`?`Publish failed`:`Publish`,n===`idle`&&e>0&&(0,Y.jsx)(`span`,{className:`tabular-nums opacity-80`,children:e})]})}function OKe({projectName:e,projectHref:t}){let n=`min-w-0 px-2 text-[0.8125rem] font-semibold tracking-tight truncate`;return t===void 0?(0,Y.jsx)(`span`,{className:n,children:e}):(0,Y.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:`Open ${e} in Val Build`,className:X(n,`rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`),children:e})}function kKe({breakpoint:e,onClick:t}){return e===`mobile`?(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Search`,onClick:t,className:`grid place-items-center w-8 h-8 shrink-0 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(My,{size:16})}):(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Search`,onClick:t,className:`inline-flex items-center gap-2 h-8 pl-2 pr-1.5 rounded-md text-xs text-fg-secondary-alt border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(My,{size:14}),(0,Y.jsx)(`span`,{className:`hidden lg:inline`,children:`Search`}),(0,Y.jsx)(`kbd`,{className:`hidden lg:inline px-1.5 py-0.5 rounded border border-border-float text-[0.625rem] font-sans`,children:`⌘K`})]})}function AKe({openPanel:e,onSelect:t,destinations:n}){let r=g6(n);return r.length<2?null:(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":`Destinations`,className:`flex gap-0.5 p-0.5 rounded-md bg-bg-float-raised`,children:r.map(({panel:n,label:r,icon:i})=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:X(`flex-1 inline-flex items-center justify-center gap-1.5 h-7 rounded text-[0.6875rem]`,e===n?`bg-bg-float text-fg-primary shadow-sm font-medium`:`text-fg-secondary`),children:[(0,Y.jsx)(i,{size:13}),r]},n))})}function jKe({pendingChanges:e,onPreview:t,previewHref:n,onPublish:r,publishSlot:i,onOpenStatus:a,onOpenQuickActions:o,onToggleCanvas:s,isCanvasOpen:c,canvasActionLabel:l,onExitCanvas:u}){return(0,Y.jsxs)(`div`,{className:`absolute z-full bottom-0 inset-x-0 flex items-center gap-2 px-3 py-2.5 bg-bg-float border-t border-border-float`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:a,"aria-label":`Status and settings`,className:`grid place-items-center w-9 h-9 shrink-0 rounded-md text-fg-secondary border border-border-float`,children:(0,Y.jsx)(cy,{size:16})}),o&&(0,Y.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Quick actions`,className:`grid h-9 w-9 shrink-0 place-items-center rounded-md border border-border-float text-fg-secondary`,children:(0,Y.jsx)(Cy,{size:16})}),(0,Y.jsx)(v6,{onPreview:t,previewHref:n,onToggleCanvas:s,isCanvasOpen:c,canvasActionLabel:l,onExitCanvas:u,menuPlacement:`above`,alwaysShowLabel:!0,className:`h-9 flex-1`}),i??(0,Y.jsx)(S6,{pendingChanges:e,onPublish:r,className:`flex-1 h-9`})]})}var C6=5;function w6(e){return e.length<=C6?e.join(`, `):`${e.slice(0,C6).join(`, `)} and ${e.length-C6} more`}function MKe(e,t){let{total:n,settled:r,unfetched:i,unapplied:a,statSeen:o}=e;return o?i.length>0?{summary:`${r} of ${n} unpublished ${n===1?`change`:`changes`} loaded. ${i.length} never arrived.`,detail:[`The server announced ${n} unpublished ${n===1?`change`:`changes`} and sent the contents of ${r}. These were announced but never delivered:`,w6(i),t===null?`No fetch error was reported, so the request is most likely still outstanding rather than refused.`:`The last fetch error was: ${t}`,`The fields are editable again. Anything you change now is written on top of what did load, so the changes above may be lost — reload before editing if you can.`].join(`
|
|
217
|
+
`))}var uKe={page:$v,external:Zv,media:sy,data:Nv,content:Lae,recent:Ay},dKe={page:`Pages`,external:`External pages`,media:`Media`,data:`Data`,content:`In content`,recent:`Recently changed`},fKe=[`page`,`data`,`media`,`external`];function pKe(e){let t=[],n=e=>{for(let r of e)t.push({id:r.id,kind:`page`,label:r.name,detail:r.urlPath}),n(r.children??[])};n(e.pages);for(let n of e.data)t.push({id:n.id,kind:`data`,label:n.name,detail:n.moduleFilePath});for(let n of e.media)t.push({id:n.id,kind:`media`,label:n.name,detail:n.directory});for(let n of e.externalPages)t.push({id:n.id,kind:`external`,label:n.name,detail:n.url});return t}function mKe({results:e,contentResults:t,recentResults:n,isSearchingContent:r,onQueryChange:i,onSelect:a,onClose:o}){let[s,c]=(0,b.useState)(``);(0,b.useEffect)(()=>{i?.(s)},[s,i]);let[l,u]=(0,b.useState)(0),d=(0,b.useRef)(null),f=(0,b.useMemo)(()=>{let r=s.trim().toLowerCase(),i=r?e.filter(e=>e.label.toLowerCase().includes(r)||e.detail.toLowerCase().includes(r)):e,a=fKe.flatMap(e=>i.filter(t=>t.kind===e)),o=new Set(a.map(e=>e.id)),c=(r?t??[]:[]).filter(e=>!o.has(e.id));return[...r?[]:n??[],...a,...c].slice(0,40)},[e,t,n,s]);(0,b.useEffect)(()=>u(0),[s]),(0,b.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){e.preventDefault(),o();return}if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),u(t=>f.length===0?0:((e.key===`ArrowDown`?t+1:t-1)+f.length)%f.length);return}if(e.key===`Enter`){e.preventDefault();let t=f[l];t&&a(t)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f,l,a,o]),(0,b.useEffect)(()=>{d.current?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})},[l]);let p=null;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{onClick:o,"aria-hidden":!0,className:`absolute inset-0 z-overlay bg-black/50`}),(0,Y.jsxs)(`div`,{role:`dialog`,"aria-label":`Search`,className:`absolute z-overlay left-1/2 -translate-x-1/2 top-[12svh] w-[min(34rem,calc(100vw-1.5rem))] max-h-[70svh] flex flex-col rounded-xl bg-bg-float border border-border-float shadow-xl overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 h-11 px-3 border-b border-border-float shrink-0`,children:[(0,Y.jsx)(My,{size:15,className:`shrink-0 text-fg-secondary-alt`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:s,onChange:e=>c(e.target.value),placeholder:`Search pages, media and data…`,"aria-label":`Search the project`,className:`flex-1 min-w-0 rounded-sm bg-transparent text-sm placeholder:text-fg-secondary-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`}),(0,Y.jsx)(`kbd`,{className:`shrink-0 px-1.5 py-0.5 rounded border border-border-float text-[0.625rem] text-fg-secondary-alt font-sans`,children:`esc`})]}),(0,Y.jsxs)(`div`,{ref:d,className:`flex-1 min-h-0 overflow-y-auto py-1.5 scrollbar-slim`,children:[f.length===0?(0,Y.jsx)(`p`,{className:`px-4 py-6 text-xs text-fg-secondary-alt`,children:r?`Searching…`:`Nothing matches “${s}”.`}):f.map((e,t)=>{let n=uKe[e.kind],r=e.kind!==p;return p=e.kind,(0,Y.jsxs)(`div`,{children:[r&&(0,Y.jsx)(`div`,{className:`px-4 pt-2.5 pb-1 text-[0.6875rem] font-semibold uppercase tracking-wider text-fg-secondary-alt`,children:dKe[e.kind]}),(0,Y.jsxs)(`button`,{type:`button`,"data-active":t===l,onMouseMove:()=>u(t),onClick:()=>a(e),className:X(`flex items-center gap-2.5 w-full px-3 py-1.5 mx-1.5 rounded-md text-left`,`w-[calc(100%-0.75rem)]`,t===l?`bg-bg-float-raised`:`hover:bg-bg-float-raised`),children:[(0,Y.jsx)(n,{size:14,className:X(`shrink-0`,t===l?`text-fg-primary`:`text-fg-secondary-alt`)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary truncate`,children:e.label}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt truncate`,children:e.detail})]})]})]},`${e.kind}-${e.id}`)}),r&&f.length>0&&(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 px-4 py-2 text-[0.6875rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(hy,{size:11,className:`animate-spin`}),`Still searching content…`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 h-8 px-3 shrink-0 border-t border-border-float text-[0.625rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(`span`,{children:`↑↓ to navigate`}),(0,Y.jsx)(`span`,{children:`↵ to open`})]})]})]})}function hKe(e){(0,b.useEffect)(()=>{let t=t=>{if(t.key!==`k`||!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return;let n=t.target;n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable)||(t.preventDefault(),e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function p6({className:e,blinking:t}){let n=CC(),r=t&&!n;return(0,Y.jsxs)(`svg`,{viewBox:`0 0 105 149`,fill:`none`,role:`img`,"aria-label":`Val`,className:X(`w-full h-full`,e),children:[(0,Y.jsxs)(`defs`,{children:[(0,Y.jsxs)(`mask`,{id:`val-mark-hole`,children:[(0,Y.jsx)(`rect`,{x:`0`,y:`0`,width:`105`,height:`149`,fill:`white`}),(0,Y.jsx)(`circle`,{cx:`49.9`,cy:`104.2`,r:`9.61`,fill:`black`,children:r&&(0,Y.jsx)(`animate`,{attributeName:`fill`,values:`black;black;white;white`,dur:`1.06s`,calcMode:`discrete`,repeatCount:`indefinite`})})]}),(0,Y.jsxs)(`filter`,{id:`val-mark-glow`,x:`0`,y:`0`,width:`105`,height:`149`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Y.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`10.72`}),(0,Y.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`out`}),(0,Y.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0.219608 0 0 0 0 0.803922 0 0 0 0 0.501961 0 0 0 0.3 0`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in2:`SourceGraphic`})]}),(0,Y.jsx)(`filter`,{id:`val-mark-hole-shadow`,x:`35`,y:`90`,width:`30`,height:`30`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`2.4`})})]}),(0,Y.jsx)(`g`,{filter:`url(#val-mark-glow)`,children:(0,Y.jsx)(`path`,{d:`M21.4768 23.3474C21.4768 22.4628 22.1939 21.7457 23.0785 21.7457H77.1357C78.0203 21.7457 78.7374 22.4628 78.7374 23.3474V125.055C78.7374 125.94 78.0203 126.657 77.1357 126.657H23.0785C22.1939 126.657 21.4768 125.94 21.4768 125.055V23.3474Z`,fill:m6,mask:`url(#val-mark-hole)`})}),(0,Y.jsx)(`circle`,{cx:`49.9`,cy:`104.2`,r:`9.61`,fill:`none`,stroke:m6,strokeWidth:`3`,strokeOpacity:`0.3`,filter:`url(#val-mark-hole-shadow)`})]})}var m6=`var(--colors-brand-green-400)`;function h6({initials:e,size:t=`md`,className:n}){return(0,Y.jsx)(`span`,{className:X(`grid place-items-center rounded-full bg-bg-float-raised text-fg-primary border border-border-float font-medium select-none`,t===`sm`?`w-7 h-7 text-[0.625rem]`:`w-8 h-8 text-[0.6875rem]`,n),children:e})}function g6({className:e}){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`absolute -right-0.5 -top-0.5 h-2.5 w-2.5 rounded-full`,`bg-fg-error-on-surface ring-2 ring-bg-float`,e)})}function gKe({error:e}){return(0,Y.jsxs)(`div`,{className:`mx-4 my-3 rounded-md border border-border-error-primary bg-bg-error-secondary p-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Ly,{size:13,className:`mt-0.5 shrink-0 text-fg-error-on-surface`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-fg-error-on-surface`,children:`Could not load your account`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[0.6875rem] text-fg-secondary`,children:e.message})]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:e.onRetry,className:X(`mt-2 inline-flex h-7 items-center rounded-md px-2.5 text-xs font-medium`,`border border-border-primary text-fg-primary hover:bg-bg-float-raised`),children:`Try again`})]})}var _6=[{panel:`pages`,label:`Pages`,icon:$v},{panel:`media`,label:`Media`,icon:sy},{panel:`data`,label:`Data`,icon:Nv}];function v6(e){return e===void 0?_6:_6.filter(t=>e.includes(t.panel))}function _Ke({openPanel:e,onSelect:t,destinations:n,user:r,hasDraftChanges:i,accountError:a,isLoading:o}){let s=v6(n);return(0,Y.jsxs)(`nav`,{"aria-label":`Main`,className:`absolute left-3 top-3 bottom-3 z-full w-12 flex flex-col items-center py-2 gap-1 rounded-lg bg-bg-float border border-border-float shadow-sm`,children:[(0,Y.jsx)(`div`,{className:`grid place-items-center w-8 h-8 mb-1 shrink-0 text-fg-primary`,children:(0,Y.jsx)(p6,{className:`h-6`,blinking:o})}),s.map(({panel:n,label:r,icon:i})=>(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":r,"aria-current":e===n?`true`:void 0,onClick:()=>t(n),className:X(`grid place-items-center w-8 h-8 rounded-md shrink-0 transition-colors`,e===n?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:(0,Y.jsx)(i,{size:17})})}),(0,Y.jsx)(Xg,{side:`right`,children:r})]},n)),(0,Y.jsx)(`div`,{className:`mt-auto shrink-0`,children:r?(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Account: ${r.name}`,"aria-current":e===`settings`?`true`:void 0,onClick:()=>t(`settings`),className:`relative grid place-items-center w-8 h-8 rounded-full`,children:[(0,Y.jsx)(h6,{initials:r.initials,size:`sm`}),a&&(0,Y.jsx)(g6,{}),i&&(0,Y.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 w-2 h-2 rounded-full bg-fg-secondary ring-2 ring-bg-float`})]})}),(0,Y.jsx)(Xg,{side:`right`,children:a?a.message:r.name})]}):(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Settings`,"aria-current":e===`settings`?`true`:void 0,onClick:()=>t(`settings`),className:X(`relative grid place-items-center w-8 h-8 rounded-md transition-colors`,e===`settings`?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:[(0,Y.jsx)(Tae,{size:17}),a&&(0,Y.jsx)(g6,{}),i&&(0,Y.jsx)(`span`,{className:`absolute -right-0.5 -bottom-0.5 w-2 h-2 rounded-full bg-fg-secondary ring-2 ring-bg-float`})]})}),(0,Y.jsx)(Xg,{side:`right`,children:a?a.message:`Settings`})]})})]})}var y6=40;function vKe({breakpoint:e,media:t,selectedId:n,onSelect:r,onSelectFile:i,getFileUrl:a,onUpload:o,onClose:s,navSwitcher:c,isLoading:l,loadError:u,onRetryLoad:d}){let[f,p]=(0,b.useState)(``),[m,h]=(0,b.useState)(()=>new Set),g=f.trim().toLowerCase(),_=(0,b.useMemo)(()=>g?t.map(e=>{let t=e.name.toLowerCase().includes(g)||e.directory.toLowerCase().includes(g);return{gallery:e,files:(e.files??[]).filter(e=>e.ref.toLowerCase().includes(g)),galleryMatches:t}}).filter(({files:e,galleryMatches:t})=>t||e.length>0).map(({gallery:e,files:t,galleryMatches:n})=>({gallery:e,files:n&&t.length===0?e.files:t})):t.map(e=>({gallery:e,files:e.files})),[t,g]),v=e=>g?!0:m.has(e),y=e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,Y.jsx)(pC,{side:`left`,width:300,title:`Media`,mobileVariant:`sheet`,breakpoint:e,onClose:s,subheader:c,headerAction:o&&t.length>0?(0,Y.jsx)(CKe,{media:t,onUpload:o}):void 0,sticky:l||u?void 0:(0,Y.jsx)(gC,{value:f,onChange:p,placeholder:`Filter media…`}),children:(0,Y.jsx)(`div`,{className:`py-2`,children:l?(0,Y.jsx)(vC,{}):u?(0,Y.jsx)(yC,{message:u,onRetry:d}):_.length===0?(0,Y.jsx)(hC,{children:f?`Nothing matches this filter.`:`No galleries yet.`}):_.map(({gallery:e,files:t})=>{let o=v(e.id);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_C,{selected:n===e.id,title:e.moduleFilePath,expanded:o,onClick:()=>{g||y(e.id)},action:(0,Y.jsx)(`button`,{type:`button`,onClick:()=>r(e),title:`Open in the editor`,"aria-label":`Open ${e.name} in the editor`,className:X(`ml-1 shrink-0 rounded px-1.5 h-6 text-[0.6875rem] text-fg-secondary`,`hover:bg-bg-float-raised hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,`opacity-0 transition-opacity`,`group-hover/row:opacity-100 focus-visible:opacity-100`,`[@media(hover:none)]:opacity-100`,n===e.id&&`opacity-100`),children:`Open`}),leading:(0,Y.jsx)(`span`,{className:`text-fg-secondary-alt`,children:o?(0,Y.jsx)(Iv,{size:13}):(0,Y.jsx)(Rv,{size:13})}),label:e.name,meta:aA(e.directory),trailing:(0,Y.jsx)(`span`,{className:`text-[0.6875rem] tabular-nums text-fg-secondary-alt`,children:e.itemCount})}),o&&(0,Y.jsx)(yKe,{gallery:e,files:t,selectedId:n,onSelectFile:i,getFileUrl:a})]},e.id)})})})}function yKe({gallery:e,files:t,selectedId:n,onSelectFile:r,getFileUrl:i}){let[a,o]=(0,b.useState)(y6),s=t?.length??-1;if((0,b.useEffect)(()=>o(y6),[s]),t===void 0)return(0,Y.jsxs)(`p`,{className:`flex items-center gap-1.5 pl-8 py-1.5 text-[0.6875rem] text-fg-secondary-alt`,children:[(0,Y.jsx)(hy,{size:11,className:`animate-spin`}),`Loading files…`]});if(t.length===0)return(0,Y.jsx)(`p`,{className:`pl-8 py-1.5 text-[0.6875rem] text-fg-secondary-alt`,children:`No files in this gallery yet.`});let c=t.slice(0,a),l=t.length-c.length,u=wKe(c,e.directory);return(0,Y.jsxs)(`div`,{children:[u.map(t=>(0,Y.jsxs)(`div`,{children:[u.length>1&&(0,Y.jsx)(`p`,{title:aA(t.directory),className:`truncate pl-8 pr-3 pt-1.5 pb-0.5 text-[0.625rem] uppercase tracking-wide text-fg-secondary-alt`,children:t.label}),t.files.map(t=>(0,Y.jsx)(bKe,{gallery:e,file:t,selected:n===t.sourcePath,onSelect:r,getFileUrl:i},t.ref))]},t.directory)),l>0&&(0,Y.jsx)(xKe,{remaining:l,onShowMore:()=>o(e=>e+y6)})]})}function bKe({gallery:e,file:t,selected:n,onSelect:r,getFileUrl:i}){let[a,o]=(0,b.useState)(!1),s=i?.(t.ref)??null,c=e.mediaType===`images`&&s!==null&&!a;return(0,Y.jsx)(`div`,{className:`flex items-center pl-5 pr-2`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r?.(e,t),title:aA(t.ref),"aria-current":n?`true`:void 0,className:X(`group flex items-center gap-2 min-w-0 flex-1 h-8 px-1.5 rounded-md text-xs text-left`,n?`bg-bg-float-raised text-fg-primary font-medium`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:[(0,Y.jsx)(`span`,{className:`grid place-items-center w-6 h-6 shrink-0 overflow-hidden rounded bg-bg-float-raised`,children:c?(0,Y.jsx)(cA,{url:s,loading:`lazy`,onError:()=>o(!0)}):e.mediaType===`images`?(0,Y.jsx)(sy,{size:12,className:`text-fg-secondary-alt`}):(0,Y.jsx)($v,{size:12,className:`text-fg-secondary-alt`})}),(0,Y.jsx)(`span`,{className:`truncate`,children:SKe(t.ref)})]})})}function xKe({remaining:e,onShowMore:t}){let n=(0,b.useRef)(null);return(0,b.useEffect)(()=>{let e=n.current;if(!e||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&t()});return r.observe(e),()=>r.disconnect()},[t]),(0,Y.jsxs)(`button`,{ref:n,type:`button`,onClick:t,className:`block w-full pl-8 pr-3 py-1.5 text-left text-[0.6875rem] text-fg-secondary-alt hover:text-fg-primary`,children:[`Show `,Math.min(e,y6),` more (`,e,` left)`]})}function SKe(e){let t=e.split(`/`);return t[t.length-1]||e}function CKe({media:e,onUpload:t}){let[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null);o6(i,n,(0,b.useCallback)(()=>r(!1),[]));let a=e.length===1?e[0]:null;return(0,Y.jsxs)(`div`,{ref:i,className:`relative`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-haspopup":a?void 0:`menu`,"aria-expanded":a?void 0:n,title:a?`Upload into ${aA(a.directory)}`:`Choose where to upload`,onClick:()=>a?t(a):r(e=>!e),className:`inline-flex items-center gap-1 h-7 px-2 rounded-md text-xs font-medium text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(Oy,{size:13}),`Upload`,!a&&(0,Y.jsx)(Iv,{size:12})]}),n&&!a&&(0,Y.jsx)(`div`,{role:`menu`,className:`absolute right-0 top-full z-window mt-1 w-64 rounded-md border border-border-float bg-bg-float py-1 shadow-lg`,children:e.map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{r(!1),t(e)},className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:[e.mediaType===`images`?(0,Y.jsx)(sy,{size:13,className:`mt-0.5 shrink-0`}):(0,Y.jsx)($v,{size:13,className:`mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-xs`,children:aA(e.directory)}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:e.mediaType===`images`?`Images`:`Files`})]})]},e.id))})]})}function wKe(e,t){let n=new Map;for(let t of e){let e=t.ref.slice(0,t.ref.lastIndexOf(`/`))||`/`,r=n.get(e);r?r.push(t):n.set(e,[t])}return Array.from(n.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>({directory:e,label:TKe(e,t),files:n}))}function TKe(e,t){if(e===t)return`In this folder`;let n=t.endsWith(`/`)?t:`${t}/`;return e.startsWith(n)?e.slice(n.length):aA(e)}function EKe({breakpoint:e,projectName:t,projectHref:n,openPanel:r,onTogglePanel:i,onOpenMenu:a,unreadNotifications:o,user:s,onOpenSearch:c,onPreview:l,onToggleCanvas:u,isCanvasOpen:d,onPublish:f,publishSlot:p,pendingChanges:m,onCompare:h,reviewCount:g,publishState:_=`idle`,accountError:v,isLoading:y,aiEnabled:b=!1,previewHref:x}){let S=e===`mobile`,C=e===`desktop`;return(0,Y.jsxs)(`header`,{className:X(`absolute z-full top-3 h-11 flex items-center gap-1.5 px-2 rounded-lg`,`bg-bg-float border border-border-float shadow-sm`,C?`left-[4.75rem] right-3`:`left-3 right-3`),children:[!C&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,onClick:a,className:`grid place-items-center w-8 h-8 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary shrink-0`,children:(0,Y.jsx)(mae,{size:17})}),!C&&(0,Y.jsx)(`div`,{className:`grid place-items-center w-7 h-7 shrink-0 text-fg-primary`,children:(0,Y.jsx)(p6,{className:`h-5`,blinking:y})}),(0,Y.jsx)(OKe,{projectName:t,projectHref:n}),(0,Y.jsx)(kKe,{breakpoint:e,onClick:c}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[!S&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(b6,{onPreview:l,previewHref:x,onToggleCanvas:u,isCanvasOpen:d}),(0,Y.jsx)(DKe,{onCompare:h,pendingChanges:m,reviewCount:g}),p??(0,Y.jsx)(w6,{pendingChanges:m,onPublish:f,publishState:_}),(0,Y.jsx)(S6,{})]}),b&&(0,Y.jsx)(C6,{label:`AI assistant`,active:r===`ai`,onClick:()=>i(`ai`),children:(0,Y.jsx)(Ny,{size:16})}),!S&&(0,Y.jsx)(C6,{label:`Quick actions`,active:r===`utility`,onClick:()=>i(`utility`),children:(0,Y.jsx)(Cy,{size:16})}),o!==void 0&&(0,Y.jsxs)(C6,{label:o>0?`Notifications (${o} unread)`:`Notifications`,active:r===`notifications`,onClick:()=>i(`notifications`),children:[(0,Y.jsx)(Iie,{size:16}),o>0&&(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[1rem] h-4 px-1 grid place-items-center rounded-full bg-fg-primary text-bg-float text-[0.625rem] font-semibold tabular-nums`,children:o>9?`9+`:o})]}),(s||v)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(S6,{}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":v?`Account: ${v.message}`:`Account: ${s?.name}`,title:v?.message,onClick:()=>i(`settings`),className:`relative shrink-0 rounded-full`,children:[s?(0,Y.jsx)(h6,{initials:s.initials,size:`sm`}):(0,Y.jsx)(`span`,{className:`grid h-6 w-6 place-items-center rounded-full text-fg-secondary`,children:(0,Y.jsx)(Bae,{size:15})}),v&&(0,Y.jsx)(g6,{})]})]})]})]})}function b6({onPreview:e,previewHref:t,onToggleCanvas:n,isCanvasOpen:r,canvasActionLabel:i,onExitCanvas:a,className:o,menuPlacement:s=`below`,alwaysShowLabel:c}){let[l,u]=(0,b.useState)(!1),d=(0,b.useRef)(null);o6(d,l,(0,b.useCallback)(()=>u(!1),[])),(0,b.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[l]);let f=c?void 0:`hidden md:inline`;return n?(0,Y.jsxs)(`div`,{ref:d,className:X(`relative h-8`,o),children:[(0,Y.jsxs)(`div`,{className:X(`inline-flex h-full w-full items-stretch overflow-hidden rounded-md border`,r?`border-border-float bg-bg-float-raised text-fg-primary`:`border-border-float text-fg-secondary`),children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-label":i??(r?`Close the canvas`:`Open the canvas`),"aria-pressed":i===void 0?r:void 0,onClick:n,className:`inline-flex flex-1 items-center justify-center gap-1.5 px-2.5 text-xs font-medium hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(Hie,{size:14}),(0,Y.jsx)(`span`,{className:f,children:`Preview`})]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-px self-stretch bg-border-float`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Other ways to preview`,"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(e=>!e),className:`grid w-6 place-items-center hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(Iv,{size:13})})]}),l&&(0,Y.jsxs)(`div`,{role:`menu`,className:X(`absolute right-0 z-full w-56 rounded-md border border-border-float bg-bg-float py-1 shadow-lg`,s===`above`?`bottom-full mb-1`:`top-full mt-1`),children:[a?(0,Y.jsx)(x6,{icon:Hy,label:`Exit Preview`,detail:`Back to the editor, and stop the page`,onClick:()=>{u(!1),a()}}):(0,Y.jsx)(x6,{icon:Hie,label:r?`Close the canvas`:`Open the canvas`,detail:`Beside the editor, in the studio`,onClick:()=>{u(!1),n()}}),(0,Y.jsx)(x6,{icon:uy,label:`Open in a new tab`,detail:`The page with your unpublished changes`,href:t,onClick:()=>{u(!1),t===void 0&&e()}})]})]}):(0,Y.jsxs)(`button`,{type:`button`,onClick:e,className:X(`inline-flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-md text-xs font-medium text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,o),children:[(0,Y.jsx)(Qv,{size:14}),(0,Y.jsx)(`span`,{className:f,children:`Preview`})]})}function x6({icon:e,label:t,detail:n,onClick:r,href:i}){let a=`flex w-full items-start gap-2 px-2.5 py-1.5 text-left text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,o=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(e,{size:14,className:`mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs`,children:t}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:n})]})]});return i===void 0?(0,Y.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:r,className:a,children:o}):(0,Y.jsx)(`a`,{role:`menuitem`,href:i,target:`_blank`,rel:`noopener noreferrer`,onClick:r,className:a,children:o})}function S6(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-px h-5 mx-0.5 bg-border-float`})}function DKe({onCompare:e,pendingChanges:t,reviewCount:n}){if(!e)return null;let r=t>0,i=r&&n!==void 0&&n>0;return(0,Y.jsxs)(`button`,{type:`button`,onClick:e,...r?{}:{"aria-hidden":!0,tabIndex:-1},"aria-label":i?`Review ${n} ${n===1?`change`:`changes`}`:`Review changes`,className:X(`relative inline-flex items-center gap-1.5 h-8 px-2.5 rounded-md shrink-0`,`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,!r&&`invisible`),children:[(0,Y.jsx)(ny,{size:15}),(0,Y.jsx)(`span`,{className:`text-[0.8125rem]`,children:`Review`}),i&&(0,Y.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 min-w-[1rem] h-4 px-1 grid place-items-center rounded-full bg-fg-primary text-bg-float text-[0.625rem] font-semibold tabular-nums`,children:n>9?`9+`:n})]})}function C6({label:e,active:t,onClick:n,children:r}){return(0,Y.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,onClick:n,className:X(`relative grid place-items-center w-8 h-8 rounded-md shrink-0`,t?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`),children:r})}function w6({pendingChanges:e,onPublish:t,publishState:n=`idle`,className:r}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:t,disabled:e===0||n===`publishing`||n===`blocked`,title:n===`blocked`?`Fix the validation errors before publishing`:void 0,className:X(`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium`,n===`error`?`bg-bg-error-primary text-fg-error-primary hover:bg-bg-error-primary-hover`:`bg-bg-brand-primary text-fg-brand-primary border border-border-brand-primary hover:bg-bg-brand-primary-hover`,`disabled:bg-bg-disabled disabled:text-fg-disabled`,r),children:[n===`publishing`?(0,Y.jsx)(hy,{size:14,className:`animate-spin`}):n===`error`?(0,Y.jsx)(Ly,{size:14}):(0,Y.jsx)(By,{size:14}),n===`publishing`?`Publishing…`:n===`error`?`Publish failed`:`Publish`,n===`idle`&&e>0&&(0,Y.jsx)(`span`,{className:`tabular-nums opacity-80`,children:e})]})}function OKe({projectName:e,projectHref:t}){let n=`min-w-0 px-2 text-[0.8125rem] font-semibold tracking-tight truncate`;return t===void 0?(0,Y.jsx)(`span`,{className:n,children:e}):(0,Y.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,title:`Open ${e} in Val Build`,className:X(n,`rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`),children:e})}function kKe({breakpoint:e,onClick:t}){return e===`mobile`?(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Search`,onClick:t,className:`grid place-items-center w-8 h-8 shrink-0 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:(0,Y.jsx)(My,{size:16})}):(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`Search`,onClick:t,className:`inline-flex items-center gap-2 h-8 pl-2 pr-1.5 rounded-md text-xs text-fg-secondary-alt border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(My,{size:14}),(0,Y.jsx)(`span`,{className:`hidden lg:inline`,children:`Search`}),(0,Y.jsx)(`kbd`,{className:`hidden lg:inline px-1.5 py-0.5 rounded border border-border-float text-[0.625rem] font-sans`,children:`⌘K`})]})}function AKe({openPanel:e,onSelect:t,destinations:n}){let r=v6(n);return r.length<2?null:(0,Y.jsx)(`div`,{role:`tablist`,"aria-label":`Destinations`,className:`flex gap-0.5 p-0.5 rounded-md bg-bg-float-raised`,children:r.map(({panel:n,label:r,icon:i})=>(0,Y.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e===n,onClick:()=>t(n),className:X(`flex-1 inline-flex items-center justify-center gap-1.5 h-7 rounded text-[0.6875rem]`,e===n?`bg-bg-float text-fg-primary shadow-sm font-medium`:`text-fg-secondary`),children:[(0,Y.jsx)(i,{size:13}),r]},n))})}function jKe({pendingChanges:e,onPreview:t,previewHref:n,onPublish:r,publishSlot:i,onOpenStatus:a,onOpenQuickActions:o,onToggleCanvas:s,isCanvasOpen:c,canvasActionLabel:l,onExitCanvas:u}){return(0,Y.jsxs)(`div`,{className:`absolute z-full bottom-0 inset-x-0 flex items-center gap-2 px-3 py-2.5 bg-bg-float border-t border-border-float`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:a,"aria-label":`Status and settings`,className:`grid place-items-center w-9 h-9 shrink-0 rounded-md text-fg-secondary border border-border-float`,children:(0,Y.jsx)(cy,{size:16})}),o&&(0,Y.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`Quick actions`,className:`grid h-9 w-9 shrink-0 place-items-center rounded-md border border-border-float text-fg-secondary`,children:(0,Y.jsx)(Cy,{size:16})}),(0,Y.jsx)(b6,{onPreview:t,previewHref:n,onToggleCanvas:s,isCanvasOpen:c,canvasActionLabel:l,onExitCanvas:u,menuPlacement:`above`,alwaysShowLabel:!0,className:`h-9 flex-1`}),i??(0,Y.jsx)(w6,{pendingChanges:e,onPublish:r,className:`flex-1 h-9`})]})}var T6=5;function E6(e){return e.length<=T6?e.join(`, `):`${e.slice(0,T6).join(`, `)} and ${e.length-T6} more`}function MKe(e,t){let{total:n,settled:r,unfetched:i,unapplied:a,statSeen:o}=e;return o?i.length>0?{summary:`${r} of ${n} unpublished ${n===1?`change`:`changes`} loaded. ${i.length} never arrived.`,detail:[`The server announced ${n} unpublished ${n===1?`change`:`changes`} and sent the contents of ${r}. These were announced but never delivered:`,E6(i),t===null?`No fetch error was reported, so the request is most likely still outstanding rather than refused.`:`The last fetch error was: ${t}`,`The fields are editable again. Anything you change now is written on top of what did load, so the changes above may be lost — reload before editing if you can.`].join(`
|
|
218
218
|
|
|
219
|
-
`)}:a.length>0?{summary:a.length===1?`1 of ${n} unpublished changes loaded but was not applied.`:`${a.length} of ${n} unpublished changes loaded but were not applied.`,detail:[`Their contents arrived and the source store did not take them, which points at the patches themselves rather than at the network:`,
|
|
219
|
+
`)}:a.length>0?{summary:a.length===1?`1 of ${n} unpublished changes loaded but was not applied.`:`${a.length} of ${n} unpublished changes loaded but were not applied.`,detail:[`Their contents arrived and the source store did not take them, which points at the patches themselves rather than at the network:`,E6(a),`A patch whose module no longer has the path it edits cannot be applied. The compare view lists what each one touches.`].join(`
|
|
220
220
|
|
|
221
221
|
`)}:{summary:`Unpublished changes took longer than expected to load.`,detail:[`All ${n} of them are loaded now. The wait passed the one-minute mark before the last one arrived.`,`Nothing is outstanding, so this is safe to dismiss.`].join(`
|
|
222
222
|
|
|
223
223
|
`)}:{summary:`Could not reach the server to see if there are any changes.`,detail:["The studio never received a first answer from `GET /stat`, so it does not yet know which unpublished changes exist.",t===null?null:`The last error was: ${t}`,`Check that the Val API route is mounted and reachable, then reload.`].filter(e=>e!==null).join(`
|
|
224
224
|
|
|
225
|
-
`)}}var NKe=6e4;function PKe({ready:e,progress:t,fetchError:n,children:r}){let[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(null),c=(0,b.useRef)({progress:t,fetchError:n});(0,b.useEffect)(()=>{c.current={progress:t,fetchError:n}}),(0,b.useEffect)(()=>{if(e)return;let t=setTimeout(()=>{let{progress:e,fetchError:t}=c.current;s(MKe(e(),t))},NKe);return()=>clearTimeout(t)},[e]);let l=!e&&!i&&o===null;return(0,Y.jsx)(LGe,{held:l,children:(0,Y.jsxs)(`div`,{className:`contents`,"aria-busy":l,children:[(0,Y.jsx)(`div`,{className:X(`transition-opacity duration-200`,l?`opacity-60`:`opacity-100`),children:r}),l&&(0,Y.jsx)(FKe,{onDismiss:()=>a(!0)}),!e&&o!==null&&!i&&(0,Y.jsx)(IKe,{summary:o.summary,detail:o.detail,onDismiss:()=>a(!0)})]})})}function FKe({onDismiss:e}){return(0,Y.jsx)(`div`,{className:`pointer-events-none absolute bottom-16 left-1/2 z-hover -translate-x-1/2`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border-float bg-bg-float px-2.5 py-1 text-xs text-fg-secondary shadow-sm`,children:[(0,Y.jsx)(hy,{size:12,className:`animate-spin`,"aria-hidden":!0}),`Loading unpublished changes…`,(0,Y.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Stop waiting for unpublished changes`,className:`pointer-events-auto -mr-1 ml-0.5 grid size-4 place-items-center rounded text-fg-tertiary hover:bg-bg-float-raised hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:(0,Y.jsx)(Hy,{size:11,"aria-hidden":!0})})]})})}function IKe({summary:e,detail:t,onDismiss:n}){return(0,Y.jsx)(`div`,{role:`alert`,className:`absolute bottom-16 left-1/2 z-hover w-[min(28rem,calc(100%-2rem))] -translate-x-1/2`,children:(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-float bg-bg-float p-3 shadow-md`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(Ly,{size:14,className:`mt-0.5 shrink-0 text-fg-warning-primary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-fg-primary`,children:e}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Dismiss`,className:`-mr-1 -mt-1 grid size-5 shrink-0 place-items-center rounded text-fg-tertiary hover:bg-bg-float-raised hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:(0,Y.jsx)(Hy,{size:12,"aria-hidden":!0})})]}),(0,Y.jsxs)(`details`,{className:`group mt-2`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer list-none text-xs text-fg-secondary-alt hover:text-fg-primary [&::-webkit-details-marker]:hidden`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(Rv,{size:12,className:`transition-transform group-open:rotate-90`,"aria-hidden":!0}),`Diagnostics`]})}),(0,Y.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap break-words rounded-md border border-border-float bg-bg-secondary p-3 font-mono text-[0.6875rem] leading-relaxed text-fg-secondary`,children:t})]})]})})}var LKe={content:$v,media:sy,publish:Gv,validation:Ly};function RKe({breakpoint:e,notifications:t,onSelect:n,onMarkAllRead:r,onClose:i}){let a=t.filter(e=>e.unread).length;return(0,Y.jsx)(pC,{side:`right`,width:320,title:`Notifications`,mobileVariant:`bottom-sheet`,breakpoint:e,onClose:i,headerAction:a>0?(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`h-7 px-2 rounded-md text-xs text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:`Mark all read`}):void 0,children:t.length===0?(0,Y.jsx)(hC,{children:`Nothing new. You are all caught up.`}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border-float`,children:t.map(e=>{let t=LKe[e.kind];return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`flex gap-2.5 w-full px-4 py-2.5 text-left hover:bg-bg-float-raised`,children:[(0,Y.jsx)(`span`,{className:X(`grid place-items-center w-6 h-6 mt-0.5 shrink-0 rounded-md`,e.kind===`validation`?`bg-bg-error-primary text-fg-error-primary`:`bg-bg-float-raised text-fg-secondary`),children:(0,Y.jsx)(t,{size:13})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary`,children:e.title}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:e.timestamp})]}),e.unread&&(0,Y.jsx)(`span`,{"aria-label":`Unread`,className:`w-1.5 h-1.5 mt-1.5 shrink-0 rounded-full bg-fg-secondary`})]})},e.id)})})})}var T6=`\0header`;function zKe({routes:e,currentPage:t,isOpen:n,onOpenChange:r,onSubmit:i}){let a=(0,b.useRef)(null);return i6(a,n,(0,b.useCallback)(()=>r(!1),[r])),(0,Y.jsxs)(`div`,{ref:a,className:`relative shrink-0`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`New page`,"aria-expanded":n,onClick:()=>r(!n),className:X(`inline-flex items-center gap-1 h-7 px-2 rounded-md text-xs font-medium`,`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,n&&`bg-bg-float-raised text-fg-primary`),children:[(0,Y.jsx)(Oy,{size:13}),`New`]}),n&&(0,Y.jsx)(`div`,{className:`absolute right-0 top-full z-window mt-1 w-[17rem] rounded-md border border-border-float bg-bg-float shadow-lg`,children:(0,Y.jsx)(EA,{routes:e,currentPage:t,onSubmit:i,onCancel:()=>r(!1)})})]})}function E6(e,t){for(let n of e){if(n.id===t)return n;let e=E6(n.children??[],t);if(e)return e}}function BKe(e,t){if(!t)return e;let n=t.toLowerCase(),r=e=>e.flatMap(e=>{let t=r(e.children??[]);return!(e.name.toLowerCase().includes(n)||e.urlPath.toLowerCase().includes(n))&&t.length===0?[]:[{...e,children:t}]});return r(e)}function D6(e){return e.flatMap(e=>[e.id,...D6(e.children??[])])}function O6(e){return e.reduce((e,t)=>e+ +!!t.isTracked+O6(t.children??[]),0)}function k6(e,t){if(t===null)return[];let n=(e,r)=>{for(let i of e){if(i.id===t)return r;let e=n(i.children??[],[...r,i.id]);if(e)return e}return null};return n(e,[])??[]}function A6(e){return(e.errorCount??0)+(e.children??[]).reduce((e,t)=>e+A6(t),0)}function j6(e){return e.hasDraft===!0||(e.children??[]).some(e=>j6(e))}function VKe({breakpoint:e,pages:t,externalPages:n,selectedId:r,onSelectPage:i,onSelectExternalPage:a,onNewPage:o,newPage:s,onClose:c,navSwitcher:l,isLoading:u,loadError:d,onRetryLoad:f}){let[p,m]=(0,b.useState)(``),[h,g]=(0,b.useState)(()=>new Set(k6(t,r))),_=(0,b.useMemo)(()=>k6(t,r).join(`\0`),[t,r]);(0,b.useEffect)(()=>{_&&g(e=>new Set([...e,..._.split(`\0`)]))},[_]);let v=(0,b.useMemo)(()=>BKe(t,p),[t,p]),y=(0,b.useMemo)(()=>p?new Set(D6(v)):null,[p,v]),x=(0,b.useMemo)(()=>{if(!p)return n;let e=p.toLowerCase();return n.filter(t=>t.name.toLowerCase().includes(e)||t.url.toLowerCase().includes(e))},[n,p]),S=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=(0,b.useMemo)(()=>{let e=r===null?void 0:E6(t,r);if(!e?.sourcePath)return;let[n]=H.splitModuleFilePathAndModulePath(e.sourcePath);return{moduleFilePath:n,urlPath:e.urlPath}},[t,r]),[w,T]=(0,b.useState)(null),E=(0,b.useCallback)((e,t)=>{T(null),o(e,t)},[o]),D=(e,t)=>{let n=e.children??[],a=n.length>0,o=y?y.has(e.id):h.has(e.id),s=o?e.errorCount:A6(e),c=o?e.hasDraft:j6(e);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_C,{depth:t,selected:r===e.id,title:e.urlPath,onClick:()=>{i(e),a&&!y&&S(e.id)},leading:a?(0,Y.jsx)(`span`,{role:`presentation`,onClick:t=>{t.stopPropagation(),S(e.id)},className:`text-fg-secondary-alt`,children:o?(0,Y.jsx)(Iv,{size:13}):(0,Y.jsx)(Rv,{size:13})}):t===0?(0,Y.jsx)(ey,{size:13,className:`text-fg-secondary-alt`}):(0,Y.jsx)(`span`,{className:`w-3.5`}),label:e.name,errorCount:s,hasDraft:c}),o&&a&&n.map(e=>D(e,t+1))]},e.id)};return(0,Y.jsx)(pC,{side:`left`,width:300,title:`Pages`,mobileVariant:`sheet`,breakpoint:e,onClose:c,subheader:l,headerAction:s?(0,Y.jsx)(zKe,{routes:s.routes,currentPage:C,isOpen:w===T6,onOpenChange:e=>T(e?T6:null),onSubmit:E}):void 0,sticky:u||d?void 0:(0,Y.jsx)(gC,{value:p,onChange:m,placeholder:`Filter pages…`}),children:u?(0,Y.jsx)(vC,{rows:12}):d?(0,Y.jsx)(yC,{message:d,onRetry:f}):(0,Y.jsxs)(`div`,{className:`pb-3`,children:[(0,Y.jsxs)(mC,{className:`pt-3`,children:[`Pages`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal normal-case tracking-normal text-fg-secondary-alt`,children:O6(v)})]}),v.length===0?(0,Y.jsx)(hC,{children:p?`No pages match this filter.`:`No pages yet.`}):v.map(e=>D(e,0)),(0,Y.jsxs)(mC,{children:[`External pages`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal normal-case tracking-normal text-fg-secondary-alt`,children:x.length})]}),x.length===0?(0,Y.jsx)(hC,{children:p?`No external pages match this filter.`:`No external pages yet.`}):x.map(e=>(0,Y.jsx)(_C,{selected:r===e.id,title:e.url,onClick:()=>a(e),leading:(0,Y.jsx)(Zv,{size:12,className:`text-fg-secondary-alt`}),label:e.name,errorCount:e.errorCount},e.id))]})})}function HKe(e){if(e.length===0)return{state:`none`};let t=e.filter(M6);if(t.length>0)return{state:`building`,count:t.length};let n=e[0];return N6(n)?{state:`failed`}:{state:`live`}}function M6(e){return e.isLive?!1:e.state===`created`||e.state===`pending`}function N6(e){return e.isLive?!1:e.state===`failure`||e.state===`error`}var UKe=5e3;function WKe({deployments:e,open:t,onOpenChange:n,onDismiss:r,autoClose:i=!1}){let a=HKe(e),o=(0,b.useRef)(null),[s,c]=(0,b.useState)(!1),l=t&&i&&!s&&a.state===`live`;return(0,b.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>n(!1),UKe);return()=>clearTimeout(e)},[l,n]),(0,b.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.target;t instanceof Node&&o.current&&!o.current.contains(t)&&n(!1)},r=e=>{e.key===`Escape`&&n(!1)},i=o.current?.getRootNode()??document;return i.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,r),()=>{i.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,Y.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-label":`Deployments: ${P6(a)}`,onClick:()=>n(!t),className:X(`inline-flex items-center gap-1.5 rounded px-1 -mx-1 hover:text-fg-primary`,a.state===`failed`&&`text-fg-error-on-surface`),children:[(0,Y.jsx)(GKe,{summary:a}),P6(a),(0,Y.jsx)(Lie,{size:12,className:X(`text-fg-secondary-alt transition-transform`,t&&`rotate-180`)})]}),t&&(0,Y.jsx)(KKe,{deployments:e,onDismiss:r,onClose:()=>n(!1),onReadingChange:c})]})}function P6(e){switch(e.state){case`building`:return e.count>1?`Building ${e.count} publishes`:`Building`;case`failed`:return`Build failed`;case`live`:return`Deployed`;case`none`:return`No deploys`}}function GKe({summary:e}){return e.state===`building`?(0,Y.jsx)(hy,{size:13,className:`animate-spin`}):e.state===`failed`?(0,Y.jsx)(Bv,{size:13}):e.state===`live`?(0,Y.jsx)(Fv,{size:13,className:`text-fg-secondary-alt`}):(0,Y.jsx)(ky,{size:13,className:`text-fg-secondary-alt`})}function KKe({deployments:e,onDismiss:t,onClose:n,onReadingChange:r}){return(0,Y.jsxs)(`div`,{role:`dialog`,"aria-label":`Deployments`,onPointerEnter:()=>r?.(!0),onPointerLeave:()=>r?.(!1),className:X(`absolute bottom-full right-0 mb-2 w-80 rounded-lg overflow-hidden`,`bg-bg-float border border-border-float shadow-xl`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 h-9 border-b border-border-float`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-primary`,children:`Deployments`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Close deployments`,onClick:n,className:`text-fg-secondary-alt hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:14})})]}),(0,Y.jsx)(F6,{deployments:e,onDismiss:t})]})}function F6({deployments:e,onDismiss:t}){return e.length===0?(0,Y.jsx)(`p`,{className:`px-3 py-4 text-xs text-fg-secondary-alt`,children:`Nothing published yet. Publishing sends your changes to the site and the build shows up here.`}):(0,Y.jsx)(`ul`,{className:`max-h-64 overflow-y-auto scrollbar-slim`,children:e.map(e=>(0,Y.jsx)(qKe,{deployment:e,onDismiss:()=>t(e.commitSha)},e.commitSha))})}function qKe({deployment:e,onDismiss:t}){let n=M6(e),r=N6(e);return(0,Y.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2.5 border-b border-border-float last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`mt-0.5 shrink-0`,children:[n&&(0,Y.jsx)(hy,{size:13,className:`animate-spin text-fg-secondary`}),r&&(0,Y.jsx)(Bv,{size:13,className:`text-fg-error-on-surface`}),!n&&!r&&(0,Y.jsx)(`span`,{className:`block w-1.5 h-1.5 m-[3px] rounded-full bg-bg-brand-secondary`})]}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs text-fg-primary truncate`,children:e.message??e.commitSha.slice(0,7)}),(0,Y.jsxs)(`div`,{className:`text-[11px] text-fg-secondary-alt truncate`,children:[JKe(e),e.author?` · ${e.author}`:``,` ·`,` `,e.timestamp]})]}),!n&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Dismiss deployment`,onClick:t,className:`mt-0.5 shrink-0 text-fg-secondary-alt hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:13})})]})}function JKe(e){if(e.isLive)return`Live`;switch(e.state){case`created`:return`Queued`;case`pending`:return`Building`;case`failure`:case`error`:return`Build failed`;case`success`:return`Built`}}function YKe({breakpoint:e,user:t,accountError:n,theme:r,onThemeChange:i,admin:a,mode:o,autoSave:s,onAutoSaveChange:c,branch:l,deployments:u,onDismissDeployment:d,onSignOut:f,onClose:p,navSwitcher:m}){return(0,Y.jsx)(pC,{side:`left`,width:300,title:`Settings`,mobileVariant:`sheet`,breakpoint:e,onClose:p,subheader:m,children:(0,Y.jsxs)(`div`,{className:`pb-4`,children:[n&&(0,Y.jsx)(gKe,{error:n}),t&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-3`,children:[(0,Y.jsx)(p6,{initials:t.initials}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium truncate`,children:t.name}),t.email&&(0,Y.jsx)(`div`,{className:`text-[0.6875rem] text-fg-secondary-alt truncate`,children:t.email})]})]}),(0,Y.jsx)(mC,{children:`Appearance`}),(0,Y.jsx)(`div`,{className:`px-4 pt-1`,children:(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":`Theme`,className:`flex p-0.5 rounded-md bg-bg-float-raised`,children:[`dark`,`light`].map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r===e,onClick:()=>i(e),className:X(`flex-1 inline-flex items-center justify-center gap-1.5 h-7 rounded text-xs capitalize`,r===e?`bg-bg-float text-fg-primary shadow-sm`:`text-fg-secondary hover:text-fg-primary`),children:[e===`dark`?(0,Y.jsx)(gae,{size:13}):(0,Y.jsx)(Mae,{size:13}),e]},e))})}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(mC,{divided:!0,children:`Project`}),(0,Y.jsxs)(`div`,{className:`px-4 pt-1 space-y-1.5`,children:[(0,Y.jsx)(I6,{href:a.project,icon:wae,label:`Administer project`,description:`Settings, API keys and versions in Val Build.`}),(0,Y.jsx)(I6,{href:a.members,icon:Vae,label:`Manage members`,description:`Who can edit this project's content.`})]})]}),(0,Y.jsx)(mC,{divided:!0,children:`Workspace`}),(0,Y.jsxs)(`div`,{className:`px-4 pt-1 space-y-2.5`,children:[o===`fs`&&(0,Y.jsx)(XKe,{label:`Auto save`,description:`Write changes to the working tree on a pause in typing.`,checked:s,onChange:c}),l&&(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-fg-secondary`,children:`Branch`}),(0,Y.jsx)(`span`,{className:`font-mono text-fg-primary`,children:l})]})]}),u!==void 0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(mC,{divided:!0,children:`Deployments`}),(0,Y.jsx)(`div`,{className:`pt-1`,children:(0,Y.jsx)(F6,{deployments:u,onDismiss:d??(()=>void 0)})})]}),f&&(0,Y.jsx)(`div`,{className:`px-4 pt-4`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:f,className:`inline-flex items-center gap-1.5 h-8 px-2.5 rounded-md text-xs text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(fae,{size:13}),`Sign out`]})})]})})}function I6({href:e,icon:t,label:n,description:r}){return(0,Y.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-start gap-2 -mx-2 px-2 py-1.5 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:[(0,Y.jsx)(t,{size:13,className:`mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary`,children:n}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:r})]}),(0,Y.jsx)(Zv,{size:11,className:`mt-0.5 shrink-0`})]})}function XKe({label:e,description:t,checked:n,onChange:r}){return(0,Y.jsxs)(`label`,{className:`flex gap-2.5 cursor-pointer`,children:[(0,Y.jsx)(UT,{checked:n,onCheckedChange:e=>r(e===!0),className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary`,children:e}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:t})]})]})}function ZKe({breakpoint:e,saveState:t,mode:n,autoSave:r,onAutoSaveChange:i,branch:a,deployments:o,deploymentsOpen:s=!1,onDeploymentsOpenChange:c,deploymentsAutoOpened:l=!1,onDismissDeployment:u}){return(0,Y.jsxs)(`footer`,{className:X(`absolute z-full bottom-3 right-3 h-9 flex items-center gap-3 px-3 rounded-lg`,`bg-bg-float border border-border-float shadow-sm text-xs text-fg-secondary`,e===`desktop`?`left-[4.75rem]`:`left-3`),children:[n===`fs`&&(0,Y.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,Y.jsx)(UT,{checked:r,onCheckedChange:e=>i(e===!0),className:`w-3.5 h-3.5`}),`Auto save`,(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`span`,{className:`hidden lg:inline text-fg-secondary-alt`,children:(0,Y.jsx)(cy,{size:12})})}),(0,Y.jsx)(Xg,{children:`Changes are written to your working tree on a pause in typing.`})]})]}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(L6,{}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-mono`,children:[(0,Y.jsx)($ie,{size:13,className:`text-fg-secondary-alt`}),a]})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[n===`http`&&o!==void 0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(WKe,{deployments:o,open:s,onOpenChange:c??(()=>void 0),onDismiss:u??(()=>void 0),autoClose:l}),(0,Y.jsx)(L6,{})]}),n===`fs`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(Iae,{size:13,className:`text-fg-secondary-alt`}),`Dev mode`]}),(0,Y.jsx)(L6,{})]}),(0,Y.jsx)(QKe,{saveState:t,breakpoint:e})]})]})}function L6(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-px h-4 bg-border-float`})}function QKe({saveState:e,breakpoint:t}){return e===`saving`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(Vie,{size:13,className:`text-fg-secondary-alt animate-pulse`}),`Saving…`]}):e===`error`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-fg-error-on-surface`,children:[(0,Y.jsx)(zie,{size:13}),`Could not save`]}):(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-bg-brand-secondary`}),t===`tablet`?`Saved locally`:`All changes saved locally`]})}function $Ke({breakpoint:e,activity:t=[],validationErrors:n=[],onSelectValidationError:r,onNewPage:i,onUploadMedia:a,onOpenAI:o,destinations:s,onCompare:c,reviewCount:l,onDiscardAll:u,discardAllDescription:d,portalContainer:f,pendingChanges:p=0,onSelectActivity:m,onClose:h}){let g=e=>s===void 0||s.includes(e);return(0,Y.jsx)(pC,{side:`right`,width:260,title:`Quick actions`,mobileVariant:`bottom-sheet`,breakpoint:e,onClose:h,children:(0,Y.jsxs)(`div`,{className:`pb-4`,children:[n.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(mC,{className:`pt-3 text-fg-error-on-surface`,children:[`Validation errors`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal normal-case tracking-normal tabular-nums`,children:n.reduce((e,t)=>e+t.count,0)})]}),(0,Y.jsx)(`ul`,{className:`px-3 pt-0.5`,children:n.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r?.(e),className:`flex gap-2 w-full px-1.5 py-1.5 rounded-md text-left hover:bg-bg-float-raised`,children:[(0,Y.jsx)(Ly,{size:13,className:`mt-0.5 shrink-0 text-fg-error-on-surface`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary truncate`,children:e.title}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt truncate`,children:e.detail})]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-[0.6875rem] tabular-nums text-fg-secondary-alt`,children:e.count})]})},e.id))}),(0,Y.jsx)(mC,{divided:!0,children:`Quick actions`})]}),(0,Y.jsxs)(`div`,{className:`px-3 pt-3 space-y-0.5`,children:[c&&p>0&&e===`mobile`&&(0,Y.jsx)(R6,{icon:ny,label:l===void 0||l>0?`Review ${l??p} ${(l??p)===1?`change`:`changes`}`:`Review changes`,onClick:c}),u&&p>0&&(0,Y.jsx)(eqe,{count:p,description:d,onConfirm:u,portalContainer:f}),g(`pages`)&&(0,Y.jsx)(R6,{icon:Xie,label:`New page`,onClick:i}),g(`media`)&&(0,Y.jsx)(R6,{icon:sae,label:`Upload media`,onClick:a})]}),(0,Y.jsx)(mC,{divided:!0,children:`Recent activity`}),t.length===0?(0,Y.jsx)(hC,{children:`No recent activity. Your changes will show up here.`}):(0,Y.jsx)(`ul`,{className:`px-3 pt-0.5`,children:t.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>m(e),className:`flex gap-2 w-full px-1.5 py-1.5 rounded-md text-left hover:bg-bg-float-raised`,children:[(0,Y.jsx)(Wv,{size:13,className:`mt-0.5 shrink-0 text-fg-secondary-alt`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary truncate`,children:e.title}),(0,Y.jsxs)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:[e.author?`${e.author} · `:``,e.timestamp]})]})]})},e.id))}),o&&(0,Y.jsx)(`div`,{className:`px-3 pt-4`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:o,className:`flex items-center gap-2 w-full h-8 px-2 rounded-md text-xs text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(Ny,{size:14}),`Ask the assistant`]})})]})})}function eqe({count:e,description:t,onConfirm:n,portalContainer:r}){let[i,a]=(0,b.useState)(!1),o=`Discard ${e} ${e===1?`change`:`changes`}`;return(0,Y.jsxs)(SD,{open:i,onOpenChange:a,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full h-8 px-2 rounded-md text-xs text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:[(0,Y.jsx)(zy,{size:14,className:`text-fg-secondary-alt`}),o]})}),(0,Y.jsxs)(wD,{container:r,align:`start`,className:`w-64 flex flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-xs font-semibold text-fg-primary`,children:`${o}?`}),t!==void 0&&(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-secondary`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`sm`,onClick:()=>a(!1),children:`Cancel`}),(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{a(!1),n()},children:`Discard ${e}`})]})]})]})}function R6({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 w-full h-8 px-2 rounded-md text-xs text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(e,{size:14,className:`text-fg-secondary-alt`}),t]})}function z6({isOpen:e,children:t,duration:n=.3,className:r}){return(0,Y.jsx)(`div`,{style:{transition:`grid-template-rows ${n}s`},className:(0,AC.default)(`grid overflow-hidden`,r,{"grid-rows-[0fr]":!e,"grid-rows-[1fr]":e}),children:(0,Y.jsx)(`div`,{style:{transition:`visibility ${n}s`},className:(0,AC.default)(`min-h-0`,{visible:e,invisible:!e}),children:t})})}function tqe(e){return e.length===0?`/`:`/`+e.map(e=>{if(e.type===`literal`)return e.name;let t=e.type===`string-param`?e.paramName:`...${e.paramName}`;return e.optional?`[[${t}]]`:`[${t}]`}).join(`/`)}function nqe(e,t){let n=e=>({id:e.sourcePath??e.urlPath,name:e.name,urlPath:e.urlPath,sourcePath:e.sourcePath,errorCount:e.errors?.ownCount,hasDraft:e.moduleFilePath?t.has(e.moduleFilePath):void 0,isTracked:e.sourcePath!==void 0,children:e.children.map(n)});return e.sourcePath===void 0?e.children.map(n):[n(e)]}function rqe(e){return e?Object.entries(e).map(([e,t])=>({id:t,name:mqe(e),url:e,sourcePath:t})):[]}function iqe(e,t){let n=[],r=e=>{if(e.isDirectory){e.children.forEach(r);return}n.push({id:e.fullPath,name:G6(e.name),moduleFilePath:e.fullPath,errorCount:e.errors?.ownCount,hasDraft:t.has(e.fullPath)})};return r(e),n}function aqe(e){if(!e)return[];let t=new Map;for(let n of Object.keys(e)){let[e]=n.split(`?`);t.set(e,(t.get(e)??0)+1)}return Array.from(t.entries()).map(([e,t])=>({id:e,title:G6(e),detail:e,count:t})).sort((e,t)=>t.count-e.count)}var oqe=8;function sqe(e,t){return e.slice(0,oqe).map((e,n)=>({id:`${e.moduleFilePath}?${e.patchPath.join(`/`)}-${n}`,sourcePath:H.joinModuleFilePathAndModulePath(e.moduleFilePath,H.patchPathToModulePath(e.patchPath)),title:[G6(e.moduleFilePath),...e.patchPath].join(` › `),timestamp:H6(e.lastUpdated,t),author:e.lastUpdatedBy??void 0}))}var cqe=10;function lqe(e,t,n,r){return e.slice(0,cqe).map(e=>({commitSha:e.commitSha,state:e.deploymentState,message:e.commitMessage,author:e.creator?n[e.creator]?.fullName:void 0,timestamp:H6(e.updatedAt,r),isLive:t.has(e.commitSha)}))}var uqe=60,B6=3600,V6=24*B6;function H6(e,t){let n=new Date(e).getTime();if(Number.isNaN(n))return e;let r=Math.round((t-n)/1e3);return r<0||r<45?`just now`:r<B6?U6(Math.round(r/uqe),`minute`):r<V6?U6(Math.round(r/B6),`hour`):U6(Math.round(r/V6),`day`)}function U6(e,t){return`${e} ${t}${e===1?``:`s`} ago`}function dqe(e){if(e)return Object.entries(e).map(([e,t])=>({ref:e,sourcePath:t})).sort((e,t)=>W6(e.ref).localeCompare(W6(t.ref)))}function W6(e){let t=e.split(`/`);return t[t.length-1]||e}function fqe(e){return e?Object.keys(e).length:0}function pqe(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function G6(e){return(e.split(`/`).pop()??e).replace(/\.val\.(ts|js)$/,``)}function mqe(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}function hqe(e){if(!e?.project||!e.appHost)return;let t=e.project.split(`/`);if(t.length!==2||!t[0]||!t[1])return;let[n,r]=t,i=e.appHost.replace(/\/+$/,``);return{project:`${i}/~/${encodeURIComponent(n)}/${encodeURIComponent(r)}`,members:`${i}/manage-members/${encodeURIComponent(n)}`}}function gqe(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function _qe(e,t){if(t)return[`pages`,`media`,`data`];let n=[];return e.hasRouters&&n.push(`pages`),e.media.length>0&&n.push(`media`),e.data.length>0&&n.push(`data`),n}function vqe(e){let t=new Map,n=[],r=e=>{if((e.sourcePath||e.children.length===0)&&n.push(e.urlPath),e.canAddChild&&e.moduleFilePath&&e.routePattern){let n=tqe(e.routePattern),r=`${e.moduleFilePath}::${n}`;t.has(r)||t.set(r,{moduleFilePath:e.moduleFilePath,routePattern:e.routePattern,patternString:n,existingKeys:[],keyDescription:e.keyDescription})}for(let t of e.children)r(t)};return r(e),{routes:Array.from(t.values()).map(e=>({...e,existingKeys:n})),existingUrls:n}}function K6(e){return e<768?`mobile`:e<1200?`tablet`:`desktop`}function yqe(){let[e,t]=(0,b.useState)(()=>typeof window>`u`?`desktop`:K6(window.innerWidth));return(0,b.useEffect)(()=>{let e=()=>t(K6(window.innerWidth));return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var bqe=()=>({total:0,settled:0,unfetched:[],unapplied:[],failed:[],statSeen:!0}),xqe=5;function Sqe({data:e,initialPanel:t=null,initialSelectionId:n=null,initialSearchOpen:r=!1,theme:i,onThemeChange:a,mode:o,saveState:s=`saved`,autoSave:c=!1,onAutoSaveChange:l=()=>void 0,isDevMode:u=!0,pendingChanges:d=12,reviewCount:f,publishState:p=`idle`,isLoading:m=!1,loadError:h,initialDeploymentsOpen:g=!1,canvasPage:_,renderCanvas:v,canvasPaths:y,onSelectCanvasPath:x,selectedCanvasPath:S,canvasRoute:C,onCanvasRouteChange:w,canvasRoutes:T,initialCanvasTransform:E,onViewStateChange:D,initialCanvasOpen:O=!1,initialCanvasView:k=`normal`,restoreViewState:A,skipTransition:j,selectionId:M,onSelectionChange:N,renderEditor:P,editorOverride:F,onPublish:I,publishSlot:L,onPreview:R,previewHref:ee,onSignOut:te,accountError:ne,aiEnabled:re=!1,aiSlot:ie,onMentionField:ae,pendingChangesLoaded:oe=!0,pendingChangesProgress:se,pendingChangesError:ce=null,onSelectValidationError:le,onSelectActivity:ue,onNewPage:de,onUploadMedia:fe,onCompare:pe,onDiscardAll:me,discardAllDescription:he,portalContainer:ge,getMediaFileUrl:_e,searchContentResults:ve,isSearchingContent:ye,onSearchQueryChange:be,onOpenSearchResult:xe}){let Se=yqe(),[Ce,we]=(0,b.useState)(t),[z,B]=(0,b.useState)(e.notifications??[]),Te=M!==void 0,[Ee,V]=(0,b.useState)(()=>n?Z6(e,n):null),De=(0,b.useMemo)(()=>M?Z6(e,M):null,[M,e]),Oe=Te?De:Ee,[ke,Ae]=(0,b.useState)(r),[je,Me]=(0,b.useState)(O),[Ne,Pe]=(0,b.useState)(k),[Fe,Ie]=(0,b.useState)(O?`canvas`:`editor`),[Le,Re]=(0,b.useState)(E??null),ze=A?.epoch,Be=(0,b.useRef)(A);Be.current=A,(0,b.useEffect)(()=>{let e=Be.current;e!==void 0&&(we(e.panel),Me(e.canvasOpen),Pe(e.canvasView),Ie(e.canvasOpen?`canvas`:`editor`))},[ze]),(0,b.useEffect)(()=>{D?.({panel:Ce,canvasOpen:je,canvasView:Ne,canvasTransform:Le})},[D,Ce,je,Ne,Le]);let[Ve,He]=(0,b.useState)(g),[Ue,We]=(0,b.useState)(!1),Ge=(0,b.useCallback)(e=>{He(e),We(!1)},[]),[Ke,qe]=(0,b.useState)(()=>new Set),Je=(0,b.useCallback)(e=>{qe(t=>new Set(t).add(e))},[]),Ye=(0,b.useMemo)(()=>e.deployments?.filter(e=>!Ke.has(e.commitSha)),[e.deployments,Ke]),Xe=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(e.deployments===void 0)return;let t=new Set(e.deployments.map(e=>e.commitSha)),n=Xe.current;Xe.current=t,n!==null&&e.deployments.some(e=>!n.has(e.commitSha))&&(He(!0),We(!0))},[e.deployments]);let Ze=(0,b.useCallback)(()=>Ae(!0),[]);hKe(Ze);let Qe=(0,b.useMemo)(()=>pKe(e),[e]),$e=(0,b.useMemo)(()=>(e.activity??[]).slice(0,xqe).map(e=>({id:e.sourcePath,kind:`recent`,label:e.title,detail:e.author?`${e.timestamp} · ${e.author}`:e.timestamp})),[e.activity]),et=(0,b.useMemo)(()=>_qe(e,m),[m,e]);(0,b.useEffect)(()=>{Ce!==null&&(Ce===`pages`||Ce===`media`||Ce===`data`)&&!et.includes(Ce)&&we(null)},[Ce,et]),(0,b.useEffect)(()=>{Ce===`ai`&&!re&&we(null)},[Ce,re]);let tt=(0,b.useMemo)(()=>e.validationErrors.reduce((e,t)=>e+t.count,0),[e.validationErrors]),nt=(0,b.useMemo)(()=>z.filter(e=>e.unread).length,[z]),rt=v!==void 0||_!==void 0,it=(0,b.useCallback)(()=>{if(Se!==`mobile`){Me(e=>!e);return}if(!je){Me(!0),Ie(`canvas`);return}Ie(e=>e===`canvas`?`editor`:`canvas`)},[Se,je]),at=(0,b.useCallback)(()=>{Me(!1),Pe(`normal`),Ie(`editor`)},[]),ot=(0,b.useCallback)(e=>{we(`ai`),ae?.(e)},[ae]),st=(0,b.useMemo)(()=>cKe(y),[y]),ct=(0,b.useMemo)(()=>lKe(st),[st]),lt=(0,b.useRef)({canvasModules:ct,editedPath:S??null});lt.current={canvasModules:ct,editedPath:S??null},(0,b.useEffect)(()=>{m||sKe({selectionKind:Oe?.kind??null,...lt.current})||(Me(!1),Pe(`normal`),Ie(`editor`))},[m,Oe?.kind]);let ut=(0,b.useCallback)(()=>we(null),[]),dt=(0,b.useCallback)(e=>{we(t=>t===e?null:e)},[]),ft=(0,b.useCallback)(e=>{Te||V(e),N?.(e),Se===`mobile`&&we(null)},[Se,Te,N]),pt=(0,b.useCallback)(t=>{let n=Z6(e,t.id);if(n){ft(n);return}xe?.(t)},[e,ft,xe]),mt=Se===`mobile`?(0,Y.jsx)(AKe,{openPanel:Ce,onSelect:we,destinations:et}):void 0;return(0,Y.jsxs)(`div`,{"data-mode":i,className:`relative w-full overflow-hidden bg-bg-canvas text-fg-primary font-sans`,style:{height:`100svh`},children:[(0,Y.jsx)(nKe,{breakpoint:Se,page:rt?_:void 0,renderCanvas:rt?v:void 0,canvasPaths:rt?y:void 0,onSelectCanvasPath:x,selectedCanvasPath:S,canvasRoute:rt?C:void 0,onCanvasRouteChange:w,canvasRoutes:T,initialTransform:E,onTransformChange:Re,isCanvasOpen:je&&rt,onCloseCanvas:at,view:Ne,onViewChange:Pe,pane:Fe,onPaneChange:Ie,isDevMode:u,onAttachToChat:re?ot:void 0,skipTransition:j,children:F||(Oe===null?(0,Y.jsx)(Jce,{}):(0,Y.jsx)(PKe,{ready:oe,progress:se??bqe,fetchError:ce,children:P?P(Oe):(0,Y.jsx)(Yce,{title:Oe.title,urlPath:Oe.urlPath,sourcePath:Oe.sourcePath,isDevMode:u,hasDraft:Oe.hasDraft})}))}),Se===`desktop`&&(0,Y.jsx)(_Ke,{openPanel:Ce,onSelect:dt,destinations:et,user:e.user,hasDraftChanges:d>0,accountError:ne,isLoading:m}),(0,Y.jsx)(EKe,{breakpoint:Se,projectName:e.projectName,projectHref:e.admin?.project,openPanel:Ce,onTogglePanel:dt,onOpenMenu:()=>we(et[0]??`settings`),onOpenSearch:Ze,unreadNotifications:e.notifications===void 0?void 0:nt,user:Se===`desktop`?void 0:e.user,accountError:Se===`desktop`?void 0:ne,isLoading:m,aiEnabled:re,onPreview:R??(()=>void 0),previewHref:ee,onToggleCanvas:rt?it:void 0,isCanvasOpen:je,onPublish:I??(()=>void 0),publishSlot:L,pendingChanges:d,onCompare:pe,reviewCount:f??d,publishState:p===`idle`&&tt>0?`blocked`:p}),Se===`mobile`?(0,Y.jsx)(jKe,{pendingChanges:d,onPreview:R??(()=>void 0),previewHref:ee,onToggleCanvas:rt?it:void 0,isCanvasOpen:je,canvasActionLabel:je?Fe===`canvas`?`Back to the editor`:`Back to the preview`:`Open the canvas`,onExitCanvas:je?at:void 0,onPublish:I??(()=>void 0),publishSlot:L,onOpenStatus:()=>we(`settings`),onOpenQuickActions:()=>we(`utility`)}):(0,Y.jsx)(ZKe,{breakpoint:Se,saveState:s,mode:o,autoSave:c,onAutoSaveChange:l,branch:e.branch,deployments:Ye,deploymentsOpen:Ve,onDeploymentsOpenChange:Ge,deploymentsAutoOpened:Ue,onDismissDeployment:Je}),Ce===`pages`&&(0,Y.jsx)(VKe,{breakpoint:Se,pages:e.pages,externalPages:e.externalPages,selectedId:Oe?.id??null,onSelectPage:e=>{let t=q6(e);t&&ft(t)},onSelectExternalPage:e=>{let t=J6(e);t&&ft(t)},onNewPage:de??(()=>void 0),newPage:de?e.newPage:void 0,onClose:ut,navSwitcher:mt,isLoading:m,loadError:h}),Ce===`media`&&(0,Y.jsx)(vKe,{breakpoint:Se,media:e.media,selectedId:Oe?.id??null,onSelect:e=>ft(Y6(e)),onSelectFile:(e,t)=>ft({kind:`media`,id:t.sourcePath,title:t.ref.split(`/`).pop()??t.ref,urlPath:aA(e.directory),sourcePath:t.sourcePath}),getFileUrl:_e,onUpload:fe,onClose:ut,navSwitcher:mt,isLoading:m,loadError:h}),Ce===`data`&&(0,Y.jsx)(Kce,{breakpoint:Se,data:e.data,selectedId:Oe?.id??null,onSelect:e=>ft(X6(e)),onClose:ut,navSwitcher:mt,isLoading:m,loadError:h}),Ce===`settings`&&(0,Y.jsx)(YKe,{breakpoint:Se,mode:o,user:e.user,accountError:ne,theme:i,onThemeChange:a,admin:e.admin,autoSave:c,onAutoSaveChange:l,branch:e.branch,deployments:o===`fs`?void 0:Ye,onDismissDeployment:Je,onSignOut:te,onClose:ut,navSwitcher:mt}),Ce===`utility`&&(0,Y.jsx)($Ke,{breakpoint:Se,activity:e.activity,validationErrors:e.validationErrors,onSelectValidationError:le??(()=>void 0),onNewPage:()=>we(`pages`),onUploadMedia:()=>we(`media`),destinations:et,onOpenAI:re?()=>we(`ai`):void 0,onCompare:pe,reviewCount:f??d,onDiscardAll:me,discardAllDescription:he,portalContainer:ge,pendingChanges:d,onSelectActivity:ue??(()=>void 0),onClose:ut}),re&&(0,Y.jsx)(Vce,{breakpoint:Se,hidden:Ce!==`ai`,onClose:ut,children:ie??(0,Y.jsx)(Cqe,{})}),Ce===`notifications`&&(0,Y.jsx)(RKe,{breakpoint:Se,notifications:z,onSelect:e=>B(t=>t.map(t=>t.id===e.id?{...t,unread:!1}:t)),onMarkAllRead:()=>B(e=>e.map(e=>({...e,unread:!1}))),onClose:ut}),ke&&(0,Y.jsx)(mKe,{results:Qe,contentResults:ve,recentResults:$e,isSearchingContent:ye,onQueryChange:be,onSelect:e=>{Ae(!1),pt(e)},onClose:()=>Ae(!1)})]})}function Cqe(){return(0,Y.jsx)(`p`,{className:`p-4 text-xs text-fg-secondary-alt`,children:`No assistant is configured for this project.`})}function q6(e){return e.sourcePath===void 0?null:{kind:`page`,id:e.id,title:e.name,urlPath:e.urlPath,sourcePath:e.sourcePath,hasDraft:e.hasDraft,isTracked:e.isTracked}}function J6(e){return e.sourcePath===void 0?null:{kind:`external`,id:e.id,title:e.name,urlPath:e.url,sourcePath:e.sourcePath}}function Y6(e){return{kind:`media`,id:e.id,title:e.name,urlPath:aA(e.directory),sourcePath:e.moduleFilePath}}function X6(e){return{kind:`data`,id:e.id,title:e.name,urlPath:e.moduleFilePath,sourcePath:e.moduleFilePath,hasDraft:e.hasDraft}}function Z6(e,t){let n=e=>{for(let r of e){if(r.id===t)return q6(r);let e=n(r.children??[]);if(e)return e}return null},r=n(e.pages);if(r)return r;let i=e.externalPages.find(e=>e.id===t);if(i)return J6(i);let a=e.media.find(e=>e.id===t);if(a)return Y6(a);let o=e.data.find(e=>e.id===t);return o?X6(o):null}var wqe=8e3;function Tqe({url:e,width:t,height:n,reloadKey:r,isPicking:i,highlightedPath:a,onElements:o,onPick:s,onPinch:c,onZoom:l,onRequestReload:u,onRefreshingChange:d}){let f=(0,b.useRef)(null),[p,m]=(0,b.useState)({status:`waiting`}),[h,g]=(0,b.useState)(!1),[_,v]=(0,b.useState)(0),y=(0,b.useRef)(null),x=(0,b.useMemo)(()=>yp(e),[e]),S=(0,b.useCallback)(e=>{f.current?.contentWindow?.postMessage(e,window.origin)},[]);(0,b.useEffect)(()=>{m({status:`waiting`}),d?.(!1)},[x,r,d]),(0,b.useEffect)(()=>{if(p.status!==`waiting`)return;let e=setTimeout(()=>m({status:`no-answer`}),wqe);return()=>clearTimeout(e)},[p.status,x,r]),(0,b.useEffect)(()=>{let e=e=>{if(e.source!==f.current?.contentWindow||!vp(e.data))return;let t=e.data;t.type===`ready`?(m({status:`ready`,draftMode:t.draftMode}),v(e=>e+1),g(!1)):t.type===`elements`?o?.(t.elements):t.type===`refreshing`?d?.(t.pending):t.type===`pinch`?c?.({phase:t.phase,span:t.span,center:t.center}):t.type===`zoom`?l?.(t.factor,t.center):(y.current=t.paths[0]??null,s?.(t.paths))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[o,s,c,l,d]),(0,b.useEffect)(()=>{S({val:_p,type:`setPicking`,picking:i})},[S,i,p.status]),(0,b.useEffect)(()=>{let e=a!==null&&a===y.current;y.current=null,S({val:_p,type:`highlight`,path:a,scrollIntoView:!e})},[S,a,p.status]);let C=(0,b.useCallback)(()=>{g(!0);let e=new URL(x,window.location.origin).toString(),t=`/api/val/enable?redirect_to=${encodeURIComponent(e)}`;f.current&&(f.current.src=t)},[x]),w=p.status===`ready`&&p.draftMode,T=(0,b.useCallback)((e,t)=>{S({val:_p,type:`sourceUpdate`,moduleFilePath:e,source:t})},[S]);Coe(w,T);let E=woe();(0,b.useEffect)(()=>{w&&(E(T),S({val:_p,type:`sourcesSynced`}))},[w,_,E,T,S]);let D=p.status===`ready`&&!p.draftMode||p.status===`no-answer`;return(0,Y.jsxs)(`div`,{style:{width:t,height:n},className:`relative bg-white`,children:[(0,Y.jsx)(`iframe`,{ref:f,src:x,title:`Preview of ${e}`,style:{width:t,height:n,border:`none`,display:`block`},referrerPolicy:`same-origin`},`${x}-${r}`),D&&(0,Y.jsx)(Eqe,{isEnabling:h,onEnable:C,onReload:u,unreachable:p.status===`no-answer`})]})}function Eqe({isEnabling:e,onEnable:t,onReload:n,unreachable:r}){return(0,Y.jsx)(`div`,{className:`absolute inset-0 grid place-items-center bg-bg-canvas/80 backdrop-blur-sm p-6`,children:(0,Y.jsxs)(`div`,{className:`max-w-sm rounded-lg border border-border-float bg-bg-float p-5 text-center shadow-lg`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium text-fg-primary`,children:r?`No answer from the page`:`Preview mode is off`}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-secondary`,children:r?`The page loaded but did not report back. It may be an older version of Val, preview mode may have been turned off elsewhere, or the app may not be wired up yet.`:`Without preview mode the canvas shows the published page, and nothing on it can be selected or edited.`}),r&&(0,Y.jsx)(Dqe,{}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center justify-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:t,disabled:e,className:X(`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium`,`bg-bg-brand-primary text-fg-brand-primary border border-border-brand-primary`,`hover:bg-bg-brand-primary-hover`,`disabled:bg-bg-disabled disabled:text-fg-disabled`),children:[e&&(0,Y.jsx)(hy,{size:13,className:`animate-spin`}),e?`Turning on…`:`Turn on preview mode`]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(bae,{size:13}),`Reload`]})]})]})})}function Dqe(){return(0,Y.jsxs)(`details`,{className:`group mt-3 text-left`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer list-none text-xs text-fg-secondary-alt hover:text-fg-primary [&::-webkit-details-marker]:hidden`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(Rv,{size:12,className:`transition-transform group-open:rotate-90`,"aria-hidden":!0}),`Setup instructions`]})}),(0,Y.jsxs)(`div`,{className:`mt-2 rounded-md border border-border-float bg-bg-secondary p-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-secondary`,children:`The canvas talks to the page through Val's provider. If it never answers, check that:`}),(0,Y.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-1.5 pl-4 text-xs leading-relaxed text-fg-secondary`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.6875rem] text-fg-primary`,children:`ValProvider`}),` `,`is in the ROOT layout —`,` `,(0,Y.jsx)(`code`,{className:`font-mono`,children:`app/layout.tsx`}),` — and therefore above every page it should preview. A provider inside a route group does not cover the pages outside it.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.6875rem] text-fg-primary`,children:`ValModulesClient`}),` `,`is rendered inside it, so the editor can read your schemas.`]}),(0,Y.jsxs)(`li`,{children:[`The API route exists at`,` `,(0,Y.jsx)(`code`,{className:`font-mono`,children:`app/(val)/api/val/[[...val]]/route.ts`}),`, since preview mode is turned on through it.`]}),(0,Y.jsx)(`li`,{children:`The page is not served from a different origin than the studio: the canvas and the page have to be able to talk to each other.`}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`font-mono`,children:`@valbuild/next`}),` and`,` `,(0,Y.jsx)(`code`,{className:`font-mono`,children:`@valbuild/core`}),` are on the same version, in the app and in the editor.`]})]}),(0,Y.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-secondary-alt`,children:[`The setup guide has the whole layout:`,` `,(0,Y.jsx)(`a`,{href:`https://github.com/valbuild/val/blob/main/packages/next/MANUAL_CONFIGURATION.md`,target:`_blank`,rel:`noopener noreferrer`,className:`underline hover:text-fg-primary`,children:`manual configuration`}),`.`]})]})]})}function Oqe(e){return e.length===0||e.includes(`/`)?`/`:e[0]}function kqe(e){let t={"/":{name:`/`,fullPath:`/`,isDirectory:!0,children:[]}};for(let n of e){let e=n.split(`/`);if(e[0]!==``)throw Error(`Expected path to start with '/'`);for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(`/`),i=[r,e[n]].join(`/`),a=e[n];if(!a)throw Error(`Expected name to be non-empty`);if(!t[i]){let o={name:a,fullPath:i,children:[]};n<e.length-1&&(o.isDirectory=!0),t[i]=o,t[r||`/`].children.push(t[i])}}}return t[`/`]}function Aqe(){let e=wb();return(0,b.useMemo)(()=>{if(e.status===`success`){let t=[],n={};for(let r in e.data){let i=r,a=e.data[i];a.type===`record`&&a.router?(n[a.router]=n[a.router]||[],n[a.router].push(i)):t.push(i)}return{status:e.status,data:{root:kqe(t),routers:n}}}return e},[e])}function jqe(e){return e?.type===`record`&&!!e.mediaType}function Mqe(e,t){let n=[];for(let r in e){let i=r,a=e[i];jqe(a)&&n.push({moduleFilePath:i,directory:a.directory??i,mediaType:a.mediaType,errors:t(i)})}return n.sort((e,t)=>e.directory.localeCompare(t.directory))}function Q6(e,t,n){let r=e.get(t);if(r){r.ownCount+=n.length,r.firstMessage||=n[0]?.message;return}e.set(t,{ownCount:n.length,firstMessage:n[0]?.message})}function Nqe(e){let t=new Map,n=new Map;for(let r in e){let i=e[r];if(!i||i.length===0)continue;let[a,o]=H.splitModuleFilePathAndModulePath(r);Q6(n,a,i);let s=H.splitModulePath(o),c=s.length>0?H.createValPathOfItem(a,s[0]):a;c&&Q6(t,c,i)}return{byEntry:t,byModule:n}}function Pqe(e,t){return e.byEntry.get(t)}function $6(e,t){return e.byModule.get(t)}function e8(e,t,n){let r=!!e.pattern?.includes(`[`),i=r&&e.pattern?np(e.pattern):void 0,a=r?e.children.map(e=>`/`+e.name):void 0,o=e.sourcePath,s=o?Pqe(t,o):void 0,c=e.moduleFilePath,l=r&&c?n?.[c]:void 0,u=l?.type===`record`?l.key?.description:void 0,d=(e.type===`leaf`?e.fullPath:e.page?.fullPath)||e.pattern||`/`;return{name:e.name,urlPath:d,sourcePath:o,moduleFilePath:c,canAddChild:r,routePattern:i,existingKeys:a,keyDescription:u,errors:s,children:e.children.map(e=>e8(e,t,n))}}function t8(e,t,n){let r=!!e.isDirectory,i=!r&&e.fullPath?$6(t,e.fullPath):void 0;return{name:e.name,fullPath:e.fullPath,isDirectory:r,errors:i,children:e.children.filter(e=>!n.has(e.fullPath)).map(e=>t8(e,t,n))}}function Fqe(){let e=Aqe(),t=(0,b.useMemo)(()=>e.status===`success`&&e.data.routers[`next-app-router`]||[],[e]),n=cC(t,`record`),r=lC(),i=Fb(),a=wb();return(0,b.useMemo)(()=>{if(e.status!==`success`)return e;let o=Nqe(i??{}),s={hasRouters:Object.keys(e.data.routers).filter(t=>(e.data.routers[t]??[]).length>0).length>0};if(t.length>0){if(r.status===`success`&&r.data&&n.status===`success`&&n.data){let e=[];for(let t of n.data||[])for(let n in t){let[r]=H.splitModuleFilePathAndModulePath(t[n]);e.push({urlPath:n,moduleFilePath:r})}s.sitemap=e8(ep(r.data,e),o,a.status===`success`?a.data:void 0)}else if(r.status===`loading`||n.status===`loading`)return{status:`loading`}}let c=a.status===`success`?Mqe(a.data,e=>$6(o,e)):[];c.length>0&&(s.media=c);let l=new Set(c.map(e=>e.moduleFilePath));if(e.data.root&&e.data.root.children.length>0){let t=t8(e.data.root,o,l);t.children.length>0&&(s.explorer=t)}let u=e.data.routers[`external-url-router`];return u&&u.length>0&&(s.external={moduleFilePath:u[0]}),{status:`success`,data:s}},[e,t,r,n,i,a])}function Iqe(){let e=Fqe(),t=bb(),n=tC(),r=Fb(),i=US(),a=YS(),o=GS(),{deployments:s,observedCommitShas:c}=HS(),l=sC(),u=(0,b.useMemo)(()=>lqe(s,c,l,Date.now()),[s,c,l]),d=e.status===`success`?e.data:void 0,f=d?.external?.moduleFilePath,p=(0,b.useMemo)(()=>(d?.media??[]).map(e=>e.moduleFilePath),[d?.media]),m=cC((0,b.useMemo)(()=>(f?[f]:[]).concat(p),[f,p]),`record`),h=(0,b.useMemo)(()=>i.status===`success`?new Set(i.data.map(e=>e.moduleFilePath)):new Set,[i]);return(0,b.useMemo)(()=>{if(e.status===`loading`)return{status:`loading`};if(e.status===`error`)return{status:`error`,error:e.error};let s=d?.sitemap?vqe(d.sitemap):null,c=s&&s.routes.length>0?{routes:s.routes}:void 0,l=m.status===`success`?m.data:null,p=f?l?.[0]:void 0,g=l?.slice(+!!f)??[];return{status:`success`,data:{projectName:t?.project??`Val`,admin:hqe(t),branch:t?.gitBranch,hasRouters:d?.hasRouters??!1,pages:d?.sitemap?nqe(d.sitemap,h):[],newPage:c,externalPages:rqe(p),media:(d?.media??[]).map((e,t)=>({id:e.moduleFilePath,name:pqe(e.directory),directory:e.directory,moduleFilePath:e.moduleFilePath,mediaType:e.mediaType,itemCount:fqe(g[t]),files:dqe(g[t])})),data:d?.explorer?iqe(d.explorer,h):[],validationErrors:aqe(r),activity:i.status===`success`?sqe(i.data,Date.now()):void 0,pendingChanges:a.length-o.size,deployments:u,user:n?{name:n.fullName,email:n.email,initials:gqe(n.fullName)}:void 0}}},[e,d,m,f,t,n,r,i,h,a,o,u])}function n8(e,t){let n=e===1?`1 unpublished change in this project goes away`:`All ${e} unpublished changes in this project go away`;if(t.length>0){let e=t.slice(0,2),r=t.length-e.length;return`${n} — including changes made by ${r>0?`${e.join(`, `)} and ${r} ${r===1?`other`:`others`}`:e.join(` and `)}. This cannot be undone.`}return`${n}. This cannot be undone.`}var Lqe=20;function Rqe(e){let t=nb(),n=Db(),r=e.trim(),i=r!==``,a=PD(i),[o,s]=(0,b.useState)([]),[c,l]=(0,b.useState)(!1),u=a.status===`loading`?a.percentage:a.status;return(0,b.useEffect)(()=>{if(t===null||!i){s([]),l(!1);return}let e=!1;return l(!0),t.system.search(r,Lqe).then(t=>{e||s(t.status===`no-index`?[]:t.results)}).catch(()=>{e||s([])}).finally(()=>{e||l(!1)}),()=>{e=!0}},[t,r,i,u]),{results:(0,b.useMemo)(()=>{let e=new Set,t=[];for(let r of o){let i=n(r.path)||r.path;if(e.has(i))continue;e.add(i);let[a]=H.splitModuleFilePathAndModulePath(r.path);t.push({id:r.path,kind:`content`,label:r.label,detail:a})}return t},[o,n]),isSearching:i&&(c||a.status===`loading`)}}var zqe=[`pages`,`media`,`data`,`settings`,`utility`,`ai`,`notifications`],r8={panel:`panel`,canvasOpen:`canvas`,canvasRoute:`canvas-route`,canvasView:`canvas-view`,canvasTransform:`canvas-at`};function i8(e){let t=new URLSearchParams(e),n=t.get(r8.panel),r=t.get(r8.canvasView);return{panel:zqe.find(e=>e===n)??null,canvasOpen:t.get(r8.canvasOpen)===`1`,canvasRoute:t.get(r8.canvasRoute),canvasView:r===`fields`?`fields`:`normal`,canvasTransform:Bqe(t.get(r8.canvasTransform))}}function Bqe(e){if(e===null)return null;let t=e.split(`,`).map(e=>Number.parseFloat(e));if(t.length!==3||t.some(e=>!Number.isFinite(e)))return null;let[n,r,i]=t;return n<=0?null:{scale:n,x:r,y:i}}function Vqe(e){return[e.scale.toFixed(2),Math.round(e.x),Math.round(e.y)].join(`,`)}function Hqe(e,t){let n=new URLSearchParams(e),r=(e,t)=>{t===null?n.delete(e):n.set(e,t)};r(r8.panel,t.panel),r(r8.canvasOpen,t.canvasOpen?`1`:null),r(r8.canvasRoute,t.canvasRoute),r(r8.canvasView,t.canvasView===`fields`?`fields`:null),r(r8.canvasTransform,t.canvasTransform===null?null:Vqe(t.canvasTransform));let i=n.toString();return i?`?${i}`:``}function Uqe(e,t){return e.canvasOpen===t.canvasOpen?`replace`:`push`}function Wqe(){let[e]=(0,b.useState)(()=>i8(typeof window>`u`?``:window.location.search));return{initial:e,write:(0,b.useCallback)((e,t=`replace`)=>{if(typeof window>`u`)return;let n=Hqe(window.location.search,e),r=`${window.location.pathname}${n}${window.location.hash}`;r!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(t===`push`?window.history.pushState(null,``,r):window.history.replaceState(null,``,r))},[])}}function Gqe(e,t){let n=(0,b.useMemo)(()=>JSON.stringify(t),[t]);(0,b.useEffect)(()=>{let t=setTimeout(()=>{let t=JSON.parse(n);e(t,Uqe(typeof window>`u`?t:i8(window.location.search),t))},250);return()=>clearTimeout(t)},[n,e])}var a8=b.forwardRef(({...e},t)=>(0,Y.jsx)(`nav`,{ref:t,"aria-label":`breadcrumb`,...e}));a8.displayName=`Breadcrumb`;var o8=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`ol`,{ref:n,className:X(`flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5`,e),...t}));o8.displayName=`BreadcrumbList`;var s8=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`li`,{ref:n,className:X(`inline-flex items-center gap-1.5`,e),...t}));s8.displayName=`BreadcrumbItem`;var Kqe=b.forwardRef(({asChild:e,className:t,...n},r)=>(0,Y.jsx)(e?fm:`a`,{ref:r,className:X(`transition-colors hover:text-foreground`,t),...n}));Kqe.displayName=`BreadcrumbLink`;var c8=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`span`,{ref:n,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:X(`font-normal text-foreground`,e),...t}));c8.displayName=`BreadcrumbPage`;var l8=({children:e,className:t,...n})=>(0,Y.jsx)(`li`,{role:`presentation`,"aria-hidden":`true`,className:X(`[&>svg]:w-3.5 [&>svg]:h-3.5`,t),...n,children:e??(0,Y.jsx)(Rv,{})});l8.displayName=`BreadcrumbSeparator`;var u8=({className:e,...t})=>(0,Y.jsxs)(`span`,{role:`presentation`,"aria-hidden":`true`,className:X(`flex h-9 w-9 items-center justify-center`,e),...t,children:[(0,Y.jsx)(Jv,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`More`})]});u8.displayName=`BreadcrumbElipssis`;var qqe=Object.defineProperty,d8=(e,t)=>qqe(e,`name`,{value:t,configurable:!0}),f8,p8=`HoverCard`,[m8,Jqe]=sm(p8,[Vh]),h8=Vh(),[Yqe,g8]=m8(p8),Xqe=d8(e=>{let{__scopeHoverCard:t,children:n,open:r,defaultOpen:i,onOpenChange:a,openDelay:o=700,closeDelay:s=300}=e,c=h8(t),l=b.useRef(0),u=b.useRef(0),d=b.useRef(!1),f=b.useRef(!1),[p,m]=ng({prop:r,defaultProp:i??!1,onChange:a,caller:p8}),h=b.useCallback(()=>{clearTimeout(u.current),l.current=window.setTimeout(()=>m(!0),o)},[o,m]),g=b.useCallback(()=>{clearTimeout(l.current),!d.current&&!f.current&&(u.current=window.setTimeout(()=>m(!1),s))},[s,m]),_=b.useCallback(()=>m(!1),[m]);return b.useEffect(()=>()=>{clearTimeout(l.current),clearTimeout(u.current)},[]),(0,Y.jsx)(Yqe,{scope:t,open:p,onOpenChange:m,onOpen:h,onClose:g,onDismiss:_,hasSelectionRef:d,isPointerDownOnContentRef:f,children:(0,Y.jsx)(Uh,{...c,children:n})})},`HoverCard`),Zqe=`HoverCardTrigger`,Qqe=b.forwardRef(d8(function(e,t){let{__scopeHoverCard:n,...r}=e,i=g8(Zqe,n),a=h8(n);return(0,Y.jsx)(Wh,{asChild:!0,...a,children:(0,Y.jsx)(xm.a,{"data-state":i.open?`open`:`closed`,...r,ref:t,onPointerEnter:Qp(e.onPointerEnter,b8(i.onOpen)),onPointerLeave:Qp(e.onPointerLeave,b8(i.onClose)),onFocus:Qp(e.onFocus,i.onOpen),onBlur:Qp(e.onBlur,i.onClose),onTouchStart:Qp(e.onTouchStart,e=>e.preventDefault())})})},`HoverCardTrigger`)),_8=`HoverCardPortal`,[$qe,eJe]=m8(_8,{forceMount:void 0}),tJe=d8(e=>{let{__scopeHoverCard:t,forceMount:n,children:r,container:i}=e,a=g8(_8,t);return(0,Y.jsx)($qe,{scope:t,forceMount:n,children:(0,Y.jsx)(Jh,{present:n||a.open,children:(0,Y.jsx)(Kh,{asChild:!0,container:i,children:r})})})},`HoverCardPortal`),v8=`HoverCardContent`,nJe=b.forwardRef(d8(function(e,t){let n=eJe(v8,e.__scopeHoverCard),{forceMount:r=n.forceMount,...i}=e,a=g8(v8,e.__scopeHoverCard);return(0,Y.jsx)(Jh,{present:r||a.open,children:(0,Y.jsx)(rJe,{"data-state":a.open?`open`:`closed`,...i,onPointerEnter:Qp(e.onPointerEnter,b8(a.onOpen)),onPointerLeave:Qp(e.onPointerLeave,b8(a.onClose)),ref:t})})},`HoverCardContent`)),rJe=b.forwardRef(d8(function(e,t){let{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,...s}=e,c=g8(v8,n),l=h8(n),u=b.useRef(null),d=am(t,u),[f,p]=b.useState(!1);return b.useEffect(()=>{if(f){let e=document.body;return f8=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect=`none`,e.style.webkitUserSelect=`none`,()=>{e.style.userSelect=f8,e.style.webkitUserSelect=f8}}},[f]),b.useEffect(()=>{if(u.current){let e=d8(()=>{p(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==``&&(c.hasSelectionRef.current=!0)})},`handlePointerUp`);return document.addEventListener(`pointerup`,e),()=>{document.removeEventListener(`pointerup`,e),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),b.useEffect(()=>{u.current&&x8(u.current).forEach(e=>e.setAttribute(`tabindex`,`-1`))}),(0,Y.jsx)(Om,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:Qp(a,e=>{e.preventDefault()}),onDismiss:c.onDismiss,children:(0,Y.jsx)(Gh,{...l,...s,onPointerDown:Qp(s.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:d,style:{...s.style,userSelect:f?`text`:void 0,WebkitUserSelect:f?`text`:void 0,"--radix-hover-card-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-hover-card-content-available-width":`var(--radix-popper-available-width)`,"--radix-hover-card-content-available-height":`var(--radix-popper-available-height)`,"--radix-hover-card-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-hover-card-trigger-height":`var(--radix-popper-anchor-height)`}})})},`HoverCardContentImpl`)),y8=b.forwardRef(d8(function(e,t){let{__scopeHoverCard:n,...r}=e,i=h8(n);return(0,Y.jsx)(gne,{...i,...r,ref:t})},`HoverCardArrow`));function b8(e){return t=>t.pointerType===`touch`?void 0:e()}d8(b8,`excludeTouch`);function x8(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:d8(e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}d8(x8,`getTabbableNodes`);var iJe=Xqe,aJe=Qqe,oJe=tJe,S8=nJe,C8=iJe,w8=aJe,T8=b.forwardRef(({className:e,align:t=`center`,sideOffset:n=4,container:r,...i},a)=>(0,Y.jsx)(oJe,{container:r,children:(0,Y.jsx)(S8,{ref:a,align:t,sideOffset:n,className:X(`z-50 w-64 text-xs rounded-md border border-border-secondary`,`bg-bg-secondary-hover text-fg-secondary p-4`,`data-[state=open]:animate-in data-[state=closed]:animate-out`,`data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0`,`data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95`,`data-[side=top]:slide-in-from-bottom-2`,`data-[side=bottom]:slide-in-from-top-2`,`data-[side=left]:slide-in-from-right-2`,`data-[side=right]:slide-in-from-left-2`,e),...i})}));T8.displayName=S8.displayName;function sJe({size:e,type:t,className:n}){if(t===`loading`)return(0,Y.jsx)(hy,{size:e,className:n});switch(t){case`string`:return(0,Y.jsx)(Ry,{size:e,className:n});case`number`:return(0,Y.jsx)(oy,{size:e,className:n});case`boolean`:return(0,Y.jsx)(Rae,{size:e,className:n});case`object`:return(0,Y.jsx)(uae,{size:e,className:n});case`literal`:return(0,Y.jsx)(Kv,{size:e,className:n});case`array`:return(0,Y.jsx)(my,{size:e,className:n});case`union`:return(0,Y.jsx)(Oae,{size:e,className:n});case`richtext`:return(0,Y.jsx)($v,{size:e,className:n});case`record`:return(0,Y.jsx)(Nae,{size:e,className:n});case`keyOf`:return(0,Y.jsx)(lae,{size:e,className:n});case`file`:return(0,Y.jsx)(ey,{size:e,className:n});case`date`:return(0,Y.jsx)(Pv,{size:e,className:n});case`dateTime`:return(0,Y.jsx)(Wv,{size:e,className:n});case`color`:return(0,Y.jsx)(_ae,{size:e,className:n});case`code`:return(0,Y.jsx)(qie,{size:e,className:n});case`image`:return(0,Y.jsx)(sy,{size:e,className:n});default:return(0,Y.jsx)(Hv,{size:e,className:n})}}function cJe({path:e,size:t}){let n=Cb(e),r=`data`in n&&n.data?n.data.type:`loading`,i=Cb(H.parentOfSourcePath(e)),a=`data`in i&&i.data?.type===`array`,o=`data`in i&&i.data?.type===`record`&&!!i.data?.router,[,s]=H.splitModuleFilePathAndModulePath(e),c=H.splitModulePath(s).pop(),l=a?`#${c}`:c;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 w-full`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-tertiary`,children:[o?(0,Y.jsx)(ry,{size:12}):(0,Y.jsx)(sJe,{type:r,size:12}),(0,Y.jsx)(`span`,{children:l})]}),(0,Y.jsx)(X3,{path:e,size:t})]})}function lJe({results:e,onSelect:t,indexing:n}){let r=Db(),i=n?.status===`loading`;return(0,Y.jsx)(ok,{className:`absolute top-full left-0 right-0 h-[min(420px,100vh-56px)]`,children:(0,Y.jsxs)(eD,{className:`h-[calc(min(420px,100vh-56px)-124px)] z-50 p-2 pb-0 bg-bg-primary border border-t-0 border-border-primary rounded-lg rounded-t-none shadow-lg `,children:[n?.status===`loading`&&(0,Y.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-tertiary`,children:[`Searching… `,n.percentage,`% indexed`]}),n?.status===`error`&&(0,Y.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-tertiary`,children:`Some content could not be loaded, so these results may be incomplete.`}),e.length===0&&!i&&(0,Y.jsx)(sk,{className:`py-6 text-center text-fg-tertiary`,children:`No results found.`}),e.map(e=>{let n=r(e.path)||e.path;return(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-px bg-border-primary opacity-50`}),(0,Y.jsx)(uk,{onSelect:()=>t(n),className:`flex flex-col justify-between px-3 py-2.5 aria-selected:bg-bg-secondary hover:bg-bg-secondary transition-colors`,children:(0,Y.jsx)(cJe,{path:n,size:`compact`})})]},e.path)})]})})}function uJe({container:e}){let[t,n]=(0,b.useState)(!1),r=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=e=>{if(e.key===`k`&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)return;e.preventDefault(),n(!0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let{navigate:i}=GC();return(0,Y.jsx)(Uy,{open:t,onOpenChange:n,modal:!1,children:(0,Y.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,Y.jsx)(Hae,{className:`w-full`,onClick:()=>n(!0),children:(0,Y.jsx)(dJe,{})}),(0,Y.jsx)(Wy,{container:e??r.current,children:(0,Y.jsxs)(Cv,{className:`top-full absolute left-0 bg-bg-primary -translate-y-full z-[8999] w-full`,children:[(0,Y.jsx)(Gy,{}),(0,Y.jsx)(fJe,{onSelect:e=>{i(e),n(!1)},onDeactivate:()=>n(!1)})]})})]})})}function dJe(){return(0,Y.jsx)(`div`,{className:`rounded-lg border border-border-primary shadow-sm overflow-visible cursor-text`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-center px-3`,children:[(0,Y.jsx)(My,{className:`w-4 h-4 mr-2 opacity-50 shrink-0`}),(0,Y.jsx)(`span`,{className:X(`flex h-11 w-full rounded-md py-3 text-sm`,`text-fg-secondary cursor-text`,`leading-[21px]`),children:`Search content...`})]})})}function fJe({onSelect:e,onDeactivate:t}){let n=nb(),[r,i]=(0,b.useState)(``),a=(0,b.useRef)(null),[o,s]=(0,b.useState)([]),c=r.trim()!==``,l=PD(c),u=l.status===`loading`?l.percentage:l.status;(0,b.useEffect)(()=>{if(n===null||!c){s([]);return}let e=!1;return n.system.search(r,10).then(t=>{e||s(t.status===`no-index`?[]:t.results)}).catch(()=>{e||s([])}),()=>{e=!0}},[n,r,c,u]);let d=(0,b.useCallback)(n=>{e(n),i(``),t?.()},[e,t]),f=Db(),p=(0,b.useMemo)(()=>{let e=new Set,t=[];for(let n of o){let r=f(n.path)||n.path;e.has(r)||(t.push(n),e.add(r))}return t},[o,f]);return(0,b.useEffect)(()=>{let e=setTimeout(()=>{a.current?.focus()},0);return()=>clearTimeout(e)},[]),(0,Y.jsx)(`div`,{className:`relative w-full overflow-visible`,children:(0,Y.jsxs)(ik,{className:X(`rounded-lg border border-border-primary shadow-sm overflow-visible`,{"border-b-0 rounded-b-none pb-[1px]":!!r.trim()}),shouldFilter:!1,children:[(0,Y.jsx)(ak,{ref:a,placeholder:`Search content...`,value:r,onValueChange:i}),c&&(0,Y.jsx)(lJe,{results:p,onSelect:d,indexing:l})]},`search-command`)})}function E8(e,t){let{navigate:n,hrefOf:r}=GC(),i=t?.scrollToPath,a=t?.errorFields,o=(0,b.useCallback)(t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),n(e,{scrollToPath:i,errorFields:a}))},[n,e,i,a]);return{href:r(e,{scrollToPath:i,errorFields:a}),onClick:o}}function D8({part:e,isParent:t,className:n}){let r=E8(e.sourcePath),i=fk(e.sourcePath)?.title?.trim()||e.text;return e.isDirectory?(0,Y.jsx)(`span`,{className:X(`truncate text-fg-quaternary`,n),children:i}):(0,Y.jsxs)(`a`,{...r,title:e.sourcePath,"aria-label":t?`Up one level, to ${i}`:void 0,className:X(`inline-flex min-w-0 items-center gap-0.5 rounded-sm text-fg-tertiary hover:text-fg-brand-primary hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,n),children:[t&&(0,Y.jsx)(Lv,{size:14,"aria-hidden":!0,className:`shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i})]})}function O8(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-fg-quaternary`,children:`/`})}function pJe({part:e}){let t=E8(e.sourcePath),n=fk(e.sourcePath)?.title?.trim()||e.text;return e.isDirectory?(0,Y.jsxs)(M3,{disabled:!0,className:`gap-1.5`,children:[(0,Y.jsx)(O8,{}),(0,Y.jsx)(`span`,{className:`truncate`,children:n})]}):(0,Y.jsx)(M3,{asChild:!0,className:`gap-1.5`,children:(0,Y.jsxs)(`a`,{...t,title:e.sourcePath,children:[(0,Y.jsx)(O8,{}),(0,Y.jsx)(`span`,{className:`truncate`,children:n})]})})}var mJe=3;function hJe({parts:e,portalContainer:t,className:n}){let r=e.length>0?e[e.length-1]:null,i=r!==null&&r.isDirectory!==!0?r:null,{visibleStart:a,collapsed:o,visibleEnd:s}=(0,b.useMemo)(()=>e.length<=mJe?{visibleStart:e,collapsed:[],visibleEnd:[]}:{visibleStart:e.slice(0,1),collapsed:e.slice(1,-2),visibleEnd:e.slice(-2)},[e]);return r===null?null:(0,Y.jsxs)(`nav`,{"aria-label":`Scope`,className:X(`flex min-w-0 items-center gap-1 text-xs text-fg-quaternary`,n),children:[a.map((e,t)=>(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(D8,{part:e,isParent:e===i}),(o.length>0||s.length>0||t<a.length-1)&&(0,Y.jsx)(O8,{})]},e.sourcePath+t)),o.length>0&&(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{"aria-label":`${o.length} more levels`,className:`rounded-sm px-0.5 text-fg-tertiary hover:text-fg-brand-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:`…`}),(0,Y.jsx)(j3,{align:`start`,container:t,children:o.map(e=>(0,Y.jsx)(pJe,{part:e},e.sourcePath))})]}),(0,Y.jsx)(O8,{})]}),s.map((e,t)=>(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(D8,{part:e,isParent:e===i}),t<s.length-1&&(0,Y.jsx)(O8,{})]},e.sourcePath+t))]})}function k8({path:e,showModuleGalleryChild:t}){let n=Cb(e),{path:r,schema:i}=TD(e),a=Pb(e),o=XS(e),s=o?o.length>0:!1,c=sC(),l=(0,b.useMemo)(()=>{let e={};for(let t of o||[]){let n=t.authorId??`unknown`;e[n]||(e[n]=[]),e[n].push(t)}return e},[o]),u=eb(),d=TD(e);if((0,b.useMemo)(()=>!!(d.path!==e&&d.schema?.type===`record`&&d.schema.mediaType),[e,d]))return(0,Y.jsx)(k8,{path:d.path,showModuleGalleryChild:e},e);if(n.status===`error`)return(0,Y.jsx)(NC,{path:e,error:n.error,type:`module`});if(n.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:`module`});if((e?.length||0)===0)return(0,Y.jsx)(gJe,{});if(n.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:`module`});let f=n.data,p=xk(e),m=p.slice(0,-1),h=p[p.length-1],g=Qfe(e,r,i),_=ED(e,r,i),v=a.filter(e=>!!e.keyError),y=a.filter(e=>!e.keyError),x=r!==e&&i?.type===`record`&&!!i?.router,S=f.type===`record`&&!!f.router,C=f.type===`record`&&!!f.mediaType,w=_&&i?.type===`record`?i.key?.description:void 0,T=!C&&(0,Y.jsxs)(`div`,{className:`shrink-0 flex gap-2 items-center`,children:[s&&(0,Y.jsx)(Kk,{patchesByAuthorIds:l,profilesByAuthorIds:c,sourcePath:e}),(0,Y.jsx)(hk,{path:e,variant:`module`})]}),E=g?(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`#`,Number(h.text)]}):x?(0,Y.jsx)(vJe,{path:h.text,portalContainer:u}):S?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Y.jsx)(ry,{size:20,className:`text-fg-tertiary shrink-0`}),(0,Y.jsx)(`span`,{children:`Pages`})]}):(0,Y.jsx)(`span`,{className:`truncate block`,children:h.text});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4 pb-40`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 text-left overflow-hidden`,children:(0,Y.jsxs)(`div`,{className:X({"border rounded-lg border-bg-warning-secondary p-4":v.length>0}),children:[(0,Y.jsxs)(`div`,{className:`flex gap-4 justify-between items-start min-h-6`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{role:`heading`,"aria-level":1,className:`text-2xl leading-tight`,children:E}),w&&(0,Y.jsx)(`div`,{className:`mt-1 text-sm text-fg-tertiary`,children:w})]}),T]}),m.length>0&&(0,Y.jsx)(hJe,{parts:m,portalContainer:u,className:w?`mt-3`:`mt-1.5`}),v.length>0&&(0,Y.jsx)(Uk,{validationErrors:v}),f.description&&(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:f.description})]})}),(0,Y.jsxs)(`div`,{children:[_&&y.length>0&&(0,Y.jsx)(Uk,{validationErrors:a}),(0,Y.jsx)(`div`,{className:X({"border rounded-lg border-bg-warning-secondary p-4 mt-4":y.length>0}),children:t?(0,Y.jsx)(sX,{path:e,showChildPath:t,readonly:f.readonly},e):(0,Y.jsx)(r6,{path:e,schema:f},e)})]})]})}function gJe(){return(0,Y.jsx)(`div`,{className:`flex flex-col min-h-[calc(100vh-100px)] items-center grow`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col pt-20 gap-2 w-full max-w-md text-center`,children:[(0,Y.jsx)(`div`,{className:`w-full`,children:(0,Y.jsx)(uJe,{})}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-tertiary`,children:`Search or use the menu on the left to find and edit your content.`})]})})}var _Je=4;function vJe({path:e,portalContainer:t}){let{segments:n,isFullUrl:r,protocol:i,host:a}=(0,b.useMemo)(()=>{let t=e.startsWith(`http://`)||e.startsWith(`https://`),n=e,r=``,i=``;if(t)try{let t=new URL(e);r=t.protocol,i=t.host,n=t.pathname}catch{}return{segments:n.split(`/`).filter(Boolean),isFullUrl:t,protocol:r,host:i}},[e]);if(n.length===0&&r)return(0,Y.jsxs)(C8,{openDelay:200,children:[(0,Y.jsx)(w8,{asChild:!0,children:(0,Y.jsx)(`div`,{className:`cursor-default`,children:(0,Y.jsx)(a8,{children:(0,Y.jsx)(o8,{className:`flex-nowrap font-normal`,children:(0,Y.jsxs)(s8,{className:`shrink-0`,children:[(0,Y.jsxs)(`span`,{className:`text-fg-tertiary`,children:[i,`//`]}),(0,Y.jsx)(`span`,{children:a})]})})})})}),(0,Y.jsx)(T8,{className:`w-auto max-w-[400px] break-all`,container:t,side:`bottom`,align:`start`,children:(0,Y.jsx)(`p`,{className:`font-mono text-sm`,children:e})})]});if(n.length===0)return(0,Y.jsx)(`span`,{className:`text-fg-secondary`,children:`/`});let o=n.length>_Je,s=o?n.slice(0,1):n,c=o?n.slice(-2):[],l=(0,Y.jsx)(a8,{children:(0,Y.jsxs)(o8,{className:`flex-nowrap font-normal`,children:[r&&(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(s8,{className:`shrink-0`,children:[(0,Y.jsxs)(`span`,{className:`text-fg-tertiary`,children:[i,`//`]}),(0,Y.jsx)(`span`,{children:a})]})}),(0,Y.jsx)(s8,{className:`shrink-0`,children:(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`})}),s.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(s8,{className:X(`shrink-0`,{"max-w-[120px]":t<s.length-1}),children:(0,Y.jsx)(c8,{className:`truncate block`,children:e})}),(t<s.length-1||o||!o&&t<n.length-1)&&(0,Y.jsx)(l8,{className:`shrink-0`,children:(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`})})]},`start-${t}`)),o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(s8,{children:(0,Y.jsx)(u8,{className:`h-4 w-4`})}),(0,Y.jsx)(l8,{className:`shrink-0`,children:(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`})})]}),c.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(s8,{className:`shrink-0 max-w-[120px]`,children:(0,Y.jsx)(c8,{className:`truncate block`,children:e})}),t<c.length-1&&(0,Y.jsx)(l8,{className:`shrink-0`,children:(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`})})]},`end-${t}`))]})});return(0,Y.jsxs)(C8,{openDelay:200,children:[(0,Y.jsx)(w8,{asChild:!0,children:(0,Y.jsx)(`div`,{className:`cursor-default`,children:l})}),(0,Y.jsx)(T8,{className:`w-auto max-w-[400px] break-all`,container:t,side:`bottom`,align:`start`,children:(0,Y.jsx)(`p`,{className:`font-mono text-sm`,children:e})})]})}function yJe(){let{addModuleFilePatch:e}=LS(),t=wb(),{navigate:n}=GC();return(0,b.useCallback)((r,i)=>{if(t.status!==`success`){console.error(`Val: cannot add a page before the schemas have loaded`);return}let a=t.data[r];if(!a||a.type!==`record`){console.error(`Val: cannot add a page to a module that is not a record`,{moduleFilePath:r,schema:a});return}let o=H.createPatchPath(``).concat(i);e(r,[{op:`add`,path:o,value:Cp(a.item)}],`record`),n(H.joinModuleFilePathAndModulePath(r,H.patchPathToModulePath(o)))},[e,t,n])}function A8(e,t,n){return e===1?t:n}function bJe(e){let{mode:t,validationErrorCount:n,conflictingChangeCount:r,isPublishing:i,publishDisabled:a,autoPublish:o,pendingServerSidePatchCount:s,pendingClientSidePatchCount:c,netChangesEmpty:l}=e,u=t===`fs`;if(n>0||r>0){let e=[];return n>0&&e.push(`${n} validation ${A8(n,`error`,`errors`)} to fix.`),r>0&&e.push(`${r} ${A8(r,`change`,`changes`)} cannot be applied. Remove ${A8(r,`it`,`them`)} to continue.`),{kind:`blocked`,label:n>0?`Fix ${n>9?`9+`:n}`:`Fix errors`,description:n>0?`Show the validation errors`:`Show the changes that cannot be applied`,reason:e.join(` `),action:n>0?`show-errors`:`none`}}if(i)return{kind:`in-flight`,label:u?`Saving`:`Pushing`,description:u?`Saving changes to disk`:`Pushing changes`,reason:null,action:`none`};let d=s===0,f=c>0,p=!d&&!f&&l;return a||d||f||p||u&&o?{kind:`idle`,label:u?`Save`:`Publish`,description:u?`Save to disk`:`Publish pending changes`,reason:f?`Waiting for the last edit to reach the server.`:u&&o?`Auto save is on: changes are saved for you.`:d?`Nothing to send.`:p?`Every change has been reverted, so there is nothing to publish. Discard them to clear.`:null,action:`none`}:{kind:`ready`,label:u?`Save`:`Publish`,description:u?`Save to disk`:`Publish pending changes`,reason:null,action:u?`save`:`publish`}}function xJe({value:e,onChange:t,ai:n,onUseAiSummary:r,onOpenAiSession:i,onSetUpAi:a,onPublish:o,onClose:s,publishDisabled:c,isPublishing:l,waitingForAiSeconds:u}){let d=`w-full p-2 border rounded bg-bg-secondary`,f=u!==null;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Summary`}),(0,Y.jsx)(SJe,{ai:n,canApply:n.status===`ready`&&n.text.trim()!==e.trim(),onUseAiSummary:r,onOpenAiSession:i,onSetUpAi:a})]}),(0,Y.jsxs)(`div`,{className:`grid text-xs font-light`,children:[(0,Y.jsx)(`div`,{"aria-hidden":!0,className:X(d,`invisible whitespace-pre-wrap`),style:{gridArea:`1 / 1 / 2 / 2`},children:e+` `}),(0,Y.jsx)(`textarea`,{className:X(d,`resize-none overflow-clip`),value:e,style:{gridArea:`1 / 1 / 2 / 2`},placeholder:`Write a summary of your changes`,onChange:e=>t(e.currentTarget.value)})]}),f&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:12,className:`animate-spin mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{children:[`Waiting for the AI summary. Publishing in `,u,`s either way — press Publish again to skip the wait.`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Y.jsx)(t_,{variant:`outline`,onClick:s,children:`Close`}),(0,Y.jsxs)(t_,{disabled:c||e.trim()===``,onClick:o,variant:`default`,className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:l?`Pushing...`:`Publish`}),(0,Y.jsx)(By,{size:16})]})]})]})}function SJe({ai:e,canApply:t,onUseAiSummary:n,onOpenAiSession:r,onSetUpAi:i}){let a=eb();return e.status===`off`?i?(0,Y.jsx)(j8,{container:a,text:`Val can write your summary for you once an AI key is set up. Publishing works the same either way.`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:i,className:`flex items-center gap-1 text-xs text-fg-secondary underline cursor-pointer`,children:[(0,Y.jsx)(Ny,{size:12}),(0,Y.jsx)(`span`,{children:`Set up AI`})]})}):null:e.status===`idle`?null:e.status===`loading`?(0,Y.jsx)(j8,{container:a,text:`Writing a summary with AI. You do not have to wait — edit the text or publish whenever you like.`,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:12,className:`animate-spin`}),(0,Y.jsx)(`span`,{children:`AI is writing…`})]})}):e.status===`failed`?(0,Y.jsx)(j8,{container:a,text:`${e.message} Your summary is unaffected — publish when ready.`,children:e.canSetUp&&i?(0,Y.jsxs)(`button`,{type:`button`,onClick:i,className:`flex items-center gap-1 text-xs text-fg-secondary underline cursor-pointer`,children:[(0,Y.jsx)(Ly,{size:12}),(0,Y.jsx)(`span`,{children:`AI unavailable`})]}):(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Ly,{size:12}),(0,Y.jsx)(`span`,{children:`AI unavailable`})]})}):(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[t&&(0,Y.jsx)(j8,{container:a,text:`Replace what you have written with the AI's summary.`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-1 text-xs text-fg-secondary underline cursor-pointer`,children:[(0,Y.jsx)(Ny,{size:12}),(0,Y.jsx)(`span`,{children:`Use AI summary`})]})}),r&&(0,Y.jsx)(j8,{container:a,text:`Open the chat that wrote this summary to ask what changed.`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:r,className:`flex items-center gap-1 text-xs text-fg-secondary underline cursor-pointer`,children:[(0,Y.jsx)(vy,{size:12}),(0,Y.jsx)(`span`,{children:`Ask what changed`})]})})]})}function j8({text:e,container:t,children:n}){return(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:n}),(0,Y.jsx)(Xg,{container:t,className:`max-w-[260px] text-xs`,children:e})]})}function CJe(e){let[t,n]=(0,b.useState)(null),r=(0,b.useRef)(null),i=(0,b.useCallback)(()=>{let e=r.current;r.current=null,n(null),e?.()},[]);return(0,b.useEffect)(()=>{if(t===null)return;if(t<=0){i();return}let e=setTimeout(()=>n(e=>(e??1)-1),1e3);return()=>clearTimeout(e)},[t,i]),(0,b.useEffect)(()=>()=>{let e=r.current;r.current=null,e?.()},[]),{remaining:t,isWaiting:t!==null,start:t=>{r.current===null&&(r.current=t,n(e))},skip:i,cancel:()=>{r.current=null,n(null)}}}var wJe=3,M8=6;function N8(e){let t=e.split(`/`).filter(Boolean),n=(t[t.length-1]??e).replace(/\.val\.(ts|tsx|js|jsx|json)$/,``),r=(n===`page`||n===`index`?t[t.length-2]??n:n).replace(/[-_]+/g,` `).trim();return r?r.charAt(0).toUpperCase()+r.slice(1):e}function TJe(e){let t=Array.from(new Set(e.map(e=>N8(e)))).sort((e,t)=>e.localeCompare(t));if(t.length===0)return`Update content`;if(t.length<=wJe)return`Update ${EJe(t)}`;let n=t.slice(0,M8).join(`, `),r=t.length-M8,i=r>0?`${n} and ${r} more`:n;return`Update content in ${t.length} places\n\nChanged: ${i}`}function EJe(e){return e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function P8(e){return!e.hasEdited&&e.currentValue.trim()===e.defaultSummary.trim()}var DJe=240,OJe=40;function F8(e){if(e===void 0)return`(not set)`;if(e===null)return`(empty)`;if(typeof e==`string`)return I8(e);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`(list of ${e.length})`;if(typeof e==`object`){let t=e;if(typeof t.path==`string`)return`(file ${I8(t.path,80)})`;let n=Object.keys(t);return`(fields: ${n.slice(0,6).join(`, `)}${n.length>6?`, …`:``})`}return`(value)`}function I8(e,t=DJe){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t)}… (${n.length} characters in total)`}function kJe(e){if(e.length===0)return`No changes.`;let t=e.slice(0,OJe),n=new Map;for(let e of t){let t=n.get(e.moduleFilePath);t?t.push(e):n.set(e.moduleFilePath,[e])}let r=[];for(let[e,t]of n){r.push(`## ${N8(e)}`);for(let e of t){let t=e.fieldPath||`(the whole entry)`,n=e.schemaType?` [${e.schemaType}]`:``;r.push(`- ${t}${n}`),r.push(` before: ${F8(e.before)}`),r.push(` after: ${F8(e.after)}`)}r.push(``)}let i=e.length-t.length;return i>0&&r.push(`(${i} further ${i===1?`change`:`changes`} not listed)`),r.join(`
|
|
225
|
+
`)}}var NKe=6e4;function PKe({ready:e,progress:t,fetchError:n,children:r}){let[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(null),c=(0,b.useRef)({progress:t,fetchError:n});(0,b.useEffect)(()=>{c.current={progress:t,fetchError:n}}),(0,b.useEffect)(()=>{if(e)return;let t=setTimeout(()=>{let{progress:e,fetchError:t}=c.current;s(MKe(e(),t))},NKe);return()=>clearTimeout(t)},[e]);let l=!e&&!i&&o===null;return(0,Y.jsx)(LGe,{held:l,children:(0,Y.jsxs)(`div`,{className:`contents`,"aria-busy":l,children:[(0,Y.jsx)(`div`,{className:X(`transition-opacity duration-200`,l?`opacity-60`:`opacity-100`),children:r}),l&&(0,Y.jsx)(FKe,{onDismiss:()=>a(!0)}),!e&&o!==null&&!i&&(0,Y.jsx)(IKe,{summary:o.summary,detail:o.detail,onDismiss:()=>a(!0)})]})})}function FKe({onDismiss:e}){return(0,Y.jsx)(`div`,{className:`pointer-events-none absolute bottom-16 left-1/2 z-hover -translate-x-1/2`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border-float bg-bg-float px-2.5 py-1 text-xs text-fg-secondary shadow-sm`,children:[(0,Y.jsx)(hy,{size:12,className:`animate-spin`,"aria-hidden":!0}),`Loading unpublished changes…`,(0,Y.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`Stop waiting for unpublished changes`,className:`pointer-events-auto -mr-1 ml-0.5 grid size-4 place-items-center rounded text-fg-tertiary hover:bg-bg-float-raised hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:(0,Y.jsx)(Hy,{size:11,"aria-hidden":!0})})]})})}function IKe({summary:e,detail:t,onDismiss:n}){return(0,Y.jsx)(`div`,{role:`alert`,className:`absolute bottom-16 left-1/2 z-hover w-[min(28rem,calc(100%-2rem))] -translate-x-1/2`,children:(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-float bg-bg-float p-3 shadow-md`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(Ly,{size:14,className:`mt-0.5 shrink-0 text-fg-warning-primary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`p`,{className:`min-w-0 flex-1 text-xs leading-relaxed text-fg-primary`,children:e}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Dismiss`,className:`-mr-1 -mt-1 grid size-5 shrink-0 place-items-center rounded text-fg-tertiary hover:bg-bg-float-raised hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:(0,Y.jsx)(Hy,{size:12,"aria-hidden":!0})})]}),(0,Y.jsxs)(`details`,{className:`group mt-2`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer list-none text-xs text-fg-secondary-alt hover:text-fg-primary [&::-webkit-details-marker]:hidden`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(Rv,{size:12,className:`transition-transform group-open:rotate-90`,"aria-hidden":!0}),`Diagnostics`]})}),(0,Y.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap break-words rounded-md border border-border-float bg-bg-secondary p-3 font-mono text-[0.6875rem] leading-relaxed text-fg-secondary`,children:t})]})]})})}var LKe={content:$v,media:sy,publish:Gv,validation:Ly};function RKe({breakpoint:e,notifications:t,onSelect:n,onMarkAllRead:r,onClose:i}){let a=t.filter(e=>e.unread).length;return(0,Y.jsx)(pC,{side:`right`,width:320,title:`Notifications`,mobileVariant:`bottom-sheet`,breakpoint:e,onClose:i,headerAction:a>0?(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`h-7 px-2 rounded-md text-xs text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:`Mark all read`}):void 0,children:t.length===0?(0,Y.jsx)(hC,{children:`Nothing new. You are all caught up.`}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border-float`,children:t.map(e=>{let t=LKe[e.kind];return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:`flex gap-2.5 w-full px-4 py-2.5 text-left hover:bg-bg-float-raised`,children:[(0,Y.jsx)(`span`,{className:X(`grid place-items-center w-6 h-6 mt-0.5 shrink-0 rounded-md`,e.kind===`validation`?`bg-bg-error-primary text-fg-error-primary`:`bg-bg-float-raised text-fg-secondary`),children:(0,Y.jsx)(t,{size:13})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary`,children:e.title}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:e.timestamp})]}),e.unread&&(0,Y.jsx)(`span`,{"aria-label":`Unread`,className:`w-1.5 h-1.5 mt-1.5 shrink-0 rounded-full bg-fg-secondary`})]})},e.id)})})})}var D6=`\0header`;function zKe({routes:e,currentPage:t,isOpen:n,onOpenChange:r,onSubmit:i}){let a=(0,b.useRef)(null);return o6(a,n,(0,b.useCallback)(()=>r(!1),[r])),(0,Y.jsxs)(`div`,{ref:a,className:`relative shrink-0`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-label":`New page`,"aria-expanded":n,onClick:()=>r(!n),className:X(`inline-flex items-center gap-1 h-7 px-2 rounded-md text-xs font-medium`,`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,n&&`bg-bg-float-raised text-fg-primary`),children:[(0,Y.jsx)(Oy,{size:13}),`New`]}),n&&(0,Y.jsx)(`div`,{className:`absolute right-0 top-full z-window mt-1 w-[17rem] rounded-md border border-border-float bg-bg-float shadow-lg`,children:(0,Y.jsx)(EA,{routes:e,currentPage:t,onSubmit:i,onCancel:()=>r(!1)})})]})}function O6(e,t){for(let n of e){if(n.id===t)return n;let e=O6(n.children??[],t);if(e)return e}}function BKe(e,t){if(!t)return e;let n=t.toLowerCase(),r=e=>e.flatMap(e=>{let t=r(e.children??[]);return!(e.name.toLowerCase().includes(n)||e.urlPath.toLowerCase().includes(n))&&t.length===0?[]:[{...e,children:t}]});return r(e)}function k6(e){return e.flatMap(e=>[e.id,...k6(e.children??[])])}function A6(e){return e.reduce((e,t)=>e+ +!!t.isTracked+A6(t.children??[]),0)}function j6(e,t){if(t===null)return[];let n=(e,r)=>{for(let i of e){if(i.id===t)return r;let e=n(i.children??[],[...r,i.id]);if(e)return e}return null};return n(e,[])??[]}function M6(e){return(e.errorCount??0)+(e.children??[]).reduce((e,t)=>e+M6(t),0)}function N6(e){return e.hasDraft===!0||(e.children??[]).some(e=>N6(e))}function VKe({breakpoint:e,pages:t,externalPages:n,selectedId:r,onSelectPage:i,onSelectExternalPage:a,onNewPage:o,newPage:s,onClose:c,navSwitcher:l,isLoading:u,loadError:d,onRetryLoad:f}){let[p,m]=(0,b.useState)(``),[h,g]=(0,b.useState)(()=>new Set(j6(t,r))),_=(0,b.useMemo)(()=>j6(t,r).join(`\0`),[t,r]);(0,b.useEffect)(()=>{_&&g(e=>new Set([...e,..._.split(`\0`)]))},[_]);let v=(0,b.useMemo)(()=>BKe(t,p),[t,p]),y=(0,b.useMemo)(()=>p?new Set(k6(v)):null,[p,v]),x=(0,b.useMemo)(()=>{if(!p)return n;let e=p.toLowerCase();return n.filter(t=>t.name.toLowerCase().includes(e)||t.url.toLowerCase().includes(e))},[n,p]),S=e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=(0,b.useMemo)(()=>{let e=r===null?void 0:O6(t,r);if(!e?.sourcePath)return;let[n]=H.splitModuleFilePathAndModulePath(e.sourcePath);return{moduleFilePath:n,urlPath:e.urlPath}},[t,r]),[w,T]=(0,b.useState)(null),E=(0,b.useCallback)((e,t)=>{T(null),o(e,t)},[o]),D=(e,t)=>{let n=e.children??[],a=n.length>0,o=y?y.has(e.id):h.has(e.id),s=o?e.errorCount:M6(e),c=o?e.hasDraft:N6(e);return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(_C,{depth:t,selected:r===e.id,title:e.urlPath,onClick:()=>{i(e),a&&!y&&S(e.id)},leading:a?(0,Y.jsx)(`span`,{role:`presentation`,onClick:t=>{t.stopPropagation(),S(e.id)},className:`text-fg-secondary-alt`,children:o?(0,Y.jsx)(Iv,{size:13}):(0,Y.jsx)(Rv,{size:13})}):t===0?(0,Y.jsx)(ey,{size:13,className:`text-fg-secondary-alt`}):(0,Y.jsx)(`span`,{className:`w-3.5`}),label:e.name,errorCount:s,hasDraft:c}),o&&a&&n.map(e=>D(e,t+1))]},e.id)};return(0,Y.jsx)(pC,{side:`left`,width:300,title:`Pages`,mobileVariant:`sheet`,breakpoint:e,onClose:c,subheader:l,headerAction:s?(0,Y.jsx)(zKe,{routes:s.routes,currentPage:C,isOpen:w===D6,onOpenChange:e=>T(e?D6:null),onSubmit:E}):void 0,sticky:u||d?void 0:(0,Y.jsx)(gC,{value:p,onChange:m,placeholder:`Filter pages…`}),children:u?(0,Y.jsx)(vC,{rows:12}):d?(0,Y.jsx)(yC,{message:d,onRetry:f}):(0,Y.jsxs)(`div`,{className:`pb-3`,children:[(0,Y.jsxs)(mC,{className:`pt-3`,children:[`Pages`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal normal-case tracking-normal text-fg-secondary-alt`,children:A6(v)})]}),v.length===0?(0,Y.jsx)(hC,{children:p?`No pages match this filter.`:`No pages yet.`}):v.map(e=>D(e,0)),(0,Y.jsxs)(mC,{children:[`External pages`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal normal-case tracking-normal text-fg-secondary-alt`,children:x.length})]}),x.length===0?(0,Y.jsx)(hC,{children:p?`No external pages match this filter.`:`No external pages yet.`}):x.map(e=>(0,Y.jsx)(_C,{selected:r===e.id,title:e.url,onClick:()=>a(e),leading:(0,Y.jsx)(Zv,{size:12,className:`text-fg-secondary-alt`}),label:e.name,errorCount:e.errorCount},e.id))]})})}function HKe(e){if(e.length===0)return{state:`none`};let t=e.filter(P6);if(t.length>0)return{state:`building`,count:t.length};let n=e[0];return F6(n)?{state:`failed`}:{state:`live`}}function P6(e){return e.isLive?!1:e.state===`created`||e.state===`pending`}function F6(e){return e.isLive?!1:e.state===`failure`||e.state===`error`}var UKe=5e3;function WKe({deployments:e,open:t,onOpenChange:n,onDismiss:r,autoClose:i=!1}){let a=HKe(e),o=(0,b.useRef)(null),[s,c]=(0,b.useState)(!1),l=t&&i&&!s&&a.state===`live`;return(0,b.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>n(!1),UKe);return()=>clearTimeout(e)},[l,n]),(0,b.useEffect)(()=>{if(!t)return;let e=e=>{let t=e.target;t instanceof Node&&o.current&&!o.current.contains(t)&&n(!1)},r=e=>{e.key===`Escape`&&n(!1)},i=o.current?.getRootNode()??document;return i.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,r),()=>{i.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,r)}},[t,n]),(0,Y.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":t,"aria-label":`Deployments: ${I6(a)}`,onClick:()=>n(!t),className:X(`inline-flex items-center gap-1.5 rounded px-1 -mx-1 hover:text-fg-primary`,a.state===`failed`&&`text-fg-error-on-surface`),children:[(0,Y.jsx)(GKe,{summary:a}),I6(a),(0,Y.jsx)(Lie,{size:12,className:X(`text-fg-secondary-alt transition-transform`,t&&`rotate-180`)})]}),t&&(0,Y.jsx)(KKe,{deployments:e,onDismiss:r,onClose:()=>n(!1),onReadingChange:c})]})}function I6(e){switch(e.state){case`building`:return e.count>1?`Building ${e.count} publishes`:`Building`;case`failed`:return`Build failed`;case`live`:return`Deployed`;case`none`:return`No deploys`}}function GKe({summary:e}){return e.state===`building`?(0,Y.jsx)(hy,{size:13,className:`animate-spin`}):e.state===`failed`?(0,Y.jsx)(Bv,{size:13}):e.state===`live`?(0,Y.jsx)(Fv,{size:13,className:`text-fg-secondary-alt`}):(0,Y.jsx)(ky,{size:13,className:`text-fg-secondary-alt`})}function KKe({deployments:e,onDismiss:t,onClose:n,onReadingChange:r}){return(0,Y.jsxs)(`div`,{role:`dialog`,"aria-label":`Deployments`,onPointerEnter:()=>r?.(!0),onPointerLeave:()=>r?.(!1),className:X(`absolute bottom-full right-0 mb-2 w-80 rounded-lg overflow-hidden`,`bg-bg-float border border-border-float shadow-xl`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-3 h-9 border-b border-border-float`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-fg-primary`,children:`Deployments`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Close deployments`,onClick:n,className:`text-fg-secondary-alt hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:14})})]}),(0,Y.jsx)(L6,{deployments:e,onDismiss:t})]})}function L6({deployments:e,onDismiss:t}){return e.length===0?(0,Y.jsx)(`p`,{className:`px-3 py-4 text-xs text-fg-secondary-alt`,children:`Nothing published yet. Publishing sends your changes to the site and the build shows up here.`}):(0,Y.jsx)(`ul`,{className:`max-h-64 overflow-y-auto scrollbar-slim`,children:e.map(e=>(0,Y.jsx)(qKe,{deployment:e,onDismiss:()=>t(e.commitSha)},e.commitSha))})}function qKe({deployment:e,onDismiss:t}){let n=P6(e),r=F6(e);return(0,Y.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2.5 border-b border-border-float last:border-b-0`,children:[(0,Y.jsxs)(`span`,{className:`mt-0.5 shrink-0`,children:[n&&(0,Y.jsx)(hy,{size:13,className:`animate-spin text-fg-secondary`}),r&&(0,Y.jsx)(Bv,{size:13,className:`text-fg-error-on-surface`}),!n&&!r&&(0,Y.jsx)(`span`,{className:`block w-1.5 h-1.5 m-[3px] rounded-full bg-bg-brand-secondary`})]}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs text-fg-primary truncate`,children:e.message??e.commitSha.slice(0,7)}),(0,Y.jsxs)(`div`,{className:`text-[11px] text-fg-secondary-alt truncate`,children:[JKe(e),e.author?` · ${e.author}`:``,` ·`,` `,e.timestamp]})]}),!n&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Dismiss deployment`,onClick:t,className:`mt-0.5 shrink-0 text-fg-secondary-alt hover:text-fg-primary`,children:(0,Y.jsx)(Hy,{size:13})})]})}function JKe(e){if(e.isLive)return`Live`;switch(e.state){case`created`:return`Queued`;case`pending`:return`Building`;case`failure`:case`error`:return`Build failed`;case`success`:return`Built`}}function YKe({breakpoint:e,user:t,accountError:n,theme:r,onThemeChange:i,admin:a,mode:o,autoSave:s,onAutoSaveChange:c,branch:l,deployments:u,onDismissDeployment:d,onSignOut:f,onClose:p,navSwitcher:m}){return(0,Y.jsx)(pC,{side:`left`,width:300,title:`Settings`,mobileVariant:`sheet`,breakpoint:e,onClose:p,subheader:m,children:(0,Y.jsxs)(`div`,{className:`pb-4`,children:[n&&(0,Y.jsx)(gKe,{error:n}),t&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-3`,children:[(0,Y.jsx)(h6,{initials:t.initials}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium truncate`,children:t.name}),t.email&&(0,Y.jsx)(`div`,{className:`text-[0.6875rem] text-fg-secondary-alt truncate`,children:t.email})]})]}),(0,Y.jsx)(mC,{children:`Appearance`}),(0,Y.jsx)(`div`,{className:`px-4 pt-1`,children:(0,Y.jsx)(`div`,{role:`radiogroup`,"aria-label":`Theme`,className:`flex p-0.5 rounded-md bg-bg-float-raised`,children:[`dark`,`light`].map(e=>(0,Y.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r===e,onClick:()=>i(e),className:X(`flex-1 inline-flex items-center justify-center gap-1.5 h-7 rounded text-xs capitalize`,r===e?`bg-bg-float text-fg-primary shadow-sm`:`text-fg-secondary hover:text-fg-primary`),children:[e===`dark`?(0,Y.jsx)(gae,{size:13}):(0,Y.jsx)(Mae,{size:13}),e]},e))})}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(mC,{divided:!0,children:`Project`}),(0,Y.jsxs)(`div`,{className:`px-4 pt-1 space-y-1.5`,children:[(0,Y.jsx)(R6,{href:a.project,icon:wae,label:`Administer project`,description:`Settings, API keys and versions in Val Build.`}),(0,Y.jsx)(R6,{href:a.members,icon:Vae,label:`Manage members`,description:`Who can edit this project's content.`})]})]}),(0,Y.jsx)(mC,{divided:!0,children:`Workspace`}),(0,Y.jsxs)(`div`,{className:`px-4 pt-1 space-y-2.5`,children:[o===`fs`&&(0,Y.jsx)(XKe,{label:`Auto save`,description:`Write changes to the working tree on a pause in typing.`,checked:s,onChange:c}),l&&(0,Y.jsxs)(`div`,{className:`flex items-baseline justify-between text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-fg-secondary`,children:`Branch`}),(0,Y.jsx)(`span`,{className:`font-mono text-fg-primary`,children:l})]})]}),u!==void 0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(mC,{divided:!0,children:`Deployments`}),(0,Y.jsx)(`div`,{className:`pt-1`,children:(0,Y.jsx)(L6,{deployments:u,onDismiss:d??(()=>void 0)})})]}),f&&(0,Y.jsx)(`div`,{className:`px-4 pt-4`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:f,className:`inline-flex items-center gap-1.5 h-8 px-2.5 rounded-md text-xs text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(fae,{size:13}),`Sign out`]})})]})})}function R6({href:e,icon:t,label:n,description:r}){return(0,Y.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-start gap-2 -mx-2 px-2 py-1.5 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:[(0,Y.jsx)(t,{size:13,className:`mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary`,children:n}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:r})]}),(0,Y.jsx)(Zv,{size:11,className:`mt-0.5 shrink-0`})]})}function XKe({label:e,description:t,checked:n,onChange:r}){return(0,Y.jsxs)(`label`,{className:`flex gap-2.5 cursor-pointer`,children:[(0,Y.jsx)(UT,{checked:n,onCheckedChange:e=>r(e===!0),className:`mt-0.5 w-3.5 h-3.5 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary`,children:e}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:t})]})]})}function ZKe({breakpoint:e,saveState:t,mode:n,autoSave:r,onAutoSaveChange:i,branch:a,deployments:o,deploymentsOpen:s=!1,onDeploymentsOpenChange:c,deploymentsAutoOpened:l=!1,onDismissDeployment:u}){return(0,Y.jsxs)(`footer`,{className:X(`absolute z-full bottom-3 right-3 h-9 flex items-center gap-3 px-3 rounded-lg`,`bg-bg-float border border-border-float shadow-sm text-xs text-fg-secondary`,e===`desktop`?`left-[4.75rem]`:`left-3`),children:[n===`fs`&&(0,Y.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 cursor-pointer select-none`,children:[(0,Y.jsx)(UT,{checked:r,onCheckedChange:e=>i(e===!0),className:`w-3.5 h-3.5`}),`Auto save`,(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:(0,Y.jsx)(`span`,{className:`hidden lg:inline text-fg-secondary-alt`,children:(0,Y.jsx)(cy,{size:12})})}),(0,Y.jsx)(Xg,{children:`Changes are written to your working tree on a pause in typing.`})]})]}),a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z6,{}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-mono`,children:[(0,Y.jsx)($ie,{size:13,className:`text-fg-secondary-alt`}),a]})]}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[n===`http`&&o!==void 0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(WKe,{deployments:o,open:s,onOpenChange:c??(()=>void 0),onDismiss:u??(()=>void 0),autoClose:l}),(0,Y.jsx)(z6,{})]}),n===`fs`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(Iae,{size:13,className:`text-fg-secondary-alt`}),`Dev mode`]}),(0,Y.jsx)(z6,{})]}),(0,Y.jsx)(QKe,{saveState:t,breakpoint:e})]})]})}function z6(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-px h-4 bg-border-float`})}function QKe({saveState:e,breakpoint:t}){return e===`saving`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(Vie,{size:13,className:`text-fg-secondary-alt animate-pulse`}),`Saving…`]}):e===`error`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-fg-error-on-surface`,children:[(0,Y.jsx)(zie,{size:13}),`Could not save`]}):(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-bg-brand-secondary`}),t===`tablet`?`Saved locally`:`All changes saved locally`]})}function $Ke({breakpoint:e,activity:t=[],validationErrors:n=[],onSelectValidationError:r,onNewPage:i,onUploadMedia:a,onOpenAI:o,destinations:s,onCompare:c,reviewCount:l,onDiscardAll:u,discardAllDescription:d,portalContainer:f,pendingChanges:p=0,onSelectActivity:m,onClose:h}){let g=e=>s===void 0||s.includes(e);return(0,Y.jsx)(pC,{side:`right`,width:260,title:`Quick actions`,mobileVariant:`bottom-sheet`,breakpoint:e,onClose:h,children:(0,Y.jsxs)(`div`,{className:`pb-4`,children:[n.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(mC,{className:`pt-3 text-fg-error-on-surface`,children:[`Validation errors`,(0,Y.jsx)(`span`,{className:`ml-1.5 font-normal normal-case tracking-normal tabular-nums`,children:n.reduce((e,t)=>e+t.count,0)})]}),(0,Y.jsx)(`ul`,{className:`px-3 pt-0.5`,children:n.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r?.(e),className:`flex gap-2 w-full px-1.5 py-1.5 rounded-md text-left hover:bg-bg-float-raised`,children:[(0,Y.jsx)(Ly,{size:13,className:`mt-0.5 shrink-0 text-fg-error-on-surface`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary truncate`,children:e.title}),(0,Y.jsx)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt truncate`,children:e.detail})]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-[0.6875rem] tabular-nums text-fg-secondary-alt`,children:e.count})]})},e.id))}),(0,Y.jsx)(mC,{divided:!0,children:`Quick actions`})]}),(0,Y.jsxs)(`div`,{className:`px-3 pt-3 space-y-0.5`,children:[c&&p>0&&e===`mobile`&&(0,Y.jsx)(B6,{icon:ny,label:l===void 0||l>0?`Review ${l??p} ${(l??p)===1?`change`:`changes`}`:`Review changes`,onClick:c}),u&&p>0&&(0,Y.jsx)(eqe,{count:p,description:d,onConfirm:u,portalContainer:f}),g(`pages`)&&(0,Y.jsx)(B6,{icon:Xie,label:`New page`,onClick:i}),g(`media`)&&(0,Y.jsx)(B6,{icon:sae,label:`Upload media`,onClick:a})]}),(0,Y.jsx)(mC,{divided:!0,children:`Recent activity`}),t.length===0?(0,Y.jsx)(hC,{children:`No recent activity. Your changes will show up here.`}):(0,Y.jsx)(`ul`,{className:`px-3 pt-0.5`,children:t.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>m(e),className:`flex gap-2 w-full px-1.5 py-1.5 rounded-md text-left hover:bg-bg-float-raised`,children:[(0,Y.jsx)(Wv,{size:13,className:`mt-0.5 shrink-0 text-fg-secondary-alt`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block text-xs text-fg-primary truncate`,children:e.title}),(0,Y.jsxs)(`span`,{className:`block text-[0.6875rem] text-fg-secondary-alt`,children:[e.author?`${e.author} · `:``,e.timestamp]})]})]})},e.id))}),o&&(0,Y.jsx)(`div`,{className:`px-3 pt-4`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:o,className:`flex items-center gap-2 w-full h-8 px-2 rounded-md text-xs text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(Ny,{size:14}),`Ask the assistant`]})})]})})}function eqe({count:e,description:t,onConfirm:n,portalContainer:r}){let[i,a]=(0,b.useState)(!1),o=`Discard ${e} ${e===1?`change`:`changes`}`;return(0,Y.jsxs)(SD,{open:i,onOpenChange:a,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full h-8 px-2 rounded-md text-xs text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:[(0,Y.jsx)(zy,{size:14,className:`text-fg-secondary-alt`}),o]})}),(0,Y.jsxs)(wD,{container:r,align:`start`,className:`w-64 flex flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-xs font-semibold text-fg-primary`,children:`${o}?`}),t!==void 0&&(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-fg-secondary`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`sm`,onClick:()=>a(!1),children:`Cancel`}),(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{a(!1),n()},children:`Discard ${e}`})]})]})]})}function B6({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 w-full h-8 px-2 rounded-md text-xs text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(e,{size:14,className:`text-fg-secondary-alt`}),t]})}function V6({isOpen:e,children:t,duration:n=.3,className:r}){return(0,Y.jsx)(`div`,{style:{transition:`grid-template-rows ${n}s`},className:(0,AC.default)(`grid overflow-hidden`,r,{"grid-rows-[0fr]":!e,"grid-rows-[1fr]":e}),children:(0,Y.jsx)(`div`,{style:{transition:`visibility ${n}s`},className:(0,AC.default)(`min-h-0`,{visible:e,invisible:!e}),children:t})})}function tqe(e){return e.length===0?`/`:`/`+e.map(e=>{if(e.type===`literal`)return e.name;let t=e.type===`string-param`?e.paramName:`...${e.paramName}`;return e.optional?`[[${t}]]`:`[${t}]`}).join(`/`)}function nqe(e,t){let n=e=>({id:e.sourcePath??e.urlPath,name:e.name,urlPath:e.urlPath,sourcePath:e.sourcePath,errorCount:e.errors?.ownCount,hasDraft:e.moduleFilePath?t.has(e.moduleFilePath):void 0,isTracked:e.sourcePath!==void 0,children:e.children.map(n)});return e.sourcePath===void 0?e.children.map(n):[n(e)]}function rqe(e){return e?Object.entries(e).map(([e,t])=>({id:t,name:mqe(e),url:e,sourcePath:t})):[]}function iqe(e,t){let n=[],r=e=>{if(e.isDirectory){e.children.forEach(r);return}n.push({id:e.fullPath,name:q6(e.name),moduleFilePath:e.fullPath,errorCount:e.errors?.ownCount,hasDraft:t.has(e.fullPath)})};return r(e),n}function aqe(e){if(!e)return[];let t=new Map;for(let n of Object.keys(e)){let[e]=n.split(`?`);t.set(e,(t.get(e)??0)+1)}return Array.from(t.entries()).map(([e,t])=>({id:e,title:q6(e),detail:e,count:t})).sort((e,t)=>t.count-e.count)}var oqe=8;function sqe(e,t){return e.slice(0,oqe).map((e,n)=>({id:`${e.moduleFilePath}?${e.patchPath.join(`/`)}-${n}`,sourcePath:H.joinModuleFilePathAndModulePath(e.moduleFilePath,H.patchPathToModulePath(e.patchPath)),title:[q6(e.moduleFilePath),...e.patchPath].join(` › `),timestamp:W6(e.lastUpdated,t),author:e.lastUpdatedBy??void 0}))}var cqe=10;function lqe(e,t,n,r){return e.slice(0,cqe).map(e=>({commitSha:e.commitSha,state:e.deploymentState,message:e.commitMessage,author:e.creator?n[e.creator]?.fullName:void 0,timestamp:W6(e.updatedAt,r),isLive:t.has(e.commitSha)}))}var uqe=60,H6=3600,U6=24*H6;function W6(e,t){let n=new Date(e).getTime();if(Number.isNaN(n))return e;let r=Math.round((t-n)/1e3);return r<0||r<45?`just now`:r<H6?G6(Math.round(r/uqe),`minute`):r<U6?G6(Math.round(r/H6),`hour`):G6(Math.round(r/U6),`day`)}function G6(e,t){return`${e} ${t}${e===1?``:`s`} ago`}function dqe(e){if(e)return Object.entries(e).map(([e,t])=>({ref:e,sourcePath:t})).sort((e,t)=>K6(e.ref).localeCompare(K6(t.ref)))}function K6(e){let t=e.split(`/`);return t[t.length-1]||e}function fqe(e){return e?Object.keys(e).length:0}function pqe(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]??e}function q6(e){return(e.split(`/`).pop()??e).replace(/\.val\.(ts|js)$/,``)}function mqe(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return e}}function hqe(e){if(!e?.project||!e.appHost)return;let t=e.project.split(`/`);if(t.length!==2||!t[0]||!t[1])return;let[n,r]=t,i=e.appHost.replace(/\/+$/,``);return{project:`${i}/~/${encodeURIComponent(n)}/${encodeURIComponent(r)}`,members:`${i}/manage-members/${encodeURIComponent(n)}`}}function gqe(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function _qe(e,t){if(t)return[`pages`,`media`,`data`];let n=[];return e.hasRouters&&n.push(`pages`),e.media.length>0&&n.push(`media`),e.data.length>0&&n.push(`data`),n}function vqe(e){let t=new Map,n=[],r=e=>{if((e.sourcePath||e.children.length===0)&&n.push(e.urlPath),e.canAddChild&&e.moduleFilePath&&e.routePattern){let n=tqe(e.routePattern),r=`${e.moduleFilePath}::${n}`;t.has(r)||t.set(r,{moduleFilePath:e.moduleFilePath,routePattern:e.routePattern,patternString:n,existingKeys:[],keyDescription:e.keyDescription})}for(let t of e.children)r(t)};return r(e),{routes:Array.from(t.values()).map(e=>({...e,existingKeys:n})),existingUrls:n}}function J6(e){return e<768?`mobile`:e<1200?`tablet`:`desktop`}function yqe(){let[e,t]=(0,b.useState)(()=>typeof window>`u`?`desktop`:J6(window.innerWidth));return(0,b.useEffect)(()=>{let e=()=>t(J6(window.innerWidth));return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}var bqe=()=>({total:0,settled:0,unfetched:[],unapplied:[],failed:[],statSeen:!0}),xqe=5;function Sqe({data:e,initialPanel:t=null,initialSelectionId:n=null,initialSearchOpen:r=!1,theme:i,onThemeChange:a,mode:o,saveState:s=`saved`,autoSave:c=!1,onAutoSaveChange:l=()=>void 0,isDevMode:u=!0,pendingChanges:d=12,reviewCount:f,publishState:p=`idle`,isLoading:m=!1,loadError:h,initialDeploymentsOpen:g=!1,canvasPage:_,renderCanvas:v,canvasPaths:y,onSelectCanvasPath:x,selectedCanvasPath:S,canvasRoute:C,onCanvasRouteChange:w,canvasRoutes:T,initialCanvasTransform:E,onViewStateChange:D,initialCanvasOpen:O=!1,initialCanvasView:k=`normal`,restoreViewState:A,skipTransition:j,selectionId:M,onSelectionChange:N,renderEditor:P,editorOverride:F,onPublish:I,publishSlot:L,onPreview:R,previewHref:ee,onSignOut:te,accountError:ne,aiEnabled:re=!1,aiSlot:ie,onMentionField:ae,pendingChangesLoaded:oe=!0,pendingChangesProgress:se,pendingChangesError:ce=null,onSelectValidationError:le,onSelectActivity:ue,onNewPage:de,onUploadMedia:fe,onCompare:pe,onDiscardAll:me,discardAllDescription:he,portalContainer:ge,getMediaFileUrl:_e,searchContentResults:ve,isSearchingContent:ye,onSearchQueryChange:be,onOpenSearchResult:xe}){let Se=yqe(),[Ce,we]=(0,b.useState)(t),[z,B]=(0,b.useState)(e.notifications??[]),Te=M!==void 0,[Ee,V]=(0,b.useState)(()=>n?$6(e,n):null),De=(0,b.useMemo)(()=>M?$6(e,M):null,[M,e]),Oe=Te?De:Ee,[ke,Ae]=(0,b.useState)(r),[je,Me]=(0,b.useState)(O),[Ne,Pe]=(0,b.useState)(k),[Fe,Ie]=(0,b.useState)(O?`canvas`:`editor`),[Le,Re]=(0,b.useState)(E??null),ze=A?.epoch,Be=(0,b.useRef)(A);Be.current=A,(0,b.useEffect)(()=>{let e=Be.current;e!==void 0&&(we(e.panel),Me(e.canvasOpen),Pe(e.canvasView),Ie(e.canvasOpen?`canvas`:`editor`))},[ze]),(0,b.useEffect)(()=>{D?.({panel:Ce,canvasOpen:je,canvasView:Ne,canvasTransform:Le})},[D,Ce,je,Ne,Le]);let[Ve,He]=(0,b.useState)(g),[Ue,We]=(0,b.useState)(!1),Ge=(0,b.useCallback)(e=>{He(e),We(!1)},[]),[Ke,qe]=(0,b.useState)(()=>new Set),Je=(0,b.useCallback)(e=>{qe(t=>new Set(t).add(e))},[]),Ye=(0,b.useMemo)(()=>e.deployments?.filter(e=>!Ke.has(e.commitSha)),[e.deployments,Ke]),Xe=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(e.deployments===void 0)return;let t=new Set(e.deployments.map(e=>e.commitSha)),n=Xe.current;Xe.current=t,n!==null&&e.deployments.some(e=>!n.has(e.commitSha))&&(He(!0),We(!0))},[e.deployments]);let Ze=(0,b.useCallback)(()=>Ae(!0),[]);hKe(Ze);let Qe=(0,b.useMemo)(()=>pKe(e),[e]),$e=(0,b.useMemo)(()=>(e.activity??[]).slice(0,xqe).map(e=>({id:e.sourcePath,kind:`recent`,label:e.title,detail:e.author?`${e.timestamp} · ${e.author}`:e.timestamp})),[e.activity]),et=(0,b.useMemo)(()=>_qe(e,m),[m,e]);(0,b.useEffect)(()=>{Ce!==null&&(Ce===`pages`||Ce===`media`||Ce===`data`)&&!et.includes(Ce)&&we(null)},[Ce,et]),(0,b.useEffect)(()=>{Ce===`ai`&&!re&&we(null)},[Ce,re]);let tt=(0,b.useMemo)(()=>e.validationErrors.reduce((e,t)=>e+t.count,0),[e.validationErrors]),nt=(0,b.useMemo)(()=>z.filter(e=>e.unread).length,[z]),rt=v!==void 0||_!==void 0,it=(0,b.useCallback)(()=>{if(Se!==`mobile`){Me(e=>!e);return}if(!je){Me(!0),Ie(`canvas`);return}Ie(e=>e===`canvas`?`editor`:`canvas`)},[Se,je]),at=(0,b.useCallback)(()=>{Me(!1),Pe(`normal`),Ie(`editor`)},[]),ot=(0,b.useCallback)(e=>{we(`ai`),ae?.(e)},[ae]),st=(0,b.useMemo)(()=>cKe(y),[y]),ct=(0,b.useMemo)(()=>lKe(st),[st]),lt=(0,b.useRef)({canvasModules:ct,editedPath:S??null});lt.current={canvasModules:ct,editedPath:S??null},(0,b.useEffect)(()=>{m||sKe({selectionKind:Oe?.kind??null,...lt.current})||(Me(!1),Pe(`normal`),Ie(`editor`))},[m,Oe?.kind]);let ut=(0,b.useCallback)(()=>we(null),[]),dt=(0,b.useCallback)(e=>{we(t=>t===e?null:e)},[]),ft=(0,b.useCallback)(e=>{Te||V(e),N?.(e),Se===`mobile`&&we(null)},[Se,Te,N]),pt=(0,b.useCallback)(t=>{let n=$6(e,t.id);if(n){ft(n);return}xe?.(t)},[e,ft,xe]),mt=Se===`mobile`?(0,Y.jsx)(AKe,{openPanel:Ce,onSelect:we,destinations:et}):void 0;return(0,Y.jsxs)(`div`,{"data-mode":i,className:`relative w-full overflow-hidden bg-bg-canvas text-fg-primary font-sans`,style:{height:`100svh`},children:[(0,Y.jsx)(nKe,{breakpoint:Se,page:rt?_:void 0,renderCanvas:rt?v:void 0,canvasPaths:rt?y:void 0,onSelectCanvasPath:x,selectedCanvasPath:S,canvasRoute:rt?C:void 0,onCanvasRouteChange:w,canvasRoutes:T,initialTransform:E,onTransformChange:Re,isCanvasOpen:je&&rt,onCloseCanvas:at,view:Ne,onViewChange:Pe,pane:Fe,onPaneChange:Ie,isDevMode:u,onAttachToChat:re?ot:void 0,skipTransition:j,children:F||(Oe===null?(0,Y.jsx)(Jce,{}):(0,Y.jsx)(PKe,{ready:oe,progress:se??bqe,fetchError:ce,children:P?P(Oe):(0,Y.jsx)(Yce,{title:Oe.title,urlPath:Oe.urlPath,sourcePath:Oe.sourcePath,isDevMode:u,hasDraft:Oe.hasDraft})}))}),Se===`desktop`&&(0,Y.jsx)(_Ke,{openPanel:Ce,onSelect:dt,destinations:et,user:e.user,hasDraftChanges:d>0,accountError:ne,isLoading:m}),(0,Y.jsx)(EKe,{breakpoint:Se,projectName:e.projectName,projectHref:e.admin?.project,openPanel:Ce,onTogglePanel:dt,onOpenMenu:()=>we(et[0]??`settings`),onOpenSearch:Ze,unreadNotifications:e.notifications===void 0?void 0:nt,user:Se===`desktop`?void 0:e.user,accountError:Se===`desktop`?void 0:ne,isLoading:m,aiEnabled:re,onPreview:R??(()=>void 0),previewHref:ee,onToggleCanvas:rt?it:void 0,isCanvasOpen:je,onPublish:I??(()=>void 0),publishSlot:L,pendingChanges:d,onCompare:pe,reviewCount:f??d,publishState:p===`idle`&&tt>0?`blocked`:p}),Se===`mobile`?(0,Y.jsx)(jKe,{pendingChanges:d,onPreview:R??(()=>void 0),previewHref:ee,onToggleCanvas:rt?it:void 0,isCanvasOpen:je,canvasActionLabel:je?Fe===`canvas`?`Back to the editor`:`Back to the preview`:`Open the canvas`,onExitCanvas:je?at:void 0,onPublish:I??(()=>void 0),publishSlot:L,onOpenStatus:()=>we(`settings`),onOpenQuickActions:()=>we(`utility`)}):(0,Y.jsx)(ZKe,{breakpoint:Se,saveState:s,mode:o,autoSave:c,onAutoSaveChange:l,branch:e.branch,deployments:Ye,deploymentsOpen:Ve,onDeploymentsOpenChange:Ge,deploymentsAutoOpened:Ue,onDismissDeployment:Je}),Ce===`pages`&&(0,Y.jsx)(VKe,{breakpoint:Se,pages:e.pages,externalPages:e.externalPages,selectedId:Oe?.id??null,onSelectPage:e=>{let t=Y6(e);t&&ft(t)},onSelectExternalPage:e=>{let t=X6(e);t&&ft(t)},onNewPage:de??(()=>void 0),newPage:de?e.newPage:void 0,onClose:ut,navSwitcher:mt,isLoading:m,loadError:h}),Ce===`media`&&(0,Y.jsx)(vKe,{breakpoint:Se,media:e.media,selectedId:Oe?.id??null,onSelect:e=>ft(Z6(e)),onSelectFile:(e,t)=>ft({kind:`media`,id:t.sourcePath,title:t.ref.split(`/`).pop()??t.ref,urlPath:aA(e.directory),sourcePath:t.sourcePath}),getFileUrl:_e,onUpload:fe,onClose:ut,navSwitcher:mt,isLoading:m,loadError:h}),Ce===`data`&&(0,Y.jsx)(Kce,{breakpoint:Se,data:e.data,selectedId:Oe?.id??null,onSelect:e=>ft(Q6(e)),onClose:ut,navSwitcher:mt,isLoading:m,loadError:h}),Ce===`settings`&&(0,Y.jsx)(YKe,{breakpoint:Se,mode:o,user:e.user,accountError:ne,theme:i,onThemeChange:a,admin:e.admin,autoSave:c,onAutoSaveChange:l,branch:e.branch,deployments:o===`fs`?void 0:Ye,onDismissDeployment:Je,onSignOut:te,onClose:ut,navSwitcher:mt}),Ce===`utility`&&(0,Y.jsx)($Ke,{breakpoint:Se,activity:e.activity,validationErrors:e.validationErrors,onSelectValidationError:le??(()=>void 0),onNewPage:()=>we(`pages`),onUploadMedia:()=>we(`media`),destinations:et,onOpenAI:re?()=>we(`ai`):void 0,onCompare:pe,reviewCount:f??d,onDiscardAll:me,discardAllDescription:he,portalContainer:ge,pendingChanges:d,onSelectActivity:ue??(()=>void 0),onClose:ut}),re&&(0,Y.jsx)(Vce,{breakpoint:Se,hidden:Ce!==`ai`,onClose:ut,children:ie??(0,Y.jsx)(Cqe,{})}),Ce===`notifications`&&(0,Y.jsx)(RKe,{breakpoint:Se,notifications:z,onSelect:e=>B(t=>t.map(t=>t.id===e.id?{...t,unread:!1}:t)),onMarkAllRead:()=>B(e=>e.map(e=>({...e,unread:!1}))),onClose:ut}),ke&&(0,Y.jsx)(mKe,{results:Qe,contentResults:ve,recentResults:$e,isSearchingContent:ye,onQueryChange:be,onSelect:e=>{Ae(!1),pt(e)},onClose:()=>Ae(!1)})]})}function Cqe(){return(0,Y.jsx)(`p`,{className:`p-4 text-xs text-fg-secondary-alt`,children:`No assistant is configured for this project.`})}function Y6(e){return e.sourcePath===void 0?null:{kind:`page`,id:e.id,title:e.name,urlPath:e.urlPath,sourcePath:e.sourcePath,hasDraft:e.hasDraft,isTracked:e.isTracked}}function X6(e){return e.sourcePath===void 0?null:{kind:`external`,id:e.id,title:e.name,urlPath:e.url,sourcePath:e.sourcePath}}function Z6(e){return{kind:`media`,id:e.id,title:e.name,urlPath:aA(e.directory),sourcePath:e.moduleFilePath}}function Q6(e){return{kind:`data`,id:e.id,title:e.name,urlPath:e.moduleFilePath,sourcePath:e.moduleFilePath,hasDraft:e.hasDraft}}function $6(e,t){let n=e=>{for(let r of e){if(r.id===t)return Y6(r);let e=n(r.children??[]);if(e)return e}return null},r=n(e.pages);if(r)return r;let i=e.externalPages.find(e=>e.id===t);if(i)return X6(i);let a=e.media.find(e=>e.id===t);if(a)return Z6(a);let o=e.data.find(e=>e.id===t);return o?Q6(o):null}var wqe=8e3;function Tqe({url:e,width:t,height:n,reloadKey:r,isPicking:i,highlightedPath:a,onElements:o,onPick:s,onPinch:c,onZoom:l,onRequestReload:u,onRefreshingChange:d}){let f=(0,b.useRef)(null),[p,m]=(0,b.useState)({status:`waiting`}),[h,g]=(0,b.useState)(!1),[_,v]=(0,b.useState)(0),y=(0,b.useRef)(null),x=(0,b.useMemo)(()=>yp(e),[e]),S=(0,b.useCallback)(e=>{f.current?.contentWindow?.postMessage(e,window.origin)},[]);(0,b.useEffect)(()=>{m({status:`waiting`}),d?.(!1)},[x,r,d]),(0,b.useEffect)(()=>{if(p.status!==`waiting`)return;let e=setTimeout(()=>m({status:`no-answer`}),wqe);return()=>clearTimeout(e)},[p.status,x,r]),(0,b.useEffect)(()=>{let e=e=>{if(e.source!==f.current?.contentWindow||!vp(e.data))return;let t=e.data;t.type===`ready`?(m({status:`ready`,draftMode:t.draftMode}),v(e=>e+1),g(!1)):t.type===`elements`?o?.(t.elements):t.type===`refreshing`?d?.(t.pending):t.type===`pinch`?c?.({phase:t.phase,span:t.span,center:t.center}):t.type===`zoom`?l?.(t.factor,t.center):(y.current=t.paths[0]??null,s?.(t.paths))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[o,s,c,l,d]),(0,b.useEffect)(()=>{S({val:_p,type:`setPicking`,picking:i})},[S,i,p.status]),(0,b.useEffect)(()=>{let e=a!==null&&a===y.current;y.current=null,S({val:_p,type:`highlight`,path:a,scrollIntoView:!e})},[S,a,p.status]);let C=(0,b.useCallback)(()=>{g(!0);let e=new URL(x,window.location.origin).toString(),t=`/api/val/enable?redirect_to=${encodeURIComponent(e)}`;f.current&&(f.current.src=t)},[x]),w=p.status===`ready`&&p.draftMode,T=(0,b.useCallback)((e,t)=>{S({val:_p,type:`sourceUpdate`,moduleFilePath:e,source:t})},[S]);Coe(w,T);let E=woe();(0,b.useEffect)(()=>{w&&(E(T),S({val:_p,type:`sourcesSynced`}))},[w,_,E,T,S]);let D=p.status===`ready`&&!p.draftMode||p.status===`no-answer`;return(0,Y.jsxs)(`div`,{style:{width:t,height:n},className:`relative bg-white`,children:[(0,Y.jsx)(`iframe`,{ref:f,src:x,title:`Preview of ${e}`,style:{width:t,height:n,border:`none`,display:`block`},referrerPolicy:`same-origin`},`${x}-${r}`),D&&(0,Y.jsx)(Eqe,{isEnabling:h,onEnable:C,onReload:u,unreachable:p.status===`no-answer`})]})}function Eqe({isEnabling:e,onEnable:t,onReload:n,unreachable:r}){return(0,Y.jsx)(`div`,{className:`absolute inset-0 grid place-items-center bg-bg-canvas/80 backdrop-blur-sm p-6`,children:(0,Y.jsxs)(`div`,{className:`max-w-sm rounded-lg border border-border-float bg-bg-float p-5 text-center shadow-lg`,children:[(0,Y.jsx)(`h3`,{className:`text-sm font-medium text-fg-primary`,children:r?`No answer from the page`:`Preview mode is off`}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-secondary`,children:r?`The page loaded but did not report back. It may be an older version of Val, preview mode may have been turned off elsewhere, or the app may not be wired up yet.`:`Without preview mode the canvas shows the published page, and nothing on it can be selected or edited.`}),r&&(0,Y.jsx)(Dqe,{}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center justify-center gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:t,disabled:e,className:X(`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium`,`bg-bg-brand-primary text-fg-brand-primary border border-border-brand-primary`,`hover:bg-bg-brand-primary-hover`,`disabled:bg-bg-disabled disabled:text-fg-disabled`),children:[e&&(0,Y.jsx)(hy,{size:13,className:`animate-spin`}),e?`Turning on…`:`Turn on preview mode`]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium text-fg-secondary border border-border-float hover:bg-bg-float-raised hover:text-fg-primary`,children:[(0,Y.jsx)(bae,{size:13}),`Reload`]})]})]})})}function Dqe(){return(0,Y.jsxs)(`details`,{className:`group mt-3 text-left`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer list-none text-xs text-fg-secondary-alt hover:text-fg-primary [&::-webkit-details-marker]:hidden`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(Rv,{size:12,className:`transition-transform group-open:rotate-90`,"aria-hidden":!0}),`Setup instructions`]})}),(0,Y.jsxs)(`div`,{className:`mt-2 rounded-md border border-border-float bg-bg-secondary p-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-secondary`,children:`The canvas talks to the page through Val's provider. If it never answers, check that:`}),(0,Y.jsxs)(`ol`,{className:`mt-2 list-decimal space-y-1.5 pl-4 text-xs leading-relaxed text-fg-secondary`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.6875rem] text-fg-primary`,children:`ValProvider`}),` `,`is in the ROOT layout —`,` `,(0,Y.jsx)(`code`,{className:`font-mono`,children:`app/layout.tsx`}),` — and therefore above every page it should preview. A provider inside a route group does not cover the pages outside it.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.6875rem] text-fg-primary`,children:`ValModulesClient`}),` `,`is rendered inside it, so the editor can read your schemas.`]}),(0,Y.jsxs)(`li`,{children:[`The API route exists at`,` `,(0,Y.jsx)(`code`,{className:`font-mono`,children:`app/(val)/api/val/[[...val]]/route.ts`}),`, since preview mode is turned on through it.`]}),(0,Y.jsx)(`li`,{children:`The page is not served from a different origin than the studio: the canvas and the page have to be able to talk to each other.`}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`font-mono`,children:`@valbuild/next`}),` and`,` `,(0,Y.jsx)(`code`,{className:`font-mono`,children:`@valbuild/core`}),` are on the same version, in the app and in the editor.`]})]}),(0,Y.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-fg-secondary-alt`,children:[`The setup guide has the whole layout:`,` `,(0,Y.jsx)(`a`,{href:`https://github.com/valbuild/val/blob/main/packages/next/MANUAL_CONFIGURATION.md`,target:`_blank`,rel:`noopener noreferrer`,className:`underline hover:text-fg-primary`,children:`manual configuration`}),`.`]})]})]})}function Oqe(e){return e.length===0||e.includes(`/`)?`/`:e[0]}function kqe(e){let t={"/":{name:`/`,fullPath:`/`,isDirectory:!0,children:[]}};for(let n of e){let e=n.split(`/`);if(e[0]!==``)throw Error(`Expected path to start with '/'`);for(let n=1;n<e.length;n++){let r=e.slice(0,n).join(`/`),i=[r,e[n]].join(`/`),a=e[n];if(!a)throw Error(`Expected name to be non-empty`);if(!t[i]){let o={name:a,fullPath:i,children:[]};n<e.length-1&&(o.isDirectory=!0),t[i]=o,t[r||`/`].children.push(t[i])}}}return t[`/`]}function Aqe(){let e=wb();return(0,b.useMemo)(()=>{if(e.status===`success`){let t=[],n={};for(let r in e.data){let i=r,a=e.data[i];a.type===`record`&&a.router?(n[a.router]=n[a.router]||[],n[a.router].push(i)):t.push(i)}return{status:e.status,data:{root:kqe(t),routers:n}}}return e},[e])}function jqe(e){return e?.type===`record`&&!!e.mediaType}function Mqe(e,t){let n=[];for(let r in e){let i=r,a=e[i];jqe(a)&&n.push({moduleFilePath:i,directory:a.directory??i,mediaType:a.mediaType,errors:t(i)})}return n.sort((e,t)=>e.directory.localeCompare(t.directory))}function e8(e,t,n){let r=e.get(t);if(r){r.ownCount+=n.length,r.firstMessage||=n[0]?.message;return}e.set(t,{ownCount:n.length,firstMessage:n[0]?.message})}function Nqe(e){let t=new Map,n=new Map;for(let r in e){let i=e[r];if(!i||i.length===0)continue;let[a,o]=H.splitModuleFilePathAndModulePath(r);e8(n,a,i);let s=H.splitModulePath(o),c=s.length>0?H.createValPathOfItem(a,s[0]):a;c&&e8(t,c,i)}return{byEntry:t,byModule:n}}function Pqe(e,t){return e.byEntry.get(t)}function t8(e,t){return e.byModule.get(t)}function n8(e,t,n){let r=!!e.pattern?.includes(`[`),i=r&&e.pattern?np(e.pattern):void 0,a=r?e.children.map(e=>`/`+e.name):void 0,o=e.sourcePath,s=o?Pqe(t,o):void 0,c=e.moduleFilePath,l=r&&c?n?.[c]:void 0,u=l?.type===`record`?l.key?.description:void 0,d=(e.type===`leaf`?e.fullPath:e.page?.fullPath)||e.pattern||`/`;return{name:e.name,urlPath:d,sourcePath:o,moduleFilePath:c,canAddChild:r,routePattern:i,existingKeys:a,keyDescription:u,errors:s,children:e.children.map(e=>n8(e,t,n))}}function r8(e,t,n){let r=!!e.isDirectory,i=!r&&e.fullPath?t8(t,e.fullPath):void 0;return{name:e.name,fullPath:e.fullPath,isDirectory:r,errors:i,children:e.children.filter(e=>!n.has(e.fullPath)).map(e=>r8(e,t,n))}}function Fqe(){let e=Aqe(),t=(0,b.useMemo)(()=>e.status===`success`&&e.data.routers[`next-app-router`]||[],[e]),n=cC(t,`record`),r=lC(),i=Fb(),a=wb();return(0,b.useMemo)(()=>{if(e.status!==`success`)return e;let o=Nqe(i??{}),s={hasRouters:Object.keys(e.data.routers).filter(t=>(e.data.routers[t]??[]).length>0).length>0};if(t.length>0){if(r.status===`success`&&r.data&&n.status===`success`&&n.data){let e=[];for(let t of n.data||[])for(let n in t){let[r]=H.splitModuleFilePathAndModulePath(t[n]);e.push({urlPath:n,moduleFilePath:r})}s.sitemap=n8(ep(r.data,e),o,a.status===`success`?a.data:void 0)}else if(r.status===`loading`||n.status===`loading`)return{status:`loading`}}let c=a.status===`success`?Mqe(a.data,e=>t8(o,e)):[];c.length>0&&(s.media=c);let l=new Set(c.map(e=>e.moduleFilePath));if(e.data.root&&e.data.root.children.length>0){let t=r8(e.data.root,o,l);t.children.length>0&&(s.explorer=t)}let u=e.data.routers[`external-url-router`];return u&&u.length>0&&(s.external={moduleFilePath:u[0]}),{status:`success`,data:s}},[e,t,r,n,i,a])}function Iqe(){let e=Fqe(),t=bb(),n=tC(),r=Fb(),i=US(),a=YS(),o=GS(),{deployments:s,observedCommitShas:c}=HS(),l=sC(),u=(0,b.useMemo)(()=>lqe(s,c,l,Date.now()),[s,c,l]),d=e.status===`success`?e.data:void 0,f=d?.external?.moduleFilePath,p=(0,b.useMemo)(()=>(d?.media??[]).map(e=>e.moduleFilePath),[d?.media]),m=cC((0,b.useMemo)(()=>(f?[f]:[]).concat(p),[f,p]),`record`),h=(0,b.useMemo)(()=>i.status===`success`?new Set(i.data.map(e=>e.moduleFilePath)):new Set,[i]);return(0,b.useMemo)(()=>{if(e.status===`loading`)return{status:`loading`};if(e.status===`error`)return{status:`error`,error:e.error};let s=d?.sitemap?vqe(d.sitemap):null,c=s&&s.routes.length>0?{routes:s.routes}:void 0,l=m.status===`success`?m.data:null,p=f?l?.[0]:void 0,g=l?.slice(+!!f)??[];return{status:`success`,data:{projectName:t?.project??`Val`,admin:hqe(t),branch:t?.gitBranch,hasRouters:d?.hasRouters??!1,pages:d?.sitemap?nqe(d.sitemap,h):[],newPage:c,externalPages:rqe(p),media:(d?.media??[]).map((e,t)=>({id:e.moduleFilePath,name:pqe(e.directory),directory:e.directory,moduleFilePath:e.moduleFilePath,mediaType:e.mediaType,itemCount:fqe(g[t]),files:dqe(g[t])})),data:d?.explorer?iqe(d.explorer,h):[],validationErrors:aqe(r),activity:i.status===`success`?sqe(i.data,Date.now()):void 0,pendingChanges:a.length-o.size,deployments:u,user:n?{name:n.fullName,email:n.email,initials:gqe(n.fullName)}:void 0}}},[e,d,m,f,t,n,r,i,h,a,o,u])}function i8(e,t){let n=e===1?`1 unpublished change in this project goes away`:`All ${e} unpublished changes in this project go away`;if(t.length>0){let e=t.slice(0,2),r=t.length-e.length;return`${n} — including changes made by ${r>0?`${e.join(`, `)} and ${r} ${r===1?`other`:`others`}`:e.join(` and `)}. This cannot be undone.`}return`${n}. This cannot be undone.`}var Lqe=20;function Rqe(e){let t=nb(),n=Db(),r=e.trim(),i=r!==``,a=PD(i),[o,s]=(0,b.useState)([]),[c,l]=(0,b.useState)(!1),u=a.status===`loading`?a.percentage:a.status;return(0,b.useEffect)(()=>{if(t===null||!i){s([]),l(!1);return}let e=!1;return l(!0),t.system.search(r,Lqe).then(t=>{e||s(t.status===`no-index`?[]:t.results)}).catch(()=>{e||s([])}).finally(()=>{e||l(!1)}),()=>{e=!0}},[t,r,i,u]),{results:(0,b.useMemo)(()=>{let e=new Set,t=[];for(let r of o){let i=n(r.path)||r.path;if(e.has(i))continue;e.add(i);let[a]=H.splitModuleFilePathAndModulePath(r.path);t.push({id:r.path,kind:`content`,label:r.label,detail:a})}return t},[o,n]),isSearching:i&&(c||a.status===`loading`)}}var zqe=[`pages`,`media`,`data`,`settings`,`utility`,`ai`,`notifications`],a8={panel:`panel`,canvasOpen:`canvas`,canvasRoute:`canvas-route`,canvasView:`canvas-view`,canvasTransform:`canvas-at`};function o8(e){let t=new URLSearchParams(e),n=t.get(a8.panel),r=t.get(a8.canvasView);return{panel:zqe.find(e=>e===n)??null,canvasOpen:t.get(a8.canvasOpen)===`1`,canvasRoute:t.get(a8.canvasRoute),canvasView:r===`fields`?`fields`:`normal`,canvasTransform:Bqe(t.get(a8.canvasTransform))}}function Bqe(e){if(e===null)return null;let t=e.split(`,`).map(e=>Number.parseFloat(e));if(t.length!==3||t.some(e=>!Number.isFinite(e)))return null;let[n,r,i]=t;return n<=0?null:{scale:n,x:r,y:i}}function Vqe(e){return[e.scale.toFixed(2),Math.round(e.x),Math.round(e.y)].join(`,`)}function Hqe(e,t){let n=new URLSearchParams(e),r=(e,t)=>{t===null?n.delete(e):n.set(e,t)};r(a8.panel,t.panel),r(a8.canvasOpen,t.canvasOpen?`1`:null),r(a8.canvasRoute,t.canvasRoute),r(a8.canvasView,t.canvasView===`fields`?`fields`:null),r(a8.canvasTransform,t.canvasTransform===null?null:Vqe(t.canvasTransform));let i=n.toString();return i?`?${i}`:``}function Uqe(e,t){return e.canvasOpen===t.canvasOpen?`replace`:`push`}function Wqe(){let[e]=(0,b.useState)(()=>o8(typeof window>`u`?``:window.location.search));return{initial:e,write:(0,b.useCallback)((e,t=`replace`)=>{if(typeof window>`u`)return;let n=Hqe(window.location.search,e),r=`${window.location.pathname}${n}${window.location.hash}`;r!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&(t===`push`?window.history.pushState(null,``,r):window.history.replaceState(null,``,r))},[])}}function Gqe(e,t){let n=(0,b.useMemo)(()=>JSON.stringify(t),[t]);(0,b.useEffect)(()=>{let t=setTimeout(()=>{let t=JSON.parse(n);e(t,Uqe(typeof window>`u`?t:o8(window.location.search),t))},250);return()=>clearTimeout(t)},[n,e])}var s8=b.forwardRef(({...e},t)=>(0,Y.jsx)(`nav`,{ref:t,"aria-label":`breadcrumb`,...e}));s8.displayName=`Breadcrumb`;var c8=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`ol`,{ref:n,className:X(`flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5`,e),...t}));c8.displayName=`BreadcrumbList`;var l8=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`li`,{ref:n,className:X(`inline-flex items-center gap-1.5`,e),...t}));l8.displayName=`BreadcrumbItem`;var Kqe=b.forwardRef(({asChild:e,className:t,...n},r)=>(0,Y.jsx)(e?fm:`a`,{ref:r,className:X(`transition-colors hover:text-foreground`,t),...n}));Kqe.displayName=`BreadcrumbLink`;var u8=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(`span`,{ref:n,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:X(`font-normal text-foreground`,e),...t}));u8.displayName=`BreadcrumbPage`;var d8=({children:e,className:t,...n})=>(0,Y.jsx)(`li`,{role:`presentation`,"aria-hidden":`true`,className:X(`[&>svg]:w-3.5 [&>svg]:h-3.5`,t),...n,children:e??(0,Y.jsx)(Rv,{})});d8.displayName=`BreadcrumbSeparator`;var f8=({className:e,...t})=>(0,Y.jsxs)(`span`,{role:`presentation`,"aria-hidden":`true`,className:X(`flex h-9 w-9 items-center justify-center`,e),...t,children:[(0,Y.jsx)(Jv,{className:`h-4 w-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`More`})]});f8.displayName=`BreadcrumbElipssis`;var qqe=Object.defineProperty,p8=(e,t)=>qqe(e,`name`,{value:t,configurable:!0}),m8,h8=`HoverCard`,[g8,Jqe]=sm(h8,[Vh]),_8=Vh(),[Yqe,v8]=g8(h8),Xqe=p8(e=>{let{__scopeHoverCard:t,children:n,open:r,defaultOpen:i,onOpenChange:a,openDelay:o=700,closeDelay:s=300}=e,c=_8(t),l=b.useRef(0),u=b.useRef(0),d=b.useRef(!1),f=b.useRef(!1),[p,m]=ng({prop:r,defaultProp:i??!1,onChange:a,caller:h8}),h=b.useCallback(()=>{clearTimeout(u.current),l.current=window.setTimeout(()=>m(!0),o)},[o,m]),g=b.useCallback(()=>{clearTimeout(l.current),!d.current&&!f.current&&(u.current=window.setTimeout(()=>m(!1),s))},[s,m]),_=b.useCallback(()=>m(!1),[m]);return b.useEffect(()=>()=>{clearTimeout(l.current),clearTimeout(u.current)},[]),(0,Y.jsx)(Yqe,{scope:t,open:p,onOpenChange:m,onOpen:h,onClose:g,onDismiss:_,hasSelectionRef:d,isPointerDownOnContentRef:f,children:(0,Y.jsx)(Uh,{...c,children:n})})},`HoverCard`),Zqe=`HoverCardTrigger`,Qqe=b.forwardRef(p8(function(e,t){let{__scopeHoverCard:n,...r}=e,i=v8(Zqe,n),a=_8(n);return(0,Y.jsx)(Wh,{asChild:!0,...a,children:(0,Y.jsx)(xm.a,{"data-state":i.open?`open`:`closed`,...r,ref:t,onPointerEnter:Qp(e.onPointerEnter,S8(i.onOpen)),onPointerLeave:Qp(e.onPointerLeave,S8(i.onClose)),onFocus:Qp(e.onFocus,i.onOpen),onBlur:Qp(e.onBlur,i.onClose),onTouchStart:Qp(e.onTouchStart,e=>e.preventDefault())})})},`HoverCardTrigger`)),y8=`HoverCardPortal`,[$qe,eJe]=g8(y8,{forceMount:void 0}),tJe=p8(e=>{let{__scopeHoverCard:t,forceMount:n,children:r,container:i}=e,a=v8(y8,t);return(0,Y.jsx)($qe,{scope:t,forceMount:n,children:(0,Y.jsx)(Jh,{present:n||a.open,children:(0,Y.jsx)(Kh,{asChild:!0,container:i,children:r})})})},`HoverCardPortal`),b8=`HoverCardContent`,nJe=b.forwardRef(p8(function(e,t){let n=eJe(b8,e.__scopeHoverCard),{forceMount:r=n.forceMount,...i}=e,a=v8(b8,e.__scopeHoverCard);return(0,Y.jsx)(Jh,{present:r||a.open,children:(0,Y.jsx)(rJe,{"data-state":a.open?`open`:`closed`,...i,onPointerEnter:Qp(e.onPointerEnter,S8(a.onOpen)),onPointerLeave:Qp(e.onPointerLeave,S8(a.onClose)),ref:t})})},`HoverCardContent`)),rJe=b.forwardRef(p8(function(e,t){let{__scopeHoverCard:n,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,...s}=e,c=v8(b8,n),l=_8(n),u=b.useRef(null),d=am(t,u),[f,p]=b.useState(!1);return b.useEffect(()=>{if(f){let e=document.body;return m8=e.style.userSelect||e.style.webkitUserSelect,e.style.userSelect=`none`,e.style.webkitUserSelect=`none`,()=>{e.style.userSelect=m8,e.style.webkitUserSelect=m8}}},[f]),b.useEffect(()=>{if(u.current){let e=p8(()=>{p(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==``&&(c.hasSelectionRef.current=!0)})},`handlePointerUp`);return document.addEventListener(`pointerup`,e),()=>{document.removeEventListener(`pointerup`,e),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),b.useEffect(()=>{u.current&&C8(u.current).forEach(e=>e.setAttribute(`tabindex`,`-1`))}),(0,Y.jsx)(Om,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:o,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:Qp(a,e=>{e.preventDefault()}),onDismiss:c.onDismiss,children:(0,Y.jsx)(Gh,{...l,...s,onPointerDown:Qp(s.onPointerDown,e=>{e.currentTarget.contains(e.target)&&p(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:d,style:{...s.style,userSelect:f?`text`:void 0,WebkitUserSelect:f?`text`:void 0,"--radix-hover-card-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-hover-card-content-available-width":`var(--radix-popper-available-width)`,"--radix-hover-card-content-available-height":`var(--radix-popper-available-height)`,"--radix-hover-card-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-hover-card-trigger-height":`var(--radix-popper-anchor-height)`}})})},`HoverCardContentImpl`)),x8=b.forwardRef(p8(function(e,t){let{__scopeHoverCard:n,...r}=e,i=_8(n);return(0,Y.jsx)(gne,{...i,...r,ref:t})},`HoverCardArrow`));function S8(e){return t=>t.pointerType===`touch`?void 0:e()}p8(S8,`excludeTouch`);function C8(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:p8(e=>e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}p8(C8,`getTabbableNodes`);var iJe=Xqe,aJe=Qqe,oJe=tJe,w8=nJe,T8=iJe,E8=aJe,D8=b.forwardRef(({className:e,align:t=`center`,sideOffset:n=4,container:r,...i},a)=>(0,Y.jsx)(oJe,{container:r,children:(0,Y.jsx)(w8,{ref:a,align:t,sideOffset:n,className:X(`z-50 w-64 text-xs rounded-md border border-border-secondary`,`bg-bg-secondary-hover text-fg-secondary p-4`,`data-[state=open]:animate-in data-[state=closed]:animate-out`,`data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0`,`data-[state=open]:zoom-in-95 data-[state=closed]:zoom-out-95`,`data-[side=top]:slide-in-from-bottom-2`,`data-[side=bottom]:slide-in-from-top-2`,`data-[side=left]:slide-in-from-right-2`,`data-[side=right]:slide-in-from-left-2`,e),...i})}));D8.displayName=w8.displayName;function sJe({size:e,type:t,className:n}){if(t===`loading`)return(0,Y.jsx)(hy,{size:e,className:n});switch(t){case`string`:return(0,Y.jsx)(Ry,{size:e,className:n});case`number`:return(0,Y.jsx)(oy,{size:e,className:n});case`boolean`:return(0,Y.jsx)(Rae,{size:e,className:n});case`object`:return(0,Y.jsx)(uae,{size:e,className:n});case`literal`:return(0,Y.jsx)(Kv,{size:e,className:n});case`array`:return(0,Y.jsx)(my,{size:e,className:n});case`union`:return(0,Y.jsx)(Oae,{size:e,className:n});case`richtext`:return(0,Y.jsx)($v,{size:e,className:n});case`record`:return(0,Y.jsx)(Nae,{size:e,className:n});case`keyOf`:return(0,Y.jsx)(lae,{size:e,className:n});case`file`:return(0,Y.jsx)(ey,{size:e,className:n});case`date`:return(0,Y.jsx)(Pv,{size:e,className:n});case`dateTime`:return(0,Y.jsx)(Wv,{size:e,className:n});case`color`:return(0,Y.jsx)(_ae,{size:e,className:n});case`code`:return(0,Y.jsx)(qie,{size:e,className:n});case`image`:return(0,Y.jsx)(sy,{size:e,className:n});default:return(0,Y.jsx)(Hv,{size:e,className:n})}}function cJe({path:e,size:t}){let n=Cb(e),r=`data`in n&&n.data?n.data.type:`loading`,i=Cb(H.parentOfSourcePath(e)),a=`data`in i&&i.data?.type===`array`,o=`data`in i&&i.data?.type===`record`&&!!i.data?.router,[,s]=H.splitModuleFilePathAndModulePath(e),c=H.splitModulePath(s).pop(),l=a?`#${c}`:c;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 w-full`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-tertiary`,children:[o?(0,Y.jsx)(ry,{size:12}):(0,Y.jsx)(sJe,{type:r,size:12}),(0,Y.jsx)(`span`,{children:l})]}),(0,Y.jsx)(X3,{path:e,size:t})]})}function lJe({results:e,onSelect:t,indexing:n}){let r=Db(),i=n?.status===`loading`;return(0,Y.jsx)(ok,{className:`absolute top-full left-0 right-0 h-[min(420px,100vh-56px)]`,children:(0,Y.jsxs)(eD,{className:`h-[calc(min(420px,100vh-56px)-124px)] z-50 p-2 pb-0 bg-bg-primary border border-t-0 border-border-primary rounded-lg rounded-t-none shadow-lg `,children:[n?.status===`loading`&&(0,Y.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-tertiary`,children:[`Searching… `,n.percentage,`% indexed`]}),n?.status===`error`&&(0,Y.jsx)(`div`,{className:`px-3 py-2 text-xs text-fg-tertiary`,children:`Some content could not be loaded, so these results may be incomplete.`}),e.length===0&&!i&&(0,Y.jsx)(sk,{className:`py-6 text-center text-fg-tertiary`,children:`No results found.`}),e.map(e=>{let n=r(e.path)||e.path;return(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-px bg-border-primary opacity-50`}),(0,Y.jsx)(uk,{onSelect:()=>t(n),className:`flex flex-col justify-between px-3 py-2.5 aria-selected:bg-bg-secondary hover:bg-bg-secondary transition-colors`,children:(0,Y.jsx)(cJe,{path:n,size:`compact`})})]},e.path)})]})})}function uJe({container:e}){let[t,n]=(0,b.useState)(!1),r=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=e=>{if(e.key===`k`&&(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey){let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)return;e.preventDefault(),n(!0)}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let{navigate:i}=GC();return(0,Y.jsx)(Uy,{open:t,onOpenChange:n,modal:!1,children:(0,Y.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,Y.jsx)(Hae,{className:`w-full`,onClick:()=>n(!0),children:(0,Y.jsx)(dJe,{})}),(0,Y.jsx)(Wy,{container:e??r.current,children:(0,Y.jsxs)(Cv,{className:`top-full absolute left-0 bg-bg-primary -translate-y-full z-[8999] w-full`,children:[(0,Y.jsx)(Gy,{}),(0,Y.jsx)(fJe,{onSelect:e=>{i(e),n(!1)},onDeactivate:()=>n(!1)})]})})]})})}function dJe(){return(0,Y.jsx)(`div`,{className:`rounded-lg border border-border-primary shadow-sm overflow-visible cursor-text`,children:(0,Y.jsxs)(`div`,{className:`flex items-center justify-center px-3`,children:[(0,Y.jsx)(My,{className:`w-4 h-4 mr-2 opacity-50 shrink-0`}),(0,Y.jsx)(`span`,{className:X(`flex h-11 w-full rounded-md py-3 text-sm`,`text-fg-secondary cursor-text`,`leading-[21px]`),children:`Search content...`})]})})}function fJe({onSelect:e,onDeactivate:t}){let n=nb(),[r,i]=(0,b.useState)(``),a=(0,b.useRef)(null),[o,s]=(0,b.useState)([]),c=r.trim()!==``,l=PD(c),u=l.status===`loading`?l.percentage:l.status;(0,b.useEffect)(()=>{if(n===null||!c){s([]);return}let e=!1;return n.system.search(r,10).then(t=>{e||s(t.status===`no-index`?[]:t.results)}).catch(()=>{e||s([])}),()=>{e=!0}},[n,r,c,u]);let d=(0,b.useCallback)(n=>{e(n),i(``),t?.()},[e,t]),f=Db(),p=(0,b.useMemo)(()=>{let e=new Set,t=[];for(let n of o){let r=f(n.path)||n.path;e.has(r)||(t.push(n),e.add(r))}return t},[o,f]);return(0,b.useEffect)(()=>{let e=setTimeout(()=>{a.current?.focus()},0);return()=>clearTimeout(e)},[]),(0,Y.jsx)(`div`,{className:`relative w-full overflow-visible`,children:(0,Y.jsxs)(ik,{className:X(`rounded-lg border border-border-primary shadow-sm overflow-visible`,{"border-b-0 rounded-b-none pb-[1px]":!!r.trim()}),shouldFilter:!1,children:[(0,Y.jsx)(ak,{ref:a,placeholder:`Search content...`,value:r,onValueChange:i}),c&&(0,Y.jsx)(lJe,{results:p,onSelect:d,indexing:l})]},`search-command`)})}function O8(e,t){let{navigate:n,hrefOf:r}=GC(),i=t?.scrollToPath,a=t?.errorFields,o=(0,b.useCallback)(t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),n(e,{scrollToPath:i,errorFields:a}))},[n,e,i,a]);return{href:r(e,{scrollToPath:i,errorFields:a}),onClick:o}}function k8({part:e,isParent:t,className:n}){let r=O8(e.sourcePath),i=fk(e.sourcePath)?.title?.trim()||e.text;return e.isDirectory?(0,Y.jsx)(`span`,{className:X(`truncate text-fg-quaternary`,n),children:i}):(0,Y.jsxs)(`a`,{...r,title:e.sourcePath,"aria-label":t?`Up one level, to ${i}`:void 0,className:X(`inline-flex min-w-0 items-center gap-0.5 rounded-sm text-fg-tertiary hover:text-fg-brand-primary hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,n),children:[t&&(0,Y.jsx)(Lv,{size:14,"aria-hidden":!0,className:`shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:i})]})}function A8(){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-fg-quaternary`,children:`/`})}function pJe({part:e}){let t=O8(e.sourcePath),n=fk(e.sourcePath)?.title?.trim()||e.text;return e.isDirectory?(0,Y.jsxs)(M3,{disabled:!0,className:`gap-1.5`,children:[(0,Y.jsx)(A8,{}),(0,Y.jsx)(`span`,{className:`truncate`,children:n})]}):(0,Y.jsx)(M3,{asChild:!0,className:`gap-1.5`,children:(0,Y.jsxs)(`a`,{...t,title:e.sourcePath,children:[(0,Y.jsx)(A8,{}),(0,Y.jsx)(`span`,{className:`truncate`,children:n})]})})}var mJe=3;function hJe({parts:e,portalContainer:t,className:n}){let r=e.length>0?e[e.length-1]:null,i=r!==null&&r.isDirectory!==!0?r:null,{visibleStart:a,collapsed:o,visibleEnd:s}=(0,b.useMemo)(()=>e.length<=mJe?{visibleStart:e,collapsed:[],visibleEnd:[]}:{visibleStart:e.slice(0,1),collapsed:e.slice(1,-2),visibleEnd:e.slice(-2)},[e]);return r===null?null:(0,Y.jsxs)(`nav`,{"aria-label":`Scope`,className:X(`flex min-w-0 items-center gap-1 text-xs text-fg-quaternary`,n),children:[a.map((e,t)=>(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(k8,{part:e,isParent:e===i}),(o.length>0||s.length>0||t<a.length-1)&&(0,Y.jsx)(A8,{})]},e.sourcePath+t)),o.length>0&&(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{"aria-label":`${o.length} more levels`,className:`rounded-sm px-0.5 text-fg-tertiary hover:text-fg-brand-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:`…`}),(0,Y.jsx)(j3,{align:`start`,container:t,children:o.map(e=>(0,Y.jsx)(pJe,{part:e},e.sourcePath))})]}),(0,Y.jsx)(A8,{})]}),s.map((e,t)=>(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Y.jsx)(k8,{part:e,isParent:e===i}),t<s.length-1&&(0,Y.jsx)(A8,{})]},e.sourcePath+t))]})}function j8({path:e,showModuleGalleryChild:t}){let n=Cb(e),{path:r,schema:i}=TD(e),a=Pb(e),o=XS(e),s=o?o.length>0:!1,c=sC(),l=(0,b.useMemo)(()=>{let e={};for(let t of o||[]){let n=t.authorId??`unknown`;e[n]||(e[n]=[]),e[n].push(t)}return e},[o]),u=eb(),d=TD(e);if((0,b.useMemo)(()=>!!(d.path!==e&&d.schema?.type===`record`&&d.schema.mediaType),[e,d]))return(0,Y.jsx)(j8,{path:d.path,showModuleGalleryChild:e},e);if(n.status===`error`)return(0,Y.jsx)(NC,{path:e,error:n.error,type:`module`});if(n.status===`loading`)return(0,Y.jsx)(jC,{path:e,type:`module`});if((e?.length||0)===0)return(0,Y.jsx)(gJe,{});if(n.status===`not-found`)return(0,Y.jsx)(MC,{path:e,type:`module`});let f=n.data,p=xk(e),m=p.slice(0,-1),h=p[p.length-1],g=Qfe(e,r,i),_=ED(e,r,i),v=a.filter(e=>!!e.keyError),y=a.filter(e=>!e.keyError),x=r!==e&&i?.type===`record`&&!!i?.router,S=f.type===`record`&&!!f.router,C=f.type===`record`&&!!f.mediaType,w=_&&i?.type===`record`?i.key?.description:void 0,T=!C&&(0,Y.jsxs)(`div`,{className:`shrink-0 flex gap-2 items-center`,children:[s&&(0,Y.jsx)(Kk,{patchesByAuthorIds:l,profilesByAuthorIds:c,sourcePath:e}),(0,Y.jsx)(hk,{path:e,variant:`module`})]}),E=g?(0,Y.jsxs)(`span`,{className:`shrink-0`,children:[`#`,Number(h.text)]}):x?(0,Y.jsx)(vJe,{path:h.text,portalContainer:u}):S?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Y.jsx)(ry,{size:20,className:`text-fg-tertiary shrink-0`}),(0,Y.jsx)(`span`,{children:`Pages`})]}):(0,Y.jsx)(`span`,{className:`truncate block`,children:h.text});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4 pb-40`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 text-left overflow-hidden`,children:(0,Y.jsxs)(`div`,{className:X({"border rounded-lg border-bg-warning-secondary p-4":v.length>0}),children:[(0,Y.jsxs)(`div`,{className:`flex gap-4 justify-between items-start min-h-6`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{role:`heading`,"aria-level":1,className:`text-2xl leading-tight`,children:E}),w&&(0,Y.jsx)(`div`,{className:`mt-1 text-sm text-fg-tertiary`,children:w})]}),T]}),m.length>0&&(0,Y.jsx)(hJe,{parts:m,portalContainer:u,className:w?`mt-3`:`mt-1.5`}),v.length>0&&(0,Y.jsx)(Uk,{validationErrors:v}),f.description&&(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:f.description})]})}),(0,Y.jsxs)(`div`,{children:[_&&y.length>0&&(0,Y.jsx)(Uk,{validationErrors:a}),(0,Y.jsx)(`div`,{className:X({"border rounded-lg border-bg-warning-secondary p-4 mt-4":y.length>0}),children:t?(0,Y.jsx)(sX,{path:e,showChildPath:t,readonly:f.readonly},e):(0,Y.jsx)(a6,{path:e,schema:f},e)})]})]})}function gJe(){return(0,Y.jsx)(`div`,{className:`flex flex-col min-h-[calc(100vh-100px)] items-center grow`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col pt-20 gap-2 w-full max-w-md text-center`,children:[(0,Y.jsx)(`div`,{className:`w-full`,children:(0,Y.jsx)(uJe,{})}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-tertiary`,children:`Search or use the menu on the left to find and edit your content.`})]})})}var _Je=4;function vJe({path:e,portalContainer:t}){let{segments:n,isFullUrl:r,protocol:i,host:a}=(0,b.useMemo)(()=>{let t=e.startsWith(`http://`)||e.startsWith(`https://`),n=e,r=``,i=``;if(t)try{let t=new URL(e);r=t.protocol,i=t.host,n=t.pathname}catch{}return{segments:n.split(`/`).filter(Boolean),isFullUrl:t,protocol:r,host:i}},[e]);if(n.length===0&&r)return(0,Y.jsxs)(T8,{openDelay:200,children:[(0,Y.jsx)(E8,{asChild:!0,children:(0,Y.jsx)(`div`,{className:`cursor-default`,children:(0,Y.jsx)(s8,{children:(0,Y.jsx)(c8,{className:`flex-nowrap font-normal`,children:(0,Y.jsxs)(l8,{className:`shrink-0`,children:[(0,Y.jsxs)(`span`,{className:`text-fg-tertiary`,children:[i,`//`]}),(0,Y.jsx)(`span`,{children:a})]})})})})}),(0,Y.jsx)(D8,{className:`w-auto max-w-[400px] break-all`,container:t,side:`bottom`,align:`start`,children:(0,Y.jsx)(`p`,{className:`font-mono text-sm`,children:e})})]});if(n.length===0)return(0,Y.jsx)(`span`,{className:`text-fg-secondary`,children:`/`});let o=n.length>_Je,s=o?n.slice(0,1):n,c=o?n.slice(-2):[],l=(0,Y.jsx)(s8,{children:(0,Y.jsxs)(c8,{className:`flex-nowrap font-normal`,children:[r&&(0,Y.jsx)(Y.Fragment,{children:(0,Y.jsxs)(l8,{className:`shrink-0`,children:[(0,Y.jsxs)(`span`,{className:`text-fg-tertiary`,children:[i,`//`]}),(0,Y.jsx)(`span`,{children:a})]})}),(0,Y.jsx)(l8,{className:`shrink-0`,children:(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`})}),s.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(l8,{className:X(`shrink-0`,{"max-w-[120px]":t<s.length-1}),children:(0,Y.jsx)(u8,{className:`truncate block`,children:e})}),(t<s.length-1||o||!o&&t<n.length-1)&&(0,Y.jsx)(d8,{className:`shrink-0`,children:(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`})})]},`start-${t}`)),o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(l8,{children:(0,Y.jsx)(f8,{className:`h-4 w-4`})}),(0,Y.jsx)(d8,{className:`shrink-0`,children:(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`})})]}),c.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(l8,{className:`shrink-0 max-w-[120px]`,children:(0,Y.jsx)(u8,{className:`truncate block`,children:e})}),t<c.length-1&&(0,Y.jsx)(d8,{className:`shrink-0`,children:(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`})})]},`end-${t}`))]})});return(0,Y.jsxs)(T8,{openDelay:200,children:[(0,Y.jsx)(E8,{asChild:!0,children:(0,Y.jsx)(`div`,{className:`cursor-default`,children:l})}),(0,Y.jsx)(D8,{className:`w-auto max-w-[400px] break-all`,container:t,side:`bottom`,align:`start`,children:(0,Y.jsx)(`p`,{className:`font-mono text-sm`,children:e})})]})}function yJe(){let{addModuleFilePatch:e}=LS(),t=wb(),{navigate:n}=GC();return(0,b.useCallback)((r,i)=>{if(t.status!==`success`){console.error(`Val: cannot add a page before the schemas have loaded`);return}let a=t.data[r];if(!a||a.type!==`record`){console.error(`Val: cannot add a page to a module that is not a record`,{moduleFilePath:r,schema:a});return}let o=H.createPatchPath(``).concat(i);e(r,[{op:`add`,path:o,value:Cp(a.item)}],`record`),n(H.joinModuleFilePathAndModulePath(r,H.patchPathToModulePath(o)))},[e,t,n])}function M8(e,t,n){return e===1?t:n}function bJe(e){let{mode:t,validationErrorCount:n,conflictingChangeCount:r,isPublishing:i,publishDisabled:a,autoPublish:o,pendingServerSidePatchCount:s,pendingClientSidePatchCount:c,netChangesEmpty:l}=e,u=t===`fs`;if(n>0||r>0){let e=[];return n>0&&e.push(`${n} validation ${M8(n,`error`,`errors`)} to fix.`),r>0&&e.push(`${r} ${M8(r,`change`,`changes`)} cannot be applied. Remove ${M8(r,`it`,`them`)} to continue.`),{kind:`blocked`,label:n>0?`Fix ${n>9?`9+`:n}`:`Fix errors`,description:n>0?`Show the validation errors`:`Show the changes that cannot be applied`,reason:e.join(` `),action:n>0?`show-errors`:`none`}}if(i)return{kind:`in-flight`,label:u?`Saving`:`Pushing`,description:u?`Saving changes to disk`:`Pushing changes`,reason:null,action:`none`};let d=s===0,f=c>0,p=!d&&!f&&l;return a||d||f||p||u&&o?{kind:`idle`,label:u?`Save`:`Publish`,description:u?`Save to disk`:`Publish pending changes`,reason:f?`Waiting for the last edit to reach the server.`:u&&o?`Auto save is on: changes are saved for you.`:d?`Nothing to send.`:p?`Every change has been reverted, so there is nothing to publish. Discard them to clear.`:null,action:`none`}:{kind:`ready`,label:u?`Save`:`Publish`,description:u?`Save to disk`:`Publish pending changes`,reason:null,action:u?`save`:`publish`}}function xJe({value:e,onChange:t,ai:n,onUseAiSummary:r,onOpenAiSession:i,onSetUpAi:a,onPublish:o,onClose:s,publishDisabled:c,isPublishing:l,waitingForAiSeconds:u}){let d=`w-full p-2 border rounded bg-bg-secondary`,f=u!==null;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-semibold`,children:`Summary`}),(0,Y.jsx)(SJe,{ai:n,canApply:n.status===`ready`&&n.text.trim()!==e.trim(),onUseAiSummary:r,onOpenAiSession:i,onSetUpAi:a})]}),(0,Y.jsxs)(`div`,{className:`grid text-xs font-light`,children:[(0,Y.jsx)(`div`,{"aria-hidden":!0,className:X(d,`invisible whitespace-pre-wrap`),style:{gridArea:`1 / 1 / 2 / 2`},children:e+` `}),(0,Y.jsx)(`textarea`,{className:X(d,`resize-none overflow-clip`),value:e,style:{gridArea:`1 / 1 / 2 / 2`},placeholder:`Write a summary of your changes`,onChange:e=>t(e.currentTarget.value)})]}),f&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:12,className:`animate-spin mt-0.5 shrink-0`}),(0,Y.jsxs)(`span`,{children:[`Waiting for the AI summary. Publishing in `,u,`s either way — press Publish again to skip the wait.`]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Y.jsx)(t_,{variant:`outline`,onClick:s,children:`Close`}),(0,Y.jsxs)(t_,{disabled:c||e.trim()===``,onClick:o,variant:`default`,className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:l?`Pushing...`:`Publish`}),(0,Y.jsx)(By,{size:16})]})]})]})}function SJe({ai:e,canApply:t,onUseAiSummary:n,onOpenAiSession:r,onSetUpAi:i}){let a=eb();return e.status===`off`?i?(0,Y.jsx)(N8,{container:a,text:`Val can write your summary for you once an AI key is set up. Publishing works the same either way.`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:i,className:`flex items-center gap-1 text-xs text-fg-secondary underline cursor-pointer`,children:[(0,Y.jsx)(Ny,{size:12}),(0,Y.jsx)(`span`,{children:`Set up AI`})]})}):null:e.status===`idle`?null:e.status===`loading`?(0,Y.jsx)(N8,{container:a,text:`Writing a summary with AI. You do not have to wait — edit the text or publish whenever you like.`,children:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:12,className:`animate-spin`}),(0,Y.jsx)(`span`,{children:`AI is writing…`})]})}):e.status===`failed`?(0,Y.jsx)(N8,{container:a,text:`${e.message} Your summary is unaffected — publish when ready.`,children:e.canSetUp&&i?(0,Y.jsxs)(`button`,{type:`button`,onClick:i,className:`flex items-center gap-1 text-xs text-fg-secondary underline cursor-pointer`,children:[(0,Y.jsx)(Ly,{size:12}),(0,Y.jsx)(`span`,{children:`AI unavailable`})]}):(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Ly,{size:12}),(0,Y.jsx)(`span`,{children:`AI unavailable`})]})}):(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[t&&(0,Y.jsx)(N8,{container:a,text:`Replace what you have written with the AI's summary.`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-1 text-xs text-fg-secondary underline cursor-pointer`,children:[(0,Y.jsx)(Ny,{size:12}),(0,Y.jsx)(`span`,{children:`Use AI summary`})]})}),r&&(0,Y.jsx)(N8,{container:a,text:`Open the chat that wrote this summary to ask what changed.`,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:r,className:`flex items-center gap-1 text-xs text-fg-secondary underline cursor-pointer`,children:[(0,Y.jsx)(vy,{size:12}),(0,Y.jsx)(`span`,{children:`Ask what changed`})]})})]})}function N8({text:e,container:t,children:n}){return(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:n}),(0,Y.jsx)(Xg,{container:t,className:`max-w-[260px] text-xs`,children:e})]})}function CJe(e){let[t,n]=(0,b.useState)(null),r=(0,b.useRef)(null),i=(0,b.useCallback)(()=>{let e=r.current;r.current=null,n(null),e?.()},[]);return(0,b.useEffect)(()=>{if(t===null)return;if(t<=0){i();return}let e=setTimeout(()=>n(e=>(e??1)-1),1e3);return()=>clearTimeout(e)},[t,i]),(0,b.useEffect)(()=>()=>{let e=r.current;r.current=null,e?.()},[]),{remaining:t,isWaiting:t!==null,start:t=>{r.current===null&&(r.current=t,n(e))},skip:i,cancel:()=>{r.current=null,n(null)}}}var wJe=3,P8=6;function F8(e){let t=e.split(`/`).filter(Boolean),n=(t[t.length-1]??e).replace(/\.val\.(ts|tsx|js|jsx|json)$/,``),r=(n===`page`||n===`index`?t[t.length-2]??n:n).replace(/[-_]+/g,` `).trim();return r?r.charAt(0).toUpperCase()+r.slice(1):e}function TJe(e){let t=Array.from(new Set(e.map(e=>F8(e)))).sort((e,t)=>e.localeCompare(t));if(t.length===0)return`Update content`;if(t.length<=wJe)return`Update ${EJe(t)}`;let n=t.slice(0,P8).join(`, `),r=t.length-P8,i=r>0?`${n} and ${r} more`:n;return`Update content in ${t.length} places\n\nChanged: ${i}`}function EJe(e){return e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function I8(e){return!e.hasEdited&&e.currentValue.trim()===e.defaultSummary.trim()}var DJe=240,OJe=40;function L8(e){if(e===void 0)return`(not set)`;if(e===null)return`(empty)`;if(typeof e==`string`)return R8(e);if(typeof e==`number`||typeof e==`boolean`)return String(e);if(Array.isArray(e))return`(list of ${e.length})`;if(typeof e==`object`){let t=e;if(typeof t.path==`string`)return`(file ${R8(t.path,80)})`;let n=Object.keys(t);return`(fields: ${n.slice(0,6).join(`, `)}${n.length>6?`, …`:``})`}return`(value)`}function R8(e,t=DJe){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t)}… (${n.length} characters in total)`}function kJe(e){if(e.length===0)return`No changes.`;let t=e.slice(0,OJe),n=new Map;for(let e of t){let t=n.get(e.moduleFilePath);t?t.push(e):n.set(e.moduleFilePath,[e])}let r=[];for(let[e,t]of n){r.push(`## ${F8(e)}`);for(let e of t){let t=e.fieldPath||`(the whole entry)`,n=e.schemaType?` [${e.schemaType}]`:``;r.push(`- ${t}${n}`),r.push(` before: ${L8(e.before)}`),r.push(` after: ${L8(e.after)}`)}r.push(``)}let i=e.length-t.length;return i>0&&r.push(`(${i} further ${i===1?`change`:`changes`} not listed)`),r.join(`
|
|
226
226
|
`).trim()}var AJe=`You write commit messages for a content management system, for readers who are not developers.
|
|
227
227
|
|
|
228
228
|
Output format:
|
|
@@ -238,31 +238,31 @@ Guidance:
|
|
|
238
238
|
- State only what the values show. Never speculate about why ("so that", "to enable").
|
|
239
239
|
- Do not repeat the title in the description.
|
|
240
240
|
- Where a value was truncated, describe it as far as you can see and do not invent the rest.
|
|
241
|
-
- Reply with the commit message only. No preamble, no quoting of these instructions.`;function jJe(e){let{sendWsMessage:t,subscribeToWsMessages:n,isWsConnected:r}=zS(),[i,a]=(0,b.useState)({status:e===null?`off`:`idle`}),o=(0,b.useRef)(null),s=(0,b.useRef)(null),c=(0,b.useRef)(!1),l=(0,b.useRef)(``);(0,b.useEffect)(()=>{a(t=>e===null?t.status===`off`?t:{status:`off`}:t.status===`off`?{status:`idle`}:t)},[e]),(0,b.useEffect)(()=>n(e=>{if(!(!(`id`in e)||e.id!==o.current)){if(e.type===`ai_streaming`){l.current+=e.chunk;return}if(e.type===`ai_response`){let t=(e.response||l.current).trim();a(t?{status:`ready`,text:t,sessionId:s.current}:{status:`failed`,message:`The AI returned an empty summary.`}),o.current=null;return}if(e.type===`ai_error`){a({status:`failed`,message:e.message,canSetUp:e.code===`provider_not_configured`||e.code===`byok_invalid_key`}),o.current=null;return}e.type===`ai_cancelled`&&(a({status:`idle`}),o.current=null)}}),[n]);let u=(0,b.useCallback)(()=>{let e=o.current;o.current=null,e!==null&&t({type:`ai_cancel`,id:e})},[t]);return(0,b.useEffect)(()=>()=>{u(),c.current=!1},[u]),{state:i,start:(0,b.useCallback)(n=>{if(c.current||e===null||!r)return;c.current=!0;let i=crypto.randomUUID(),u=crypto.randomUUID();o.current=i,s.current=u,l.current=``,a({status:`loading`}),t({type:`ai_prompt`,id:i,sessionId:u,hidden:!0,message:n,maxIterations:1,agents:[{id:`commit-summary`,model:e,systemPrompt:AJe,tools:[]}]})||(o.current=null,a({status:`failed`,message:`Could not reach the AI service.`}))},[r,e,t]),cancel:u,reveal:(0,b.useCallback)(async()=>{let e=s.current;if(e===null)return null;let r=crypto.randomUUID();return new Promise(i=>{let a=setTimeout(()=>{o(),i(null)},1e4),o=n(e=>{!(`id`in e)||e.id!==r||(clearTimeout(a),o(),i(e.type===`ai_session_unhidden`?e.sessionId:null))});t({type:`ai_unhide_session`,id:r,sessionId:e})||(clearTimeout(a),o(),i(null))})},[t,n])}}var L8=Symbol(`unknown`);function R8(e){if(e.status===`ready`)return e.data;if(e.status!==`absent`)return L8}var MJe=10;function NJe({onPublish:e,onClose:t}){let{summary:n,setSummary:r,publishDisabled:i,isPublishing:a,aiEnabled:o}=eC(),s=US(),c=nb(),l=BS(),u=o?l:null,d=CJe(MJe),{setSessionParam:f}=KC(),{openAIChat:p}=wS(),m=jJe(u),h=(0,b.useMemo)(()=>s.status===`success`?s.data.map(e=>e.moduleFilePath):[],[s]),g=(0,b.useMemo)(()=>TJe(h),[h]),_=`text`in n?n.text:``,v=(0,b.useRef)(!1);(0,b.useEffect)(()=>{v.current||(v.current=!0,_.trim()===``&&r({type:`manual`,text:g}))},[g,_,r]),(0,b.useEffect)(()=>{if(c===null||s.status!==`success`)return;let e=c.system.sourceStore,t=[];for(let n of s.data){let r=H.joinModuleFilePathAndModulePath(n.moduleFilePath,H.patchPathToModulePath(n.patchPath)),i=R8(e.peek(r)),a=R8(e.peekBase(r));i!==L8&&a!==L8&&t.push({sourcePath:r,moduleFilePath:n.moduleFilePath,fieldPath:n.patchPath.join(`.`),schemaType:n.schemaTypes[0],before:a,after:i})}t.length!==0&&m.start(kJe(t))},[m.start,s,c]);let[y,x]=(0,b.useState)(!1),S=(0,b.useRef)(!1);(0,b.useEffect)(()=>{S.current||m.state.status!==`ready`||(S.current=!0,P8({hasEdited:y,currentValue:_,defaultSummary:g})&&r({type:`ai`,text:m.state.text}))},[m.state,y,_,g,r]);let{isWaiting:C,skip:w}=d;(0,b.useEffect)(()=>{C&&(m.state.status===`ready`||m.state.status===`failed`)&&w()},[m.state.status,C,w]);let T=()=>{m.cancel(),e?.()};return(0,Y.jsx)(xJe,{value:_,onChange:e=>{x(!0),r({type:`manual`,text:e})},ai:m.state,onUseAiSummary:()=>{m.state.status===`ready`&&r({type:`ai`,text:m.state.text})},onOpenAiSession:m.state.status===`ready`&&m.state.sessionId!==null?()=>{m.reveal().then(e=>{e!==null&&(f(e,{replace:!0}),t(),p())})}:void 0,onPublish:()=>{if(d.isWaiting){d.skip();return}if(m.state.status===`loading`&&P8({hasEdited:y,currentValue:_,defaultSummary:g})){d.start(T);return}T()},onClose:()=>{d.cancel(),m.cancel(),t()},publishDisabled:i,isPublishing:a,waitingForAiSeconds:d.remaining})}var PJe=`h-auto w-auto p-2`;function FJe({kind:e,saving:t}){return(0,Y.jsx)(`span`,{className:`grid size-4 shrink-0 place-items-center`,children:e===`blocked`?(0,Y.jsx)(Ly,{size:16}):e===`in-flight`?(0,Y.jsx)(Gv,{size:16,className:`animate-pulse`}):t?(0,Y.jsx)(jy,{size:16}):(0,Y.jsx)(ky,{size:16})})}function z8({compact:e}){let[t,n]=(0,b.useState)(!1),{publish:r,publishDisabled:i,isPublishing:a,summary:o}=eC(),s=Fb(),c=Object.keys(s??{}),{patchErrors:l}=oC(),u=Object.values(l||{}).reduce((e,t)=>e+Object.keys(t||{}).length,0),d=qS(),f=GS(),p=(0,b.useMemo)(()=>d.filter(e=>!f.has(e)),[d,f]),m=JS(),h=KS(),g=QS(),_=eb(),{autoPublish:v}=aC(),{navigate:y}=GC(),x=bJe({mode:g===`fs`?`fs`:g===null?`unknown`:`http`,validationErrorCount:c.length,conflictingChangeCount:u,isPublishing:a,publishDisabled:i,autoPublish:v,pendingServerSidePatchCount:p.length,pendingClientSidePatchCount:m.length,netChangesEmpty:!h}),S=g===`fs`,C=e?PJe:`flex h-8 min-w-[6.5rem] items-center justify-center gap-2 px-3 text-xs font-medium`,w=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(FJe,{kind:x.kind,saving:S}),!e&&(0,Y.jsx)(`span`,{children:x.label})]}),T=x.reason??x.description;if(x.kind===`blocked`){let t=(0,Y.jsx)(t_,{className:C,variant:x.action===`show-errors`?`destructive`:`default`,disabled:x.action===`none`,"aria-label":e?x.description:void 0,onClick:()=>{x.action===`show-errors`&&y(LC,{errorFields:c})},children:w});return(0,Y.jsx)(B8,{label:x.description,description:T,disabled:x.action===`none`,container:_,children:t})}if(S||x.kind!==`ready`){let t=(0,Y.jsx)(t_,{className:C,disabled:x.action===`none`,"aria-label":e?x.description:void 0,onClick:()=>{x.action===`save`&&r(`No summary provided`)},children:w});return(0,Y.jsx)(B8,{label:x.description,description:T,disabled:x.action===`none`,container:_,children:t})}let E=(0,Y.jsx)(t_,{className:C,"aria-label":e?x.description:void 0,onClick:()=>{n(!0)},children:w});return(0,Y.jsx)(`span`,{className:`inline-flex`,children:(0,Y.jsxs)(SD,{open:t,onOpenChange:e=>{n(e)},children:[e?(0,Y.jsx)(B8,{label:x.description,description:T,disabled:!1,container:_,children:(0,Y.jsx)(CD,{asChild:!0,children:E})}):(0,Y.jsx)(CD,{asChild:!0,children:E}),(0,Y.jsxs)(wD,{container:_,align:`end`,className:`z-[9001] flex flex-col gap-4`,children:[(0,Y.jsx)(yD,{asChild:!0,className:`self-end cursor-pointer`,children:(0,Y.jsx)(Hy,{size:12})}),(0,Y.jsx)(NJe,{onClose:()=>{n(!1)},onPublish:()=>{if(n(!1),o.type===`not-asked`)return;let e=o.text.trim();r(e)}})]})]})})}function B8({label:e,description:t,disabled:n,container:r,children:i}){return(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:n?(0,Y.jsx)(`span`,{className:`inline-flex`,role:`button`,tabIndex:0,"aria-disabled":`true`,"aria-label":e,children:(0,Y.jsx)(`span`,{className:`inline-flex`,"aria-hidden":`true`,children:i})}):i}),(0,Y.jsx)(Xg,{container:r,children:(0,Y.jsx)(`p`,{children:t})})]})}var IJe=`font-mono text-sm px-2 py-0.5 rounded bg-bg-secondary text-fg-primary truncate transition-colors min-w-0 block hover:bg-bg-tertiary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`;function V8({sourcePath:e,previewSegment:t,className:n,children:r}){let i=wb(),a=ob(e,Eb(),i.status===`success`?i.data:void 0)??e,o=E8(a,{scrollToPath:a===e?void 0:e}),s=(0,Y.jsx)(`a`,{...o,title:e,className:X(IJe,n),children:r});if(t===void 0)return s;let c=Jf(`/api/val/enable`,{redirect_to:(typeof window<`u`?window.location.origin:``)+t});return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 truncate min-w-0 max-w-full`,children:[s,(0,Y.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-fg-tertiary hover:text-fg-primary transition-colors`,title:`Preview ${t}`,children:(0,Y.jsx)(ry,{size:12})})]})}function LJe({errorFields:e,allErrors:t}){let n=(0,b.useMemo)(()=>UJe(e),[e]),r=e.length,i=n.length,a=r>0&&e.every(e=>!t?.[e]||t[e].length===0),o=e.filter(e=>t?.[e]&&t[e].length>0).length;return e.length===0?(0,Y.jsx)(`div`,{className:`mx-auto max-w-3xl py-12 text-center text-sm text-fg-secondary`,children:`No errors selected.`}):(0,Y.jsxs)(`div`,{className:`mx-auto max-w-3xl flex flex-col gap-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Ly,{size:18,className:`text-fg-warning-primary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`h1`,{className:`text-lg font-medium text-fg-primary`,children:`Validation errors`}),a?(0,Y.jsx)(H8,{tone:`success`,children:`All fixed`}):(0,Y.jsxs)(H8,{tone:`warning`,children:[r,` `,r===1?`field`:`fields`,i>1?(0,Y.jsxs)(Y.Fragment,{children:[` across `,i,` modules`]}):null]})]}),a&&(0,Y.jsx)(HJe,{total:r}),!a&&o<r&&r>1&&(0,Y.jsxs)(`div`,{className:`text-sm text-fg-secondary`,children:[o,` of `,r,` still need attention.`]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(({moduleFilePath:e,paths:n})=>(0,Y.jsx)(zJe,{moduleFilePath:e,paths:n,allErrors:t},e))})]})}function RJe(){let{errorFields:e}=GC(),t=Fb();return(0,Y.jsx)(LJe,{errorFields:e,allErrors:t})}function zJe({moduleFilePath:e,paths:t,allErrors:n}){let r=(0,b.useMemo)(()=>H.splitModuleFilePath(e),[e]),i=E8(e),a=t.filter(e=>n?.[e]&&n[e].length>0).length;return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border-primary bg-bg-primary`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border-primary bg-bg-secondary px-4 py-2`,children:[(0,Y.jsx)(Kie,{size:14,className:`text-fg-secondary-alt shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`a`,{...i,title:e,className:`min-w-0 flex flex-wrap items-center gap-1 rounded-sm text-sm text-fg-secondary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:r.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[t>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`}),(0,Y.jsx)(`span`,{className:(0,AC.default)({"text-fg-tertiary":t<r.length-1,"text-fg-primary":t===r.length-1}),children:kC(e)})]},`m-${t}`))}),(0,Y.jsx)(`div`,{className:`ml-auto`,children:a===0?(0,Y.jsxs)(H8,{tone:`success`,children:[(0,Y.jsx)(Vv,{size:11,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Fixed`})]}):(0,Y.jsxs)(H8,{tone:`warning`,children:[a,` `,a===1?`issue`:`issues`]})})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:t.map((e,r)=>(0,Y.jsx)(BJe,{sourcePath:e,errors:n?.[e],isLast:r===t.length-1},e))})]})}function BJe({sourcePath:e,errors:t,isLast:n}){let r=Cb(e),i=!!t&&t.length>0;return(0,Y.jsxs)(`li`,{className:(0,AC.default)(`flex flex-col gap-3 px-4 py-3`,{"border-b border-border-secondary":!n}),children:[(0,Y.jsx)(VJe,{sourcePath:e}),r.status===`success`?(0,Y.jsx)(Lhe,{children:(0,Y.jsx)(r6,{path:e,schema:r.data})}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:14,className:`animate-spin`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Loading field…`})]}),i?(0,Y.jsx)(Phe,{validationErrors:t}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-fg-brand-primary`,children:[(0,Y.jsx)(Vv,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Fixed.`})]})]})}function VJe({sourcePath:e}){let t=wb(),[n,r]=H.splitModuleFilePathAndModulePath(e),i=r?H.splitModulePath(r):[],a=(t.status===`success`?t.data:void 0)?.[n],o=a?.type===`record`&&!!a.router&&i.length===1;return(0,Y.jsx)(V8,{sourcePath:e,previewSegment:o?i[0]:void 0,className:o?void 0:`self-start max-w-full`,children:o?i[0]:r?lD(r):kC(H.splitModuleFilePath(n).pop()??``)})}function H8({children:e,tone:t}){return(0,Y.jsx)(`span`,{className:(0,AC.default)(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium`,{"bg-bg-warning-primary text-fg-warning-primary":t===`warning`,"bg-bg-brand-primary text-fg-brand-primary":t===`success`}),children:e})}function HJe({total:e}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border-primary bg-bg-secondary px-4 py-3 text-sm text-fg-primary`,children:[(0,Y.jsx)(Vv,{size:16,className:`text-fg-secondary`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{children:[`All `,(0,Y.jsx)(`span`,{className:`font-medium`,children:e}),` `,e===1?`error is`:`errors are`,` fixed. Ready to publish.`]})]})}function UJe(e){let t=new Map;for(let n of e){let[e]=H.splitModuleFilePathAndModulePath(n),r=t.get(e);r?r.push(n):t.set(e,[n])}let n=Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,paths:t.slice().sort(WJe)}));return n.sort((e,t)=>e.moduleFilePath.localeCompare(t.moduleFilePath)),n}function WJe(e,t){let[,n]=H.splitModuleFilePathAndModulePath(e),[,r]=H.splitModuleFilePathAndModulePath(t),i=n?H.splitModulePath(n):[],a=r?H.splitModulePath(r):[],o=Math.min(i.length,a.length);for(let e=0;e<o;e++)if(i[e]!==a[e])return i[e].localeCompare(a[e]);return i.length-a.length}function GJe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function KJe(e){let t=e.patchPath,n=!1,r=!1,i=!1;for(let a of e.patches)GJe(a.patchPath,t)&&(a.opType===`add`&&(n=!0),a.opType===`remove`&&(r=!0),a.opType===`move`&&(i=!0));return n&&r?null:i&&r?`removed`:n?`added`:i?`moved`:r?`removed`:`field-change`}function qJe(e,t){if(t.length===0)return e;let n=H.patchPathToModulePath(t);return H.joinModuleFilePathAndModulePath(e,n)}function JJe(e,t){let n={};for(let r of t){let t=r.author??`unknown`;n[t]||(n[t]=[]),n[t].push({moduleFilePath:e,patchId:r.patchId,opType:r.opType,createdAt:r.createdAt,authorId:r.author})}return n}function YJe(e,t,n,r,i,a,o,s,c,l){if(n.length===0){e.change={changeType:r,patchIds:i,authors:a,lastUpdatedBy:s,patchesByAuthorIds:c},o>e.lastUpdated&&(e.lastUpdated=o);return}let u=e;for(let e=0;e<n.length;e++){let d=qJe(t,n.slice(0,e+1)),f=e===n.length-1,p=u.children.find(e=>e.sourcePath===d);p||(p={sourcePath:d,lastUpdated:o,isCommitted:l,children:[]},u.children.push(p)),o>p.lastUpdated&&(p.lastUpdated=o),f&&(p.change={changeType:r,patchIds:i,authors:a,lastUpdatedBy:s,patchesByAuthorIds:c}),u=p}}function U8(e){let t=e.lastUpdated;for(let n of e.children){let e=U8(n);e>t&&(t=e)}return e.lastUpdated=t,t}function W8(e){let t=String(e),[,n]=H.splitModuleFilePathAndModulePath(t);if(!n)return t;let r=H.splitModulePath(n);return r[r.length-1]??t}function G8(e){e.children.sort((e,t)=>W8(e.sourcePath).localeCompare(W8(t.sourcePath)));for(let t of e.children)G8(t)}function K8(e,t){let n=[],r=[],i=t[0].createdAt,a=t[0].author;for(let e of t)e.author!==null&&!n.includes(e.author)&&n.push(e.author),r.includes(e.opType)||r.push(e.opType),e.createdAt>i&&(i=e.createdAt,a=e.author);return{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath,patches:t,authors:n,opTypes:r,schemaTypes:e.schemaTypes,lastUpdated:i,lastUpdatedBy:a}}function XJe(e,t){if(t.size===0)return{pending:e,committed:null};let n=[],r=[];for(let i of e.patches)t.has(i.patchId)?r.push(i):n.push(i);return r.length===0?{pending:e,committed:null}:n.length===0?{pending:null,committed:e}:{pending:K8(e,n),committed:K8(e,r)}}function ZJe(e,t){return`${e?`committed`:`pending`}\u0000${t}`}function QJe(e,t=new Set){let n={};for(let r of e){let{pending:e,committed:i}=XJe(r,t);for(let t of[{set:e,isCommitted:!1},{set:i,isCommitted:!0}])t.set!==null&&$Je(n,t.set,t.isCommitted)}let r=Object.values(n);for(let e of r)U8(e),G8(e);return r.sort((e,t)=>e.isCommitted===t.isCommitted?t.lastUpdated.localeCompare(e.lastUpdated):e.isCommitted?1:-1),{trees:r}}function $Je(e,t,n){let r=KJe(t);if(r===null)return;let{moduleFilePath:i}=t,a=ZJe(n,i);e[a]||(e[a]={sourcePath:i,lastUpdated:t.lastUpdated,isCommitted:n,children:[]});let o=e[a],s=t.patches.map(e=>e.patchId),c=t.authors.filter(e=>e!==null),l=JJe(i,t.patches);YJe(o,i,t.patchPath,r,s,c,t.lastUpdated,t.lastUpdatedBy,l,n)}var eYe=typeof window<`u`&&typeof Worker<`u`;function tYe(e,t,n){let r=(0,b.useRef)(null),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(!1),u=(0,b.useRef)(0),d=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!eYe)return;let e=new Worker(new URL(`/api/val/static/assets/patchsets.worker-D9QWxx6e.js`,``+import.meta.url),{type:`module`});return r.current=e,e.onmessage=e=>{let t=e.data;t.id===d.current&&(t.type===`result`?(a(t.trees),s(!1),l(!0)):t.type===`error`&&(console.error(`PatchSets worker error:`,t.error),s(!1),l(!0)))},e.onerror=e=>{console.error(`PatchSets worker failed:`,e.message),s(!1),l(!0)},()=>{e.terminate(),r.current=null}},[]);let f=n?Array.from(n).sort().join(`,`):``,p=(0,b.useMemo)(()=>n===void 0?[]:Array.from(n).sort(),[f]),m=(0,b.useCallback)((e,t)=>{if(!r.current){let{trees:n}=QJe(e,new Set(t));a(n),s(!1),l(!0);return}let n=`ps-${u.current++}`;d.current=n,s(!0);let i={type:`compute`,id:n,patchSets:e,committedPatchIds:t};r.current.postMessage(i)},[]),[h,g]=(0,b.useState)(t);return h!==t&&(g(t),a([]),l(!1),s(!0)),(0,b.useEffect)(()=>{m(e,p)},[e,m,t,p]),{trees:i,isComputing:o,hasComputed:c}}function q8(e,t){return e===t}function nYe(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let a=n-1;a>=0;a--)for(let n=r-1;n>=0;n--)i[a][n]=q8(e[a],t[n])?i[a+1][n+1]+1:Math.max(i[a+1][n],i[a][n+1]);let a=[],o=0,s=0;for(;o<n&&s<r;)q8(e[o],t[s])?(a.push({beforeIndex:o,index:s}),o++,s++):i[o+1][s]>=i[o][s+1]?o++:s++;return a}function rYe(e,t){let n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i++)q8(e[i],t[i])?n.push({kind:`unchanged`,index:i,beforeIndex:i,value:t[i]}):n.push({kind:`changed`,index:i,beforeIndex:i,before:e[i],after:t[i]});for(let e=r;e<t.length;e++)n.push({kind:`added`,index:e,value:t[e]});for(let t=r;t<e.length;t++)n.push({kind:`removed`,beforeIndex:t,value:e[t]});return{lines:n,positional:!0}}function iYe(e,t){if(e.length>1e3||t.length>1e3)return rYe(e,t);let n=nYe(e,t),r=new Set(n.map(e=>e.beforeIndex)),i=new Set(n.map(e=>e.index)),a=new Map(n.map(e=>[e.index,e.beforeIndex])),o=[];for(let t=0;t<e.length;t++)r.has(t)||o.push(t);let s=new Map,c=new Set;for(let n=0;n<t.length;n++){if(i.has(n))continue;let r=o.find(r=>!c.has(r)&&q8(e[r],t[n]));r!==void 0&&(c.add(r),s.set(n,r))}let l=[],u=0,d=0,f=(n,r)=>{let i=[],a=[];for(;u<n;)c.has(u)||i.push(u),u++;for(;d<r;){if(s.has(d)){let e=s.get(d);if(e===void 0)throw Error(`unreachable: movedFrom.has without a value`);l.push({kind:`moved`,index:d,beforeIndex:e,value:t[d]})}else a.push(d);d++}let o=Math.min(i.length,a.length);for(let n=0;n<o;n++)l.push({kind:`changed`,index:a[n],beforeIndex:i[n],before:e[i[n]],after:t[a[n]]});for(let e=o;e<a.length;e++)l.push({kind:`added`,index:a[e],value:t[a[e]]});for(let t=o;t<i.length;t++)l.push({kind:`removed`,beforeIndex:i[t],value:e[i[t]]})};for(let e of n){f(e.beforeIndex,e.index);let n=a.get(e.index)??e.beforeIndex;l.push({kind:`unchanged`,index:e.index,beforeIndex:n,value:t[e.index]}),u=e.beforeIndex+1,d=e.index+1}return f(e.length,t.length),{lines:l,positional:!1}}function aYe(e){return e.lines.some(e=>e.kind!==`unchanged`)}function oYe(e){let t={added:0,removed:0,moved:0,changed:0,unchanged:0};for(let n of e.lines)t[n.kind]+=1;return t}function sYe({sourcePath:e}){let t=jb(e),n=Ab(e),r=Y8(t.status===`success`?t.data:void 0),i=Y8(n.status===`success`?n.data:void 0),a=(0,b.useMemo)(()=>r===null||i===null?null:iYe(r,i),[r,i]);if(a===null)return null;if(!aYe(a))return(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:`The list ended up the same as it started.`});let o=oYe(a);return(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(cYe,{counts:o}),a.positional&&(0,Y.jsx)(lYe,{}),(0,Y.jsx)(`ol`,{className:`mt-3 flex flex-col gap-px font-mono text-sm tabular-nums`,children:a.lines.map((e,t)=>(0,Y.jsx)(uYe,{line:e},`${e.kind}-${t}`))})]})}function cYe({counts:e}){let t=[];return e.added>0&&t.push(`${e.added} added`),e.removed>0&&t.push(`${e.removed} removed`),e.moved>0&&t.push(`${e.moved} moved`),e.changed>0&&t.push(`${e.changed} changed`),(0,Y.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[t.join(`, `),e.unchanged>0&&(0,Y.jsxs)(`span`,{className:`text-fg-tertiary`,children:[t.length>0?` · `:``,e.unchanged,` unchanged`]})]})}function lYe(){return(0,Y.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Ly,{size:12,className:`mt-0.5 shrink-0 text-fg-warning-primary-alt`,"aria-hidden":!0}),`This list is too long to match items by content, so it is compared position by position. A reorder will read as a run of changes.`]})}function uYe({line:e}){let t=`index`in e?e.index:null;return(0,Y.jsxs)(`li`,{className:X(`flex min-w-0 items-baseline gap-2 rounded border-l-[3px] py-1 pl-2 pr-1`,e.kind===`added`&&`border-fg-brand-primary bg-bg-brand-primary/5`,e.kind===`removed`&&`border-fg-error bg-bg-error-secondary/30`,e.kind===`moved`&&`border-fg-warning bg-bg-secondary/40`,e.kind===`changed`&&`border-fg-warning`,e.kind===`unchanged`&&`border-transparent`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`w-3 shrink-0 select-none text-center`,e.kind===`added`&&`text-fg-brand-primary`,e.kind===`removed`&&`text-fg-error`,e.kind===`moved`&&`text-fg-warning`,e.kind===`changed`&&`text-fg-warning`,e.kind===`unchanged`&&`text-fg-quaternary`),children:dYe(e.kind)}),(0,Y.jsx)(`span`,{className:`w-8 shrink-0 text-right text-xs text-fg-quaternary`,children:t===null?``:t+1}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:(0,Y.jsx)(fYe,{line:e})}),(0,Y.jsx)(pYe,{line:e})]})}function dYe(e){switch(e){case`added`:return`+`;case`removed`:return`−`;case`moved`:return`↕`;case`changed`:return`~`;case`unchanged`:return``}}function fYe({line:e}){return e.kind===`changed`?(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary line-through decoration-fg-error/60`,children:(0,Y.jsx)(J8,{value:e.before})}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`text-fg-quaternary`,children:`→`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(J8,{value:e.after})})]}):(0,Y.jsx)(`span`,{className:e.kind===`removed`?`text-fg-tertiary`:void 0,children:(0,Y.jsx)(J8,{value:e.value})})}function J8({value:e}){return e===null?(0,Y.jsx)(`span`,{className:`italic text-fg-tertiary`,children:`null`}):e===``?(0,Y.jsx)(`span`,{className:`italic text-fg-tertiary`,children:`empty`}):typeof e==`boolean`||typeof e==`number`?(0,Y.jsx)(Y.Fragment,{children:String(e)}):(0,Y.jsx)(Y.Fragment,{children:e})}function pYe({line:e}){if(e.kind===`unchanged`)return null;if(e.kind===`moved`){let t=e.index<e.beforeIndex;return(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 whitespace-nowrap font-sans text-xs text-fg-warning`,children:[t?(0,Y.jsx)(jv,{size:11,"aria-hidden":!0}):(0,Y.jsx)(kv,{size:11,"aria-hidden":!0}),`moved from `,e.beforeIndex+1]})}let t=e.kind===`added`?`added`:e.kind===`removed`?`removed from ${e.beforeIndex+1}`:`changed`;return(0,Y.jsx)(`span`,{className:X(`ml-auto shrink-0 whitespace-nowrap font-sans text-xs`,e.kind===`added`&&`text-fg-brand-primary`,e.kind===`removed`&&`text-fg-error`,e.kind===`changed`&&`text-fg-warning`),children:t})}function Y8(e){if(!Array.isArray(e))return null;let t=[];for(let n of e)if(n===null||typeof n==`string`||typeof n==`number`||typeof n==`boolean`)t.push(n);else return null;return t}function mYe({patchSets:e,profilesByAuthorIds:t,mode:n=`unknown`,canDiscard:r=!1,reloadKey:i,committedPatchIds:a,deployment:o}){let s=eb(),c=wb(),l=GS(),u=a??l,{trees:d,isComputing:f,hasComputed:p}=tYe(e,i,u),m=(0,b.useMemo)(()=>d.flatMap(T5),[d]),h=gYe(d),g=bce((0,b.useMemo)(()=>d.filter(e=>!e.isCommitted).map(e=>e.sourcePath),[d])),{changing:_,reverted:v,committedTrees:y}=(0,b.useMemo)(()=>{let e=[],t=[],n=[];for(let r of d)r.isCommitted?n.push(r):g.has(r.sourcePath)?t.push(r):e.push(r);return{changing:e,reverted:t,committedTrees:n}},[d,g]),x=(0,b.useMemo)(()=>Q8(v.flatMap(T5)),[v]),S=(0,b.useMemo)(()=>{let t=[],n=new Set,r=new Set;for(let i of e)for(let e of i.patches)u.has(e.patchId)||r.has(e.patchId)||(r.add(e.patchId),t.push(e.patchId),e.author!==null&&n.add(e.author));return{ids:t,authorIds:[...n]}},[e,u]);if(!p||f&&d.length===0)return(0,Y.jsx)(e5,{});if(m.length===0)return S.ids.length>0?(0,Y.jsx)(`div`,{className:`mx-auto max-w-7xl min-w-0`,children:(0,Y.jsx)(Z8,{patchIds:S.ids,authorIds:S.authorIds,profilesByAuthorIds:t,canDiscard:r,portalContainer:s})}):(0,Y.jsx)(`div`,{className:`text-sm text-fg-secondary py-8 text-center`,children:`No pending changes.`});let C=c.status===`success`?c.data:void 0;return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-7xl flex flex-col gap-6 lg:gap-8 min-w-0`,children:[(0,Y.jsx)(_Ye,{authorIds:h.authorIds,pendingAuthorIds:h.pendingAuthorIds,profilesByAuthorIds:t,mode:n,pendingPatchIds:h.pendingPatchIds,deployingCount:h.deployingCount,canDiscard:r,portalContainer:s}),_.length===0&&v.length>0&&(0,Y.jsx)(Z8,{patchIds:x,authorIds:h.pendingAuthorIds,profilesByAuthorIds:t,canDiscard:r,portalContainer:s}),_.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`pending-${e.sourcePath}`)),v.length>0&&(0,Y.jsx)(hYe,{count:x.length,children:v.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`reverted-${e.sourcePath}`))}),y.length>0&&(o===void 0?(0,Y.jsx)(vYe,{}):(0,Y.jsx)(t5,{deployment:o})),y.map(e=>(0,Y.jsx)(i5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`committed-${e.sourcePath}`))]})}function X8(e,t){let n=nC();return(0,b.useMemo)(()=>e.filter(e=>e!==n).map(e=>t?.[e]?.fullName).filter(e=>!!e),[e,t,n])}function Z8({patchIds:e,authorIds:t,profilesByAuthorIds:n,canDiscard:r,portalContainer:i}){let{deletePatches:a}=RS(),o=X8(t,n);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border-primary bg-bg-secondary px-4 py-3 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(Xv,{size:16,className:`shrink-0 text-fg-secondary`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-fg-primary`,children:e.length===1?`The one pending change has been reverted.`:`Every pending change has been reverted.`}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`The content matches what is published, so there is nothing to publish.`})]}),r&&e.length>0&&(0,Y.jsx)(w5,{description:n8(e.length,o),title:`Discard ${e.length} ${e.length===1?`change`:`changes`}?`,confirmLabel:`Discard ${e.length}`,onConfirm:()=>a(e),portalContainer:i,ariaLabel:`Discard all ${e.length} reverted ${e.length===1?`change`:`changes`}`,label:`Discard all`})]})}function hYe({count:e,children:t}){let[n,r]=(0,b.useState)(!1);return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex items-center gap-2 self-start rounded-md px-1 py-1 text-xs text-fg-secondary hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:[(0,Y.jsx)(Rv,{size:14,"aria-hidden":!0,className:(0,AC.default)(`transition-transform`,{"rotate-90":n})}),(0,Y.jsx)(Ay,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e===1?`1 reverted change`:`${e} reverted changes`})]}),n&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-6 lg:gap-8`,children:t})]})}function gYe(e){return(0,b.useMemo)(()=>{let t=e.filter(e=>!e.isCommitted).flatMap(T5),n=e.filter(e=>e.isCommitted).flatMap(T5);return{authorIds:$8(e.flatMap(T5)),pendingAuthorIds:$8(t),pendingPatchIds:Q8(t),deployingCount:Q8(n).length}},[e])}function Q8(e){let t=[],n=new Set;for(let r of e)for(let e of r.change?.patchIds??[])n.has(e)||(n.add(e),t.push(e));return t}function $8(e){let t=[],n=new Set;for(let r of e)for(let e of r.change?.authors??[])n.has(e)||(n.add(e),t.push(e));return t}function e5(){return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-7xl flex flex-col gap-8 min-w-[380px]`,"aria-busy":`true`,"aria-live":`polite`,"aria-label":`Loading changes`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:14,className:`animate-spin`,"aria-hidden":!0}),`Building the comparison…`]}),[0,1].map(e=>(0,Y.jsxs)(`section`,{className:`border border-border-primary rounded-lg bg-bg-primary overflow-hidden`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 px-5 py-4 border-b border-border-primary`,children:[(0,Y.jsx)(eX,{className:`h-4 w-48`}),(0,Y.jsx)(eX,{className:`ml-auto h-6 w-6 rounded-full`})]}),(0,Y.jsx)(`div`,{className:`divide-y divide-border-primary`,children:[0,1].map(e=>(0,Y.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,Y.jsx)(eX,{className:`h-3 w-32`}),(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Y.jsx)(eX,{className:`h-10 w-full`}),(0,Y.jsx)(eX,{className:`h-10 w-full`})]})]},e))})]},e))]})}function _Ye({authorIds:e,pendingAuthorIds:t,profilesByAuthorIds:n,mode:r,pendingPatchIds:i,deployingCount:a,canDiscard:o,portalContainer:s}){let{deletePatches:c}=RS(),l=X8(t??e,n),u=i.length===0&&a>0,d=u?a:i.length;return(0,Y.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col sm:flex-row sm:items-center gap-2 sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xl font-medium leading-none text-fg-primary tabular-nums`,children:d}),(0,Y.jsx)(`span`,{className:`text-sm text-fg-secondary truncate`,children:u?`${d===1?`change`:`changes`} deploying`:`${d===1?`change`:`changes`} to review`}),(0,Y.jsx)(`span`,{className:`ml-auto sm:hidden`,children:(0,Y.jsx)(_5,{authorIds:e,profilesByAuthorIds:n,mode:r})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 sm:ml-auto border-t border-border-primary pt-2 sm:border-t-0 sm:pt-0`,children:[a>0&&i.length>0&&(0,Y.jsxs)(`span`,{className:`text-xs text-fg-tertiary whitespace-nowrap`,children:[a,` deploying`]}),o&&i.length>0&&(0,Y.jsx)(w5,{description:n8(i.length,l),title:`Discard ${i.length} ${i.length===1?`change`:`changes`}?`,confirmLabel:`Discard ${i.length}`,onConfirm:()=>c(i),portalContainer:s,ariaLabel:`Discard all ${i.length} pending ${i.length===1?`change`:`changes`}`,label:`Discard all`}),o&&i.length===0&&a>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-tertiary whitespace-nowrap`,children:[(0,Y.jsx)(gy,{size:12,"aria-hidden":!0}),`Nothing left to discard`]}),(0,Y.jsx)(`span`,{className:`ml-auto hidden sm:inline-flex`,children:(0,Y.jsx)(_5,{authorIds:e,profilesByAuthorIds:n,mode:r})})]})]})}function vYe(){let{deployments:e}=HS(),t=yce(),n=(0,b.useMemo)(()=>{for(let n of t){let t=e.find(e=>e.commitSha===n);if(t)return t}return null},[e,t]);return(0,Y.jsx)(t5,{deployment:n,commitShas:t})}function t5({deployment:e,commitShas:t=[]}){let[n]=(0,b.useState)(()=>new Date),r=e?.deploymentState,i=r===`created`||r===`pending`,a=r===`failure`||r===`error`,o=r===`success`,s=a?`Published — deploy failed`:i?`Published & deploying`:o?`Published — live`:`Published`,c=t.length>0?t:e?[e.commitSha]:[],l=c.length>1?`${c.length} commits`:c.length===1?`${c[0].slice(0,7)}${e?` · ${Wk(n,e.updatedAt)}`:``}`:null,u=(0,Y.jsx)(`span`,{className:`hidden sm:block h-px flex-1 bg-border-primary`,role:`separator`,"aria-hidden":!0});return(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-0 sm:gap-4`,children:[(0,Y.jsx)(`span`,{className:`block sm:hidden h-px bg-border-primary`,"aria-hidden":!0}),u,(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex items-start sm:items-center gap-2 min-w-0`,`border rounded-lg px-3 py-2 -mt-px`,`sm:rounded-full sm:py-1.5 sm:mt-0 sm:shrink-0`,{"bg-bg-error-secondary border-border-error-secondary text-fg-error-secondary":a,"bg-bg-warning-primary border-border-warning-primary text-fg-warning-primary":i,"bg-bg-brand-primary border-border-brand-primary text-fg-brand-primary":o,"bg-bg-secondary border-border-primary text-fg-secondary":!a&&!i&&!o}),children:[i?(0,Y.jsx)(hy,{size:14,className:`animate-spin shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):a?(0,Y.jsx)(Bv,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):o?(0,Y.jsx)(Fv,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):(0,Y.jsx)(gy,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`flex flex-col sm:flex-row sm:items-center sm:gap-2 min-w-0 text-xs sm:text-[13px]`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:s}),(0,Y.jsxs)(`span`,{className:`opacity-80`,children:[l&&(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[l,` — `]}),`these cannot be discarded`]})]})]}),u]})}function n5(e){let t=[],n=new Set;function r(e){for(let r of e.change?.patchIds??[])n.has(r)||(n.add(r),t.push(r));for(let t of e.children)r(t)}return r(e),t}function r5(e){let t=[],n=new Set,r={};function i(e){if(e.change){for(let r of e.change.authors)n.has(r)||(n.add(r),t.push(r));for(let[t,n]of Object.entries(e.change.patchesByAuthorIds)){r[t]||(r[t]=[]);for(let e of n)r[t].push({createdAt:e.createdAt,opType:e.opType})}}for(let t of e.children)i(t)}return i(e),{authorIds:t,patchesByAuthorIds:r}}function i5({tree:e,profilesByAuthorIds:t,portalContainer:n,mode:r,schemas:i,canDiscard:a}){let o=e.sourcePath,s=i?.[o],c=s?.type===`record`&&!!s.router,[l,u]=(0,b.useState)(!1),{deletePatches:d}=RS(),[f]=(0,b.useState)(()=>new Date),p=jb(o),m=Ab(o),h=p.status===`success`&&m.status===`success`&&Mr(p.data,m.data),g=(0,b.useMemo)(()=>n5(e),[e]),{patchesByAuthorIds:_}=(0,b.useMemo)(()=>r5(e),[e]),v=a&&!e.isCommitted,y={moduleFilePath:o,isRouterModule:c,profilesByAuthorIds:t,portalContainer:n,mode:r,canDiscard:v,isCommitted:e.isCommitted};return(0,Y.jsxs)(`section`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`border rounded-lg overflow-hidden`,e.isCommitted?`border-dashed border-border-primary bg-bg-secondary`:`border-border-primary bg-bg-primary`),children:[(0,Y.jsxs)(`header`,{className:(0,AC.default)(`flex items-center gap-2 px-4 lg:px-5 py-4 border-b min-w-0`,e.isCommitted?`border-dashed border-border-primary`:`border-border-primary`),children:[(0,Y.jsx)(SYe,{moduleFilePath:o}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[e.isCommitted&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-tertiary`,title:`Published — this cannot be discarded`,children:[(0,Y.jsx)(gy,{size:12,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`Deploying`})]}),v&&g.length>0&&(0,Y.jsx)(y5,{isEqual:h,onDiscard:()=>d(g),confirmDescription:`Discard all changes in this module? This cannot be undone.`,unchangedAriaLabel:`Discard all unchanged in this module`,confirmAriaLabel:`Discard all changes in this module`,portalContainer:n}),Object.keys(_).length>0&&(0,Y.jsx)(Whe,{patchesByAuthorIds:_,profilesByAuthorIds:t,now:f,portalContainer:n,mode:r}),(0,Y.jsx)(v5,{isOpen:!l,onToggle:()=>u(e=>!e),openLabel:`Collapse module`,closedLabel:`Expand module`})]})]}),!l&&(0,Y.jsxs)(`div`,{className:`divide-y divide-border-primary`,children:[e.isCommitted&&(0,Y.jsx)(`p`,{className:`px-4 lg:px-5 py-3 text-xs text-fg-tertiary`,children:`Already part of the published content, so there is no before and after to compare. Open a field to see its current value.`}),(0,Y.jsx)(a5,{node:e,rowProps:y})]})]})}function yYe(e){let t=Cb(e);if(t.status===`loading`)return;if(t.status!==`success`||t.data.type!==`array`)return!1;let n=t.data.item.type;return n===`string`||n===`number`||n===`boolean`}function a5({node:e,rowProps:t}){let n=yYe(e.sourcePath);return n===void 0?null:n?(0,Y.jsx)(CYe,{row:e,...t},e.sourcePath):e.change?e.change.changeType===`added`||e.change.changeType===`removed`?(0,Y.jsx)(c5,{row:e,...t},e.sourcePath):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(c5,{row:e,...t},e.sourcePath),e.children.length>0&&(0,Y.jsx)(s5,{parent:e,rowProps:t})]}):e.children.some(e=>o5(e))?(0,Y.jsx)(s5,{parent:e,rowProps:t}):null}function bYe(e){return H.mediaUrl({path:e})}function o5(e){return e.change?!0:e.children.some(o5)}function xYe(e){let t=[],n=[],r={},i=new Set,a=new Set,o=``,s=null;function c(e){let l=e.change;if(l){for(let e of l.patchIds)i.has(e)||(i.add(e),t.push(e));for(let e of l.authors)a.has(e)||(a.add(e),n.push(e));for(let[e,t]of Object.entries(l.patchesByAuthorIds))r[e]||(r[e]=[]),r[e].push(...t);e.lastUpdated>o&&(o=e.lastUpdated,s=l.lastUpdatedBy)}for(let t of e.children)c(t)}return c(e),{...e,children:[],change:{changeType:e.change?.changeType??`field-change`,patchIds:t,authors:n,lastUpdatedBy:s,patchesByAuthorIds:r}}}function s5({parent:e,rowProps:t}){let n=Cb(e.sourcePath),r=n.status===`success`&&n.data.type===`record`?n.data.mediaType:void 0;return r?(0,Y.jsx)(Y.Fragment,{children:e.children.filter(e=>o5(e)).map(e=>(0,Y.jsx)(c5,{row:xYe(e),...t,parentMediaType:r},e.sourcePath))}):(0,Y.jsx)(Y.Fragment,{children:e.children.filter(e=>o5(e)).map(e=>(0,Y.jsx)(a5,{node:e,rowProps:t},e.sourcePath))})}function SYe({moduleFilePath:e}){let t=H.splitModuleFilePath(e),n=E8(e);return(0,Y.jsx)(`h2`,{className:`text-sm font-medium text-fg-primary truncate min-w-0`,children:(0,Y.jsx)(`a`,{...n,title:e,className:`flex items-center gap-1.5 min-w-0 rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:t.map((e,n)=>(0,Y.jsxs)(b.Fragment,{children:[n>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,"aria-hidden":!0,children:`/`}),(0,Y.jsx)(`span`,{className:(0,AC.default)({"text-fg-secondary":n<t.length-1}),children:kC(e)})]},`${e}-${n}`))})})}function CYe({row:e,moduleFilePath:t,isRouterModule:n,profilesByAuthorIds:r,portalContainer:i,mode:a,canDiscard:o,isCommitted:s}){let{deletePatches:c}=RS(),[l]=(0,b.useState)(()=>new Date),[u,d]=(0,b.useState)(!0),f=e.sourcePath,p=jb(f),m=Ab(f),h=!s&&p.status===`success`&&m.status===`success`&&Mr(p.data,m.data),g=(0,b.useMemo)(()=>n5(e),[e]),{patchesByAuthorIds:_}=(0,b.useMemo)(()=>r5(e),[e]),[,v]=H.splitModuleFilePathAndModulePath(f),y=v?H.splitModulePath(v):[],x=n&&y.length===1,S=y[y.length-1]??``;return g.length===0?null:(0,Y.jsxs)(`article`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`px-5 py-5`,{"opacity-60":h}),children:[(0,Y.jsx)(l5,{sourcePath:f,changeType:`field-change`,segment:S,modulePath:v,moduleFilePath:t,isRouterPageKey:x,patchesByAuthorIds:_,profilesByAuthorIds:r,portalContainer:i,mode:a,now:l,onDiscard:()=>c(g),isExpanded:u,onToggleExpand:()=>d(e=>!e),isEqual:h,canDiscard:o,hideExpand:s}),u&&!s&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(sYe,{sourcePath:f})})]})}function c5({row:e,moduleFilePath:t,isRouterModule:n,profilesByAuthorIds:r,portalContainer:i,mode:a,canDiscard:o,isCommitted:s,parentMediaType:c}){let{deletePatches:l}=RS(),[u]=(0,b.useState)(()=>new Date),d=e.change,[f,p]=(0,b.useState)(d?.changeType!==`removed`),m=e.sourcePath,h=jb(m),g=Ab(m);if(!d)return null;let _=!s&&d.changeType===`field-change`&&h.status===`success`&&g.status===`success`&&Mr(h.data,g.data),[,v]=H.splitModuleFilePathAndModulePath(m),y=v?H.splitModulePath(v):[],x=n&&y.length===1,S=y[y.length-1]??``,C={};for(let[e,t]of Object.entries(d.patchesByAuthorIds))C[e]=t.map(e=>({createdAt:e.createdAt,opType:e.opType}));return(0,Y.jsxs)(`article`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`px-5 py-5`,{"opacity-60":_,"bg-bg-error-secondary/30":d.changeType===`removed`,"bg-bg-brand-primary/5":d.changeType===`added`}),children:[(0,Y.jsx)(l5,{sourcePath:m,changeType:d.changeType,segment:S,modulePath:v,moduleFilePath:t,isRouterPageKey:x,patchesByAuthorIds:C,profilesByAuthorIds:r,portalContainer:i,mode:a,now:u,onDiscard:()=>l(d.patchIds),isExpanded:f,onToggleExpand:()=>p(e=>!e),isEqual:_,canDiscard:o,hideExpand:s,parentMediaType:c}),!s&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(DYe,{sourcePath:m,changeType:d.changeType,isExpanded:f,isEqual:_,parentMediaType:c})})]})}function l5({sourcePath:e,changeType:t,segment:n,modulePath:r,moduleFilePath:i,isRouterPageKey:a,patchesByAuthorIds:o,profilesByAuthorIds:s,portalContainer:c,mode:l,now:u,onDiscard:d,isExpanded:f,onToggleExpand:p,isEqual:m,canDiscard:h,hideExpand:g,parentMediaType:_}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(EYe,{changeType:t,isEqual:m}),(0,Y.jsx)(wYe,{sourcePath:e,segment:n,modulePath:r,moduleFilePath:i,isRouterPageKey:a,parentMediaType:_}),(0,Y.jsx)(TYe,{changeType:t,isEqual:m}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[h&&(0,Y.jsx)(y5,{isEqual:m,onDiscard:d,confirmDescription:`Discard this change? This cannot be undone.`,unchangedAriaLabel:`Discard unchanged`,confirmAriaLabel:`Discard this change`,portalContainer:c}),(0,Y.jsx)(Whe,{patchesByAuthorIds:o,profilesByAuthorIds:s,now:u,portalContainer:c,mode:l}),!g&&(0,Y.jsx)(v5,{isOpen:f,onToggle:p,openLabel:`Collapse`,closedLabel:`Expand`})]})]})}function wYe({sourcePath:e,segment:t,modulePath:n,moduleFilePath:r,isRouterPageKey:i,parentMediaType:a}){let o=(()=>{if(a){let{filename:e,folder:n}=pS(t);return n===`/`?`/${e}`:`${n}/${e}`}return n?i?t:lD(n):kC(H.splitModuleFilePath(r).pop()??``)})();return(0,Y.jsx)(V8,{sourcePath:e,previewSegment:i&&!a&&n?t:void 0,className:`min-w-0`,children:o})}function TYe({changeType:e,isEqual:t}){return t?(0,Y.jsx)(`span`,{className:`text-sm text-fg-tertiary px-1.5 py-0.5 rounded bg-bg-secondary shrink-0`,children:`Unchanged`}):e===`added`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-brand-primary shrink-0`,children:`Added`}):e===`removed`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-error shrink-0`,children:`Removed`}):e===`moved`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-warning shrink-0`,children:`Moved`}):null}function EYe({changeType:e,isEqual:t}){if(t)return(0,Y.jsx)(Xv,{size:14,className:`shrink-0 text-fg-tertiary`,"aria-label":`Unchanged`});switch(e){case`added`:return(0,Y.jsx)(Oy,{size:14,className:`shrink-0 text-fg-brand-primary`,"aria-label":`Added`});case`removed`:return(0,Y.jsx)(yy,{size:14,className:`shrink-0 text-fg-error`,"aria-label":`Removed`});case`moved`:return(0,Y.jsx)(Av,{size:14,className:`shrink-0 text-fg-warning`,"aria-label":`Moved`});case`field-change`:return(0,Y.jsx)(Dy,{size:14,className:`shrink-0 text-fg-secondary`,"aria-label":`Edited`})}}function DYe({sourcePath:e,changeType:t,isExpanded:n,isEqual:r,parentMediaType:i}){return i?(0,Y.jsx)(kYe,{sourcePath:e,changeType:t,mediaType:i,isExpanded:n,isEqual:r}):t===`field-change`?(0,Y.jsx)(jYe,{sourcePath:e,isExpanded:n,isEqual:r}):n?t===`added`?(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`added`}):t===`removed`?(0,Y.jsx)(AYe,{sourcePath:e}):(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`added`}):null}function u5(e){if(e&&typeof e.hotspot==`object`&&e.hotspot!==null&&`x`in e.hotspot&&`y`in e.hotspot){let t=e.hotspot;if(typeof t.x==`number`&&typeof t.y==`number`)return{x:t.x,y:t.y}}}function d5({metadata:e}){let t=[];return e&&(typeof e.mimeType==`string`&&t.push({label:`mimeType`,value:e.mimeType}),typeof e.width==`number`&&typeof e.height==`number`&&t.push({label:`dimensions`,value:`${e.width} × ${e.height}`})),t.length===0?null:(0,Y.jsx)(`dl`,{className:`mt-4 text-xs text-fg-secondary grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:t.map(e=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-fg-tertiary`,children:e.label}),(0,Y.jsx)(`dd`,{className:`truncate`,children:e.value})]},e.label))})}function f5({sourcePath:e,showValidation:t=!1}){let n=H.createValPathOfItem(e,`alt`),r=Cb(n);return r.status===`success`?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium mb-1 block`,children:`Alt`}),(0,Y.jsx)(r6,{path:n,schema:r.data,readonly:!0,errorDisplay:t?`compact`:`none`})]}):null}function p5({url:e,filename:t,diffStyle:n,hotspot:r}){return e?(0,Y.jsxs)(`div`,{className:`w-[120px] flex-shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`relative w-[120px] h-[90px]`,children:[(0,Y.jsx)(`img`,{src:e,alt:t,draggable:!1,className:(0,AC.default)(`w-full h-full object-cover rounded border border-border-primary`,{"opacity-40":n===`removed`}),style:r?{objectPosition:`${r.x*100}% ${r.y*100}%`}:void 0}),r&&(0,Y.jsx)(sA,{hotspot:r,size:`sm`})]}),r&&(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`hotspot `,Math.round(r.x*100),`%, `,Math.round(r.y*100),`%`]})]}):(0,Y.jsxs)(`div`,{className:`w-[120px] flex-shrink-0`,children:[(0,Y.jsx)(`div`,{className:`w-[120px] h-[90px] rounded bg-bg-secondary flex items-center justify-center text-fg-disabled text-xs`,children:`No preview`}),r&&(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`hotspot `,Math.round(r.x*100),`%,`,` `,Math.round(r.y*100),`%`]})]})}function OYe(e){return(0,b.useMemo)(()=>{let[,t]=H.splitModuleFilePathAndModulePath(e),n=t?H.splitModulePath(t):[];return n[n.length-1]??``},[e])}function kYe({sourcePath:e,changeType:t,mediaType:n,isExpanded:r,isEqual:i}){let a=OYe(e),o=Mb(),s=n===`images`,c=Ab(e),l=jb(e),u=c.status===`success`?c.data:null,d=l.status===`success`?l.data:null,f=u5(u),p=u5(d),m=s?rA(a,o):null,h=Dse(a);if(!r&&t!==`field-change`)return null;if(i&&t===`field-change`)return(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(`div`,{className:`border-l-[3px] border-border-secondary pl-3 pr-1 py-2 min-w-0`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})});if(t===`added`||t===`moved`)return r?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,diffStyle:`added`,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})}):null;if(t===`removed`){if(!r)return null;let t=s?bYe(a):null;return(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`removed`,children:(0,Y.jsx)(C5,{isImage:s,url:t,filename:h,diffStyle:`removed`,hotspot:p,metadata:d,sourcePath:e})})})})}if(!r)return null;let g=l.status===`success`;return g&&l.data===null||!g?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(C5,{isImage:s,url:m,filename:h,diffStyle:`added`,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})}):(0,Y.jsxs)(`div`,{className:`border-l-[3px] border-fg-brand-primary pl-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[s&&(0,Y.jsx)(p5,{url:m,filename:h,hotspot:f}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(x5,{variant:`media`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(f5,{sourcePath:e})}),after:(0,Y.jsx)(f5,{sourcePath:e,showValidation:!0})})})]}),(0,Y.jsx)(d5,{metadata:u})]})}function AYe({sourcePath:e}){return(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(m5,{sourcePath:e,side:`after`,diffStyle:`removed`})})}function jYe({sourcePath:e,isExpanded:t,isEqual:n}){let r=roe(e),i=r.status===`success`?r.resolvedPath:e,a=jb(i);if(r.status!==`success`)return null;let o=r.data,s=a.status===`success`,c=s&&a.data===null;return t?n?(0,Y.jsx)(x5,{variant:`equal`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}),after:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`compact`})}):c||!s?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:`added`,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})})}):(0,Y.jsx)(x5,{variant:`changed`,before:(0,Y.jsx)(b5,{sourcePath:e,children:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}),after:(0,Y.jsx)(r6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})}):null}function m5({sourcePath:e,side:t,diffStyle:n}){let[r]=(0,b.useMemo)(()=>H.splitModuleFilePathAndModulePath(e),[e]),i=jb(r),a=(0,b.useMemo)(()=>i.status===`success`?{moduleFilePath:r,moduleSource:i.data}:null,[r,i]);return t===`before`?(0,Y.jsx)(lb.Provider,{value:a,children:(0,Y.jsx)(h5,{sourcePath:e,diffStyle:n})}):(0,Y.jsx)(h5,{sourcePath:e,diffStyle:n})}function h5({sourcePath:e,diffStyle:t}){let n=Cb(e);if(n.status!==`success`)return null;let r=n.data;return(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(g5,{diffStyle:t,children:t===`removed`?(0,Y.jsx)(`div`,{className:`[&_div]:decoration-fg-error [&_pre]:decoration-fg-error line-through decoration-fg-error`,children:(0,Y.jsx)(r6,{path:e,schema:r,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}):(0,Y.jsx)(r6,{path:e,schema:r,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})})})}function g5({diffStyle:e,children:t}){return(0,Y.jsx)(`div`,{className:(0,AC.default)(`border-l-[3px] pl-3 pr-1 py-2 min-w-0`,{"border-fg-error":e===`removed`,"border-fg-brand-primary":e===`added`}),children:t})}function _5({authorIds:e,profilesByAuthorIds:t,mode:n}){if(e.length===0)return null;let r=e.slice(0,9),i=e.length-r.length;return(0,Y.jsxs)(`div`,{className:`flex items-center`,"aria-label":`Authors`,children:[r.map((e,r)=>(0,Y.jsx)(MYe,{profile:t[e]??null,isFirst:r===0,mode:n},e)),i>0&&(0,Y.jsxs)(`span`,{className:`-ml-2 w-7 h-7 rounded-full inline-flex items-center justify-center text-[11px] font-semibold bg-bg-secondary text-fg-secondary border-2 border-bg-primary`,"aria-label":`${i} more authors`,children:[`+`,i]})]})}function MYe({profile:e,isFirst:t,mode:n}){let r=(0,AC.default)(`shrink-0 w-7 h-7 rounded-full inline-flex items-center justify-center text-[11px] font-semibold overflow-hidden border-2 border-bg-primary`,{"-ml-2":!t});return e?e.avatar?.url?(0,Y.jsx)(`img`,{src:e.avatar.url,alt:e.fullName,title:e.fullName,className:(0,AC.default)(r,`object-cover`)}):(0,Y.jsx)(`span`,{className:(0,AC.default)(r,`bg-bg-brand-primary text-fg-brand-primary`),title:e.fullName,children:zhe(e.fullName)}):(0,Y.jsx)(`span`,{className:(0,AC.default)(r,`bg-bg-secondary text-fg-disabled`),title:n===`fs`?`Local changes`:`Unknown author`,children:n===`fs`?(0,Y.jsx)(jy,{size:12}):(0,Y.jsx)(Vy,{size:12})})}function v5({isOpen:e,onToggle:t,openLabel:n,closedLabel:r}){return(0,Y.jsx)(`button`,{onClick:t,className:(0,AC.default)(`size-5 flex items-center justify-center text-fg-secondary hover:text-fg-primary transition-transform`,{"rotate-180":e}),"aria-label":e?n:r,children:(0,Y.jsx)(Iv,{size:14})})}function y5({isEqual:e,onDiscard:t,confirmDescription:n,unchangedAriaLabel:r,confirmAriaLabel:i,portalContainer:a}){return e?(0,Y.jsx)(t_,{variant:`default`,size:`icon-sm`,onClick:t,"aria-label":r,children:(0,Y.jsx)(zy,{size:14})}):(0,Y.jsx)(w5,{description:n,onConfirm:t,portalContainer:a,ariaLabel:i})}function b5({sourcePath:e,children:t}){let[n]=(0,b.useMemo)(()=>H.splitModuleFilePathAndModulePath(e),[e]),r=jb(n),i=(0,b.useMemo)(()=>r.status===`success`?{moduleFilePath:n,moduleSource:r.data}:null,[n,r]);return(0,Y.jsx)(lb.Provider,{value:i,children:t})}function x5({variant:e,before:t,after:n}){if(e===`media`)return(0,Y.jsxs)(`div`,{className:`grid gap-3 lg:gap-0 lg:grid-cols-[minmax(0,1fr)_24px_minmax(0,1fr)] items-start`,children:[(0,Y.jsxs)(`div`,{className:`pr-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-tertiary mb-1`,children:`Before`}),t]}),(0,Y.jsx)(`div`,{className:`hidden lg:flex items-center justify-center text-fg-tertiary pt-3`,"aria-hidden":!0,children:(0,Y.jsx)(Av,{size:14})}),(0,Y.jsxs)(`div`,{className:`pl-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-tertiary mb-1`,children:`After`}),n]})]});let r=e===`equal`?`border-border-secondary`:`border-fg-brand-primary`,i=e===`equal`?Xv:Av;return(0,Y.jsxs)(`div`,{className:`grid gap-3 lg:gap-0 lg:grid-cols-[minmax(0,1fr)_24px_minmax(0,1fr)] items-stretch`,children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`border-l-[3px] pl-3 pr-12 lg:pr-1 py-2 min-w-0`,r),children:[(0,Y.jsx)(S5,{children:`Before`}),t]}),(0,Y.jsx)(`div`,{className:`hidden lg:flex items-center justify-center text-fg-tertiary`,"aria-hidden":!0,children:(0,Y.jsx)(i,{size:14})}),(0,Y.jsxs)(`div`,{className:`pl-4 lg:pl-1 pr-3 py-2 min-w-0`,children:[(0,Y.jsx)(S5,{children:`After`}),n]})]})}function S5({children:e}){return(0,Y.jsx)(`div`,{className:`lg:hidden text-[10px] uppercase tracking-wider font-medium text-fg-tertiary mb-1`,children:e})}function C5({isImage:e,url:t,filename:n,hotspot:r,diffStyle:i,metadata:a,sourcePath:o,showValidation:s}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[e&&(0,Y.jsx)(p5,{url:t,filename:n,diffStyle:i,hotspot:r}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(f5,{sourcePath:o,showValidation:s})})]}),(0,Y.jsx)(d5,{metadata:a})]})}function w5({description:e,title:t,confirmLabel:n,onConfirm:r,portalContainer:i,ariaLabel:a,label:o}){let[s,c]=(0,b.useState)(!1);return(0,Y.jsxs)(SD,{open:s,onOpenChange:c,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:o?`sm`:`icon-sm`,"aria-label":a,className:o?`gap-2`:void 0,children:[(0,Y.jsx)(zy,{size:14}),o&&(0,Y.jsx)(`span`,{children:o})]})}),(0,Y.jsxs)(wD,{container:i,className:`w-[calc(100vw-24px)] sm:w-auto sm:max-w-xs p-3`,side:`bottom`,align:`end`,children:[t&&(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-sm font-medium text-fg-primary mb-1.5`,children:[(0,Y.jsx)(Bv,{size:15,className:`shrink-0 mt-0.5 text-fg-error-on-surface`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:t})]}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary mb-3`,children:e}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:flex sm:items-center sm:justify-end`,children:[(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>c(!1),children:`Cancel`}),(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{r(),c(!1)},children:n??`Discard`})]})]})]})}function T5(e){let t=[];if(e.change&&t.push(e),!e.change||e.change.changeType!==`added`&&e.change.changeType!==`removed`)for(let n of e.children)for(let e of T5(n))t.push(e);return t}function NYe(){let e=eb();return(0,Y.jsx)(Uy,{open:!0,modal:!0,children:(0,Y.jsxs)(Wy,{children:[(0,Y.jsx)(Gy,{}),(0,Y.jsxs)(Ky,{container:e,"aria-label":`Login required`,className:`bg-bg-secondary text-fg-secondary`,children:[(0,Y.jsx)(qy,{children:(0,Y.jsx)(Yy,{children:(0,Y.jsx)(`span`,{children:`Log in required`})})}),(0,Y.jsx)(Xy,{children:`You need to log in to access Val.`}),(0,Y.jsx)(t_,{asChild:!0,children:(0,Y.jsx)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.origin+Jf(`/val`)}),children:`Log in`})})]})]})})}function E5({code:e}){return(0,Y.jsxs)(`div`,{className:`relative bg-bg-secondary rounded-md p-4 pr-16 my-4`,children:[(0,Y.jsx)(`pre`,{className:`text-xs overflow-x-auto `,children:(0,Y.jsx)(`code`,{children:e})}),(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,className:`absolute top-2 right-2`,onClick:()=>{navigator.clipboard.writeText(e)},children:(0,Y.jsx)(qv,{size:16,className:`mr-2`})})]})}function PYe({moduleFilePath:e,patchPath:t,className:n,toolTip:r=!0,link:i=!0}){let a=bb(),o=(0,b.useRef)(null),s=(0,b.useRef)(new Map),[c,l]=(0,b.useState)([]),[u,d]=(0,b.useState)(),f=Eb(),p=wb(),{navigate:m}=GC();(0,b.useEffect)(()=>{let n=e?H.splitModuleFilePath(e):[],r=t,i=()=>{if(!o.current)return;let t=o.current,i=getComputedStyle(t),a=`${i.fontSize} ${i.fontFamily}`,c=t.offsetWidth,u=n.map(FYe).concat(r).map(e=>`/${e}`);d(u.join(``));let f=e=>{let t=`${e}:${a}`,n=s.current.get(t)??IYe(e,a);return s.current.set(t,n),n},p=`/…`,m=f(p),h=[],g=0;for(let t=u.length-1;t>=0;t--){let i=f(u[t]),a=t!==0;if(g+i+(a?m:0)<=c){let a=t>n.length?`module-path`:`module-file-path`;h.unshift({text:u[t],type:a,moduleFilePath:e,modulePathSegments:r.slice(0,t)}),g+=i}else{h.unshift({type:`ellipsis`,text:p});break}}l(h)},a=new ResizeObserver(i);return o.current&&(a.observe(o.current),i()),()=>{o.current&&a.unobserve(o.current)}},[e,t]);let h=(0,b.useMemo)(()=>{if(!i)return null;let n=`data`in p?p.data:{};if(t.length===0){let t=e;return{navPath:t,sourcePath:t}}let r=rb(t,n[e],f[e]);if(r.success){let i=H.joinModuleFilePathAndModulePath(e,r.modulePath),a=ob(i,f,n);if(a)return{navPath:a,scrollToPath:i};console.debug(`Failed to resolve nav path for ${e} and ${t.join(`.`)}: ${a}`)}else console.debug(`Failed to resolve source path for ${e} and ${t.join(`.`)}: ${r.error}`);return null},[e,t,f,p]);return(0,Y.jsxs)(Jg,{open:r!==!1&&void 0,children:[(0,Y.jsx)(hg,{asChild:!0,children:(0,Y.jsx)(`a`,{href:h&&a?`${a.studioPrefix}${h.navPath}${h.scrollToPath?`#${encodeURIComponent(h.scrollToPath)}`:``}`:void 0,ref:o,className:(0,AC.default)(`inline-block whitespace-nowrap overflow-hidden w-full align-baseline`,{"cursor-pointer hover:underline":i},n),onClick:e=>{i&&h&&e.metaKey===!1&&e.ctrlKey===!1&&e.shiftKey===!1&&(e.preventDefault(),m(h.navPath,{scrollToPath:h.scrollToPath}))},children:c.map((e,t)=>(0,Y.jsx)(`span`,{children:e.text},t))})}),(0,Y.jsx)(Xg,{side:`top`,children:(0,Y.jsx)(eD,{orientation:`horizontal`,className:`max-w-[calc(100vw-3rem)] whitespace-nowrap`,children:u})})]})}function FYe(e){let t=kC(e);return t.slice(0,1).toUpperCase()+t.slice(1)}function IYe(e,t){let n=document.createElement(`canvas`).getContext(`2d`);return n?(n.font=t,n.measureText(e).width):0}function LYe(){let{patchErrors:e}=oC(),{deletePatches:t}=RS(),{navigate:n}=GC(),r=sC(),i=US(),a=eb(),o=QS(),[s,c]=(0,b.useState)(!1),l=(0,b.useMemo)(()=>zYe(e,`data`in i?i.data:void 0),[e,i]),u=(0,b.useMemo)(()=>JSON.stringify({mode:o,changes:l},null,2),[o,l]),d=l.map(e=>e.patchId).join(`|`),[f,p]=(0,b.useState)(d);return f!==d&&(p(d),c(!1)),l.length===0?null:(0,Y.jsx)(Uy,{open:!s,onOpenChange:e=>{c(!e)},children:(0,Y.jsxs)(Ky,{container:a,className:`max-w-2xl`,children:[(0,Y.jsxs)(qy,{children:[(0,Y.jsxs)(Yy,{className:`flex gap-2 items-center`,children:[(0,Y.jsx)(Ly,{size:18}),(0,Y.jsxs)(`span`,{children:[l.length,` change`,l.length===1?``:`s`,` cannot be applied`]})]}),(0,Y.jsx)(Xy,{children:`These changes conflict with newer ones, so they can no longer be applied to the content. Nothing can be published until they are removed. Removing a change discards only that edit.`})]}),(0,Y.jsx)(eD,{className:`max-h-[40vh]`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:l.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 rounded-md border border-border-primary`,children:[(0,Y.jsx)(`div`,{className:`text-sm`,children:e.patchPath?(0,Y.jsx)(PYe,{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath}):(0,Y.jsx)(`span`,{children:e.moduleFilePath})}),(0,Y.jsx)(`div`,{className:`text-xs text-fg-secondary`,children:[e.author?r[e.author]?.fullName??e.author:null,e.createdAt?Wk(new Date,e.createdAt):null].filter(e=>e!==null).join(` · `)}),(0,Y.jsx)(`div`,{className:`text-xs text-fg-error-primary`,children:e.message}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{t([e.patchId])},children:(0,Y.jsxs)(`span`,{className:`flex gap-2 items-center`,children:[(0,Y.jsx)(`span`,{children:`Remove change`}),(0,Y.jsx)(zy,{size:14})]})}),(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>{c(!0),n(`/val/compare`,{scrollToPath:RYe(e)})},children:`Review in compare`})]})]},e.patchId))})}),(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{className:`text-xs cursor-pointer text-fg-secondary`,children:`Diagnosis for Val developers`}),(0,Y.jsx)(E5,{code:u})]}),(0,Y.jsx)(Jy,{children:(0,Y.jsxs)(t_,{variant:`destructive`,onClick:()=>{t(l.map(e=>e.patchId))},children:[`Remove all `,l.length,` and continue`]})})]})})}function RYe(e){return!e.patchPath||e.patchPath.length===0?e.moduleFilePath:H.joinModuleFilePathAndModulePath(e.moduleFilePath,H.patchPathToModulePath(e.patchPath))}function zYe(e,t){if(!e)return[];let n=new Map;for(let e of t??[])for(let t of e.patches)n.set(t.patchId,{author:t.author,createdAt:t.createdAt,patchPath:e.patchPath});let r=[];for(let[t,i]of Object.entries(e))if(i)for(let[e,a]of Object.entries(i)){let i=e,o=n.get(i);r.push({patchId:i,moduleFilePath:t,message:a.message,author:o?.author??null,createdAt:o?.createdAt??null,patchPath:o?.patchPath??null})}return r.sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``))}function BYe({value:e}){return console.warn(`Exhaustive check failed for value:`,e),null}function VYe(){let e=Fce();return e===null?null:e.type===`network-error`?(0,Y.jsx)(D5,{children:`Network error - retrying...`}):e.type===`schema-error`?(0,Y.jsx)(D5,{children:`Schema error - check your console for details`}):e.type===`profiles-auth-error`?(0,Y.jsx)(D5,{children:`Could not authenticate with your personal access token while getting profiles.`}):e.type===`remote-files-error`?(0,Y.jsx)(HYe,{error:e}):(0,Y.jsx)(BYe,{value:e})}function D5({children:e}){return(0,Y.jsx)(`div`,{role:`status`,className:`fixed inset-x-0 top-0 z-full p-4 text-center text-fg-error-primary bg-bg-error-primary`,children:e})}function HYe({error:e}){let t=eb();return(0,Y.jsx)(Uy,{defaultOpen:!0,children:(0,Y.jsxs)(Wy,{children:[(0,Y.jsx)(Gy,{}),(0,Y.jsxs)(Ky,{container:t,className:`max-w-lg p-6 rounded-lg bg-bg-primary text-fg-primary`,children:[(0,Y.jsx)(Yy,{className:`text-lg font-medium mb-4`,children:`Personal access token file required`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{children:`This project uses remote files, which means you need to be authenticated to update them.`}),(0,Y.jsx)(`p`,{children:`To do this locally in this dev environment, you need a Personal Access Token (PAT) stored in a file.`}),(0,Y.jsx)(`p`,{children:`Run the command in the root directory of your project to create the token file.`})]}),(0,Y.jsx)(E5,{code:`npx -p @valbuild/cli val login`}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(zk,{type:`multiple`,children:[(0,Y.jsxs)(Bk,{value:`why-pat`,children:[(0,Y.jsx)(Vk,{children:`Why a personal token file?`}),(0,Y.jsxs)(Hk,{children:[(0,Y.jsx)(`p`,{children:`You are using remote files, which require authentication. In local development, Val uses a personal access token (PAT) to authenticate and allow you to update remote files.`}),(0,Y.jsx)(`p`,{children:`You can create it by running the command shown above, which will create a PAT file.`}),(0,Y.jsx)(`p`,{children:`If you have the PAT already, check that you have internet access and that the project is setup correctly in https://admin.val.build, as issues with either of those could also cause this error.`})]})]}),(0,Y.jsxs)(Bk,{value:`details`,children:[(0,Y.jsx)(Vk,{children:`More details`}),(0,Y.jsx)(Hk,{children:(0,Y.jsxs)(`p`,{children:[`The underlying error message was: "`,e.error,`".`]})})]})]})})]})]})})}function UYe(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var WYe=e=>{switch(e){case`success`:return qYe;case`info`:return YYe;case`warning`:return JYe;case`error`:return XYe;default:return null}},GYe=Array(12).fill(0),KYe=({visible:e,className:t})=>b.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},b.createElement(`div`,{className:`sonner-spinner`},GYe.map((e,t)=>b.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),qYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),JYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),YYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),XYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ZYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},b.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),b.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),QYe=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},$Ye=1,eXe=100,O5=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:$Ye++,k5=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-eXe;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=O5(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],b.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(nXe(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=O5(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},tXe=(e,t)=>k5.message(e,t),nXe=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,rXe=Object.assign(tXe,{success:k5.success,info:k5.info,warning:k5.warning,error:k5.error,custom:k5.custom,message:k5.message,promise:k5.promise,dismiss:k5.dismiss,loading:k5.loading},{getHistory:()=>k5.toasts,getToasts:()=>k5.getActiveToasts()});UYe(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function A5(e){return e.label!==void 0}var iXe=3,aXe=`24px`,oXe=`16px`,j5=4e3,sXe=356,cXe=14,lXe=45,uXe=200;function M5(...e){return e.filter(Boolean).join(` `)}function dXe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var fXe=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:x,gap:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`}=e,[D,O]=b.useState(null),[k,A]=b.useState(null),[j,M]=b.useState(!1),[N,P]=b.useState(!1),[F,I]=b.useState(!1),[L,R]=b.useState(!1),[ee,te]=b.useState(!1),[ne,re]=b.useState(0),[ie,ae]=b.useState(0),oe=b.useRef(n.duration||y||j5),se=b.useRef(null),ce=b.useRef(null),le=c===0,ue=c+1<=o,de=n.type,fe=de??`default`,pe=n.dismissible!==!1,me=n.className||``,he=n.descriptionClassName||``,ge=b.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),_e=b.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ve=b.useMemo(()=>n.duration||y||j5,[n.duration,y]),ye=b.useRef(0),be=b.useRef(0),xe=b.useRef(0),Se=b.useRef(null),[Ce,we]=x.split(`-`),z=b.useMemo(()=>s.reduce((e,t,n)=>n>=ge?e:e+t.height,0),[s,ge]),B=QYe(),Te=b.useMemo(()=>e.swipeDirections??dXe(x),[e.swipeDirections,x]),Ee=n.invert||t,V=de===`loading`;be.current=b.useMemo(()=>ge*S+z,[ge,z]),b.useEffect(()=>{oe.current=ve},[ve]),b.useEffect(()=>{M(!0)},[]),b.useEffect(()=>{let e=ce.current;if(e){let t=e.getBoundingClientRect().height;return ae(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),b.useLayoutEffect(()=>{if(!j)return;let e=ce.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ae(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[j,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let De=b.useCallback(()=>{P(!0),re(be.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},uXe)},[n,d,a,be]);b.useEffect(()=>{if(n.promise&&de===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||B?(()=>{if(xe.current<ye.current){let e=new Date().getTime()-ye.current;oe.current-=e}xe.current=new Date().getTime()})():oe.current!==1/0&&(ye.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),De()},oe.current)),()=>clearTimeout(e)},[u,i,n,de,B,De]),b.useEffect(()=>{n.delete&&(De(),n.onDismiss==null||n.onDismiss.call(n,n))},[De,n.delete]);function Oe(){return T?.loading?b.createElement(`div`,{className:M5(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":de===`loading`},T.loading):b.createElement(KYe,{className:M5(w?.loader,n?.classNames?.loader),visible:de===`loading`})}let ke=n.icon||T?.[de]||WYe(de);return b.createElement(`li`,{tabIndex:0,ref:ce,className:M5(_,me,w?.toast,n?.classNames?.toast,w?.[fe],n?.classNames?.[fe]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":j,"data-promise":!!n.promise,"data-swiped":ee,"data-removed":N,"data-visible":ue,"data-y-position":Ce,"data-x-position":we,"data-index":c,"data-front":le,"data-swiping":F,"data-dismissible":pe,"data-type":de,"data-invert":Ee,"data-swipe-out":L,"data-swipe-direction":k,"data-expanded":!!(u||C&&j),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?ne:be.current}px`,"--initial-height":C?`auto`:`${ie}px`,...m,...n.style},onDragEnd:()=>{I(!1),O(null),Se.current=null},onPointerDown:e=>{e.button!==2&&(V||!pe||(se.current=new Date,re(be.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(I(!0),Se.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(L||!pe)return;Se.current=null;let e=Number(ce.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(ce.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-se.current?.getTime(),i=D===`x`?e:t,a=Math.abs(i)/r;if((D===`x`?Te.includes(e>0?`right`:`left`):Te.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=lXe||a>.11)){re(be.current),n.onDismiss==null||n.onDismiss.call(n,n),A(D===`x`?e>0?`right`:`left`:t>0?`down`:`up`),De(),R(!0);return}var o,s;(o=ce.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=ce.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),te(!1),I(!1),O(null)},onPointerMove:e=>{var t,n;if(!Se.current||!pe||window.getSelection()?.toString().length>0)return;let r=e.clientY-Se.current.y,i=e.clientX-Se.current.x;!D&&(Math.abs(i)>1||Math.abs(r)>1)&&O(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(D===`y`){if(Te.includes(`top`)||Te.includes(`bottom`)){if(Te.includes(`top`)&&r<0||Te.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(D===`x`&&(Te.includes(`left`)||Te.includes(`right`))){if(Te.includes(`left`)&&i<0||Te.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&te(!0),(t=ce.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=ce.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},_e&&!n.jsx&&de!==`loading`?b.createElement(`button`,{"aria-label":E,"data-disabled":V,"data-close-button":!0,onClick:V||!pe?()=>{}:()=>{De(),n.onDismiss==null||n.onDismiss.call(n,n)},className:M5(w?.closeButton,n?.classNames?.closeButton)},T?.close??ZYe):null,(de||n.icon||n.promise)&&n.icon!==null&&(T?.[de]!==null||n.icon)?b.createElement(`div`,{"data-icon":``,className:M5(w?.icon,n?.classNames?.icon)},de===`loading`?n.icon||Oe():n.promise?Oe():null,de===`loading`?null:ke):null,b.createElement(`div`,{"data-content":``,className:M5(w?.content,n?.classNames?.content)},b.createElement(`div`,{"data-title":``,className:M5(w?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?b.createElement(`div`,{"data-description":``,className:M5(v,he,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),b.isValidElement(n.cancel)?n.cancel:n.cancel&&A5(n.cancel)?b.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{A5(n.cancel)&&pe&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),De())},className:M5(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,b.isValidElement(n.action)?n.action:n.action&&A5(n.action)?b.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{A5(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&De())},className:M5(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function N5(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function pXe(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?oXe:aXe;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var mXe=b.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=iXe,toastOptions:g,dir:_=N5(),gap:v=cXe,icons:y,customAriaLabel:x,containerAriaLabel:S=`Notifications`}=e,[C,w]=b.useState([]),T=b.useMemo(()=>n?C.filter(e=>e.toasterId===n):C.filter(e=>!e.toasterId),[C,n]),E=b.useMemo(()=>Array.from(new Set([i].concat(T.filter(e=>e.position).map(e=>e.position)))),[T,i]),[D,O]=b.useState([]),[k,A]=b.useState(!1),[j,M]=b.useState(!1),[N,P]=b.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),F=b.useRef(null),I=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),L=b.useRef(null),R=b.useRef(!1),ee=b.useCallback(e=>{w(t=>(t.find(t=>t.id===e.id)?.delete||k5.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return b.useEffect(()=>k5.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{w(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{lm.flushSync(()=>{w(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),b.useEffect(()=>{if(d!==`system`){P(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?P(`dark`):P(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{P(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{P(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),b.useEffect(()=>{C.length<=1&&A(!1)},[C]),b.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;A(!0),(t=F.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===F.current||F.current?.contains(document.activeElement))&&A(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),b.useEffect(()=>{if(F.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,R.current=!1)}},[F.current]),b.createElement(`section`,{ref:t,"aria-label":x??`${S} ${I}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},E.map((t,n)=>{let[i,a]=t.split(`-`);return T.length?b.createElement(`ol`,{key:t,dir:_===`auto`?N5():_,tabIndex:-1,ref:F,className:c,"data-sonner-toaster":!0,"data-sonner-theme":N,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${D[0]?.height||0}px`,"--width":`${sXe}px`,"--gap":`${v}px`,...m,...pXe(l,u)},onBlur:e=>{R.current&&!e.currentTarget.contains(e.relatedTarget)&&(R.current=!1,L.current&&=(L.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||R.current||(R.current=!0,L.current=e.relatedTarget)},onMouseEnter:()=>A(!0),onMouseMove:()=>A(!0),onMouseLeave:()=>{j||A(!1)},onDragEnd:()=>A(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||M(!0)},onPointerUp:()=>M(!1)},T.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>b.createElement(fXe,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:j,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ee,toasts:T.filter(e=>e.position==n.position),heights:D.filter(e=>e.position==n.position),setHeights:O,expandByDefault:o,gap:v,expanded:k,swipeDirections:e.swipeDirections}))):null}))});function hXe(e){let{theme:t}=Qy();return(0,Y.jsx)(mXe,{theme:t??`light`,position:`bottom-center`,closeButton:!0,toastOptions:{classNames:{toast:`group rounded-lg border border-border-primary bg-bg-primary text-fg-primary shadow-lg font-serif`,title:`font-bold`,description:`text-fg-secondary`,icon:`text-fg-error-secondary`,closeButton:`bg-bg-primary text-fg-secondary border-border-primary hover:text-fg-primary`}},...e})}var gXe=6e3;function _Xe(){let{globalTransientErrors:e}=Pce(),t=(0,b.useRef)(new Set);return(0,b.useEffect)(()=>{let n=new Set;for(let r of e)n.add(r.id),!t.current.has(r.id)&&rXe.error(r.message,{id:r.id,description:r.details,duration:gXe});t.current=n},[e]),null}function vXe(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var yXe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bXe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xXe={};function P5(e,t){return((t||xXe).jsx?bXe:yXe).test(e)}var SXe=/[ \t\n\f\r]/g;function CXe(e){return typeof e==`object`?e.type===`text`&&F5(e.value):F5(e)}function F5(e){return e.replace(SXe,``)===``}var I5=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};I5.prototype.normal={},I5.prototype.property={},I5.prototype.space=void 0;function L5(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new I5(n,r,t)}function R5(e){return e.toLowerCase()}var z5=class{constructor(e,t){this.attribute=t,this.property=e}};z5.prototype.attribute=``,z5.prototype.booleanish=!1,z5.prototype.boolean=!1,z5.prototype.commaOrSpaceSeparated=!1,z5.prototype.commaSeparated=!1,z5.prototype.defined=!1,z5.prototype.mustUseProperty=!1,z5.prototype.number=!1,z5.prototype.overloadedBoolean=!1,z5.prototype.property=``,z5.prototype.spaceSeparated=!1,z5.prototype.space=void 0;var B5=c({boolean:()=>V5,booleanish:()=>H5,commaOrSpaceSeparated:()=>q5,commaSeparated:()=>K5,number:()=>W5,overloadedBoolean:()=>U5,spaceSeparated:()=>G5}),wXe=0,V5=J5(),H5=J5(),U5=J5(),W5=J5(),G5=J5(),K5=J5(),q5=J5();function J5(){return 2**++wXe}var Y5=Object.keys(B5),X5=class extends z5{constructor(e,t,n,r){let i=-1;if(super(e,t),Z5(this,`space`,r),typeof n==`number`)for(;++i<Y5.length;){let e=Y5[i];Z5(this,Y5[i],(n&B5[e])===B5[e])}}};X5.prototype.defined=!0;function Z5(e,t,n){n&&(e[t]=n)}function Q5(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new X5(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[R5(r)]=r,n[R5(a.attribute)]=r}return new I5(t,n,e.space)}var $5=Q5({properties:{ariaActiveDescendant:null,ariaAtomic:H5,ariaAutoComplete:null,ariaBusy:H5,ariaChecked:H5,ariaColCount:W5,ariaColIndex:W5,ariaColSpan:W5,ariaControls:G5,ariaCurrent:null,ariaDescribedBy:G5,ariaDetails:null,ariaDisabled:H5,ariaDropEffect:G5,ariaErrorMessage:null,ariaExpanded:H5,ariaFlowTo:G5,ariaGrabbed:H5,ariaHasPopup:null,ariaHidden:H5,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:G5,ariaLevel:W5,ariaLive:null,ariaModal:H5,ariaMultiLine:H5,ariaMultiSelectable:H5,ariaOrientation:null,ariaOwns:G5,ariaPlaceholder:null,ariaPosInSet:W5,ariaPressed:H5,ariaReadOnly:H5,ariaRelevant:null,ariaRequired:H5,ariaRoleDescription:G5,ariaRowCount:W5,ariaRowIndex:W5,ariaRowSpan:W5,ariaSelected:H5,ariaSetSize:W5,ariaSort:null,ariaValueMax:W5,ariaValueMin:W5,ariaValueNow:W5,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function e7(e,t){return t in e?e[t]:t}function t7(e,t){return e7(e,t.toLowerCase())}var TXe=Q5({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:K5,acceptCharset:G5,accessKey:G5,action:null,allow:null,allowFullScreen:V5,allowPaymentRequest:V5,allowUserMedia:V5,alt:null,as:null,async:V5,autoCapitalize:null,autoComplete:G5,autoFocus:V5,autoPlay:V5,blocking:G5,capture:null,charSet:null,checked:V5,cite:null,className:G5,cols:W5,colSpan:null,content:null,contentEditable:H5,controls:V5,controlsList:G5,coords:W5|K5,crossOrigin:null,data:null,dateTime:null,decoding:null,default:V5,defer:V5,dir:null,dirName:null,disabled:V5,download:U5,draggable:H5,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:V5,formTarget:null,headers:G5,height:W5,hidden:U5,high:W5,href:null,hrefLang:null,htmlFor:G5,httpEquiv:G5,id:null,imageSizes:null,imageSrcSet:null,inert:V5,inputMode:null,integrity:null,is:null,isMap:V5,itemId:null,itemProp:G5,itemRef:G5,itemScope:V5,itemType:G5,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:V5,low:W5,manifest:null,max:null,maxLength:W5,media:null,method:null,min:null,minLength:W5,multiple:V5,muted:V5,name:null,nonce:null,noModule:V5,noValidate:V5,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:V5,optimum:W5,pattern:null,ping:G5,placeholder:null,playsInline:V5,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:V5,referrerPolicy:null,rel:G5,required:V5,reversed:V5,rows:W5,rowSpan:W5,sandbox:G5,scope:null,scoped:V5,seamless:V5,selected:V5,shadowRootClonable:V5,shadowRootDelegatesFocus:V5,shadowRootMode:null,shape:null,size:W5,sizes:null,slot:null,span:W5,spellCheck:H5,src:null,srcDoc:null,srcLang:null,srcSet:null,start:W5,step:null,style:null,tabIndex:W5,target:null,title:null,translate:null,type:null,typeMustMatch:V5,useMap:null,value:H5,width:W5,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:G5,axis:null,background:null,bgColor:null,border:W5,borderColor:null,bottomMargin:W5,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:V5,declare:V5,event:null,face:null,frame:null,frameBorder:null,hSpace:W5,leftMargin:W5,link:null,longDesc:null,lowSrc:null,marginHeight:W5,marginWidth:W5,noResize:V5,noHref:V5,noShade:V5,noWrap:V5,object:null,profile:null,prompt:null,rev:null,rightMargin:W5,rules:null,scheme:null,scrolling:H5,standby:null,summary:null,text:null,topMargin:W5,valueType:null,version:null,vAlign:null,vLink:null,vSpace:W5,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:V5,disableRemotePlayback:V5,prefix:null,property:null,results:W5,security:null,unselectable:null},space:`html`,transform:t7}),EXe=Q5({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-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:q5,accentHeight:W5,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:W5,amplitude:W5,arabicForm:null,ascent:W5,attributeName:null,attributeType:null,azimuth:W5,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:W5,by:null,calcMode:null,capHeight:W5,className:G5,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:W5,diffuseConstant:W5,direction:null,display:null,dur:null,divisor:W5,dominantBaseline:null,download:V5,dx:null,dy:null,edgeMode:null,editable:null,elevation:W5,enableBackground:null,end:null,event:null,exponent:W5,externalResourcesRequired:null,fill:null,fillOpacity:W5,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:K5,g2:K5,glyphName:K5,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:W5,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:W5,horizOriginX:W5,horizOriginY:W5,id:null,ideographic:W5,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:W5,k:W5,k1:W5,k2:W5,k3:W5,k4:W5,kernelMatrix:q5,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:W5,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:W5,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:W5,overlineThickness:W5,paintOrder:null,panose1:null,path:null,pathLength:W5,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:G5,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:W5,pointsAtY:W5,pointsAtZ:W5,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:q5,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:q5,rev:q5,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:q5,requiredFeatures:q5,requiredFonts:q5,requiredFormats:q5,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:W5,specularExponent:W5,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:W5,strikethroughThickness:W5,string:null,stroke:null,strokeDashArray:q5,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:W5,strokeOpacity:W5,strokeWidth:null,style:null,surfaceScale:W5,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:q5,tabIndex:W5,tableValues:null,target:null,targetX:W5,targetY:W5,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:q5,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:W5,underlineThickness:W5,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:W5,values:null,vAlphabetic:W5,vMathematical:W5,vectorEffect:null,vHanging:W5,vIdeographic:W5,version:null,vertAdvY:W5,vertOriginX:W5,vertOriginY:W5,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:W5,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:e7}),n7=Q5({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()}}),r7=Q5({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:t7}),i7=Q5({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),DXe={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`},OXe=/[A-Z]/g,a7=/-[a-z]/g,kXe=/^data[-\w.:]+$/i;function AXe(e,t){let n=R5(t),r=t,i=z5;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&kXe.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(a7,MXe);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!a7.test(e)){let n=e.replace(OXe,jXe);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=X5}return new i(r,t)}function jXe(e){return`-`+e.toLowerCase()}function MXe(e){return e.charAt(1).toUpperCase()}var NXe=L5([$5,TXe,n7,r7,i7],`html`),o7=L5([$5,EXe,n7,r7,i7],`svg`);function PXe(e){return e.join(` `).trim()}var FXe=s(((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(`
|
|
242
|
-
`);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})),IXe=s((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(FXe());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}})),LXe=s((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))}})),RXe=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(IXe()),r=LXe();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})),s7=l7(`end`),c7=l7(`start`);function l7(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 zXe(e){let t=c7(e),n=s7(e);if(t&&n)return{start:t,end:n}}function u7(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?f7(e.position):`start`in e||`end`in e?f7(e):`line`in e||`column`in e?d7(e):``}function d7(e){return p7(e&&e.line)+`:`+p7(e&&e.column)}function f7(e){return d7(e&&e.start)+`-`+d7(e&&e.end)}function p7(e){return e&&typeof e==`number`?e:1}var m7=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=u7(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}};m7.prototype.file=``,m7.prototype.name=``,m7.prototype.reason=``,m7.prototype.message=``,m7.prototype.stack=``,m7.prototype.column=void 0,m7.prototype.line=void 0,m7.prototype.ancestors=void 0,m7.prototype.cause=void 0,m7.prototype.fatal=void 0,m7.prototype.place=void 0,m7.prototype.ruleId=void 0,m7.prototype.source=void 0;var BXe=u(RXe(),1),h7={}.hasOwnProperty,VXe=new Map,HXe=/[A-Z]/g,UXe=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),WXe=new Set([`td`,`th`]),g7=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function GXe(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=$Xe(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=QXe(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`?o7:NXe,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=_7(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function _7(e,t,n){if(t.type===`element`)return KXe(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return qXe(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return YXe(e,t,n);if(t.type===`mdxjsEsm`)return JXe(e,t);if(t.type===`root`)return XXe(e,t,n);if(t.type===`text`)return ZXe(e,t)}function KXe(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=o7,e.schema=i),e.ancestors.push(t);let a=x7(e,t.tagName,!1),o=eZe(e,t),s=b7(e,t);return UXe.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!CXe(e)})),v7(e,o,a,t),y7(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function qXe(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)}S7(e,t.position)}function JXe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);S7(e,t.position)}function YXe(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=o7,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:x7(e,t.name,!0),o=tZe(e,t),s=b7(e,t);return v7(e,o,a,t),y7(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function XXe(e,t,n){let r={};return y7(r,b7(e,t)),e.create(t,e.Fragment,r,n)}function ZXe(e,t){return t.value}function v7(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function y7(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function QXe(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 $Xe(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=c7(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 eZe(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&h7.call(t.properties,i)){let a=nZe(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&WXe.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 tZe(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 S7(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 S7(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function b7(e,t){let n=[],r=-1,i=e.passKeys?new Map:VXe;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=_7(e,a,o);s!==void 0&&n.push(s)}return n}function nZe(e,t,n){let r=AXe(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?vXe(n):PXe(n)),r.property===`style`){let t=typeof n==`object`?n:rZe(e,String(n));return e.stylePropertyNameCase===`css`&&(t=iZe(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?DXe[r.property]||r.property:r.attribute,n]}}function rZe(e,t){try{return(0,BXe.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new m7("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=g7+`#cannot-parse-style-attribute`,r}}function x7(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=P5(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=P5(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return h7.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);S7(e)}function S7(e,t){let n=new m7("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=g7+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function iZe(e){let t={},n;for(n in e)h7.call(e,n)&&(t[aZe(n)]=e[n]);return t}function aZe(e){let t=e.replace(HXe,oZe);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function oZe(e){return`-`+e.toLowerCase()}var C7={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`]},sZe={};function cZe(e,t){let n=t||sZe;return w7(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function w7(e,t,n){if(lZe(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 T7(e.children,t,n)}return Array.isArray(e)?T7(e,t,n):``}function T7(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=w7(e[i],t,n);return r.join(``)}function lZe(e){return!!(e&&typeof e==`object`)}var E7=document.createElement(`i`);function D7(e){let t=`&`+e+`;`;E7.innerHTML=t;let n=E7.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function O7(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 k7(e,t){return e.length>0?(O7(e,e.length,0,t),e):t}var uZe={}.hasOwnProperty;function dZe(e){let t={},n=-1;for(;++n<e.length;)fZe(t,e[n]);return t}function fZe(e,t){let n;for(n in t){let r=(uZe.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){uZe.call(r,a)||(r[a]=[]);let e=i[a];pZe(r[a],Array.isArray(e)?e:e?[e]:[])}}}function pZe(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);O7(e,0,0,r)}function mZe(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 A7(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var j7=R7(/[A-Za-z]/),M7=R7(/[\dA-Za-z]/),hZe=R7(/[#-'*+\--9=?A-Z^-~]/);function N7(e){return e!==null&&(e<32||e===127)}var P7=R7(/\d/),gZe=R7(/[\dA-Fa-f]/),_Ze=R7(/[!-/:-@[-`{-~]/);function F7(e){return e!==null&&e<-2}function I7(e){return e!==null&&(e<0||e===32)}function L7(e){return e===-2||e===-1||e===32}var vZe=R7(/\p{P}|\p{S}/u),yZe=R7(/\s/);function R7(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function z7(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&M7(e.charCodeAt(n+1))&&M7(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 B7(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return L7(r)?(e.enter(n),s(r)):t(r)}function s(r){return L7(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var bZe={tokenize:xZe};function xZe(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`),B7(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 F7(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var SZe={tokenize:wZe},CZe={tokenize:TZe};function wZe(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 O7(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(CZe,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(CZe,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 F7(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++;O7(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 TZe(e,t,n){return B7(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function EZe(e){if(e===null||I7(e)||yZe(e))return 1;if(vZe(e))return 2}function V7(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 H7={name:`attention`,resolveAll:DZe,tokenize:OZe};function DZe(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};kZe(d,-c),kZe(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=k7(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=k7(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=k7(l,V7(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=k7(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=k7(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,O7(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 OZe(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=EZe(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=EZe(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 kZe(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var AZe={name:`autolink`,tokenize:jZe};function jZe(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 j7(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||M7(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||M7(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||N7(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):hZe(t)?(e.consume(t),l):n(t)}function u(e){return M7(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||M7(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var U7={partial:!0,tokenize:MZe};function MZe(e,t,n){return r;function r(t){return L7(t)?B7(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||F7(e)?t(e):n(e)}}var NZe={continuation:{tokenize:FZe},exit:IZe,name:`blockQuote`,tokenize:PZe};function PZe(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 L7(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function FZe(e,t,n){let r=this;return i;function i(t){return L7(t)?B7(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(NZe,t,n)(r)}}function IZe(e){e.exit(`blockQuote`)}var LZe={name:`characterEscape`,tokenize:RZe};function RZe(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 _Ze(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var zZe={name:`characterReference`,tokenize:BZe};function BZe(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=M7,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=gZe,u):(e.enter(`characterReferenceValue`),a=7,o=P7,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===M7&&!D7(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 VZe={partial:!0,tokenize:WZe},HZe={concrete:!0,name:`codeFenced`,tokenize:UZe};function UZe(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`),L7(t)?B7(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||F7(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(VZe,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||F7(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):L7(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),B7(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||F7(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||F7(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&&L7(t)?B7(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||F7(t)?e.check(VZe,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||F7(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`),L7(t)?B7(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`),L7(t)?B7(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||F7(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function WZe(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 W7={name:`codeIndented`,tokenize:KZe},GZe={partial:!0,tokenize:qZe};function KZe(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),B7(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):F7(t)?e.attempt(GZe,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||F7(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function qZe(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):F7(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):B7(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):F7(e)?i(e):n(e)}}var JZe={name:`codeText`,previous:XZe,resolve:YZe,tokenize:ZZe};function YZe(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 XZe(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function ZZe(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)):F7(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||F7(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 QZe=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&&G7(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),G7(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),G7(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);G7(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);G7(this.left,t.reverse())}}}};function G7(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 $Ze(e){let t={},n=-1,r,i,a,o,s,c,l,u=new QZe(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,eQe(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 O7(e,0,1/0,u.slice(0)),!l}function eQe(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 tQe={resolve:rQe,tokenize:iQe},nQe={partial:!0,tokenize:aQe};function rQe(e){return $Ze(e),e}function iQe(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):F7(t)?e.check(nQe,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 aQe(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),B7(e,a,`linePrefix`)}function a(i){if(i===null||F7(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 oQe(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||N7(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||F7(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||I7(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||N7(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 sQe(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):F7(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||F7(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!L7(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function cQe(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):F7(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),B7(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||F7(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 K7(e,t){let n;return r;function r(i){return F7(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):L7(i)?B7(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var lQe={name:`definition`,tokenize:dQe},uQe={partial:!0,tokenize:fQe};function dQe(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return sQe.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=A7(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 I7(t)?K7(e,l)(t):l(t)}function l(t){return oQe(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(uQe,d,d)(t)}function d(t){return L7(t)?B7(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||F7(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function fQe(e,t,n){return r;function r(t){return I7(t)?K7(e,i)(t):n(t)}function i(t){return cQe(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return L7(t)?B7(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||F7(e)?t(e):n(e)}}var pQe={name:`hardBreakEscape`,tokenize:mQe};function mQe(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return F7(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var hQe={name:`headingAtx`,resolve:gQe,tokenize:_Qe};function gQe(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`},O7(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function _Qe(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||I7(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||F7(n)?(e.exit(`atxHeading`),t(n)):L7(n)?B7(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||I7(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var vQe=`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(`.`),yQe=[`pre`,`script`,`style`,`textarea`],bQe={concrete:!0,name:`htmlFlow`,resolveTo:CQe,tokenize:wQe},xQe={partial:!0,tokenize:EQe},SQe={partial:!0,tokenize:TQe};function CQe(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 wQe(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):j7(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):j7(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 j7(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||I7(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&yQe.includes(l)?(i=1,r.interrupt?t(s):O(s)):vQe.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||M7(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 L7(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||j7(t)?(e.consume(t),b):L7(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||M7(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):L7(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):L7(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||F7(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||I7(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||L7(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||F7(t)?O(t):L7(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),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):F7(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(xQe,R,k)(t)):t===null||F7(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(SQe,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||F7(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 yQe.includes(n)?(e.consume(t),L):O(t)}return j7(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),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||F7(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function TQe(e,t,n){let r=this;return i;function i(t){return F7(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 EQe(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(U7,t,n)}}var DQe={name:`htmlText`,tokenize:OQe};function OQe(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):j7(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):j7(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):F7(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):F7(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):F7(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):F7(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return j7(t)?(e.consume(t),S):n(t)}function S(t){return t===45||M7(t)?(e.consume(t),S):C(t)}function C(t){return F7(t)?(o=C,N(t)):L7(t)?(e.consume(t),C):M(t)}function w(t){return t===45||M7(t)?(e.consume(t),w):t===47||t===62||I7(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||j7(t)?(e.consume(t),E):F7(t)?(o=T,N(t)):L7(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||M7(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):F7(t)?(o=D,N(t)):L7(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):F7(t)?(o=O,N(t)):L7(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):F7(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||I7(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||I7(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 L7(t)?B7(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 q7={name:`labelEnd`,resolveAll:MQe,resolveTo:NQe,tokenize:PQe},kQe={tokenize:FQe},AQe={tokenize:IQe},jQe={tokenize:LQe};function MQe(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&&O7(e,0,e.length,n),e}function NQe(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=k7(s,e.slice(a+1,a+r+3)),s=k7(s,[[`enter`,u,t]]),s=k7(s,V7(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=k7(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=k7(s,e.slice(o+1)),s=k7(s,[[`exit`,c,t]]),O7(e,a,e.length,s),e}function PQe(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(A7(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(kQe,u,o?u:d)(t):t===91?e.attempt(AQe,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(jQe,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function FQe(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 I7(t)?K7(e,a)(t):a(t)}function a(t){return t===41?u(t):oQe(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return I7(t)?K7(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?cQe(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return I7(t)?K7(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 IQe(e,t,n){let r=this;return i;function i(t){return sQe.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(A7(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function LQe(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 RQe={name:`labelStartImage`,resolveAll:q7.resolveAll,tokenize:zQe};function zQe(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 BQe={name:`labelStartLink`,resolveAll:q7.resolveAll,tokenize:VQe};function VQe(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 J7={name:`lineEnding`,tokenize:HQe};function HQe(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),B7(e,t,`linePrefix`)}}var Y7={name:`thematicBreak`,tokenize:UQe};function UQe(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||F7(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),L7(t)?B7(e,s,`whitespace`)(t):s(t))}}var X7={continuation:{tokenize:qQe},exit:YQe,name:`list`,tokenize:KQe},WQe={partial:!0,tokenize:XQe},GQe={partial:!0,tokenize:JQe};function KQe(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:P7(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(Y7,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 P7(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(U7,r.interrupt?n:u,e.attempt(WQe,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return L7(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 qQe(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(U7,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B7(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!L7(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(GQe,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,B7(e,e.attempt(X7,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function JQe(e,t,n){let r=this;return B7(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 YQe(e){e.exit(this.containerState.type)}function XQe(e,t,n){let r=this;return B7(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!L7(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var ZQe={name:`setextUnderline`,resolveTo:QQe,tokenize:$Qe};function QQe(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 $Qe(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`),L7(t)?B7(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||F7(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var e$e={tokenize:t$e};function t$e(e){let t=this,n=e.attempt(U7,r,e.attempt(this.parser.constructs.flowInitial,i,B7(e,e.attempt(this.parser.constructs.flow,i,e.attempt(tQe,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 n$e={resolveAll:o$e()},r$e=a$e(`string`),i$e=a$e(`text`);function a$e(e){return{resolveAll:o$e(e===`text`?s$e: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 o$e(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 s$e(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 c$e=c({attentionMarkers:()=>g$e,contentInitial:()=>u$e,disable:()=>_$e,document:()=>l$e,flow:()=>f$e,flowInitial:()=>d$e,insideSpan:()=>h$e,string:()=>p$e,text:()=>m$e}),l$e={42:X7,43:X7,45:X7,48:X7,49:X7,50:X7,51:X7,52:X7,53:X7,54:X7,55:X7,56:X7,57:X7,62:NZe},u$e={91:lQe},d$e={[-2]:W7,[-1]:W7,32:W7},f$e={35:hQe,42:Y7,45:[ZQe,Y7],60:bQe,61:ZQe,95:Y7,96:HZe,126:HZe},p$e={38:zZe,92:LZe},m$e={[-5]:J7,[-4]:J7,[-3]:J7,33:RQe,38:zZe,42:H7,60:[AZe,DQe],91:BQe,92:[pQe,LZe],93:q7,95:H7,96:JZe},h$e={null:[H7,n$e]},g$e={null:[42,95]},_$e={null:[]};function v$e(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=k7(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=V7(a,l.events,l),l.events):[]}function f(e,t){return b$e(p(e),t)}function p(e){return y$e(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){F7(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&&O7(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 y$e(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 b$e(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=`
|
|
241
|
+
- Reply with the commit message only. No preamble, no quoting of these instructions.`;function jJe(e){let{sendWsMessage:t,subscribeToWsMessages:n,isWsConnected:r}=zS(),[i,a]=(0,b.useState)({status:e===null?`off`:`idle`}),o=(0,b.useRef)(null),s=(0,b.useRef)(null),c=(0,b.useRef)(!1),l=(0,b.useRef)(``);(0,b.useEffect)(()=>{a(t=>e===null?t.status===`off`?t:{status:`off`}:t.status===`off`?{status:`idle`}:t)},[e]),(0,b.useEffect)(()=>n(e=>{if(!(!(`id`in e)||e.id!==o.current)){if(e.type===`ai_streaming`){l.current+=e.chunk;return}if(e.type===`ai_response`){let t=(e.response||l.current).trim();a(t?{status:`ready`,text:t,sessionId:s.current}:{status:`failed`,message:`The AI returned an empty summary.`}),o.current=null;return}if(e.type===`ai_error`){a({status:`failed`,message:e.message,canSetUp:e.code===`provider_not_configured`||e.code===`byok_invalid_key`}),o.current=null;return}e.type===`ai_cancelled`&&(a({status:`idle`}),o.current=null)}}),[n]);let u=(0,b.useCallback)(()=>{let e=o.current;o.current=null,e!==null&&t({type:`ai_cancel`,id:e})},[t]);return(0,b.useEffect)(()=>()=>{u(),c.current=!1},[u]),{state:i,start:(0,b.useCallback)(n=>{if(c.current||e===null||!r)return;c.current=!0;let i=crypto.randomUUID(),u=crypto.randomUUID();o.current=i,s.current=u,l.current=``,a({status:`loading`}),t({type:`ai_prompt`,id:i,sessionId:u,hidden:!0,message:n,maxIterations:1,agents:[{id:`commit-summary`,model:e,systemPrompt:AJe,tools:[]}]})||(o.current=null,a({status:`failed`,message:`Could not reach the AI service.`}))},[r,e,t]),cancel:u,reveal:(0,b.useCallback)(async()=>{let e=s.current;if(e===null)return null;let r=crypto.randomUUID();return new Promise(i=>{let a=setTimeout(()=>{o(),i(null)},1e4),o=n(e=>{!(`id`in e)||e.id!==r||(clearTimeout(a),o(),i(e.type===`ai_session_unhidden`?e.sessionId:null))});t({type:`ai_unhide_session`,id:r,sessionId:e})||(clearTimeout(a),o(),i(null))})},[t,n])}}var z8=Symbol(`unknown`);function B8(e){if(e.status===`ready`)return e.data;if(e.status!==`absent`)return z8}var MJe=10;function NJe({onPublish:e,onClose:t}){let{summary:n,setSummary:r,publishDisabled:i,isPublishing:a,aiEnabled:o}=eC(),s=US(),c=nb(),l=BS(),u=o?l:null,d=CJe(MJe),{setSessionParam:f}=KC(),{openAIChat:p}=wS(),m=jJe(u),h=(0,b.useMemo)(()=>s.status===`success`?s.data.map(e=>e.moduleFilePath):[],[s]),g=(0,b.useMemo)(()=>TJe(h),[h]),_=`text`in n?n.text:``,v=(0,b.useRef)(!1);(0,b.useEffect)(()=>{v.current||(v.current=!0,_.trim()===``&&r({type:`manual`,text:g}))},[g,_,r]),(0,b.useEffect)(()=>{if(c===null||s.status!==`success`)return;let e=c.system.sourceStore,t=[];for(let n of s.data){let r=H.joinModuleFilePathAndModulePath(n.moduleFilePath,H.patchPathToModulePath(n.patchPath)),i=B8(e.peek(r)),a=B8(e.peekBase(r));i!==z8&&a!==z8&&t.push({sourcePath:r,moduleFilePath:n.moduleFilePath,fieldPath:n.patchPath.join(`.`),schemaType:n.schemaTypes[0],before:a,after:i})}t.length!==0&&m.start(kJe(t))},[m.start,s,c]);let[y,x]=(0,b.useState)(!1),S=(0,b.useRef)(!1);(0,b.useEffect)(()=>{S.current||m.state.status!==`ready`||(S.current=!0,I8({hasEdited:y,currentValue:_,defaultSummary:g})&&r({type:`ai`,text:m.state.text}))},[m.state,y,_,g,r]);let{isWaiting:C,skip:w}=d;(0,b.useEffect)(()=>{C&&(m.state.status===`ready`||m.state.status===`failed`)&&w()},[m.state.status,C,w]);let T=()=>{m.cancel(),e?.()};return(0,Y.jsx)(xJe,{value:_,onChange:e=>{x(!0),r({type:`manual`,text:e})},ai:m.state,onUseAiSummary:()=>{m.state.status===`ready`&&r({type:`ai`,text:m.state.text})},onOpenAiSession:m.state.status===`ready`&&m.state.sessionId!==null?()=>{m.reveal().then(e=>{e!==null&&(f(e,{replace:!0}),t(),p())})}:void 0,onPublish:()=>{if(d.isWaiting){d.skip();return}if(m.state.status===`loading`&&I8({hasEdited:y,currentValue:_,defaultSummary:g})){d.start(T);return}T()},onClose:()=>{d.cancel(),m.cancel(),t()},publishDisabled:i,isPublishing:a,waitingForAiSeconds:d.remaining})}var PJe=`h-auto w-auto p-2`;function FJe({kind:e,saving:t}){return(0,Y.jsx)(`span`,{className:`grid size-4 shrink-0 place-items-center`,children:e===`blocked`?(0,Y.jsx)(Ly,{size:16}):e===`in-flight`?(0,Y.jsx)(Gv,{size:16,className:`animate-pulse`}):t?(0,Y.jsx)(jy,{size:16}):(0,Y.jsx)(ky,{size:16})})}function V8({compact:e}){let[t,n]=(0,b.useState)(!1),{publish:r,publishDisabled:i,isPublishing:a,summary:o}=eC(),s=Fb(),c=Object.keys(s??{}),{patchErrors:l}=oC(),u=Object.values(l||{}).reduce((e,t)=>e+Object.keys(t||{}).length,0),d=qS(),f=GS(),p=(0,b.useMemo)(()=>d.filter(e=>!f.has(e)),[d,f]),m=JS(),h=KS(),g=QS(),_=eb(),{autoPublish:v}=aC(),{navigate:y}=GC(),x=bJe({mode:g===`fs`?`fs`:g===null?`unknown`:`http`,validationErrorCount:c.length,conflictingChangeCount:u,isPublishing:a,publishDisabled:i,autoPublish:v,pendingServerSidePatchCount:p.length,pendingClientSidePatchCount:m.length,netChangesEmpty:!h}),S=g===`fs`,C=e?PJe:`flex h-8 min-w-[6.5rem] items-center justify-center gap-2 px-3 text-xs font-medium`,w=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(FJe,{kind:x.kind,saving:S}),!e&&(0,Y.jsx)(`span`,{children:x.label})]}),T=x.reason??x.description;if(x.kind===`blocked`){let t=(0,Y.jsx)(t_,{className:C,variant:x.action===`show-errors`?`destructive`:`default`,disabled:x.action===`none`,"aria-label":e?x.description:void 0,onClick:()=>{x.action===`show-errors`&&y(LC,{errorFields:c})},children:w});return(0,Y.jsx)(H8,{label:x.description,description:T,disabled:x.action===`none`,container:_,children:t})}if(S||x.kind!==`ready`){let t=(0,Y.jsx)(t_,{className:C,disabled:x.action===`none`,"aria-label":e?x.description:void 0,onClick:()=>{x.action===`save`&&r(`No summary provided`)},children:w});return(0,Y.jsx)(H8,{label:x.description,description:T,disabled:x.action===`none`,container:_,children:t})}let E=(0,Y.jsx)(t_,{className:C,"aria-label":e?x.description:void 0,onClick:()=>{n(!0)},children:w});return(0,Y.jsx)(`span`,{className:`inline-flex`,children:(0,Y.jsxs)(SD,{open:t,onOpenChange:e=>{n(e)},children:[e?(0,Y.jsx)(H8,{label:x.description,description:T,disabled:!1,container:_,children:(0,Y.jsx)(CD,{asChild:!0,children:E})}):(0,Y.jsx)(CD,{asChild:!0,children:E}),(0,Y.jsxs)(wD,{container:_,align:`end`,className:`z-[9001] flex flex-col gap-4`,children:[(0,Y.jsx)(yD,{asChild:!0,className:`self-end cursor-pointer`,children:(0,Y.jsx)(Hy,{size:12})}),(0,Y.jsx)(NJe,{onClose:()=>{n(!1)},onPublish:()=>{if(n(!1),o.type===`not-asked`)return;let e=o.text.trim();r(e)}})]})]})})}function H8({label:e,description:t,disabled:n,container:r,children:i}){return(0,Y.jsxs)(Jg,{children:[(0,Y.jsx)(Yg,{asChild:!0,children:n?(0,Y.jsx)(`span`,{className:`inline-flex`,role:`button`,tabIndex:0,"aria-disabled":`true`,"aria-label":e,children:(0,Y.jsx)(`span`,{className:`inline-flex`,"aria-hidden":`true`,children:i})}):i}),(0,Y.jsx)(Xg,{container:r,children:(0,Y.jsx)(`p`,{children:t})})]})}var IJe=`font-mono text-sm px-2 py-0.5 rounded bg-bg-secondary text-fg-primary truncate transition-colors min-w-0 block hover:bg-bg-tertiary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`;function U8({sourcePath:e,previewSegment:t,className:n,children:r}){let i=wb(),a=ob(e,Eb(),i.status===`success`?i.data:void 0)??e,o=O8(a,{scrollToPath:a===e?void 0:e}),s=(0,Y.jsx)(`a`,{...o,title:e,className:X(IJe,n),children:r});if(t===void 0)return s;let c=Jf(`/api/val/enable`,{redirect_to:(typeof window<`u`?window.location.origin:``)+t});return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 truncate min-w-0 max-w-full`,children:[s,(0,Y.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 text-fg-tertiary hover:text-fg-primary transition-colors`,title:`Preview ${t}`,children:(0,Y.jsx)(ry,{size:12})})]})}function LJe({errorFields:e,allErrors:t}){let n=(0,b.useMemo)(()=>UJe(e),[e]),r=e.length,i=n.length,a=r>0&&e.every(e=>!t?.[e]||t[e].length===0),o=e.filter(e=>t?.[e]&&t[e].length>0).length;return e.length===0?(0,Y.jsx)(`div`,{className:`mx-auto max-w-3xl py-12 text-center text-sm text-fg-secondary`,children:`No errors selected.`}):(0,Y.jsxs)(`div`,{className:`mx-auto max-w-3xl flex flex-col gap-4 py-6`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Ly,{size:18,className:`text-fg-warning-primary-alt`,"aria-hidden":!0}),(0,Y.jsx)(`h1`,{className:`text-lg font-medium text-fg-primary`,children:`Validation errors`}),a?(0,Y.jsx)(W8,{tone:`success`,children:`All fixed`}):(0,Y.jsxs)(W8,{tone:`warning`,children:[r,` `,r===1?`field`:`fields`,i>1?(0,Y.jsxs)(Y.Fragment,{children:[` across `,i,` modules`]}):null]})]}),a&&(0,Y.jsx)(HJe,{total:r}),!a&&o<r&&r>1&&(0,Y.jsxs)(`div`,{className:`text-sm text-fg-secondary`,children:[o,` of `,r,` still need attention.`]}),(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:n.map(({moduleFilePath:e,paths:n})=>(0,Y.jsx)(zJe,{moduleFilePath:e,paths:n,allErrors:t},e))})]})}function RJe(){let{errorFields:e}=GC(),t=Fb();return(0,Y.jsx)(LJe,{errorFields:e,allErrors:t})}function zJe({moduleFilePath:e,paths:t,allErrors:n}){let r=(0,b.useMemo)(()=>H.splitModuleFilePath(e),[e]),i=O8(e),a=t.filter(e=>n?.[e]&&n[e].length>0).length;return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-border-primary bg-bg-primary`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border-primary bg-bg-secondary px-4 py-2`,children:[(0,Y.jsx)(Kie,{size:14,className:`text-fg-secondary-alt shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`a`,{...i,title:e,className:`min-w-0 flex flex-wrap items-center gap-1 rounded-sm text-sm text-fg-secondary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:r.map((e,t)=>(0,Y.jsxs)(b.Fragment,{children:[t>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`/`}),(0,Y.jsx)(`span`,{className:(0,AC.default)({"text-fg-tertiary":t<r.length-1,"text-fg-primary":t===r.length-1}),children:kC(e)})]},`m-${t}`))}),(0,Y.jsx)(`div`,{className:`ml-auto`,children:a===0?(0,Y.jsxs)(W8,{tone:`success`,children:[(0,Y.jsx)(Vv,{size:11,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Fixed`})]}):(0,Y.jsxs)(W8,{tone:`warning`,children:[a,` `,a===1?`issue`:`issues`]})})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:t.map((e,r)=>(0,Y.jsx)(BJe,{sourcePath:e,errors:n?.[e],isLast:r===t.length-1},e))})]})}function BJe({sourcePath:e,errors:t,isLast:n}){let r=Cb(e),i=!!t&&t.length>0;return(0,Y.jsxs)(`li`,{className:(0,AC.default)(`flex flex-col gap-3 px-4 py-3`,{"border-b border-border-secondary":!n}),children:[(0,Y.jsx)(VJe,{sourcePath:e}),r.status===`success`?(0,Y.jsx)(Lhe,{children:(0,Y.jsx)(a6,{path:e,schema:r.data})}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:14,className:`animate-spin`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Loading field…`})]}),i?(0,Y.jsx)(Phe,{validationErrors:t}):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-fg-brand-primary`,children:[(0,Y.jsx)(Vv,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Fixed.`})]})]})}function VJe({sourcePath:e}){let t=wb(),[n,r]=H.splitModuleFilePathAndModulePath(e),i=r?H.splitModulePath(r):[],a=(t.status===`success`?t.data:void 0)?.[n],o=a?.type===`record`&&!!a.router&&i.length===1;return(0,Y.jsx)(U8,{sourcePath:e,previewSegment:o?i[0]:void 0,className:o?void 0:`self-start max-w-full`,children:o?i[0]:r?lD(r):kC(H.splitModuleFilePath(n).pop()??``)})}function W8({children:e,tone:t}){return(0,Y.jsx)(`span`,{className:(0,AC.default)(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium`,{"bg-bg-warning-primary text-fg-warning-primary":t===`warning`,"bg-bg-brand-primary text-fg-brand-primary":t===`success`}),children:e})}function HJe({total:e}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border-primary bg-bg-secondary px-4 py-3 text-sm text-fg-primary`,children:[(0,Y.jsx)(Vv,{size:16,className:`text-fg-secondary`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{children:[`All `,(0,Y.jsx)(`span`,{className:`font-medium`,children:e}),` `,e===1?`error is`:`errors are`,` fixed. Ready to publish.`]})]})}function UJe(e){let t=new Map;for(let n of e){let[e]=H.splitModuleFilePathAndModulePath(n),r=t.get(e);r?r.push(n):t.set(e,[n])}let n=Array.from(t.entries()).map(([e,t])=>({moduleFilePath:e,paths:t.slice().sort(WJe)}));return n.sort((e,t)=>e.moduleFilePath.localeCompare(t.moduleFilePath)),n}function WJe(e,t){let[,n]=H.splitModuleFilePathAndModulePath(e),[,r]=H.splitModuleFilePathAndModulePath(t),i=n?H.splitModulePath(n):[],a=r?H.splitModulePath(r):[],o=Math.min(i.length,a.length);for(let e=0;e<o;e++)if(i[e]!==a[e])return i[e].localeCompare(a[e]);return i.length-a.length}function GJe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function KJe(e){let t=e.patchPath,n=!1,r=!1,i=!1;for(let a of e.patches)GJe(a.patchPath,t)&&(a.opType===`add`&&(n=!0),a.opType===`remove`&&(r=!0),a.opType===`move`&&(i=!0));return n&&r?null:i&&r?`removed`:n?`added`:i?`moved`:r?`removed`:`field-change`}function qJe(e,t){if(t.length===0)return e;let n=H.patchPathToModulePath(t);return H.joinModuleFilePathAndModulePath(e,n)}function JJe(e,t){let n={};for(let r of t){let t=r.author??`unknown`;n[t]||(n[t]=[]),n[t].push({moduleFilePath:e,patchId:r.patchId,opType:r.opType,createdAt:r.createdAt,authorId:r.author})}return n}function YJe(e,t,n,r,i,a,o,s,c,l){if(n.length===0){e.change={changeType:r,patchIds:i,authors:a,lastUpdatedBy:s,patchesByAuthorIds:c},o>e.lastUpdated&&(e.lastUpdated=o);return}let u=e;for(let e=0;e<n.length;e++){let d=qJe(t,n.slice(0,e+1)),f=e===n.length-1,p=u.children.find(e=>e.sourcePath===d);p||(p={sourcePath:d,lastUpdated:o,isCommitted:l,children:[]},u.children.push(p)),o>p.lastUpdated&&(p.lastUpdated=o),f&&(p.change={changeType:r,patchIds:i,authors:a,lastUpdatedBy:s,patchesByAuthorIds:c}),u=p}}function G8(e){let t=e.lastUpdated;for(let n of e.children){let e=G8(n);e>t&&(t=e)}return e.lastUpdated=t,t}function K8(e){let t=String(e),[,n]=H.splitModuleFilePathAndModulePath(t);if(!n)return t;let r=H.splitModulePath(n);return r[r.length-1]??t}function q8(e){e.children.sort((e,t)=>K8(e.sourcePath).localeCompare(K8(t.sourcePath)));for(let t of e.children)q8(t)}function J8(e,t){let n=[],r=[],i=t[0].createdAt,a=t[0].author;for(let e of t)e.author!==null&&!n.includes(e.author)&&n.push(e.author),r.includes(e.opType)||r.push(e.opType),e.createdAt>i&&(i=e.createdAt,a=e.author);return{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath,patches:t,authors:n,opTypes:r,schemaTypes:e.schemaTypes,lastUpdated:i,lastUpdatedBy:a}}function XJe(e,t){if(t.size===0)return{pending:e,committed:null};let n=[],r=[];for(let i of e.patches)t.has(i.patchId)?r.push(i):n.push(i);return r.length===0?{pending:e,committed:null}:n.length===0?{pending:null,committed:e}:{pending:J8(e,n),committed:J8(e,r)}}function ZJe(e,t){return`${e?`committed`:`pending`}\u0000${t}`}function QJe(e,t=new Set){let n={};for(let r of e){let{pending:e,committed:i}=XJe(r,t);for(let t of[{set:e,isCommitted:!1},{set:i,isCommitted:!0}])t.set!==null&&$Je(n,t.set,t.isCommitted)}let r=Object.values(n);for(let e of r)G8(e),q8(e);return r.sort((e,t)=>e.isCommitted===t.isCommitted?t.lastUpdated.localeCompare(e.lastUpdated):e.isCommitted?1:-1),{trees:r}}function $Je(e,t,n){let r=KJe(t);if(r===null)return;let{moduleFilePath:i}=t,a=ZJe(n,i);e[a]||(e[a]={sourcePath:i,lastUpdated:t.lastUpdated,isCommitted:n,children:[]});let o=e[a],s=t.patches.map(e=>e.patchId),c=t.authors.filter(e=>e!==null),l=JJe(i,t.patches);YJe(o,i,t.patchPath,r,s,c,t.lastUpdated,t.lastUpdatedBy,l,n)}var eYe=typeof window<`u`&&typeof Worker<`u`;function tYe(e,t,n){let r=(0,b.useRef)(null),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(!1),u=(0,b.useRef)(0),d=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!eYe)return;let e=new Worker(new URL(`/api/val/static/assets/patchsets.worker-D9QWxx6e.js`,``+import.meta.url),{type:`module`});return r.current=e,e.onmessage=e=>{let t=e.data;t.id===d.current&&(t.type===`result`?(a(t.trees),s(!1),l(!0)):t.type===`error`&&(console.error(`PatchSets worker error:`,t.error),s(!1),l(!0)))},e.onerror=e=>{console.error(`PatchSets worker failed:`,e.message),s(!1),l(!0)},()=>{e.terminate(),r.current=null}},[]);let f=n?Array.from(n).sort().join(`,`):``,p=(0,b.useMemo)(()=>n===void 0?[]:Array.from(n).sort(),[f]),m=(0,b.useCallback)((e,t)=>{if(!r.current){let{trees:n}=QJe(e,new Set(t));a(n),s(!1),l(!0);return}let n=`ps-${u.current++}`;d.current=n,s(!0);let i={type:`compute`,id:n,patchSets:e,committedPatchIds:t};r.current.postMessage(i)},[]),[h,g]=(0,b.useState)(t);return h!==t&&(g(t),a([]),l(!1),s(!0)),(0,b.useEffect)(()=>{m(e,p)},[e,m,t,p]),{trees:i,isComputing:o,hasComputed:c}}function Y8(e,t){return e===t}function nYe(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let a=n-1;a>=0;a--)for(let n=r-1;n>=0;n--)i[a][n]=Y8(e[a],t[n])?i[a+1][n+1]+1:Math.max(i[a+1][n],i[a][n+1]);let a=[],o=0,s=0;for(;o<n&&s<r;)Y8(e[o],t[s])?(a.push({beforeIndex:o,index:s}),o++,s++):i[o+1][s]>=i[o][s+1]?o++:s++;return a}function rYe(e,t){let n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i++)Y8(e[i],t[i])?n.push({kind:`unchanged`,index:i,beforeIndex:i,value:t[i]}):n.push({kind:`changed`,index:i,beforeIndex:i,before:e[i],after:t[i]});for(let e=r;e<t.length;e++)n.push({kind:`added`,index:e,value:t[e]});for(let t=r;t<e.length;t++)n.push({kind:`removed`,beforeIndex:t,value:e[t]});return{lines:n,positional:!0}}function iYe(e,t){if(e.length>1e3||t.length>1e3)return rYe(e,t);let n=nYe(e,t),r=new Set(n.map(e=>e.beforeIndex)),i=new Set(n.map(e=>e.index)),a=new Map(n.map(e=>[e.index,e.beforeIndex])),o=[];for(let t=0;t<e.length;t++)r.has(t)||o.push(t);let s=new Map,c=new Set;for(let n=0;n<t.length;n++){if(i.has(n))continue;let r=o.find(r=>!c.has(r)&&Y8(e[r],t[n]));r!==void 0&&(c.add(r),s.set(n,r))}let l=[],u=0,d=0,f=(n,r)=>{let i=[],a=[];for(;u<n;)c.has(u)||i.push(u),u++;for(;d<r;){if(s.has(d)){let e=s.get(d);if(e===void 0)throw Error(`unreachable: movedFrom.has without a value`);l.push({kind:`moved`,index:d,beforeIndex:e,value:t[d]})}else a.push(d);d++}let o=Math.min(i.length,a.length);for(let n=0;n<o;n++)l.push({kind:`changed`,index:a[n],beforeIndex:i[n],before:e[i[n]],after:t[a[n]]});for(let e=o;e<a.length;e++)l.push({kind:`added`,index:a[e],value:t[a[e]]});for(let t=o;t<i.length;t++)l.push({kind:`removed`,beforeIndex:i[t],value:e[i[t]]})};for(let e of n){f(e.beforeIndex,e.index);let n=a.get(e.index)??e.beforeIndex;l.push({kind:`unchanged`,index:e.index,beforeIndex:n,value:t[e.index]}),u=e.beforeIndex+1,d=e.index+1}return f(e.length,t.length),{lines:l,positional:!1}}function aYe(e){return e.lines.some(e=>e.kind!==`unchanged`)}function oYe(e){let t={added:0,removed:0,moved:0,changed:0,unchanged:0};for(let n of e.lines)t[n.kind]+=1;return t}function sYe({sourcePath:e}){let t=jb(e),n=Ab(e),r=Z8(t.status===`success`?t.data:void 0),i=Z8(n.status===`success`?n.data:void 0),a=(0,b.useMemo)(()=>r===null||i===null?null:iYe(r,i),[r,i]);if(a===null)return null;if(!aYe(a))return(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:`The list ended up the same as it started.`});let o=oYe(a);return(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(cYe,{counts:o}),a.positional&&(0,Y.jsx)(lYe,{}),(0,Y.jsx)(`ol`,{className:`mt-3 flex flex-col gap-px font-mono text-sm tabular-nums`,children:a.lines.map((e,t)=>(0,Y.jsx)(uYe,{line:e},`${e.kind}-${t}`))})]})}function cYe({counts:e}){let t=[];return e.added>0&&t.push(`${e.added} added`),e.removed>0&&t.push(`${e.removed} removed`),e.moved>0&&t.push(`${e.moved} moved`),e.changed>0&&t.push(`${e.changed} changed`),(0,Y.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[t.join(`, `),e.unchanged>0&&(0,Y.jsxs)(`span`,{className:`text-fg-tertiary`,children:[t.length>0?` · `:``,e.unchanged,` unchanged`]})]})}function lYe(){return(0,Y.jsxs)(`p`,{className:`mt-2 flex items-start gap-1.5 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Ly,{size:12,className:`mt-0.5 shrink-0 text-fg-warning-primary-alt`,"aria-hidden":!0}),`This list is too long to match items by content, so it is compared position by position. A reorder will read as a run of changes.`]})}function uYe({line:e}){let t=`index`in e?e.index:null;return(0,Y.jsxs)(`li`,{className:X(`flex min-w-0 items-baseline gap-2 rounded border-l-[3px] py-1 pl-2 pr-1`,e.kind===`added`&&`border-fg-brand-primary bg-bg-brand-primary/5`,e.kind===`removed`&&`border-fg-error bg-bg-error-secondary/30`,e.kind===`moved`&&`border-fg-warning bg-bg-secondary/40`,e.kind===`changed`&&`border-fg-warning`,e.kind===`unchanged`&&`border-transparent`),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`w-3 shrink-0 select-none text-center`,e.kind===`added`&&`text-fg-brand-primary`,e.kind===`removed`&&`text-fg-error`,e.kind===`moved`&&`text-fg-warning`,e.kind===`changed`&&`text-fg-warning`,e.kind===`unchanged`&&`text-fg-quaternary`),children:dYe(e.kind)}),(0,Y.jsx)(`span`,{className:`w-8 shrink-0 text-right text-xs text-fg-quaternary`,children:t===null?``:t+1}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:(0,Y.jsx)(fYe,{line:e})}),(0,Y.jsx)(pYe,{line:e})]})}function dYe(e){switch(e){case`added`:return`+`;case`removed`:return`−`;case`moved`:return`↕`;case`changed`:return`~`;case`unchanged`:return``}}function fYe({line:e}){return e.kind===`changed`?(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary line-through decoration-fg-error/60`,children:(0,Y.jsx)(X8,{value:e.before})}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`text-fg-quaternary`,children:`→`}),(0,Y.jsx)(`span`,{children:(0,Y.jsx)(X8,{value:e.after})})]}):(0,Y.jsx)(`span`,{className:e.kind===`removed`?`text-fg-tertiary`:void 0,children:(0,Y.jsx)(X8,{value:e.value})})}function X8({value:e}){return e===null?(0,Y.jsx)(`span`,{className:`italic text-fg-tertiary`,children:`null`}):e===``?(0,Y.jsx)(`span`,{className:`italic text-fg-tertiary`,children:`empty`}):typeof e==`boolean`||typeof e==`number`?(0,Y.jsx)(Y.Fragment,{children:String(e)}):(0,Y.jsx)(Y.Fragment,{children:e})}function pYe({line:e}){if(e.kind===`unchanged`)return null;if(e.kind===`moved`){let t=e.index<e.beforeIndex;return(0,Y.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 whitespace-nowrap font-sans text-xs text-fg-warning`,children:[t?(0,Y.jsx)(jv,{size:11,"aria-hidden":!0}):(0,Y.jsx)(kv,{size:11,"aria-hidden":!0}),`moved from `,e.beforeIndex+1]})}let t=e.kind===`added`?`added`:e.kind===`removed`?`removed from ${e.beforeIndex+1}`:`changed`;return(0,Y.jsx)(`span`,{className:X(`ml-auto shrink-0 whitespace-nowrap font-sans text-xs`,e.kind===`added`&&`text-fg-brand-primary`,e.kind===`removed`&&`text-fg-error`,e.kind===`changed`&&`text-fg-warning`),children:t})}function Z8(e){if(!Array.isArray(e))return null;let t=[];for(let n of e)if(n===null||typeof n==`string`||typeof n==`number`||typeof n==`boolean`)t.push(n);else return null;return t}function mYe({patchSets:e,profilesByAuthorIds:t,mode:n=`unknown`,canDiscard:r=!1,reloadKey:i,committedPatchIds:a,deployment:o}){let s=eb(),c=wb(),l=GS(),u=a??l,{trees:d,isComputing:f,hasComputed:p}=tYe(e,i,u),m=(0,b.useMemo)(()=>d.flatMap(D5),[d]),h=gYe(d),g=bce((0,b.useMemo)(()=>d.filter(e=>!e.isCommitted).map(e=>e.sourcePath),[d])),{changing:_,reverted:v,committedTrees:y}=(0,b.useMemo)(()=>{let e=[],t=[],n=[];for(let r of d)r.isCommitted?n.push(r):g.has(r.sourcePath)?t.push(r):e.push(r);return{changing:e,reverted:t,committedTrees:n}},[d,g]),x=(0,b.useMemo)(()=>e5(v.flatMap(D5)),[v]),S=(0,b.useMemo)(()=>{let t=[],n=new Set,r=new Set;for(let i of e)for(let e of i.patches)u.has(e.patchId)||r.has(e.patchId)||(r.add(e.patchId),t.push(e.patchId),e.author!==null&&n.add(e.author));return{ids:t,authorIds:[...n]}},[e,u]);if(!p||f&&d.length===0)return(0,Y.jsx)(n5,{});if(m.length===0)return S.ids.length>0?(0,Y.jsx)(`div`,{className:`mx-auto max-w-7xl min-w-0`,children:(0,Y.jsx)($8,{patchIds:S.ids,authorIds:S.authorIds,profilesByAuthorIds:t,canDiscard:r,portalContainer:s})}):(0,Y.jsx)(`div`,{className:`text-sm text-fg-secondary py-8 text-center`,children:`No pending changes.`});let C=c.status===`success`?c.data:void 0;return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-7xl flex flex-col gap-6 lg:gap-8 min-w-0`,children:[(0,Y.jsx)(_Ye,{authorIds:h.authorIds,pendingAuthorIds:h.pendingAuthorIds,profilesByAuthorIds:t,mode:n,pendingPatchIds:h.pendingPatchIds,deployingCount:h.deployingCount,canDiscard:r,portalContainer:s}),_.length===0&&v.length>0&&(0,Y.jsx)($8,{patchIds:x,authorIds:h.pendingAuthorIds,profilesByAuthorIds:t,canDiscard:r,portalContainer:s}),_.map(e=>(0,Y.jsx)(o5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`pending-${e.sourcePath}`)),v.length>0&&(0,Y.jsx)(hYe,{count:x.length,children:v.map(e=>(0,Y.jsx)(o5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`reverted-${e.sourcePath}`))}),y.length>0&&(o===void 0?(0,Y.jsx)(vYe,{}):(0,Y.jsx)(r5,{deployment:o})),y.map(e=>(0,Y.jsx)(o5,{tree:e,profilesByAuthorIds:t,portalContainer:s,mode:n,schemas:C,canDiscard:r},`committed-${e.sourcePath}`))]})}function Q8(e,t){let n=nC();return(0,b.useMemo)(()=>e.filter(e=>e!==n).map(e=>t?.[e]?.fullName).filter(e=>!!e),[e,t,n])}function $8({patchIds:e,authorIds:t,profilesByAuthorIds:n,canDiscard:r,portalContainer:i}){let{deletePatches:a}=RS(),o=Q8(t,n);return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border-primary bg-bg-secondary px-4 py-3 sm:flex-row sm:items-center`,children:[(0,Y.jsx)(Xv,{size:16,className:`shrink-0 text-fg-secondary`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-fg-primary`,children:e.length===1?`The one pending change has been reverted.`:`Every pending change has been reverted.`}),(0,Y.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`The content matches what is published, so there is nothing to publish.`})]}),r&&e.length>0&&(0,Y.jsx)(E5,{description:i8(e.length,o),title:`Discard ${e.length} ${e.length===1?`change`:`changes`}?`,confirmLabel:`Discard ${e.length}`,onConfirm:()=>a(e),portalContainer:i,ariaLabel:`Discard all ${e.length} reverted ${e.length===1?`change`:`changes`}`,label:`Discard all`})]})}function hYe({count:e,children:t}){let[n,r]=(0,b.useState)(!1);return(0,Y.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,className:`flex items-center gap-2 self-start rounded-md px-1 py-1 text-xs text-fg-secondary hover:text-fg-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:[(0,Y.jsx)(Rv,{size:14,"aria-hidden":!0,className:(0,AC.default)(`transition-transform`,{"rotate-90":n})}),(0,Y.jsx)(Ay,{size:13,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:e===1?`1 reverted change`:`${e} reverted changes`})]}),n&&(0,Y.jsx)(`div`,{className:`flex flex-col gap-6 lg:gap-8`,children:t})]})}function gYe(e){return(0,b.useMemo)(()=>{let t=e.filter(e=>!e.isCommitted).flatMap(D5),n=e.filter(e=>e.isCommitted).flatMap(D5);return{authorIds:t5(e.flatMap(D5)),pendingAuthorIds:t5(t),pendingPatchIds:e5(t),deployingCount:e5(n).length}},[e])}function e5(e){let t=[],n=new Set;for(let r of e)for(let e of r.change?.patchIds??[])n.has(e)||(n.add(e),t.push(e));return t}function t5(e){let t=[],n=new Set;for(let r of e)for(let e of r.change?.authors??[])n.has(e)||(n.add(e),t.push(e));return t}function n5(){return(0,Y.jsxs)(`div`,{className:`mx-auto max-w-7xl flex flex-col gap-8 min-w-[380px]`,"aria-busy":`true`,"aria-live":`polite`,"aria-label":`Loading changes`,children:[(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-secondary`,children:[(0,Y.jsx)(hy,{size:14,className:`animate-spin`,"aria-hidden":!0}),`Building the comparison…`]}),[0,1].map(e=>(0,Y.jsxs)(`section`,{className:`border border-border-primary rounded-lg bg-bg-primary overflow-hidden`,children:[(0,Y.jsxs)(`header`,{className:`flex items-center gap-2 px-5 py-4 border-b border-border-primary`,children:[(0,Y.jsx)(eX,{className:`h-4 w-48`}),(0,Y.jsx)(eX,{className:`ml-auto h-6 w-6 rounded-full`})]}),(0,Y.jsx)(`div`,{className:`divide-y divide-border-primary`,children:[0,1].map(e=>(0,Y.jsxs)(`div`,{className:`px-5 py-4 flex flex-col gap-3`,children:[(0,Y.jsx)(eX,{className:`h-3 w-32`}),(0,Y.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,Y.jsx)(eX,{className:`h-10 w-full`}),(0,Y.jsx)(eX,{className:`h-10 w-full`})]})]},e))})]},e))]})}function _Ye({authorIds:e,pendingAuthorIds:t,profilesByAuthorIds:n,mode:r,pendingPatchIds:i,deployingCount:a,canDiscard:o,portalContainer:s}){let{deletePatches:c}=RS(),l=Q8(t??e,n),u=i.length===0&&a>0,d=u?a:i.length;return(0,Y.jsxs)(`div`,{className:`flex flex-1 min-w-0 flex-col sm:flex-row sm:items-center gap-2 sm:gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xl font-medium leading-none text-fg-primary tabular-nums`,children:d}),(0,Y.jsx)(`span`,{className:`text-sm text-fg-secondary truncate`,children:u?`${d===1?`change`:`changes`} deploying`:`${d===1?`change`:`changes`} to review`}),(0,Y.jsx)(`span`,{className:`ml-auto sm:hidden`,children:(0,Y.jsx)(y5,{authorIds:e,profilesByAuthorIds:n,mode:r})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0 sm:ml-auto border-t border-border-primary pt-2 sm:border-t-0 sm:pt-0`,children:[a>0&&i.length>0&&(0,Y.jsxs)(`span`,{className:`text-xs text-fg-tertiary whitespace-nowrap`,children:[a,` deploying`]}),o&&i.length>0&&(0,Y.jsx)(E5,{description:i8(i.length,l),title:`Discard ${i.length} ${i.length===1?`change`:`changes`}?`,confirmLabel:`Discard ${i.length}`,onConfirm:()=>c(i),portalContainer:s,ariaLabel:`Discard all ${i.length} pending ${i.length===1?`change`:`changes`}`,label:`Discard all`}),o&&i.length===0&&a>0&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-tertiary whitespace-nowrap`,children:[(0,Y.jsx)(gy,{size:12,"aria-hidden":!0}),`Nothing left to discard`]}),(0,Y.jsx)(`span`,{className:`ml-auto hidden sm:inline-flex`,children:(0,Y.jsx)(y5,{authorIds:e,profilesByAuthorIds:n,mode:r})})]})]})}function vYe(){let{deployments:e}=HS(),t=yce(),n=(0,b.useMemo)(()=>{for(let n of t){let t=e.find(e=>e.commitSha===n);if(t)return t}return null},[e,t]);return(0,Y.jsx)(r5,{deployment:n,commitShas:t})}function r5({deployment:e,commitShas:t=[]}){let[n]=(0,b.useState)(()=>new Date),r=e?.deploymentState,i=r===`created`||r===`pending`,a=r===`failure`||r===`error`,o=r===`success`,s=a?`Published — deploy failed`:i?`Published & deploying`:o?`Published — live`:`Published`,c=t.length>0?t:e?[e.commitSha]:[],l=c.length>1?`${c.length} commits`:c.length===1?`${c[0].slice(0,7)}${e?` · ${Wk(n,e.updatedAt)}`:``}`:null,u=(0,Y.jsx)(`span`,{className:`hidden sm:block h-px flex-1 bg-border-primary`,role:`separator`,"aria-hidden":!0});return(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-0 sm:gap-4`,children:[(0,Y.jsx)(`span`,{className:`block sm:hidden h-px bg-border-primary`,"aria-hidden":!0}),u,(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex items-start sm:items-center gap-2 min-w-0`,`border rounded-lg px-3 py-2 -mt-px`,`sm:rounded-full sm:py-1.5 sm:mt-0 sm:shrink-0`,{"bg-bg-error-secondary border-border-error-secondary text-fg-error-secondary":a,"bg-bg-warning-primary border-border-warning-primary text-fg-warning-primary":i,"bg-bg-brand-primary border-border-brand-primary text-fg-brand-primary":o,"bg-bg-secondary border-border-primary text-fg-secondary":!a&&!i&&!o}),children:[i?(0,Y.jsx)(hy,{size:14,className:`animate-spin shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):a?(0,Y.jsx)(Bv,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):o?(0,Y.jsx)(Fv,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}):(0,Y.jsx)(gy,{size:14,className:`shrink-0 mt-0.5 sm:mt-0`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`flex flex-col sm:flex-row sm:items-center sm:gap-2 min-w-0 text-xs sm:text-[13px]`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:s}),(0,Y.jsxs)(`span`,{className:`opacity-80`,children:[l&&(0,Y.jsxs)(`span`,{className:`tabular-nums`,children:[l,` — `]}),`these cannot be discarded`]})]})]}),u]})}function i5(e){let t=[],n=new Set;function r(e){for(let r of e.change?.patchIds??[])n.has(r)||(n.add(r),t.push(r));for(let t of e.children)r(t)}return r(e),t}function a5(e){let t=[],n=new Set,r={};function i(e){if(e.change){for(let r of e.change.authors)n.has(r)||(n.add(r),t.push(r));for(let[t,n]of Object.entries(e.change.patchesByAuthorIds)){r[t]||(r[t]=[]);for(let e of n)r[t].push({createdAt:e.createdAt,opType:e.opType})}}for(let t of e.children)i(t)}return i(e),{authorIds:t,patchesByAuthorIds:r}}function o5({tree:e,profilesByAuthorIds:t,portalContainer:n,mode:r,schemas:i,canDiscard:a}){let o=e.sourcePath,s=i?.[o],c=s?.type===`record`&&!!s.router,[l,u]=(0,b.useState)(!1),{deletePatches:d}=RS(),[f]=(0,b.useState)(()=>new Date),p=jb(o),m=Ab(o),h=p.status===`success`&&m.status===`success`&&Mr(p.data,m.data),g=(0,b.useMemo)(()=>i5(e),[e]),{patchesByAuthorIds:_}=(0,b.useMemo)(()=>a5(e),[e]),v=a&&!e.isCommitted,y={moduleFilePath:o,isRouterModule:c,profilesByAuthorIds:t,portalContainer:n,mode:r,canDiscard:v,isCommitted:e.isCommitted};return(0,Y.jsxs)(`section`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`border rounded-lg overflow-hidden`,e.isCommitted?`border-dashed border-border-primary bg-bg-secondary`:`border-border-primary bg-bg-primary`),children:[(0,Y.jsxs)(`header`,{className:(0,AC.default)(`flex items-center gap-2 px-4 lg:px-5 py-4 border-b min-w-0`,e.isCommitted?`border-dashed border-border-primary`:`border-border-primary`),children:[(0,Y.jsx)(SYe,{moduleFilePath:o}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[e.isCommitted&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-fg-tertiary`,title:`Published — this cannot be discarded`,children:[(0,Y.jsx)(gy,{size:12,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`hidden sm:inline`,children:`Deploying`})]}),v&&g.length>0&&(0,Y.jsx)(x5,{isEqual:h,onDiscard:()=>d(g),confirmDescription:`Discard all changes in this module? This cannot be undone.`,unchangedAriaLabel:`Discard all unchanged in this module`,confirmAriaLabel:`Discard all changes in this module`,portalContainer:n}),Object.keys(_).length>0&&(0,Y.jsx)(Whe,{patchesByAuthorIds:_,profilesByAuthorIds:t,now:f,portalContainer:n,mode:r}),(0,Y.jsx)(b5,{isOpen:!l,onToggle:()=>u(e=>!e),openLabel:`Collapse module`,closedLabel:`Expand module`})]})]}),!l&&(0,Y.jsxs)(`div`,{className:`divide-y divide-border-primary`,children:[e.isCommitted&&(0,Y.jsx)(`p`,{className:`px-4 lg:px-5 py-3 text-xs text-fg-tertiary`,children:`Already part of the published content, so there is no before and after to compare. Open a field to see its current value.`}),(0,Y.jsx)(s5,{node:e,rowProps:y})]})]})}function yYe(e){let t=Cb(e);if(t.status===`loading`)return;if(t.status!==`success`||t.data.type!==`array`)return!1;let n=t.data.item.type;return n===`string`||n===`number`||n===`boolean`}function s5({node:e,rowProps:t}){let n=yYe(e.sourcePath);return n===void 0?null:n?(0,Y.jsx)(CYe,{row:e,...t},e.sourcePath):e.change?e.change.changeType===`added`||e.change.changeType===`removed`?(0,Y.jsx)(u5,{row:e,...t},e.sourcePath):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(u5,{row:e,...t},e.sourcePath),e.children.length>0&&(0,Y.jsx)(l5,{parent:e,rowProps:t})]}):e.children.some(e=>c5(e))?(0,Y.jsx)(l5,{parent:e,rowProps:t}):null}function bYe(e){return H.mediaUrl({path:e})}function c5(e){return e.change?!0:e.children.some(c5)}function xYe(e){let t=[],n=[],r={},i=new Set,a=new Set,o=``,s=null;function c(e){let l=e.change;if(l){for(let e of l.patchIds)i.has(e)||(i.add(e),t.push(e));for(let e of l.authors)a.has(e)||(a.add(e),n.push(e));for(let[e,t]of Object.entries(l.patchesByAuthorIds))r[e]||(r[e]=[]),r[e].push(...t);e.lastUpdated>o&&(o=e.lastUpdated,s=l.lastUpdatedBy)}for(let t of e.children)c(t)}return c(e),{...e,children:[],change:{changeType:e.change?.changeType??`field-change`,patchIds:t,authors:n,lastUpdatedBy:s,patchesByAuthorIds:r}}}function l5({parent:e,rowProps:t}){let n=Cb(e.sourcePath),r=n.status===`success`&&n.data.type===`record`?n.data.mediaType:void 0;return r?(0,Y.jsx)(Y.Fragment,{children:e.children.filter(e=>c5(e)).map(e=>(0,Y.jsx)(u5,{row:xYe(e),...t,parentMediaType:r},e.sourcePath))}):(0,Y.jsx)(Y.Fragment,{children:e.children.filter(e=>c5(e)).map(e=>(0,Y.jsx)(s5,{node:e,rowProps:t},e.sourcePath))})}function SYe({moduleFilePath:e}){let t=H.splitModuleFilePath(e),n=O8(e);return(0,Y.jsx)(`h2`,{className:`text-sm font-medium text-fg-primary truncate min-w-0`,children:(0,Y.jsx)(`a`,{...n,title:e,className:`flex items-center gap-1.5 min-w-0 rounded-sm hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus`,children:t.map((e,n)=>(0,Y.jsxs)(b.Fragment,{children:[n>0&&(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,"aria-hidden":!0,children:`/`}),(0,Y.jsx)(`span`,{className:(0,AC.default)({"text-fg-secondary":n<t.length-1}),children:kC(e)})]},`${e}-${n}`))})})}function CYe({row:e,moduleFilePath:t,isRouterModule:n,profilesByAuthorIds:r,portalContainer:i,mode:a,canDiscard:o,isCommitted:s}){let{deletePatches:c}=RS(),[l]=(0,b.useState)(()=>new Date),[u,d]=(0,b.useState)(!0),f=e.sourcePath,p=jb(f),m=Ab(f),h=!s&&p.status===`success`&&m.status===`success`&&Mr(p.data,m.data),g=(0,b.useMemo)(()=>i5(e),[e]),{patchesByAuthorIds:_}=(0,b.useMemo)(()=>a5(e),[e]),[,v]=H.splitModuleFilePathAndModulePath(f),y=v?H.splitModulePath(v):[],x=n&&y.length===1,S=y[y.length-1]??``;return g.length===0?null:(0,Y.jsxs)(`article`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`px-5 py-5`,{"opacity-60":h}),children:[(0,Y.jsx)(d5,{sourcePath:f,changeType:`field-change`,segment:S,modulePath:v,moduleFilePath:t,isRouterPageKey:x,patchesByAuthorIds:_,profilesByAuthorIds:r,portalContainer:i,mode:a,now:l,onDiscard:()=>c(g),isExpanded:u,onToggleExpand:()=>d(e=>!e),isEqual:h,canDiscard:o,hideExpand:s}),u&&!s&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(sYe,{sourcePath:f})})]})}function u5({row:e,moduleFilePath:t,isRouterModule:n,profilesByAuthorIds:r,portalContainer:i,mode:a,canDiscard:o,isCommitted:s,parentMediaType:c}){let{deletePatches:l}=RS(),[u]=(0,b.useState)(()=>new Date),d=e.change,[f,p]=(0,b.useState)(d?.changeType!==`removed`),m=e.sourcePath,h=jb(m),g=Ab(m);if(!d)return null;let _=!s&&d.changeType===`field-change`&&h.status===`success`&&g.status===`success`&&Mr(h.data,g.data),[,v]=H.splitModuleFilePathAndModulePath(m),y=v?H.splitModulePath(v):[],x=n&&y.length===1,S=y[y.length-1]??``,C={};for(let[e,t]of Object.entries(d.patchesByAuthorIds))C[e]=t.map(e=>({createdAt:e.createdAt,opType:e.opType}));return(0,Y.jsxs)(`article`,{"data-val-studio-path":e.sourcePath,className:(0,AC.default)(`px-5 py-5`,{"opacity-60":_,"bg-bg-error-secondary/30":d.changeType===`removed`,"bg-bg-brand-primary/5":d.changeType===`added`}),children:[(0,Y.jsx)(d5,{sourcePath:m,changeType:d.changeType,segment:S,modulePath:v,moduleFilePath:t,isRouterPageKey:x,patchesByAuthorIds:C,profilesByAuthorIds:r,portalContainer:i,mode:a,now:u,onDiscard:()=>l(d.patchIds),isExpanded:f,onToggleExpand:()=>p(e=>!e),isEqual:_,canDiscard:o,hideExpand:s,parentMediaType:c}),!s&&(0,Y.jsx)(`div`,{className:`mt-4`,children:(0,Y.jsx)(DYe,{sourcePath:m,changeType:d.changeType,isExpanded:f,isEqual:_,parentMediaType:c})})]})}function d5({sourcePath:e,changeType:t,segment:n,modulePath:r,moduleFilePath:i,isRouterPageKey:a,patchesByAuthorIds:o,profilesByAuthorIds:s,portalContainer:c,mode:l,now:u,onDiscard:d,isExpanded:f,onToggleExpand:p,isEqual:m,canDiscard:h,hideExpand:g,parentMediaType:_}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Y.jsx)(EYe,{changeType:t,isEqual:m}),(0,Y.jsx)(wYe,{sourcePath:e,segment:n,modulePath:r,moduleFilePath:i,isRouterPageKey:a,parentMediaType:_}),(0,Y.jsx)(TYe,{changeType:t,isEqual:m}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[h&&(0,Y.jsx)(x5,{isEqual:m,onDiscard:d,confirmDescription:`Discard this change? This cannot be undone.`,unchangedAriaLabel:`Discard unchanged`,confirmAriaLabel:`Discard this change`,portalContainer:c}),(0,Y.jsx)(Whe,{patchesByAuthorIds:o,profilesByAuthorIds:s,now:u,portalContainer:c,mode:l}),!g&&(0,Y.jsx)(b5,{isOpen:f,onToggle:p,openLabel:`Collapse`,closedLabel:`Expand`})]})]})}function wYe({sourcePath:e,segment:t,modulePath:n,moduleFilePath:r,isRouterPageKey:i,parentMediaType:a}){let o=(()=>{if(a){let{filename:e,folder:n}=pS(t);return n===`/`?`/${e}`:`${n}/${e}`}return n?i?t:lD(n):kC(H.splitModuleFilePath(r).pop()??``)})();return(0,Y.jsx)(U8,{sourcePath:e,previewSegment:i&&!a&&n?t:void 0,className:`min-w-0`,children:o})}function TYe({changeType:e,isEqual:t}){return t?(0,Y.jsx)(`span`,{className:`text-sm text-fg-tertiary px-1.5 py-0.5 rounded bg-bg-secondary shrink-0`,children:`Unchanged`}):e===`added`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-brand-primary shrink-0`,children:`Added`}):e===`removed`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-error shrink-0`,children:`Removed`}):e===`moved`?(0,Y.jsx)(`span`,{className:`text-sm text-fg-warning shrink-0`,children:`Moved`}):null}function EYe({changeType:e,isEqual:t}){if(t)return(0,Y.jsx)(Xv,{size:14,className:`shrink-0 text-fg-tertiary`,"aria-label":`Unchanged`});switch(e){case`added`:return(0,Y.jsx)(Oy,{size:14,className:`shrink-0 text-fg-brand-primary`,"aria-label":`Added`});case`removed`:return(0,Y.jsx)(yy,{size:14,className:`shrink-0 text-fg-error`,"aria-label":`Removed`});case`moved`:return(0,Y.jsx)(Av,{size:14,className:`shrink-0 text-fg-warning`,"aria-label":`Moved`});case`field-change`:return(0,Y.jsx)(Dy,{size:14,className:`shrink-0 text-fg-secondary`,"aria-label":`Edited`})}}function DYe({sourcePath:e,changeType:t,isExpanded:n,isEqual:r,parentMediaType:i}){return i?(0,Y.jsx)(kYe,{sourcePath:e,changeType:t,mediaType:i,isExpanded:n,isEqual:r}):t===`field-change`?(0,Y.jsx)(jYe,{sourcePath:e,isExpanded:n,isEqual:r}):n?t===`added`?(0,Y.jsx)(g5,{sourcePath:e,side:`after`,diffStyle:`added`}):t===`removed`?(0,Y.jsx)(AYe,{sourcePath:e}):(0,Y.jsx)(g5,{sourcePath:e,side:`after`,diffStyle:`added`}):null}function f5(e){if(e&&typeof e.hotspot==`object`&&e.hotspot!==null&&`x`in e.hotspot&&`y`in e.hotspot){let t=e.hotspot;if(typeof t.x==`number`&&typeof t.y==`number`)return{x:t.x,y:t.y}}}function p5({metadata:e}){let t=[];return e&&(typeof e.mimeType==`string`&&t.push({label:`mimeType`,value:e.mimeType}),typeof e.width==`number`&&typeof e.height==`number`&&t.push({label:`dimensions`,value:`${e.width} × ${e.height}`})),t.length===0?null:(0,Y.jsx)(`dl`,{className:`mt-4 text-xs text-fg-secondary grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:t.map(e=>(0,Y.jsxs)(b.Fragment,{children:[(0,Y.jsx)(`dt`,{className:`text-fg-tertiary`,children:e.label}),(0,Y.jsx)(`dd`,{className:`truncate`,children:e.value})]},e.label))})}function m5({sourcePath:e,showValidation:t=!1}){let n=H.createValPathOfItem(e,`alt`),r=Cb(n);return r.status===`success`?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`text-sm font-medium mb-1 block`,children:`Alt`}),(0,Y.jsx)(a6,{path:n,schema:r.data,readonly:!0,errorDisplay:t?`compact`:`none`})]}):null}function h5({url:e,filename:t,diffStyle:n,hotspot:r}){return e?(0,Y.jsxs)(`div`,{className:`w-[120px] flex-shrink-0`,children:[(0,Y.jsxs)(`div`,{className:`relative w-[120px] h-[90px]`,children:[(0,Y.jsx)(`img`,{src:e,alt:t,draggable:!1,className:(0,AC.default)(`w-full h-full object-cover rounded border border-border-primary`,{"opacity-40":n===`removed`}),style:r?{objectPosition:`${r.x*100}% ${r.y*100}%`}:void 0}),r&&(0,Y.jsx)(sA,{hotspot:r,size:`sm`})]}),r&&(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`hotspot `,Math.round(r.x*100),`%, `,Math.round(r.y*100),`%`]})]}):(0,Y.jsxs)(`div`,{className:`w-[120px] flex-shrink-0`,children:[(0,Y.jsx)(`div`,{className:`w-[120px] h-[90px] rounded bg-bg-secondary flex items-center justify-center text-fg-disabled text-xs`,children:`No preview`}),r&&(0,Y.jsxs)(`div`,{className:`mt-1 text-xs text-fg-tertiary`,children:[`hotspot `,Math.round(r.x*100),`%,`,` `,Math.round(r.y*100),`%`]})]})}function OYe(e){return(0,b.useMemo)(()=>{let[,t]=H.splitModuleFilePathAndModulePath(e),n=t?H.splitModulePath(t):[];return n[n.length-1]??``},[e])}function kYe({sourcePath:e,changeType:t,mediaType:n,isExpanded:r,isEqual:i}){let a=OYe(e),o=Mb(),s=n===`images`,c=Ab(e),l=jb(e),u=c.status===`success`?c.data:null,d=l.status===`success`?l.data:null,f=f5(u),p=f5(d),m=s?rA(a,o):null,h=Dse(a);if(!r&&t!==`field-change`)return null;if(i&&t===`field-change`)return(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(`div`,{className:`border-l-[3px] border-border-secondary pl-3 pr-1 py-2 min-w-0`,children:(0,Y.jsx)(T5,{isImage:s,url:m,filename:h,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})});if(t===`added`||t===`moved`)return r?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(v5,{diffStyle:`added`,children:(0,Y.jsx)(T5,{isImage:s,url:m,filename:h,diffStyle:`added`,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})}):null;if(t===`removed`){if(!r)return null;let t=s?bYe(a):null;return(0,Y.jsx)(S5,{sourcePath:e,children:(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(v5,{diffStyle:`removed`,children:(0,Y.jsx)(T5,{isImage:s,url:t,filename:h,diffStyle:`removed`,hotspot:p,metadata:d,sourcePath:e})})})})}if(!r)return null;let g=l.status===`success`;return g&&l.data===null||!g?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(v5,{diffStyle:`added`,children:(0,Y.jsx)(T5,{isImage:s,url:m,filename:h,diffStyle:`added`,hotspot:f,metadata:u,sourcePath:e,showValidation:!0})})}):(0,Y.jsxs)(`div`,{className:`border-l-[3px] border-fg-brand-primary pl-3 py-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[s&&(0,Y.jsx)(h5,{url:m,filename:h,hotspot:f}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(C5,{variant:`media`,before:(0,Y.jsx)(S5,{sourcePath:e,children:(0,Y.jsx)(m5,{sourcePath:e})}),after:(0,Y.jsx)(m5,{sourcePath:e,showValidation:!0})})})]}),(0,Y.jsx)(p5,{metadata:u})]})}function AYe({sourcePath:e}){return(0,Y.jsx)(S5,{sourcePath:e,children:(0,Y.jsx)(g5,{sourcePath:e,side:`after`,diffStyle:`removed`})})}function jYe({sourcePath:e,isExpanded:t,isEqual:n}){let r=roe(e),i=r.status===`success`?r.resolvedPath:e,a=jb(i);if(r.status!==`success`)return null;let o=r.data,s=a.status===`success`,c=s&&a.data===null;return t?n?(0,Y.jsx)(C5,{variant:`equal`,before:(0,Y.jsx)(S5,{sourcePath:e,children:(0,Y.jsx)(a6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}),after:(0,Y.jsx)(a6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`compact`})}):c||!s?(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(v5,{diffStyle:`added`,children:(0,Y.jsx)(a6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})})}):(0,Y.jsx)(C5,{variant:`changed`,before:(0,Y.jsx)(S5,{sourcePath:e,children:(0,Y.jsx)(a6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}),after:(0,Y.jsx)(a6,{path:i,schema:o,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})}):null}function g5({sourcePath:e,side:t,diffStyle:n}){let[r]=(0,b.useMemo)(()=>H.splitModuleFilePathAndModulePath(e),[e]),i=jb(r),a=(0,b.useMemo)(()=>i.status===`success`?{moduleFilePath:r,moduleSource:i.data}:null,[r,i]);return t===`before`?(0,Y.jsx)(lb.Provider,{value:a,children:(0,Y.jsx)(_5,{sourcePath:e,diffStyle:n})}):(0,Y.jsx)(_5,{sourcePath:e,diffStyle:n})}function _5({sourcePath:e,diffStyle:t}){let n=Cb(e);if(n.status!==`success`)return null;let r=n.data;return(0,Y.jsx)(`div`,{className:`max-w-xl`,children:(0,Y.jsx)(v5,{diffStyle:t,children:t===`removed`?(0,Y.jsx)(`div`,{className:`[&_div]:decoration-fg-error [&_pre]:decoration-fg-error line-through decoration-fg-error`,children:(0,Y.jsx)(a6,{path:e,schema:r,readonly:!0,compact:!0,inline:!0,hideUpload:!0,errorDisplay:`none`})}):(0,Y.jsx)(a6,{path:e,schema:r,readonly:!0,compact:!0,inline:!0,errorDisplay:`compact`})})})}function v5({diffStyle:e,children:t}){return(0,Y.jsx)(`div`,{className:(0,AC.default)(`border-l-[3px] pl-3 pr-1 py-2 min-w-0`,{"border-fg-error":e===`removed`,"border-fg-brand-primary":e===`added`}),children:t})}function y5({authorIds:e,profilesByAuthorIds:t,mode:n}){if(e.length===0)return null;let r=e.slice(0,9),i=e.length-r.length;return(0,Y.jsxs)(`div`,{className:`flex items-center`,"aria-label":`Authors`,children:[r.map((e,r)=>(0,Y.jsx)(MYe,{profile:t[e]??null,isFirst:r===0,mode:n},e)),i>0&&(0,Y.jsxs)(`span`,{className:`-ml-2 w-7 h-7 rounded-full inline-flex items-center justify-center text-[11px] font-semibold bg-bg-secondary text-fg-secondary border-2 border-bg-primary`,"aria-label":`${i} more authors`,children:[`+`,i]})]})}function MYe({profile:e,isFirst:t,mode:n}){let r=(0,AC.default)(`shrink-0 w-7 h-7 rounded-full inline-flex items-center justify-center text-[11px] font-semibold overflow-hidden border-2 border-bg-primary`,{"-ml-2":!t});return e?e.avatar?.url?(0,Y.jsx)(`img`,{src:e.avatar.url,alt:e.fullName,title:e.fullName,className:(0,AC.default)(r,`object-cover`)}):(0,Y.jsx)(`span`,{className:(0,AC.default)(r,`bg-bg-brand-primary text-fg-brand-primary`),title:e.fullName,children:zhe(e.fullName)}):(0,Y.jsx)(`span`,{className:(0,AC.default)(r,`bg-bg-secondary text-fg-disabled`),title:n===`fs`?`Local changes`:`Unknown author`,children:n===`fs`?(0,Y.jsx)(jy,{size:12}):(0,Y.jsx)(Vy,{size:12})})}function b5({isOpen:e,onToggle:t,openLabel:n,closedLabel:r}){return(0,Y.jsx)(`button`,{onClick:t,className:(0,AC.default)(`size-5 flex items-center justify-center text-fg-secondary hover:text-fg-primary transition-transform`,{"rotate-180":e}),"aria-label":e?n:r,children:(0,Y.jsx)(Iv,{size:14})})}function x5({isEqual:e,onDiscard:t,confirmDescription:n,unchangedAriaLabel:r,confirmAriaLabel:i,portalContainer:a}){return e?(0,Y.jsx)(t_,{variant:`default`,size:`icon-sm`,onClick:t,"aria-label":r,children:(0,Y.jsx)(zy,{size:14})}):(0,Y.jsx)(E5,{description:n,onConfirm:t,portalContainer:a,ariaLabel:i})}function S5({sourcePath:e,children:t}){let[n]=(0,b.useMemo)(()=>H.splitModuleFilePathAndModulePath(e),[e]),r=jb(n),i=(0,b.useMemo)(()=>r.status===`success`?{moduleFilePath:n,moduleSource:r.data}:null,[n,r]);return(0,Y.jsx)(lb.Provider,{value:i,children:t})}function C5({variant:e,before:t,after:n}){if(e===`media`)return(0,Y.jsxs)(`div`,{className:`grid gap-3 lg:gap-0 lg:grid-cols-[minmax(0,1fr)_24px_minmax(0,1fr)] items-start`,children:[(0,Y.jsxs)(`div`,{className:`pr-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-tertiary mb-1`,children:`Before`}),t]}),(0,Y.jsx)(`div`,{className:`hidden lg:flex items-center justify-center text-fg-tertiary pt-3`,"aria-hidden":!0,children:(0,Y.jsx)(Av,{size:14})}),(0,Y.jsxs)(`div`,{className:`pl-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-fg-tertiary mb-1`,children:`After`}),n]})]});let r=e===`equal`?`border-border-secondary`:`border-fg-brand-primary`,i=e===`equal`?Xv:Av;return(0,Y.jsxs)(`div`,{className:`grid gap-3 lg:gap-0 lg:grid-cols-[minmax(0,1fr)_24px_minmax(0,1fr)] items-stretch`,children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`border-l-[3px] pl-3 pr-12 lg:pr-1 py-2 min-w-0`,r),children:[(0,Y.jsx)(w5,{children:`Before`}),t]}),(0,Y.jsx)(`div`,{className:`hidden lg:flex items-center justify-center text-fg-tertiary`,"aria-hidden":!0,children:(0,Y.jsx)(i,{size:14})}),(0,Y.jsxs)(`div`,{className:`pl-4 lg:pl-1 pr-3 py-2 min-w-0`,children:[(0,Y.jsx)(w5,{children:`After`}),n]})]})}function w5({children:e}){return(0,Y.jsx)(`div`,{className:`lg:hidden text-[10px] uppercase tracking-wider font-medium text-fg-tertiary mb-1`,children:e})}function T5({isImage:e,url:t,filename:n,hotspot:r,diffStyle:i,metadata:a,sourcePath:o,showValidation:s}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[e&&(0,Y.jsx)(h5,{url:t,filename:n,diffStyle:i,hotspot:r}),(0,Y.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Y.jsx)(m5,{sourcePath:o,showValidation:s})})]}),(0,Y.jsx)(p5,{metadata:a})]})}function E5({description:e,title:t,confirmLabel:n,onConfirm:r,portalContainer:i,ariaLabel:a,label:o}){let[s,c]=(0,b.useState)(!1);return(0,Y.jsxs)(SD,{open:s,onOpenChange:c,children:[(0,Y.jsx)(CD,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:o?`sm`:`icon-sm`,"aria-label":a,className:o?`gap-2`:void 0,children:[(0,Y.jsx)(zy,{size:14}),o&&(0,Y.jsx)(`span`,{children:o})]})}),(0,Y.jsxs)(wD,{container:i,className:`w-[calc(100vw-24px)] sm:w-auto sm:max-w-xs p-3`,side:`bottom`,align:`end`,children:[t&&(0,Y.jsxs)(`p`,{className:`flex items-start gap-2 text-sm font-medium text-fg-primary mb-1.5`,children:[(0,Y.jsx)(Bv,{size:15,className:`shrink-0 mt-0.5 text-fg-error-on-surface`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:t})]}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary mb-3`,children:e}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:flex sm:items-center sm:justify-end`,children:[(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>c(!1),children:`Cancel`}),(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{r(),c(!1)},children:n??`Discard`})]})]})]})}function D5(e){let t=[];if(e.change&&t.push(e),!e.change||e.change.changeType!==`added`&&e.change.changeType!==`removed`)for(let n of e.children)for(let e of D5(n))t.push(e);return t}function NYe(){let e=eb();return(0,Y.jsx)(Uy,{open:!0,modal:!0,children:(0,Y.jsxs)(Wy,{children:[(0,Y.jsx)(Gy,{}),(0,Y.jsxs)(Ky,{container:e,"aria-label":`Login required`,className:`bg-bg-secondary text-fg-secondary`,children:[(0,Y.jsx)(qy,{children:(0,Y.jsx)(Yy,{children:(0,Y.jsx)(`span`,{children:`Log in required`})})}),(0,Y.jsx)(Xy,{children:`You need to log in to access Val.`}),(0,Y.jsx)(t_,{asChild:!0,children:(0,Y.jsx)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.origin+Jf(`/val`)}),children:`Log in`})})]})]})})}function O5({code:e}){return(0,Y.jsxs)(`div`,{className:`relative bg-bg-secondary rounded-md p-4 pr-16 my-4`,children:[(0,Y.jsx)(`pre`,{className:`text-xs overflow-x-auto `,children:(0,Y.jsx)(`code`,{children:e})}),(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,className:`absolute top-2 right-2`,onClick:()=>{navigator.clipboard.writeText(e)},children:(0,Y.jsx)(qv,{size:16,className:`mr-2`})})]})}function PYe({moduleFilePath:e,patchPath:t,className:n,toolTip:r=!0,link:i=!0}){let a=bb(),o=(0,b.useRef)(null),s=(0,b.useRef)(new Map),[c,l]=(0,b.useState)([]),[u,d]=(0,b.useState)(),f=Eb(),p=wb(),{navigate:m}=GC();(0,b.useEffect)(()=>{let n=e?H.splitModuleFilePath(e):[],r=t,i=()=>{if(!o.current)return;let t=o.current,i=getComputedStyle(t),a=`${i.fontSize} ${i.fontFamily}`,c=t.offsetWidth,u=n.map(FYe).concat(r).map(e=>`/${e}`);d(u.join(``));let f=e=>{let t=`${e}:${a}`,n=s.current.get(t)??IYe(e,a);return s.current.set(t,n),n},p=`/…`,m=f(p),h=[],g=0;for(let t=u.length-1;t>=0;t--){let i=f(u[t]),a=t!==0;if(g+i+(a?m:0)<=c){let a=t>n.length?`module-path`:`module-file-path`;h.unshift({text:u[t],type:a,moduleFilePath:e,modulePathSegments:r.slice(0,t)}),g+=i}else{h.unshift({type:`ellipsis`,text:p});break}}l(h)},a=new ResizeObserver(i);return o.current&&(a.observe(o.current),i()),()=>{o.current&&a.unobserve(o.current)}},[e,t]);let h=(0,b.useMemo)(()=>{if(!i)return null;let n=`data`in p?p.data:{};if(t.length===0){let t=e;return{navPath:t,sourcePath:t}}let r=rb(t,n[e],f[e]);if(r.success){let i=H.joinModuleFilePathAndModulePath(e,r.modulePath),a=ob(i,f,n);if(a)return{navPath:a,scrollToPath:i};console.debug(`Failed to resolve nav path for ${e} and ${t.join(`.`)}: ${a}`)}else console.debug(`Failed to resolve source path for ${e} and ${t.join(`.`)}: ${r.error}`);return null},[e,t,f,p]);return(0,Y.jsxs)(Jg,{open:r!==!1&&void 0,children:[(0,Y.jsx)(hg,{asChild:!0,children:(0,Y.jsx)(`a`,{href:h&&a?`${a.studioPrefix}${h.navPath}${h.scrollToPath?`#${encodeURIComponent(h.scrollToPath)}`:``}`:void 0,ref:o,className:(0,AC.default)(`inline-block whitespace-nowrap overflow-hidden w-full align-baseline`,{"cursor-pointer hover:underline":i},n),onClick:e=>{i&&h&&e.metaKey===!1&&e.ctrlKey===!1&&e.shiftKey===!1&&(e.preventDefault(),m(h.navPath,{scrollToPath:h.scrollToPath}))},children:c.map((e,t)=>(0,Y.jsx)(`span`,{children:e.text},t))})}),(0,Y.jsx)(Xg,{side:`top`,children:(0,Y.jsx)(eD,{orientation:`horizontal`,className:`max-w-[calc(100vw-3rem)] whitespace-nowrap`,children:u})})]})}function FYe(e){let t=kC(e);return t.slice(0,1).toUpperCase()+t.slice(1)}function IYe(e,t){let n=document.createElement(`canvas`).getContext(`2d`);return n?(n.font=t,n.measureText(e).width):0}function LYe(){let{patchErrors:e}=oC(),{deletePatches:t}=RS(),{navigate:n}=GC(),r=sC(),i=US(),a=eb(),o=QS(),[s,c]=(0,b.useState)(!1),l=(0,b.useMemo)(()=>zYe(e,`data`in i?i.data:void 0),[e,i]),u=(0,b.useMemo)(()=>JSON.stringify({mode:o,changes:l},null,2),[o,l]),d=l.map(e=>e.patchId).join(`|`),[f,p]=(0,b.useState)(d);return f!==d&&(p(d),c(!1)),l.length===0?null:(0,Y.jsx)(Uy,{open:!s,onOpenChange:e=>{c(!e)},children:(0,Y.jsxs)(Ky,{container:a,className:`max-w-2xl`,children:[(0,Y.jsxs)(qy,{children:[(0,Y.jsxs)(Yy,{className:`flex gap-2 items-center`,children:[(0,Y.jsx)(Ly,{size:18}),(0,Y.jsxs)(`span`,{children:[l.length,` change`,l.length===1?``:`s`,` cannot be applied`]})]}),(0,Y.jsx)(Xy,{children:`These changes conflict with newer ones, so they can no longer be applied to the content. Nothing can be published until they are removed. Removing a change discards only that edit.`})]}),(0,Y.jsx)(eD,{className:`max-h-[40vh]`,children:(0,Y.jsx)(`div`,{className:`flex flex-col gap-3`,children:l.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 rounded-md border border-border-primary`,children:[(0,Y.jsx)(`div`,{className:`text-sm`,children:e.patchPath?(0,Y.jsx)(PYe,{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath}):(0,Y.jsx)(`span`,{children:e.moduleFilePath})}),(0,Y.jsx)(`div`,{className:`text-xs text-fg-secondary`,children:[e.author?r[e.author]?.fullName??e.author:null,e.createdAt?Wk(new Date,e.createdAt):null].filter(e=>e!==null).join(` · `)}),(0,Y.jsx)(`div`,{className:`text-xs text-fg-error-primary`,children:e.message}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(t_,{variant:`destructive`,size:`sm`,onClick:()=>{t([e.patchId])},children:(0,Y.jsxs)(`span`,{className:`flex gap-2 items-center`,children:[(0,Y.jsx)(`span`,{children:`Remove change`}),(0,Y.jsx)(zy,{size:14})]})}),(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>{c(!0),n(`/val/compare`,{scrollToPath:RYe(e)})},children:`Review in compare`})]})]},e.patchId))})}),(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{className:`text-xs cursor-pointer text-fg-secondary`,children:`Diagnosis for Val developers`}),(0,Y.jsx)(O5,{code:u})]}),(0,Y.jsx)(Jy,{children:(0,Y.jsxs)(t_,{variant:`destructive`,onClick:()=>{t(l.map(e=>e.patchId))},children:[`Remove all `,l.length,` and continue`]})})]})})}function RYe(e){return!e.patchPath||e.patchPath.length===0?e.moduleFilePath:H.joinModuleFilePathAndModulePath(e.moduleFilePath,H.patchPathToModulePath(e.patchPath))}function zYe(e,t){if(!e)return[];let n=new Map;for(let e of t??[])for(let t of e.patches)n.set(t.patchId,{author:t.author,createdAt:t.createdAt,patchPath:e.patchPath});let r=[];for(let[t,i]of Object.entries(e))if(i)for(let[e,a]of Object.entries(i)){let i=e,o=n.get(i);r.push({patchId:i,moduleFilePath:t,message:a.message,author:o?.author??null,createdAt:o?.createdAt??null,patchPath:o?.patchPath??null})}return r.sort((e,t)=>(e.createdAt??``).localeCompare(t.createdAt??``))}function BYe({value:e}){return console.warn(`Exhaustive check failed for value:`,e),null}function VYe(){let e=Fce();return e===null?null:e.type===`network-error`?(0,Y.jsx)(k5,{children:`Network error - retrying...`}):e.type===`schema-error`?(0,Y.jsx)(k5,{children:`Schema error - check your console for details`}):e.type===`profiles-auth-error`?(0,Y.jsx)(k5,{children:`Could not authenticate with your personal access token while getting profiles.`}):e.type===`remote-files-error`?(0,Y.jsx)(HYe,{error:e}):(0,Y.jsx)(BYe,{value:e})}function k5({children:e}){return(0,Y.jsx)(`div`,{role:`status`,className:`fixed inset-x-0 top-0 z-full p-4 text-center text-fg-error-primary bg-bg-error-primary`,children:e})}function HYe({error:e}){let t=eb();return(0,Y.jsx)(Uy,{defaultOpen:!0,children:(0,Y.jsxs)(Wy,{children:[(0,Y.jsx)(Gy,{}),(0,Y.jsxs)(Ky,{container:t,className:`max-w-lg p-6 rounded-lg bg-bg-primary text-fg-primary`,children:[(0,Y.jsx)(Yy,{className:`text-lg font-medium mb-4`,children:`Personal access token file required`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{children:`This project uses remote files, which means you need to be authenticated to update them.`}),(0,Y.jsx)(`p`,{children:`To do this locally in this dev environment, you need a Personal Access Token (PAT) stored in a file.`}),(0,Y.jsx)(`p`,{children:`Run the command in the root directory of your project to create the token file.`})]}),(0,Y.jsx)(O5,{code:`npx -p @valbuild/cli val login`}),(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(zk,{type:`multiple`,children:[(0,Y.jsxs)(Bk,{value:`why-pat`,children:[(0,Y.jsx)(Vk,{children:`Why a personal token file?`}),(0,Y.jsxs)(Hk,{children:[(0,Y.jsx)(`p`,{children:`You are using remote files, which require authentication. In local development, Val uses a personal access token (PAT) to authenticate and allow you to update remote files.`}),(0,Y.jsx)(`p`,{children:`You can create it by running the command shown above, which will create a PAT file.`}),(0,Y.jsx)(`p`,{children:`If you have the PAT already, check that you have internet access and that the project is setup correctly in https://admin.val.build, as issues with either of those could also cause this error.`})]})]}),(0,Y.jsxs)(Bk,{value:`details`,children:[(0,Y.jsx)(Vk,{children:`More details`}),(0,Y.jsx)(Hk,{children:(0,Y.jsxs)(`p`,{children:[`The underlying error message was: "`,e.error,`".`]})})]})]})})]})]})})}function UYe(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var WYe=e=>{switch(e){case`success`:return qYe;case`info`:return YYe;case`warning`:return JYe;case`error`:return XYe;default:return null}},GYe=Array(12).fill(0),KYe=({visible:e,className:t})=>b.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},b.createElement(`div`,{className:`sonner-spinner`},GYe.map((e,t)=>b.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),qYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),JYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),YYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),XYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`,"aria-hidden":`true`},b.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),ZYe=b.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`},b.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),b.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),QYe=()=>{let[e,t]=b.useState(document.hidden);return b.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e},$Ye=1,eXe=100,A5=e=>typeof e?.id==`number`||e?.id?.length>0?e.id:$Ye++,j5=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),this.getActiveToasts().forEach(t=>e(t)),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e],this.trimHistory()},this.trimHistory=()=>{let e=this.toasts.length-eXe;e<=0||(this.toasts=this.toasts.filter(t=>e>0&&this.dismissedToasts.has(t.id)?(this.dismissedToasts.delete(t.id),e--,!1):!0))},this.create=e=>{let{message:t,...n}=e,r=A5(e),i=this.pendingDismissals.get(r);i!==void 0&&(cancelAnimationFrame(i),this.pendingDismissals.delete(r),this.dismissedToasts.delete(r));let a=this.dismissedToasts.has(r),o=e.dismissible===void 0||e.dismissible;return a&&(this.dismissedToasts.delete(r),this.toasts=this.toasts.filter(e=>e.id!==r)),!a&&this.toasts.find(e=>e.id===r)?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:o,title:t}):n):this.addToast({title:t,...n,dismissible:o,id:r}),r},this.dismiss=e=>{if(e==null)return this.getActiveToasts().forEach(e=>{this.dismissedToasts.add(e.id),this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e;this.dismissedToasts.add(e);let t=this.pendingDismissals.get(e);return t!==void 0&&cancelAnimationFrame(t),this.pendingDismissals.set(e,requestAnimationFrame(()=>{this.pendingDismissals.delete(e),this.subscribers.forEach(t=>t({id:e,dismiss:!0}))})),e},this.message=(e,t)=>this.create({...t,message:e,type:void 0}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],b.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(nXe(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!b.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=A5(t);return this.create({...t,jsx:e(n),id:n,type:void 0}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}},tXe=(e,t)=>j5.message(e,t),nXe=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,rXe=Object.assign(tXe,{success:j5.success,info:j5.info,warning:j5.warning,error:j5.error,custom:j5.custom,message:j5.message,promise:j5.promise,dismiss:j5.dismiss,loading:j5.loading},{getHistory:()=>j5.toasts,getToasts:()=>j5.getActiveToasts()});UYe(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function M5(e){return e.label!==void 0}var iXe=3,aXe=`24px`,oXe=`16px`,N5=4e3,sXe=356,cXe=14,lXe=45,uXe=200;function P5(...e){return e.filter(Boolean).join(` `)}function dXe(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var fXe=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:x,gap:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`}=e,[D,O]=b.useState(null),[k,A]=b.useState(null),[j,M]=b.useState(!1),[N,P]=b.useState(!1),[F,I]=b.useState(!1),[L,R]=b.useState(!1),[ee,te]=b.useState(!1),[ne,re]=b.useState(0),[ie,ae]=b.useState(0),oe=b.useRef(n.duration||y||N5),se=b.useRef(null),ce=b.useRef(null),le=c===0,ue=c+1<=o,de=n.type,fe=de??`default`,pe=n.dismissible!==!1,me=n.className||``,he=n.descriptionClassName||``,ge=b.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),_e=b.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ve=b.useMemo(()=>n.duration||y||N5,[n.duration,y]),ye=b.useRef(0),be=b.useRef(0),xe=b.useRef(0),Se=b.useRef(null),[Ce,we]=x.split(`-`),z=b.useMemo(()=>s.reduce((e,t,n)=>n>=ge?e:e+t.height,0),[s,ge]),B=QYe(),Te=b.useMemo(()=>e.swipeDirections??dXe(x),[e.swipeDirections,x]),Ee=n.invert||t,V=de===`loading`;be.current=b.useMemo(()=>ge*S+z,[ge,z]),b.useEffect(()=>{oe.current=ve},[ve]),b.useEffect(()=>{M(!0)},[]),b.useEffect(()=>{let e=ce.current;if(e){let t=e.getBoundingClientRect().height;return ae(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),b.useLayoutEffect(()=>{if(!j)return;let e=ce.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ae(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[j,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let De=b.useCallback(()=>{P(!0),re(be.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},uXe)},[n,d,a,be]);b.useEffect(()=>{if(n.promise&&de===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||B?(()=>{if(xe.current<ye.current){let e=new Date().getTime()-ye.current;oe.current-=e}xe.current=new Date().getTime()})():oe.current!==1/0&&(ye.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),De()},oe.current)),()=>clearTimeout(e)},[u,i,n,de,B,De]),b.useEffect(()=>{n.delete&&(De(),n.onDismiss==null||n.onDismiss.call(n,n))},[De,n.delete]);function Oe(){return T?.loading?b.createElement(`div`,{className:P5(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":de===`loading`},T.loading):b.createElement(KYe,{className:P5(w?.loader,n?.classNames?.loader),visible:de===`loading`})}let ke=n.icon||T?.[de]||WYe(de);return b.createElement(`li`,{tabIndex:0,ref:ce,className:P5(_,me,w?.toast,n?.classNames?.toast,w?.[fe],n?.classNames?.[fe]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":j,"data-promise":!!n.promise,"data-swiped":ee,"data-removed":N,"data-visible":ue,"data-y-position":Ce,"data-x-position":we,"data-index":c,"data-front":le,"data-swiping":F,"data-dismissible":pe,"data-type":de,"data-invert":Ee,"data-swipe-out":L,"data-swipe-direction":k,"data-expanded":!!(u||C&&j),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?ne:be.current}px`,"--initial-height":C?`auto`:`${ie}px`,...m,...n.style},onDragEnd:()=>{I(!1),O(null),Se.current=null},onPointerDown:e=>{e.button!==2&&(V||!pe||(se.current=new Date,re(be.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(I(!0),Se.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(L||!pe)return;Se.current=null;let e=Number(ce.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(ce.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-se.current?.getTime(),i=D===`x`?e:t,a=Math.abs(i)/r;if((D===`x`?Te.includes(e>0?`right`:`left`):Te.includes(t>0?`bottom`:`top`))&&(Math.abs(i)>=lXe||a>.11)){re(be.current),n.onDismiss==null||n.onDismiss.call(n,n),A(D===`x`?e>0?`right`:`left`:t>0?`down`:`up`),De(),R(!0);return}var o,s;(o=ce.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=ce.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`),te(!1),I(!1),O(null)},onPointerMove:e=>{var t,n;if(!Se.current||!pe||window.getSelection()?.toString().length>0)return;let r=e.clientY-Se.current.y,i=e.clientX-Se.current.x;!D&&(Math.abs(i)>1||Math.abs(r)>1)&&O(Math.abs(i)>Math.abs(r)?`x`:`y`);let a={x:0,y:0},o=e=>1/(1.5+Math.abs(e)/20);if(D===`y`){if(Te.includes(`top`)||Te.includes(`bottom`)){if(Te.includes(`top`)&&r<0||Te.includes(`bottom`)&&r>0)a.y=r;else{let e=r*o(r);a.y=Math.abs(e)<Math.abs(r)?e:r}}}else if(D===`x`&&(Te.includes(`left`)||Te.includes(`right`))){if(Te.includes(`left`)&&i<0||Te.includes(`right`)&&i>0)a.x=i;else{let e=i*o(i);a.x=Math.abs(e)<Math.abs(i)?e:i}}(Math.abs(a.x)>0||Math.abs(a.y)>0)&&te(!0),(t=ce.current)==null||t.style.setProperty(`--swipe-amount-x`,`${a.x}px`),(n=ce.current)==null||n.style.setProperty(`--swipe-amount-y`,`${a.y}px`)}},_e&&!n.jsx&&de!==`loading`?b.createElement(`button`,{"aria-label":E,"data-disabled":V,"data-close-button":!0,onClick:V||!pe?()=>{}:()=>{De(),n.onDismiss==null||n.onDismiss.call(n,n)},className:P5(w?.closeButton,n?.classNames?.closeButton)},T?.close??ZYe):null,(de||n.icon||n.promise)&&n.icon!==null&&(T?.[de]!==null||n.icon)?b.createElement(`div`,{"data-icon":``,className:P5(w?.icon,n?.classNames?.icon)},de===`loading`?n.icon||Oe():n.promise?Oe():null,de===`loading`?null:ke):null,b.createElement(`div`,{"data-content":``,className:P5(w?.content,n?.classNames?.content)},b.createElement(`div`,{"data-title":``,className:P5(w?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?b.createElement(`div`,{"data-description":``,className:P5(v,he,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),b.isValidElement(n.cancel)?n.cancel:n.cancel&&M5(n.cancel)?b.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{M5(n.cancel)&&pe&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),De())},className:P5(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,b.isValidElement(n.action)?n.action:n.action&&M5(n.action)?b.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{M5(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&De())},className:P5(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function F5(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function pXe(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?oXe:aXe;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var mXe=b.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=iXe,toastOptions:g,dir:_=F5(),gap:v=cXe,icons:y,customAriaLabel:x,containerAriaLabel:S=`Notifications`}=e,[C,w]=b.useState([]),T=b.useMemo(()=>n?C.filter(e=>e.toasterId===n):C.filter(e=>!e.toasterId),[C,n]),E=b.useMemo(()=>Array.from(new Set([i].concat(T.filter(e=>e.position).map(e=>e.position)))),[T,i]),[D,O]=b.useState([]),[k,A]=b.useState(!1),[j,M]=b.useState(!1),[N,P]=b.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),F=b.useRef(null),I=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),L=b.useRef(null),R=b.useRef(!1),ee=b.useCallback(e=>{w(t=>(t.find(t=>t.id===e.id)?.delete||j5.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return b.useEffect(()=>j5.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{w(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{lm.flushSync(()=>{w(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[]),b.useEffect(()=>{if(d!==`system`){P(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?P(`dark`):P(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{P(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{P(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),b.useEffect(()=>{C.length<=1&&A(!1)},[C]),b.useEffect(()=>{let e=e=>{if(a.length>0&&a.every(t=>e[t]||e.code===t)){var t;A(!0),(t=F.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===F.current||F.current?.contains(document.activeElement))&&A(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),b.useEffect(()=>{if(F.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,R.current=!1)}},[F.current]),b.createElement(`section`,{ref:t,"aria-label":x??`${S} ${I}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0,"data-react-aria-top-layer":!0},E.map((t,n)=>{let[i,a]=t.split(`-`);return T.length?b.createElement(`ol`,{key:t,dir:_===`auto`?F5():_,tabIndex:-1,ref:F,className:c,"data-sonner-toaster":!0,"data-sonner-theme":N,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${D[0]?.height||0}px`,"--width":`${sXe}px`,"--gap":`${v}px`,...m,...pXe(l,u)},onBlur:e=>{R.current&&!e.currentTarget.contains(e.relatedTarget)&&(R.current=!1,L.current&&=(L.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||R.current||(R.current=!0,L.current=e.relatedTarget)},onMouseEnter:()=>A(!0),onMouseMove:()=>A(!0),onMouseLeave:()=>{j||A(!1)},onDragEnd:()=>A(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||M(!0)},onPointerUp:()=>M(!1)},T.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>b.createElement(fXe,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:j,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ee,toasts:T.filter(e=>e.position==n.position),heights:D.filter(e=>e.position==n.position),setHeights:O,expandByDefault:o,gap:v,expanded:k,swipeDirections:e.swipeDirections}))):null}))});function hXe(e){let{theme:t}=Qy();return(0,Y.jsx)(mXe,{theme:t??`light`,position:`bottom-center`,closeButton:!0,toastOptions:{classNames:{toast:`group rounded-lg border border-border-primary bg-bg-primary text-fg-primary shadow-lg font-serif`,title:`font-bold`,description:`text-fg-secondary`,icon:`text-fg-error-secondary`,closeButton:`bg-bg-primary text-fg-secondary border-border-primary hover:text-fg-primary`}},...e})}var gXe=6e3;function _Xe(){let{globalTransientErrors:e}=Pce(),t=(0,b.useRef)(new Set);return(0,b.useEffect)(()=>{let n=new Set;for(let r of e)n.add(r.id),!t.current.has(r.id)&&rXe.error(r.message,{id:r.id,description:r.details,duration:gXe});t.current=n},[e]),null}function vXe(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var yXe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bXe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xXe={};function I5(e,t){return((t||xXe).jsx?bXe:yXe).test(e)}var SXe=/[ \t\n\f\r]/g;function CXe(e){return typeof e==`object`?e.type===`text`&&L5(e.value):L5(e)}function L5(e){return e.replace(SXe,``)===``}var R5=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};R5.prototype.normal={},R5.prototype.property={},R5.prototype.space=void 0;function z5(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new R5(n,r,t)}function B5(e){return e.toLowerCase()}var V5=class{constructor(e,t){this.attribute=t,this.property=e}};V5.prototype.attribute=``,V5.prototype.booleanish=!1,V5.prototype.boolean=!1,V5.prototype.commaOrSpaceSeparated=!1,V5.prototype.commaSeparated=!1,V5.prototype.defined=!1,V5.prototype.mustUseProperty=!1,V5.prototype.number=!1,V5.prototype.overloadedBoolean=!1,V5.prototype.property=``,V5.prototype.spaceSeparated=!1,V5.prototype.space=void 0;var H5=c({boolean:()=>U5,booleanish:()=>W5,commaOrSpaceSeparated:()=>Y5,commaSeparated:()=>J5,number:()=>K5,overloadedBoolean:()=>G5,spaceSeparated:()=>q5}),wXe=0,U5=X5(),W5=X5(),G5=X5(),K5=X5(),q5=X5(),J5=X5(),Y5=X5();function X5(){return 2**++wXe}var Z5=Object.keys(H5),Q5=class extends V5{constructor(e,t,n,r){let i=-1;if(super(e,t),$5(this,`space`,r),typeof n==`number`)for(;++i<Z5.length;){let e=Z5[i];$5(this,Z5[i],(n&H5[e])===H5[e])}}};Q5.prototype.defined=!0;function $5(e,t,n){n&&(e[t]=n)}function e7(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Q5(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[B5(r)]=r,n[B5(a.attribute)]=r}return new R5(t,n,e.space)}var t7=e7({properties:{ariaActiveDescendant:null,ariaAtomic:W5,ariaAutoComplete:null,ariaBusy:W5,ariaChecked:W5,ariaColCount:K5,ariaColIndex:K5,ariaColSpan:K5,ariaControls:q5,ariaCurrent:null,ariaDescribedBy:q5,ariaDetails:null,ariaDisabled:W5,ariaDropEffect:q5,ariaErrorMessage:null,ariaExpanded:W5,ariaFlowTo:q5,ariaGrabbed:W5,ariaHasPopup:null,ariaHidden:W5,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:q5,ariaLevel:K5,ariaLive:null,ariaModal:W5,ariaMultiLine:W5,ariaMultiSelectable:W5,ariaOrientation:null,ariaOwns:q5,ariaPlaceholder:null,ariaPosInSet:K5,ariaPressed:W5,ariaReadOnly:W5,ariaRelevant:null,ariaRequired:W5,ariaRoleDescription:q5,ariaRowCount:K5,ariaRowIndex:K5,ariaRowSpan:K5,ariaSelected:W5,ariaSetSize:K5,ariaSort:null,ariaValueMax:K5,ariaValueMin:K5,ariaValueNow:K5,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function n7(e,t){return t in e?e[t]:t}function r7(e,t){return n7(e,t.toLowerCase())}var TXe=e7({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:J5,acceptCharset:q5,accessKey:q5,action:null,allow:null,allowFullScreen:U5,allowPaymentRequest:U5,allowUserMedia:U5,alt:null,as:null,async:U5,autoCapitalize:null,autoComplete:q5,autoFocus:U5,autoPlay:U5,blocking:q5,capture:null,charSet:null,checked:U5,cite:null,className:q5,cols:K5,colSpan:null,content:null,contentEditable:W5,controls:U5,controlsList:q5,coords:K5|J5,crossOrigin:null,data:null,dateTime:null,decoding:null,default:U5,defer:U5,dir:null,dirName:null,disabled:U5,download:G5,draggable:W5,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:U5,formTarget:null,headers:q5,height:K5,hidden:G5,high:K5,href:null,hrefLang:null,htmlFor:q5,httpEquiv:q5,id:null,imageSizes:null,imageSrcSet:null,inert:U5,inputMode:null,integrity:null,is:null,isMap:U5,itemId:null,itemProp:q5,itemRef:q5,itemScope:U5,itemType:q5,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:U5,low:K5,manifest:null,max:null,maxLength:K5,media:null,method:null,min:null,minLength:K5,multiple:U5,muted:U5,name:null,nonce:null,noModule:U5,noValidate:U5,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:U5,optimum:K5,pattern:null,ping:q5,placeholder:null,playsInline:U5,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:U5,referrerPolicy:null,rel:q5,required:U5,reversed:U5,rows:K5,rowSpan:K5,sandbox:q5,scope:null,scoped:U5,seamless:U5,selected:U5,shadowRootClonable:U5,shadowRootDelegatesFocus:U5,shadowRootMode:null,shape:null,size:K5,sizes:null,slot:null,span:K5,spellCheck:W5,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K5,step:null,style:null,tabIndex:K5,target:null,title:null,translate:null,type:null,typeMustMatch:U5,useMap:null,value:W5,width:K5,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:q5,axis:null,background:null,bgColor:null,border:K5,borderColor:null,bottomMargin:K5,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:U5,declare:U5,event:null,face:null,frame:null,frameBorder:null,hSpace:K5,leftMargin:K5,link:null,longDesc:null,lowSrc:null,marginHeight:K5,marginWidth:K5,noResize:U5,noHref:U5,noShade:U5,noWrap:U5,object:null,profile:null,prompt:null,rev:null,rightMargin:K5,rules:null,scheme:null,scrolling:W5,standby:null,summary:null,text:null,topMargin:K5,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K5,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:U5,disableRemotePlayback:U5,prefix:null,property:null,results:K5,security:null,unselectable:null},space:`html`,transform:r7}),EXe=e7({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-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:Y5,accentHeight:K5,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K5,amplitude:K5,arabicForm:null,ascent:K5,attributeName:null,attributeType:null,azimuth:K5,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K5,by:null,calcMode:null,capHeight:K5,className:q5,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:K5,diffuseConstant:K5,direction:null,display:null,dur:null,divisor:K5,dominantBaseline:null,download:U5,dx:null,dy:null,edgeMode:null,editable:null,elevation:K5,enableBackground:null,end:null,event:null,exponent:K5,externalResourcesRequired:null,fill:null,fillOpacity:K5,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:J5,g2:J5,glyphName:J5,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K5,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K5,horizOriginX:K5,horizOriginY:K5,id:null,ideographic:K5,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K5,k:K5,k1:K5,k2:K5,k3:K5,k4:K5,kernelMatrix:Y5,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K5,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K5,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:K5,overlineThickness:K5,paintOrder:null,panose1:null,path:null,pathLength:K5,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:q5,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K5,pointsAtY:K5,pointsAtZ:K5,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Y5,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Y5,rev:Y5,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Y5,requiredFeatures:Y5,requiredFonts:Y5,requiredFormats:Y5,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:K5,specularExponent:K5,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K5,strikethroughThickness:K5,string:null,stroke:null,strokeDashArray:Y5,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K5,strokeOpacity:K5,strokeWidth:null,style:null,surfaceScale:K5,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Y5,tabIndex:K5,tableValues:null,target:null,targetX:K5,targetY:K5,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Y5,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K5,underlineThickness:K5,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K5,values:null,vAlphabetic:K5,vMathematical:K5,vectorEffect:null,vHanging:K5,vIdeographic:K5,version:null,vertAdvY:K5,vertOriginX:K5,vertOriginY:K5,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K5,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:n7}),i7=e7({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()}}),a7=e7({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:r7}),o7=e7({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),DXe={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`},OXe=/[A-Z]/g,s7=/-[a-z]/g,kXe=/^data[-\w.:]+$/i;function AXe(e,t){let n=B5(t),r=t,i=V5;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&kXe.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(s7,MXe);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!s7.test(e)){let n=e.replace(OXe,jXe);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Q5}return new i(r,t)}function jXe(e){return`-`+e.toLowerCase()}function MXe(e){return e.charAt(1).toUpperCase()}var NXe=z5([t7,TXe,i7,a7,o7],`html`),c7=z5([t7,EXe,i7,a7,o7],`svg`);function PXe(e){return e.join(` `).trim()}var FXe=s(((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(`
|
|
242
|
+
`);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})),IXe=s((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(FXe());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}})),LXe=s((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))}})),RXe=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(IXe()),r=LXe();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})),l7=d7(`end`),u7=d7(`start`);function d7(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 zXe(e){let t=u7(e),n=l7(e);if(t&&n)return{start:t,end:n}}function f7(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?m7(e.position):`start`in e||`end`in e?m7(e):`line`in e||`column`in e?p7(e):``}function p7(e){return h7(e&&e.line)+`:`+h7(e&&e.column)}function m7(e){return p7(e&&e.start)+`-`+p7(e&&e.end)}function h7(e){return e&&typeof e==`number`?e:1}var g7=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=f7(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}};g7.prototype.file=``,g7.prototype.name=``,g7.prototype.reason=``,g7.prototype.message=``,g7.prototype.stack=``,g7.prototype.column=void 0,g7.prototype.line=void 0,g7.prototype.ancestors=void 0,g7.prototype.cause=void 0,g7.prototype.fatal=void 0,g7.prototype.place=void 0,g7.prototype.ruleId=void 0,g7.prototype.source=void 0;var BXe=u(RXe(),1),_7={}.hasOwnProperty,VXe=new Map,HXe=/[A-Z]/g,UXe=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),WXe=new Set([`td`,`th`]),v7=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function GXe(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=$Xe(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=QXe(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`?c7:NXe,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=y7(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function y7(e,t,n){if(t.type===`element`)return KXe(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return qXe(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return YXe(e,t,n);if(t.type===`mdxjsEsm`)return JXe(e,t);if(t.type===`root`)return XXe(e,t,n);if(t.type===`text`)return ZXe(e,t)}function KXe(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=c7,e.schema=i),e.ancestors.push(t);let a=C7(e,t.tagName,!1),o=eZe(e,t),s=S7(e,t);return UXe.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!CXe(e)})),b7(e,o,a,t),x7(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function qXe(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)}w7(e,t.position)}function JXe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);w7(e,t.position)}function YXe(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=c7,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:C7(e,t.name,!0),o=tZe(e,t),s=S7(e,t);return b7(e,o,a,t),x7(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function XXe(e,t,n){let r={};return x7(r,S7(e,t)),e.create(t,e.Fragment,r,n)}function ZXe(e,t){return t.value}function b7(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function x7(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function QXe(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 $Xe(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=u7(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 eZe(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&_7.call(t.properties,i)){let a=nZe(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&WXe.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 tZe(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 w7(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 w7(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function S7(e,t){let n=[],r=-1,i=e.passKeys?new Map:VXe;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=y7(e,a,o);s!==void 0&&n.push(s)}return n}function nZe(e,t,n){let r=AXe(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?vXe(n):PXe(n)),r.property===`style`){let t=typeof n==`object`?n:rZe(e,String(n));return e.stylePropertyNameCase===`css`&&(t=iZe(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?DXe[r.property]||r.property:r.attribute,n]}}function rZe(e,t){try{return(0,BXe.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new g7("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=v7+`#cannot-parse-style-attribute`,r}}function C7(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=I5(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=I5(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return _7.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);w7(e)}function w7(e,t){let n=new g7("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=v7+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function iZe(e){let t={},n;for(n in e)_7.call(e,n)&&(t[aZe(n)]=e[n]);return t}function aZe(e){let t=e.replace(HXe,oZe);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function oZe(e){return`-`+e.toLowerCase()}var T7={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`]},sZe={};function cZe(e,t){let n=t||sZe;return E7(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function E7(e,t,n){if(lZe(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 D7(e.children,t,n)}return Array.isArray(e)?D7(e,t,n):``}function D7(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=E7(e[i],t,n);return r.join(``)}function lZe(e){return!!(e&&typeof e==`object`)}var uZe=document.createElement(`i`);function O7(e){let t=`&`+e+`;`;uZe.innerHTML=t;let n=uZe.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function k7(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 A7(e,t){return e.length>0?(k7(e,e.length,0,t),e):t}var dZe={}.hasOwnProperty;function fZe(e){let t={},n=-1;for(;++n<e.length;)pZe(t,e[n]);return t}function pZe(e,t){let n;for(n in t){let r=(dZe.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){dZe.call(r,a)||(r[a]=[]);let e=i[a];mZe(r[a],Array.isArray(e)?e:e?[e]:[])}}}function mZe(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);k7(e,0,0,r)}function hZe(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 j7(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var M7=z7(/[A-Za-z]/),N7=z7(/[\dA-Za-z]/),gZe=z7(/[#-'*+\--9=?A-Z^-~]/);function P7(e){return e!==null&&(e<32||e===127)}var F7=z7(/\d/),_Ze=z7(/[\dA-Fa-f]/),vZe=z7(/[!-/:-@[-`{-~]/);function I7(e){return e!==null&&e<-2}function L7(e){return e!==null&&(e<0||e===32)}function R7(e){return e===-2||e===-1||e===32}var yZe=z7(/\p{P}|\p{S}/u),bZe=z7(/\s/);function z7(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function B7(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&N7(e.charCodeAt(n+1))&&N7(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 V7(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return R7(r)?(e.enter(n),s(r)):t(r)}function s(r){return R7(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var xZe={tokenize:SZe};function SZe(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`),V7(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 I7(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var CZe={tokenize:TZe},wZe={tokenize:EZe};function TZe(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 k7(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(wZe,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(wZe,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 I7(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++;k7(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 EZe(e,t,n){return V7(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function DZe(e){if(e===null||L7(e)||bZe(e))return 1;if(yZe(e))return 2}function H7(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 U7={name:`attention`,resolveAll:OZe,tokenize:kZe};function OZe(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};AZe(d,-c),AZe(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=A7(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=A7(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=A7(l,H7(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=A7(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=A7(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,k7(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 kZe(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=DZe(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=DZe(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 AZe(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var jZe={name:`autolink`,tokenize:MZe};function MZe(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 M7(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||N7(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||N7(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||P7(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):gZe(t)?(e.consume(t),l):n(t)}function u(e){return N7(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||N7(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var W7={partial:!0,tokenize:NZe};function NZe(e,t,n){return r;function r(t){return R7(t)?V7(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||I7(e)?t(e):n(e)}}var PZe={continuation:{tokenize:IZe},exit:LZe,name:`blockQuote`,tokenize:FZe};function FZe(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 R7(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function IZe(e,t,n){let r=this;return i;function i(t){return R7(t)?V7(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(PZe,t,n)(r)}}function LZe(e){e.exit(`blockQuote`)}var RZe={name:`characterEscape`,tokenize:zZe};function zZe(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 vZe(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var BZe={name:`characterReference`,tokenize:VZe};function VZe(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=N7,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=_Ze,u):(e.enter(`characterReferenceValue`),a=7,o=F7,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===N7&&!O7(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 HZe={partial:!0,tokenize:GZe},UZe={concrete:!0,name:`codeFenced`,tokenize:WZe};function WZe(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`),R7(t)?V7(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||I7(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(HZe,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||I7(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):R7(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),V7(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||I7(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||I7(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&&R7(t)?V7(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||I7(t)?e.check(HZe,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||I7(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`),R7(t)?V7(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`),R7(t)?V7(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||I7(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function GZe(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 G7={name:`codeIndented`,tokenize:qZe},KZe={partial:!0,tokenize:JZe};function qZe(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),V7(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):I7(t)?e.attempt(KZe,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||I7(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function JZe(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):I7(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):V7(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):I7(e)?i(e):n(e)}}var YZe={name:`codeText`,previous:ZZe,resolve:XZe,tokenize:QZe};function XZe(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 ZZe(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function QZe(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)):I7(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||I7(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 $Ze=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&&K7(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),K7(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),K7(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);K7(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);K7(this.left,t.reverse())}}}};function K7(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 eQe(e){let t={},n=-1,r,i,a,o,s,c,l,u=new $Ze(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,tQe(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 k7(e,0,1/0,u.slice(0)),!l}function tQe(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 nQe={resolve:iQe,tokenize:aQe},rQe={partial:!0,tokenize:oQe};function iQe(e){return eQe(e),e}function aQe(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):I7(t)?e.check(rQe,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 oQe(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),V7(e,a,`linePrefix`)}function a(i){if(i===null||I7(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 sQe(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||P7(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||I7(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||L7(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||P7(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 cQe(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):I7(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||I7(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!R7(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function lQe(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):I7(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),V7(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||I7(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 q7(e,t){let n;return r;function r(i){return I7(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):R7(i)?V7(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var uQe={name:`definition`,tokenize:fQe},dQe={partial:!0,tokenize:pQe};function fQe(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return cQe.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=j7(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 L7(t)?q7(e,l)(t):l(t)}function l(t){return sQe(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(dQe,d,d)(t)}function d(t){return R7(t)?V7(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||I7(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function pQe(e,t,n){return r;function r(t){return L7(t)?q7(e,i)(t):n(t)}function i(t){return lQe(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return R7(t)?V7(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||I7(e)?t(e):n(e)}}var mQe={name:`hardBreakEscape`,tokenize:hQe};function hQe(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return I7(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var gQe={name:`headingAtx`,resolve:_Qe,tokenize:vQe};function _Qe(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`},k7(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function vQe(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||L7(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||I7(n)?(e.exit(`atxHeading`),t(n)):R7(n)?V7(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||L7(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var yQe=`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(`.`),bQe=[`pre`,`script`,`style`,`textarea`],xQe={concrete:!0,name:`htmlFlow`,resolveTo:wQe,tokenize:TQe},SQe={partial:!0,tokenize:DQe},CQe={partial:!0,tokenize:EQe};function wQe(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 TQe(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):M7(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):M7(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 M7(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||L7(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&bQe.includes(l)?(i=1,r.interrupt?t(s):O(s)):yQe.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||N7(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 R7(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||M7(t)?(e.consume(t),b):R7(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||N7(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):R7(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):R7(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||I7(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||L7(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||R7(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||I7(t)?O(t):R7(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),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):I7(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(SQe,R,k)(t)):t===null||I7(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(CQe,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||I7(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 bQe.includes(n)?(e.consume(t),L):O(t)}return M7(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),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||I7(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function EQe(e,t,n){let r=this;return i;function i(t){return I7(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 DQe(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(W7,t,n)}}var OQe={name:`htmlText`,tokenize:kQe};function kQe(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):M7(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):M7(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):I7(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):I7(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):I7(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):I7(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return M7(t)?(e.consume(t),S):n(t)}function S(t){return t===45||N7(t)?(e.consume(t),S):C(t)}function C(t){return I7(t)?(o=C,N(t)):R7(t)?(e.consume(t),C):M(t)}function w(t){return t===45||N7(t)?(e.consume(t),w):t===47||t===62||L7(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||M7(t)?(e.consume(t),E):I7(t)?(o=T,N(t)):R7(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||N7(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):I7(t)?(o=D,N(t)):R7(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):I7(t)?(o=O,N(t)):R7(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):I7(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||L7(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||L7(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 R7(t)?V7(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 J7={name:`labelEnd`,resolveAll:NQe,resolveTo:PQe,tokenize:FQe},AQe={tokenize:IQe},jQe={tokenize:LQe},MQe={tokenize:RQe};function NQe(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&&k7(e,0,e.length,n),e}function PQe(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=A7(s,e.slice(a+1,a+r+3)),s=A7(s,[[`enter`,u,t]]),s=A7(s,H7(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=A7(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=A7(s,e.slice(o+1)),s=A7(s,[[`exit`,c,t]]),k7(e,a,e.length,s),e}function FQe(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(j7(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(AQe,u,o?u:d)(t):t===91?e.attempt(jQe,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(MQe,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function IQe(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 L7(t)?q7(e,a)(t):a(t)}function a(t){return t===41?u(t):sQe(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return L7(t)?q7(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?lQe(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return L7(t)?q7(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 LQe(e,t,n){let r=this;return i;function i(t){return cQe.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(j7(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function RQe(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 zQe={name:`labelStartImage`,resolveAll:J7.resolveAll,tokenize:BQe};function BQe(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 VQe={name:`labelStartLink`,resolveAll:J7.resolveAll,tokenize:HQe};function HQe(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 Y7={name:`lineEnding`,tokenize:UQe};function UQe(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),V7(e,t,`linePrefix`)}}var X7={name:`thematicBreak`,tokenize:WQe};function WQe(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||I7(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),R7(t)?V7(e,s,`whitespace`)(t):s(t))}}var Z7={continuation:{tokenize:JQe},exit:XQe,name:`list`,tokenize:qQe},GQe={partial:!0,tokenize:ZQe},KQe={partial:!0,tokenize:YQe};function qQe(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:F7(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(X7,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 F7(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(W7,r.interrupt?n:u,e.attempt(GQe,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return R7(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 JQe(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(W7,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,V7(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!R7(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(KQe,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,V7(e,e.attempt(Z7,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function YQe(e,t,n){let r=this;return V7(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 XQe(e){e.exit(this.containerState.type)}function ZQe(e,t,n){let r=this;return V7(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!R7(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var QQe={name:`setextUnderline`,resolveTo:$Qe,tokenize:e$e};function $Qe(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 e$e(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`),R7(t)?V7(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||I7(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var t$e={tokenize:n$e};function n$e(e){let t=this,n=e.attempt(W7,r,e.attempt(this.parser.constructs.flowInitial,i,V7(e,e.attempt(this.parser.constructs.flow,i,e.attempt(nQe,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 r$e={resolveAll:s$e()},i$e=o$e(`string`),a$e=o$e(`text`);function o$e(e){return{resolveAll:s$e(e===`text`?c$e: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 s$e(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 c$e(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 l$e=c({attentionMarkers:()=>_$e,contentInitial:()=>d$e,disable:()=>v$e,document:()=>u$e,flow:()=>p$e,flowInitial:()=>f$e,insideSpan:()=>g$e,string:()=>m$e,text:()=>h$e}),u$e={42:Z7,43:Z7,45:Z7,48:Z7,49:Z7,50:Z7,51:Z7,52:Z7,53:Z7,54:Z7,55:Z7,56:Z7,57:Z7,62:PZe},d$e={91:uQe},f$e={[-2]:G7,[-1]:G7,32:G7},p$e={35:gQe,42:X7,45:[QQe,X7],60:xQe,61:QQe,95:X7,96:UZe,126:UZe},m$e={38:BZe,92:RZe},h$e={[-5]:Y7,[-4]:Y7,[-3]:Y7,33:zQe,38:BZe,42:U7,60:[jZe,OQe],91:VQe,92:[mQe,RZe],93:J7,95:U7,96:YZe},g$e={null:[U7,r$e]},_$e={null:[42,95]},v$e={null:[]};function y$e(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=A7(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=H7(a,l.events,l),l.events):[]}function f(e,t){return x$e(p(e),t)}function p(e){return b$e(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){I7(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&&k7(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 b$e(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 x$e(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=`
|
|
243
243
|
`;break;case-3:o=`\r
|
|
244
|
-
`;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 x$e(e){let t={constructs:dZe([c$e,...(e||{}).extensions||[]]),content:n(bZe),defined:[],document:n(SZe),flow:n(e$e),lazy:{},string:n(r$e),text:n(i$e)};return t;function n(e){return n;function n(n){return v$e(t,e,n)}}}function S$e(e){for(;!$Ze(e););return e}var C$e=/[\0\t\n\r]/g;function w$e(){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(C$e.lastIndex=u,c=C$e.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 T$e=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function E$e(e){return e.replace(T$e,D$e)}function D$e(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return mZe(n.slice(t?2:1),t?16:10)}return D7(n)||e}var O$e={}.hasOwnProperty;function k$e(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),A$e(n)(S$e(x$e(n).document().write(w$e()(e,t,!0))))}function A$e(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ge),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(fe),blockQuote:a(se),characterEscape:T,characterReference:T,codeFenced:a(ce),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ce,o),codeText:a(le,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ue),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(de),hardBreakEscape:a(pe),hardBreakTrailing:a(pe),htmlFlow:a(me,o),htmlFlowData:T,htmlText:a(me,o),htmlTextData:T,image:a(he),label:o,link:a(ge),listItem:a(ve),listItemValue:f,listOrdered:a(_e,d),listUnordered:a(_e),paragraph:a(ye),reference:ee,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(fe),strong:a(be),thematicBreak:a(Se)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:oe,autolinkProtocol:ae,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:re,characterReference:ie,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:te,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};j$e(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]];O$e.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]||N$e).call(a,void 0,e[0])}for(r.position={start:Z7(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Z7(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:Z7(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]||N$e).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+u7({start:e.start,end:e.end})+`): it’s not open`);n.position.end=Z7(e.end)}function u(){return cZe(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=A7(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=xe(),n.position={start:Z7(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=Z7(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=Z7(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=E$e(t),n.identifier=A7(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 L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function ee(){this.data.referenceType=`collapsed`}function te(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=A7(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ne(e){this.data.characterReferenceType=e.type}function re(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=mZe(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=D7(t);let i=this.stack[this.stack.length-1];i.value+=r}function ie(e){let t=this.stack.pop();t.position.end=Z7(e.end)}function ae(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function se(){return{type:`blockquote`,children:[]}}function ce(){return{type:`code`,lang:null,meta:null,value:``}}function le(){return{type:`inlineCode`,value:``}}function ue(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function de(){return{type:`emphasis`,children:[]}}function fe(){return{type:`heading`,depth:0,children:[]}}function pe(){return{type:`break`}}function me(){return{type:`html`,value:``}}function he(){return{type:`image`,title:null,url:``,alt:null}}function ge(){return{type:`link`,title:null,url:``,children:[]}}function _e(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ve(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function ye(){return{type:`paragraph`,children:[]}}function be(){return{type:`strong`,children:[]}}function xe(){return{type:`text`,value:``}}function Se(){return{type:`thematicBreak`}}}function Z7(e){return{line:e.line,column:e.column,offset:e.offset}}function j$e(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?j$e(e,r):M$e(e,r)}}function M$e(e,t){let n;for(n in t)if(O$e.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 N$e(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+u7({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+u7({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+u7({start:t.start,end:t.end})+`) is still open`)}function P$e(e){let t=this;t.parser=n;function n(n){return k$e(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function F$e(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 I$e(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
245
|
-
`}]}function
|
|
246
|
-
`:``,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
|
|
244
|
+
`;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 S$e(e){let t={constructs:fZe([l$e,...(e||{}).extensions||[]]),content:n(xZe),defined:[],document:n(CZe),flow:n(t$e),lazy:{},string:n(i$e),text:n(a$e)};return t;function n(e){return n;function n(n){return y$e(t,e,n)}}}function C$e(e){for(;!eQe(e););return e}var w$e=/[\0\t\n\r]/g;function T$e(){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(w$e.lastIndex=u,c=w$e.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 E$e=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function D$e(e){return e.replace(E$e,O$e)}function O$e(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return hZe(n.slice(t?2:1),t?16:10)}return O7(n)||e}var k$e={}.hasOwnProperty;function A$e(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),j$e(n)(C$e(S$e(n).document().write(T$e()(e,t,!0))))}function j$e(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ge),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(fe),blockQuote:a(se),characterEscape:T,characterReference:T,codeFenced:a(ce),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(ce,o),codeText:a(le,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ue),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(de),hardBreakEscape:a(pe),hardBreakTrailing:a(pe),htmlFlow:a(me,o),htmlFlowData:T,htmlText:a(me,o),htmlTextData:T,image:a(he),label:o,link:a(ge),listItem:a(ve),listItemValue:f,listOrdered:a(_e,d),listUnordered:a(_e),paragraph:a(ye),reference:ee,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(fe),strong:a(be),thematicBreak:a(Se)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:oe,autolinkProtocol:ae,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ne,characterReferenceMarkerNumeric:ne,characterReferenceValue:re,characterReference:ie,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:te,resourceDestinationString:I,resourceTitleString:L,resource:R,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};M$e(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]];k$e.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]||P$e).call(a,void 0,e[0])}for(r.position={start:Q7(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Q7(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:Q7(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]||P$e).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+f7({start:e.start,end:e.end})+`): it’s not open`);n.position.end=Q7(e.end)}function u(){return cZe(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=j7(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=xe(),n.position={start:Q7(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=Q7(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=Q7(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=D$e(t),n.identifier=j7(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 L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function R(){this.data.inReference=void 0}function ee(){this.data.referenceType=`collapsed`}function te(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=j7(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ne(e){this.data.characterReferenceType=e.type}function re(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=hZe(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=O7(t);let i=this.stack[this.stack.length-1];i.value+=r}function ie(e){let t=this.stack.pop();t.position.end=Q7(e.end)}function ae(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function se(){return{type:`blockquote`,children:[]}}function ce(){return{type:`code`,lang:null,meta:null,value:``}}function le(){return{type:`inlineCode`,value:``}}function ue(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function de(){return{type:`emphasis`,children:[]}}function fe(){return{type:`heading`,depth:0,children:[]}}function pe(){return{type:`break`}}function me(){return{type:`html`,value:``}}function he(){return{type:`image`,title:null,url:``,alt:null}}function ge(){return{type:`link`,title:null,url:``,children:[]}}function _e(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function ve(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function ye(){return{type:`paragraph`,children:[]}}function be(){return{type:`strong`,children:[]}}function xe(){return{type:`text`,value:``}}function Se(){return{type:`thematicBreak`}}}function Q7(e){return{line:e.line,column:e.column,offset:e.offset}}function M$e(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?M$e(e,r):N$e(e,r)}}function N$e(e,t){let n;for(n in t)if(k$e.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 P$e(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+f7({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+f7({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+f7({start:t.start,end:t.end})+`) is still open`)}function F$e(e){let t=this;t.parser=n;function n(n){return A$e(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function I$e(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 L$e(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
245
|
+
`}]}function R$e(e,t){let n=t.value?t.value+`
|
|
246
|
+
`:``,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 z$e(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function B$e(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function V$e(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=B7(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 H$e(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 U$e(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function W$e(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 G$e(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return W$e(e,t);let i={src:B7(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 K$e(e,t){let n={src:B7(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 q$e(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 J$e(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return W$e(e,t);let i={href:B7(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 Y$e(e,t){let n={href:B7(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 X$e(e,t,n){let r=e.all(t),i=n?Z$e(n):Q$e(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:`
|
|
247
247
|
`}),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:`
|
|
248
|
-
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function
|
|
248
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Z$e(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Q$e(n[r])}return t}function Q$e(e){return e.spread??e.children.length>1}function $$e(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 e1e(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function t1e(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function n1e(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function r1e(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=u7(t.children[1]),o=l7(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 i1e(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 a1e(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var o1e=9,s1e=32;function c1e(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(l1e(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(l1e(t.slice(i),i>0,!1)),a.join(``)}function l1e(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===o1e||t===s1e;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===o1e||t===s1e;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function u1e(e,t){let n={type:`text`,value:c1e(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function d1e(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var f1e={blockquote:I$e,break:L$e,code:R$e,delete:z$e,emphasis:B$e,footnoteReference:V$e,heading:H$e,html:U$e,imageReference:G$e,image:K$e,inlineCode:q$e,linkReference:J$e,link:Y$e,listItem:X$e,list:$$e,paragraph:e1e,root:t1e,strong:n1e,table:r1e,tableCell:a1e,tableRow:i1e,text:u1e,thematicBreak:d1e,toml:$7,yaml:$7,definition:$7,footnoteDefinition:$7};function $7(){}var p1e=typeof self==`object`?self:globalThis,m1e=(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)e[r(t)]=r(n);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(new p1e[e](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)}}return n(new p1e[a](o),i)};return r},h1e=e=>m1e(new Map,e)(0),e9=``,{toString:g1e}={},{keys:_1e}=Object,t9=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=g1e.call(e).slice(8,-1);switch(n){case`Array`:return[1,e9];case`Object`:return[2,e9];case`Date`:return[3,e9];case`RegExp`:return[4,e9];case`Map`:return[5,e9];case`Set`:return[6,e9];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},n9=([e,t])=>e===0&&(t===`function`||t===`symbol`),v1e=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=t9(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of _1e(r))(e||!n9(t9(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(n9(t9(n))||n9(t9(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!n9(t9(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},y1e=(e,{json:t,lossy:n}={})=>{let r=[];return v1e(!(t||n),!!t,new Map,r)(e),r},r9=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?h1e(y1e(e,t)):structuredClone(e):(e,t)=>h1e(y1e(e,t));function b1e(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 x1e(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function S1e(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||b1e,r=e.options.footnoteBackLabel||x1e,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=B7(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:{...r9(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
249
249
|
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
250
|
-
`}]}}var
|
|
250
|
+
`}]}}var C1e=(function(e){if(e==null)return D1e;if(typeof e==`function`)return i9(e);if(typeof e==`object`)return Array.isArray(e)?w1e(e):T1e(e);if(typeof e==`string`)return E1e(e);throw Error(`Expected function, string, or object as test`)});function w1e(e){let t=[],n=-1;for(;++n<e.length;)t[n]=C1e(e[n]);return i9(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function T1e(e){let t=e;return i9(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function E1e(e){return i9(t);function t(t){return t&&t.type===e}}function i9(e){return t;function t(t,n,r){return!!(O1e(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function D1e(){return!0}function O1e(e){return typeof e==`object`&&!!e&&`type`in e}function k1e(e){return e}var A1e=[];function j1e(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=C1e(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 (`+k1e(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=A1e,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=M1e(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 M1e(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?A1e:[e]}function N1e(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),j1e(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 a9={}.hasOwnProperty,P1e={};function F1e(e,t){let n=t||P1e,r=new Map,i=new Map,a={all:s,applyData:L1e,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...f1e,...n.handlers},one:o,options:n,patch:I1e,wrap:z1e};return N1e(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(a9.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=r9(n);return r.children=a.all(e),r}return r9(e)}return(a.options.unknownHandler||R1e)(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=B1e(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=B1e(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function I1e(e,t){e.position&&(t.position=zXe(e))}function L1e(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,r9(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function R1e(e,t){let n=t.data||{},r=`value`in t&&!(a9.call(n,`hProperties`)||a9.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 z1e(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
251
251
|
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
252
252
|
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
253
|
-
`}),n}function
|
|
254
|
-
`},i)),a}function V1e(e,t){return e&&`run`in e?async function(n,r){let i=B1e(n,{file:r,...t});await e.run(i,r)}:function(n,r){return B1e(n,{file:r,...e||t})}}function H1e(e){if(e)throw e}var U1e=s(((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 a9(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 W1e(){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?G1e(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 G1e(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 o9={basename:K1e,dirname:q1e,extname:J1e,join:Y1e,sep:`/`};function K1e(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);s9(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 q1e(e){if(s9(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 J1e(e){s9(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 Y1e(...e){let t=-1,n;for(;++t<e.length;)s9(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:X1e(n)}function X1e(e){s9(e);let t=e.codePointAt(0)===47,n=Z1e(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Z1e(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 s9(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var Q1e={cwd:$1e};function $1e(){return`/`}function c9(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function e0e(e){if(typeof e==`string`)e=new URL(e);else if(!c9(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 t0e(e)}function t0e(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 l9=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],n0e=class{constructor(e){let t;t=e?c9(e)?{path:e}:typeof e==`string`||i0e(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:Q1e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<l9.length;){let e=l9[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)l9.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?o9.basename(this.path):void 0}set basename(e){d9(e,`basename`),u9(e,`basename`),this.path=o9.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?o9.dirname(this.path):void 0}set dirname(e){r0e(this.basename,`dirname`),this.path=o9.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?o9.extname(this.path):void 0}set extname(e){if(u9(e,`extname`),r0e(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=o9.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){c9(e)&&(e=e0e(e)),d9(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?o9.basename(this.path,this.extname):void 0}set stem(e){d9(e,`stem`),u9(e,`stem`),this.path=o9.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 m7(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 u9(e,t){if(e&&e.includes(o9.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+o9.sep+"`")}function d9(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function r0e(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function i0e(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var a0e=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),f9=u(U1e(),1),o0e={}.hasOwnProperty,s0e=new class e extends a0e{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=W1e()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,f9.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(h9(`data`,this.frozen),this.namespace[e]=t,this):o0e.call(this.namespace,e)&&this.namespace[e]||void 0:e?(h9(`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=g9(e),n=this.parser||this.Parser;return p9(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),p9(`process`,this.parser||this.Parser),m9(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=g9(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);d0e(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(),p9(`processSync`,this.parser||this.Parser),m9(`processSync`,this.compiler||this.Compiler),this.process(e,r),l0e(`processSync`,`process`,t),n;function r(e,r){t=!0,H1e(e),n=r}}run(e,t,n){c0e(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=g9(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),l0e(`runSync`,`run`,n),r;function i(e,t){H1e(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=g9(t),r=this.compiler||this.Compiler;return m9(`stringify`,r),c0e(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(h9(`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,f9.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];a9(o)&&a9(r)&&(r=(0,f9.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function p9(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function m9(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function h9(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 c0e(e){if(!a9(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function l0e(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function g9(e){return u0e(e)?e:new n0e(e)}function u0e(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function d0e(e){return typeof e==`string`||f0e(e)}function f0e(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var p0e=[],m0e={allowDangerousHtml:!0},h0e=/^(https?|ircs?|mailto|xmpp)$/i,g0e=[{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 _0e(e){let t=v0e(e),n=y0e(e);return b0e(t.runSync(t.parse(n),n),e)}function v0e(e){let t=e.rehypePlugins||p0e,n=e.remarkPlugins||p0e,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...m0e}:m0e;return s0e().use(P$e).use(n).use(V1e,r).use(t)}function y0e(e){let t=e.children||``,n=new n0e;return typeof t==`string`?n.value=t:``+t,n}function b0e(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||x0e;for(let e of g0e)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return M1e(e,l),GXe(e,{Fragment:Y.Fragment,components:i,ignoreInvalidStyle:!0,jsx:Y.jsx,jsxs:Y.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 C7)if(Object.hasOwn(C7,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=C7[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 x0e(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||h0e.test(e.slice(0,t))?e:``}function S0e(e){if(e.startsWith(`/`)&&!e.startsWith(`//`))return e;let t;try{t=new URL(e)}catch{return}return t.protocol===`https:`||t.protocol===`http:`?e:void 0}function C0e(){return{doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`},{tag:`h4`},{tag:`h5`},{tag:`h6`}],toDOM(){return[`p`,0]}},text:{group:`inline`},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}},heading:{attrs:{level:{default:1}},content:`inline*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}}],toDOM(e){return[`h${e.attrs.level}`,0]}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return[`blockquote`,0]}},list_item:{content:`paragraph block*`,parseDOM:[{tag:`li`}],toDOM(){return[`li`,0]},defining:!0},bullet_list:{content:`list_item+`,group:`block`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}},ordered_list:{attrs:{order:{default:1}},content:`list_item+`,group:`block`,parseDOM:[{tag:`ol`,getAttrs(e){let t=e;return{order:t.hasAttribute(`start`)?+(t.getAttribute(`start`)||1):1}}}],toDOM(e){return e.attrs.order===1?[`ol`,0]:[`ol`,{start:e.attrs.order},0]}},image:{inline:!0,atom:!0,attrs:{key:{default:``},alt:{default:null},previewUrl:{default:null},width:{default:null},height:{default:null},mimeType:{default:null}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[data-val-ai-key]`,getAttrs(e){let t=e;return{key:t.getAttribute(`data-val-ai-key`)||``,alt:t.getAttribute(`alt`),previewUrl:t.getAttribute(`src`)}}}],toDOM(e){return[`img`,{src:e.attrs.previewUrl??``,alt:e.attrs.alt??``,"data-val-ai-key":e.attrs.key}]}},field_ref:{inline:!0,atom:!0,selectable:!0,draggable:!1,attrs:{path:{default:``}},group:`inline`,parseDOM:[{tag:`span[data-val-field-ref]`,getAttrs(e){return{path:e.getAttribute(`data-val-field-ref`)||``}}}],toDOM(e){return[`span`,{"data-val-field-ref":e.attrs.path,contenteditable:`false`,class:`inline-flex items-center align-baseline rounded bg-bg-secondary text-fg-primary px-1.5 py-0.5 text-xs font-mono mx-0.5`},e.attrs.path]}}}}function w0e(){let e={};return e.bold={parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=bold`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return[`strong`,0]}},e.italic={parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`}],toDOM(){return[`em`,0]}},e.strikethrough={parseDOM:[{tag:`s`},{tag:`del`},{style:`text-decoration=line-through`}],toDOM(){return[`del`,0]}},e.code={parseDOM:[{tag:`code`}],toDOM(){return[`code`,0]}},e}function T0e(){return new ZX({nodes:C0e(),marks:w0e()})}function E0e(e){let t={};t[`Mod-z`]=w0,t[`Mod-y`]=T0,t[`Mod-Shift-z`]=T0,t[`Mod-b`]=b2(e.marks.bold),t[`Mod-i`]=b2(e.marks.italic),t[`Mod-Shift-x`]=b2(e.marks.strikethrough),t[`Mod-e`]=b2(e.marks.code);let n=e.nodes.hard_break;t[`Shift-Enter`]=(e,t)=>(t&&t(e.tr.replaceSelectionWith(n.create()).scrollIntoView()),!0);for(let n=1;n<=3;n++)t[`Mod-Alt-${n}`]=y2(e.nodes.heading,{level:n});return t[`Mod-Alt-0`]=y2(e.nodes.paragraph),t[`Mod-Shift-b`]=v2(e.nodes.blockquote),t[`Mod-Shift-8`]=D2(e.nodes.bullet_list),t[`Mod-Shift-9`]=D2(e.nodes.ordered_list),t.Enter=O2(e.nodes.list_item),t[`Mod-[`]=k2(e.nodes.list_item),t[`Mod-]`]=A2(e.nodes.list_item),[O0(t),O0(E2)]}function _9(e,t,n){return new N2(e,(e,r,i,a)=>{let o=r[1];if(!o)return null;let s=r[0].length-(t.length*2+o.length);if(s<0)return null;let c=e.tr;return c.replaceWith(i+s,a,e.schema.text(o,[n.create()])),c.removeStoredMark(n),c})}function D0e(e){let t=[];return t.push(L2(/^(#{1,3})\s$/,e.nodes.heading,e=>({level:e[1].length}))),t.push(I2(/^\s*>\s$/,e.nodes.blockquote)),t.push(I2(/^\s*([-+*])\s$/,e.nodes.bullet_list)),t.push(I2(/^(\d+)\.\s$/,e.nodes.ordered_list,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order===+e[1])),t.push(_9(/\*\*([^*]+)\*\*$/,`**`,e.marks.bold)),t.push(_9(/(?:^|[^*])\*([^*]+)\*$/,`*`,e.marks.italic)),t.push(_9(/~~([^~]+)~~$/,`~~`,e.marks.strikethrough)),t.push(_9(/`([^`]+)`$/,"`",e.marks.code)),P2({rules:t})}var O0e=new CQ(`submitOnEnter`);function k0e(e,t){return new bQ({key:O0e,props:{handleKeyDown(n,r){if(r.key!==`Enter`)return!1;if(r.metaKey||r.ctrlKey)return r.preventDefault(),t(),!0;if(r.shiftKey)return!1;let{$from:i}=n.state.selection;for(let t=i.depth;t>0;t--)if(i.node(t).type===e.nodes.list_item)return!1;return r.preventDefault(),t(),!0}}})}function A0e(){return function(e,t,n){let r=document.createElement(`span`);r.className=`relative inline-block align-baseline mx-0.5`,r.style.lineHeight=`0`,r.contentEditable=`false`;let i=document.createElement(`img`);i.style.maxHeight=`64px`,i.style.borderRadius=`4px`,i.style.border=`1px solid var(--border-primary, #ddd)`,i.style.display=`inline-block`,i.style.verticalAlign=`baseline`;let a=e=>{i.src=e.attrs.previewUrl??``,i.alt=e.attrs.alt??``,i.setAttribute(`data-val-ai-key`,e.attrs.key??``);let t=e.attrs.key?.startsWith(`pending:`);r.style.opacity=t?`0.6`:`1`};a(e);let o=document.createElement(`button`);return o.type=`button`,o.textContent=`×`,o.setAttribute(`aria-label`,`Remove image`),o.className=`absolute -top-1 -right-1 rounded-full bg-bg-primary border border-border-primary text-fg-secondary hover:text-fg-primary w-4 h-4 leading-none text-xs flex items-center justify-center`,o.addEventListener(`mousedown`,r=>{r.preventDefault(),r.stopPropagation();let i=n();i!==void 0&&(t.dispatch(t.state.tr.delete(i,i+e.nodeSize)),t.focus())}),r.appendChild(i),r.appendChild(o),{dom:r,update(t){return t.type===e.type&&(a(t),!0)},stopEvent(e){return e.type===`mousedown`},ignoreMutation(){return!0}}}}async function j0e(e,t=`pasted-image`){try{let n=await fetch(e,{credentials:`omit`,mode:`cors`});if(!n.ok)return null;let r=await n.blob();if(!r.type.startsWith(`image/`))return null;let i=r.type.split(`/`)[1]||`png`;return new File([r],`${t}.${i}`,{type:r.type})}catch{return null}}function v9(e,t,n){let r=e.state.schema.nodes.image;if(!r)return!1;let i=`pending:${crypto.randomUUID()}`,a=URL.createObjectURL(t),o=t.type||`image/*`,s=r.create({key:i,alt:``,previewUrl:a,mimeType:o}),{from:c}=e.state.selection;return e.dispatch(e.state.tr.insert(c,s)),n(t).then(({key:t})=>{e.state.doc.descendants((n,a)=>{if(n.type===r&&n.attrs.key===i){let r=e.state.tr.setNodeMarkup(a,void 0,{...n.attrs,key:t});return e.dispatch(r),!1}return!0})}).catch(t=>{console.error(`AI chat image upload failed`,t),e.state.doc.descendants((t,n)=>t.type===r&&t.attrs.key===i?(e.dispatch(e.state.tr.delete(n,n+t.nodeSize).setMeta(`addToHistory`,!1)),!1):!0),URL.revokeObjectURL(a)}),!0}function y9(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}function b9(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--)if(n.node(e).type===t)return!0;return!1}function M0e(e,t,n){let{state:r,dispatch:i}=e;return b9(r,t)?k2(n.nodes.list_item)(r,i):D2(t)(r,i)}function N0e(e){let{$from:t}=e.selection;if(t.parent.type.name===`heading`){let e=t.parent.attrs.level;if(e===1||e===2||e===3)return e}return null}function x9({active:e,onMouseDown:t,title:n,children:r,disabled:i}){return(0,Y.jsx)(`button`,{type:`button`,title:n,"aria-pressed":e,disabled:i,onMouseDown:t,className:(0,AC.default)(`flex h-7 w-7 items-center justify-center rounded text-fg-primary`,`hover:bg-bg-secondary disabled:opacity-50`,{"bg-bg-secondary":e}),children:r})}function P0e({view:e,schema:t,onUploadAiImage:n}){let[r,i]=(0,b.useState)(!1),{state:a}=e,o=N0e(a),s=o?`H${o}`:`P`,c=t=>n=>{n.preventDefault(),t(e.state),e.focus()};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsxs)(`button`,{type:`button`,title:`Block type`,onMouseDown:e=>{e.preventDefault(),i(e=>!e)},className:`flex h-7 items-center justify-center gap-1 rounded px-2 text-xs font-medium text-fg-primary hover:bg-bg-secondary`,children:[s,(0,Y.jsx)(Iv,{size:12})]}),r&&(0,Y.jsx)(`div`,{className:`absolute left-0 top-8 z-window min-w-[8em] rounded-md border border-border-primary bg-bg-primary shadow-md py-1`,children:[`P`,`H1`,`H2`,`H3`].map(n=>(0,Y.jsx)(`button`,{type:`button`,onMouseDown:r=>{if(r.preventDefault(),n===`P`)y2(t.nodes.paragraph)(e.state,e.dispatch,e);else{let r=parseInt(n[1],10);y2(t.nodes.heading,{level:r})(e.state,e.dispatch,e)}i(!1),e.focus()},className:`block w-full px-3 py-1 text-left text-xs hover:bg-bg-secondary`,children:n===`P`?`Paragraph`:`Heading ${n[1]}`},n))})]}),(0,Y.jsx)(`div`,{className:`mx-1 h-5 w-px bg-border-primary`}),(0,Y.jsx)(x9,{title:`Bold (Ctrl+B)`,active:y9(a,t.marks.bold),onMouseDown:c(n=>b2(t.marks.bold)(n,e.dispatch)),children:(0,Y.jsx)(Mv,{size:14})}),(0,Y.jsx)(x9,{title:`Italic (Ctrl+I)`,active:y9(a,t.marks.italic),onMouseDown:c(n=>b2(t.marks.italic)(n,e.dispatch)),children:(0,Y.jsx)(ly,{size:14})}),(0,Y.jsx)(x9,{title:`Strikethrough (Ctrl+Shift+X)`,active:y9(a,t.marks.strikethrough),onMouseDown:c(n=>b2(t.marks.strikethrough)(n,e.dispatch)),children:(0,Y.jsx)(Fy,{size:14})}),(0,Y.jsx)(x9,{title:`Inline code (Ctrl+E)`,active:y9(a,t.marks.code),onMouseDown:c(n=>b2(t.marks.code)(n,e.dispatch)),children:(0,Y.jsx)(Kv,{size:14})}),(0,Y.jsx)(`div`,{className:`mx-1 h-5 w-px bg-border-primary`}),(0,Y.jsx)(x9,{title:`Bullet list (Ctrl+Shift+8)`,active:b9(a,t.nodes.bullet_list),onMouseDown:n=>{n.preventDefault(),M0e(e,t.nodes.bullet_list,t),e.focus()},children:(0,Y.jsx)(my,{size:14})}),(0,Y.jsx)(x9,{title:`Numbered list (Ctrl+Shift+9)`,active:b9(a,t.nodes.ordered_list),onMouseDown:n=>{n.preventDefault(),M0e(e,t.nodes.ordered_list,t),e.focus()},children:(0,Y.jsx)(fy,{size:14})}),(0,Y.jsx)(x9,{title:`Blockquote (Ctrl+Shift+B)`,onMouseDown:n=>{n.preventDefault(),v2(t.nodes.blockquote)(e.state,e.dispatch),e.focus()},children:(0,Y.jsx)(yae,{size:14})}),n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`mx-1 h-5 w-px bg-border-primary`}),(0,Y.jsx)(x9,{title:`Insert image`,onMouseDown:t=>{t.preventDefault();let r=document.createElement(`input`);r.type=`file`,r.accept=`image/*`,r.onchange=()=>{let t=r.files?.[0];t&&v9(e,t,n)},r.click()},children:(0,Y.jsx)(sy,{size:14})})]})]})}var F0e=new CQ(`chatFloatingToolbar`);function I0e(e,t){let n=null,r=null;function i(i){if(!n||!r)return;let{selection:a}=i.state,{empty:o,from:s,to:c}=a;if(o||!i.hasFocus()){n.style.display=`none`;return}r.render((0,b.createElement)(P0e,{view:i,schema:e,onUploadAiImage:t?.getUploadAiImage?.()}));let l=t?.getPortalContainer?.();n.style.display=`flex`;let u=()=>{if(!n)return;let e=i.coordsAtPos(s),t=i.coordsAtPos(c),r=(e.left+t.left)/2,a=Math.min(e.top,t.top),o=Math.max(e.bottom,t.bottom),u=n.offsetWidth||220,d=n.offsetHeight||36,f=r-u/2,p=a-d-8;p<8&&(p=o+8);let m=window.innerWidth-u-8;if(f=Math.max(8,Math.min(f,m)),l)n.style.left=`${f}px`,n.style.top=`${p}px`;else{let e=i.dom.parentElement?.getBoundingClientRect();if(!e)return;n.style.left=`${f-e.left}px`,n.style.top=`${p-e.top}px`}};u(),requestAnimationFrame(u)}return new bQ({key:F0e,view(e){n=document.createElement(`div`);let a=t?.getPortalContainer?.();return n.className=[`${a?`fixed`:`absolute`} z-window flex items-center gap-x-0.5 rounded-md border border-border-primary`,`bg-bg-primary px-1 py-1 shadow-lg`].join(` `),n.style.display=`none`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Chat formatting (selection)`),n.addEventListener(`mousedown`,e=>e.preventDefault(),!0),(a??e.dom.parentElement)?.appendChild(n),r=(0,x.createRoot)(n),{update:i,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}function L0e({path:e,onRemove:t}){let n=e;try{let[t,r]=H.splitModuleFilePathAndModulePath(e),i=H.splitModuleFilePath(t),a=H.splitModulePath(r);n=[i.length>0?kC(i[i.length-1]):t,...a.map(kC)].join(` / `)}catch{}return(0,b.createElement)(`span`,{className:`inline-flex items-center gap-1 align-baseline rounded bg-bg-secondary text-fg-primary px-1.5 py-0.5 text-xs font-mono mx-0.5`,title:e,contentEditable:!1},(0,b.createElement)(`span`,{className:`truncate max-w-[16em]`},n),(0,b.createElement)(`button`,{type:`button`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),t()},className:`text-fg-secondary hover:text-fg-primary leading-none`,"aria-label":`Remove field reference`},`×`))}function R0e(){return function(e,t,n){let r=document.createElement(`span`);r.setAttribute(`data-val-field-ref`,e.attrs.path),r.style.display=`inline-block`,r.style.verticalAlign=`baseline`,r.contentEditable=`false`;let i=(0,x.createRoot)(r),a=()=>{let r=n();if(r===void 0)return;let i=t.state.tr.delete(r,r+e.nodeSize);t.dispatch(i),t.focus()};return i.render((0,b.createElement)(L0e,{path:e.attrs.path,onRemove:a})),{dom:r,update(t){return t.type===e.type&&(t.attrs.path===e.attrs.path||i.render((0,b.createElement)(L0e,{path:t.attrs.path,onRemove:a})),!0)},stopEvent(e){return e.type===`mousedown`},ignoreMutation(){return!0},destroy(){queueMicrotask(()=>i.unmount())}}}}function z0e(e){let t=[];return e.forEach(e=>{let n=S9(e);n&&t.push(n)}),t}function S9(e){switch(e.type.name){case`paragraph`:return{tag:`p`,children:V0e(e)};case`heading`:return{tag:`h${Math.min(3,Math.max(1,e.attrs.level))}`,children:V0e(e)};case`bullet_list`:return{tag:`ul`,children:B0e(e)};case`ordered_list`:return{tag:`ol`,children:B0e(e)};case`blockquote`:{let t=[];return e.forEach(e=>{let n=S9(e);n&&t.push(n)}),{tag:`blockquote`,children:t}}default:return null}}function B0e(e){let t=[];return e.forEach(e=>{if(e.type.name===`list_item`){let n=[];e.forEach(e=>{let t=S9(e);t&&n.push(t)}),t.push({tag:`li`,children:n})}}),t}function V0e(e){let t=[];return e.forEach(e=>{if(e.isText){let n=e.text||``,r=H0e(e.marks);r.length===0?t.push(n):t.push({tag:`span`,styles:r,children:[n]})}else if(e.type.name===`hard_break`)t.push({tag:`br`});else if(e.type.name===`image`){let n=e.attrs.key,r=e.attrs.width,i=e.attrs.height,a=e.attrs.mimeType,o=e.attrs.previewUrl,s=e.attrs.alt,c={tag:`img`,key:n};s&&(c.alt=s),o&&(c.previewUrl=o),r!==null&&(c.width=r),i!==null&&(c.height=i),a!==null&&(c.mimeType=a),t.push(c)}else e.type.name===`field_ref`&&t.push({tag:`field_ref`,path:e.attrs.path})}),t}function H0e(e){let t=[];for(let n of e)switch(n.type.name){case`bold`:t.push(`bold`);break;case`italic`:t.push(`italic`);break;case`strikethrough`:t.push(`line-through`);break;case`code`:t.push(`code`)}return t}var U0e={bold:`bold`,italic:`italic`,"line-through":`strikethrough`,code:`code`};function W0e(e,t){let n=U0e[e],r=n?t.marks[n]:void 0;return r?r.create():null}function G0e(e,t){let n=e.map(e=>C9(e,t));return n.length===0&&n.push(t.node(`paragraph`)),t.node(`doc`,null,n)}function C9(e,t){switch(e.tag){case`p`:return t.node(`paragraph`,null,q0e(e.children,t));case`h1`:case`h2`:case`h3`:{let n=parseInt(e.tag[1],10);return t.node(`heading`,{level:n},q0e(e.children,t))}case`ul`:return t.node(`bullet_list`,null,e.children.map(e=>K0e(e,t)));case`ol`:return t.node(`ordered_list`,null,e.children.map(e=>K0e(e,t)));case`blockquote`:return t.node(`blockquote`,null,e.children.map(e=>C9(e,t)))}}function K0e(e,t){let n=e.children.map(e=>C9(e,t));return t.node(`list_item`,null,n)}function q0e(e,t){let n=[];for(let r of e)if(typeof r==`string`)r.length>0&&n.push(t.text(r));else if(r.tag===`br`)t.nodes.hard_break&&n.push(t.node(`hard_break`));else if(r.tag===`span`){let e=r.styles.map(e=>W0e(e,t)).filter(e=>e!==null);r.children[0].length>0&&n.push(t.text(r.children[0],e))}else r.tag===`img`?t.nodes.image&&n.push(t.node(`image`,{key:r.key,alt:r.alt??null,previewUrl:r.previewUrl??null,width:r.width??null,height:r.height??null,mimeType:r.mimeType??null})):r.tag===`field_ref`&&t.nodes.field_ref&&n.push(t.node(`field_ref`,{path:r.path}));return n}function J0e(e){return e.replace(/<style[\s\S]*?<\/style>/gi,``).replace(/<meta[^>]*>/gi,``).replace(/<o:p\b[^>]*>[\s\S]*?<\/o:p>/gi,``)}function Y0e(e){if(!e)return[];let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=[];return t.body.querySelectorAll(`img`).forEach(e=>{if(e.hasAttribute(`data-val-ai-key`))return;let t=e.getAttribute(`src`);t&&n.push(t)}),n}async function X0e(e,t,n){for(let r of t){let t=await j0e(r);if(!t){console.warn(`AI chat: skipped pasted image (fetch failed)`,r);continue}v9(e,t,n)}}var Z0e=(0,b.forwardRef)(function({placeholder:e,disabled:t,className:n,onSubmit:r,onChange:i,onUploadAiImage:a,getPortalContainer:o},s){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),u=(0,b.useMemo)(()=>T0e(),[]),d=(0,b.useRef)(r);d.current=r;let f=(0,b.useRef)(i);f.current=i;let p=(0,b.useRef)(a);p.current=a;let m=(0,b.useRef)(t);return m.current=t,(0,b.useLayoutEffect)(()=>{let e=c.current;if(!e)return;let t=u.node(`doc`,null,[u.node(`paragraph`)]),n=[k0e(u,()=>d.current?.()),...E0e(u),D0e(u),S0(),E0(),M0(),I0e(u,{getPortalContainer:o,getUploadAiImage:()=>p.current})],r=new i0(e,{state:vQ.create({doc:t,schema:u,plugins:n}),nodeViews:{field_ref:R0e(),image:A0e()},transformPastedHTML:J0e,handlePaste(e,t){let n=p.current;if(!n)return!1;let r=t.clipboardData?.items;if(r)for(let t=0;t<r.length;t++){let i=r[t];if(i.kind===`file`&&i.type.startsWith(`image/`)){let t=i.getAsFile();if(t)return v9(e,t,n),!0}}let i=t.clipboardData?.getData(`text/html`),a=Y0e(i);return a.length>0&&(X0e(e,a,n),!0)},handleDrop(e,t){let n=p.current;if(!n)return!1;let r=t.dataTransfer,i=r?.files;if(i&&i.length>0){let r=Array.from(i).find(e=>e.type.startsWith(`image/`));if(r)return t.preventDefault(),v9(e,r,n),!0}let a=r?.getData(`text/html`),o=Y0e(a);return o.length>0&&(t.preventDefault(),X0e(e,o,n),!0)},dispatchTransaction(e){let t=r.state.apply(e);r.updateState(t),e.docChanged&&f.current?.(z0e(t.doc))},editable:()=>!m.current});return l.current=r,()=>{r.destroy(),l.current=null}},[u]),(0,b.useEffect)(()=>{let e=l.current;e&&e.setProps({editable:()=>!m.current})},[t]),(0,b.useImperativeHandle)(s,()=>({getDocument:()=>{let e=l.current;return e?z0e(e.state.doc):[]},setDocument:e=>{let t=l.current;if(!t)return;let n=G0e(e,u),r=vQ.create({doc:n,schema:u,plugins:t.state.plugins});t.updateState(r)},clear:()=>{let e=l.current;if(!e)return;let t=u.node(`doc`,null,[u.node(`paragraph`)]),n=vQ.create({doc:t,schema:u,plugins:e.state.plugins});e.updateState(n)},focus:()=>{l.current?.focus()},isEmpty:()=>{let e=l.current;if(!e)return!0;let t=e.state.doc;if(t.childCount===0)return!0;if(t.childCount>1)return!1;let n=t.firstChild;return!n||n.type.name===`paragraph`&&n.content.size===0},insertFieldRef:e=>{let t=l.current;if(!t)return;let n=u.nodes.field_ref.create({path:e}),r=t.state.doc.content.size,i=t.state.doc.lastChild,a=t.state.tr;if(i&&i.type.name===`paragraph`){let e=r-1;a.insert(e,n),a.insertText(` `,e+n.nodeSize)}else{let e=u.node(`paragraph`,null,[n]);a.insert(r,e)}t.dispatch(a.scrollIntoView()),t.focus()}}),[u]),(0,Y.jsx)(`div`,{className:(0,AC.default)(`val-chat-editor relative flex flex-col cursor-text`,n,{"opacity-60 cursor-not-allowed":t}),onMouseDown:e=>{if(t)return;let n=l.current;if(n&&(e.target===e.currentTarget||e.target===c.current)){e.preventDefault(),n.focus();let t=n.state.doc.content.size;n.dispatch(n.state.tr.setSelection(nQ.near(n.state.doc.resolve(t))))}},children:(0,Y.jsx)(`div`,{ref:c,className:(0,AC.default)(`val-chat-editor-content flex-1 min-h-[2.25rem] outline-none`,`[&_.ProseMirror]:min-h-full [&_.ProseMirror]:outline-none`),"data-placeholder":e||``})})}),Q0e={bold:`strong`,italic:`em`,"line-through":`del`,code:`code`};function $0e(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function w9(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function e2e(e){if(typeof e==`string`)return $0e(e);if(e.tag===`br`)return`<br/>`;if(e.tag===`span`){let t=$0e(e.children[0]),n=e.styles.map(e=>Q0e[e]).filter(e=>!!e);return`${n.map(e=>`<${e}>`).join(``)}${t}${n.slice().reverse().map(e=>`</${e}>`).join(``)}`}if(e.tag===`img`){let t=e.alt===void 0?``:` alt="${w9(e.alt)}"`;return`<img key="${w9(e.key)}"${t}/>`}return e.tag===`field_ref`?`<field path="${w9(e.path)}"/>`:``}function t2e(e){return e.map(e2e).join(``)}function n2e(e){return`<li>${e.children.map(T9).join(``)}</li>`}function T9(e){switch(e.tag){case`p`:return`<p>${t2e(e.children)}</p>`;case`h1`:case`h2`:case`h3`:return`<${e.tag}>${t2e(e.children)}</${e.tag}>`;case`ul`:return`<ul>${e.children.map(n2e).join(``)}</ul>`;case`ol`:return`<ol>${e.children.map(n2e).join(``)}</ol>`;case`blockquote`:return`<blockquote>${e.children.map(T9).join(``)}</blockquote>`}}function r2e(e){return e.map(T9).join(`
|
|
255
|
-
`)}function
|
|
256
|
-
`:e.tag===`span`?e.children[0]:e.tag===`img`?e.alt?`[image: ${e.alt}]`:`[image]`:e.tag===`field_ref`?`@${
|
|
257
|
-
`))a(e);break;case`ul`:for(let e of t.children)r.push(
|
|
258
|
-
`)}function
|
|
259
|
-
`);case`ul`:return e.children.map(e=>
|
|
260
|
-
`);case`ol`:return e.children.map((e,t)=>
|
|
261
|
-
`)}}function
|
|
262
|
-
|
|
263
|
-
`)}function s2e(e,t){typeof e!=`string`&&e.tag===`img`&&t.push(e)}function c2e(e,t){for(let n of e.children)k9(n,t)}function k9(e,t){switch(e.tag){case`p`:case`h1`:case`h2`:case`h3`:for(let n of e.children)s2e(n,t);return;case`ul`:case`ol`:for(let n of e.children)c2e(n,t);return;case`blockquote`:for(let n of e.children)k9(n,t);return}}function l2e(e){let t=[];for(let n of e)k9(n,t);return t}function u2e(e){return l2e(e).map(e=>e.key)}function A9(e){return e.questions!==void 0&&e.answers===void 0&&!e.cancelled&&e.status===`pending`}var d2e={get_all_schema:{label:`Reading schemas`,icon:(0,Y.jsx)(Uie,{className:`h-3 w-3`})},get_source:{label:`Reading content`,icon:(0,Y.jsx)($v,{className:`h-3 w-3`})},search_content:{label:`Searching`,icon:(0,Y.jsx)(My,{className:`h-3 w-3`})},validate_content:{label:`Validating`,icon:(0,Y.jsx)(Eae,{className:`h-3 w-3`})},create_patch:{label:`Updating content`,icon:(0,Y.jsx)(Dy,{className:`h-3 w-3`})},add_session_image_to_gallery:{label:`Adding image to gallery`,icon:(0,Y.jsx)(Ey,{className:`h-3 w-3`})},remove_image_gallery_entry:{label:`Removing image from gallery`,icon:(0,Y.jsx)(Ey,{className:`h-3 w-3`})},navigate_to:{label:`Navigating to content`,icon:(0,Y.jsx)(xy,{className:`h-3 w-3`})},get_patches:{label:`Loading changes`,icon:(0,Y.jsx)(Wv,{className:`h-3 w-3`})},get_source_path_from_route:{label:`Resolving route`,icon:(0,Y.jsx)(xy,{className:`h-3 w-3`})},get_current_context:{label:`Gathering context`,icon:(0,Y.jsx)(Vy,{className:`h-3 w-3`})},set_session_name:{label:`Naming session`,icon:(0,Y.jsx)(Fae,{className:`h-3 w-3`})},show_compare_view:{label:`Opening compare view`,icon:(0,Y.jsx)(ty,{className:`h-3 w-3`})},ask_user_question:{label:`Asking a question`,icon:(0,Y.jsx)(Hv,{className:`h-3 w-3`})},duplicate_source:{label:`Duplicating content`,icon:(0,Y.jsx)(qv,{className:`h-3 w-3`})},empty_at_path:{label:`Creating empty entry`,icon:(0,Y.jsx)(Zie,{className:`h-3 w-3`})},count_entries:{label:`Counting entries`,icon:(0,Y.jsx)(oy,{className:`h-3 w-3`})},get_record_keys:{label:`Listing keys`,icon:(0,Y.jsx)(my,{className:`h-3 w-3`})}};function j9(e){return d2e[e]??{label:e,icon:(0,Y.jsx)(Ny,{className:`h-3 w-3`})}}function f2e(e){return e===`pending`?`Running`:e===`error`?`Failed`:`Completed`}function p2e({activities:e,onSubmitAnswers:t,onCancel:n,defaultExpanded:r}){let i=e.filter(e=>e.questions===void 0),a=e.filter(e=>e.questions!==void 0);return e.length===0?null:(0,Y.jsxs)(`div`,{className:`not-prose flex flex-col gap-1.5 min-w-0`,children:[i.length>0&&(0,Y.jsx)(h2e,{activities:i,defaultExpanded:r}),a.map(e=>A9(e)&&e.questions?(0,Y.jsx)(v2e,{questions:e.questions,onSubmit:n=>t(e.toolCallId,n),onCancel:()=>n(e.toolCallId)},e.toolCallId):e.questions&&e.answers?(0,Y.jsx)(g2e,{answers:e.answers,questions:e.questions},e.toolCallId):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs py-0.5 text-fg-secondary`,children:[(0,Y.jsx)(Uv,{className:`h-3 w-3`}),(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Question dismissed`})]},e.toolCallId))]})}function m2e(e){let t=e.find(e=>e.status===`pending`);return t?`${j9(t.name).label}…`:e.length===1?j9(e[0].name).label:`Used ${e.length} tools`}function h2e({activities:e,defaultExpanded:t}){let[n,r]=(0,b.useState)(t===!0),i=(0,b.useId)(),a=e.find(e=>e.status===`pending`),o=e.filter(e=>e.status===`error`).length,s=m2e(e),c=j9((a??e[e.length-1]).name).icon;return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-primary bg-bg-secondary overflow-hidden`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-controls":i,className:X(`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,`text-xs touch:text-sm hover:bg-bg-secondary-hover transition-colors`),children:[(0,Y.jsx)(Rv,{className:X(`h-3 w-3 shrink-0 text-fg-tertiary transition-transform`,n&&`rotate-90`)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-tertiary`,children:c}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:(0,Y.jsx)(`span`,{className:X(a&&`val-shimmer-text`),children:s})}),o>0&&(0,Y.jsxs)(`span`,{className:`shrink-0 text-fg-error-on-surface`,children:[o,` failed`]})]}),n&&(0,Y.jsx)(`ul`,{id:i,className:`flex flex-col gap-1 border-t border-border-primary px-2.5 py-1.5`,children:e.map(e=>{let t=j9(e.name);return(0,Y.jsxs)(`li`,{className:X(`flex items-center gap-1.5 text-xs touch:text-sm`,e.status===`error`?`text-fg-error-on-surface`:`text-fg-secondary`),children:[(0,Y.jsx)(`span`,{className:`shrink-0`,"aria-hidden":`true`,children:e.status===`pending`?(0,Y.jsx)(hy,{className:`h-3 w-3 animate-spin`}):e.status===`error`?(0,Y.jsx)(Uv,{className:`h-3 w-3`}):(0,Y.jsx)(Fv,{className:`h-3 w-3`})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:f2e(e.status)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-tertiary`,"aria-hidden":`true`,children:t.icon}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,Y.jsxs)(`span`,{className:X(e.status===`pending`&&`val-shimmer-text`),children:[t.label,e.status===`pending`?`…`:``]})})]},e.toolCallId)})})]})}function g2e({questions:e,answers:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-xs text-fg-secondary py-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Asked a question`})]}),t.map((t,n)=>{let r=e[n],i=[];r&&t.selectedOptions.forEach(e=>{let t=r.options[e]?.label;t&&i.push(t)}),t.customAnswer&&i.push(t.customAnswer);let a=i.join(`, `)||`(no answer)`;return(0,Y.jsxs)(`div`,{className:`pl-4 truncate`,children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`Q:`}),` `,t.question,` `,(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`→`}),` `,a]},n)})]})}function _2e(e){return e.map(e=>{let t=new Set;if(e.defaults&&e.defaults.length>0){let n=e.defaults.filter(t=>Number.isInteger(t)&&t>=0&&t<e.options.length);e.multiSelect?n.forEach(e=>t.add(e)):n.length>0&&t.add(n[0])}return{selected:t,custom:``,otherSelected:!1}})}function v2e({questions:e,onSubmit:t,onCancel:n}){let[r,i]=(0,b.useState)(()=>_2e(e)),[a,o]=(0,b.useState)(!1),s=(0,b.useId)(),c=r.every(e=>e.selected.size>0||e.otherSelected&&e.custom.trim().length>0),l=(e,t,n)=>{a||i(r=>r.map((r,i)=>{if(i!==e)return r;let a=new Set(r.selected);return n?(a.has(t)?a.delete(t):a.add(t),{...r,selected:a}):(a.clear(),a.add(t),{...r,selected:a,otherSelected:!1})}))},u=(e,t)=>{a||i(n=>n.map((n,r)=>r===e?t?{...n,otherSelected:!n.otherSelected}:{...n,selected:new Set,otherSelected:!0}:n))},d=(e,t,n)=>{a||i(r=>r.map((r,i)=>i===e?n?{...r,custom:t,otherSelected:!0}:{...r,custom:t,otherSelected:!0,selected:new Set}:r))},f=(0,b.useRef)(new Map),p=(e,t)=>`${e}:${t}`,m=(e,t,n,r)=>{let i;if(e.key===`ArrowDown`||e.key===`ArrowRight`)i=(n+1)%r;else if(e.key===`ArrowUp`||e.key===`ArrowLeft`)i=(n-1+r)%r;else return;e.preventDefault();let a=r-1;i===a?u(t,!1):l(t,i,!1),f.current.get(p(t,i))?.focus()};return(0,Y.jsxs)(`div`,{className:`not-prose flex flex-col gap-3 rounded-md border border-border-primary bg-bg-secondary p-3 my-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Please answer to continue`})]}),e.map((e,t)=>{let n=e.multiSelect===!0,i=r[t],o=e.options.length,c=o+1,h=`${s}-q${t}`,g=i.otherSelected?o:Array.from(i.selected).sort((e,t)=>e-t)[0]??0,_=e=>n?void 0:g===e?0:-1;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,Y.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-tertiary`,children:e.header}),(0,Y.jsx)(`div`,{id:h,className:`text-sm text-fg-primary`,children:e.question}),(0,Y.jsxs)(`div`,{role:n?`group`:`radiogroup`,"aria-labelledby":h,className:`flex flex-col gap-1`,children:[e.options.map((e,r)=>{let o=i.selected.has(r);return(0,Y.jsxs)(`button`,{ref:e=>{f.current.set(p(t,r),e)},type:`button`,role:n?`checkbox`:`radio`,"aria-checked":o,tabIndex:_(r),disabled:a,onClick:()=>l(t,r,n),onKeyDown:n?void 0:e=>m(e,t,r,c),className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-left text-sm transition-colors`,o?`border-fg-primary bg-bg-primary`:`border-border-primary bg-bg-primary hover:bg-bg-secondary`,a&&`opacity-60 cursor-not-allowed`),children:[(0,Y.jsxs)(`span`,{className:X(`shrink-0 h-3.5 w-3.5 flex items-center justify-center border`,n?`rounded-sm`:`rounded-full`,o?`bg-fg-primary border-fg-primary`:`border-border-primary`),children:[o&&n&&(0,Y.jsx)(Fv,{className:`h-2.5 w-2.5 text-bg-primary`}),o&&!n&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bg-primary`})]}),(0,Y.jsxs)(`span`,{className:`flex-1 leading-tight`,children:[(0,Y.jsx)(`span`,{className:`block text-fg-primary`,children:e.label}),e.description&&(0,Y.jsx)(`span`,{className:`block text-xs text-fg-secondary`,children:e.description})]})]},r)}),(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-sm transition-colors`,i.otherSelected?`border-fg-primary bg-bg-primary`:`border-border-primary bg-bg-primary`,a&&`opacity-60`),children:[(0,Y.jsxs)(`button`,{ref:e=>{f.current.set(p(t,o),e)},type:`button`,role:n?`checkbox`:`radio`,"aria-checked":i.otherSelected,"aria-label":`Other`,tabIndex:_(o),disabled:a,onClick:()=>u(t,n),onKeyDown:n?void 0:e=>m(e,t,o,c),className:X(`shrink-0 h-3.5 w-3.5 flex items-center justify-center border`,n?`rounded-sm`:`rounded-full`,i.otherSelected?`bg-fg-primary border-fg-primary`:`border-border-primary`,a&&`cursor-not-allowed`),children:[i.otherSelected&&n&&(0,Y.jsx)(Fv,{className:`h-2.5 w-2.5 text-bg-primary`}),i.otherSelected&&!n&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bg-primary`})]}),(0,Y.jsx)(`input`,{type:`text`,disabled:a,placeholder:`Other (type your own answer)`,value:i.custom,onChange:e=>d(t,e.target.value,n),className:X(`flex-1 bg-transparent text-fg-primary`,`focus:outline-none placeholder:text-fg-tertiary`)})]})]})]},t)}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{a||(o(!0),n())},disabled:a,children:`Cancel`}),(0,Y.jsx)(t_,{size:`sm`,onClick:()=>{a||!c||(o(!0),t(e.map((e,t)=>{let n=r[t];return{question:e.question,selectedOptions:Array.from(n.selected).sort((e,t)=>e-t),customAnswer:n.otherSelected&&n.custom.trim().length>0?n.custom.trim():null}})))},disabled:a||!c,children:`Submit`})]})]})}function y2e(e){let{isUser:t,isError:n,isStreaming:r,hasText:i,hasFiles:a,hasRunningTool:o,hasPendingQuestion:s}=e,c=r&&!s&&(i||!o);return{hasBubble:t||n||i||a||c||!r&&!s,showCursor:c}}var b2e=[`Summarize recent changes`,`What am I looking at?`,`Fix typos`],x2e=0;function S2e(){return`chat-${++x2e}-${Date.now()}`}function M9(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
264
|
-
|
|
265
|
-
`)}var C2e=/<\/?(?:p|h[1-3]|blockquote|ul|ol|li|strong|b|em|i|del|s|code|br|img|field)\b/i;function w2e(e){return Array.from(e).map((e,t)=>T2e(e,t))}function T2e(e,t){if(e.nodeType===3)return e.nodeValue??``;if(e.nodeType!==1)return null;let n=e,r=w2e(n.childNodes);switch(n.tagName.toLowerCase()){case`p`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:r},t);case`h1`:return(0,Y.jsx)(`h1`,{className:`text-base font-semibold`,children:r},t);case`h2`:return(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:r},t);case`h3`:return(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:r},t);case`blockquote`:return(0,Y.jsx)(`blockquote`,{className:`border-l-2 border-border-primary pl-2 italic`,children:r},t);case`ul`:return(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:r},t);case`ol`:return(0,Y.jsx)(`ol`,{className:`list-decimal pl-5`,children:r},t);case`li`:return(0,Y.jsx)(`li`,{children:r},t);case`strong`:case`b`:return(0,Y.jsx)(`strong`,{children:r},t);case`em`:case`i`:return(0,Y.jsx)(`em`,{children:r},t);case`del`:case`s`:return(0,Y.jsx)(`del`,{children:r},t);case`code`:return(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.85em]`,children:r},t);case`br`:return(0,Y.jsx)(`br`,{},t);case`img`:{let e=n.getAttribute(`alt`);return(0,Y.jsxs)(`span`,{className:`italic text-fg-secondary`,children:[`[`,e?`image: ${e}`:`image`,`]`]},t)}case`field`:{let e=n.getAttribute(`path`)??``;return(0,Y.jsxs)(`span`,{className:`rounded bg-bg-tertiary px-1 py-0.5 text-fg-brand-primary`,children:[`@`,e]},t)}default:return(0,Y.jsx)(b.Fragment,{children:r},t)}}function E2e(e){if(!C2e.test(e))return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e});let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`);return(0,Y.jsx)(Y.Fragment,{children:w2e(t.body.childNodes)})}function D2e({doc:e}){return(0,Y.jsx)(Y.Fragment,{children:e.map((e,t)=>N9(e,t))})}function N9(e,t){switch(e.tag){case`p`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.children.map((e,t)=>P9(e,t))},t);case`h1`:return(0,Y.jsx)(`h1`,{className:`text-base font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`h2`:return(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`h3`:return(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.children.map((e,t)=>P9(e,t))},t);case`blockquote`:return(0,Y.jsx)(`blockquote`,{className:`border-l-2 border-border-primary pl-2 italic`,children:e.children.map((e,t)=>N9(e,t))},t);case`ul`:return(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:e.children.map((e,t)=>(0,Y.jsx)(`li`,{children:e.children.map((e,t)=>N9(e,t))},t))},t);case`ol`:return(0,Y.jsx)(`ol`,{className:`list-decimal pl-5`,children:e.children.map((e,t)=>(0,Y.jsx)(`li`,{children:e.children.map((e,t)=>N9(e,t))},t))},t)}}function P9(e,t){if(typeof e==`string`)return e;if(e.tag===`br`)return(0,Y.jsx)(`br`,{},t);if(e.tag===`span`){let n=e.children[0];for(let r of e.styles)r===`bold`?n=(0,Y.jsx)(`strong`,{children:n},t):r===`italic`?n=(0,Y.jsx)(`em`,{children:n},t):r===`line-through`?n=(0,Y.jsx)(`del`,{children:n},t):r===`code`&&(n=(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.85em]`,children:n},t));return(0,Y.jsx)(b.Fragment,{children:n},t)}return e.tag===`img`?e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.alt??``,className:`inline-block max-h-16 rounded border border-border-primary align-baseline mx-0.5`},t):(0,Y.jsxs)(`span`,{className:`italic text-fg-secondary`,children:[`[`,e.alt?`image: ${e.alt}`:`image`,`]`]},t):e.tag===`field_ref`?(0,Y.jsxs)(`span`,{className:`rounded bg-bg-tertiary px-1 py-0.5 text-fg-brand-primary`,children:[`@`,e.path]},t):null}function O2e(e){return typeof e==`string`?[]:e.filter(e=>e.type===`image_url`).map(e=>e.url)}var k2e=(0,b.forwardRef)(function({onCancel:e,models:t,selectedModel:n,onSelectModel:r,onSendMessage:i,onUploadFile:a,onNewSession:o,suggestions:s=b2e,className:c,isConnected:l,authError:u,unavailable:d,mode:f,sessions:p,currentSessionId:m,onLoadSession:h,onFetchSessions:g,onSetSessionName:_,isLoadingSession:v,onAnswerToolQuestions:y,onCancelToolQuestion:x,initialMessages:S,chatEditorRef:C},w){let[T,E]=(0,b.useState)(S??[]),[D,O]=(0,b.useState)(null),[k,A]=(0,b.useState)(!0),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)([]),L=(0,b.useRef)(null),R=(0,b.useRef)(null),ee=C??R,te=(0,b.useRef)(null),[ne,re]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(null),[oe,se]=(0,b.useState)(``),ce=bb(),le=eb(),ue=ce?.ai?.chat?.suggestions??s,de=ce?.ai?.chat?.title,fe=ce?.ai?.chat?.description,pe=D?[...T,D.message]:T;(0,b.useEffect)(()=>{requestAnimationFrame(()=>{te.current?.scrollIntoView({block:`end`})})},[pe]),(0,b.useEffect)(()=>{D&&P(!1)},[D]);let me=(D?.message.toolActivities??[]).some(A9),he=(0,b.useCallback)((e,t)=>{O(n=>{if(!n)return null;if(e!==null&&n.message.id!==e)return n;let r=t(n.message);return E(e=>e.some(e=>e.id===r.id)?e:[...e,r]),null})},[]),ge=(0,b.useCallback)(e=>({...e,status:`error`,error:`Response timed out`}),[]);(0,b.useEffect)(()=>{if(!D||me)return;let e=12e4-(Date.now()-D.startedAt);if(e<=0){he(D.message.id,ge);return}let t=setTimeout(()=>{he(null,ge)},e);return()=>clearTimeout(t)},[D,me,he,ge]);let _e=(0,b.useCallback)((e,t,n)=>{let r=e=>({...e,toolActivities:(e.toolActivities??[]).map(e=>e.toolCallId===t?n(e):e)});O(t=>!t||t.message.id!==e?t:{message:r(t.message),startedAt:Date.now()}),E(t=>t.some(t=>t.id===e)?t.map(t=>t.id===e?r(t):t):t)},[]),ve=(0,b.useCallback)((e,t,n)=>{_e(e,t,e=>({...e,status:`complete`,answers:n}))},[_e]),ye=(0,b.useCallback)((e,t)=>{_e(e,t,e=>({...e,status:`error`,cancelled:!0}))},[_e]);(0,b.useImperativeHandle)(w,()=>({startAssistantMessage(e){O({message:{id:e,role:`assistant`,content:``,status:`streaming`},startedAt:Date.now()})},appendAssistantChunk(e,t){O(n=>n?.message.id===e?{...n,message:{...n.message,content:M9(n.message.content)+t}}:n)},completeAssistantMessage(e){he(e,e=>({...e,status:`complete`}))},errorAssistantMessage(e,t,n,r,i){he(e,e=>({...e,status:`error`,error:t,errorAction:r,errorCode:n,errorDetails:i}))},addToolCall(e,t,n,r){let i={toolCallId:t,name:n,status:`pending`,...r?{questions:r}:{}};O(t=>t&&t.message.id===e?{...t,message:{...t.message,toolActivities:[...t.message.toolActivities??[],i]}}:t)},completeToolCall(e,t){O(n=>!n||n.message.id!==e?n:{...n,message:{...n.message,toolActivities:(n.message.toolActivities??[]).map(e=>e.toolCallId===t?{...e,status:`complete`}:e)}})},errorToolCall(e,t){O(n=>!n||n.message.id!==e?n:{...n,message:{...n.message,toolActivities:(n.message.toolActivities??[]).map(e=>e.toolCallId===t?{...e,status:`error`}:e)}})},clearMessages(){E([]),O(null)},loadMessages(e){O(null),E(e)}}));let be=D!==null,xe=F.some(e=>e.status===`uploading`),Se=pe.length===0,Ce=(0,b.useCallback)(e=>{let t=Array.from(e.target.files??[]);if(t.length===0)return;e.target.value=``;let n=t.map(e=>({id:crypto.randomUUID(),file:e,status:`uploading`,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0}));I(e=>[...e,...n]),a&&n.forEach(e=>{a(e.file).then(({key:t})=>{I(n=>n.map(n=>n.id===e.id?{...n,status:`done`,key:t}:n))}).catch(t=>{console.error(`Failed to upload file`,{fileName:e.file.name,error:t}),I(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))})})},[a]),we=(0,b.useCallback)(e=>{I(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),z=(0,b.useCallback)(e=>{if(be)return;let t,n,r;if(e!==void 0){let r=e.trim();if(!r)return;t=r,n=r}else{let e=ee.current;if(!e||e.isEmpty())return;let i=e.getDocument();if(u2e(i).some(e=>e.startsWith(`pending:`)))return;t=i,r=i,n=o2e(i)}let a=F.filter(e=>e.status===`done`&&e.key!==void 0).map(e=>({key:e.key,name:e.file.name,mimeType:e.file.type||void 0,previewUrl:e.previewUrl}));F.forEach(e=>{e.previewUrl&&e.status!==`done`&&URL.revokeObjectURL(e.previewUrl)}),I([]);let o=S2e(),s={id:o,role:`user`,content:n,status:`complete`,attachments:a.length>0?a:void 0,userDoc:r};E(e=>[...e,s]),e===void 0&&(ee.current?.clear(),A(!0)),!i||i(t,a.length>0?a:void 0)?P(!0):E(e=>e.map(e=>e.id===o?{...e,status:`error`,error:`Failed to send`}:e)),requestAnimationFrame(()=>ee.current?.focus())},[be,F,i,ee]),B=(0,b.useCallback)(e=>{let t=pe.find(t=>t.id===e);if(t?.role===`user`){E(t=>t.map(t=>t.id===e?{...t,status:`complete`,error:void 0}:t));let n=t.userDoc??M9(t.content);!i||i(n,t.attachments)?P(!0):E(t=>t.map(t=>t.id===e?{...t,status:`error`,error:`Failed to send`}:t));return}let n=pe.findIndex(t=>t.id===e);if(n<=0)return;let r=pe.slice(0,n).reverse().find(e=>e.role===`user`);if(!r)return;E(t=>t.filter(t=>t.id!==e));let a=r.userDoc??M9(r.content);(i?.(a,r.attachments)??!0)&&P(!0)},[pe,i]);return(0,Y.jsxs)(`div`,{className:X(`flex flex-col h-full w-full bg-bg-primary text-fg-primary relative overflow-hidden`,c),children:[(!Se||g)&&(0,Y.jsxs)(`div`,{className:`shrink-0 flex justify-between items-center p-2 border-b border-border-primary`,children:[(0,Y.jsx)(`div`,{children:g&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{g(),re(!0)},className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Ay,{className:`h-3 w-3`}),`History`]})}),(0,Y.jsx)(`div`,{children:!Se&&o&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:o,disabled:be,className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Oy,{className:`h-3 w-3`}),`New chat`]})})]}),ne&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 z-overlay flex flex-col bg-bg-primary`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 p-2 border-b border-border-primary`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:()=>{re(!1),ae(null)},"aria-label":`Back to chat`,children:(0,Y.jsx)(Lv,{className:`h-4 w-4`})}),(0,Y.jsx)(`span`,{className:`text-sm font-medium flex-1`,children:`Chat history`}),o&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{o(),re(!1)},className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Oy,{className:`h-3 w-3`}),`New chat`]})]}),(0,Y.jsx)(eD,{className:`flex-1 min-h-0`,children:!p||p.length===0?(0,Y.jsx)(`div`,{className:`p-6 text-center text-sm text-fg-secondary`,children:`No previous sessions`}):(0,Y.jsx)(`div`,{className:`flex flex-col divide-y divide-border-primary`,children:p.map(e=>{let t=e.id===m,n=ie===e.id,r=e.name??`Chat, ${new Date(e.updatedAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}`;return(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 px-3 py-2.5 group`,t&&`bg-bg-secondary`),children:[n?(0,Y.jsx)(`input`,{autoFocus:!0,className:`flex-1 text-sm bg-bg-primary border border-border-primary rounded px-2 py-0.5 focus:outline-none focus:ring-1 focus:ring-border-focus`,value:oe,onChange:e=>se(e.target.value),onKeyDown:t=>{if(t.key===`Enter`){let t=oe.trim();t&&_&&_(e.id,t),ae(null)}else t.key===`Escape`&&ae(null)},onBlur:()=>{let t=oe.trim();t&&_&&_(e.id,t),ae(null)}}):(0,Y.jsx)(`button`,{className:`flex-1 text-left text-sm truncate`,onClick:()=>{h?.(e.id),re(!1)},children:r}),!n&&(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,className:`opacity-0 group-hover:opacity-100 shrink-0`,onClick:t=>{t.stopPropagation(),se(e.name??``),ae(e.id)},"aria-label":`Rename session`,children:(0,Y.jsx)(Dy,{className:`h-3 w-3`})})]},e.id)})})})]}),(0,Y.jsx)(eD,{className:`flex-1 min-h-0`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 min-w-0 max-w-full`,children:[u?(0,Y.jsx)(j2e,{mode:f}):v&&Se?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-12 text-fg-secondary`,children:[(0,Y.jsx)(hy,{className:`h-5 w-5 animate-spin`}),(0,Y.jsx)(`span`,{className:`text-sm`,children:`Loading conversation…`})]}):Se?(0,Y.jsx)(M2e,{suggestions:ue,title:de,description:fe,onSelect:e=>z(e)}):pe.map(e=>(0,Y.jsx)(N2e,{message:e,onRetry:B,onSubmitToolAnswers:(t,n)=>{ve(e.id,t,n),y?.(t,n)},onCancelToolQuestion:t=>{ye(e.id,t),x?.(t)}},e.id)),N&&!D&&(0,Y.jsx)(I2e,{}),(0,Y.jsx)(`div`,{ref:te})]})}),(0,Y.jsx)(`div`,{className:`shrink-0 border-t border-border-primary bg-bg-primary p-3`,children:d&&!u?(0,Y.jsx)(A2e,{...d}):(0,Y.jsxs)(Y.Fragment,{children:[!l&&!u&&(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-1.5 rounded-md border border-border-primary bg-bg-secondary px-2 py-1.5 text-xs touch:text-sm text-fg-secondary`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),`Connecting…`]}),F.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:F.map(e=>(0,Y.jsxs)(`div`,{className:`relative flex items-center gap-1.5 rounded-md border border-border-primary bg-bg-secondary px-2 py-1 text-xs touch:text-sm text-fg-primary`,children:[e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.file.name,className:`h-8 w-8 rounded object-cover`}):(0,Y.jsx)($v,{className:`h-4 w-4 shrink-0 text-fg-secondary`}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.file.name}),e.status===`uploading`&&(0,Y.jsx)(hy,{className:`h-3 w-3 animate-spin text-fg-secondary`}),e.status===`error`&&(0,Y.jsx)(Uv,{className:`h-3 w-3 text-fg-error-primary`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>we(e.id),className:`ml-0.5 text-fg-secondary hover:text-fg-primary`,"aria-label":`Remove ${e.file.name}`,children:(0,Y.jsx)(Hy,{className:`h-3 w-3`})})]},e.id))}),a&&(0,Y.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`hidden`,onChange:Ce,accept:`image/*`}),(0,Y.jsxs)(`div`,{className:X(`flex flex-col rounded-md border border-border-primary bg-bg-primary`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-border-focus`),children:[(0,Y.jsx)(Z0e,{ref:ee,disabled:u||!l||be,placeholder:l&&!u?`Ask something…`:``,onSubmit:()=>z(),onUploadAiImage:a,getPortalContainer:()=>le,onChange:e=>{let t=e.length===0||e.length===1&&e[0].tag===`p`&&e[0].children.length===0;A(t);let n=u2e(e);M(n.some(e=>e.startsWith(`pending:`)))},className:X(`max-h-[18rem] overflow-y-auto px-3 pt-3 pb-1`,`text-fg-primary text-base`)}),(0,Y.jsxs)(`div`,{className:`flex items-center border-t border-border-primary px-2 py-1.5`,children:[a&&(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,disabled:!l||be||u,onClick:()=>L.current?.click(),"aria-label":`Attach files`,children:(0,Y.jsx)(Ey,{className:`h-4 w-4`})}),t&&t.length>1&&r&&(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,disabled:be,className:`h-7 px-2 text-xs text-fg-secondary gap-1`,"aria-label":F9(t,n)===P2e?`Choose a model`:`Change model, currently ${F9(t,n)}`,children:[F9(t,n),(0,Y.jsx)(Iv,{className:`h-3 w-3`})]})}),(0,Y.jsx)(j3,{align:`start`,className:`max-h-72 overflow-y-auto`,children:t.map(e=>{let t=n?.provider===e.ref.provider&&n?.model===e.ref.model;return(0,Y.jsxs)(M3,{onSelect:()=>r(e.ref),className:`text-xs`,children:[(0,Y.jsx)(Fv,{className:X(`h-3 w-3 mr-2`,t?`opacity-100`:`opacity-0`)}),e.label]},`${e.ref.provider}:${e.ref.model}`)})})]}),be&&e?(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:e,"aria-label":`Stop generating`,title:`Stop generating`,className:`ml-auto`,children:(0,Y.jsx)(jae,{className:`h-3.5 w-3.5 fill-current`})}):(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,disabled:!l||be||xe||j||u||k,onClick:()=>z(),"aria-label":`Send message`,className:`ml-auto`,children:(0,Y.jsx)(Cae,{className:`h-4 w-4`})})]})]})]})})]})});function A2e({message:e,onRetry:t}){return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-primary bg-bg-secondary p-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Ly,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-fg-error-primary`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-fg-primary`,children:`The assistant is unavailable`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[0.6875rem] text-fg-secondary`,children:e})]})]}),(0,Y.jsx)(t_,{variant:`outline`,size:`sm`,onClick:t,className:`mt-2 text-xs`,children:`Try again`})]})}function j2e({mode:e}){let t=e===`fs`;return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 py-12 text-center`,children:[(0,Y.jsx)(`div`,{className:`rounded-full bg-bg-secondary p-3`,children:(0,Y.jsx)(_y,{className:`h-6 w-6`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:`Login to use AI chat`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:t?`Val is running in development mode. Run this command in your project root to create a personal access token, then refresh:`:`Your session has expired. Sign in again to continue.`})]}),t?(0,Y.jsx)(`div`,{className:`w-full text-left`,children:(0,Y.jsx)(E5,{code:`npx -p @valbuild/cli val login`})}):(0,Y.jsx)(t_,{asChild:!0,variant:`default`,size:`sm`,children:(0,Y.jsxs)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.location.href}),children:[(0,Y.jsx)(_y,{className:`mr-2 h-4 w-4`}),`Sign in`]})})]})}function M2e({suggestions:e,title:t,description:n,onSelect:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-6 py-16 text-center`,children:[(0,Y.jsx)(`div`,{className:`rounded-full p-3`,children:(0,Y.jsx)(Ny,{className:`h-8 w-8`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:t??`How can I help?`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:n??`Ask me anything or pick a suggestion below`})]}),e.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>r(e),className:`text-sm`,children:e},e))})]})}function N2e({message:e,onRetry:t,onSubmitToolAnswers:n,onCancelToolQuestion:r}){let i=e.role===`user`,a=e.status===`error`,o=e.status===`streaming`,s=e.toolActivities??[],c=s.some(A9),l=s.some(e=>e.status===`pending`&&e.questions===void 0),u=M9(e.content),d=O2e(e.content),{hasBubble:f,showCursor:p}=y2e({isUser:i,isError:a,isStreaming:o,hasText:u.length>0,hasFiles:d.length>0,hasRunningTool:l,hasPendingQuestion:c});return(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1.5 min-w-0`,i?`items-end`:`items-stretch`),children:[!i&&s.length>0&&(0,Y.jsx)(p2e,{activities:s,onSubmitAnswers:n,onCancel:r}),f&&(0,Y.jsxs)(`div`,{className:X(`min-w-0 overflow-hidden rounded-lg px-4 py-2.5 text-sm touch:text-base leading-relaxed`,`[overflow-wrap:anywhere]`,i?`bg-bg-secondary text-fg-primary max-w-[80%]`:`bg-bg-tertiary text-fg-primary w-full max-w-full`,a&&`border border-border-error-primary`),children:[i?(0,Y.jsxs)(Y.Fragment,{children:[e.attachments&&e.attachments.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-1.5`,children:e.attachments.map(e=>e.mimeType?.startsWith(`image/`)&&e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`h-16 w-16 rounded object-cover`},e.key):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded border border-border-primary bg-bg-primary px-2 py-1 text-xs text-fg-secondary`,children:[(0,Y.jsx)($v,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.key))}),d.length>0&&(0,Y.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:d.map(e=>(0,Y.jsx)(`img`,{src:e,alt:`Session attachment`,className:`max-h-48 rounded object-contain`},e))}),e.userDoc?(0,Y.jsx)(D2e,{doc:e.userDoc}):u&&E2e(u)]}):(0,Y.jsxs)(`div`,{className:X(`prose prose-sm dark:prose-invert max-w-none`,`[&_pre]:overflow-x-auto [&_pre]:max-w-full`,`[&_code]:break-words`,`[&_table]:block [&_table]:overflow-x-auto [&_table]:max-w-full`,`[&_a]:break-all`),children:[d.length>0&&(0,Y.jsx)(`div`,{className:`not-prose mb-3 flex flex-wrap gap-2`,children:d.map(e=>(0,Y.jsx)(`img`,{src:e,alt:`AI session image`,className:`max-h-64 rounded border border-border-primary object-contain`},e))}),u?(0,Y.jsx)(_0e,{children:u}):o||a||d.length>0||c?null:(0,Y.jsx)(`p`,{className:`text-fg-secondary italic`,children:`Empty response`}),p&&(0,Y.jsx)(F2e,{})]}),a&&(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-fg-error-primary`,children:e.error??`Something went wrong`}),e.errorAction&&S0e(e.errorAction.url)&&(0,Y.jsx)(`a`,{href:S0e(e.errorAction.url),target:`_blank`,rel:`noreferrer noopener`,className:`text-xs text-fg-brand-primary underline`,children:e.errorAction.label}),e.errorDetails&&(0,Y.jsxs)(`details`,{className:`text-xs text-fg-secondary`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Y.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-bg-secondary p-2 font-mono text-[11px] text-fg-secondary`,children:e.errorDetails})]})]}),(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:()=>t(e.id),"aria-label":`Retry`,className:`h-6 w-6`,children:(0,Y.jsx)(xae,{className:`h-3.5 w-3.5 text-fg-error-primary`})})]})]})]})}var P2e=`Model`;function F9(e,t){return(t?e.find(e=>e.ref.provider===t.provider&&e.ref.model===t.model):void 0)?.label??P2e}function F2e(){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 ml-1 align-middle`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`150ms`}}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`300ms`}})]})}function I2e(){return(0,Y.jsx)(`div`,{className:`flex justify-start`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg bg-bg-tertiary px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`150ms`}}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`300ms`}})]})})}function L2e(){let e=nb();return{query:(0,b.useCallback)(async(t,n,r)=>{if(e===null)return;let i=await e.system.search(t,n,r);return i.status===`no-index`?{results:[],total:0}:{results:i.results,total:i.total}},[e])}}function R2e(){let e=Fb();return{getErrors:(0,b.useCallback)(()=>{let t=e??{},n=new Map;for(let e in t){let r=e,[i]=H.splitModuleFilePathAndModulePath(r),a=t[r]??[],o={sourcePath:e,messages:a.map(e=>e.message)};a.some(e=>e.typeError)&&(o.typeError=!0),a.some(e=>e.schemaError)&&(o.schemaError=!0),a.some(e=>e.keyError)&&(o.keyError=!0);let s=n.get(i)??[];s.push(o),n.set(i,s)}return Array.from(n.entries()).map(([e,t])=>({modulePath:e,errors:t}))},[e])}}var I9=`_tag`;function L9(e){if(typeof e!=`object`||!e)return!1;let t=e;return!(t._type!==`ai_session_file`||t[I9]!==`image`&&t[I9]!==`file`||typeof t.key!=`string`||typeof t.filePath!=`string`)}function z2e(e){return JSON.parse(JSON.stringify(e))}function B2e(e,t,n){if(t.length===0)return{ok:!1,reason:`cannot set at empty path`};let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(Array.isArray(r)){let i=Number(n);if(!Number.isInteger(i)||i<0||i>=r.length)return{ok:!1,reason:`index out of bounds at ${t.slice(0,e+1).join(`/`)}`};r=r[i]}else if(r&&typeof r==`object`)r=r[n];else return{ok:!1,reason:`cannot descend into non-object at ${t.slice(0,e+1).join(`/`)}`}}let i=t[t.length-1];if(Array.isArray(r)){let e=Number(i);return Number.isInteger(e)?(r[e]=n,{ok:!0}):{ok:!1,reason:`expected numeric index at ${t.join(`/`)}`}}return r&&typeof r==`object`?(r[i]=n,{ok:!0}):{ok:!1,reason:`cannot set on non-object at ${t.join(`/`)}`}}function V2e(e,t,n){let r=(e,i)=>{if(L9(e)){n(i);return}if(Array.isArray(e)){e.forEach((e,t)=>r(e,[...i,String(t)]));return}if(e&&typeof e==`object`){let n=e;if(n.tag===`img`&&L9(n.src)){for(let[e,t]of Object.entries(n))e!==`src`&&r(t,[...i,e]);t(n.src,[...i,`src`]);return}for(let[e,t]of Object.entries(n))r(t,[...i,e])}};r(e,[])}function R9(e){return L9(e)?!0:Array.isArray(e)?e.some(R9):e&&typeof e==`object`?Object.values(e).some(R9):!1}function H2e(e,t){let n=e?{...e}:{};return t[I9]===`image`&&(t.alt!==void 0&&(n.alt=t.alt),t.hotspot!==void 0&&(n.hotspot=t.hotspot)),n}function U2e(e){let{patch:t,moduleSchema:n}=e,r=[];for(let e=0;e<t.length;e++){let i=t[e];if(i.op===`file`)return{kind:`error`,message:`Patch op #${e} is a 'file' op — those are emitted by the system, not by create_patch input.`};if(i.op===`remove`||i.op===`move`||i.op===`copy`)continue;if(i.op===`test`){if(R9(i.value))return{kind:`error`,message:`Patch op #${e} ('test') cannot contain a SessionKey.`};continue}let a=i.path,o=Ep(n,a);if(o.kind===`unresolved`){if(R9(i.value))return{kind:`error`,message:`Patch op #${e} contains a SessionKey but the path ${JSON.stringify(a)} could not be resolved against the module schema.`};continue}if(o.kind===`gallery-traversed`){if(R9(i.value))return{kind:`wrong-tool`,suggestedTool:`add_session_image_to_gallery`,reason:`Patch op #${e} targets an images gallery (s.images()) with a SessionKey. Galleries use file paths as keys; use add_session_image_to_gallery instead.`};continue}if(o.kind===`leaf`){let t=o.schema,n=L9(i.value);if(t.type===`image`||t.type===`file`){if(n){let n=i.value;if(n[I9]!==t.type)return{kind:`error`,message:`Patch op #${e}: SessionKey _tag is '${n[I9]}' but the schema is '${t.type}'.`};r.push({kind:`leaf`,opIndex:e,opPath:a,subtype:t.type,remote:Op(t),sessionKey:n});continue}if(R9(i.value))return{kind:`error`,message:`Patch op #${e}: SessionKey nested inside a non-SessionKey value at an ${t.type} field. Place the SessionKey directly as the value.`};continue}if(R9(i.value))return{kind:`error`,message:`Patch op #${e}: SessionKey is not allowed at a '${t.type}' field.`};continue}let s=Dp(o.schema),c=0,l=null;if(V2e(i.value,(t,n)=>{r.push({kind:`inline-img`,opIndex:e,opPath:a,valuePath:n,remote:s.kind===`allowed`&&s.remote,sessionKey:t}),c+=1},e=>{l===null&&(l=e)}),l)return{kind:`error`,message:`Patch op #${e}: SessionKey at value path ${JSON.stringify(l)} is not inside a {tag:"img", src: ...} node.`};if(c>0&&s.kind===`not-allowed`)return{kind:`error`,message:`Patch op #${e} inserts an inline image into a richtext that does not allow inline images (options.img is not enabled).`}}return{kind:`ok`,transfers:r.map((e,t)=>({siteId:t,key:e.sessionKey.key,filePath:e.sessionKey.filePath,isRemote:e.remote})),apply:e=>{if(r.length===0)return{kind:`ok`,patch:t};let n=t.map(e=>z2e(e)),i=[];for(let t=0;t<r.length;t++){let a=r[t],o=H2e(e[t],a.sessionKey),s=wp(a.sessionKey.filePath,o);if(a.kind===`leaf`){let e=n[a.opIndex];e.value=s,i.push({op:`file`,path:a.opPath,filePath:a.sessionKey.filePath,value:a.sessionKey.key,remote:a.remote,metadata:o})}else{let e=n[a.opIndex];if(a.valuePath.length===0)e.value=s;else{let t=B2e(e.value,a.valuePath,s);if(!t.ok)return{kind:`error`,message:`Failed to rewrite SessionKey at op #${a.opIndex}, value path ${JSON.stringify(a.valuePath)}: ${t.reason}`}}i.push({op:`file`,path:a.opPath,nestedFilePath:a.valuePath,filePath:a.sessionKey.filePath,value:a.sessionKey.key,remote:a.remote,metadata:o})}}let a=[...n,...i],o=Jd.safeParse(a);return o.success?{kind:`ok`,patch:o.data}:{kind:`error`,message:`Rewritten patch failed schema validation: ${JSON.stringify(o.error)}`}}}}async function W2e(e){let t=U2e({patch:e.patch,moduleSchema:e.moduleSchema,moduleSource:e.moduleSource});if(t.kind!==`ok`)return t;let n={};if(t.transfers.length>0){let r=e=>`${e.isRemote?`1`:`0`}${e.filePath}${e.key}`,i=[],a=new Map;for(let e of t.transfers){let t=r(e);a.has(t)||(a.set(t,i.length),i.push({filePath:e.filePath,key:e.key,isRemote:e.isRemote}))}let o=await e.transfer({patchId:e.patchId,parentRef:e.parentRef,files:i});if(o.files.length!==i.length)return{kind:`error`,message:`Session image transfer returned ${o.files.length} results for ${i.length} files.`};for(let e of t.transfers){let t=a.get(r(e));if(t===void 0)return{kind:`error`,message:`Internal error: missing transfer index for site ${e.siteId}.`};n[e.siteId]=o.files[t].metadata}}let r=t.apply(n);return r.kind===`error`?{kind:`error`,message:r.message}:{kind:`ok`,patch:r.patch}}var G2e=new qr,K2e={name:`get_all_schema`,description:`Get all val schemas — returns the complete schema definitions for all val modules`,parameters:{type:`object`,properties:{},required:[]}},q2e={name:`get_source`,description:`Get the current source content of a Val module by its file path. The 'module_file_path' must exactly match one of the keys returned by get_all_schema.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/homepage.val.ts'. Can be obtained from the keys of get_all_schema.`}},required:[`module_file_path`]}},J2e={name:`search_content`,description:`Search content — accepts a query and returns matching content items. Returns { results, total } where total is the number of matches found. Use offset to page through results if total exceeds the returned results count.`,parameters:{type:`object`,properties:{query:{type:`string`,description:`The search query`},limit:{type:`number`,description:`Max results to return (default 50)`},offset:{type:`number`,description:`Number of results to skip for pagination (default 0)`}},required:[`query`]}},Y2e={name:`validate_content`,description:`Get all current validation errors — returns a list of modules with their validation errors, grouped by module path`,parameters:{type:`object`,properties:{},required:[]}},X2e={name:`create_patch`,description:`Create a Val patch — applies JSON Patch operations to a Val module.
|
|
253
|
+
`}),n}function B1e(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function V1e(e,t){let n=F1e(e,t),r=n.one(e,void 0),i=S1e(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
254
|
+
`},i)),a}function H1e(e,t){return e&&`run`in e?async function(n,r){let i=V1e(n,{file:r,...t});await e.run(i,r)}:function(n,r){return V1e(n,{file:r,...e||t})}}function U1e(e){if(e)throw e}var W1e=s(((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 o9(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 G1e(){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?K1e(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 K1e(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 s9={basename:q1e,dirname:J1e,extname:Y1e,join:X1e,sep:`/`};function q1e(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);c9(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 J1e(e){if(c9(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 Y1e(e){c9(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 X1e(...e){let t=-1,n;for(;++t<e.length;)c9(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:Z1e(n)}function Z1e(e){c9(e);let t=e.codePointAt(0)===47,n=Q1e(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function Q1e(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 c9(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var $1e={cwd:e0e};function e0e(){return`/`}function l9(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function t0e(e){if(typeof e==`string`)e=new URL(e);else if(!l9(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 n0e(e)}function n0e(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 u9=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],r0e=class{constructor(e){let t;t=e?l9(e)?{path:e}:typeof e==`string`||a0e(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:$1e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<u9.length;){let e=u9[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)u9.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?s9.basename(this.path):void 0}set basename(e){f9(e,`basename`),d9(e,`basename`),this.path=s9.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?s9.dirname(this.path):void 0}set dirname(e){i0e(this.basename,`dirname`),this.path=s9.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?s9.extname(this.path):void 0}set extname(e){if(d9(e,`extname`),i0e(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=s9.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){l9(e)&&(e=t0e(e)),f9(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?s9.basename(this.path,this.extname):void 0}set stem(e){f9(e,`stem`),d9(e,`stem`),this.path=s9.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 g7(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 d9(e,t){if(e&&e.includes(s9.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+s9.sep+"`")}function f9(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function i0e(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function a0e(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var o0e=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),p9=u(W1e(),1),s0e={}.hasOwnProperty,c0e=new class e extends o0e{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=G1e()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,p9.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(g9(`data`,this.frozen),this.namespace[e]=t,this):s0e.call(this.namespace,e)&&this.namespace[e]||void 0:e?(g9(`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=_9(e),n=this.parser||this.Parser;return m9(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),m9(`process`,this.parser||this.Parser),h9(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=_9(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);f0e(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(),m9(`processSync`,this.parser||this.Parser),h9(`processSync`,this.compiler||this.Compiler),this.process(e,r),u0e(`processSync`,`process`,t),n;function r(e,r){t=!0,U1e(e),n=r}}run(e,t,n){l0e(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=_9(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),u0e(`runSync`,`run`,n),r;function i(e,t){U1e(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=_9(t),r=this.compiler||this.Compiler;return h9(`stringify`,r),l0e(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(g9(`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,p9.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];o9(o)&&o9(r)&&(r=(0,p9.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function m9(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function h9(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function g9(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 l0e(e){if(!o9(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function u0e(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function _9(e){return d0e(e)?e:new r0e(e)}function d0e(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function f0e(e){return typeof e==`string`||p0e(e)}function p0e(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var m0e=[],h0e={allowDangerousHtml:!0},g0e=/^(https?|ircs?|mailto|xmpp)$/i,_0e=[{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 v0e(e){let t=y0e(e),n=b0e(e);return x0e(t.runSync(t.parse(n),n),e)}function y0e(e){let t=e.rehypePlugins||m0e,n=e.remarkPlugins||m0e,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...h0e}:h0e;return c0e().use(F$e).use(n).use(H1e,r).use(t)}function b0e(e){let t=e.children||``,n=new r0e;return typeof t==`string`?n.value=t:``+t,n}function x0e(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||S0e;for(let e of _0e)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return N1e(e,l),GXe(e,{Fragment:Y.Fragment,components:i,ignoreInvalidStyle:!0,jsx:Y.jsx,jsxs:Y.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 T7)if(Object.hasOwn(T7,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=T7[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 S0e(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||g0e.test(e.slice(0,t))?e:``}function C0e(e){if(e.startsWith(`/`)&&!e.startsWith(`//`))return e;let t;try{t=new URL(e)}catch{return}return t.protocol===`https:`||t.protocol===`http:`?e:void 0}function w0e(){return{doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`},{tag:`h4`},{tag:`h5`},{tag:`h6`}],toDOM(){return[`p`,0]}},text:{group:`inline`},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}},heading:{attrs:{level:{default:1}},content:`inline*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}}],toDOM(e){return[`h${e.attrs.level}`,0]}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return[`blockquote`,0]}},list_item:{content:`paragraph block*`,parseDOM:[{tag:`li`}],toDOM(){return[`li`,0]},defining:!0},bullet_list:{content:`list_item+`,group:`block`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}},ordered_list:{attrs:{order:{default:1}},content:`list_item+`,group:`block`,parseDOM:[{tag:`ol`,getAttrs(e){let t=e;return{order:t.hasAttribute(`start`)?+(t.getAttribute(`start`)||1):1}}}],toDOM(e){return e.attrs.order===1?[`ol`,0]:[`ol`,{start:e.attrs.order},0]}},image:{inline:!0,atom:!0,attrs:{key:{default:``},alt:{default:null},previewUrl:{default:null},width:{default:null},height:{default:null},mimeType:{default:null}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[data-val-ai-key]`,getAttrs(e){let t=e;return{key:t.getAttribute(`data-val-ai-key`)||``,alt:t.getAttribute(`alt`),previewUrl:t.getAttribute(`src`)}}}],toDOM(e){return[`img`,{src:e.attrs.previewUrl??``,alt:e.attrs.alt??``,"data-val-ai-key":e.attrs.key}]}},field_ref:{inline:!0,atom:!0,selectable:!0,draggable:!1,attrs:{path:{default:``}},group:`inline`,parseDOM:[{tag:`span[data-val-field-ref]`,getAttrs(e){return{path:e.getAttribute(`data-val-field-ref`)||``}}}],toDOM(e){return[`span`,{"data-val-field-ref":e.attrs.path,contenteditable:`false`,class:`inline-flex items-center align-baseline rounded bg-bg-secondary text-fg-primary px-1.5 py-0.5 text-xs font-mono mx-0.5`},e.attrs.path]}}}}function T0e(){let e={};return e.bold={parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=bold`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return[`strong`,0]}},e.italic={parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`}],toDOM(){return[`em`,0]}},e.strikethrough={parseDOM:[{tag:`s`},{tag:`del`},{style:`text-decoration=line-through`}],toDOM(){return[`del`,0]}},e.code={parseDOM:[{tag:`code`}],toDOM(){return[`code`,0]}},e}function E0e(){return new ZX({nodes:w0e(),marks:T0e()})}function D0e(e){let t={};t[`Mod-z`]=w0,t[`Mod-y`]=T0,t[`Mod-Shift-z`]=T0,t[`Mod-b`]=b2(e.marks.bold),t[`Mod-i`]=b2(e.marks.italic),t[`Mod-Shift-x`]=b2(e.marks.strikethrough),t[`Mod-e`]=b2(e.marks.code);let n=e.nodes.hard_break;t[`Shift-Enter`]=(e,t)=>(t&&t(e.tr.replaceSelectionWith(n.create()).scrollIntoView()),!0);for(let n=1;n<=3;n++)t[`Mod-Alt-${n}`]=y2(e.nodes.heading,{level:n});return t[`Mod-Alt-0`]=y2(e.nodes.paragraph),t[`Mod-Shift-b`]=v2(e.nodes.blockquote),t[`Mod-Shift-8`]=D2(e.nodes.bullet_list),t[`Mod-Shift-9`]=D2(e.nodes.ordered_list),t.Enter=O2(e.nodes.list_item),t[`Mod-[`]=k2(e.nodes.list_item),t[`Mod-]`]=A2(e.nodes.list_item),[O0(t),O0(E2)]}function v9(e,t,n){return new N2(e,(e,r,i,a)=>{let o=r[1];if(!o)return null;let s=r[0].length-(t.length*2+o.length);if(s<0)return null;let c=e.tr;return c.replaceWith(i+s,a,e.schema.text(o,[n.create()])),c.removeStoredMark(n),c})}function O0e(e){let t=[];return t.push(L2(/^(#{1,3})\s$/,e.nodes.heading,e=>({level:e[1].length}))),t.push(I2(/^\s*>\s$/,e.nodes.blockquote)),t.push(I2(/^\s*([-+*])\s$/,e.nodes.bullet_list)),t.push(I2(/^(\d+)\.\s$/,e.nodes.ordered_list,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order===+e[1])),t.push(v9(/\*\*([^*]+)\*\*$/,`**`,e.marks.bold)),t.push(v9(/(?:^|[^*])\*([^*]+)\*$/,`*`,e.marks.italic)),t.push(v9(/~~([^~]+)~~$/,`~~`,e.marks.strikethrough)),t.push(v9(/`([^`]+)`$/,"`",e.marks.code)),P2({rules:t})}var k0e=new CQ(`submitOnEnter`);function A0e(e,t){return new bQ({key:k0e,props:{handleKeyDown(n,r){if(r.key!==`Enter`)return!1;if(r.metaKey||r.ctrlKey)return r.preventDefault(),t(),!0;if(r.shiftKey)return!1;let{$from:i}=n.state.selection;for(let t=i.depth;t>0;t--)if(i.node(t).type===e.nodes.list_item)return!1;return r.preventDefault(),t(),!0}}})}function j0e(){return function(e,t,n){let r=document.createElement(`span`);r.className=`relative inline-block align-baseline mx-0.5`,r.style.lineHeight=`0`,r.contentEditable=`false`;let i=document.createElement(`img`);i.style.maxHeight=`64px`,i.style.borderRadius=`4px`,i.style.border=`1px solid var(--border-primary, #ddd)`,i.style.display=`inline-block`,i.style.verticalAlign=`baseline`;let a=e=>{i.src=e.attrs.previewUrl??``,i.alt=e.attrs.alt??``,i.setAttribute(`data-val-ai-key`,e.attrs.key??``);let t=e.attrs.key?.startsWith(`pending:`);r.style.opacity=t?`0.6`:`1`};a(e);let o=document.createElement(`button`);return o.type=`button`,o.textContent=`×`,o.setAttribute(`aria-label`,`Remove image`),o.className=`absolute -top-1 -right-1 rounded-full bg-bg-primary border border-border-primary text-fg-secondary hover:text-fg-primary w-4 h-4 leading-none text-xs flex items-center justify-center`,o.addEventListener(`mousedown`,r=>{r.preventDefault(),r.stopPropagation();let i=n();i!==void 0&&(t.dispatch(t.state.tr.delete(i,i+e.nodeSize)),t.focus())}),r.appendChild(i),r.appendChild(o),{dom:r,update(t){return t.type===e.type&&(a(t),!0)},stopEvent(e){return e.type===`mousedown`},ignoreMutation(){return!0}}}}async function M0e(e,t=`pasted-image`){try{let n=await fetch(e,{credentials:`omit`,mode:`cors`});if(!n.ok)return null;let r=await n.blob();if(!r.type.startsWith(`image/`))return null;let i=r.type.split(`/`)[1]||`png`;return new File([r],`${t}.${i}`,{type:r.type})}catch{return null}}function y9(e,t,n){let r=e.state.schema.nodes.image;if(!r)return!1;let i=`pending:${crypto.randomUUID()}`,a=URL.createObjectURL(t),o=t.type||`image/*`,s=r.create({key:i,alt:``,previewUrl:a,mimeType:o}),{from:c}=e.state.selection;return e.dispatch(e.state.tr.insert(c,s)),n(t).then(({key:t})=>{e.state.doc.descendants((n,a)=>{if(n.type===r&&n.attrs.key===i){let r=e.state.tr.setNodeMarkup(a,void 0,{...n.attrs,key:t});return e.dispatch(r),!1}return!0})}).catch(t=>{console.error(`AI chat image upload failed`,t),e.state.doc.descendants((t,n)=>t.type===r&&t.attrs.key===i?(e.dispatch(e.state.tr.delete(n,n+t.nodeSize).setMeta(`addToHistory`,!1)),!1):!0),URL.revokeObjectURL(a)}),!0}function b9(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}function x9(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--)if(n.node(e).type===t)return!0;return!1}function N0e(e,t,n){let{state:r,dispatch:i}=e;return x9(r,t)?k2(n.nodes.list_item)(r,i):D2(t)(r,i)}function P0e(e){let{$from:t}=e.selection;if(t.parent.type.name===`heading`){let e=t.parent.attrs.level;if(e===1||e===2||e===3)return e}return null}function S9({active:e,onMouseDown:t,title:n,children:r,disabled:i}){return(0,Y.jsx)(`button`,{type:`button`,title:n,"aria-pressed":e,disabled:i,onMouseDown:t,className:(0,AC.default)(`flex h-7 w-7 items-center justify-center rounded text-fg-primary`,`hover:bg-bg-secondary disabled:opacity-50`,{"bg-bg-secondary":e}),children:r})}function F0e({view:e,schema:t,onUploadAiImage:n}){let[r,i]=(0,b.useState)(!1),{state:a}=e,o=P0e(a),s=o?`H${o}`:`P`,c=t=>n=>{n.preventDefault(),t(e.state),e.focus()};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsxs)(`button`,{type:`button`,title:`Block type`,onMouseDown:e=>{e.preventDefault(),i(e=>!e)},className:`flex h-7 items-center justify-center gap-1 rounded px-2 text-xs font-medium text-fg-primary hover:bg-bg-secondary`,children:[s,(0,Y.jsx)(Iv,{size:12})]}),r&&(0,Y.jsx)(`div`,{className:`absolute left-0 top-8 z-window min-w-[8em] rounded-md border border-border-primary bg-bg-primary shadow-md py-1`,children:[`P`,`H1`,`H2`,`H3`].map(n=>(0,Y.jsx)(`button`,{type:`button`,onMouseDown:r=>{if(r.preventDefault(),n===`P`)y2(t.nodes.paragraph)(e.state,e.dispatch,e);else{let r=parseInt(n[1],10);y2(t.nodes.heading,{level:r})(e.state,e.dispatch,e)}i(!1),e.focus()},className:`block w-full px-3 py-1 text-left text-xs hover:bg-bg-secondary`,children:n===`P`?`Paragraph`:`Heading ${n[1]}`},n))})]}),(0,Y.jsx)(`div`,{className:`mx-1 h-5 w-px bg-border-primary`}),(0,Y.jsx)(S9,{title:`Bold (Ctrl+B)`,active:b9(a,t.marks.bold),onMouseDown:c(n=>b2(t.marks.bold)(n,e.dispatch)),children:(0,Y.jsx)(Mv,{size:14})}),(0,Y.jsx)(S9,{title:`Italic (Ctrl+I)`,active:b9(a,t.marks.italic),onMouseDown:c(n=>b2(t.marks.italic)(n,e.dispatch)),children:(0,Y.jsx)(ly,{size:14})}),(0,Y.jsx)(S9,{title:`Strikethrough (Ctrl+Shift+X)`,active:b9(a,t.marks.strikethrough),onMouseDown:c(n=>b2(t.marks.strikethrough)(n,e.dispatch)),children:(0,Y.jsx)(Fy,{size:14})}),(0,Y.jsx)(S9,{title:`Inline code (Ctrl+E)`,active:b9(a,t.marks.code),onMouseDown:c(n=>b2(t.marks.code)(n,e.dispatch)),children:(0,Y.jsx)(Kv,{size:14})}),(0,Y.jsx)(`div`,{className:`mx-1 h-5 w-px bg-border-primary`}),(0,Y.jsx)(S9,{title:`Bullet list (Ctrl+Shift+8)`,active:x9(a,t.nodes.bullet_list),onMouseDown:n=>{n.preventDefault(),N0e(e,t.nodes.bullet_list,t),e.focus()},children:(0,Y.jsx)(my,{size:14})}),(0,Y.jsx)(S9,{title:`Numbered list (Ctrl+Shift+9)`,active:x9(a,t.nodes.ordered_list),onMouseDown:n=>{n.preventDefault(),N0e(e,t.nodes.ordered_list,t),e.focus()},children:(0,Y.jsx)(fy,{size:14})}),(0,Y.jsx)(S9,{title:`Blockquote (Ctrl+Shift+B)`,onMouseDown:n=>{n.preventDefault(),v2(t.nodes.blockquote)(e.state,e.dispatch),e.focus()},children:(0,Y.jsx)(yae,{size:14})}),n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`mx-1 h-5 w-px bg-border-primary`}),(0,Y.jsx)(S9,{title:`Insert image`,onMouseDown:t=>{t.preventDefault();let r=document.createElement(`input`);r.type=`file`,r.accept=`image/*`,r.onchange=()=>{let t=r.files?.[0];t&&y9(e,t,n)},r.click()},children:(0,Y.jsx)(sy,{size:14})})]})]})}var I0e=new CQ(`chatFloatingToolbar`);function L0e(e,t){let n=null,r=null;function i(i){if(!n||!r)return;let{selection:a}=i.state,{empty:o,from:s,to:c}=a;if(o||!i.hasFocus()){n.style.display=`none`;return}r.render((0,b.createElement)(F0e,{view:i,schema:e,onUploadAiImage:t?.getUploadAiImage?.()}));let l=t?.getPortalContainer?.();n.style.display=`flex`;let u=()=>{if(!n)return;let e=i.coordsAtPos(s),t=i.coordsAtPos(c),r=(e.left+t.left)/2,a=Math.min(e.top,t.top),o=Math.max(e.bottom,t.bottom),u=n.offsetWidth||220,d=n.offsetHeight||36,f=r-u/2,p=a-d-8;p<8&&(p=o+8);let m=window.innerWidth-u-8;if(f=Math.max(8,Math.min(f,m)),l)n.style.left=`${f}px`,n.style.top=`${p}px`;else{let e=i.dom.parentElement?.getBoundingClientRect();if(!e)return;n.style.left=`${f-e.left}px`,n.style.top=`${p-e.top}px`}};u(),requestAnimationFrame(u)}return new bQ({key:I0e,view(e){n=document.createElement(`div`);let a=t?.getPortalContainer?.();return n.className=[`${a?`fixed`:`absolute`} z-window flex items-center gap-x-0.5 rounded-md border border-border-primary`,`bg-bg-primary px-1 py-1 shadow-lg`].join(` `),n.style.display=`none`,n.setAttribute(`role`,`toolbar`),n.setAttribute(`aria-label`,`Chat formatting (selection)`),n.addEventListener(`mousedown`,e=>e.preventDefault(),!0),(a??e.dom.parentElement)?.appendChild(n),r=(0,x.createRoot)(n),{update:i,destroy(){let e=r;r=null,n?.remove(),n=null,e&&queueMicrotask(()=>e.unmount())}}}})}function R0e({path:e,onRemove:t}){let n=e;try{let[t,r]=H.splitModuleFilePathAndModulePath(e),i=H.splitModuleFilePath(t),a=H.splitModulePath(r);n=[i.length>0?kC(i[i.length-1]):t,...a.map(kC)].join(` / `)}catch{}return(0,b.createElement)(`span`,{className:`inline-flex items-center gap-1 align-baseline rounded bg-bg-secondary text-fg-primary px-1.5 py-0.5 text-xs font-mono mx-0.5`,title:e,contentEditable:!1},(0,b.createElement)(`span`,{className:`truncate max-w-[16em]`},n),(0,b.createElement)(`button`,{type:`button`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),t()},className:`text-fg-secondary hover:text-fg-primary leading-none`,"aria-label":`Remove field reference`},`×`))}function z0e(){return function(e,t,n){let r=document.createElement(`span`);r.setAttribute(`data-val-field-ref`,e.attrs.path),r.style.display=`inline-block`,r.style.verticalAlign=`baseline`,r.contentEditable=`false`;let i=(0,x.createRoot)(r),a=()=>{let r=n();if(r===void 0)return;let i=t.state.tr.delete(r,r+e.nodeSize);t.dispatch(i),t.focus()};return i.render((0,b.createElement)(R0e,{path:e.attrs.path,onRemove:a})),{dom:r,update(t){return t.type===e.type&&(t.attrs.path===e.attrs.path||i.render((0,b.createElement)(R0e,{path:t.attrs.path,onRemove:a})),!0)},stopEvent(e){return e.type===`mousedown`},ignoreMutation(){return!0},destroy(){queueMicrotask(()=>i.unmount())}}}}function B0e(e){let t=[];return e.forEach(e=>{let n=C9(e);n&&t.push(n)}),t}function C9(e){switch(e.type.name){case`paragraph`:return{tag:`p`,children:H0e(e)};case`heading`:return{tag:`h${Math.min(3,Math.max(1,e.attrs.level))}`,children:H0e(e)};case`bullet_list`:return{tag:`ul`,children:V0e(e)};case`ordered_list`:return{tag:`ol`,children:V0e(e)};case`blockquote`:{let t=[];return e.forEach(e=>{let n=C9(e);n&&t.push(n)}),{tag:`blockquote`,children:t}}default:return null}}function V0e(e){let t=[];return e.forEach(e=>{if(e.type.name===`list_item`){let n=[];e.forEach(e=>{let t=C9(e);t&&n.push(t)}),t.push({tag:`li`,children:n})}}),t}function H0e(e){let t=[];return e.forEach(e=>{if(e.isText){let n=e.text||``,r=U0e(e.marks);r.length===0?t.push(n):t.push({tag:`span`,styles:r,children:[n]})}else if(e.type.name===`hard_break`)t.push({tag:`br`});else if(e.type.name===`image`){let n=e.attrs.key,r=e.attrs.width,i=e.attrs.height,a=e.attrs.mimeType,o=e.attrs.previewUrl,s=e.attrs.alt,c={tag:`img`,key:n};s&&(c.alt=s),o&&(c.previewUrl=o),r!==null&&(c.width=r),i!==null&&(c.height=i),a!==null&&(c.mimeType=a),t.push(c)}else e.type.name===`field_ref`&&t.push({tag:`field_ref`,path:e.attrs.path})}),t}function U0e(e){let t=[];for(let n of e)switch(n.type.name){case`bold`:t.push(`bold`);break;case`italic`:t.push(`italic`);break;case`strikethrough`:t.push(`line-through`);break;case`code`:t.push(`code`)}return t}var W0e={bold:`bold`,italic:`italic`,"line-through":`strikethrough`,code:`code`};function G0e(e,t){let n=W0e[e],r=n?t.marks[n]:void 0;return r?r.create():null}function K0e(e,t){let n=e.map(e=>w9(e,t));return n.length===0&&n.push(t.node(`paragraph`)),t.node(`doc`,null,n)}function w9(e,t){switch(e.tag){case`p`:return t.node(`paragraph`,null,J0e(e.children,t));case`h1`:case`h2`:case`h3`:{let n=parseInt(e.tag[1],10);return t.node(`heading`,{level:n},J0e(e.children,t))}case`ul`:return t.node(`bullet_list`,null,e.children.map(e=>q0e(e,t)));case`ol`:return t.node(`ordered_list`,null,e.children.map(e=>q0e(e,t)));case`blockquote`:return t.node(`blockquote`,null,e.children.map(e=>w9(e,t)))}}function q0e(e,t){let n=e.children.map(e=>w9(e,t));return t.node(`list_item`,null,n)}function J0e(e,t){let n=[];for(let r of e)if(typeof r==`string`)r.length>0&&n.push(t.text(r));else if(r.tag===`br`)t.nodes.hard_break&&n.push(t.node(`hard_break`));else if(r.tag===`span`){let e=r.styles.map(e=>G0e(e,t)).filter(e=>e!==null);r.children[0].length>0&&n.push(t.text(r.children[0],e))}else r.tag===`img`?t.nodes.image&&n.push(t.node(`image`,{key:r.key,alt:r.alt??null,previewUrl:r.previewUrl??null,width:r.width??null,height:r.height??null,mimeType:r.mimeType??null})):r.tag===`field_ref`&&t.nodes.field_ref&&n.push(t.node(`field_ref`,{path:r.path}));return n}function Y0e(e){return e.replace(/<style[\s\S]*?<\/style>/gi,``).replace(/<meta[^>]*>/gi,``).replace(/<o:p\b[^>]*>[\s\S]*?<\/o:p>/gi,``)}function X0e(e){if(!e)return[];let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`),n=[];return t.body.querySelectorAll(`img`).forEach(e=>{if(e.hasAttribute(`data-val-ai-key`))return;let t=e.getAttribute(`src`);t&&n.push(t)}),n}async function Z0e(e,t,n){for(let r of t){let t=await M0e(r);if(!t){console.warn(`AI chat: skipped pasted image (fetch failed)`,r);continue}y9(e,t,n)}}var Q0e=(0,b.forwardRef)(function({placeholder:e,disabled:t,className:n,onSubmit:r,onChange:i,onUploadAiImage:a,getPortalContainer:o},s){let c=(0,b.useRef)(null),l=(0,b.useRef)(null),u=(0,b.useMemo)(()=>E0e(),[]),d=(0,b.useRef)(r);d.current=r;let f=(0,b.useRef)(i);f.current=i;let p=(0,b.useRef)(a);p.current=a;let m=(0,b.useRef)(t);return m.current=t,(0,b.useLayoutEffect)(()=>{let e=c.current;if(!e)return;let t=u.node(`doc`,null,[u.node(`paragraph`)]),n=[A0e(u,()=>d.current?.()),...D0e(u),O0e(u),S0(),E0(),M0(),L0e(u,{getPortalContainer:o,getUploadAiImage:()=>p.current})],r=new i0(e,{state:vQ.create({doc:t,schema:u,plugins:n}),nodeViews:{field_ref:z0e(),image:j0e()},transformPastedHTML:Y0e,handlePaste(e,t){let n=p.current;if(!n)return!1;let r=t.clipboardData?.items;if(r)for(let t=0;t<r.length;t++){let i=r[t];if(i.kind===`file`&&i.type.startsWith(`image/`)){let t=i.getAsFile();if(t)return y9(e,t,n),!0}}let i=t.clipboardData?.getData(`text/html`),a=X0e(i);return a.length>0&&(Z0e(e,a,n),!0)},handleDrop(e,t){let n=p.current;if(!n)return!1;let r=t.dataTransfer,i=r?.files;if(i&&i.length>0){let r=Array.from(i).find(e=>e.type.startsWith(`image/`));if(r)return t.preventDefault(),y9(e,r,n),!0}let a=r?.getData(`text/html`),o=X0e(a);return o.length>0&&(t.preventDefault(),Z0e(e,o,n),!0)},dispatchTransaction(e){let t=r.state.apply(e);r.updateState(t),e.docChanged&&f.current?.(B0e(t.doc))},editable:()=>!m.current});return l.current=r,()=>{r.destroy(),l.current=null}},[u]),(0,b.useEffect)(()=>{let e=l.current;e&&e.setProps({editable:()=>!m.current})},[t]),(0,b.useImperativeHandle)(s,()=>({getDocument:()=>{let e=l.current;return e?B0e(e.state.doc):[]},setDocument:e=>{let t=l.current;if(!t)return;let n=K0e(e,u),r=vQ.create({doc:n,schema:u,plugins:t.state.plugins});t.updateState(r)},clear:()=>{let e=l.current;if(!e)return;let t=u.node(`doc`,null,[u.node(`paragraph`)]),n=vQ.create({doc:t,schema:u,plugins:e.state.plugins});e.updateState(n)},focus:()=>{l.current?.focus()},isEmpty:()=>{let e=l.current;if(!e)return!0;let t=e.state.doc;if(t.childCount===0)return!0;if(t.childCount>1)return!1;let n=t.firstChild;return!n||n.type.name===`paragraph`&&n.content.size===0},insertFieldRef:e=>{let t=l.current;if(!t)return;let n=u.nodes.field_ref.create({path:e}),r=t.state.doc.content.size,i=t.state.doc.lastChild,a=t.state.tr;if(i&&i.type.name===`paragraph`){let e=r-1;a.insert(e,n),a.insertText(` `,e+n.nodeSize)}else{let e=u.node(`paragraph`,null,[n]);a.insert(r,e)}t.dispatch(a.scrollIntoView()),t.focus()}}),[u]),(0,Y.jsx)(`div`,{className:(0,AC.default)(`val-chat-editor relative flex flex-col cursor-text`,n,{"opacity-60 cursor-not-allowed":t}),onMouseDown:e=>{if(t)return;let n=l.current;if(n&&(e.target===e.currentTarget||e.target===c.current)){e.preventDefault(),n.focus();let t=n.state.doc.content.size;n.dispatch(n.state.tr.setSelection(nQ.near(n.state.doc.resolve(t))))}},children:(0,Y.jsx)(`div`,{ref:c,className:(0,AC.default)(`val-chat-editor-content flex-1 min-h-[2.25rem] outline-none`,`[&_.ProseMirror]:min-h-full [&_.ProseMirror]:outline-none`),"data-placeholder":e||``})})}),$0e={bold:`strong`,italic:`em`,"line-through":`del`,code:`code`};function e2e(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}function T9(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function t2e(e){if(typeof e==`string`)return e2e(e);if(e.tag===`br`)return`<br/>`;if(e.tag===`span`){let t=e2e(e.children[0]),n=e.styles.map(e=>$0e[e]).filter(e=>!!e);return`${n.map(e=>`<${e}>`).join(``)}${t}${n.slice().reverse().map(e=>`</${e}>`).join(``)}`}if(e.tag===`img`){let t=e.alt===void 0?``:` alt="${T9(e.alt)}"`;return`<img key="${T9(e.key)}"${t}/>`}return e.tag===`field_ref`?`<field path="${T9(e.path)}"/>`:``}function n2e(e){return e.map(t2e).join(``)}function r2e(e){return`<li>${e.children.map(E9).join(``)}</li>`}function E9(e){switch(e.tag){case`p`:return`<p>${n2e(e.children)}</p>`;case`h1`:case`h2`:case`h3`:return`<${e.tag}>${n2e(e.children)}</${e.tag}>`;case`ul`:return`<ul>${e.children.map(r2e).join(``)}</ul>`;case`ol`:return`<ol>${e.children.map(r2e).join(``)}</ol>`;case`blockquote`:return`<blockquote>${e.children.map(E9).join(``)}</blockquote>`}}function i2e(e){return e.map(E9).join(`
|
|
255
|
+
`)}function a2e(e){try{let[t,n]=H.splitModuleFilePathAndModulePath(e),r=H.splitModulePath(n);return r.length===0?t:`${t}#${r.join(`/`)}`}catch{return e}}function o2e(e){return typeof e==`string`?e:e.tag===`br`?`
|
|
256
|
+
`:e.tag===`span`?e.children[0]:e.tag===`img`?e.alt?`[image: ${e.alt}]`:`[image]`:e.tag===`field_ref`?`@${a2e(e.path)}`:``}function D9(e){return e.map(o2e).join(``)}function O9(e,t,n){let r=[],i=!0,a=e=>{r.push(`${i?`${n}${t} `:`${n} `}${e}`),i=!1};for(let t of e.children)switch(t.tag){case`p`:case`h1`:case`h2`:case`h3`:a(D9(t.children));break;case`blockquote`:for(let e of k9(t).split(`
|
|
257
|
+
`))a(e);break;case`ul`:for(let e of t.children)r.push(O9(e,`-`,`${n} `));break;case`ol`:{let e=0;for(let i of t.children)r.push(O9(i,`${e+1}.`,`${n} `)),e+=1;break}}return r.join(`
|
|
258
|
+
`)}function k9(e){switch(e.tag){case`p`:return D9(e.children);case`h1`:case`h2`:case`h3`:return D9(e.children);case`blockquote`:return e.children.map(k9).join(`
|
|
259
|
+
`);case`ul`:return e.children.map(e=>O9(e,`-`,``)).join(`
|
|
260
|
+
`);case`ol`:return e.children.map((e,t)=>O9(e,`${t+1}.`,``)).join(`
|
|
261
|
+
`)}}function s2e(e){return e.map(k9).join(`
|
|
262
|
+
|
|
263
|
+
`)}function c2e(e,t){typeof e!=`string`&&e.tag===`img`&&t.push(e)}function l2e(e,t){for(let n of e.children)A9(n,t)}function A9(e,t){switch(e.tag){case`p`:case`h1`:case`h2`:case`h3`:for(let n of e.children)c2e(n,t);return;case`ul`:case`ol`:for(let n of e.children)l2e(n,t);return;case`blockquote`:for(let n of e.children)A9(n,t);return}}function u2e(e){let t=[];for(let n of e)A9(n,t);return t}function d2e(e){return u2e(e).map(e=>e.key)}function f2e(e,t){return(t?e.find(e=>e.ref.provider===t.provider&&e.ref.model===t.model):void 0)?.label??`Model`}function p2e({models:e,selectedModel:t,onSelectModel:n,disabled:r,portalContainer:i}){if(e.length===0)return null;let a=f2e(e,t);return(0,Y.jsxs)(k3,{children:[(0,Y.jsx)(A3,{asChild:!0,children:(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,disabled:r,className:`h-7 px-2 text-xs text-fg-secondary gap-1`,"aria-label":a===`Model`?`Choose a model`:`Change model, currently ${a}`,children:[a,(0,Y.jsx)(Iv,{className:`h-3 w-3`})]})}),(0,Y.jsx)(j3,{align:`start`,container:i,className:`max-h-72 overflow-y-auto`,children:e.map(e=>{let r=t?.provider===e.ref.provider&&t?.model===e.ref.model;return(0,Y.jsxs)(M3,{onSelect:()=>n(e.ref),className:`text-xs`,children:[(0,Y.jsx)(Fv,{className:X(`h-3 w-3 mr-2`,r?`opacity-100`:`opacity-0`)}),e.label]},`${e.ref.provider}:${e.ref.model}`)})})]})}function j9(e){return e.questions!==void 0&&e.answers===void 0&&!e.cancelled&&e.status===`pending`}var m2e={get_all_schema:{label:`Reading schemas`,icon:(0,Y.jsx)(Uie,{className:`h-3 w-3`})},get_source:{label:`Reading content`,icon:(0,Y.jsx)($v,{className:`h-3 w-3`})},search_content:{label:`Searching`,icon:(0,Y.jsx)(My,{className:`h-3 w-3`})},validate_content:{label:`Validating`,icon:(0,Y.jsx)(Eae,{className:`h-3 w-3`})},create_patch:{label:`Updating content`,icon:(0,Y.jsx)(Dy,{className:`h-3 w-3`})},add_session_image_to_gallery:{label:`Adding image to gallery`,icon:(0,Y.jsx)(Ey,{className:`h-3 w-3`})},remove_image_gallery_entry:{label:`Removing image from gallery`,icon:(0,Y.jsx)(Ey,{className:`h-3 w-3`})},navigate_to:{label:`Navigating to content`,icon:(0,Y.jsx)(xy,{className:`h-3 w-3`})},get_patches:{label:`Loading changes`,icon:(0,Y.jsx)(Wv,{className:`h-3 w-3`})},get_source_path_from_route:{label:`Resolving route`,icon:(0,Y.jsx)(xy,{className:`h-3 w-3`})},get_current_context:{label:`Gathering context`,icon:(0,Y.jsx)(Vy,{className:`h-3 w-3`})},set_session_name:{label:`Naming session`,icon:(0,Y.jsx)(Fae,{className:`h-3 w-3`})},show_compare_view:{label:`Opening compare view`,icon:(0,Y.jsx)(ty,{className:`h-3 w-3`})},ask_user_question:{label:`Asking a question`,icon:(0,Y.jsx)(Hv,{className:`h-3 w-3`})},duplicate_source:{label:`Duplicating content`,icon:(0,Y.jsx)(qv,{className:`h-3 w-3`})},empty_at_path:{label:`Creating empty entry`,icon:(0,Y.jsx)(Zie,{className:`h-3 w-3`})},count_entries:{label:`Counting entries`,icon:(0,Y.jsx)(oy,{className:`h-3 w-3`})},get_record_keys:{label:`Listing keys`,icon:(0,Y.jsx)(my,{className:`h-3 w-3`})}};function M9(e){return m2e[e]??{label:e,icon:(0,Y.jsx)(Ny,{className:`h-3 w-3`})}}function h2e(e){return e===`pending`?`Running`:e===`error`?`Failed`:`Completed`}function g2e({activities:e,onSubmitAnswers:t,onCancel:n,defaultExpanded:r}){let i=e.filter(e=>e.questions===void 0),a=e.filter(e=>e.questions!==void 0);return e.length===0?null:(0,Y.jsxs)(`div`,{className:`not-prose flex flex-col gap-1.5 min-w-0`,children:[i.length>0&&(0,Y.jsx)(v2e,{activities:i,defaultExpanded:r}),a.map(e=>j9(e)&&e.questions?(0,Y.jsx)(x2e,{questions:e.questions,onSubmit:n=>t(e.toolCallId,n),onCancel:()=>n(e.toolCallId)},e.toolCallId):e.questions&&e.answers?(0,Y.jsx)(y2e,{answers:e.answers,questions:e.questions},e.toolCallId):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs py-0.5 text-fg-secondary`,children:[(0,Y.jsx)(Uv,{className:`h-3 w-3`}),(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Question dismissed`})]},e.toolCallId))]})}function _2e(e){let t=e.find(e=>e.status===`pending`);return t?`${M9(t.name).label}…`:e.length===1?M9(e[0].name).label:`Used ${e.length} tools`}function v2e({activities:e,defaultExpanded:t}){let[n,r]=(0,b.useState)(t===!0),i=(0,b.useId)(),a=e.find(e=>e.status===`pending`),o=e.filter(e=>e.status===`error`).length,s=_2e(e),c=M9((a??e[e.length-1]).name).icon;return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-primary bg-bg-secondary overflow-hidden`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-controls":i,className:X(`flex w-full items-center gap-2 px-2.5 py-1.5 text-left`,`text-xs touch:text-sm hover:bg-bg-secondary-hover transition-colors`),children:[(0,Y.jsx)(Rv,{className:X(`h-3 w-3 shrink-0 text-fg-tertiary transition-transform`,n&&`rotate-90`)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-tertiary`,children:c}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-fg-secondary`,children:(0,Y.jsx)(`span`,{className:X(a&&`val-shimmer-text`),children:s})}),o>0&&(0,Y.jsxs)(`span`,{className:`shrink-0 text-fg-error-on-surface`,children:[o,` failed`]})]}),n&&(0,Y.jsx)(`ul`,{id:i,className:`flex flex-col gap-1 border-t border-border-primary px-2.5 py-1.5`,children:e.map(e=>{let t=M9(e.name);return(0,Y.jsxs)(`li`,{className:X(`flex items-center gap-1.5 text-xs touch:text-sm`,e.status===`error`?`text-fg-error-on-surface`:`text-fg-secondary`),children:[(0,Y.jsx)(`span`,{className:`shrink-0`,"aria-hidden":`true`,children:e.status===`pending`?(0,Y.jsx)(hy,{className:`h-3 w-3 animate-spin`}):e.status===`error`?(0,Y.jsx)(Uv,{className:`h-3 w-3`}):(0,Y.jsx)(Fv,{className:`h-3 w-3`})}),(0,Y.jsx)(`span`,{className:`sr-only`,children:h2e(e.status)}),(0,Y.jsx)(`span`,{className:`shrink-0 text-fg-tertiary`,"aria-hidden":`true`,children:t.icon}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,Y.jsxs)(`span`,{className:X(e.status===`pending`&&`val-shimmer-text`),children:[t.label,e.status===`pending`?`…`:``]})})]},e.toolCallId)})})]})}function y2e({questions:e,answers:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 text-xs text-fg-secondary py-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Asked a question`})]}),t.map((t,n)=>{let r=e[n],i=[];r&&t.selectedOptions.forEach(e=>{let t=r.options[e]?.label;t&&i.push(t)}),t.customAnswer&&i.push(t.customAnswer);let a=i.join(`, `)||`(no answer)`;return(0,Y.jsxs)(`div`,{className:`pl-4 truncate`,children:[(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`Q:`}),` `,t.question,` `,(0,Y.jsx)(`span`,{className:`text-fg-tertiary`,children:`→`}),` `,a]},n)})]})}function b2e(e){return e.map(e=>{let t=new Set;if(e.defaults&&e.defaults.length>0){let n=e.defaults.filter(t=>Number.isInteger(t)&&t>=0&&t<e.options.length);e.multiSelect?n.forEach(e=>t.add(e)):n.length>0&&t.add(n[0])}return{selected:t,custom:``,otherSelected:!1}})}function x2e({questions:e,onSubmit:t,onCancel:n}){let[r,i]=(0,b.useState)(()=>b2e(e)),[a,o]=(0,b.useState)(!1),s=(0,b.useId)(),c=r.every(e=>e.selected.size>0||e.otherSelected&&e.custom.trim().length>0),l=(e,t,n)=>{a||i(r=>r.map((r,i)=>{if(i!==e)return r;let a=new Set(r.selected);return n?(a.has(t)?a.delete(t):a.add(t),{...r,selected:a}):(a.clear(),a.add(t),{...r,selected:a,otherSelected:!1})}))},u=(e,t)=>{a||i(n=>n.map((n,r)=>r===e?t?{...n,otherSelected:!n.otherSelected}:{...n,selected:new Set,otherSelected:!0}:n))},d=(e,t,n)=>{a||i(r=>r.map((r,i)=>i===e?n?{...r,custom:t,otherSelected:!0}:{...r,custom:t,otherSelected:!0,selected:new Set}:r))},f=(0,b.useRef)(new Map),p=(e,t)=>`${e}:${t}`,m=(e,t,n,r)=>{let i;if(e.key===`ArrowDown`||e.key===`ArrowRight`)i=(n+1)%r;else if(e.key===`ArrowUp`||e.key===`ArrowLeft`)i=(n-1+r)%r;else return;e.preventDefault();let a=r-1;i===a?u(t,!1):l(t,i,!1),f.current.get(p(t,i))?.focus()};return(0,Y.jsxs)(`div`,{className:`not-prose flex flex-col gap-3 rounded-md border border-border-primary bg-bg-secondary p-3 my-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-fg-secondary`,children:[(0,Y.jsx)(Hv,{className:`h-3 w-3`}),(0,Y.jsx)(`span`,{children:`Please answer to continue`})]}),e.map((e,t)=>{let n=e.multiSelect===!0,i=r[t],o=e.options.length,c=o+1,h=`${s}-q${t}`,g=i.otherSelected?o:Array.from(i.selected).sort((e,t)=>e-t)[0]??0,_=e=>n?void 0:g===e?0:-1;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,Y.jsx)(`div`,{className:`text-xs uppercase tracking-wide text-fg-tertiary`,children:e.header}),(0,Y.jsx)(`div`,{id:h,className:`text-sm text-fg-primary`,children:e.question}),(0,Y.jsxs)(`div`,{role:n?`group`:`radiogroup`,"aria-labelledby":h,className:`flex flex-col gap-1`,children:[e.options.map((e,r)=>{let o=i.selected.has(r);return(0,Y.jsxs)(`button`,{ref:e=>{f.current.set(p(t,r),e)},type:`button`,role:n?`checkbox`:`radio`,"aria-checked":o,tabIndex:_(r),disabled:a,onClick:()=>l(t,r,n),onKeyDown:n?void 0:e=>m(e,t,r,c),className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-left text-sm transition-colors`,o?`border-fg-primary bg-bg-primary`:`border-border-primary bg-bg-primary hover:bg-bg-secondary`,a&&`opacity-60 cursor-not-allowed`),children:[(0,Y.jsxs)(`span`,{className:X(`shrink-0 h-3.5 w-3.5 flex items-center justify-center border`,n?`rounded-sm`:`rounded-full`,o?`bg-fg-primary border-fg-primary`:`border-border-primary`),children:[o&&n&&(0,Y.jsx)(Fv,{className:`h-2.5 w-2.5 text-bg-primary`}),o&&!n&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bg-primary`})]}),(0,Y.jsxs)(`span`,{className:`flex-1 leading-tight`,children:[(0,Y.jsx)(`span`,{className:`block text-fg-primary`,children:e.label}),e.description&&(0,Y.jsx)(`span`,{className:`block text-xs text-fg-secondary`,children:e.description})]})]},r)}),(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-sm transition-colors`,i.otherSelected?`border-fg-primary bg-bg-primary`:`border-border-primary bg-bg-primary`,a&&`opacity-60`),children:[(0,Y.jsxs)(`button`,{ref:e=>{f.current.set(p(t,o),e)},type:`button`,role:n?`checkbox`:`radio`,"aria-checked":i.otherSelected,"aria-label":`Other`,tabIndex:_(o),disabled:a,onClick:()=>u(t,n),onKeyDown:n?void 0:e=>m(e,t,o,c),className:X(`shrink-0 h-3.5 w-3.5 flex items-center justify-center border`,n?`rounded-sm`:`rounded-full`,i.otherSelected?`bg-fg-primary border-fg-primary`:`border-border-primary`,a&&`cursor-not-allowed`),children:[i.otherSelected&&n&&(0,Y.jsx)(Fv,{className:`h-2.5 w-2.5 text-bg-primary`}),i.otherSelected&&!n&&(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bg-primary`})]}),(0,Y.jsx)(`input`,{type:`text`,disabled:a,placeholder:`Other (type your own answer)`,value:i.custom,onChange:e=>d(t,e.target.value,n),className:X(`flex-1 bg-transparent text-fg-primary`,`focus:outline-none placeholder:text-fg-tertiary`)})]})]})]},t)}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{a||(o(!0),n())},disabled:a,children:`Cancel`}),(0,Y.jsx)(t_,{size:`sm`,onClick:()=>{a||!c||(o(!0),t(e.map((e,t)=>{let n=r[t];return{question:e.question,selectedOptions:Array.from(n.selected).sort((e,t)=>e-t),customAnswer:n.otherSelected&&n.custom.trim().length>0?n.custom.trim():null}})))},disabled:a||!c,children:`Submit`})]})]})}function S2e(e){let{isUser:t,isError:n,isStreaming:r,hasText:i,hasFiles:a,hasRunningTool:o,hasPendingQuestion:s}=e,c=r&&!s&&(i||!o);return{hasBubble:t||n||i||a||c||!r&&!s,showCursor:c}}var C2e=[`Summarize recent changes`,`What am I looking at?`,`Fix typos`],w2e=0;function T2e(){return`chat-${++w2e}-${Date.now()}`}function N9(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
264
|
+
|
|
265
|
+
`)}var E2e=/<\/?(?:p|h[1-3]|blockquote|ul|ol|li|strong|b|em|i|del|s|code|br|img|field)\b/i;function D2e(e){return Array.from(e).map((e,t)=>O2e(e,t))}function O2e(e,t){if(e.nodeType===3)return e.nodeValue??``;if(e.nodeType!==1)return null;let n=e,r=D2e(n.childNodes);switch(n.tagName.toLowerCase()){case`p`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:r},t);case`h1`:return(0,Y.jsx)(`h1`,{className:`text-base font-semibold`,children:r},t);case`h2`:return(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:r},t);case`h3`:return(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:r},t);case`blockquote`:return(0,Y.jsx)(`blockquote`,{className:`border-l-2 border-border-primary pl-2 italic`,children:r},t);case`ul`:return(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:r},t);case`ol`:return(0,Y.jsx)(`ol`,{className:`list-decimal pl-5`,children:r},t);case`li`:return(0,Y.jsx)(`li`,{children:r},t);case`strong`:case`b`:return(0,Y.jsx)(`strong`,{children:r},t);case`em`:case`i`:return(0,Y.jsx)(`em`,{children:r},t);case`del`:case`s`:return(0,Y.jsx)(`del`,{children:r},t);case`code`:return(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.85em]`,children:r},t);case`br`:return(0,Y.jsx)(`br`,{},t);case`img`:{let e=n.getAttribute(`alt`);return(0,Y.jsxs)(`span`,{className:`italic text-fg-secondary`,children:[`[`,e?`image: ${e}`:`image`,`]`]},t)}case`field`:{let e=n.getAttribute(`path`)??``;return(0,Y.jsxs)(`span`,{className:`rounded bg-bg-tertiary px-1 py-0.5 text-fg-brand-primary`,children:[`@`,e]},t)}default:return(0,Y.jsx)(b.Fragment,{children:r},t)}}function k2e(e){if(!E2e.test(e))return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e});let t=new DOMParser().parseFromString(`<body>${e}</body>`,`text/html`);return(0,Y.jsx)(Y.Fragment,{children:D2e(t.body.childNodes)})}function A2e({doc:e}){return(0,Y.jsx)(Y.Fragment,{children:e.map((e,t)=>P9(e,t))})}function P9(e,t){switch(e.tag){case`p`:return(0,Y.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.children.map((e,t)=>F9(e,t))},t);case`h1`:return(0,Y.jsx)(`h1`,{className:`text-base font-semibold`,children:e.children.map((e,t)=>F9(e,t))},t);case`h2`:return(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.children.map((e,t)=>F9(e,t))},t);case`h3`:return(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.children.map((e,t)=>F9(e,t))},t);case`blockquote`:return(0,Y.jsx)(`blockquote`,{className:`border-l-2 border-border-primary pl-2 italic`,children:e.children.map((e,t)=>P9(e,t))},t);case`ul`:return(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:e.children.map((e,t)=>(0,Y.jsx)(`li`,{children:e.children.map((e,t)=>P9(e,t))},t))},t);case`ol`:return(0,Y.jsx)(`ol`,{className:`list-decimal pl-5`,children:e.children.map((e,t)=>(0,Y.jsx)(`li`,{children:e.children.map((e,t)=>P9(e,t))},t))},t)}}function F9(e,t){if(typeof e==`string`)return e;if(e.tag===`br`)return(0,Y.jsx)(`br`,{},t);if(e.tag===`span`){let n=e.children[0];for(let r of e.styles)r===`bold`?n=(0,Y.jsx)(`strong`,{children:n},t):r===`italic`?n=(0,Y.jsx)(`em`,{children:n},t):r===`line-through`?n=(0,Y.jsx)(`del`,{children:n},t):r===`code`&&(n=(0,Y.jsx)(`code`,{className:`rounded bg-bg-tertiary px-1 py-0.5 font-mono text-[0.85em]`,children:n},t));return(0,Y.jsx)(b.Fragment,{children:n},t)}return e.tag===`img`?e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.alt??``,className:`inline-block max-h-16 rounded border border-border-primary align-baseline mx-0.5`},t):(0,Y.jsxs)(`span`,{className:`italic text-fg-secondary`,children:[`[`,e.alt?`image: ${e.alt}`:`image`,`]`]},t):e.tag===`field_ref`?(0,Y.jsxs)(`span`,{className:`rounded bg-bg-tertiary px-1 py-0.5 text-fg-brand-primary`,children:[`@`,e.path]},t):null}function j2e(e){return typeof e==`string`?[]:e.filter(e=>e.type===`image_url`).map(e=>e.url)}var M2e=(0,b.forwardRef)(function({onCancel:e,models:t,selectedModel:n,onSelectModel:r,onSendMessage:i,onUploadFile:a,onNewSession:o,suggestions:s=C2e,className:c,isConnected:l,authError:u,unavailable:d,mode:f,sessions:p,currentSessionId:m,onLoadSession:h,onFetchSessions:g,onSetSessionName:_,isLoadingSession:v,onAnswerToolQuestions:y,onCancelToolQuestion:x,initialMessages:S,chatEditorRef:C},w){let[T,E]=(0,b.useState)(S??[]),[D,O]=(0,b.useState)(null),[k,A]=(0,b.useState)(!0),[j,M]=(0,b.useState)(!1),[N,P]=(0,b.useState)(!1),[F,I]=(0,b.useState)([]),L=(0,b.useRef)(null),R=(0,b.useRef)(null),ee=C??R,te=(0,b.useRef)(null),[ne,re]=(0,b.useState)(!1),[ie,ae]=(0,b.useState)(null),[oe,se]=(0,b.useState)(``),ce=bb(),le=eb(),ue=ce?.ai?.chat?.suggestions??s,de=ce?.ai?.chat?.title,fe=ce?.ai?.chat?.description,pe=D?[...T,D.message]:T;(0,b.useEffect)(()=>{requestAnimationFrame(()=>{te.current?.scrollIntoView({block:`end`})})},[pe]),(0,b.useEffect)(()=>{D&&P(!1)},[D]);let me=(D?.message.toolActivities??[]).some(j9),he=(0,b.useCallback)((e,t)=>{O(n=>{if(!n)return null;if(e!==null&&n.message.id!==e)return n;let r=t(n.message);return E(e=>e.some(e=>e.id===r.id)?e:[...e,r]),null})},[]),ge=(0,b.useCallback)(e=>({...e,status:`error`,error:`Response timed out`}),[]);(0,b.useEffect)(()=>{if(!D||me)return;let e=12e4-(Date.now()-D.startedAt);if(e<=0){he(D.message.id,ge);return}let t=setTimeout(()=>{he(null,ge)},e);return()=>clearTimeout(t)},[D,me,he,ge]);let _e=(0,b.useCallback)((e,t,n)=>{let r=e=>({...e,toolActivities:(e.toolActivities??[]).map(e=>e.toolCallId===t?n(e):e)});O(t=>!t||t.message.id!==e?t:{message:r(t.message),startedAt:Date.now()}),E(t=>t.some(t=>t.id===e)?t.map(t=>t.id===e?r(t):t):t)},[]),ve=(0,b.useCallback)((e,t,n)=>{_e(e,t,e=>({...e,status:`complete`,answers:n}))},[_e]),ye=(0,b.useCallback)((e,t)=>{_e(e,t,e=>({...e,status:`error`,cancelled:!0}))},[_e]);(0,b.useImperativeHandle)(w,()=>({startAssistantMessage(e){O({message:{id:e,role:`assistant`,content:``,status:`streaming`},startedAt:Date.now()})},appendAssistantChunk(e,t){O(n=>n?.message.id===e?{...n,message:{...n.message,content:N9(n.message.content)+t}}:n)},completeAssistantMessage(e){he(e,e=>({...e,status:`complete`}))},errorAssistantMessage(e,t,n,r,i){he(e,e=>({...e,status:`error`,error:t,errorAction:r,errorCode:n,errorDetails:i}))},addToolCall(e,t,n,r){let i={toolCallId:t,name:n,status:`pending`,...r?{questions:r}:{}};O(t=>t&&t.message.id===e?{...t,message:{...t.message,toolActivities:[...t.message.toolActivities??[],i]}}:t)},completeToolCall(e,t){O(n=>!n||n.message.id!==e?n:{...n,message:{...n.message,toolActivities:(n.message.toolActivities??[]).map(e=>e.toolCallId===t?{...e,status:`complete`}:e)}})},errorToolCall(e,t){O(n=>!n||n.message.id!==e?n:{...n,message:{...n.message,toolActivities:(n.message.toolActivities??[]).map(e=>e.toolCallId===t?{...e,status:`error`}:e)}})},clearMessages(){E([]),O(null)},loadMessages(e){O(null),E(e)}}));let be=D!==null,xe=F.some(e=>e.status===`uploading`),Se=pe.length===0,Ce=(0,b.useCallback)(e=>{let t=Array.from(e.target.files??[]);if(t.length===0)return;e.target.value=``;let n=t.map(e=>({id:crypto.randomUUID(),file:e,status:`uploading`,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0}));I(e=>[...e,...n]),a&&n.forEach(e=>{a(e.file).then(({key:t})=>{I(n=>n.map(n=>n.id===e.id?{...n,status:`done`,key:t}:n))}).catch(t=>{console.error(`Failed to upload file`,{fileName:e.file.name,error:t}),I(t=>t.map(t=>t.id===e.id?{...t,status:`error`}:t))})})},[a]),we=(0,b.useCallback)(e=>{I(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})},[]),z=(0,b.useCallback)(e=>{if(be)return;let t,n,r;if(e!==void 0){let r=e.trim();if(!r)return;t=r,n=r}else{let e=ee.current;if(!e||e.isEmpty())return;let i=e.getDocument();if(d2e(i).some(e=>e.startsWith(`pending:`)))return;t=i,r=i,n=s2e(i)}let a=F.filter(e=>e.status===`done`&&e.key!==void 0).map(e=>({key:e.key,name:e.file.name,mimeType:e.file.type||void 0,previewUrl:e.previewUrl}));F.forEach(e=>{e.previewUrl&&e.status!==`done`&&URL.revokeObjectURL(e.previewUrl)}),I([]);let o=T2e(),s={id:o,role:`user`,content:n,status:`complete`,attachments:a.length>0?a:void 0,userDoc:r};E(e=>[...e,s]),e===void 0&&(ee.current?.clear(),A(!0)),!i||i(t,a.length>0?a:void 0)?P(!0):E(e=>e.map(e=>e.id===o?{...e,status:`error`,error:`Failed to send`}:e)),requestAnimationFrame(()=>ee.current?.focus())},[be,F,i,ee]),B=(0,b.useCallback)(e=>{let t=pe.find(t=>t.id===e);if(t?.role===`user`){E(t=>t.map(t=>t.id===e?{...t,status:`complete`,error:void 0}:t));let n=t.userDoc??N9(t.content);!i||i(n,t.attachments)?P(!0):E(t=>t.map(t=>t.id===e?{...t,status:`error`,error:`Failed to send`}:t));return}let n=pe.findIndex(t=>t.id===e);if(n<=0)return;let r=pe.slice(0,n).reverse().find(e=>e.role===`user`);if(!r)return;E(t=>t.filter(t=>t.id!==e));let a=r.userDoc??N9(r.content);(i?.(a,r.attachments)??!0)&&P(!0)},[pe,i]);return(0,Y.jsxs)(`div`,{className:X(`flex flex-col h-full w-full bg-bg-primary text-fg-primary relative overflow-hidden`,c),children:[(!Se||g)&&(0,Y.jsxs)(`div`,{className:`shrink-0 flex justify-between items-center p-2 border-b border-border-primary`,children:[(0,Y.jsx)(`div`,{children:g&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{g(),re(!0)},className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Ay,{className:`h-3 w-3`}),`History`]})}),(0,Y.jsx)(`div`,{children:!Se&&o&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:o,disabled:be,className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Oy,{className:`h-3 w-3`}),`New chat`]})})]}),ne&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 z-overlay flex flex-col bg-bg-primary`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 flex items-center gap-2 p-2 border-b border-border-primary`,children:[(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:()=>{re(!1),ae(null)},"aria-label":`Back to chat`,children:(0,Y.jsx)(Lv,{className:`h-4 w-4`})}),(0,Y.jsx)(`span`,{className:`text-sm font-medium flex-1`,children:`Chat history`}),o&&(0,Y.jsxs)(t_,{variant:`ghost`,size:`sm`,onClick:()=>{o(),re(!1)},className:`text-xs touch:text-sm gap-1`,children:[(0,Y.jsx)(Oy,{className:`h-3 w-3`}),`New chat`]})]}),(0,Y.jsx)(eD,{className:`flex-1 min-h-0`,children:!p||p.length===0?(0,Y.jsx)(`div`,{className:`p-6 text-center text-sm text-fg-secondary`,children:`No previous sessions`}):(0,Y.jsx)(`div`,{className:`flex flex-col divide-y divide-border-primary`,children:p.map(e=>{let t=e.id===m,n=ie===e.id,r=e.name??`Chat, ${new Date(e.updatedAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}`;return(0,Y.jsxs)(`div`,{className:X(`flex items-center gap-2 px-3 py-2.5 group`,t&&`bg-bg-secondary`),children:[n?(0,Y.jsx)(`input`,{autoFocus:!0,className:`flex-1 text-sm bg-bg-primary border border-border-primary rounded px-2 py-0.5 focus:outline-none focus:ring-1 focus:ring-border-focus`,value:oe,onChange:e=>se(e.target.value),onKeyDown:t=>{if(t.key===`Enter`){let t=oe.trim();t&&_&&_(e.id,t),ae(null)}else t.key===`Escape`&&ae(null)},onBlur:()=>{let t=oe.trim();t&&_&&_(e.id,t),ae(null)}}):(0,Y.jsx)(`button`,{className:`flex-1 text-left text-sm truncate`,onClick:()=>{h?.(e.id),re(!1)},children:r}),!n&&(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,className:`opacity-0 group-hover:opacity-100 shrink-0`,onClick:t=>{t.stopPropagation(),se(e.name??``),ae(e.id)},"aria-label":`Rename session`,children:(0,Y.jsx)(Dy,{className:`h-3 w-3`})})]},e.id)})})})]}),(0,Y.jsx)(eD,{className:`flex-1 min-h-0`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 min-w-0 max-w-full`,children:[u?(0,Y.jsx)(P2e,{mode:f}):v&&Se?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-12 text-fg-secondary`,children:[(0,Y.jsx)(hy,{className:`h-5 w-5 animate-spin`}),(0,Y.jsx)(`span`,{className:`text-sm`,children:`Loading conversation…`})]}):Se?(0,Y.jsx)(F2e,{suggestions:ue,title:de,description:fe,onSelect:e=>z(e)}):pe.map(e=>(0,Y.jsx)(I2e,{message:e,onRetry:B,onSubmitToolAnswers:(t,n)=>{ve(e.id,t,n),y?.(t,n)},onCancelToolQuestion:t=>{ye(e.id,t),x?.(t)}},e.id)),N&&!D&&(0,Y.jsx)(R2e,{}),(0,Y.jsx)(`div`,{ref:te})]})}),(0,Y.jsx)(`div`,{className:`shrink-0 border-t border-border-primary bg-bg-primary p-3`,children:d&&!u?(0,Y.jsx)(N2e,{...d}):(0,Y.jsxs)(Y.Fragment,{children:[!l&&!u&&(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-center gap-1.5 rounded-md border border-border-primary bg-bg-secondary px-2 py-1.5 text-xs touch:text-sm text-fg-secondary`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),`Connecting…`]}),F.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:F.map(e=>(0,Y.jsxs)(`div`,{className:`relative flex items-center gap-1.5 rounded-md border border-border-primary bg-bg-secondary px-2 py-1 text-xs touch:text-sm text-fg-primary`,children:[e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.file.name,className:`h-8 w-8 rounded object-cover`}):(0,Y.jsx)($v,{className:`h-4 w-4 shrink-0 text-fg-secondary`}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.file.name}),e.status===`uploading`&&(0,Y.jsx)(hy,{className:`h-3 w-3 animate-spin text-fg-secondary`}),e.status===`error`&&(0,Y.jsx)(Uv,{className:`h-3 w-3 text-fg-error-primary`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>we(e.id),className:`ml-0.5 text-fg-secondary hover:text-fg-primary`,"aria-label":`Remove ${e.file.name}`,children:(0,Y.jsx)(Hy,{className:`h-3 w-3`})})]},e.id))}),a&&(0,Y.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`hidden`,onChange:Ce,accept:`image/*`}),(0,Y.jsxs)(`div`,{className:X(`flex flex-col rounded-md border border-border-primary bg-bg-primary`,`focus-within:outline-none focus-within:ring-2 focus-within:ring-border-focus`),children:[(0,Y.jsx)(Q0e,{ref:ee,disabled:u||!l||be,placeholder:l&&!u?`Ask something…`:``,onSubmit:()=>z(),onUploadAiImage:a,getPortalContainer:()=>le,onChange:e=>{let t=e.length===0||e.length===1&&e[0].tag===`p`&&e[0].children.length===0;A(t);let n=d2e(e);M(n.some(e=>e.startsWith(`pending:`)))},className:X(`max-h-[18rem] overflow-y-auto px-3 pt-3 pb-1`,`text-fg-primary text-base`)}),(0,Y.jsxs)(`div`,{className:`flex items-center border-t border-border-primary px-2 py-1.5`,children:[a&&(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,disabled:!l||be||u,onClick:()=>L.current?.click(),"aria-label":`Attach files`,children:(0,Y.jsx)(Ey,{className:`h-4 w-4`})}),t&&r&&(0,Y.jsx)(p2e,{models:t,selectedModel:n,onSelectModel:r,disabled:be,portalContainer:le}),be&&e?(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:e,"aria-label":`Stop generating`,title:`Stop generating`,className:`ml-auto`,children:(0,Y.jsx)(jae,{className:`h-3.5 w-3.5 fill-current`})}):(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,disabled:!l||be||xe||j||u||k,onClick:()=>z(),"aria-label":`Send message`,className:`ml-auto`,children:(0,Y.jsx)(Cae,{className:`h-4 w-4`})})]})]})]})})]})});function N2e({message:e,onRetry:t}){return(0,Y.jsxs)(`div`,{className:`rounded-md border border-border-primary bg-bg-secondary p-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(Ly,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-fg-error-primary`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-fg-primary`,children:`The assistant is unavailable`}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-[0.6875rem] text-fg-secondary`,children:e})]})]}),(0,Y.jsx)(t_,{variant:`outline`,size:`sm`,onClick:t,className:`mt-2 text-xs`,children:`Try again`})]})}function P2e({mode:e}){let t=e===`fs`;return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-4 py-12 text-center`,children:[(0,Y.jsx)(`div`,{className:`rounded-full bg-bg-secondary p-3`,children:(0,Y.jsx)(_y,{className:`h-6 w-6`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:`Login to use AI chat`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:t?`Val is running in development mode. Run this command in your project root to create a personal access token, then refresh:`:`Your session has expired. Sign in again to continue.`})]}),t?(0,Y.jsx)(`div`,{className:`w-full text-left`,children:(0,Y.jsx)(O5,{code:`npx -p @valbuild/cli val login`})}):(0,Y.jsx)(t_,{asChild:!0,variant:`default`,size:`sm`,children:(0,Y.jsxs)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.location.href}),children:[(0,Y.jsx)(_y,{className:`mr-2 h-4 w-4`}),`Sign in`]})})]})}function F2e({suggestions:e,title:t,description:n,onSelect:r}){return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-6 py-16 text-center`,children:[(0,Y.jsx)(`div`,{className:`rounded-full p-3`,children:(0,Y.jsx)(Ny,{className:`h-8 w-8`})}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`text-lg font-semibold text-fg-primary`,children:t??`How can I help?`}),(0,Y.jsx)(`p`,{className:`mt-1 text-sm text-fg-secondary`,children:n??`Ask me anything or pick a suggestion below`})]}),e.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:e.map(e=>(0,Y.jsx)(t_,{variant:`secondary`,size:`sm`,onClick:()=>r(e),className:`text-sm`,children:e},e))})]})}function I2e({message:e,onRetry:t,onSubmitToolAnswers:n,onCancelToolQuestion:r}){let i=e.role===`user`,a=e.status===`error`,o=e.status===`streaming`,s=e.toolActivities??[],c=s.some(j9),l=s.some(e=>e.status===`pending`&&e.questions===void 0),u=N9(e.content),d=j2e(e.content),{hasBubble:f,showCursor:p}=S2e({isUser:i,isError:a,isStreaming:o,hasText:u.length>0,hasFiles:d.length>0,hasRunningTool:l,hasPendingQuestion:c});return(0,Y.jsxs)(`div`,{className:X(`flex flex-col gap-1.5 min-w-0`,i?`items-end`:`items-stretch`),children:[!i&&s.length>0&&(0,Y.jsx)(g2e,{activities:s,onSubmitAnswers:n,onCancel:r}),f&&(0,Y.jsxs)(`div`,{className:X(`min-w-0 overflow-hidden rounded-lg px-4 py-2.5 text-sm touch:text-base leading-relaxed`,`[overflow-wrap:anywhere]`,i?`bg-bg-secondary text-fg-primary max-w-[80%]`:`bg-bg-tertiary text-fg-primary w-full max-w-full`,a&&`border border-border-error-primary`),children:[i?(0,Y.jsxs)(Y.Fragment,{children:[e.attachments&&e.attachments.length>0&&(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-1.5`,children:e.attachments.map(e=>e.mimeType?.startsWith(`image/`)&&e.previewUrl?(0,Y.jsx)(`img`,{src:e.previewUrl,alt:e.name,className:`h-16 w-16 rounded object-cover`},e.key):(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded border border-border-primary bg-bg-primary px-2 py-1 text-xs text-fg-secondary`,children:[(0,Y.jsx)($v,{className:`h-3 w-3 shrink-0`}),(0,Y.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.key))}),d.length>0&&(0,Y.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-2`,children:d.map(e=>(0,Y.jsx)(`img`,{src:e,alt:`Session attachment`,className:`max-h-48 rounded object-contain`},e))}),e.userDoc?(0,Y.jsx)(A2e,{doc:e.userDoc}):u&&k2e(u)]}):(0,Y.jsxs)(`div`,{className:X(`prose prose-sm dark:prose-invert max-w-none`,`[&_pre]:overflow-x-auto [&_pre]:max-w-full`,`[&_code]:break-words`,`[&_table]:block [&_table]:overflow-x-auto [&_table]:max-w-full`,`[&_a]:break-all`),children:[d.length>0&&(0,Y.jsx)(`div`,{className:`not-prose mb-3 flex flex-wrap gap-2`,children:d.map(e=>(0,Y.jsx)(`img`,{src:e,alt:`AI session image`,className:`max-h-64 rounded border border-border-primary object-contain`},e))}),u?(0,Y.jsx)(v0e,{children:u}):o||a||d.length>0||c?null:(0,Y.jsx)(`p`,{className:`text-fg-secondary italic`,children:`Empty response`}),p&&(0,Y.jsx)(L2e,{})]}),a&&(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-fg-error-primary`,children:e.error??`Something went wrong`}),e.errorAction&&C0e(e.errorAction.url)&&(0,Y.jsx)(`a`,{href:C0e(e.errorAction.url),target:`_blank`,rel:`noreferrer noopener`,className:`text-xs text-fg-brand-primary underline`,children:e.errorAction.label}),e.errorDetails&&(0,Y.jsxs)(`details`,{className:`text-xs text-fg-secondary`,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Details`}),(0,Y.jsx)(`pre`,{className:`mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-bg-secondary p-2 font-mono text-[11px] text-fg-secondary`,children:e.errorDetails})]})]}),(0,Y.jsx)(t_,{variant:`ghost`,size:`icon-sm`,onClick:()=>t(e.id),"aria-label":`Retry`,className:`h-6 w-6`,children:(0,Y.jsx)(xae,{className:`h-3.5 w-3.5 text-fg-error-primary`})})]})]})]})}function L2e(){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 ml-1 align-middle`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`150ms`}}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`300ms`}})]})}function R2e(){return(0,Y.jsx)(`div`,{className:`flex justify-start`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg bg-bg-tertiary px-4 py-3`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`150ms`}}),(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-fg-secondary animate-pulse`,style:{animationDelay:`300ms`}})]})})}function z2e(){let e=nb();return{query:(0,b.useCallback)(async(t,n,r)=>{if(e===null)return;let i=await e.system.search(t,n,r);return i.status===`no-index`?{results:[],total:0}:{results:i.results,total:i.total}},[e])}}function B2e(){let e=Fb();return{getErrors:(0,b.useCallback)(()=>{let t=e??{},n=new Map;for(let e in t){let r=e,[i]=H.splitModuleFilePathAndModulePath(r),a=t[r]??[],o={sourcePath:e,messages:a.map(e=>e.message)};a.some(e=>e.typeError)&&(o.typeError=!0),a.some(e=>e.schemaError)&&(o.schemaError=!0),a.some(e=>e.keyError)&&(o.keyError=!0);let s=n.get(i)??[];s.push(o),n.set(i,s)}return Array.from(n.entries()).map(([e,t])=>({modulePath:e,errors:t}))},[e])}}var I9=`_tag`;function L9(e){if(typeof e!=`object`||!e)return!1;let t=e;return!(t._type!==`ai_session_file`||t[I9]!==`image`&&t[I9]!==`file`||typeof t.key!=`string`||typeof t.filePath!=`string`)}function V2e(e){return JSON.parse(JSON.stringify(e))}function H2e(e,t,n){if(t.length===0)return{ok:!1,reason:`cannot set at empty path`};let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(Array.isArray(r)){let i=Number(n);if(!Number.isInteger(i)||i<0||i>=r.length)return{ok:!1,reason:`index out of bounds at ${t.slice(0,e+1).join(`/`)}`};r=r[i]}else if(r&&typeof r==`object`)r=r[n];else return{ok:!1,reason:`cannot descend into non-object at ${t.slice(0,e+1).join(`/`)}`}}let i=t[t.length-1];if(Array.isArray(r)){let e=Number(i);return Number.isInteger(e)?(r[e]=n,{ok:!0}):{ok:!1,reason:`expected numeric index at ${t.join(`/`)}`}}return r&&typeof r==`object`?(r[i]=n,{ok:!0}):{ok:!1,reason:`cannot set on non-object at ${t.join(`/`)}`}}function U2e(e,t,n){let r=(e,i)=>{if(L9(e)){n(i);return}if(Array.isArray(e)){e.forEach((e,t)=>r(e,[...i,String(t)]));return}if(e&&typeof e==`object`){let n=e;if(n.tag===`img`&&L9(n.src)){for(let[e,t]of Object.entries(n))e!==`src`&&r(t,[...i,e]);t(n.src,[...i,`src`]);return}for(let[e,t]of Object.entries(n))r(t,[...i,e])}};r(e,[])}function R9(e){return L9(e)?!0:Array.isArray(e)?e.some(R9):e&&typeof e==`object`?Object.values(e).some(R9):!1}function W2e(e,t){let n=e?{...e}:{};return t[I9]===`image`&&(t.alt!==void 0&&(n.alt=t.alt),t.hotspot!==void 0&&(n.hotspot=t.hotspot)),n}function G2e(e){let{patch:t,moduleSchema:n}=e,r=[];for(let e=0;e<t.length;e++){let i=t[e];if(i.op===`file`)return{kind:`error`,message:`Patch op #${e} is a 'file' op — those are emitted by the system, not by create_patch input.`};if(i.op===`remove`||i.op===`move`||i.op===`copy`)continue;if(i.op===`test`){if(R9(i.value))return{kind:`error`,message:`Patch op #${e} ('test') cannot contain a SessionKey.`};continue}let a=i.path,o=Ep(n,a);if(o.kind===`unresolved`){if(R9(i.value))return{kind:`error`,message:`Patch op #${e} contains a SessionKey but the path ${JSON.stringify(a)} could not be resolved against the module schema.`};continue}if(o.kind===`gallery-traversed`){if(R9(i.value))return{kind:`wrong-tool`,suggestedTool:`add_session_image_to_gallery`,reason:`Patch op #${e} targets an images gallery (s.images()) with a SessionKey. Galleries use file paths as keys; use add_session_image_to_gallery instead.`};continue}if(o.kind===`leaf`){let t=o.schema,n=L9(i.value);if(t.type===`image`||t.type===`file`){if(n){let n=i.value;if(n[I9]!==t.type)return{kind:`error`,message:`Patch op #${e}: SessionKey _tag is '${n[I9]}' but the schema is '${t.type}'.`};r.push({kind:`leaf`,opIndex:e,opPath:a,subtype:t.type,remote:Op(t),sessionKey:n});continue}if(R9(i.value))return{kind:`error`,message:`Patch op #${e}: SessionKey nested inside a non-SessionKey value at an ${t.type} field. Place the SessionKey directly as the value.`};continue}if(R9(i.value))return{kind:`error`,message:`Patch op #${e}: SessionKey is not allowed at a '${t.type}' field.`};continue}let s=Dp(o.schema),c=0,l=null;if(U2e(i.value,(t,n)=>{r.push({kind:`inline-img`,opIndex:e,opPath:a,valuePath:n,remote:s.kind===`allowed`&&s.remote,sessionKey:t}),c+=1},e=>{l===null&&(l=e)}),l)return{kind:`error`,message:`Patch op #${e}: SessionKey at value path ${JSON.stringify(l)} is not inside a {tag:"img", src: ...} node.`};if(c>0&&s.kind===`not-allowed`)return{kind:`error`,message:`Patch op #${e} inserts an inline image into a richtext that does not allow inline images (options.img is not enabled).`}}return{kind:`ok`,transfers:r.map((e,t)=>({siteId:t,key:e.sessionKey.key,filePath:e.sessionKey.filePath,isRemote:e.remote})),apply:e=>{if(r.length===0)return{kind:`ok`,patch:t};let n=t.map(e=>V2e(e)),i=[];for(let t=0;t<r.length;t++){let a=r[t],o=W2e(e[t],a.sessionKey),s=wp(a.sessionKey.filePath,o);if(a.kind===`leaf`){let e=n[a.opIndex];e.value=s,i.push({op:`file`,path:a.opPath,filePath:a.sessionKey.filePath,value:a.sessionKey.key,remote:a.remote,metadata:o})}else{let e=n[a.opIndex];if(a.valuePath.length===0)e.value=s;else{let t=H2e(e.value,a.valuePath,s);if(!t.ok)return{kind:`error`,message:`Failed to rewrite SessionKey at op #${a.opIndex}, value path ${JSON.stringify(a.valuePath)}: ${t.reason}`}}i.push({op:`file`,path:a.opPath,nestedFilePath:a.valuePath,filePath:a.sessionKey.filePath,value:a.sessionKey.key,remote:a.remote,metadata:o})}}let a=[...n,...i],o=Jd.safeParse(a);return o.success?{kind:`ok`,patch:o.data}:{kind:`error`,message:`Rewritten patch failed schema validation: ${JSON.stringify(o.error)}`}}}}async function K2e(e){let t=G2e({patch:e.patch,moduleSchema:e.moduleSchema,moduleSource:e.moduleSource});if(t.kind!==`ok`)return t;let n={};if(t.transfers.length>0){let r=e=>`${e.isRemote?`1`:`0`}${e.filePath}${e.key}`,i=[],a=new Map;for(let e of t.transfers){let t=r(e);a.has(t)||(a.set(t,i.length),i.push({filePath:e.filePath,key:e.key,isRemote:e.isRemote}))}let o=await e.transfer({patchId:e.patchId,parentRef:e.parentRef,files:i});if(o.files.length!==i.length)return{kind:`error`,message:`Session image transfer returned ${o.files.length} results for ${i.length} files.`};for(let e of t.transfers){let t=a.get(r(e));if(t===void 0)return{kind:`error`,message:`Internal error: missing transfer index for site ${e.siteId}.`};n[e.siteId]=o.files[t].metadata}}let r=t.apply(n);return r.kind===`error`?{kind:`error`,message:r.message}:{kind:`ok`,patch:r.patch}}var q2e=new qr,J2e={name:`get_all_schema`,description:`Get all val schemas — returns the complete schema definitions for all val modules`,parameters:{type:`object`,properties:{},required:[]}},Y2e={name:`get_source`,description:`Get the current source content of a Val module by its file path. The 'module_file_path' must exactly match one of the keys returned by get_all_schema.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/homepage.val.ts'. Can be obtained from the keys of get_all_schema.`}},required:[`module_file_path`]}},X2e={name:`search_content`,description:`Search content — accepts a query and returns matching content items. Returns { results, total } where total is the number of matches found. Use offset to page through results if total exceeds the returned results count.`,parameters:{type:`object`,properties:{query:{type:`string`,description:`The search query`},limit:{type:`number`,description:`Max results to return (default 50)`},offset:{type:`number`,description:`Number of results to skip for pagination (default 0)`}},required:[`query`]}},Z2e={name:`validate_content`,description:`Get all current validation errors — returns a list of modules with their validation errors, grouped by module path`,parameters:{type:`object`,properties:{},required:[]}},Q2e={name:`create_patch`,description:`Create a Val patch — applies JSON Patch operations to a Val module.
|
|
266
266
|
Supports string, number, boolean, null, object, array, date (ISO 8601), image, file, and richtext fields.
|
|
267
267
|
Supported ops: 'replace', 'add', 'remove'.
|
|
268
268
|
The 'path' must be a JSON Pointer AS AN ARRAY: (e.g. ['title'], ['items', '0', 'name']).
|
|
@@ -293,7 +293,7 @@ Guidance:
|
|
|
293
293
|
|
|
294
294
|
Multiple session keys can appear in a single patch.
|
|
295
295
|
For images-gallery modules (s.images()) you must use add_session_image_to_gallery instead — galleries don't fit this pattern.
|
|
296
|
-
`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/homepage.val.ts'`},patch:{type:`array`,description:`Array of patch operations, except that path is array of strings. Each item: { op, path, value? }. Use a session-key object as the value for image/file/richtext-inline-img — see the tool description.`,items:{type:`object`,properties:{op:{type:`string`,enum:[`replace`,`add`,`remove`]},path:{type:`array`,items:{type:`string`}},value:{}},required:[`op`,`path`]}}},required:[`module_file_path`,`patch`]}},Z2e={name:`add_session_image_to_gallery`,description:`Use when the user wants a session-uploaded image added to an images gallery (a module defined with s.images(), where each entry's key is the file path and the value is the image's metadata).`,parameters:{type:`object`,properties:{image_key:{type:`string`,description:`The exact image_key string shown in the user's [Attached images] list in their message. Do NOT use any internal vision-system file id (e.g. 'file-...' or 'image-N') — only use the key string from that list verbatim.`},module_file_path:{type:`string`,description:`The images-gallery module file path, e.g. '/content/media.val.ts'.`},file_path:{type:`string`,description:`Where the image file should live on disk. This is also used as the entry key in the gallery.`},alt:{type:`string`,description:`Optional alt text.`},hotspot:{type:`object`,description:`Optional focal point in the image (numbers between 0 and 1). Provide only if the user asked for a specific crop/focal point.`,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`]}},required:[`image_key`,`module_file_path`,`file_path`]}},Q2e={name:`remove_image_gallery_entry`,description:`Remove an existing image entry from an images gallery (a module defined with s.images()). The system records the deletion as a 'file' patch op with value: null and removes the corresponding gallery record entry.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The images-gallery module file path, e.g. '/content/media.val.ts'.`},file_path:{type:`string`,description:`The exact entry key in the gallery (the image's file path or remote ref). Use get_source on the gallery module to list available keys.`}},required:[`module_file_path`,`file_path`]}},$2e={name:`navigate_to`,description:`Navigate the user's view to a specific location in the content tree. Use ONLY when the user explicitly asks to be shown or navigated to something, or immediately after creating/modifying content when navigating there is clearly the expected next step. Do NOT call this tool during normal information gathering.AVOIDING USING THIS TOOL IF USER IS NOT ON A BROWSER PATHNAME THAT STARTS WITH /val`,parameters:{type:`object`,properties:{source_path:{type:`string`,description:`The SourcePath to navigate to. Format: '/path/to/file.val.ts' for a module root, or '/path/to/file.val.ts?p=key."subkey"' for a specific field. String keys in the ModulePath are JSON-quoted (e.g. "title"), array indices are plain numbers (e.g. 0).`}},required:[`source_path`]}},e4e={name:`get_current_context`,description:`Get the current context: logged-in author, date/time, the val source path the user is viewing, and the browser pathname. If the browser is on a page tracked by val (a Next.js app-router route), the matching source path is included.`,parameters:{type:`object`,properties:{},required:[]}},t4e={name:`get_patches`,description:`List pending (unpublished) patches — changes that have been made but not yet published. Returns patches sorted by date descending (newest first), paginated. Each patch includes the module it affects, when it was made, and the author's name and email if available. Use this to answer questions like 'what changed recently', 'who made changes', or 'what is waiting to be published'.`,parameters:{type:`object`,properties:{limit:{type:`number`,description:`Max patches to return (default 20)`},offset:{type:`number`,description:`Number of patches to skip for pagination (default 0)`}},required:[]}},n4e={name:`get_source_path_from_route`,description:`Given a URL pathname (e.g. '/blogs/blog-1'), find the val module and source path that contains the content for that page. Only works for Next.js app router pages. Returns moduleFilePath (use with get_source) and sourcePath (use with navigate_to or create_patch).`,parameters:{type:`object`,properties:{pathname:{type:`string`,description:`The URL pathname, e.g. '/blogs/blog-1' or '/'`}},required:[`pathname`]}},r4e={name:`set_session_name`,description:`Give the current chat session a short, descriptive name once the topic is clear. Call this exactly once per session, early in the conversation when the topic becomes clear. Max 5 words, plain language (e.g. 'Update homepage hero text').`,parameters:{type:`object`,properties:{name:{type:`string`,description:`Short session name, max 60 characters`}},required:[`name`]}},i4e={name:`show_compare_view`,description:`Navigate the user to the compare view to show pending changes (patches that have not yet been published). Use when the user wants to review, inspect, or compare their unpublished changes.`,parameters:{type:`object`,properties:{},required:[]}},a4e={name:`ask_user_question`,description:`Ask the user 1-4 structured clarification questions at once and wait for their answers. Use ONLY when the request is ambiguous and a small set of concrete options would resolve it. Prefer this over open-ended follow-up text. Group related clarifications into one call rather than asking sequentially. Each question is single-select by default; set multiSelect: true on a question to let the user pick multiple options. Each question may set defaults (indices of options to pre-select). The user can also type a free-text 'Other' answer per question. Returns { answers: Array<{ question: string; selectedOptions: number[]; customAnswer: string | null }> } in the same order as the input questions. selectedOptions holds the indices of options the user kept selected (length 0 or 1 for single-select; 0..N for multi-select). customAnswer is the user's free-text 'Other' input for that question (null if they didn't type one). The user may also cancel: in that case the tool result is an error and you should follow up in plain text instead.`,parameters:{type:`object`,properties:{questions:{type:`array`,description:`1-4 questions to ask the user, all shown together in a single card.`,items:{type:`object`,properties:{question:{type:`string`,description:`The full question shown to the user. One sentence, plain language.`},header:{type:`string`,description:`Optional short label (1-4 words) shown above the question, e.g. 'Which page?'`},options:{type:`array`,description:`2-4 distinct answer options.`,items:{type:`object`,properties:{label:{type:`string`,description:`Short button label (max ~40 chars)`},description:{type:`string`,description:`Optional one-line elaboration`}},required:[`label`]}},multiSelect:{type:`boolean`,description:`If true, the user can select multiple options for this question. Defaults to false (single-select).`},defaults:{type:`array`,description:`Optional indices of options to pre-select. For single-select questions only the first entry is honored. Out-of-range indices are ignored.`,items:{type:`number`}}},required:[`question`,`options`]}}},required:[`questions`]},timeoutMs:null},o4e=q({questions:K(q({question:W(),header:W().optional().catch(void 0),options:K(q({label:W(),description:W().optional().catch(void 0)})),multiSelect:G().optional().catch(void 0),defaults:K(iu()).optional().catch(void 0)})).min(1)}),z9=`JSON Pointer AS AN ARRAY (e.g. ['posts', 'blog-1'] or ['items', '0', 'title']). Array indices are numeric strings. Record keys that contain slashes stay as a single segment, e.g. ['/foo/bar'].`,s4e=[K2e,q2e,J2e,Y2e,X2e,Z2e,Q2e,$2e,e4e,t4e,n4e,r4e,i4e,a4e,{name:`duplicate_source`,description:`Duplicate the value at 'source_path' to 'destination_path' within the same Val module. Use the op rule: if the destination's parent is an array or record, the patch uses 'add' (creating a new entry); if the destination's parent is an object, the patch uses 'replace'; if destination_path is empty, replaces the whole module. PREFER this tool over empty_at_path when there is an existing similar entry to copy — copying preserves nested structure, optional fields, and image references correctly, while emptying often produces nulls the model would have to fill in. For richtext destinations or images-gallery destinations, use create_patch or add_session_image_to_gallery instead.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/blog.val.ts'.`},source_path:{type:`array`,items:{type:`string`},description:`Path within the module to read FROM. `+z9},destination_path:{type:`array`,items:{type:`string`},description:`Path within the SAME module to write TO. `+z9}},required:[`module_file_path`,`source_path`,`destination_path`]}},{name:`empty_at_path`,description:`Create an empty value (built from the schema via emptyOf) at 'destination_path' in a Val module. Same op rule as duplicate_source (array/record parent → 'add', object parent → 'replace', empty path → 'replace'). Use this ONLY when there is no good donor to duplicate from — duplicate_source is almost always better when something similar exists, because empty values for optional fields become null and image/file fields become null (which then need a follow-up upload). For richtext destinations or images-gallery destinations, use create_patch or add_session_image_to_gallery instead.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/blog.val.ts'.`},destination_path:{type:`array`,items:{type:`string`},description:`Path within the module to write to. `+z9}},required:[`module_file_path`,`destination_path`]}},{name:`count_entries`,description:`Count the entries of the value at 'path' in a Val module — record or gallery keys, object keys, array indices, or richtext top-level blocks. Use this before paging through a large record/array or to answer 'how many X are there?' without pulling the entire module. Returns { kind: 'array' | 'record' | 'object' | 'gallery' | 'richtext', count: number }. Fails for anything that is not a container - primitives, and image/file/union values (which are objects at runtime but hold no entries).`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/blog.val.ts'.`},path:{type:`array`,items:{type:`string`},description:`Path within the module pointing at the collection to count. Pass [] for the module root. `+z9}},required:[`module_file_path`,`path`]}},{name:`get_record_keys`,description:`List the keys of the record (or object) at 'path' in a Val module, with pagination. Use this to enumerate entries without pulling their contents — e.g. to find which slug to operate on next. Returns { kind: 'record' | 'object', keys: string[], total: number }. Fails on arrays, primitives, richtext and galleries - use count_entries for array/richtext sizes and get_source to read a gallery.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/blog.val.ts'.`},path:{type:`array`,items:{type:`string`},description:`Path within the module pointing at the record/object. Pass [] for the module root. `+z9},limit:{type:`number`,description:`Max keys to return (default 100).`},offset:{type:`number`,description:`Number of keys to skip for pagination (default 0).`}},required:[`module_file_path`,`path`]}}];function c4e(e,t){let{subscribeToWsMessages:n,sendWsMessage:r,isWsConnected:i,aiAuthError:a,aiGetSessions:o,aiGetSessionMessages:s,aiSetSessionName:c,aiSessionImagesToPatchFile:l}=zS(),u=nb(),d=(0,b.useMemo)(()=>{let e=u?.system??null;return{getAllSchemasSnapshot(){return e?.schemaStore.all()??{}},getAllSourcesSnapshot(){return e?.sourceStore.allSources()??{}},getSourceSnapshot(t){let n=e?.sourceStore.moduleSource(t);return n===void 0?{status:`not-found`}:{status:`success`,data:n}},createPatchId(){if(e===null)throw Error(`Cannot mint a patch id: no store system is mounted`);return e.patchStore.mintPatchId()},getParentRef(){return e?.patchSync.currentParentRef()??null},validatePatchResult(t,n){if(e===null)return{status:`no-source`,message:`No store system is mounted`};let r=e.sourceStore.moduleSource(t);if(r===void 0)return{status:`no-source`,message:`Content at '${t}' is not yet initialized`};if(e.schemaStore.get(t)===void 0)return{status:`no-schema`,message:`Schema not found for '${t}'`};let i=n.filter(e=>e.op!==`file`),a=Yr(JSON.parse(JSON.stringify(r)),G2e,i);if(te.isErr(a))return{status:`patch-error`,message:a.error.message};let o=e.host.validateSpeculative(t,a.value);return o.status===`unknown-module`?{status:`no-schema`,message:`No schema instance for '${t}'`}:o.errors},getAllPatchesSnapshot(){if(e===null)return{};let t={};for(let n of e.patchStore.allRecords())t[n.patchId]={moduleFilePath:n.moduleFilePath,createdAt:n.createdAt??``,isPending:e.patchStore.isPending(n.patchId),authorId:n.authorId??null};return t}}},[u]),f=(0,b.useCallback)(async(e,t,n,r,i)=>{if(u===null)return{status:`patch-error`,message:`Cannot write: no store system is mounted.`};let a=await u.system.patchStore.createPatch(e,t,void 0,void 0,void 0,r,n??void 0,`image`,i);return a.status===`created`?{status:`patch-synced`,patchId:a.record.patchId}:{status:`patch-error`,message:a.message}},[u]),p=L2e(),m=R2e(),{navigate:h,currentSourcePath:g}=GC(),_=tC(),v=sC(),y=noe(),x=bb()?.ai?.chat?.experimental?.enable===!0,{selected:S}=VS(),C=BS(),w=S??C,[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)([]),[j,M]=(0,b.useState)(null),N=(0,b.useRef)(null),P=(0,b.useRef)(t?.onSessionBorn),F=(0,b.useRef)(t?.onSessionCleared);(0,b.useEffect)(()=>{P.current=t?.onSessionBorn,F.current=t?.onSessionCleared});let I=(0,b.useRef)(null),L=(0,b.useRef)(null),R=(0,b.useRef)(new Set),ee=(0,b.useRef)(new Map);(0,b.useEffect)(()=>n(t=>{if(!(`id`in t&&!R.current.has(t.id))){if(t.type===`ai_streaming`){if(!e.current)return;I.current!==t.id&&(I.current=t.id,e.current.startAssistantMessage(t.id),E(!0)),e.current.appendAssistantChunk(t.id,t.chunk)}else if(t.type===`ai_response`){if(!e.current)return;I.current!==t.id&&(e.current.startAssistantMessage(t.id),e.current.appendAssistantChunk(t.id,t.response)),e.current.completeAssistantMessage(t.id),I.current=null,L.current===t.id&&(L.current=null),R.current.delete(t.id),E(!1)}else if(t.type===`ai_tool_call`){let n;if(t.name===`ask_user_question`){let i=o4e.safeParse(t.arguments),a=null;if(i.success?e.current?n=i.data.questions:a=`The chat UI is not available to show the question.`:a=`Malformed arguments: ${Gi(i.error)}`,a){console.error(`Cannot show ask_user_question card:`,a),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`${a} Ask the user in plain text instead.`},isError:!0});return}}if(e.current&&(I.current!==t.id&&(I.current=t.id,e.current.startAssistantMessage(t.id),E(!0)),e.current.addToolCall(t.id,t.toolCallId,t.name,n)),t.name===`ask_user_question`)ee.current.set(t.toolCallId,t.id);else if(t.name===`get_all_schema`){let n=d.getAllSchemasSnapshot();r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:n??{}}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`get_source`){let n=t.arguments.module_file_path,i=d.getSourceSnapshot(n);i.status===`success`?(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,source:i.data}}),e.current?.completeToolCall(t.id,t.toolCallId)):(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Module not found: '${n}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId))}else if(t.name===`search_content`){let n=t.arguments;p.query(n.query,n.limit,n.offset).then(n=>{r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:n??{results:[],total:0}}),e.current?.completeToolCall(t.id,t.toolCallId)}).catch(n=>{r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:String(n)},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId)})}else if(t.name===`validate_content`){let n=m.getErrors();r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:n}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`create_patch`){let n=t.arguments;(async()=>{let i=Jd.safeParse(n.patch);if(!i.success){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Invalid patch operations. Zod error: ${JSON.stringify(i.error)}`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let a=i.data,o=n.module_file_path,s=d.getAllSchemasSnapshot()?.[o];if(!s){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Module not found: '${o}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let c=d.getSourceSnapshot(o),u=c.status===`success`?c.data:void 0,p=d.createPatchId(),m=d.getParentRef();if(m===null){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Cannot apply patch yet: editor is still initializing. Ask the user to retry in a moment.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let h;try{h=await W2e({patch:a,moduleSchema:s,moduleSource:u,patchId:p,parentRef:m,transfer:l})}catch(n){let i=n instanceof jS?n.availableKeys:void 0,a=n instanceof Error?n.message:String(n),o=i&&i.length>0?` Available image keys for this session: ${i.map(e=>`"${e}"`).join(`, `)}.`:``;r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Failed to transfer session-uploaded file: ${a}.${o}`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}if(h.kind===`wrong-tool`){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`${h.reason} Retry with ${h.suggestedTool}.`,suggestedTool:h.suggestedTool},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}if(h.kind===`error`){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:h.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let g=h.patch,_=d.validatePatchResult(o,g);if(_&&`status`in _){console.error(`Patch status not valid`,_),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:_.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}if(_!==!1){let n=Up(_,d.getAllSchemasSnapshot(),d.getAllSourcesSnapshot());if(Object.keys(n).length>0){console.error(`Patch validation failed`,n),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Patch produces validation errors: ${JSON.stringify(n)}`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}}let v=await f(o,g,N.current,p,!0);v.status===`patch-synced`?(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,patchId:v.patchId,message:`Patch applied successfully.`}}),e.current?.completeToolCall(t.id,t.toolCallId)):(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:v.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId))})().then(()=>{e.current&&e.current.completeToolCall(t.id,t.toolCallId)})}else if(t.name===`add_session_image_to_gallery`){let n=t.name,i=t.arguments,a=t.toolCallId,o=t.id;(async()=>{if(!i.image_key||!i.module_file_path||!i.file_path){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Missing required arguments. Expected: image_key, module_file_path, file_path.`},isError:!0}),e.current?.errorToolCall(o,a);return}let t=i.module_file_path,s=d.getAllSchemasSnapshot()?.[t];if(!s){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Module not found: '${t}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(o,a);return}let c=d.createPatchId(),u=Op(s),p=d.getParentRef();if(p===null){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Cannot add image to gallery yet: editor is still initializing. Ask the user to retry in a moment.`},isError:!0}),e.current?.errorToolCall(o,a);return}let m;try{let e=await l({patchId:c,parentRef:p,files:[{filePath:i.file_path,key:i.image_key,isRemote:u}]});if(e.files.length===0)throw Error(`Server did not return image metadata. Ask the user to re-attach the image.`);m=e.files[0]}catch(t){let i=t instanceof jS?t.availableKeys:void 0,s=t instanceof Error?t.message:String(t),c=i&&i.length>0?` Available image keys for this session: ${i.map(e=>`"${e}"`).join(`, `)}. Retry ${n} with one of these as image_key.`:``;r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Failed to transfer image from session: ${s}.${c}`},isError:!0}),e.current?.errorToolCall(o,a);return}let h={...m.metadata};typeof i.alt==`string`&&(h.alt=i.alt),i.hotspot&&typeof i.hotspot==`object`&&typeof i.hotspot.x==`number`&&typeof i.hotspot.y==`number`&&(h.hotspot=i.hotspot);let g=jp({filePath:i.file_path,imageKey:i.image_key,metadata:h},s);if(g.kind===`wrong-tool`){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`${g.reason} Retry with ${g.suggestedTool}.`,suggestedTool:g.suggestedTool},isError:!0}),e.current?.errorToolCall(o,a);return}if(g.kind===`error`){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:g.message},isError:!0}),e.current?.errorToolCall(o,a);return}let _=g.patch,v=d.validatePatchResult(t,_);if(v&&`status`in v){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:v.message},isError:!0}),e.current?.errorToolCall(o,a);return}if(v!==!1){let t=Up(v,d.getAllSchemasSnapshot(),d.getAllSourcesSnapshot());if(Object.keys(t).length>0){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Patch produces validation errors: ${JSON.stringify(t)}`},isError:!0}),e.current?.errorToolCall(o,a);return}}let y=await f(t,_,N.current,c,!0);y.status===`patch-synced`?(r({type:`ai_tool_result`,toolCallId:a,result:{success:!0,patchId:y.patchId,filePath:m.filePath,message:`Image converted to patch successfully.`}}),e.current?.completeToolCall(o,a)):(r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:y.message},isError:!0}),e.current?.errorToolCall(o,a))})()}else if(t.name===`remove_image_gallery_entry`){let n=t.arguments,i=t.toolCallId,a=t.id;(async()=>{if(!n.module_file_path||!n.file_path){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:`Missing required arguments. Expected: module_file_path, file_path.`},isError:!0}),e.current?.errorToolCall(a,i);return}let t=n.module_file_path,o=d.getAllSchemasSnapshot()?.[t];if(!o){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:`Module not found: '${t}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(a,i);return}let s=d.getSourceSnapshot(t),c=s.status===`success`?s.data:void 0,l=Mp({filePath:n.file_path},o,c);if(l.kind===`wrong-tool`){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:`${l.reason} Retry with ${l.suggestedTool}.`,suggestedTool:l.suggestedTool},isError:!0}),e.current?.errorToolCall(a,i);return}if(l.kind===`error`){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:l.message},isError:!0}),e.current?.errorToolCall(a,i);return}let u=l.patch,p=d.validatePatchResult(t,u);if(p&&`status`in p){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:p.message},isError:!0}),e.current?.errorToolCall(a,i);return}if(p!==!1){let t=Up(p,d.getAllSchemasSnapshot(),d.getAllSourcesSnapshot());if(Object.keys(t).length>0){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:`Patch produces validation errors: ${JSON.stringify(t)}`},isError:!0}),e.current?.errorToolCall(a,i);return}}let m=await f(t,u,N.current);m.status===`patch-synced`?(r({type:`ai_tool_result`,toolCallId:i,result:{success:!0,patchId:m.patchId,filePath:n.file_path,message:`Image removed from gallery successfully.`}}),e.current?.completeToolCall(a,i)):(r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:m.message},isError:!0}),e.current?.errorToolCall(a,i))})()}else if(t.name===`navigate_to`){let n=t.arguments,i=n.source_path,a=ob(i,d.getAllSourcesSnapshot(),d.getAllSchemasSnapshot());a===null?(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Invalid source path: '${n.source_path}'. Could not resolve navigation path.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId)):(h(a),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0}}),e.current?.completeToolCall(t.id,t.toolCallId))}else if(t.name===`get_current_context`){let n=d.getAllSchemasSnapshot(),i=window.location.pathname,a=Er(i,n??{});r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{author:_?{fullName:_.fullName,email:_.email,avatar:_.avatar}:null,dateTime:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,valSourcePath:g,browserPathname:i,...a?{routeSourcePath:a}:{}}}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`get_source_path_from_route`){let n=t.arguments.pathname;if(!n)r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Missing required parameter: pathname`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);else{let i=Er(n,d.getAllSchemasSnapshot()??{});i?(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,...i}}),e.current?.completeToolCall(t.id,t.toolCallId)):(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`No next-app-router page found for pathname "${n}".`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId))}}else if(t.name===`get_patches`){let n=t.arguments,i=n.limit??20,a=n.offset??0,o=d.getAllPatchesSnapshot()??{},s=Object.entries(o).filter(([,e])=>e!==void 0).map(([e,t])=>{let n=t.authorId?v[t.authorId]:null;return{patchId:e,moduleFilePath:t.moduleFilePath,createdAt:t.createdAt,isPending:t.isPending,author:n?{fullName:n.fullName,email:n.email}:null}}).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{patches:s.slice(a,a+i),total:s.length}}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`set_session_name`){let n=t.arguments,i=String(n.name??``).slice(0,60),a=N.current;if(a==null){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`No active session.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}c(a,i).then(()=>{A(e=>e.map(e=>e.id===a?{...e,name:i}:e)),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0}}),e.current?.completeToolCall(t.id,t.toolCallId)}).catch(n=>{r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:String(n)},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId)})}else if(t.name===`show_compare_view`)h(`/val/compare`),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0}}),e.current?.completeToolCall(t.id,t.toolCallId);else if(t.name===`duplicate_source`||t.name===`empty_at_path`){let n=t.name,i=t.arguments,a=t.toolCallId,o=t.id;(async()=>{if(!i.module_file_path){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Missing required argument: module_file_path.`},isError:!0}),e.current?.errorToolCall(o,a);return}let t=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`);if(!t(i.destination_path)){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`destination_path must be an array of strings (path segments).`},isError:!0}),e.current?.errorToolCall(o,a);return}if(n===`duplicate_source`&&!t(i.source_path)){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`source_path must be an array of strings (path segments).`},isError:!0}),e.current?.errorToolCall(o,a);return}let s=i.module_file_path,c=d.getAllSchemasSnapshot()?.[s];if(!c){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Module not found: '${s}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(o,a);return}let l=d.getSourceSnapshot(s),u=l.status===`success`?l.data:void 0,p;if(p=n===`duplicate_source`?Ip({sourcePath:i.source_path,destinationPath:i.destination_path},c,u):Rp({destinationPath:i.destination_path},c,u),p.kind===`wrong-tool`){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`${p.reason} Retry with ${p.suggestedTool}.`,suggestedTool:p.suggestedTool},isError:!0}),e.current?.errorToolCall(o,a);return}if(p.kind===`error`){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:p.message},isError:!0}),e.current?.errorToolCall(o,a);return}let m=p.patch,h=d.validatePatchResult(s,m);if(h&&`status`in h){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:h.message},isError:!0}),e.current?.errorToolCall(o,a);return}if(h!==!1){let t=Up(h,d.getAllSchemasSnapshot(),d.getAllSourcesSnapshot());if(Object.keys(t).length>0){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Patch produces validation errors: ${JSON.stringify(t)}`},isError:!0}),e.current?.errorToolCall(o,a);return}}let g=await f(s,m,N.current);g.status===`patch-synced`?(r({type:`ai_tool_result`,toolCallId:a,result:{success:!0,patchId:g.patchId,message:n===`duplicate_source`?`Duplicated successfully.`:`Empty value created successfully.`}}),e.current?.completeToolCall(o,a)):(r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:g.message},isError:!0}),e.current?.errorToolCall(o,a))})()}else if(t.name===`count_entries`){let n=t.arguments;if(!n.module_file_path||!Array.isArray(n.path)||!n.path.every(e=>typeof e==`string`)){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`count_entries requires module_file_path (string) and path (string[]).`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let i=n.module_file_path,a=d.getAllSchemasSnapshot()?.[i];if(!a){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Module not found: '${i}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let o=d.getSourceSnapshot(i),s=zp(a,o.status===`success`?o.data:void 0,n.path);if(s.kind===`error`){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:s.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let c=Array.isArray(s.value)?s.value.length:Object.keys(s.value).length;r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,kind:s.container,count:c}}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`get_record_keys`){let n=t.arguments;if(!n.module_file_path||!Array.isArray(n.path)||!n.path.every(e=>typeof e==`string`)){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`get_record_keys requires module_file_path (string) and path (string[]).`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let i=n.module_file_path,a=d.getAllSchemasSnapshot()?.[i];if(!a){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Module not found: '${i}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let o=d.getSourceSnapshot(i),s=zp(a,o.status===`success`?o.data:void 0,n.path);if(s.kind===`error`){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:s.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}if(s.container!==`record`&&s.container!==`object`){let n=s.container===`array`?`use count_entries to get the array length`:s.container===`richtext`?`use count_entries to get the number of blocks`:`use get_source to read the gallery's entries`;r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Path points to a ${s.container}. get_record_keys only works on records and objects — ${n}.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let c=Object.keys(s.value),l=(e,t)=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.floor(e)):t,u=l(n.limit,100),f=l(n.offset,0);r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,kind:s.container,keys:c.slice(f,f+u),total:c.length}}),e.current?.completeToolCall(t.id,t.toolCallId)}else console.error(`Received unknown tool call in useAI`,t.name),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Unknown tool: ${t.name}`},isError:!0})}else if(t.type===`ai_error`){if(console.error(`Received AI error message`,t),!e.current)return;I.current!==t.id&&e.current.startAssistantMessage(t.id),e.current.errorAssistantMessage(t.id,t.message,t.code,t.action,t.details),I.current=null,L.current===t.id&&(L.current=null),R.current.delete(t.id),E(!1)}else if(t.type===`ai_cancelled`){if(!e.current)return;let n=I.current===t.id;n||(e.current.startAssistantMessage(t.id),t.partialResponse&&e.current.appendAssistantChunk(t.id,t.partialResponse)),!n&&!t.partialResponse&&e.current.appendAssistantChunk(t.id,`Stopped.`),e.current.completeAssistantMessage(t.id);for(let[e,n]of Array.from(ee.current.entries()))n===t.id&&ee.current.delete(e);I.current===t.id&&(I.current=null),L.current===t.id&&(L.current=null,E(!1)),R.current.delete(t.id)}else t.type===`ai_session_unhidden`||(t.type===`ai_agent_handoff`?console.log(`AI agent handoff message received - agents are working`,t):console.error(`Received unknown message type in useAI`,t))}}),[n,r,d,p,m,e,h,_,g,v]);let ne=(0,b.useCallback)(async e=>{let t=await gA(e),n=await y();if(n.status===`error`)throw Error(n.error);let{contentBaseUrl:r,contentAuthNonce:i}=n.data;if(!r)throw Error("Cannot upload AI image: content host is not configured. Set the `project` option in val.config (or VAL_PROJECT) and ensure a personal access token is available.");let a=N.current,o=a==null;a??(a=crypto.randomUUID(),N.current=a,M(a));let s={"Content-Type":e.type||`application/octet-stream`,"Content-Length":String(e.size)};i&&(s[`x-val-auth-nonce`]=i);let c=new URLSearchParams;c.set(`sessionid`,encodeURIComponent(a)),c.set(`width`,encodeURIComponent(t.width||0)),c.set(`height`,encodeURIComponent(t.height||0)),c.set(`mimetype`,encodeURIComponent(t.mimeType||e.type||`application/octet-stream`));let l=await fetch(`${r}/ai/images?${c.toString()}`,{method:`POST`,headers:s,body:await e.arrayBuffer()});if(!l.ok)throw Error(`Upload failed: ${l.status} ${l.statusText}`);let u=await l.json();return o&&P.current?.(a),u},[y]),re=(0,b.useCallback)((t,n)=>{if(w===null){let t=crypto.randomUUID();return e.current?.startAssistantMessage(t),e.current?.errorAssistantMessage(t,`No AI key is set up for this project. Add one in admin to use the assistant.`,`provider_not_configured`),!1}let i=N.current,a=i==null;i??(i=crypto.randomUUID(),N.current=i,M(i));let o=typeof t==`string`?t:r2e(t),s=(typeof t==`string`?[]:l2e(t)).filter(e=>e.key&&!e.key.startsWith(`pending:`)).map(e=>({key:e.key,name:e.alt||`inline image`,mimeType:e.mimeType,previewUrl:e.previewUrl})),c=[],l=new Set;for(let e of[...n??[],...s])l.has(e.key)||(l.add(e.key),c.push(e));let u=o;if(c.length>0){let e=c.map(e=>`- ${e.name}: image_key="${e.key}"`);u=o+`
|
|
296
|
+
`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/homepage.val.ts'`},patch:{type:`array`,description:`Array of patch operations, except that path is array of strings. Each item: { op, path, value? }. Use a session-key object as the value for image/file/richtext-inline-img — see the tool description.`,items:{type:`object`,properties:{op:{type:`string`,enum:[`replace`,`add`,`remove`]},path:{type:`array`,items:{type:`string`}},value:{}},required:[`op`,`path`]}}},required:[`module_file_path`,`patch`]}},$2e={name:`add_session_image_to_gallery`,description:`Use when the user wants a session-uploaded image added to an images gallery (a module defined with s.images(), where each entry's key is the file path and the value is the image's metadata).`,parameters:{type:`object`,properties:{image_key:{type:`string`,description:`The exact image_key string shown in the user's [Attached images] list in their message. Do NOT use any internal vision-system file id (e.g. 'file-...' or 'image-N') — only use the key string from that list verbatim.`},module_file_path:{type:`string`,description:`The images-gallery module file path, e.g. '/content/media.val.ts'.`},file_path:{type:`string`,description:`Where the image file should live on disk. This is also used as the entry key in the gallery.`},alt:{type:`string`,description:`Optional alt text.`},hotspot:{type:`object`,description:`Optional focal point in the image (numbers between 0 and 1). Provide only if the user asked for a specific crop/focal point.`,properties:{x:{type:`number`},y:{type:`number`}},required:[`x`,`y`]}},required:[`image_key`,`module_file_path`,`file_path`]}},e4e={name:`remove_image_gallery_entry`,description:`Remove an existing image entry from an images gallery (a module defined with s.images()). The system records the deletion as a 'file' patch op with value: null and removes the corresponding gallery record entry.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The images-gallery module file path, e.g. '/content/media.val.ts'.`},file_path:{type:`string`,description:`The exact entry key in the gallery (the image's file path or remote ref). Use get_source on the gallery module to list available keys.`}},required:[`module_file_path`,`file_path`]}},t4e={name:`navigate_to`,description:`Navigate the user's view to a specific location in the content tree. Use ONLY when the user explicitly asks to be shown or navigated to something, or immediately after creating/modifying content when navigating there is clearly the expected next step. Do NOT call this tool during normal information gathering.AVOIDING USING THIS TOOL IF USER IS NOT ON A BROWSER PATHNAME THAT STARTS WITH /val`,parameters:{type:`object`,properties:{source_path:{type:`string`,description:`The SourcePath to navigate to. Format: '/path/to/file.val.ts' for a module root, or '/path/to/file.val.ts?p=key."subkey"' for a specific field. String keys in the ModulePath are JSON-quoted (e.g. "title"), array indices are plain numbers (e.g. 0).`}},required:[`source_path`]}},n4e={name:`get_current_context`,description:`Get the current context: logged-in author, date/time, the val source path the user is viewing, and the browser pathname. If the browser is on a page tracked by val (a Next.js app-router route), the matching source path is included.`,parameters:{type:`object`,properties:{},required:[]}},r4e={name:`get_patches`,description:`List pending (unpublished) patches — changes that have been made but not yet published. Returns patches sorted by date descending (newest first), paginated. Each patch includes the module it affects, when it was made, and the author's name and email if available. Use this to answer questions like 'what changed recently', 'who made changes', or 'what is waiting to be published'.`,parameters:{type:`object`,properties:{limit:{type:`number`,description:`Max patches to return (default 20)`},offset:{type:`number`,description:`Number of patches to skip for pagination (default 0)`}},required:[]}},i4e={name:`get_source_path_from_route`,description:`Given a URL pathname (e.g. '/blogs/blog-1'), find the val module and source path that contains the content for that page. Only works for Next.js app router pages. Returns moduleFilePath (use with get_source) and sourcePath (use with navigate_to or create_patch).`,parameters:{type:`object`,properties:{pathname:{type:`string`,description:`The URL pathname, e.g. '/blogs/blog-1' or '/'`}},required:[`pathname`]}},a4e={name:`set_session_name`,description:`Give the current chat session a short, descriptive name once the topic is clear. Call this exactly once per session, early in the conversation when the topic becomes clear. Max 5 words, plain language (e.g. 'Update homepage hero text').`,parameters:{type:`object`,properties:{name:{type:`string`,description:`Short session name, max 60 characters`}},required:[`name`]}},o4e={name:`show_compare_view`,description:`Navigate the user to the compare view to show pending changes (patches that have not yet been published). Use when the user wants to review, inspect, or compare their unpublished changes.`,parameters:{type:`object`,properties:{},required:[]}},s4e={name:`ask_user_question`,description:`Ask the user 1-4 structured clarification questions at once and wait for their answers. Use ONLY when the request is ambiguous and a small set of concrete options would resolve it. Prefer this over open-ended follow-up text. Group related clarifications into one call rather than asking sequentially. Each question is single-select by default; set multiSelect: true on a question to let the user pick multiple options. Each question may set defaults (indices of options to pre-select). The user can also type a free-text 'Other' answer per question. Returns { answers: Array<{ question: string; selectedOptions: number[]; customAnswer: string | null }> } in the same order as the input questions. selectedOptions holds the indices of options the user kept selected (length 0 or 1 for single-select; 0..N for multi-select). customAnswer is the user's free-text 'Other' input for that question (null if they didn't type one). The user may also cancel: in that case the tool result is an error and you should follow up in plain text instead.`,parameters:{type:`object`,properties:{questions:{type:`array`,description:`1-4 questions to ask the user, all shown together in a single card.`,items:{type:`object`,properties:{question:{type:`string`,description:`The full question shown to the user. One sentence, plain language.`},header:{type:`string`,description:`Optional short label (1-4 words) shown above the question, e.g. 'Which page?'`},options:{type:`array`,description:`2-4 distinct answer options.`,items:{type:`object`,properties:{label:{type:`string`,description:`Short button label (max ~40 chars)`},description:{type:`string`,description:`Optional one-line elaboration`}},required:[`label`]}},multiSelect:{type:`boolean`,description:`If true, the user can select multiple options for this question. Defaults to false (single-select).`},defaults:{type:`array`,description:`Optional indices of options to pre-select. For single-select questions only the first entry is honored. Out-of-range indices are ignored.`,items:{type:`number`}}},required:[`question`,`options`]}}},required:[`questions`]},timeoutMs:null},c4e=q({questions:K(q({question:W(),header:W().optional().catch(void 0),options:K(q({label:W(),description:W().optional().catch(void 0)})),multiSelect:G().optional().catch(void 0),defaults:K(iu()).optional().catch(void 0)})).min(1)}),z9=`JSON Pointer AS AN ARRAY (e.g. ['posts', 'blog-1'] or ['items', '0', 'title']). Array indices are numeric strings. Record keys that contain slashes stay as a single segment, e.g. ['/foo/bar'].`,l4e=[J2e,Y2e,X2e,Z2e,Q2e,$2e,e4e,t4e,n4e,r4e,i4e,a4e,o4e,s4e,{name:`duplicate_source`,description:`Duplicate the value at 'source_path' to 'destination_path' within the same Val module. Use the op rule: if the destination's parent is an array or record, the patch uses 'add' (creating a new entry); if the destination's parent is an object, the patch uses 'replace'; if destination_path is empty, replaces the whole module. PREFER this tool over empty_at_path when there is an existing similar entry to copy — copying preserves nested structure, optional fields, and image references correctly, while emptying often produces nulls the model would have to fill in. For richtext destinations or images-gallery destinations, use create_patch or add_session_image_to_gallery instead.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/blog.val.ts'.`},source_path:{type:`array`,items:{type:`string`},description:`Path within the module to read FROM. `+z9},destination_path:{type:`array`,items:{type:`string`},description:`Path within the SAME module to write TO. `+z9}},required:[`module_file_path`,`source_path`,`destination_path`]}},{name:`empty_at_path`,description:`Create an empty value (built from the schema via emptyOf) at 'destination_path' in a Val module. Same op rule as duplicate_source (array/record parent → 'add', object parent → 'replace', empty path → 'replace'). Use this ONLY when there is no good donor to duplicate from — duplicate_source is almost always better when something similar exists, because empty values for optional fields become null and image/file fields become null (which then need a follow-up upload). For richtext destinations or images-gallery destinations, use create_patch or add_session_image_to_gallery instead.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/blog.val.ts'.`},destination_path:{type:`array`,items:{type:`string`},description:`Path within the module to write to. `+z9}},required:[`module_file_path`,`destination_path`]}},{name:`count_entries`,description:`Count the entries of the value at 'path' in a Val module — record or gallery keys, object keys, array indices, or richtext top-level blocks. Use this before paging through a large record/array or to answer 'how many X are there?' without pulling the entire module. Returns { kind: 'array' | 'record' | 'object' | 'gallery' | 'richtext', count: number }. Fails for anything that is not a container - primitives, and image/file/union values (which are objects at runtime but hold no entries).`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/blog.val.ts'.`},path:{type:`array`,items:{type:`string`},description:`Path within the module pointing at the collection to count. Pass [] for the module root. `+z9}},required:[`module_file_path`,`path`]}},{name:`get_record_keys`,description:`List the keys of the record (or object) at 'path' in a Val module, with pagination. Use this to enumerate entries without pulling their contents — e.g. to find which slug to operate on next. Returns { kind: 'record' | 'object', keys: string[], total: number }. Fails on arrays, primitives, richtext and galleries - use count_entries for array/richtext sizes and get_source to read a gallery.`,parameters:{type:`object`,properties:{module_file_path:{type:`string`,description:`The Val module file path, e.g. '/content/blog.val.ts'.`},path:{type:`array`,items:{type:`string`},description:`Path within the module pointing at the record/object. Pass [] for the module root. `+z9},limit:{type:`number`,description:`Max keys to return (default 100).`},offset:{type:`number`,description:`Number of keys to skip for pagination (default 0).`}},required:[`module_file_path`,`path`]}}];function u4e(e,t){let{subscribeToWsMessages:n,sendWsMessage:r,isWsConnected:i,aiAuthError:a,aiGetSessions:o,aiGetSessionMessages:s,aiSetSessionName:c,aiSessionImagesToPatchFile:l}=zS(),u=nb(),d=(0,b.useMemo)(()=>{let e=u?.system??null;return{getAllSchemasSnapshot(){return e?.schemaStore.all()??{}},getAllSourcesSnapshot(){return e?.sourceStore.allSources()??{}},getSourceSnapshot(t){let n=e?.sourceStore.moduleSource(t);return n===void 0?{status:`not-found`}:{status:`success`,data:n}},createPatchId(){if(e===null)throw Error(`Cannot mint a patch id: no store system is mounted`);return e.patchStore.mintPatchId()},getParentRef(){return e?.patchSync.currentParentRef()??null},validatePatchResult(t,n){if(e===null)return{status:`no-source`,message:`No store system is mounted`};let r=e.sourceStore.moduleSource(t);if(r===void 0)return{status:`no-source`,message:`Content at '${t}' is not yet initialized`};if(e.schemaStore.get(t)===void 0)return{status:`no-schema`,message:`Schema not found for '${t}'`};let i=n.filter(e=>e.op!==`file`),a=Yr(JSON.parse(JSON.stringify(r)),q2e,i);if(te.isErr(a))return{status:`patch-error`,message:a.error.message};let o=e.host.validateSpeculative(t,a.value);return o.status===`unknown-module`?{status:`no-schema`,message:`No schema instance for '${t}'`}:o.errors},getAllPatchesSnapshot(){if(e===null)return{};let t={};for(let n of e.patchStore.allRecords())t[n.patchId]={moduleFilePath:n.moduleFilePath,createdAt:n.createdAt??``,isPending:e.patchStore.isPending(n.patchId),authorId:n.authorId??null};return t}}},[u]),f=(0,b.useCallback)(async(e,t,n,r,i)=>{if(u===null)return{status:`patch-error`,message:`Cannot write: no store system is mounted.`};let a=await u.system.patchStore.createPatch(e,t,void 0,void 0,void 0,r,n??void 0,`image`,i);return a.status===`created`?{status:`patch-synced`,patchId:a.record.patchId}:{status:`patch-error`,message:a.message}},[u]),p=z2e(),m=B2e(),{navigate:h,currentSourcePath:g}=GC(),_=tC(),v=sC(),y=noe(),x=bb()?.ai?.chat?.experimental?.enable===!0,{selected:S}=VS(),C=BS(),w=S??C,[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)([]),[j,M]=(0,b.useState)(null),N=(0,b.useRef)(null),P=(0,b.useRef)(t?.onSessionBorn),F=(0,b.useRef)(t?.onSessionCleared);(0,b.useEffect)(()=>{P.current=t?.onSessionBorn,F.current=t?.onSessionCleared});let I=(0,b.useRef)(null),L=(0,b.useRef)(null),R=(0,b.useRef)(new Set),ee=(0,b.useRef)(new Map);(0,b.useEffect)(()=>n(t=>{if(!(`id`in t&&!R.current.has(t.id))){if(t.type===`ai_streaming`){if(!e.current)return;I.current!==t.id&&(I.current=t.id,e.current.startAssistantMessage(t.id),E(!0)),e.current.appendAssistantChunk(t.id,t.chunk)}else if(t.type===`ai_response`){if(!e.current)return;I.current!==t.id&&(e.current.startAssistantMessage(t.id),e.current.appendAssistantChunk(t.id,t.response)),e.current.completeAssistantMessage(t.id),I.current=null,L.current===t.id&&(L.current=null),R.current.delete(t.id),E(!1)}else if(t.type===`ai_tool_call`){let n;if(t.name===`ask_user_question`){let i=c4e.safeParse(t.arguments),a=null;if(i.success?e.current?n=i.data.questions:a=`The chat UI is not available to show the question.`:a=`Malformed arguments: ${Gi(i.error)}`,a){console.error(`Cannot show ask_user_question card:`,a),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`${a} Ask the user in plain text instead.`},isError:!0});return}}if(e.current&&(I.current!==t.id&&(I.current=t.id,e.current.startAssistantMessage(t.id),E(!0)),e.current.addToolCall(t.id,t.toolCallId,t.name,n)),t.name===`ask_user_question`)ee.current.set(t.toolCallId,t.id);else if(t.name===`get_all_schema`){let n=d.getAllSchemasSnapshot();r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:n??{}}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`get_source`){let n=t.arguments.module_file_path,i=d.getSourceSnapshot(n);i.status===`success`?(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,source:i.data}}),e.current?.completeToolCall(t.id,t.toolCallId)):(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Module not found: '${n}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId))}else if(t.name===`search_content`){let n=t.arguments;p.query(n.query,n.limit,n.offset).then(n=>{r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:n??{results:[],total:0}}),e.current?.completeToolCall(t.id,t.toolCallId)}).catch(n=>{r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:String(n)},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId)})}else if(t.name===`validate_content`){let n=m.getErrors();r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:n}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`create_patch`){let n=t.arguments;(async()=>{let i=Jd.safeParse(n.patch);if(!i.success){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Invalid patch operations. Zod error: ${JSON.stringify(i.error)}`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let a=i.data,o=n.module_file_path,s=d.getAllSchemasSnapshot()?.[o];if(!s){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Module not found: '${o}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let c=d.getSourceSnapshot(o),u=c.status===`success`?c.data:void 0,p=d.createPatchId(),m=d.getParentRef();if(m===null){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Cannot apply patch yet: editor is still initializing. Ask the user to retry in a moment.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let h;try{h=await K2e({patch:a,moduleSchema:s,moduleSource:u,patchId:p,parentRef:m,transfer:l})}catch(n){let i=n instanceof jS?n.availableKeys:void 0,a=n instanceof Error?n.message:String(n),o=i&&i.length>0?` Available image keys for this session: ${i.map(e=>`"${e}"`).join(`, `)}.`:``;r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Failed to transfer session-uploaded file: ${a}.${o}`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}if(h.kind===`wrong-tool`){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`${h.reason} Retry with ${h.suggestedTool}.`,suggestedTool:h.suggestedTool},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}if(h.kind===`error`){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:h.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let g=h.patch,_=d.validatePatchResult(o,g);if(_&&`status`in _){console.error(`Patch status not valid`,_),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:_.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}if(_!==!1){let n=Up(_,d.getAllSchemasSnapshot(),d.getAllSourcesSnapshot());if(Object.keys(n).length>0){console.error(`Patch validation failed`,n),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Patch produces validation errors: ${JSON.stringify(n)}`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}}let v=await f(o,g,N.current,p,!0);v.status===`patch-synced`?(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,patchId:v.patchId,message:`Patch applied successfully.`}}),e.current?.completeToolCall(t.id,t.toolCallId)):(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:v.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId))})().then(()=>{e.current&&e.current.completeToolCall(t.id,t.toolCallId)})}else if(t.name===`add_session_image_to_gallery`){let n=t.name,i=t.arguments,a=t.toolCallId,o=t.id;(async()=>{if(!i.image_key||!i.module_file_path||!i.file_path){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Missing required arguments. Expected: image_key, module_file_path, file_path.`},isError:!0}),e.current?.errorToolCall(o,a);return}let t=i.module_file_path,s=d.getAllSchemasSnapshot()?.[t];if(!s){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Module not found: '${t}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(o,a);return}let c=d.createPatchId(),u=Op(s),p=d.getParentRef();if(p===null){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Cannot add image to gallery yet: editor is still initializing. Ask the user to retry in a moment.`},isError:!0}),e.current?.errorToolCall(o,a);return}let m;try{let e=await l({patchId:c,parentRef:p,files:[{filePath:i.file_path,key:i.image_key,isRemote:u}]});if(e.files.length===0)throw Error(`Server did not return image metadata. Ask the user to re-attach the image.`);m=e.files[0]}catch(t){let i=t instanceof jS?t.availableKeys:void 0,s=t instanceof Error?t.message:String(t),c=i&&i.length>0?` Available image keys for this session: ${i.map(e=>`"${e}"`).join(`, `)}. Retry ${n} with one of these as image_key.`:``;r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Failed to transfer image from session: ${s}.${c}`},isError:!0}),e.current?.errorToolCall(o,a);return}let h={...m.metadata};typeof i.alt==`string`&&(h.alt=i.alt),i.hotspot&&typeof i.hotspot==`object`&&typeof i.hotspot.x==`number`&&typeof i.hotspot.y==`number`&&(h.hotspot=i.hotspot);let g=jp({filePath:i.file_path,imageKey:i.image_key,metadata:h},s);if(g.kind===`wrong-tool`){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`${g.reason} Retry with ${g.suggestedTool}.`,suggestedTool:g.suggestedTool},isError:!0}),e.current?.errorToolCall(o,a);return}if(g.kind===`error`){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:g.message},isError:!0}),e.current?.errorToolCall(o,a);return}let _=g.patch,v=d.validatePatchResult(t,_);if(v&&`status`in v){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:v.message},isError:!0}),e.current?.errorToolCall(o,a);return}if(v!==!1){let t=Up(v,d.getAllSchemasSnapshot(),d.getAllSourcesSnapshot());if(Object.keys(t).length>0){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Patch produces validation errors: ${JSON.stringify(t)}`},isError:!0}),e.current?.errorToolCall(o,a);return}}let y=await f(t,_,N.current,c,!0);y.status===`patch-synced`?(r({type:`ai_tool_result`,toolCallId:a,result:{success:!0,patchId:y.patchId,filePath:m.filePath,message:`Image converted to patch successfully.`}}),e.current?.completeToolCall(o,a)):(r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:y.message},isError:!0}),e.current?.errorToolCall(o,a))})()}else if(t.name===`remove_image_gallery_entry`){let n=t.arguments,i=t.toolCallId,a=t.id;(async()=>{if(!n.module_file_path||!n.file_path){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:`Missing required arguments. Expected: module_file_path, file_path.`},isError:!0}),e.current?.errorToolCall(a,i);return}let t=n.module_file_path,o=d.getAllSchemasSnapshot()?.[t];if(!o){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:`Module not found: '${t}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(a,i);return}let s=d.getSourceSnapshot(t),c=s.status===`success`?s.data:void 0,l=Mp({filePath:n.file_path},o,c);if(l.kind===`wrong-tool`){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:`${l.reason} Retry with ${l.suggestedTool}.`,suggestedTool:l.suggestedTool},isError:!0}),e.current?.errorToolCall(a,i);return}if(l.kind===`error`){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:l.message},isError:!0}),e.current?.errorToolCall(a,i);return}let u=l.patch,p=d.validatePatchResult(t,u);if(p&&`status`in p){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:p.message},isError:!0}),e.current?.errorToolCall(a,i);return}if(p!==!1){let t=Up(p,d.getAllSchemasSnapshot(),d.getAllSourcesSnapshot());if(Object.keys(t).length>0){r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:`Patch produces validation errors: ${JSON.stringify(t)}`},isError:!0}),e.current?.errorToolCall(a,i);return}}let m=await f(t,u,N.current);m.status===`patch-synced`?(r({type:`ai_tool_result`,toolCallId:i,result:{success:!0,patchId:m.patchId,filePath:n.file_path,message:`Image removed from gallery successfully.`}}),e.current?.completeToolCall(a,i)):(r({type:`ai_tool_result`,toolCallId:i,result:{success:!1,error:m.message},isError:!0}),e.current?.errorToolCall(a,i))})()}else if(t.name===`navigate_to`){let n=t.arguments,i=n.source_path,a=ob(i,d.getAllSourcesSnapshot(),d.getAllSchemasSnapshot());a===null?(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Invalid source path: '${n.source_path}'. Could not resolve navigation path.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId)):(h(a),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0}}),e.current?.completeToolCall(t.id,t.toolCallId))}else if(t.name===`get_current_context`){let n=d.getAllSchemasSnapshot(),i=window.location.pathname,a=Er(i,n??{});r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{author:_?{fullName:_.fullName,email:_.email,avatar:_.avatar}:null,dateTime:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,valSourcePath:g,browserPathname:i,...a?{routeSourcePath:a}:{}}}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`get_source_path_from_route`){let n=t.arguments.pathname;if(!n)r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Missing required parameter: pathname`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);else{let i=Er(n,d.getAllSchemasSnapshot()??{});i?(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,...i}}),e.current?.completeToolCall(t.id,t.toolCallId)):(r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`No next-app-router page found for pathname "${n}".`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId))}}else if(t.name===`get_patches`){let n=t.arguments,i=n.limit??20,a=n.offset??0,o=d.getAllPatchesSnapshot()??{},s=Object.entries(o).filter(([,e])=>e!==void 0).map(([e,t])=>{let n=t.authorId?v[t.authorId]:null;return{patchId:e,moduleFilePath:t.moduleFilePath,createdAt:t.createdAt,isPending:t.isPending,author:n?{fullName:n.fullName,email:n.email}:null}}).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime());r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{patches:s.slice(a,a+i),total:s.length}}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`set_session_name`){let n=t.arguments,i=String(n.name??``).slice(0,60),a=N.current;if(a==null){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`No active session.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}c(a,i).then(()=>{A(e=>e.map(e=>e.id===a?{...e,name:i}:e)),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0}}),e.current?.completeToolCall(t.id,t.toolCallId)}).catch(n=>{r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:String(n)},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId)})}else if(t.name===`show_compare_view`)h(`/val/compare`),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0}}),e.current?.completeToolCall(t.id,t.toolCallId);else if(t.name===`duplicate_source`||t.name===`empty_at_path`){let n=t.name,i=t.arguments,a=t.toolCallId,o=t.id;(async()=>{if(!i.module_file_path){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Missing required argument: module_file_path.`},isError:!0}),e.current?.errorToolCall(o,a);return}let t=e=>Array.isArray(e)&&e.every(e=>typeof e==`string`);if(!t(i.destination_path)){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`destination_path must be an array of strings (path segments).`},isError:!0}),e.current?.errorToolCall(o,a);return}if(n===`duplicate_source`&&!t(i.source_path)){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`source_path must be an array of strings (path segments).`},isError:!0}),e.current?.errorToolCall(o,a);return}let s=i.module_file_path,c=d.getAllSchemasSnapshot()?.[s];if(!c){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Module not found: '${s}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(o,a);return}let l=d.getSourceSnapshot(s),u=l.status===`success`?l.data:void 0,p;if(p=n===`duplicate_source`?Ip({sourcePath:i.source_path,destinationPath:i.destination_path},c,u):Rp({destinationPath:i.destination_path},c,u),p.kind===`wrong-tool`){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`${p.reason} Retry with ${p.suggestedTool}.`,suggestedTool:p.suggestedTool},isError:!0}),e.current?.errorToolCall(o,a);return}if(p.kind===`error`){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:p.message},isError:!0}),e.current?.errorToolCall(o,a);return}let m=p.patch,h=d.validatePatchResult(s,m);if(h&&`status`in h){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:h.message},isError:!0}),e.current?.errorToolCall(o,a);return}if(h!==!1){let t=Up(h,d.getAllSchemasSnapshot(),d.getAllSourcesSnapshot());if(Object.keys(t).length>0){r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:`Patch produces validation errors: ${JSON.stringify(t)}`},isError:!0}),e.current?.errorToolCall(o,a);return}}let g=await f(s,m,N.current);g.status===`patch-synced`?(r({type:`ai_tool_result`,toolCallId:a,result:{success:!0,patchId:g.patchId,message:n===`duplicate_source`?`Duplicated successfully.`:`Empty value created successfully.`}}),e.current?.completeToolCall(o,a)):(r({type:`ai_tool_result`,toolCallId:a,result:{success:!1,error:g.message},isError:!0}),e.current?.errorToolCall(o,a))})()}else if(t.name===`count_entries`){let n=t.arguments;if(!n.module_file_path||!Array.isArray(n.path)||!n.path.every(e=>typeof e==`string`)){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`count_entries requires module_file_path (string) and path (string[]).`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let i=n.module_file_path,a=d.getAllSchemasSnapshot()?.[i];if(!a){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Module not found: '${i}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let o=d.getSourceSnapshot(i),s=zp(a,o.status===`success`?o.data:void 0,n.path);if(s.kind===`error`){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:s.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let c=Array.isArray(s.value)?s.value.length:Object.keys(s.value).length;r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,kind:s.container,count:c}}),e.current?.completeToolCall(t.id,t.toolCallId)}else if(t.name===`get_record_keys`){let n=t.arguments;if(!n.module_file_path||!Array.isArray(n.path)||!n.path.every(e=>typeof e==`string`)){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`get_record_keys requires module_file_path (string) and path (string[]).`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let i=n.module_file_path,a=d.getAllSchemasSnapshot()?.[i];if(!a){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Module not found: '${i}'. Use get_all_schema to see available modules.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let o=d.getSourceSnapshot(i),s=zp(a,o.status===`success`?o.data:void 0,n.path);if(s.kind===`error`){r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:s.message},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}if(s.container!==`record`&&s.container!==`object`){let n=s.container===`array`?`use count_entries to get the array length`:s.container===`richtext`?`use count_entries to get the number of blocks`:`use get_source to read the gallery's entries`;r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Path points to a ${s.container}. get_record_keys only works on records and objects — ${n}.`},isError:!0}),e.current?.errorToolCall(t.id,t.toolCallId);return}let c=Object.keys(s.value),l=(e,t)=>typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.floor(e)):t,u=l(n.limit,100),f=l(n.offset,0);r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!0,kind:s.container,keys:c.slice(f,f+u),total:c.length}}),e.current?.completeToolCall(t.id,t.toolCallId)}else console.error(`Received unknown tool call in useAI`,t.name),r({type:`ai_tool_result`,toolCallId:t.toolCallId,result:{success:!1,error:`Unknown tool: ${t.name}`},isError:!0})}else if(t.type===`ai_error`){if(console.error(`Received AI error message`,t),!e.current)return;I.current!==t.id&&e.current.startAssistantMessage(t.id),e.current.errorAssistantMessage(t.id,t.message,t.code,t.action,t.details),I.current=null,L.current===t.id&&(L.current=null),R.current.delete(t.id),E(!1)}else if(t.type===`ai_cancelled`){if(!e.current)return;let n=I.current===t.id;n||(e.current.startAssistantMessage(t.id),t.partialResponse&&e.current.appendAssistantChunk(t.id,t.partialResponse)),!n&&!t.partialResponse&&e.current.appendAssistantChunk(t.id,`Stopped.`),e.current.completeAssistantMessage(t.id);for(let[e,n]of Array.from(ee.current.entries()))n===t.id&&ee.current.delete(e);I.current===t.id&&(I.current=null),L.current===t.id&&(L.current=null,E(!1)),R.current.delete(t.id)}else t.type===`ai_session_unhidden`||(t.type===`ai_agent_handoff`?console.log(`AI agent handoff message received - agents are working`,t):console.error(`Received unknown message type in useAI`,t))}}),[n,r,d,p,m,e,h,_,g,v]);let ne=(0,b.useCallback)(async e=>{let t=await gA(e),n=await y();if(n.status===`error`)throw Error(n.error);let{contentBaseUrl:r,contentAuthNonce:i}=n.data;if(!r)throw Error("Cannot upload AI image: content host is not configured. Set the `project` option in val.config (or VAL_PROJECT) and ensure a personal access token is available.");let a=N.current,o=a==null;a??(a=crypto.randomUUID(),N.current=a,M(a));let s={"Content-Type":e.type||`application/octet-stream`,"Content-Length":String(e.size)};i&&(s[`x-val-auth-nonce`]=i);let c=new URLSearchParams;c.set(`sessionid`,encodeURIComponent(a)),c.set(`width`,encodeURIComponent(t.width||0)),c.set(`height`,encodeURIComponent(t.height||0)),c.set(`mimetype`,encodeURIComponent(t.mimeType||e.type||`application/octet-stream`));let l=await fetch(`${r}/ai/images?${c.toString()}`,{method:`POST`,headers:s,body:await e.arrayBuffer()});if(!l.ok)throw Error(`Upload failed: ${l.status} ${l.statusText}`);let u=await l.json();return o&&P.current?.(a),u},[y]),re=(0,b.useCallback)((t,n)=>{if(w===null){let t=crypto.randomUUID();return e.current?.startAssistantMessage(t),e.current?.errorAssistantMessage(t,`No AI key is set up for this project. Add one in admin to use the assistant.`,`provider_not_configured`),!1}let i=N.current,a=i==null;i??(i=crypto.randomUUID(),N.current=i,M(i));let o=typeof t==`string`?t:i2e(t),s=(typeof t==`string`?[]:u2e(t)).filter(e=>e.key&&!e.key.startsWith(`pending:`)).map(e=>({key:e.key,name:e.alt||`inline image`,mimeType:e.mimeType,previewUrl:e.previewUrl})),c=[],l=new Set;for(let e of[...n??[],...s])l.has(e.key)||(l.add(e.key),c.push(e));let u=o;if(c.length>0){let e=c.map(e=>`- ${e.name}: image_key="${e.key}"`);u=o+`
|
|
297
297
|
|
|
298
298
|
[Attached images — when calling convert_session_image_to_patch, use the exact image_key string from this list (NOT any vision-system file id):
|
|
299
299
|
`+e.join(`
|
|
@@ -379,8 +379,8 @@ Do not describe what you will do unless you do it for clarification — just do
|
|
|
379
379
|
- Be concise and friendly.
|
|
380
380
|
- This is a CMS, it is not a chat. The intention of user is to find and edit content. If user asks existential questions, interpret them as a technical question. If for example they ask "who they are", they probably mean "what is my profile". If they ask "what can you do?", they probably want to know what kind of content changes you can make or what information you can provide about their content. Always interpret vague questions in a way that assumes the user wants to understand or change their content, rather than asking about the assistant itself.
|
|
381
381
|
- Confirm changes in plain language after every successful update.
|
|
382
|
-
- If something goes wrong, explain what happened and what to do next.`,tools:s4e}]},f=r(d);return f&&(L.current=d.id,R.current.add(d.id)),f&&a&&P.current?.(i),f},[w,e,r]),ie=(0,b.useCallback)(t=>{t&&e.current?.errorAssistantMessage(t,`Lost the connection to the AI service, so your response was not delivered. Please try again.`),I.current=null,E(!1)},[e]),ae=(0,b.useCallback)(()=>{let t=L.current;if(t===null){let t=I.current;return t!==null&&(e.current?.completeAssistantMessage(t),I.current=null),E(!1),!1}return r({type:`ai_cancel`,id:t})||(I.current!==t&&(e.current?.startAssistantMessage(t),e.current?.appendAssistantChunk(t,`Stopped.`)),e.current?.completeAssistantMessage(t),L.current=null,I.current=null,E(!1)),!0},[r,e]),oe=(0,b.useCallback)((e,t)=>{let n=ee.current.get(e);ee.current.delete(e),r({type:`ai_tool_result`,toolCallId:e,result:{answers:t}})||ie(n)},[r,ie]),se=(0,b.useCallback)(e=>{let t=ee.current.get(e);ee.current.delete(e),r({type:`ai_tool_result`,toolCallId:e,result:{error:`User declined to answer the question(s).`},isError:!0})||ie(t)},[r,ie]),ce=(0,b.useCallback)(e=>{for(let t of ee.current.keys())r({type:`ai_tool_result`,toolCallId:t,result:{error:e},isError:!0});ee.current.clear()},[r]),le=(0,b.useCallback)(()=>{ce(`User started a new session.`),N.current=null,M(null),e.current?.clearMessages(),F.current?.()},[e,ce]),ue=(0,b.useCallback)(async e=>{let t=await o(e);return A(t.sessions),t.sessions},[o]),de=(0,b.useCallback)(async(e,t)=>{await c(e,t),A(n=>n.map(n=>n.id===e?{...n,name:t}:n))},[c]),fe=(0,b.useCallback)(async t=>{ce(`User switched to a different session.`),N.current=t,M(t),e.current?.clearMessages(),O(!0);try{let n=(await s(t)).messages?.filter(e=>e.role===`user`||e.role===`assistant`).map((e,n)=>({id:`history-${t}-${n}`,role:e.role,content:e.content,status:`complete`}));e.current?.loadMessages(n),P.current?.(t)}catch(t){console.warn(`Failed to load session messages, clearing:`,t),N.current=null,M(null),e.current?.clearMessages(),F.current?.()}finally{O(!1)}},[e,s,ce]),pe=(0,b.useRef)(t?.initialSessionId??null);return(0,b.useEffect)(()=>{x&&(ue({limit:1}).catch(()=>{}),pe.current!=null&&fe(pe.current))},[x]),{sendMessage:re,uploadAiImage:ne,isStreaming:T,cancel:ae,isLoadingSession:D,isConnected:i,authError:a,newSession:le,sessions:k,currentSessionId:j,getSessions:ue,setSessionName:de,loadSession:fe,answerToolQuestions:oe,cancelToolQuestion:se}}function l4e({className:e}){let t=(0,b.useRef)(null),n=QS(),r=Ice(),{chatEditorRef:i,flushPendingFieldRefs:a}=wS(),o=VS(),{sessionParam:s,setSessionParam:c}=KC(),{sendMessage:l,uploadAiImage:u,isConnected:d,authError:f,newSession:p,sessions:m,currentSessionId:h,getSessions:g,setSessionName:_,loadSession:v,isLoadingSession:y,answerToolQuestions:x,cancelToolQuestion:S,cancel:C}=c4e(t,{initialSessionId:(0,b.useRef)(s).current,onSessionBorn:e=>{c(e,{replace:!0});try{sessionStorage.setItem(Zf,e)}catch{}},onSessionCleared:()=>{c(null,{replace:!0});try{sessionStorage.removeItem(Zf)}catch{}}});return(0,b.useEffect)(()=>{let e=requestAnimationFrame(()=>a());return()=>cancelAnimationFrame(e)},[a]),(0,Y.jsx)(k2e,{ref:t,className:e,chatEditorRef:i,onSendMessage:l,onCancel:C,models:o.models,selectedModel:o.selected,onSelectModel:o.select,onUploadFile:u,onNewSession:p,isConnected:d,authError:f,unavailable:r?{message:r.message,onRetry:r.retry}:void 0,mode:n,sessions:m,currentSessionId:h,onLoadSession:v,onFetchSessions:g,onSetSessionName:_,isLoadingSession:y,onAnswerToolQuestions:x,onCancelToolQuestion:S})}function u4e(){let e=Iqe();return IS()===`login-required`?(0,Y.jsx)(`div`,{className:`min-h-[100svh] bg-bg-primary`,children:(0,Y.jsx)(NYe,{})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(d4e,{state:e}),(0,Y.jsx)(hXe,{}),(0,Y.jsx)(_Xe,{}),(0,Y.jsx)(LYe,{}),(0,Y.jsx)(VYe,{})]})}function d4e({state:e}){let{theme:t,setTheme:n}=Qy(),r=QS(),i=Lce(),{isAIChatEnabled:a,setOpenAIChatImpl:o}=wS(),s=TS(),c=GC(),l=_ce(),u=JS(),{patchErrors:d}=oC(),f=Fb(),[p,m]=(0,b.useState)(``),h=Rqe(p),g=Wqe(),[_,v]=(0,b.useState)(()=>({panel:g.initial.panel,canvasOpen:g.initial.canvasOpen,canvasView:g.initial.canvasView,canvasTransform:g.initial.canvasTransform})),{isPublishing:y}=eC(),x=xce(),S=KS(),{deletePatches:C}=RS(),w=YS(),T=GS(),E=US(),D=sC(),O=nC(),k=eb(),A=(0,b.useMemo)(()=>w.filter(e=>!T.has(e)),[w,T]),j=(0,b.useMemo)(()=>{if(E.status!==`success`)return[];let e=new Set(A),t=new Set;for(let n of E.data)for(let r of n.patches)r.author!==null&&r.author!==O&&e.has(r.patchId)&&t.add(r.author);return[...t].map(e=>D?.[e]?.fullName).filter(e=>!!e)},[E,A,D,O]),M=Sce(),N=Cce(),[P,F]=(0,b.useState)();(0,b.useEffect)(()=>{let e=()=>{let e=i8(window.location.search);F(t=>({epoch:(t?.epoch??0)+1,panel:e.panel,canvasOpen:e.canvasOpen,canvasView:e.canvasView}))};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let I=(0,b.useRef)(_);I.current=_;let L=(0,b.useCallback)(()=>{F(e=>({epoch:(e?.epoch??0)+1,panel:`ai`,canvasOpen:I.current.canvasOpen,canvasView:I.current.canvasView}))},[]);(0,b.useEffect)(()=>{if(a)return o(L),()=>o(null)},[a,o,L]);let R=e.status===`success`?e.data:g4e,ee=(0,b.useMemo)(()=>p4e(R,c.currentSourcePath),[R,c.currentSourcePath]),te=(0,b.useMemo)(()=>ee===null?null:Z6(R,ee),[R,ee]),ne=(0,b.useCallback)(e=>{c.navigate(e.sourcePath)},[c]),re=c.focusedSourcePath??(c.currentSourcePath||null);(0,b.useEffect)(()=>{if(_.canvasView!==`normal`)return;let e=c.focusedSourcePath;e&&HC(e)},[_.canvasView,c.focusedSourcePath]);let ie=(0,b.useCallback)(e=>(0,Y.jsx)(k8,{path:c.currentSourcePath||e.sourcePath,showModuleGalleryChild:null}),[c.currentSourcePath]),ae=te?.kind===`page`?te.urlPath:null,[oe,se]=(0,b.useState)(g.initial.canvasRoute),ce=(0,b.useRef)(!0);(0,b.useEffect)(()=>{if(ce.current){ce.current=!1;return}se(null)},[ae]);let le=(0,b.useMemo)(()=>{let e=new Map,t=n=>{for(let r of n)r.sourcePath!==void 0&&(e.has(r.urlPath)||e.set(r.urlPath,r.sourcePath)),t(r.children??[])};return t(R.pages),e},[R.pages]),ue=(0,b.useCallback)(e=>{se(e);let t=le.get(e);t!==void 0&&c.navigate(t)},[le,c]),de=(0,b.useMemo)(()=>Array.from(le.keys()).sort((e,t)=>e.localeCompare(t)),[le]),fe=(0,b.useMemo)(()=>Oqe(de),[de]),pe=ae??fe,me=oe??pe;Gqe(g.write,(0,b.useMemo)(()=>({..._,canvasRoute:oe!==null&&oe!==pe?oe:null}),[_,oe,pe]));let[he,ge]=(0,b.useState)([]),_e=(0,b.useMemo)(()=>{let e=new Set,t=[];for(let n of he)for(let r of n.paths)e.has(r)||(e.add(r),t.push(r));return t},[he]),ve=(0,b.useMemo)(()=>{let e=new URL(me,window.location.origin).toString();return`/api/val/enable?redirect_to=${encodeURIComponent(e)}`},[me]),ye=(0,b.useCallback)(()=>{window.open(ve,`_blank`,`noopener,noreferrer`)},[ve]),be=Mb(),xe=(0,b.useCallback)(e=>rA(e,be),[be]),Se=yJe(),Ce=DRe(),we=(0,b.useCallback)(e=>{let t=e.moduleFilePath;c.navigate(t),Ce(t)},[c,Ce]),z=Db(),B=(0,b.useCallback)(e=>{let t=z(e)??e;c.navigate(t,{scrollToPath:e})},[c,z]),Te=ioe(),Ee=Nce(),V=(0,b.useCallback)(e=>{let t=e[0];if(t===void 0)return Ee(`That element on the page has no content behind it`,`The page reported a selection with no source path. Check that @valbuild/next and @valbuild/ui are on the same version.`),!1;let n=Te(t);return n.status===`resolved`?(c.navigate(n.path,{scrollToPath:t}),!0):(Ee(...h4e(n,t)),!1)},[c,Te,Ee]),De=(0,b.useMemo)(()=>({width:e,height:t,reloadKey:n,isPicking:r,onRequestReload:i,onRefreshingChange:a,onPinch:o,onZoom:s,onPicked:c})=>(0,Y.jsx)(Tqe,{url:me,width:e,height:t,reloadKey:n,isPicking:r,highlightedPath:r?re:null,onElements:ge,onPick:e=>{V(e)&&c()},onPinch:o,onZoom:s,onRequestReload:i,onRefreshingChange:a}),[me,re,V]),Oe=(0,b.useMemo)(()=>f===void 0?[]:Object.keys(f),[f]),ke=(0,b.useCallback)(e=>{let t=Oe.filter(t=>t.startsWith(e.id));c.navigate(LC,{errorFields:t.length>0?t:Oe})},[c,Oe]),Ae=(0,b.useCallback)(()=>{c.navigate(IC)},[c]),je=(0,b.useMemo)(()=>{if(r===`http`)return()=>{let e=encodeURIComponent(window.location.href);window.location.href=`/api/val/logout?redirect_to=${e}`}},[r]),Me=(0,b.useMemo)(()=>Object.values(d??{}).some(e=>Object.keys(e??{}).length>0)||l===`service-unavailable`?`error`:u.length>0?`saving`:`saved`,[d,l,u]),Ne=y?`publishing`:`idle`,{autoPublish:Pe,setAutoPublish:Fe}=aC(),Ie=!c.isCompareView&&!c.isErrorsView&&ee===null&&c.currentSourcePath?c.currentSourcePath:null,Le=c.isCompareView?(0,Y.jsx)(f4e,{}):c.isErrorsView?(0,Y.jsx)(RJe,{}):Ie?(0,Y.jsx)(k8,{path:Ie,showModuleGalleryChild:null}):null;return(0,Y.jsx)(Sqe,{data:R,theme:t===`light`?`light`:`dark`,onThemeChange:n,mode:r,selectionId:Le?null:ee,onSelectionChange:ne,renderEditor:ie,editorOverride:Le,publishSlot:(0,Y.jsx)(z8,{}),publishState:Ne,saveState:Me,autoSave:Pe,onAutoSaveChange:Fe,pendingChanges:R.pendingChanges??0,reviewCount:S?R.pendingChanges??0:0,onDiscardAll:A.length>0&&E.status===`success`?()=>C(A):void 0,discardAllDescription:n8(A.length,j),portalContainer:k,isLoading:e.status===`loading`,loadError:e.status===`error`?e.error:void 0,renderCanvas:De,canvasPaths:_e,onSelectCanvasPath:B,selectedCanvasPath:re,canvasRoute:me,onCanvasRouteChange:ue,canvasRoutes:de,initialPanel:g.initial.panel,initialCanvasOpen:g.initial.canvasOpen,initialCanvasView:g.initial.canvasView,restoreViewState:P,initialCanvasTransform:g.initial.canvasTransform,onViewStateChange:v,onNewPage:Se,onUploadMedia:we,onPreview:ye,previewHref:ve,onSelectValidationError:ke,onCompare:Ae,onSelectActivity:e=>B(e.sourcePath),getMediaFileUrl:xe,searchContentResults:h.results,isSearchingContent:h.isSearching,onSearchQueryChange:m,onOpenSearchResult:e=>B(e.id),onSignOut:je,accountError:i?{message:i.message,onRetry:i.retry}:void 0,aiEnabled:a,aiSlot:a?(0,Y.jsx)(l4e,{className:`h-full`}):void 0,onMentionField:e=>s(e),pendingChangesLoaded:x,pendingChangesProgress:M,pendingChangesError:N})}function f4e(){let e=nb();(0,b.useEffect)(()=>{e!==null&&e.system.patchSync.flush()},[e]);let t=US(),n=sC(),r=QS(),i=vce();return t.status===`not-asked`?(0,Y.jsx)(e5,{}):t.status===`error`?(0,Y.jsxs)(`div`,{className:`text-sm text-fg-error py-8 text-center`,children:[`Failed to load changes: `,t.error]}):(0,Y.jsx)(mYe,{patchSets:t.data,profilesByAuthorIds:n,mode:r,canDiscard:!0,reloadKey:i})}function p4e(e,t){if(!t)return null;let n=null,r=e=>{m4e(t,e)&&(n===null||e.length>n.length)&&(n=e)},i=e=>{for(let t of e)t.sourcePath!==void 0&&r(t.id),i(t.children??[])};i(e.pages);for(let t of e.externalPages)t.sourcePath!==void 0&&r(t.id);for(let t of e.media)r(t.id);for(let t of e.data)r(t.id);return n}function m4e(e,t){if(e===t)return!0;if(!e.startsWith(t))return!1;let n=e[t.length];return n===`?`||n===`.`}function h4e(e,t){return e.status===`schemas-not-loaded`?[`Still loading — try that again in a moment`,`The content schema had not arrived yet, so ${t} could not be opened.`]:e.status===`module-not-loaded`?[`That field's content file is not loaded`,`The page points at ${e.moduleFilePath}, which the studio does not have. It may have been deleted or renamed since the page was built.`]:[`That field is no longer where the page says it is`,`${t} does not resolve in ${e.moduleFilePath}: ${e.reason}. The page is probably rendering content from before a change to the schema — reload the canvas.`]}var g4e={projectName:`Val`,hasRouters:!1,pages:[],externalPages:[],media:[],data:[],validationErrors:[]},_4e=(0,b.createContext)(null),B9={didCatch:!1,error:null},V9=class extends b.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=B9}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState(B9))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&v4e(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(B9))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,b.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,b.createElement)(_4e.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function v4e(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var y4e=({className:e})=>(0,Y.jsxs)(`svg`,{width:`58`,height:`34`,viewBox:`0 0 58 34`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:e,children:[(0,Y.jsx)(`g`,{filter:`url(#filter0_d_21_1677)`,children:(0,Y.jsx)(`path`,{d:`M5 5.36426C5 5.16309 5.16309 5 5.36426 5H17.6581C17.8593 5 18.0223 5.16309 18.0223 5.36426V28.4949C18.0223 28.696 17.8593 28.8591 17.6581 28.8591H5.36426C5.16309 28.8591 5 28.696 5 28.4949V5.36426Z`,fill:`hsl(var(--accent))`})}),(0,Y.jsx)(`g`,{filter:`url(#filter1_i_21_1677)`,children:(0,Y.jsx)(`circle`,{cx:`11.4656`,cy:`23.7595`,r:`2.18557`,fill:`currentColor`})}),(0,Y.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M52.8588 23.839H48.7257H48.537H48.1128C47.6715 23.839 47.4508 23.5942 47.4508 23.1044V13.7293C47.4508 13.5784 47.3285 13.4561 47.1777 13.4561H45.8118C45.6609 13.4561 45.5386 13.5784 45.5386 13.7293V15.1836C45.5386 15.2844 45.4569 15.3661 45.3561 15.3661C45.2876 15.3661 45.225 15.3275 45.1924 15.2672C44.805 14.5503 44.283 14.02 43.6264 13.6765C42.9563 13.301 42.2045 13.1132 41.3709 13.1132C40.6028 13.1132 39.8755 13.252 39.189 13.5295C38.5026 13.8071 37.8979 14.2152 37.3748 14.7539C36.8682 15.2764 36.4678 15.9212 36.1736 16.6885C35.8794 17.4558 35.7323 18.3374 35.7323 19.3332V19.725C35.7323 20.7372 35.8794 21.627 36.1736 22.3942C36.4678 23.1615 36.8682 23.8146 37.3748 24.3533C37.8979 24.8757 38.5026 25.2757 39.189 25.5532C39.8755 25.8144 40.6191 25.945 41.42 25.945C42.1881 25.945 42.9154 25.7491 43.6019 25.3573C44.2751 24.982 44.8058 24.4119 45.1941 23.6471C45.2255 23.5852 45.2886 23.5452 45.358 23.5452H45.3917C45.4728 23.5452 45.5386 23.611 45.5386 23.6921C45.5386 23.7904 45.544 23.8856 45.5547 23.9777V25.1392C45.5547 25.3904 45.7584 25.5941 46.0096 25.5941H47.2261C47.2914 25.5995 47.3581 25.6022 47.4263 25.6022H48.537H48.7257H57.7268C57.8777 25.6022 58 25.4799 58 25.329V24.1122C58 23.9614 57.8777 23.839 57.7268 23.839H55.3174C55.1665 23.839 55.0442 23.7167 55.0442 23.5659V8.73368C55.0442 8.58279 54.9219 8.46048 54.771 8.46048H50.5054C50.3545 8.46048 50.2322 8.58279 50.2322 8.73368V9.95043C50.2322 10.1013 50.3545 10.2236 50.5054 10.2236H52.8588C53.0097 10.2236 53.132 10.3459 53.132 10.4968V23.5659C53.132 23.7167 53.0097 23.839 52.8588 23.839ZM41.6161 24.1329C42.1881 24.1329 42.7111 24.0268 43.1851 23.8146C43.6754 23.6023 44.0922 23.3003 44.4354 22.9085C44.7786 22.5167 45.0483 22.0514 45.2444 21.5127C45.4406 20.9576 45.5386 20.3454 45.5386 19.6761V19.3822C45.5386 18.7292 45.4406 18.1333 45.2444 17.5946C45.0483 17.0395 44.7705 16.5661 44.4109 16.1743C44.0677 15.7824 43.6509 15.4804 43.1606 15.2682C42.6866 15.0396 42.1718 14.9254 41.6161 14.9254C41.044 14.9254 40.521 15.0315 40.0471 15.2437C39.5731 15.4559 39.1563 15.758 38.7968 16.1498C38.4535 16.5252 38.1839 16.9905 37.9877 17.5456C37.7916 18.0843 37.6936 18.6802 37.6936 19.3332V19.725C37.6936 21.1127 38.0531 22.1983 38.7722 22.982C39.5077 23.7493 40.4557 24.1329 41.6161 24.1329ZM31.1115 25.4191C31.0732 25.5287 30.9698 25.6022 30.8536 25.6022H27.4661C27.35 25.6022 27.2465 25.5287 27.2082 25.4191L23.1578 13.8193C23.0958 13.6417 23.2276 13.4561 23.4157 13.4561H25.089C25.2068 13.4561 25.3114 13.5316 25.3484 13.6435L28.9666 24.581C28.9942 24.6643 29.0721 24.7206 29.1599 24.7206C29.2477 24.7206 29.3256 24.6643 29.3532 24.581L32.9714 13.6435C33.0084 13.5316 33.1129 13.4561 33.2308 13.4561H34.9041C35.0922 13.4561 35.224 13.6417 35.162 13.8193L31.1115 25.4191Z`,fill:`currentColor`}),(0,Y.jsxs)(`defs`,{children:[(0,Y.jsxs)(`filter`,{id:`filter0_d_21_1677`,x:`0.124722`,y:`0.124722`,width:`22.7729`,height:`33.6097`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Y.jsx)(`feFlood`,{floodOpacity:`0`,result:`BackgroundImageFix`}),(0,Y.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Y.jsx)(`feOffset`,{}),(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`2.43764`}),(0,Y.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`out`}),(0,Y.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0.219608 0 0 0 0 0.803922 0 0 0 0 0.501961 0 0 0 0.3 0`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in2:`BackgroundImageFix`,result:`effect1_dropShadow_21_1677`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in:`SourceGraphic`,in2:`effect1_dropShadow_21_1677`,result:`shape`})]}),(0,Y.jsxs)(`filter`,{id:`filter1_i_21_1677`,x:`9.28003`,y:`21.5739`,width:`4.37112`,height:`4.37112`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Y.jsx)(`feFlood`,{floodOpacity:`0`,result:`BackgroundImageFix`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in:`SourceGraphic`,in2:`BackgroundImageFix`,result:`shape`}),(0,Y.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Y.jsx)(`feOffset`,{}),(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`0.546392`}),(0,Y.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`arithmetic`,k2:`-1`,k3:`1`}),(0,Y.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0.219608 0 0 0 0 0.803922 0 0 0 0 0.501961 0 0 0 0.3 0`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in2:`shape`,result:`effect1_innerShadow_21_1677`})]})]})]});function b4e({error:e,resetErrorBoundary:t,onDeleteAllPatches:n,onDeleteLastPatch:r}){return(0,Y.jsx)(`div`,{className:`flex absolute top-0 left-0 justify-center items-center w-screen h-screen bg-bg-primary text-fg-primary`,children:(0,Y.jsx)(`div`,{className:`p-10 w-full h-full`,children:(0,Y.jsxs)(`div`,{className:`overflow-scroll p-10 w-full h-full bg-card text-fg-primary`,children:[(0,Y.jsx)(`div`,{className:`flex justify-between items-center`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-[0.5em] text-lg font-bold text-center py-2`,children:[(0,Y.jsx)(y4e,{}),` encountered an error`,(0,Y.jsx)(`button`,{onClick:t,children:(0,Y.jsx)(Hy,{})})]})}),(0,Y.jsx)(`div`,{className:`text-4xl font-normal`,children:`Message:`}),(0,Y.jsx)(`pre`,{children:e.message}),e.stack&&(0,Y.jsx)(zk,{type:`single`,className:`font-serif`,collapsible:!0,defaultValue:`error`,children:(0,Y.jsxs)(Bk,{value:`error`,children:[(0,Y.jsx)(Vk,{children:`Stack trace:`}),(0,Y.jsx)(Hk,{className:`p-4 bg-bg-secondary`,children:e.stack&&(0,Y.jsx)(`pre`,{children:e.stack})})]})}),(r||n)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 py-8`,children:[(0,Y.jsx)(`p`,{className:`max-w-prose text-pretty`,children:`If this problem was caused by a recent change, you can revert all recent changes by clicking the button below. If the problem persists after reverting changes, a developer needs to investigate.`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r&&(0,Y.jsx)(t_,{variant:`destructive`,onClick:r,className:`text-sm px-3 py-1.5 rounded border border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground transition-colors`,children:`Revert last change`}),n&&(0,Y.jsx)(t_,{variant:`destructive`,onClick:n,className:`text-sm px-3 py-1.5 rounded border border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground transition-colors`,children:`Revert all changes`})]})]})]})})})}function x4e({error:e,resetErrorBoundary:t}){return console.error(e),(0,Y.jsx)(b4e,{error:e,resetErrorBoundary:t})}function S4e({error:e,resetErrorBoundary:t}){console.error(e);let n=YS(),{deletePatches:r}=RS(),i=n.length>0?()=>{r(n),t()}:void 0,a=n.length>0?n[n.length-1]:void 0;return(0,Y.jsx)(b4e,{error:e,resetErrorBoundary:t,onDeleteAllPatches:i,onDeleteLastPatch:a?()=>{r([a]),t()}:void 0})}var C4e=({client:e,config:t,valModules:n,cssLoaded:r,theme:i,setTheme:a})=>(0,Y.jsx)(PS,{client:e,dispatchValEvents:!1,config:t,valModules:n??null,theme:i,setTheme:a,children:(0,Y.jsx)(V9,{FallbackComponent:S4e,children:(0,Y.jsx)(`div`,{style:{minHeight:`100svh`,width:`100vw`,visibility:`hidden`},id:`val-app-container`,children:(0,Y.jsx)(WC,{children:(0,Y.jsx)(ERe,{children:r&&(0,Y.jsx)(u4e,{})})})})})});function w4e({root:e,children:t}){return(0,lm.createPortal)(t,e)}var T4e=({children:e,style:t})=>{let n=(0,b.useRef)(null),[r,i]=(0,b.useState)(null);return(0,b.useLayoutEffect)(()=>{if(n.current){if(n.current.shadowRoot)i(n.current.shadowRoot);else{let e=n.current.attachShadow({mode:`open`});i(e)}}},[]),(0,Y.jsx)(`div`,{ref:n,style:t,id:`val-shadow-root`,children:r&&(0,Y.jsx)(w4e,{root:r,children:e})})},E4e=`/spa/index.css`,H9=`val-app`,D4e=`val-overlay`,O4e=`$$BUILD_$$REPLACE_WITH_VERSION$$`;function k4e(){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`link`,{rel:`preconnect`,href:`https://fonts.googleapis.com`}),(0,Y.jsx)(`link`,{rel:`preconnect`,href:`https://fonts.gstatic.com`,crossOrigin:`use-credentials`}),(0,Y.jsx)(`link`,{href:`https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Space+Grotesk:wght@300..700&display=swap`,rel:`stylesheet`})]})}function A4e(){let[e,t]=(0,b.useState)(null),n=(0,b.useMemo)(j4e,[]);return(0,b.useEffect)(()=>{let e=e=>{e.key===`val-config`&&t(j4e())};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[]),e||n}function j4e(){let e=sessionStorage.getItem(Yf);if(e){let t=Qf.safeParse(JSON.parse(e));return t.error?(console.error(`Error parsing config from session storage`,t.error),null):t.data}return null}var M4e=`val-modules-updated`;function N4e(){let[e,t]=(0,b.useState)(()=>typeof window<`u`?window.__VAL_MODULES__??null:null);return(0,b.useEffect)(()=>{let e=()=>{t(window.__VAL_MODULES__??null)};return window.__VAL_MODULES__&&t(window.__VAL_MODULES__),window.addEventListener(M4e,e),()=>{window.removeEventListener(M4e,e)}},[]),e}function P4e(){let e=A4e(),t=N4e(),n=`/api/val`,{client:r}=(0,b.useMemo)(()=>({client:Hf(n,{...e,contentHostUrl:Dr})}),[n,e]),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(()=>{try{let e=sessionStorage.getItem(Xf);if(e===`light`||e===`dark`)return e;let t=sessionStorage.getItem(Yf),n=t?JSON.parse(t):null,r=localStorage.getItem(`val-theme-`+(n?.project||`unknown`));if(r===`light`||r===`dark`)return r;if(n?.defaultTheme===`light`||n?.defaultTheme===`dark`)return n.defaultTheme}catch{}return`dark`});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(k4e,{}),(0,Y.jsxs)(T4e,{children:[(0,Y.jsx)(`link`,{rel:`stylesheet`,href:`${n}/static${`/${O4e}`}${E4e}`,onLoad:()=>{window.dispatchEvent(new CustomEvent(`val-css-loaded`,{detail:{type:`val-css-loaded`}})),a(!0)}}),(0,Y.jsx)(V9,{fallbackRender:x4e,children:(0,Y.jsx)(`div`,{...o?{"data-mode":o}:{},className:`bg-bg-primary font-sans text-fg-primary`,children:(0,Y.jsx)(C4e,{client:r,config:e,valModules:t,cssLoaded:i,theme:o,setTheme:s})})})]})]})}var F4e=Object.defineProperty,U9=(e,t)=>F4e(e,`name`,{value:t,configurable:!0}),W9=`Switch`,[I4e,L4e]=sm(W9),[R4e,G9]=I4e(W9);function z4e(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=ng({prop:n,defaultProp:i??!1,onChange:c,caller:W9}),[m,h]=b.useState(null),[g,_]=b.useState(null),v=b.useRef(!1),[y,x]=b.useReducer(e=>e+1,0),S={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:x,required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,Y.jsx)(R4e,{scope:t,...S,children:q4e(d)?d(S):r})}U9(z4e,`SwitchProvider`);var B4e=`SwitchTrigger`,V4e=b.forwardRef(U9(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=G9(B4e,e),g=am(r,u),_=b.useRef(c);return b.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=U9(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,Y.jsx)(xm.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":K9(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:g,onClick:Qp(t,e=>{p(),d(e=>!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`SwitchTrigger`)),H4e=b.forwardRef(U9(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Y.jsx)(z4e,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(V4e,{...d,ref:t,__scopeSwitch:n}),e&&(0,Y.jsx)(K4e,{__scopeSwitch:n})]})})},`Switch`)),U4e=`SwitchThumb`,W4e=b.forwardRef(U9(function(e,t){let{__scopeSwitch:n,...r}=e,i=G9(U4e,n);return(0,Y.jsx)(xm.span,{"data-state":K9(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),G4e=`SwitchBubbleInput`,K4e=b.forwardRef(U9(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=G9(G4e,e),g=am(r,h),_=zh(i),v=b.useRef(!1),y=b.useRef(s),x=b.useRef(o);b.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==x.current;x.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});n.call(e,s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let S=b.useRef(s);return(0,Y.jsx)(xm.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??S.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:Qp(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function q4e(e){return typeof e==`function`}U9(q4e,`isFunction`);function K9(e){return e?`checked`:`unchecked`}U9(K9,`getState`);var J4e=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(H4e,{className:X(`peer inline-flex h-[22px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:bg-bg-primary disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-bg-tertiary data-[state=unchecked]:bg-bg-secondary-hover`,e),...t,ref:n,children:(0,Y.jsx)(W4e,{className:X(`pointer-events-none block h-[18px] w-5 rounded-full bg-bg-primary shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0`)})}));J4e.displayName=H4e.displayName;function q9({size:e}){return(0,Y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`11`}),(0,Y.jsx)(`line`,{x1:`12`,y1:`4`,x2:`12`,y2:`12`,className:`animate-rotate-clock-minute-hand origin-center`}),(0,Y.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`,className:`animate-rotate-clock-hour-hand origin-center`})]})}function Y4e({orientation:e,ghost:t,compact:n,children:r,className:i}){return(0,Y.jsx)(`div`,{role:`toolbar`,"aria-label":`Val`,"aria-orientation":e,className:X(`flex relative items-center rounded-lg`,`bg-bg-float border border-border-float text-fg-primary shadow-lg`,e===`vertical`?`flex-col`:`flex-row`,n?e===`vertical`?`flex-col gap-0.5 px-1 py-1.5`:`flex-row gap-0.5 px-1.5 py-1`:e===`vertical`?`flex-col gap-1 px-1.5 py-2`:`flex-row gap-1 px-2 py-1.5`,t&&`opacity-70`,i),children:r})}(0,b.forwardRef)(function({label:e,icon:t,active:n,disabled:r,href:i,compact:a,onClick:o,onMouseEnter:s,onMouseLeave:c,...l},u){let d=X(`inline-flex items-center justify-center shrink-0 rounded-md transition-colors`,a?`w-7 h-7`:`w-8 h-8`,n?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,r&&`text-fg-disabled pointer-events-none`);return i?(0,Y.jsx)(`a`,{ref:u,href:i,className:d,onClick:o,onMouseEnter:s,onMouseLeave:c,"aria-label":e,title:e,...l,children:t}):(0,Y.jsx)(`button`,{ref:u,type:`button`,disabled:r,"aria-pressed":n,className:d,onClick:o,onMouseEnter:s,onMouseLeave:c,"aria-label":e,title:e,...l,children:t})});function X4e({orientation:e}){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`shrink-0 bg-border-float`,e===`vertical`?`h-px w-5 my-0.5`:`w-px h-5 mx-0.5`)})}function Z4e({orientation:e,dock:t,compact:n,ghost:r,status:i=`none`,mark:a,children:o,expanded:s,onExpandedChange:c,defaultExpanded:l=!1}){let[u,d]=(0,b.useState)(l),[f,p]=(0,b.useState)(!1),m=r===!0||(s??(u||f)),h=s!==void 0&&!!c,g=e=>{if(h){c?.(e);return}d(e),e||p(!1)},_=(0,b.useRef)(null);i6(_,m,(0,b.useCallback)(()=>g(!1),[g])),(0,b.useEffect)(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&g(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,g]);let v=t===`right-top`||t===`right-center`||t===`right-bottom`,y=e===`vertical`;return(0,Y.jsx)(`div`,{ref:_,onMouseEnter:()=>h?g(!0):p(!0),onMouseLeave:()=>h?g(!1):p(!1),className:X(`inline-flex`,y?`flex-col`:`flex-row`),children:(0,Y.jsx)(Y4e,{orientation:e,compact:n,ghost:r,className:X(`transition-[border-radius,padding] duration-200`,!m&&[`rounded-full`,`p-1.5`]),children:(0,Y.jsxs)(`div`,{className:X(`flex items-center`,y?`flex-col`:`flex-row`,v?y?`flex-col-reverse`:`flex-row-reverse`:void 0),children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":m,"aria-label":m?`Close Val menu`:`Open Val menu`,onClick:()=>g(h?!m:!u),className:X(`relative grid place-items-center shrink-0 rounded-full transition-colors`,n&&m?`w-7 h-7`:`w-8 h-8`,`text-fg-primary hover:bg-bg-float-raised`),children:[a,i!==`none`&&!m&&(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`absolute -right-0.5 -top-0.5 w-2 h-2 rounded-full ring-2 ring-bg-float`,i===`errors`?`bg-bg-error-primary`:`bg-fg-secondary`)})]}),(0,Y.jsx)(`div`,{className:X(`overflow-hidden`,`transition-[max-width,max-height,opacity,visibility] duration-200 ease-out`,m?y?`max-h-[32rem] max-w-[32rem] px-2 -mx-2`:`max-w-[32rem] max-h-[32rem] py-2 -my-2`:`max-w-0 max-h-0`,m?`opacity-100`:`opacity-0`,m?`visible`:`invisible`),children:(0,Y.jsx)(`div`,{className:X(`flex items-center`,y?`flex-col`:`flex-row`,n?`gap-0.5`:`gap-1`,y?`pt-1`:`pl-1`),children:o})})]})})})}var J9=(0,b.createContext)({bornSessionId:null,setBornSessionId:()=>{}});function Y9(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}session=${encodeURIComponent(t)}`:e}function Q4e(e){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)([]),[p,m]=(0,b.useState)(!1),[h,g]=(0,b.useState)(()=>{try{return sessionStorage.getItem(Zf)}catch{return null}}),_=(0,b.useCallback)(e=>{g(e);try{e==null?sessionStorage.removeItem(Zf):sessionStorage.setItem(Zf,e)}catch{}},[]);(0,b.useEffect)(()=>{e.draftMode||(n(null),i(null),o(null),c(!1),u(!1),f([]),m(!1))},[e.draftMode]),(0,b.useEffect)(()=>{if(t===`select`&&r===null){let e=(e,t)=>{let n=document.elementsFromPoint(e,t),r=null;for(let e of n)if(e instanceof HTMLElement){let t=e.getAttribute(`data-val-path`);if(t){let n=e;if(e.tagName===`SOURCE`){let t=e.parentElement;t&&(t.tagName===`VIDEO`||t.tagName===`PICTURE`)&&(n=t)}let i=n.getBoundingClientRect();r={top:i.top+window.scrollY,left:i.left+window.scrollX,width:i.width,height:i.height,joinedPaths:t}}}r&&o(r)},t=t=>{e(t.touches[0].clientX,t.touches[0].clientY)},n=t=>{e(t.clientX,t.clientY)},r=()=>{o(null)},i=()=>{o(null)};return window.addEventListener(`mousemove`,n),window.addEventListener(`touchmove`,t),window.addEventListener(`touchstart`,t),window.addEventListener(`mouseleave`,r),window.addEventListener(`resize`,i),()=>{window.removeEventListener(`mousemove`,n),window.removeEventListener(`touchmove`,t),window.removeEventListener(`touchstart`,t),window.removeEventListener(`mouseleave`,r),window.removeEventListener(`resize`,i),o(null)}}o(null)},[r,t]),(0,b.useEffect)(()=>{if(t===`select`&&r===null){let e=e=>{e.key===`Escape`&&(n(null),o(null))};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}}},[t,r]);let{theme:v}=Qy(),[y,x]=(0,b.useState)(null),S=bb(),C=`val-menu-right-center`;(0,b.useEffect)(()=>{try{let e=S&&localStorage.getItem(`val-menu-drop-zone-`+(S?.project||`unknown`))||localStorage.getItem(`val-menu-drop-zone-default`);if(e){if(e===`val-menu-left-top`||e===`val-menu-left-center`||e===`val-menu-left-bottom`||e===`val-menu-center-top`||e===`val-menu-center-bottom`||e===`val-menu-right-top`||e===`val-menu-right-center`||e===`val-menu-right-bottom`)x(e);else throw Error(`Invalid drop zone: `+e)}else x(C)}catch(e){console.error(`Error getting drop zone from local storage`,e),x(C)}},[S]);let w=e=>{x(e);try{e&&(localStorage.setItem(`val-menu-drop-zone-`+(S?.project||`unknown`),e),localStorage.setItem(`val-menu-drop-zone-default`,e))}catch(e){console.error(`Error setting drop zone to local storage`,e)}},T=()=>{let e=document.querySelectorAll(`[data-val-path]`),t=[];return e.forEach(e=>{if(e instanceof HTMLElement){let n=e.getAttribute(`data-val-path`);if(n){let r=e;if(e.tagName===`SOURCE`){let t=e.parentElement;t&&(t.tagName===`VIDEO`||t.tagName===`PICTURE`)&&(r=t)}let i=r.getBoundingClientRect();t.push({top:i.top+window.scrollY,left:i.left+window.scrollX,width:i.width,height:i.height,joinedPaths:n})}}}),t};return(0,Y.jsx)(J9.Provider,{value:{bornSessionId:h,setBornSessionId:_},children:(0,Y.jsxs)(`div`,{...v?{"data-mode":v}:{},id:`val-overlay-container`,children:[(0,Y.jsx)($4e,{editMode:r,setMode:n,setEditMode:i}),a&&(0,Y.jsx)(`div`,{className:X(`absolute z-[8998]`,`cursor-pointer`,`rounded-sm`,`transition-all duration-150 ease-in-out`,`border-2 border-bg-page-selection bg-bg-page-selection-fill`),style:u3e({top:a.top,left:a.left,width:a.width,height:a.height},{top:window.scrollY,left:window.scrollX,width:window.innerWidth,height:window.innerHeight},2),onClick:e=>{e.preventDefault(),e.stopPropagation(),o(null),i({joinedPaths:a.joinedPaths,clientX:a.left,clientY:a.top,boundingBox:{top:a.top,left:a.left,width:a.width,height:a.height}})}}),s&&d.map((e,t)=>(0,Y.jsx)(`div`,{className:X(`absolute z-[8997] pointer-events-none`,`rounded-sm`,`border-2 border-bg-page-selection`,`transition-opacity duration-200 ease-out`,l?`opacity-70`:`opacity-0`),style:u3e({top:e.top,left:e.left,width:e.width,height:e.height},{top:window.scrollY,left:window.scrollX,width:window.innerWidth,height:window.innerHeight},2)},`${e.joinedPaths}-${t}`)),(0,Y.jsx)(e3e,{isOpen:p&&e.draftMode,onClose:()=>m(!1),onOpen:()=>m(!0)}),r===null&&(0,Y.jsx)(l3e,{...e,mode:t,setMode:n,loading:v===null,dropZone:y,setDropZone:w,findAllValPathElements:T,setAllBoundingBoxes:f,setShowAllBoundingBoxes:c,setAllBoundingBoxesVisible:u,isChatOpen:p,setIsChatOpen:m})]})})}function $4e({editMode:e,setMode:t,setEditMode:n}){let{bornSessionId:r}=(0,b.useContext)(J9),[i,a]=(0,b.useState)({x:window.innerWidth,y:window.innerHeight}),[o,s]=(0,b.useState)({width:0,height:0}),[c,l]=(0,b.useState)(window.innerWidth),u=(0,b.useRef)(null),d=c<1024,f=uC(d);fC(d&&e!==null);let[p,m]=(0,b.useState)(null);(0,b.useEffect)(()=>{window.innerWidth<1024?a({x:16,y:16}):e?setTimeout(()=>{if(u.current){let{innerWidth:t,innerHeight:n}=window,{offsetWidth:r,offsetHeight:i}=u.current,o=e.clientX,c=e.clientY;s({width:r,height:i}),o+r>t-20&&(o=t-r-20),o<20&&(o=20),c+i>n-20&&(c=n-i-20),c<20&&(c=20),a({x:o,y:c})}},100):(a({x:window.innerWidth,y:window.innerHeight}),s({width:0,height:0}))},[e]),(0,b.useEffect)(()=>{let e=()=>{l(window.innerWidth),window.innerWidth<1024?a({x:16,y:16}):u.current&&a(e=>{let{innerWidth:t,innerHeight:n}=window,{offsetWidth:r}=u.current,i=t-100,a=n-100,o=-(r-100);return{x:Math.max(o,Math.min(i,e.x)),y:Math.max(0,Math.min(a,e.y))}})};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[]);let[h,g]=(0,b.useState)(!1);(0,b.useEffect)(()=>{if(h&&!d){let e=e=>{a(t=>{if(!u.current)return t;let{innerWidth:n,innerHeight:r}=window,{offsetWidth:i}=u.current,a=t.x+e.movementX,o=t.y+e.movementY,s=n-100,c=r-100,l=-(i-100);return a=Math.max(l,Math.min(s,a)),o=Math.max(0,Math.min(c,o)),{x:a,y:o}})},t=()=>{g(!1)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}}},[h,d]),(0,b.useEffect)(()=>{if(p&&!d){let e=e=>{let{innerWidth:t,innerHeight:n}=window;(p===`se`||p===`e`)&&s(n=>{let r=Math.max(400,Math.min(t-i.x-20,n.width+e.movementX));return{...n,width:r}}),(p===`se`||p===`s`)&&s(t=>{let r=Math.max(300,Math.min(n-i.y-20,t.height+e.movementY));return{...t,height:r}})},t=()=>{m(null)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}}},[p,d,i.x,i.y]),(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(t(`select`),n(null))};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[]);let _=()=>{t(`select`),n(null)};return(0,Y.jsxs)(`div`,{className:(0,AC.default)(`fixed top-0 left-0`,d?`z-[9001]`:`z-[8998]`,{hidden:e===null,"opacity-100 w-[200svw] h-[100svh]":e!==null&&!d,"opacity-100 w-[100vw] h-[100svh]":e!==null&&d}),children:[(0,Y.jsx)(`div`,{className:(0,AC.default)(`fixed top-0 left-0`,{hidden:e===null,"w-[100vw] h-[100svh]":e!==null}),onClick:e=>{e.preventDefault(),h||_()}}),(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex flex-col bg-bg-float text-fg-primary`,d?`fixed inset-x-0 border-0 rounded-none`:`absolute rounded-lg border border-border-float shadow-xl`),ref:u,style:d?{top:f.offsetTop,height:f.height}:{top:i.y,left:i.x,...o.width>0?{width:o.width,height:o.height}:{maxWidth:`640px`}},children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`grid grid-cols-3 items-center px-4 h-11 border-b border-border-float rounded-t-lg`,{"cursor-grab active:cursor-grabbing":!d}),onMouseDown:e=>{d||(e.preventDefault(),g(!0))},children:[(0,Y.jsx)(`div`,{className:`text-[0.8125rem] font-semibold tracking-tight text-fg-primary`,children:`Edit content`}),(0,Y.jsx)(`div`,{className:`flex justify-center`,children:!d&&(0,Y.jsx)(iy,{size:16,className:`text-fg-secondary`})}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:d&&(0,Y.jsx)(`button`,{onClick:_,className:`grid place-items-center w-7 h-7 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary transition-colors`,"aria-label":`Close`,children:(0,Y.jsx)(Hy,{size:18})})})]}),(0,Y.jsx)(`div`,{className:(0,AC.default)(`flex-1 overflow-y-auto`,{"p-6":!d,"p-4":d}),children:(0,Y.jsxs)(`form`,{className:`flex flex-col gap-6 w-full`,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),_()},children:[e&&(0,Y.jsx)(Y.Fragment,{children:H.splitJoinedSourcePaths(e.joinedPaths).map(t=>{let n=H.splitJoinedSourcePaths(e.joinedPaths).length>1;return(0,Y.jsx)(r3e,{path:t,showInlineStudioLink:n},t)})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-2 border-t border-border-secondary`,children:[e&&H.splitJoinedSourcePaths(e.joinedPaths).length===1&&(0,Y.jsxs)(`a`,{href:Y9(window.origin+`/val/~`+H.splitJoinedSourcePaths(e.joinedPaths)[0],r),className:`inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-border-primary bg-bg-secondary hover:bg-bg-secondary-hover text-fg-primary transition-colors`,children:[(0,Y.jsx)(Zv,{size:16}),(0,Y.jsx)(`span`,{children:`Open Studio`})]}),(0,Y.jsx)(`div`,{className:`flex-1`}),(0,Y.jsx)(t_,{type:`submit`,children:`Done`})]})]})}),!d&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`absolute top-0 right-0 w-1 h-full cursor-ew-resize hover:bg-bg-brand-primary/50 transition-colors`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m(`e`)}}),(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-1 cursor-ns-resize hover:bg-bg-brand-primary/50 transition-colors`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m(`s`)}}),(0,Y.jsx)(`div`,{className:`absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize group`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m(`se`)},children:(0,Y.jsx)(`svg`,{className:`absolute bottom-0.5 right-0.5 w-3 h-3 text-fg-tertiary group-hover:text-fg-secondary transition-colors`,viewBox:`0 0 12 12`,fill:`none`,children:(0,Y.jsx)(`path`,{d:`M10 2L2 10M10 6L6 10M10 10H10.01`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]})]})]})}function e3e({isOpen:e,onClose:t,onOpen:n}){let r=(0,b.useRef)(null),{chatEditorRef:i,setOpenAIChatImpl:a}=wS();(0,b.useEffect)(()=>(a(n),()=>a(null)),[n,a]);let{bornSessionId:o,setBornSessionId:s}=(0,b.useContext)(J9),{sendMessage:c,uploadAiImage:l,isConnected:u,authError:d,newSession:f,sessions:p,currentSessionId:m,getSessions:h,setSessionName:g,loadSession:_,isLoadingSession:v,answerToolQuestions:y,cancelToolQuestion:x}=c4e(r,{initialSessionId:(0,b.useRef)(o).current,onSessionBorn:s,onSessionCleared:()=>s(null)}),S=QS(),[C,w]=(0,b.useState)({x:Math.max(20,window.innerWidth-570),y:80}),[T,E]=(0,b.useState)({width:480,height:600}),[D,O]=(0,b.useState)(window.innerWidth),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(null),N=(0,b.useRef)(null),P=D<1024,F=uC(P);return fC(P&&e),(0,b.useEffect)(()=>{let e=()=>{O(window.innerWidth),window.innerWidth<1024?w({x:16,y:16}):w(e=>{let t=window.innerWidth-100,n=window.innerHeight-100;return{x:Math.max(-(T.width-100),Math.min(t,e.x)),y:Math.max(0,Math.min(n,e.y))}})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[T.width]),(0,b.useEffect)(()=>{if(k&&!P){let e=e=>{w(t=>{let n=window.innerWidth-100,r=window.innerHeight-100,i=N.current?.offsetWidth??T.width;return{x:Math.max(-(i-100),Math.min(n,t.x+e.movementX)),y:Math.max(0,Math.min(r,t.y+e.movementY))}})},t=()=>A(!1);return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}}},[k,P,T.width]),(0,b.useEffect)(()=>{if(j&&!P){let e=e=>{(j===`se`||j===`e`)&&E(t=>({...t,width:Math.max(360,Math.min(window.innerWidth-C.x-20,t.width+e.movementX))})),(j===`se`||j===`s`)&&E(t=>({...t,height:Math.max(400,Math.min(window.innerHeight-C.y-20,t.height+e.movementY))}))},t=()=>M(null);return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}}},[j,P,C.x,C.y]),(0,Y.jsx)(`div`,{className:X(`fixed top-0 left-0`,P?`z-[9001]`:`z-[8999]`),style:e?void 0:{display:`none`},children:(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex flex-col bg-bg-float text-fg-primary`,P?`fixed inset-x-0 border-0 rounded-none`:`absolute rounded-lg border border-border-float shadow-xl`),ref:N,style:P?{top:F.offsetTop,height:F.height}:{top:C.y,left:C.x,width:T.width,height:T.height},children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`grid grid-cols-3 items-center px-4 h-11 border-b border-border-float rounded-t-lg`,{"cursor-grab active:cursor-grabbing":!P}),onMouseDown:e=>{P||(e.preventDefault(),A(!0))},children:[(0,Y.jsx)(`div`,{className:`text-[0.8125rem] font-semibold tracking-tight text-fg-primary`,children:`AI assistant`}),(0,Y.jsx)(`div`,{className:`flex justify-center`,children:!P&&(0,Y.jsx)(iy,{size:16,className:`text-fg-secondary`})}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsx)(`button`,{onClick:t,className:`p-1 rounded hover:bg-bg-secondary transition-colors`,"aria-label":`Close`,children:(0,Y.jsx)(Hy,{size:18})})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,Y.jsx)(k2e,{ref:r,chatEditorRef:i,onSendMessage:c,onUploadFile:l,onNewSession:f,isConnected:u,authError:d,mode:S,sessions:p,currentSessionId:m,onLoadSession:_,onFetchSessions:h,onSetSessionName:g,isLoadingSession:v,onAnswerToolQuestions:y,onCancelToolQuestion:x})}),!P&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`absolute top-0 right-0 w-1 h-full cursor-ew-resize hover:bg-bg-brand-primary/50 transition-colors`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),M(`e`)}}),(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-1 cursor-ns-resize hover:bg-bg-brand-primary/50 transition-colors`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),M(`s`)}}),(0,Y.jsx)(`div`,{className:`absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize group`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),M(`se`)},children:(0,Y.jsx)(`svg`,{className:`absolute bottom-0.5 right-0.5 w-3 h-3 text-fg-tertiary group-hover:text-fg-secondary transition-colors`,viewBox:`0 0 12 12`,fill:`none`,children:(0,Y.jsx)(`path`,{d:`M10 2L2 10M10 6L6 10M10 10H10.01`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]})]})})}var t3e=`inline-flex items-center justify-center w-8 h-8 rounded-md transition-colors disabled:text-fg-disabled disabled:pointer-events-none`,n3e=`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`;function r3e({path:e,showInlineStudioLink:t}){let n=Cb(e),{bornSessionId:r}=(0,b.useContext)(J9),i=Y9(window.origin+`/val/~`+e,r);return n.status===`error`?(0,Y.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,Y.jsx)(`div`,{className:`text-fg-error text-sm`,children:n.error})}):!(`data`in n)||n.data===void 0?(0,Y.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,Y.jsx)(jC,{path:e})}):t?(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 w-full`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[n.data.description&&(0,Y.jsx)(`div`,{className:`pb-2 text-sm text-fg-tertiary`,children:n.data.description}),(0,Y.jsx)(r6,{path:e,schema:n.data,autoFocus:!0})]}),(0,Y.jsx)(`a`,{href:i,className:`flex-shrink-0 p-2 rounded-md border border-border-primary bg-bg-secondary hover:bg-bg-secondary-hover text-fg-secondary hover:text-fg-primary transition-colors mt-1`,title:`Open in Studio`,"aria-label":`Open in Studio`,children:(0,Y.jsx)(Zv,{size:16})})]})}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 w-full`,children:[n.data.description&&(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:n.data.description}),(0,Y.jsx)(r6,{path:e,schema:n.data,autoFocus:!0})]})}function i3e({dropZone:e}){return e===`val-menu-left-top`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(wy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Left Top`})]}):e===`val-menu-left-center`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(vae,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Left Center`})]}):e===`val-menu-left-bottom`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Left Bottom`})]}):e===`val-menu-center-top`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(wy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Center Top`})]}):e===`val-menu-center-bottom`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Center Bottom`})]}):e===`val-menu-right-top`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(wy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Right Top`})]}):e===`val-menu-right-center`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Cy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Right Center`})]}):e===`val-menu-right-bottom`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Right Bottom`})]}):(console.warn(`Unknown drop zone:`,e),null)}function a3e({dropZone:e,ghost:t,draftMode:n,draftModeLoading:r,setDraftMode:i,mode:a,setMode:o,disableOverlay:s,loading:c,setDropZone:l,findAllValPathElements:u,setAllBoundingBoxes:d,setShowAllBoundingBoxes:f,setAllBoundingBoxesVisible:p,isChatOpen:m,setIsChatOpen:h}){let{bornSessionId:g}=(0,b.useContext)(J9),_=e===`val-menu-right-center`||e===`val-menu-left-center`?`vertical`:`horizontal`,v=IS(),y=eb(),x=()=>{d(u()),f(!0),p(!1),setTimeout(()=>{p(!0)},50)},S=()=>{p(!1),setTimeout(()=>{f(!1)},200)},{theme:C,setTheme:w}=Qy(),T=YS(),E=Fb()||{},D=Object.keys(E).length,O=QS(),k=bb()?.ai?.chat?.experimental?.enable===!0,A=s3e(),j=e===`val-menu-center-bottom`?`top`:e===`val-menu-center-top`?`bottom`:e===`val-menu-right-center`?`left`:e===`val-menu-left-center`?`right`:e===`val-menu-left-bottom`||e===`val-menu-right-bottom`?`top`:e===`val-menu-right-top`||e===`val-menu-left-top`?`bottom`:`top`,M=e.replace(`val-menu-`,``),N=D>0?`errors`:T.length>0?`changes`:`none`;return(0,Y.jsxs)(`div`,{className:`p-4 right-16`,children:[c&&(0,Y.jsx)(`div`,{className:Z9(e)+` p-4`,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center w-9 h-9 rounded-lg bg-bg-float border border-border-float text-fg-primary shadow-lg`,children:(0,Y.jsx)(q9,{size:16})})}),v===`login-required`&&(0,Y.jsx)(`div`,{className:Z9(e)+` p-4`,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center w-9 h-9 rounded-lg bg-bg-float border border-border-float text-fg-primary shadow-lg`,children:(0,Y.jsx)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.location.href}),children:(0,Y.jsx)(_y,{size:16})})})}),(0,Y.jsx)(z6,{isOpen:n&&!r&&!c&&v!==`login-required`,children:(0,Y.jsxs)(Z4e,{orientation:_,dock:M,ghost:t,status:N,mark:(0,Y.jsx)(o3e,{}),children:[(0,Y.jsxs)(C8,{children:[(0,Y.jsx)(w8,{className:`inline-flex`,children:(0,Y.jsx)(X9,{active:a===`select`,onClick:()=>{let e=a===`select`?null:`select`;o(e),e===`select`?x():(f(!1),p(!1))},onMouseEnter:()=>{a===`select`&&x()},onMouseLeave:()=>{a===`select`&&S()},icon:(0,Y.jsx)(Py,{size:16})})}),(0,Y.jsxs)(T8,{side:j,className:`z-50`,container:y,children:[`Click on content in the page to select and edit it`,(0,Y.jsx)(y8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(0,Y.jsxs)(C8,{children:[(0,Y.jsx)(w8,{className:`inline-flex`,children:(0,Y.jsx)(X9,{disabled:r,icon:r?(0,Y.jsx)(q9,{size:16}):(0,Y.jsx)(Gie,{size:16}),onClick:()=>i(!1)})}),(0,Y.jsxs)(T8,{side:j,className:`z-50`,container:y,children:[`Exit preview mode to see the currently published version of your content`,(0,Y.jsx)(y8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(0,Y.jsx)(X4e,{orientation:_}),(0,Y.jsxs)(C8,{children:[(0,Y.jsx)(w8,{asChild:!0,children:(0,Y.jsx)(X9,{href:Y9(window.origin+`/val/compare`,g),icon:(0,Y.jsxs)(`div`,{className:`flex relative`,children:[(0,Y.jsx)(c3e,{patchCount:T.length,validationErrorCount:D}),(0,Y.jsx)(ty,{size:16})]})})}),(0,Y.jsxs)(T8,{side:j,className:`z-50`,container:y,children:[D>0&&(0,Y.jsxs)(`div`,{className:`text-fg-error-primary`,children:[D,` validation error`,D>1&&`s`]}),T.length>0&&D===0&&(0,Y.jsxs)(`div`,{children:[T.length,` pending change`,T.length>1&&`s`]}),`Review changes in Studio`,(0,Y.jsx)(y8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(0,Y.jsx)(z8,{compact:!0}),(0,Y.jsxs)(C8,{children:[(0,Y.jsx)(w8,{asChild:!0,children:(0,Y.jsx)(X9,{icon:A.status===`success`&&A.data?(0,Y.jsx)(ry,{size:16}):(0,Y.jsx)(Ty,{size:16}),href:Y9(window.origin+`/val/~`+(A.status===`success`&&A.data?A.data:``),g)})}),(0,Y.jsxs)(T8,{side:j,className:`z-50`,container:y,children:[`Open Val Studio to edit and manage your content`,(0,Y.jsx)(y8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(O===`http`||O===`fs`)&&k&&(0,Y.jsxs)(C8,{children:[(0,Y.jsx)(w8,{className:`inline-flex`,children:(0,Y.jsx)(X9,{active:m,onClick:()=>h(e=>!e),icon:(0,Y.jsx)(vy,{size:16})})}),(0,Y.jsxs)(T8,{side:j,className:`z-50`,container:y,children:[`Open AI Chat to ask questions and edit content with AI`,(0,Y.jsx)(y8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(hD,{className:(0,AC.default)(t3e,n3e),children:(0,Y.jsx)(Jv,{size:16})}),(0,Y.jsx)(wD,{container:y,className:`z-[9003]`,children:(0,Y.jsxs)(`div`,{className:`grid grid-cols-[1fr,auto] gap-2 items-center`,children:[(0,Y.jsx)(`span`,{children:`Position`}),(0,Y.jsxs)(nD,{value:e,onValueChange:e=>{l(e)},children:[(0,Y.jsx)(iD,{children:(0,Y.jsx)(rD,{children:(0,Y.jsx)(i3e,{dropZone:e})})}),(0,Y.jsx)(aD,{container:y,className:`z-[9004]`,children:[`val-menu-left-top`,`val-menu-left-center`,`val-menu-left-bottom`,`val-menu-center-top`,`val-menu-center-bottom`,`val-menu-right-top`,`val-menu-right-center`,`val-menu-right-bottom`].map(e=>(0,Y.jsx)(oD,{value:e,children:(0,Y.jsx)(i3e,{dropZone:e})},e))})]}),(0,Y.jsx)(`span`,{children:C===`dark`?`Light mode`:`Dark mode`}),(0,Y.jsx)(J4e,{checked:C===`dark`,onCheckedChange:e=>{w(e?`dark`:`light`)}})]})})]})]})}),(0,Y.jsx)(z6,{isOpen:!(n&&!r)&&!c&&v!==`login-required`,children:(0,Y.jsxs)(Z4e,{orientation:_,dock:M,ghost:t,status:N,mark:(0,Y.jsx)(o3e,{}),children:[(0,Y.jsx)(X9,{label:`Enable preview mode`,disabled:r,icon:r?(0,Y.jsx)(q9,{size:16}):(0,Y.jsx)(Qv,{size:16}),onClick:()=>{i(!0)}}),(0,Y.jsx)(X9,{label:`Studio`,icon:A.status===`success`&&A.data?(0,Y.jsx)(ry,{size:16}):(0,Y.jsx)(Ty,{size:16}),href:Y9(window.origin+`/val/~`+(A.status===`success`&&A.data?A.data:``),g)}),(0,Y.jsx)(X9,{label:`Disable Val`,icon:(0,Y.jsx)(Hy,{size:16}),onClick:()=>s()})]})})]})}function o3e(){return(0,Y.jsx)(d6,{className:`h-6`})}function s3e(){let e=wb(),t=cC(`data`in e&&e.data?Object.keys(e.data):[],`record`),[n,r]=(0,b.useState)(null);return(0,b.useEffect)(()=>{r(window.location.pathname);let e=()=>{r(window.location.pathname)};window.addEventListener(`popstate`,e);let t=e=>{e instanceof CustomEvent&&typeof e.detail==`string`&&e.detail!==n&&r(e.detail)};return window.addEventListener(`val-provider:pathname`,t),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`val-provider:pathname`,t)}},[]),(0,b.useMemo)(()=>{if(n){for(let r of t.data||[])for(let[t,i]of Object.entries(r))if(t===n){let[n]=H.splitModuleFilePathAndModulePath(i),r=`data`in e?e.data[n]:void 0;if(r?.type===`record`&&r.router!==void 0)return{status:`success`,data:H.joinModuleFilePathAndModulePath(n,JSON.stringify(t))}}}return{status:`not-found`}},[e,t,n])}function c3e({patchCount:e,validationErrorCount:t}){let n=t>0,r=n?t:e;return r===0?null:(0,Y.jsx)(`span`,{"aria-label":`${r} ${n?`validation error`:`pending change`}${r===1?``:`s`}`,className:(0,AC.default)(`absolute -top-2 -right-2 inline-flex justify-center items-center px-1 h-4 min-w-[1rem] text-[9px] font-medium leading-none rounded-full tabular-nums`,`ring-2 ring-bg-float`,{"bg-fg-primary text-bg-float":!n,"bg-bg-error-primary text-fg-error-primary":n}),children:r>9?`9+`:r})}var X9=b.forwardRef(({icon:e,onClick:t,disabled:n,active:r,label:i,href:a,onMouseEnter:o,onMouseLeave:s,...c},l)=>{let u=(0,AC.default)(t3e,{"bg-bg-float-raised text-fg-primary":r,[n3e]:!r});return a?(0,Y.jsx)(`a`,{ref:l,href:a,className:u,onClick:t,onMouseEnter:o,onMouseLeave:s,"aria-label":i,title:i,...c,children:e}):(0,Y.jsx)(`button`,{ref:l,disabled:n,className:u,onClick:t,onMouseEnter:o,onMouseLeave:s,"aria-label":i,title:i,...c,children:e})});X9.displayName=`MenuButton`;function l3e(e){let[t,n]=(0,b.useState)(!1),{dropZone:r,setDropZone:i}=e,[a,o]=(0,b.useState)(null),s=e=>t=>{t.preventDefault(),i(e)},c=e=>t=>{t.preventDefault(),o(e)};return(0,Y.jsxs)(Y.Fragment,{children:[r&&(0,Y.jsx)(`div`,{className:(0,AC.default)(`z-[8999] cursor-grab`,Z9(r)),draggable:!0,onDragStart:()=>{n(!0)},onDragEnd:()=>{n(!1)},children:(0,Y.jsx)(a3e,{...e,dropZone:r})}),t&&r&&(0,Y.jsxs)(Y.Fragment,{children:[a&&a!==r&&(0,Y.jsx)(`div`,{className:(0,AC.default)(`z-[3]`,Z9(a)),onDrop:s(a),onDragOver:c(a),children:(0,Y.jsx)(a3e,{ghost:!0,...e,dropZone:a})}),(0,Y.jsxs)(`div`,{className:`fixed top-0 left-0 grid w-screen h-screen grid-cols-3 grid-rows-3 z-[2]`,children:[(0,Y.jsx)(Q9,{id:`val-menu-left-top`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-center-top`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-right-top`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-left-center`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(`div`,{}),(0,Y.jsx)(Q9,{id:`val-menu-right-center`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-left-bottom`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-center-bottom`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-right-bottom`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c})]})]})]})}function Z9(e){let t=`fixed transform`;return t+=e===`val-menu-left-top`?` left-0 top-0`:e===`val-menu-left-center`?` left-0 top-1/2 -translate-y-1/2`:e===`val-menu-left-bottom`?` left-0 bottom-0`:e===`val-menu-center-top`?` left-1/2 -translate-x-1/2 top-0`:e===`val-menu-center-bottom`?` left-1/2 -translate-x-1/2 bottom-0`:e===`val-menu-right-top`?` right-0 top-0`:e===`val-menu-right-center`?` right-0 top-1/2 -translate-y-1/2`:` right-0 bottom-0`,t}var Q9=({id:e,onDrop:t,onDragOver:n})=>(0,Y.jsx)(`div`,{onDrop:t(e),onDragOver:n(e)});function u3e(e,t,n){let r=e.top-n,i=e.left-n,a=e.width+n*2,o=e.height+n*2,s=Math.max(t.top,r),c=Math.max(t.left,i),l=Math.min(t.left+t.width,i+a),u=Math.min(t.top+t.height,r+o);return{top:s,left:c,width:Math.max(0,l-c),height:Math.max(0,u-s)}}function d3e(){let e=A4e(),t=N4e(),[n,r]=(0,b.useState)(()=>{try{let e=sessionStorage.getItem(Xf);if(e===`light`||e===`dark`)return e;let t=sessionStorage.getItem(Yf),n=t?JSON.parse(t):null,r=localStorage.getItem(`val-theme-`+(n?.project||`unknown`));if(r===`light`||r===`dark`)return r;if(n?.defaultTheme===`light`||n?.defaultTheme===`dark`)return n.defaultTheme}catch{}return`dark`}),i=Hf(`/api/val`,{...e,contentHostUrl:Dr}),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=e=>{e instanceof CustomEvent?e?.detail.type===`draftMode`&&typeof e?.detail.value==`boolean`?o(e.detail.value):e.detail.type===`draftModeLoading`&&typeof e.detail.value==`boolean`?c(e.detail.value):console.error(`Val: invalid event detail (val-overlay-spa)`,e.detail):console.error(`Val: invalid event (val-overlay-spa)`,e)};return window.addEventListener(`val-overlay-spa`,e),window.dispatchEvent(new CustomEvent(`val-overlay-provider`,{detail:{type:`spa-ready`}})),()=>{window.removeEventListener(`val-overlay-spa`,e)}},[]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(k4e,{}),(0,Y.jsxs)(T4e,{children:[(0,Y.jsx)(`style`,{children:`
|
|
382
|
+
- If something goes wrong, explain what happened and what to do next.`,tools:l4e}]},f=r(d);return f&&(L.current=d.id,R.current.add(d.id)),f&&a&&P.current?.(i),f},[w,e,r]),ie=(0,b.useCallback)(t=>{t&&e.current?.errorAssistantMessage(t,`Lost the connection to the AI service, so your response was not delivered. Please try again.`),I.current=null,E(!1)},[e]),ae=(0,b.useCallback)(()=>{let t=L.current;if(t===null){let t=I.current;return t!==null&&(e.current?.completeAssistantMessage(t),I.current=null),E(!1),!1}return r({type:`ai_cancel`,id:t})||(I.current!==t&&(e.current?.startAssistantMessage(t),e.current?.appendAssistantChunk(t,`Stopped.`)),e.current?.completeAssistantMessage(t),L.current=null,I.current=null,E(!1)),!0},[r,e]),oe=(0,b.useCallback)((e,t)=>{let n=ee.current.get(e);ee.current.delete(e),r({type:`ai_tool_result`,toolCallId:e,result:{answers:t}})||ie(n)},[r,ie]),se=(0,b.useCallback)(e=>{let t=ee.current.get(e);ee.current.delete(e),r({type:`ai_tool_result`,toolCallId:e,result:{error:`User declined to answer the question(s).`},isError:!0})||ie(t)},[r,ie]),ce=(0,b.useCallback)(e=>{for(let t of ee.current.keys())r({type:`ai_tool_result`,toolCallId:t,result:{error:e},isError:!0});ee.current.clear()},[r]),le=(0,b.useCallback)(()=>{ce(`User started a new session.`),N.current=null,M(null),e.current?.clearMessages(),F.current?.()},[e,ce]),ue=(0,b.useCallback)(async e=>{let t=await o(e);return A(t.sessions),t.sessions},[o]),de=(0,b.useCallback)(async(e,t)=>{await c(e,t),A(n=>n.map(n=>n.id===e?{...n,name:t}:n))},[c]),fe=(0,b.useCallback)(async t=>{ce(`User switched to a different session.`),N.current=t,M(t),e.current?.clearMessages(),O(!0);try{let n=(await s(t)).messages?.filter(e=>e.role===`user`||e.role===`assistant`).map((e,n)=>({id:`history-${t}-${n}`,role:e.role,content:e.content,status:`complete`}));e.current?.loadMessages(n),P.current?.(t)}catch(t){console.warn(`Failed to load session messages, clearing:`,t),N.current=null,M(null),e.current?.clearMessages(),F.current?.()}finally{O(!1)}},[e,s,ce]),pe=(0,b.useRef)(t?.initialSessionId??null);return(0,b.useEffect)(()=>{x&&(ue({limit:1}).catch(()=>{}),pe.current!=null&&fe(pe.current))},[x]),{sendMessage:re,uploadAiImage:ne,isStreaming:T,cancel:ae,isLoadingSession:D,isConnected:i,authError:a,newSession:le,sessions:k,currentSessionId:j,getSessions:ue,setSessionName:de,loadSession:fe,answerToolQuestions:oe,cancelToolQuestion:se}}function d4e({className:e}){let t=(0,b.useRef)(null),n=QS(),r=Ice(),{chatEditorRef:i,flushPendingFieldRefs:a}=wS(),o=VS(),{sessionParam:s,setSessionParam:c}=KC(),{sendMessage:l,uploadAiImage:u,isConnected:d,authError:f,newSession:p,sessions:m,currentSessionId:h,getSessions:g,setSessionName:_,loadSession:v,isLoadingSession:y,answerToolQuestions:x,cancelToolQuestion:S,cancel:C}=u4e(t,{initialSessionId:(0,b.useRef)(s).current,onSessionBorn:e=>{c(e,{replace:!0});try{sessionStorage.setItem(Zf,e)}catch{}},onSessionCleared:()=>{c(null,{replace:!0});try{sessionStorage.removeItem(Zf)}catch{}}});return(0,b.useEffect)(()=>{let e=requestAnimationFrame(()=>a());return()=>cancelAnimationFrame(e)},[a]),(0,Y.jsx)(M2e,{ref:t,className:e,chatEditorRef:i,onSendMessage:l,onCancel:C,models:o.models,selectedModel:o.selected,onSelectModel:o.select,onUploadFile:u,onNewSession:p,isConnected:d,authError:f,unavailable:r?{message:r.message,onRetry:r.retry}:void 0,mode:n,sessions:m,currentSessionId:h,onLoadSession:v,onFetchSessions:g,onSetSessionName:_,isLoadingSession:y,onAnswerToolQuestions:x,onCancelToolQuestion:S})}function f4e(){let e=Iqe();return IS()===`login-required`?(0,Y.jsx)(`div`,{className:`min-h-[100svh] bg-bg-primary`,children:(0,Y.jsx)(NYe,{})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(p4e,{state:e}),(0,Y.jsx)(hXe,{}),(0,Y.jsx)(_Xe,{}),(0,Y.jsx)(LYe,{}),(0,Y.jsx)(VYe,{})]})}function p4e({state:e}){let{theme:t,setTheme:n}=Qy(),r=QS(),i=Lce(),{isAIChatEnabled:a,setOpenAIChatImpl:o}=wS(),s=TS(),c=GC(),l=_ce(),u=JS(),{patchErrors:d}=oC(),f=Fb(),[p,m]=(0,b.useState)(``),h=Rqe(p),g=Wqe(),[_,v]=(0,b.useState)(()=>({panel:g.initial.panel,canvasOpen:g.initial.canvasOpen,canvasView:g.initial.canvasView,canvasTransform:g.initial.canvasTransform})),{isPublishing:y}=eC(),x=xce(),S=KS(),{deletePatches:C}=RS(),w=YS(),T=GS(),E=US(),D=sC(),O=nC(),k=eb(),A=(0,b.useMemo)(()=>w.filter(e=>!T.has(e)),[w,T]),j=(0,b.useMemo)(()=>{if(E.status!==`success`)return[];let e=new Set(A),t=new Set;for(let n of E.data)for(let r of n.patches)r.author!==null&&r.author!==O&&e.has(r.patchId)&&t.add(r.author);return[...t].map(e=>D?.[e]?.fullName).filter(e=>!!e)},[E,A,D,O]),M=Sce(),N=Cce(),[P,F]=(0,b.useState)();(0,b.useEffect)(()=>{let e=()=>{let e=o8(window.location.search);F(t=>({epoch:(t?.epoch??0)+1,panel:e.panel,canvasOpen:e.canvasOpen,canvasView:e.canvasView}))};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let I=(0,b.useRef)(_);I.current=_;let L=(0,b.useCallback)(()=>{F(e=>({epoch:(e?.epoch??0)+1,panel:`ai`,canvasOpen:I.current.canvasOpen,canvasView:I.current.canvasView}))},[]);(0,b.useEffect)(()=>{if(a)return o(L),()=>o(null)},[a,o,L]);let R=e.status===`success`?e.data:v4e,ee=(0,b.useMemo)(()=>h4e(R,c.currentSourcePath),[R,c.currentSourcePath]),te=(0,b.useMemo)(()=>ee===null?null:$6(R,ee),[R,ee]),ne=(0,b.useCallback)(e=>{c.navigate(e.sourcePath)},[c]),re=c.focusedSourcePath??(c.currentSourcePath||null);(0,b.useEffect)(()=>{if(_.canvasView!==`normal`)return;let e=c.focusedSourcePath;e&&HC(e)},[_.canvasView,c.focusedSourcePath]);let ie=(0,b.useCallback)(e=>(0,Y.jsx)(j8,{path:c.currentSourcePath||e.sourcePath,showModuleGalleryChild:null}),[c.currentSourcePath]),ae=te?.kind===`page`?te.urlPath:null,[oe,se]=(0,b.useState)(g.initial.canvasRoute),ce=(0,b.useRef)(!0);(0,b.useEffect)(()=>{if(ce.current){ce.current=!1;return}se(null)},[ae]);let le=(0,b.useMemo)(()=>{let e=new Map,t=n=>{for(let r of n)r.sourcePath!==void 0&&(e.has(r.urlPath)||e.set(r.urlPath,r.sourcePath)),t(r.children??[])};return t(R.pages),e},[R.pages]),ue=(0,b.useCallback)(e=>{se(e);let t=le.get(e);t!==void 0&&c.navigate(t)},[le,c]),de=(0,b.useMemo)(()=>Array.from(le.keys()).sort((e,t)=>e.localeCompare(t)),[le]),fe=(0,b.useMemo)(()=>Oqe(de),[de]),pe=ae??fe,me=oe??pe;Gqe(g.write,(0,b.useMemo)(()=>({..._,canvasRoute:oe!==null&&oe!==pe?oe:null}),[_,oe,pe]));let[he,ge]=(0,b.useState)([]),_e=(0,b.useMemo)(()=>{let e=new Set,t=[];for(let n of he)for(let r of n.paths)e.has(r)||(e.add(r),t.push(r));return t},[he]),ve=(0,b.useMemo)(()=>{let e=new URL(me,window.location.origin).toString();return`/api/val/enable?redirect_to=${encodeURIComponent(e)}`},[me]),ye=(0,b.useCallback)(()=>{window.open(ve,`_blank`,`noopener,noreferrer`)},[ve]),be=Mb(),xe=(0,b.useCallback)(e=>rA(e,be),[be]),Se=yJe(),Ce=DRe(),we=(0,b.useCallback)(e=>{let t=e.moduleFilePath;c.navigate(t),Ce(t)},[c,Ce]),z=Db(),B=(0,b.useCallback)(e=>{let t=z(e)??e;c.navigate(t,{scrollToPath:e})},[c,z]),Te=ioe(),Ee=Nce(),V=(0,b.useCallback)(e=>{let t=e[0];if(t===void 0)return Ee(`That element on the page has no content behind it`,`The page reported a selection with no source path. Check that @valbuild/next and @valbuild/ui are on the same version.`),!1;let n=Te(t);return n.status===`resolved`?(c.navigate(n.path,{scrollToPath:t}),!0):(Ee(..._4e(n,t)),!1)},[c,Te,Ee]),De=(0,b.useMemo)(()=>({width:e,height:t,reloadKey:n,isPicking:r,onRequestReload:i,onRefreshingChange:a,onPinch:o,onZoom:s,onPicked:c})=>(0,Y.jsx)(Tqe,{url:me,width:e,height:t,reloadKey:n,isPicking:r,highlightedPath:r?re:null,onElements:ge,onPick:e=>{V(e)&&c()},onPinch:o,onZoom:s,onRequestReload:i,onRefreshingChange:a}),[me,re,V]),Oe=(0,b.useMemo)(()=>f===void 0?[]:Object.keys(f),[f]),ke=(0,b.useCallback)(e=>{let t=Oe.filter(t=>t.startsWith(e.id));c.navigate(LC,{errorFields:t.length>0?t:Oe})},[c,Oe]),Ae=(0,b.useCallback)(()=>{c.navigate(IC)},[c]),je=(0,b.useMemo)(()=>{if(r===`http`)return()=>{let e=encodeURIComponent(window.location.href);window.location.href=`/api/val/logout?redirect_to=${e}`}},[r]),Me=(0,b.useMemo)(()=>Object.values(d??{}).some(e=>Object.keys(e??{}).length>0)||l===`service-unavailable`?`error`:u.length>0?`saving`:`saved`,[d,l,u]),Ne=y?`publishing`:`idle`,{autoPublish:Pe,setAutoPublish:Fe}=aC(),Ie=!c.isCompareView&&!c.isErrorsView&&ee===null&&c.currentSourcePath?c.currentSourcePath:null,Le=c.isCompareView?(0,Y.jsx)(m4e,{}):c.isErrorsView?(0,Y.jsx)(RJe,{}):Ie?(0,Y.jsx)(j8,{path:Ie,showModuleGalleryChild:null}):null;return(0,Y.jsx)(Sqe,{data:R,theme:t===`light`?`light`:`dark`,onThemeChange:n,mode:r,selectionId:Le?null:ee,onSelectionChange:ne,renderEditor:ie,editorOverride:Le,publishSlot:(0,Y.jsx)(V8,{}),publishState:Ne,saveState:Me,autoSave:Pe,onAutoSaveChange:Fe,pendingChanges:R.pendingChanges??0,reviewCount:S?R.pendingChanges??0:0,onDiscardAll:A.length>0&&E.status===`success`?()=>C(A):void 0,discardAllDescription:i8(A.length,j),portalContainer:k,isLoading:e.status===`loading`,loadError:e.status===`error`?e.error:void 0,renderCanvas:De,canvasPaths:_e,onSelectCanvasPath:B,selectedCanvasPath:re,canvasRoute:me,onCanvasRouteChange:ue,canvasRoutes:de,initialPanel:g.initial.panel,initialCanvasOpen:g.initial.canvasOpen,initialCanvasView:g.initial.canvasView,restoreViewState:P,initialCanvasTransform:g.initial.canvasTransform,onViewStateChange:v,onNewPage:Se,onUploadMedia:we,onPreview:ye,previewHref:ve,onSelectValidationError:ke,onCompare:Ae,onSelectActivity:e=>B(e.sourcePath),getMediaFileUrl:xe,searchContentResults:h.results,isSearchingContent:h.isSearching,onSearchQueryChange:m,onOpenSearchResult:e=>B(e.id),onSignOut:je,accountError:i?{message:i.message,onRetry:i.retry}:void 0,aiEnabled:a,aiSlot:a?(0,Y.jsx)(d4e,{className:`h-full`}):void 0,onMentionField:e=>s(e),pendingChangesLoaded:x,pendingChangesProgress:M,pendingChangesError:N})}function m4e(){let e=nb();(0,b.useEffect)(()=>{e!==null&&e.system.patchSync.flush()},[e]);let t=US(),n=sC(),r=QS(),i=vce();return t.status===`not-asked`?(0,Y.jsx)(n5,{}):t.status===`error`?(0,Y.jsxs)(`div`,{className:`text-sm text-fg-error py-8 text-center`,children:[`Failed to load changes: `,t.error]}):(0,Y.jsx)(mYe,{patchSets:t.data,profilesByAuthorIds:n,mode:r,canDiscard:!0,reloadKey:i})}function h4e(e,t){if(!t)return null;let n=null,r=e=>{g4e(t,e)&&(n===null||e.length>n.length)&&(n=e)},i=e=>{for(let t of e)t.sourcePath!==void 0&&r(t.id),i(t.children??[])};i(e.pages);for(let t of e.externalPages)t.sourcePath!==void 0&&r(t.id);for(let t of e.media)r(t.id);for(let t of e.data)r(t.id);return n}function g4e(e,t){if(e===t)return!0;if(!e.startsWith(t))return!1;let n=e[t.length];return n===`?`||n===`.`}function _4e(e,t){return e.status===`schemas-not-loaded`?[`Still loading — try that again in a moment`,`The content schema had not arrived yet, so ${t} could not be opened.`]:e.status===`module-not-loaded`?[`That field's content file is not loaded`,`The page points at ${e.moduleFilePath}, which the studio does not have. It may have been deleted or renamed since the page was built.`]:[`That field is no longer where the page says it is`,`${t} does not resolve in ${e.moduleFilePath}: ${e.reason}. The page is probably rendering content from before a change to the schema — reload the canvas.`]}var v4e={projectName:`Val`,hasRouters:!1,pages:[],externalPages:[],media:[],data:[],validationErrors:[]},y4e=(0,b.createContext)(null),B9={didCatch:!1,error:null},V9=class extends b.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=B9}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:`imperative-api`}),this.setState(B9))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;n&&t.error!==null&&b4e(e.resetKeys,r)&&(this.props.onReset?.({next:r,prev:e.resetKeys,reason:`keys`}),this.setState(B9))}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:a}=this.state,o=e;if(i){let e={error:a,resetErrorBoundary:this.resetErrorBoundary};if(typeof t==`function`)o=t(e);else if(n)o=(0,b.createElement)(n,e);else if(r!==void 0)o=r;else throw a}return(0,b.createElement)(y4e.Provider,{value:{didCatch:i,error:a,resetErrorBoundary:this.resetErrorBoundary}},o)}};function b4e(e=[],t=[]){return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}var x4e=({className:e})=>(0,Y.jsxs)(`svg`,{width:`58`,height:`34`,viewBox:`0 0 58 34`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:e,children:[(0,Y.jsx)(`g`,{filter:`url(#filter0_d_21_1677)`,children:(0,Y.jsx)(`path`,{d:`M5 5.36426C5 5.16309 5.16309 5 5.36426 5H17.6581C17.8593 5 18.0223 5.16309 18.0223 5.36426V28.4949C18.0223 28.696 17.8593 28.8591 17.6581 28.8591H5.36426C5.16309 28.8591 5 28.696 5 28.4949V5.36426Z`,fill:`hsl(var(--accent))`})}),(0,Y.jsx)(`g`,{filter:`url(#filter1_i_21_1677)`,children:(0,Y.jsx)(`circle`,{cx:`11.4656`,cy:`23.7595`,r:`2.18557`,fill:`currentColor`})}),(0,Y.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M52.8588 23.839H48.7257H48.537H48.1128C47.6715 23.839 47.4508 23.5942 47.4508 23.1044V13.7293C47.4508 13.5784 47.3285 13.4561 47.1777 13.4561H45.8118C45.6609 13.4561 45.5386 13.5784 45.5386 13.7293V15.1836C45.5386 15.2844 45.4569 15.3661 45.3561 15.3661C45.2876 15.3661 45.225 15.3275 45.1924 15.2672C44.805 14.5503 44.283 14.02 43.6264 13.6765C42.9563 13.301 42.2045 13.1132 41.3709 13.1132C40.6028 13.1132 39.8755 13.252 39.189 13.5295C38.5026 13.8071 37.8979 14.2152 37.3748 14.7539C36.8682 15.2764 36.4678 15.9212 36.1736 16.6885C35.8794 17.4558 35.7323 18.3374 35.7323 19.3332V19.725C35.7323 20.7372 35.8794 21.627 36.1736 22.3942C36.4678 23.1615 36.8682 23.8146 37.3748 24.3533C37.8979 24.8757 38.5026 25.2757 39.189 25.5532C39.8755 25.8144 40.6191 25.945 41.42 25.945C42.1881 25.945 42.9154 25.7491 43.6019 25.3573C44.2751 24.982 44.8058 24.4119 45.1941 23.6471C45.2255 23.5852 45.2886 23.5452 45.358 23.5452H45.3917C45.4728 23.5452 45.5386 23.611 45.5386 23.6921C45.5386 23.7904 45.544 23.8856 45.5547 23.9777V25.1392C45.5547 25.3904 45.7584 25.5941 46.0096 25.5941H47.2261C47.2914 25.5995 47.3581 25.6022 47.4263 25.6022H48.537H48.7257H57.7268C57.8777 25.6022 58 25.4799 58 25.329V24.1122C58 23.9614 57.8777 23.839 57.7268 23.839H55.3174C55.1665 23.839 55.0442 23.7167 55.0442 23.5659V8.73368C55.0442 8.58279 54.9219 8.46048 54.771 8.46048H50.5054C50.3545 8.46048 50.2322 8.58279 50.2322 8.73368V9.95043C50.2322 10.1013 50.3545 10.2236 50.5054 10.2236H52.8588C53.0097 10.2236 53.132 10.3459 53.132 10.4968V23.5659C53.132 23.7167 53.0097 23.839 52.8588 23.839ZM41.6161 24.1329C42.1881 24.1329 42.7111 24.0268 43.1851 23.8146C43.6754 23.6023 44.0922 23.3003 44.4354 22.9085C44.7786 22.5167 45.0483 22.0514 45.2444 21.5127C45.4406 20.9576 45.5386 20.3454 45.5386 19.6761V19.3822C45.5386 18.7292 45.4406 18.1333 45.2444 17.5946C45.0483 17.0395 44.7705 16.5661 44.4109 16.1743C44.0677 15.7824 43.6509 15.4804 43.1606 15.2682C42.6866 15.0396 42.1718 14.9254 41.6161 14.9254C41.044 14.9254 40.521 15.0315 40.0471 15.2437C39.5731 15.4559 39.1563 15.758 38.7968 16.1498C38.4535 16.5252 38.1839 16.9905 37.9877 17.5456C37.7916 18.0843 37.6936 18.6802 37.6936 19.3332V19.725C37.6936 21.1127 38.0531 22.1983 38.7722 22.982C39.5077 23.7493 40.4557 24.1329 41.6161 24.1329ZM31.1115 25.4191C31.0732 25.5287 30.9698 25.6022 30.8536 25.6022H27.4661C27.35 25.6022 27.2465 25.5287 27.2082 25.4191L23.1578 13.8193C23.0958 13.6417 23.2276 13.4561 23.4157 13.4561H25.089C25.2068 13.4561 25.3114 13.5316 25.3484 13.6435L28.9666 24.581C28.9942 24.6643 29.0721 24.7206 29.1599 24.7206C29.2477 24.7206 29.3256 24.6643 29.3532 24.581L32.9714 13.6435C33.0084 13.5316 33.1129 13.4561 33.2308 13.4561H34.9041C35.0922 13.4561 35.224 13.6417 35.162 13.8193L31.1115 25.4191Z`,fill:`currentColor`}),(0,Y.jsxs)(`defs`,{children:[(0,Y.jsxs)(`filter`,{id:`filter0_d_21_1677`,x:`0.124722`,y:`0.124722`,width:`22.7729`,height:`33.6097`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Y.jsx)(`feFlood`,{floodOpacity:`0`,result:`BackgroundImageFix`}),(0,Y.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Y.jsx)(`feOffset`,{}),(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`2.43764`}),(0,Y.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`out`}),(0,Y.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0.219608 0 0 0 0 0.803922 0 0 0 0 0.501961 0 0 0 0.3 0`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in2:`BackgroundImageFix`,result:`effect1_dropShadow_21_1677`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in:`SourceGraphic`,in2:`effect1_dropShadow_21_1677`,result:`shape`})]}),(0,Y.jsxs)(`filter`,{id:`filter1_i_21_1677`,x:`9.28003`,y:`21.5739`,width:`4.37112`,height:`4.37112`,filterUnits:`userSpaceOnUse`,colorInterpolationFilters:`sRGB`,children:[(0,Y.jsx)(`feFlood`,{floodOpacity:`0`,result:`BackgroundImageFix`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in:`SourceGraphic`,in2:`BackgroundImageFix`,result:`shape`}),(0,Y.jsx)(`feColorMatrix`,{in:`SourceAlpha`,type:`matrix`,values:`0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0`,result:`hardAlpha`}),(0,Y.jsx)(`feOffset`,{}),(0,Y.jsx)(`feGaussianBlur`,{stdDeviation:`0.546392`}),(0,Y.jsx)(`feComposite`,{in2:`hardAlpha`,operator:`arithmetic`,k2:`-1`,k3:`1`}),(0,Y.jsx)(`feColorMatrix`,{type:`matrix`,values:`0 0 0 0 0.219608 0 0 0 0 0.803922 0 0 0 0 0.501961 0 0 0 0.3 0`}),(0,Y.jsx)(`feBlend`,{mode:`normal`,in2:`shape`,result:`effect1_innerShadow_21_1677`})]})]})]});function S4e({error:e,resetErrorBoundary:t,onDeleteAllPatches:n,onDeleteLastPatch:r}){return(0,Y.jsx)(`div`,{className:`flex absolute top-0 left-0 justify-center items-center w-screen h-screen bg-bg-primary text-fg-primary`,children:(0,Y.jsx)(`div`,{className:`p-10 w-full h-full`,children:(0,Y.jsxs)(`div`,{className:`overflow-scroll p-10 w-full h-full bg-card text-fg-primary`,children:[(0,Y.jsx)(`div`,{className:`flex justify-between items-center`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-[0.5em] text-lg font-bold text-center py-2`,children:[(0,Y.jsx)(x4e,{}),` encountered an error`,(0,Y.jsx)(`button`,{onClick:t,children:(0,Y.jsx)(Hy,{})})]})}),(0,Y.jsx)(`div`,{className:`text-4xl font-normal`,children:`Message:`}),(0,Y.jsx)(`pre`,{children:e.message}),e.stack&&(0,Y.jsx)(zk,{type:`single`,className:`font-serif`,collapsible:!0,defaultValue:`error`,children:(0,Y.jsxs)(Bk,{value:`error`,children:[(0,Y.jsx)(Vk,{children:`Stack trace:`}),(0,Y.jsx)(Hk,{className:`p-4 bg-bg-secondary`,children:e.stack&&(0,Y.jsx)(`pre`,{children:e.stack})})]})}),(r||n)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 py-8`,children:[(0,Y.jsx)(`p`,{className:`max-w-prose text-pretty`,children:`If this problem was caused by a recent change, you can revert all recent changes by clicking the button below. If the problem persists after reverting changes, a developer needs to investigate.`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r&&(0,Y.jsx)(t_,{variant:`destructive`,onClick:r,className:`text-sm px-3 py-1.5 rounded border border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground transition-colors`,children:`Revert last change`}),n&&(0,Y.jsx)(t_,{variant:`destructive`,onClick:n,className:`text-sm px-3 py-1.5 rounded border border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground transition-colors`,children:`Revert all changes`})]})]})]})})})}function C4e({error:e,resetErrorBoundary:t}){return console.error(e),(0,Y.jsx)(S4e,{error:e,resetErrorBoundary:t})}function w4e({error:e,resetErrorBoundary:t}){console.error(e);let n=YS(),{deletePatches:r}=RS(),i=n.length>0?()=>{r(n),t()}:void 0,a=n.length>0?n[n.length-1]:void 0;return(0,Y.jsx)(S4e,{error:e,resetErrorBoundary:t,onDeleteAllPatches:i,onDeleteLastPatch:a?()=>{r([a]),t()}:void 0})}var T4e=({client:e,config:t,valModules:n,cssLoaded:r,theme:i,setTheme:a})=>(0,Y.jsx)(PS,{client:e,dispatchValEvents:!1,config:t,valModules:n??null,theme:i,setTheme:a,children:(0,Y.jsx)(V9,{FallbackComponent:w4e,children:(0,Y.jsx)(`div`,{style:{minHeight:`100svh`,width:`100vw`,visibility:`hidden`},id:`val-app-container`,children:(0,Y.jsx)(WC,{children:(0,Y.jsx)(ERe,{children:r&&(0,Y.jsx)(f4e,{})})})})})});function E4e({root:e,children:t}){return(0,lm.createPortal)(t,e)}var D4e=({children:e,style:t})=>{let n=(0,b.useRef)(null),[r,i]=(0,b.useState)(null);return(0,b.useLayoutEffect)(()=>{if(n.current){if(n.current.shadowRoot)i(n.current.shadowRoot);else{let e=n.current.attachShadow({mode:`open`});i(e)}}},[]),(0,Y.jsx)(`div`,{ref:n,style:t,id:`val-shadow-root`,children:r&&(0,Y.jsx)(E4e,{root:r,children:e})})},O4e=`/spa/index.css`,H9=`val-app`,k4e=`val-overlay`,A4e=`$$BUILD_$$REPLACE_WITH_VERSION$$`;function j4e(){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`link`,{rel:`preconnect`,href:`https://fonts.googleapis.com`}),(0,Y.jsx)(`link`,{rel:`preconnect`,href:`https://fonts.gstatic.com`,crossOrigin:`use-credentials`}),(0,Y.jsx)(`link`,{href:`https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Space+Grotesk:wght@300..700&display=swap`,rel:`stylesheet`})]})}function M4e(){let[e,t]=(0,b.useState)(null),n=(0,b.useMemo)(N4e,[]);return(0,b.useEffect)(()=>{let e=e=>{e.key===`val-config`&&t(N4e())};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[]),e||n}function N4e(){let e=sessionStorage.getItem(Yf);if(e){let t=Qf.safeParse(JSON.parse(e));return t.error?(console.error(`Error parsing config from session storage`,t.error),null):t.data}return null}var P4e=`val-modules-updated`;function F4e(){let[e,t]=(0,b.useState)(()=>typeof window<`u`?window.__VAL_MODULES__??null:null);return(0,b.useEffect)(()=>{let e=()=>{t(window.__VAL_MODULES__??null)};return window.__VAL_MODULES__&&t(window.__VAL_MODULES__),window.addEventListener(P4e,e),()=>{window.removeEventListener(P4e,e)}},[]),e}function I4e(){let e=M4e(),t=F4e(),n=`/api/val`,{client:r}=(0,b.useMemo)(()=>({client:Hf(n,{...e,contentHostUrl:Dr})}),[n,e]),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(()=>{try{let e=sessionStorage.getItem(Xf);if(e===`light`||e===`dark`)return e;let t=sessionStorage.getItem(Yf),n=t?JSON.parse(t):null,r=localStorage.getItem(`val-theme-`+(n?.project||`unknown`));if(r===`light`||r===`dark`)return r;if(n?.defaultTheme===`light`||n?.defaultTheme===`dark`)return n.defaultTheme}catch{}return`dark`});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(j4e,{}),(0,Y.jsxs)(D4e,{children:[(0,Y.jsx)(`link`,{rel:`stylesheet`,href:`${n}/static${`/${A4e}`}${O4e}`,onLoad:()=>{window.dispatchEvent(new CustomEvent(`val-css-loaded`,{detail:{type:`val-css-loaded`}})),a(!0)}}),(0,Y.jsx)(V9,{fallbackRender:C4e,children:(0,Y.jsx)(`div`,{...o?{"data-mode":o}:{},className:`bg-bg-primary font-sans text-fg-primary`,children:(0,Y.jsx)(T4e,{client:r,config:e,valModules:t,cssLoaded:i,theme:o,setTheme:s})})})]})]})}var L4e=Object.defineProperty,U9=(e,t)=>L4e(e,`name`,{value:t,configurable:!0}),W9=`Switch`,[R4e,z4e]=sm(W9),[B4e,G9]=R4e(W9);function V4e(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=ng({prop:n,defaultProp:i??!1,onChange:c,caller:W9}),[m,h]=b.useState(null),[g,_]=b.useState(null),v=b.useRef(!1),[y,x]=b.useReducer(e=>e+1,0),S={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:y,onUserInteraction:x,required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,Y.jsx)(B4e,{scope:t,...S,children:Y4e(d)?d(S):r})}U9(V4e,`SwitchProvider`);var H4e=`SwitchTrigger`,U4e=b.forwardRef(U9(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=G9(H4e,e),g=am(r,u),_=b.useRef(c);return b.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=U9(()=>d(_.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,Y.jsx)(xm.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":K9(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:g,onClick:Qp(t,e=>{p(),d(e=>!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`SwitchTrigger`)),W4e=b.forwardRef(U9(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Y.jsx)(V4e,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(U4e,{...d,ref:t,__scopeSwitch:n}),e&&(0,Y.jsx)(J4e,{__scopeSwitch:n})]})})},`Switch`)),G4e=`SwitchThumb`,K4e=b.forwardRef(U9(function(e,t){let{__scopeSwitch:n,...r}=e,i=G9(G4e,n);return(0,Y.jsx)(xm.span,{"data-state":K9(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),q4e=`SwitchBubbleInput`,J4e=b.forwardRef(U9(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:m,setBubbleInput:h}=G9(q4e,e),g=am(r,h),_=zh(i),v=b.useRef(!1),y=b.useRef(s),x=b.useRef(o);b.useEffect(()=>{let e=m;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==x.current;x.current=o;let i=y.current!==s;y.current=s;let c=!(r&&a.current);if(i&&n){v.current=!r;let t=new Event(`click`,{bubbles:c});n.call(e,s),e.dispatchEvent(t),v.current=!1}},[m,s,a,o]);let S=b.useRef(s);return(0,Y.jsx)(xm.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??S.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:g,onClick:Qp(t,e=>{v.current&&e.stopPropagation()}),style:{...n.style,..._,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function Y4e(e){return typeof e==`function`}U9(Y4e,`isFunction`);function K9(e){return e?`checked`:`unchecked`}U9(K9,`getState`);var X4e=b.forwardRef(({className:e,...t},n)=>(0,Y.jsx)(W4e,{className:X(`peer inline-flex h-[22px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:bg-bg-primary disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-bg-tertiary data-[state=unchecked]:bg-bg-secondary-hover`,e),...t,ref:n,children:(0,Y.jsx)(K4e,{className:X(`pointer-events-none block h-[18px] w-5 rounded-full bg-bg-primary shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0`)})}));X4e.displayName=W4e.displayName;function q9({size:e}){return(0,Y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Y.jsx)(`circle`,{cx:`12`,cy:`12`,r:`11`}),(0,Y.jsx)(`line`,{x1:`12`,y1:`4`,x2:`12`,y2:`12`,className:`animate-rotate-clock-minute-hand origin-center`}),(0,Y.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`,className:`animate-rotate-clock-hour-hand origin-center`})]})}function Z4e({orientation:e,ghost:t,compact:n,children:r,className:i}){return(0,Y.jsx)(`div`,{role:`toolbar`,"aria-label":`Val`,"aria-orientation":e,className:X(`flex relative items-center rounded-lg`,`bg-bg-float border border-border-float text-fg-primary shadow-lg`,e===`vertical`?`flex-col`:`flex-row`,n?e===`vertical`?`flex-col gap-0.5 px-1 py-1.5`:`flex-row gap-0.5 px-1.5 py-1`:e===`vertical`?`flex-col gap-1 px-1.5 py-2`:`flex-row gap-1 px-2 py-1.5`,t&&`opacity-70`,i),children:r})}(0,b.forwardRef)(function({label:e,icon:t,active:n,disabled:r,href:i,compact:a,onClick:o,onMouseEnter:s,onMouseLeave:c,...l},u){let d=X(`inline-flex items-center justify-center shrink-0 rounded-md transition-colors`,a?`w-7 h-7`:`w-8 h-8`,n?`bg-bg-float-raised text-fg-primary`:`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`,r&&`text-fg-disabled pointer-events-none`);return i?(0,Y.jsx)(`a`,{ref:u,href:i,className:d,onClick:o,onMouseEnter:s,onMouseLeave:c,"aria-label":e,title:e,...l,children:t}):(0,Y.jsx)(`button`,{ref:u,type:`button`,disabled:r,"aria-pressed":n,className:d,onClick:o,onMouseEnter:s,onMouseLeave:c,"aria-label":e,title:e,...l,children:t})});function Q4e({orientation:e}){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`shrink-0 bg-border-float`,e===`vertical`?`h-px w-5 my-0.5`:`w-px h-5 mx-0.5`)})}function $4e({orientation:e,dock:t,compact:n,ghost:r,status:i=`none`,mark:a,children:o,expanded:s,onExpandedChange:c,defaultExpanded:l=!1}){let[u,d]=(0,b.useState)(l),[f,p]=(0,b.useState)(!1),m=r===!0||(s??(u||f)),h=s!==void 0&&!!c,g=e=>{if(h){c?.(e);return}d(e),e||p(!1)},_=(0,b.useRef)(null);o6(_,m,(0,b.useCallback)(()=>g(!1),[g])),(0,b.useEffect)(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&g(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,g]);let v=t===`right-top`||t===`right-center`||t===`right-bottom`,y=e===`vertical`;return(0,Y.jsx)(`div`,{ref:_,onMouseEnter:()=>h?g(!0):p(!0),onMouseLeave:()=>h?g(!1):p(!1),className:X(`inline-flex`,y?`flex-col`:`flex-row`),children:(0,Y.jsx)(Z4e,{orientation:e,compact:n,ghost:r,className:X(`transition-[border-radius,padding] duration-200`,!m&&[`rounded-full`,`p-1.5`]),children:(0,Y.jsxs)(`div`,{className:X(`flex items-center`,y?`flex-col`:`flex-row`,v?y?`flex-col-reverse`:`flex-row-reverse`:void 0),children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":m,"aria-label":m?`Close Val menu`:`Open Val menu`,onClick:()=>g(h?!m:!u),className:X(`relative grid place-items-center shrink-0 rounded-full transition-colors`,n&&m?`w-7 h-7`:`w-8 h-8`,`text-fg-primary hover:bg-bg-float-raised`),children:[a,i!==`none`&&!m&&(0,Y.jsx)(`span`,{"aria-hidden":!0,className:X(`absolute -right-0.5 -top-0.5 w-2 h-2 rounded-full ring-2 ring-bg-float`,i===`errors`?`bg-bg-error-primary`:`bg-fg-secondary`)})]}),(0,Y.jsx)(`div`,{className:X(`overflow-hidden`,`transition-[max-width,max-height,opacity,visibility] duration-200 ease-out`,m?y?`max-h-[32rem] max-w-[32rem] px-2 -mx-2`:`max-w-[32rem] max-h-[32rem] py-2 -my-2`:`max-w-0 max-h-0`,m?`opacity-100`:`opacity-0`,m?`visible`:`invisible`),children:(0,Y.jsx)(`div`,{className:X(`flex items-center`,y?`flex-col`:`flex-row`,n?`gap-0.5`:`gap-1`,y?`pt-1`:`pl-1`),children:o})})]})})})}var J9=(0,b.createContext)({bornSessionId:null,setBornSessionId:()=>{}});function Y9(e,t){return t?`${e}${e.includes(`?`)?`&`:`?`}session=${encodeURIComponent(t)}`:e}function e3e(e){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)(null),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)([]),[p,m]=(0,b.useState)(!1),[h,g]=(0,b.useState)(()=>{try{return sessionStorage.getItem(Zf)}catch{return null}}),_=(0,b.useCallback)(e=>{g(e);try{e==null?sessionStorage.removeItem(Zf):sessionStorage.setItem(Zf,e)}catch{}},[]);(0,b.useEffect)(()=>{e.draftMode||(n(null),i(null),o(null),c(!1),u(!1),f([]),m(!1))},[e.draftMode]),(0,b.useEffect)(()=>{if(t===`select`&&r===null){let e=(e,t)=>{let n=document.elementsFromPoint(e,t),r=null;for(let e of n)if(e instanceof HTMLElement){let t=e.getAttribute(`data-val-path`);if(t){let n=e;if(e.tagName===`SOURCE`){let t=e.parentElement;t&&(t.tagName===`VIDEO`||t.tagName===`PICTURE`)&&(n=t)}let i=n.getBoundingClientRect();r={top:i.top+window.scrollY,left:i.left+window.scrollX,width:i.width,height:i.height,joinedPaths:t}}}o(r)},t=t=>{e(t.touches[0].clientX,t.touches[0].clientY)},n=t=>{e(t.clientX,t.clientY)},r=()=>{o(null)},i=()=>{o(null)};return window.addEventListener(`mousemove`,n),window.addEventListener(`touchmove`,t),window.addEventListener(`touchstart`,t),window.addEventListener(`mouseleave`,r),window.addEventListener(`resize`,i),()=>{window.removeEventListener(`mousemove`,n),window.removeEventListener(`touchmove`,t),window.removeEventListener(`touchstart`,t),window.removeEventListener(`mouseleave`,r),window.removeEventListener(`resize`,i),o(null)}}o(null)},[r,t]),(0,b.useEffect)(()=>{if(t===`select`&&r===null){let e=e=>{e.key===`Escape`&&(n(null),o(null))};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}}},[t,r]);let{theme:v}=Qy(),[y,x]=(0,b.useState)(null),S=bb(),C=`val-menu-right-center`;(0,b.useEffect)(()=>{try{let e=S&&localStorage.getItem(`val-menu-drop-zone-`+(S?.project||`unknown`))||localStorage.getItem(`val-menu-drop-zone-default`);if(e){if(e===`val-menu-left-top`||e===`val-menu-left-center`||e===`val-menu-left-bottom`||e===`val-menu-center-top`||e===`val-menu-center-bottom`||e===`val-menu-right-top`||e===`val-menu-right-center`||e===`val-menu-right-bottom`)x(e);else throw Error(`Invalid drop zone: `+e)}else x(C)}catch(e){console.error(`Error getting drop zone from local storage`,e),x(C)}},[S]);let w=e=>{x(e);try{e&&(localStorage.setItem(`val-menu-drop-zone-`+(S?.project||`unknown`),e),localStorage.setItem(`val-menu-drop-zone-default`,e))}catch(e){console.error(`Error setting drop zone to local storage`,e)}},T=()=>{let e=document.querySelectorAll(`[data-val-path]`),t=[];return e.forEach(e=>{if(e instanceof HTMLElement){let n=e.getAttribute(`data-val-path`);if(n){let r=e;if(e.tagName===`SOURCE`){let t=e.parentElement;t&&(t.tagName===`VIDEO`||t.tagName===`PICTURE`)&&(r=t)}let i=r.getBoundingClientRect();t.push({top:i.top+window.scrollY,left:i.left+window.scrollX,width:i.width,height:i.height,joinedPaths:n})}}}),t};return(0,Y.jsx)(J9.Provider,{value:{bornSessionId:h,setBornSessionId:_},children:(0,Y.jsxs)(`div`,{...v?{"data-mode":v}:{},id:`val-overlay-container`,children:[(0,Y.jsx)(t3e,{editMode:r,setMode:n,setEditMode:i}),a&&(0,Y.jsx)(`div`,{className:X(`absolute z-[8998]`,`cursor-pointer`,`rounded-sm`,`transition-all duration-150 ease-in-out`,`border-2 border-bg-page-selection bg-bg-page-selection-fill`),style:f3e({top:a.top,left:a.left,width:a.width,height:a.height},{top:window.scrollY,left:window.scrollX,width:window.innerWidth,height:window.innerHeight},2),onClick:e=>{e.preventDefault(),e.stopPropagation(),o(null),i({joinedPaths:a.joinedPaths,clientX:a.left,clientY:a.top,boundingBox:{top:a.top,left:a.left,width:a.width,height:a.height}})}}),s&&d.map((e,t)=>(0,Y.jsx)(`div`,{className:X(`absolute z-[8997] pointer-events-none`,`rounded-sm`,`border-2 border-bg-page-selection`,`transition-opacity duration-200 ease-out`,l?`opacity-70`:`opacity-0`),style:f3e({top:e.top,left:e.left,width:e.width,height:e.height},{top:window.scrollY,left:window.scrollX,width:window.innerWidth,height:window.innerHeight},2)},`${e.joinedPaths}-${t}`)),(0,Y.jsx)(n3e,{isOpen:p&&e.draftMode,onClose:()=>m(!1),onOpen:()=>m(!0)}),r===null&&(0,Y.jsx)(d3e,{...e,mode:t,setMode:n,loading:v===null,dropZone:y,setDropZone:w,findAllValPathElements:T,setAllBoundingBoxes:f,setShowAllBoundingBoxes:c,setAllBoundingBoxesVisible:u,isChatOpen:p,setIsChatOpen:m})]})})}function t3e({editMode:e,setMode:t,setEditMode:n}){let{bornSessionId:r}=(0,b.useContext)(J9),[i,a]=(0,b.useState)({x:window.innerWidth,y:window.innerHeight}),[o,s]=(0,b.useState)({width:0,height:0}),[c,l]=(0,b.useState)(window.innerWidth),u=(0,b.useRef)(null),d=c<1024,f=uC(d);fC(d&&e!==null);let[p,m]=(0,b.useState)(null);(0,b.useEffect)(()=>{window.innerWidth<1024?a({x:16,y:16}):e?setTimeout(()=>{if(u.current){let{innerWidth:t,innerHeight:n}=window,{offsetWidth:r,offsetHeight:i}=u.current,o=e.clientX,c=e.clientY;s({width:r,height:i}),o+r>t-20&&(o=t-r-20),o<20&&(o=20),c+i>n-20&&(c=n-i-20),c<20&&(c=20),a({x:o,y:c})}},100):(a({x:window.innerWidth,y:window.innerHeight}),s({width:0,height:0}))},[e]),(0,b.useEffect)(()=>{let e=()=>{l(window.innerWidth),window.innerWidth<1024?a({x:16,y:16}):u.current&&a(e=>{let{innerWidth:t,innerHeight:n}=window,{offsetWidth:r}=u.current,i=t-100,a=n-100,o=-(r-100);return{x:Math.max(o,Math.min(i,e.x)),y:Math.max(0,Math.min(a,e.y))}})};return e(),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[]);let[h,g]=(0,b.useState)(!1);(0,b.useEffect)(()=>{if(h&&!d){let e=e=>{a(t=>{if(!u.current)return t;let{innerWidth:n,innerHeight:r}=window,{offsetWidth:i}=u.current,a=t.x+e.movementX,o=t.y+e.movementY,s=n-100,c=r-100,l=-(i-100);return a=Math.max(l,Math.min(s,a)),o=Math.max(0,Math.min(c,o)),{x:a,y:o}})},t=()=>{g(!1)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}}},[h,d]),(0,b.useEffect)(()=>{if(p&&!d){let e=e=>{let{innerWidth:t,innerHeight:n}=window;(p===`se`||p===`e`)&&s(n=>{let r=Math.max(400,Math.min(t-i.x-20,n.width+e.movementX));return{...n,width:r}}),(p===`se`||p===`s`)&&s(t=>{let r=Math.max(300,Math.min(n-i.y-20,t.height+e.movementY));return{...t,height:r}})},t=()=>{m(null)};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}}},[p,d,i.x,i.y]),(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(t(`select`),n(null))};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[]);let _=()=>{t(`select`),n(null)};return(0,Y.jsxs)(`div`,{className:(0,AC.default)(`fixed top-0 left-0`,d?`z-[9001]`:`z-[8998]`,{hidden:e===null,"opacity-100 w-[200svw] h-[100svh]":e!==null&&!d,"opacity-100 w-[100vw] h-[100svh]":e!==null&&d}),children:[(0,Y.jsx)(`div`,{className:(0,AC.default)(`fixed top-0 left-0`,{hidden:e===null,"w-[100vw] h-[100svh]":e!==null}),onClick:e=>{e.preventDefault(),h||_()}}),(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex flex-col bg-bg-float text-fg-primary`,d?`fixed inset-x-0 border-0 rounded-none`:`absolute rounded-lg border border-border-float shadow-xl`),ref:u,style:d?{top:f.offsetTop,height:f.height}:{top:i.y,left:i.x,...o.width>0?{width:o.width,height:o.height}:{maxWidth:`640px`}},children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`grid grid-cols-3 items-center px-4 h-11 border-b border-border-float rounded-t-lg`,{"cursor-grab active:cursor-grabbing":!d}),onMouseDown:e=>{d||(e.preventDefault(),g(!0))},children:[(0,Y.jsx)(`div`,{className:`text-[0.8125rem] font-semibold tracking-tight text-fg-primary`,children:`Edit content`}),(0,Y.jsx)(`div`,{className:`flex justify-center`,children:!d&&(0,Y.jsx)(iy,{size:16,className:`text-fg-secondary`})}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:d&&(0,Y.jsx)(`button`,{onClick:_,className:`grid place-items-center w-7 h-7 rounded-md text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary transition-colors`,"aria-label":`Close`,children:(0,Y.jsx)(Hy,{size:18})})})]}),(0,Y.jsx)(`div`,{className:(0,AC.default)(`flex-1 overflow-y-auto`,{"p-6":!d,"p-4":d}),children:(0,Y.jsxs)(`form`,{className:`flex flex-col gap-6 w-full`,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),_()},children:[e&&(0,Y.jsx)(Y.Fragment,{children:H.splitJoinedSourcePaths(e.joinedPaths).map(t=>{let n=H.splitJoinedSourcePaths(e.joinedPaths).length>1;return(0,Y.jsx)(a3e,{path:t,showInlineStudioLink:n},t)})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pt-2 border-t border-border-secondary`,children:[e&&H.splitJoinedSourcePaths(e.joinedPaths).length===1&&(0,Y.jsxs)(`a`,{href:Y9(window.origin+`/val/~`+H.splitJoinedSourcePaths(e.joinedPaths)[0],r),className:`inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-border-primary bg-bg-secondary hover:bg-bg-secondary-hover text-fg-primary transition-colors`,children:[(0,Y.jsx)(Zv,{size:16}),(0,Y.jsx)(`span`,{children:`Open Studio`})]}),(0,Y.jsx)(`div`,{className:`flex-1`}),(0,Y.jsx)(t_,{type:`submit`,children:`Done`})]})]})}),!d&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`absolute top-0 right-0 w-1 h-full cursor-ew-resize hover:bg-bg-brand-primary/50 transition-colors`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m(`e`)}}),(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-1 cursor-ns-resize hover:bg-bg-brand-primary/50 transition-colors`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m(`s`)}}),(0,Y.jsx)(`div`,{className:`absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize group`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),m(`se`)},children:(0,Y.jsx)(`svg`,{className:`absolute bottom-0.5 right-0.5 w-3 h-3 text-fg-tertiary group-hover:text-fg-secondary transition-colors`,viewBox:`0 0 12 12`,fill:`none`,children:(0,Y.jsx)(`path`,{d:`M10 2L2 10M10 6L6 10M10 10H10.01`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]})]})]})}function n3e({isOpen:e,onClose:t,onOpen:n}){let r=(0,b.useRef)(null),{chatEditorRef:i,setOpenAIChatImpl:a}=wS();(0,b.useEffect)(()=>(a(n),()=>a(null)),[n,a]);let{bornSessionId:o,setBornSessionId:s}=(0,b.useContext)(J9),{sendMessage:c,uploadAiImage:l,isConnected:u,authError:d,newSession:f,sessions:p,currentSessionId:m,getSessions:h,setSessionName:g,loadSession:_,isLoadingSession:v,answerToolQuestions:y,cancelToolQuestion:x}=u4e(r,{initialSessionId:(0,b.useRef)(o).current,onSessionBorn:s,onSessionCleared:()=>s(null)}),S=QS(),[C,w]=(0,b.useState)({x:Math.max(20,window.innerWidth-570),y:80}),[T,E]=(0,b.useState)({width:480,height:600}),[D,O]=(0,b.useState)(window.innerWidth),[k,A]=(0,b.useState)(!1),[j,M]=(0,b.useState)(null),N=(0,b.useRef)(null),P=D<1024,F=uC(P);return fC(P&&e),(0,b.useEffect)(()=>{let e=()=>{O(window.innerWidth),window.innerWidth<1024?w({x:16,y:16}):w(e=>{let t=window.innerWidth-100,n=window.innerHeight-100;return{x:Math.max(-(T.width-100),Math.min(t,e.x)),y:Math.max(0,Math.min(n,e.y))}})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[T.width]),(0,b.useEffect)(()=>{if(k&&!P){let e=e=>{w(t=>{let n=window.innerWidth-100,r=window.innerHeight-100,i=N.current?.offsetWidth??T.width;return{x:Math.max(-(i-100),Math.min(n,t.x+e.movementX)),y:Math.max(0,Math.min(r,t.y+e.movementY))}})},t=()=>A(!1);return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}}},[k,P,T.width]),(0,b.useEffect)(()=>{if(j&&!P){let e=e=>{(j===`se`||j===`e`)&&E(t=>({...t,width:Math.max(360,Math.min(window.innerWidth-C.x-20,t.width+e.movementX))})),(j===`se`||j===`s`)&&E(t=>({...t,height:Math.max(400,Math.min(window.innerHeight-C.y-20,t.height+e.movementY))}))},t=()=>M(null);return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}}},[j,P,C.x,C.y]),(0,Y.jsx)(`div`,{className:X(`fixed top-0 left-0`,P?`z-[9001]`:`z-[8999]`),style:e?void 0:{display:`none`},children:(0,Y.jsxs)(`div`,{className:(0,AC.default)(`flex flex-col bg-bg-float text-fg-primary`,P?`fixed inset-x-0 border-0 rounded-none`:`absolute rounded-lg border border-border-float shadow-xl`),ref:N,style:P?{top:F.offsetTop,height:F.height}:{top:C.y,left:C.x,width:T.width,height:T.height},children:[(0,Y.jsxs)(`div`,{className:(0,AC.default)(`grid grid-cols-3 items-center px-4 h-11 border-b border-border-float rounded-t-lg`,{"cursor-grab active:cursor-grabbing":!P}),onMouseDown:e=>{P||(e.preventDefault(),A(!0))},children:[(0,Y.jsx)(`div`,{className:`text-[0.8125rem] font-semibold tracking-tight text-fg-primary`,children:`AI assistant`}),(0,Y.jsx)(`div`,{className:`flex justify-center`,children:!P&&(0,Y.jsx)(iy,{size:16,className:`text-fg-secondary`})}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsx)(`button`,{onClick:t,className:`p-1 rounded hover:bg-bg-secondary transition-colors`,"aria-label":`Close`,children:(0,Y.jsx)(Hy,{size:18})})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,Y.jsx)(M2e,{ref:r,chatEditorRef:i,onSendMessage:c,onUploadFile:l,onNewSession:f,isConnected:u,authError:d,mode:S,sessions:p,currentSessionId:m,onLoadSession:_,onFetchSessions:h,onSetSessionName:g,isLoadingSession:v,onAnswerToolQuestions:y,onCancelToolQuestion:x})}),!P&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`absolute top-0 right-0 w-1 h-full cursor-ew-resize hover:bg-bg-brand-primary/50 transition-colors`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),M(`e`)}}),(0,Y.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-1 cursor-ns-resize hover:bg-bg-brand-primary/50 transition-colors`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),M(`s`)}}),(0,Y.jsx)(`div`,{className:`absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize group`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),M(`se`)},children:(0,Y.jsx)(`svg`,{className:`absolute bottom-0.5 right-0.5 w-3 h-3 text-fg-tertiary group-hover:text-fg-secondary transition-colors`,viewBox:`0 0 12 12`,fill:`none`,children:(0,Y.jsx)(`path`,{d:`M10 2L2 10M10 6L6 10M10 10H10.01`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})]})]})})}var r3e=`inline-flex items-center justify-center w-8 h-8 rounded-md transition-colors disabled:text-fg-disabled disabled:pointer-events-none`,i3e=`text-fg-secondary hover:bg-bg-float-raised hover:text-fg-primary`;function a3e({path:e,showInlineStudioLink:t}){let n=Cb(e),{bornSessionId:r}=(0,b.useContext)(J9),i=Y9(window.origin+`/val/~`+e,r);return n.status===`error`?(0,Y.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,Y.jsx)(`div`,{className:`text-fg-error text-sm`,children:n.error})}):!(`data`in n)||n.data===void 0?(0,Y.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,Y.jsx)(jC,{path:e})}):t?(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 w-full`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[n.data.description&&(0,Y.jsx)(`div`,{className:`pb-2 text-sm text-fg-tertiary`,children:n.data.description}),(0,Y.jsx)(a6,{path:e,schema:n.data,autoFocus:!0})]}),(0,Y.jsx)(`a`,{href:i,className:`flex-shrink-0 p-2 rounded-md border border-border-primary bg-bg-secondary hover:bg-bg-secondary-hover text-fg-secondary hover:text-fg-primary transition-colors mt-1`,title:`Open in Studio`,"aria-label":`Open in Studio`,children:(0,Y.jsx)(Zv,{size:16})})]})}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4 w-full`,children:[n.data.description&&(0,Y.jsx)(`div`,{className:`text-sm text-fg-tertiary`,children:n.data.description}),(0,Y.jsx)(a6,{path:e,schema:n.data,autoFocus:!0})]})}function o3e({dropZone:e}){return e===`val-menu-left-top`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(wy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Left Top`})]}):e===`val-menu-left-center`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(vae,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Left Center`})]}):e===`val-menu-left-bottom`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Left Bottom`})]}):e===`val-menu-center-top`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(wy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Center Top`})]}):e===`val-menu-center-bottom`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Center Bottom`})]}):e===`val-menu-right-top`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(wy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Right Top`})]}):e===`val-menu-right-center`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Cy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Right Center`})]}):e===`val-menu-right-bottom`?(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(Sy,{className:`w-4 h-4`}),(0,Y.jsx)(`span`,{children:`Right Bottom`})]}):(console.warn(`Unknown drop zone:`,e),null)}function s3e({dropZone:e,ghost:t,draftMode:n,draftModeLoading:r,setDraftMode:i,mode:a,setMode:o,disableOverlay:s,loading:c,setDropZone:l,findAllValPathElements:u,setAllBoundingBoxes:d,setShowAllBoundingBoxes:f,setAllBoundingBoxesVisible:p,isChatOpen:m,setIsChatOpen:h}){let{bornSessionId:g}=(0,b.useContext)(J9),_=e===`val-menu-right-center`||e===`val-menu-left-center`?`vertical`:`horizontal`,v=IS(),y=eb(),x=()=>{d(u()),f(!0),p(!1),setTimeout(()=>{p(!0)},50)},S=()=>{p(!1),setTimeout(()=>{f(!1)},200)},{theme:C,setTheme:w}=Qy(),T=YS(),E=Fb()||{},D=Object.keys(E).length,O=QS(),k=bb()?.ai?.chat?.experimental?.enable===!0,A=l3e(),j=e===`val-menu-center-bottom`?`top`:e===`val-menu-center-top`?`bottom`:e===`val-menu-right-center`?`left`:e===`val-menu-left-center`?`right`:e===`val-menu-left-bottom`||e===`val-menu-right-bottom`?`top`:e===`val-menu-right-top`||e===`val-menu-left-top`?`bottom`:`top`,M=e.replace(`val-menu-`,``),N=D>0?`errors`:T.length>0?`changes`:`none`;return(0,Y.jsxs)(`div`,{className:`p-4 right-16`,children:[c&&(0,Y.jsx)(`div`,{className:Z9(e)+` p-4`,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center w-9 h-9 rounded-lg bg-bg-float border border-border-float text-fg-primary shadow-lg`,children:(0,Y.jsx)(q9,{size:16})})}),v===`login-required`&&(0,Y.jsx)(`div`,{className:Z9(e)+` p-4`,children:(0,Y.jsx)(`div`,{className:`flex items-center justify-center w-9 h-9 rounded-lg bg-bg-float border border-border-float text-fg-primary shadow-lg`,children:(0,Y.jsx)(`a`,{href:Jf(`/api/val/authorize`,{redirect_to:window.location.href}),children:(0,Y.jsx)(_y,{size:16})})})}),(0,Y.jsx)(V6,{isOpen:n&&!r&&!c&&v!==`login-required`,children:(0,Y.jsxs)($4e,{orientation:_,dock:M,ghost:t,status:N,mark:(0,Y.jsx)(c3e,{}),children:[(0,Y.jsxs)(T8,{children:[(0,Y.jsx)(E8,{className:`inline-flex`,children:(0,Y.jsx)(X9,{active:a===`select`,onClick:()=>{let e=a===`select`?null:`select`;o(e),e===`select`?x():(f(!1),p(!1))},onMouseEnter:()=>{a===`select`&&x()},onMouseLeave:()=>{a===`select`&&S()},icon:(0,Y.jsx)(Py,{size:16})})}),(0,Y.jsxs)(D8,{side:j,className:`z-50`,container:y,children:[`Click on content in the page to select and edit it`,(0,Y.jsx)(x8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(0,Y.jsxs)(T8,{children:[(0,Y.jsx)(E8,{className:`inline-flex`,children:(0,Y.jsx)(X9,{disabled:r,icon:r?(0,Y.jsx)(q9,{size:16}):(0,Y.jsx)(Gie,{size:16}),onClick:()=>i(!1)})}),(0,Y.jsxs)(D8,{side:j,className:`z-50`,container:y,children:[`Exit preview mode to see the currently published version of your content`,(0,Y.jsx)(x8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(0,Y.jsx)(Q4e,{orientation:_}),(0,Y.jsxs)(T8,{children:[(0,Y.jsx)(E8,{asChild:!0,children:(0,Y.jsx)(X9,{href:Y9(window.origin+`/val/compare`,g),icon:(0,Y.jsxs)(`div`,{className:`flex relative`,children:[(0,Y.jsx)(u3e,{patchCount:T.length,validationErrorCount:D}),(0,Y.jsx)(ty,{size:16})]})})}),(0,Y.jsxs)(D8,{side:j,className:`z-50`,container:y,children:[D>0&&(0,Y.jsxs)(`div`,{className:`text-fg-error-primary`,children:[D,` validation error`,D>1&&`s`]}),T.length>0&&D===0&&(0,Y.jsxs)(`div`,{children:[T.length,` pending change`,T.length>1&&`s`]}),`Review changes in Studio`,(0,Y.jsx)(x8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(0,Y.jsx)(V8,{compact:!0}),(0,Y.jsxs)(T8,{children:[(0,Y.jsx)(E8,{asChild:!0,children:(0,Y.jsx)(X9,{icon:A.status===`success`&&A.data?(0,Y.jsx)(ry,{size:16}):(0,Y.jsx)(Ty,{size:16}),href:Y9(window.origin+`/val/~`+(A.status===`success`&&A.data?A.data:``),g)})}),(0,Y.jsxs)(D8,{side:j,className:`z-50`,container:y,children:[`Open Val Studio to edit and manage your content`,(0,Y.jsx)(x8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(O===`http`||O===`fs`)&&k&&(0,Y.jsxs)(T8,{children:[(0,Y.jsx)(E8,{className:`inline-flex`,children:(0,Y.jsx)(X9,{active:m,onClick:()=>h(e=>!e),icon:(0,Y.jsx)(vy,{size:16})})}),(0,Y.jsxs)(D8,{side:j,className:`z-50`,container:y,children:[`Open AI Chat to ask questions and edit content with AI`,(0,Y.jsx)(x8,{className:`z-50 fill-bg-secondary-hover`})]})]}),(0,Y.jsxs)(SD,{children:[(0,Y.jsx)(hD,{className:(0,AC.default)(r3e,i3e),children:(0,Y.jsx)(Jv,{size:16})}),(0,Y.jsx)(wD,{container:y,className:`z-[9003]`,children:(0,Y.jsxs)(`div`,{className:`grid grid-cols-[1fr,auto] gap-2 items-center`,children:[(0,Y.jsx)(`span`,{children:`Position`}),(0,Y.jsxs)(nD,{value:e,onValueChange:e=>{l(e)},children:[(0,Y.jsx)(iD,{children:(0,Y.jsx)(rD,{children:(0,Y.jsx)(o3e,{dropZone:e})})}),(0,Y.jsx)(aD,{container:y,className:`z-[9004]`,children:[`val-menu-left-top`,`val-menu-left-center`,`val-menu-left-bottom`,`val-menu-center-top`,`val-menu-center-bottom`,`val-menu-right-top`,`val-menu-right-center`,`val-menu-right-bottom`].map(e=>(0,Y.jsx)(oD,{value:e,children:(0,Y.jsx)(o3e,{dropZone:e})},e))})]}),(0,Y.jsx)(`span`,{children:C===`dark`?`Light mode`:`Dark mode`}),(0,Y.jsx)(X4e,{checked:C===`dark`,onCheckedChange:e=>{w(e?`dark`:`light`)}})]})})]})]})}),(0,Y.jsx)(V6,{isOpen:!(n&&!r)&&!c&&v!==`login-required`,children:(0,Y.jsxs)($4e,{orientation:_,dock:M,ghost:t,status:N,mark:(0,Y.jsx)(c3e,{}),children:[(0,Y.jsx)(X9,{label:`Enable preview mode`,disabled:r,icon:r?(0,Y.jsx)(q9,{size:16}):(0,Y.jsx)(Qv,{size:16}),onClick:()=>{i(!0)}}),(0,Y.jsx)(X9,{label:`Studio`,icon:A.status===`success`&&A.data?(0,Y.jsx)(ry,{size:16}):(0,Y.jsx)(Ty,{size:16}),href:Y9(window.origin+`/val/~`+(A.status===`success`&&A.data?A.data:``),g)}),(0,Y.jsx)(X9,{label:`Disable Val`,icon:(0,Y.jsx)(Hy,{size:16}),onClick:()=>s()})]})})]})}function c3e(){return(0,Y.jsx)(p6,{className:`h-6`})}function l3e(){let e=wb(),t=cC(`data`in e&&e.data?Object.keys(e.data):[],`record`),[n,r]=(0,b.useState)(null);return(0,b.useEffect)(()=>{r(window.location.pathname);let e=()=>{r(window.location.pathname)};window.addEventListener(`popstate`,e);let t=e=>{e instanceof CustomEvent&&typeof e.detail==`string`&&e.detail!==n&&r(e.detail)};return window.addEventListener(`val-provider:pathname`,t),()=>{window.removeEventListener(`popstate`,e),window.removeEventListener(`val-provider:pathname`,t)}},[]),(0,b.useMemo)(()=>{if(n){for(let r of t.data||[])for(let[t,i]of Object.entries(r))if(t===n){let[n]=H.splitModuleFilePathAndModulePath(i),r=`data`in e?e.data[n]:void 0;if(r?.type===`record`&&r.router!==void 0)return{status:`success`,data:H.joinModuleFilePathAndModulePath(n,JSON.stringify(t))}}}return{status:`not-found`}},[e,t,n])}function u3e({patchCount:e,validationErrorCount:t}){let n=t>0,r=n?t:e;return r===0?null:(0,Y.jsx)(`span`,{"aria-label":`${r} ${n?`validation error`:`pending change`}${r===1?``:`s`}`,className:(0,AC.default)(`absolute -top-2 -right-2 inline-flex justify-center items-center px-1 h-4 min-w-[1rem] text-[9px] font-medium leading-none rounded-full tabular-nums`,`ring-2 ring-bg-float`,{"bg-fg-primary text-bg-float":!n,"bg-bg-error-primary text-fg-error-primary":n}),children:r>9?`9+`:r})}var X9=b.forwardRef(({icon:e,onClick:t,disabled:n,active:r,label:i,href:a,onMouseEnter:o,onMouseLeave:s,...c},l)=>{let u=(0,AC.default)(r3e,{"bg-bg-float-raised text-fg-primary":r,[i3e]:!r});return a?(0,Y.jsx)(`a`,{ref:l,href:a,className:u,onClick:t,onMouseEnter:o,onMouseLeave:s,"aria-label":i,title:i,...c,children:e}):(0,Y.jsx)(`button`,{ref:l,disabled:n,className:u,onClick:t,onMouseEnter:o,onMouseLeave:s,"aria-label":i,title:i,...c,children:e})});X9.displayName=`MenuButton`;function d3e(e){let[t,n]=(0,b.useState)(!1),{dropZone:r,setDropZone:i}=e,[a,o]=(0,b.useState)(null),s=e=>t=>{t.preventDefault(),i(e)},c=e=>t=>{t.preventDefault(),o(e)};return(0,Y.jsxs)(Y.Fragment,{children:[r&&(0,Y.jsx)(`div`,{className:(0,AC.default)(`z-[8999] cursor-grab`,Z9(r)),draggable:!0,onDragStart:()=>{n(!0)},onDragEnd:()=>{n(!1)},children:(0,Y.jsx)(s3e,{...e,dropZone:r})}),t&&r&&(0,Y.jsxs)(Y.Fragment,{children:[a&&a!==r&&(0,Y.jsx)(`div`,{className:(0,AC.default)(`z-[3]`,Z9(a)),onDrop:s(a),onDragOver:c(a),children:(0,Y.jsx)(s3e,{ghost:!0,...e,dropZone:a})}),(0,Y.jsxs)(`div`,{className:`fixed top-0 left-0 grid w-screen h-screen grid-cols-3 grid-rows-3 z-[2]`,children:[(0,Y.jsx)(Q9,{id:`val-menu-left-top`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-center-top`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-right-top`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-left-center`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(`div`,{}),(0,Y.jsx)(Q9,{id:`val-menu-right-center`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-left-bottom`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-center-bottom`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c}),(0,Y.jsx)(Q9,{id:`val-menu-right-bottom`,dropZone:r,dragOverDropZone:a,onDrop:s,onDragOver:c})]})]})]})}function Z9(e){let t=`fixed transform`;return t+=e===`val-menu-left-top`?` left-0 top-0`:e===`val-menu-left-center`?` left-0 top-1/2 -translate-y-1/2`:e===`val-menu-left-bottom`?` left-0 bottom-0`:e===`val-menu-center-top`?` left-1/2 -translate-x-1/2 top-0`:e===`val-menu-center-bottom`?` left-1/2 -translate-x-1/2 bottom-0`:e===`val-menu-right-top`?` right-0 top-0`:e===`val-menu-right-center`?` right-0 top-1/2 -translate-y-1/2`:` right-0 bottom-0`,t}var Q9=({id:e,onDrop:t,onDragOver:n})=>(0,Y.jsx)(`div`,{onDrop:t(e),onDragOver:n(e)});function f3e(e,t,n){let r=e.top-n,i=e.left-n,a=e.width+n*2,o=e.height+n*2,s=Math.max(t.top,r),c=Math.max(t.left,i),l=Math.min(t.left+t.width,i+a),u=Math.min(t.top+t.height,r+o);return{top:s,left:c,width:Math.max(0,l-c),height:Math.max(0,u-s)}}function p3e(){let e=M4e(),t=F4e(),[n,r]=(0,b.useState)(()=>{try{let e=sessionStorage.getItem(Xf);if(e===`light`||e===`dark`)return e;let t=sessionStorage.getItem(Yf),n=t?JSON.parse(t):null,r=localStorage.getItem(`val-theme-`+(n?.project||`unknown`));if(r===`light`||r===`dark`)return r;if(n?.defaultTheme===`light`||n?.defaultTheme===`dark`)return n.defaultTheme}catch{}return`dark`}),i=Hf(`/api/val`,{...e,contentHostUrl:Dr}),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=e=>{e instanceof CustomEvent?e?.detail.type===`draftMode`&&typeof e?.detail.value==`boolean`?o(e.detail.value):e.detail.type===`draftModeLoading`&&typeof e.detail.value==`boolean`?c(e.detail.value):console.error(`Val: invalid event detail (val-overlay-spa)`,e.detail):console.error(`Val: invalid event (val-overlay-spa)`,e)};return window.addEventListener(`val-overlay-spa`,e),window.dispatchEvent(new CustomEvent(`val-overlay-provider`,{detail:{type:`spa-ready`}})),()=>{window.removeEventListener(`val-overlay-spa`,e)}},[]),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(j4e,{}),(0,Y.jsxs)(D4e,{children:[(0,Y.jsx)(`style`,{children:`
|
|
383
383
|
#val-overlay-container {
|
|
384
384
|
visibility: hidden;
|
|
385
385
|
}
|
|
386
|
-
`}),(0,Y.jsx)(`link`,{rel:`stylesheet`,href:`/api/val/static${`/${
|
|
386
|
+
`}),(0,Y.jsx)(`link`,{rel:`stylesheet`,href:`/api/val/static${`/${A4e}`}${O4e}`}),(0,Y.jsx)(V9,{fallbackRender:C4e,children:(0,Y.jsx)(PS,{client:i,dispatchValEvents:a,config:e,valModules:t,theme:n,setTheme:r,children:(0,Y.jsx)(V9,{FallbackComponent:w4e,children:(0,Y.jsx)(WC,{overlay:!0,children:(0,Y.jsx)(e3e,{draftMode:a,draftModeLoading:s,setDraftMode:e=>{let t=new CustomEvent(`val-overlay-provider`,{detail:{type:`draftMode`,value:e}});window.dispatchEvent(t)},disableOverlay:()=>{location.href=`${window.location.origin}/api/val/disable?redirect_to=${encodeURIComponent(window.location.href)}`}})})})})})]})]})}var m3e=document.getElementById(H9),h3e=document.getElementById(k4e),$9=null;m3e?($9=document.createElement(`div`),x.createRoot($9).render((0,Y.jsx)(b.StrictMode,{children:(0,Y.jsx)(I4e,{})})),m3e.appendChild($9),window.dispatchEvent(new CustomEvent(`val-ui-created`))):h3e?($9=document.createElement(`div`),x.createRoot($9).render((0,Y.jsx)(b.StrictMode,{children:(0,Y.jsx)(p3e,{})})),h3e.appendChild($9),window.dispatchEvent(new CustomEvent(`val-ui-created`))):console.error(`Val: could not mount Val element. Check your configuration.`);function g3e(e){if(!$9){console.error(`Val: could not mount Val element. Check your configuration.`);return}if(!e){console.error(`Val: could not find element with id ${H9}`);return}if(e.childElementCount>0){console.error(`Val: could not append root element, mount point is not empty.`);return}e?.appendChild($9),window.dispatchEvent(new CustomEvent(`val-ui-created`))}window.addEventListener(`val-append-studio`,()=>{g3e(document.getElementById(H9))}),window.addEventListener(`val-append-overlay`,()=>{g3e(document.getElementById(k4e))});
|