uhuu-components 0.2.52 → 0.2.53

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.
@@ -871,7 +871,7 @@ ${d}`}const u=af(()=>{if(!i.current||!o.current){console.warn("Container or page
871
871
  `)},Ym=function(){var t=parseInt(document.body.getAttribute(tr)||"0",10);return isFinite(t)?t:0},Gk=function(){T.useEffect(function(){return document.body.setAttribute(tr,(Ym()+1).toString()),function(){var t=Ym()-1;t<=0?document.body.removeAttribute(tr):document.body.setAttribute(tr,t.toString())}},[])},Vk=function(t){var e=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;Gk();var i=T.useMemo(function(){return Rk(a)},[a]);return T.createElement(Fk,{styles:$k(i,!e,a,r?"":"!important")})},vl=!1;if(typeof window<"u")try{var An=Object.defineProperty({},"passive",{get:function(){return vl=!0,!0}});window.addEventListener("test",An,An),window.removeEventListener("test",An,An)}catch{vl=!1}var rr=vl?{passive:!1}:!1,Hk=function(t){return t.tagName==="TEXTAREA"},Xm=function(t,e){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!Hk(t)&&r[e]==="visible")},Uk=function(t){return Xm(t,"overflowY")},Kk=function(t){return Xm(t,"overflowX")},Zm=function(t,e){var r=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=Qm(t,n);if(a){var i=Jm(t,n),o=i[1],s=i[2];if(o>s)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Yk=function(t){var e=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[e,r,n]},Xk=function(t){var e=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[e,r,n]},Qm=function(t,e){return t==="v"?Uk(e):Kk(e)},Jm=function(t,e){return t==="v"?Yk(e):Xk(e)},Zk=function(t,e){return t==="h"&&e==="rtl"?-1:1},Qk=function(t,e,r,n,a){var i=Zk(t,window.getComputedStyle(e).direction),o=i*n,s=r.target,l=e.contains(s),c=!1,d=o>0,u=0,p=0;do{if(!s)break;var f=Jm(t,s),v=f[0],m=f[1],g=f[2],w=m-g-i*v;(v||w)&&Qm(t,s)&&(u+=w,p+=v);var x=s.parentNode;s=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!l&&s!==document.body||l&&(e.contains(s)||e===s));return(d&&Math.abs(u)<1||!d&&Math.abs(p)<1)&&(c=!0),c},_n=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},eh=function(t){return[t.deltaX,t.deltaY]},th=function(t){return t&&"current"in t?t.current:t},Jk=function(t,e){return t[0]===e[0]&&t[1]===e[1]},eE=function(t){return`
872
872
  .block-interactivity-`.concat(t,` {pointer-events: none;}
873
873
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
874
- `)},tE=0,nr=[];function rE(t){var e=T.useRef([]),r=T.useRef([0,0]),n=T.useRef(),a=T.useState(tE++)[0],i=T.useState(Km)[0],o=T.useRef(t);T.useEffect(function(){o.current=t},[t]),T.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var m=Ck([t.lockRef.current],(t.shards||[]).map(th),!0).filter(Boolean);return m.forEach(function(g){return g.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),m.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var s=T.useCallback(function(m,g){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!o.current.allowPinchZoom;var w=_n(m),x=r.current,h="deltaX"in m?m.deltaX:x[0]-w[0],b="deltaY"in m?m.deltaY:x[1]-w[1],S,E=m.target,k=Math.abs(h)>Math.abs(b)?"h":"v";if("touches"in m&&k==="h"&&E.type==="range")return!1;var C=window.getSelection(),A=C&&C.anchorNode,_=A?A===E||A.contains(E):!1;if(_)return!1;var I=Zm(k,E);if(!I)return!0;if(I?S=k:(S=k==="v"?"h":"v",I=Zm(k,E)),!I)return!1;if(!n.current&&"changedTouches"in m&&(h||b)&&(n.current=S),!S)return!0;var M=n.current||S;return Qk(M,g,m,M==="h"?h:b)},[]),l=T.useCallback(function(m){var g=m;if(!(!nr.length||nr[nr.length-1]!==i)){var w="deltaY"in g?eh(g):_n(g),x=e.current.filter(function(S){return S.name===g.type&&(S.target===g.target||g.target===S.shadowParent)&&Jk(S.delta,w)})[0];if(x&&x.should){g.cancelable&&g.preventDefault();return}if(!x){var h=(o.current.shards||[]).map(th).filter(Boolean).filter(function(S){return S.contains(g.target)}),b=h.length>0?s(g,h[0]):!o.current.noIsolation;b&&g.cancelable&&g.preventDefault()}}},[]),c=T.useCallback(function(m,g,w,x){var h={name:m,delta:g,target:w,should:x,shadowParent:nE(w)};e.current.push(h),setTimeout(function(){e.current=e.current.filter(function(b){return b!==h})},1)},[]),d=T.useCallback(function(m){r.current=_n(m),n.current=void 0},[]),u=T.useCallback(function(m){c(m.type,eh(m),m.target,s(m,t.lockRef.current))},[]),p=T.useCallback(function(m){c(m.type,_n(m),m.target,s(m,t.lockRef.current))},[]);T.useEffect(function(){return nr.push(i),t.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:p}),document.addEventListener("wheel",l,rr),document.addEventListener("touchmove",l,rr),document.addEventListener("touchstart",d,rr),function(){nr=nr.filter(function(m){return m!==i}),document.removeEventListener("wheel",l,rr),document.removeEventListener("touchmove",l,rr),document.removeEventListener("touchstart",d,rr)}},[]);var f=t.removeScrollBar,v=t.inert;return T.createElement(T.Fragment,null,v?T.createElement(i,{styles:eE(a)}):null,f?T.createElement(Vk,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function nE(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const aE=Nk(Um,rE);var yl=T.forwardRef(function(t,e){return T.createElement(Tn,Je({},t,{ref:e,sideCar:aE}))});yl.classNames=Tn.classNames;var bl=["Enter"," "],iE=["ArrowDown","PageUp","Home"],rh=["ArrowUp","PageDown","End"],oE=[...iE,...rh],sE={ltr:[...bl,"ArrowRight"],rtl:[...bl,"ArrowLeft"]},lE={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Tr="Menu",[Ar,cE,dE]=Fs(Tr),[jt,nh]=ot(Tr,[dE,Am,jm]),On=Am(),ah=jm(),[uE,Wt]=jt(Tr),[pE,_r]=jt(Tr),ih=t=>{const{__scopeMenu:e,open:r=!1,children:n,dir:a,onOpenChange:i,modal:o=!0}=t,s=On(e),[l,c]=T.useState(null),d=T.useRef(!1),u=st(i),p=$s(a);return T.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),y.jsx(ek,{...s,children:y.jsx(uE,{scope:e,open:r,onOpenChange:u,content:l,onContentChange:c,children:y.jsx(pE,{scope:e,onClose:T.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:p,modal:o,children:n})})})};ih.displayName=Tr;var fE="MenuAnchor",Sl=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,a=On(r);return y.jsx(tk,{...a,...n,ref:e})});Sl.displayName=fE;var xl="MenuPortal",[mE,oh]=jt(xl,{forceMount:void 0}),sh=t=>{const{__scopeMenu:e,forceMount:r,children:n,container:a}=t,i=Wt(xl,e);return y.jsx(mE,{scope:e,forceMount:r,children:y.jsx(wt,{present:r||i.open,children:y.jsx(dl,{asChild:!0,container:a,children:n})})})};sh.displayName=xl;var qe="MenuContent",[hE,wl]=jt(qe),lh=T.forwardRef((t,e)=>{const r=oh(qe,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,i=Wt(qe,t.__scopeMenu),o=_r(qe,t.__scopeMenu);return y.jsx(Ar.Provider,{scope:t.__scopeMenu,children:y.jsx(wt,{present:n||i.open,children:y.jsx(Ar.Slot,{scope:t.__scopeMenu,children:o.modal?y.jsx(gE,{...a,ref:e}):y.jsx(vE,{...a,ref:e})})})})}),gE=T.forwardRef((t,e)=>{const r=Wt(qe,t.__scopeMenu),n=T.useRef(null),a=me(e,n);return T.useEffect(()=>{const i=n.current;if(i)return $m(i)},[]),y.jsx(Cl,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:ie(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),vE=T.forwardRef((t,e)=>{const r=Wt(qe,t.__scopeMenu);return y.jsx(Cl,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),yE=wr("MenuContent.ScrollLock"),Cl=T.forwardRef((t,e)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,onDismiss:f,disableOutsideScroll:v,...m}=t,g=Wt(qe,r),w=_r(qe,r),x=On(r),h=ah(r),b=cE(r),[S,E]=T.useState(null),k=T.useRef(null),C=me(e,k,g.onContentChange),A=T.useRef(0),_=T.useRef(""),I=T.useRef(0),M=T.useRef(null),z=T.useRef("right"),q=T.useRef(0),H=v?yl:T.Fragment,D=v?{as:yE,allowPinchZoom:!0}:void 0,F=P=>{const j=_.current+P,K=b().filter(U=>!U.disabled),X=document.activeElement,W=K.find(U=>U.ref.current===X)?.textValue,L=K.map(U=>U.textValue),B=PE(L,j,W),V=K.find(U=>U.textValue===B)?.ref.current;(function U(oe){_.current=oe,window.clearTimeout(A.current),oe!==""&&(A.current=window.setTimeout(()=>U(""),1e3))})(j),V&&setTimeout(()=>V.focus())};T.useEffect(()=>()=>window.clearTimeout(A.current),[]),Xf();const R=T.useCallback(P=>z.current===M.current?.side&&NE(P,M.current?.area),[]);return y.jsx(hE,{scope:r,searchRef:_,onItemEnter:T.useCallback(P=>{R(P)&&P.preventDefault()},[R]),onItemLeave:T.useCallback(P=>{R(P)||(k.current?.focus(),E(null))},[R]),onTriggerLeave:T.useCallback(P=>{R(P)&&P.preventDefault()},[R]),pointerGraceTimerRef:I,onPointerGraceIntentChange:T.useCallback(P=>{M.current=P},[]),children:y.jsx(H,{...D,children:y.jsx(Ys,{asChild:!0,trapped:a,onMountAutoFocus:ie(i,P=>{P.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:y.jsx(Vs,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,onDismiss:f,children:y.jsx(yk,{asChild:!0,...h,dir:w.dir,orientation:"vertical",loop:n,currentTabStopId:S,onCurrentTabStopIdChange:E,onEntryFocus:ie(l,P=>{w.isUsingKeyboardRef.current||P.preventDefault()}),preventScrollOnEntryFocus:!0,children:y.jsx(rk,{role:"menu","aria-orientation":"vertical","data-state":Eh(g.open),"data-radix-menu-content":"",dir:w.dir,...x,...m,ref:C,style:{outline:"none",...m.style},onKeyDown:ie(m.onKeyDown,P=>{const K=P.target.closest("[data-radix-menu-content]")===P.currentTarget,X=P.ctrlKey||P.altKey||P.metaKey,W=P.key.length===1;K&&(P.key==="Tab"&&P.preventDefault(),!X&&W&&F(P.key));const L=k.current;if(P.target!==L||!oE.includes(P.key))return;P.preventDefault();const V=b().filter(U=>!U.disabled).map(U=>U.ref.current);rh.includes(P.key)&&V.reverse(),_E(V)}),onBlur:ie(t.onBlur,P=>{P.currentTarget.contains(P.target)||(window.clearTimeout(A.current),_.current="")}),onPointerMove:ie(t.onPointerMove,Pr(P=>{const j=P.target,K=q.current!==P.clientX;if(P.currentTarget.contains(j)&&K){const X=P.clientX>q.current?"right":"left";z.current=X,q.current=P.clientX}}))})})})})})})});lh.displayName=qe;var bE="MenuGroup",kl=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return y.jsx(he.div,{role:"group",...n,ref:e})});kl.displayName=bE;var SE="MenuLabel",ch=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return y.jsx(he.div,{...n,ref:e})});ch.displayName=SE;var Pn="MenuItem",dh="menu.itemSelect",In=T.forwardRef((t,e)=>{const{disabled:r=!1,onSelect:n,...a}=t,i=T.useRef(null),o=_r(Pn,t.__scopeMenu),s=wl(Pn,t.__scopeMenu),l=me(e,i),c=T.useRef(!1),d=()=>{const u=i.current;if(!r&&u){const p=new CustomEvent(dh,{bubbles:!0,cancelable:!0});u.addEventListener(dh,f=>n?.(f),{once:!0}),Vf(u,p),p.defaultPrevented?c.current=!1:o.onClose()}};return y.jsx(uh,{...a,ref:l,disabled:r,onClick:ie(t.onClick,d),onPointerDown:u=>{t.onPointerDown?.(u),c.current=!0},onPointerUp:ie(t.onPointerUp,u=>{c.current||u.currentTarget?.click()}),onKeyDown:ie(t.onKeyDown,u=>{const p=s.searchRef.current!=="";r||p&&u.key===" "||bl.includes(u.key)&&(u.currentTarget.click(),u.preventDefault())})})});In.displayName=Pn;var uh=T.forwardRef((t,e)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...i}=t,o=wl(Pn,r),s=ah(r),l=T.useRef(null),c=me(e,l),[d,u]=T.useState(!1),[p,f]=T.useState("");return T.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[i.children]),y.jsx(Ar.ItemSlot,{scope:r,disabled:n,textValue:a??p,children:y.jsx(bk,{asChild:!0,...s,focusable:!n,children:y.jsx(he.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:c,onPointerMove:ie(t.onPointerMove,Pr(v=>{n?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(t.onPointerLeave,Pr(v=>o.onItemLeave(v))),onFocus:ie(t.onFocus,()=>u(!0)),onBlur:ie(t.onBlur,()=>u(!1))})})})}),xE="MenuCheckboxItem",ph=T.forwardRef((t,e)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return y.jsx(vh,{scope:t.__scopeMenu,checked:r,children:y.jsx(In,{role:"menuitemcheckbox","aria-checked":Nn(r)?"mixed":r,...a,ref:e,"data-state":Tl(r),onSelect:ie(a.onSelect,()=>n?.(Nn(r)?!0:!r),{checkForDefaultPrevented:!1})})})});ph.displayName=xE;var fh="MenuRadioGroup",[wE,CE]=jt(fh,{value:void 0,onValueChange:()=>{}}),mh=T.forwardRef((t,e)=>{const{value:r,onValueChange:n,...a}=t,i=st(n);return y.jsx(wE,{scope:t.__scopeMenu,value:r,onValueChange:i,children:y.jsx(kl,{...a,ref:e})})});mh.displayName=fh;var hh="MenuRadioItem",gh=T.forwardRef((t,e)=>{const{value:r,...n}=t,a=CE(hh,t.__scopeMenu),i=r===a.value;return y.jsx(vh,{scope:t.__scopeMenu,checked:i,children:y.jsx(In,{role:"menuitemradio","aria-checked":i,...n,ref:e,"data-state":Tl(i),onSelect:ie(n.onSelect,()=>a.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});gh.displayName=hh;var El="MenuItemIndicator",[vh,kE]=jt(El,{checked:!1}),yh=T.forwardRef((t,e)=>{const{__scopeMenu:r,forceMount:n,...a}=t,i=kE(El,r);return y.jsx(wt,{present:n||Nn(i.checked)||i.checked===!0,children:y.jsx(he.span,{...a,ref:e,"data-state":Tl(i.checked)})})});yh.displayName=El;var EE="MenuSeparator",bh=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return y.jsx(he.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});bh.displayName=EE;var TE="MenuArrow",Sh=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,a=On(r);return y.jsx(nk,{...a,...n,ref:e})});Sh.displayName=TE;var AE="MenuSub",[tI,xh]=jt(AE),Or="MenuSubTrigger",wh=T.forwardRef((t,e)=>{const r=Wt(Or,t.__scopeMenu),n=_r(Or,t.__scopeMenu),a=xh(Or,t.__scopeMenu),i=wl(Or,t.__scopeMenu),o=T.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=i,c={__scopeMenu:t.__scopeMenu},d=T.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return T.useEffect(()=>d,[d]),T.useEffect(()=>{const u=s.current;return()=>{window.clearTimeout(u),l(null)}},[s,l]),y.jsx(Sl,{asChild:!0,...c,children:y.jsx(uh,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":Eh(r.open),...t,ref:Sr(e,a.onTriggerChange),onClick:u=>{t.onClick?.(u),!(t.disabled||u.defaultPrevented)&&(u.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:ie(t.onPointerMove,Pr(u=>{i.onItemEnter(u),!u.defaultPrevented&&!t.disabled&&!r.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{r.onOpenChange(!0),d()},100))})),onPointerLeave:ie(t.onPointerLeave,Pr(u=>{d();const p=r.content?.getBoundingClientRect();if(p){const f=r.content?.dataset.side,v=f==="right",m=v?-5:5,g=p[v?"left":"right"],w=p[v?"right":"left"];i.onPointerGraceIntentChange({area:[{x:u.clientX+m,y:u.clientY},{x:g,y:p.top},{x:w,y:p.top},{x:w,y:p.bottom},{x:g,y:p.bottom}],side:f}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(u),u.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:ie(t.onKeyDown,u=>{const p=i.searchRef.current!=="";t.disabled||p&&u.key===" "||sE[n.dir].includes(u.key)&&(r.onOpenChange(!0),r.content?.focus(),u.preventDefault())})})})});wh.displayName=Or;var Ch="MenuSubContent",kh=T.forwardRef((t,e)=>{const r=oh(qe,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,i=Wt(qe,t.__scopeMenu),o=_r(qe,t.__scopeMenu),s=xh(Ch,t.__scopeMenu),l=T.useRef(null),c=me(e,l);return y.jsx(Ar.Provider,{scope:t.__scopeMenu,children:y.jsx(wt,{present:n||i.open,children:y.jsx(Ar.Slot,{scope:t.__scopeMenu,children:y.jsx(Cl,{id:s.contentId,"aria-labelledby":s.triggerId,...a,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{o.isUsingKeyboardRef.current&&l.current?.focus(),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(t.onFocusOutside,d=>{d.target!==s.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:ie(t.onEscapeKeyDown,d=>{o.onClose(),d.preventDefault()}),onKeyDown:ie(t.onKeyDown,d=>{const u=d.currentTarget.contains(d.target),p=lE[o.dir].includes(d.key);u&&p&&(i.onOpenChange(!1),s.trigger?.focus(),d.preventDefault())})})})})})});kh.displayName=Ch;function Eh(t){return t?"open":"closed"}function Nn(t){return t==="indeterminate"}function Tl(t){return Nn(t)?"indeterminate":t?"checked":"unchecked"}function _E(t){const e=document.activeElement;for(const r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function OE(t,e){return t.map((r,n)=>t[(e+n)%t.length])}function PE(t,e,r){const a=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=r?t.indexOf(r):-1;let o=OE(t,Math.max(i,0));a.length===1&&(o=o.filter(c=>c!==r));const l=o.find(c=>c.toLowerCase().startsWith(a.toLowerCase()));return l!==r?l:void 0}function IE(t,e){const{x:r,y:n}=t;let a=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){const s=e[i],l=e[o],c=s.x,d=s.y,u=l.x,p=l.y;d>n!=p>n&&r<(u-c)*(n-d)/(p-d)+c&&(a=!a)}return a}function NE(t,e){if(!e)return!1;const r={x:t.clientX,y:t.clientY};return IE(r,e)}function Pr(t){return e=>e.pointerType==="mouse"?t(e):void 0}var ME=ih,DE=Sl,zE=sh,LE=lh,jE=kl,WE=ch,BE=In,qE=ph,RE=mh,FE=gh,$E=yh,GE=bh,VE=Sh,HE=wh,UE=kh,Mn="DropdownMenu",[KE]=ot(Mn,[nh]),_e=nh(),[YE,Th]=KE(Mn),Ah=t=>{const{__scopeDropdownMenu:e,children:r,dir:n,open:a,defaultOpen:i,onOpenChange:o,modal:s=!0}=t,l=_e(e),c=T.useRef(null),[d,u]=xr({prop:a,defaultProp:i??!1,onChange:o,caller:Mn});return y.jsx(YE,{scope:e,triggerId:Yt(),triggerRef:c,contentId:Yt(),open:d,onOpenChange:u,onOpenToggle:T.useCallback(()=>u(p=>!p),[u]),modal:s,children:y.jsx(ME,{...l,open:d,onOpenChange:u,dir:n,modal:s,children:r})})};Ah.displayName=Mn;var _h="DropdownMenuTrigger",Oh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,i=Th(_h,r),o=_e(r);return y.jsx(DE,{asChild:!0,...o,children:y.jsx(he.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...a,ref:Sr(e,i.triggerRef),onPointerDown:ie(t.onPointerDown,s=>{!n&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:ie(t.onKeyDown,s=>{n||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});Oh.displayName=_h;var XE="DropdownMenuPortal",Ph=t=>{const{__scopeDropdownMenu:e,...r}=t,n=_e(e);return y.jsx(zE,{...n,...r})};Ph.displayName=XE;var Ih="DropdownMenuContent",Nh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=Th(Ih,r),i=_e(r),o=T.useRef(!1);return y.jsx(LE,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...n,ref:e,onCloseAutoFocus:ie(t.onCloseAutoFocus,s=>{o.current||a.triggerRef.current?.focus(),o.current=!1,s.preventDefault()}),onInteractOutside:ie(t.onInteractOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!a.modal||d)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Nh.displayName=Ih;var ZE="DropdownMenuGroup",QE=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(jE,{...a,...n,ref:e})});QE.displayName=ZE;var JE="DropdownMenuLabel",Mh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(WE,{...a,...n,ref:e})});Mh.displayName=JE;var eT="DropdownMenuItem",Dh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(BE,{...a,...n,ref:e})});Dh.displayName=eT;var tT="DropdownMenuCheckboxItem",zh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(qE,{...a,...n,ref:e})});zh.displayName=tT;var rT="DropdownMenuRadioGroup",Lh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(RE,{...a,...n,ref:e})});Lh.displayName=rT;var nT="DropdownMenuRadioItem",jh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(FE,{...a,...n,ref:e})});jh.displayName=nT;var aT="DropdownMenuItemIndicator",iT=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx($E,{...a,...n,ref:e})});iT.displayName=aT;var oT="DropdownMenuSeparator",Wh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(GE,{...a,...n,ref:e})});Wh.displayName=oT;var sT="DropdownMenuArrow",lT=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(VE,{...a,...n,ref:e})});lT.displayName=sT;var cT="DropdownMenuSubTrigger",Bh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(HE,{...a,...n,ref:e})});Bh.displayName=cT;var dT="DropdownMenuSubContent",qh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(UE,{...a,...n,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qh.displayName=dT;var uT=Ah,pT=Oh,fT=Ph,Rh=Nh,Fh=Mh,$h=Dh,Gh=zh,mT=Lh,Vh=jh,Hh=Wh,Uh=Bh,Kh=qh;const Dn=uT,zn=pT,hT=mT,gT=T.forwardRef(({className:t,inset:e,children:r,...n},a)=>y.jsx(Uh,{ref:a,className:pe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-gray-100 data-[state=open]:bg-gray-100",e&&"pl-8",t),...n,children:r}));gT.displayName=Uh.displayName;const vT=T.forwardRef(({className:t,...e},r)=>y.jsx(Kh,{ref:r,className:pe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white p-1 text-gray-900 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...e}));vT.displayName=Kh.displayName;const Ir=T.forwardRef(({className:t,sideOffset:e=4,...r},n)=>{const{portalContainer:a}=zs();return y.jsx(fT,{container:a||void 0,children:y.jsx(Rh,{ref:n,sideOffset:e,"data-uhuu-editor":!0,className:pe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white p-1 text-gray-900 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})})});Ir.displayName=Rh.displayName;const Bt=T.forwardRef(({className:t,inset:e,...r},n)=>y.jsx($h,{ref:n,className:pe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e&&"pl-8",t),...r}));Bt.displayName=$h.displayName;const yT=T.forwardRef(({className:t,children:e,checked:r,...n},a)=>y.jsx(Gh,{ref:a,className:pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:r,...n,children:e}));yT.displayName=Gh.displayName;const Yh=T.forwardRef(({className:t,children:e,...r},n)=>y.jsx(Vh,{ref:n,className:pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:e}));Yh.displayName=Vh.displayName;const Al=T.forwardRef(({className:t,inset:e,...r},n)=>y.jsx(Fh,{ref:n,className:pe("px-2 py-1.5 text-sm font-medium",e&&"pl-8",t),...r}));Al.displayName=Fh.displayName;const Ln=T.forwardRef(({className:t,...e},r)=>y.jsx(Hh,{ref:r,className:pe("-mx-1 my-1 h-px bg-gray-200",t),...e}));Ln.displayName=Hh.displayName;const bT=(t,e)=>{if(t.stopPropagation(),e.onSelect){e.onSelect(t);return}e.dialog&&typeof window<"u"&&window.$uhuu?.editDialog?.(e.dialog)},_l=(t,e)=>{if(!t)return null;const r=t.trim();if(r.startsWith("<")){const a=r.replace(/<svg\b([^>]*)>/i,(i,o)=>{let s=o;return/\bwidth=/.test(s)?s=s.replace(/\bwidth=(\"[^\"]*\"|'[^']*'|[^\s>]+)/i,'width="100%"'):s+=' width="100%"',/\bheight=/.test(s)?s=s.replace(/\bheight=(\"[^\"]*\"|'[^']*'|[^\s>]+)/i,'height="100%"'):s+=' height="100%"',/\bpreserveAspectRatio=/.test(s)?s=s.replace(/\bpreserveAspectRatio=(\"[^\"]*\"|'[^']*'|[^\s>]+)/i,'preserveAspectRatio="xMidYMid slice"'):s+=' preserveAspectRatio="xMidYMid slice"',`<svg${s}>`});return y.jsx("div",{className:pe("pointer-events-none absolute inset-0 z-10",e),"aria-hidden":"true",dangerouslySetInnerHTML:{__html:a}})}return y.jsx("img",{src:t,alt:"","aria-hidden":"true",className:pe("pointer-events-none absolute inset-0 z-10 h-full w-full object-cover",e)})},Ol=(t,e)=>e?y.jsx("div",{className:"absolute right-2 top-2 z-20",children:y.jsxs(Dn,{modal:!1,children:[y.jsx(zn,{asChild:!0,children:y.jsx(Ae,{variant:"secondary",size:"icon",title:"Image options",className:"h-7 w-7 shadow-sm",onPointerDown:r=>r.stopPropagation(),onClick:r=>r.stopPropagation(),children:y.jsx(mf,{className:"h-4 w-4"})})}),y.jsx(Ir,{className:"w-40 p-1.5",align:"end",children:t.map(r=>y.jsxs(Bt,{onSelect:n=>bT(n,r),disabled:r.disabled,children:[r.icon&&y.jsx("span",{className:"mr-2 inline-flex",children:r.icon}),y.jsx("span",{children:r.label})]},r.id))})]})}):null,Pl=(t=[])=>{const e=js();return t.length>0&&!e},ST=({className:t,style:e,overlaySvg:r,overlayClassName:n,options:a=[],dialog:i,dialogProps:o,bleedProps:s,children:l})=>{const c=O.useContext(Mt),d=Pl(a),u=i?Kt({dialog:i},c):{};return T.useMemo(()=>{if(!o)return u;const p={...u,...o};return(u.className||o.className)&&(p.className=`${u.className||""} ${o.className||""}`.trim()),Object.keys(u).forEach(f=>{const v=u[f],m=o[f];f.startsWith("on")&&typeof v=="function"&&typeof m=="function"&&(p[f]=g=>{v(g),m(g)})}),p},[u,o]),y.jsxs(y.Fragment,{children:[y.jsxs(Ns,{...s,dialog:i,children:[_l(r,n),l]}),Ol(a,d)]})};function Il(t){const e=O.useContext(Mt),r=t.bleed??e?.page?.bleed??0,n=t.pageWidth??e?.page?.width??210,a=t.pageHeight??e?.page?.height??297,{src:i,side:o,backgroundColor:s,width:l,height:c,left:d=0,right:u=0,top:p=0,bottom:f=0}=t,[v,m]=O.useState("h-full w-full object-cover object-center"),g=D=>`${D}mm`,w=()=>{let D=l;return l||(D=2*n,d||(D+=2*r),u||(D+=2*r),(d||u)&&(D-=(d??0)+(u??0))),D},x=()=>{let D=c;return c||(D=a,p||(D+=r),f||(D+=r),(p||f)&&(D-=(p??0)+(f??0))),D},h=w(),b=x(),S=D=>D!==void 0?g(D):void 0,E=D=>Object.fromEntries(Object.entries(D).filter(([F,R])=>R!==void 0)),k=d>0?d+r:-1*r,C=p>0?p+r:-1*r,A=f>0?f+r:-1*r,_=-1*n+k,I=p>0&&f>0,M=E({backgroundColor:s,width:S(h),...I?{height:S(b)}:{},left:S(k),top:S(C),bottom:S(A)}),z=E({width:S(h),...I?{height:S(b)}:{},left:S(_),top:S(C),bottom:S(A)}),q=b!=0?h/b:h/(a-(p??0)-(f??0)),H=D=>{let R=D.target.naturalWidth/D.target.naturalHeight>q?"cover-vertical":"cover-horizontal";m(R)};return y.jsx("div",{className:"uhuu-image-container",style:o=="end"?z:M,...t.dataUhuu!==void 0?{"data-uhuu":t.dataUhuu}:{},children:y.jsxs("div",{className:"uhuu-image-inner",...Kt(t,e),children:[y.jsx("img",{className:v,src:i,onLoad:D=>H(D)},`${i}-${h}-${b}`),t.children]})})}const xT=({overlaySvg:t,overlayClassName:e,options:r=[],dialog:n,spreadProps:a,children:i})=>{const o=Pl(r);return y.jsxs(y.Fragment,{children:[y.jsxs(Il,{...a,dialog:n,children:[_l(t,e),i]}),Ol(r,o)]})},wT=({src:t,alt:e="",className:r,imageClassName:n,style:a,imageStyle:i,overlaySvg:o,overlayClassName:s,options:l=[],dialog:c,dialogProps:d,placeholder:u,children:p,imageProps:f,renderImage:v})=>{const m=O.useContext(Mt),g=c?Kt({dialog:c},m):{},w=Pl(l),x=T.useMemo(()=>{if(!d)return g;const C={...g,...d};return(g.className||d.className)&&(C.className=pe(g.className,d.className)),Object.keys(g).forEach(A=>{const _=g[A],I=d[A];A.startsWith("on")&&typeof _=="function"&&typeof I=="function"&&(C[A]=M=>{_(M),I(M)})}),C},[g,d]),h=()=>{const C=f?.className,A=f?.style,_=f?.src??t,I=f?.alt??e,M={...f,src:_,alt:I,className:pe("h-full w-full object-cover",n,C),style:{...i,...A}};return v?v(M):_?y.jsx("img",{...M}):u??null},b=x["data-uhuu"],S=T.Children.toArray(p).some(C=>T.isValidElement(C)?C.type===Il||C.type===Ns:!1);S&&delete x["data-uhuu"];const E=T.Children.map(p,C=>T.isValidElement(C)?T.cloneElement(C,{dataUhuu:b}):C),k=S?"relative h-full w-full":"relative";return y.jsxs("div",{className:pe(k,r),style:a,children:[y.jsxs("div",{className:"relative h-full w-full",...x,children:[h(),E,_l(o,s)]}),Ol(l,w)]})},CT=t=>{const{computedOverlaySvg:e,computedOptions:r,computedDirectDialog:n}=O.useMemo(()=>{const{annotation:H,dialog:D,overlaySvg:F,options:R,src:P}=t;if(!H&&!D)return{computedOverlaySvg:F,computedOptions:R,computedDirectDialog:void 0};const j=H?.value||{},K=F??j.annotationSvg??"",X=[];if(H){if(D){const $={...D};if(D.type==="satellite"){const{path:Z,type:se,...le}=D;$.config={...le,path:"image"},$.path=Z,$.type=se}else D.type==="image"&&($.imagePath||($.imagePath="url"));X.push({id:"edit",label:"Edit image",dialog:$})}const B=Array.isArray(j.annotations)?j.annotations:[],{path:V,value:U,annotations:oe,...ae}=H,N={path:H.path,type:"annotation",image:P,annotations:B,...ae};X.push({id:"annotate",label:"Annotate",dialog:N})}const W=R?[...X,...R]:X;let L;if(D){const B={...D};if(D.type==="satellite"){const{path:V,type:U,...oe}=D;B.config={...oe,path:"image"},B.path=V,B.type=U}else D.type==="image"&&(B.imagePath||(B.imagePath="url"));L=B}return{computedOverlaySvg:K,computedOptions:W.length>0?W:void 0,computedDirectDialog:L}},[t.annotation,t.dialog,t.overlaySvg,t.options,t.src]),a=O.useMemo(()=>t.mode?t.mode:t.side!==void 0?"spread":t.width!==void 0||t.height!==void 0||t.left!==void 0||t.right!==void 0||t.top!==void 0||t.bottom!==void 0?"bleed":"auto",[t.mode,t.side,t.width,t.height,t.left,t.right,t.top,t.bottom]),i=a==="auto"||r&&r.length>0||e||n||t.renderImage!==void 0||t.placeholder!==void 0||t.children!==void 0,{mode:o,side:s,src:l,alt:c,className:d,imageClassName:u,style:p,imageStyle:f,backgroundColor:v,width:m,height:g,left:w,right:x,top:h,bottom:b,pageWidth:S,pageHeight:E,bleed:k,overlayClassName:C,dialogProps:A,placeholder:_,children:I,imageProps:M,renderImage:z}=t,q={src:l,backgroundColor:v,width:m,height:g,left:w,right:x,top:h,bottom:b,pageWidth:S,pageHeight:E,bleed:k};if(a==="auto")return y.jsx(wT,{src:l,alt:c,className:d,style:p,imageClassName:u,imageStyle:f,overlaySvg:e,overlayClassName:C,options:r,dialog:n,dialogProps:A,placeholder:_,children:I,imageProps:M,renderImage:z});if(a==="spread"){const H={...q,side:s};return i&&(e||r?.length||n)?y.jsx(xT,{className:d,style:p,overlaySvg:e,overlayClassName:C,options:r,dialog:n,dialogProps:A,spreadProps:H,children:I}):y.jsx(Il,{...H})}return i&&(e||r?.length||n)?y.jsx(ST,{className:d,style:p,overlaySvg:e,overlayClassName:C,options:r,dialog:n,dialogProps:A,bleedProps:q,children:I}):y.jsx(Ns,{...q})},kT=t=>{const e=O.useContext(Mt);return y.jsx("div",{className:t.className,...Kt(t,e),children:t.children})},qt="uhuu_page_editor";function Oe(t){return t.kind==="group"}function ET(t){const e=[];let r=1;for(const n of t)if(Oe(n))for(const a of n.pages)e.push({...a,kind:"page",pageNum:r++});else e.push({...n,pageNum:r++});return e}function TT(t){const e=[];let r=1;for(const n of t)if(Oe(n)){const a=n.pages.map(i=>({...i,kind:"page",pageNum:r++}));e.push({...n,pages:a})}else e.push({...n,pageNum:r++});return e}function Ct(t){return ET(t).length}function AT(t){return t.map(e=>{const r=e.strictPosition;if(Oe(e)){const n=e.pages[0],a=n?.componentKey??n?.id;return{kind:"group",id:e.id,groupId:e.id,firstPageId:n?.id,firstPageComponentKey:a,firstPageComponent:n?.component,pageCount:e.pages.length,label:e.label||`${e.id} (${e.pages.length} pages)`,strictPosition:r}}else{const n=e.componentKey??e.id;return{kind:"page",id:e.id,label:e.label,pageId:e.id,pageComponentKey:n,pageLabel:e.label,pageNum:e.pageNum,pageComponent:e.component,strictPosition:r}}})}function _T(t,e){const r=new Map;e.forEach(a=>{r.set(a.id,a)});const n=[];for(const a of t){const i=r.get(a.id);i&&n.push(i)}return n}function Nl(t){return t.map(e=>{if("kind"in e&&e.kind)return e;if(e.pages&&Array.isArray(e.pages))return{kind:"group",...e,pages:(e.pages??[]).map(i=>{const{kind:o,...s}=i||{};return{kind:"page",...s}})};const{kind:n,...a}=e;return{kind:"page",...a}})}function Xh(t,e=qt){const r=Nl(t);return{key:e,items:r,totalPages:Ct(r),updatedAt:new Date().toISOString()}}function OT(t,e=qt){const r=t?.[e];if(!r?.items)return null;const n=Nl(r.items);return{key:e,items:n,totalPages:Ct(n),updatedAt:r.updatedAt||new Date().toISOString()}}function PT(t,e,r=qt){const n=Xh(e,r);return{...t??{},[r]:n}}function Zh(){return Math.random().toString(36).slice(2,11)}function Qh(t,e,r){return{kind:"page",id:r?.repeatable?Zh():t,componentKey:e,templateId:t,label:r?.label,repeatable:r?.repeatable,maxInstances:r?.maxInstances,...r}}function Jh(t,e,r){const n=r?.repeatable?Zh():t;return{kind:"group",id:n,templateId:t,label:r?.label,repeatable:r?.repeatable??!1,maxInstances:r?.maxInstances??null,pages:e.map((a,i)=>{const o=typeof a=="string"?a:a.key,s=typeof a=="string"?void 0:a.dataKey;return{id:`${n}__${s??o}__${i}`,componentKey:o,templateId:o,...s?{dataKey:s}:{}}}),...r}}function eg(t,e){return t<0?e+t+1:t}function tg(t,e,r){for(const n of e){const a=eg(n.start,r),i=eg(n.end,r);if(t>=a&&t<=i)return!0}return!1}function IT(t,e,r=2){switch(t){case"all":return[{start:1,end:e}];case"cover":return[{start:1,end:r},{start:-r,end:-1}];case"text":return e<=r*2?[]:[{start:r+1,end:-(r+1)}];default:return[]}}function NT(t,e){if(!e||e.mode==="all")return t;const r=Ct(t),n=e.mode??"all",a=e.coverPageCount??2,i=n==="custom"&&e.ranges?e.ranges:IT(n,r,a);if(i.length===0)return[];const o=[];for(const s of t)if(Oe(s)){const l=s.pages.filter(c=>c.pageNum&&tg(c.pageNum,i,r));l.length>0&&o.push({...s,pages:l})}else s.pageNum&&tg(s.pageNum,i,r)&&o.push(s);return o}function rg(t,e){if(t?.integrations)return t.integrations[e]}function MT(t,e){return e&&Oe(e)?e.id:t?.id??null}function ng(t,e,r){const n=MT(e,r);return n?{instanceId:n,integration:rg(t,n)}:{instanceId:null,integration:void 0}}function ag(t,e,r){return ng(t,e,r).integration}function ig(t,e){if(!t)return null;const r=`integrations.${t}`;return e?`${r}.${e}`:r}function DT(t){if(!t)return{instanceId:null,fieldPath:t,isIntegrationPath:!1};const e="integrations.";if(t.startsWith(e)){const r=t.slice(e.length),n=r.indexOf(".");if(n>0){const a=r.slice(0,n),i=r.slice(n+1);return{instanceId:a,fieldPath:i,isIntegrationPath:!0}}else return{instanceId:r,fieldPath:"",isIntegrationPath:!0}}return{instanceId:null,fieldPath:t,isIntegrationPath:!1}}function zT(t,e,r){if(!e)return r;const n=e.split("."),a={...t};let i=a;for(let s=0;s<n.length-1;s++){const l=n[s];!(l in i)||typeof i[l]!="object"||i[l]===null?i[l]={}:i[l]={...i[l]},i=i[l]}const o=n[n.length-1];return i[o]=r,a}function LT(t,e,r){const n=DT(e);if(!n.isIntegrationPath||!n.instanceId)return t;const{instanceId:a,fieldPath:i}=n,o=rg(t,a)||{},s=zT(o,i,r);return{...t,integrations:{...t?.integrations||{},[a]:s}}}function jn(t,e){if(!t||!e)return;const r=typeof e=="string"?e:e?.id,n=typeof e=="string"?void 0:e?.templateId??e?.componentKey,a=typeof e=="string"?void 0:e?.componentKey,i=Array.from(new Set([r,n,a].filter(Boolean)));for(const o of i)if(t?.pages?.[o]!==void 0)return t.pages[o];for(const o of i)if(t?.groups?.[o]!==void 0)return t.groups[o];for(const o of i)if(t[o]!==void 0)return t[o]}const Nr=T.createContext(null);function jT(t=qt){return[t]}function WT(t,e,r){if(!e)return t;if(!t)return e;const n={...e};return r.forEach(a=>{t[a]!==void 0&&(n[a]=t[a])}),n}function og({payload:t,onPayloadChange:e,children:r,stateKey:n=qt}){const[a,i]=T.useState(t??{}),o=T.useRef(null),s=T.useRef(!1),l=T.useRef(null),c=T.useRef(0),d=T.useRef(!0),u=T.useCallback(C=>{try{return JSON.stringify(C)}catch{return String(C)}},[]),p=T.useMemo(()=>jT(n),[n]),f=T.useCallback((C,A)=>{if(!C)return null;const _={...C};return A.forEach(I=>{delete _[I]}),_},[]);T.useEffect(()=>{if(d.current){d.current=!1,t&&(o.current=t,i(t));return}if(s.current){s.current=!1,l.current=t,c.current=Date.now(),o.current=t;return}if(t===o.current)return;if(Date.now()-c.current<500&&l.current!==null){const _=f(t,p),I=f(l.current,p),M=_?u(_):null,z=I?u(I):null;if(M&&M===z){l.current=null,o.current=t;return}}o.current=t,i(_=>t?WT(_,t,p):_)},[t,p,u,f]);const v=T.useCallback(C=>{e?.(C),typeof window<"u"&&window.$uhuu?.initPayload&&window.$uhuu.initPayload(C)},[e]),m=T.useCallback(C=>{s.current=!0,i(A=>{const _=typeof C=="function"?C(A):C;let I=_;return _&&typeof _=="object"&&Object.keys(_).filter(z=>z.startsWith("integrations.")||z==="integrations").length>0&&_.integrations&&(I=_),l.current=I,c.current=Date.now(),v(I),I})},[v]),g=T.useCallback((C,A,_)=>{m(I=>({...I??{},pages:{...I?.pages??{},[C]:{...I?.pages?.[C]??{},[A]:_}}}))},[m]),w=T.useCallback((C,A)=>{m(_=>{const I=_?.integrations??{},M=I[C],z=typeof A=="function"?A(M):A;return{..._??{},integrations:{...I,[C]:z}}})},[m]),x=T.useCallback((C,A,_)=>{w(C,I=>({...I??{},[A]:_}))},[w]),h=T.useCallback(C=>{m(A=>{if(!A?.integrations||!A.integrations[C])return A;const{[C]:_,...I}=A.integrations;return{...A,integrations:Object.keys(I).length>0?I:void 0}})},[m]),b=T.useCallback((C,A)=>{m(_=>LT(_,C,A))},[m]),S=T.useCallback((C,A)=>{const _=A??n;m(I=>PT(I,C,_))},[m,n]),E=T.useCallback(C=>jn(a,C),[a]),k=T.useMemo(()=>({payload:a,setPayload:m,setPageOptionValue:g,setIntegrationPayload:w,setIntegrationPayloadValue:x,removeIntegrationPayload:h,updateIntegrationByDialogPath:b,mergePageEditorState:S,getPagePayload:E}),[a,m,g,w,x,h,b,S,E]);return y.jsx(Nr.Provider,{value:k,children:r})}function BT(t){return t.defaultValue!==void 0?t.defaultValue:t.type==="toggle"?!1:t.type==="slider"||t.type==="counter"?0:""}function qT(t,e){return t.type==="toggle"?e===!0||e==="true":t.type==="slider"||t.type==="counter"?Number(e):e}function RT(t,e,r){const n=t.field??t.id;return{...t,getValue:i=>{const o=e?.pages?.[i.id]?.[n];return o===void 0?BT(t):t.type==="toggle"?!!o:o},onChange:(i,o)=>{r(i,n,qT(t,o))}}}const Wn=O.createContext({zoom:100,scaleValue:1,hideUI:!1});function FT({children:t,layout:e="spread"}){const{scaleValue:r}=O.useContext(Wn),n=O.useRef(null);return O.useEffect(()=>{if(!n.current)return;const a=()=>{const s=n.current?.querySelectorAll("[data-section-content]");if(!s?.length)return;const l=Array.from(s).reduce((c,d)=>{const u=Number.parseInt(d.getAttribute("data-natural-width")||"0");return c+u},0);if(l>0){const c=l*r;n.current?.style.setProperty("--uhuu-group-pair-width",`${c}px`)}};a();const i=new ResizeObserver(a);return n.current.querySelectorAll("[data-section-content]").forEach(s=>i.observe(s)),()=>i.disconnect()},[t,r]),y.jsx("div",{ref:n,className:`two-pages-pair two-pages-pair--${e}`,children:t})}function Bn({children:t,title:e,className:r="",controls:n,origin:a="center"}){const{scaleValue:i,hideUI:o}=O.useContext(Wn),s=O.useRef(null),[l,c]=O.useState(0),[d,u]=O.useState(0);O.useEffect(()=>{if(s.current){const w=()=>{const h=s.current;if(h){const b=h.style.transform;h.style.transform="scale(1)";const S=h.scrollHeight,E=h.scrollWidth;h.style.transform=b,c(S),u(E)}};w();const x=new ResizeObserver(w);return x.observe(s.current),()=>{x.disconnect()}}},[t]);const p=l*i,f=Math.max(d*i,150),v={left:{justify:"justify-start",origin:"top left"},right:{justify:"justify-end",origin:"top right"},center:{justify:"justify-center",origin:"top center"}},{justify:m,origin:g}=v[a];return o?y.jsx("div",{className:r,children:t}):y.jsxs("div",{className:`group/section ${r}`,style:{width:`${f}px`,minWidth:"150px"},children:[y.jsx("div",{children:n??y.jsx("div",{className:"px-4 py-2 border-b border-gray-200",children:y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:[e," Controls"]})})}),y.jsx("div",{className:"pt-1",style:{height:p>0?`${p+32}px`:"auto",minHeight:"100px"},children:y.jsx("div",{className:`flex items-start ${m}`,children:y.jsx("div",{ref:s,"data-section-content":!0,"data-natural-width":d,"data-natural-height":l,style:{transform:`scale(${i})`,transformOrigin:g},children:t})})})]})}function $T({children:t,className:e="",defaultZoom:r=100,minZoom:n=25,maxZoom:a=200,onAddPage:i,menuItems:o,hideUI:s,preview:l="single_page"}){const c=js(),d=s??c,[u,p]=O.useState(r),[f,v]=O.useState("none"),m=O.useRef(null),g=O.useRef(null),[w,x]=O.useState(!1),[h,b]=O.useState(0),[S,E]=O.useState(!0),k=M=>{if(!m.current||!g.current)return u;const z=m.current.getBoundingClientRect(),q=g.current.querySelector("[data-section-content]");if(!q)return u;let H=Number.parseInt(q.getAttribute("data-natural-width")||"0");const D=Number.parseInt(q.getAttribute("data-natural-height")||"0");if(H===0||D===0)return u;l==="two_pages"&&(H=H*2);const F=z.width-32,R=screen.height-120,P=F/H*100,j=R/D*100;switch(M){case"width":return Math.min(Math.max(P,n),a);case"height":return Math.min(Math.max(j,n),a);case"both":return Math.min(Math.max(Math.min(P,j),n),a);default:return u}},C=M=>{if(v(M),M!=="none"){const z=k(M);p(z)}},A=()=>{const M=Math.min(u+25,a);p(M),v("none")},_=()=>{const M=Math.max(u-25,n);p(M),v("none")};O.useEffect(()=>{const M=()=>{if(!m.current||!g.current)return;const H=m.current.getBoundingClientRect().width;if(!w){const D=g.current.querySelector("[data-section-content]");if(D){const F=Number.parseInt(D.getAttribute("data-natural-width")||"0");if(F>0){if(F>H-48){const R=k("both");v("both"),p(R)}x(!0),b(H),E(!1);return}}if(S){setTimeout(M,50);return}}E(!1)},z=()=>{if(!m.current||S)return;const H=m.current.getBoundingClientRect().width;if(Math.abs(H-h)>10){if(f!=="none"){const D=k(f);p(D)}b(H)}};return M(),window.addEventListener("resize",z),()=>{window.removeEventListener("resize",z)}},[f,n,a,w,h,S]);const I=u/100;return d?y.jsx(Wn.Provider,{value:{zoom:100,scaleValue:1,hideUI:!0},children:y.jsx("div",{className:e,children:t})}):y.jsx(Wn.Provider,{value:{zoom:u,scaleValue:I,hideUI:!1},children:y.jsxs("div",{ref:m,className:`flex flex-col min-h-0 ${e}`,children:[y.jsxs("div",{"data-uhuu-editor":!0,className:"fixed right-4 bottom-4 z-50 flex items-center gap-1.5 px-2.5 py-1.5 bg-white/90 backdrop-blur-md border border-gray-200/60 rounded-lg shadow-sm",children:[o,y.jsx("div",{className:"h-4 w-px bg-gray-200 mx-0.5"}),y.jsxs(Dn,{modal:!1,children:[y.jsx(zn,{asChild:!0,children:y.jsxs(Ae,{variant:"ghost",size:"sm",title:"Zoom",className:"text-xs font-medium text-gray-700 hover:bg-gray-100/80 h-7 px-2.5",children:[Math.round(u),"%",y.jsx(aw,{className:"w-3 h-3 ml-1 opacity-60"})]})}),y.jsxs(Ir,{className:"w-52 p-1.5",align:"end",children:[y.jsxs(Bt,{onClick:()=>C("width"),className:`cursor-pointer flex items-center ${f==="width"?"bg-gray-100":""}`,children:[y.jsx(uw,{className:"w-4 h-4 mr-2"}),y.jsx("span",{children:"Fit to Width"})]}),y.jsxs(Bt,{onClick:()=>C("height"),className:`cursor-pointer flex items-center ${f==="height"?"bg-gray-100":""}`,children:[y.jsx(pw,{className:"w-4 h-4 mr-2"}),y.jsx("span",{children:"Fit to Height"})]}),y.jsxs(Bt,{onClick:()=>C("both"),className:`cursor-pointer flex items-center ${f==="both"?"bg-gray-100":""}`,children:[y.jsx(sw,{className:"w-4 h-4 mr-2"}),y.jsx("span",{children:"Fit to Page"})]}),y.jsx(Ln,{className:"my-1.5"}),y.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-2.5",onClick:M=>M.stopPropagation(),children:[y.jsx(Ae,{variant:"ghost",size:"sm",onClick:M=>{M.stopPropagation(),_()},disabled:u<=n,className:"h-8 w-8 p-0 hover:bg-gray-100 disabled:opacity-40",title:"Zoom out (25%)",children:y.jsx(mw,{className:"w-4 h-4"})}),y.jsxs("div",{className:"relative",children:[y.jsx("input",{type:"number",value:Math.round(u),onChange:M=>{const z=Number.parseInt(M.target.value);if(!isNaN(z)){const q=Math.min(Math.max(z,n),a);p(q),v("none")}},onFocus:M=>M.target.select(),className:"w-20 pr-6 text-center text-sm text-gray-700 bg-white border border-gray-300 rounded px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all",min:n,max:a}),y.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-gray-400 pointer-events-none",children:"%"})]}),y.jsx(Ae,{variant:"ghost",size:"sm",onClick:M=>{M.stopPropagation(),A()},disabled:u>=a,className:"h-8 w-8 p-0 hover:bg-gray-100 disabled:opacity-40",title:"Zoom in (25%)",children:y.jsx(fw,{className:"w-4 h-4"})})]})]})]})]}),y.jsx("div",{ref:g,children:y.jsx("div",{className:l==="two_pages"?"group_two_pages":"flex flex-col items-center",children:t})}),y.jsx("div",{className:"flex justify-center pb-16",children:y.jsx(Ae,{size:"sm",variant:"outline",onClick:()=>i?i():null,children:y.jsx(mt,{})})})]})})}var qn="Dialog",[sg,lg]=ot(qn),[GT,He]=sg(qn),cg=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,s=T.useRef(null),l=T.useRef(null),[c,d]=xr({prop:n,defaultProp:a??!1,onChange:i,caller:qn});return y.jsx(GT,{scope:e,triggerRef:s,contentRef:l,contentId:Yt(),titleId:Yt(),descriptionId:Yt(),open:c,onOpenChange:d,onOpenToggle:T.useCallback(()=>d(u=>!u),[d]),modal:o,children:r})};cg.displayName=qn;var dg="DialogTrigger",ug=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(dg,r),i=me(e,a.triggerRef);return y.jsx(he.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":zl(a.open),...n,ref:i,onClick:ie(t.onClick,a.onOpenToggle)})});ug.displayName=dg;var Ml="DialogPortal",[VT,pg]=sg(Ml,{forceMount:void 0}),fg=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:a}=t,i=He(Ml,e);return y.jsx(VT,{scope:e,forceMount:r,children:T.Children.map(n,o=>y.jsx(wt,{present:r||i.open,children:y.jsx(dl,{asChild:!0,container:a,children:o})}))})};fg.displayName=Ml;var Rn="DialogOverlay",mg=T.forwardRef((t,e)=>{const r=pg(Rn,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,i=He(Rn,t.__scopeDialog);return i.modal?y.jsx(wt,{present:n||i.open,children:y.jsx(UT,{...a,ref:e})}):null});mg.displayName=Rn;var HT=wr("DialogOverlay.RemoveScroll"),UT=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(Rn,r);return y.jsx(yl,{as:HT,allowPinchZoom:!0,shards:[a.contentRef],children:y.jsx(he.div,{"data-state":zl(a.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),Rt="DialogContent",hg=T.forwardRef((t,e)=>{const r=pg(Rt,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,i=He(Rt,t.__scopeDialog);return y.jsx(wt,{present:n||i.open,children:i.modal?y.jsx(KT,{...a,ref:e}):y.jsx(YT,{...a,ref:e})})});hg.displayName=Rt;var KT=T.forwardRef((t,e)=>{const r=He(Rt,t.__scopeDialog),n=T.useRef(null),a=me(e,r.contentRef,n);return T.useEffect(()=>{const i=n.current;if(i)return $m(i)},[]),y.jsx(gg,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(t.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:ie(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,s=o.button===0&&o.ctrlKey===!0;(o.button===2||s)&&i.preventDefault()}),onFocusOutside:ie(t.onFocusOutside,i=>i.preventDefault())})}),YT=T.forwardRef((t,e)=>{const r=He(Rt,t.__scopeDialog),n=T.useRef(!1),a=T.useRef(!1);return y.jsx(gg,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;r.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),gg=T.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,s=He(Rt,r),l=T.useRef(null),c=me(e,l);return Xf(),y.jsxs(y.Fragment,{children:[y.jsx(Ys,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:y.jsx(Vs,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":zl(s.open),...o,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),y.jsxs(y.Fragment,{children:[y.jsx(ZT,{titleId:s.titleId}),y.jsx(JT,{contentRef:l,descriptionId:s.descriptionId})]})]})}),Dl="DialogTitle",vg=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(Dl,r);return y.jsx(he.h2,{id:a.titleId,...n,ref:e})});vg.displayName=Dl;var yg="DialogDescription",bg=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(yg,r);return y.jsx(he.p,{id:a.descriptionId,...n,ref:e})});bg.displayName=yg;var Sg="DialogClose",xg=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(Sg,r);return y.jsx(he.button,{type:"button",...n,ref:e,onClick:ie(t.onClick,()=>a.onOpenChange(!1))})});xg.displayName=Sg;function zl(t){return t?"open":"closed"}var wg="DialogTitleWarning",[XT,Cg]=oC(wg,{contentName:Rt,titleName:Dl,docsSlug:"dialog"}),ZT=({titleId:t})=>{const e=Cg(wg),r=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
874
+ `)},tE=0,nr=[];function rE(t){var e=T.useRef([]),r=T.useRef([0,0]),n=T.useRef(),a=T.useState(tE++)[0],i=T.useState(Km)[0],o=T.useRef(t);T.useEffect(function(){o.current=t},[t]),T.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var m=Ck([t.lockRef.current],(t.shards||[]).map(th),!0).filter(Boolean);return m.forEach(function(g){return g.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),m.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var s=T.useCallback(function(m,g){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!o.current.allowPinchZoom;var w=_n(m),x=r.current,h="deltaX"in m?m.deltaX:x[0]-w[0],b="deltaY"in m?m.deltaY:x[1]-w[1],S,E=m.target,k=Math.abs(h)>Math.abs(b)?"h":"v";if("touches"in m&&k==="h"&&E.type==="range")return!1;var C=window.getSelection(),A=C&&C.anchorNode,_=A?A===E||A.contains(E):!1;if(_)return!1;var I=Zm(k,E);if(!I)return!0;if(I?S=k:(S=k==="v"?"h":"v",I=Zm(k,E)),!I)return!1;if(!n.current&&"changedTouches"in m&&(h||b)&&(n.current=S),!S)return!0;var M=n.current||S;return Qk(M,g,m,M==="h"?h:b)},[]),l=T.useCallback(function(m){var g=m;if(!(!nr.length||nr[nr.length-1]!==i)){var w="deltaY"in g?eh(g):_n(g),x=e.current.filter(function(S){return S.name===g.type&&(S.target===g.target||g.target===S.shadowParent)&&Jk(S.delta,w)})[0];if(x&&x.should){g.cancelable&&g.preventDefault();return}if(!x){var h=(o.current.shards||[]).map(th).filter(Boolean).filter(function(S){return S.contains(g.target)}),b=h.length>0?s(g,h[0]):!o.current.noIsolation;b&&g.cancelable&&g.preventDefault()}}},[]),c=T.useCallback(function(m,g,w,x){var h={name:m,delta:g,target:w,should:x,shadowParent:nE(w)};e.current.push(h),setTimeout(function(){e.current=e.current.filter(function(b){return b!==h})},1)},[]),d=T.useCallback(function(m){r.current=_n(m),n.current=void 0},[]),u=T.useCallback(function(m){c(m.type,eh(m),m.target,s(m,t.lockRef.current))},[]),p=T.useCallback(function(m){c(m.type,_n(m),m.target,s(m,t.lockRef.current))},[]);T.useEffect(function(){return nr.push(i),t.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:p}),document.addEventListener("wheel",l,rr),document.addEventListener("touchmove",l,rr),document.addEventListener("touchstart",d,rr),function(){nr=nr.filter(function(m){return m!==i}),document.removeEventListener("wheel",l,rr),document.removeEventListener("touchmove",l,rr),document.removeEventListener("touchstart",d,rr)}},[]);var f=t.removeScrollBar,v=t.inert;return T.createElement(T.Fragment,null,v?T.createElement(i,{styles:eE(a)}):null,f?T.createElement(Vk,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function nE(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const aE=Nk(Um,rE);var yl=T.forwardRef(function(t,e){return T.createElement(Tn,Je({},t,{ref:e,sideCar:aE}))});yl.classNames=Tn.classNames;var bl=["Enter"," "],iE=["ArrowDown","PageUp","Home"],rh=["ArrowUp","PageDown","End"],oE=[...iE,...rh],sE={ltr:[...bl,"ArrowRight"],rtl:[...bl,"ArrowLeft"]},lE={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Tr="Menu",[Ar,cE,dE]=Fs(Tr),[jt,nh]=ot(Tr,[dE,Am,jm]),On=Am(),ah=jm(),[uE,Wt]=jt(Tr),[pE,_r]=jt(Tr),ih=t=>{const{__scopeMenu:e,open:r=!1,children:n,dir:a,onOpenChange:i,modal:o=!0}=t,s=On(e),[l,c]=T.useState(null),d=T.useRef(!1),u=st(i),p=$s(a);return T.useEffect(()=>{const f=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),y.jsx(ek,{...s,children:y.jsx(uE,{scope:e,open:r,onOpenChange:u,content:l,onContentChange:c,children:y.jsx(pE,{scope:e,onClose:T.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:p,modal:o,children:n})})})};ih.displayName=Tr;var fE="MenuAnchor",Sl=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,a=On(r);return y.jsx(tk,{...a,...n,ref:e})});Sl.displayName=fE;var xl="MenuPortal",[mE,oh]=jt(xl,{forceMount:void 0}),sh=t=>{const{__scopeMenu:e,forceMount:r,children:n,container:a}=t,i=Wt(xl,e);return y.jsx(mE,{scope:e,forceMount:r,children:y.jsx(wt,{present:r||i.open,children:y.jsx(dl,{asChild:!0,container:a,children:n})})})};sh.displayName=xl;var qe="MenuContent",[hE,wl]=jt(qe),lh=T.forwardRef((t,e)=>{const r=oh(qe,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,i=Wt(qe,t.__scopeMenu),o=_r(qe,t.__scopeMenu);return y.jsx(Ar.Provider,{scope:t.__scopeMenu,children:y.jsx(wt,{present:n||i.open,children:y.jsx(Ar.Slot,{scope:t.__scopeMenu,children:o.modal?y.jsx(gE,{...a,ref:e}):y.jsx(vE,{...a,ref:e})})})})}),gE=T.forwardRef((t,e)=>{const r=Wt(qe,t.__scopeMenu),n=T.useRef(null),a=me(e,n);return T.useEffect(()=>{const i=n.current;if(i)return $m(i)},[]),y.jsx(Cl,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:ie(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),vE=T.forwardRef((t,e)=>{const r=Wt(qe,t.__scopeMenu);return y.jsx(Cl,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),yE=wr("MenuContent.ScrollLock"),Cl=T.forwardRef((t,e)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,onDismiss:f,disableOutsideScroll:v,...m}=t,g=Wt(qe,r),w=_r(qe,r),x=On(r),h=ah(r),b=cE(r),[S,E]=T.useState(null),k=T.useRef(null),C=me(e,k,g.onContentChange),A=T.useRef(0),_=T.useRef(""),I=T.useRef(0),M=T.useRef(null),z=T.useRef("right"),q=T.useRef(0),H=v?yl:T.Fragment,D=v?{as:yE,allowPinchZoom:!0}:void 0,F=P=>{const j=_.current+P,K=b().filter(U=>!U.disabled),X=document.activeElement,W=K.find(U=>U.ref.current===X)?.textValue,L=K.map(U=>U.textValue),B=PE(L,j,W),V=K.find(U=>U.textValue===B)?.ref.current;(function U(oe){_.current=oe,window.clearTimeout(A.current),oe!==""&&(A.current=window.setTimeout(()=>U(""),1e3))})(j),V&&setTimeout(()=>V.focus())};T.useEffect(()=>()=>window.clearTimeout(A.current),[]),Xf();const R=T.useCallback(P=>z.current===M.current?.side&&NE(P,M.current?.area),[]);return y.jsx(hE,{scope:r,searchRef:_,onItemEnter:T.useCallback(P=>{R(P)&&P.preventDefault()},[R]),onItemLeave:T.useCallback(P=>{R(P)||(k.current?.focus(),E(null))},[R]),onTriggerLeave:T.useCallback(P=>{R(P)&&P.preventDefault()},[R]),pointerGraceTimerRef:I,onPointerGraceIntentChange:T.useCallback(P=>{M.current=P},[]),children:y.jsx(H,{...D,children:y.jsx(Ys,{asChild:!0,trapped:a,onMountAutoFocus:ie(i,P=>{P.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:y.jsx(Vs,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:p,onDismiss:f,children:y.jsx(yk,{asChild:!0,...h,dir:w.dir,orientation:"vertical",loop:n,currentTabStopId:S,onCurrentTabStopIdChange:E,onEntryFocus:ie(l,P=>{w.isUsingKeyboardRef.current||P.preventDefault()}),preventScrollOnEntryFocus:!0,children:y.jsx(rk,{role:"menu","aria-orientation":"vertical","data-state":Eh(g.open),"data-radix-menu-content":"",dir:w.dir,...x,...m,ref:C,style:{outline:"none",...m.style},onKeyDown:ie(m.onKeyDown,P=>{const K=P.target.closest("[data-radix-menu-content]")===P.currentTarget,X=P.ctrlKey||P.altKey||P.metaKey,W=P.key.length===1;K&&(P.key==="Tab"&&P.preventDefault(),!X&&W&&F(P.key));const L=k.current;if(P.target!==L||!oE.includes(P.key))return;P.preventDefault();const V=b().filter(U=>!U.disabled).map(U=>U.ref.current);rh.includes(P.key)&&V.reverse(),_E(V)}),onBlur:ie(t.onBlur,P=>{P.currentTarget.contains(P.target)||(window.clearTimeout(A.current),_.current="")}),onPointerMove:ie(t.onPointerMove,Pr(P=>{const j=P.target,K=q.current!==P.clientX;if(P.currentTarget.contains(j)&&K){const X=P.clientX>q.current?"right":"left";z.current=X,q.current=P.clientX}}))})})})})})})});lh.displayName=qe;var bE="MenuGroup",kl=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return y.jsx(he.div,{role:"group",...n,ref:e})});kl.displayName=bE;var SE="MenuLabel",ch=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return y.jsx(he.div,{...n,ref:e})});ch.displayName=SE;var Pn="MenuItem",dh="menu.itemSelect",In=T.forwardRef((t,e)=>{const{disabled:r=!1,onSelect:n,...a}=t,i=T.useRef(null),o=_r(Pn,t.__scopeMenu),s=wl(Pn,t.__scopeMenu),l=me(e,i),c=T.useRef(!1),d=()=>{const u=i.current;if(!r&&u){const p=new CustomEvent(dh,{bubbles:!0,cancelable:!0});u.addEventListener(dh,f=>n?.(f),{once:!0}),Vf(u,p),p.defaultPrevented?c.current=!1:o.onClose()}};return y.jsx(uh,{...a,ref:l,disabled:r,onClick:ie(t.onClick,d),onPointerDown:u=>{t.onPointerDown?.(u),c.current=!0},onPointerUp:ie(t.onPointerUp,u=>{c.current||u.currentTarget?.click()}),onKeyDown:ie(t.onKeyDown,u=>{const p=s.searchRef.current!=="";r||p&&u.key===" "||bl.includes(u.key)&&(u.currentTarget.click(),u.preventDefault())})})});In.displayName=Pn;var uh=T.forwardRef((t,e)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...i}=t,o=wl(Pn,r),s=ah(r),l=T.useRef(null),c=me(e,l),[d,u]=T.useState(!1),[p,f]=T.useState("");return T.useEffect(()=>{const v=l.current;v&&f((v.textContent??"").trim())},[i.children]),y.jsx(Ar.ItemSlot,{scope:r,disabled:n,textValue:a??p,children:y.jsx(bk,{asChild:!0,...s,focusable:!n,children:y.jsx(he.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:c,onPointerMove:ie(t.onPointerMove,Pr(v=>{n?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ie(t.onPointerLeave,Pr(v=>o.onItemLeave(v))),onFocus:ie(t.onFocus,()=>u(!0)),onBlur:ie(t.onBlur,()=>u(!1))})})})}),xE="MenuCheckboxItem",ph=T.forwardRef((t,e)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return y.jsx(vh,{scope:t.__scopeMenu,checked:r,children:y.jsx(In,{role:"menuitemcheckbox","aria-checked":Nn(r)?"mixed":r,...a,ref:e,"data-state":Tl(r),onSelect:ie(a.onSelect,()=>n?.(Nn(r)?!0:!r),{checkForDefaultPrevented:!1})})})});ph.displayName=xE;var fh="MenuRadioGroup",[wE,CE]=jt(fh,{value:void 0,onValueChange:()=>{}}),mh=T.forwardRef((t,e)=>{const{value:r,onValueChange:n,...a}=t,i=st(n);return y.jsx(wE,{scope:t.__scopeMenu,value:r,onValueChange:i,children:y.jsx(kl,{...a,ref:e})})});mh.displayName=fh;var hh="MenuRadioItem",gh=T.forwardRef((t,e)=>{const{value:r,...n}=t,a=CE(hh,t.__scopeMenu),i=r===a.value;return y.jsx(vh,{scope:t.__scopeMenu,checked:i,children:y.jsx(In,{role:"menuitemradio","aria-checked":i,...n,ref:e,"data-state":Tl(i),onSelect:ie(n.onSelect,()=>a.onValueChange?.(r),{checkForDefaultPrevented:!1})})})});gh.displayName=hh;var El="MenuItemIndicator",[vh,kE]=jt(El,{checked:!1}),yh=T.forwardRef((t,e)=>{const{__scopeMenu:r,forceMount:n,...a}=t,i=kE(El,r);return y.jsx(wt,{present:n||Nn(i.checked)||i.checked===!0,children:y.jsx(he.span,{...a,ref:e,"data-state":Tl(i.checked)})})});yh.displayName=El;var EE="MenuSeparator",bh=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return y.jsx(he.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});bh.displayName=EE;var TE="MenuArrow",Sh=T.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,a=On(r);return y.jsx(nk,{...a,...n,ref:e})});Sh.displayName=TE;var AE="MenuSub",[tI,xh]=jt(AE),Or="MenuSubTrigger",wh=T.forwardRef((t,e)=>{const r=Wt(Or,t.__scopeMenu),n=_r(Or,t.__scopeMenu),a=xh(Or,t.__scopeMenu),i=wl(Or,t.__scopeMenu),o=T.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=i,c={__scopeMenu:t.__scopeMenu},d=T.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return T.useEffect(()=>d,[d]),T.useEffect(()=>{const u=s.current;return()=>{window.clearTimeout(u),l(null)}},[s,l]),y.jsx(Sl,{asChild:!0,...c,children:y.jsx(uh,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":Eh(r.open),...t,ref:Sr(e,a.onTriggerChange),onClick:u=>{t.onClick?.(u),!(t.disabled||u.defaultPrevented)&&(u.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:ie(t.onPointerMove,Pr(u=>{i.onItemEnter(u),!u.defaultPrevented&&!t.disabled&&!r.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{r.onOpenChange(!0),d()},100))})),onPointerLeave:ie(t.onPointerLeave,Pr(u=>{d();const p=r.content?.getBoundingClientRect();if(p){const f=r.content?.dataset.side,v=f==="right",m=v?-5:5,g=p[v?"left":"right"],w=p[v?"right":"left"];i.onPointerGraceIntentChange({area:[{x:u.clientX+m,y:u.clientY},{x:g,y:p.top},{x:w,y:p.top},{x:w,y:p.bottom},{x:g,y:p.bottom}],side:f}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(u),u.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:ie(t.onKeyDown,u=>{const p=i.searchRef.current!=="";t.disabled||p&&u.key===" "||sE[n.dir].includes(u.key)&&(r.onOpenChange(!0),r.content?.focus(),u.preventDefault())})})})});wh.displayName=Or;var Ch="MenuSubContent",kh=T.forwardRef((t,e)=>{const r=oh(qe,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,i=Wt(qe,t.__scopeMenu),o=_r(qe,t.__scopeMenu),s=xh(Ch,t.__scopeMenu),l=T.useRef(null),c=me(e,l);return y.jsx(Ar.Provider,{scope:t.__scopeMenu,children:y.jsx(wt,{present:n||i.open,children:y.jsx(Ar.Slot,{scope:t.__scopeMenu,children:y.jsx(Cl,{id:s.contentId,"aria-labelledby":s.triggerId,...a,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{o.isUsingKeyboardRef.current&&l.current?.focus(),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:ie(t.onFocusOutside,d=>{d.target!==s.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:ie(t.onEscapeKeyDown,d=>{o.onClose(),d.preventDefault()}),onKeyDown:ie(t.onKeyDown,d=>{const u=d.currentTarget.contains(d.target),p=lE[o.dir].includes(d.key);u&&p&&(i.onOpenChange(!1),s.trigger?.focus(),d.preventDefault())})})})})})});kh.displayName=Ch;function Eh(t){return t?"open":"closed"}function Nn(t){return t==="indeterminate"}function Tl(t){return Nn(t)?"indeterminate":t?"checked":"unchecked"}function _E(t){const e=document.activeElement;for(const r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function OE(t,e){return t.map((r,n)=>t[(e+n)%t.length])}function PE(t,e,r){const a=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=r?t.indexOf(r):-1;let o=OE(t,Math.max(i,0));a.length===1&&(o=o.filter(c=>c!==r));const l=o.find(c=>c.toLowerCase().startsWith(a.toLowerCase()));return l!==r?l:void 0}function IE(t,e){const{x:r,y:n}=t;let a=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){const s=e[i],l=e[o],c=s.x,d=s.y,u=l.x,p=l.y;d>n!=p>n&&r<(u-c)*(n-d)/(p-d)+c&&(a=!a)}return a}function NE(t,e){if(!e)return!1;const r={x:t.clientX,y:t.clientY};return IE(r,e)}function Pr(t){return e=>e.pointerType==="mouse"?t(e):void 0}var ME=ih,DE=Sl,zE=sh,LE=lh,jE=kl,WE=ch,BE=In,qE=ph,RE=mh,FE=gh,$E=yh,GE=bh,VE=Sh,HE=wh,UE=kh,Mn="DropdownMenu",[KE]=ot(Mn,[nh]),_e=nh(),[YE,Th]=KE(Mn),Ah=t=>{const{__scopeDropdownMenu:e,children:r,dir:n,open:a,defaultOpen:i,onOpenChange:o,modal:s=!0}=t,l=_e(e),c=T.useRef(null),[d,u]=xr({prop:a,defaultProp:i??!1,onChange:o,caller:Mn});return y.jsx(YE,{scope:e,triggerId:Yt(),triggerRef:c,contentId:Yt(),open:d,onOpenChange:u,onOpenToggle:T.useCallback(()=>u(p=>!p),[u]),modal:s,children:y.jsx(ME,{...l,open:d,onOpenChange:u,dir:n,modal:s,children:r})})};Ah.displayName=Mn;var _h="DropdownMenuTrigger",Oh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,i=Th(_h,r),o=_e(r);return y.jsx(DE,{asChild:!0,...o,children:y.jsx(he.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...a,ref:Sr(e,i.triggerRef),onPointerDown:ie(t.onPointerDown,s=>{!n&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:ie(t.onKeyDown,s=>{n||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})})});Oh.displayName=_h;var XE="DropdownMenuPortal",Ph=t=>{const{__scopeDropdownMenu:e,...r}=t,n=_e(e);return y.jsx(zE,{...n,...r})};Ph.displayName=XE;var Ih="DropdownMenuContent",Nh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=Th(Ih,r),i=_e(r),o=T.useRef(!1);return y.jsx(LE,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...n,ref:e,onCloseAutoFocus:ie(t.onCloseAutoFocus,s=>{o.current||a.triggerRef.current?.focus(),o.current=!1,s.preventDefault()}),onInteractOutside:ie(t.onInteractOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!a.modal||d)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Nh.displayName=Ih;var ZE="DropdownMenuGroup",QE=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(jE,{...a,...n,ref:e})});QE.displayName=ZE;var JE="DropdownMenuLabel",Mh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(WE,{...a,...n,ref:e})});Mh.displayName=JE;var eT="DropdownMenuItem",Dh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(BE,{...a,...n,ref:e})});Dh.displayName=eT;var tT="DropdownMenuCheckboxItem",zh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(qE,{...a,...n,ref:e})});zh.displayName=tT;var rT="DropdownMenuRadioGroup",Lh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(RE,{...a,...n,ref:e})});Lh.displayName=rT;var nT="DropdownMenuRadioItem",jh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(FE,{...a,...n,ref:e})});jh.displayName=nT;var aT="DropdownMenuItemIndicator",iT=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx($E,{...a,...n,ref:e})});iT.displayName=aT;var oT="DropdownMenuSeparator",Wh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(GE,{...a,...n,ref:e})});Wh.displayName=oT;var sT="DropdownMenuArrow",lT=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(VE,{...a,...n,ref:e})});lT.displayName=sT;var cT="DropdownMenuSubTrigger",Bh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(HE,{...a,...n,ref:e})});Bh.displayName=cT;var dT="DropdownMenuSubContent",qh=T.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,a=_e(r);return y.jsx(UE,{...a,...n,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});qh.displayName=dT;var uT=Ah,pT=Oh,fT=Ph,Rh=Nh,Fh=Mh,$h=Dh,Gh=zh,mT=Lh,Vh=jh,Hh=Wh,Uh=Bh,Kh=qh;const Dn=uT,zn=pT,hT=mT,gT=T.forwardRef(({className:t,inset:e,children:r,...n},a)=>y.jsx(Uh,{ref:a,className:pe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-gray-100 data-[state=open]:bg-gray-100",e&&"pl-8",t),...n,children:r}));gT.displayName=Uh.displayName;const vT=T.forwardRef(({className:t,...e},r)=>y.jsx(Kh,{ref:r,className:pe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white p-1 text-gray-900 shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...e}));vT.displayName=Kh.displayName;const Ir=T.forwardRef(({className:t,sideOffset:e=4,...r},n)=>{const{portalContainer:a}=zs();return y.jsx(fT,{container:a||void 0,children:y.jsx(Rh,{ref:n,sideOffset:e,"data-uhuu-editor":!0,className:pe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white p-1 text-gray-900 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})})});Ir.displayName=Rh.displayName;const Bt=T.forwardRef(({className:t,inset:e,...r},n)=>y.jsx($h,{ref:n,className:pe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e&&"pl-8",t),...r}));Bt.displayName=$h.displayName;const yT=T.forwardRef(({className:t,children:e,checked:r,...n},a)=>y.jsx(Gh,{ref:a,className:pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:r,...n,children:e}));yT.displayName=Gh.displayName;const Yh=T.forwardRef(({className:t,children:e,...r},n)=>y.jsx(Vh,{ref:n,className:pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:e}));Yh.displayName=Vh.displayName;const Al=T.forwardRef(({className:t,inset:e,...r},n)=>y.jsx(Fh,{ref:n,className:pe("px-2 py-1.5 text-sm font-medium",e&&"pl-8",t),...r}));Al.displayName=Fh.displayName;const Ln=T.forwardRef(({className:t,...e},r)=>y.jsx(Hh,{ref:r,className:pe("-mx-1 my-1 h-px bg-gray-200",t),...e}));Ln.displayName=Hh.displayName;const bT=(t,e)=>{if(t.stopPropagation(),e.onSelect){e.onSelect(t);return}e.dialog&&typeof window<"u"&&window.$uhuu?.editDialog?.(e.dialog)},_l=(t,e)=>{if(!t)return null;const r=t.trim();if(r.startsWith("<")){const a=r.replace(/<svg\b([^>]*)>/i,(i,o)=>{let s=o;return/\bwidth=/.test(s)?s=s.replace(/\bwidth=(\"[^\"]*\"|'[^']*'|[^\s>]+)/i,'width="100%"'):s+=' width="100%"',/\bheight=/.test(s)?s=s.replace(/\bheight=(\"[^\"]*\"|'[^']*'|[^\s>]+)/i,'height="100%"'):s+=' height="100%"',/\bpreserveAspectRatio=/.test(s)?s=s.replace(/\bpreserveAspectRatio=(\"[^\"]*\"|'[^']*'|[^\s>]+)/i,'preserveAspectRatio="xMidYMid slice"'):s+=' preserveAspectRatio="xMidYMid slice"',`<svg${s}>`});return y.jsx("div",{className:pe("pointer-events-none absolute inset-0 z-10",e),"aria-hidden":"true",dangerouslySetInnerHTML:{__html:a}})}return y.jsx("img",{src:t,alt:"","aria-hidden":"true",className:pe("pointer-events-none absolute inset-0 z-10 h-full w-full object-cover",e)})},Ol=(t,e)=>e?y.jsx("div",{className:"absolute right-2 top-2 z-20",children:y.jsxs(Dn,{modal:!1,children:[y.jsx(zn,{asChild:!0,children:y.jsx(Ae,{variant:"secondary",size:"icon",title:"Image options",className:"h-7 w-7 shadow-sm",onPointerDown:r=>r.stopPropagation(),onClick:r=>r.stopPropagation(),children:y.jsx(mf,{className:"h-4 w-4"})})}),y.jsx(Ir,{className:"w-40 p-1.5",align:"end",children:t.map(r=>y.jsxs(Bt,{onSelect:n=>bT(n,r),disabled:r.disabled,children:[r.icon&&y.jsx("span",{className:"mr-2 inline-flex",children:r.icon}),y.jsx("span",{children:r.label})]},r.id))})]})}):null,Pl=(t=[])=>{const e=js();return t.length>0&&!e},ST=({className:t,style:e,overlaySvg:r,overlayClassName:n,options:a=[],dialog:i,dialogProps:o,bleedProps:s,children:l})=>{const c=O.useContext(Mt),d=Pl(a),u=i?Kt({dialog:i},c):{};return T.useMemo(()=>{if(!o)return u;const p={...u,...o};return(u.className||o.className)&&(p.className=`${u.className||""} ${o.className||""}`.trim()),Object.keys(u).forEach(f=>{const v=u[f],m=o[f];f.startsWith("on")&&typeof v=="function"&&typeof m=="function"&&(p[f]=g=>{v(g),m(g)})}),p},[u,o]),y.jsxs(y.Fragment,{children:[y.jsxs(Ns,{...s,dialog:i,children:[_l(r,n),l]}),Ol(a,d)]})};function Il(t){const e=O.useContext(Mt),r=t.bleed??e?.page?.bleed??0,n=t.pageWidth??e?.page?.width??210,a=t.pageHeight??e?.page?.height??297,{src:i,side:o,backgroundColor:s,width:l,height:c,left:d=0,right:u=0,top:p=0,bottom:f=0}=t,[v,m]=O.useState("h-full w-full object-cover object-center"),g=D=>`${D}mm`,w=()=>{let D=l;return l||(D=2*n,d||(D+=2*r),u||(D+=2*r),(d||u)&&(D-=(d??0)+(u??0))),D},x=()=>{let D=c;return c||(D=a,p||(D+=r),f||(D+=r),(p||f)&&(D-=(p??0)+(f??0))),D},h=w(),b=x(),S=D=>D!==void 0?g(D):void 0,E=D=>Object.fromEntries(Object.entries(D).filter(([F,R])=>R!==void 0)),k=d>0?d+r:-1*r,C=p>0?p+r:-1*r,A=f>0?f+r:-1*r,_=-1*n+k,I=p>0&&f>0,M=E({backgroundColor:s,width:S(h),...I?{height:S(b)}:{},left:S(k),top:S(C),bottom:S(A)}),z=E({width:S(h),...I?{height:S(b)}:{},left:S(_),top:S(C),bottom:S(A)}),q=b!=0?h/b:h/(a-(p??0)-(f??0)),H=D=>{let R=D.target.naturalWidth/D.target.naturalHeight>q?"cover-vertical":"cover-horizontal";m(R)};return y.jsx("div",{className:"uhuu-image-container",style:o=="end"?z:M,...t.dataUhuu!==void 0?{"data-uhuu":t.dataUhuu}:{},children:y.jsxs("div",{className:"uhuu-image-inner",...Kt(t,e),children:[y.jsx("img",{className:v,src:i,onLoad:D=>H(D)},`${i}-${h}-${b}`),t.children]})})}const xT=({overlaySvg:t,overlayClassName:e,options:r=[],dialog:n,spreadProps:a,children:i})=>{const o=Pl(r);return y.jsxs(y.Fragment,{children:[y.jsxs(Il,{...a,dialog:n,children:[_l(t,e),i]}),Ol(r,o)]})},wT=({src:t,alt:e="",className:r,imageClassName:n,style:a,imageStyle:i,overlaySvg:o,overlayClassName:s,options:l=[],dialog:c,dialogProps:d,placeholder:u,children:p,imageProps:f,renderImage:v})=>{const m=O.useContext(Mt),g=c?Kt({dialog:c},m):{},w=Pl(l),x=T.useMemo(()=>{if(!d)return g;const C={...g,...d};return(g.className||d.className)&&(C.className=pe(g.className,d.className)),Object.keys(g).forEach(A=>{const _=g[A],I=d[A];A.startsWith("on")&&typeof _=="function"&&typeof I=="function"&&(C[A]=M=>{_(M),I(M)})}),C},[g,d]),h=()=>{const C=f?.className,A=f?.style,_=f?.src??t,I=f?.alt??e,M={...f,src:_,alt:I,className:pe("h-full w-full object-cover",n,C),style:{...i,...A}};return v?v(M):_?y.jsx("img",{...M}):u??null},b=x["data-uhuu"],S=T.Children.toArray(p).some(C=>T.isValidElement(C)?C.type===Il||C.type===Ns:!1);S&&delete x["data-uhuu"];const E=T.Children.map(p,C=>T.isValidElement(C)?T.cloneElement(C,{dataUhuu:b}):C),k=S?"relative h-full w-full":"relative";return y.jsxs("div",{className:pe(k,r),style:a,children:[y.jsxs("div",{className:"relative h-full w-full",...x,children:[h(),E,_l(o,s)]}),Ol(l,w)]})},CT=t=>{const{computedOverlaySvg:e,computedOptions:r,computedDirectDialog:n}=O.useMemo(()=>{const{annotation:H,dialog:D,overlaySvg:F,options:R,src:P}=t;if(!H&&!D)return{computedOverlaySvg:F,computedOptions:R,computedDirectDialog:void 0};const j=H?.value||{},K=F??j.annotationSvg??"",X=[];if(H){if(D){const $={...D};if(D.type==="satellite"){const{path:Z,type:se,...le}=D;$.config={...le,path:"image"},$.path=Z,$.type=se}X.push({id:"edit",label:"Edit image",dialog:$})}const B=Array.isArray(j.annotations)?j.annotations:[],{path:V,value:U,annotations:oe,...ae}=H,N={path:H.path,type:"annotation",image:P,annotations:B,...ae};X.push({id:"annotate",label:"Annotate",dialog:N})}const W=R?[...X,...R]:X;let L;if(D){const B={...D};if(D.type==="satellite"){const{path:V,type:U,...oe}=D;B.config={...oe,path:"image"},B.path=V,B.type=U}L=B}return{computedOverlaySvg:K,computedOptions:W.length>0?W:void 0,computedDirectDialog:L}},[t.annotation,t.dialog,t.overlaySvg,t.options,t.src]),a=O.useMemo(()=>t.mode?t.mode:t.side!==void 0?"spread":t.width!==void 0||t.height!==void 0||t.left!==void 0||t.right!==void 0||t.top!==void 0||t.bottom!==void 0?"bleed":"auto",[t.mode,t.side,t.width,t.height,t.left,t.right,t.top,t.bottom]),i=a==="auto"||r&&r.length>0||e||n||t.renderImage!==void 0||t.placeholder!==void 0||t.children!==void 0,{mode:o,side:s,src:l,alt:c,className:d,imageClassName:u,style:p,imageStyle:f,backgroundColor:v,width:m,height:g,left:w,right:x,top:h,bottom:b,pageWidth:S,pageHeight:E,bleed:k,overlayClassName:C,dialogProps:A,placeholder:_,children:I,imageProps:M,renderImage:z}=t,q={src:l,backgroundColor:v,width:m,height:g,left:w,right:x,top:h,bottom:b,pageWidth:S,pageHeight:E,bleed:k};if(a==="auto")return y.jsx(wT,{src:l,alt:c,className:d,style:p,imageClassName:u,imageStyle:f,overlaySvg:e,overlayClassName:C,options:r,dialog:n,dialogProps:A,placeholder:_,children:I,imageProps:M,renderImage:z});if(a==="spread"){const H={...q,side:s};return i&&(e||r?.length||n)?y.jsx(xT,{className:d,style:p,overlaySvg:e,overlayClassName:C,options:r,dialog:n,dialogProps:A,spreadProps:H,children:I}):y.jsx(Il,{...H})}return i&&(e||r?.length||n)?y.jsx(ST,{className:d,style:p,overlaySvg:e,overlayClassName:C,options:r,dialog:n,dialogProps:A,bleedProps:q,children:I}):y.jsx(Ns,{...q})},kT=t=>{const e=O.useContext(Mt);return y.jsx("div",{className:t.className,...Kt(t,e),children:t.children})},qt="uhuu_page_editor";function Oe(t){return t.kind==="group"}function ET(t){const e=[];let r=1;for(const n of t)if(Oe(n))for(const a of n.pages)e.push({...a,kind:"page",pageNum:r++});else e.push({...n,pageNum:r++});return e}function TT(t){const e=[];let r=1;for(const n of t)if(Oe(n)){const a=n.pages.map(i=>({...i,kind:"page",pageNum:r++}));e.push({...n,pages:a})}else e.push({...n,pageNum:r++});return e}function Ct(t){return ET(t).length}function AT(t){return t.map(e=>{const r=e.strictPosition;if(Oe(e)){const n=e.pages[0],a=n?.componentKey??n?.id;return{kind:"group",id:e.id,groupId:e.id,firstPageId:n?.id,firstPageComponentKey:a,firstPageComponent:n?.component,pageCount:e.pages.length,label:e.label||`${e.id} (${e.pages.length} pages)`,strictPosition:r}}else{const n=e.componentKey??e.id;return{kind:"page",id:e.id,label:e.label,pageId:e.id,pageComponentKey:n,pageLabel:e.label,pageNum:e.pageNum,pageComponent:e.component,strictPosition:r}}})}function _T(t,e){const r=new Map;e.forEach(a=>{r.set(a.id,a)});const n=[];for(const a of t){const i=r.get(a.id);i&&n.push(i)}return n}function Nl(t){return t.map(e=>{if("kind"in e&&e.kind)return e;if(e.pages&&Array.isArray(e.pages))return{kind:"group",...e,pages:(e.pages??[]).map(i=>{const{kind:o,...s}=i||{};return{kind:"page",...s}})};const{kind:n,...a}=e;return{kind:"page",...a}})}function Xh(t,e=qt){const r=Nl(t);return{key:e,items:r,totalPages:Ct(r),updatedAt:new Date().toISOString()}}function OT(t,e=qt){const r=t?.[e];if(!r?.items)return null;const n=Nl(r.items);return{key:e,items:n,totalPages:Ct(n),updatedAt:r.updatedAt||new Date().toISOString()}}function PT(t,e,r=qt){const n=Xh(e,r);return{...t??{},[r]:n}}function Zh(){return Math.random().toString(36).slice(2,11)}function Qh(t,e,r){return{kind:"page",id:r?.repeatable?Zh():t,componentKey:e,templateId:t,label:r?.label,repeatable:r?.repeatable,maxInstances:r?.maxInstances,...r}}function Jh(t,e,r){const n=r?.repeatable?Zh():t;return{kind:"group",id:n,templateId:t,label:r?.label,repeatable:r?.repeatable??!1,maxInstances:r?.maxInstances??null,pages:e.map((a,i)=>{const o=typeof a=="string"?a:a.key,s=typeof a=="string"?void 0:a.dataKey;return{id:`${n}__${s??o}__${i}`,componentKey:o,templateId:o,...s?{dataKey:s}:{}}}),...r}}function eg(t,e){return t<0?e+t+1:t}function tg(t,e,r){for(const n of e){const a=eg(n.start,r),i=eg(n.end,r);if(t>=a&&t<=i)return!0}return!1}function IT(t,e,r=2){switch(t){case"all":return[{start:1,end:e}];case"cover":return[{start:1,end:r},{start:-r,end:-1}];case"text":return e<=r*2?[]:[{start:r+1,end:-(r+1)}];default:return[]}}function NT(t,e){if(!e||e.mode==="all")return t;const r=Ct(t),n=e.mode??"all",a=e.coverPageCount??2,i=n==="custom"&&e.ranges?e.ranges:IT(n,r,a);if(i.length===0)return[];const o=[];for(const s of t)if(Oe(s)){const l=s.pages.filter(c=>c.pageNum&&tg(c.pageNum,i,r));l.length>0&&o.push({...s,pages:l})}else s.pageNum&&tg(s.pageNum,i,r)&&o.push(s);return o}function rg(t,e){if(t?.integrations)return t.integrations[e]}function MT(t,e){return e&&Oe(e)?e.id:t?.id??null}function ng(t,e,r){const n=MT(e,r);return n?{instanceId:n,integration:rg(t,n)}:{instanceId:null,integration:void 0}}function ag(t,e,r){return ng(t,e,r).integration}function ig(t,e){if(!t)return null;const r=`integrations.${t}`;return e?`${r}.${e}`:r}function DT(t){if(!t)return{instanceId:null,fieldPath:t,isIntegrationPath:!1};const e="integrations.";if(t.startsWith(e)){const r=t.slice(e.length),n=r.indexOf(".");if(n>0){const a=r.slice(0,n),i=r.slice(n+1);return{instanceId:a,fieldPath:i,isIntegrationPath:!0}}else return{instanceId:r,fieldPath:"",isIntegrationPath:!0}}return{instanceId:null,fieldPath:t,isIntegrationPath:!1}}function zT(t,e,r){if(!e)return r;const n=e.split("."),a={...t};let i=a;for(let s=0;s<n.length-1;s++){const l=n[s];!(l in i)||typeof i[l]!="object"||i[l]===null?i[l]={}:i[l]={...i[l]},i=i[l]}const o=n[n.length-1];return i[o]=r,a}function LT(t,e,r){const n=DT(e);if(!n.isIntegrationPath||!n.instanceId)return t;const{instanceId:a,fieldPath:i}=n,o=rg(t,a)||{},s=zT(o,i,r);return{...t,integrations:{...t?.integrations||{},[a]:s}}}function jn(t,e){if(!t||!e)return;const r=typeof e=="string"?e:e?.id,n=typeof e=="string"?void 0:e?.templateId??e?.componentKey,a=typeof e=="string"?void 0:e?.componentKey,i=Array.from(new Set([r,n,a].filter(Boolean)));for(const o of i)if(t?.pages?.[o]!==void 0)return t.pages[o];for(const o of i)if(t?.groups?.[o]!==void 0)return t.groups[o];for(const o of i)if(t[o]!==void 0)return t[o]}const Nr=T.createContext(null);function jT(t=qt){return[t]}function WT(t,e,r){if(!e)return t;if(!t)return e;const n={...e};return r.forEach(a=>{t[a]!==void 0&&(n[a]=t[a])}),n}function og({payload:t,onPayloadChange:e,children:r,stateKey:n=qt}){const[a,i]=T.useState(t??{}),o=T.useRef(null),s=T.useRef(!1),l=T.useRef(null),c=T.useRef(0),d=T.useRef(!0),u=T.useCallback(C=>{try{return JSON.stringify(C)}catch{return String(C)}},[]),p=T.useMemo(()=>jT(n),[n]),f=T.useCallback((C,A)=>{if(!C)return null;const _={...C};return A.forEach(I=>{delete _[I]}),_},[]);T.useEffect(()=>{if(d.current){d.current=!1,t&&(o.current=t,i(t));return}if(s.current){s.current=!1,l.current=t,c.current=Date.now(),o.current=t;return}if(t===o.current)return;if(Date.now()-c.current<500&&l.current!==null){const _=f(t,p),I=f(l.current,p),M=_?u(_):null,z=I?u(I):null;if(M&&M===z){l.current=null,o.current=t;return}}o.current=t,i(_=>t?WT(_,t,p):_)},[t,p,u,f]);const v=T.useCallback(C=>{e?.(C),typeof window<"u"&&window.$uhuu?.initPayload&&window.$uhuu.initPayload(C)},[e]),m=T.useCallback(C=>{s.current=!0,i(A=>{const _=typeof C=="function"?C(A):C;let I=_;return _&&typeof _=="object"&&Object.keys(_).filter(z=>z.startsWith("integrations.")||z==="integrations").length>0&&_.integrations&&(I=_),l.current=I,c.current=Date.now(),v(I),I})},[v]),g=T.useCallback((C,A,_)=>{m(I=>({...I??{},pages:{...I?.pages??{},[C]:{...I?.pages?.[C]??{},[A]:_}}}))},[m]),w=T.useCallback((C,A)=>{m(_=>{const I=_?.integrations??{},M=I[C],z=typeof A=="function"?A(M):A;return{..._??{},integrations:{...I,[C]:z}}})},[m]),x=T.useCallback((C,A,_)=>{w(C,I=>({...I??{},[A]:_}))},[w]),h=T.useCallback(C=>{m(A=>{if(!A?.integrations||!A.integrations[C])return A;const{[C]:_,...I}=A.integrations;return{...A,integrations:Object.keys(I).length>0?I:void 0}})},[m]),b=T.useCallback((C,A)=>{m(_=>LT(_,C,A))},[m]),S=T.useCallback((C,A)=>{const _=A??n;m(I=>PT(I,C,_))},[m,n]),E=T.useCallback(C=>jn(a,C),[a]),k=T.useMemo(()=>({payload:a,setPayload:m,setPageOptionValue:g,setIntegrationPayload:w,setIntegrationPayloadValue:x,removeIntegrationPayload:h,updateIntegrationByDialogPath:b,mergePageEditorState:S,getPagePayload:E}),[a,m,g,w,x,h,b,S,E]);return y.jsx(Nr.Provider,{value:k,children:r})}function BT(t){return t.defaultValue!==void 0?t.defaultValue:t.type==="toggle"?!1:t.type==="slider"||t.type==="counter"?0:""}function qT(t,e){return t.type==="toggle"?e===!0||e==="true":t.type==="slider"||t.type==="counter"?Number(e):e}function RT(t,e,r){const n=t.field??t.id;return{...t,getValue:i=>{const o=e?.pages?.[i.id]?.[n];return o===void 0?BT(t):t.type==="toggle"?!!o:o},onChange:(i,o)=>{r(i,n,qT(t,o))}}}const Wn=O.createContext({zoom:100,scaleValue:1,hideUI:!1});function FT({children:t,layout:e="spread"}){const{scaleValue:r}=O.useContext(Wn),n=O.useRef(null);return O.useEffect(()=>{if(!n.current)return;const a=()=>{const s=n.current?.querySelectorAll("[data-section-content]");if(!s?.length)return;const l=Array.from(s).reduce((c,d)=>{const u=Number.parseInt(d.getAttribute("data-natural-width")||"0");return c+u},0);if(l>0){const c=l*r;n.current?.style.setProperty("--uhuu-group-pair-width",`${c}px`)}};a();const i=new ResizeObserver(a);return n.current.querySelectorAll("[data-section-content]").forEach(s=>i.observe(s)),()=>i.disconnect()},[t,r]),y.jsx("div",{ref:n,className:`two-pages-pair two-pages-pair--${e}`,children:t})}function Bn({children:t,title:e,className:r="",controls:n,origin:a="center"}){const{scaleValue:i,hideUI:o}=O.useContext(Wn),s=O.useRef(null),[l,c]=O.useState(0),[d,u]=O.useState(0);O.useEffect(()=>{if(s.current){const w=()=>{const h=s.current;if(h){const b=h.style.transform;h.style.transform="scale(1)";const S=h.scrollHeight,E=h.scrollWidth;h.style.transform=b,c(S),u(E)}};w();const x=new ResizeObserver(w);return x.observe(s.current),()=>{x.disconnect()}}},[t]);const p=l*i,f=Math.max(d*i,150),v={left:{justify:"justify-start",origin:"top left"},right:{justify:"justify-end",origin:"top right"},center:{justify:"justify-center",origin:"top center"}},{justify:m,origin:g}=v[a];return o?y.jsx("div",{className:r,children:t}):y.jsxs("div",{className:`group/section ${r}`,style:{width:`${f}px`,minWidth:"150px"},children:[y.jsx("div",{children:n??y.jsx("div",{className:"px-4 py-2 border-b border-gray-200",children:y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:[e," Controls"]})})}),y.jsx("div",{className:"pt-1",style:{height:p>0?`${p+32}px`:"auto",minHeight:"100px"},children:y.jsx("div",{className:`flex items-start ${m}`,children:y.jsx("div",{ref:s,"data-section-content":!0,"data-natural-width":d,"data-natural-height":l,style:{transform:`scale(${i})`,transformOrigin:g},children:t})})})]})}function $T({children:t,className:e="",defaultZoom:r=100,minZoom:n=25,maxZoom:a=200,onAddPage:i,menuItems:o,hideUI:s,preview:l="single_page"}){const c=js(),d=s??c,[u,p]=O.useState(r),[f,v]=O.useState("none"),m=O.useRef(null),g=O.useRef(null),[w,x]=O.useState(!1),[h,b]=O.useState(0),[S,E]=O.useState(!0),k=M=>{if(!m.current||!g.current)return u;const z=m.current.getBoundingClientRect(),q=g.current.querySelector("[data-section-content]");if(!q)return u;let H=Number.parseInt(q.getAttribute("data-natural-width")||"0");const D=Number.parseInt(q.getAttribute("data-natural-height")||"0");if(H===0||D===0)return u;l==="two_pages"&&(H=H*2);const F=z.width-32,R=screen.height-120,P=F/H*100,j=R/D*100;switch(M){case"width":return Math.min(Math.max(P,n),a);case"height":return Math.min(Math.max(j,n),a);case"both":return Math.min(Math.max(Math.min(P,j),n),a);default:return u}},C=M=>{if(v(M),M!=="none"){const z=k(M);p(z)}},A=()=>{const M=Math.min(u+25,a);p(M),v("none")},_=()=>{const M=Math.max(u-25,n);p(M),v("none")};O.useEffect(()=>{const M=()=>{if(!m.current||!g.current)return;const H=m.current.getBoundingClientRect().width;if(!w){const D=g.current.querySelector("[data-section-content]");if(D){const F=Number.parseInt(D.getAttribute("data-natural-width")||"0");if(F>0){if(F>H-48){const R=k("both");v("both"),p(R)}x(!0),b(H),E(!1);return}}if(S){setTimeout(M,50);return}}E(!1)},z=()=>{if(!m.current||S)return;const H=m.current.getBoundingClientRect().width;if(Math.abs(H-h)>10){if(f!=="none"){const D=k(f);p(D)}b(H)}};return M(),window.addEventListener("resize",z),()=>{window.removeEventListener("resize",z)}},[f,n,a,w,h,S]);const I=u/100;return d?y.jsx(Wn.Provider,{value:{zoom:100,scaleValue:1,hideUI:!0},children:y.jsx("div",{className:e,children:t})}):y.jsx(Wn.Provider,{value:{zoom:u,scaleValue:I,hideUI:!1},children:y.jsxs("div",{ref:m,className:`flex flex-col min-h-0 ${e}`,children:[y.jsxs("div",{"data-uhuu-editor":!0,className:"fixed right-4 bottom-4 z-50 flex items-center gap-1.5 px-2.5 py-1.5 bg-white/90 backdrop-blur-md border border-gray-200/60 rounded-lg shadow-sm",children:[o,y.jsx("div",{className:"h-4 w-px bg-gray-200 mx-0.5"}),y.jsxs(Dn,{modal:!1,children:[y.jsx(zn,{asChild:!0,children:y.jsxs(Ae,{variant:"ghost",size:"sm",title:"Zoom",className:"text-xs font-medium text-gray-700 hover:bg-gray-100/80 h-7 px-2.5",children:[Math.round(u),"%",y.jsx(aw,{className:"w-3 h-3 ml-1 opacity-60"})]})}),y.jsxs(Ir,{className:"w-52 p-1.5",align:"end",children:[y.jsxs(Bt,{onClick:()=>C("width"),className:`cursor-pointer flex items-center ${f==="width"?"bg-gray-100":""}`,children:[y.jsx(uw,{className:"w-4 h-4 mr-2"}),y.jsx("span",{children:"Fit to Width"})]}),y.jsxs(Bt,{onClick:()=>C("height"),className:`cursor-pointer flex items-center ${f==="height"?"bg-gray-100":""}`,children:[y.jsx(pw,{className:"w-4 h-4 mr-2"}),y.jsx("span",{children:"Fit to Height"})]}),y.jsxs(Bt,{onClick:()=>C("both"),className:`cursor-pointer flex items-center ${f==="both"?"bg-gray-100":""}`,children:[y.jsx(sw,{className:"w-4 h-4 mr-2"}),y.jsx("span",{children:"Fit to Page"})]}),y.jsx(Ln,{className:"my-1.5"}),y.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-2.5",onClick:M=>M.stopPropagation(),children:[y.jsx(Ae,{variant:"ghost",size:"sm",onClick:M=>{M.stopPropagation(),_()},disabled:u<=n,className:"h-8 w-8 p-0 hover:bg-gray-100 disabled:opacity-40",title:"Zoom out (25%)",children:y.jsx(mw,{className:"w-4 h-4"})}),y.jsxs("div",{className:"relative",children:[y.jsx("input",{type:"number",value:Math.round(u),onChange:M=>{const z=Number.parseInt(M.target.value);if(!isNaN(z)){const q=Math.min(Math.max(z,n),a);p(q),v("none")}},onFocus:M=>M.target.select(),className:"w-20 pr-6 text-center text-sm text-gray-700 bg-white border border-gray-300 rounded px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all",min:n,max:a}),y.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-gray-400 pointer-events-none",children:"%"})]}),y.jsx(Ae,{variant:"ghost",size:"sm",onClick:M=>{M.stopPropagation(),A()},disabled:u>=a,className:"h-8 w-8 p-0 hover:bg-gray-100 disabled:opacity-40",title:"Zoom in (25%)",children:y.jsx(fw,{className:"w-4 h-4"})})]})]})]})]}),y.jsx("div",{ref:g,children:y.jsx("div",{className:l==="two_pages"?"group_two_pages":"flex flex-col items-center",children:t})}),y.jsx("div",{className:"flex justify-center pb-16",children:y.jsx(Ae,{size:"sm",variant:"outline",onClick:()=>i?i():null,children:y.jsx(mt,{})})})]})})}var qn="Dialog",[sg,lg]=ot(qn),[GT,He]=sg(qn),cg=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:o=!0}=t,s=T.useRef(null),l=T.useRef(null),[c,d]=xr({prop:n,defaultProp:a??!1,onChange:i,caller:qn});return y.jsx(GT,{scope:e,triggerRef:s,contentRef:l,contentId:Yt(),titleId:Yt(),descriptionId:Yt(),open:c,onOpenChange:d,onOpenToggle:T.useCallback(()=>d(u=>!u),[d]),modal:o,children:r})};cg.displayName=qn;var dg="DialogTrigger",ug=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(dg,r),i=me(e,a.triggerRef);return y.jsx(he.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":zl(a.open),...n,ref:i,onClick:ie(t.onClick,a.onOpenToggle)})});ug.displayName=dg;var Ml="DialogPortal",[VT,pg]=sg(Ml,{forceMount:void 0}),fg=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:a}=t,i=He(Ml,e);return y.jsx(VT,{scope:e,forceMount:r,children:T.Children.map(n,o=>y.jsx(wt,{present:r||i.open,children:y.jsx(dl,{asChild:!0,container:a,children:o})}))})};fg.displayName=Ml;var Rn="DialogOverlay",mg=T.forwardRef((t,e)=>{const r=pg(Rn,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,i=He(Rn,t.__scopeDialog);return i.modal?y.jsx(wt,{present:n||i.open,children:y.jsx(UT,{...a,ref:e})}):null});mg.displayName=Rn;var HT=wr("DialogOverlay.RemoveScroll"),UT=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(Rn,r);return y.jsx(yl,{as:HT,allowPinchZoom:!0,shards:[a.contentRef],children:y.jsx(he.div,{"data-state":zl(a.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),Rt="DialogContent",hg=T.forwardRef((t,e)=>{const r=pg(Rt,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,i=He(Rt,t.__scopeDialog);return y.jsx(wt,{present:n||i.open,children:i.modal?y.jsx(KT,{...a,ref:e}):y.jsx(YT,{...a,ref:e})})});hg.displayName=Rt;var KT=T.forwardRef((t,e)=>{const r=He(Rt,t.__scopeDialog),n=T.useRef(null),a=me(e,r.contentRef,n);return T.useEffect(()=>{const i=n.current;if(i)return $m(i)},[]),y.jsx(gg,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ie(t.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:ie(t.onPointerDownOutside,i=>{const o=i.detail.originalEvent,s=o.button===0&&o.ctrlKey===!0;(o.button===2||s)&&i.preventDefault()}),onFocusOutside:ie(t.onFocusOutside,i=>i.preventDefault())})}),YT=T.forwardRef((t,e)=>{const r=He(Rt,t.__scopeDialog),n=T.useRef(!1),a=T.useRef(!1);return y.jsx(gg,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{t.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{t.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;r.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),gg=T.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=t,s=He(Rt,r),l=T.useRef(null),c=me(e,l);return Xf(),y.jsxs(y.Fragment,{children:[y.jsx(Ys,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:y.jsx(Vs,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":zl(s.open),...o,ref:c,onDismiss:()=>s.onOpenChange(!1)})}),y.jsxs(y.Fragment,{children:[y.jsx(ZT,{titleId:s.titleId}),y.jsx(JT,{contentRef:l,descriptionId:s.descriptionId})]})]})}),Dl="DialogTitle",vg=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(Dl,r);return y.jsx(he.h2,{id:a.titleId,...n,ref:e})});vg.displayName=Dl;var yg="DialogDescription",bg=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(yg,r);return y.jsx(he.p,{id:a.descriptionId,...n,ref:e})});bg.displayName=yg;var Sg="DialogClose",xg=T.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,a=He(Sg,r);return y.jsx(he.button,{type:"button",...n,ref:e,onClick:ie(t.onClick,()=>a.onOpenChange(!1))})});xg.displayName=Sg;function zl(t){return t?"open":"closed"}var wg="DialogTitleWarning",[XT,Cg]=oC(wg,{contentName:Rt,titleName:Dl,docsSlug:"dialog"}),ZT=({titleId:t})=>{const e=Cg(wg),r=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
875
875
 
876
876
  If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
877
877