react-window-manager-ui
Version:
A lightweight React component library for creating draggable, resizable windows with TypeScript support
3 lines (2 loc) • 25 kB
JavaScript
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".react-window-manager{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;color:#1a1a1a}.react-window-manager *,.react-window-manager *:before,.react-window-manager *:after{box-sizing:inherit}.react-window-manager.window{position:absolute;overflow:hidden;display:flex;flex-direction:column;border:none;background-color:#fff;color:#1a1a1a;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f;border-radius:.5rem}.react-window-manager.window.active{box-shadow:0 20px 25px -5px #0000001a,0 10px 10px -5px #0000000a}.react-window-manager.window.fullscreen{border-radius:0}.react-window-manager .header{padding:.5rem;display:flex;align-items:center;justify-content:space-between;cursor:move;background-color:#f8f9fa;color:#1a1a1a;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.react-window-manager .header .toolbar{display:flex;align-items:center}.react-window-manager .header .title{margin-left:.5rem;margin-right:.5rem;flex:1;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}.react-window-manager .header .controls{display:flex;gap:.25rem}.react-window-manager .content{flex:1;overflow:auto;padding:0}.react-window-manager .button{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;border-radius:.375rem;font-size:.875rem;font-weight:500;border:none;background:none;cursor:pointer;transition:all .15s ease-in-out;outline:none;text-decoration:none}.react-window-manager .button:focus-visible{outline:2px solid #3b82f6;outline-offset:2px}.react-window-manager .button:disabled{pointer-events:none;opacity:.5}.react-window-manager .button.default{background-color:#1a1a1a;color:#fff}.react-window-manager .button.default:hover{background-color:#1a1a1ae6}.react-window-manager .button.ghost{background-color:transparent;color:inherit}.react-window-manager .button.ghost:hover{background-color:#0000000d}.react-window-manager .button.ghost.destructive:hover{background-color:#dc2626;color:#fff}.react-window-manager .button.size-default{height:2.5rem;padding:.5rem 1rem}.react-window-manager .button.size-sm{height:2.25rem;padding:.5rem .75rem;border-radius:.375rem}.react-window-manager .button.size-lg{height:2.75rem;padding:.5rem 2rem;border-radius:.375rem}.react-window-manager .button.size-icon{height:2.5rem;width:2.5rem}.react-window-manager .header .button.size-icon{height:1.5rem;width:1.5rem;padding:.25rem;border-radius:9999px}.react-window-manager .header .button.size-icon:hover{background-color:#0000001a}.react-window-manager .header .button.size-icon.destructive:hover{background-color:#dc2626;color:#fff}.react-window-manager .resize-handle{position:absolute;z-index:10}.react-window-manager .resize-handle.se{bottom:0;right:0;width:1rem;height:1rem;cursor:se-resize}.react-window-manager .resize-handle.sw{bottom:0;left:0;width:1rem;height:1rem;cursor:sw-resize}.react-window-manager .resize-handle.ne{top:0;right:0;width:1rem;height:1rem;cursor:ne-resize}.react-window-manager .resize-handle.nw{top:0;left:0;width:1rem;height:1rem;cursor:nw-resize}.react-window-manager .resize-handle.n{top:0;left:1rem;right:1rem;height:.5rem;cursor:n-resize}.react-window-manager .resize-handle.s{bottom:0;left:1rem;right:1rem;height:.5rem;cursor:s-resize}.react-window-manager .resize-handle.e{top:1rem;bottom:1rem;right:0;width:.5rem;cursor:e-resize}.react-window-manager .resize-handle.w{top:1rem;bottom:1rem;left:0;width:.5rem;cursor:w-resize}@keyframes react-window-manager-fade-in{0%{opacity:0}to{opacity:1}}@keyframes react-window-manager-fade-out{0%{opacity:1}to{opacity:0}}@keyframes react-window-manager-scale-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes react-window-manager-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes react-window-manager-slide-in{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes react-window-manager-slide-out{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(20px)}}.react-window-manager .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.react-window-manager .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.react-window-manager .flex{display:flex}.react-window-manager .flex-1{flex:1}.react-window-manager .items-center{align-items:center}.react-window-manager .justify-center{justify-content:center}.react-window-manager .justify-between{justify-content:space-between}.react-window-manager .gap-1{gap:.25rem}.react-window-manager .text-center{text-align:center}.react-window-manager .font-medium{font-weight:500}.react-window-manager .select-none{user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.react-window-manager .cursor-move{cursor:move}.react-window-manager .overflow-hidden{overflow:hidden}.react-window-manager .overflow-auto{overflow:auto}.react-window-manager .rounded-full{border-radius:9999px}.react-window-manager .p-0{padding:0}.react-window-manager .p-1{padding:.25rem}.react-window-manager .p-2{padding:.5rem}.react-window-manager .mx-2{margin-left:.5rem;margin-right:.5rem}.react-window-manager .h-6{height:1.5rem}.react-window-manager .w-6{width:1.5rem}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),g=require("react");function Me(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const b=Me(g),se=e=>{let n;const t=new Set,s=(v,f)=>{const Y=typeof v=="function"?v(n):v;if(!Object.is(Y,n)){const O=n;n=f??(typeof Y!="object"||Y===null)?Y:Object.assign({},n,Y),t.forEach(_=>_(n,O))}},o=()=>n,u={setState:s,getState:o,getInitialState:()=>j,subscribe:v=>(t.add(v),()=>t.delete(v))},j=n=e(s,o,u);return u},Ye=e=>e?se(e):se,Xe=e=>e;function He(e,n=Xe){const t=g.useSyncExternalStore(e.subscribe,()=>n(e.getState()),()=>n(e.getInitialState()));return g.useDebugValue(t),t}const ae=e=>{const n=Ye(e),t=s=>He(n,s);return Object.assign(t,n),t},De=e=>e?ae(e):ae,le=De(e=>({windows:[],activeWindowId:null,previousWindowId:null,windowHistory:[],isAltQOpen:!1,selectedWindowIndex:0,splitterPosition:50,isSplitterVisible:!1,windowAnimation:"fade",addWindow:n=>e(t=>{if(t.windows.some(d=>d.id===n.id))return t;const s=Math.max(...t.windows.map(d=>d.zIndex),0),o={...n,zIndex:s+1,originalSize:n.size},c=t.activeWindowId?[t.activeWindowId,...t.windowHistory.filter(d=>d!==t.activeWindowId)]:t.windowHistory;return{windows:[...t.windows,o],activeWindowId:n.id,previousWindowId:t.activeWindowId,windowHistory:c}}),removeWindow:n=>e(t=>{const s=t.windows.filter(u=>u.id!==n);let o=t.activeWindowId;const c=t.windowHistory.filter(u=>u!==n);t.activeWindowId===n&&(o=c.length>0?c[0]:null);let d=t.previousWindowId;return t.previousWindowId===n&&(d=c.length>1?c[1]:null),{windows:s,activeWindowId:o,previousWindowId:d,windowHistory:c}}),updateWindow:(n,t)=>e(s=>({windows:s.windows.map(c=>{if(c.id===n){const d=t.size&&!c.snapPosition&&(!t.snapPosition||t.snapPosition==="none");return{...c,...t,originalSize:d?t.size:c.originalSize}}return c})})),setActiveWindow:n=>e(t=>{const s=Math.max(...t.windows.map(d=>d.zIndex),0),o=t.activeWindowId&&t.activeWindowId!==n?[t.activeWindowId,...t.windowHistory.filter(d=>d!==t.activeWindowId&&d!==n)]:t.windowHistory.filter(d=>d!==n),c=t.windows.map(d=>d.id===n?{...d,zIndex:s+1}:d);return{activeWindowId:n,previousWindowId:t.activeWindowId!==n?t.activeWindowId:t.previousWindowId,windowHistory:o,windows:c}}),bringToFront:n=>e(t=>{const s=Math.max(...t.windows.map(u=>u.zIndex),0),o=t.windows.find(u=>u.id===n);if(o&&o.zIndex===s)return{activeWindowId:n,previousWindowId:t.activeWindowId!==n?t.activeWindowId:t.previousWindowId,windowHistory:t.windowHistory};const c=t.activeWindowId&&t.activeWindowId!==n?[t.activeWindowId,...t.windowHistory.filter(u=>u!==t.activeWindowId&&u!==n)]:t.windowHistory.filter(u=>u!==n),d=t.windows.map(u=>u.id===n?{...u,zIndex:s+1}:u);return{activeWindowId:n,previousWindowId:t.activeWindowId!==n?t.activeWindowId:t.previousWindowId,windowHistory:c,windows:d}}),endSplitOnDrag:n=>{console.log("End split on drag:",n)},setWindowAnimation:n=>e({windowAnimation:n})}));function Ee(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{d:"m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),l.jsx("path",{fill:"currentColor",d:"m12 14.122l5.303 5.303a1.5 1.5 0 0 0 2.122-2.122L14.12 12l5.304-5.303a1.5 1.5 0 1 0-2.122-2.121L12 9.879L6.697 4.576a1.5 1.5 0 1 0-2.122 2.12L9.88 12l-5.304 5.304a1.5 1.5 0 1 0 2.122 2.12z"})]})})}function Re(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e,children:l.jsxs("g",{fill:"none",children:[l.jsx("path",{d:"M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),l.jsx("path",{fill:"currentColor",d:"M8.94 12.94a1.5 1.5 0 0 1 2.224 2.007l-.103.114L7.12 19H8.5a1.5 1.5 0 0 1 .144 2.993L8.5 22h-5a1.5 1.5 0 0 1-1.493-1.356L2 20.5v-5a1.5 1.5 0 0 1 2.993-.144L5 15.5v1.379zM20.5 2a1.5 1.5 0 0 1 1.493 1.356L22 3.5v5a1.5 1.5 0 0 1-2.993.144L19 8.5V7.121l-3.94 3.94a1.5 1.5 0 0 1-2.224-2.008l.103-.114L16.88 5H15.5a1.5 1.5 0 0 1-.144-2.993L15.5 2z"})]})})}function Le(e){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e,children:l.jsxs("g",{fill:"none",children:[l.jsx("path",{d:"M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"}),l.jsx("path",{fill:"currentColor",d:"M10.5 12a1.5 1.5 0 0 1 1.493 1.356L12 13.5v5a1.5 1.5 0 0 1-2.993.144L9 18.5v-1.379l-3.94 3.94a1.5 1.5 0 0 1-2.224-2.008l.103-.114L6.88 15H5.5a1.5 1.5 0 0 1-.144-2.993L5.5 12zm8.44-9.06a1.5 1.5 0 0 1 2.224 2.007l-.103.114L17.12 9h1.38a1.5 1.5 0 0 1 .144 2.993L18.5 12h-5a1.5 1.5 0 0 1-1.493-1.356L12 10.5v-5a1.5 1.5 0 0 1 2.993-.144L15 5.5v1.379l3.94-3.94Z"})]})})}function ce(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function Pe(...e){return n=>{let t=!1;const s=e.map(o=>{const c=ce(o,n);return!t&&typeof c=="function"&&(t=!0),c});if(t)return()=>{for(let o=0;o<s.length;o++){const c=s[o];typeof c=="function"?c():ce(e[o],null)}}}}function $e(e){const n=Ne(e),t=b.forwardRef((s,o)=>{const{children:c,...d}=s,u=b.Children.toArray(c),j=u.find(Ce);if(j){const v=j.props.children,f=u.map(Y=>Y===j?b.Children.count(v)>1?b.Children.only(null):b.isValidElement(v)?v.props.children:null:Y);return l.jsx(n,{...d,ref:o,children:b.isValidElement(v)?b.cloneElement(v,void 0,f):null})}return l.jsx(n,{...d,ref:o,children:c})});return t.displayName=`${e}.Slot`,t}var ke=$e("Slot");function Ne(e){const n=b.forwardRef((t,s)=>{const{children:o,...c}=t;if(b.isValidElement(o)){const d=_e(o),u=Oe(c,o.props);return o.type!==b.Fragment&&(u.ref=s?Pe(s,d):d),b.cloneElement(o,u)}return b.Children.count(o)>1?b.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var Ae=Symbol("radix.slottable");function Ce(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ae}function Oe(e,n){const t={...n};for(const s in n){const o=e[s],c=n[s];/^on[A-Z]/.test(s)?o&&c?t[s]=(...u)=>{const j=c(...u);return o(...u),j}:o&&(t[s]=o):s==="style"?t[s]={...o,...c}:s==="className"&&(t[s]=[o,c].filter(Boolean).join(" "))}return{...e,...t}}function _e(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=n&&"isReactWarning"in n&&n.isReactWarning;return t?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=n&&"isReactWarning"in n&&n.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}const ee=b.forwardRef(({className:e,variant:n="default",size:t="default",asChild:s=!1,...o},c)=>{const d=s?ke:"button",u="react-window-manager button",j=n,v=`size-${t}`,f=[u,j,v,e].filter(Boolean).join(" ");return l.jsx(d,{className:f,ref:c,...o})});ee.displayName="Button";const qe=({id:e,title:n="Window",children:t,position:s={x:100,y:100},size:o={width:800,height:600},toolbar:c,className:d="",animation:u,icons:j,resize:v=!0,minSize:f={width:200,height:150},maxSize:Y,allowFullscreen:O=!0,onClose:_,onToggleFullscreen:te,onResize:ne})=>{const{updateWindow:Z,removeWindow:G,activeWindowId:de,setActiveWindow:q,bringToFront:T,endSplitOnDrag:ie,windows:ue,windowAnimation:we}=le(),F=u||we,a=g.useRef(null),he=g.useRef(null),[W,k]=g.useState(s),[y,V]=g.useState(o),[H,re]=g.useState(!1),[B,fe]=g.useState({position:s,size:o});g.useEffect(()=>{ne&&ne({width:y.width,height:y.height})},[y]);const R=g.useRef(!1),N=g.useRef(!1),A=g.useRef({mouseX:0,mouseY:0,windowX:0,windowY:0}),r=g.useRef({mouseX:0,mouseY:0,width:0,height:0,cursorType:"",initialX:0,initialY:0}),C=g.useRef({touchX:0,touchY:0,windowX:0,windowY:0}),S=g.useRef(null),U=ue.find(i=>i.id===e)?.zIndex||1,Q=(i,p)=>{const I=window.innerWidth,P=window.innerHeight,D=Math.max(0,Math.min(i,I-y.width)),z=Math.max(0,Math.min(p,P-y.height));return{x:D,y:z}},pe=i=>{(i.target===i.currentTarget||i.currentTarget.contains(i.target))&&(q(e),T(e))};g.useEffect(()=>{const i=z=>{!R.current&&!N.current||(z.preventDefault(),R.current?(S.current!==null&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(()=>{const x=z.clientX-A.current.mouseX,M=z.clientY-A.current.mouseY,m=A.current.windowX+x,w=A.current.windowY+M,{x:h,y:X}=Q(m,w);k({x:h,y:X}),S.current=null})):N.current&&(S.current!==null&&cancelAnimationFrame(S.current),S.current=requestAnimationFrame(()=>{const x=z.clientX-r.current.mouseX,M=z.clientY-r.current.mouseY,m=r.current.cursorType;let w=r.current.width,h=r.current.height,X=r.current.initialX,E=r.current.initialY;if(m==="se-resize"?(w=Math.max(f.width,r.current.width+x),h=Math.max(f.height,r.current.height+M)):m==="sw-resize"?(w=Math.max(f.width,r.current.width-x),h=Math.max(f.height,r.current.height+M),X=r.current.initialX+r.current.width-w):m==="ne-resize"?(w=Math.max(f.width,r.current.width+x),h=Math.max(f.height,r.current.height-M),E=r.current.initialY+r.current.height-h):m==="nw-resize"?(w=Math.max(f.width,r.current.width-x),h=Math.max(f.height,r.current.height-M),X=r.current.initialX+r.current.width-w,E=r.current.initialY+r.current.height-h):m==="n-resize"?(h=Math.max(f.height,r.current.height-M),E=r.current.initialY+r.current.height-h):m==="s-resize"?h=Math.max(f.height,r.current.height+M):m==="e-resize"?w=Math.max(f.width,r.current.width+x):m==="w-resize"&&(w=Math.max(f.width,r.current.width-x),X=r.current.initialX+r.current.width-w),Y){const J=w,K=h;w=Math.min(w,Y.width),h=Math.min(h,Y.height),m==="nw-resize"?(w!==J&&(X=r.current.initialX+r.current.width-w),h!==K&&(E=r.current.initialY+r.current.height-h)):m==="ne-resize"?h!==K&&(E=r.current.initialY+r.current.height-h):m==="sw-resize"?w!==J&&(X=r.current.initialX+r.current.width-w):m==="n-resize"?h!==K&&(E=r.current.initialY+r.current.height-h):m==="w-resize"&&w!==J&&(X=r.current.initialX+r.current.width-w)}const be=window.innerWidth-X,ze=window.innerHeight-E,je=Math.min(w,be),Se=Math.min(h,ze);V({width:je,height:Se}),k({x:X,y:E}),S.current=null})))},p=z=>{if(!R.current)return;z.preventDefault();const x=z.touches[0];if(!x)return;const M=x.clientX-C.current.touchX,m=x.clientY-C.current.touchY,w=C.current.windowX+M,h=C.current.windowY+m,{x:X,y:E}=Q(w,h);k({x:X,y:E})},I=()=>{R.current&&(R.current=!1,Z(e,{position:W}),ie(e)),N.current&&(N.current=!1,Z(e,{position:W,size:y})),S.current!==null&&(cancelAnimationFrame(S.current),S.current=null)},P=()=>{R.current&&(R.current=!1,ie(e))},D=()=>{const z=window.innerWidth,x=window.innerHeight;H?(k({x:0,y:0}),V({width:z,height:x})):k(M=>{const{x:m,y:w}=Q(M.x,M.y);return{x:m,y:w}})};return document.addEventListener("mousemove",i),document.addEventListener("mouseup",I),document.addEventListener("touchmove",p),document.addEventListener("touchend",P),window.addEventListener("resize",D),()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",I),document.removeEventListener("touchmove",p),document.removeEventListener("touchend",P),window.removeEventListener("resize",D),S.current!==null&&cancelAnimationFrame(S.current)}},[e,y.width,y.height,H]);const me=i=>{H||(i.preventDefault(),i.stopPropagation(),R.current=!0,A.current={mouseX:i.clientX,mouseY:i.clientY,windowX:W.x,windowY:W.y},q(e),T(e))},ge=i=>{i.preventDefault(),i.stopPropagation(),O&&oe()},xe=i=>{if(H)return;i.preventDefault(),i.stopPropagation();const p=i.touches[0];p&&(R.current=!0,C.current={touchX:p.clientX,touchY:p.clientY,windowX:W.x,windowY:W.y},q(e),T(e))},$=i=>{i.preventDefault(),i.stopPropagation(),N.current=!0;const p=i.target,I=window.getComputedStyle(p).cursor;r.current={mouseX:i.clientX,mouseY:i.clientY,width:y.width,height:y.height,cursorType:I,initialX:W.x,initialY:W.y},q(e),T(e)},ve=()=>{if(a.current){let i;switch(F){case"fade":i=a.current.animate([{opacity:1},{opacity:0}],{duration:200,easing:"ease-out",fill:"forwards"});break;case"scale":i=a.current.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(0.8)"}],{duration:200,easing:"ease-out",fill:"forwards"});break;case"slide":i=a.current.animate([{opacity:1,transform:"translateY(0)"},{opacity:0,transform:"translateY(20px)"}],{duration:200,easing:"ease-out",fill:"forwards"});break;case"flip":i=a.current.animate([{opacity:1,transform:"rotateX(0deg)"},{opacity:0,transform:"rotateX(15deg)"}],{duration:300,easing:"ease-out",fill:"forwards"});break;case"rotate":i=a.current.animate([{opacity:1,transform:"rotate(0deg)"},{opacity:0,transform:"rotate(2deg)"}],{duration:300,easing:"ease-out",fill:"forwards"});break;case"jellyfish":i=a.current.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(0.8) translateY(10px)"}],{duration:300,easing:"ease-in-out",fill:"forwards"});break;default:G(e);return}i.onfinish=()=>{G(e),_&&_()}}else G(e)},oe=()=>{const i=!H;if(H){const p={...B.position},I={...B.size};if(a.current){a.current.getAnimations().forEach(x=>x.cancel());let P="cubic-bezier(0.4, 0, 0.2, 1)",D=300;F==="jellyfish"&&(P="cubic-bezier(0.34, 1.56, 0.64, 1)",D=400);const z=a.current.animate([{left:`${W.x}px`,top:`${W.y}px`,width:`${y.width}px`,height:`${y.height}px`,borderRadius:"0"},{left:`${p.x}px`,top:`${p.y}px`,width:`${I.width}px`,height:`${I.height}px`,borderRadius:"0.5rem"}],{duration:D,easing:P,fill:"forwards"});z.onfinish=()=>{a.current&&(a.current.getAnimations().forEach(x=>x.cancel()),a.current.style.cssText="",a.current.style.position="absolute",a.current.style.left=`${p.x}px`,a.current.style.top=`${p.y}px`,a.current.style.width=`${I.width}px`,a.current.style.height=`${I.height}px`,a.current.style.transformOrigin="top center",a.current.style.zIndex=U.toString()),k(p),V(I),re(!1)}}}else if(fe({position:{...W},size:{...y}}),re(!0),a.current){a.current.getAnimations().forEach(D=>D.cancel());let p="cubic-bezier(0.4, 0, 0.2, 1)",I=300;F==="jellyfish"&&(p="cubic-bezier(0.34, 1.56, 0.64, 1)",I=400);const P=a.current.animate([{left:`${W.x}px`,top:`${W.y}px`,width:`${y.width}px`,height:`${y.height}px`,borderRadius:"0.5rem"},{left:"0px",top:"0px",width:`${window.innerWidth}px`,height:`${window.innerHeight}px`,borderRadius:"0"}],{duration:I,easing:p,fill:"forwards"});P.onfinish=()=>{a.current&&(a.current.getAnimations().forEach(D=>D.cancel()),a.current.style.cssText="",a.current.style.position="absolute",a.current.style.left="0px",a.current.style.top="0px",a.current.style.width=`${window.innerWidth}px`,a.current.style.height=`${window.innerHeight}px`,a.current.style.transformOrigin="top center",a.current.style.zIndex=U.toString()),k({x:0,y:0}),V({width:window.innerWidth,height:window.innerHeight})}}Z(e,{position:H?B.position:{x:0,y:0},size:H?B.size:{width:window.innerWidth,height:window.innerHeight}}),te&&te(i)};g.useEffect(()=>{if(a.current)switch(F){case"fade":a.current.animate([{opacity:0},{opacity:1}],{duration:200,easing:"ease-out",fill:"forwards"});break;case"scale":a.current.animate([{opacity:0,transform:"scale(0.8)"},{opacity:1,transform:"scale(1)"}],{duration:200,easing:"ease-out",fill:"forwards"});break;case"slide":a.current.animate([{opacity:0,transform:"translateY(20px)"},{opacity:1,transform:"translateY(0)"}],{duration:200,easing:"ease-out",fill:"forwards"});break;case"flip":a.current.animate([{opacity:0,transform:"rotateX(15deg)"},{opacity:1,transform:"rotateX(0deg)"}],{duration:300,easing:"ease-out",fill:"forwards"});break;case"rotate":a.current.animate([{opacity:0,transform:"rotate(-2deg)"},{opacity:1,transform:"rotate(0deg)"}],{duration:300,easing:"ease-out",fill:"forwards"});break;case"jellyfish":a.current.animate([{opacity:0,transform:"scale(0.7)"},{opacity:1,transform:"scale(1)"}],{duration:400,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)",fill:"forwards"});break}},[e]),g.useEffect(()=>(window.__WINDOW_ID__=e,()=>{window.__WINDOW_ID__===e&&delete window.__WINDOW_ID__}),[e]);const ye=l.jsx(Re,{}),We=l.jsx(Le,{}),Ie=l.jsx(Ee,{}),L=(()=>{if(v===!1)return[];const i=[];switch(v){case!0:case"both":i.push("se","sw","ne","nw","n","s","e","w");break;case"horizontal":i.push("e","w","ne","nw","se","sw");break;case"vertical":i.push("n","s","ne","nw","se","sw");break;case"left":i.push("w","nw","sw");break;case"right":i.push("e","ne","se");break;case"top":i.push("n");break;case"bottom":i.push("s");break;default:i.push("se","sw","ne","nw","n","s","e","w");break}return i})();return l.jsxs("div",{ref:a,style:{position:"absolute",width:y.width,height:y.height,left:W.x,top:W.y,transformOrigin:"top center",zIndex:U},className:`react-window-manager window ${H?"fullscreen":""} ${de===e?"active":""} ${d}`,onMouseDown:pe,"data-window-id":e,children:[l.jsxs("div",{ref:he,onMouseDown:me,onTouchStart:xe,onDoubleClick:ge,className:"react-window-manager header",children:[l.jsx("div",{className:"react-window-manager toolbar",children:c}),l.jsx("div",{className:"react-window-manager title",children:n}),l.jsxs("div",{className:"react-window-manager controls",children:[O&&l.jsx(ee,{onClick:i=>{i.preventDefault(),i.stopPropagation(),oe()},onMouseDown:i=>i.stopPropagation(),size:"icon",variant:"ghost",children:H?j?.fullscreenExit||We:j?.fullscreen||ye}),l.jsx(ee,{onClick:ve,onMouseDown:i=>i.stopPropagation(),size:"icon",variant:"ghost",className:"destructive",children:j?.close||Ie})]})]}),l.jsx("div",{className:"react-window-manager content",children:t}),!H&&L.length>0&&l.jsxs(l.Fragment,{children:[L.includes("se")&&l.jsx("div",{onMouseDown:$,className:"react-window-manager resize-handle se"}),L.includes("sw")&&l.jsx("div",{onMouseDown:$,className:"react-window-manager resize-handle sw"}),L.includes("ne")&&l.jsx("div",{onMouseDown:$,className:"react-window-manager resize-handle ne"}),L.includes("nw")&&l.jsx("div",{onMouseDown:$,className:"react-window-manager resize-handle nw"}),L.includes("n")&&l.jsx("div",{onMouseDown:$,className:"react-window-manager resize-handle n"}),L.includes("s")&&l.jsx("div",{onMouseDown:$,className:"react-window-manager resize-handle s"}),L.includes("e")&&l.jsx("div",{onMouseDown:$,className:"react-window-manager resize-handle e"}),L.includes("w")&&l.jsx("div",{onMouseDown:$,className:"react-window-manager resize-handle w"})]})]})};exports.Window=qe;exports.useWindowManagerStore=le;