@valbuild/ui 0.87.2 → 0.87.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _="/spa/index.css",A="/app",V="val-app",P="val-overlay",s=!1,t="0.87.2";exports.IS_DEV=s;exports.VAL_APP_ID=V;exports.VAL_APP_PATH=A;exports.VAL_CSS_PATH=_;exports.VAL_OVERLAY_ID=P;exports.VERSION=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _="/spa/index.css",A="/app",V="val-app",P="val-overlay",s=!1,t="0.87.3";exports.IS_DEV=s;exports.VAL_APP_ID=V;exports.VAL_APP_PATH=A;exports.VAL_CSS_PATH=_;exports.VAL_OVERLAY_ID=P;exports.VERSION=t;
@@ -1,4 +1,4 @@
1
- const _ = "/spa/index.css", s = "/app", A = "val-app", o = "val-overlay", V = !1, a = "0.87.2";
1
+ const _ = "/spa/index.css", s = "/app", A = "val-app", o = "val-overlay", V = !1, a = "0.87.3";
2
2
  export {
3
3
  V as IS_DEV,
4
4
  A as VAL_APP_ID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/ui",
3
- "version": "0.87.2",
3
+ "version": "0.87.3",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "typecheck": "tsc --noEmit",
@@ -60,8 +60,8 @@
60
60
  "@types/express": "^4.17.17",
61
61
  "@types/react": "^18.2.38",
62
62
  "@types/react-resizable": "^3.0.5",
63
- "@valbuild/core": "~0.87.2",
64
- "@valbuild/shared": "~0.87.2",
63
+ "@valbuild/core": "~0.87.3",
64
+ "@valbuild/shared": "~0.87.3",
65
65
  "autoprefixer": "^10.4.13",
66
66
  "class-variance-authority": "^0.7.0",
67
67
  "classnames": "^2.3.2",
@@ -447,7 +447,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
447
447
  `)},HN=function(){var e=parseInt(document.body.getAttribute(Zc)||"0",10);return isFinite(e)?e:0},_G=function(){g.useEffect(function(){return document.body.setAttribute(Zc,(HN()+1).toString()),function(){var e=HN()-1;e<=0?document.body.removeAttribute(Zc):document.body.setAttribute(Zc,e.toString())}},[])},TG=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;_G();var i=g.useMemo(function(){return NG(o)},[o]);return g.createElement(PG,{styles:jG(i,!t,o,n?"":"!important")})},Xb=!1;if(typeof window<"u")try{var om=Object.defineProperty({},"passive",{get:function(){return Xb=!0,!0}});window.addEventListener("test",om,om),window.removeEventListener("test",om,om)}catch{Xb=!1}var pc=Xb?{passive:!1}:!1,OG=function(e){return e.tagName==="TEXTAREA"},z2=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!OG(e)&&n[t]==="visible")},MG=function(e){return z2(e,"overflowY")},RG=function(e){return z2(e,"overflowX")},KN=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=$2(e,r);if(o){var i=B2(e,r),s=i[1],a=i[2];if(s>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},AG=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},IG=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},$2=function(e,t){return e==="v"?MG(t):RG(t)},B2=function(e,t){return e==="v"?AG(t):IG(t)},DG=function(e,t){return e==="h"&&t==="rtl"?-1:1},LG=function(e,t,n,r,o){var i=DG(e,window.getComputedStyle(t).direction),s=i*r,a=n.target,l=t.contains(a),c=!1,u=s>0,f=0,h=0;do{var p=B2(e,a),m=p[0],v=p[1],x=p[2],b=v-x-i*m;(m||b)&&$2(e,a)&&(f+=b,h+=m),a instanceof ShadowRoot?a=a.host:a=a.parentNode}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&(Math.abs(f)<1||!o)||!u&&(Math.abs(h)<1||!o))&&(c=!0),c},im=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},GN=function(e){return[e.deltaX,e.deltaY]},qN=function(e){return e&&"current"in e?e.current:e},FG=function(e,t){return e[0]===t[0]&&e[1]===t[1]},zG=function(e){return`
448
448
  .block-interactivity-`.concat(e,` {pointer-events: none;}
449
449
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
450
- `)},$G=0,mc=[];function BG(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),o=g.useState($G++)[0],i=g.useState(F2)[0],s=g.useRef(e);g.useEffect(function(){s.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=lG([e.lockRef.current],(e.shards||[]).map(qN),!0).filter(Boolean);return v.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,x){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!s.current.allowPinchZoom;var b=im(v),w=n.current,S="deltaX"in v?v.deltaX:w[0]-b[0],C="deltaY"in v?v.deltaY:w[1]-b[1],N,P=v.target,j=Math.abs(S)>Math.abs(C)?"h":"v";if("touches"in v&&j==="h"&&P.type==="range")return!1;var O=KN(j,P);if(!O)return!0;if(O?N=j:(N=j==="v"?"h":"v",O=KN(j,P)),!O)return!1;if(!r.current&&"changedTouches"in v&&(S||C)&&(r.current=N),!N)return!0;var M=r.current||N;return LG(M,x,v,M==="h"?S:C,!0)},[]),l=g.useCallback(function(v){var x=v;if(!(!mc.length||mc[mc.length-1]!==i)){var b="deltaY"in x?GN(x):im(x),w=t.current.filter(function(N){return N.name===x.type&&(N.target===x.target||x.target===N.shadowParent)&&FG(N.delta,b)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(s.current.shards||[]).map(qN).filter(Boolean).filter(function(N){return N.contains(x.target)}),C=S.length>0?a(x,S[0]):!s.current.noIsolation;C&&x.cancelable&&x.preventDefault()}}},[]),c=g.useCallback(function(v,x,b,w){var S={name:v,delta:x,target:b,should:w,shadowParent:VG(b)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(C){return C!==S})},1)},[]),u=g.useCallback(function(v){n.current=im(v),r.current=void 0},[]),f=g.useCallback(function(v){c(v.type,GN(v),v.target,a(v,e.lockRef.current))},[]),h=g.useCallback(function(v){c(v.type,im(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return mc.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,pc),document.addEventListener("touchmove",l,pc),document.addEventListener("touchstart",u,pc),function(){mc=mc.filter(function(v){return v!==i}),document.removeEventListener("wheel",l,pc),document.removeEventListener("touchmove",l,pc),document.removeEventListener("touchstart",u,pc)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(i,{styles:zG(o)}):null,p?g.createElement(TG,{gapMode:e.gapMode}):null)}function VG(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const UG=vG(L2,BG);var dp=g.forwardRef(function(e,t){return g.createElement(my,pi({},e,{ref:t,sideCar:UG}))});dp.classNames=my.classNames;var ek="Popover",[V2,kge]=So(ek,[Mi]),fp=Mi(),[WG,Ka]=V2(ek),U2=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=fp(t),l=g.useRef(null),[c,u]=g.useState(!1),[f=!1,h]=Gr({prop:r,defaultProp:o,onChange:i});return d.jsx(rp,{...a,children:d.jsx(WG,{scope:t,contentId:Ur(),triggerRef:l,open:f,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:g.useCallback(()=>u(!0),[]),onCustomAnchorRemove:g.useCallback(()=>u(!1),[]),modal:s,children:n})})};U2.displayName=ek;var W2="PopoverAnchor",HG=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ka(W2,n),i=fp(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return g.useEffect(()=>(s(),()=>a()),[s,a]),d.jsx(Ku,{...i,...r,ref:t})});HG.displayName=W2;var H2="PopoverTrigger",Bg=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ka(H2,n),i=fp(n),s=Ve(t,o.triggerRef),a=d.jsx(Oe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":J2(o.open),...r,ref:s,onClick:te(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Ku,{asChild:!0,...i,children:a})});Bg.displayName=H2;var tk="PopoverPortal",[KG,GG]=V2(tk,{forceMount:void 0}),K2=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Ka(tk,t);return d.jsx(KG,{scope:t,forceMount:n,children:d.jsx(ln,{present:n||i.open,children:d.jsx(Gu,{asChild:!0,container:o,children:r})})})};K2.displayName=tk;var ju="PopoverContent",G2=g.forwardRef((e,t)=>{const n=GG(ju,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Ka(ju,e.__scopePopover);return d.jsx(ln,{present:r||i.open,children:i.modal?d.jsx(qG,{...o,ref:t}):d.jsx(YG,{...o,ref:t})})});G2.displayName=ju;var qG=g.forwardRef((e,t)=>{const n=Ka(ju,e.__scopePopover),r=g.useRef(null),o=Ve(t,r),i=g.useRef(!1);return g.useEffect(()=>{const s=r.current;if(s)return py(s)},[]),d.jsx(dp,{as:ds,allowPinchZoom:!0,children:d.jsx(q2,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:te(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:te(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),YG=g.forwardRef((e,t)=>{const n=Ka(ju,e.__scopePopover),r=g.useRef(!1),o=g.useRef(!1);return d.jsx(q2,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),q2=g.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=e,h=Ka(ju,n),p=fp(n);return hy(),d.jsx(up,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:d.jsx(Ql,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:d.jsx(op,{"data-state":J2(h.open),role:"dialog",id:h.contentId,...p,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Y2="PopoverClose",Fl=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ka(Y2,n);return d.jsx(Oe.button,{type:"button",...r,ref:t,onClick:te(e.onClick,()=>o.onOpenChange(!1))})});Fl.displayName=Y2;var JG="PopoverArrow",XG=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=fp(n);return d.jsx(ip,{...o,...r,ref:t})});XG.displayName=JG;function J2(e){return e?"open":"closed"}var ZG=U2,QG=Bg,eq=K2,X2=G2;const br=ZG,xo=QG,tr=g.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>d.jsx(eq,{container:r.container,children:d.jsx(X2,{ref:o,align:t,sideOffset:n,className:ue("z-50 w-72 rounded-md border bg-bg-secondary p-4 text-fg-secondary shadow-md outline-none 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})}));tr.displayName=X2.displayName;function YN({profile:e,size:t="md"}){var c,u,f;const[n,r]=g.useState(((c=e==null?void 0:e.avatar)==null?void 0:c.url)||null);g.useEffect(()=>{var h,p;(h=e==null?void 0:e.avatar)!=null&&h.url?r((p=e==null?void 0:e.avatar)==null?void 0:p.url):r(null)},[(u=e==null?void 0:e.avatar)==null?void 0:u.url]);const[o,...i]=((f=e.fullName)==null?void 0:f.split(" "))||[""],s=i[i.length-1]||"",a=`${o[0].toUpperCase()}${s[0].toUpperCase()}`,l=Ne("rounded-full text-center inline-block bg-bg-brand-primary text-fg-brand-primary",{"h-8 w-8 leading-8 text-xs":t==="sm","h-10 w-10 leading-10 text-base":t==="md","h-12 w-12 leading-[3rem] text-lg":t==="lg"});return n?d.jsx("img",{src:n,alt:a,className:l,onError:()=>{r(null)}}):d.jsx("span",{className:l,children:a})}function tq(e,t,n,r){if(t[n]===void 0)return console.error(`Get keysOf source not found for ${n}`),[];if(!e[n])return console.error(`Schema not found for ${n}`),[];const s=n,a=[],l=(c,u,f)=>{var h;if(u===void 0){console.error(`Schema not found for ${c}`);return}if(u.type==="keyOf")u.path===s&&(r?typeof f=="string"&&f===r&&(a.includes(c)?console.error(`Duplicate keyOf reference found for ${c} in ${n}`):a.push(c)):a.includes(c)?console.error(`Duplicate keyOf reference found for ${c} in ${n}`):a.push(c));else if(u.type==="object"||u.type==="record"){if(XN(f)||Z2(f))for(const p in f){const m=f==null?void 0:f[p],v=u.type==="object"?(h=u.items)==null?void 0:h[p]:u.item;m&&l(JN(c,p),v,m)}}else if(u.type==="array"){if(nq(f)){let p=0;for(const m of f)l(JN(c,p),u.item,m),p++}}else if(u.type==="union"){const p=u.key;if(typeof p=="string"&&XN(f)){const m=f[p];if(typeof m=="string"){const v=u.items.filter(x=>x.type==="object").find(x=>{const b=x.items[p];if((b==null?void 0:b.type)==="literal")return b.value===m});v&&l(c,v,f)}}}else u.type==="string"||u.type==="number"||u.type==="boolean"||u.type==="literal"||u.type==="date"||u.type==="image"||u.type==="file"||u.type==="richtext"||console.error("Could not get keyOf references. Unhandled schema type",u)};for(const c in e){const u=c;l(c,e[u],t[u])}return a}function JN(e,t){return e.includes(Ca)?`${e}.${JSON.stringify(t)}`:`${e}${Ca}${JSON.stringify(t)}`}function XN(e){return Z2(e)}function Z2(e){return typeof e=="object"&&!!e&&!oa(e)}function nq(e){return typeof e=="object"&&!!e&&oa(e)}function Q2(e,t){const n=Ha(),r=uy(),o=US();return g.useMemo(()=>e!==void 0&&"data"in n&&n.data!==void 0&&n.data[e]!==void 0?tq(n.data,o,e,t):[],[r,o,"data"in n&&n.data,e,t])}const ZN=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,QN=HR,rq=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return QN(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(c=>{const u=n==null?void 0:n[c],f=i==null?void 0:i[c];if(u===null)return null;const h=ZN(u)||ZN(f);return o[c][h]}),a=n&&Object.entries(n).reduce((c,u)=>{let[f,h]=u;return h===void 0||(c[f]=h),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:f,className:h,...p}=u;return Object.entries(p).every(m=>{let[v,x]=m;return Array.isArray(x)?x.includes({...i,...a}[v]):{...i,...a}[v]===x})?[...c,f,h]:c},[]);return QN(e,s,l,n==null?void 0:n.class,n==null?void 0:n.className)},Zb=rq("inline-flex items-center justify-center whitespace-nowrap rounded-md text-fg-primary text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:text-fg-disabled disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:ue("cursor-pointer","border border-border-brand-primary","bg-bg-brand-primary text-fg-brand-primary","hover:bg-bg-brand-primary-hover hover:text-fg-brand-primary-hover","disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary"),destructive:ue("cursor-pointer","border border-bg-error-primary","bg-bg-error-primary text-fg-error-primary hover:bg-bg-error-primary-hover disabled:text-fg-error-primary"),outline:ue("cursor-pointer","border border-transparent","bg-bg-background hover:bg-bg-secondary","disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary"),secondary:ue("cursor-pointer","border border-border-secondary","bg-bg-secondary text-fg-secondary hover:bg-bg-secondary-hover"),ghost:ue("cursor-pointer","border border-transparent","bg-bg-background hover:bg-bg-secondary","disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary","hover:bg-bg-secondary-hover hover:text-fg-secondary"),link:ue("cursor-pointer","border border-transparent","text-fg-primary underline-offset-4 hover:underline")},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ge=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const s=r?ds:"button";return d.jsx(s,{className:ue(Zb({variant:t,size:n,className:e})),ref:i,...o})});Ge.displayName="Button";function oq({path:e,disabled:t}){const[n,r]=Y.splitModuleFilePathAndModulePath(e),o=Y.splitModuleFilePath(n),i=Y.splitModulePath(r),{navigate:s}=xn();return d.jsxs("div",{className:"w-full",children:[d.jsx("button",{type:"button",title:n,disabled:t,className:"inline-block text-left truncate",onClick:()=>{s(n)},children:o.map((a,l)=>d.jsxs(g.Fragment,{children:[l===0&&d.jsx("span",{className:"text-muted",children:"/"}),d.jsx("span",{className:Ne({"text-muted":!(i.length===0&&l===o.length-1)}),children:Nu(a)}),l>0&&l<o.length-1&&d.jsx("span",{className:"text-muted",children:"/"})]},`${a}-${l}`))}),d.jsx("button",{type:"button",disabled:t,title:Y.joinModuleFilePathAndModulePath(n,r),className:"inline-block text-left truncate",onClick:()=>{s(Y.joinModuleFilePathAndModulePath(n,r))},children:i.map((a,l)=>d.jsxs(g.Fragment,{children:[d.jsx("span",{className:"text-muted",children:"/"}),d.jsx("span",{className:Ne({"text-muted":l===i.length-2}),children:Nu(a)})]},`${a}-${l}`))})]})}function eA({path:e,parentPath:t,variant:n,refs:r,children:o,size:i,onComplete:s,confirmationMessage:a,className:l}){const c=bn();return d.jsxs(br,{children:[d.jsx(xo,{asChild:!0,children:d.jsx(Ge,{size:i,variant:n,className:l,children:o})}),d.jsxs(tr,{container:c,className:"flex flex-col gap-2 p-4",children:[d.jsx("div",{className:"text-lg font-bold",children:"Are you sure?"}),d.jsx("div",{children:a}),d.jsx(Fl,{asChild:!0,children:d.jsx(iq,{path:e,parentPath:t,refs:r,variant:"destructive",onComplete:s,children:d.jsxs("div",{className:"flex gap-2 items-center",children:[d.jsx(qS,{size:12}),d.jsx("span",{children:"Delete"})]})})})]})]})}function iq({path:e,parentPath:t,variant:n,refs:r,children:o,size:i,onComplete:s}){const{navigate:a}=xn(),{addPatch:l,patchPath:c}=wn(e),u=lt(t,"record");return!("data"in u)||u.data===void 0||u.data===null?(console.error("Parent source not found",u,{path:e}),null):d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(Ge,{size:i,variant:n,disabled:r.length>0,onClick:()=>{l([{op:"remove",path:c}],"record"),a(t),s&&s()},children:o})}),d.jsx(fr,{side:"top",children:r.length>0?d.jsxs("div",{children:[d.jsx("p",{children:"Cannot delete record."}),d.jsxs("p",{children:["You must change the following references"," ",d.jsx(v2,{size:10,className:"inline"})," to be able to delete:"]}),d.jsx("ul",{children:r.map(f=>d.jsx("li",{children:d.jsx(oq,{path:f})},f))})]}):d.jsx("p",{children:"Delete record"})})]})}function zl(e){if(e.type==="object")return Object.fromEntries(Object.keys(e.items).map(n=>[n,zl(e.items[n])]));if(e.type==="array")return[];if(e.type==="record")return{};if(e.opt)return null;if(e.type==="richtext")return[];if(e.type==="string")return"";if(e.type==="boolean")return!1;if(e.type==="number")return 0;if(e.type==="keyOf")return e.values==="string"?"":e.values[0];if(e.type==="file"||e.type==="image")return null;if(e.type==="literal")return e.value;if(e.type==="union")return typeof e.key=="string"?zl(e.items[0]):e.key.value;if(e.type==="date")return ys(new Date,"yyyy-MM-dd");throw Error("Unexpected schema type: "+JSON.stringify(e))}const ed=g.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:ue("flex h-10 m-1 w-[calc(100%-8px)] rounded-md border border-input bg-bg-primary px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));ed.displayName="Input";function sq(e,t){const n={},r=t==null?void 0:t.split("/");(r==null?void 0:r[0])===""&&r.shift();const o=(r==null?void 0:r.filter(s=>s!==""))||[];let i=0;for(let s=0;s<e.length;s++){const a=e[s];if(a.type==="literal"){const l=o[i];if(!l)return{status:"error",message:`Missing required literal part: ${a.name}`};if(a.name!==l)return{status:"error",message:`Invalid path part: expected "${a.name}", got "${l}"`};i++}else if(a.type==="string-param"){const l=o[i];if(!l){if(a.optional)continue;return{status:"error",message:`Missing required parameter: ${a.paramName}`}}n[a.paramName]=l,i++}else if(a.type==="array-param"){const l=o.slice(i);if(l.length===0){if(a.optional)continue;return{status:"error",message:`Missing required catch-all parameter: ${a.paramName}`}}n[a.paramName]=l,i+=l.length}}return i<o.length?{status:"error",message:`Extra path parts found: ${o.slice(i).join("/")}`}:{status:"success",params:n}}function tA({routePattern:e,existingKeys:t,onSubmit:n,submitText:r,defaultParams:o,onCancel:i,defaultValue:s}){const[a,l]=g.useState({});g.useEffect(()=>{o&&l(o)},[o]);const[c,u]=g.useState({});g.useEffect(()=>{if(s){const m=sq(e,s);m.status==="success"&&l(m.params)}},[s,e]);const f=g.useMemo(()=>"/"+e.map(m=>{if(m.type==="string-param"||m.type==="array-param"){const v=a[m.paramName];return Array.isArray(v)?v.join("/"):v}return m.name}).join("/"),[e,a]),p=!g.useMemo(()=>e.every(m=>m.type==="string-param"||m.type==="array-param"?!!a[m.paramName]&&!c[m.paramName]:!0),[e,a,c])||f in t;return d.jsxs("form",{className:"p-4 space-y-3",onSubmit:m=>{m.preventDefault(),n(f)},children:[d.jsx("div",{className:"flex items-center",children:e.map((m,v)=>d.jsx("span",{className:"truncate",children:m.type==="string-param"||m.type==="array-param"?d.jsxs("span",{className:"flex items-center",children:[d.jsx("span",{children:"/"}),d.jsxs("span",{className:"flex flex-col",children:[d.jsx("input",{className:ue("p-1 bg-transparent border-0 max-w-[10ch]",{"border-border-secondary border-1":c[m.paramName]}),placeholder:m.paramName,value:aq(a,m.paramName),onChange:x=>{l({...a,[m.paramName]:x.target.value});const b=m.type==="string-param"?x.target.value:x.target.value.replace(/\//g,"");encodeURIComponent(b)!==b?u({...c,[m.paramName]:"Invalid characters"}):u({...c,[m.paramName]:void 0})}}),c[m.paramName]&&d.jsx("span",{className:"text-xs text-fg-error-secondary",children:c[m.paramName]})]})]}):d.jsxs("span",{className:"text-fg-secondary",children:["/",m.name]})},v))}),d.jsxs("div",{className:"flex gap-4",children:[d.jsx(Ge,{disabled:p,children:r}),d.jsx(Ge,{variant:"ghost",type:"reset",onClick:i,children:"Cancel"})]})]})}function aq(e,t){const n=e[t];return Array.isArray(n)?n.join("/"):n||""}function nA({path:e,size:t,variant:n,children:r,open:o,setOpen:i,defaultOpen:s,routePattern:a}){const l=lt(e,"record"),c=Ft(e),u=bn(),{addPatch:f}=wn(e),{navigate:h}=xn(),[p,m]=g.useState(s??!1);g.useEffect(()=>{o!==void 0&&m(o)},[o]),g.useEffect(()=>{i!==void 0&&i(p)},[p,i]),g.useEffect(()=>{s!==void 0&&m(s)},[s]);const v=g.useCallback(S=>{const C="data"in c?c.data:null;if(C===null||C.type!=="record")return;const N=Y.createPatchPath(w).concat(S);f([{op:"add",path:N,value:zl(C.item)}],"record"),h(Y.joinModuleFilePathAndModulePath(b,Y.patchPathToModulePath(N))),m(!1)},[f,h,c,e]);if(!("data"in l)||l.data===void 0||l.data===null)return console.error("Source not found",l,{path:e}),null;if(!("data"in c)||c.data===void 0)return console.error("Schema not found",l,{path:e}),null;if(c.data.type!=="record")return console.error("Schema is not a record",c,{path:e}),null;const[b,w]=Y.splitModuleFilePathAndModulePath(e);return d.jsxs(br,{open:p,onOpenChange:m,children:[d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(xo,{onClick:()=>{m(!0)},asChild:!0,children:d.jsx(Ge,{size:t,variant:n,children:r})})}),d.jsx(fr,{children:d.jsx("p",{children:"Add"})})]}),d.jsx(tr,{container:u,children:a?d.jsx(tA,{routePattern:a,existingKeys:Object.keys(l.data),onSubmit:v,onCancel:()=>{m(!1)},submitText:"Create"}):d.jsx(lq,{existingKeys:Object.keys(l.data),onSubmit:v})})]})}function lq({existingKeys:e,onSubmit:t}){const[n,r]=g.useState(""),o=n===""||n in e;return d.jsxs("form",{className:"flex flex-col gap-2",onSubmit:i=>{i.preventDefault(),t(n)},children:[d.jsx(ed,{autoFocus:!0,value:n,onChange:i=>{r(i.target.value)}}),d.jsx("div",{children:d.jsx(Ge,{type:"submit",disabled:o,variant:"outline",children:"Add"})})]})}function cq({existingKeys:e,defaultValue:t,onCancel:n,onSubmit:r}){const[o,i]=g.useState(t),s=o===t||o===""||o in e;return d.jsxs("form",{className:"flex flex-col gap-2",onSubmit:a=>{a.preventDefault(),r(o)},children:[d.jsx(ed,{type:"text",value:o,onChange:a=>{i(a.target.value)}}),d.jsxs("div",{className:"flex gap-2 items-center",children:[d.jsx(Ge,{disabled:s,variant:"outline",type:"submit",children:"Update"}),d.jsx(Ge,{variant:"ghost",type:"reset",onClick:()=>{n(),i(t)},children:"Cancel"})]})]})}function rA({defaultValue:e,path:t,parentPath:n,variant:r,existingKeys:o,routePattern:i,size:s,children:a,onComplete:l}){const{navigate:c}=xn(),[u,f]=g.useState(!1),h=bn();g.useEffect(()=>{const S=C=>{C.key==="Escape"&&f(!1)};return window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}},[]);const{addPatch:p,addModuleFilePatch:m}=wn(t),[v,x]=Y.splitModuleFilePathAndModulePath(n),b=Y.createPatchPath(x),w=g.useCallback(S=>{const C=[{op:"move",from:b.concat(e),path:b.concat(S)}];p(C,"record");for(const P of o){const[j,O]=Y.splitModuleFilePathAndModulePath(P),M=Y.createPatchPath(O);m(j,[{op:"replace",path:M,value:S}],"record")}const N=Y.joinModuleFilePathAndModulePath(v,Y.patchPathToModulePath(b.concat(S)));c(N,{replace:!0}),l&&l()},[p,m,v,b,c,l]);return d.jsxs(br,{open:u,children:[d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(Ge,{asChild:!0,size:s,variant:r,children:d.jsx(xo,{onClick:()=>{f(!0)},children:a})})}),d.jsx(fr,{side:"top",children:"Rename record"})]}),d.jsx(tr,{container:h,className:"text-fg-primary",children:i?d.jsx(tA,{routePattern:i,existingKeys:o,defaultValue:e,onSubmit:S=>{w(S),f(!1)},onCancel:()=>{f(!1)},submitText:"Update"}):d.jsx(cq,{parentPath:n,defaultValue:e,existingKeys:o,onSubmit:S=>{w(S),f(!1)},onCancel:()=>{f(!1)}})})]})}function uq({moduleFilePaths:e}){const t=o2(e,"record"),n=i2(),r=g.useMemo(()=>{const o=[];if(n.status!=="success")return n;if(n.data===null)return{status:"error",error:"No src folder found"};if(t.status!=="success")return t.status==="not-found"?{status:"error",error:"No data found"}:t.status==="error"?{status:"error",error:`Failed to load ${Object.keys(t.errors).length} modules: ${Object.entries(t.errors).map(([a,l])=>`"${a}": ${l.message}`).join(", ")}`}:t;for(const s of t.data||[])for(const a in s){const[l]=Y.splitModuleFilePathAndModulePath(s[a]);o.push({urlPath:a,moduleFilePath:l})}const i=U8(n.data,o);return{status:t.status,data:i}},[t,n]);return r.status==="loading"||r.status==="not-asked"?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(qr,{size:16,className:"animate-spin"})}):r.status==="error"?(console.error("Sitemap errors",r.error),null):d.jsx(oA,{node:r.data})}function oA({node:e}){var m;const t=bn(),{currentSourcePath:n}=xn(),[r,o]=g.useState(!0),{navigate:i}=xn(),[s,a]=g.useState(!1),[l,c]=g.useState(!1),u=g.useMemo(()=>e.sourcePath===n,[n,e.sourcePath]),f=g.useMemo(()=>{if(!e.pattern)return;const v=HM(e.pattern);if(v.some(x=>x.type==="string-param"||x.type==="array-param"))return v},[e.pattern]),h=g.useCallback(()=>{var v;e.sourcePath?i(e.sourcePath):e.type==="node"&&((v=e.children)==null?void 0:v.length)>0&&o(x=>!x)},[i,e]),p=e.moduleFilePath;return d.jsxs("div",{children:[d.jsxs("div",{className:"relative flex items-center justify-between w-full h-10 group",children:[d.jsxs("div",{className:"flex items-center my-1",children:[d.jsx("button",{onClick:()=>o(!r),className:ue("hidden h-4 w-4 mr-2",{block:((m=e.children)==null?void 0:m.length)>0}),children:d.jsx(Qu,{size:16,className:ue("transform",{"rotate-90":r})})}),d.jsx("span",{children:e.sourcePath?d.jsxs("button",{onClick:h,className:ue("flex items-center gap-1",{}),children:[e.type==="leaf"||e.type==="node"&&e.page?d.jsx(f2,{size:14}):null,d.jsxs("span",{className:ue({underline:u}),children:["/",e.name!=="/"&&e.name]})]}):d.jsxs("button",{onClick:h,className:ue("flex items-center gap-1",{}),children:[d.jsx(fK,{size:14}),d.jsx("span",{children:d.jsxs("span",{children:["/",e.name!=="/"&&e.name]})})]})})]}),d.jsxs("div",{className:ue("absolute right-0 top-0 items-center group-hover:flex h-10 bg-bg-primary",{hidden:!s&&!l,flex:s||l}),children:[e.sourcePath&&d.jsx(Ge,{size:"sm",variant:"ghost",onClick:h,className:"flex items-center gap-2",children:d.jsx(KS,{size:12})}),(e.sourcePath||e.type==="leaf"||e.page)&&d.jsxs(br,{onOpenChange:a,open:s,children:[d.jsx(xo,{asChild:!0,children:d.jsx(Ge,{size:"sm",variant:"ghost",children:d.jsx(HS,{size:12})})}),d.jsx(tr,{container:t,children:d.jsx(dq,{node:e,routePatternWithParams:f,onClose:()=>a(!1)})})]}),f&&p&&d.jsx(nA,{path:p,size:"sm",variant:"ghost",open:l,setOpen:c,routePattern:f,children:d.jsx(GS,{size:12})})]})]}),d.jsx(Cu,{isOpen:r,className:"pl-3",children:e.children.map((v,x)=>d.jsx(oA,{node:v},x))})]})}function dq({node:e,onClose:t,routePatternWithParams:n}){const r=g.useMemo(()=>{var s;return e.type==="leaf"?e.fullPath:(s=e.page)==null?void 0:s.fullPath},[e]),o=g.useMemo(()=>e.sourcePath?Y.splitModuleFilePathAndModulePath(e.sourcePath)[0]:void 0,[e==null?void 0:e.sourcePath]),i=Q2(o,r);return d.jsxs("div",{className:"flex flex-col items-start justify-center gap-2",children:[o&&e.sourcePath&&d.jsx(eA,{path:e.sourcePath,parentPath:o,refs:i,size:"sm",variant:"ghost",onComplete:t,confirmationMessage:`This will delete the ${r} page.`,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(qS,{size:14}),d.jsx("span",{children:"Delete"})]})}),r!==void 0&&e.sourcePath&&o&&d.jsx(rA,{variant:"ghost",size:"sm",existingKeys:i,path:e.sourcePath,defaultValue:r,routePattern:n,parentPath:o,onComplete:t,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(CK,{size:12}),d.jsx("span",{children:"Rename"})]})})]})}function fq(e){const t={"/":{name:"/",fullPath:"/",isDirectory:!0,children:[]}};for(const n of e){const r=n.split("/");if(r[0]!=="")throw new Error("Expected path to start with '/'");for(let o=1;o<r.length;o++){const i=r.slice(0,o).join("/"),s=[i,r[o]].join("/"),a=r[o];if(!a)throw new Error("Expected name to be non-empty");if(!t[s]){const l={name:a,fullPath:s,children:[]};o<r.length-1&&(l.isDirectory=!0),t[s]=l,t[i||"/"].children.push(t[s])}}}return t["/"]}function hq(){const e=Ha();return g.useMemo(()=>{if(e.status==="success"){const t=[],n={};for(const r in e.data){const o=r,i=e.data[o];i.type==="record"&&i.router?(n[i.router]=n[i.router]||[],n[i.router].push(o)):t.push(o)}return{status:e.status,data:{root:fq(t),sitemap:n}}}return e},[e])}const iA=1280;function pq(){const e=Yu(),[t,n]=g.useState(""),[r,o]=g.useState("");g.useEffect(()=>{async function w(){let S=!1;const C=async N=>{if(!S)try{(await fetch(N)).ok&&(S=!0,n(N))}catch{}};await C("/favicon.ico"),await C("/favicon.svg"),await C("/favicon.png"),await C("/apple-touch-icon.png"),await C("https://valbuild.com/favicon.ico")}if(w(),e!=null&&e.project)o(e.project);else try{let S=new URL(location.origin).hostname;if(S!=="localhost"){const C=S.split(".");C.length>=2&&(S=C.slice(1,-1).join(".")),o(kf(S))}else o("Dev mode")}catch{o("Studio")}},[JSON.stringify(e)]);const i=Ha(),s=bn(),{theme:a,setTheme:l}=cy(),{navMenu:c}=Qy(),u=hq(),f=(e==null?void 0:e.appHost)||Tb,[h,p]=r.split("/"),m=q7(),v=`${f}/manage-members/${h}`,b=`${`${f}/~/${h}`}/${p}`;return d.jsxs("nav",{className:"relative min-h-[100svh] bg-bg-primary",children:[d.jsxs("div",{className:"flex gap-4 justify-between items-center p-4 pr-6 h-16 border-b border-border-primary",children:[d.jsxs("div",{className:"flex gap-4 items-center",children:[t?d.jsx("img",{src:t,alt:"",className:"w-4 h-4"}):d.jsx("div",{className:"w-4 h-4"}),h&&p?d.jsx("a",{className:"truncate hover:underline",href:b,children:r}):d.jsx("span",{className:"truncate",children:r})]}),d.jsx("button",{className:"lg:hidden",onClick:()=>{c.setOpen(!c.isOpen)},children:d.jsx(Dg,{size:16,className:Ne("transform",{"rotate-180":!c.isOpen})})})]}),"data"in i&&d.jsx("div",{className:Ne("py-4 pl-2",{}),children:d.jsxs(hr,{children:[d.jsx("div",{className:"max-h-[calc(100svh-32px-64px-32px-16px)] max-w-[320px] px-2",children:"data"in u?d.jsxs(d.Fragment,{children:[d.jsx(gq,{title:"Site map",defaultOpen:!0,sitemap:u.data.sitemap}),d.jsx(mq,{title:"Explorer",defaultOpen:!0,node:u.data.root})]}):u.status==="loading"?d.jsx(vq,{}):null}),d.jsx(QS,{orientation:"horizontal"})]})}),d.jsx("div",{className:"p-4 h-6"}),d.jsx("div",{className:"absolute bottom-0 left-0 w-full",children:d.jsxs(br,{children:[d.jsxs(xo,{className:"flex items-center justify-between w-full p-4 border-t border-border-primary hover:bg-bg-secondary data-[state=open]:bg-bg-secondary",children:[d.jsx("span",{children:m&&d.jsx(YN,{size:"sm",profile:m})}),d.jsx(HS,{size:16})]}),d.jsx(tr,{className:"p-0 py-2",container:s,side:"top",children:d.jsxs("div",{className:"flex flex-col gap-2 justify-between items-center",children:[m&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex gap-2 items-center px-4 py-2 w-full",children:[d.jsx(YN,{size:"sm",profile:m}),d.jsxs("div",{className:"text-sm",children:[d.jsx("div",{className:"truncate",children:m.fullName}),m.email&&d.jsx("div",{className:"font-light truncate",children:m.email})]})]}),d.jsx("hr",{className:"mb-1 w-full h-1 border-t border-border-primary"})]}),d.jsxs("div",{className:"flex gap-2 items-center px-4 w-full",children:[a==="dark"?d.jsx(SK,{size:"1rem"}):d.jsx(OK,{size:"1rem"}),d.jsx("button",{className:"",onClick:()=>{l(a==="dark"?"light":"dark")},children:a==="dark"?d.jsx("span",{className:"text-sm",children:"Dark mode"}):d.jsx("span",{className:"text-sm",children:"Light mode"})})]}),m&&d.jsxs("div",{className:"flex gap-2 items-center px-4 w-full",children:[d.jsx(LK,{size:"1rem"}),d.jsx("a",{href:v,children:d.jsx("span",{className:"text-sm truncate",children:"Manage members"})})]}),m&&d.jsxs(d.Fragment,{children:[d.jsx("hr",{className:"mt-1 mb-1 w-full h-1 border-t border-border-primary"}),d.jsxs("div",{className:"flex gap-2 items-center px-4 w-full",children:[d.jsx(bK,{size:"1rem"}),d.jsx("a",{href:yu("/api/val/logout",{redirect_to:`${window.location.origin}`}),children:d.jsx("span",{className:"text-sm",children:"Log out"})})]})]})]})})]})})]})}function mq({title:e,defaultOpen:t,node:n}){return!n||(n==null?void 0:n.children.length)===0?null:d.jsx(sA,{icon:d.jsx(Lg,{size:16}),title:e,defaultOpen:t,children:n.children.sort(aA).map((r,o)=>g.createElement(lA,{...r,name:r.name,key:o,root:!0}))})}function sA({title:e,children:t,defaultOpen:n,icon:r}){const[o,i]=g.useState(n??!0);return d.jsxs("div",{className:"py-2",children:[d.jsxs("button",{className:"flex justify-between items-center py-2 w-full text-sm tracking-tighter uppercase text-fg-secondary",onClick:()=>{i(!o)},children:[d.jsxs("div",{className:"flex gap-2 items-center",children:[r,e]}),d.jsx(Qu,{size:16,className:Ne("transform",{"rotate-90":o})})]}),d.jsx(Cu,{isOpen:o,className:"pr-1",children:t})]})}function gq({title:e,defaultOpen:t,sitemap:n}){const r=n["next-app-router"];return r?d.jsx(sA,{title:e,defaultOpen:t,icon:d.jsx(Ig,{size:16}),children:d.jsx(uq,{moduleFilePaths:r})}):null}function vq(){return d.jsx("div",{className:"flex justify-start items-center w-full h-full",children:d.jsx(qr,{size:16,className:"animate-spin"})})}function aA(e,t){return e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)}function lA({name:e,fullPath:t,isDirectory:n,children:r,root:o}){const{navigate:i,currentSourcePath:s}=xn(),{navMenu:a}=Qy(),[l,c]=g.useState(!0),u=tc()||{},f=g.useMemo(()=>{let x=!1;for(const b in u)if(b.startsWith(t)){x=!0;break}return x},[u,t]),h=g.useMemo(()=>{if(n){if(!l)return f}else if(!n)return f;return!1},[f,l,n]),p=t,m=Ft(p),v="data"in m?m.data.type:"loading";return d.jsxs("div",{className:"w-full text-sm",children:[d.jsxs("button",{className:Ne("relative flex items-center justify-between w-full ",{"py-2":o,"p-2":!o,underline:s.startsWith(p)&&!n,"font-bold":s.startsWith(p)&&n}),onClick:()=>{n?c(!l):(window.innerWidth<iA&&a.setOpen(!1),i(p))},children:[d.jsxs("div",{className:"flex items-center pr-2",children:[n?d.jsx(Qu,{size:16,className:Ne("transform mr-2",{"rotate-90":l,hidden:!r.length})}):d.jsx(yq,{type:v,size:14}),d.jsx("span",{children:Nu(e)})]}),h&&d.jsx("div",{className:"ml-2 w-2 h-2 rounded-full bg-bg-error-secondary"})]}),d.jsx("div",{className:"pl-2",children:d.jsx(Cu,{isOpen:l,children:r.sort(aA).map((x,b)=>g.createElement(lA,{...x,key:b}))})})]})}function yq({size:e,type:t}){if(t==="loading")return d.jsx(qr,{size:e,className:"mr-2 animate-spin"});switch(t){case"string":return d.jsx(IK,{size:e,className:"mr-2"});case"number":return d.jsx(pK,{size:e,className:"mr-2"});case"boolean":return d.jsx(RK,{size:e,className:"mr-2"});case"object":return d.jsx(vK,{size:e,className:"mr-2"});case"literal":return d.jsx(aK,{size:e,className:"mr-2"});case"array":return d.jsx(m2,{size:e,className:"mr-2"});case"union":return d.jsx(NK,{size:e,className:"mr-2"});case"richtext":return d.jsx(f2,{size:e,className:"mr-2"});case"record":return d.jsx(MK,{size:e,className:"mr-2"});case"keyOf":return d.jsx(gK,{size:e,className:"mr-2"});case"file":return d.jsx(h2,{size:e,className:"mr-2"});case"date":return d.jsx(u2,{size:e,className:"mr-2"});case"image":return d.jsx(p2,{size:e,className:"mr-2"});default:return d.jsx(iK,{size:e,className:"mr-2"})}}function nk(e){const t=g.useRef({value:e,previous:e});return g.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var rk="Checkbox",[xq,Ege]=So(rk),[bq,wq]=xq(rk),cA=g.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=g.useState(null),m=Ve(t,C=>p(C)),v=g.useRef(!1),x=h?u||!!h.closest("form"):!0,[b=!1,w]=Gr({prop:o,defaultProp:i,onChange:c}),S=g.useRef(b);return g.useEffect(()=>{const C=h==null?void 0:h.form;if(C){const N=()=>w(S.current);return C.addEventListener("reset",N),()=>C.removeEventListener("reset",N)}},[h,w]),d.jsxs(bq,{scope:n,state:b,disabled:a,children:[d.jsx(Oe.button,{type:"button",role:"checkbox","aria-checked":ga(b)?"mixed":b,"aria-required":s,"data-state":fA(b),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onKeyDown:te(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:te(e.onClick,C=>{w(N=>ga(N)?!0:!N),x&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})}),x&&d.jsx(Sq,{control:h,bubbles:!v.current,name:r,value:l,checked:b,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:ga(i)?!1:i})]})});cA.displayName=rk;var uA="CheckboxIndicator",dA=g.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=wq(uA,n);return d.jsx(ln,{present:r||ga(i.state)||i.state===!0,children:d.jsx(Oe.span,{"data-state":fA(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});dA.displayName=uA;var Sq=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=g.useRef(null),a=nk(n),l=_S(t);g.useEffect(()=>{const u=s.current,f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(a!==n&&p){const m=new Event("click",{bubbles:r});u.indeterminate=ga(n),p.call(u,ga(n)?!1:n),u.dispatchEvent(m)}},[a,n,r]);const c=g.useRef(ga(n)?!1:n);return d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function ga(e){return e==="indeterminate"}function fA(e){return ga(e)?"indeterminate":e?"checked":"unchecked"}var hA=cA,kq=dA;const td=g.forwardRef(({className:e,...t},n)=>{const[r,o]=g.useState();return g.useEffect(()=>{o(t.checked)},[t.checked]),d.jsx(hA,{ref:n,checked:r,onCheckedChange:i=>{o(i),t.onCheckedChange&&t.onCheckedChange(i)},className:ue("peer h-4 w-4 shrink-0 rounded-sm bg-bg-primary border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 data-[state=checked]:bg-bg-primary data-[state=checked]:text-fg-primary",e),...t,children:d.jsxs(kq,{className:ue("flex items-center justify-center text-current"),children:[r===!0&&d.jsx(Xu,{size:12}),r==="indeterminate"&&d.jsx(wK,{size:12})]})})});td.displayName=hA.displayName;function Om(e,t){const n=new Date(t).getTime(),r=e.getTime(),o=Math.floor((r-n)/1e3),i=Math.floor(o/60),s=Math.floor(o/3600),a=Math.floor(o/86400),l=Math.floor(a/30);return o<60?"just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a===1?"yesterday":a<30?`${a}d ago`:`${l}mo ago`}function pA({onPublish:e,onClose:t}){const[n,r]=g.useState(null),o=ap(),{summary:i,canGenerate:s,setSummary:a,publishDisabled:l,generateSummary:c}=lp(),[u,f]=g.useState(!1),h=()=>{f(!1),i.type!=="not-asked"&&a({...i})};g.useEffect(()=>{i.type!=="not-asked"&&!i.isGenerating&&!wu(i.patchIds,o)&&f(!0)},[i,o]);const p=g.useCallback(()=>{h(),c().then(x=>{x.type==="ai"?a({type:"ai",text:x.text.trim()}):r(x.message)})},[h,c,a,r]),m="w-full p-2 border rounded bg-bg-secondary",v="text"in i?i.text:"";return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-center justify-between w-full gap-2",children:[d.jsx("span",{className:"font-semibold",children:"Summary"}),s&&d.jsx(eP,{onClick:p,isGenerating:i.isGenerating})]}),n&&d.jsx("div",{className:"p-4 rounded bg-bg-error-primary text-fg-error-primary",children:n}),d.jsxs("div",{className:"grid text-xs font-light",children:[d.jsx("div",{"aria-hidden":!0,className:ue(m,"invisible whitespace-pre-wrap"),style:{gridArea:"1 / 1 / 2 / 2"},children:v+" "}),d.jsx("textarea",{disabled:!!i.isGenerating,className:ue(m,"resize-none overflow-clip disabled:opacity-50"),value:v,style:{gridArea:"1 / 1 / 2 / 2"},placeholder:"Write a summary of your changes"+(s?" or generate one using AI":""),onChange:x=>{h(),a({type:"manual",text:x.currentTarget.value})}})]}),d.jsxs("div",{className:ue("p-2 text-xs flex-grow font-light bg-bg-warning-primary text-[black] rounded flex items-center","flex justify-between w-full gap-2 py-2",{hidden:!u}),"aria-hidden":u,children:[d.jsx("span",{children:"Summary might be outdated. "}),d.jsx("button",{className:"underline",onClick:h,children:"Dismiss"})]}),d.jsx("div",{className:"flex items-center justify-end gap-2",children:e?d.jsxs(d.Fragment,{children:[d.jsx(Ge,{variant:"outline",onClick:()=>{t()},children:"Close"}),u&&s&&d.jsx(eP,{isGenerating:i.isGenerating,onClick:p}),!u&&d.jsxs(Ge,{disabled:l||v.trim()==="",onClick:()=>{i.type!=="not-asked"&&e()},variant:"default",className:"flex items-center gap-2",children:[d.jsxs("span",{children:[" ",l?"Pushing...":"Publish"]}),d.jsx(Fg,{size:16})]})]}):d.jsx(d.Fragment,{children:d.jsx(Ge,{variant:"outline",onClick:()=>{t()},children:"Close"})})})]})}function eP({isGenerating:e,onClick:t}){return d.jsx(Ge,{className:"truncate",disabled:!!e,onClick:()=>{t()},variant:"outline",children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx("span",{children:e?"Generating...":"Generate"}),d.jsx(g2,{size:16})]})})}function Eq(e,t=[]){let n=[];function r(i,s){const a=g.createContext(s),l=n.length;n=[...n,s];function c(f){const{scope:h,children:p,...m}=f,v=(h==null?void 0:h[e][l])||a,x=g.useMemo(()=>m,Object.values(m));return d.jsx(v.Provider,{value:x,children:p})}function u(f,h){const p=(h==null?void 0:h[e][l])||a,m=g.useContext(p);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>g.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Cq(o,...t)]}function Cq(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function gy(e){const t=e+"CollectionProvider",[n,r]=Eq(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:m,children:v}=p,x=Ce.useRef(null),b=Ce.useRef(new Map).current;return d.jsx(o,{scope:m,itemMap:b,collectionRef:x,children:v})};s.displayName=t;const a=e+"CollectionSlot",l=Ce.forwardRef((p,m)=>{const{scope:v,children:x}=p,b=i(a,v),w=Ve(m,b.collectionRef);return d.jsx(ds,{ref:w,children:x})});l.displayName=a;const c=e+"CollectionItemSlot",u="data-radix-collection-item",f=Ce.forwardRef((p,m)=>{const{scope:v,children:x,...b}=p,w=Ce.useRef(null),S=Ve(m,w),C=i(c,v);return Ce.useEffect(()=>(C.itemMap.set(w,{ref:w,...b}),()=>void C.itemMap.delete(w))),d.jsx(ds,{[u]:"",ref:S,children:x})});f.displayName=c;function h(p){const m=i(e+"CollectionConsumer",p);return Ce.useCallback(()=>{const x=m.collectionRef.current;if(!x)return[];const b=Array.from(x.querySelectorAll(`[${u}]`));return Array.from(m.itemMap.values()).sort((C,N)=>b.indexOf(C.ref.current)-b.indexOf(N.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},h,r]}var ok="Collapsible",[Nq,mA]=So(ok),[Pq,ik]=Nq(ok),gA=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:s,...a}=e,[l=!1,c]=Gr({prop:r,defaultProp:o,onChange:s});return d.jsx(Pq,{scope:n,disabled:i,contentId:Ur(),open:l,onOpenToggle:g.useCallback(()=>c(u=>!u),[c]),children:d.jsx(Oe.div,{"data-state":ak(l),"data-disabled":i?"":void 0,...a,ref:t})})});gA.displayName=ok;var vA="CollapsibleTrigger",yA=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ik(vA,n);return d.jsx(Oe.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ak(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:te(e.onClick,o.onOpenToggle)})});yA.displayName=vA;var sk="CollapsibleContent",xA=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ik(sk,e.__scopeCollapsible);return d.jsx(ln,{present:n||o.open,children:({present:i})=>d.jsx(jq,{...r,ref:t,present:i})})});xA.displayName=sk;var jq=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,s=ik(sk,n),[a,l]=g.useState(r),c=g.useRef(null),u=Ve(t,c),f=g.useRef(0),h=f.current,p=g.useRef(0),m=p.current,v=s.open||a,x=g.useRef(v),b=g.useRef();return g.useEffect(()=>{const w=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(w)},[]),Mn(()=>{const w=c.current;if(w){b.current=b.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();f.current=S.height,p.current=S.width,x.current||(w.style.transitionDuration=b.current.transitionDuration,w.style.animationName=b.current.animationName),l(r)}},[s.open,r]),d.jsx(Oe.div,{"data-state":ak(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!v,...i,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:v&&o})});function ak(e){return e?"open":"closed"}var _q=gA,Tq=yA,Oq=xA,xs="Accordion",Mq=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[lk,Rq,Aq]=gy(xs),[vy,Cge]=So(xs,[Aq,mA]),ck=mA(),bA=Ce.forwardRef((e,t)=>{const{type:n,...r}=e,o=r,i=r;return d.jsx(lk.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?d.jsx(Fq,{...i,ref:t}):d.jsx(Lq,{...o,ref:t})})});bA.displayName=xs;var[wA,Iq]=vy(xs),[SA,Dq]=vy(xs,{collapsible:!1}),Lq=Ce.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},collapsible:i=!1,...s}=e,[a,l]=Gr({prop:n,defaultProp:r,onChange:o});return d.jsx(wA,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:Ce.useCallback(()=>i&&l(""),[i,l]),children:d.jsx(SA,{scope:e.__scopeAccordion,collapsible:i,children:d.jsx(kA,{...s,ref:t})})})}),Fq=Ce.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},...i}=e,[s=[],a]=Gr({prop:n,defaultProp:r,onChange:o}),l=Ce.useCallback(u=>a((f=[])=>[...f,u]),[a]),c=Ce.useCallback(u=>a((f=[])=>f.filter(h=>h!==u)),[a]);return d.jsx(wA,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c,children:d.jsx(SA,{scope:e.__scopeAccordion,collapsible:!0,children:d.jsx(kA,{...i,ref:t})})})}),[zq,yy]=vy(xs),kA=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:o,orientation:i="vertical",...s}=e,a=Ce.useRef(null),l=Ve(a,t),c=Rq(n),f=cp(o)==="ltr",h=te(e.onKeyDown,p=>{var O;if(!Mq.includes(p.key))return;const m=p.target,v=c().filter(M=>{var D;return!((D=M.ref.current)!=null&&D.disabled)}),x=v.findIndex(M=>M.ref.current===m),b=v.length;if(x===-1)return;p.preventDefault();let w=x;const S=0,C=b-1,N=()=>{w=x+1,w>C&&(w=S)},P=()=>{w=x-1,w<S&&(w=C)};switch(p.key){case"Home":w=S;break;case"End":w=C;break;case"ArrowRight":i==="horizontal"&&(f?N():P());break;case"ArrowDown":i==="vertical"&&N();break;case"ArrowLeft":i==="horizontal"&&(f?P():N());break;case"ArrowUp":i==="vertical"&&P();break}const j=w%b;(O=v[j].ref.current)==null||O.focus()});return d.jsx(zq,{scope:n,disabled:r,direction:o,orientation:i,children:d.jsx(lk.Slot,{scope:n,children:d.jsx(Oe.div,{...s,"data-orientation":i,ref:l,onKeyDown:r?void 0:h})})})}),Vg="AccordionItem",[$q,uk]=vy(Vg),dk=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...o}=e,i=yy(Vg,n),s=Iq(Vg,n),a=ck(n),l=Ur(),c=r&&s.value.includes(r)||!1,u=i.disabled||e.disabled;return d.jsx($q,{scope:n,open:c,disabled:u,triggerId:l,children:d.jsx(_q,{"data-orientation":i.orientation,"data-state":PA(c),...a,...o,ref:t,disabled:u,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})})});dk.displayName=Vg;var EA="AccordionHeader",CA=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=yy(xs,n),i=uk(EA,n);return d.jsx(Oe.h3,{"data-orientation":o.orientation,"data-state":PA(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});CA.displayName=EA;var Qb="AccordionTrigger",fk=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=yy(xs,n),i=uk(Qb,n),s=Dq(Qb,n),a=ck(n);return d.jsx(lk.ItemSlot,{scope:n,children:d.jsx(Tq,{"aria-disabled":i.open&&!s.collapsible||void 0,"data-orientation":o.orientation,id:i.triggerId,...a,...r,ref:t})})});fk.displayName=Qb;var NA="AccordionContent",hk=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=yy(xs,n),i=uk(NA,n),s=ck(n);return d.jsx(Oq,{role:"region","aria-labelledby":i.triggerId,"data-orientation":o.orientation,...s,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});hk.displayName=NA;function PA(e){return e?"open":"closed"}var jA=bA,Bq=dk,Vq=CA,_A=fk,TA=hk;const Ra=jA,Ei=g.forwardRef(({className:e,...t},n)=>d.jsx(Bq,{ref:n,className:ue("border-b",e),...t}));Ei.displayName="AccordionItem";const ps=g.forwardRef(({className:e,children:t,...n},r)=>d.jsx(Vq,{className:"flex",children:d.jsxs(_A,{ref:r,className:ue("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,d.jsx(Zu,{className:"w-4 h-4 transition-transform duration-200 shrink-0"})]})}));ps.displayName=_A.displayName;const Ci=g.forwardRef(({className:e,children:t,...n},r)=>d.jsx(TA,{ref:r,className:ue("overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",e),...n,children:d.jsx("div",{className:"pt-0 pb-4",children:t})}));Ci.displayName=TA.displayName;function OA(e,t,n){if(e.length===0)return{success:!1,error:"Empty path"};let r=-1,o="";const i=c=>{o===""?o=c:o+="."+c};if(t===void 0)return{success:!1,error:`Undefined schema in: '${e.join("/")}'.`};if(n===void 0)return{success:!1,error:`Undefined source in: '${e.join("/")}'.`};let s=t,a=n;const l=[{modulePath:o,schema:s,source:a}];for(const c of e){if(r++,c==="")return{success:!1,error:`Empty path part in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(s.type==="array"){s=s.item;const u=Number(c);if(!Number.isSafeInteger(u))return{success:!1,error:`Invalid array index in: '${e.join("/")}'. Expected an integer but got '${c}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(typeof a!="object")return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got '${typeof a}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(a===null)return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got 'null' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(a===void 0)return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got 'undefined' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(!Array.isArray(a))return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an array but got '${typeof a}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(!a[u])return{success:!1,error:`Invalid array index in: '${e.join("/")}'. Expected an index less than ${a.length} but got '${u}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};a=a[u],i(c)}else if(s.type==="record"){s=s.item;const u=sm(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else if(s.type==="object"){s=s.items[c];const u=sm(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else if(s.type==="union"){const u=typeof s.key=="object"&&s.key.type==="literal"?s:void 0,f=typeof s.key=="string"?s:void 0;if(u)return{success:!1,error:"Invalid lookup in string union"};if(f){const h=sm(e,c,r,a,"union object");if(!h.success)return{success:!1,error:h.error};const p=h.source;let m;for(const v of f.items){const x=v.items[f.key];if(x.type==="literal"){if(p[f.key]===x.value){m=v;break}}else return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`}}if(!m)return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};s=m.items[c],a=p[c],i(JSON.stringify(c))}else return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`}}else if(s.type==="image"||s.type==="file"){const u=sm(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else return{success:!1,error:`Cannot construct sub-path in schema of '${s.type}' in: '${e.join("/")}'. Path was: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")}`};l.push({modulePath:o,schema:s,source:a})}return{success:!0,modulePath:o,schema:s,source:a,allResolved:l}}function sm(e,t,n,r,o){return typeof r!="object"?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got '${typeof r}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:r===null?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'null' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:r===void 0?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'undefined' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:typeof r!="object"?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got '${typeof r}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:Array.isArray(r)?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'array' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:t in r?{success:!0,source:r}:{success:!1,error:`Could not find key of source: '${e.join("/")}'. Expected a key in ${Object.keys(r).join(", ")} but got '${t}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}}function Uq(e,t){return(t==null?void 0:t.type)==="array"?e.type!=="string":(t==null?void 0:t.type)==="record"}function MA(e,t,n){if(!n)return null;const[r,o]=Y.splitModuleFilePathAndModulePath(e);if(!o)return r;const i=t[r],s=n[r];if(i===void 0||!s)return null;const a=OA(Y.splitModulePath(o),s,i);if(a.success){for(let l=a.allResolved.length-1;l>=0;l--){const c=a.allResolved[l],u=a.allResolved[l-1];if(Uq(c.schema,(u==null?void 0:u.schema)||null))return c.modulePath===""?r:Y.joinModuleFilePathAndModulePath(r,c.modulePath)}return r}else console.error(`Error resolving path: ${a.error} for path: ${e}`);return null}function hp({moduleFilePath:e,patchPath:t,className:n,toolTip:r=!0,link:o=!0}){const i=Yu(),s=g.useRef(null),a=g.useRef(new Map),[l,c]=g.useState([]),[u,f]=g.useState(),h=US(),p=Ha(),{navigate:m}=xn();g.useEffect(()=>{const x=e?Y.splitModuleFilePath(e):[],b=t,w=()=>{if(!s.current)return;const C=s.current,N=getComputedStyle(C),P=`${N.fontSize} ${N.fontFamily}`,j=C.offsetWidth,O=x.map(Wq).concat(b).map(H=>`/${H}`);f(O.join(""));const M=H=>{const V=`${H}:${P}`,I=a.current.get(V)??Hq(H,P);return a.current.set(V,I),I},D="/…",U=M(D),z=[];let K=0;for(let H=O.length-1;H>=0;H--){const V=M(O[H]),A=!(H===0);if(K+V+(A?U:0)<=j){const _=H>x.length?"module-path":"module-file-path";z.unshift({text:O[H],type:_,moduleFilePath:e,modulePathSegments:b.slice(0,H)}),K+=V}else{z.unshift({type:"ellipsis",text:D});break}}c(z)},S=new ResizeObserver(w);return s.current&&(S.observe(s.current),w()),()=>{s.current&&S.unobserve(s.current)}},[e,t]);const v=g.useMemo(()=>{if(!o)return null;const x="data"in p?p.data:{};if(t.length===0){const w=e;return{navPath:w,sourcePath:w}}const b=OA(t,x[e],h[e]);if(b.success){const w=Y.joinModuleFilePathAndModulePath(e,b.modulePath),S=MA(w,h,x);if(S)return{navPath:S,scrollToId:w};console.debug(`Failed to resolve nav path for ${e} and ${t.join(".")}: ${S}`)}else console.debug(`Failed to resolve source path for ${e} and ${t.join(".")}: ${b.error}`);return null},[e,t,h,p]);return d.jsxs($r,{open:r===!1?!1:void 0,children:[d.jsx(AS,{asChild:!0,children:d.jsx("a",{href:v&&i?`${i.studioPrefix}${v.navPath}#${v.scrollToId}`:void 0,ref:s,className:Ne("inline-block whitespace-nowrap overflow-hidden w-full align-baseline",{"cursor-pointer hover:underline":o},n),onClick:x=>{o&&v&&x.metaKey===!1&&x.ctrlKey===!1&&x.shiftKey===!1&&(x.preventDefault(),m(v.navPath,{scrollToId:v.scrollToId}))},children:l.map((x,b)=>d.jsx("span",{children:x.text},b))})}),d.jsx(fr,{side:"top",children:d.jsx(hr,{orientation:"horizontal",className:"max-w-[calc(100vw-3rem)] whitespace-nowrap",children:u})})]})}function Wq(e){const t=Nu(e);return t.slice(0,1).toUpperCase()+t.slice(1)}function Hq(e,t){const r=document.createElement("canvas").getContext("2d");return r?(r.font=t,r.measureText(e).width):0}function RA({className:e,loadingStatus:t}){const n=ap(),r=Ju(),o=U7(),i=V7(),s=bn(),[a,l]=g.useState(!1),{canGenerate:c}=lp(),u=tc(),{autoPublish:f}=zS(),h=g.useMemo(()=>{var D;let M=0;for(const U in u)M+=((D=u[U])==null?void 0:D.length)||0;return M},[u]),p=n.length-o.size,{deployments:m,dismissDeployment:v,observedCommitShas:x}=B7(),{globalTransientErrors:b,removeGlobalTransientErrors:w}=Y7(),{patchErrors:S}=r2(),[C,N]=g.useState(new Date);g.useEffect(()=>{const M=setInterval(()=>{N(new Date)},6e4);return()=>{clearInterval(M)}},[]);const{deletePatches:P}=QR(),j=L7(),O=async(M,D,U)=>{const z=await j("/patches","GET",{query:{patch_id:[D],exclude_patch_ops:!1}});if(z.status===200){const K=z.json,H=`val-patch-error-report-${M.replace("/","__").replace(/\.val\./,"-")}-${D}.json`,V=new Blob([JSON.stringify({moduleFilePath:M,patchId:D,error:U,patch:K},null,2)],{type:"application/json"}),I=document.createElement("a");I.href=URL.createObjectURL(V),I.download=H,I.click()}else alert("Failed to download report")};return d.jsxs("div",{className:Ne("text-sm",e),children:[S&&Object.values(S).some(M=>M!==null)&&d.jsx("div",{className:"sticky top-0 border-b border-border-primary bg-bg-error-primary text-fg-error-primary z-5",children:d.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[d.jsxs("div",{className:"px-4 text-pretty",children:[d.jsx("div",{children:"Unfortunately, one or more changes have errors."}),d.jsx("div",{children:"No changes can currently be applied."})]}),Object.entries(S).map(([M,D],U)=>d.jsx("div",{className:"pb-4",children:d.jsx(hr,{orientation:"horizontal",className:"max-w-[280px] text-pretty text-xs",children:D&&Object.entries(D).map(([z,K],H)=>d.jsx(jA,{className:"grid grid-cols-2 gap-2",type:"single",collapsible:!0,children:d.jsxs(dk,{value:z,children:[d.jsx("div",{children:d.jsx(Ge,{variant:"destructive",onClick:()=>{P([z])},children:d.jsx("span",{className:"flex gap-2 justify-between items-center text-left",children:d.jsx("span",{children:"Remove change and fix issue"})})})}),d.jsx(fk,{asChild:!0,className:"group",children:d.jsxs(Ge,{variant:"destructive",children:[d.jsx("span",{className:"text-left truncate group-data-[state=open]:hidden",children:"Report"}),d.jsx("span",{className:"text-left truncate group-data-[state=open]:block hidden",children:"Hide"})]})}),d.jsxs(hk,{children:[d.jsx(Ge,{variant:"destructive",onClick:()=>{O(M,z,K.message)},children:d.jsxs("span",{className:"flex gap-2 justify-between items-center text-left",children:[d.jsx("span",{children:"Download debug report"}),d.jsx(lK,{size:14})]})}),d.jsxs("div",{className:"p-4",children:[d.jsx("div",{className:"font-bold",children:"Details"}),d.jsx("div",{children:"Module file path"}),d.jsx("div",{children:d.jsx(tP,{sourcePath:M})}),d.jsx("div",{children:"Error message"}),d.jsx("pre",{children:K.message})]})]})]})},H))})},M+"#"+U))]})}),u&&h>0&&d.jsx("div",{className:"sticky top-0 border-b border-border-primary bg-bg-error-primary text-fg-error-primary z-5",children:d.jsx(hr,{orientation:"horizontal",children:d.jsx(Ra,{type:"single",className:"px-4 font-serif",collapsible:!0,children:d.jsxs(Ei,{value:"error",className:"border-b-0",children:[d.jsx(ps,{className:" data-[state=open]:mb-4 text-fg-error-primary border-fg-error-primary ",children:d.jsxs("div",{className:"flex justify-between items-center w-full",children:[d.jsxs("div",{children:[h," validation issue",h>1?"s":""]}),d.jsx(Eu,{size:16})]})}),d.jsx(Ci,{className:"",children:d.jsx("div",{className:"flex flex-col gap-4",children:Object.entries(u).map(([M,D],U)=>d.jsxs("div",{className:"pb-4",children:[d.jsx("div",{className:"items-start text-left",children:d.jsx(tP,{sourcePath:M})}),d.jsx("div",{children:d.jsx(hr,{orientation:"horizontal",className:"max-w-[280px] text-pretty text-xs",children:D==null?void 0:D.map((z,K)=>d.jsx("div",{className:"",children:d.jsx("div",{children:z.message})},K))})})]},M+"#"+U))})})]})})})}),b&&b.length>0&&d.jsx("div",{className:"sticky top-0 border-b border-border-primary bg-bg-error-primary text-fg-error-primary z-5",children:d.jsx(hr,{orientation:"horizontal",children:d.jsx(Ra,{type:"single",className:"px-4 font-serif",collapsible:!0,children:d.jsxs(Ei,{value:"error",className:"border-b-0 data-[state=open]:mb-4",children:[d.jsxs(ps,{children:[b.length," transient error",b.length>1?"s":""]}),d.jsx(Ci,{className:"w-full",children:d.jsx("div",{className:"flex flex-col gap-2",children:b.map(M=>d.jsxs("div",{className:"flex gap-2 justify-between items-start",children:[d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("div",{className:"font-bold",children:M.message}),M.details&&d.jsx("div",{children:M.details}),d.jsx("div",{className:"text-[10px] font-thin",children:Om(C,new Date(M.timestamp).toISOString())})]}),d.jsx("button",{onClick:()=>w([M.id]),children:d.jsx(Ll,{size:14})})]},M.id))})})]})})})}),m.length>0&&d.jsx("div",{className:"p-4 border-b border-border-primary",children:d.jsx(Kq,{deployments:m,observedCommitShas:x,onDismiss:v})}),r==="http"&&d.jsx("div",{className:"flex justify-end items-center p-4 border-b z-5 border-border-primary",children:d.jsxs(br,{open:a,onOpenChange:M=>{l(M)},children:[d.jsx(xo,{asChild:!0,children:d.jsxs(Ge,{variant:"secondary",className:"flex gap-2 items-center text-sm",children:[d.jsx("span",{children:"Summary"}),c&&d.jsx(g2,{size:14})]})}),d.jsxs(tr,{container:s,align:"end",className:"z-[9001] flex flex-col gap-4",children:[d.jsx(Fl,{asChild:!0,className:"self-end cursor-pointer",children:d.jsx(Ll,{size:12})}),d.jsx(pA,{onClose:()=>{l(!1)}})]})]})}),d.jsx("div",{className:"p-4 z-5",children:d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsxs("div",{className:"flex gap-2 items-center",children:[d.jsxs("div",{className:"font-bold",children:[p<=0?"No ":`${p} `,"pending change",p===1?"":"s"]}),(t==="loading"||t==="not-asked")&&d.jsx("div",{className:"",children:d.jsx(qr,{size:16,className:"animate-spin"})})]}),d.jsxs(br,{children:[d.jsx(xo,{asChild:!0,children:d.jsxs(Ge,{disabled:n.length===0,variant:"secondary",className:"flex gap-2 items-center text-sm",children:[d.jsx("span",{children:"Undo all"}),d.jsx(Yb,{size:14})]})}),d.jsx(tr,{container:s,className:"z-[9001]",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("div",{className:"text-lg font-bold",children:"Are you sure?"}),d.jsx("div",{children:"This will undo all changes to the current state."}),d.jsx("div",{children:d.jsx(Fl,{asChild:!0,children:d.jsxs(Ge,{variant:"destructive",className:"flex gap-2 items-center text-sm",onClick:()=>{P(n)},children:[d.jsx("span",{children:"Undo all changes"}),d.jsx(Yb,{size:14})]})})})]})})]})]})}),(!f||h>0)&&d.jsx("div",{className:"flex flex-col gap-[2px]",children:"data"in i&&n.length>0&&i.data.map(M=>d.jsx(Jq,{committedPatchIds:o,patchSet:M,patchErrors:(S==null?void 0:S[M.moduleFilePath])??{}},M.moduleFilePath+":"+M.patchPath.join("/")))})]})}function tP({sourcePath:e}){const[t,n]=Y.splitModuleFilePathAndModulePath(e),r=Y.splitModulePath(n);return d.jsx(hp,{moduleFilePath:t,patchPath:r})}function Kq({deployments:e,observedCommitShas:t,onDismiss:n}){return g.useEffect(()=>{for(const r of e)t.has(r.commitSha)&&setTimeout(()=>{n(r.commitSha)},5e3)},[e,t]),d.jsxs("div",{children:[d.jsxs("div",{className:"flex justify-between items-center p-2 font-bold",children:[d.jsx("span",{children:"Deployments"}),d.jsx(qr,{size:16,className:"inline animate-spin"})]}),d.jsx("div",{children:e.reverse().map(r=>d.jsx(Gq,{deployment:r,isFinished:t.has(r.commitSha),onDismiss:()=>{n(r.commitSha)}},r.commitSha))})]})}function Gq({deployment:e,isFinished:t,onDismiss:n}){var s;const r=VS(),o=bn(),i=e.creator&&r[e.creator];return d.jsxs("div",{className:"flex justify-between items-start p-2",children:[d.jsxs("div",{className:"flex gap-2 items-start",children:[i&&d.jsx("img",{src:(s=i.avatar)==null?void 0:s.url,alt:i.fullName,className:"w-8 h-8 rounded-full"}),d.jsxs($r,{children:[d.jsx(zR,{container:o}),d.jsx(ho,{children:d.jsx("div",{className:"max-w-[180px] overflow-clip font-light truncate",children:e.commitMessage})}),d.jsx(fr,{className:"max-w-[320px]",children:d.jsx("pre",{className:"font-sans font-light whitespace-break-spaces",children:e.commitMessage})})]})]}),t&&d.jsxs("div",{className:"flex gap-2 items-start",children:[d.jsx("span",{className:"text-xs font-light text-fg-quaternary",children:"Deployed"}),d.jsx("button",{onClick:()=>{n()},children:d.jsx(Xu,{size:14})})]}),!t&&d.jsx(qq,{since:new Date(e.createdAt)})]})}function qq({since:e}){const[t,n]=g.useState("00"),[r,o]=g.useState("00");return g.useEffect(()=>{let i;const s=()=>{const a=Date.now(),l=Math.floor((a-e.getTime())/1e3),c=Math.floor(l/60),u=l%60;let f;c>4?(f=(60-u)*1e3,n(c.toString()),o(null)):(f=1e3,n(c.toString().padStart(2,"0")),o(u.toString().padStart(2,"0"))),i=setTimeout(s,f)};return s(),()=>{clearTimeout(i)}},[e]),d.jsxs("div",{className:"text-xs font-light text-fg-quaternary",children:[t,r!==null?`:${r}`:" mins"]})}function Yq({moduleFilePath:e,patchMetadata:t,committedPatchIds:n}){var u;const r=AA([t.opType],t.createdAt,n.has(t.patchId)),o=VS(),{skippedPatches:i}=BS(),s=void 0,[a]=g.useMemo(()=>[!!i[t.patchId]],[t.patchId,i[t.patchId]]),l=Ju();let c=[];if(t.author){const f=o[t.author];if(f){const h=((u=f==null?void 0:f.avatar)==null?void 0:u.url)??null;c=[{fullName:f.fullName,url:h}]}else console.warn("Did not find profile for author: ",t.author,{profilesById:o})}return c.length===0&&l==="http"&&console.warn("No authors",{patchMetadata:t}),d.jsx(ew,{moduleFilePath:e,patchPath:t.patchPath,changeDescription:a?"Skipped":r,authors:c,errors:s,skipped:a,isApplied:n.has(t.patchId)})}function AA(e,t,n){const[r,o]=g.useState(new Date);if(g.useEffect(()=>{const a=setInterval(()=>{o(new Date)},6e4);return()=>{clearInterval(a)}},[]),n)return"Pushed "+Om(r,t);if(e.length>1)return"Updated "+Om(r,t);const i=e[0];let s=i;return i==="add"?s="Added":i==="remove"?s="Removed":i==="replace"?s="Replaced":i==="move"?s="Moved":i==="copy"?s="Copied":i==="test"?s="Tested":i==="file"?s="Updated":console.warn("Unexpected op type: ",i),s+" "+Om(r,t)}function Jq({patchSet:e,committedPatchIds:t,patchErrors:n}){const[r,o]=g.useState(!1),i=g.useRef(null),[s,a]=g.useState(!1);g.useEffect(()=>{const v=new IntersectionObserver(x=>{x[0].isIntersecting&&a(!0)},{threshold:0});return i.current&&v.observe(i.current),()=>{v.disconnect()}},[]);const{skippedPatches:l}=BS(),{deletePatches:c}=QR(),u=g.useMemo(()=>e.patches.map(v=>v.patchId),[e.patches.map(v=>v.patchId).join(",")]),f=g.useMemo(()=>{const v=[];for(const x of u){const b=n==null?void 0:n[x];!l[x]&&b&&v.unshift(b.message)}return v},[u,n,l]),h=AA(e.opTypes,e.lastUpdated,!1),p=VS(),m=e.patches.every(v=>t.has(v.patchId));return s?d.jsxs(d.Fragment,{children:[d.jsx(ew,{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath,isApplied:m,authors:e.authors.reduce((v,x)=>v.includes(x)?v:v.concat(x),[]).flatMap(v=>{var b;const x=p[v];if(x){const w=((b=x==null?void 0:x.avatar)==null?void 0:b.url)??null;return[{fullName:x.fullName,url:w}]}return[]}),changeDescription:h,isOpen:r,setOpen:o,errors:f,onDelete:()=>{c(u.filter(v=>!t.has(v)))},amount:new Set(u).size}),d.jsx(Cu,{isOpen:r,children:e.patches.map((v,x)=>d.jsx(Yq,{committedPatchIds:t,moduleFilePath:e.moduleFilePath,patchMetadata:v},e.moduleFilePath+":"+e.patchPath.join("/")+v.patchId+x))})]}):d.jsx(ew,{ref:i,isApplied:m})}const ew=g.forwardRef(({moduleFilePath:e,patchPath:t,changeDescription:n,authors:r,isOpen:o,setOpen:i,isSelected:s,setSelected:a,errors:l,skipped:c,onDelete:u,amount:f,isApplied:h},p)=>{const m=bn();return d.jsxs("div",{ref:p,className:Ne("p-6",{"bg-bg-secondary":!o,"bg-bg-tertiary":o,"opacity-50":h}),children:[d.jsxs("div",{className:"relative",children:[d.jsx("span",{className:"inline-block w-[calc(320px-24px-8px-16px-24px-48px)] truncate mr-2 ",children:e&&t&&d.jsx(hp,{moduleFilePath:e,patchPath:t,link:!0,toolTip:!0})}),s===void 0&&d.jsx("span",{className:Ne("inline-block w-6 h-6 rounded",{"bg-bg-disabled animate-pulse":t===void 0})}),s!==void 0&&!h&&d.jsx(td,{checked:s,onCheckedChange:v=>{a&&a(v)}}),d.jsxs("div",{className:"inline relative ml-5",children:[f&&d.jsxs($r,{children:[d.jsx(ho,{children:d.jsx("span",{className:"absolute -right-5 -top-6 w-6 h-6 text-xs leading-6 text-center rounded-full bg-bg-primary text-fg-primary",children:f>9?"9+":f})}),d.jsx(fr,{side:"left",children:d.jsxs("p",{children:[f," change",f>1?"s":""," in this patch set"]})})]}),u&&!h&&f&&f>0&&d.jsxs(br,{children:[d.jsx(xo,{children:d.jsx(Yb,{size:16,className:"inline"})}),d.jsxs(tr,{container:m,className:"flex flex-col gap-2 z-[9001]",children:[d.jsx("div",{className:"text-lg font-bold",children:"Are you sure?"}),d.jsxs("div",{children:["This will undo ",f," change",f>1?"s":"","."]}),d.jsx("div",{children:d.jsx(Fl,{asChild:!0,children:d.jsxs(Ge,{variant:"destructive",onClick:u,children:["Undo change",f>1?"s":""]})})})]})]})]})]}),l&&l.length>0&&!c&&d.jsxs("div",{className:"p-2 max-w-[240px] bg-bg-error-primary text-fg-primary rounded-lg",children:[l.slice(0,1).map((v,x)=>d.jsx("div",{title:v,className:"truncate",children:"Invalid change"},x)),l.length>1&&d.jsxs("div",{className:"truncate",children:["+",l.length-1," more"]})]}),(!l||l.length===0)&&c&&d.jsx("div",{className:"p-2 max-w-[240px] bg-bg-error-primary text-fg-primary",children:d.jsx("div",{className:"truncate",children:"Skipped"})}),d.jsxs("div",{className:"flex justify-between items-center pt-2",children:[d.jsxs("span",{className:"flex flex-shrink-0 gap-2",children:[r!==void 0&&r.length>0&&d.jsxs("span",{className:"flex gap-1 mr-2",children:[r.slice(0,2).map((v,x)=>{if(v.url)return d.jsxs($r,{children:[d.jsx(ho,{className:"flex-shrink-0 w-6 h-6",children:d.jsx("img",{src:v.url,alt:v.fullName,className:Ne("rounded-full",{"-ml-3":r.length>2&&x>0})})}),d.jsx(fr,{children:d.jsx("div",{children:v.fullName})})]},v.url);const b=Xq(v.fullName);return d.jsxs($r,{children:[d.jsx(ho,{className:Ne({"-ml-3":r.length>2&&x>0}),children:d.jsx("span",{className:Ne("flex items-center justify-center w-6 h-6 text-xs font-semibold rounded-full bg-bg-primary text-fg-primary"),"aria-label":"Initials for: "+v.fullName,children:b})}),d.jsx(fr,{children:d.jsx("div",{children:v.fullName})})]},v.fullName+v.url)}),r.length>2&&d.jsxs($r,{children:[d.jsx(ho,{className:Ne({"-ml-3":r.length>2}),children:d.jsxs("span",{className:"flex justify-center items-center -ml-3 w-6 h-6 text-xs font-semibold rounded-full bg-bg-primary text-fg-primary",children:["+",r.length-2]})}),d.jsx(fr,{className:"grid grid-cols-[auto,1fr] gap-2",children:r.slice(2).map(v=>d.jsxs(g.Fragment,{children:[v.url?d.jsx("img",{src:v.url,alt:v.fullName,title:v.fullName,className:Ne("w-6 h-6 rounded-full")},v.url):d.jsx("div",{}),d.jsx("div",{children:v.fullName})]},v.fullName+v.url))})]})]}),r===void 0&&d.jsx("span",{className:Ne("inline-block w-6 h-6 mr-2",{"bg-bg-disabled animate-pulse rounded-3xl":r===void 0})}),n&&d.jsx("span",{className:Ne({"text-fg-disabled":c}),children:n})]}),o!==void 0&&d.jsx("button",{className:"inline-block flex-shrink-0",onClick:()=>{i&&i(!o)},children:d.jsx(Zu,{size:16,className:Ne("transform",{"rotate-180":o})})})]})]})});function Xq(e){return!e||typeof e!="string"?"":e.trim().normalize("NFC").split(/\s+/).filter(r=>r.length>0).map(r=>/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(r)?r[0]:r[0].toLocaleUpperCase()).join("")}function tw(){const[e,t]=g.useState(!1),{publish:n,publishDisabled:r,isPublishing:o,summary:i}=lp(),s=tc(),a=s!==void 0&&Object.keys(s).length>0,l=e2(),c=t2(),u=Ju(),f=bn(),{autoPublish:h}=zS();return a?d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(Ge,{className:"flex gap-2 items-center",disabled:!0,children:u==="fs"?"Save":d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Ready"}),d.jsx(Fg,{size:16})]})})}),d.jsx(fr,{children:d.jsx("div",{className:"flex flex-col gap-2",children:d.jsx("p",{children:"Fix validation errors to continue"})})})]}):u==="fs"?d.jsxs(Ge,{className:"flex gap-2 items-center",disabled:r||a||h||l.length===0||c.length>0,title:a?"Please fix validation errors":"",onClick:()=>{n("No summary provided")},children:[a?d.jsx("span",{children:"Save"}):d.jsx("span",{children:o?"Saving":"Save"}),o&&d.jsx(qr,{className:"animate-spin",size:16})]}):d.jsx("span",{children:d.jsxs(br,{open:e,onOpenChange:p=>{t(p)},children:[d.jsx(xo,{asChild:!0,children:d.jsxs(Ge,{className:"flex gap-2 items-center",disabled:r||a||l.length===0||c.length>0,onClick:()=>{t(!0)},children:[!o&&d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Ready"}),d.jsx(Fg,{size:16})]}),o&&d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Pushing"}),d.jsx(qr,{className:"animate-spin",size:16})]})]})}),d.jsxs(tr,{container:f,align:"end",className:"z-[9001] flex flex-col gap-4",children:[d.jsx(Fl,{asChild:!0,className:"self-end cursor-pointer",children:d.jsx(Ll,{size:12})}),d.jsx(pA,{onClose:()=>{t(!1)},onPublish:()=>{if(t(!1),i.type==="not-asked")return;const p=i.text.trim();n(p)}})]})]})})}function Zq(){const e=uy(),{isPublishing:t}=lp(),n=tc()||{},{globalErrors:r}=BS(),o=Ju(),[i,s]=g.useMemo(()=>{const a=new Set;let l=0;for(const c in n){const[u]=Y.splitModuleFilePathAndModulePath(c);a.add(u),l+=1}return[Array.from(a).sort(),l]},[n]);return d.jsxs("div",{className:"min-h-[100svh] bg-bg-primary",style:{"--menu-width":"320px"},children:[d.jsx("div",{className:"h-16 border-b border-border-primary",children:d.jsx(tY,{})}),t&&d.jsxs("div",{className:"flex gap-2 justify-end items-center p-4 text-right border-t bg-bg-tertiary text-fg-primary border-border-primary",children:[d.jsx("span",{children:"Publishing changes "}),d.jsx(qr,{size:16,className:"animate-spin"})]}),d.jsx(hr,{children:d.jsxs("div",{className:"max-h-[calc(100svh-64px)]",children:[r&&r.length>0&&r.length!==s&&d.jsx(Ra,{type:"single",collapsible:!0,children:d.jsxs(Ei,{value:"global-errors",children:[d.jsxs(ps,{className:"p-4 font-normal text-left rounded data-[state=open]:rounded-b-none bg-bg-error-primary text-fg-error-primary",children:["Cannot ",o==="fs"?"save":"publish"," now. Found"," ",r==null?void 0:r.length," errors in all."," ",r.length-s," were non-validation errors. A developer might need to fix these issues."]}),d.jsx(Ci,{children:d.jsx(hr,{children:d.jsx("div",{className:"max-h-[calc(100svh-128px)] max-w-[var(--menu-width)]",children:r==null?void 0:r.map((a,l)=>d.jsx(eY,{error:a},l))})})})]})}),(r==null?void 0:r.length)===s&&i.length>0&&d.jsx(Ra,{type:"single",collapsible:!0,children:d.jsxs(Ei,{value:"global-errors",children:[d.jsx(ps,{className:"p-4 font-normal text-left rounded data-[state=open]:rounded-b-none bg-bg-error-primary text-fg-error-primary",children:d.jsxs("div",{children:[d.jsxs("div",{children:["Cannot ",o==="fs"?"save":"publish"," now."]}),d.jsx("div",{children:"Found errors in modules"})]})}),d.jsx(Ci,{children:d.jsx(hr,{children:d.jsx("div",{className:"max-h-[calc(100svh-64px)] max-w-[var(--menu-width)]",children:i==null?void 0:i.map((a,l)=>d.jsx(Qq,{moduleFilePath:a},l))})})})]})}),e!=="not-asked"&&d.jsx("div",{className:Ne("",{}),children:d.jsx(hr,{children:d.jsx("div",{className:"max-h-[calc(100svh-64px)] border-b border-border-primary",children:d.jsx(RA,{loadingStatus:e})})})})]})})]})}function Qq({moduleFilePath:e}){const t=Y.splitModuleFilePath(e),n=xn();return d.jsx("div",{className:"px-4 py-2 border-b bg-bg-error-primary text-fg-error-primary border-border-error-primary",children:d.jsx("button",{className:"underline cursor-pointer",onClick:()=>{n.navigate(e)},children:t.map((r,o)=>d.jsxs(g.Fragment,{children:[d.jsx("span",{className:ue("text-fg-brand-secondary",{"ml-1":o>0}),children:"/"}),d.jsx("span",{children:Nu(r)})]},o))})})}function eY({error:e}){const[t,n]=g.useState(!1);return d.jsx("div",{className:ue("px-1 py-2 bg-bg-error-primary text-fg-error-primary border-b border-border-error-primary",{truncate:!t,"whitespace-normal":t}),onClick:()=>n(!t),children:e})}function tY(){const{currentSourcePath:e}=xn(),t=Ha(),[n,r]=Y.splitModuleFilePathAndModulePath(e),o=lt(n,"record"),i=g.useMemo(()=>{if(t.status!=="success")return t;if(o.status!=="success")return o;const f=t.data[n];if(f.type==="record"&&f.router){if(o.data===null)return{status:"success",data:null};const h=Object.keys(o.data),p=Y.splitModulePath(r)[0];for(const m of h)if(p&&p.startsWith(m))return{status:"success",data:{previewRoute:m}}}return{status:"success",data:null}},["data"in t&&t.data,n,r,o]),{navMenu:s,toolsMenu:a}=Qy(),l=Ju(),{setAutoPublish:c,autoPublish:u}=zS();return d.jsx("div",{className:"flex flex-col",children:d.jsxs("div",{className:"flex gap-2 justify-between items-center p-4 w-full",children:[d.jsx("button",{className:"lg:hidden",onClick:()=>{a.setOpen(!a.isOpen)},children:d.jsx(Dg,{size:16,className:Ne("transform",{"rotate-180":!s.isOpen})})}),d.jsxs("div",{className:"flex gap-2 justify-end items-center w-full",children:[l==="fs"&&d.jsxs("div",{className:"overflow-hidden flex items-center gap-2 text-[10px] lg:text-xs",children:[d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx("span",{className:"truncate text-fg-secondary",children:"Auto-save"})}),d.jsxs(fr,{children:[d.jsx("p",{children:"When auto-save is enabled Val will save to changes to disk automatically"}),d.jsx("p",{children:"This is a development mode feature"})]})]}),d.jsx(td,{checked:u,onCheckedChange:c})]}),d.jsx(nY,{maybePreviewRoute:i}),d.jsx(tw,{})]})]})})}function nY({maybePreviewRoute:e}){var n,r;const t=g.useMemo(()=>{var o;return e.status==="success"&&((o=e.data)!=null&&o.previewRoute)?yu("/api/val/enable",{redirect_to:window.origin+e.data.previewRoute}):yu("/api/val/enable",{redirect_to:window.origin})},[e]);return d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(Ge,{className:"flex gap-2 items-center",variant:"secondary",asChild:!0,children:d.jsxs("a",{href:t,children:[d.jsx("span",{children:"Preview"}),e.status==="success"&&((n=e.data)!=null&&n.previewRoute)?d.jsx(Ig,{size:16}):d.jsx(Lg,{size:16})]})})}),d.jsx(fr,{children:e.status==="success"&&((r=e.data)!=null&&r.previewRoute)?d.jsxs("p",{children:["Preview your changes in ",e.data.previewRoute]}):d.jsx("p",{children:"Preview your changes on the main page"})})]})}function Xt({error:e,path:t}){return d.jsx("div",{id:t,children:d.jsx("div",{className:"p-4 bg-bg-error-primary text-fg-error-primary",children:e})})}function yt({path:e,type:t}){return d.jsx("div",{id:e,className:Ne("pt-6",{"w-full flex items-center justify-center":t==="module","text-left":t!=="module"}),children:d.jsx(qr,{size:t==="module"?24:16,className:"animate-spin"})})}function Rn({path:e,type:t}){const[n,r]=g.useState(!1);return g.useEffect(()=>{const o=setTimeout(()=>{r(!0)},2e3);return()=>{clearTimeout(o)}},[]),e.length===0?null:n?d.jsx("div",{className:"pt-6",id:e,children:d.jsx("div",{children:"Could not get data"})}):d.jsx(yt,{path:e,type:t})}function Er({actualType:e,expectedType:t,path:n}){return d.jsx("div",{id:n,children:d.jsxs("div",{children:["Schema mismatch: actual: ",e," vs expected: ",t," "]})})}function it({error:e,path:t,schema:n}){const{addPatch:r,patchPath:o}=wn(t);return d.jsxs("div",{id:t,className:"flex justify-between items-center px-2 py-3 rounded-lg bg-bg-error-primary text-fg-primary",children:[d.jsxs("div",{children:["Source error: ",e]}),d.jsxs("div",{className:"flex gap-2 items-center",children:[n&&n.status==="success"&&!(n.data.type==="file"||n.data.type==="image")&&d.jsx(Ge,{variant:"outline",className:"hover:bg-bg-error-secondary-hover",onClick:()=>{r([{op:"replace",path:o,value:zl(n.data)}],n.data.type)},children:"Fix"}),d.jsx(Eu,{size:16})]})]})}function rY(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const xy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function nd(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function pk(e){return"nodeType"in e}function Cr(e){var t,n;return e?nd(e)?e:pk(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function mk(e){const{Document:t}=Cr(e);return e instanceof t}function pp(e){return nd(e)?!1:e instanceof Cr(e).HTMLElement}function IA(e){return e instanceof Cr(e).SVGElement}function rd(e){return e?nd(e)?e.document:pk(e)?mk(e)?e:pp(e)||IA(e)?e.ownerDocument:document:document:document}const Ni=xy?g.useLayoutEffect:g.useEffect;function gk(e){const t=g.useRef(e);return Ni(()=>{t.current=e}),g.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function oY(){const e=g.useRef(null),t=g.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=g.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function yh(e,t){t===void 0&&(t=[e]);const n=g.useRef(e);return Ni(()=>{n.current!==e&&(n.current=e)},t),n}function mp(e,t){const n=g.useRef();return g.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ug(e){const t=gk(e),n=g.useRef(null),r=g.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function nw(e){const t=g.useRef();return g.useEffect(()=>{t.current=e},[e]),t.current}let i0={};function gp(e,t){return g.useMemo(()=>{if(t)return t;const n=i0[e]==null?0:i0[e]+1;return i0[e]=n,e+"-"+n},[e,t])}function DA(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,c]of a){const u=i[l];u!=null&&(i[l]=u+e*c)}return i},{...t})}}const Qc=DA(1),xh=DA(-1);function iY(e){return"clientX"in e&&"clientY"in e}function vk(e){if(!e)return!1;const{KeyboardEvent:t}=Cr(e.target);return t&&e instanceof t}function sY(e){if(!e)return!1;const{TouchEvent:t}=Cr(e.target);return t&&e instanceof t}function rw(e){if(sY(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return iY(e)?{x:e.clientX,y:e.clientY}:null}const bh=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[bh.Translate.toString(e),bh.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),nP="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function aY(e){return e.matches(nP)?e:e.querySelector(nP)}const lY={display:"none"};function cY(e){let{id:t,value:n}=e;return Ce.createElement("div",{id:t,style:lY},n)}function uY(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ce.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function dY(){const[e,t]=g.useState("");return{announce:g.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const LA=g.createContext(null);function fY(e){const t=g.useContext(LA);g.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function hY(){const[e]=g.useState(()=>new Set),t=g.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[g.useCallback(r=>{let{type:o,event:i}=r;e.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[e]),t]}const pY={draggable:`
450
+ `)},$G=0,mc=[];function BG(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),o=g.useState($G++)[0],i=g.useState(F2)[0],s=g.useRef(e);g.useEffect(function(){s.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var v=lG([e.lockRef.current],(e.shards||[]).map(qN),!0).filter(Boolean);return v.forEach(function(x){return x.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),v.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,x){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!s.current.allowPinchZoom;var b=im(v),w=n.current,S="deltaX"in v?v.deltaX:w[0]-b[0],C="deltaY"in v?v.deltaY:w[1]-b[1],N,P=v.target,j=Math.abs(S)>Math.abs(C)?"h":"v";if("touches"in v&&j==="h"&&P.type==="range")return!1;var O=KN(j,P);if(!O)return!0;if(O?N=j:(N=j==="v"?"h":"v",O=KN(j,P)),!O)return!1;if(!r.current&&"changedTouches"in v&&(S||C)&&(r.current=N),!N)return!0;var M=r.current||N;return LG(M,x,v,M==="h"?S:C,!0)},[]),l=g.useCallback(function(v){var x=v;if(!(!mc.length||mc[mc.length-1]!==i)){var b="deltaY"in x?GN(x):im(x),w=t.current.filter(function(N){return N.name===x.type&&(N.target===x.target||x.target===N.shadowParent)&&FG(N.delta,b)})[0];if(w&&w.should){x.cancelable&&x.preventDefault();return}if(!w){var S=(s.current.shards||[]).map(qN).filter(Boolean).filter(function(N){return N.contains(x.target)}),C=S.length>0?a(x,S[0]):!s.current.noIsolation;C&&x.cancelable&&x.preventDefault()}}},[]),c=g.useCallback(function(v,x,b,w){var S={name:v,delta:x,target:b,should:w,shadowParent:VG(b)};t.current.push(S),setTimeout(function(){t.current=t.current.filter(function(C){return C!==S})},1)},[]),u=g.useCallback(function(v){n.current=im(v),r.current=void 0},[]),f=g.useCallback(function(v){c(v.type,GN(v),v.target,a(v,e.lockRef.current))},[]),h=g.useCallback(function(v){c(v.type,im(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return mc.push(i),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",l,pc),document.addEventListener("touchmove",l,pc),document.addEventListener("touchstart",u,pc),function(){mc=mc.filter(function(v){return v!==i}),document.removeEventListener("wheel",l,pc),document.removeEventListener("touchmove",l,pc),document.removeEventListener("touchstart",u,pc)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(i,{styles:zG(o)}):null,p?g.createElement(TG,{gapMode:e.gapMode}):null)}function VG(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const UG=vG(L2,BG);var dp=g.forwardRef(function(e,t){return g.createElement(my,pi({},e,{ref:t,sideCar:UG}))});dp.classNames=my.classNames;var ek="Popover",[V2,kge]=So(ek,[Mi]),fp=Mi(),[WG,Ka]=V2(ek),U2=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:s=!1}=e,a=fp(t),l=g.useRef(null),[c,u]=g.useState(!1),[f=!1,h]=Gr({prop:r,defaultProp:o,onChange:i});return d.jsx(rp,{...a,children:d.jsx(WG,{scope:t,contentId:Ur(),triggerRef:l,open:f,onOpenChange:h,onOpenToggle:g.useCallback(()=>h(p=>!p),[h]),hasCustomAnchor:c,onCustomAnchorAdd:g.useCallback(()=>u(!0),[]),onCustomAnchorRemove:g.useCallback(()=>u(!1),[]),modal:s,children:n})})};U2.displayName=ek;var W2="PopoverAnchor",HG=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ka(W2,n),i=fp(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=o;return g.useEffect(()=>(s(),()=>a()),[s,a]),d.jsx(Ku,{...i,...r,ref:t})});HG.displayName=W2;var H2="PopoverTrigger",Bg=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ka(H2,n),i=fp(n),s=Ve(t,o.triggerRef),a=d.jsx(Oe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":J2(o.open),...r,ref:s,onClick:te(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:d.jsx(Ku,{asChild:!0,...i,children:a})});Bg.displayName=H2;var tk="PopoverPortal",[KG,GG]=V2(tk,{forceMount:void 0}),K2=e=>{const{__scopePopover:t,forceMount:n,children:r,container:o}=e,i=Ka(tk,t);return d.jsx(KG,{scope:t,forceMount:n,children:d.jsx(ln,{present:n||i.open,children:d.jsx(Gu,{asChild:!0,container:o,children:r})})})};K2.displayName=tk;var ju="PopoverContent",G2=g.forwardRef((e,t)=>{const n=GG(ju,e.__scopePopover),{forceMount:r=n.forceMount,...o}=e,i=Ka(ju,e.__scopePopover);return d.jsx(ln,{present:r||i.open,children:i.modal?d.jsx(qG,{...o,ref:t}):d.jsx(YG,{...o,ref:t})})});G2.displayName=ju;var qG=g.forwardRef((e,t)=>{const n=Ka(ju,e.__scopePopover),r=g.useRef(null),o=Ve(t,r),i=g.useRef(!1);return g.useEffect(()=>{const s=r.current;if(s)return py(s)},[]),d.jsx(dp,{as:ds,allowPinchZoom:!0,children:d.jsx(q2,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:te(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),i.current||(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:te(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:te(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),YG=g.forwardRef((e,t)=>{const n=Ka(ju,e.__scopePopover),r=g.useRef(!1),o=g.useRef(!1);return d.jsx(q2,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var s,a;(s=e.onCloseAutoFocus)==null||s.call(e,i),i.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const s=i.target;((c=n.triggerRef.current)==null?void 0:c.contains(s))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),q2=g.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=e,h=Ka(ju,n),p=fp(n);return hy(),d.jsx(up,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:d.jsx(Ql,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>h.onOpenChange(!1),children:d.jsx(op,{"data-state":J2(h.open),role:"dialog",id:h.contentId,...p,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Y2="PopoverClose",Fl=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=Ka(Y2,n);return d.jsx(Oe.button,{type:"button",...r,ref:t,onClick:te(e.onClick,()=>o.onOpenChange(!1))})});Fl.displayName=Y2;var JG="PopoverArrow",XG=g.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,o=fp(n);return d.jsx(ip,{...o,...r,ref:t})});XG.displayName=JG;function J2(e){return e?"open":"closed"}var ZG=U2,QG=Bg,eq=K2,X2=G2;const br=ZG,xo=QG,tr=g.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},o)=>d.jsx(eq,{container:r.container,children:d.jsx(X2,{ref:o,align:t,sideOffset:n,className:ue("z-50 w-72 rounded-md border bg-bg-secondary p-4 text-fg-secondary shadow-md outline-none 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})}));tr.displayName=X2.displayName;function YN({profile:e,size:t="md"}){var c,u,f;const[n,r]=g.useState(((c=e==null?void 0:e.avatar)==null?void 0:c.url)||null);g.useEffect(()=>{var h,p;(h=e==null?void 0:e.avatar)!=null&&h.url?r((p=e==null?void 0:e.avatar)==null?void 0:p.url):r(null)},[(u=e==null?void 0:e.avatar)==null?void 0:u.url]);const[o,...i]=((f=e.fullName)==null?void 0:f.split(" "))||[""],s=i[i.length-1]||"",a=`${o[0].toUpperCase()}${s[0].toUpperCase()}`,l=Ne("rounded-full text-center inline-block bg-bg-brand-primary text-fg-brand-primary",{"h-8 w-8 leading-8 text-xs":t==="sm","h-10 w-10 leading-10 text-base":t==="md","h-12 w-12 leading-[3rem] text-lg":t==="lg"});return n?d.jsx("img",{src:n,alt:a,className:l,onError:()=>{r(null)}}):d.jsx("span",{className:l,children:a})}function tq(e,t,n,r){if(t[n]===void 0)return console.error(`Get keysOf source not found for ${n}`),[];if(!e[n])return console.error(`Schema not found for ${n}`),[];const s=n,a=[],l=(c,u,f)=>{var h;if(u===void 0){console.error(`Schema not found for ${c}`);return}if(u.type==="keyOf")u.path===s&&(r?typeof f=="string"&&f===r&&(a.includes(c)?console.error(`Duplicate keyOf reference found for ${c} in ${n}`):a.push(c)):a.includes(c)?console.error(`Duplicate keyOf reference found for ${c} in ${n}`):a.push(c));else if(u.type==="object"||u.type==="record"){if(XN(f)||Z2(f))for(const p in f){const m=f==null?void 0:f[p],v=u.type==="object"?(h=u.items)==null?void 0:h[p]:u.item;m&&l(JN(c,p),v,m)}}else if(u.type==="array"){if(nq(f)){let p=0;for(const m of f)l(JN(c,p),u.item,m),p++}}else if(u.type==="union"){const p=u.key;if(typeof p=="string"&&XN(f)){const m=f[p];if(typeof m=="string"){const v=u.items.filter(x=>x.type==="object").find(x=>{const b=x.items[p];if((b==null?void 0:b.type)==="literal")return b.value===m});v&&l(c,v,f)}}}else u.type==="string"||u.type==="number"||u.type==="boolean"||u.type==="literal"||u.type==="date"||u.type==="image"||u.type==="file"||u.type==="richtext"||console.error("Could not get keyOf references. Unhandled schema type",u)};for(const c in e){const u=c;l(c,e[u],t[u])}return a}function JN(e,t){return e.includes(Ca)?`${e}.${JSON.stringify(t)}`:`${e}${Ca}${JSON.stringify(t)}`}function XN(e){return Z2(e)}function Z2(e){return typeof e=="object"&&!!e&&!oa(e)}function nq(e){return typeof e=="object"&&!!e&&oa(e)}function Q2(e,t){const n=Ha(),r=uy(),o=US();return g.useMemo(()=>e!==void 0&&"data"in n&&n.data!==void 0&&n.data[e]!==void 0?tq(n.data,o,e,t):[],[r,o,"data"in n&&n.data,e,t])}const ZN=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,QN=HR,rq=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return QN(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=t,s=Object.keys(o).map(c=>{const u=n==null?void 0:n[c],f=i==null?void 0:i[c];if(u===null)return null;const h=ZN(u)||ZN(f);return o[c][h]}),a=n&&Object.entries(n).reduce((c,u)=>{let[f,h]=u;return h===void 0||(c[f]=h),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:f,className:h,...p}=u;return Object.entries(p).every(m=>{let[v,x]=m;return Array.isArray(x)?x.includes({...i,...a}[v]):{...i,...a}[v]===x})?[...c,f,h]:c},[]);return QN(e,s,l,n==null?void 0:n.class,n==null?void 0:n.className)},Zb=rq("inline-flex items-center justify-center whitespace-nowrap rounded-md text-fg-primary text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:text-fg-disabled disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:ue("cursor-pointer","border border-border-brand-primary","bg-bg-brand-primary text-fg-brand-primary","hover:bg-bg-brand-primary-hover hover:text-fg-brand-primary-hover","disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary"),destructive:ue("cursor-pointer","border border-bg-error-primary","bg-bg-error-primary text-fg-error-primary hover:bg-bg-error-primary-hover disabled:text-fg-error-primary"),outline:ue("cursor-pointer","border border-transparent","bg-bg-background hover:bg-bg-secondary","disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary"),secondary:ue("cursor-pointer","border border-border-secondary","bg-bg-secondary text-fg-secondary hover:bg-bg-secondary-hover"),ghost:ue("cursor-pointer","border border-transparent","bg-bg-background hover:bg-bg-secondary","disabled:bg-bg-disabled disabled:text-fg-disabled disabled:border disabled:border-border-primary","hover:bg-bg-secondary-hover hover:text-fg-secondary"),link:ue("cursor-pointer","border border-transparent","text-fg-primary underline-offset-4 hover:underline")},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Ge=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...o},i)=>{const s=r?ds:"button";return d.jsx(s,{className:ue(Zb({variant:t,size:n,className:e})),ref:i,...o})});Ge.displayName="Button";function oq({path:e,disabled:t}){const[n,r]=Y.splitModuleFilePathAndModulePath(e),o=Y.splitModuleFilePath(n),i=Y.splitModulePath(r),{navigate:s}=xn();return d.jsxs("div",{className:"w-full",children:[d.jsx("button",{type:"button",title:n,disabled:t,className:"inline-block text-left truncate",onClick:()=>{s(n)},children:o.map((a,l)=>d.jsxs(g.Fragment,{children:[l===0&&d.jsx("span",{className:"text-muted",children:"/"}),d.jsx("span",{className:Ne({"text-muted":!(i.length===0&&l===o.length-1)}),children:Nu(a)}),l>0&&l<o.length-1&&d.jsx("span",{className:"text-muted",children:"/"})]},`${a}-${l}`))}),d.jsx("button",{type:"button",disabled:t,title:Y.joinModuleFilePathAndModulePath(n,r),className:"inline-block text-left truncate",onClick:()=>{s(Y.joinModuleFilePathAndModulePath(n,r))},children:i.map((a,l)=>d.jsxs(g.Fragment,{children:[d.jsx("span",{className:"text-muted",children:"/"}),d.jsx("span",{className:Ne({"text-muted":l===i.length-2}),children:Nu(a)})]},`${a}-${l}`))})]})}function eA({path:e,parentPath:t,variant:n,refs:r,children:o,size:i,onComplete:s,confirmationMessage:a,className:l}){const c=bn();return d.jsxs(br,{children:[d.jsx(xo,{asChild:!0,children:d.jsx(Ge,{size:i,variant:n,className:l,children:o})}),d.jsxs(tr,{container:c,className:"flex flex-col gap-2 p-4",children:[d.jsx("div",{className:"text-lg font-bold",children:"Are you sure?"}),d.jsx("div",{children:a}),d.jsx(Fl,{asChild:!0,children:d.jsx(iq,{path:e,parentPath:t,refs:r,variant:"destructive",onComplete:s,children:d.jsxs("div",{className:"flex gap-2 items-center",children:[d.jsx(qS,{size:12}),d.jsx("span",{children:"Delete"})]})})})]})]})}function iq({path:e,parentPath:t,variant:n,refs:r,children:o,size:i,onComplete:s}){const{navigate:a}=xn(),{addPatch:l,patchPath:c}=wn(e),u=lt(t,"record");return!("data"in u)||u.data===void 0||u.data===null?(console.error("Parent source not found",u,{path:e}),null):d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(Ge,{size:i,variant:n,disabled:r.length>0,onClick:()=>{l([{op:"remove",path:c}],"record"),a(t),s&&s()},children:o})}),d.jsx(fr,{side:"top",children:r.length>0?d.jsxs("div",{children:[d.jsx("p",{children:"Cannot delete record."}),d.jsxs("p",{children:["You must change the following references"," ",d.jsx(v2,{size:10,className:"inline"})," to be able to delete:"]}),d.jsx("ul",{children:r.map(f=>d.jsx("li",{children:d.jsx(oq,{path:f})},f))})]}):d.jsx("p",{children:"Delete record"})})]})}function zl(e){if(e.type==="object")return Object.fromEntries(Object.keys(e.items).map(n=>[n,zl(e.items[n])]));if(e.type==="array")return[];if(e.type==="record")return{};if(e.opt)return null;if(e.type==="richtext")return[];if(e.type==="string")return"";if(e.type==="boolean")return!1;if(e.type==="number")return 0;if(e.type==="keyOf")return e.values==="string"?"":e.values[0];if(e.type==="file"||e.type==="image")return null;if(e.type==="literal")return e.value;if(e.type==="union")return typeof e.key=="string"?zl(e.items[0]):e.key.value;if(e.type==="date")return ys(new Date,"yyyy-MM-dd");throw Error("Unexpected schema type: "+JSON.stringify(e))}const ed=g.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:ue("flex h-10 m-1 w-[calc(100%-8px)] rounded-md border border-input bg-bg-primary px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));ed.displayName="Input";function sq(e,t){const n={},r=t==null?void 0:t.split("/");(r==null?void 0:r[0])===""&&r.shift();const o=(r==null?void 0:r.filter(s=>s!==""))||[];let i=0;for(let s=0;s<e.length;s++){const a=e[s];if(a.type==="literal"){const l=o[i];if(!l)return{status:"error",message:`Missing required literal part: ${a.name}`};if(a.name!==l)return{status:"error",message:`Invalid path part: expected "${a.name}", got "${l}"`};i++}else if(a.type==="string-param"){const l=o[i];if(!l){if(a.optional)continue;return{status:"error",message:`Missing required parameter: ${a.paramName}`}}n[a.paramName]=l,i++}else if(a.type==="array-param"){const l=o.slice(i);if(l.length===0){if(a.optional)continue;return{status:"error",message:`Missing required catch-all parameter: ${a.paramName}`}}n[a.paramName]=l,i+=l.length}}return i<o.length?{status:"error",message:`Extra path parts found: ${o.slice(i).join("/")}`}:{status:"success",params:n}}function tA({routePattern:e,existingKeys:t,onSubmit:n,submitText:r,defaultParams:o,onCancel:i,defaultValue:s}){const[a,l]=g.useState({});g.useEffect(()=>{o&&l(o)},[o]);const[c,u]=g.useState({});g.useEffect(()=>{if(s){const m=sq(e,s);m.status==="success"&&l(m.params)}},[s,e]);const f=g.useMemo(()=>"/"+e.map(m=>{if(m.type==="string-param"||m.type==="array-param"){const v=a[m.paramName];return Array.isArray(v)?v.join("/"):v}return m.name}).join("/"),[e,a]),p=!g.useMemo(()=>e.every(m=>m.type==="string-param"||m.type==="array-param"?!!a[m.paramName]&&!c[m.paramName]:!0),[e,a,c])||f in t;return d.jsxs("form",{className:"p-4 space-y-3",onSubmit:m=>{m.preventDefault(),n(f)},children:[d.jsx("div",{className:"flex items-center",children:e.map((m,v)=>d.jsx("span",{className:"truncate",children:m.type==="string-param"||m.type==="array-param"?d.jsxs("span",{className:"flex items-center",children:[d.jsx("span",{children:"/"}),d.jsxs("span",{className:"flex flex-col",children:[d.jsx("input",{className:ue("p-1 bg-transparent border-0 max-w-[10ch]",{"border-border-secondary border-1":c[m.paramName]}),placeholder:m.paramName,value:aq(a,m.paramName),onChange:x=>{l({...a,[m.paramName]:x.target.value});const b=m.type==="string-param"?x.target.value:x.target.value.replace(/\//g,"");encodeURIComponent(b)!==b?u({...c,[m.paramName]:"Invalid characters"}):u({...c,[m.paramName]:void 0})}}),c[m.paramName]&&d.jsx("span",{className:"text-xs text-fg-error-secondary",children:c[m.paramName]})]})]}):d.jsxs("span",{className:"text-fg-secondary",children:["/",m.name]})},v))}),d.jsxs("div",{className:"flex gap-4",children:[d.jsx(Ge,{disabled:p,children:r}),d.jsx(Ge,{variant:"ghost",type:"reset",onClick:i,children:"Cancel"})]})]})}function aq(e,t){const n=e[t];return Array.isArray(n)?n.join("/"):n||""}function nA({path:e,size:t,variant:n,children:r,open:o,setOpen:i,defaultOpen:s,routePattern:a}){const l=lt(e,"record"),c=Ft(e),u=bn(),{addPatch:f}=wn(e),{navigate:h}=xn(),[p,m]=g.useState(s??!1);g.useEffect(()=>{o!==void 0&&m(o)},[o]),g.useEffect(()=>{i!==void 0&&i(p)},[p,i]),g.useEffect(()=>{s!==void 0&&m(s)},[s]);const v=g.useCallback(S=>{const C="data"in c?c.data:null;if(C===null||C.type!=="record")return;const N=Y.createPatchPath(w).concat(S);f([{op:"add",path:N,value:zl(C.item)}],"record"),h(Y.joinModuleFilePathAndModulePath(b,Y.patchPathToModulePath(N))),m(!1)},[f,h,c,e]);if(!("data"in l)||l.data===void 0||l.data===null)return console.error("Source not found",l,{path:e}),null;if(!("data"in c)||c.data===void 0)return console.error("Schema not found",l,{path:e}),null;if(c.data.type!=="record")return console.error("Schema is not a record",c,{path:e}),null;const[b,w]=Y.splitModuleFilePathAndModulePath(e);return d.jsxs(br,{open:p,onOpenChange:m,children:[d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(xo,{onClick:()=>{m(!0)},asChild:!0,children:d.jsx(Ge,{size:t,variant:n,children:r})})}),d.jsx(fr,{children:d.jsx("p",{children:"Add"})})]}),d.jsx(tr,{container:u,children:a?d.jsx(tA,{routePattern:a,existingKeys:Object.keys(l.data),onSubmit:v,onCancel:()=>{m(!1)},submitText:"Create"}):d.jsx(lq,{existingKeys:Object.keys(l.data),onSubmit:v})})]})}function lq({existingKeys:e,onSubmit:t}){const[n,r]=g.useState(""),o=n===""||n in e;return d.jsxs("form",{className:"flex flex-col gap-2",onSubmit:i=>{i.preventDefault(),t(n)},children:[d.jsx(ed,{autoFocus:!0,value:n,onChange:i=>{r(i.target.value)}}),d.jsx("div",{children:d.jsx(Ge,{type:"submit",disabled:o,variant:"outline",children:"Add"})})]})}function cq({existingKeys:e,defaultValue:t,onCancel:n,onSubmit:r}){const[o,i]=g.useState(t),s=o===t||o===""||o in e;return d.jsxs("form",{className:"flex flex-col gap-2",onSubmit:a=>{a.preventDefault(),r(o)},children:[d.jsx(ed,{type:"text",value:o,onChange:a=>{i(a.target.value)}}),d.jsxs("div",{className:"flex gap-2 items-center",children:[d.jsx(Ge,{disabled:s,variant:"outline",type:"submit",children:"Update"}),d.jsx(Ge,{variant:"ghost",type:"reset",onClick:()=>{n(),i(t)},children:"Cancel"})]})]})}function rA({defaultValue:e,path:t,parentPath:n,variant:r,existingKeys:o,routePattern:i,size:s,children:a,onComplete:l}){const{navigate:c}=xn(),[u,f]=g.useState(!1),h=bn();g.useEffect(()=>{const S=C=>{C.key==="Escape"&&f(!1)};return window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}},[]);const{addPatch:p,addModuleFilePatch:m}=wn(t),[v,x]=Y.splitModuleFilePathAndModulePath(n),b=Y.createPatchPath(x),w=g.useCallback(S=>{const C=[{op:"move",from:b.concat(e),path:b.concat(S)}];p(C,"record");for(const P of o){const[j,O]=Y.splitModuleFilePathAndModulePath(P),M=Y.createPatchPath(O);m(j,[{op:"replace",path:M,value:S}],"record")}const N=Y.joinModuleFilePathAndModulePath(v,Y.patchPathToModulePath(b.concat(S)));c(N,{replace:!0}),l&&l()},[p,m,v,b,c,l]);return d.jsxs(br,{open:u,children:[d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(Ge,{asChild:!0,size:s,variant:r,children:d.jsx(xo,{onClick:()=>{f(!0)},children:a})})}),d.jsx(fr,{side:"top",children:"Rename record"})]}),d.jsx(tr,{container:h,className:"text-fg-primary",children:i?d.jsx(tA,{routePattern:i,existingKeys:o,defaultValue:e,onSubmit:S=>{w(S),f(!1)},onCancel:()=>{f(!1)},submitText:"Update"}):d.jsx(cq,{parentPath:n,defaultValue:e,existingKeys:o,onSubmit:S=>{w(S),f(!1)},onCancel:()=>{f(!1)}})})]})}function uq({moduleFilePaths:e}){const t=o2(e,"record"),n=i2(),r=g.useMemo(()=>{const o=[];if(n.status!=="success")return n;if(n.data===null)return{status:"error",error:"No src folder found"};if(t.status!=="success")return t.status==="not-found"?{status:"error",error:"No data found"}:t.status==="error"?{status:"error",error:`Failed to load ${Object.keys(t.errors).length} modules: ${Object.entries(t.errors).map(([a,l])=>`"${a}": ${l.message}`).join(", ")}`}:t;for(const s of t.data||[])for(const a in s){const[l]=Y.splitModuleFilePathAndModulePath(s[a]);o.push({urlPath:a,moduleFilePath:l})}const i=U8(n.data,o);return{status:t.status,data:i}},[t,n]);return r.status==="loading"||r.status==="not-asked"?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(qr,{size:16,className:"animate-spin"})}):r.status==="error"?(console.error("Sitemap errors",r.error),null):d.jsx(oA,{node:r.data})}function oA({node:e}){var m;const t=bn(),{currentSourcePath:n}=xn(),[r,o]=g.useState(!0),{navigate:i}=xn(),[s,a]=g.useState(!1),[l,c]=g.useState(!1),u=g.useMemo(()=>e.sourcePath===n,[n,e.sourcePath]),f=g.useMemo(()=>{if(!e.pattern)return;const v=HM(e.pattern);if(v.some(x=>x.type==="string-param"||x.type==="array-param"))return v},[e.pattern]),h=g.useCallback(()=>{var v;e.sourcePath?i(e.sourcePath):e.type==="node"&&((v=e.children)==null?void 0:v.length)>0&&o(x=>!x)},[i,e]),p=e.moduleFilePath;return d.jsxs("div",{children:[d.jsxs("div",{className:"relative flex items-center justify-between w-full h-10 group",children:[d.jsxs("div",{className:"flex items-center my-1",children:[d.jsx("button",{onClick:()=>o(!r),className:ue("hidden h-4 w-4 mr-2",{block:((m=e.children)==null?void 0:m.length)>0}),children:d.jsx(Qu,{size:16,className:ue("transform",{"rotate-90":r})})}),d.jsx("span",{children:e.sourcePath?d.jsxs("button",{onClick:h,className:ue("flex items-center gap-1",{}),children:[e.type==="leaf"||e.type==="node"&&e.page?d.jsx(f2,{size:14}):null,d.jsxs("span",{className:ue({underline:u}),children:["/",e.name!=="/"&&e.name]})]}):d.jsxs("button",{onClick:h,className:ue("flex items-center gap-1",{}),children:[d.jsx(fK,{size:14}),d.jsx("span",{children:d.jsxs("span",{children:["/",e.name!=="/"&&e.name]})})]})})]}),d.jsxs("div",{className:ue("absolute right-0 top-0 items-center group-hover:flex h-10 bg-bg-primary",{hidden:!s&&!l,flex:s||l}),children:[e.sourcePath&&d.jsx(Ge,{size:"sm",variant:"ghost",onClick:h,className:"flex items-center gap-2",children:d.jsx(KS,{size:12})}),(e.sourcePath||e.type==="leaf"||e.page)&&d.jsxs(br,{onOpenChange:a,open:s,children:[d.jsx(xo,{asChild:!0,children:d.jsx(Ge,{size:"sm",variant:"ghost",children:d.jsx(HS,{size:12})})}),d.jsx(tr,{container:t,children:d.jsx(dq,{node:e,routePatternWithParams:f,onClose:()=>a(!1)})})]}),f&&p&&d.jsx(nA,{path:p,size:"sm",variant:"ghost",open:l,setOpen:c,routePattern:f,children:d.jsx(GS,{size:12})})]})]}),d.jsx(Cu,{isOpen:r,className:"pl-3",children:e.children.map((v,x)=>d.jsx(oA,{node:v},x))})]})}function dq({node:e,onClose:t,routePatternWithParams:n}){const r=g.useMemo(()=>{var s;return e.type==="leaf"?e.fullPath:(s=e.page)==null?void 0:s.fullPath},[e]),o=g.useMemo(()=>e.sourcePath?Y.splitModuleFilePathAndModulePath(e.sourcePath)[0]:void 0,[e==null?void 0:e.sourcePath]),i=Q2(o,r);return d.jsxs("div",{className:"flex flex-col items-start justify-center gap-2",children:[o&&e.sourcePath&&d.jsx(eA,{path:e.sourcePath,parentPath:o,refs:i,size:"sm",variant:"ghost",onComplete:t,confirmationMessage:`This will delete the ${r} page.`,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(qS,{size:14}),d.jsx("span",{children:"Delete"})]})}),r!==void 0&&e.sourcePath&&o&&d.jsx(rA,{variant:"ghost",size:"sm",existingKeys:i,path:e.sourcePath,defaultValue:r,routePattern:n,parentPath:o,onComplete:t,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(CK,{size:12}),d.jsx("span",{children:"Rename"})]})})]})}function fq(e){const t={"/":{name:"/",fullPath:"/",isDirectory:!0,children:[]}};for(const n of e){const r=n.split("/");if(r[0]!=="")throw new Error("Expected path to start with '/'");for(let o=1;o<r.length;o++){const i=r.slice(0,o).join("/"),s=[i,r[o]].join("/"),a=r[o];if(!a)throw new Error("Expected name to be non-empty");if(!t[s]){const l={name:a,fullPath:s,children:[]};o<r.length-1&&(l.isDirectory=!0),t[s]=l,t[i||"/"].children.push(t[s])}}}return t["/"]}function hq(){const e=Ha();return g.useMemo(()=>{if(e.status==="success"){const t=[],n={};for(const r in e.data){const o=r,i=e.data[o];i.type==="record"&&i.router?(n[i.router]=n[i.router]||[],n[i.router].push(o)):t.push(o)}return{status:e.status,data:{root:fq(t),sitemap:n}}}return e},[e])}const iA=1280;function pq(){const e=Yu(),[t,n]=g.useState(""),[r,o]=g.useState("");g.useEffect(()=>{async function w(){let S=!1;const C=async N=>{if(!S)try{(await fetch(N)).ok&&(S=!0,n(N))}catch{}};await C("/favicon.ico"),await C("/favicon.svg"),await C("/favicon.png"),await C("/apple-touch-icon.png"),await C("https://valbuild.com/favicon.ico")}if(w(),e!=null&&e.project)o(e.project);else try{let S=new URL(location.origin).hostname;if(S!=="localhost"){const C=S.split(".");C.length>=2&&(S=C.slice(1,-1).join(".")),o(kf(S))}else o("Dev mode")}catch{o("Studio")}},[JSON.stringify(e)]);const i=Ha(),s=bn(),{theme:a,setTheme:l}=cy(),{navMenu:c}=Qy(),u=hq(),f=(e==null?void 0:e.appHost)||Tb,[h,p]=r.split("/"),m=q7(),v=`${f}/manage-members/${h}`,b=`${`${f}/~/${h}`}/${p}`;return d.jsxs("nav",{className:"relative min-h-[100svh] bg-bg-primary",children:[d.jsxs("div",{className:"flex gap-4 justify-between items-center p-4 pr-6 h-16 border-b border-border-primary",children:[d.jsxs("div",{className:"flex gap-4 items-center",children:[t?d.jsx("img",{src:t,alt:"",className:"w-4 h-4"}):d.jsx("div",{className:"w-4 h-4"}),h&&p?d.jsx("a",{className:"truncate hover:underline",href:b,children:r}):d.jsx("span",{className:"truncate",children:r})]}),d.jsx("button",{className:"lg:hidden",onClick:()=>{c.setOpen(!c.isOpen)},children:d.jsx(Dg,{size:16,className:Ne("transform",{"rotate-180":!c.isOpen})})})]}),"data"in i&&d.jsx("div",{className:Ne("py-4 pl-2",{}),children:d.jsxs(hr,{children:[d.jsx("div",{className:"max-h-[calc(100svh-32px-64px-32px-16px)] max-w-[320px] px-2",children:"data"in u?d.jsxs(d.Fragment,{children:[d.jsx(gq,{title:"Site map",defaultOpen:!0,sitemap:u.data.sitemap}),d.jsx(mq,{title:"Explorer",defaultOpen:!0,node:u.data.root})]}):u.status==="loading"?d.jsx(vq,{}):null}),d.jsx(QS,{orientation:"horizontal"})]})}),d.jsx("div",{className:"p-4 h-6"}),d.jsx("div",{className:"absolute bottom-0 left-0 w-full",children:d.jsxs(br,{children:[d.jsxs(xo,{className:"flex items-center justify-between w-full p-4 border-t border-border-primary hover:bg-bg-secondary data-[state=open]:bg-bg-secondary",children:[d.jsx("span",{children:m&&d.jsx(YN,{size:"sm",profile:m})}),d.jsx(HS,{size:16})]}),d.jsx(tr,{className:"p-0 py-2",container:s,side:"top",children:d.jsxs("div",{className:"flex flex-col gap-2 justify-between items-center",children:[m&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex gap-2 items-center px-4 py-2 w-full",children:[d.jsx(YN,{size:"sm",profile:m}),d.jsxs("div",{className:"text-sm",children:[d.jsx("div",{className:"truncate",children:m.fullName}),m.email&&d.jsx("div",{className:"font-light truncate",children:m.email})]})]}),d.jsx("hr",{className:"mb-1 w-full h-1 border-t border-border-primary"})]}),d.jsxs("div",{className:"flex gap-2 items-center px-4 w-full",children:[a==="dark"?d.jsx(SK,{size:"1rem"}):d.jsx(OK,{size:"1rem"}),d.jsx("button",{className:"",onClick:()=>{l(a==="dark"?"light":"dark")},children:a==="dark"?d.jsx("span",{className:"text-sm",children:"Dark mode"}):d.jsx("span",{className:"text-sm",children:"Light mode"})})]}),m&&d.jsxs("div",{className:"flex gap-2 items-center px-4 w-full",children:[d.jsx(LK,{size:"1rem"}),d.jsx("a",{href:v,children:d.jsx("span",{className:"text-sm truncate",children:"Manage members"})})]}),m&&d.jsxs(d.Fragment,{children:[d.jsx("hr",{className:"mt-1 mb-1 w-full h-1 border-t border-border-primary"}),d.jsxs("div",{className:"flex gap-2 items-center px-4 w-full",children:[d.jsx(bK,{size:"1rem"}),d.jsx("a",{href:yu("/api/val/logout",{redirect_to:`${window.location.origin}`}),children:d.jsx("span",{className:"text-sm",children:"Log out"})})]})]})]})})]})})]})}function mq({title:e,defaultOpen:t,node:n}){return!n||(n==null?void 0:n.children.length)===0?null:d.jsx(sA,{icon:d.jsx(Lg,{size:16}),title:e,defaultOpen:t,children:n.children.sort(aA).map((r,o)=>g.createElement(lA,{...r,name:r.name,key:o,root:!0}))})}function sA({title:e,children:t,defaultOpen:n,icon:r}){const[o,i]=g.useState(n??!0);return d.jsxs("div",{className:"py-2",children:[d.jsxs("button",{className:"flex justify-between items-center py-2 w-full text-sm tracking-tighter uppercase text-fg-secondary",onClick:()=>{i(!o)},children:[d.jsxs("div",{className:"flex gap-2 items-center",children:[r,e]}),d.jsx(Qu,{size:16,className:Ne("transform",{"rotate-90":o})})]}),d.jsx(Cu,{isOpen:o,className:"pr-1",children:t})]})}function gq({title:e,defaultOpen:t,sitemap:n}){const r=n["next-app-router"];return r?d.jsx(sA,{title:e,defaultOpen:t,icon:d.jsx(Ig,{size:16}),children:d.jsx(uq,{moduleFilePaths:r})}):null}function vq(){return d.jsx("div",{className:"flex justify-start items-center w-full h-full",children:d.jsx(qr,{size:16,className:"animate-spin"})})}function aA(e,t){return e.isDirectory&&!t.isDirectory?-1:!e.isDirectory&&t.isDirectory?1:e.name.localeCompare(t.name)}function lA({name:e,fullPath:t,isDirectory:n,children:r,root:o}){const{navigate:i,currentSourcePath:s}=xn(),{navMenu:a}=Qy(),[l,c]=g.useState(!0),u=tc()||{},f=g.useMemo(()=>{let x=!1;for(const b in u)if(b.startsWith(t)){x=!0;break}return x},[u,t]),h=g.useMemo(()=>{if(n){if(!l)return f}else if(!n)return f;return!1},[f,l,n]),p=t,m=Ft(p),v="data"in m?m.data.type:"loading";return d.jsxs("div",{className:"w-full text-sm",children:[d.jsxs("button",{className:Ne("relative flex items-center justify-between w-full ",{"py-2":o,"p-2":!o,underline:s.startsWith(p)&&!n,"font-bold":s.startsWith(p)&&n}),onClick:()=>{n?c(!l):(window.innerWidth<iA&&a.setOpen(!1),i(p))},children:[d.jsxs("div",{className:"flex items-center pr-2",children:[n?d.jsx(Qu,{size:16,className:Ne("transform mr-2",{"rotate-90":l,hidden:!r.length})}):d.jsx(yq,{type:v,size:14}),d.jsx("span",{children:Nu(e)})]}),h&&d.jsx("div",{className:"ml-2 w-2 h-2 rounded-full bg-bg-error-secondary"})]}),d.jsx("div",{className:"pl-2",children:d.jsx(Cu,{isOpen:l,children:r.sort(aA).map((x,b)=>g.createElement(lA,{...x,key:b}))})})]})}function yq({size:e,type:t}){if(t==="loading")return d.jsx(qr,{size:e,className:"mr-2 animate-spin"});switch(t){case"string":return d.jsx(IK,{size:e,className:"mr-2"});case"number":return d.jsx(pK,{size:e,className:"mr-2"});case"boolean":return d.jsx(RK,{size:e,className:"mr-2"});case"object":return d.jsx(vK,{size:e,className:"mr-2"});case"literal":return d.jsx(aK,{size:e,className:"mr-2"});case"array":return d.jsx(m2,{size:e,className:"mr-2"});case"union":return d.jsx(NK,{size:e,className:"mr-2"});case"richtext":return d.jsx(f2,{size:e,className:"mr-2"});case"record":return d.jsx(MK,{size:e,className:"mr-2"});case"keyOf":return d.jsx(gK,{size:e,className:"mr-2"});case"file":return d.jsx(h2,{size:e,className:"mr-2"});case"date":return d.jsx(u2,{size:e,className:"mr-2"});case"image":return d.jsx(p2,{size:e,className:"mr-2"});default:return d.jsx(iK,{size:e,className:"mr-2"})}}function nk(e){const t=g.useRef({value:e,previous:e});return g.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var rk="Checkbox",[xq,Ege]=So(rk),[bq,wq]=xq(rk),cA=g.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=g.useState(null),m=Ve(t,C=>p(C)),v=g.useRef(!1),x=h?u||!!h.closest("form"):!0,[b=!1,w]=Gr({prop:o,defaultProp:i,onChange:c}),S=g.useRef(b);return g.useEffect(()=>{const C=h==null?void 0:h.form;if(C){const N=()=>w(S.current);return C.addEventListener("reset",N),()=>C.removeEventListener("reset",N)}},[h,w]),d.jsxs(bq,{scope:n,state:b,disabled:a,children:[d.jsx(Oe.button,{type:"button",role:"checkbox","aria-checked":ga(b)?"mixed":b,"aria-required":s,"data-state":fA(b),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:m,onKeyDown:te(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:te(e.onClick,C=>{w(N=>ga(N)?!0:!N),x&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})}),x&&d.jsx(Sq,{control:h,bubbles:!v.current,name:r,value:l,checked:b,required:s,disabled:a,form:u,style:{transform:"translateX(-100%)"},defaultChecked:ga(i)?!1:i})]})});cA.displayName=rk;var uA="CheckboxIndicator",dA=g.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...o}=e,i=wq(uA,n);return d.jsx(ln,{present:r||ga(i.state)||i.state===!0,children:d.jsx(Oe.span,{"data-state":fA(i.state),"data-disabled":i.disabled?"":void 0,...o,ref:t,style:{pointerEvents:"none",...e.style}})})});dA.displayName=uA;var Sq=e=>{const{control:t,checked:n,bubbles:r=!0,defaultChecked:o,...i}=e,s=g.useRef(null),a=nk(n),l=_S(t);g.useEffect(()=>{const u=s.current,f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(a!==n&&p){const m=new Event("click",{bubbles:r});u.indeterminate=ga(n),p.call(u,ga(n)?!1:n),u.dispatchEvent(m)}},[a,n,r]);const c=g.useRef(ga(n)?!1:n);return d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??c.current,...i,tabIndex:-1,ref:s,style:{...e.style,...l,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function ga(e){return e==="indeterminate"}function fA(e){return ga(e)?"indeterminate":e?"checked":"unchecked"}var hA=cA,kq=dA;const td=g.forwardRef(({className:e,...t},n)=>{const[r,o]=g.useState();return g.useEffect(()=>{o(t.checked)},[t.checked]),d.jsx(hA,{ref:n,checked:r,onCheckedChange:i=>{o(i),t.onCheckedChange&&t.onCheckedChange(i)},className:ue("peer h-4 w-4 shrink-0 rounded-sm bg-bg-primary border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 data-[state=checked]:bg-bg-primary data-[state=checked]:text-fg-primary",e),...t,children:d.jsxs(kq,{className:ue("flex items-center justify-center text-current"),children:[r===!0&&d.jsx(Xu,{size:12}),r==="indeterminate"&&d.jsx(wK,{size:12})]})})});td.displayName=hA.displayName;function Om(e,t){const n=new Date(t).getTime(),r=e.getTime(),o=Math.floor((r-n)/1e3),i=Math.floor(o/60),s=Math.floor(o/3600),a=Math.floor(o/86400),l=Math.floor(a/30);return o<60?"just now":i<60?`${i}m ago`:s<24?`${s}h ago`:a===1?"yesterday":a<30?`${a}d ago`:`${l}mo ago`}function pA({onPublish:e,onClose:t}){const[n,r]=g.useState(null),o=ap(),{summary:i,canGenerate:s,setSummary:a,publishDisabled:l,generateSummary:c}=lp(),[u,f]=g.useState(!1),h=()=>{f(!1),i.type!=="not-asked"&&a({...i})};g.useEffect(()=>{i.type!=="not-asked"&&!i.isGenerating&&!wu(i.patchIds,o)&&f(!0)},[i,o]);const p=g.useCallback(()=>{h(),c().then(x=>{x.type==="ai"?a({type:"ai",text:x.text.trim()}):r(x.message)})},[h,c,a,r]),m="w-full p-2 border rounded bg-bg-secondary",v="text"in i?i.text:"";return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex items-center justify-between w-full gap-2",children:[d.jsx("span",{className:"font-semibold",children:"Summary"}),s&&d.jsx(eP,{onClick:p,isGenerating:i.isGenerating})]}),n&&d.jsx("div",{className:"p-4 rounded bg-bg-error-primary text-fg-error-primary",children:n}),d.jsxs("div",{className:"grid text-xs font-light",children:[d.jsx("div",{"aria-hidden":!0,className:ue(m,"invisible whitespace-pre-wrap"),style:{gridArea:"1 / 1 / 2 / 2"},children:v+" "}),d.jsx("textarea",{disabled:!!i.isGenerating,className:ue(m,"resize-none overflow-clip disabled:opacity-50"),value:v,style:{gridArea:"1 / 1 / 2 / 2"},placeholder:"Write a summary of your changes"+(s?" or generate one using AI":""),onChange:x=>{h(),a({type:"manual",text:x.currentTarget.value})}})]}),d.jsxs("div",{className:ue("p-2 text-xs flex-grow font-light bg-bg-warning-primary text-[black] rounded flex items-center","flex justify-between w-full gap-2 py-2",{hidden:!u}),"aria-hidden":u,children:[d.jsx("span",{children:"Summary might be outdated. "}),d.jsx("button",{className:"underline",onClick:h,children:"Dismiss"})]}),d.jsx("div",{className:"flex items-center justify-end gap-2",children:e?d.jsxs(d.Fragment,{children:[d.jsx(Ge,{variant:"outline",onClick:()=>{t()},children:"Close"}),u&&s&&d.jsx(eP,{isGenerating:i.isGenerating,onClick:p}),!u&&d.jsxs(Ge,{disabled:l||v.trim()==="",onClick:()=>{i.type!=="not-asked"&&e()},variant:"default",className:"flex items-center gap-2",children:[d.jsxs("span",{children:[" ",l?"Pushing...":"Publish"]}),d.jsx(Fg,{size:16})]})]}):d.jsx(d.Fragment,{children:d.jsx(Ge,{variant:"outline",onClick:()=>{t()},children:"Close"})})})]})}function eP({isGenerating:e,onClick:t}){return d.jsx(Ge,{className:"truncate",disabled:!!e,onClick:()=>{t()},variant:"outline",children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx("span",{children:e?"Generating...":"Generate"}),d.jsx(g2,{size:16})]})})}function Eq(e,t=[]){let n=[];function r(i,s){const a=g.createContext(s),l=n.length;n=[...n,s];function c(f){const{scope:h,children:p,...m}=f,v=(h==null?void 0:h[e][l])||a,x=g.useMemo(()=>m,Object.values(m));return d.jsx(v.Provider,{value:x,children:p})}function u(f,h){const p=(h==null?void 0:h[e][l])||a,m=g.useContext(p);if(m)return m;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>g.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,Cq(o,...t)]}function Cq(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function gy(e){const t=e+"CollectionProvider",[n,r]=Eq(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:m,children:v}=p,x=Ce.useRef(null),b=Ce.useRef(new Map).current;return d.jsx(o,{scope:m,itemMap:b,collectionRef:x,children:v})};s.displayName=t;const a=e+"CollectionSlot",l=Ce.forwardRef((p,m)=>{const{scope:v,children:x}=p,b=i(a,v),w=Ve(m,b.collectionRef);return d.jsx(ds,{ref:w,children:x})});l.displayName=a;const c=e+"CollectionItemSlot",u="data-radix-collection-item",f=Ce.forwardRef((p,m)=>{const{scope:v,children:x,...b}=p,w=Ce.useRef(null),S=Ve(m,w),C=i(c,v);return Ce.useEffect(()=>(C.itemMap.set(w,{ref:w,...b}),()=>void C.itemMap.delete(w))),d.jsx(ds,{[u]:"",ref:S,children:x})});f.displayName=c;function h(p){const m=i(e+"CollectionConsumer",p);return Ce.useCallback(()=>{const x=m.collectionRef.current;if(!x)return[];const b=Array.from(x.querySelectorAll(`[${u}]`));return Array.from(m.itemMap.values()).sort((C,N)=>b.indexOf(C.ref.current)-b.indexOf(N.ref.current))},[m.collectionRef,m.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},h,r]}var ok="Collapsible",[Nq,mA]=So(ok),[Pq,ik]=Nq(ok),gA=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:s,...a}=e,[l=!1,c]=Gr({prop:r,defaultProp:o,onChange:s});return d.jsx(Pq,{scope:n,disabled:i,contentId:Ur(),open:l,onOpenToggle:g.useCallback(()=>c(u=>!u),[c]),children:d.jsx(Oe.div,{"data-state":ak(l),"data-disabled":i?"":void 0,...a,ref:t})})});gA.displayName=ok;var vA="CollapsibleTrigger",yA=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=ik(vA,n);return d.jsx(Oe.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ak(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:te(e.onClick,o.onOpenToggle)})});yA.displayName=vA;var sk="CollapsibleContent",xA=g.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ik(sk,e.__scopeCollapsible);return d.jsx(ln,{present:n||o.open,children:({present:i})=>d.jsx(jq,{...r,ref:t,present:i})})});xA.displayName=sk;var jq=g.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,s=ik(sk,n),[a,l]=g.useState(r),c=g.useRef(null),u=Ve(t,c),f=g.useRef(0),h=f.current,p=g.useRef(0),m=p.current,v=s.open||a,x=g.useRef(v),b=g.useRef();return g.useEffect(()=>{const w=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(w)},[]),Mn(()=>{const w=c.current;if(w){b.current=b.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const S=w.getBoundingClientRect();f.current=S.height,p.current=S.width,x.current||(w.style.transitionDuration=b.current.transitionDuration,w.style.animationName=b.current.animationName),l(r)}},[s.open,r]),d.jsx(Oe.div,{"data-state":ak(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!v,...i,ref:u,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...e.style},children:v&&o})});function ak(e){return e?"open":"closed"}var _q=gA,Tq=yA,Oq=xA,xs="Accordion",Mq=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[lk,Rq,Aq]=gy(xs),[vy,Cge]=So(xs,[Aq,mA]),ck=mA(),bA=Ce.forwardRef((e,t)=>{const{type:n,...r}=e,o=r,i=r;return d.jsx(lk.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?d.jsx(Fq,{...i,ref:t}):d.jsx(Lq,{...o,ref:t})})});bA.displayName=xs;var[wA,Iq]=vy(xs),[SA,Dq]=vy(xs,{collapsible:!1}),Lq=Ce.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},collapsible:i=!1,...s}=e,[a,l]=Gr({prop:n,defaultProp:r,onChange:o});return d.jsx(wA,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:Ce.useCallback(()=>i&&l(""),[i,l]),children:d.jsx(SA,{scope:e.__scopeAccordion,collapsible:i,children:d.jsx(kA,{...s,ref:t})})})}),Fq=Ce.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:o=()=>{},...i}=e,[s=[],a]=Gr({prop:n,defaultProp:r,onChange:o}),l=Ce.useCallback(u=>a((f=[])=>[...f,u]),[a]),c=Ce.useCallback(u=>a((f=[])=>f.filter(h=>h!==u)),[a]);return d.jsx(wA,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c,children:d.jsx(SA,{scope:e.__scopeAccordion,collapsible:!0,children:d.jsx(kA,{...i,ref:t})})})}),[zq,yy]=vy(xs),kA=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:o,orientation:i="vertical",...s}=e,a=Ce.useRef(null),l=Ve(a,t),c=Rq(n),f=cp(o)==="ltr",h=te(e.onKeyDown,p=>{var O;if(!Mq.includes(p.key))return;const m=p.target,v=c().filter(M=>{var D;return!((D=M.ref.current)!=null&&D.disabled)}),x=v.findIndex(M=>M.ref.current===m),b=v.length;if(x===-1)return;p.preventDefault();let w=x;const S=0,C=b-1,N=()=>{w=x+1,w>C&&(w=S)},P=()=>{w=x-1,w<S&&(w=C)};switch(p.key){case"Home":w=S;break;case"End":w=C;break;case"ArrowRight":i==="horizontal"&&(f?N():P());break;case"ArrowDown":i==="vertical"&&N();break;case"ArrowLeft":i==="horizontal"&&(f?P():N());break;case"ArrowUp":i==="vertical"&&P();break}const j=w%b;(O=v[j].ref.current)==null||O.focus()});return d.jsx(zq,{scope:n,disabled:r,direction:o,orientation:i,children:d.jsx(lk.Slot,{scope:n,children:d.jsx(Oe.div,{...s,"data-orientation":i,ref:l,onKeyDown:r?void 0:h})})})}),Vg="AccordionItem",[$q,uk]=vy(Vg),dk=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...o}=e,i=yy(Vg,n),s=Iq(Vg,n),a=ck(n),l=Ur(),c=r&&s.value.includes(r)||!1,u=i.disabled||e.disabled;return d.jsx($q,{scope:n,open:c,disabled:u,triggerId:l,children:d.jsx(_q,{"data-orientation":i.orientation,"data-state":PA(c),...a,...o,ref:t,disabled:u,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})})});dk.displayName=Vg;var EA="AccordionHeader",CA=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=yy(xs,n),i=uk(EA,n);return d.jsx(Oe.h3,{"data-orientation":o.orientation,"data-state":PA(i.open),"data-disabled":i.disabled?"":void 0,...r,ref:t})});CA.displayName=EA;var Qb="AccordionTrigger",fk=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=yy(xs,n),i=uk(Qb,n),s=Dq(Qb,n),a=ck(n);return d.jsx(lk.ItemSlot,{scope:n,children:d.jsx(Tq,{"aria-disabled":i.open&&!s.collapsible||void 0,"data-orientation":o.orientation,id:i.triggerId,...a,...r,ref:t})})});fk.displayName=Qb;var NA="AccordionContent",hk=Ce.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,o=yy(xs,n),i=uk(NA,n),s=ck(n);return d.jsx(Oq,{role:"region","aria-labelledby":i.triggerId,"data-orientation":o.orientation,...s,...r,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});hk.displayName=NA;function PA(e){return e?"open":"closed"}var jA=bA,Bq=dk,Vq=CA,_A=fk,TA=hk;const Ra=jA,Ei=g.forwardRef(({className:e,...t},n)=>d.jsx(Bq,{ref:n,className:ue("border-b",e),...t}));Ei.displayName="AccordionItem";const ps=g.forwardRef(({className:e,children:t,...n},r)=>d.jsx(Vq,{className:"flex",children:d.jsxs(_A,{ref:r,className:ue("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,d.jsx(Zu,{className:"w-4 h-4 transition-transform duration-200 shrink-0"})]})}));ps.displayName=_A.displayName;const Ci=g.forwardRef(({className:e,children:t,...n},r)=>d.jsx(TA,{ref:r,className:ue("overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",e),...n,children:d.jsx("div",{className:"pt-0 pb-4",children:t})}));Ci.displayName=TA.displayName;function OA(e,t,n){if(e.length===0)return{success:!1,error:"Empty path"};let r=-1,o="";const i=c=>{o===""?o=c:o+="."+c};if(t===void 0)return{success:!1,error:`Undefined schema in: '${e.join("/")}'.`};if(n===void 0)return{success:!1,error:`Undefined source in: '${e.join("/")}'.`};let s=t,a=n;const l=[{modulePath:o,schema:s,source:a}];for(const c of e){if(r++,c==="")return{success:!1,error:`Empty path part in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(s.type==="array"){s=s.item;const u=Number(c);if(!Number.isSafeInteger(u))return{success:!1,error:`Invalid array index in: '${e.join("/")}'. Expected an integer but got '${c}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(typeof a!="object")return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got '${typeof a}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(a===null)return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got 'null' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(a===void 0)return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an object but got 'undefined' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(!Array.isArray(a))return{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an array but got '${typeof a}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};if(!a[u])return{success:!1,error:`Invalid array index in: '${e.join("/")}'. Expected an index less than ${a.length} but got '${u}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};a=a[u],i(c)}else if(s.type==="record"){s=s.item;const u=sm(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else if(s.type==="object"){s=s.items[c];const u=sm(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else if(s.type==="union"){const u=typeof s.key=="object"&&s.key.type==="literal"?s:void 0,f=typeof s.key=="string"?s:void 0;if(u)return{success:!1,error:"Invalid lookup in string union"};if(f){const h=sm(e,c,r,a,"union object");if(!h.success)return{success:!1,error:h.error};const p=h.source;let m;for(const v of f.items){const x=v.items[f.key];if(x.type==="literal"){if(p[f.key]===x.value){m=v;break}}else return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`}}if(!m)return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`};s=m.items[c],a=p[c],i(JSON.stringify(c))}else return{success:!1,error:`Invalid lookup in union: unknown union type in: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")})`}}else if(s.type==="image"||s.type==="file"){const u=sm(e,c,r,a,"record");if(!u.success)return{success:!1,error:u.error};a=u.source[c],i(JSON.stringify(c))}else return{success:!1,error:`Cannot construct sub-path in schema of '${s.type}' in: '${e.join("/")}'. Path was: '${e.join("/")}' at part ${r} (sliced: ${e.slice(0,r+1).join("/")}`};l.push({modulePath:o,schema:s,source:a})}return{success:!0,modulePath:o,schema:s,source:a,allResolved:l}}function sm(e,t,n,r,o){return typeof r!="object"?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got '${typeof r}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:r===null?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'null' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:r===void 0?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'undefined' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:typeof r!="object"?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got '${typeof r}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:Array.isArray(r)?{success:!1,error:`Invalid source type in: '${e.join("/")}'. Expected an '${o}' but got 'array' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}:t in r?{success:!0,source:r}:{success:!1,error:`Could not find key of source: '${e.join("/")}'. Expected a key in ${Object.keys(r).join(", ")} but got '${t}' at part ${n} (sliced: ${e.slice(0,n+1).join("/")})`}}function Uq(e,t){return(t==null?void 0:t.type)==="array"?e.type!=="string":(t==null?void 0:t.type)==="record"}function MA(e,t,n){if(!n)return null;const[r,o]=Y.splitModuleFilePathAndModulePath(e);if(!o)return r;const i=t[r],s=n[r];if(i===void 0||!s)return null;const a=OA(Y.splitModulePath(o),s,i);if(a.success){for(let l=a.allResolved.length-1;l>=0;l--){const c=a.allResolved[l],u=a.allResolved[l-1];if(Uq(c.schema,(u==null?void 0:u.schema)||null))return c.modulePath===""?r:Y.joinModuleFilePathAndModulePath(r,c.modulePath)}return r}else console.error(`Error resolving path: ${a.error} for path: ${e}`);return null}function hp({moduleFilePath:e,patchPath:t,className:n,toolTip:r=!0,link:o=!0}){const i=Yu(),s=g.useRef(null),a=g.useRef(new Map),[l,c]=g.useState([]),[u,f]=g.useState(),h=US(),p=Ha(),{navigate:m}=xn();g.useEffect(()=>{const x=e?Y.splitModuleFilePath(e):[],b=t,w=()=>{if(!s.current)return;const C=s.current,N=getComputedStyle(C),P=`${N.fontSize} ${N.fontFamily}`,j=C.offsetWidth,O=x.map(Wq).concat(b).map(H=>`/${H}`);f(O.join(""));const M=H=>{const V=`${H}:${P}`,I=a.current.get(V)??Hq(H,P);return a.current.set(V,I),I},D="/…",U=M(D),z=[];let K=0;for(let H=O.length-1;H>=0;H--){const V=M(O[H]),A=!(H===0);if(K+V+(A?U:0)<=j){const _=H>x.length?"module-path":"module-file-path";z.unshift({text:O[H],type:_,moduleFilePath:e,modulePathSegments:b.slice(0,H)}),K+=V}else{z.unshift({type:"ellipsis",text:D});break}}c(z)},S=new ResizeObserver(w);return s.current&&(S.observe(s.current),w()),()=>{s.current&&S.unobserve(s.current)}},[e,t]);const v=g.useMemo(()=>{if(!o)return null;const x="data"in p?p.data:{};if(t.length===0){const w=e;return{navPath:w,sourcePath:w}}const b=OA(t,x[e],h[e]);if(b.success){const w=Y.joinModuleFilePathAndModulePath(e,b.modulePath),S=MA(w,h,x);if(S)return{navPath:S,scrollToId:w};console.debug(`Failed to resolve nav path for ${e} and ${t.join(".")}: ${S}`)}else console.debug(`Failed to resolve source path for ${e} and ${t.join(".")}: ${b.error}`);return null},[e,t,h,p]);return d.jsxs($r,{open:r===!1?!1:void 0,children:[d.jsx(AS,{asChild:!0,children:d.jsx("a",{href:v&&i?`${i.studioPrefix}${v.navPath}#${v.scrollToId}`:void 0,ref:s,className:Ne("inline-block whitespace-nowrap overflow-hidden w-full align-baseline",{"cursor-pointer hover:underline":o},n),onClick:x=>{o&&v&&x.metaKey===!1&&x.ctrlKey===!1&&x.shiftKey===!1&&(x.preventDefault(),m(v.navPath,{scrollToId:v.scrollToId}))},children:l.map((x,b)=>d.jsx("span",{children:x.text},b))})}),d.jsx(fr,{side:"top",children:d.jsx(hr,{orientation:"horizontal",className:"max-w-[calc(100vw-3rem)] whitespace-nowrap",children:u})})]})}function Wq(e){const t=Nu(e);return t.slice(0,1).toUpperCase()+t.slice(1)}function Hq(e,t){const r=document.createElement("canvas").getContext("2d");return r?(r.font=t,r.measureText(e).width):0}function RA({className:e,loadingStatus:t}){const n=ap(),r=Ju(),o=U7(),i=V7(),s=bn(),[a,l]=g.useState(!1),{canGenerate:c}=lp(),u=tc(),{autoPublish:f}=zS(),h=g.useMemo(()=>{var D;let M=0;for(const U in u)M+=((D=u[U])==null?void 0:D.length)||0;return M},[u]),p=n.length-o.size,{deployments:m,dismissDeployment:v,observedCommitShas:x}=B7(),{globalTransientErrors:b,removeGlobalTransientErrors:w}=Y7(),{patchErrors:S}=r2(),[C,N]=g.useState(new Date);g.useEffect(()=>{const M=setInterval(()=>{N(new Date)},6e4);return()=>{clearInterval(M)}},[]);const{deletePatches:P}=QR(),j=L7(),O=async(M,D,U)=>{const z=await j("/patches","GET",{query:{patch_id:[D],exclude_patch_ops:!1}});if(z.status===200){const K=z.json,H=`val-patch-error-report-${M.replace("/","__").replace(/\.val\./,"-")}-${D}.json`,V=new Blob([JSON.stringify({moduleFilePath:M,patchId:D,error:U,patch:K},null,2)],{type:"application/json"}),I=document.createElement("a");I.href=URL.createObjectURL(V),I.download=H,I.click()}else alert("Failed to download report")};return d.jsxs("div",{className:Ne("text-sm",e),children:[S&&Object.values(S).some(M=>M!==null)&&d.jsx("div",{className:"sticky top-0 border-b border-border-primary bg-bg-error-primary text-fg-error-primary z-5",children:d.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[d.jsxs("div",{className:"px-4 text-pretty",children:[d.jsx("div",{children:"Unfortunately, one or more changes have errors."}),d.jsx("div",{children:"No changes can currently be applied."})]}),Object.entries(S).map(([M,D],U)=>d.jsx("div",{className:"pb-4",children:d.jsx(hr,{orientation:"horizontal",className:"max-w-[280px] text-pretty text-xs",children:D&&Object.entries(D).map(([z,K],H)=>d.jsx(jA,{className:"grid grid-cols-2 gap-2",type:"single",collapsible:!0,children:d.jsxs(dk,{value:z,children:[d.jsx("div",{children:d.jsx(Ge,{variant:"destructive",onClick:()=>{P([z])},children:d.jsx("span",{className:"flex gap-2 justify-between items-center text-left",children:d.jsx("span",{children:"Remove change and fix issue"})})})}),d.jsx(fk,{asChild:!0,className:"group",children:d.jsxs(Ge,{variant:"destructive",children:[d.jsx("span",{className:"text-left truncate group-data-[state=open]:hidden",children:"Report"}),d.jsx("span",{className:"text-left truncate group-data-[state=open]:block hidden",children:"Hide"})]})}),d.jsxs(hk,{children:[d.jsx(Ge,{variant:"destructive",onClick:()=>{O(M,z,K.message)},children:d.jsxs("span",{className:"flex gap-2 justify-between items-center text-left",children:[d.jsx("span",{children:"Download debug report"}),d.jsx(lK,{size:14})]})}),d.jsxs("div",{className:"p-4",children:[d.jsx("div",{className:"font-bold",children:"Details"}),d.jsx("div",{children:"Module file path"}),d.jsx("div",{children:d.jsx(tP,{sourcePath:M})}),d.jsx("div",{children:"Error message"}),d.jsx("pre",{children:K.message})]})]})]})},H))})},M+"#"+U))]})}),u&&h>0&&d.jsx("div",{className:"sticky top-0 border-b border-border-primary bg-bg-error-primary text-fg-error-primary z-5",children:d.jsx(hr,{orientation:"horizontal",children:d.jsx(Ra,{type:"single",className:"px-4 font-serif",collapsible:!0,children:d.jsxs(Ei,{value:"error",className:"border-b-0",children:[d.jsx(ps,{className:" data-[state=open]:mb-4 text-fg-error-primary border-fg-error-primary ",children:d.jsxs("div",{className:"flex justify-between items-center w-full",children:[d.jsxs("div",{children:[h," validation issue",h>1?"s":""]}),d.jsx(Eu,{size:16})]})}),d.jsx(Ci,{className:"",children:d.jsx("div",{className:"flex flex-col gap-4",children:Object.entries(u).map(([M,D],U)=>d.jsxs("div",{className:"pb-4",children:[d.jsx("div",{className:"items-start text-left",children:d.jsx(tP,{sourcePath:M})}),d.jsx("div",{children:d.jsx(hr,{orientation:"horizontal",className:"max-w-[280px] text-pretty text-xs",children:D==null?void 0:D.map((z,K)=>d.jsx("div",{className:"",children:d.jsx("div",{children:z.message})},K))})})]},M+"#"+U))})})]})})})}),b&&b.length>0&&d.jsx("div",{className:"sticky top-0 border-b border-border-primary bg-bg-error-primary text-fg-error-primary z-5",children:d.jsx(hr,{orientation:"horizontal",children:d.jsx(Ra,{type:"single",className:"px-4 font-serif",collapsible:!0,children:d.jsxs(Ei,{value:"error",className:"border-b-0 data-[state=open]:mb-4",children:[d.jsxs(ps,{children:[b.length," transient error",b.length>1?"s":""]}),d.jsx(Ci,{className:"w-full",children:d.jsx("div",{className:"flex flex-col gap-2",children:b.map(M=>d.jsxs("div",{className:"flex gap-2 justify-between items-start",children:[d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("div",{className:"font-bold",children:M.message}),M.details&&d.jsx("div",{children:M.details}),d.jsx("div",{className:"text-[10px] font-thin",children:Om(C,new Date(M.timestamp).toISOString())})]}),d.jsx("button",{onClick:()=>w([M.id]),children:d.jsx(Ll,{size:14})})]},M.id))})})]})})})}),m.length>0&&d.jsx("div",{className:"p-4 border-b border-border-primary",children:d.jsx(Kq,{deployments:m,observedCommitShas:x,onDismiss:v})}),r==="http"&&d.jsx("div",{className:"flex justify-end items-center p-4 border-b z-5 border-border-primary",children:d.jsxs(br,{open:a,onOpenChange:M=>{l(M)},children:[d.jsx(xo,{asChild:!0,children:d.jsxs(Ge,{variant:"secondary",className:"flex gap-2 items-center text-sm",children:[d.jsx("span",{children:"Summary"}),c&&d.jsx(g2,{size:14})]})}),d.jsxs(tr,{container:s,align:"end",className:"z-[9001] flex flex-col gap-4",children:[d.jsx(Fl,{asChild:!0,className:"self-end cursor-pointer",children:d.jsx(Ll,{size:12})}),d.jsx(pA,{onClose:()=>{l(!1)}})]})]})}),d.jsx("div",{className:"p-4 z-5",children:d.jsxs("div",{className:"flex justify-between items-center",children:[d.jsxs("div",{className:"flex gap-2 items-center",children:[d.jsxs("div",{className:"font-bold",children:[p<=0?"No ":`${p} `,"pending change",p===1?"":"s"]}),(t==="loading"||t==="not-asked")&&d.jsx("div",{className:"",children:d.jsx(qr,{size:16,className:"animate-spin"})})]}),d.jsxs(br,{children:[d.jsx(xo,{asChild:!0,children:d.jsxs(Ge,{disabled:n.length===0,variant:"secondary",className:"flex gap-2 items-center text-sm",children:[d.jsx("span",{children:"Undo all"}),d.jsx(Yb,{size:14})]})}),d.jsx(tr,{container:s,className:"z-[9001]",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("div",{className:"text-lg font-bold",children:"Are you sure?"}),d.jsx("div",{children:"This will undo all changes to the current state."}),d.jsx("div",{children:d.jsx(Fl,{asChild:!0,children:d.jsxs(Ge,{variant:"destructive",className:"flex gap-2 items-center text-sm",onClick:()=>{P(n)},children:[d.jsx("span",{children:"Undo all changes"}),d.jsx(Yb,{size:14})]})})})]})})]})]})}),(!f||h>0)&&d.jsx("div",{className:"flex flex-col gap-[2px]",children:"data"in i&&n.length>0&&i.data.map(M=>d.jsx(Jq,{committedPatchIds:o,patchSet:M,patchErrors:(S==null?void 0:S[M.moduleFilePath])??{}},M.moduleFilePath+":"+M.patchPath.join("/")))})]})}function tP({sourcePath:e}){const[t,n]=Y.splitModuleFilePathAndModulePath(e),r=Y.splitModulePath(n);return d.jsx(hp,{moduleFilePath:t,patchPath:r})}function Kq({deployments:e,observedCommitShas:t,onDismiss:n}){return g.useEffect(()=>{for(const r of e)t.has(r.commitSha)&&setTimeout(()=>{n(r.commitSha)},5e3)},[e,t]),d.jsxs("div",{children:[d.jsxs("div",{className:"flex justify-between items-center p-2 font-bold",children:[d.jsx("span",{children:"Deployments"}),d.jsx(qr,{size:16,className:"inline animate-spin"})]}),d.jsx("div",{children:e.reverse().map(r=>d.jsx(Gq,{deployment:r,isFinished:t.has(r.commitSha),onDismiss:()=>{n(r.commitSha)}},r.commitSha))})]})}function Gq({deployment:e,isFinished:t,onDismiss:n}){var s;const r=VS(),o=bn(),i=e.creator&&r[e.creator];return d.jsxs("div",{className:"flex justify-between items-start p-2",children:[d.jsxs("div",{className:"flex gap-2 items-start",children:[i&&d.jsx("img",{src:(s=i.avatar)==null?void 0:s.url,alt:i.fullName,className:"w-8 h-8 rounded-full"}),d.jsxs($r,{children:[d.jsx(zR,{container:o}),d.jsx(ho,{children:d.jsx("div",{className:"max-w-[180px] overflow-clip font-light truncate",children:e.commitMessage})}),d.jsx(fr,{className:"max-w-[320px]",children:d.jsx("pre",{className:"font-sans font-light whitespace-break-spaces",children:e.commitMessage})})]})]}),t&&d.jsxs("div",{className:"flex gap-2 items-start",children:[d.jsx("span",{className:"text-xs font-light text-fg-quaternary",children:"Deployed"}),d.jsx("button",{onClick:()=>{n()},children:d.jsx(Xu,{size:14})})]}),!t&&d.jsx(qq,{since:new Date(e.createdAt)})]})}function qq({since:e}){const[t,n]=g.useState("00"),[r,o]=g.useState("00");return g.useEffect(()=>{let i;const s=()=>{const a=Date.now(),l=Math.floor((a-e.getTime())/1e3),c=Math.floor(l/60),u=l%60;let f;c>4?(f=(60-u)*1e3,n(c.toString()),o(null)):(f=1e3,n(c.toString().padStart(2,"0")),o(u.toString().padStart(2,"0"))),i=setTimeout(s,f)};return s(),()=>{clearTimeout(i)}},[e]),d.jsxs("div",{className:"text-xs font-light text-fg-quaternary",children:[t,r!==null?`:${r}`:" mins"]})}function Yq({moduleFilePath:e,patchMetadata:t,committedPatchIds:n}){var u;const r=AA([t.opType],t.createdAt,n.has(t.patchId)),o=VS(),{skippedPatches:i}=BS(),s=void 0,[a]=g.useMemo(()=>[!!i[t.patchId]],[t.patchId,i[t.patchId]]),l=Ju();let c=[];if(t.author){const f=o[t.author];if(f){const h=((u=f==null?void 0:f.avatar)==null?void 0:u.url)??null;c=[{fullName:f.fullName,url:h}]}else console.warn("Did not find profile for author: ",t.author,{profilesById:o})}return c.length===0&&l==="http"&&console.warn("No authors",{patchMetadata:t}),d.jsx(ew,{moduleFilePath:e,patchPath:t.patchPath,changeDescription:a?"Skipped":r,authors:c,errors:s,skipped:a,isApplied:n.has(t.patchId)})}function AA(e,t,n){const[r,o]=g.useState(new Date);if(g.useEffect(()=>{const a=setInterval(()=>{o(new Date)},6e4);return()=>{clearInterval(a)}},[]),n)return"Pushed "+Om(r,t);if(e.length>1)return"Updated "+Om(r,t);const i=e[0];let s=i;return i==="add"?s="Added":i==="remove"?s="Removed":i==="replace"?s="Replaced":i==="move"?s="Moved":i==="copy"?s="Copied":i==="test"?s="Tested":i==="file"?s="Updated":console.warn("Unexpected op type: ",i),s+" "+Om(r,t)}function Jq({patchSet:e,committedPatchIds:t,patchErrors:n}){const[r,o]=g.useState(!1),i=g.useRef(null),[s,a]=g.useState(!1);g.useEffect(()=>{const v=new IntersectionObserver(x=>{x[0].isIntersecting&&a(!0)},{threshold:0});return i.current&&v.observe(i.current),()=>{v.disconnect()}},[]);const{skippedPatches:l}=BS(),{deletePatches:c}=QR(),u=g.useMemo(()=>e.patches.map(v=>v.patchId),[e.patches.map(v=>v.patchId).join(",")]),f=g.useMemo(()=>{const v=[];for(const x of u){const b=n==null?void 0:n[x];!l[x]&&b&&v.unshift(b.message)}return v},[u,n,l]),h=AA(e.opTypes,e.lastUpdated,!1),p=VS(),m=e.patches.every(v=>t.has(v.patchId));return s?d.jsxs(d.Fragment,{children:[d.jsx(ew,{moduleFilePath:e.moduleFilePath,patchPath:e.patchPath,isApplied:m,authors:e.authors.reduce((v,x)=>v.includes(x)?v:v.concat(x),[]).flatMap(v=>{var b;const x=p[v];if(x){const w=((b=x==null?void 0:x.avatar)==null?void 0:b.url)??null;return[{fullName:x.fullName,url:w}]}return[]}),changeDescription:h,isOpen:r,setOpen:o,errors:f,onDelete:()=>{c(u.filter(v=>!t.has(v)))},amount:new Set(u).size}),d.jsx(Cu,{isOpen:r,children:e.patches.map((v,x)=>d.jsx(Yq,{committedPatchIds:t,moduleFilePath:e.moduleFilePath,patchMetadata:v},e.moduleFilePath+":"+e.patchPath.join("/")+v.patchId+x))})]}):d.jsx(ew,{ref:i,isApplied:m})}const ew=g.forwardRef(({moduleFilePath:e,patchPath:t,changeDescription:n,authors:r,isOpen:o,setOpen:i,isSelected:s,setSelected:a,errors:l,skipped:c,onDelete:u,amount:f,isApplied:h},p)=>{const m=bn();return d.jsxs("div",{ref:p,className:Ne("p-6",{"bg-bg-secondary":!o,"bg-bg-tertiary":o,"opacity-50":h}),children:[d.jsxs("div",{className:"relative",children:[d.jsx("span",{className:"inline-block w-[calc(320px-24px-8px-16px-24px-48px)] truncate mr-2 ",children:e&&t&&d.jsx(hp,{moduleFilePath:e,patchPath:t,link:!0,toolTip:!0})}),s===void 0&&d.jsx("span",{className:Ne("inline-block w-6 h-6 rounded",{"bg-bg-disabled animate-pulse":t===void 0})}),s!==void 0&&!h&&d.jsx(td,{checked:s,onCheckedChange:v=>{a&&a(v)}}),d.jsxs("div",{className:"inline relative ml-5",children:[f&&d.jsxs($r,{children:[d.jsx(ho,{children:d.jsx("span",{className:"absolute -right-5 -top-6 w-6 h-6 text-xs leading-6 text-center rounded-full bg-bg-primary text-fg-primary",children:f>9?"9+":f})}),d.jsx(fr,{side:"left",children:d.jsxs("p",{children:[f," change",f>1?"s":""," in this patch set"]})})]}),u&&!h&&f&&f>0&&d.jsxs(br,{children:[d.jsx(xo,{children:d.jsx(Yb,{size:16,className:"inline"})}),d.jsxs(tr,{container:m,className:"flex flex-col gap-2 z-[9001]",children:[d.jsx("div",{className:"text-lg font-bold",children:"Are you sure?"}),d.jsxs("div",{children:["This will undo ",f," change",f>1?"s":"","."]}),d.jsx("div",{children:d.jsx(Fl,{asChild:!0,children:d.jsxs(Ge,{variant:"destructive",onClick:u,children:["Undo change",f>1?"s":""]})})})]})]})]})]}),l&&l.length>0&&!c&&d.jsxs("div",{className:"p-2 max-w-[240px] bg-bg-error-primary text-fg-primary rounded-lg",children:[l.slice(0,1).map((v,x)=>d.jsx("div",{title:v,className:"truncate",children:"Invalid change"},x)),l.length>1&&d.jsxs("div",{className:"truncate",children:["+",l.length-1," more"]})]}),(!l||l.length===0)&&c&&d.jsx("div",{className:"p-2 max-w-[240px] bg-bg-error-primary text-fg-primary",children:d.jsx("div",{className:"truncate",children:"Skipped"})}),d.jsxs("div",{className:"flex justify-between items-center pt-2",children:[d.jsxs("span",{className:"flex flex-shrink-0 gap-2",children:[r!==void 0&&r.length>0&&d.jsxs("span",{className:"flex gap-1 mr-2",children:[r.slice(0,2).map((v,x)=>{if(v.url)return d.jsxs($r,{children:[d.jsx(ho,{className:"flex-shrink-0 w-6 h-6",children:d.jsx("img",{src:v.url,alt:v.fullName,className:Ne("rounded-full",{"-ml-3":r.length>2&&x>0})})}),d.jsx(fr,{children:d.jsx("div",{children:v.fullName})})]},v.url);const b=Xq(v.fullName);return d.jsxs($r,{children:[d.jsx(ho,{className:Ne({"-ml-3":r.length>2&&x>0}),children:d.jsx("span",{className:Ne("flex items-center justify-center w-6 h-6 text-xs font-semibold rounded-full bg-bg-primary text-fg-primary"),"aria-label":"Initials for: "+v.fullName,children:b})}),d.jsx(fr,{children:d.jsx("div",{children:v.fullName})})]},v.fullName+v.url)}),r.length>2&&d.jsxs($r,{children:[d.jsx(ho,{className:Ne({"-ml-3":r.length>2}),children:d.jsxs("span",{className:"flex justify-center items-center -ml-3 w-6 h-6 text-xs font-semibold rounded-full bg-bg-primary text-fg-primary",children:["+",r.length-2]})}),d.jsx(fr,{className:"grid grid-cols-[auto,1fr] gap-2",children:r.slice(2).map(v=>d.jsxs(g.Fragment,{children:[v.url?d.jsx("img",{src:v.url,alt:v.fullName,title:v.fullName,className:Ne("w-6 h-6 rounded-full")},v.url):d.jsx("div",{}),d.jsx("div",{children:v.fullName})]},v.fullName+v.url))})]})]}),r===void 0&&d.jsx("span",{className:Ne("inline-block w-6 h-6 mr-2",{"bg-bg-disabled animate-pulse rounded-3xl":r===void 0})}),n&&d.jsx("span",{className:Ne({"text-fg-disabled":c}),children:n})]}),o!==void 0&&d.jsx("button",{className:"inline-block flex-shrink-0",onClick:()=>{i&&i(!o)},children:d.jsx(Zu,{size:16,className:Ne("transform",{"rotate-180":o})})})]})]})});function Xq(e){return!e||typeof e!="string"?"":e.trim().normalize("NFC").split(/\s+/).filter(r=>r.length>0).map(r=>/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(r)?r[0]:r[0].toLocaleUpperCase()).join("")}function tw(){const[e,t]=g.useState(!1),{publish:n,publishDisabled:r,isPublishing:o,summary:i}=lp(),s=tc(),a=s!==void 0&&Object.keys(s).length>0,l=e2(),c=t2(),u=Ju(),f=bn(),{autoPublish:h}=zS();return a?d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(Ge,{className:"flex gap-2 items-center",disabled:!0,children:u==="fs"?"Save":d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Ready"}),d.jsx(Fg,{size:16})]})})}),d.jsx(fr,{children:d.jsx("div",{className:"flex flex-col gap-2",children:d.jsx("p",{children:"Fix validation errors to continue"})})})]}):u==="fs"?d.jsxs(Ge,{className:"flex gap-2 items-center",disabled:r||a||h||l.length===0||c.length>0,title:a?"Please fix validation errors":"",onClick:()=>{n("No summary provided")},children:[a?d.jsx("span",{children:"Save"}):d.jsx("span",{children:o?"Saving":"Save"}),o&&d.jsx(qr,{className:"animate-spin",size:16})]}):d.jsx("span",{children:d.jsxs(br,{open:e,onOpenChange:p=>{t(p)},children:[d.jsx(xo,{asChild:!0,children:d.jsxs(Ge,{className:"flex gap-2 items-center",disabled:r||a||l.length===0||c.length>0,onClick:()=>{t(!0)},children:[!o&&d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Ready"}),d.jsx(Fg,{size:16})]}),o&&d.jsxs(d.Fragment,{children:[d.jsx("span",{children:"Pushing"}),d.jsx(qr,{className:"animate-spin",size:16})]})]})}),d.jsxs(tr,{container:f,align:"end",className:"z-[9001] flex flex-col gap-4",children:[d.jsx(Fl,{asChild:!0,className:"self-end cursor-pointer",children:d.jsx(Ll,{size:12})}),d.jsx(pA,{onClose:()=>{t(!1)},onPublish:()=>{if(t(!1),i.type==="not-asked")return;const p=i.text.trim();n(p)}})]})]})})}function Zq(){const e=uy(),{isPublishing:t}=lp(),n=tc()||{},{globalErrors:r}=BS(),o=Ju(),[i,s]=g.useMemo(()=>{const a=new Set;let l=0;for(const c in n){const[u]=Y.splitModuleFilePathAndModulePath(c);a.add(u),l+=1}return[Array.from(a).sort(),l]},[n]);return d.jsxs("div",{className:"min-h-[100svh] bg-bg-primary",style:{"--menu-width":"320px"},children:[d.jsx("div",{className:"h-16 border-b border-border-primary",children:d.jsx(tY,{})}),t&&d.jsxs("div",{className:"flex gap-2 justify-end items-center p-4 text-right border-t bg-bg-tertiary text-fg-primary border-border-primary",children:[d.jsx("span",{children:"Publishing changes "}),d.jsx(qr,{size:16,className:"animate-spin"})]}),d.jsx(hr,{children:d.jsxs("div",{className:"max-h-[calc(100svh-64px)]",children:[r&&r.length>0&&r.length!==s&&d.jsx(Ra,{type:"single",collapsible:!0,children:d.jsxs(Ei,{value:"global-errors",children:[d.jsxs(ps,{className:"p-4 font-normal text-left rounded data-[state=open]:rounded-b-none bg-bg-error-primary text-fg-error-primary",children:["Cannot ",o==="fs"?"save":"publish"," now. Found"," ",r==null?void 0:r.length," errors in all."," ",r.length-s," were non-validation errors. A developer might need to fix these issues."]}),d.jsx(Ci,{children:d.jsx(hr,{children:d.jsx("div",{className:"max-h-[calc(100svh-128px)] max-w-[var(--menu-width)]",children:r==null?void 0:r.map((a,l)=>d.jsx(eY,{error:a},l))})})})]})}),(r==null?void 0:r.length)===s&&i.length>0&&d.jsx(Ra,{type:"single",collapsible:!0,children:d.jsxs(Ei,{value:"global-errors",children:[d.jsx(ps,{className:"p-4 font-normal text-left rounded data-[state=open]:rounded-b-none bg-bg-error-primary text-fg-error-primary",children:d.jsxs("div",{children:[d.jsxs("div",{children:["Cannot ",o==="fs"?"save":"publish"," now."]}),d.jsx("div",{children:"Found errors in modules"})]})}),d.jsx(Ci,{children:d.jsx(hr,{children:d.jsx("div",{className:"max-h-[calc(100svh-64px)] max-w-[var(--menu-width)]",children:i==null?void 0:i.map((a,l)=>d.jsx(Qq,{moduleFilePath:a},l))})})})]})}),e!=="not-asked"&&d.jsx("div",{className:Ne("",{}),children:d.jsx(hr,{children:d.jsx("div",{className:"max-h-[calc(100svh-64px)] border-b border-border-primary",children:d.jsx(RA,{loadingStatus:e})})})})]})})]})}function Qq({moduleFilePath:e}){const t=Y.splitModuleFilePath(e),n=xn();return d.jsx("div",{className:"px-4 py-2 border-b bg-bg-error-primary text-fg-error-primary border-border-error-primary",children:d.jsx("button",{className:"underline cursor-pointer",onClick:()=>{n.navigate(e)},children:t.map((r,o)=>d.jsxs(g.Fragment,{children:[d.jsx("span",{className:ue("text-fg-brand-secondary",{"ml-1":o>0}),children:"/"}),d.jsx("span",{children:Nu(r)})]},o))})})}function eY({error:e}){const[t,n]=g.useState(!1);return d.jsx("div",{className:ue("px-1 py-2 bg-bg-error-primary text-fg-error-primary border-b border-border-error-primary",{truncate:!t,"whitespace-normal":t}),onClick:()=>n(!t),children:e})}function tY(){const{currentSourcePath:e}=xn(),t=Ha(),[n,r]=Y.splitModuleFilePathAndModulePath(e),o=lt(n,"record"),i=g.useMemo(()=>{if(t.status!=="success")return t;if(o.status!=="success")return o;const f=t.data[n];if(f.type==="record"&&f.router){if(o.data===null)return{status:"success",data:null};const h=Object.keys(o.data),m=Y.splitModulePath(r)[0];for(const v of h)if(m&&m===v)return{status:"success",data:{previewRoute:v}}}return{status:"success",data:null}},["data"in t&&t.data,n,r,o]),{navMenu:s,toolsMenu:a}=Qy(),l=Ju(),{setAutoPublish:c,autoPublish:u}=zS();return d.jsx("div",{className:"flex flex-col",children:d.jsxs("div",{className:"flex gap-2 justify-between items-center p-4 w-full",children:[d.jsx("button",{className:"lg:hidden",onClick:()=>{a.setOpen(!a.isOpen)},children:d.jsx(Dg,{size:16,className:Ne("transform",{"rotate-180":!s.isOpen})})}),d.jsxs("div",{className:"flex gap-2 justify-end items-center w-full",children:[l==="fs"&&d.jsxs("div",{className:"overflow-hidden flex items-center gap-2 text-[10px] lg:text-xs",children:[d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx("span",{className:"truncate text-fg-secondary",children:"Auto-save"})}),d.jsxs(fr,{children:[d.jsx("p",{children:"When auto-save is enabled Val will save to changes to disk automatically"}),d.jsx("p",{children:"This is a development mode feature"})]})]}),d.jsx(td,{checked:u,onCheckedChange:c})]}),d.jsx(nY,{maybePreviewRoute:i}),d.jsx(tw,{})]})]})})}function nY({maybePreviewRoute:e}){var n,r;const t=g.useMemo(()=>{var o;return e.status==="success"&&((o=e.data)!=null&&o.previewRoute)?yu("/api/val/enable",{redirect_to:window.origin+e.data.previewRoute}):yu("/api/val/enable",{redirect_to:window.origin})},[e]);return d.jsxs($r,{children:[d.jsx(ho,{asChild:!0,children:d.jsx(Ge,{className:"flex gap-2 items-center",variant:"secondary",asChild:!0,children:d.jsxs("a",{href:t,children:[d.jsx("span",{children:"Preview"}),e.status==="success"&&((n=e.data)!=null&&n.previewRoute)?d.jsx(Ig,{size:16}):d.jsx(Lg,{size:16})]})})}),d.jsx(fr,{children:e.status==="success"&&((r=e.data)!=null&&r.previewRoute)?d.jsxs("p",{children:["Preview your changes in ",e.data.previewRoute]}):d.jsx("p",{children:"Preview your changes on the main page"})})]})}function Xt({error:e,path:t}){return d.jsx("div",{id:t,children:d.jsx("div",{className:"p-4 bg-bg-error-primary text-fg-error-primary",children:e})})}function yt({path:e,type:t}){return d.jsx("div",{id:e,className:Ne("pt-6",{"w-full flex items-center justify-center":t==="module","text-left":t!=="module"}),children:d.jsx(qr,{size:t==="module"?24:16,className:"animate-spin"})})}function Rn({path:e,type:t}){const[n,r]=g.useState(!1);return g.useEffect(()=>{const o=setTimeout(()=>{r(!0)},2e3);return()=>{clearTimeout(o)}},[]),e.length===0?null:n?d.jsx("div",{className:"pt-6",id:e,children:d.jsx("div",{children:"Could not get data"})}):d.jsx(yt,{path:e,type:t})}function Er({actualType:e,expectedType:t,path:n}){return d.jsx("div",{id:n,children:d.jsxs("div",{children:["Schema mismatch: actual: ",e," vs expected: ",t," "]})})}function it({error:e,path:t,schema:n}){const{addPatch:r,patchPath:o}=wn(t);return d.jsxs("div",{id:t,className:"flex justify-between items-center px-2 py-3 rounded-lg bg-bg-error-primary text-fg-primary",children:[d.jsxs("div",{children:["Source error: ",e]}),d.jsxs("div",{className:"flex gap-2 items-center",children:[n&&n.status==="success"&&!(n.data.type==="file"||n.data.type==="image")&&d.jsx(Ge,{variant:"outline",className:"hover:bg-bg-error-secondary-hover",onClick:()=>{r([{op:"replace",path:o,value:zl(n.data)}],n.data.type)},children:"Fix"}),d.jsx(Eu,{size:16})]})]})}function rY(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const xy=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function nd(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function pk(e){return"nodeType"in e}function Cr(e){var t,n;return e?nd(e)?e:pk(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function mk(e){const{Document:t}=Cr(e);return e instanceof t}function pp(e){return nd(e)?!1:e instanceof Cr(e).HTMLElement}function IA(e){return e instanceof Cr(e).SVGElement}function rd(e){return e?nd(e)?e.document:pk(e)?mk(e)?e:pp(e)||IA(e)?e.ownerDocument:document:document:document}const Ni=xy?g.useLayoutEffect:g.useEffect;function gk(e){const t=g.useRef(e);return Ni(()=>{t.current=e}),g.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function oY(){const e=g.useRef(null),t=g.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=g.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function yh(e,t){t===void 0&&(t=[e]);const n=g.useRef(e);return Ni(()=>{n.current!==e&&(n.current=e)},t),n}function mp(e,t){const n=g.useRef();return g.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ug(e){const t=gk(e),n=g.useRef(null),r=g.useCallback(o=>{o!==n.current&&(t==null||t(o,n.current)),n.current=o},[]);return[n,r]}function nw(e){const t=g.useRef();return g.useEffect(()=>{t.current=e},[e]),t.current}let i0={};function gp(e,t){return g.useMemo(()=>{if(t)return t;const n=i0[e]==null?0:i0[e]+1;return i0[e]=n,e+"-"+n},[e,t])}function DA(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,c]of a){const u=i[l];u!=null&&(i[l]=u+e*c)}return i},{...t})}}const Qc=DA(1),xh=DA(-1);function iY(e){return"clientX"in e&&"clientY"in e}function vk(e){if(!e)return!1;const{KeyboardEvent:t}=Cr(e.target);return t&&e instanceof t}function sY(e){if(!e)return!1;const{TouchEvent:t}=Cr(e.target);return t&&e instanceof t}function rw(e){if(sY(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return iY(e)?{x:e.clientX,y:e.clientY}:null}const bh=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[bh.Translate.toString(e),bh.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),nP="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function aY(e){return e.matches(nP)?e:e.querySelector(nP)}const lY={display:"none"};function cY(e){let{id:t,value:n}=e;return Ce.createElement("div",{id:t,style:lY},n)}function uY(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return Ce.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function dY(){const[e,t]=g.useState("");return{announce:g.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const LA=g.createContext(null);function fY(e){const t=g.useContext(LA);g.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function hY(){const[e]=g.useState(()=>new Set),t=g.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[g.useCallback(r=>{let{type:o,event:i}=r;e.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[e]),t]}const pY={draggable:`
451
451
  To pick up a draggable item, press the space bar.
452
452
  While dragging, use the arrow keys to move the item.
453
453
  Press space again to drop the item in its new position, or press escape to cancel.
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Val</title>
7
- <script type="module" crossorigin src="/api/val/static/assets/index-BqgaZ3j-.js"></script>
7
+ <script type="module" crossorigin src="/api/val/static/assets/index-C6mV7nKj.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/api/val/static/assets/index-DXIM1dhC.css">
9
9
  </head>
10
10
  <body>