uhuu-components 0.2.51 → 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.
package/uhuu-components.umd.js
CHANGED
|
@@ -871,11 +871,11 @@ ${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
|
|
|
878
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return T.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},QT="DialogDescriptionWarning",JT=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Cg(QT).contentName}}.`;return T.useEffect(()=>{const a=t.current?.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},kg=cg,eA=ug,Eg=fg,Ll=mg,jl=hg,Wl=vg,Bl=bg,ql=xg;const Tg=kg,tA=Eg,Ag=T.forwardRef(({className:t,...e},r)=>y.jsx(Ll,{className:pe("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));Ag.displayName=Ll.displayName;const Rl=T.forwardRef(({side:t="right",className:e,children:r,...n},a)=>{const{portalContainer:i}=zs();return y.jsxs(tA,{container:i||void 0,children:[y.jsx(Ag,{}),y.jsxs(jl,{ref:a,className:pe("fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",t==="top"&&"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",t==="bottom"&&"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",t==="left"&&"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",t==="right"&&"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",e),...n,children:[r,y.jsxs(ql,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100",children:[y.jsx(hf,{className:"h-4 w-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Rl.displayName=jl.displayName;const Fl=({className:t,...e})=>y.jsx("div",{className:pe("flex flex-col space-y-2 text-center sm:text-left",t),...e});Fl.displayName="SheetHeader";const _g=({className:t,...e})=>y.jsx("div",{className:pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});_g.displayName="SheetFooter";const $l=T.forwardRef(({className:t,...e},r)=>y.jsx(Wl,{ref:r,className:pe("text-lg font-medium text-gray-900",t),...e}));$l.displayName=Wl.displayName;const Gl=T.forwardRef(({className:t,...e},r)=>y.jsx(Bl,{ref:r,className:pe("text-sm text-gray-500",t),...e}));Gl.displayName=Bl.displayName;function Vl(t){const{pageComponents:e,payload:r,setup:n={width:210,height:297},thumbnailWidth:a=200,thumbnailHeight:i}=t,o=n.width||210,s=n.height||297,l=o/s,c=a,d=i??Math.round(c/l),u=o*3.779527559,p=s*3.779527559;return(f,v,m)=>{const g=f.strictPosition,w=g==="start"||g==="end";if(f.kind==="group"){const x=f.firstPageId,h=f.firstPageComponentKey??x,b=jn(r,{id:x,componentKey:h}),S=f.firstPageComponent||(h?e[h]:null),E=r?.integrations?.[f.id];return y.jsxs("div",{className:`relative bg-white border transition-all ${m?"border-blue-400 shadow-2xl scale-105":w?"border-gray-300 bg-gray-50":"border-gray-200 hover:border-gray-300 hover:shadow-lg"}`,style:{width:`${c}px`,height:`${d}px`},title:f.id,children:[S?y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 overflow-hidden relative pointer-events-none",children:y.jsx("div",{style:{transform:`scale(${Math.min(c/u,d/p)})`,transformOrigin:"center"},children:y.jsx("div",{className:"!shrink-0",style:{width:`${u}px`,height:`${p}px`,backgroundColor:"white",pointerEvents:"none"},children:y.jsx(S,{payload:r,pageId:x,templateId:h,pagePayload:b,componentKey:h,integration:E})})})}):y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 pointer-events-none",children:y.jsxs("div",{className:"text-center p-4",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:["Group ",f.id]}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x||"No preview"})]})}),y.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 bg-blue-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none",children:["Group (",f.pageCount," pages)"]}),w&&y.jsxs("div",{className:"absolute top-2 left-2 px-2 py-1 bg-gray-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none flex items-center gap-1",children:[y.jsx(Ds,{className:"size-3"}),y.jsx("span",{children:g==="start"?"Start":"End"})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:f.label||f.id})})})}),m&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/10 pointer-events-none",children:y.jsx("div",{className:"text-blue-600 font-medium text-sm bg-white/90 px-3 py-1 rounded-full shadow-lg",children:"Dragging Group..."})})]})}else{const x=f.pageId,h=f.pageComponentKey??x,b=jn(r,{id:x,componentKey:h}),S=f.pageComponent||(h?e[h]:null),E=x?ag(r,{id:x}):void 0;return y.jsxs("div",{className:`relative bg-white border transition-all ${m?"border-blue-400 shadow-2xl scale-105":w?"border-gray-300 bg-gray-50":"border-gray-200 hover:border-gray-300 hover:shadow-lg"}`,style:{width:`${c}px`,height:`${d}px`},title:f.pageId,children:[S?y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 overflow-hidden relative pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-center pointer-events-none",style:{transform:`scale(${Math.min(c/u,d/p)})`,transformOrigin:"center"},children:y.jsx("div",{className:"!shrink-0",style:{width:`${u}px`,height:`${p}px`,backgroundColor:"white",pointerEvents:"none"},children:y.jsx(S,{payload:r,pageId:x,templateId:h,pagePayload:b,componentKey:h,integration:E})})})}):y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 pointer-events-none",children:y.jsxs("div",{className:"text-center p-4",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:["Page ",f.pageNum]}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x||"No preview"})]})}),w&&y.jsxs("div",{className:"absolute top-2 left-2 px-2 py-1 bg-gray-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none flex items-center gap-1",children:[y.jsx(Ds,{className:"size-3"}),y.jsx("span",{children:g==="start"?"Start":"End"})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:f.pageLabel||`Page ${f.pageNum}`})})})}),m&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/10 pointer-events-none",children:y.jsx("div",{className:"text-blue-600 font-medium text-sm bg-white/90 px-3 py-1 rounded-full shadow-lg",children:"Dragging..."})})]})}}}function rA({open:t,onOpenChange:e,availableItems:r,onSelectItem:n,pageComponents:a,payload:i,setup:o={width:210,height:297},gridColsClass:s="page-order-grid-cols"}){const[l,c]=T.useState(""),d=T.useMemo(()=>{if(!l.trim())return r;const b=l.toLowerCase();return r.filter(S=>(S.label||"").toLowerCase().includes(b)||S.id.toLowerCase().includes(b))},[r,l]),u=b=>{e(!1),n(b)},p=o.width||210,f=o.height||297,v=p/f,m=200,g=Math.round(m/v),w=T.useMemo(()=>a?Vl({pageComponents:a,payload:i,setup:o,thumbnailWidth:m,thumbnailHeight:g}):null,[a,i,o,m,g]),x=(b,S)=>{if(!b)return[];if(Array.isArray(b))return b;try{const E=b(S);if(!Array.isArray(E))return console.error("[uhuu-components] pageComponentKeys function must return an array, got:",typeof E),[];const k=E.filter(C=>typeof C=="string");return k.length!==E.length&&console.warn("[uhuu-components] pageComponentKeys returned non-string values, filtering them out"),k}catch(E){return console.error("[uhuu-components] Error evaluating pageComponentKeys function:",E),[]}},h=(b,S)=>{if(b.kind==="group"){const C=b,A={payload:i,item:void 0,parent:void 0},_=x(C.pageComponentKeys,A),I=_[0];return{kind:"group",id:b.id,label:b.label,pageCount:_.length,firstPageId:I,firstPageComponentKey:I}}const E=b,k=E.componentKey??E.id;return{kind:"page",id:E.id,pageId:E.id,pageComponentKey:k,pageLabel:E.label,pageNum:S+1}};return y.jsx(Tg,{open:t,onOpenChange:e,children:y.jsxs(Rl,{side:"bottom",className:"h-[90vh] p-0 gap-0 w-full max-w-none bg-gray-50","data-uhuu-editor":!0,children:[y.jsx(Fl,{className:"border-b border-gray-200 p-4 bg-white",children:y.jsxs("div",{className:"flex items-end gap-3",children:[y.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center shrink-0 mb-0.5",children:y.jsx(mt,{className:"w-4 h-4"})}),y.jsxs("div",{className:"flex-1",children:[y.jsx($l,{className:"text-base font-medium text-gray-900 leading-tight",children:"Add Page or Group"}),y.jsx(Gl,{className:"text-xs text-gray-400 mt-0.5",children:"Select a page or group to add to your document."})]}),y.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400 mb-0.5 mr-8",children:[y.jsx(cw,{className:"w-3.5 h-3.5 shrink-0"}),y.jsx("input",{type:"text",placeholder:"Filter…",value:l,onChange:b=>c(b.target.value),tabIndex:-1,className:"w-24 bg-transparent border-0 focus:outline-none text-sm text-gray-600 placeholder:text-gray-400 focus:w-40 transition-all duration-150"})]})]})}),y.jsx("div",{className:"flex-1 overflow-hidden",children:y.jsx("div",{className:"h-full max-h-[calc(90vh-100px)] overflow-auto p-6",children:d.length===0?y.jsxs("div",{className:"text-center py-16",children:[y.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:y.jsx(mt,{className:"w-8 h-8 text-gray-400"})}),y.jsx("div",{className:"text-lg font-medium text-gray-900 mb-2",children:"No items available"}),y.jsx("p",{className:"text-gray-500 mb-4",children:l.trim()?"No pages or groups match your search.":"All pages and groups have been added."})]}):y.jsx("div",{className:s,children:d.map((b,S)=>{const E=b.kind==="group",k=b.id,C=E?b.label||`Group ${S+1}`:b.label||`Page ${b.id}`,A={payload:i,item:void 0,parent:void 0},_=E?x(b.pageComponentKeys,A).length:1,I=!!w;return y.jsxs("div",{onClick:()=>u(b),className:["relative w-full h-[280px] cursor-pointer transition-all group",!I&&"bg-white border-2 border-gray-200"].filter(Boolean).join(" "),children:[y.jsx("div",{className:"w-full h-full relative",children:b.thumbnail?y.jsx("div",{className:"absolute inset-0 bg-gray-100 hover:bg-white",children:y.jsx("img",{src:b.thumbnail,className:"w-full h-full object-contain pointer-events-none object-top border border-gray-200 p-4",alt:C})}):w?y.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:w(h(b,S),S,!1)}):y.jsx(y.Fragment,{children:E?y.jsxs("div",{className:"p-4",children:[y.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-3",children:y.jsx(mt,{className:"w-8 h-8 text-blue-600"})}),y.jsx("div",{className:"text-sm font-medium text-gray-700",children:C}),y.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[_," ",_===1?"page":"pages"]})]}):y.jsxs("div",{className:"p-4",children:[y.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3",children:y.jsx(mt,{className:"w-8 h-8 text-gray-400"})}),y.jsx("div",{className:"text-sm font-medium text-gray-700",children:C}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:k})]})})}),(!w||b?.thumbnail)&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 bg-blue-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none",children:["Group (",_," ",_===1?"page":"pages",")"]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none","data-item-id":k,children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:C})})})})]}),y.jsx("div",{className:"absolute top-3 left-3 w-8 h-8 bg-black rounded-full flex items-center justify-center shadow-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10",children:y.jsx(mt,{className:"w-4 h-4 text-white"})})]},k)})})})})]})})}function nA(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return O.useMemo(()=>n=>{e.forEach(a=>a(n))},e)}const Fn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ar(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Hl(t){return"nodeType"in t}function Pe(t){var e,r;return t?ar(t)?t:Hl(t)&&(e=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?e:window:window}function Ul(t){const{Document:e}=Pe(t);return t instanceof e}function Mr(t){return ar(t)?!1:t instanceof Pe(t).HTMLElement}function Og(t){return t instanceof Pe(t).SVGElement}function ir(t){return t?ar(t)?t.document:Hl(t)?Ul(t)?t:Mr(t)||Og(t)?t.ownerDocument:document:document:document}const Ue=Fn?O.useLayoutEffect:O.useEffect;function $n(t){const e=O.useRef(t);return Ue(()=>{e.current=t}),O.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return e.current==null?void 0:e.current(...n)},[])}function aA(){const t=O.useRef(null),e=O.useCallback((n,a)=>{t.current=setInterval(n,a)},[]),r=O.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,r]}function Dr(t,e){e===void 0&&(e=[t]);const r=O.useRef(t);return Ue(()=>{r.current!==t&&(r.current=t)},e),r}function zr(t,e){const r=O.useRef();return O.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...e])}function Gn(t){const e=$n(t),r=O.useRef(null),n=O.useCallback(a=>{a!==r.current&&e?.(a,r.current),r.current=a},[]);return[r,n]}function Vn(t){const e=O.useRef();return O.useEffect(()=>{e.current=t},[t]),e.current}let Kl={};function Lr(t,e){return O.useMemo(()=>{if(e)return e;const r=Kl[t]==null?0:Kl[t]+1;return Kl[t]=r,t+"-"+r},[t,e])}function Pg(t){return function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return n.reduce((i,o)=>{const s=Object.entries(o);for(const[l,c]of s){const d=i[l];d!=null&&(i[l]=d+t*c)}return i},{...e})}}const or=Pg(1),jr=Pg(-1);function iA(t){return"clientX"in t&&"clientY"in t}function Hn(t){if(!t)return!1;const{KeyboardEvent:e}=Pe(t.target);return e&&t instanceof e}function oA(t){if(!t)return!1;const{TouchEvent:e}=Pe(t.target);return e&&t instanceof e}function Un(t){if(oA(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:r}=t.touches[0];return{x:e,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:r}=t.changedTouches[0];return{x:e,y:r}}}return iA(t)?{x:t.clientX,y:t.clientY}:null}const kt=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:r}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:r}=t;return"scaleX("+e+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[kt.Translate.toString(t),kt.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:r,easing:n}=t;return e+" "+r+"ms "+n}}}),Ig="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function sA(t){return t.matches(Ig)?t:t.querySelector(Ig)}const lA={display:"none"};function cA(t){let{id:e,value:r}=t;return O.createElement("div",{id:e,style:lA},r)}function dA(t){let{id:e,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return O.createElement("div",{id:e,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function uA(){const[t,e]=O.useState("");return{announce:O.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const Ng=O.createContext(null);function pA(t){const e=O.useContext(Ng);O.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function fA(){const[t]=O.useState(()=>new Set),e=O.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[O.useCallback(n=>{let{type:a,event:i}=n;t.forEach(o=>{var s;return(s=o[a])==null?void 0:s.call(o,i)})},[t]),e]}const mA={draggable:`
|
|
878
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return T.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},QT="DialogDescriptionWarning",JT=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Cg(QT).contentName}}.`;return T.useEffect(()=>{const a=t.current?.getAttribute("aria-describedby");e&&a&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},kg=cg,eA=ug,Eg=fg,Ll=mg,jl=hg,Wl=vg,Bl=bg,ql=xg;const Tg=kg,tA=Eg,Ag=T.forwardRef(({className:t,...e},r)=>y.jsx(Ll,{className:pe("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));Ag.displayName=Ll.displayName;const Rl=T.forwardRef(({side:t="right",className:e,children:r,...n},a)=>{const{portalContainer:i}=zs();return y.jsxs(tA,{container:i||void 0,children:[y.jsx(Ag,{}),y.jsxs(jl,{ref:a,className:pe("fixed z-50 gap-4 bg-white p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",t==="top"&&"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",t==="bottom"&&"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",t==="left"&&"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",t==="right"&&"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",e),...n,children:[r,y.jsxs(ql,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100",children:[y.jsx(hf,{className:"h-4 w-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})]})});Rl.displayName=jl.displayName;const Fl=({className:t,...e})=>y.jsx("div",{className:pe("flex flex-col space-y-2 text-center sm:text-left",t),...e});Fl.displayName="SheetHeader";const _g=({className:t,...e})=>y.jsx("div",{className:pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});_g.displayName="SheetFooter";const $l=T.forwardRef(({className:t,...e},r)=>y.jsx(Wl,{ref:r,className:pe("text-lg font-medium text-gray-900",t),...e}));$l.displayName=Wl.displayName;const Gl=T.forwardRef(({className:t,...e},r)=>y.jsx(Bl,{ref:r,className:pe("text-sm text-gray-500",t),...e}));Gl.displayName=Bl.displayName;function Vl(t){const{pageComponents:e,payload:r,setup:n={width:210,height:297},thumbnailWidth:a=200,thumbnailHeight:i}=t,o=n.width||210,s=n.height||297,l=o/s,c=a,d=i??Math.round(c/l),u=o*3.779527559,p=s*3.779527559;return(f,v,m)=>{const g=f.strictPosition,w=g==="start"||g==="end";if(f.kind==="group"){const x=f.firstPageId,h=f.firstPageComponentKey??x,b=jn(r,{id:x,componentKey:h}),S=f.firstPageComponent||(h?e[h]:null),E=r?.integrations?.[f.id];return y.jsxs("div",{className:`relative bg-white border transition-all ${m?"border-blue-400 shadow-2xl scale-105":w?"border-gray-300 bg-gray-50":"border-gray-200 hover:border-gray-300 hover:shadow-lg"}`,style:{width:`${c}px`,height:`${d}px`},title:f.id,children:[S?y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 overflow-hidden relative pointer-events-none",children:y.jsx("div",{style:{transform:`scale(${Math.min(c/u,d/p)})`,transformOrigin:"center"},children:y.jsx("div",{className:"!shrink-0",style:{width:`${u}px`,height:`${p}px`,backgroundColor:"white",pointerEvents:"none"},children:y.jsx(S,{payload:r,pageId:x,templateId:h,pagePayload:b,componentKey:h,integration:E,parentGroup:f})})})}):y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 pointer-events-none",children:y.jsxs("div",{className:"text-center p-4",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:["Group ",f.id]}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x||"No preview"})]})}),y.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 bg-blue-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none",children:["Group (",f.pageCount," pages)"]}),w&&y.jsxs("div",{className:"absolute top-2 left-2 px-2 py-1 bg-gray-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none flex items-center gap-1",children:[y.jsx(Ds,{className:"size-3"}),y.jsx("span",{children:g==="start"?"Start":"End"})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:f.label||f.id})})})}),m&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/10 pointer-events-none",children:y.jsx("div",{className:"text-blue-600 font-medium text-sm bg-white/90 px-3 py-1 rounded-full shadow-lg",children:"Dragging Group..."})})]})}else{const x=f.pageId,h=f.pageComponentKey??x,b=jn(r,{id:x,componentKey:h}),S=f.pageComponent||(h?e[h]:null),E=x?ag(r,{id:x}):void 0;return y.jsxs("div",{className:`relative bg-white border transition-all ${m?"border-blue-400 shadow-2xl scale-105":w?"border-gray-300 bg-gray-50":"border-gray-200 hover:border-gray-300 hover:shadow-lg"}`,style:{width:`${c}px`,height:`${d}px`},title:f.pageId,children:[S?y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 overflow-hidden relative pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-center pointer-events-none",style:{transform:`scale(${Math.min(c/u,d/p)})`,transformOrigin:"center"},children:y.jsx("div",{className:"!shrink-0",style:{width:`${u}px`,height:`${p}px`,backgroundColor:"white",pointerEvents:"none"},children:y.jsx(S,{payload:r,pageId:x,templateId:h,pagePayload:b,componentKey:h,integration:E})})})}):y.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-50 pointer-events-none",children:y.jsxs("div",{className:"text-center p-4",children:[y.jsxs("div",{className:"text-sm font-medium text-gray-700",children:["Page ",f.pageNum]}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:x||"No preview"})]})}),w&&y.jsxs("div",{className:"absolute top-2 left-2 px-2 py-1 bg-gray-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none flex items-center gap-1",children:[y.jsx(Ds,{className:"size-3"}),y.jsx("span",{children:g==="start"?"Start":"End"})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none",children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:f.pageLabel||`Page ${f.pageNum}`})})})}),m&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-blue-500/10 pointer-events-none",children:y.jsx("div",{className:"text-blue-600 font-medium text-sm bg-white/90 px-3 py-1 rounded-full shadow-lg",children:"Dragging..."})})]})}}}function rA({open:t,onOpenChange:e,availableItems:r,onSelectItem:n,pageComponents:a,payload:i,setup:o={width:210,height:297},gridColsClass:s="page-order-grid-cols"}){const[l,c]=T.useState(""),d=T.useMemo(()=>{if(!l.trim())return r;const b=l.toLowerCase();return r.filter(S=>(S.label||"").toLowerCase().includes(b)||S.id.toLowerCase().includes(b))},[r,l]),u=b=>{e(!1),n(b)},p=o.width||210,f=o.height||297,v=p/f,m=200,g=Math.round(m/v),w=T.useMemo(()=>a?Vl({pageComponents:a,payload:i,setup:o,thumbnailWidth:m,thumbnailHeight:g}):null,[a,i,o,m,g]),x=(b,S)=>{if(!b)return[];if(Array.isArray(b))return b;try{const E=b(S);if(!Array.isArray(E))return console.error("[uhuu-components] pageComponentKeys function must return an array, got:",typeof E),[];const k=E.filter(C=>typeof C=="string");return k.length!==E.length&&console.warn("[uhuu-components] pageComponentKeys returned non-string values, filtering them out"),k}catch(E){return console.error("[uhuu-components] Error evaluating pageComponentKeys function:",E),[]}},h=(b,S)=>{if(b.kind==="group"){const C=b,A={payload:i,item:void 0,parent:void 0},_=x(C.pageComponentKeys,A),I=_[0];return{kind:"group",id:b.id,label:b.label,pageCount:_.length,firstPageId:I,firstPageComponentKey:I}}const E=b,k=E.componentKey??E.id;return{kind:"page",id:E.id,pageId:E.id,pageComponentKey:k,pageLabel:E.label,pageNum:S+1}};return y.jsx(Tg,{open:t,onOpenChange:e,children:y.jsxs(Rl,{side:"bottom",className:"h-[90vh] p-0 gap-0 w-full max-w-none bg-gray-50","data-uhuu-editor":!0,children:[y.jsx(Fl,{className:"border-b border-gray-200 p-4 bg-white",children:y.jsxs("div",{className:"flex items-end gap-3",children:[y.jsx("div",{className:"w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center shrink-0 mb-0.5",children:y.jsx(mt,{className:"w-4 h-4"})}),y.jsxs("div",{className:"flex-1",children:[y.jsx($l,{className:"text-base font-medium text-gray-900 leading-tight",children:"Add Page or Group"}),y.jsx(Gl,{className:"text-xs text-gray-400 mt-0.5",children:"Select a page or group to add to your document."})]}),y.jsxs("div",{className:"flex items-center gap-1.5 text-gray-400 mb-0.5 mr-8",children:[y.jsx(cw,{className:"w-3.5 h-3.5 shrink-0"}),y.jsx("input",{type:"text",placeholder:"Filter…",value:l,onChange:b=>c(b.target.value),tabIndex:-1,className:"w-24 bg-transparent border-0 focus:outline-none text-sm text-gray-600 placeholder:text-gray-400 focus:w-40 transition-all duration-150"})]})]})}),y.jsx("div",{className:"flex-1 overflow-hidden",children:y.jsx("div",{className:"h-full max-h-[calc(90vh-100px)] overflow-auto p-6",children:d.length===0?y.jsxs("div",{className:"text-center py-16",children:[y.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4",children:y.jsx(mt,{className:"w-8 h-8 text-gray-400"})}),y.jsx("div",{className:"text-lg font-medium text-gray-900 mb-2",children:"No items available"}),y.jsx("p",{className:"text-gray-500 mb-4",children:l.trim()?"No pages or groups match your search.":"All pages and groups have been added."})]}):y.jsx("div",{className:s,children:d.map((b,S)=>{const E=b.kind==="group",k=b.id,C=E?b.label||`Group ${S+1}`:b.label||`Page ${b.id}`,A={payload:i,item:void 0,parent:void 0},_=E?x(b.pageComponentKeys,A).length:1,I=!!w;return y.jsxs("div",{onClick:()=>u(b),className:["relative w-full h-[280px] cursor-pointer transition-all group",!I&&"bg-white border-2 border-gray-200"].filter(Boolean).join(" "),children:[y.jsx("div",{className:"w-full h-full relative",children:b.thumbnail?y.jsx("div",{className:"absolute inset-0 bg-gray-100 hover:bg-white",children:y.jsx("img",{src:b.thumbnail,className:"w-full h-full object-contain pointer-events-none object-top border border-gray-200 p-4",alt:C})}):w?y.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:w(h(b,S),S,!1)}):y.jsx(y.Fragment,{children:E?y.jsxs("div",{className:"p-4",children:[y.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-3",children:y.jsx(mt,{className:"w-8 h-8 text-blue-600"})}),y.jsx("div",{className:"text-sm font-medium text-gray-700",children:C}),y.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[_," ",_===1?"page":"pages"]})]}):y.jsxs("div",{className:"p-4",children:[y.jsx("div",{className:"w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3",children:y.jsx(mt,{className:"w-8 h-8 text-gray-400"})}),y.jsx("div",{className:"text-sm font-medium text-gray-700",children:C}),y.jsx("div",{className:"text-xs text-gray-500 mt-1",children:k})]})})}),(!w||b?.thumbnail)&&y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"absolute top-2 right-2 px-2 py-1 bg-blue-600/80 backdrop-blur-sm text-white text-xs font-medium rounded shadow-lg pointer-events-none",children:["Group (",_," ",_===1?"page":"pages",")"]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-black/40 backdrop-blur-sm p-3 pointer-events-none","data-item-id":k,children:y.jsx("div",{className:"flex items-center justify-between gap-2 text-white",children:y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("div",{className:"text-sm font-medium truncate",children:C})})})})]}),y.jsx("div",{className:"absolute top-3 left-3 w-8 h-8 bg-black rounded-full flex items-center justify-center shadow-lg opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10",children:y.jsx(mt,{className:"w-4 h-4 text-white"})})]},k)})})})})]})})}function nA(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return O.useMemo(()=>n=>{e.forEach(a=>a(n))},e)}const Fn=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ar(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Hl(t){return"nodeType"in t}function Pe(t){var e,r;return t?ar(t)?t:Hl(t)&&(e=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?e:window:window}function Ul(t){const{Document:e}=Pe(t);return t instanceof e}function Mr(t){return ar(t)?!1:t instanceof Pe(t).HTMLElement}function Og(t){return t instanceof Pe(t).SVGElement}function ir(t){return t?ar(t)?t.document:Hl(t)?Ul(t)?t:Mr(t)||Og(t)?t.ownerDocument:document:document:document}const Ue=Fn?O.useLayoutEffect:O.useEffect;function $n(t){const e=O.useRef(t);return Ue(()=>{e.current=t}),O.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return e.current==null?void 0:e.current(...n)},[])}function aA(){const t=O.useRef(null),e=O.useCallback((n,a)=>{t.current=setInterval(n,a)},[]),r=O.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,r]}function Dr(t,e){e===void 0&&(e=[t]);const r=O.useRef(t);return Ue(()=>{r.current!==t&&(r.current=t)},e),r}function zr(t,e){const r=O.useRef();return O.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...e])}function Gn(t){const e=$n(t),r=O.useRef(null),n=O.useCallback(a=>{a!==r.current&&e?.(a,r.current),r.current=a},[]);return[r,n]}function Vn(t){const e=O.useRef();return O.useEffect(()=>{e.current=t},[t]),e.current}let Kl={};function Lr(t,e){return O.useMemo(()=>{if(e)return e;const r=Kl[t]==null?0:Kl[t]+1;return Kl[t]=r,t+"-"+r},[t,e])}function Pg(t){return function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];return n.reduce((i,o)=>{const s=Object.entries(o);for(const[l,c]of s){const d=i[l];d!=null&&(i[l]=d+t*c)}return i},{...e})}}const or=Pg(1),jr=Pg(-1);function iA(t){return"clientX"in t&&"clientY"in t}function Hn(t){if(!t)return!1;const{KeyboardEvent:e}=Pe(t.target);return e&&t instanceof e}function oA(t){if(!t)return!1;const{TouchEvent:e}=Pe(t.target);return e&&t instanceof e}function Un(t){if(oA(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:r}=t.touches[0];return{x:e,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:r}=t.changedTouches[0];return{x:e,y:r}}}return iA(t)?{x:t.clientX,y:t.clientY}:null}const kt=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:r}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:r}=t;return"scaleX("+e+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[kt.Translate.toString(t),kt.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:r,easing:n}=t;return e+" "+r+"ms "+n}}}),Ig="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function sA(t){return t.matches(Ig)?t:t.querySelector(Ig)}const lA={display:"none"};function cA(t){let{id:e,value:r}=t;return O.createElement("div",{id:e,style:lA},r)}function dA(t){let{id:e,announcement:r,ariaLiveType:n="assertive"}=t;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return O.createElement("div",{id:e,style:a,role:"status","aria-live":n,"aria-atomic":!0},r)}function uA(){const[t,e]=O.useState("");return{announce:O.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const Ng=O.createContext(null);function pA(t){const e=O.useContext(Ng);O.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function fA(){const[t]=O.useState(()=>new Set),e=O.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[O.useCallback(n=>{let{type:a,event:i}=n;t.forEach(o=>{var s;return(s=o[a])==null?void 0:s.call(o,i)})},[t]),e]}const mA={draggable:`
|
|
879
879
|
To pick up a draggable item, press the space bar.
|
|
880
880
|
While dragging, use the arrow keys to move the item.
|
|
881
881
|
Press space again to drop the item in its new position, or press escape to cancel.
|