@liberfi.io/ui-scaffold 0.1.49 → 0.1.51

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/dist/index.d.mts CHANGED
@@ -408,6 +408,6 @@ declare global {
408
408
  };
409
409
  }
410
410
  }
411
- declare const _default: "0.1.49";
411
+ declare const _default: "0.1.51";
412
412
 
413
413
  export { ALL_BREAKPOINTS, AsyncModal, type AsyncModalProps, type DraggableContentProps, DraggableModal, type DraggableModalProps, DraggablePanel, type DraggablePanelProps, DraggablePanelProvider, type DraggablePanelProviderProps, type LayoutBreakpoint, Logo, type LogoProps, type NavItem, NavLink, type NavLinkProps, type OpenAsyncModalOptions, type OpenDraggableModalOptions, type OpenDraggablePanelOptions, type RenderAsyncModalProps, Scaffold, ScaffoldContext, type ScaffoldContextValue, ScaffoldFooter, type ScaffoldFooterProps, ScaffoldHeader, type ScaffoldHeaderProps, type ScaffoldProps, ScaffoldToolbar, type ScaffoldToolbarProps, SplitHandle, type SplitHandleProps, SplitView, type SplitViewProps, type UseAsyncModalReturnType, type UseDraggableDisclosureReturnType, type UseDraggableModalDisclosureReturnType, type UseDraggablePanelDisclosureReturnType, getVisibilityClass, isNavItemActive, useAsyncModal, useDraggableDisclosure, useDraggableModalDisclosure, useDraggablePanelDisclosure, useScaffold, useScaffoldLayout, _default as version };
package/dist/index.d.ts CHANGED
@@ -408,6 +408,6 @@ declare global {
408
408
  };
409
409
  }
410
410
  }
411
- declare const _default: "0.1.49";
411
+ declare const _default: "0.1.51";
412
412
 
413
413
  export { ALL_BREAKPOINTS, AsyncModal, type AsyncModalProps, type DraggableContentProps, DraggableModal, type DraggableModalProps, DraggablePanel, type DraggablePanelProps, DraggablePanelProvider, type DraggablePanelProviderProps, type LayoutBreakpoint, Logo, type LogoProps, type NavItem, NavLink, type NavLinkProps, type OpenAsyncModalOptions, type OpenDraggableModalOptions, type OpenDraggablePanelOptions, type RenderAsyncModalProps, Scaffold, ScaffoldContext, type ScaffoldContextValue, ScaffoldFooter, type ScaffoldFooterProps, ScaffoldHeader, type ScaffoldHeaderProps, type ScaffoldProps, ScaffoldToolbar, type ScaffoldToolbarProps, SplitHandle, type SplitHandleProps, SplitView, type SplitViewProps, type UseAsyncModalReturnType, type UseDraggableDisclosureReturnType, type UseDraggableModalDisclosureReturnType, type UseDraggablePanelDisclosureReturnType, getVisibilityClass, isNavItemActive, useAsyncModal, useDraggableDisclosure, useDraggableModalDisclosure, useDraggablePanelDisclosure, useScaffold, useScaffoldLayout, _default as version };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var react=require('react'),reactDom=require('react-dom'),jotai=require('jotai'),hooks=require('@liberfi.io/hooks'),i18n=require('@liberfi.io/i18n'),ui$1=require('@liberfi.io/ui'),utils$1=require('@liberfi.io/utils'),jotaiFamily=require('jotai-family'),utils=require('jotai/utils'),jsxRuntime=require('react/jsx-runtime');var ct="";function Ct(e){ct=e;}function V(e,t){let n=`${e}.${t??"default"}`;return ct?`${ct}:${n}`:n}var xe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelState",e),"none",void 0,{getOnInit:true})),Xe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelWidth",e),350,void 0,{getOnInit:true})),Ye=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelMinWidth",e),320,void 0,{getOnInit:true})),Ue=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelMaxWidth",e),440,void 0,{getOnInit:true})),Vt=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalOpen",e),false,void 0,{getOnInit:true})),Ze=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalShouldStartDragging",e),false,void 0,{getOnInit:true})),je=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalSize",e),{width:350,height:580},void 0,{getOnInit:true})),Ge=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalRestoreSize",e),{width:350,height:580},void 0,{getOnInit:true})),Ke=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalPosition",e),{x:typeof window<"u"?Math.max(0,(window.innerWidth-350)/2):0,y:typeof window<"u"?Math.max(0,(window.innerHeight-580)/2):0},void 0,{getOnInit:true})),Je=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalRestorePosition",e),{x:typeof window<"u"?Math.max(0,(window.innerWidth-350)/2):0,y:typeof window<"u"?Math.max(0,(window.innerHeight-580)/2):0},void 0,{getOnInit:true})),qe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalMinimized",e),false,void 0,{getOnInit:true})),Qe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalMinWidth",e),200,void 0,{getOnInit:true})),et=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalMaxWidth",e),typeof window<"u"?window.innerWidth-40:0,void 0,{getOnInit:true})),Re=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("lastPanelType",e),"modal",void 0,{getOnInit:true})),tt=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelOrders",null),{left:{},right:{}},void 0,{getOnInit:true}));function Me(e){let[t,n]=jotai.useAtom(Vt(e)),[i,r]=jotai.useAtom(qe(e)),d=jotai.useAtomValue(Ge(e)),a=jotai.useAtomValue(Je(e)),c=jotai.useSetAtom(je(e)),m=jotai.useSetAtom(Ke(e)),o=jotai.useSetAtom(Ze(e)),s=jotai.useSetAtom(Re(e)),f=react.useCallback((z={})=>{let{shouldStartDragging:p,position:v,size:w}=z;v&&m(P=>({...P,...v})),w&&c(P=>({...P,...w})),o(p??false),n(true),s("modal");},[n,m,c,o]),b=react.useCallback(()=>{n(false),i&&(c({...d}),m({...a}),r(false));},[i,d,a,r,n,c,m]);return react.useMemo(()=>({isOpen:t,onOpen:f,onClose:b}),[t,f,b])}function ze(e){let[t,n]=jotai.useAtom(xe(e)),i=jotai.useSetAtom(Xe(e)),r=jotai.useSetAtom(Re(e)),d=jotai.useSetAtom(tt(null)),a=react.useCallback((s={})=>{let f=s.position??"left";i(s.width??320),n(f),r(f),d(({left:b,right:z})=>f==="left"?{left:{...b,[e]:Date.now()},right:z}:{left:b,right:{...z,[e]:Date.now()}});},[e,n,i]),c=react.useCallback(()=>{n("none");},[n]),m=react.useMemo(()=>t!=="none",[t]),o=react.useMemo(()=>t!=="none"?t:void 0,[t]);return react.useMemo(()=>({isOpen:m,position:o,onOpen:a,onClose:c}),[m,a,c])}var Ao={width:200,height:48},Ve={width:typeof window<"u"?window.innerWidth-40:0,height:typeof window<"u"?window.innerHeight-40:0},_o={x:20,y:20},$t=react.memo(function({id:t,title:n,minWidth:i=504,maxWidth:r=Ve.width,minHeight:d=200,maxHeight:a=Ve.height,leftSidebar:c,leftSidebarWidth:m=200,rightSidebar:o,rightSidebarWidth:s=200,aspectRatio:f,showHeader:b=true,header:z,headerHeight:p=44,children:v}){let{t:w}=i18n.useTranslation(),{isOpen:P,onClose:K}=Me(t),{onOpen:U}=ze(t),[N,R]=jotai.useAtom(qe(t)),[x,ue]=jotai.useAtom(Ke(t)),[u,me]=jotai.useAtom(je(t)),[Z,ne]=jotai.useAtom(Ge(t)),[X,J]=jotai.useAtom(Je(t)),[re,ie]=jotai.useAtom(Ze(t)),[S,se]=react.useState(re),[fe,y]=react.useState(false),[W,ae]=react.useState(null),[pe,le]=react.useState(null),[he,_]=react.useState(null),[ve,de]=react.useState(null),q=react.useRef(null),uo=jotai.useAtomValue(Ye(t)),mo=jotai.useAtomValue(Ue(t)),Q=hooks.useValueRef(x),E=hooks.useCallbackRef(ue),ge=hooks.useValueRef(u),H=hooks.useCallbackRef(me),fo=hooks.useValueRef(m),po=hooks.useValueRef(!!c),ho=hooks.useValueRef(s),go=hooks.useValueRef(!!o),j=hooks.useValueRef(f),ee=hooks.useValueRef(p),We=hooks.useValueRef(i),Ee=hooks.useValueRef(r),ke=hooks.useValueRef(d),Le=hooks.useValueRef(a),bo=hooks.useValueRef(S),Dt=hooks.useValueRef(pe),dt=hooks.useValueRef(ve),xo=hooks.useCallbackRef(K),yo=hooks.useCallbackRef(U),vo=hooks.useValueRef(uo),wo=hooks.useValueRef(mo),Ie=react.useMemo(()=>u.width===Ve.width&&u.height===Ve.height,[u.width,u.height]);react.useEffect(()=>{let l=Math.min(Math.max(u.width,i),r),k=Math.min(Math.max(u.height,d),a);(l!==u.width||k!==u.height)&&H({width:l,height:k});let A=Math.max(0,x.x),be=Math.max(0,x.y);A+l>window.innerWidth&&(A=Math.max(0,window.innerWidth-l)),be+k>window.innerHeight&&(be=Math.max(0,window.innerHeight-k)),(A!==x.x||be!==x.y)&&E({x:A,y:be});},[t]),react.useEffect(()=>{if(P&&re){se(true);let l=A=>{E({x:A.clientX-u.width/2,y:A.clientY-20});},k=()=>{se(false),ie(false),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",k);};return document.addEventListener("mousemove",l),document.addEventListener("mouseup",k),document.body.style.cursor="grabbing",()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",k),document.body.style.cursor="";}}},[P,re,ie,u.width]);let G=(l,k,A)=>{ie(false),se(false),y(false),ae(null),k==="drag"?se(true):k==="resize"&&(ae(A||null),y(true));let be=l.clientX,Ot=l.clientY,B=ge.current.width,Y=ge.current.height,$={...Q.current},Wt=()=>{document.removeEventListener("mousemove",Et),document.removeEventListener("mouseup",kt),document.body.style.cursor="",se(false),y(false),ae(null),le(null),q.current&&(clearTimeout(q.current),q.current=null),de(null),_(null);},Et=Be=>{if(k==="drag"){let te=Be.clientX-be,oe=Be.clientY-Ot,D=$.x+te,g=$.y+oe,we=po.current?fo.current:0,Ce=12+we,F=go.current?ho.current:0,O=window.innerWidth-12-B-F,$e=window.innerHeight-12-44,L=D<=Ce?"left":D>=O?"right":null;L!==Dt.current&&le(L),q.current&&L&&_(L),q.current&&(dt.current==="left"&&(D>Ce||L!=="left")||dt.current==="right"&&(D<O||L!=="right"))&&(clearTimeout(q.current),q.current=null,de(null),_(null)),!q.current&&L&&dt.current!==L&&(de(L),_(L),q.current=setTimeout(()=>{bo.current&&Dt.current===L?(Wt(),xo(),yo({position:L,width:Math.min(Math.max(ge.current.width,vo.current),wo.current)})):de(null);},350)),D=Math.min(Math.max(D,12+we),O),g=Math.min(Math.max(g,12),$e),E({x:D,y:g});}else if(k==="resize"&&A){let te=Be.clientX-be,oe=Be.clientY-Ot,D=(g,we,Ce)=>{let F=Math.min(Math.max(g,We.current),Ee.current),O=Math.min(Math.max(we,ke.current),Le.current);if(j.current){if(Ce==="width")O=Math.min(Math.max(g/j.current+ee.current,ke.current),Le.current),F=(O-ee.current)*j.current;else if(Ce==="height")F=Math.min(Math.max((we-ee.current)*j.current,We.current),Ee.current),O=F/j.current+ee.current;else {let $e=g/j.current+ee.current,L=(we-ee.current)*j.current,Lt=Math.abs(te),It=Math.abs(oe);if(Lt>1.1*It)O=Math.min(Math.max($e,ke.current),Le.current),F=(O-ee.current)*j.current;else if(It>1.1*Lt)F=Math.min(Math.max(L,We.current),Ee.current),O=F/j.current+ee.current;else {let zo=(O+$e)/2;F=Math.min(Math.max((F+L)/2,We.current),Ee.current),O=Math.min(Math.max(zo,ke.current),Le.current),F=(O-ee.current)*j.current;}}F=Math.min(Math.max(F,We.current),Ee.current),O=Math.min(Math.max(O,ke.current),Le.current);}return {width:F,height:O}};switch(A){case "topLeft":{let g=D(B-te,Y-oe,"both");H(g),E({x:$.x+(B-g.width),y:$.y+(Y-g.height)});break}case "topRight":{let g=D(B+te,Y-oe,"both");H(g),E({x:$.x,y:$.y+(Y-g.height)});break}case "bottomLeft":{let g=D(B-te,Y+oe,"both");H(g),E({x:$.x+(B-g.width),y:$.y});break}case "bottomRight":{H(D(B+te,Y+oe,"both"));break}case "top":{let g=D(B,Y-oe,"height");H(g),E({x:$.x,y:$.y+(Y-g.height)});break}case "bottom":{H(D(B,Y+oe,"height"));break}case "left":{let g=D(B-te,Y,"width");H(g),E({x:$.x+(B-g.width),y:$.y});break}case "right":{H(D(B+te,Y,"width"));break}}}},kt=()=>{(x.x<0||x.y<0)&&E({x:Math.max(0,x.x),y:Math.max(0,x.y)}),Wt();};document.addEventListener("mousemove",Et),document.addEventListener("mouseup",kt);},Ro=react.useCallback(()=>{N?(H({...Z}),E({...X}),R(false)):(Ie?E({...X}):(ne({...u}),J({...x})),H({...Ao}),R(true));},[N,Ie,u,x,Z,X,R,ne,J]),Mo=react.useCallback(()=>{Ie?(H({...Z}),E({...X})):(N?R(false):(ne({...u}),J({...x})),H({...Ve}),E({..._o}));},[Ie,N,u,x,Z,X,R,ne,J]);return react.useEffect(()=>{let l=utils$1.throttle(()=>{(Q.current.x<0||Q.current.y<0)&&E({x:Math.max(0,Q.current.x),y:Math.max(0,Q.current.y)});let k=Q.current.x+ge.current.width,A=Q.current.y+ge.current.height;(k>window.innerWidth||A>window.innerHeight)&&E({x:Math.min(Q.current.x,Math.max(0,window.innerWidth-ge.current.width)),y:Math.min(Q.current.y,Math.max(0,window.innerHeight-ge.current.height))});},100);return window.addEventListener("resize",l),()=>{window.removeEventListener("resize",l);}},[]),P?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(S||fe)&&reactDom.createPortal(jsxRuntime.jsx("div",{className:ui$1.cn("max-sm:hidden fixed inset-0 z-9999 bg-transparent w-full h-full select-none",S&&(ve?"cursor-grabbing":"cursor-move"),!S&&{"cursor-ns-resize":W==="top"||W==="bottom","cursor-ew-resize":W==="left"||W==="right","cursor-nwse-resize":W==="topLeft"||W==="bottomRight","cursor-nesw-resize":W==="topRight"||W==="bottomLeft","cursor-auto":W===null})}),document.body),jsxRuntime.jsx("div",{className:ui$1.cn("max-sm:hidden fixed z-50 left-0 top-0",S?"will-change-transform":"will-change-auto",fe||S?"transition-none":"transition-transform duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]"),style:{transform:`translate(${Math.round(x.x-(c?m:0))}px, ${Math.round(x.y)}px)`},children:jsxRuntime.jsxs("div",{className:"flex relative z-50",children:[c&&jsxRuntime.jsx("div",{className:ui$1.cn("relative mt-1 z-10 transition-all duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]",S?"opacity-40 translate-x-4":"opacity-100 translate-x-0"),style:{width:m,height:N?40:u.height-8},children:c}),jsxRuntime.jsx("div",{className:ui$1.cn("z-50 relative bg-content1 border border-border rounded-lg overflow-hidden",S?"opacity-80 shadow-md scale-102 blur-[0.5px]":"opacity-100 shadow-lg scale-100 blur-none"),style:{width:u.width,height:u.height,transition:fe||S?"none":"transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1), height 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1)",contain:"content"},children:jsxRuntime.jsxs("div",{className:ui$1.cn("w-full h-full",he&&"animate-modal-shrink",he==="left"?"origin-left":"origin-right"),style:{contain:"paint"},children:[!N&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-3 h-3 cursor-nw-resize z-20",onMouseDown:l=>G(l,"resize","topLeft")}),jsxRuntime.jsx("div",{className:"absolute top-0 right-0 w-3 h-3 cursor-ne-resize z-20",onMouseDown:l=>G(l,"resize","topRight")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 w-3 h-3 cursor-sw-resize z-20",onMouseDown:l=>G(l,"resize","bottomLeft")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize z-20",onMouseDown:l=>G(l,"resize","bottomRight")}),jsxRuntime.jsx("div",{className:"absolute top-0 left-3 right-3 h-1.5 cursor-n-resize z-20",onMouseDown:l=>G(l,"resize","top")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-1.5 cursor-s-resize z-20",onMouseDown:l=>G(l,"resize","bottom")}),jsxRuntime.jsx("div",{className:"absolute left-0 top-3 bottom-3 w-1.5 cursor-w-resize z-20",onMouseDown:l=>G(l,"resize","left")}),jsxRuntime.jsx("div",{className:"absolute right-0 top-3 bottom-3 w-1.5 cursor-e-resize z-20",onMouseDown:l=>G(l,"resize","right")})]}),b&&jsxRuntime.jsxs("div",{className:"relative border-b border-border/80 px-3 gap-4 flex items-center justify-between cursor-move select-none",onMouseDown:l=>G(l,"drag"),style:{height:p},children:[jsxRuntime.jsx(ui$1.StyledTooltip,{placement:"top",content:w("scaffold.draggableModal.snapToEdge"),children:jsxRuntime.jsx(ui$1.DraggableIcon,{className:"text-neutral absolute left-1/2 -translate-x-1/2 top-0"})}),z||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-initial text-sm font-medium truncate cursor-auto",onMouseDown:l=>l.stopPropagation(),children:n}),jsxRuntime.jsxs("div",{className:"flex-none flex items-center justify-end gap-1",onMouseDown:l=>l.stopPropagation(),children:[jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:Ro,children:N?jsxRuntime.jsx(ui$1.RestoreWindowIcon,{width:18,height:18,className:"text-neutral"}):jsxRuntime.jsx(ui$1.MinimizeIcon,{width:18,height:18,className:"text-neutral"})}),jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:Mo,children:Ie?jsxRuntime.jsx(ui$1.UnMaximizeIcon,{width:18,height:18,className:"text-neutral"}):jsxRuntime.jsx(ui$1.MaximizeIcon,{width:18,height:18,className:"text-neutral"})}),jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:K,children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:18,height:18,className:"text-neutral"})})]})]})]}),!N&&jsxRuntime.jsx("div",{className:b?"h-[calc(100%-44px)] overflow-x-hidden overflow-y-auto":"h-full overflow-x-hidden overflow-y-auto cursor-move",onMouseDown:b?void 0:l=>G(l,"drag"),children:v})]})}),o&&jsxRuntime.jsx("div",{className:ui$1.cn("relative mt-1 z-10 transition-all duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]",S?"opacity-40 -translate-x-4":"opacity-100 translate-x-0"),style:{width:s,height:N?40:u.height-8},children:o})]})})]}):null});function xt({id:e,title:t,maxWidth:n=440,minWidth:i=320,position:r,showHeader:d=true,header:a,headerHeight:c=44,children:m}){let{t:o}=i18n.useTranslation(),s=jotai.useAtomValue(xe(e)),[f,b]=react.useState(false),[z,p]=react.useState(false),[v,w]=jotai.useAtom(Xe(e)),{onOpen:P}=Me(e),{onClose:K}=ze(e),U=jotai.useAtomValue(Qe(e)),N=jotai.useAtomValue(et(e)),R=hooks.useValueRef(v),x=hooks.useValueRef(n),ue=hooks.useValueRef(i),u=hooks.useValueRef(r),me=hooks.useValueRef(f),Z=hooks.useValueRef(z),ne=hooks.useCallbackRef(w),X=hooks.useCallbackRef(P),J=hooks.useCallbackRef(K),re=hooks.useValueRef(U),ie=hooks.useValueRef(N),S=y=>{y.preventDefault(),y.stopPropagation(),b(true),document.body.style.cursor="ew-resize",document.body.style.userSelect="none",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%";let W=y.clientX,ae=R.current,pe=he=>{if(!me.current)return;let _=he.clientX-W,ve=u.current==="right"?ae-_:ae+_,de=Math.min(Math.max(ve,ue.current),x.current);ne(de);},le=()=>{b(false),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width="",document.body.style.height="",document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",le);};document.addEventListener("mousemove",pe),document.addEventListener("mouseup",le);},se=y=>{if(y.target instanceof HTMLElement&&y.target.closest("button"))return;y.preventDefault(),p(true);let W=y.clientX,ae=y.clientY,pe=()=>{document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",he),p(false);},le=_=>{if(!Z.current)return;let ve=Math.abs(_.clientX-W),de=Math.abs(_.clientY-ae);(ve>10||de>10)&&(pe(),J(),X({shouldStartDragging:true,position:{x:_.clientX-R.current/2+20,y:_.clientY-20},size:{width:Math.min(Math.max(R.current,re.current),ie.current)}}));},he=()=>{pe();};document.addEventListener("mousemove",le),document.addEventListener("mouseup",he);},fe=()=>{J();};return s!==r?null:jsxRuntime.jsxs("div",{className:"max-sm:hidden flex-none flex flex-row overflow-hidden",children:[r==="right"&&jsxRuntime.jsx(Yt,{isResizing:f,handleResizeStart:S}),jsxRuntime.jsxs("div",{className:ui$1.cn("flex flex-col min-h-0 overflow-hidden bg-content1",z?"opacity-80 scale-98 blur-[1px]":"opacity-100 scale-100 blur-none"),style:{width:`${v}px`,transition:f||z?"none":"transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1), height 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1)",contain:"content"},children:[d&&jsxRuntime.jsxs("div",{className:"flex-none relative border-b border-border/80 px-3 gap-4 flex items-center justify-between cursor-move select-none",onMouseDown:se,style:{height:c},children:[jsxRuntime.jsx(ui$1.StyledTooltip,{placement:"top",content:o("scaffold.draggablePanel.snapToModal"),children:jsxRuntime.jsx(ui$1.DraggableIcon,{className:"text-neutral absolute left-1/2 -translate-x-1/2 top-0"})}),a||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-initial text-sm font-medium truncate cursor-auto",onMouseDown:y=>y.stopPropagation(),children:t}),jsxRuntime.jsx("div",{className:"flex-none flex items-center justify-end gap-1",onMouseDown:y=>y.stopPropagation(),children:jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:fe,children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:18,height:18,className:"text-neutral"})})})]})]}),jsxRuntime.jsx("div",{className:"flex-auto min-h-0 overflow-y-auto",children:m})]}),r==="left"&&jsxRuntime.jsx(Yt,{isResizing:f,handleResizeStart:S})]})}function Yt({isResizing:e,handleResizeStart:t}){return jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative w-1 h-full cursor-ew-resize bg-border/80 hover:bg-border transition-colors duration-150 ease-in-out group flex flex-col items-center justify-center gap-1",children:[jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("div",{className:"absolute inset-0 -left-1.5 -right-1.5 cursor-ew-resize",onMouseDown:t})]}),e&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 cursor-ew-resize"})]})}function vr({contents:e=[],storagePrefix:t,className:n,classNames:i,children:r}){let d=react.useRef(false);!d.current&&t!==void 0&&(Ct(t),d.current=true);let a=jotai.useAtomValue(tt(null));react.useEffect(()=>{let o=jotai.getDefaultStore();e.forEach(s=>{o.set(Ye(s.id),s.panelMinWidth??320),o.set(Ue(s.id),s.panelMaxWidth??440),o.set(Qe(s.id),s.modalMinWidth??504),o.set(et(s.id),s.modalMaxWidth??window.innerWidth-40);});},[e]);let c=react.useMemo(()=>e.filter(o=>{let s=jotai.getDefaultStore();return a.left[o.id]?s.get(xe(o.id))==="left":false}).sort((o,s)=>a.left[s.id]-a.left[o.id]),[e,a.left]),m=react.useMemo(()=>e.filter(o=>{let s=jotai.getDefaultStore();return a.right[o.id]?s.get(xe(o.id))==="right":false}).sort((o,s)=>(a.right[o.id]??0)-(a.right[s.id]??0)),[e,a.right]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:ui$1.cn("w-full h-full flex flex-row overflow-hidden",n,i?.root),children:[jsxRuntime.jsx("div",{className:ui$1.cn("flex-none h-full flex flex-row",i?.left),children:c.map(o=>jsxRuntime.jsx(xt,{...o,position:"left",minWidth:o.panelMinWidth??320,maxWidth:o.panelMaxWidth??440},`left-${o.id}`))}),jsxRuntime.jsx("div",{className:ui$1.cn("flex-auto min-w-0 h-full",i?.content),children:r}),jsxRuntime.jsx("div",{className:ui$1.cn("flex-none h-full flex flex-row",i?.right),children:m.map(o=>jsxRuntime.jsx(xt,{...o,position:"right",minWidth:o.panelMinWidth??320,maxWidth:o.panelMaxWidth??440},`right-${o.id}`))})]}),e.map(o=>jsxRuntime.jsx($t,{...o,minWidth:o.modalMinWidth??504,maxWidth:o.modalMaxWidth??window.innerWidth-40},`modal-${o.id}`))]})}function Dr(e){let{isOpen:t,onOpen:n,onClose:i}=Me(e),{isOpen:r,onOpen:d,onClose:a}=ze(e),c=jotai.useAtomValue(Re(e)),m=react.useCallback(()=>{t||r||(c==="modal"?n():d({position:c}));},[t,r,c,n,d]),o=react.useCallback(()=>{t?i():r&&a();},[t,r,i,a]),s=react.useMemo(()=>t||r,[t,r]);return react.useMemo(()=>({isOpen:s,onOpen:m,onClose:o}),[s,m,o])}var Kt=["desktop","tablet","mobile"];function Jt(e,t){return e.match!==void 0?typeof e.match=="function"?e.match(t):e.match instanceof RegExp?e.match.test(t):t.startsWith(e.match):e.href==="/"?t==="/":t.startsWith(e.href)}function it(e){let t={desktop:e.includes("desktop"),tablet:e.includes("tablet"),mobile:e.includes("mobile")};if(t.desktop&&t.tablet&&t.mobile)return "";if(!t.desktop&&!t.tablet&&!t.mobile)return "hidden";if(t.desktop&&t.tablet&&!t.mobile)return "max-sm:hidden";if(t.desktop&&!t.tablet&&!t.mobile)return "max-lg:hidden";if(!t.desktop&&t.tablet&&t.mobile)return "lg:hidden";if(!t.desktop&&!t.tablet&&t.mobile)return "sm:hidden";if(!t.desktop&&t.tablet&&!t.mobile)return "max-sm:hidden lg:hidden";throw new Error(`getVisibilityClass: non-contiguous breakpoints [${e.join(", ")}] are not supported. Use a contiguous range (e.g. [desktop, tablet], [tablet, mobile]).`)}var vt=react.createContext(null);function wt(){let e=react.useContext(vt);if(!e)throw new Error("useScaffold must be used within a <Scaffold> component.");return e}function Hr(e){let t=wt();react.useEffect(()=>(e.headerVisible!==void 0&&t.setHeaderVisible(e.headerVisible),e.footerVisible!==void 0&&t.setFooterVisible(e.footerVisible),e.toolbarVisible!==void 0&&t.setToolbarVisible(e.toolbarVisible),()=>{e.headerVisible!==void 0&&t.setHeaderVisible(t.defaultHeaderVisible),e.footerVisible!==void 0&&t.setFooterVisible(t.defaultFooterVisible),e.toolbarVisible!==void 0&&t.setToolbarVisible(t.defaultToolbarVisible);}),[e.headerVisible,e.footerVisible,e.toolbarVisible]);}var an=60,ln=48,dn=56,cn=36,un=()=>{};function Yr({children:e,pathname:t="",onNavigate:n=un,header:i,footer:r,toolbar:d,headerHeight:a=an,mobileHeaderHeight:c=ln,footerHeight:m=dn,toolbarHeight:o=cn,headerVisible:s=Kt,footerVisible:f=[],toolbarVisible:b=[],className:z,classNames:p}){let[v,w]=react.useState(s),[P,K]=react.useState(f),[U,N]=react.useState(b),R=react.useId(),x=react.useMemo(()=>({pathname:t,onNavigate:n,headerHeight:a,mobileHeaderHeight:c,footerHeight:m,toolbarHeight:o,headerVisible:v,footerVisible:P,toolbarVisible:U,setHeaderVisible:w,setFooterVisible:K,setToolbarVisible:N,defaultHeaderVisible:s,defaultFooterVisible:f,defaultToolbarVisible:b}),[t,n,a,c,m,o,v,P,U,s,f,b]),ue=it(v),u=it(P),me=it(U),Z=c!==a?`[data-scaffold-id="${R}"]{--scaffold-header-height:${a}px}@media(max-width:639px){[data-scaffold-id="${R}"]{--scaffold-header-height:${c}px}}`:`[data-scaffold-id="${R}"]{--scaffold-header-height:${a}px}`;return jsxRuntime.jsxs(vt.Provider,{value:x,children:[jsxRuntime.jsx("style",{children:Z}),jsxRuntime.jsxs("div",{"data-scaffold-id":R,className:ui$1.cn("w-full h-screen max-sm:h-dvh flex flex-col overflow-hidden bg-background",p?.wrapper,z),style:{"--scaffold-footer-height":`calc(${m}px + env(safe-area-inset-bottom))`,"--scaffold-toolbar-height":`${o}px`},children:[i&&jsxRuntime.jsx("nav",{className:ui$1.cn("w-full flex-none",ue,p?.header),style:{height:"var(--scaffold-header-height)"},children:i}),jsxRuntime.jsx("div",{className:ui$1.cn("w-full flex-auto min-h-0 relative overflow-y-auto",p?.content),children:e}),d&&jsxRuntime.jsx("div",{className:ui$1.cn("w-full flex-none",me,p?.toolbar),style:{height:`${o}px`},children:d}),r&&jsxRuntime.jsx("div",{className:ui$1.cn("w-full flex-none pb-[env(safe-area-inset-bottom)]",u,p?.footer),style:{height:`calc(${m}px + env(safe-area-inset-bottom))`},children:r})]})]})}function st({item:e,variant:t="header",className:n}){let{pathname:i,onNavigate:r}=wt(),d=Jt(e,i),a=react.useCallback(()=>{r(e.href);},[r,e.href]);return t==="footer"?jsxRuntime.jsxs("button",{type:"button","data-active":d,className:ui$1.cn("flex flex-col items-center justify-center gap-0.5 px-2 py-1 min-w-0","text-xs font-medium text-foreground/60","data-[active=true]:text-primary",n),onClick:a,"aria-label":e.label,"aria-current":d?"page":void 0,children:[e.icon&&jsxRuntime.jsx("span",{className:"flex items-center justify-center",children:e.icon}),jsxRuntime.jsx("span",{className:"truncate",children:e.label})]}):jsxRuntime.jsx("button",{type:"button","data-active":d,className:ui$1.cn("h-8 text-sm font-medium px-2 xl:px-3 rounded-sm cursor-pointer","text-foreground hover:text-primary hover:bg-primary-50","data-[active=true]:text-primary",n),onClick:a,"aria-label":e.label,"aria-current":d?"page":void 0,children:e.label})}function oi({children:e,left:t,right:n,navItems:i,className:r}){return e?jsxRuntime.jsx("header",{className:ui$1.cn("w-full h-full flex items-center bg-background border-b border-border",r),children:e}):jsxRuntime.jsxs("header",{className:ui$1.cn("w-full h-full px-6 max-lg:px-4 max-sm:px-3 flex items-center justify-between gap-6 max-lg:gap-4 max-sm:gap-3 bg-background border-b border-border",r),children:[t&&jsxRuntime.jsx("div",{className:"shrink-0 flex items-center",children:t}),i&&i.length>0&&jsxRuntime.jsx(ui$1.HorizontalScrollContainer,{className:"flex-auto min-w-0 max-sm:hidden",classNames:{content:"gap-1"},children:i.map(d=>jsxRuntime.jsx(st,{item:d,variant:"header"},d.key))}),n&&jsxRuntime.jsx("div",{className:"shrink-0 flex items-center gap-4",children:n})]})}function ai({children:e,navItems:t,className:n}){return e?jsxRuntime.jsx("footer",{className:ui$1.cn("w-full h-full flex items-center bg-background border-t border-border",n),children:e}):jsxRuntime.jsx("footer",{className:ui$1.cn("w-full h-full flex justify-evenly items-center bg-background border-t border-border",n),children:t?.map(i=>jsxRuntime.jsx(st,{item:i,variant:"footer"},i.key))})}function ui({children:e,left:t,right:n,className:i}){return e?jsxRuntime.jsx("div",{className:ui$1.cn("w-full h-full flex items-center bg-background border-t border-border",i),children:e}):jsxRuntime.jsxs("div",{className:ui$1.cn("w-full h-full px-6 flex items-center justify-between gap-4 bg-background border-t border-border",i),children:[t&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:t}),n&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:n})]})}function hi({href:e="/",icon:t,miniIcon:n,ariaLabel:i="Home",className:r}){return jsxRuntime.jsxs(ui$1.Link,{href:e,className:ui$1.cn("flex-none flex justify-center items-center",r),"aria-label":i,children:[jsxRuntime.jsx("div",{className:ui$1.cn("flex justify-center items-center",!!n&&"max-xl:hidden"),children:t}),n&&jsxRuntime.jsx("div",{className:"flex justify-center items-center xl:hidden",children:n})]})}function Ei({id:e,children:t}){let n=hooks.useEventEmitter(),{isOpen:i,onOpen:r,onClose:d,onOpenChange:a}=ui$1.useDisclosure(),[c,m]=react.useState(void 0),o=react.useRef(void 0),s=react.useCallback(()=>{o.current=void 0,m(void 0);},[]),f=react.useCallback(()=>{o.current?.(void 0),s(),d();},[d,s]),b=react.useCallback(p=>{o.current?.(p),s(),d();},[d,s]),z=react.useCallback(p=>{p||f();},[f]);return react.useEffect(()=>{let p=v=>{m(v?.params),o.current=v?.onResult,r();};return n.on(`open_modal:${e}`,p),()=>{n.off(`open_modal:${e}`,p);}},[e,r,n]),react.useEffect(()=>{let p=()=>{f();};return n.on(`close_modal:${e}`,p),()=>{n.off(`close_modal:${e}`,p);}},[e,f,n]),t({params:c,isOpen:i,onClose:f,onOpenChange:z,onResult:b})}function Ci(e){let t=hooks.useEventEmitter(),n=react.useCallback(r=>new Promise(d=>{let a=c=>{r?.onResult?.(c),d(c);};t.emit(`open_modal:${e}`,{...r,onResult:a});}),[e,t]),i=react.useCallback(()=>{t.emit(`close_modal:${e}`);},[e,t]);return {onOpen:n,onClose:i}}function lo({direction:e,isResizing:t,onResizeStart:n,className:i}){let r=e==="horizontal";return jsxRuntime.jsxs("div",{className:ui$1.cn("relative flex-none",i),children:[jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center justify-center bg-border/80 hover:bg-border transition-colors duration-150 ease-in-out",r?"w-1 h-full cursor-ew-resize flex-col gap-1":"w-full h-1 cursor-ns-resize flex-row gap-1"),children:[jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("div",{className:ui$1.cn("absolute inset-0",r?"-left-1.5 -right-1.5 cursor-ew-resize":"-top-1.5 -bottom-1.5 cursor-ns-resize"),onMouseDown:n})]}),t&&jsxRuntime.jsx("div",{className:ui$1.cn("fixed inset-0 z-50",r?"cursor-ew-resize":"cursor-ns-resize")})]})}var Sn=4;function Dn(e){if(!e)return null;try{let t=localStorage.getItem(`splitView.${e}`);return t?Number(t):null}catch{return null}}function On(e,t){if(e)try{localStorage.setItem(`splitView.${e}`,String(t));}catch{}}function Zi({direction:e="horizontal",primary:t,secondary:n,defaultSize:i=400,minSize:r=100,maxSize:d=1/0,secondaryMinSize:a=100,onSizeChange:c,persistId:m,className:o,classNames:s}){let f=react.useRef(null),[b,z]=react.useState(()=>Dn(m)??i),[p,v]=react.useState(false),w=e==="horizontal",P=hooks.useValueRef(b),K=hooks.useValueRef(r),U=hooks.useValueRef(d),N=hooks.useValueRef(a),R=hooks.useValueRef(p),x=hooks.useCallbackRef(u=>{z(u),On(m,u),c?.(u);}),ue=react.useCallback(u=>{u.preventDefault(),u.stopPropagation(),v(true);let me=w?"ew-resize":"ns-resize";document.body.style.cursor=me,document.body.style.userSelect="none";let Z=w?u.clientX:u.clientY,ne=P.current,X=f.current,J=X?w?X.offsetWidth:X.offsetHeight:1/0,re=S=>{if(!R.current)return;let fe=(w?S.clientX:S.clientY)-Z,y=Math.min(U.current,J-N.current-Sn),W=Math.min(Math.max(ne+fe,K.current),y);x(W);},ie=()=>{v(false),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",ie);};document.addEventListener("mousemove",re),document.addEventListener("mouseup",ie);},[w,P,K,U,N,R,x]);return jsxRuntime.jsxs("div",{ref:f,className:ui$1.cn("w-full h-full flex overflow-hidden",w?"flex-row":"flex-col",o),children:[jsxRuntime.jsx("div",{className:ui$1.cn("flex-none overflow-hidden",s?.primary),style:w?{width:`${b}px`,minWidth:`${r}px`}:{height:`${b}px`,minHeight:`${r}px`},children:t}),jsxRuntime.jsx(lo,{direction:e,isResizing:p,onResizeStart:ue,className:s?.handle}),jsxRuntime.jsx("div",{className:ui$1.cn("flex-auto min-w-0 min-h-0 overflow-hidden",s?.secondary),style:w?{minWidth:`${a}px`}:{minHeight:`${a}px`},children:n})]})}typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-scaffold"]="0.1.49");var En="0.1.49";exports.ALL_BREAKPOINTS=Kt;exports.AsyncModal=Ei;exports.DraggableModal=$t;exports.DraggablePanel=xt;exports.DraggablePanelProvider=vr;exports.Logo=hi;exports.NavLink=st;exports.Scaffold=Yr;exports.ScaffoldContext=vt;exports.ScaffoldFooter=ai;exports.ScaffoldHeader=oi;exports.ScaffoldToolbar=ui;exports.SplitHandle=lo;exports.SplitView=Zi;exports.getVisibilityClass=it;exports.isNavItemActive=Jt;exports.useAsyncModal=Ci;exports.useDraggableDisclosure=Dr;exports.useDraggableModalDisclosure=Me;exports.useDraggablePanelDisclosure=ze;exports.useScaffold=wt;exports.useScaffoldLayout=Hr;exports.version=En;//# sourceMappingURL=index.js.map
1
+ 'use strict';var react=require('react'),reactDom=require('react-dom'),jotai=require('jotai'),hooks=require('@liberfi.io/hooks'),i18n=require('@liberfi.io/i18n'),ui$1=require('@liberfi.io/ui'),utils$1=require('@liberfi.io/utils'),jotaiFamily=require('jotai-family'),utils=require('jotai/utils'),jsxRuntime=require('react/jsx-runtime');var ct="";function Ct(e){ct=e;}function V(e,t){let n=`${e}.${t??"default"}`;return ct?`${ct}:${n}`:n}var xe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelState",e),"none",void 0,{getOnInit:true})),Xe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelWidth",e),350,void 0,{getOnInit:true})),Ye=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelMinWidth",e),320,void 0,{getOnInit:true})),Ue=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelMaxWidth",e),440,void 0,{getOnInit:true})),Vt=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalOpen",e),false,void 0,{getOnInit:true})),Ze=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalShouldStartDragging",e),false,void 0,{getOnInit:true})),je=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalSize",e),{width:350,height:580},void 0,{getOnInit:true})),Ge=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalRestoreSize",e),{width:350,height:580},void 0,{getOnInit:true})),Ke=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalPosition",e),{x:typeof window<"u"?Math.max(0,(window.innerWidth-350)/2):0,y:typeof window<"u"?Math.max(0,(window.innerHeight-580)/2):0},void 0,{getOnInit:true})),Je=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalRestorePosition",e),{x:typeof window<"u"?Math.max(0,(window.innerWidth-350)/2):0,y:typeof window<"u"?Math.max(0,(window.innerHeight-580)/2):0},void 0,{getOnInit:true})),qe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalMinimized",e),false,void 0,{getOnInit:true})),Qe=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalMinWidth",e),200,void 0,{getOnInit:true})),et=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("modalMaxWidth",e),typeof window<"u"?window.innerWidth-40:0,void 0,{getOnInit:true})),Re=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("lastPanelType",e),"modal",void 0,{getOnInit:true})),tt=jotaiFamily.atomFamily(e=>utils.atomWithStorage(V("panelOrders",null),{left:{},right:{}},void 0,{getOnInit:true}));function Me(e){let[t,n]=jotai.useAtom(Vt(e)),[i,r]=jotai.useAtom(qe(e)),d=jotai.useAtomValue(Ge(e)),a=jotai.useAtomValue(Je(e)),c=jotai.useSetAtom(je(e)),m=jotai.useSetAtom(Ke(e)),o=jotai.useSetAtom(Ze(e)),s=jotai.useSetAtom(Re(e)),f=react.useCallback((z={})=>{let{shouldStartDragging:p,position:v,size:w}=z;v&&m(P=>({...P,...v})),w&&c(P=>({...P,...w})),o(p??false),n(true),s("modal");},[n,m,c,o]),b=react.useCallback(()=>{n(false),i&&(c({...d}),m({...a}),r(false));},[i,d,a,r,n,c,m]);return react.useMemo(()=>({isOpen:t,onOpen:f,onClose:b}),[t,f,b])}function ze(e){let[t,n]=jotai.useAtom(xe(e)),i=jotai.useSetAtom(Xe(e)),r=jotai.useSetAtom(Re(e)),d=jotai.useSetAtom(tt(null)),a=react.useCallback((s={})=>{let f=s.position??"left";i(s.width??320),n(f),r(f),d(({left:b,right:z})=>f==="left"?{left:{...b,[e]:Date.now()},right:z}:{left:b,right:{...z,[e]:Date.now()}});},[e,n,i]),c=react.useCallback(()=>{n("none");},[n]),m=react.useMemo(()=>t!=="none",[t]),o=react.useMemo(()=>t!=="none"?t:void 0,[t]);return react.useMemo(()=>({isOpen:m,position:o,onOpen:a,onClose:c}),[m,a,c])}var Ao={width:200,height:48},Ve={width:typeof window<"u"?window.innerWidth-40:0,height:typeof window<"u"?window.innerHeight-40:0},_o={x:20,y:20},$t=react.memo(function({id:t,title:n,minWidth:i=504,maxWidth:r=Ve.width,minHeight:d=200,maxHeight:a=Ve.height,leftSidebar:c,leftSidebarWidth:m=200,rightSidebar:o,rightSidebarWidth:s=200,aspectRatio:f,showHeader:b=true,header:z,headerHeight:p=44,children:v}){let{t:w}=i18n.useTranslation(),{isOpen:P,onClose:K}=Me(t),{onOpen:U}=ze(t),[N,R]=jotai.useAtom(qe(t)),[x,ue]=jotai.useAtom(Ke(t)),[u,me]=jotai.useAtom(je(t)),[Z,ne]=jotai.useAtom(Ge(t)),[X,J]=jotai.useAtom(Je(t)),[re,ie]=jotai.useAtom(Ze(t)),[S,se]=react.useState(re),[fe,y]=react.useState(false),[W,ae]=react.useState(null),[pe,le]=react.useState(null),[he,_]=react.useState(null),[ve,de]=react.useState(null),q=react.useRef(null),uo=jotai.useAtomValue(Ye(t)),mo=jotai.useAtomValue(Ue(t)),Q=hooks.useValueRef(x),E=hooks.useCallbackRef(ue),ge=hooks.useValueRef(u),H=hooks.useCallbackRef(me),fo=hooks.useValueRef(m),po=hooks.useValueRef(!!c),ho=hooks.useValueRef(s),go=hooks.useValueRef(!!o),j=hooks.useValueRef(f),ee=hooks.useValueRef(p),We=hooks.useValueRef(i),Ee=hooks.useValueRef(r),ke=hooks.useValueRef(d),Le=hooks.useValueRef(a),bo=hooks.useValueRef(S),Dt=hooks.useValueRef(pe),dt=hooks.useValueRef(ve),xo=hooks.useCallbackRef(K),yo=hooks.useCallbackRef(U),vo=hooks.useValueRef(uo),wo=hooks.useValueRef(mo),Ie=react.useMemo(()=>u.width===Ve.width&&u.height===Ve.height,[u.width,u.height]);react.useEffect(()=>{let l=Math.min(Math.max(u.width,i),r),k=Math.min(Math.max(u.height,d),a);(l!==u.width||k!==u.height)&&H({width:l,height:k});let A=Math.max(0,x.x),be=Math.max(0,x.y);A+l>window.innerWidth&&(A=Math.max(0,window.innerWidth-l)),be+k>window.innerHeight&&(be=Math.max(0,window.innerHeight-k)),(A!==x.x||be!==x.y)&&E({x:A,y:be});},[t]),react.useEffect(()=>{if(P&&re){se(true);let l=A=>{E({x:A.clientX-u.width/2,y:A.clientY-20});},k=()=>{se(false),ie(false),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",k);};return document.addEventListener("mousemove",l),document.addEventListener("mouseup",k),document.body.style.cursor="grabbing",()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",k),document.body.style.cursor="";}}},[P,re,ie,u.width]);let G=(l,k,A)=>{ie(false),se(false),y(false),ae(null),k==="drag"?se(true):k==="resize"&&(ae(A||null),y(true));let be=l.clientX,Ot=l.clientY,B=ge.current.width,Y=ge.current.height,$={...Q.current},Wt=()=>{document.removeEventListener("mousemove",Et),document.removeEventListener("mouseup",kt),document.body.style.cursor="",se(false),y(false),ae(null),le(null),q.current&&(clearTimeout(q.current),q.current=null),de(null),_(null);},Et=Be=>{if(k==="drag"){let te=Be.clientX-be,oe=Be.clientY-Ot,D=$.x+te,g=$.y+oe,we=po.current?fo.current:0,Ce=12+we,F=go.current?ho.current:0,O=window.innerWidth-12-B-F,$e=window.innerHeight-12-44,L=D<=Ce?"left":D>=O?"right":null;L!==Dt.current&&le(L),q.current&&L&&_(L),q.current&&(dt.current==="left"&&(D>Ce||L!=="left")||dt.current==="right"&&(D<O||L!=="right"))&&(clearTimeout(q.current),q.current=null,de(null),_(null)),!q.current&&L&&dt.current!==L&&(de(L),_(L),q.current=setTimeout(()=>{bo.current&&Dt.current===L?(Wt(),xo(),yo({position:L,width:Math.min(Math.max(ge.current.width,vo.current),wo.current)})):de(null);},350)),D=Math.min(Math.max(D,12+we),O),g=Math.min(Math.max(g,12),$e),E({x:D,y:g});}else if(k==="resize"&&A){let te=Be.clientX-be,oe=Be.clientY-Ot,D=(g,we,Ce)=>{let F=Math.min(Math.max(g,We.current),Ee.current),O=Math.min(Math.max(we,ke.current),Le.current);if(j.current){if(Ce==="width")O=Math.min(Math.max(g/j.current+ee.current,ke.current),Le.current),F=(O-ee.current)*j.current;else if(Ce==="height")F=Math.min(Math.max((we-ee.current)*j.current,We.current),Ee.current),O=F/j.current+ee.current;else {let $e=g/j.current+ee.current,L=(we-ee.current)*j.current,Lt=Math.abs(te),It=Math.abs(oe);if(Lt>1.1*It)O=Math.min(Math.max($e,ke.current),Le.current),F=(O-ee.current)*j.current;else if(It>1.1*Lt)F=Math.min(Math.max(L,We.current),Ee.current),O=F/j.current+ee.current;else {let zo=(O+$e)/2;F=Math.min(Math.max((F+L)/2,We.current),Ee.current),O=Math.min(Math.max(zo,ke.current),Le.current),F=(O-ee.current)*j.current;}}F=Math.min(Math.max(F,We.current),Ee.current),O=Math.min(Math.max(O,ke.current),Le.current);}return {width:F,height:O}};switch(A){case "topLeft":{let g=D(B-te,Y-oe,"both");H(g),E({x:$.x+(B-g.width),y:$.y+(Y-g.height)});break}case "topRight":{let g=D(B+te,Y-oe,"both");H(g),E({x:$.x,y:$.y+(Y-g.height)});break}case "bottomLeft":{let g=D(B-te,Y+oe,"both");H(g),E({x:$.x+(B-g.width),y:$.y});break}case "bottomRight":{H(D(B+te,Y+oe,"both"));break}case "top":{let g=D(B,Y-oe,"height");H(g),E({x:$.x,y:$.y+(Y-g.height)});break}case "bottom":{H(D(B,Y+oe,"height"));break}case "left":{let g=D(B-te,Y,"width");H(g),E({x:$.x+(B-g.width),y:$.y});break}case "right":{H(D(B+te,Y,"width"));break}}}},kt=()=>{(x.x<0||x.y<0)&&E({x:Math.max(0,x.x),y:Math.max(0,x.y)}),Wt();};document.addEventListener("mousemove",Et),document.addEventListener("mouseup",kt);},Ro=react.useCallback(()=>{N?(H({...Z}),E({...X}),R(false)):(Ie?E({...X}):(ne({...u}),J({...x})),H({...Ao}),R(true));},[N,Ie,u,x,Z,X,R,ne,J]),Mo=react.useCallback(()=>{Ie?(H({...Z}),E({...X})):(N?R(false):(ne({...u}),J({...x})),H({...Ve}),E({..._o}));},[Ie,N,u,x,Z,X,R,ne,J]);return react.useEffect(()=>{let l=utils$1.throttle(()=>{(Q.current.x<0||Q.current.y<0)&&E({x:Math.max(0,Q.current.x),y:Math.max(0,Q.current.y)});let k=Q.current.x+ge.current.width,A=Q.current.y+ge.current.height;(k>window.innerWidth||A>window.innerHeight)&&E({x:Math.min(Q.current.x,Math.max(0,window.innerWidth-ge.current.width)),y:Math.min(Q.current.y,Math.max(0,window.innerHeight-ge.current.height))});},100);return window.addEventListener("resize",l),()=>{window.removeEventListener("resize",l);}},[]),P?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[(S||fe)&&reactDom.createPortal(jsxRuntime.jsx("div",{className:ui$1.cn("max-sm:hidden fixed inset-0 z-9999 bg-transparent w-full h-full select-none",S&&(ve?"cursor-grabbing":"cursor-move"),!S&&{"cursor-ns-resize":W==="top"||W==="bottom","cursor-ew-resize":W==="left"||W==="right","cursor-nwse-resize":W==="topLeft"||W==="bottomRight","cursor-nesw-resize":W==="topRight"||W==="bottomLeft","cursor-auto":W===null})}),document.body),jsxRuntime.jsx("div",{className:ui$1.cn("max-sm:hidden fixed z-50 left-0 top-0",S?"will-change-transform":"will-change-auto",fe||S?"transition-none":"transition-transform duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]"),style:{transform:`translate(${Math.round(x.x-(c?m:0))}px, ${Math.round(x.y)}px)`},children:jsxRuntime.jsxs("div",{className:"flex relative z-50",children:[c&&jsxRuntime.jsx("div",{className:ui$1.cn("relative mt-1 z-10 transition-all duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]",S?"opacity-40 translate-x-4":"opacity-100 translate-x-0"),style:{width:m,height:N?40:u.height-8},children:c}),jsxRuntime.jsx("div",{className:ui$1.cn("z-50 relative bg-content1 border border-border rounded-lg overflow-hidden",S?"opacity-80 shadow-md scale-102 blur-[0.5px]":"opacity-100 shadow-lg scale-100 blur-none"),style:{width:u.width,height:u.height,transition:fe||S?"none":"transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1), height 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1)",contain:"content"},children:jsxRuntime.jsxs("div",{className:ui$1.cn("w-full h-full",he&&"animate-modal-shrink",he==="left"?"origin-left":"origin-right"),style:{contain:"paint"},children:[!N&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-3 h-3 cursor-nw-resize z-20",onMouseDown:l=>G(l,"resize","topLeft")}),jsxRuntime.jsx("div",{className:"absolute top-0 right-0 w-3 h-3 cursor-ne-resize z-20",onMouseDown:l=>G(l,"resize","topRight")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 w-3 h-3 cursor-sw-resize z-20",onMouseDown:l=>G(l,"resize","bottomLeft")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize z-20",onMouseDown:l=>G(l,"resize","bottomRight")}),jsxRuntime.jsx("div",{className:"absolute top-0 left-3 right-3 h-1.5 cursor-n-resize z-20",onMouseDown:l=>G(l,"resize","top")}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-1.5 cursor-s-resize z-20",onMouseDown:l=>G(l,"resize","bottom")}),jsxRuntime.jsx("div",{className:"absolute left-0 top-3 bottom-3 w-1.5 cursor-w-resize z-20",onMouseDown:l=>G(l,"resize","left")}),jsxRuntime.jsx("div",{className:"absolute right-0 top-3 bottom-3 w-1.5 cursor-e-resize z-20",onMouseDown:l=>G(l,"resize","right")})]}),b&&jsxRuntime.jsxs("div",{className:"relative border-b border-border/80 px-3 gap-4 flex items-center justify-between cursor-move select-none",onMouseDown:l=>G(l,"drag"),style:{height:p},children:[jsxRuntime.jsx(ui$1.StyledTooltip,{placement:"top",content:w("scaffold.draggableModal.snapToEdge"),children:jsxRuntime.jsx(ui$1.DraggableIcon,{className:"text-neutral absolute left-1/2 -translate-x-1/2 top-0"})}),z||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-initial text-sm font-medium truncate cursor-auto",onMouseDown:l=>l.stopPropagation(),children:n}),jsxRuntime.jsxs("div",{className:"flex-none flex items-center justify-end gap-1",onMouseDown:l=>l.stopPropagation(),children:[jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:Ro,children:N?jsxRuntime.jsx(ui$1.RestoreWindowIcon,{width:18,height:18,className:"text-neutral"}):jsxRuntime.jsx(ui$1.MinimizeIcon,{width:18,height:18,className:"text-neutral"})}),jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:Mo,children:Ie?jsxRuntime.jsx(ui$1.UnMaximizeIcon,{width:18,height:18,className:"text-neutral"}):jsxRuntime.jsx(ui$1.MaximizeIcon,{width:18,height:18,className:"text-neutral"})}),jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:K,children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:18,height:18,className:"text-neutral"})})]})]})]}),!N&&jsxRuntime.jsx("div",{className:b?"h-[calc(100%-44px)] overflow-x-hidden overflow-y-auto":"h-full overflow-x-hidden overflow-y-auto cursor-move",onMouseDown:b?void 0:l=>G(l,"drag"),children:v})]})}),o&&jsxRuntime.jsx("div",{className:ui$1.cn("relative mt-1 z-10 transition-all duration-250 ease-[cubic-bezier(0.16,1,0.3,1)]",S?"opacity-40 -translate-x-4":"opacity-100 translate-x-0"),style:{width:s,height:N?40:u.height-8},children:o})]})})]}):null});function xt({id:e,title:t,maxWidth:n=440,minWidth:i=320,position:r,showHeader:d=true,header:a,headerHeight:c=44,children:m}){let{t:o}=i18n.useTranslation(),s=jotai.useAtomValue(xe(e)),[f,b]=react.useState(false),[z,p]=react.useState(false),[v,w]=jotai.useAtom(Xe(e)),{onOpen:P}=Me(e),{onClose:K}=ze(e),U=jotai.useAtomValue(Qe(e)),N=jotai.useAtomValue(et(e)),R=hooks.useValueRef(v),x=hooks.useValueRef(n),ue=hooks.useValueRef(i),u=hooks.useValueRef(r),me=hooks.useValueRef(f),Z=hooks.useValueRef(z),ne=hooks.useCallbackRef(w),X=hooks.useCallbackRef(P),J=hooks.useCallbackRef(K),re=hooks.useValueRef(U),ie=hooks.useValueRef(N),S=y=>{y.preventDefault(),y.stopPropagation(),b(true),document.body.style.cursor="ew-resize",document.body.style.userSelect="none",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",document.body.style.height="100%";let W=y.clientX,ae=R.current,pe=he=>{if(!me.current)return;let _=he.clientX-W,ve=u.current==="right"?ae-_:ae+_,de=Math.min(Math.max(ve,ue.current),x.current);ne(de);},le=()=>{b(false),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width="",document.body.style.height="",document.removeEventListener("mousemove",pe),document.removeEventListener("mouseup",le);};document.addEventListener("mousemove",pe),document.addEventListener("mouseup",le);},se=y=>{if(y.target instanceof HTMLElement&&y.target.closest("button"))return;y.preventDefault(),p(true);let W=y.clientX,ae=y.clientY,pe=()=>{document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",he),p(false);},le=_=>{if(!Z.current)return;let ve=Math.abs(_.clientX-W),de=Math.abs(_.clientY-ae);(ve>10||de>10)&&(pe(),J(),X({shouldStartDragging:true,position:{x:_.clientX-R.current/2+20,y:_.clientY-20},size:{width:Math.min(Math.max(R.current,re.current),ie.current)}}));},he=()=>{pe();};document.addEventListener("mousemove",le),document.addEventListener("mouseup",he);},fe=()=>{J();};return s!==r?null:jsxRuntime.jsxs("div",{className:"max-sm:hidden flex-none flex flex-row overflow-hidden",children:[r==="right"&&jsxRuntime.jsx(Yt,{isResizing:f,handleResizeStart:S}),jsxRuntime.jsxs("div",{className:ui$1.cn("flex flex-col min-h-0 overflow-hidden bg-content1",z?"opacity-80 scale-98 blur-[1px]":"opacity-100 scale-100 blur-none"),style:{width:`${v}px`,transition:f||z?"none":"transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s cubic-bezier(0.33, 1, 0.68, 1), height 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.33, 1, 0.68, 1)",contain:"content"},children:[d&&jsxRuntime.jsxs("div",{className:"flex-none relative border-b border-border/80 px-3 gap-4 flex items-center justify-between cursor-move select-none",onMouseDown:se,style:{height:c},children:[jsxRuntime.jsx(ui$1.StyledTooltip,{placement:"top",content:o("scaffold.draggablePanel.snapToModal"),children:jsxRuntime.jsx(ui$1.DraggableIcon,{className:"text-neutral absolute left-1/2 -translate-x-1/2 top-0"})}),a||jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"min-w-0 flex-initial text-sm font-medium truncate cursor-auto",onMouseDown:y=>y.stopPropagation(),children:t}),jsxRuntime.jsx("div",{className:"flex-none flex items-center justify-end gap-1",onMouseDown:y=>y.stopPropagation(),children:jsxRuntime.jsx(ui$1.Button,{size:"sm",variant:"light",radius:"lg",isIconOnly:true,onPress:fe,children:jsxRuntime.jsx(ui$1.XCloseIcon,{width:18,height:18,className:"text-neutral"})})})]})]}),jsxRuntime.jsx("div",{className:"flex-auto min-h-0 overflow-y-auto",children:m})]}),r==="left"&&jsxRuntime.jsx(Yt,{isResizing:f,handleResizeStart:S})]})}function Yt({isResizing:e,handleResizeStart:t}){return jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsxs("div",{className:"relative w-1 h-full cursor-ew-resize bg-border/80 hover:bg-border transition-colors duration-150 ease-in-out group flex flex-col items-center justify-center gap-1",children:[jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("div",{className:"absolute inset-0 -left-1.5 -right-1.5 cursor-ew-resize",onMouseDown:t})]}),e&&jsxRuntime.jsx("div",{className:"fixed inset-0 z-50 cursor-ew-resize"})]})}function vr({contents:e=[],storagePrefix:t,className:n,classNames:i,children:r}){let d=react.useRef(false);!d.current&&t!==void 0&&(Ct(t),d.current=true);let a=jotai.useAtomValue(tt(null));react.useEffect(()=>{let o=jotai.getDefaultStore();e.forEach(s=>{o.set(Ye(s.id),s.panelMinWidth??320),o.set(Ue(s.id),s.panelMaxWidth??440),o.set(Qe(s.id),s.modalMinWidth??504),o.set(et(s.id),s.modalMaxWidth??window.innerWidth-40);});},[e]);let c=react.useMemo(()=>e.filter(o=>{let s=jotai.getDefaultStore();return a.left[o.id]?s.get(xe(o.id))==="left":false}).sort((o,s)=>a.left[s.id]-a.left[o.id]),[e,a.left]),m=react.useMemo(()=>e.filter(o=>{let s=jotai.getDefaultStore();return a.right[o.id]?s.get(xe(o.id))==="right":false}).sort((o,s)=>(a.right[o.id]??0)-(a.right[s.id]??0)),[e,a.right]);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:ui$1.cn("w-full h-full flex flex-row overflow-hidden",n,i?.root),children:[jsxRuntime.jsx("div",{className:ui$1.cn("flex-none h-full flex flex-row",i?.left),children:c.map(o=>jsxRuntime.jsx(xt,{...o,position:"left",minWidth:o.panelMinWidth??320,maxWidth:o.panelMaxWidth??440},`left-${o.id}`))}),jsxRuntime.jsx("div",{className:ui$1.cn("flex-auto min-w-0 h-full",i?.content),children:r}),jsxRuntime.jsx("div",{className:ui$1.cn("flex-none h-full flex flex-row",i?.right),children:m.map(o=>jsxRuntime.jsx(xt,{...o,position:"right",minWidth:o.panelMinWidth??320,maxWidth:o.panelMaxWidth??440},`right-${o.id}`))})]}),e.map(o=>jsxRuntime.jsx($t,{...o,minWidth:o.modalMinWidth??504,maxWidth:o.modalMaxWidth??window.innerWidth-40},`modal-${o.id}`))]})}function Dr(e){let{isOpen:t,onOpen:n,onClose:i}=Me(e),{isOpen:r,onOpen:d,onClose:a}=ze(e),c=jotai.useAtomValue(Re(e)),m=react.useCallback(()=>{t||r||(c==="modal"?n():d({position:c}));},[t,r,c,n,d]),o=react.useCallback(()=>{t?i():r&&a();},[t,r,i,a]),s=react.useMemo(()=>t||r,[t,r]);return react.useMemo(()=>({isOpen:s,onOpen:m,onClose:o}),[s,m,o])}var Kt=["desktop","tablet","mobile"];function Jt(e,t){return e.match!==void 0?typeof e.match=="function"?e.match(t):e.match instanceof RegExp?e.match.test(t):t.startsWith(e.match):e.href==="/"?t==="/":t.startsWith(e.href)}function it(e){let t={desktop:e.includes("desktop"),tablet:e.includes("tablet"),mobile:e.includes("mobile")};if(t.desktop&&t.tablet&&t.mobile)return "";if(!t.desktop&&!t.tablet&&!t.mobile)return "hidden";if(t.desktop&&t.tablet&&!t.mobile)return "max-sm:hidden";if(t.desktop&&!t.tablet&&!t.mobile)return "max-lg:hidden";if(!t.desktop&&t.tablet&&t.mobile)return "lg:hidden";if(!t.desktop&&!t.tablet&&t.mobile)return "sm:hidden";if(!t.desktop&&t.tablet&&!t.mobile)return "max-sm:hidden lg:hidden";throw new Error(`getVisibilityClass: non-contiguous breakpoints [${e.join(", ")}] are not supported. Use a contiguous range (e.g. [desktop, tablet], [tablet, mobile]).`)}var vt=react.createContext(null);function wt(){let e=react.useContext(vt);if(!e)throw new Error("useScaffold must be used within a <Scaffold> component.");return e}function Hr(e){let t=wt();react.useEffect(()=>(e.headerVisible!==void 0&&t.setHeaderVisible(e.headerVisible),e.footerVisible!==void 0&&t.setFooterVisible(e.footerVisible),e.toolbarVisible!==void 0&&t.setToolbarVisible(e.toolbarVisible),()=>{e.headerVisible!==void 0&&t.setHeaderVisible(t.defaultHeaderVisible),e.footerVisible!==void 0&&t.setFooterVisible(t.defaultFooterVisible),e.toolbarVisible!==void 0&&t.setToolbarVisible(t.defaultToolbarVisible);}),[e.headerVisible,e.footerVisible,e.toolbarVisible]);}var an=60,ln=48,dn=56,cn=36,un=()=>{};function Yr({children:e,pathname:t="",onNavigate:n=un,header:i,footer:r,toolbar:d,headerHeight:a=an,mobileHeaderHeight:c=ln,footerHeight:m=dn,toolbarHeight:o=cn,headerVisible:s=Kt,footerVisible:f=[],toolbarVisible:b=[],className:z,classNames:p}){let[v,w]=react.useState(s),[P,K]=react.useState(f),[U,N]=react.useState(b),R=react.useId(),x=react.useMemo(()=>({pathname:t,onNavigate:n,headerHeight:a,mobileHeaderHeight:c,footerHeight:m,toolbarHeight:o,headerVisible:v,footerVisible:P,toolbarVisible:U,setHeaderVisible:w,setFooterVisible:K,setToolbarVisible:N,defaultHeaderVisible:s,defaultFooterVisible:f,defaultToolbarVisible:b}),[t,n,a,c,m,o,v,P,U,s,f,b]),ue=it(v),u=it(P),me=it(U),Z=c!==a?`[data-scaffold-id="${R}"]{--scaffold-header-height:${a}px}@media(max-width:639px){[data-scaffold-id="${R}"]{--scaffold-header-height:${c}px}}`:`[data-scaffold-id="${R}"]{--scaffold-header-height:${a}px}`;return jsxRuntime.jsxs(vt.Provider,{value:x,children:[jsxRuntime.jsx("style",{children:Z}),jsxRuntime.jsxs("div",{"data-scaffold-id":R,className:ui$1.cn("w-full h-screen max-sm:h-dvh flex flex-col overflow-hidden bg-background",p?.wrapper,z),style:{"--scaffold-footer-height":`calc(${m}px + env(safe-area-inset-bottom))`,"--scaffold-toolbar-height":`${o}px`},children:[i&&jsxRuntime.jsx("nav",{className:ui$1.cn("w-full flex-none",ue,p?.header),style:{height:"var(--scaffold-header-height)"},children:i}),jsxRuntime.jsx("div",{className:ui$1.cn("w-full flex-auto min-h-0 relative overflow-y-auto",p?.content),children:e}),d&&jsxRuntime.jsx("div",{className:ui$1.cn("w-full flex-none",me,p?.toolbar),style:{height:`${o}px`},children:d}),r&&jsxRuntime.jsx("div",{className:ui$1.cn("w-full flex-none pb-[env(safe-area-inset-bottom)]",u,p?.footer),style:{height:`calc(${m}px + env(safe-area-inset-bottom))`},children:r})]})]})}function st({item:e,variant:t="header",className:n}){let{pathname:i,onNavigate:r}=wt(),d=Jt(e,i),a=react.useCallback(()=>{r(e.href);},[r,e.href]);return t==="footer"?jsxRuntime.jsxs("button",{type:"button","data-active":d,className:ui$1.cn("flex flex-col items-center justify-center gap-0.5 px-2 py-1 min-w-0","text-xs font-medium text-foreground/60","data-[active=true]:text-primary",n),onClick:a,"aria-label":e.label,"aria-current":d?"page":void 0,children:[e.icon&&jsxRuntime.jsx("span",{className:"flex items-center justify-center",children:e.icon}),jsxRuntime.jsx("span",{className:"truncate",children:e.label})]}):jsxRuntime.jsx("button",{type:"button","data-active":d,className:ui$1.cn("h-8 text-sm font-medium px-2 xl:px-3 rounded-sm cursor-pointer","text-foreground hover:text-primary hover:bg-primary-50","data-[active=true]:text-primary",n),onClick:a,"aria-label":e.label,"aria-current":d?"page":void 0,children:e.label})}function oi({children:e,left:t,right:n,navItems:i,className:r}){return e?jsxRuntime.jsx("header",{className:ui$1.cn("w-full h-full flex items-center bg-background border-b border-border",r),children:e}):jsxRuntime.jsxs("header",{className:ui$1.cn("w-full h-full px-6 max-lg:px-4 max-sm:px-3 flex items-center justify-between gap-6 max-lg:gap-4 max-sm:gap-3 bg-background border-b border-border",r),children:[t&&jsxRuntime.jsx("div",{className:"shrink-0 flex items-center",children:t}),i&&i.length>0&&jsxRuntime.jsx(ui$1.HorizontalScrollContainer,{className:"flex-auto min-w-0 max-sm:hidden",classNames:{content:"gap-1"},children:i.map(d=>jsxRuntime.jsx(st,{item:d,variant:"header"},d.key))}),n&&jsxRuntime.jsx("div",{className:"shrink-0 flex items-center gap-4",children:n})]})}function ai({children:e,navItems:t,className:n}){return e?jsxRuntime.jsx("footer",{className:ui$1.cn("w-full h-full flex items-center bg-background border-t border-border",n),children:e}):jsxRuntime.jsx("footer",{className:ui$1.cn("w-full h-full flex justify-evenly items-center bg-background border-t border-border",n),children:t?.map(i=>jsxRuntime.jsx(st,{item:i,variant:"footer"},i.key))})}function ui({children:e,left:t,right:n,className:i}){return e?jsxRuntime.jsx("div",{className:ui$1.cn("w-full h-full flex items-center bg-background border-t border-border",i),children:e}):jsxRuntime.jsxs("div",{className:ui$1.cn("w-full h-full px-6 flex items-center justify-between gap-4 bg-background border-t border-border",i),children:[t&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:t}),n&&jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:n})]})}function hi({href:e="/",icon:t,miniIcon:n,ariaLabel:i="Home",className:r}){return jsxRuntime.jsxs(ui$1.Link,{href:e,className:ui$1.cn("flex-none flex justify-center items-center",r),"aria-label":i,children:[jsxRuntime.jsx("div",{className:ui$1.cn("flex justify-center items-center",!!n&&"max-xl:hidden"),children:t}),n&&jsxRuntime.jsx("div",{className:"flex justify-center items-center xl:hidden",children:n})]})}function Ei({id:e,children:t}){let n=hooks.useEventEmitter(),{isOpen:i,onOpen:r,onClose:d,onOpenChange:a}=ui$1.useDisclosure(),[c,m]=react.useState(void 0),o=react.useRef(void 0),s=react.useCallback(()=>{o.current=void 0,m(void 0);},[]),f=react.useCallback(()=>{o.current?.(void 0),s(),d();},[d,s]),b=react.useCallback(p=>{o.current?.(p),s(),d();},[d,s]),z=react.useCallback(p=>{p||f();},[f]);return react.useEffect(()=>{let p=v=>{m(v?.params),o.current=v?.onResult,r();};return n.on(`open_modal:${e}`,p),()=>{n.off(`open_modal:${e}`,p);}},[e,r,n]),react.useEffect(()=>{let p=()=>{f();};return n.on(`close_modal:${e}`,p),()=>{n.off(`close_modal:${e}`,p);}},[e,f,n]),t({params:c,isOpen:i,onClose:f,onOpenChange:z,onResult:b})}function Ci(e){let t=hooks.useEventEmitter(),n=react.useCallback(r=>new Promise(d=>{let a=c=>{r?.onResult?.(c),d(c);};t.emit(`open_modal:${e}`,{...r,onResult:a});}),[e,t]),i=react.useCallback(()=>{t.emit(`close_modal:${e}`);},[e,t]);return {onOpen:n,onClose:i}}function lo({direction:e,isResizing:t,onResizeStart:n,className:i}){let r=e==="horizontal";return jsxRuntime.jsxs("div",{className:ui$1.cn("relative flex-none",i),children:[jsxRuntime.jsxs("div",{className:ui$1.cn("flex items-center justify-center bg-border/80 hover:bg-border transition-colors duration-150 ease-in-out",r?"w-1 h-full cursor-ew-resize flex-col gap-1":"w-full h-1 cursor-ns-resize flex-row gap-1"),children:[jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("i",{className:"rounded-full w-0.5 h-0.5 bg-neutral"}),jsxRuntime.jsx("div",{className:ui$1.cn("absolute inset-0",r?"-left-1.5 -right-1.5 cursor-ew-resize":"-top-1.5 -bottom-1.5 cursor-ns-resize"),onMouseDown:n})]}),t&&jsxRuntime.jsx("div",{className:ui$1.cn("fixed inset-0 z-50",r?"cursor-ew-resize":"cursor-ns-resize")})]})}var Sn=4;function Dn(e){if(!e)return null;try{let t=localStorage.getItem(`splitView.${e}`);return t?Number(t):null}catch{return null}}function On(e,t){if(e)try{localStorage.setItem(`splitView.${e}`,String(t));}catch{}}function Zi({direction:e="horizontal",primary:t,secondary:n,defaultSize:i=400,minSize:r=100,maxSize:d=1/0,secondaryMinSize:a=100,onSizeChange:c,persistId:m,className:o,classNames:s}){let f=react.useRef(null),[b,z]=react.useState(()=>Dn(m)??i),[p,v]=react.useState(false),w=e==="horizontal",P=hooks.useValueRef(b),K=hooks.useValueRef(r),U=hooks.useValueRef(d),N=hooks.useValueRef(a),R=hooks.useValueRef(p),x=hooks.useCallbackRef(u=>{z(u),On(m,u),c?.(u);}),ue=react.useCallback(u=>{u.preventDefault(),u.stopPropagation(),v(true);let me=w?"ew-resize":"ns-resize";document.body.style.cursor=me,document.body.style.userSelect="none";let Z=w?u.clientX:u.clientY,ne=P.current,X=f.current,J=X?w?X.offsetWidth:X.offsetHeight:1/0,re=S=>{if(!R.current)return;let fe=(w?S.clientX:S.clientY)-Z,y=Math.min(U.current,J-N.current-Sn),W=Math.min(Math.max(ne+fe,K.current),y);x(W);},ie=()=>{v(false),document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",re),document.removeEventListener("mouseup",ie);};document.addEventListener("mousemove",re),document.addEventListener("mouseup",ie);},[w,P,K,U,N,R,x]);return jsxRuntime.jsxs("div",{ref:f,className:ui$1.cn("w-full h-full flex overflow-hidden",w?"flex-row":"flex-col",o),children:[jsxRuntime.jsx("div",{className:ui$1.cn("flex-none overflow-hidden",s?.primary),style:w?{width:`${b}px`,minWidth:`${r}px`}:{height:`${b}px`,minHeight:`${r}px`},children:t}),jsxRuntime.jsx(lo,{direction:e,isResizing:p,onResizeStart:ue,className:s?.handle}),jsxRuntime.jsx("div",{className:ui$1.cn("flex-auto min-w-0 min-h-0 overflow-hidden",s?.secondary),style:w?{minWidth:`${a}px`}:{minHeight:`${a}px`},children:n})]})}typeof window<"u"&&(window.__LIBERFI_VERSION__=window.__LIBERFI_VERSION__||{},window.__LIBERFI_VERSION__["@liberfi.io/ui-scaffold"]="0.1.51");var En="0.1.51";exports.ALL_BREAKPOINTS=Kt;exports.AsyncModal=Ei;exports.DraggableModal=$t;exports.DraggablePanel=xt;exports.DraggablePanelProvider=vr;exports.Logo=hi;exports.NavLink=st;exports.Scaffold=Yr;exports.ScaffoldContext=vt;exports.ScaffoldFooter=ai;exports.ScaffoldHeader=oi;exports.ScaffoldToolbar=ui;exports.SplitHandle=lo;exports.SplitView=Zi;exports.getVisibilityClass=it;exports.isNavItemActive=Jt;exports.useAsyncModal=Ci;exports.useDraggableDisclosure=Dr;exports.useDraggableModalDisclosure=Me;exports.useDraggablePanelDisclosure=ze;exports.useScaffold=wt;exports.useScaffoldLayout=Hr;exports.version=En;//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map