@classicy/classicy 3.8.0 → 3.9.0

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/README.md CHANGED
@@ -14,6 +14,25 @@ A UI framework using native CSS/JS replications of the Mac OS 8 interface compon
14
14
 
15
15
  ### [See our Storybook collection here!](https://demo.classicy.ing/storybook/)
16
16
 
17
+ ## Start a new app
18
+
19
+ `create-classicy` scaffolds a Vite + React + TypeScript app with Classicy and
20
+ a starter application, asking which looks to install:
21
+
22
+ ```sh
23
+ npm create classicy@latest my-app
24
+ # or: pnpm create classicy my-app, yarn create classicy my-app, npx create-classicy my-app
25
+ cd my-app
26
+ npm install
27
+ npm run dev
28
+ ```
29
+
30
+ Pass `--appearance windows98,platinum` (`platinum`, `system7`, `windows98` or
31
+ `all`; the first is the look a first visit starts in) and `--yes` to skip the
32
+ questions; with npm, put them after `--`. The templates live in
33
+ [`templates/`](templates/), the tool in
34
+ [`packages/create-classicy`](packages/create-classicy/).
35
+
17
36
  ## Using Classicy in a Vite app
18
37
 
19
38
  Classicy is a framework, `@classicy/classicy`, and the looks it draws, its
@@ -37941,7 +37941,7 @@ const oB = 3e3, d2e = () => typeof CSS < "u" && typeof CSS.supports == "function
37941
37941
  ]
37942
37942
  }
37943
37943
  ) : b;
37944
- }, f2e = "3.8.0", g2e = "Ravel", Cz = {
37944
+ }, f2e = "3.9.0", g2e = "Bart\xF3k", Cz = {
37945
37945
  version: f2e,
37946
37946
  release: g2e
37947
37947
  }, CC = 64, m2e = 20.5, h2e = "Off", y2e = "Finder.app", { version: b2e } = Cz, C2e = Cz, w2e = C2e.release, v2e = ({ className: e, style: t }) => {
@@ -76,7 +76,7 @@ This is a plain text file opened in SimpleText.`},"The Oregon Trail.stack":DU},U
76
76
  ${r}`},yH=({topicId:t,className:e,style:n})=>{const s=st(),r=ye(w=>w.System.Manager.Applications.apps[Ks]?.data),i=R7(t),o=gt().help?.topicWindow==="winhelp",a=et("icons","system.extensions.appleGuide")??"",{name:c}=cs(Ks,{name:nb,icon:a}),l=tn(),{showContextMenu:d}=ar(),u=g.useRef(null),p=r??{},h=(sb(p)?p:{}).pages?.[t]??0;if(!i)return null;const A=w=>s({type:"ClassicyAppAppleGuideSetPage",app:{id:Ks},topicId:t,page:w}),m=()=>{const w=mH(i.title,u.current?.querySelector(".classicyAssistantBodyViewport")),k=typeof navigator>"u"?void 0:navigator.clipboard;if(!k){Ve("warn","AppleGuide","No clipboard to copy the topic to");return}k.writeText(w).catch(I=>Ve("warn","AppleGuide","Could not copy the topic",I))},y=[{id:`${$0(t)}_copy`,title:"Copy",accessKey:l("o"),onClickFunc:m}],C=w=>{const k=w.currentTarget.getBoundingClientRect();d(y,[k.left-1,k.bottom-1],{helpItem:!1})},v=i.pages.length-1,S=i.pages.map((w,k)=>({title:i.title,content:b.jsxs(b.Fragment,{children:[w,k===v&&b.jsx("p",{className:"appleGuideEnd",children:"- End -"})]})}));return b.jsx(Qt,{id:$0(t),appId:Ks,className:Ae("appleGuideWindowFrame",e),style:n,title:o?c:void 0,icon:o?a:void 0,hideIcon:!o,closable:!0,zoomable:!0,collapsable:!0,resizable:o,scrollable:!1,initialSize:[700,322],minimumSize:o?[320,200]:void 0,initialPosition:["center","center"],onCloseFunc:()=>s({type:"ClassicyAppAppleGuideCloseTopic",app:{id:Ks},topicId:t}),children:b.jsxs("div",{ref:u,className:Ae("appleGuideWindow",o&&"appleGuideWindowWithButtonBar"),children:[o&&b.jsxs("div",{className:"appleGuideButtonBar",children:[b.jsx($e,{accessKey:l("T"),onClickFunc:()=>s({type:qc,app:{id:Ks}}),children:"Help Topics"}),b.jsx($e,{accessKey:l(""),disabled:h===0,onClickFunc:()=>A(h-1),children:"Back"}),b.jsx($e,{accessKey:l("O"),"aria-haspopup":"menu",onClickFunc:C,children:"Options"})]}),b.jsx(gH,{pages:S,page:h,onPageChange:A})]})})},aM=t=>Array.isArray(t.children)&&t.children.length>0;function bH(t,e=new Set){for(const n of t)aM(n)&&n.defaultOpen&&e.add(n.id),n.children&&bH(n.children,e);return e}function CH(t,e,n=0,s=[],r){for(const i of t){const o=aM(i),a=o&&e.has(i.id);s.push({id:i.id,node:i,depth:n,hasChildren:o,open:a,parentId:r}),a&&i.children&&CH(i.children,e,n+1,s,i.id)}return s}const vH=(t,e,n)=>{!t.selectOnPress||n.button!==0||(t.pressedRef.current=e.id,!(n.detail>1)&&t.onSelectNode?.(e.id,e,n))},wH=(t,e)=>{const n=t.pressedRef.current===e.id;return t.pressedRef.current=null,n},SH=({node:t,depth:e,ctx:n})=>{const s=aM(t),r=s&&n.openSet.has(t.id),i=n.tabStopId===t.id,o=!s&&n.selectionMode!=="none"&&t.selectable!==!1&&!t.disabled,a=!s&&n.selectedIds.includes(t.id),c=s&&n.selectionMode!=="none"&&t.branchSelectable===!0&&!t.disabled,l=s&&n.selectedIds.includes(t.id),d=t.buttons??(t.button?[t.button]:[]),u=b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"classicyTreeNodeDisclosure",children:s&&b.jsx(lC,{direction:n.direction,open:r,interactive:!1})}),t.leftIcon&&b.jsx(pn,{className:"classicyTreeNodeIcon",src:t.leftIcon,dimmed:t.disabled?"disabledItem":!1,alt:"","aria-hidden":!0}),b.jsx("span",{className:"classicyTreeNodeLabel",children:t.label})]}),p=h=>n.registerRef(t.id,h),f=()=>n.focus(t.id);return b.jsxs("li",{className:"classicyTreeNode",children:[b.jsxs("div",{className:"classicyTreeNodeRow",style:{paddingLeft:`calc(var(--window-control-size) * ${e})`},children:[s?b.jsx("div",{role:"button","aria-expanded":r,"aria-pressed":c?l:void 0,tabIndex:i?0:-1,ref:p,className:Ae("classicyTreeNodeLabelHolder classicyTreeNodeBranch",xt({disabled:t.disabled,selected:c&&l})),onMouseDown:h=>{c&&vH(n,t,h)},onClick:h=>{if(!t.disabled){if(c){if(wH(n,t))return;n.onSelectNode?.(t.id,t,h);return}n.toggle(t.id)}},onDoubleClick:()=>{t.disabled||n.toggle(t.id)},onFocus:f,children:u}):o?b.jsx("div",{role:"button",tabIndex:i?0:-1,"aria-pressed":a,ref:p,className:Ae("classicyTreeNodeLabelHolder","classicyTreeNodeLeaf","classicyTreeNodeSelectable",xt({selected:a})),onMouseDown:h=>vH(n,t,h),onClick:h=>{wH(n,t)||n.onSelectNode?.(t.id,t,h)},onDoubleClick:()=>n.onActivateNode?.(t.id,t),onFocus:f,children:u}):b.jsx("div",{tabIndex:i?0:-1,ref:p,className:Ae("classicyTreeNodeLabelHolder","classicyTreeNodeLeaf",xt({disabled:t.disabled,selected:a})),onFocus:f,children:u}),!s&&d.map((h,A)=>b.jsx($e,{buttonSize:"small",margin:"sm",isDefault:h.isDefault,disabled:h.disabled,depressed:h.depressed,onClickFunc:m=>{m.stopPropagation(),h.onClickFunc?.(m)},children:h.label},A)),t.rightIcon&&b.jsx(pn,{className:"classicyTreeNodeIconRight",src:t.rightIcon,alt:"","aria-hidden":!0})]}),s&&r&&b.jsx("ul",{className:"classicyTreeGroup",children:t.children?.map(h=>b.jsx(SH,{node:h,depth:e+1,ctx:n},h.id))})]})},cM=({nodes:t,direction:e="right",onToggleNode:n,openIds:s,selectionMode:r="none",selectedIds:i,onSelectNode:o,onActivateNode:a,className:c,style:l})=>{const[d,u]=g.useState(()=>bH(t)),p=s!==void 0,f=g.useMemo(()=>s?new Set(s):d,[s,d]),h=g.useMemo(()=>CH(t,f),[t,f]),A=gt(),m=O6(A),y=Xd(A),C=QE(A),v=g.useRef(null),S=g.useRef(null),w=g.useMemo(()=>h.map(G=>({id:G.id,label:G.node.label})),[h]),{activeId:k,setActiveId:I,tabStopId:T,registerRef:D,selectRow:O,handleNavKey:x}=tD(w,C?{pageRows:()=>XE(S.current?.querySelector(".classicyTreeNodeLabelHolder"))?.pageRows??1}:void 0),B=g.useContext(Ia)===!1,F=xn("Tree",{inactive:B},S),z=F.emit,V=g.useCallback((G,Y)=>{p||u(N=>{const J=new Set(N);return Y?J.add(G):J.delete(G),J}),z(Y?"expand":"collapse",mt({nodeId:G,open:Y})),n?.(G,Y)},[p,n,z]),P=g.useCallback(G=>{V(G,!f.has(G))},[f,V]),W=i??[],K=g.useCallback((G,Y,N)=>{z("select",mt({nodeId:G})),o?.(G,Y,N)},[z,o]),L={direction:e,openSet:f,tabStopId:T,toggle:P,focus:I,registerRef:D,selectionMode:r,selectedIds:W,onSelectNode:K,onActivateNode:a,selectOnPress:y,pressedRef:v},M=g.useCallback(G=>{if(h.length===0)return;if(m&&(G.ctrlKey||G.metaKey)&&!G.altKey){const te=y0(S.current),H=S.current?.querySelector(".classicyTreeNodeRow"),X=Dye(G.key,{rowHeight:H?.getBoundingClientRect().height??0,scrollTop:te?.scrollTop??0,scrollHeight:te?.scrollHeight??0,clientHeight:te?.clientHeight??0});if(X){G.preventDefault(),Mye(S.current,X[0],X[1]);return}}if(x(G)!==null)return;const Y=k?h.findIndex(te=>te.id===k):-1,N=Y>=0?h[Y]:void 0,J=m&&!G.metaKey&&!G.ctrlKey&&!G.altKey;switch(G.key){case"ArrowRight":{if((G.metaKey||G.ctrlKey)&&N?.hasChildren&&!N.open&&!N.node.disabled){G.preventDefault(),V(N.id,!0);return}if(J&&N){if(G.preventDefault(),!N.hasChildren)return;if(!N.open){N.node.disabled||V(N.id,!0);return}const te=h[Y+1];te&&te.parentId===N.id&&O(te.id)}return}case"ArrowLeft":{if((G.metaKey||G.ctrlKey)&&N?.hasChildren&&N.open&&!N.node.disabled){G.preventDefault(),V(N.id,!1);return}if(J&&N){if(G.preventDefault(),N.hasChildren&&N.open&&!N.node.disabled){V(N.id,!1);return}N.parentId!==void 0&&O(N.parentId)}return}case"Enter":case" ":{if(!N)return;if(N.hasChildren){if(N.node.disabled)return;const H=r!=="none"&&N.node.branchSelectable===!0;G.preventDefault(),H?K(N.id,N.node,G):P(N.id);return}r!=="none"&&N.node.selectable!==!1&&!N.node.disabled&&(G.preventDefault(),K(N.id,N.node,G));return}}},[h,k,x,m,O,V,P,r,K]);return b.jsx("ul",{...F.attrs,ref:S,className:Ae("classicyTree",F.className,c),style:F.style?{...F.style,...l}:l,onKeyDown:M,children:t.map(G=>b.jsx(SH,{node:G,depth:0,ctx:L},G.id))})},lM="book:",IC="topic:",EH=t=>{const e=[],n=new Map;for(const s of t){if(s.book===void 0||s.book===""){e.push({kind:"topic",id:`${IC}${s.id}`,title:s.title,topic:s});continue}let r=n.get(s.book);r||(r=[],n.set(s.book,r),e.push({kind:"book",id:`${lM}${s.book}`,title:s.book,topics:r})),r.push(s)}return e},kH=({className:t,style:e})=>{const n=st(),s=W7(),r=tn(),i=et("icons","system.extensions.appleGuide")??"",{name:o}=cs(Ks,{name:nb,icon:i}),a=et("icons","system.help")??"",c=et("icons","system.files.document")??"",l=g.useMemo(()=>EH(s),[s]),[d,u]=g.useState([]),[p,f]=g.useState(void 0),h=g.useMemo(()=>l.map(F=>F.kind==="book"?{id:F.id,label:F.title,leftIcon:a,branchSelectable:!0,children:F.topics.map(z=>({id:`${IC}${z.id}`,label:z.title,leftIcon:c}))}:{id:F.id,label:F.title,leftIcon:c}),[l,a,c]),A=g.useMemo(()=>new Set(h.flatMap(F=>[F.id,...(F.children??[]).map(z=>z.id)])),[h]),m=p!==void 0&&A.has(p)?p:h[0]?.id,y=g.useRef(m);y.current=m;const C=g.useRef(null),v=g.useMemo(()=>({get current(){return C.current?.querySelector('.classicyTreeNodeLabelHolder[tabindex="0"]')??null}}),[]),S=()=>n({type:"ClassicyAppAppleGuideCloseTopics",app:{id:Ks}}),w=F=>{y.current=F,f(F)},k=(F,z)=>u(V=>z?V.includes(F)?V:[...V,F]:V.filter(P=>P!==F)),I=F=>{F.startsWith(IC)&&(n({type:np,app:{id:Ks},topicId:F.slice(IC.length)}),S())},T=F=>{F!==void 0&&(F.startsWith(lM)?k(F,!d.includes(F)):I(F))},D=m?.startsWith(lM)===!0,O=D&&d.includes(m??""),x=D?O?{label:"Close",key:"l"}:{label:"Open",key:"O"}:{label:"Display",key:"D"},B=F=>{if(!(F.altKey||F.ctrlKey||F.metaKey)){if(F.key==="Escape"){F.preventDefault(),S();return}F.key==="Enter"&&!(F.target instanceof Element&&F.target.closest("button"))&&(F.preventDefault(),T(y.current))}};return b.jsx(Qt,{id:CI,appId:Ks,title:`Help Topics: ${o}`,className:Ae("classicyHelpTopicsWindow",t),style:e,hideIcon:!0,closable:!0,zoomable:!1,collapsable:!1,resizable:!1,scrollable:!1,contentFrame:!0,initialSize:[428,423],initialPosition:["center","center"],initialFocusRef:v,onCloseFunc:S,children:b.jsxs("div",{className:"classicyHelpTopics",onKeyDown:B,children:[b.jsx(au,{tabs:[{title:"Contents",accessKey:r("C"),children:b.jsxs("div",{className:"classicyHelpTopicsContents",children:[b.jsx("p",{className:"classicyHelpTopicsPrompt",children:D?"Click a book, and then click Open.":"Click a topic, and then click Display."}),b.jsx(Os,{ref:C,className:"classicyHelpTopicsList",viewportClassName:"classicyHelpTopicsListViewport",children:b.jsx(cM,{nodes:h,selectionMode:"single",selectedIds:m===void 0?[]:[m],openIds:d,onToggleNode:k,onSelectNode:w,onActivateNode:F=>{w(F),I(F)}})})]})}]}),b.jsxs("div",{className:"classicyHelpTopicsButtons",children:[b.jsx($e,{isDefault:!0,disabled:m===void 0,accessKey:r(x.key),onClickFunc:()=>T(y.current),children:x.label}),b.jsx($e,{onClickFunc:S,children:"Cancel"})]})]})})},IH=()=>{const t=et("icons","system.extensions.appleGuide")??"",n=ye(o=>o.System.Manager.Applications.apps[Ks]?.data)??{},s=sb(n)?n:{},r=s.openTopics??[],i=gt().help?.topicWindow==="winhelp";return b.jsxs(Fs,{id:Ks,name:nb,icon:t,extension:!0,children:[r.map(o=>b.jsx(yH,{topicId:o},o)),i&&s.helpTopicsOpen===!0&&b.jsx(kH,{})]})},TH={id:"spacer"},wSe=()=>{const t=st(),e=ye(a=>a.System.Manager.Applications.apps[Ba]?.data),n=e?.enabled??!0,s=Qc().id;ny();const r=OD(s).length>0,i=e?.timeoutMinutes??FD,o=cs(Tp,{name:"Screen Saver",icon:ir.system.extensions.screensaver});return[{id:"screen-saver-status",title:n?`Starts After ${i} Minute${i===1?"":"s"} Idle`:"Screen Saver Is Off",disabled:!0,className:"classicyControlStripStatus"},TH,{id:"screen-saver-sleep-now",title:"Sleep Now",disabled:!n||!r,onClickFunc:()=>t({type:Dp})},{id:"screen-saver-enabled",title:"Screen Saver On",checked:n,onClickFunc:()=>t({type:"ClassicyAppScreenSaverSetEnabled",enabled:!n})},TH,RT(t,o.name,{id:Tp,name:"Screen Saver",icon:ir.system.extensions.screensaver})]},SSe=()=>et("icons","system.controlStrip.screenSaver")??ir.system.controlStrip.screenSaver,ESe=Wb({id:Rb.screenSaver,appId:Ba,label:"Screen Saver",order:20,icon:SSe,fileIcon:ir.system.extensions.screensaver,menuItems:wSe,panel:{id:Tp,name:"Screen Saver",icon:ir.system.extensions.screensaver}}),kSe=(t,e)=>{const n=st(),s=GA(t),r=ND(t)*6e4,i=t.active===!0,o=g.useRef(Date.now()),a=g.useRef(i);a.current=i,g.useEffect(()=>{if(!s)return;const c=u=>{o.current=Date.now(),a.current&&((u.type==="keydown"||u.type==="mousedown")&&(u.preventDefault(),u.stopPropagation()),n({type:"ClassicyAppScreenSaverDeactivate"}))},l={capture:!0,passive:!0},d={capture:!0};return document.addEventListener("mousemove",c,l),document.addEventListener("wheel",c,l),document.addEventListener("touchstart",c,l),document.addEventListener("mousedown",c,d),document.addEventListener("keydown",c,d),()=>{document.removeEventListener("mousemove",c,l),document.removeEventListener("wheel",c,l),document.removeEventListener("touchstart",c,l),document.removeEventListener("mousedown",c,d),document.removeEventListener("keydown",c,d)}},[s,n]),g.useEffect(()=>{if(!s||i||!e)return;let c;const l=()=>{const d=Date.now()-o.current;if(d>=r){n({type:Dp});return}c=setTimeout(l,r-d)};return c=setTimeout(l,r),()=>clearTimeout(c)},[s,i,e,r,n])},uM="classicyScreenSaverActive",DH="classicy-screen-saver-overlay",ISe=()=>{g.useEffect(()=>{const t=document.documentElement;return t.classList.add(uM),()=>{t.classList.remove(uM)}},[])},TSe="(prefers-reduced-motion: reduce)",DSe=(t,e)=>{g.useEffect(()=>{const n=t.current;if(e===void 0||!n||typeof window.matchMedia!="function")return;const s=window.matchMedia(TSe),r=new Set,i=l=>{if(l.playState!=="paused"){for(const d of r)d.effect?.target?.isConnected===!1&&r.delete(d);l.pause(),r.add(l)}},o=l=>{if(!l){for(const d of r)d.play();r.clear();return}if(typeof n.getAnimations=="function")for(const d of n.getAnimations({subtree:!0}))i(d)};s.matches&&o(!0);const a=l=>{if(s.matches)for(const d of l.target.getAnimations?.()??[])i(d)},c=l=>o(l.matches);return n.addEventListener("animationstart",a,!0),s.addEventListener?.("change",c),()=>{n.removeEventListener("animationstart",a,!0),s.removeEventListener?.("change",c)}},[t,e])},MSe=({data:t,saver:e})=>{ISe();const n=g.useRef(null),s=e?.component,r=mw(e,t.saverConfigs?.[e.id]);return DSe(n,e.id),b.jsx("div",{ref:n,id:DH,className:`classicyScreenSaverOverlay${e.transparentBackground?" classicyScreenSaverOverlayTransparent":""}`,role:"presentation",children:s?b.jsx(s,{config:r}):null})},MH=()=>{const t=et("icons","system.extensions.screensaver")??"",n=ye(i=>i.System.Manager.Applications.apps[Ba]?.data)??{},s=Qc().id;ny();const r=iC(s,n.selectedSaver);return kSe(n,r!==void 0),b.jsxs(b.Fragment,{children:[b.jsx(Fs,{id:Ba,name:rG,icon:t,extension:!0}),n.active===!0&&GA(n)&&r&&b.jsx(MSe,{data:n,saver:r})]})},xH=t=>t&&String(t[0]).toUpperCase()+String(t).slice(1),BH=t=>t==="app_shortcut"?"Application":xH(t.replaceAll("_"," ")),dM=(t,e)=>Object.hasOwn(t,e)?t[e]??BH(e):BH(e),xSe=(t,e)=>dM(Fk(e),t),pM=()=>{const t=vR();return g.useCallback(e=>dM(t,e),[t])},Tr=(t,e)=>t==="directory"?Jn("icons","system.folders.directory",e)??"":(t!==""?Jn("icons",`system.files.byType.${t}`,e):void 0)??Jn("icons","system.files.file",e)??"",BSe=(t,e,n)=>[Math.floor(n[0]/(t*2+e)),Math.floor(n[1]/(t*2+e))],OH=(t,e)=>[t%e[0],Math.floor(t/e[0])],QA=(t,e)=>{const n=$l(t);return{size:Kt("--desktop-icon-size",n.size,e),padding:Kt("--desktop-icon-padding",n.padding,e),cell:Kt("--desktop-icon-cell",n.cell,e)}},fM=(t,e,n=QA(t))=>{const s=e!==void 0?e*2:n.cell;return{origin:[n.padding,n.padding],pitch:[s,s]}},hM=(t,e,n,s,r,i=QA(t))=>{const{origin:o,pitch:a}=fM(t,r,i),c=[Math.floor(s[0]/(a[0]+i.padding)),Math.floor(s[1]/(a[1]+i.padding))],[l,d]=OH(e,c);return[o[0]+Math.floor(a[0]*l),o[1]+Math.floor(a[1]*d)]},FH=(t,e,n)=>{const s=new Set;return t.map(([r,i])=>{const o=[Math.max(0,Math.round((r-n[0])/e[0])),Math.max(0,Math.round((i-n[1])/e[1]))],a=([c,l])=>[n[0]+c*e[0],n[1]+l*e[1]];for(let c=0;;c++){const l=[];for(let p=-c;p<=c;p++)for(let f=-c;f<=c;f++){if(Math.max(Math.abs(p),Math.abs(f))!==c)continue;const h=[o[0]+p,o[1]+f];h[0]>=0&&h[1]>=0&&l.push(h)}const d=p=>{const[f,h]=a(p);return(f-r)**2+(h-i)**2};l.sort((p,f)=>d(p)-d(f));const u=l.find(p=>!s.has(`${p[0]},${p[1]}`));if(u)return s.add(`${u[0]},${u[1]}`),a(u)}})},NH=(t,e,n)=>e.find(s=>!t.some(([r,i])=>Math.abs(r-s[0])<n[0]/2&&Math.abs(i-s[1])<n[1]/2)),AM=t=>Gh("\u2318X",t)?"cut":Gh("\u2318C",t)?"copy":Gh("\u2318V",t)?"paste":void 0,TC="classicyStorage";let La=null;const gM=new Set,PH=()=>{for(const t of[...gM])t()},OSe=t=>t instanceof Element&&t.closest("input, textarea, select, [contenteditable='true']")!==null,LH=t=>{if(La?.op!=="cut"||t.key!=="Escape"||t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||OSe(t.target))return;const e=t.target;(e===document.body||e===document.documentElement||e instanceof Element&&(e.id==="classicyDesktop"||e.closest(".classicyFileBrowserFill, .classicyDesktopIcon")!==null))&&MC()},DC=()=>MC();let RH=!1;const zH=()=>{if(typeof document>"u")return;const t=La!==null;t!==RH&&(RH=t,t?(document.addEventListener("keydown",LH),document.addEventListener("cut",DC,!0),document.addEventListener("copy",DC,!0)):(document.removeEventListener("keydown",LH),document.removeEventListener("cut",DC,!0),document.removeEventListener("copy",DC,!0)))};function mM(t,e,n=TC){const s=[...new Set(e)];La=s.length>0?Object.freeze({op:t,paths:Object.freeze(s),storageKey:n}):null,zH(),PH()}function MC(){La!==null&&(La=null,zH(),PH())}function Gp(){return La}function WH(t){return gM.add(t),()=>{gM.delete(t)}}function xC(){return g.useSyncExternalStore(WH,Gp,Gp)}function FSe(t,e=TC){return La?.op==="cut"&&La.storageKey===e&&La.paths.includes(t)}const NSe=new Set;function BC(t=TC){const e=xC();return g.useMemo(()=>e?.op==="cut"&&e.storageKey===t?new Set(e.paths):NSe,[e,t])}function VH(t,e=TC){const n=BC(e);return t!==void 0&&n.has(t)}const PSe=3,LSe=100,RSe=20,zSe=250,WSe=()=>({samples:[],next:0,full:!1,lastScroll:null}),VSe=(t,e)=>(t.samples[t.next]=e,t.next=(t.next+1)%PSe,t.next===0&&(t.full=!0),t.full),USe=t=>{const e=t.samples,n=e.length;if(n<2)return 0;let s=0,r=1;for(let i=0;i<n;i++){const o=e[i],a=e[(i+1)%n];s+=Math.abs(o.x-a.x)+Math.abs(o.y-a.y),r+=Math.abs(o.t-a.t)}return Math.floor(s*1024/r)},UH=(t,e,n)=>e>=t.left&&e<t.right&&n>=t.top&&n<t.bottom,GSe=(t,e,n,s,r)=>{const i={left:t.left+s,top:t.top+s,right:t.right-s,bottom:t.bottom-s},o={left:t.left-r,top:t.top-r,right:t.right+r,bottom:t.bottom+r};return UH(i,e,n)||!UH(o,e,n)?null:{left:e<i.left,right:e>=i.left&&e>i.right,up:n<i.top,down:n>=i.top&&n>i.bottom}},GH="[data-classicy-drop-folder]",HSe=(t,e)=>typeof document<"u"&&document.elementsFromPoint?document.elementsFromPoint(t,e):[],YSe=t=>{const s=t?.closest("[data-classicy-part='scrollbar'], [data-classicy-part='scroll-corner']")?.closest(".classicyScrollArea")?.querySelector(":scope > .classicyScrollAreaBody > .classicyScrollAreaViewport");return s?Ca(s):null},ZSe=()=>({inset:Kt("--desktop-icon-size"),outset:Kt("--icon-small-size")});function jSe(t,e,{exclude:n,elementsFromPoint:s=HSe,zone:r}){const i=s(t,e).find(A=>!n?.contains(A))??null,o=Ca(i)??YSe(i);if(!o)return null;const{element:a,entry:c}=o;if(!a.closest(GH)&&!a.querySelector(GH))return null;const l=a.getBoundingClientRect(),d=GSe({left:l.left,top:l.top,right:l.right,bottom:l.bottom},t,e,r.inset,r.outset);if(!d)return null;const u=c.lineStep(),p=(A,m,y)=>{const C=pA(y);return A&&!C.start?-u:m&&!C.end?u:0},f=p(d.left,d.right,{total:a.scrollWidth,visible:a.clientWidth,position:a.scrollLeft}),h=p(d.up,d.down,{total:a.scrollHeight,visible:a.clientHeight,position:a.scrollTop});return f||h?{viewport:a,dx:f,dy:h}:null}const KSe=127,QSe=[[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[-1,-1],[1,-1]];function HH(t,e,n){const s=(a,c)=>a>=0&&c>=0&&a<e&&c<n&&t[c*e+a]===1,r=new Uint8Array(e*n);for(let a=0;a<n;a++)for(let c=0;c<e;c++)s(c,a)&&(!s(c-1,a)||!s(c+1,a)||!s(c,a-1)||!s(c,a+1))&&(r[a*e+c]=1);const i=new Uint8Array(e*n),o=new Uint8Array(e*n);for(let a=0;a<r.length;a++){if(!r[a]||o[a])continue;let c=a,l=!0;for(;c!==-1;){o[c]=1,l&&(i[c]=1),l=!l;const d=c%e,u=(c-d)/e;let p=-1;for(const[f,h]of QSe){const A=d+f,m=u+h;if(A<0||m<0||A>=e||m>=n)continue;const y=m*e+A;if(r[y]&&!o[y]){p=y;break}}c=p}}return i}const YH=t=>{const e=t.getBoundingClientRect();return e.width>0&&e.height>0?{left:e.left,top:e.top,width:e.width,height:e.height}:null};function ZH(t){const e=t.map(h=>({image:h.image??null,imageBox:h.image?YH(h.image):null,labelBox:h.label?YH(h.label):null})),n=e.flatMap(h=>[h.imageBox,h.labelBox].filter(A=>A!==null));if(n.length===0)return null;const s=Math.floor(Math.min(...n.map(h=>h.left))),r=Math.floor(Math.min(...n.map(h=>h.top))),i=Math.ceil(Math.max(...n.map(h=>h.left+h.width))),o=Math.ceil(Math.max(...n.map(h=>h.top+h.height))),a=i-s,c=o-r,l=document.createElement("canvas");l.width=a,l.height=c;const d=l.getContext("2d",{willReadFrequently:!0});if(!d)return null;d.imageSmoothingEnabled=!1;for(const{image:h,imageBox:A}of e)!h||!A||d.drawImage(h,Math.round(A.left-s),Math.round(A.top-r),Math.round(A.width),Math.round(A.height));const u=new Uint8Array(a*c);try{const{data:h}=d.getImageData(0,0,a,c);for(let A=0;A<u.length;A++)h[A*4+3]>KSe&&(u[A]=1)}catch{for(const{imageBox:h}of e)h&&jH(u,a,h,s,r)}for(const{labelBox:h}of e)h&&jH(u,a,h,s,r);const p=HH(u,a,c);d.clearRect(0,0,a,c);const f=d.createImageData(a,c);for(let h=0;h<p.length;h++)p[h]===1&&(f.data[h*4+3]=255);return d.putImageData(f,0,0),{canvas:l,left:s,top:r}}function jH(t,e,n,s,r){const i=Math.max(0,Math.round(n.left-s)),o=Math.max(0,Math.round(n.top-r)),a=Math.min(e,Math.round(n.left-s+n.width)),c=Math.min(t.length/e,Math.round(n.top-r+n.height));for(let l=o;l<c;l++)for(let d=i;d<a;d++)t[l*e+d]=1}const yM=()=>Jn("systemArt","trashEmpty",Ut,"")??"",an="Trash",bM={_trashed:void 0,_trashedFrom:void 0,_trashedName:void 0,_trashedLocation:void 0},KH=(t,e)=>e.split(t.separator).pop()??e,QH=(t,e)=>e.split(t.separator).slice(0,-1).join(t.separator),hl=(t,e)=>e===an||e.startsWith(`${an}${t.separator}`),JA=(t,e)=>e!==an&&QH(t,e)===an;function CM(t,e=yM()){const n=t.resolve(an);return n?e!==""&&n._icon!==e&&t.setMetadata(an,{_icon:e}):(t.mkDir(an),t.setMetadata(an,{_icon:e,_system:!0,_nameLocked:!0,_invisible:!0})),an}function Al(t){const e=t.resolve(an);return e?Object.keys(e).filter(n=>!n.startsWith("_")).map(n=>`${an}${t.separator}${n}`):[]}const JSe=(t,e)=>{const n=t.resolve(an)??{},s=a=>ll(n,a)!==void 0;if(!s(e))return e;const r=e.lastIndexOf("."),[i,o]=r>0?[e.slice(0,r),e.slice(r)]:[e,""];for(let a=2;;a++){const c=`${i} ${a}${o}`;if(!s(c))return c}};function JH(t,e,n={}){CM(t);const s={moves:[]};for(const r of e){if(hl(t,r))continue;const i=KH(t,r),o=JSe(t,i),a=n[r],c=t.move(r,an,{name:o,metadata:{_trashed:!0,_trashedFrom:QH(t,r),...o===i?{}:{_trashedName:i},...a?{_trashedLocation:a}:{}}});c.ok?s.moves.push({from:r,to:c.path}):s.refusal||(s.refusal={reason:c.reason,name:i})}return s}function XH(t,e){const n={moves:[]};for(const s of e){if(!JA(t,s))continue;const r=t.resolve(s);if(!r)continue;const i=r._trashedName??KH(t,s),o=r._trashedFrom;if(typeof o!="string"||!t.resolve(o)){n.refusal??={reason:"no-origin",name:i};continue}const a=t.move(s,o,{name:i,metadata:bM});a.ok?n.moves.push({from:s,to:a.path}):n.refusal||(n.refusal={reason:a.reason,name:i})}return n}function qH(t){const e=Al(t);for(const n of e)t.rmDir(n);return e.length}const vM="data-classicy-drop",XSe=["move","copy","link"],qSe=["move"],wM=t=>t.kind==="folder"&&t.path===an?qSe:XSe,_Se=(t,e,n)=>t.transfer?.copyModifier!=="ctrl"||n||!e.ctrlKey?"move":e.shiftKey?"link":"copy",$Se=(t,e)=>e.includes(t)?t:e.includes("move")?"move":e[0]??"move",eEe=t=>t===!0&&Jl(),tEe=t=>typeof document>"u"?null:t?.closest(".classicyDesktop")??document.getElementById("classicyDesktop")??document.querySelector(".classicyDesktop"),SM=(t,e)=>{if(t){if(e===null){t.removeAttribute(vM);return}t.getAttribute(vM)!==e&&t.setAttribute(vM,e)}},nEe=500,sEe=()=>{if(typeof document>"u")return;let t=null;const e=()=>{document.removeEventListener("contextmenu",n,!0),document.removeEventListener("mousedown",e,!0),document.removeEventListener("keydown",e,!0),t!==null&&clearTimeout(t),t=null};function n(s){s.preventDefault(),s.stopPropagation(),e()}document.addEventListener("contextmenu",n,!0),document.addEventListener("mousedown",e,!0),document.addEventListener("keydown",e,!0),t=setTimeout(e,nEe)},Bi="data-classicy-file-path",Ra="data-classicy-drop-folder",EM="data-classicy-drop-desktop",kM="data-classicy-drop-activate",OC="classicy:dropactivate",FC="classicy:droprefused",_H=500,$H=4,eY="classicyFileDropTarget",tY="classicyFileDragging",rEe=".classicyWindow, .classicyDesktopMenuBar, .classicyControlStrip, .classicyTaskbar, [role='dialog']",nY=(t,e)=>typeof document<"u"&&document.elementsFromPoint?document.elementsFromPoint(t,e):[],IM={kind:"none"};function TM(t,e,{exclude:n,elementsFromPoint:s=nY}){for(const r of s(t,e))if(!n?.contains(r)){for(let i=r;i;i=i.parentElement){if(i.hasAttribute(kM))return{kind:"activate",element:i};const o=i.getAttribute(Ra);if(o!==null)return{kind:"target",target:{destination:{kind:"folder",path:o},element:i}};if(i.hasAttribute(EM))return{kind:"target",target:{destination:{kind:"desktop"},element:i}};if(i.matches(rEe))return IM}return IM}return IM}function iEe(t,e,n={}){const s=TM(t,e,n);return s.kind==="target"?s.target:null}function oEe(t,e,n={}){const s=TM(t,e,n);return s.kind==="activate"?s.element:null}function sY(t,e,{exclude:n,elementsFromPoint:s=nY}={}){const r=s(t,e).find(f=>!n?.contains(f)),i=Ca(r??null);if(!i)return null;const{element:o,entry:a}=i;if(!o.closest(`[${Ra}]`)&&!o.querySelector(`[${Ra}]`))return null;const c=o.getBoundingClientRect();if(t<c.left||t>=c.right||e<c.top||e>=c.bottom)return null;const l=a.lineStep(),d=(f,h,A,m)=>{const y=pA(m);return f<h+l&&!y.start?-l:f>=A-l&&!y.end?l:0},u=d(t,c.left,c.right,{total:o.scrollWidth,visible:o.clientWidth,position:o.scrollLeft}),p=d(e,c.top,c.bottom,{total:o.scrollHeight,visible:o.clientHeight,position:o.scrollTop});return u||p?{viewport:o,dx:u,dy:p}:null}function XA(t){const{start:e,source:n,elementsFromPoint:s}=t,r=dn(),i=r.transfer?.autoScroll===!0,o=t.button===2;let a={ctrlKey:e.ctrlKey===!0,shiftKey:e.shiftKey===!0};const c=eEe(e.ctrlKey),l=tEe(n);let d=null,u=null,p=[0,0],f=null,h=null,A=null;const m=Z=>{f!==Z&&(f?.classList.remove(eY),f=Z,f?.classList.add(eY))},y=Z=>{h!==Z&&(A!==null&&clearTimeout(A),A=null,h=Z,Z&&(A=setTimeout(()=>{A=null,Z.isConnected&&Z.dispatchEvent(new Event(OC))},_H)))},C=(Z,oe)=>{u&&(u.style.transform=`translate(${Z-p[0]}px, ${oe-p[1]}px)`)},v=()=>{u=document.createElement("div"),u.className="classicyFileDragGhost",u.setAttribute("aria-hidden","true");const Z=ZH(t.parts);Z&&(u.append(Z.canvas),p=[e.clientX-Z.left,e.clientY-Z.top]),document.body.append(u),document.body.classList.add(tY)};let S=()=>{},w=null,k=null;const I=()=>{w!==null&&clearInterval(w),w=null,k!==null&&clearInterval(k),k=null},T=()=>{I(),S(),document.removeEventListener("mousemove",Y,!0),document.removeEventListener("mouseup",N,!0),document.removeEventListener("keydown",H,!0),document.removeEventListener("keyup",X,!0),m(null),y(null),d=null,SM(l,null),u?.remove(),u=null,document.body.classList.remove(tY)},D=Z=>{try{t.onEnd?.(Z)}catch(oe){Ve("error","ClassicyFileDrag","onEnd threw; ignored.",oe)}},O=Z=>t.effects?.(Z)??wM(Z.destination),x=(Z,oe)=>TM(Z,oe,{exclude:n,elementsFromPoint:s}),B=Z=>{if(Z.kind!=="target")return null;const{target:oe}=Z;return t.canDrop&&!t.canDrop(oe)?null:O(oe).length>0?oe:null},F=Z=>$Se(_Se(r,a,c),O(Z)),z=()=>{if(u){if(!d){SM(l,"none");return}SM(l,F(d))}};let V=[e.clientX,e.clientY];const P=(Z,oe)=>{const he=x(Z,oe),ee=B(he);m(ee?.destination.kind==="folder"?ee.element:null),y(he.kind==="activate"?he.element:null),d=ee,z()},W=(Z,oe)=>sY(Z,oe,{exclude:n,elementsFromPoint:s}),K=()=>{if(!W(V[0],V[1])){I();return}w===null&&(w=setInterval(()=>{const Z=W(V[0],V[1]);if(!Z){I();return}Ca(Z.viewport)?.entry.scrollBy(Z.dx,Z.dy),P(V[0],V[1])},fb))},L=WSe();let M=null;const G=()=>{const Z=Date.now();if(!VSe(L,{x:V[0],y:V[1],t:Z})||USe(L)>RSe||L.lastScroll!==null&&Z-L.lastScroll<zSe)return;M??=ZSe();const he=jSe(V[0],V[1],{exclude:n,elementsFromPoint:s,zone:M});he&&(Ca(he.viewport)?.entry.scrollBy(he.dx,he.dy),L.lastScroll=Z,P(V[0],V[1]))};function Y(Z){const oe=!u;if(!u){if(Math.max(Math.abs(Z.clientX-e.clientX),Math.abs(Z.clientY-e.clientY))<$H)return;v(),t.onStart?.()}if(Z.preventDefault(),V=[Z.clientX,Z.clientY],a={ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey},C(Z.clientX,Z.clientY),P(Z.clientX,Z.clientY),!i){K();return}G(),oe&&k===null&&(k=setInterval(G,LSe))}function N(Z){if(t.button!==void 0&&Z.button!==t.button)return;const oe=u!==null;if(oe&&(a={ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey}),T(),!oe){t.onClick?.();return}const he=x(Z.clientX,Z.clientY),ee=B(he),ce=[Z.clientX,Z.clientY],re=[Z.clientX-p[0],Z.clientY-p[1]],le=ee?F(ee):"move";if(D({dropped:ee!==null,canceled:!1,lost:!1}),o&&sEe(),ee&&o&&t.onMenu){t.onMenu(ee,ce,re,le);return}t.onDrop(ee,ce,re,le),he.kind==="activate"&&he.element.isConnected&&he.element.dispatchEvent(new Event(FC))}const J=Z=>{const oe=u!==null;T(),oe&&D({dropped:!1,canceled:!0,lost:Z})},te=Z=>{!u||Z.key!=="Control"&&Z.key!=="Shift"||(a={ctrlKey:Z.ctrlKey,shiftKey:Z.shiftKey},z())};function H(Z){te(Z),!(Z.key!=="Escape"||!u)&&(Z.preventDefault(),Z.stopPropagation(),J(!1))}function X(Z){te(Z)}return document.addEventListener("mousemove",Y,!0),document.addEventListener("mouseup",N,!0),document.addEventListener("keydown",H,!0),document.addEventListener("keyup",X,!0),S=ls(()=>J(!0)),()=>J(!1)}const rY=Object.freeze(["\\","/",":","*","?",'"',"<",">","|"]),aEe=Object.freeze([":"]),DM=`A filename cannot contain any of the following characters:
77
77
  \\ / : * ? " < > |`,iY="Rename",NC=t=>t.files?.names==="windows",oY=t=>NC(dn(t))?rY:aEe,vu=(t,e)=>!oY(e).some(n=>t.includes(n)),aY=t=>NC(dn(t))?DM:void 0,cY=(t,e,n)=>{const s=n?`.${n.replace(/^\./,"")}`:"";return e===1?`${t}${s}`:`${t} (${e})${s}`},lY=(t,e,{extension:n}={})=>{const s=new Set;for(const r of t)s.add(r.toLowerCase());for(let r=1;;r++){const i=cY(e,r,n);if(!s.has(i.toLowerCase()))return i}},uY=(t,e,n,{extension:s}={})=>{for(let r=1;;r++){const i=cY(n,r,s);if(!t.resolve(`${e}${t.separator}${i}`))return i}},cEe="Finder.app",lEe=new Set(["directory","drive"]),uEe=new RegExp("(?<=.)\\.(?=[A-Za-z0-9]{0,4}[A-Za-z])[A-Za-z0-9]{1,5}$"),MM=(t,e=!0)=>t.files?.extensions==="hideRegistered"&&e,dY=(t,e)=>{if(t===void 0||!e||!Object.hasOwn(e,t))return!1;const n=e[t];return typeof n=="string"&&n!==cEe},xM=(t,e,n)=>{const s=e?._type;return s===void 0||lEe.has(s)||!dY(s,n)?"":uEe.exec(t)?.[0]??""},pY=(t,e,n,{fileTypeHandlers:s,hideFileExtensions:r=!0}={})=>MM(dn(n),r)?xM(t,e,s):"",dEe=(t,e,n,s={})=>t.slice(0,t.length-pY(t,e,n,s).length),fY="Trash",hY=Object.freeze({name:fY,icon:""}),qA=t=>t9("trash",hY,t).name,Hp=()=>oE("trash",hY).name,AY="Desktop Folder",Oi="classicy-desktop-item:",wu=t=>Object.keys(t.filterByType("",xe.Drive))[0],Yp=t=>{const e=wu(t);return e?`${e}${t.separator}${AY}`:void 0},Su=t=>{const e=Yp(t);if(e)return t.resolve(e)||(t.mkDir(e),t.setMetadata(e,{_invisible:!0})),e},za=(t,e,n)=>{const s=t.resolve(e);if(!s)return;const r=e.split(t.separator).pop()??e,i=s._type===xe.Directory;return{type:"ClassicyDesktopIconAdd",app:{id:`${Oi}${e}`,name:r,icon:s._icon??Tr(s._type,Ut)},kind:i?"directory":s._type===xe.FileShortcut?xe.FileShortcut:"file",filePath:e,noLaunch:!0,...n?{location:n}:{}}},pEe=(t,e,n)=>{switch(t){case"exists":return`An item named \u201C${e}\u201D already exists in \u201C${n}\u201D. It was not moved.`;case"into-itself":return`\u201C${e}\u201D can\u2019t be moved into itself.`;case"locked":return`\u201C${e}\u201D can\u2019t be moved, because it or \u201C${n}\u201D is locked or used by the system software.`;default:return`\u201C${e}\u201D could not be moved.`}},_A=t=>{const n=(typeof document<"u"?document.getElementById("classicyDesktop"):null)?.getBoundingClientRect();return[Math.round(t[0]-(n?.left??0)),Math.round(t[1]-(n?.top??0))]},PC=({desktopLocation:t,desktopStep:e=72,desktopLocationFor:n},s,r)=>t?[t[0],t[1]+s*e]:n?.(s,r);function BM(t,e,n,s,r={}){if(n.kind==="folder"&&n.path===an)return Zp(t,e,s);const i=n.kind==="desktop"?Su(t):n.path;if(!i)return[];const o=[];let a=null;for(const c of e){if(c===i)continue;const l=t.move(c,i,JA(t,c)?{metadata:bM}:{});l.ok?o.push({from:c,to:l.path}):l.reason!=="same-folder"&&!a&&(a={reason:l.reason,name:c.split(t.separator).pop()??c})}if(o.length>0&&(s({type:"ClassicyAppFinderPathsMoved",moves:o}),n.kind==="desktop"&&o.forEach(({from:c,to:l},d)=>{const u=za(t,l,PC(r,d,c));u&&s(u)})),a){const c=n.kind==="desktop"?"the desktop":i.split(t.separator).pop()??i;s({type:"ClassicyDesktopShowErrorDialog",message:pEe(a.reason,a.name,c)})}return o}const fEe=(t,e,n)=>{switch(t){case"exists":return`An item named \u201C${e}\u201D already exists in \u201C${n}\u201D. It was not copied.`;case"into-itself":return`\u201C${e}\u201D can\u2019t be copied into itself.`;case"locked":return`\u201C${e}\u201D can\u2019t be copied, because it or \u201C${n}\u201D is locked or used by the system software.`;default:return`\u201C${e}\u201D could not be copied.`}};function OM(t,e,n,s,r={}){const i=n.kind==="desktop"?Su(t):n.path;if(!i)return[];const o=[];let a=null;for(const c of e){const l=t.copy(c,i);l.ok?o.push({from:c,to:l.path}):a||(a={reason:l.reason,name:c.split(t.separator).pop()??c})}if(n.kind==="desktop"&&o.forEach(({from:c,to:l},d)=>{const u=za(t,l,PC(r,d,c));u&&s(u)}),a){const c=n.kind==="desktop"?"the desktop":i.split(t.separator).pop()??i;s({type:"ClassicyDesktopShowErrorDialog",message:fEe(a.reason,a.name,c)})}return o}const FM="Finder.app";function NM(t,e){if(!t||dn().transfer?.activateDropWindow!==!0)return!1;const n=t.element.closest(".classicyWindow");if(!n||n.classList.contains("active"))return!1;const s=t.element.closest(".classicyFileBrowserFill")?.getAttribute(Ra);if(!s||n.id!==[FM,s].join("_"))return!1;const r=rn(ye.getState().System.Manager.Applications.apps[FM],s);return r?(e({type:"ClassicyWindowFocus",app:{id:FM},window:r}),!0):!1}const hEe=(t,e)=>t==="locked"?`\u201C${e}\u201D can\u2019t be moved to the ${qA()}, because it is locked or used by the system software.`:`\u201C${e}\u201D could not be moved to the ${qA()}.`,gY=t=>{const e=new Set(t),n={};for(const s of ye.getState().System.Manager.Desktop.icons)s.filePath&&e.has(s.filePath)&&s.location&&(n[s.filePath]=s.location);return n},mY=()=>dn().finder?.commands==="windows"&&H0("Finder.app");function Zp(t,e,n,{confirmed:s=!1,trust:r}={}){if(!s&&e.length>0&&mY()){const a={type:"ClassicyAppFinderConfirmDelete",paths:[...e]};return r===void 0?n(a):n(a,r),[]}const{moves:i,refusal:o}=JH(t,e,gY(e));return i.length>0&&n({type:"ClassicyAppFinderPathsMoved",moves:i}),o&&n({type:"ClassicyDesktopShowErrorDialog",message:hEe(o.reason,o.name)}),i}const AEe=(t,e)=>{switch(t){case"no-origin":return`\u201C${e}\u201D can\u2019t be restored, because the folder it came from no longer exists. Drag it out of the ${qA()} instead.`;case"exists":return`\u201C${e}\u201D can\u2019t be restored, because an item with that name is already where it came from.`;default:return`\u201C${e}\u201D could not be restored.`}};function yY(t,e,n){const s=Object.fromEntries(e.map(o=>[o,t.resolve(o)?._trashedLocation])),{moves:r,refusal:i}=XH(t,e);if(r.length>0){n({type:"ClassicyAppFinderPathsMoved",moves:r});const o=Yp(t);for(const{from:a,to:c}of r){const l=s[a];if(!o||c.split(t.separator).slice(0,-1).join(t.separator)!==o)continue;const d=za(t,c,Array.isArray(l)?l:void 0);d&&n(d)}}return i&&n({type:"ClassicyDesktopShowErrorDialog",message:AEe(i.reason,i.name)}),r}const bY=(t,e,n)=>{switch(t){case"exists":return`The name \u201C${e}\u201D is already taken. Please use a different name.`;case"locked":return`\u201C${n}\u201D can\u2019t be renamed, because it is locked or used by the system software.`;case"invalid":return`\u201C${e}\u201D can\u2019t be used as a name.`;default:return`\u201C${n}\u201D could not be renamed.`}};function LC(t,e,n,s){const r=e.split(t.separator),i=r.pop()??e,o=r.join(t.separator);if(n===i)return;const a=aY();if(a!==void 0&&n.trim()!==""&&!vu(n)){s({type:"ClassicyDesktopShowErrorDialog",title:iY,message:a});return}if(n.trim()===""||n.includes(t.separator)||!vu(n)||n.startsWith("_")){s({type:"ClassicyDesktopShowErrorDialog",message:bY("invalid",n,i)});return}const c=gY([e])[e],l=t.move(e,o,{name:n});if(!l.ok){s({type:"ClassicyDesktopShowErrorDialog",message:bY(l.reason,n,i)});return}if(s({type:"ClassicyAppFinderPathsMoved",moves:[{from:e,to:l.path}]}),o===Yp(t)){const d=za(t,l.path,c);d&&s(d)}return l.path}const CY="Shortcut",vY="Problem with Shortcut",wY=`Windows cannot create a shortcut here.
78
78
  Do you want the shortcut to be placed on the desktop instead?`,SY=t=>`The file or folder '${t}' that this shortcut refers to cannot be found.`,EY="The original item for this shortcut could not be found.",kY=(t,e)=>dn(e).finder?.commands==="windows"?{title:vY,message:SY(t)}:{message:EY},IY=(t,e=1)=>e<=1?`Shortcut to ${t}`:`Shortcut (${e}) to ${t}`,TY=(t,e,n)=>{for(let s=1;;s++){const r=IY(n,s);if(!t.resolve(`${e}${t.separator}${r}`))return r}},PM=t=>t?._type===xe.FileShortcut,gEe=(t,e)=>e.split(t.separator).pop()??e,mEe=(t,e)=>{const n=t._derived===!0&&typeof t._creator=="string"?e?.(t._creator):void 0;return n||(typeof t._icon=="string"&&t._icon!==""?t._icon:Tr(t._type,Ut))},yEe=(t,e,n)=>{if(PM(e))return{_type:xe.FileShortcut,_targetPath:e._targetPath,...typeof e._icon=="string"?{_icon:e._icon}:{},...typeof e._creator=="string"?{_creator:e._creator}:{}};const s=mEe(e,n);return{_type:xe.FileShortcut,_targetPath:t,...s?{_icon:s}:{},...e._type===xe.AppShortcut&&typeof e._creator=="string"?{_creator:e._creator}:{}}},RC=(t,e,n)=>`${n}${t.separator}${TY(t,n,gEe(t,e))}`,$A=(t,e,n,s={})=>{const r=t.resolve(e);if(!r)return;const i=s.path??RC(t,e,n);if(t.writeFile(i,"",yEe(e,r,s.appIcon)))return t.resolve(i)?i:void 0},bEe=16,DY=(t,e)=>{let n=typeof e._targetPath=="string"?e._targetPath:"";const s=new Set;for(let r=0;r<bEe;r++){if(n===""||s.has(n))return{found:!1,path:n};s.add(n);const i=t.resolve(n);if(!i)return{found:!1,path:n};if(!PM(i))return{found:!0,path:n,entry:i};n=typeof i._targetPath=="string"?i._targetPath:""}return{found:!1,path:n}},CEe=()=>gt().finder?.commands==="windows",vEe=t=>t.kind==="folder"?"New Folder":`New ${t.type.typeName}`,jp=(t,e)=>{const n=t.resolve(e);return!!n&&(n._type===xe.Directory||n._type===xe.Drive)&&n._readOnly!==!0&&n._system!==!0&&n._derived!==!0&&n._trashed!==!0&&e!=="Trash"},MY=(t,e,n)=>`${e}${t.separator}${uY(t,e,vEe(n),{extension:n.kind==="file"?n.type.extension:void 0})}`,xY=(t,e,n)=>(n.kind==="folder"?t.mkDir(e):t.writeFile(e,n.type.data??"",{_type:n.type.fileType}),!!t.resolve(e)),BY=()=>{const t=Si();return g.useMemo(()=>j8(t),[t])},wEe=t=>{const e=new Set(["f"]);return t.map(n=>{for(const s of n){const r=s.toLowerCase();if(!(!/[a-z0-9]/.test(r)||e.has(r)))return e.add(r),s}})},zr=(t,e)=>t(e)!==void 0?{accessKey:t(e)}:{},zC=(t,e,n,s,r=!1)=>{const i=wEe(n.map(o=>o.typeName));return{id:`${t}_new`,title:"New",...zr(e,"w"),disabled:r,menuChildren:[{id:`${t}_new_folder`,title:"Folder",...zr(e,"F"),onClickFunc:()=>s({kind:"folder"})},...n.length>0?[{id:"spacer"},...n.map((o,a)=>{const c=i[a];return{id:`${t}_new_${o.appId}_${o.fileType}`,title:o.typeName,...c!==void 0?zr(e,c):{},onClickFunc:()=>s({kind:"file",type:o})}})]:[]]}},SEe=[{key:"name",title:"by Name",accessKey:"N"},{key:"kind",title:"by Type",accessKey:"T"},{key:"size",title:"by Size",accessKey:"z"},{key:"modified",title:"by Date",accessKey:"D"}],OY=(t,e,n,s,r=!1)=>({id:`${t}_arrange`,title:"Arrange Icons",...zr(e,"I"),disabled:r,menuChildren:SEe.filter(i=>n.includes(i.key)).map(i=>({id:`${t}_arrange_${i.key}`,title:i.title,...zr(e,i.accessKey),onClickFunc:()=>s(i.key)}))}),FY=(t,e,n,s=!1)=>({id:`${t}_line_up`,title:"Line Up Icons",...zr(e,"U"),disabled:s,onClickFunc:n}),WC=(t,e,n,s=!1)=>({id:`${t}_delete`,title:"Delete",...zr(e,"D"),keyboardShortcut:"\u2326",nativeShortcut:!0,disabled:s,onClickFunc:n}),VC=(t,e,n,s=!1)=>({id:`${t}_rename`,title:"Rename",...zr(e,"m"),disabled:s,onClickFunc:n}),eg=(t,e)=>{const n=t.resolve(e),s=t.resolve(e.split(t.separator).slice(0,-1).join(t.separator));return!!n&&n._type!==xe.Drive&&n._system!==!0&&n._readOnly!==!0&&n._derived!==!0&&n._nameLocked!==!0&&s?._readOnly!==!0},EEe=(t,e,n="Trash")=>{if(e.length===1){const s=e[0].split(t.separator).pop()??e[0];return t.resolve(e[0])?._type===xe.Directory?{title:"Confirm Folder Delete",message:`Are you sure you want to remove the folder '${s}' and move all its contents to the ${n}?`}:{title:"Confirm File Delete",message:`Are you sure you want to send '${s}' to the ${n}?`}}return{title:"Confirm Multiple File Delete",message:`Are you sure you want to send these ${e.length} items to the ${n}?`}},tg=(t,e,n,s=!1)=>({id:`${t}_create_shortcut`,title:"Create Shortcut",...zr(e,"S"),disabled:s,onClickFunc:n}),NY=(t,e)=>e.split(t.separator).slice(0,-1).join(t.separator),kEe=(t,e)=>{const n=NY(t,e);return n!==""&&jp(t,n)?n:void 0},IEe=(t,e)=>{const n=new Map,s=[];for(const r of e){if(!t.resolve(r)||hl(t,r))continue;const i=kEe(t,r);i===void 0?s.push(r):n.set(i,[...n.get(i)??[],r])}return{beside:n,offerDesktop:s}},UC=t=>ye.getState().System.Manager.Applications.apps[t]?.icon,LM=()=>{const t=ye.getState().System.Manager;return bk(t.Appearance.activeTheme,t.Desktop.icons,dn(t.Appearance.packageId).desktop.iconGridOrigin)},RM=(t,e,n,{at:s}={})=>{const r=Su(t);if(!r)return[];const i=[];for(const o of e){const a=$A(t,o,r,{appIcon:UC});if(!a)continue;const c=s&&i.length===0?_A(s):LM(),l=za(t,a,c);l&&n(l),i.push(a)}return i.length>0&&n({type:"ClassicyDesktopIconSelectBox",iconIds:i.map(o=>`${Oi}${o}`)}),i},PY=(t,e,n,s=null)=>{const r=IEe(t,e),i=Yp(t),o=[];for(const[a,c]of r.beside){if(a===i){o.push(...RM(t,c,n));continue}const l=[];for(const d of c){const u=RC(t,d,a);s?.place(u),$A(t,d,a,{path:u,appIcon:UC})&&l.push(u)}l.length>0&&s?.select(l),o.push(...l)}return r.offerDesktop.length>0&&n({type:"ClassicyAppFinderOfferDesktopShortcut",paths:r.offerDesktop}),o},TEe=(t,e,n)=>{if(t===void 0||t===xe.Directory||t===xe.Drive)return[];const s=Object.hasOwn(e,t)?e[t]:void 0;return!s||!n.has(s)?[]:K8(s).map(r=>({...r,appId:s}))},DEe=(t,e,n,s,r)=>n.map(i=>({id:`${t}_verb_${i.appId}_${i.id}`,title:i.title,...i.accessKey!==void 0?zr(e,i.accessKey):{},onClickFunc:()=>{for(const o of s())r({type:i.action,app:{id:i.appId},path:o})}})),MEe=()=>{const t=Si(),e=ye(n=>n.System.Manager.Applications.fileTypeHandlers);return g.useMemo(()=>n=>TEe(n,e,t),[e,t])},zM=(t,e,n,{disabled:s=!1,shortcut:r=!1}={})=>({id:`${t}_cut`,title:"Cut",...zr(e,"t"),...r?{keyboardShortcut:"\u2318X",nativeShortcut:!0}:{},disabled:s,onClickFunc:n}),WM=(t,e,n,{disabled:s=!1,shortcut:r=!1}={})=>({id:`${t}_copy`,title:"Copy",...zr(e,"C"),...r?{keyboardShortcut:"\u2318C",nativeShortcut:!0}:{},disabled:s,onClickFunc:n}),LY=(t,e,n,{disabled:s=!1,shortcut:r=!1}={})=>({id:`${t}_paste`,title:"Paste",...zr(e,"P"),...r?{keyboardShortcut:"\u2318V",nativeShortcut:!0}:{},disabled:s,onClickFunc:n}),RY=(t,e,n,{disabled:s=!1}={})=>({id:`${t}_paste_shortcut`,title:"Paste Shortcut",...zr(e,"S"),disabled:s,onClickFunc:n}),zY=(t,e)=>{const n=t.resolve(e);return!!n&&e!==an&&n._type!==xe.Drive&&n._system!==!0&&n._readOnly!==!0&&n._derived!==!0&&t.resolve(NY(t,e))?._readOnly!==!0},VM=(t,e)=>{const n=t.resolve(e);return!!n&&e!==an&&n._type!==xe.Drive&&n._system!==!0&&n._derived!==!0&&!hl(t,e)},UM=(t,e)=>{const n=e.filter(s=>zY(t,s));return n.length>0&&mM("cut",n,t.storageKey),n},GM=(t,e)=>{const n=e.filter(s=>VM(t,s));return n.length>0&&mM("copy",n,t.storageKey),n},WY=(t,e)=>{const n=e.kind==="desktop"?Su(t):e.path;return n!==void 0&&jp(t,n)?n:void 0},GC=(t,e,{shortcut:n=!1}={})=>{const s=Gp();return!s||s.storageKey!==t.storageKey||n&&s.op!=="copy"?!1:e===void 0||jp(t,e)},VY=t=>t.map(e=>`${Oi}${e}`),xEe=(t,e,n,{commands:s=null,at:r})=>{if(t.length!==0){if(e.kind==="desktop"){n({type:"ClassicyDesktopIconSelectBox",iconIds:VY(t)});return}t.forEach((i,o)=>{s?.place(i,o===0?r:void 0)}),s?.select([...t])}},HM=(t,e,n,s={})=>{const r=Gp();if(!r||r.storageKey!==t.storageKey)return[];const i=WY(t,e);if(i===void 0)return[];const o=r.paths.filter(u=>t.resolve(u));if(o.length===0)return[];const a=e.kind==="desktop"?e:{kind:"folder",path:i},c=e.kind!=="desktop"?{}:s.at?{desktopLocation:_A(s.at)}:{desktopLocationFor:LM},l=r.op==="cut"?BM(t,o,a,n,c):OM(t,o,a,n,c);r.op==="cut"&&l.length>0&&MC();const d=l.map(({to:u})=>u);return xEe(d,e,n,s),d},UY=(t,e,n,s={})=>{const r=Gp();if(r?.op!=="copy"||r.storageKey!==t.storageKey)return[];const i=WY(t,e);if(i===void 0)return[];const o=r.paths.filter(c=>t.resolve(c));if(e.kind==="desktop")return RM(t,o,n,{at:s.at});const a=[];for(const c of o){const l=RC(t,c,i);s.commands?.place(l,a.length===0?s.at:void 0),$A(t,c,i,{path:l,appIcon:UC})&&a.push(l)}return a.length>0&&s.commands?.select(a),a},BEe=(t,e,n,s,r={})=>{const i=e.filter(c=>t.resolve(c)&&!hl(t,c));if(i.length===0)return[];const o=n.kind==="desktop"?Su(t):n.path;if(o===void 0)return[];if(!jp(t,o))return s({type:"ClassicyAppFinderOfferDesktopShortcut",paths:i}),[];const a=[];for(const c of i){const l=$A(t,c,o,{appIcon:UC});if(l){if(n.kind==="desktop"){const d=za(t,l,PC(r,a.length,c)??LM());d&&s(d)}a.push({from:c,to:l})}}return n.kind==="desktop"&&a.length>0&&s({type:"ClassicyDesktopIconSelectBox",iconIds:VY(a.map(({to:c})=>c))}),a},YM=(t,e,n,s,r="move",i={})=>{switch(r){case"copy":return OM(t,e,n,s,i);case"link":return BEe(t,e,n,s,i);default:return BM(t,e,n,s,i)}},OEe=Object.freeze({hides:!1,display:t=>t,hiddenExtension:()=>""}),Eu=()=>{const t=gt(),e=ye(r=>r?.System?.Manager?.Applications?.fileTypeHandlers),n=ye(r=>r?.System?.Manager?.Applications?.apps?.["Finder.app"]?.data?.hideFileExtensions!==!1),s=MM(t,n);return g.useMemo(()=>{if(!s)return OEe;const r=(i,o)=>xM(i,o,e);return{hides:!0,hiddenExtension:r,display:(i,o)=>i.slice(0,i.length-r(i,o).length)}},[s,e])},to=({label:t,children:e})=>b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"classicyFilePropertiesLabel",children:t}),b.jsx("span",{className:"classicyFilePropertiesValue",children:e})]}),GY=(t,e)=>{const n=t.filter(s=>s[e]===!0).length;return n===0?!1:n===t.length?!0:"mixed"},FEe=(t,e)=>{const n=t.resolve(e);return n?n._type===xe.Directory||n._type===xe.Drive?t.calculateSizeDir(n):t.size(e):Promise.resolve(-1)},NEe=(t,e)=>{const[n,s]=g.useState(void 0),r=e.join(`
79
- `);return g.useEffect(()=>{let i=!1;return s(void 0),Promise.all(e.map(o=>FEe(t,o))).then(o=>{if(i)return;const a=o.filter(c=>c>=0);s(a.length===0?null:a.reduce((c,l)=>c+l,0))}),()=>{i=!0}},[t,r]),n},HY=t=>t===void 0?"Calculating\u2026":t===null?pE:f9(t),YY="Specifies whether this item is read-only, which means that it cannot be changed or accidentally deleted.",ZY="Specifies whether this item is hidden, which means you cannot see or use it unless you know its name.",jY=({appId:t,fs:e,paths:n=[],targetAppId:s,index:r=0,trashIcon:i,className:o,style:a})=>{const c=st(),l=cr(t),d=tn(),u=pM(),p=Eu(),f=Hp(),h=g.useRef(null),A=Dh(s!==void 0?{appId:s}:{paths:n}),m=Wc(A),y=g.useMemo(()=>n.flatMap(ae=>{const ne=e.resolve(ae);return ne?[{path:ae,entry:ne}]:[]}),[e,n]),C=g.useMemo(()=>y.map(ae=>ae.entry),[y]),v=y.length===1?y[0]:void 0,S=ye(ae=>s!==void 0?ae.System.Manager.Applications.apps[s]:void 0),w=cs(s,{name:S?.name??s??"",icon:S?.icon??""}),k=v?v.path===an?f:v.path.split(e.separator).pop()??v.path:"",I=v?p.hiddenExtension(k,v.entry):"",T=k.slice(0,k.length-I.length),D=v?.entry._type===xe.Drive,O=v?.path===an,x=v?.entry._type===xe.Directory,B=!!v&&!O&&eg(e,v.path),F=y.length>0&&C.every(ae=>A9(ae))&&!O,z=GY(C,"_readOnly"),V=GY(C,"_invisible"),[P,W]=g.useState(T),[K,L]=g.useState(z),[M,G]=g.useState(V),Y=B&&P!==T||K!==z||M!==V,N=NEe(e,s!==void 0?[]:y.map(ae=>ae.path)),J=g.useCallback(()=>{let ae=y.map(ne=>ne.path);if(v&&B&&P!==T){const ne=LC(e,v.path,P+I,c);if(ne===void 0)return;ae=[ne]}if(F)for(const ne of ae){const ue={};K!==z&&K!=="mixed"&&(ue._readOnly=K),M!==V&&M!=="mixed"&&(ue._invisible=M),Object.keys(ue).length>0&&e.setMetadata(ne,ue)}return Dh({paths:ae})},[y,v,B,P,T,e,I,c,F,K,z,M,V]),te=g.useCallback(ae=>l(Wc(ae),{type:Jy,key:ae}),[l]),H=g.useCallback(()=>{if(s!==void 0){te(A);return}const ae=Y?J():A;ae!==void 0&&te(ae)},[s,te,A,Y,J]),X=g.useCallback(()=>te(A),[te,A]);No({onDefault:H,onCancel:X,targetRef:h});const Z=g.useMemo(()=>[{find:sD(`${m}-read-only`),help:{content:YY}},{find:sD(`${m}-hidden`),help:{content:ZY}}],[m]);lU(h,Z);const oe=g.useMemo(()=>({get current(){return h.current?.querySelector('[role="tab"][tabindex="0"]')??null}}),[]),he=s===void 0&&y.length===0;if(g.useEffect(()=>{he&&c({type:Jy,key:A})},[he,c,A]),he)return null;const ee=s!==void 0?w.name:v?T:o9(p.display(y[0].path.split(e.separator).pop()??"",y[0].entry)),ce=s!==void 0?w.icon:O?i||v?.entry._icon||Tr("directory"):v?v.entry._icon||Tr(v.entry._type):Tr(xe.File),re=new Set(C.map(ae=>ae._type)),le=new Set(y.map(ae=>AE(e,ae.path))),Ce=C.filter(ae=>ae._type===xe.Directory||ae._type===xe.Drive).length,De={files:C.length-Ce,folders:Ce},Te=x?h9(v?.entry):null,q=v?AE(e,v.path):"",Q=q===an?f:q,se=b.jsxs("div",{className:"classicyFilePropertiesGeneral",children:[b.jsxs("div",{className:"classicyFilePropertiesHead",children:[b.jsx(pn,{className:"classicyFilePropertiesIcon",src:ce,drawnAt:Number.POSITIVE_INFINITY,alt:""}),B?b.jsx(ri,{id:`${m}-name`,className:"classicyFilePropertiesName",prefillValue:T,onChangeFunc:ae=>W(ae.target.value)}):b.jsx("span",{className:"classicyFilePropertiesName",children:s!==void 0?w.name:v?T:fE(De.files,De.folders)})]}),b.jsx(ap,{}),b.jsx("div",{className:"classicyFilePropertiesRows",children:s!==void 0?b.jsx(to,{label:"Type:",children:u(xe.AppShortcut)}):v?b.jsxs(b.Fragment,{children:[b.jsx(to,{label:"Type:",children:u(v.entry._type)}),Q!==""&&b.jsx(to,{label:"Location:",children:Q}),b.jsx(to,{label:D?"Used space:":"Size:",children:HY(N)}),Te&&b.jsx(to,{label:"Contains:",children:fE(Te.files,Te.folders)})]}):b.jsxs(b.Fragment,{children:[b.jsx(to,{label:"Type:",children:re.size===1?l9(u(C[0]._type)):a9}),b.jsx(to,{label:"Location:",children:le.size===1?u9([...le][0]):c9}),b.jsx(to,{label:"Size:",children:HY(N)})]})}),v&&!D&&b.jsxs(b.Fragment,{children:[b.jsx(ap,{}),b.jsxs("div",{className:"classicyFilePropertiesRows",children:[b.jsx(to,{label:"Created:",children:hE(v.entry._createdOn)}),!x&&b.jsx(to,{label:"Modified:",children:hE(v.entry._modifiedOn)})]})]}),s===void 0&&!D&&b.jsxs(b.Fragment,{children:[b.jsx(ap,{}),b.jsx("div",{className:"classicyFilePropertiesRows",children:b.jsx(to,{label:"Attributes:",children:b.jsxs("span",{className:"classicyFilePropertiesAttributes",children:[b.jsx(qn,{id:`${m}-read-only`,label:"Read-only",accessKey:d("R"),checked:K===!0,mixed:K==="mixed",disabled:!F,onClickFunc:ae=>L(ae)}),b.jsx(qn,{id:`${m}-hidden`,label:"Hidden",accessKey:d("d"),checked:M===!0,mixed:M==="mixed",disabled:!F,onClickFunc:ae=>G(ae)})]})})})]})]});return b.jsx(Qt,{id:m,appId:t,title:i9(ee),hideIcon:!0,closable:!0,resizable:!1,zoomable:!1,collapsable:!1,scrollable:!1,modal:!1,initialSize:[360,0],initialPosition:[80+r*24,60+r*24],initialFocusRef:oe,contextHelp:!0,analyticsPath:dA(t,"properties"),onCloseFunc:()=>c({type:Jy,key:A}),className:o,style:a,children:b.jsxs("div",{ref:h,className:Ae("classicyFileProperties"),children:[b.jsx(au,{tabs:[{title:"General",children:se}]}),b.jsxs("div",{className:"classicyFilePropertiesButtons",children:[b.jsx($e,{isDefault:!0,onClickFunc:H,children:"OK"}),b.jsx($e,{onClickFunc:X,children:"Cancel"}),b.jsx($e,{accessKey:d("A"),disabled:!Y,onClickFunc:()=>{J()},children:"Apply"})]})]})})},HC="finder_open_with",KY=t=>`Click the program you want to use to open the file '${t}'.`,QY=()=>{const t=ye(s=>s.System.Manager.Applications.apps),e=Si(),n=ws();return g.useMemo(()=>Object.values(t).filter(s=>s.id!=="Finder.app"&&e.has(s.id)&&(nM(s.id)!==void 0||(s.handlesFileTypes?.length??0)>0)).map(s=>{const r=Object.hasOwn(n,s.id)?n[s.id]:void 0;return{id:s.id,name:r?.name??s.name,icon:r?.icon??s.icon}}).sort((s,r)=>s.name.localeCompare(r.name)),[t,e,n])},JY=({appId:t,fs:e,path:n,className:s,style:r})=>{const i=st(),o=tn(),a=Eu(),c=QY(),l=g.useRef(null),[d,u]=g.useState(void 0),[p,f]=g.useState(!0),h=e.resolve(n),A=n.split(e.separator).pop()??n,m=g.useMemo(()=>c.map(v=>({value:v.id,label:v.name,icon:v.icon})),[c]),y=g.useCallback(v=>{v!==void 0&&(p&&h?._type&&i({type:"ClassicyAppSetDefaultFileTypeHandler",app:{id:v},fileType:h._type}),i({type:"ClassicyAppFinderOpenWithChoose",appId:v}))},[p,h,i]),C=g.useCallback(()=>i({type:"ClassicyAppFinderOpenWithClose"}),[i]);return No({onDefault:()=>y(d),onCancel:C,targetRef:l}),ou({ref:l,autoFocus:!0}),b.jsx(Qt,{id:HC,appId:t,title:"Open With",hideIcon:!0,closable:!1,resizable:!1,zoomable:!1,collapsable:!1,scrollable:!1,modal:!0,initialSize:[0,0],initialPosition:["center","center"],analyticsExclude:!0,className:s,style:r,children:b.jsx(vp,{rootRef:l,children:b.jsxs("div",{ref:l,className:"classicyOpenWithDialog",role:"dialog","aria-modal":"true","aria-label":"Open With",children:[b.jsxs("div",{className:"classicyOpenWithDialogTop",children:[b.jsx(pn,{className:"classicyOpenWithDialogIcon",src:h?._icon||Tr(h?._type??"file"),drawnAt:Number.POSITIVE_INFINITY,alt:""}),b.jsx("p",{className:"classicyOpenWithDialogPrompt",children:KY(a.display(A,h))})]}),b.jsx(nD,{id:`${HC}-programs`,label:"Choose the program you want to use:",accessKey:o("C"),options:m,selected:d!==void 0?[d]:[],onChangeFunc:v=>u(v[0]),onActivateFunc:v=>y(v)}),b.jsx(qn,{id:`${HC}-always`,label:"Always use this program to open this type of file",accessKey:o("u"),checked:p,onClickFunc:f}),b.jsxs("div",{className:"classicyOpenWithDialogButtons",children:[b.jsx($e,{isDefault:!0,disabled:d===void 0,onClickFunc:()=>y(d),children:"OK"}),b.jsx($e,{onClickFunc:C,children:"Cancel"})]})]})})})},ZM=t=>Yy(t).startupDisk!==void 0,XY=(t,e,n)=>[...Object.entries(t.filterByType("",xe.Drive)).map(([s,r])=>{const i=r._icon;return{id:`drive:${s}`,name:s,icon:typeof i=="string"&&i!==""?i:n(xe.Drive),kind:"drive",path:s,open:{type:"ClassicyAppFinderOpenFolder",path:s}}}),{id:"controlPanel",name:Qy,icon:e,kind:"folder",open:{type:Fd,folder:"controlPanel"}}],qY=(t,e)=>t.flatMap(n=>{if(typeof n.event!="string")return[];const s=n.id.startsWith(e)?n.id.slice(e.length):n.id;return[{id:`panel:${s}`,name:n.title??s,icon:n.image??"",kind:"controlPanel",appId:s,open:{type:n.event,...n.eventData??{}}}]});function jM(t){return t!==null&&typeof t=="object"&&"openFiles"in t&&Array.isArray(t.openFiles)}const ng=Mc([We().describe("A ClassicyFileSystem path to a media file."),rr({url:We().describe("Source URL of the media document."),name:We().optional().describe("Display name of the document."),type:at(["audio","video","image"]).optional().describe("Media kind, when known."),icon:We().optional().describe("Icon shown for the document."),subtitlesUrl:We().optional().describe("URL of an optional subtitle track.")}).describe("A manually opened media document.")]),_Y=rr({openFiles:bn(ng).optional().describe("Media documents currently open in Movie Player.")}),Dr={name:"Movie Player",id:"MoviePlayer.app",get icon(){return Jn("icons","system.quicktime.player")??""}},YC=at(["icons","list"]),KM=at(["small","medium","large"]),$Y=at(["none","grid","sorted"]),eZ=at(["name","modified","created","size","kind","label"]),QM=Ue({arrangement:$Y.default("none"),keepArrangedBy:eZ.default("name"),iconSize:KM.default("large")}),JM=Ue({modified:Gt().default(!0),created:Gt().default(!1),size:Gt().default(!0),kind:Gt().default(!0),label:Gt().default(!1),comments:Gt().default(!1),version:Gt().default(!1)}),XM=Ue({useRelativeDate:Gt().default(!0),calculateFolderSizes:Gt().default(!1),iconSize:KM.default("medium"),columns:JM.default(JM.parse({}))}),sg=Ue({icons:QM.default(QM.parse({})),list:XM.default(XM.parse({}))}),qM="finder_preferences",ZC=t=>{const e=sg.safeParse(t.standardViews??{});return e.success?e.data:sg.parse({})},_M=rr({openPaths:bn(We()).optional().describe("Folder paths with an open Finder window, in open order."),showAboutThisComputer:Gt().optional().describe("Whether the About This Computer window is open."),showPreferences:Gt().optional().describe("Whether the Finder Preferences window is open."),standardViews:sg.optional().describe("Default view options applied to folders using standard views."),folderViews:ps(We(),YC).optional().describe("Explicit per-folder view type. A path absent from this map follows the standard views."),confirmDelete:Ue({paths:bn(We()),trust:at(["trusted","untrusted"])}).optional().describe("A Delete waiting for its confirmation (Explorer's commands, `layout.finder.commands` \"windows\"): the items' paths and the trust the request arrived with. Session-only: never persisted."),desktopShortcutOffer:Ue({paths:bn(We())}).optional().describe("A Create Shortcut waiting for its answer (Explorer's commands): items whose folder takes no shortcut, which Windows 98 offers to make on the desktop instead. Session-only: never persisted."),hideFileExtensions:Gt().optional().describe('Finder Preferences\' "Hide file extensions for known file types" (Windows 98\'s Folder Options, offered under `layout.files.extensions` "hideRegistered"): on unless false.'),properties:bn(Ue({key:We(),paths:bn(We()).optional(),appId:We().optional()})).optional().describe("The open property sheets (Explorer's Properties, `layout.finder.commands` \"windows\"), in open order: each its key (one path, several sorted paths joined by ::, or : and an app id) and the items' paths or the application's id. Session-only: never persisted."),shellFolders:bn(at(["myComputer","controlPanel"])).optional().describe("The open shell folder windows, My Computer and its Control Panel, in open order (only while the active package shows the startup disk as My Computer, `desktopIcons.startupDisk`). Session-only: never persisted."),openWith:Ue({path:We(),trust:at(["trusted","untrusted"])}).optional().describe('An open waiting in the Open With dialog (`layout.files.unregisteredOpen` "openWith"): the file\'s path and the trust the open arrived with. Session-only: never persisted.')}),$M="finder_about_this_computer";function ex(t){return _M.safeParse(t).success}const PEe=t=>Array.isArray(t.moves)?t.moves.filter(e=>typeof e=="object"&&e!==null&&typeof e.from=="string"&&typeof e.to=="string"&&e.from!==""):[],jC=(t,e)=>{Kl(e)==="trusted"&&n1e(t)},tZ=(t,e,n,s)=>{const r=tM(e);return ma(s,r)?Qh(t,{type:r,app:{id:"Finder.app"},path:n}):t},LEe=new Set([xe.Extension,xe.FileShortcut,xe.AppShortcut,xe.Shortcut,xe.Directory,xe.Drive]),nZ=(t,e,n)=>{if(dn(n).files?.unregisteredOpen!=="openWith"||!t||t._system===!0||t._creator==="QuickTime")return!1;const s=t._type;if(typeof s!="string"||LEe.has(s))return!1;const r=Object.hasOwn(e.fileTypeHandlers,s)?e.fileTypeHandlers[s]:void 0;return!(typeof r=="string"&&r!=="Finder.app"&&Object.hasOwn(e.apps,r))},tx=(t,e,n)=>{const s="Finder.app";if(!t.System.Manager.Applications.apps[s])return t;const r=t.System.Manager.Applications.apps[s].data??{};let i=_8(s,r)??{...r};switch(e.type){case"ClassicyAppFinderOpenFolder":{if(!jl(e))break;if(!i.openPaths){i={...i,openPaths:[e.path]};break}Hd(t,s,e.path,i.openPaths.includes(e.path)),i={...i,openPaths:Array.from(new Set([...i.openPaths,e.path]))};break}case"ClassicyAppFinderOpenFolders":{if(!r0(e))break;const o=i.openPaths??[];i={...i,openPaths:Array.from(new Set([...o,...e.paths]))};break}case"ClassicyAppFinderCloseFolder":{if(!jl(e))break;const o=i.openPaths??[];i={...i,openPaths:o.filter(a=>a!==e.path)},Lh(t.System.Manager.Applications.apps[s],e.path,{closed:!0,focused:!1});break}case"ClassicyAppFinderAboutThisComputerOpen":{i={...i,showAboutThisComputer:!0},t=kr(t,s,$M);break}case"ClassicyAppFinderAboutThisComputerClose":{i={...i,showAboutThisComputer:!1};break}case"ClassicyAppFinderPreferencesOpen":{i={...i,showPreferences:!0},t=kr(t,s,qM);break}case"ClassicyAppFinderPreferencesClose":{i={...i,showPreferences:!1};break}case"ClassicyAppFinderSetStandardViewOption":{const{view:o,option:a,value:c}=e;if(o!=="icons"&&o!=="list"||typeof a!="string")break;const l=a.split(".");if(l.length>2)break;const d=ZC(i),u=d[o];let p;if(l.length===1)p={...u,[l[0]]:c};else{const A=u[l[0]];if(typeof A!="object"||A===null)break;p={...u,[l[0]]:{...A,[l[1]]:c}}}const f={...d,[o]:p},h=sg.safeParse(f);if(!h.success)break;i={...i,standardViews:h.data};break}case"ClassicyAppFinderSetFolderView":{if(!jl(e))break;const o=e.viewType;if(o!=="icons"&&o!=="list")break;i={...i,folderViews:{...i.folderViews??{},[e.path]:o}};break}case"ClassicyAppFinderPathsMoved":{const o=PEe(e);if(o.length===0)break;s1e(o);const a=d=>{for(const{from:u,to:p}of o){if(d===u)return p;if(d.startsWith(`${u}:`))return p+d.slice(u.length)}return d},c=t.System.Manager.Applications.apps[s];for(const d of i.openPaths??[]){const u=a(d);if(u===d)continue;const p=rn(c,d);p&&(Ud(c,d),i0(c,{...p,id:u}))}const l=i.properties?.map(d=>{if(!d.paths)return d;const u=d.paths.map(a);if(u.every((h,A)=>h===d.paths?.[A]))return d;const p=Dh({paths:u}),f=rn(c,Wc(d.key));return f&&(Ud(c,Wc(d.key)),i0(c,{...f,id:Wc(p)})),{key:p,paths:u}});i={...i,...l?{properties:l}:{},...i.openPaths?{openPaths:i.openPaths.map(a)}:{},...i.folderViews?{folderViews:Object.fromEntries(Object.entries(i.folderViews).map(([d,u])=>[a(d),u]))}:{}};break}case"ClassicyAppFinderConfirmDelete":{if(!r0(e))break;const o=e.paths.filter(a=>typeof a=="string"&&a!=="");if(o.length===0)break;i={...i,confirmDelete:{paths:o,trust:Kl(n)}};break}case"ClassicyAppFinderConfirmDeleteClose":{const{confirmDelete:o,...a}=i;i=a;break}case"ClassicyAppFinderOfferDesktopShortcut":{if(!r0(e))break;const o=e.paths.filter(a=>typeof a=="string"&&a!=="");if(o.length===0)break;i={...i,desktopShortcutOffer:{paths:o}};break}case"ClassicyAppFinderOfferDesktopShortcutClose":{const{desktopShortcutOffer:o,...a}=i;i=a;break}case"ClassicyAppFinderPropertiesOpen":{const{paths:o,appId:a}=e,c=Array.isArray(o)?o.filter(p=>typeof p=="string"&&p!==""):[],l=c.length>0?{paths:c}:typeof a=="string"&&a!==""?{appId:a}:void 0;if(!l)break;const d=Dh(l),u=i.properties??[];u.some(p=>p.key===d)||(i={...i,properties:[...u,"appId"in l?{key:d,appId:l.appId}:{key:d,paths:[...l.paths]}]}),t=kr(t,s,Wc(d));break}case"ClassicyAppFinderPropertiesClose":{const o=e.key;if(typeof o!="string")break;i={...i,properties:(i.properties??[]).filter(a=>a.key!==o)},Ud(t.System.Manager.Applications.apps[s],Wc(o));break}case Fd:{const o=e.folder;if(!cE(o)||!ZM(t.System.Manager.Appearance?.packageId))break;const a=i.shellFolders??[];a.includes(o)||(i={...i,shellFolders:[...a,o]}),t=kr(t,s,Th(o));break}case Ky:{const o=e.folder;if(!cE(o)||!i.shellFolders)break;const a=i.shellFolders.filter(c=>c!==o);if(a.length>0)i={...i,shellFolders:a};else{const{shellFolders:c,...l}=i;i=l}Lh(t.System.Manager.Applications.apps[s],Th(o),{closed:!0,focused:!1});break}case"ClassicyAppFinderSetHideFileExtensions":{const o=e.hide;if(typeof o!="boolean")break;i={...i,hideFileExtensions:o};break}case"ClassicyAppFinderOpenWithChoose":{const o=i.openWith,{openWith:a,...c}=i;i=c;const l=e.appId,d=typeof l=="string"&&l!==s?t.System.Manager.Applications.apps[l]:void 0;if(!o||!d)break;t.System.Manager.Applications.apps[s].data={...i};const u=Kl(n)==="untrusted"||o.trust==="untrusted"?"untrusted":"trusted";return sM(t,d,o.path,u)}case"ClassicyAppFinderOpenWithClose":{const{openWith:o,...a}=i;i=a;break}case"ClassicyAppFinderEmptyTrash":break;case"ClassicyAppFinderOpenFile":{const o=zL(e)?e.file:void 0;if(o?._system)return t.System.Manager.Desktop.errorDialog={message:"This file is used by the system software. It cannot be opened."},t;if(o?._type===xe.Extension){const a=vD(o),c=a?t.System.Manager.Applications.apps[a]:void 0;return c&&dn(t.System.Manager.Appearance.packageId).finder?.commands==="windows"?(ma(n,"ClassicyAppOpen")&&js(t,c.id,c.name,c.icon),t):(t.System.Manager.Desktop.errorDialog={title:"Library",message:"This file adds functionality to your computer. It cannot be opened."},t)}if(o?._type===xe.FileShortcut){const a=OU(),c=a?DY(a,o):void 0;if(c?.found){const u=c.entry._type===xe.Directory||c.entry._type===xe.Drive?{type:"ClassicyAppFinderOpenFolder",path:c.path}:{type:"ClassicyAppFinderOpenFile",file:c.entry,path:c.path};return ma(n,u.type)?tx(t,u,n):t}const l=typeof o._creator=="string"?t.System.Manager.Applications.apps[o._creator]:void 0;return l?(ma(n,"ClassicyAppOpen")&&js(t,l.id,l.name,l.icon),t):(t.System.Manager.Desktop.errorDialog=kY(c?.path||(typeof o._targetPath=="string"?o._targetPath:""),t.System.Manager.Appearance.packageId),t)}if(o&&o._creator==="QuickTime"){let a;try{a=typeof o._data=="string"?JSON.parse(o._data):o._data}catch(c){Ve("warn","ClassicyFinder","failed to parse QuickTime file data",{error:c,file:o})}if(typeof a=="object"&&a!==null&&"url"in a&&typeof a.url=="string"&&D0(a.url)){if(!ma(n,"ClassicyAppMoviePlayerOpenDocument"))return t;t=Qh(t,{type:"ClassicyAppOpen",app:Dr}),t=kk(t,"ClassicyAppMoviePlayer",{type:"ClassicyAppMoviePlayerOpenDocument",document:a}),jl(e)&&jC(e.path,n)}}else if(o&&o._type===xe.AppShortcut){const a=typeof o._creator=="string"?o._creator:void 0,c=a?t.System.Manager.Applications.apps[a]:void 0;c?js(t,c.id,c.name,c.icon):t.System.Manager.Desktop.errorDialog={message:"The application that created this item could not be found."}}else if(o&&o._type===xe.Shortcut){if(typeof o._url!="string"||o._url==="")return t.System.Manager.Desktop.errorDialog={message:"The original item for this shortcut could not be found."},t;if(!ma(n,"ClassicyDesktopOpenUrl"))return t;const a=jl(e)?e.path.split(":").pop()??e.path:o._url;t=Sk(t,{type:"ClassicyDesktopOpenUrl",url:o._url,disposition:o._openIn,title:typeof o._label=="string"?o._label:a})}else if(o&&jl(e)){const a=o._type,c=t.System.Manager.Applications.fileTypeHandlers[a],l=c?t.System.Manager.Applications.apps[c]:void 0;if(l&&l.id!==s)t=sM(t,l,e.path,n),jC(e.path,n);else if(dn(t.System.Manager.Appearance.packageId).files?.unregisteredOpen==="openWith")t.System.Manager.Applications.apps[s].data={...i,openWith:{path:e.path,trust:Kl(n)}};else if(l)t=tZ(t,l.name,e.path,n),jC(e.path,n);else{const d=t.System.Manager.Applications.apps[s];d?.handlesFileTypes?.includes(a)?(t=tZ(t,d.name,e.path,n),jC(e.path,n)):t.System.Manager.Desktop.errorDialog={message:"Finder cannot open the file type you requested."}}}return t}}return t.System.Manager.Applications.apps[s].data={...i},t};Es({id:"Finder.app",description:"The system file browser: desktop, folders, and the Trash.",prefix:"ClassicyAppFinder",handler:tx,actions:{ClassicyAppFinderOpenFolder:{description:"Open a Finder window at the given folder path.",params:Ue({path:We().describe("Absolute path of the folder to open.")})},ClassicyAppFinderOpenFolders:{description:"Open Finder windows for several folder paths at once.",params:Ue({paths:bn(We()).describe("Absolute paths of the folders to open.")})},ClassicyAppFinderCloseFolder:{description:"Close the Finder window showing the given folder path.",params:Ue({path:We().describe("Absolute path of the folder to close.")})},ClassicyAppFinderAboutThisComputerOpen:{description:"Open the About This Computer window."},ClassicyAppFinderAboutThisComputerClose:{description:"Close the About This Computer window."},ClassicyAppFinderPreferencesOpen:{description:"Open the Finder Preferences window."},ClassicyAppFinderPreferencesClose:{description:"Close the Finder Preferences window."},ClassicyAppFinderSetStandardViewOption:{description:"Set one standard-view option for the icon or list view. `option` is a dotted path at most one level deep, e.g. `columns.created`.",params:Ue({view:YC.describe("Which view's options to change."),option:We().describe("Dotted option path within that view, max one level deep."),value:Ed().describe("New value; validated against the schema.")})},ClassicyAppFinderSetFolderView:{description:"Remember an explicit view type for one folder, overriding the standard views.",params:Ue({path:We().describe("Absolute path of the folder."),viewType:YC.describe("The view to use for it.")})},ClassicyAppFinderPathsMoved:{description:"Items were moved to another folder (a Finder drag): open windows on moved folders, and their remembered view types, follow them to the new paths. Sent after the move; it does not move anything itself.",params:Ue({moves:bn(Ue({from:We().describe("Path before the move."),to:We().describe("Path after the move.")})).describe("Each moved item's old and new path.")})},ClassicyAppFinderConfirmDelete:{description:"Ask before moving items to the Trash (Explorer's commands: Windows 98 SE's Confirm File Delete box). Its Yes moves them under the trust this arrived with; it moves nothing itself.",params:Ue({paths:bn(We()).describe("Absolute paths of the items to move to the Trash.")})},ClassicyAppFinderConfirmDeleteClose:{description:"Dismiss a pending Delete confirmation (its Yes or No was chosen)."},ClassicyAppFinderOfferDesktopShortcut:{description:`Offer to make on the desktop the shortcuts Create Shortcut cannot make beside their items (Explorer's commands: Windows 98 SE's "Windows cannot create a shortcut here."). Its Yes makes them; it makes nothing itself.`,params:Ue({paths:bn(We()).describe("Absolute paths of the items the shortcuts are to.")})},ClassicyAppFinderOfferDesktopShortcutClose:{description:"Dismiss a pending desktop-shortcut offer (its Yes or No was chosen)."},ClassicyAppFinderPropertiesOpen:{description:"Open the property sheet of items, or of an application (Explorer's Properties: its General page), or focus it when it is open.",params:Ue({paths:bn(We()).optional().describe("Absolute paths of the items the sheet describes."),appId:We().optional().describe("An application's id, for its desktop icon's sheet.")})},ClassicyAppFinderPropertiesClose:{description:"Close a property sheet (its OK, Cancel or close box).",params:Ue({key:We().describe("The sheet's key, as its open recorded it.")})},ClassicyAppFinderOpenShellFolder:{description:"Open My Computer or its Control Panel (Windows 98 SE's shell folders), or bring its window forward; only while the active package shows the startup disk as My Computer (`desktopIcons.startupDisk`).",params:Ue({folder:at(["myComputer","controlPanel"]).describe("The shell folder to open.")})},ClassicyAppFinderCloseShellFolder:{description:"Close My Computer's or Control Panel's window.",params:Ue({folder:at(["myComputer","controlPanel"]).describe("The shell folder to close.")})},ClassicyAppFinderSetHideFileExtensions:{description:'Set Finder Preferences\' "Hide file extensions for known file types" (under `layout.files.extensions` "hideRegistered").',params:Ue({hide:Gt().describe("Whether registered types' extensions are hidden.")})},ClassicyAppFinderOpenWithChoose:{description:"The Open With dialog's OK: open the waiting file in the application chosen, under the trust its open arrived with.",params:Ue({appId:We().describe("The id of the application to open it in.")})},ClassicyAppFinderOpenWithClose:{description:"Dismiss the Open With dialog without opening the file."},ClassicyAppFinderEmptyTrash:{description:"Empty the Trash. Guarded route: never reachable by untrusted dispatch."},ClassicyAppFinderOpenFile:{description:"Open a file with its default app, resolved by the entry's file type.",params:Ue({file:rr({}).describe("The ClassicyFileSystem entry being opened."),path:We().optional().describe("Filesystem path of the entry, when known.")})}},state:_M});const sZ=3e3,REe=()=>typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("selector(::-webkit-progress-value)")&&typeof CSS.registerProperty!="function",zEe=(t,e)=>{const[n,s]=g.useState(!1);return g.useEffect(()=>{const r=t.current;if(!e||!r||!REe()){s(!1);return}s(!0);const i=Kt("--progress-bar-stripe-period",void 0,r)*2;r.setAttribute(jI,"");let o=0;const a=c=>{const l=c%sZ/sZ;r.style.setProperty("--slide-var",`${l*i}px`),o=requestAnimationFrame(a)};return o=requestAnimationFrame(a),()=>{cancelAnimationFrame(o),r.style.removeProperty("--slide-var"),r.removeAttribute(jI)}},[t,e]),n},WEe=()=>b.jsx("svg",{className:"classicyProgressChasingArrowsSpinner",viewBox:"0 0 32 32",width:"16",height:"16",role:"img","aria-hidden":"true",focusable:"false",children:b.jsxs("g",{fill:"currentColor",children:[b.jsx("path",{d:"M16 3a13 13 0 0 1 12.5 9.4l-3.8 1.1A9 9 0 0 0 16 7z"}),b.jsx("path",{d:"M24.7 9.5 30 12l-2 5.6z"}),b.jsx("path",{d:"M16 29A13 13 0 0 1 3.5 19.6l3.8-1.1A9 9 0 0 0 16 25z"}),b.jsx("path",{d:"M7.3 22.5 2 20l2-5.6z"})]})}),KC=({max:t=100,value:e,indeterminate:n,chasingArrows:s,autoSwitch:r,label:i,labelPosition:o="above",labelAlign:a="left",className:c,style:l})=>{const u=n&&!(r&&e!==void 0),p=g.useRef(null),f=zEe(p,!!(u&&!s)),h=u?100:t,A=u?100:e??0,m=i?void 0:c,y=i?void 0:l;let C;return s?C=b.jsx("div",{className:Ae("classicyProgress classicyProgressChasingArrows",m),style:y,role:"progressbar","aria-busy":"true","aria-label":i,children:b.jsx(WEe,{})}):C=b.jsx("div",{className:Ae("classicyProgress",u?"classicyProgressIndeterminate":"classicyProgressDeterminate",f&&"classicyProgressSlideByScript",m),style:y,children:b.jsx("progress",{ref:p,max:h,value:A})}),i?b.jsxs("div",{className:Ae(Ns(o),Nb(a),c),style:l,children:[b.jsx(kt,{label:i}),C]}):C},rZ={version:"3.8.0",release:"Ravel"},nx=64,VEe=20.5,UEe="Off",GEe="Finder.app",{version:HEe}=rZ,YEe=rZ.release,iZ=({className:t,style:e})=>{const n=et("icons","classicy.bg")??"",s=et("systemArt","aboutLogo")??"",r=et("icons","system.macos")??"",i=et("icons","system.mac")??"",o=st(),[a,c]=g.useState(VEe);g.useEffect(()=>{const p=performance;typeof p.measureUserAgentSpecificMemory=="function"?p.measureUserAgentSpecificMemory().then(f=>c(f.bytes/(1024*1024))).catch(()=>{Ve("info","Finder","Could not measure memory usage, using default value")}):Ve("info","Finder","Memory measurement API not available, using default value")},[]);const l=nx-a,d=q8("Finder.app","ClassicyAppFinderAboutThisComputerOpen"),u=`Classicy ${HEe} (${YEe})`;return b.jsx(Qt,{id:$M,appId:GEe,className:t,style:e,hideIcon:!0,title:"About This Computer",closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,taskbarButton:!1,initialSize:[520,290],initialPosition:["center","center"],onCloseFunc:()=>o({type:"ClassicyAppFinderAboutThisComputerClose"}),children:b.jsxs("div",{className:"finderAboutThisComputer",children:[b.jsxs("div",{className:"finderAboutThisComputerHeader",children:[b.jsx("div",{className:"finderAboutThisComputerBanner",style:{backgroundSize:"cover",backgroundPosition:"bottom left",backgroundImage:`url("${n}")`,backgroundRepeat:"no-repeat"},children:b.jsx("img",{src:s,alt:"Classicy"})}),b.jsxs("div",{className:"finderAboutThisComputerVersion",children:[b.jsx("img",{src:r,alt:"Classicy"}),d?b.jsx(II,{title:d.title,content:d.content,children:b.jsx("span",{children:u})}):b.jsx("span",{children:u})]})]}),b.jsxs("div",{className:"finderAboutThisComputerInfo",children:[b.jsxs("div",{className:"finderAboutThisComputerMemoryStats",children:[b.jsxs("p",{children:[b.jsx("strong",{children:"Built-in Memory:"})," ",nx," MB"]}),b.jsxs("p",{children:[b.jsx("strong",{children:"Virtual Memory:"})," ",UEe]}),b.jsxs("p",{children:[b.jsx("strong",{children:"Largest Unused Block:"})," ",l.toFixed(1)," MB"]})]}),b.jsx("p",{className:"finderAboutThisComputerCopyright",children:"Not \u2122 & \xA9 Apple Computer, Inc. 1983\u20131999"})]}),b.jsx(Os,{className:"finderAboutThisComputerUsage",children:b.jsxs("div",{className:"finderAboutThisComputerUsageItem",children:[b.jsx(pn,{src:i,alt:"Classicy"}),b.jsx("span",{className:"finderAboutThisComputerUsageName",children:"Classicy"}),b.jsxs("span",{className:"finderAboutThisComputerUsageSize",children:[a.toFixed(1)," MB"]}),b.jsx("div",{className:"finderAboutThisComputerUsageBar",children:b.jsx(KC,{value:a,max:nx})})]})})]})})},ZEe=[{value:"name",label:"by Name"},{value:"modified",label:"by Date Modified"},{value:"created",label:"by Date Created"},{value:"size",label:"by Size"},{value:"kind",label:"by Kind"},{value:"label",label:"by Label"}],jEe=[{key:"modified",label:"Date Modified"},{key:"created",label:"Date Created"},{key:"size",label:"Size"},{key:"kind",label:"Kind"},{key:"label",label:"Label"},{key:"comments",label:"Comments"},{key:"version",label:"Version"}],oZ=(t,e)=>{const n=st(),s=e?.hide,[r,i]=g.useState("icons"),o=g.useCallback((d,u,p)=>{n({type:"ClassicyAppFinderSetStandardViewOption",view:d,option:u,value:p})},[n]),a=t.icons,c=t.list;return{title:"Views",children:g.useMemo(()=>b.jsxs("div",{className:"finderPreferencesViews",children:[b.jsxs(ks,{label:"View Options",children:[b.jsx(on,{id:"finder_prefs_view_type",label:"View type:",labelPosition:"left",selected:r,options:[{value:"icons",label:"Icons"},{value:"list",label:"List"}],onChangeFunc:d=>i(d.target.value)}),r==="icons"?b.jsxs("div",{className:"finderPreferencesPane",children:[b.jsx("p",{className:"finderPreferencesGroupHeading",children:"Icon Arrangement:"}),b.jsx(il,{name:"finder_prefs_icon_arrangement",onClickFunc:d=>o("icons","arrangement",d.split("__").pop()),inputs:[{id:"finder_prefs_icon_arrangement__none",label:"None",checked:a.arrangement==="none"},{id:"finder_prefs_icon_arrangement__grid",label:"Always snap to grid",checked:a.arrangement==="grid"},{id:"finder_prefs_icon_arrangement__sorted",label:"Keep arranged:",checked:a.arrangement==="sorted"}]}),b.jsx(on,{id:"finder_prefs_icon_sort",disabled:a.arrangement!=="sorted",selected:a.keepArrangedBy,options:ZEe,onChangeFunc:d=>o("icons","keepArrangedBy",d.target.value)}),b.jsx(il,{name:"finder_prefs_icon_size",onClickFunc:d=>o("icons","iconSize",d.split("__").pop()),inputs:[{id:"finder_prefs_icon_size__small",label:"Small icons",checked:a.iconSize==="small"},{id:"finder_prefs_icon_size__large",label:"Large icons",checked:a.iconSize!=="small"}]})]}):b.jsxs("div",{className:"finderPreferencesPane",children:[b.jsx(qn,{id:"finder_prefs_relative_date",label:"Use relative date",checked:c.useRelativeDate,onClickFunc:d=>o("list","useRelativeDate",d)}),b.jsx(qn,{id:"finder_prefs_folder_sizes",label:"Calculate folder sizes",checked:c.calculateFolderSizes,onClickFunc:d=>o("list","calculateFolderSizes",d)}),b.jsx("p",{className:"finderPreferencesGroupHeading",children:"Show Columns:"}),jEe.map(({key:d,label:u})=>b.jsx(qn,{id:`finder_prefs_column_${d}`,label:u,checked:c.columns[d]===!0,onClickFunc:p=>o("list",`columns.${d}`,p)},d)),b.jsx(il,{name:"finder_prefs_list_icon_size",onClickFunc:d=>o("list","iconSize",d.split("__").pop()),inputs:[{id:"finder_prefs_list_icon_size__small",label:"Small icons",checked:c.iconSize==="small"},{id:"finder_prefs_list_icon_size__medium",label:"Medium icons",checked:c.iconSize==="medium"},{id:"finder_prefs_list_icon_size__large",label:"Large icons",checked:c.iconSize==="large"}]})]})]}),s!==void 0&&b.jsx(qn,{id:"finder_prefs_hide_extensions",label:"Hide file extensions for known file types",checked:s,onClickFunc:d=>n({type:"ClassicyAppFinderSetHideFileExtensions",hide:d})})]}),[r,a,c,o,s,n])}},sx="Finder.app",aZ=({className:t,style:e})=>{const n=et("icons","system.help")??"",s=st(),r=ye(u=>u.System.Manager.Applications.apps[sx]?.data),i=g.useMemo(()=>ZC(r??{}),[r]),o=gt().files?.extensions==="hideRegistered",a=r?.hideFileExtensions!==!1,c=oZ(i,o?{hide:a}:void 0),l=g.useMemo(()=>[c],[c]),d=HT(sx,"preferences");return b.jsx(Qt,{id:qM,appId:sx,className:t,style:e,title:"Preferences",closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,modal:!1,taskbarButton:!1,initialSize:[470,0],initialPosition:["center","center"],onCloseFunc:()=>s({type:"ClassicyAppFinderPreferencesClose"}),children:b.jsxs("div",{className:"finderPreferences",children:[b.jsx(au,{tabs:l,...d}),b.jsxs("div",{className:"finderPreferencesFooter",children:[b.jsx(pn,{className:"finderPreferencesHelpIcon",src:n,alt:"Help"}),b.jsx("p",{className:"finderPreferencesNote",children:"Changes are applied to all folders that are set to Standard views. Other folders are not affected."})]})]})})},rx="My Computer",ix=(t,e,n)=>n>0?`${n} object(s) selected`:e>0?`${t} object(s) (plus ${e} hidden)`:`${t} object(s)`,cZ=t=>t===void 0||t<0?"":Xy(t),lZ=(t,e,n)=>(n.length>0?[...n]:Object.keys(t.resolve(e)??{}).filter(r=>!r.startsWith("_")).map(r=>`${e}${t.separator}${r}`)).filter(r=>{const i=t.resolve(r);return i!==void 0&&i._type!==xe.Directory&&i._type!==xe.Drive&&i._invisible!==!0}),uZ=(t,e,n,s)=>{const[r,i]=g.useState(void 0),o=n.join(`
79
+ `);return g.useEffect(()=>{let i=!1;return s(void 0),Promise.all(e.map(o=>FEe(t,o))).then(o=>{if(i)return;const a=o.filter(c=>c>=0);s(a.length===0?null:a.reduce((c,l)=>c+l,0))}),()=>{i=!0}},[t,r]),n},HY=t=>t===void 0?"Calculating\u2026":t===null?pE:f9(t),YY="Specifies whether this item is read-only, which means that it cannot be changed or accidentally deleted.",ZY="Specifies whether this item is hidden, which means you cannot see or use it unless you know its name.",jY=({appId:t,fs:e,paths:n=[],targetAppId:s,index:r=0,trashIcon:i,className:o,style:a})=>{const c=st(),l=cr(t),d=tn(),u=pM(),p=Eu(),f=Hp(),h=g.useRef(null),A=Dh(s!==void 0?{appId:s}:{paths:n}),m=Wc(A),y=g.useMemo(()=>n.flatMap(ae=>{const ne=e.resolve(ae);return ne?[{path:ae,entry:ne}]:[]}),[e,n]),C=g.useMemo(()=>y.map(ae=>ae.entry),[y]),v=y.length===1?y[0]:void 0,S=ye(ae=>s!==void 0?ae.System.Manager.Applications.apps[s]:void 0),w=cs(s,{name:S?.name??s??"",icon:S?.icon??""}),k=v?v.path===an?f:v.path.split(e.separator).pop()??v.path:"",I=v?p.hiddenExtension(k,v.entry):"",T=k.slice(0,k.length-I.length),D=v?.entry._type===xe.Drive,O=v?.path===an,x=v?.entry._type===xe.Directory,B=!!v&&!O&&eg(e,v.path),F=y.length>0&&C.every(ae=>A9(ae))&&!O,z=GY(C,"_readOnly"),V=GY(C,"_invisible"),[P,W]=g.useState(T),[K,L]=g.useState(z),[M,G]=g.useState(V),Y=B&&P!==T||K!==z||M!==V,N=NEe(e,s!==void 0?[]:y.map(ae=>ae.path)),J=g.useCallback(()=>{let ae=y.map(ne=>ne.path);if(v&&B&&P!==T){const ne=LC(e,v.path,P+I,c);if(ne===void 0)return;ae=[ne]}if(F)for(const ne of ae){const ue={};K!==z&&K!=="mixed"&&(ue._readOnly=K),M!==V&&M!=="mixed"&&(ue._invisible=M),Object.keys(ue).length>0&&e.setMetadata(ne,ue)}return Dh({paths:ae})},[y,v,B,P,T,e,I,c,F,K,z,M,V]),te=g.useCallback(ae=>l(Wc(ae),{type:Jy,key:ae}),[l]),H=g.useCallback(()=>{if(s!==void 0){te(A);return}const ae=Y?J():A;ae!==void 0&&te(ae)},[s,te,A,Y,J]),X=g.useCallback(()=>te(A),[te,A]);No({onDefault:H,onCancel:X,targetRef:h});const Z=g.useMemo(()=>[{find:sD(`${m}-read-only`),help:{content:YY}},{find:sD(`${m}-hidden`),help:{content:ZY}}],[m]);lU(h,Z);const oe=g.useMemo(()=>({get current(){return h.current?.querySelector('[role="tab"][tabindex="0"]')??null}}),[]),he=s===void 0&&y.length===0;if(g.useEffect(()=>{he&&c({type:Jy,key:A})},[he,c,A]),he)return null;const ee=s!==void 0?w.name:v?T:o9(p.display(y[0].path.split(e.separator).pop()??"",y[0].entry)),ce=s!==void 0?w.icon:O?i||v?.entry._icon||Tr("directory"):v?v.entry._icon||Tr(v.entry._type):Tr(xe.File),re=new Set(C.map(ae=>ae._type)),le=new Set(y.map(ae=>AE(e,ae.path))),Ce=C.filter(ae=>ae._type===xe.Directory||ae._type===xe.Drive).length,De={files:C.length-Ce,folders:Ce},Te=x?h9(v?.entry):null,q=v?AE(e,v.path):"",Q=q===an?f:q,se=b.jsxs("div",{className:"classicyFilePropertiesGeneral",children:[b.jsxs("div",{className:"classicyFilePropertiesHead",children:[b.jsx(pn,{className:"classicyFilePropertiesIcon",src:ce,drawnAt:Number.POSITIVE_INFINITY,alt:""}),B?b.jsx(ri,{id:`${m}-name`,className:"classicyFilePropertiesName",prefillValue:T,onChangeFunc:ae=>W(ae.target.value)}):b.jsx("span",{className:"classicyFilePropertiesName",children:s!==void 0?w.name:v?T:fE(De.files,De.folders)})]}),b.jsx(ap,{}),b.jsx("div",{className:"classicyFilePropertiesRows",children:s!==void 0?b.jsx(to,{label:"Type:",children:u(xe.AppShortcut)}):v?b.jsxs(b.Fragment,{children:[b.jsx(to,{label:"Type:",children:u(v.entry._type)}),Q!==""&&b.jsx(to,{label:"Location:",children:Q}),b.jsx(to,{label:D?"Used space:":"Size:",children:HY(N)}),Te&&b.jsx(to,{label:"Contains:",children:fE(Te.files,Te.folders)})]}):b.jsxs(b.Fragment,{children:[b.jsx(to,{label:"Type:",children:re.size===1?l9(u(C[0]._type)):a9}),b.jsx(to,{label:"Location:",children:le.size===1?u9([...le][0]):c9}),b.jsx(to,{label:"Size:",children:HY(N)})]})}),v&&!D&&b.jsxs(b.Fragment,{children:[b.jsx(ap,{}),b.jsxs("div",{className:"classicyFilePropertiesRows",children:[b.jsx(to,{label:"Created:",children:hE(v.entry._createdOn)}),!x&&b.jsx(to,{label:"Modified:",children:hE(v.entry._modifiedOn)})]})]}),s===void 0&&!D&&b.jsxs(b.Fragment,{children:[b.jsx(ap,{}),b.jsx("div",{className:"classicyFilePropertiesRows",children:b.jsx(to,{label:"Attributes:",children:b.jsxs("span",{className:"classicyFilePropertiesAttributes",children:[b.jsx(qn,{id:`${m}-read-only`,label:"Read-only",accessKey:d("R"),checked:K===!0,mixed:K==="mixed",disabled:!F,onClickFunc:ae=>L(ae)}),b.jsx(qn,{id:`${m}-hidden`,label:"Hidden",accessKey:d("d"),checked:M===!0,mixed:M==="mixed",disabled:!F,onClickFunc:ae=>G(ae)})]})})})]})]});return b.jsx(Qt,{id:m,appId:t,title:i9(ee),hideIcon:!0,closable:!0,resizable:!1,zoomable:!1,collapsable:!1,scrollable:!1,modal:!1,initialSize:[360,0],initialPosition:[80+r*24,60+r*24],initialFocusRef:oe,contextHelp:!0,analyticsPath:dA(t,"properties"),onCloseFunc:()=>c({type:Jy,key:A}),className:o,style:a,children:b.jsxs("div",{ref:h,className:Ae("classicyFileProperties"),children:[b.jsx(au,{tabs:[{title:"General",children:se}]}),b.jsxs("div",{className:"classicyFilePropertiesButtons",children:[b.jsx($e,{isDefault:!0,onClickFunc:H,children:"OK"}),b.jsx($e,{onClickFunc:X,children:"Cancel"}),b.jsx($e,{accessKey:d("A"),disabled:!Y,onClickFunc:()=>{J()},children:"Apply"})]})]})})},HC="finder_open_with",KY=t=>`Click the program you want to use to open the file '${t}'.`,QY=()=>{const t=ye(s=>s.System.Manager.Applications.apps),e=Si(),n=ws();return g.useMemo(()=>Object.values(t).filter(s=>s.id!=="Finder.app"&&e.has(s.id)&&(nM(s.id)!==void 0||(s.handlesFileTypes?.length??0)>0)).map(s=>{const r=Object.hasOwn(n,s.id)?n[s.id]:void 0;return{id:s.id,name:r?.name??s.name,icon:r?.icon??s.icon}}).sort((s,r)=>s.name.localeCompare(r.name)),[t,e,n])},JY=({appId:t,fs:e,path:n,className:s,style:r})=>{const i=st(),o=tn(),a=Eu(),c=QY(),l=g.useRef(null),[d,u]=g.useState(void 0),[p,f]=g.useState(!0),h=e.resolve(n),A=n.split(e.separator).pop()??n,m=g.useMemo(()=>c.map(v=>({value:v.id,label:v.name,icon:v.icon})),[c]),y=g.useCallback(v=>{v!==void 0&&(p&&h?._type&&i({type:"ClassicyAppSetDefaultFileTypeHandler",app:{id:v},fileType:h._type}),i({type:"ClassicyAppFinderOpenWithChoose",appId:v}))},[p,h,i]),C=g.useCallback(()=>i({type:"ClassicyAppFinderOpenWithClose"}),[i]);return No({onDefault:()=>y(d),onCancel:C,targetRef:l}),ou({ref:l,autoFocus:!0}),b.jsx(Qt,{id:HC,appId:t,title:"Open With",hideIcon:!0,closable:!1,resizable:!1,zoomable:!1,collapsable:!1,scrollable:!1,modal:!0,initialSize:[0,0],initialPosition:["center","center"],analyticsExclude:!0,className:s,style:r,children:b.jsx(vp,{rootRef:l,children:b.jsxs("div",{ref:l,className:"classicyOpenWithDialog",role:"dialog","aria-modal":"true","aria-label":"Open With",children:[b.jsxs("div",{className:"classicyOpenWithDialogTop",children:[b.jsx(pn,{className:"classicyOpenWithDialogIcon",src:h?._icon||Tr(h?._type??"file"),drawnAt:Number.POSITIVE_INFINITY,alt:""}),b.jsx("p",{className:"classicyOpenWithDialogPrompt",children:KY(a.display(A,h))})]}),b.jsx(nD,{id:`${HC}-programs`,label:"Choose the program you want to use:",accessKey:o("C"),options:m,selected:d!==void 0?[d]:[],onChangeFunc:v=>u(v[0]),onActivateFunc:v=>y(v)}),b.jsx(qn,{id:`${HC}-always`,label:"Always use this program to open this type of file",accessKey:o("u"),checked:p,onClickFunc:f}),b.jsxs("div",{className:"classicyOpenWithDialogButtons",children:[b.jsx($e,{isDefault:!0,disabled:d===void 0,onClickFunc:()=>y(d),children:"OK"}),b.jsx($e,{onClickFunc:C,children:"Cancel"})]})]})})})},ZM=t=>Yy(t).startupDisk!==void 0,XY=(t,e,n)=>[...Object.entries(t.filterByType("",xe.Drive)).map(([s,r])=>{const i=r._icon;return{id:`drive:${s}`,name:s,icon:typeof i=="string"&&i!==""?i:n(xe.Drive),kind:"drive",path:s,open:{type:"ClassicyAppFinderOpenFolder",path:s}}}),{id:"controlPanel",name:Qy,icon:e,kind:"folder",open:{type:Fd,folder:"controlPanel"}}],qY=(t,e)=>t.flatMap(n=>{if(typeof n.event!="string")return[];const s=n.id.startsWith(e)?n.id.slice(e.length):n.id;return[{id:`panel:${s}`,name:n.title??s,icon:n.image??"",kind:"controlPanel",appId:s,open:{type:n.event,...n.eventData??{}}}]});function jM(t){return t!==null&&typeof t=="object"&&"openFiles"in t&&Array.isArray(t.openFiles)}const ng=Mc([We().describe("A ClassicyFileSystem path to a media file."),rr({url:We().describe("Source URL of the media document."),name:We().optional().describe("Display name of the document."),type:at(["audio","video","image"]).optional().describe("Media kind, when known."),icon:We().optional().describe("Icon shown for the document."),subtitlesUrl:We().optional().describe("URL of an optional subtitle track.")}).describe("A manually opened media document.")]),_Y=rr({openFiles:bn(ng).optional().describe("Media documents currently open in Movie Player.")}),Dr={name:"Movie Player",id:"MoviePlayer.app",get icon(){return Jn("icons","system.quicktime.player")??""}},YC=at(["icons","list"]),KM=at(["small","medium","large"]),$Y=at(["none","grid","sorted"]),eZ=at(["name","modified","created","size","kind","label"]),QM=Ue({arrangement:$Y.default("none"),keepArrangedBy:eZ.default("name"),iconSize:KM.default("large")}),JM=Ue({modified:Gt().default(!0),created:Gt().default(!1),size:Gt().default(!0),kind:Gt().default(!0),label:Gt().default(!1),comments:Gt().default(!1),version:Gt().default(!1)}),XM=Ue({useRelativeDate:Gt().default(!0),calculateFolderSizes:Gt().default(!1),iconSize:KM.default("medium"),columns:JM.default(JM.parse({}))}),sg=Ue({icons:QM.default(QM.parse({})),list:XM.default(XM.parse({}))}),qM="finder_preferences",ZC=t=>{const e=sg.safeParse(t.standardViews??{});return e.success?e.data:sg.parse({})},_M=rr({openPaths:bn(We()).optional().describe("Folder paths with an open Finder window, in open order."),showAboutThisComputer:Gt().optional().describe("Whether the About This Computer window is open."),showPreferences:Gt().optional().describe("Whether the Finder Preferences window is open."),standardViews:sg.optional().describe("Default view options applied to folders using standard views."),folderViews:ps(We(),YC).optional().describe("Explicit per-folder view type. A path absent from this map follows the standard views."),confirmDelete:Ue({paths:bn(We()),trust:at(["trusted","untrusted"])}).optional().describe("A Delete waiting for its confirmation (Explorer's commands, `layout.finder.commands` \"windows\"): the items' paths and the trust the request arrived with. Session-only: never persisted."),desktopShortcutOffer:Ue({paths:bn(We())}).optional().describe("A Create Shortcut waiting for its answer (Explorer's commands): items whose folder takes no shortcut, which Windows 98 offers to make on the desktop instead. Session-only: never persisted."),hideFileExtensions:Gt().optional().describe('Finder Preferences\' "Hide file extensions for known file types" (Windows 98\'s Folder Options, offered under `layout.files.extensions` "hideRegistered"): on unless false.'),properties:bn(Ue({key:We(),paths:bn(We()).optional(),appId:We().optional()})).optional().describe("The open property sheets (Explorer's Properties, `layout.finder.commands` \"windows\"), in open order: each its key (one path, several sorted paths joined by ::, or : and an app id) and the items' paths or the application's id. Session-only: never persisted."),shellFolders:bn(at(["myComputer","controlPanel"])).optional().describe("The open shell folder windows, My Computer and its Control Panel, in open order (only while the active package shows the startup disk as My Computer, `desktopIcons.startupDisk`). Session-only: never persisted."),openWith:Ue({path:We(),trust:at(["trusted","untrusted"])}).optional().describe('An open waiting in the Open With dialog (`layout.files.unregisteredOpen` "openWith"): the file\'s path and the trust the open arrived with. Session-only: never persisted.')}),$M="finder_about_this_computer";function ex(t){return _M.safeParse(t).success}const PEe=t=>Array.isArray(t.moves)?t.moves.filter(e=>typeof e=="object"&&e!==null&&typeof e.from=="string"&&typeof e.to=="string"&&e.from!==""):[],jC=(t,e)=>{Kl(e)==="trusted"&&n1e(t)},tZ=(t,e,n,s)=>{const r=tM(e);return ma(s,r)?Qh(t,{type:r,app:{id:"Finder.app"},path:n}):t},LEe=new Set([xe.Extension,xe.FileShortcut,xe.AppShortcut,xe.Shortcut,xe.Directory,xe.Drive]),nZ=(t,e,n)=>{if(dn(n).files?.unregisteredOpen!=="openWith"||!t||t._system===!0||t._creator==="QuickTime")return!1;const s=t._type;if(typeof s!="string"||LEe.has(s))return!1;const r=Object.hasOwn(e.fileTypeHandlers,s)?e.fileTypeHandlers[s]:void 0;return!(typeof r=="string"&&r!=="Finder.app"&&Object.hasOwn(e.apps,r))},tx=(t,e,n)=>{const s="Finder.app";if(!t.System.Manager.Applications.apps[s])return t;const r=t.System.Manager.Applications.apps[s].data??{};let i=_8(s,r)??{...r};switch(e.type){case"ClassicyAppFinderOpenFolder":{if(!jl(e))break;if(!i.openPaths){i={...i,openPaths:[e.path]};break}Hd(t,s,e.path,i.openPaths.includes(e.path)),i={...i,openPaths:Array.from(new Set([...i.openPaths,e.path]))};break}case"ClassicyAppFinderOpenFolders":{if(!r0(e))break;const o=i.openPaths??[];i={...i,openPaths:Array.from(new Set([...o,...e.paths]))};break}case"ClassicyAppFinderCloseFolder":{if(!jl(e))break;const o=i.openPaths??[];i={...i,openPaths:o.filter(a=>a!==e.path)},Lh(t.System.Manager.Applications.apps[s],e.path,{closed:!0,focused:!1});break}case"ClassicyAppFinderAboutThisComputerOpen":{i={...i,showAboutThisComputer:!0},t=kr(t,s,$M);break}case"ClassicyAppFinderAboutThisComputerClose":{i={...i,showAboutThisComputer:!1};break}case"ClassicyAppFinderPreferencesOpen":{i={...i,showPreferences:!0},t=kr(t,s,qM);break}case"ClassicyAppFinderPreferencesClose":{i={...i,showPreferences:!1};break}case"ClassicyAppFinderSetStandardViewOption":{const{view:o,option:a,value:c}=e;if(o!=="icons"&&o!=="list"||typeof a!="string")break;const l=a.split(".");if(l.length>2)break;const d=ZC(i),u=d[o];let p;if(l.length===1)p={...u,[l[0]]:c};else{const A=u[l[0]];if(typeof A!="object"||A===null)break;p={...u,[l[0]]:{...A,[l[1]]:c}}}const f={...d,[o]:p},h=sg.safeParse(f);if(!h.success)break;i={...i,standardViews:h.data};break}case"ClassicyAppFinderSetFolderView":{if(!jl(e))break;const o=e.viewType;if(o!=="icons"&&o!=="list")break;i={...i,folderViews:{...i.folderViews??{},[e.path]:o}};break}case"ClassicyAppFinderPathsMoved":{const o=PEe(e);if(o.length===0)break;s1e(o);const a=d=>{for(const{from:u,to:p}of o){if(d===u)return p;if(d.startsWith(`${u}:`))return p+d.slice(u.length)}return d},c=t.System.Manager.Applications.apps[s];for(const d of i.openPaths??[]){const u=a(d);if(u===d)continue;const p=rn(c,d);p&&(Ud(c,d),i0(c,{...p,id:u}))}const l=i.properties?.map(d=>{if(!d.paths)return d;const u=d.paths.map(a);if(u.every((h,A)=>h===d.paths?.[A]))return d;const p=Dh({paths:u}),f=rn(c,Wc(d.key));return f&&(Ud(c,Wc(d.key)),i0(c,{...f,id:Wc(p)})),{key:p,paths:u}});i={...i,...l?{properties:l}:{},...i.openPaths?{openPaths:i.openPaths.map(a)}:{},...i.folderViews?{folderViews:Object.fromEntries(Object.entries(i.folderViews).map(([d,u])=>[a(d),u]))}:{}};break}case"ClassicyAppFinderConfirmDelete":{if(!r0(e))break;const o=e.paths.filter(a=>typeof a=="string"&&a!=="");if(o.length===0)break;i={...i,confirmDelete:{paths:o,trust:Kl(n)}};break}case"ClassicyAppFinderConfirmDeleteClose":{const{confirmDelete:o,...a}=i;i=a;break}case"ClassicyAppFinderOfferDesktopShortcut":{if(!r0(e))break;const o=e.paths.filter(a=>typeof a=="string"&&a!=="");if(o.length===0)break;i={...i,desktopShortcutOffer:{paths:o}};break}case"ClassicyAppFinderOfferDesktopShortcutClose":{const{desktopShortcutOffer:o,...a}=i;i=a;break}case"ClassicyAppFinderPropertiesOpen":{const{paths:o,appId:a}=e,c=Array.isArray(o)?o.filter(p=>typeof p=="string"&&p!==""):[],l=c.length>0?{paths:c}:typeof a=="string"&&a!==""?{appId:a}:void 0;if(!l)break;const d=Dh(l),u=i.properties??[];u.some(p=>p.key===d)||(i={...i,properties:[...u,"appId"in l?{key:d,appId:l.appId}:{key:d,paths:[...l.paths]}]}),t=kr(t,s,Wc(d));break}case"ClassicyAppFinderPropertiesClose":{const o=e.key;if(typeof o!="string")break;i={...i,properties:(i.properties??[]).filter(a=>a.key!==o)},Ud(t.System.Manager.Applications.apps[s],Wc(o));break}case Fd:{const o=e.folder;if(!cE(o)||!ZM(t.System.Manager.Appearance?.packageId))break;const a=i.shellFolders??[];a.includes(o)||(i={...i,shellFolders:[...a,o]}),t=kr(t,s,Th(o));break}case Ky:{const o=e.folder;if(!cE(o)||!i.shellFolders)break;const a=i.shellFolders.filter(c=>c!==o);if(a.length>0)i={...i,shellFolders:a};else{const{shellFolders:c,...l}=i;i=l}Lh(t.System.Manager.Applications.apps[s],Th(o),{closed:!0,focused:!1});break}case"ClassicyAppFinderSetHideFileExtensions":{const o=e.hide;if(typeof o!="boolean")break;i={...i,hideFileExtensions:o};break}case"ClassicyAppFinderOpenWithChoose":{const o=i.openWith,{openWith:a,...c}=i;i=c;const l=e.appId,d=typeof l=="string"&&l!==s?t.System.Manager.Applications.apps[l]:void 0;if(!o||!d)break;t.System.Manager.Applications.apps[s].data={...i};const u=Kl(n)==="untrusted"||o.trust==="untrusted"?"untrusted":"trusted";return sM(t,d,o.path,u)}case"ClassicyAppFinderOpenWithClose":{const{openWith:o,...a}=i;i=a;break}case"ClassicyAppFinderEmptyTrash":break;case"ClassicyAppFinderOpenFile":{const o=zL(e)?e.file:void 0;if(o?._system)return t.System.Manager.Desktop.errorDialog={message:"This file is used by the system software. It cannot be opened."},t;if(o?._type===xe.Extension){const a=vD(o),c=a?t.System.Manager.Applications.apps[a]:void 0;return c&&dn(t.System.Manager.Appearance.packageId).finder?.commands==="windows"?(ma(n,"ClassicyAppOpen")&&js(t,c.id,c.name,c.icon),t):(t.System.Manager.Desktop.errorDialog={title:"Library",message:"This file adds functionality to your computer. It cannot be opened."},t)}if(o?._type===xe.FileShortcut){const a=OU(),c=a?DY(a,o):void 0;if(c?.found){const u=c.entry._type===xe.Directory||c.entry._type===xe.Drive?{type:"ClassicyAppFinderOpenFolder",path:c.path}:{type:"ClassicyAppFinderOpenFile",file:c.entry,path:c.path};return ma(n,u.type)?tx(t,u,n):t}const l=typeof o._creator=="string"?t.System.Manager.Applications.apps[o._creator]:void 0;return l?(ma(n,"ClassicyAppOpen")&&js(t,l.id,l.name,l.icon),t):(t.System.Manager.Desktop.errorDialog=kY(c?.path||(typeof o._targetPath=="string"?o._targetPath:""),t.System.Manager.Appearance.packageId),t)}if(o&&o._creator==="QuickTime"){let a;try{a=typeof o._data=="string"?JSON.parse(o._data):o._data}catch(c){Ve("warn","ClassicyFinder","failed to parse QuickTime file data",{error:c,file:o})}if(typeof a=="object"&&a!==null&&"url"in a&&typeof a.url=="string"&&D0(a.url)){if(!ma(n,"ClassicyAppMoviePlayerOpenDocument"))return t;t=Qh(t,{type:"ClassicyAppOpen",app:Dr}),t=kk(t,"ClassicyAppMoviePlayer",{type:"ClassicyAppMoviePlayerOpenDocument",document:a}),jl(e)&&jC(e.path,n)}}else if(o&&o._type===xe.AppShortcut){const a=typeof o._creator=="string"?o._creator:void 0,c=a?t.System.Manager.Applications.apps[a]:void 0;c?js(t,c.id,c.name,c.icon):t.System.Manager.Desktop.errorDialog={message:"The application that created this item could not be found."}}else if(o&&o._type===xe.Shortcut){if(typeof o._url!="string"||o._url==="")return t.System.Manager.Desktop.errorDialog={message:"The original item for this shortcut could not be found."},t;if(!ma(n,"ClassicyDesktopOpenUrl"))return t;const a=jl(e)?e.path.split(":").pop()??e.path:o._url;t=Sk(t,{type:"ClassicyDesktopOpenUrl",url:o._url,disposition:o._openIn,title:typeof o._label=="string"?o._label:a})}else if(o&&jl(e)){const a=o._type,c=t.System.Manager.Applications.fileTypeHandlers[a],l=c?t.System.Manager.Applications.apps[c]:void 0;if(l&&l.id!==s)t=sM(t,l,e.path,n),jC(e.path,n);else if(dn(t.System.Manager.Appearance.packageId).files?.unregisteredOpen==="openWith")t.System.Manager.Applications.apps[s].data={...i,openWith:{path:e.path,trust:Kl(n)}};else if(l)t=tZ(t,l.name,e.path,n),jC(e.path,n);else{const d=t.System.Manager.Applications.apps[s];d?.handlesFileTypes?.includes(a)?(t=tZ(t,d.name,e.path,n),jC(e.path,n)):t.System.Manager.Desktop.errorDialog={message:"Finder cannot open the file type you requested."}}}return t}}return t.System.Manager.Applications.apps[s].data={...i},t};Es({id:"Finder.app",description:"The system file browser: desktop, folders, and the Trash.",prefix:"ClassicyAppFinder",handler:tx,actions:{ClassicyAppFinderOpenFolder:{description:"Open a Finder window at the given folder path.",params:Ue({path:We().describe("Absolute path of the folder to open.")})},ClassicyAppFinderOpenFolders:{description:"Open Finder windows for several folder paths at once.",params:Ue({paths:bn(We()).describe("Absolute paths of the folders to open.")})},ClassicyAppFinderCloseFolder:{description:"Close the Finder window showing the given folder path.",params:Ue({path:We().describe("Absolute path of the folder to close.")})},ClassicyAppFinderAboutThisComputerOpen:{description:"Open the About This Computer window."},ClassicyAppFinderAboutThisComputerClose:{description:"Close the About This Computer window."},ClassicyAppFinderPreferencesOpen:{description:"Open the Finder Preferences window."},ClassicyAppFinderPreferencesClose:{description:"Close the Finder Preferences window."},ClassicyAppFinderSetStandardViewOption:{description:"Set one standard-view option for the icon or list view. `option` is a dotted path at most one level deep, e.g. `columns.created`.",params:Ue({view:YC.describe("Which view's options to change."),option:We().describe("Dotted option path within that view, max one level deep."),value:Ed().describe("New value; validated against the schema.")})},ClassicyAppFinderSetFolderView:{description:"Remember an explicit view type for one folder, overriding the standard views.",params:Ue({path:We().describe("Absolute path of the folder."),viewType:YC.describe("The view to use for it.")})},ClassicyAppFinderPathsMoved:{description:"Items were moved to another folder (a Finder drag): open windows on moved folders, and their remembered view types, follow them to the new paths. Sent after the move; it does not move anything itself.",params:Ue({moves:bn(Ue({from:We().describe("Path before the move."),to:We().describe("Path after the move.")})).describe("Each moved item's old and new path.")})},ClassicyAppFinderConfirmDelete:{description:"Ask before moving items to the Trash (Explorer's commands: Windows 98 SE's Confirm File Delete box). Its Yes moves them under the trust this arrived with; it moves nothing itself.",params:Ue({paths:bn(We()).describe("Absolute paths of the items to move to the Trash.")})},ClassicyAppFinderConfirmDeleteClose:{description:"Dismiss a pending Delete confirmation (its Yes or No was chosen)."},ClassicyAppFinderOfferDesktopShortcut:{description:`Offer to make on the desktop the shortcuts Create Shortcut cannot make beside their items (Explorer's commands: Windows 98 SE's "Windows cannot create a shortcut here."). Its Yes makes them; it makes nothing itself.`,params:Ue({paths:bn(We()).describe("Absolute paths of the items the shortcuts are to.")})},ClassicyAppFinderOfferDesktopShortcutClose:{description:"Dismiss a pending desktop-shortcut offer (its Yes or No was chosen)."},ClassicyAppFinderPropertiesOpen:{description:"Open the property sheet of items, or of an application (Explorer's Properties: its General page), or focus it when it is open.",params:Ue({paths:bn(We()).optional().describe("Absolute paths of the items the sheet describes."),appId:We().optional().describe("An application's id, for its desktop icon's sheet.")})},ClassicyAppFinderPropertiesClose:{description:"Close a property sheet (its OK, Cancel or close box).",params:Ue({key:We().describe("The sheet's key, as its open recorded it.")})},ClassicyAppFinderOpenShellFolder:{description:"Open My Computer or its Control Panel (Windows 98 SE's shell folders), or bring its window forward; only while the active package shows the startup disk as My Computer (`desktopIcons.startupDisk`).",params:Ue({folder:at(["myComputer","controlPanel"]).describe("The shell folder to open.")})},ClassicyAppFinderCloseShellFolder:{description:"Close My Computer's or Control Panel's window.",params:Ue({folder:at(["myComputer","controlPanel"]).describe("The shell folder to close.")})},ClassicyAppFinderSetHideFileExtensions:{description:'Set Finder Preferences\' "Hide file extensions for known file types" (under `layout.files.extensions` "hideRegistered").',params:Ue({hide:Gt().describe("Whether registered types' extensions are hidden.")})},ClassicyAppFinderOpenWithChoose:{description:"The Open With dialog's OK: open the waiting file in the application chosen, under the trust its open arrived with.",params:Ue({appId:We().describe("The id of the application to open it in.")})},ClassicyAppFinderOpenWithClose:{description:"Dismiss the Open With dialog without opening the file."},ClassicyAppFinderEmptyTrash:{description:"Empty the Trash. Guarded route: never reachable by untrusted dispatch."},ClassicyAppFinderOpenFile:{description:"Open a file with its default app, resolved by the entry's file type.",params:Ue({file:rr({}).describe("The ClassicyFileSystem entry being opened."),path:We().optional().describe("Filesystem path of the entry, when known.")})}},state:_M});const sZ=3e3,REe=()=>typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("selector(::-webkit-progress-value)")&&typeof CSS.registerProperty!="function",zEe=(t,e)=>{const[n,s]=g.useState(!1);return g.useEffect(()=>{const r=t.current;if(!e||!r||!REe()){s(!1);return}s(!0);const i=Kt("--progress-bar-stripe-period",void 0,r)*2;r.setAttribute(jI,"");let o=0;const a=c=>{const l=c%sZ/sZ;r.style.setProperty("--slide-var",`${l*i}px`),o=requestAnimationFrame(a)};return o=requestAnimationFrame(a),()=>{cancelAnimationFrame(o),r.style.removeProperty("--slide-var"),r.removeAttribute(jI)}},[t,e]),n},WEe=()=>b.jsx("svg",{className:"classicyProgressChasingArrowsSpinner",viewBox:"0 0 32 32",width:"16",height:"16",role:"img","aria-hidden":"true",focusable:"false",children:b.jsxs("g",{fill:"currentColor",children:[b.jsx("path",{d:"M16 3a13 13 0 0 1 12.5 9.4l-3.8 1.1A9 9 0 0 0 16 7z"}),b.jsx("path",{d:"M24.7 9.5 30 12l-2 5.6z"}),b.jsx("path",{d:"M16 29A13 13 0 0 1 3.5 19.6l3.8-1.1A9 9 0 0 0 16 25z"}),b.jsx("path",{d:"M7.3 22.5 2 20l2-5.6z"})]})}),KC=({max:t=100,value:e,indeterminate:n,chasingArrows:s,autoSwitch:r,label:i,labelPosition:o="above",labelAlign:a="left",className:c,style:l})=>{const u=n&&!(r&&e!==void 0),p=g.useRef(null),f=zEe(p,!!(u&&!s)),h=u?100:t,A=u?100:e??0,m=i?void 0:c,y=i?void 0:l;let C;return s?C=b.jsx("div",{className:Ae("classicyProgress classicyProgressChasingArrows",m),style:y,role:"progressbar","aria-busy":"true","aria-label":i,children:b.jsx(WEe,{})}):C=b.jsx("div",{className:Ae("classicyProgress",u?"classicyProgressIndeterminate":"classicyProgressDeterminate",f&&"classicyProgressSlideByScript",m),style:y,children:b.jsx("progress",{ref:p,max:h,value:A})}),i?b.jsxs("div",{className:Ae(Ns(o),Nb(a),c),style:l,children:[b.jsx(kt,{label:i}),C]}):C},rZ={version:"3.9.0",release:"Bart\xF3k"},nx=64,VEe=20.5,UEe="Off",GEe="Finder.app",{version:HEe}=rZ,YEe=rZ.release,iZ=({className:t,style:e})=>{const n=et("icons","classicy.bg")??"",s=et("systemArt","aboutLogo")??"",r=et("icons","system.macos")??"",i=et("icons","system.mac")??"",o=st(),[a,c]=g.useState(VEe);g.useEffect(()=>{const p=performance;typeof p.measureUserAgentSpecificMemory=="function"?p.measureUserAgentSpecificMemory().then(f=>c(f.bytes/(1024*1024))).catch(()=>{Ve("info","Finder","Could not measure memory usage, using default value")}):Ve("info","Finder","Memory measurement API not available, using default value")},[]);const l=nx-a,d=q8("Finder.app","ClassicyAppFinderAboutThisComputerOpen"),u=`Classicy ${HEe} (${YEe})`;return b.jsx(Qt,{id:$M,appId:GEe,className:t,style:e,hideIcon:!0,title:"About This Computer",closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,taskbarButton:!1,initialSize:[520,290],initialPosition:["center","center"],onCloseFunc:()=>o({type:"ClassicyAppFinderAboutThisComputerClose"}),children:b.jsxs("div",{className:"finderAboutThisComputer",children:[b.jsxs("div",{className:"finderAboutThisComputerHeader",children:[b.jsx("div",{className:"finderAboutThisComputerBanner",style:{backgroundSize:"cover",backgroundPosition:"bottom left",backgroundImage:`url("${n}")`,backgroundRepeat:"no-repeat"},children:b.jsx("img",{src:s,alt:"Classicy"})}),b.jsxs("div",{className:"finderAboutThisComputerVersion",children:[b.jsx("img",{src:r,alt:"Classicy"}),d?b.jsx(II,{title:d.title,content:d.content,children:b.jsx("span",{children:u})}):b.jsx("span",{children:u})]})]}),b.jsxs("div",{className:"finderAboutThisComputerInfo",children:[b.jsxs("div",{className:"finderAboutThisComputerMemoryStats",children:[b.jsxs("p",{children:[b.jsx("strong",{children:"Built-in Memory:"})," ",nx," MB"]}),b.jsxs("p",{children:[b.jsx("strong",{children:"Virtual Memory:"})," ",UEe]}),b.jsxs("p",{children:[b.jsx("strong",{children:"Largest Unused Block:"})," ",l.toFixed(1)," MB"]})]}),b.jsx("p",{className:"finderAboutThisComputerCopyright",children:"Not \u2122 & \xA9 Apple Computer, Inc. 1983\u20131999"})]}),b.jsx(Os,{className:"finderAboutThisComputerUsage",children:b.jsxs("div",{className:"finderAboutThisComputerUsageItem",children:[b.jsx(pn,{src:i,alt:"Classicy"}),b.jsx("span",{className:"finderAboutThisComputerUsageName",children:"Classicy"}),b.jsxs("span",{className:"finderAboutThisComputerUsageSize",children:[a.toFixed(1)," MB"]}),b.jsx("div",{className:"finderAboutThisComputerUsageBar",children:b.jsx(KC,{value:a,max:nx})})]})})]})})},ZEe=[{value:"name",label:"by Name"},{value:"modified",label:"by Date Modified"},{value:"created",label:"by Date Created"},{value:"size",label:"by Size"},{value:"kind",label:"by Kind"},{value:"label",label:"by Label"}],jEe=[{key:"modified",label:"Date Modified"},{key:"created",label:"Date Created"},{key:"size",label:"Size"},{key:"kind",label:"Kind"},{key:"label",label:"Label"},{key:"comments",label:"Comments"},{key:"version",label:"Version"}],oZ=(t,e)=>{const n=st(),s=e?.hide,[r,i]=g.useState("icons"),o=g.useCallback((d,u,p)=>{n({type:"ClassicyAppFinderSetStandardViewOption",view:d,option:u,value:p})},[n]),a=t.icons,c=t.list;return{title:"Views",children:g.useMemo(()=>b.jsxs("div",{className:"finderPreferencesViews",children:[b.jsxs(ks,{label:"View Options",children:[b.jsx(on,{id:"finder_prefs_view_type",label:"View type:",labelPosition:"left",selected:r,options:[{value:"icons",label:"Icons"},{value:"list",label:"List"}],onChangeFunc:d=>i(d.target.value)}),r==="icons"?b.jsxs("div",{className:"finderPreferencesPane",children:[b.jsx("p",{className:"finderPreferencesGroupHeading",children:"Icon Arrangement:"}),b.jsx(il,{name:"finder_prefs_icon_arrangement",onClickFunc:d=>o("icons","arrangement",d.split("__").pop()),inputs:[{id:"finder_prefs_icon_arrangement__none",label:"None",checked:a.arrangement==="none"},{id:"finder_prefs_icon_arrangement__grid",label:"Always snap to grid",checked:a.arrangement==="grid"},{id:"finder_prefs_icon_arrangement__sorted",label:"Keep arranged:",checked:a.arrangement==="sorted"}]}),b.jsx(on,{id:"finder_prefs_icon_sort",disabled:a.arrangement!=="sorted",selected:a.keepArrangedBy,options:ZEe,onChangeFunc:d=>o("icons","keepArrangedBy",d.target.value)}),b.jsx(il,{name:"finder_prefs_icon_size",onClickFunc:d=>o("icons","iconSize",d.split("__").pop()),inputs:[{id:"finder_prefs_icon_size__small",label:"Small icons",checked:a.iconSize==="small"},{id:"finder_prefs_icon_size__large",label:"Large icons",checked:a.iconSize!=="small"}]})]}):b.jsxs("div",{className:"finderPreferencesPane",children:[b.jsx(qn,{id:"finder_prefs_relative_date",label:"Use relative date",checked:c.useRelativeDate,onClickFunc:d=>o("list","useRelativeDate",d)}),b.jsx(qn,{id:"finder_prefs_folder_sizes",label:"Calculate folder sizes",checked:c.calculateFolderSizes,onClickFunc:d=>o("list","calculateFolderSizes",d)}),b.jsx("p",{className:"finderPreferencesGroupHeading",children:"Show Columns:"}),jEe.map(({key:d,label:u})=>b.jsx(qn,{id:`finder_prefs_column_${d}`,label:u,checked:c.columns[d]===!0,onClickFunc:p=>o("list",`columns.${d}`,p)},d)),b.jsx(il,{name:"finder_prefs_list_icon_size",onClickFunc:d=>o("list","iconSize",d.split("__").pop()),inputs:[{id:"finder_prefs_list_icon_size__small",label:"Small icons",checked:c.iconSize==="small"},{id:"finder_prefs_list_icon_size__medium",label:"Medium icons",checked:c.iconSize==="medium"},{id:"finder_prefs_list_icon_size__large",label:"Large icons",checked:c.iconSize==="large"}]})]})]}),s!==void 0&&b.jsx(qn,{id:"finder_prefs_hide_extensions",label:"Hide file extensions for known file types",checked:s,onClickFunc:d=>n({type:"ClassicyAppFinderSetHideFileExtensions",hide:d})})]}),[r,a,c,o,s,n])}},sx="Finder.app",aZ=({className:t,style:e})=>{const n=et("icons","system.help")??"",s=st(),r=ye(u=>u.System.Manager.Applications.apps[sx]?.data),i=g.useMemo(()=>ZC(r??{}),[r]),o=gt().files?.extensions==="hideRegistered",a=r?.hideFileExtensions!==!1,c=oZ(i,o?{hide:a}:void 0),l=g.useMemo(()=>[c],[c]),d=HT(sx,"preferences");return b.jsx(Qt,{id:qM,appId:sx,className:t,style:e,title:"Preferences",closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,modal:!1,taskbarButton:!1,initialSize:[470,0],initialPosition:["center","center"],onCloseFunc:()=>s({type:"ClassicyAppFinderPreferencesClose"}),children:b.jsxs("div",{className:"finderPreferences",children:[b.jsx(au,{tabs:l,...d}),b.jsxs("div",{className:"finderPreferencesFooter",children:[b.jsx(pn,{className:"finderPreferencesHelpIcon",src:n,alt:"Help"}),b.jsx("p",{className:"finderPreferencesNote",children:"Changes are applied to all folders that are set to Standard views. Other folders are not affected."})]})]})})},rx="My Computer",ix=(t,e,n)=>n>0?`${n} object(s) selected`:e>0?`${t} object(s) (plus ${e} hidden)`:`${t} object(s)`,cZ=t=>t===void 0||t<0?"":Xy(t),lZ=(t,e,n)=>(n.length>0?[...n]:Object.keys(t.resolve(e)??{}).filter(r=>!r.startsWith("_")).map(r=>`${e}${t.separator}${r}`)).filter(r=>{const i=t.resolve(r);return i!==void 0&&i._type!==xe.Directory&&i._type!==xe.Drive&&i._invisible!==!0}),uZ=(t,e,n,s)=>{const[r,i]=g.useState(void 0),o=n.join(`
80
80
  `);return g.useEffect(()=>{if(!s)return;let a=!1;i(void 0);const c=lZ(t,e,n);return Promise.all(c.map(l=>t.size(l))).then(l=>{a||i(l.reduce((d,u)=>d+Math.max(0,u),0))}),()=>{a=!0}},[t,e,o,s]),s?r:void 0},dZ=(t,e)=>t.includes(e)?t.filter(n=>n!==e):[...t,e],pZ=(t,e,n)=>{const s=t.indexOf(e),r=t.indexOf(n);return s<0||r<0?[n]:t.slice(Math.min(s,r),Math.max(s,r)+1)},ox=(t,e,n)=>{const s=t.find(l=>l.path===e),r=t.find(l=>l.path===n);if(!s||!r)return[n];const i=Math.min(s.left,r.left),o=Math.min(s.top,r.top),a=Math.max(s.right,r.right),c=Math.max(s.bottom,r.bottom);return t.filter(l=>l.left>=i&&l.left<a&&l.top>=o&&l.top<c).map(l=>l.path)},ax=(t,e,n,s,{shiftKey:r,metaKey:i,ctrlKey:o},a)=>{if(t==="mac")return r||i||o?{selected:dZ(n.selected,s),anchor:s}:{selected:[s],anchor:s};const c=i||o;if(r&&n.anchor&&e.includes(n.anchor)){const l=n.anchor,d=a?ox(a,l,s):pZ(e,l,s);return{selected:c?Zd(n.selected,d,n.selected.includes(l)):d,anchor:l}}return c?{selected:dZ(n.selected,s),anchor:s}:{selected:[s],anchor:s}},cx=(t,e,n)=>C0(t.map(s=>({appId:s.path,appName:s.name,location:s.location})),e,n),fZ=(t,e,n,s)=>{const r=t.find(f=>f.path===e);if(!r)return null;const[i,o]=r.location,a=t.filter(f=>n?f.location[1]<o:f.location[1]>o);if(a.length===0)return null;const c=a.filter(f=>Math.abs(f.location[1]-o)<=Math.max(s,0)),l=c.length>0?c:a,d=f=>Math.abs(f.location[1]-o),u=c.length>0?Math.max(...l.map(d)):Math.min(...l.map(d)),p=l.filter(f=>d(f)===u);return p.sort((f,h)=>Math.abs(f.location[0]-i)-Math.abs(h.location[0]-i)),p[0]?.path??null},lx=(t,e,n,s)=>{if(!n)return null;if(t==="mac")return $E(e.map(d=>({appId:d.path,appName:d.name})),n);const r=n.toLowerCase(),i=(d,u)=>d.name.toLowerCase().startsWith(u),o=Math.max(0,e.findIndex(d=>d.path===s)),a=[...r].every(d=>d===r[0]),c=a&&s!==void 0?o+1:o,l=a?r[0]:r;for(let d=0;d<e.length;d++){const u=e[(c+d)%e.length];if(i(u,l))return u.path}return null},ux=1e3,hZ=500,dx=(t,e,n,{shiftKey:s,metaKey:r,ctrlKey:i})=>{const o=r||i;if(!s&&!o)return[...n];if(t==="windows"&&o){const a=new Set(n),c=new Set(e);return[...e.filter(l=>!a.has(l)),...n.filter(l=>!c.has(l))]}return[...new Set([...e,...n])]},AZ=t=>t.fileBrowser?.iconSelection==="view",px=t=>t.fileBrowser?.regionSelect===!0,gZ=(t,e)=>t.left<e.right&&e.left<t.right&&t.top<e.bottom&&e.top<t.bottom;function fx(t){return{onStart:()=>t("dragStart",{kind:"file"}),onEnd:({dropped:e,canceled:n,lost:s})=>t("dragEnd",{kind:"file",dropped:e,canceled:n,lost:s})}}function hx(){const t=g.useRef(null);return g.useLayoutEffect(()=>()=>{t.current?.(),t.current=null},[]),g.useCallback(e=>{t.current=e},[])}const mZ=Object.freeze({move:{title:"Move Here",accessKey:"M"},copy:{title:"Copy Here",accessKey:"C"},link:{title:"Create Shortcut(s) Here",accessKey:"S"}}),yZ="Cancel",KEe=(t,e)=>!!t.resolve(e)&&!hl(t,e),QC=(t,e,n)=>{const s=wM(n);return t?s.filter(r=>r==="move"||r==="copy"&&e.some(i=>VM(t,i))||r==="link"&&e.some(i=>KEe(t,i))):s},bZ=(t,e,n,s)=>{const r=["move","copy","link"].filter(o=>t.includes(o)),i=r.includes(e)?e:r[0];return[...r.map(o=>{const{title:a,accessKey:c}=mZ[o],l=n(c);return{id:`classicy_file_drop_${o}`,title:a,...l!==void 0?{accessKey:l}:{},...o===i?{isDefault:!0}:{},onClickFunc:()=>s(o)}}),{id:"spacer"},{id:"classicy_file_drop_cancel",title:yZ,onClickFunc:()=>{}}]},JC=()=>{const t=gt().transfer?.secondaryButton==="menu",{showContextMenu:e,hideContextMenu:n}=ar(),s=tn(),r=g.useCallback(o=>o.button===0||o.button===2&&t,[t]),i=g.useCallback((o,{effects:a,onStart:c,transferAt:l})=>o.button!==2||!t?{effects:a,...c?{onStart:c}:{}}:{effects:a,button:2,onStart:()=>{n(),c?.()},onMenu:(d,u,p,f)=>{const h=l(d,u,p);e(bZ(a(d),f,s,h),u,{helpItem:!1})}},[t,e,n,s]);return g.useMemo(()=>({secondaryDrags:t,startsDrag:r,dragOptions:i}),[t,r,i])},Ax=({name:t,className:e,onCommit:n,onCancel:s})=>{const r=g.useRef(null),i=g.useRef(!1);g.useLayoutEffect(()=>{const c=r.current;c&&(c.focus({preventScroll:!0}),c.select())},[]);const o=c=>{i.current||(i.current=!0,c?n(r.current?.value??t):s())},a=c=>c.stopPropagation();return b.jsx("input",{ref:r,className:e,type:"text",defaultValue:t,"aria-label":"Name",spellCheck:!1,onMouseDown:a,onMouseUp:a,onClick:a,onDoubleClick:a,onContextMenu:a,onKeyDown:c=>{c.stopPropagation(),c.key==="Enter"?(c.preventDefault(),o(!0)):c.key==="Escape"&&(c.preventDefault(),o(!1))},onBlur:()=>o(!0)})},XC=(t,e,n=[0,0])=>[n[0]+Math.round((t[0]-n[0])/e[0])*e[0],n[1]+Math.round((t[1]-n[1])/e[1])*e[1]],gx=({appId:t,name:e,icon:n,label:s,labelPosition:r="below",initialPosition:i=[0,0],holder:o,onClickFunc:a,invisible:c=!1,cut:l=!1,size:d,snapTo:u,snapOrigin:p,positionLocked:f=!1,dropFolderPath:h,filePath:A,onFileDrag:m,fileDropEffects:y,fileDragParts:C,moveBy:v,selected:S,onSelectClick:w,onSelectPress:k,listOption:I=!1,tabStop:T=!0,renaming:D=!1,renameText:O,onRenameCommit:x,onRenameCancel:B,alias:F=!1,className:z,style:V})=>{const[P,W]=g.useState(i),[K,L]=g.useState(!1),[M,G]=g.useState(!1),Y=S!==void 0,N=Y?S:M,J=g.useRef(v?.id);g.useEffect(()=>{!v||J.current===v.id||(J.current=v.id,!f&&W(_e=>{const it=[_e[0]+v.by[0],_e[1]+v.by[1]];return u?XC(it,u,p):it}))},[v?.id]);const te=g.useRef(!1),H=gt(),X=Xl(H),Z=g.useRef({point:[0,0],position:[0,0]}),oe=g.useRef(null),he=g.useContext(Ia)===!1,ee=xn("Icon",{dragging:K,selected:N,inactive:he},oe),ce=g.useRef(!1),re=hx(),le=JC(),Ce=`${t}.shortcut`,{track:De}=Bs(),Te={type:"ClassicyIcon",appId:t,name:e,icon:n,label:s},q=()=>{De("focus",Te),ee.emit("select",{selected:!N}),G(!N)},Q=g.useRef(N);g.useEffect(()=>{!Y||Q.current===N||(Q.current=N,ee.emit("select",{selected:N}))},[N,Y]);const se=_e=>{if(!Y){q();return}De("focus",Te),w?.(_e)},ae=_e=>{De("focus",Te),G(_e)},ne=()=>{De("blur",Te),G(!1)},ue=()=>{D||a&&(ee.emit("open",mt()),Y||ne(),a())},ke=_e=>{u&&te.current&&W(it=>XC(it,u,p)),te.current=!1,L(!1),ce.current&&(ce.current=!1,ee.emit("dragEnd",{lost:_e}))};ql(K,()=>ke(!0)),yb(K,()=>{te.current&&W(Z.current.position),te.current=!1,L(!1),ce.current&&(ce.current=!1,ee.emit("dragEnd",{lost:!1,canceled:!0}))});const fe=_e=>{if(!D){if(Y&&k?.(_e),m){if(!le.startsDrag(_e))return;const it=oe.current,Bt=o?.current?.getBoundingClientRect(),Et=()=>[{image:it?.querySelector("img"),label:it?.querySelector("p")}],yn=(Re,Ee,Pe)=>{const Je=o?.current?.getBoundingClientRect(),bt=Bt&&Je?[Je.left-Bt.left,Je.top-Bt.top]:[0,0],Fe=[Ee[0]-_e.clientX-bt[0],Ee[1]-_e.clientY-bt[1]];return dt=>{if(m(Re,Ee,Pe,Fe,dt)||f)return;const St=[P[0]+Fe[0],P[1]+Fe[1]];W(u?XC(St,u,p):St),ae(!0)}},ln=fx(ee.emit),Tn=XA({start:{clientX:_e.clientX,clientY:_e.clientY,ctrlKey:_e.ctrlKey,shiftKey:_e.shiftKey},get parts(){return C?C():Et()},source:it,...ln,...le.dragOptions(_e,{effects:Re=>y?.(Re)??wM(Re.destination),onStart:ln.onStart,transferAt:yn}),onDrop:(Re,Ee,Pe,Je)=>yn(Re,Ee,Pe)(Je)});re(Tn);return}f||Oo(_e,H)&&(te.current=!1,Z.current={point:[_e.clientX,_e.clientY],position:P},L(!0),ce.current=!0,ee.emit("dragStart"))}},j=_e=>{if(o?.current&&K&&oe.current){const it=uk(H),Bt=Z.current;if(!te.current&&!dk(Bt.point,[_e.clientX,_e.clientY],it))return;if(te.current=!0,ae(!0),it>0){W([Bt.position[0]+_e.clientX-Bt.point[0],Bt.position[1]+_e.clientY-Bt.point[1]]);return}W([_e.clientX-o.current.getBoundingClientRect().left-oe.current.getBoundingClientRect().width/2,_e.clientY-o.current.getBoundingClientRect().top-oe.current.getBoundingClientRect().height/2])}},de=g.useId(),R=D?b.jsx(Ax,{className:"classicyIconRename",name:O??e,onCommit:_e=>x?.(_e),onCancel:()=>B?.()}):b.jsx("p",{className:Ae(c?"classicyIconInvisible":""),children:s||e}),ge=ye(_e=>_e.System?.Manager?.Appearance?.activeTheme?.desktop?.iconSize),{image:pe,plain:Ie,drawsSelectedImage:Ge}=MI(n,d??ge??Number.POSITIVE_INFINITY,N),He=b.jsx("div",{className:Ae("classicyIconMaskOuter",c?"classicyIconInvisible":"",Ge&&"classicyIconSelectedImage"),style:{"--classicy-icon-mask":`url("${Ie}")`},children:b.jsx("div",{className:"classicyIconMask",children:b.jsx("img",{src:pe,alt:e})})}),rt=et("systemArt","aliasBadge")??"",At=F&&H.icon?.aliasBadge==="everywhere"?b.jsxs("div",{className:"classicyIconImage",children:[He,b.jsx("div",{className:"classicyIconMaskOuter classicyIconAliasBadge",style:{"--classicy-icon-mask":`url("${rt}")`},children:b.jsx("div",{className:"classicyIconMask",children:b.jsx("img",{src:rt,alt:"","aria-hidden":"true"})})})]}):He;return b.jsxs("div",{...ee.attrs,...I?{role:"option","aria-selected":N}:{role:"button"},tabIndex:T?0:-1,ref:oe,id:`${Ce}-${de}`,draggable:!1,...h===void 0?{}:{[Ra]:h},...A===void 0?{}:{[Bi]:A},className:Ae("classicyIcon",ee.className,Ns(r),l&&"classicyFileCut",z),style:{...uA(ee.style),left:`${P[0]}px`,top:`${P[1]}px`,...d===void 0?{}:{"--desktop-icon-size":`${d}px`},...uA(V)},onClick:se,onKeyDown:_e=>{if(!D){if(_e.key===" "&&X){if(Y)return;_e.preventDefault(),_e.ctrlKey||_e.metaKey?q():N||(ee.emit("select",{selected:!0}),ae(!0));return}(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),ue())}},onMouseDown:fe,onMouseMove:j,onMouseUp:()=>ke(!1),onDoubleClick:ue,children:[r==="above"?R:At,r==="above"?At:R]})},QEe=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),CZ=({appId:t,folder:e,title:n,icon:s,items:r,idx:i,openItem:o,itemContextMenu:a,close:c,onClosed:l,windowsCommands:d,helpItems:u})=>{const p=Th(e),h=gt().fileBrowser?.keys==="windows"?"windows":"mac",A=tn(),m=dr(),{showContextMenu:y}=ar(),C=ws(),v=ye(H=>H.System.Manager.Appearance.activeTheme),S=g.useRef(null),[w,k]=g.useState({selected:[]}),[I,T]=g.useState([]),D=g.useRef({buffer:"",at:0}),O=r.map(H=>H.id).join("\0");g.useLayoutEffect(()=>{const H=S.current;if(!H)return;const X=H.getBoundingClientRect(),Z=QA(v);T(r.map((oe,he)=>hM(v,he,r.length,[X.width,X.height],void 0,Z)))},[O,v]);const x=new Set(r.map(H=>H.id)),B=w.selected.filter(H=>x.has(H)),F=r.map(H=>H.id),z=r.map((H,X)=>({path:H.id,name:H.name,location:I[X]??[0,0]})),V=H=>{const X=F.indexOf(H);S.current?.querySelectorAll(".classicyIcon")[X]?.focus({preventScroll:!0})},P=H=>{k({selected:[H],anchor:H}),V(H)},W=()=>{for(const H of r)B.includes(H.id)&&o(H)},K=H=>{if(H.defaultPrevented||F.length===0)return;const X=H.metaKey||H.ctrlKey||H.altKey,Z=w.anchor??B[0];if(QEe.has(H.key)&&!X){H.preventDefault();const oe=Z?cx(z,Z,H.key):F[0];oe&&P(oe);return}if(h==="windows"&&!X&&(H.key==="Home"||H.key==="End")){H.preventDefault(),P(H.key==="Home"?F[0]:F[F.length-1]);return}if(H.key.length===1&&H.key!==" "&&!X){const oe=Date.now(),he=D.current,ee=oe-he.at<ux?he.buffer+H.key:H.key;D.current={buffer:ee,at:oe};const ce=lx(h,z,ee,Z);ce&&(H.preventDefault(),P(ce))}},L=H=>{H.target===H.currentTarget&&H.button===0&&k({selected:[]})},M=H=>{if(H.defaultPrevented)return;const X=H.target.closest(".classicyIcon");if(!X||!S.current?.contains(X))return;const Z=Array.from(S.current.querySelectorAll(".classicyIcon")).indexOf(X),oe=r[Z];if(!oe)return;H.preventDefault(),H.stopPropagation(),B.includes(oe.id)||k({selected:[oe.id],anchor:oe.id});const he=a(oe);he.length>0&&y(he,[H.clientX,H.clientY])},G=B.length===1?r.find(H=>H.id===B[0]):void 0,N=(G?.kind==="controlPanel"&&G.appId?rs(C,G.appId,{name:G.name,icon:G.icon,description:F0(G.appId)?.description}).description:void 0)??ix(r.length,0,B.length),J=d?b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"classicyWindowStatusPart",children:N}),b.jsx("span",{className:"classicyWindowStatusPart"}),b.jsx("span",{className:"classicyWindowStatusPart",children:rx})]}):b.jsx("span",{children:`${r.length} item${r.length===1?"":"s"}`}),te=[{id:`${t}_${p}_file`,title:"File",accessKey:A("f"),menuChildren:[{id:`${t}_${p}_file_open`,title:"Open",...A("o")!==void 0?{accessKey:A("o")}:{},keyboardShortcut:m("finder_file_open","\u2318O"),disabled:B.length===0,onClickFunc:W},{id:"spacer"},{id:`${t}_${p}_file_close`,title:"Close",...A("c")!==void 0?{accessKey:A("c")}:{},onClickFunc:c}]},{id:`${t}_${p}_edit`,title:"Edit",accessKey:A("e"),menuChildren:[{id:`${t}_${p}_edit_select_all`,title:"Select All",accessKey:A("a"),keyboardShortcut:m("finder_edit_select_all","\u2318A"),onClickFunc:()=>k({selected:[...F],anchor:F[0]})}]},{id:`${t}_${p}_view`,title:"View",accessKey:A("v"),menuChildren:[{id:`${t}_${p}_view_large_icons`,title:"Large Icons",...A("g")!==void 0?{accessKey:A("g")}:{},checked:!0,mark:"bullet"}]},{id:`${t}_${p}_help`,title:"Help",accessKey:A("h"),menuChildren:u}];return b.jsx(Qt,{id:p,appId:t,title:n,icon:s,defaultWindow:!1,hidden:!1,initialSize:[425,300],initialPosition:[50+i*50,50+i*50],header:J,headerVariant:d?"status":void 0,onCloseFunc:l,appMenu:te,children:b.jsx("div",{ref:S,className:Ae("classicyFileBrowserFill","classicyFinderShellFolder"),tabIndex:-1,onMouseDown:L,onKeyDown:K,onContextMenu:M,children:r.map((H,X)=>b.jsx(gx,{appId:`${t}.${p}`,name:H.name,icon:H.icon,holder:S,initialPosition:I[X]??[0,0],style:I[X]?{left:I[X][0],top:I[X][1]}:void 0,positionLocked:!0,dropFolderPath:H.kind==="drive"?H.path:void 0,selected:B.includes(H.id),onSelectClick:Z=>{k(ax(h,F,w,H.id,Z))},onClickFunc:()=>o(H)},H.id))})})};function vZ(t,e){const[n,s]=g.useState(void 0);return g.useEffect(()=>{let r=!1;s(void 0);const i=e.resolve(t);return i&&e.calculateSizeDir(i).then(o=>{r||s(o)}),()=>{r=!0}},[t,e]),n}let Kp=null;const mx=new Set,wZ=()=>{for(const t of mx)t()},qC=t=>{Kp!==t&&(Kp=t,wZ())},SZ=t=>{Kp!==null&&(t!==void 0&&Kp!==t||(Kp=null,wZ()))},JEe=t=>(mx.add(t),()=>{mx.delete(t)}),XEe=t=>g.useSyncExternalStore(JEe,()=>Kp===t,()=>!1),no={emptyTrash:"empty_trash",resetPram:"reset_pram",shutDown:"shut_down",run:"run",logOff:"log_off",taskbarDrop:"taskbar_drop"},_C=(t,e,n=qA())=>[{id:`${e}_special_empty_trash`,title:`Empty ${n}`,confirms:!0,onClickFunc:()=>{t({type:"ClassicyDesktopShowSystemDialog",dialog:"emptyTrash"})}},{id:"spacer"},{id:`${e}_special_reset_pram`,title:"Reset PRAM",confirms:!0,onClickFunc:()=>{t({type:"ClassicyDesktopShowSystemDialog",dialog:"resetPram"})}}],EZ=(t,e)=>t===1&&e!==void 0?e.folder?{title:"Confirm Folder Delete",message:`Are you sure you want to remove the folder '${e.name}' and all its contents?`}:{title:"Confirm File Delete",message:`Are you sure you want to delete '${e.name}'?`}:{title:"Confirm Multiple File Delete",message:`Are you sure you want to delete these ${t} items?`},kZ=({itemCount:t,onEmpty:e,onClose:n,className:s,style:r})=>{const i=Hp(),o=gt().finder?.commands==="windows",a=Di();if(t===0)return b.jsx(Ps,{id:no.emptyTrash,appId:"Finder.app",alertType:"note",label:`The ${i} is empty.`,buttons:[{id:"ok",label:"OK",role:"default"}],onClose:n,className:s,style:r});if(o){const l=t===1?a():void 0,d=l?Al(l)[0]:void 0,u=d!==void 0?l?.resolve(d):void 0,p=l&&d!==void 0&&u?{name:u._trashedName??d.split(l.separator).pop()??d,folder:u._type===xe.Directory}:void 0,{title:f,message:h}=EZ(t,p);return b.jsx(Ps,{id:no.emptyTrash,appId:"Finder.app",alertType:"caution",movable:!0,title:f,label:h,defaultButtonId:"yes",buttons:[{id:"yes",label:"Yes",role:"default",onClick:e},{id:"no",label:"No",role:"cancel"}],onClose:n,className:s,style:r})}const c=t===1?"1 item":`${t} items`;return b.jsx(Ps,{id:no.emptyTrash,appId:"Finder.app",alertType:"caution",label:`The ${i} contains ${c}. Are you sure you want to permanently remove ${t===1?"it":"these items"}?`,message:"You can\u2019t undo this action.",defaultButtonId:"ok",buttons:[{id:"cancel",label:"Cancel",role:"cancel"},{id:"ok",label:"OK",role:"default",onClick:e}],onClose:n,className:s,style:r})},qEe={small:.5,medium:1,large:1},_Ee={small:.25,medium:.375,large:.667},IZ=(t,e)=>Math.round(t*qEe[e]),TZ={small:"--file-browser-list-small-icon-size",medium:"--file-browser-list-medium-icon-size",large:"--file-browser-list-large-icon-size"},DZ=(t,e,n)=>n!==void 0&&Number.isFinite(n)&&n>0?n:Math.round(t*_Ee[e]),$C=(t,e)=>t.name.localeCompare(e.name,void 0,{sensitivity:"base"}),MZ=t=>(e,n)=>{if(t==="name")return $C(e,n);const s=a=>{switch(t){case"modified":return a.modifiedOn?.getTime();case"created":return a.createdOn?.getTime();case"size":return a.size;case"kind":return a.kind;case"label":return a.label}},r=s(e),i=s(n);if(r===void 0&&i===void 0)return $C(e,n);if(r===void 0)return 1;if(i===void 0)return-1;if(typeof r=="string"&&typeof i=="string"){const a=r.localeCompare(i,void 0,{sensitivity:"base"});return a!==0?a:$C(e,n)}const o=Number(r)-Number(i);return o!==0?o:$C(e,n)},$Ee=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],eke=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],yx=t=>{const e=t.getHours(),n=e>=12?"PM":"AM";return`${e%12===0?12:e%12}:${String(t.getMinutes()).padStart(2,"0")} ${n}`},xZ=t=>`${$Ee[t.getDay()]}, ${eke[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`,BZ=(t,e)=>t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate(),bx=(t,e,n)=>{if(!t)return"\u2014";if(!n)return`${xZ(t)}, ${yx(t)}`;if(BZ(t,e))return`Today, ${yx(t)}`;const s=new Date(e.getFullYear(),e.getMonth(),e.getDate()-1);return BZ(t,s)?`Yesterday, ${yx(t)}`:xZ(t)},Wa=t=>{if(t instanceof Date)return Number.isNaN(t.getTime())?void 0:t;if(typeof t=="string"||typeof t=="number"){const e=new Date(t);return Number.isNaN(e.getTime())?void 0:e}},OZ=2,tke=(t,e,n,s,r)=>{const i=(o,a,c,l)=>{const d=pA(l);return o<a+r&&!d.start?-r:o>=c-r&&!d.end?r:0};return{dx:i(t,n.left,n.right,s.x),dy:i(e,n.top,n.bottom,s.y)}};function FZ(t){const{holder:e}=t,n=e.getBoundingClientRect(),s=[t.start.clientX-n.left,t.start.clientY-n.top];let r=[t.start.clientX,t.start.clientY],i=!1,o=!1;const a=()=>{const y=e.getBoundingClientRect(),C=[r[0]-y.left,r[1]-y.top];if(!i&&Math.abs(C[0]-s[0])<OZ&&Math.abs(C[1]-s[1])<OZ)return;i=!0;const v={left:Math.min(s[0],C[0]),top:Math.min(s[1],C[1]),width:Math.abs(C[0]-s[0]),height:Math.abs(C[1]-s[1])};t.onBox(v);const S={left:v.left+y.left,top:v.top+y.top,right:v.left+v.width+y.left,bottom:v.top+v.height+y.top},w=[];for(const k of t.items()){const I=k.getAttribute(Bi);I&&gZ(S,k.getBoundingClientRect())&&w.push(I)}t.onTouched(w)};let c=null;const l=()=>{c!==null&&clearInterval(c),c=null},d=()=>{const y=Ca(e);if(!y)return null;const{element:C,entry:v}=y,S=tke(r[0],r[1],C.getBoundingClientRect(),{x:{total:C.scrollWidth,visible:C.clientWidth,position:C.scrollLeft},y:{total:C.scrollHeight,visible:C.clientHeight,position:C.scrollTop}},v.lineStep());return S.dx||S.dy?{entry:v,...S}:null},u=()=>{if(!(!t.autoScroll||!i)){if(!d()){l();return}c===null&&(c=setInterval(()=>{const y=d();if(!y){l();return}y.entry.scrollBy(y.dx,y.dy),a()},fb))}},p=y=>{r=[y.clientX,y.clientY],a(),u()};let f=()=>{},h=()=>{};const A=()=>o?!1:(o=!0,l(),f(),h(),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),t.onBox(null),!0),m=()=>{A()&&t.onEnd?.()};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",m),f=ls(m),h=lp(()=>{A()&&(t.onCancel?.(),t.onEnd?.())}),()=>{A()}}const nke=new Set(["app_shortcut","shortcut","file_shortcut"]),ev=t=>nke.has(t?.toLowerCase()),ske=()=>g.useSyncExternalStore(Do,yM,yM),tv=t=>{const e=et("systemArt","trashFull")??"",n=et("systemArt","trashEmpty")??"";return t?e:n},NZ=(t,e,n)=>n===an&&t.pathArray(e)?.length===0,rke=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),PZ={shiftKey:!1,metaKey:!1,ctrlKey:!1},nv=t=>[Number.parseFloat(t.style.left)||0,Number.parseFloat(t.style.top)||0],Cx=g.memo(({fs:t,path:e,appId:n,dirOnClickFunc:s,fileOnClickFunc:r,openItemsFunc:i,onSelectionChange:o,holderRef:a,hideFilesCreatedAfter:c=null,showInvisible:l=!0,iconViewOptions:d,onMoveItems:u,onRenameItem:p,selectionApiRef:f,viewCommandsRef:h,className:A,style:m})=>{const y=Eu(),C=BC(t.storageKey),v=ye(ve=>ve.System.Manager.Appearance.activeTheme),S=gt(),w=S.fileBrowser?.keys??"mac",k=Xd(S),I=Jd(S),T=AZ(S),D=px(S),O=Xl(S),x=m0(S),B=_l(S),F=B&&!!i,z=S.fileList?.foldersFirst===!0,V=tv(Al(t).length>0),P=g.useRef(null),W=a??P,[K,L]=g.useState([]),M=g.useRef(new Map),[G,Y]=g.useState(void 0),[N,J]=g.useState(null),te=g.useRef(0),H=g.useRef(0),X=g.useRef(null),Z=g.useRef(null),oe=d?.arrangement,he=d?.keepArrangedBy,ee=d?.iconSize;g.useLayoutEffect(()=>{if(!W.current)return;const ve=(Yt,En,jr)=>{if(Yt._type==="directory")return s?s(`${En}:${jr}`):void 0;if(r)return r(`${En}:${jr}`)},Be=[W.current.getBoundingClientRect().width,W.current.getBoundingClientRect().height],U=t.filterByType(e,void 0,l,c),ie=Object.entries(U),Se=G??(oe==="sorted"?he:void 0),me=Se?[...ie].sort((Yt,En)=>MZ(Se)({name:Yt[0],modifiedOn:Wa(Yt[1]._modifiedOn),createdOn:Wa(Yt[1]._createdOn),size:Yt[1]._size,kind:Yt[1]._type,label:Yt[1]._label},{name:En[0],modifiedOn:Wa(En[1]._modifiedOn),createdOn:Wa(En[1]._createdOn),size:En[1]._size,kind:En[1]._type,label:En[1]._label})):ie,ze=Yt=>Yt._type===xe.Directory||Yt._type===xe.Drive,Ke=z?[...me.filter(([,Yt])=>ze(Yt)),...me.filter(([,Yt])=>!ze(Yt))]:me;Z.current?.theme!==v&&(Z.current={theme:v,metrics:QA(v)});const Xe=Z.current.metrics,ut=ee?IZ(Xe.size,ee):void 0,jt=fM(v,ut,Xe),_t=oe==="grid"?jt.pitch:void 0,Zn=oe==="sorted",zn=(Yt,En)=>hM(v,Yt,En,Be,ut,Xe);if(X.current={cells:Yt=>Array.from({length:Yt},(En,jr)=>zn(jr,Yt)),pitch:jt.pitch,origin:jt.origin},N&&N.id!==te.current)if(te.current=N.id,H.current=N.id,N.kind==="arrange")M.current.clear();else{const Yt=new Map;for(const Kr of W.current.querySelectorAll(".classicyIcon[data-classicy-file-path]")){const oa=Kr.getAttribute("data-classicy-file-path");oa&&Yt.set(oa,Kr)}const En=Ke.map(([Kr],oa)=>{const Qf=`${e}${t.separator}${Kr}`,yc=Yt.get(Qf);return yc?nv(yc):M.current.get(Qf)??zn(oa,Ke.length)}),jr=FH(En,jt.pitch,jt.origin);Ke.forEach(([Kr],oa)=>{M.current.set(`${e}${t.separator}${Kr}`,jr[oa])})}const br=H.current,Vt=Ke.map(([Yt,En],jr)=>{const Kr=`${e}${t.separator}${Yt}`;return{mountKey:br>0?`${Yt}\0${br}`:Yt,filePath:Kr,isFolder:ze(En),fileType:En._type,dropFolderPath:En._type==="directory"?Kr:void 0,appId:n,name:Yt,invisible:En._invisible,alias:ev(En._type),icon:NZ(t,e,Yt)&&V||En._icon||Tr(En._type),onClickFunc:()=>ve(En,e,Yt),holder:W,initialPosition:M.current.get(Kr)??zn(jr,Ke.length),size:ut,snapTo:_t,snapOrigin:jt.origin,positionLocked:Zn}});L(Vt)},[n,e,t,s,r,v,W.current,W,c,l,oe,he,ee,V,z,G,N]);const[ce,re]=g.useState({selected:[]}),le=g.useRef(ce);le.current=ce;const Ce=g.useRef(void 0),[De,Te]=g.useState(),q=ve=>{Ce.current=ve,x&&Te(ve)},[Q,se]=g.useState(null),[ae,ne]=g.useState(null),[ue,ke]=g.useState(null),fe=g.useRef(K);fe.current=K,g.useEffect(()=>{const ve=new Set(K.map(Be=>Be.filePath));re(Be=>{const U=Be.selected.filter(ie=>ve.has(ie));return U.length===Be.selected.length&&(Be.anchor===void 0||ve.has(Be.anchor))?Be:{selected:U,anchor:Be.anchor&&ve.has(Be.anchor)?Be.anchor:void 0}}),Ce.current&&!ve.has(Ce.current)&&(Ce.current=void 0);for(const Be of M.current.keys())!ve.has(Be)&&!ge.current.has(Be)&&M.current.delete(Be),ve.has(Be)&&ge.current.delete(Be);pe()},[K]);const j=()=>{const ve=new Set(le.current.selected);return fe.current.map(Be=>Be.filePath).filter(Be=>ve.has(Be))},de=g.useRef(o);de.current=o,g.useLayoutEffect(()=>{de.current?.(j())},[ce,K]),g.useImperativeHandle(f,()=>({selectAll:()=>re({selected:fe.current.map(ve=>ve.filePath),anchor:fe.current[0]?.filePath})}),[]);const R=g.useRef({}),ge=g.useRef(new Set),pe=()=>{const ve=new Set(fe.current.map(U=>U.filePath)),Be=R.current;if(Be.select?.every(U=>ve.has(U))){const U=Be.select;Be.select=void 0,re({selected:U,anchor:U[0]}),q(U[0])}if(Be.rename!==void 0&&ve.has(Be.rename)){const U=Be.rename;Be.rename=void 0,it(U)&&(At(),se(U))}};g.useImperativeHandle(h,()=>({select:ve=>{R.current.select=[...ve],pe()},rename:ve=>{R.current.rename=ve,pe()},place:(ve,Be)=>{const U=W.current,ie=X.current;if(!U||!ie||oe==="sorted")return;let Se;if(Be){const me=U.getBoundingClientRect();Se=[Math.round(Be[0]-me.left),Math.round(Be[1]-me.top)]}else{const me=[...fe.current.map(ze=>{const Ke=Ie(ze.filePath);return Ke?nv(Ke):ze.initialPosition}),...[...ge.current].flatMap(ze=>{const Ke=M.current.get(ze);return ze!==ve&&Ke?[Ke]:[]})];Se=NH(me,ie.cells(me.length+1),ie.pitch)}Se&&(M.current.set(ve,Se),fe.current.some(me=>me.filePath===ve)||ge.current.add(ve))},arrange:ve=>{Y(ve),J(Be=>({kind:"arrange",id:(Be?.id??0)+1}))},lineUp:()=>J(ve=>({kind:"lineUp",id:(ve?.id??0)+1}))}));const Ie=ve=>{const Be=W.current;if(Be){for(const U of Be.querySelectorAll(".classicyIcon[data-classicy-file-path]"))if(U.getAttribute("data-classicy-file-path")===ve)return U}},Ge=()=>fe.current.map(ve=>{const Be=Ie(ve.filePath);return{path:ve.filePath,name:ve.name,location:Be?nv(Be):ve.initialPosition}}),He=()=>fe.current.flatMap(ve=>{const Be=Ie(ve.filePath);if(!Be)return[];const U=Be.getBoundingClientRect();return[{path:ve.filePath,left:U.left,top:U.top,right:U.right,bottom:U.bottom}]}),rt=(ve,Be)=>ax(w,fe.current.map(U=>U.filePath),le.current,ve,Be,w==="windows"?He():void 0),pt=g.useRef(null),At=g.useCallback(()=>{pt.current!==null&&(clearTimeout(pt.current),pt.current=null)},[]);g.useEffect(()=>At,[At]);const _e=g.useRef(null),it=ve=>{if(!p)return!1;const Be=t.resolve(ve),U=t.resolve(e);return!!Be&&Be._type!==xe.Drive&&Be._system!==!0&&Be._readOnly!==!0&&Be._derived!==!0&&U?._readOnly!==!0},Bt=g.useRef(null),Et=g.useRef(null),yn=(ve,Be)=>{if(Bt.current=null,Be.button===2){if(!I||(At(),q(ve),le.current.selected.includes(ve)||Be.shiftKey||Be.metaKey||Be.ctrlKey))return;re({selected:[ve],anchor:ve});return}if(Be.button!==0||!k)return;At();const U=le.current;if(Be.detail>1){Bt.current={path:ve,deferred:!1,before:U};return}const Se=!(Be.shiftKey||Be.metaKey||Be.ctrlKey)&&U.selected.includes(ve);Bt.current={path:ve,deferred:Se,before:U},q(ve),Se||re(rt(ve,Be))},ln=(ve,Be)=>{At();const U=Bt.current;if(Bt.current=null,Et.current===ve){Et.current=null;return}let ie=le.current;if(U?.path===ve){if(!U.deferred)return;ie=U.before}else if(B&&Be.detail>1)return;const Se=rt(ve,Be);re(Se),q(ve);const me=_e.current,ze=me!==null&&Math.abs(me[0]-Be.clientX)<=4&&Math.abs(me[1]-Be.clientY)<=4,Ke=Be.target instanceof Element&&Be.target.closest("p")!==null;Be.detail===1&&ze&&Ke&&!Be.shiftKey&&!Be.metaKey&&!Be.ctrlKey&&!Be.altKey&&ie.selected.length===1&&ie.selected[0]===ve&&it(ve)&&(pt.current=setTimeout(()=>{pt.current=null,se(ve)},hZ))},Tn=ve=>{if(!T)return[ve];const Be=j();return Be.includes(ve)?Be:[ve]},Re=ve=>Tn(ve).map(Be=>{const U=Ie(Be);return{image:U?.querySelector("img"),label:U?.querySelector("p")}}),Ee=g.useRef(0),Pe=(ve,Be,U,ie,Se="move")=>{const me=Tn(ve);return T&&(Et.current=ve),Se==="move"&&Be?.destination.kind==="folder"&&Be.destination.path===e?(re(ze=>ze.selected.includes(ve)?ze:{selected:[ve],anchor:ve}),q(ve),me.length>1&&(Ee.current+=1,ke({paths:new Set(me.filter(ze=>ze!==ve)),by:ie,id:Ee.current})),!1):(Be&&u&&u(me,Be.destination,U,Be,Se),!0)},Je=ve=>{if(F){const Be=j();if(Be.includes(ve.filePath)){i?.(Be);return}}ve.onClickFunc()},bt=(ve,Be)=>{se(null);const U=ve.split(t.separator).pop()??"",ie=Be+y.hiddenExtension(U,t.resolve(ve));if(ie===U)return;const Se=Ie(ve),me=Se?nv(Se):void 0,ze=p?.(ve,ie);typeof ze=="string"&&ze!==ve&&(me&&M.current.set(ze,me),re({selected:[ze],anchor:ze}),q(ze))},Fe=(ve,Be)=>{const U=fe.current.map(Se=>Se.filePath),ie=le.current.anchor;re(Be&&w==="windows"&&ie&&U.includes(ie)?{selected:ox(He(),ie,ve),anchor:ie}:{selected:[ve],anchor:ve}),q(ve),Ie(ve)?.focus({preventScroll:!1})},dt=g.useRef(""),St=g.useRef(null);g.useEffect(()=>()=>{St.current!==null&&clearTimeout(St.current)},[]);const Me=ve=>{if(At(),ve.defaultPrevented||Q!==null||ve.target.closest("input, textarea, [contenteditable='true']"))return;const U=fe.current.map(me=>me.filePath);if(U.length===0)return;const ie=Ce.current&&U.includes(Ce.current)?Ce.current:le.current.selected.find(me=>U.includes(me)),Se=ve.metaKey||ve.ctrlKey||ve.altKey;if(rke.has(ve.key)&&!Se){if(ve.preventDefault(),!ie){Fe(U[0],!1);return}const me=cx(Ge(),ie,ve.key);me&&Fe(me,ve.shiftKey);return}if(w==="windows"&&!Se&&(ve.key==="Home"||ve.key==="End"||ve.key==="PageUp"||ve.key==="PageDown")){ve.preventDefault();let me=null;if(ve.key==="Home")me=U[0];else if(ve.key==="End")me=U[U.length-1];else if(ie){const ze=W.current?.closest(".classicyScrollAreaViewport");me=fZ(Ge(),ie,ve.key==="PageUp",ze?.clientHeight??0)}else me=U[0];me&&Fe(me,ve.shiftKey);return}if(w==="windows"&&ve.key==="F2"&&!Se&&!ve.shiftKey){const me=le.current.selected;me.length===1&&it(me[0])&&(ve.preventDefault(),se(me[0]));return}if(ve.key===" "&&O&&!ve.altKey){ve.preventDefault();const me=ie??U[0];if(ve.ctrlKey||ve.metaKey){re(rt(me,{...PZ,ctrlKey:!0})),q(me),Ie(me)?.focus({preventScroll:!1});return}Fe(me,ve.shiftKey);return}if(ve.key.length===1&&ve.key!==" "&&!Se){ve.preventDefault(),St.current!==null&&clearTimeout(St.current),dt.current+=ve.key,St.current=setTimeout(()=>{dt.current="",St.current=null},ux);const me=lx(w,Ge(),dt.current,ie);me&&Fe(me,!1)}},Qe=g.useRef(null);g.useEffect(()=>()=>Qe.current?.(),[]);const It=ve=>{_e.current=[ve.clientX,ve.clientY],Et.current=null;const Be=W.current;if(!Be||ve.target!==Be)return;const U=ve.button===2&&I;if(ve.button!==0&&!U)return;At(),Be.focus({preventScroll:!0});const ie=U?PZ:{shiftKey:ve.shiftKey,metaKey:ve.metaKey,ctrlKey:ve.ctrlKey},Se=ie.shiftKey||ie.metaKey||ie.ctrlKey,me=le.current,ze=Se?me.selected:[];Se||re({selected:[]}),Qe.current?.(),Qe.current=FZ({holder:Be,start:ve,items:()=>Be.querySelectorAll(".classicyIcon[data-classicy-file-path]"),onBox:ne,onTouched:Ke=>{const Xe=dx(w,ze,Ke,ie);re(ut=>({selected:Xe,anchor:ut.anchor??Ke[0]})),Ke[0]!==void 0&&q(Ke[0])},autoScroll:D,onCancel:()=>re(me),onEnd:()=>{Qe.current=null}})},ft=new Set(ce.selected),Ct=De!==void 0&&K.some(ve=>ve.filePath===De)?De:K[0]?.filePath;return b.jsxs("div",{className:Ae("classicyFileBrowserFill",A),style:m,ref:W,tabIndex:-1,...O?{role:"listbox","aria-multiselectable":!0}:{},onMouseDown:It,onKeyDown:Me,children:[K.map(({isFolder:ve,fileType:Be,mountKey:U,...ie})=>{const Se=y.display(ie.name,{_type:Be});return g.createElement(gx,{...ie,...Se!==ie.name?{label:Se,renameText:Se}:{},key:U,onClickFunc:()=>Je(ie),onFileDrag:(me,ze,Ke,Xe,ut)=>Pe(ie.filePath,me,Ke,Xe,ut),fileDropEffects:me=>QC(t,Tn(ie.filePath),me.destination),fileDragParts:T?()=>Re(ie.filePath):void 0,moveBy:ue?.paths.has(ie.filePath)?{by:ue.by,id:ue.id}:void 0,selected:ft.has(ie.filePath),cut:C.has(ie.filePath),onSelectPress:me=>yn(ie.filePath,me),onSelectClick:me=>ln(ie.filePath,me),listOption:O,tabStop:!x||ie.filePath===Ct,renaming:Q===ie.filePath,onRenameCommit:me=>bt(ie.filePath,me),onRenameCancel:()=>se(null)})}),ae&&b.jsx("div",{className:"classicyFileBrowserSelect","aria-hidden":!0,style:{left:ae.left,top:ae.top,width:ae.width,height:ae.height}})]})});Cx.displayName="ClassicyFileBrowserViewIcons";const ike=t=>t._type===xe.Directory||t._type===xe.Drive?0:1,oke={name:"_name",kind:"_type",size:"_size",modified:"_modifiedOn"},LZ=(t,e=new Set)=>{for(const n of t)n._path&&e.add(n._path),n.subRows&&LZ(n.subRows,e);return e},ake={modified:!1,created:!1,size:!0,kind:!0,label:!1,comments:!1,version:!1},vx=g.memo(({fs:t,path:e,iconSize:n=64,appId:s,dirOnClickFunc:r=()=>{},fileOnClickFunc:i=()=>{},openItemsFunc:o,hideFilesCreatedAfter:a=null,showInvisible:c=!0,listViewOptions:l,now:d,selectionApiRef:u,selectedPaths:p,onSelectionChange:f,focusTargetRef:h,onMoveItems:A,onRenameItem:m,viewCommandsRef:y,className:C,style:v})=>{const S=g.useRef(p??[]);g.useEffect(()=>{p&&(S.current=p)},[p]);const w=g.useCallback(q=>{S.current=q,f?.(q)},[f]),k=hx(),I=JC(),T=g.useCallback((q,Q,se)=>{if(!I.startsDrag(q)||!A)return;const ae=q.currentTarget.closest(".classicyFileBrowserViewTableContainer");let ne=null;const ue=()=>{if(!ne){const R=S.current;ne=R.includes(Q)?R:[Q]}return ne},ke=R=>R.map(ge=>Array.from(ae?.querySelectorAll(`[${Bi}]`)??[]).find(pe=>pe.getAttribute(Bi)===ge)).filter(ge=>ge!==void 0),fe=(R,ge,pe)=>Ie=>{Ie==="move"&&R.destination.kind==="folder"&&R.destination.path===e||A(ue(),R.destination,pe,R,Ie)},j=se&&fx(se),de=XA({start:{clientX:q.clientX,clientY:q.clientY,ctrlKey:q.ctrlKey,shiftKey:q.shiftKey},get parts(){return ke(ue()).map(R=>({image:R.querySelector("img"),label:R.querySelector(".classicyFileBrowserViewTableRowIconLabel")}))},source:q.currentTarget,...j,...I.dragOptions(q,{effects:R=>QC(t,ue(),R.destination),onStart:j?.onStart,transferAt:fe}),onDrop:(R,ge,pe,Ie)=>{R&&fe(R,ge,pe)(Ie)}});k(de)},[A,e,k,I,t]),D=gt(),O=D.fileBrowser?.listColumnTitles??"inList",x=D.fileList?.foldersFirst===!0,B=D.icon?.aliasBadge==="everywhere",F=et("systemArt","aliasBadge")??"",z=l?.columns??ake,V=l?.calculateFolderSizes??!0,P=l?.useRelativeDate??!0,W=d?.getTime(),K=g.useMemo(()=>W===void 0?new Date:new Date(W),[W]),[L,M]=g.useState([]),G=tv(Al(t).length>0),Y=(q,Q)=>q._type==="directory"?r(Q):i(Q),[N,J]=g.useState(new Map),te=g.useMemo(()=>new Set(L),[L]),H=g.useMemo(()=>{const q=Q=>{const se=t.filterByType(Q,void 0,c,a);return Object.entries(se).map(([ae,ne])=>{const ue=`${Q}:${ae}`,ke={};for(const[j,de]of Object.entries(ne))j.startsWith("_")&&(ke[j]=de);ke._name=ae,ke._path=ue,G&&NZ(t,Q,ae)&&(ke._icon=G),ke._size=N.has(ue)?N.get(ue):typeof ne._size=="number"?ne._size:void 0;const fe=ke;return ne._type===xe.Directory&&te.has(ue)&&(fe.subRows=q(ue)),fe})};return q(e)},[t,e,N,te,a,c,G]);g.useEffect(()=>{if(!V)return;let q=!1;const Q=[],se=ae=>{ae.forEach(ne=>{typeof ne._size!="number"&&ne._path&&!N.has(ne._path)&&Q.push(ne._path),ne.subRows&&se(ne.subRows)})};return se(H),Q.forEach(ae=>{t.size(ae).then(ne=>{q||J(ue=>{if(ue.has(ae))return ue;const ke=new Map(ue);return ke.set(ae,ne),ke})})}),()=>{q=!0}},[H,t,N,V]);const X=g.useRef(null);g.useImperativeHandle(u,()=>({selectAll:()=>X.current?.selectAll(),select:q=>X.current?.select?.(q),sortBy:(q,Q)=>X.current?.sortBy?.(q,Q)}),[]);const[Z,oe]=g.useState(null),he=g.useRef({}),ee=q=>{if(!m)return!1;const Q=t.resolve(q),se=t.resolve(q.split(t.separator).slice(0,-1).join(t.separator));return!!Q&&Q._type!==xe.Drive&&Q._system!==!0&&Q._readOnly!==!0&&Q._derived!==!0&&se?._readOnly!==!0},ce=()=>{const q=LZ(H),Q=he.current;if(Q.select?.every(se=>q.has(se))){const se=Q.select;Q.select=void 0,X.current?.select?.(se)}if(Q.rename!==void 0&&q.has(Q.rename)){const se=Q.rename;Q.rename=void 0,ee(se)&&oe(se)}};g.useEffect(()=>{ce()},[H]),g.useImperativeHandle(y,()=>({select:q=>{he.current.select=[...q],ce()},rename:q=>{he.current.rename=q,ce()},place:()=>{},arrange:q=>X.current?.sortBy?.(oke[q],!1),lineUp:()=>{}}));const re=pM(),le=Eu(),Ce=BC(t.storageKey),De=g.useCallback((q,Q)=>{oe(null);const se=q.split(t.separator).pop()??"",ae=Q+le.hiddenExtension(se,t.resolve(q));if(ae===se)return;const ne=m?.(q,ae);typeof ne=="string"&&ne!==q&&(he.current.select=[ne])},[t,m,le]),Te=g.useMemo(()=>{const q=[{id:"_name",title:"Filename",accessor:Q=>Q._name??"",render:(Q,se)=>{const ae=Q._icon||Tr(Q._type);return b.jsxs("div",{className:Ae("classicyFileBrowserViewTableRowContainer",Q._path!==void 0&&Ce.has(Q._path)&&"classicyFileCut"),[Bi]:Q._path,...Q._type===xe.Directory&&Q._path?{[Ra]:Q._path}:{},onMouseDown:ne=>Q._path&&T(ne,Q._path,se.emitDrag),style:{paddingLeft:`calc(var(--window-control-size) * ${se.depth})`,"--classicy-icon-mask":`url("${ae}")`},children:[b.jsx("span",{className:"classicyFileBrowserViewTableDisclosure",children:se.canExpand&&b.jsx("span",{className:"classicyFileBrowserViewTableDisclosureTriangle",onClick:ne=>ne.stopPropagation(),onMouseDown:ne=>ne.stopPropagation(),children:b.jsx(lC,{direction:"right",open:se.isExpanded,onToggle:se.toggle})})}),(()=>{const ne=b.jsx(pn,{src:ae,drawnAt:n,width:n,alt:Q._path,className:"classicyFileBrowserViewTableRowIcon",selectable:!0,selected:se.selected===!0});return B&&ev(Q._type)?b.jsxs("span",{className:"classicyIconImage",children:[ne,b.jsx("span",{className:"classicyIconAliasBadge","aria-hidden":!0,children:b.jsx("img",{src:F,alt:""})})]}):ne})(),Z!==null&&Q._path===Z?b.jsx(Ax,{className:"classicyFileBrowserViewTableRename",name:le.display(Q._name??"",Q),onCommit:ne=>De(Z,ne),onCancel:()=>oe(null)}):b.jsx("span",{className:"classicyFileBrowserViewTableRowIconLabel",children:le.display(Q._name??"",Q)})]})}}];return z.modified&&q.push({id:"_modifiedOn",title:"Date Modified",accessor:Q=>Wa(Q._modifiedOn)?.getTime()??0,render:Q=>b.jsx("span",{children:bx(Wa(Q._modifiedOn),K,P)})}),z.created&&q.push({id:"_createdOn",title:"Date Created",accessor:Q=>Wa(Q._createdOn)?.getTime()??0,render:Q=>b.jsx("span",{children:bx(Wa(Q._createdOn),K,P)})}),z.size&&q.push({id:"_size",title:"Size",accessor:Q=>Q._size,render:Q=>b.jsx("span",{children:Q._size===void 0?V?"Calculating\u2026":"\u2014":Q._size===-1?"\u2014":t.formatSize(Q._size)})}),z.kind&&q.push({id:"_type",title:"Kind",accessor:Q=>Q._type,render:Q=>b.jsx("span",{children:re(Q._type)})}),z.label&&q.push({id:"_label",title:"Label",accessor:Q=>Q._label??"",render:Q=>b.jsx("span",{children:Q._label??"\u2014"})}),z.comments&&q.push({id:"_comments",title:"Comments",accessor:Q=>Q._comments??"",render:Q=>b.jsx("span",{children:Q._comments??"\u2014"})}),z.version&&q.push({id:"_version",title:"Version",accessor:Q=>Q._version??"",render:Q=>b.jsx("span",{children:Q._version??"\u2014"})}),q},[t,n,z,K,P,V,T,Z,De,re,le,Ce,B,F]);return b.jsx(ED,{className:Ae("classicyFileBrowserViewTableContainer",C),style:{"--classicy-file-browser-icon-size":`${n}px`,...v},columns:Te,rows:H,getRowId:q=>q._path??"",getSubRows:q=>q.subRows,rowCanExpand:q=>q._type===xe.Directory,expanded:L,onToggleRow:(q,Q)=>M(se=>Q?[...se,q]:se.filter(ae=>ae!==q)),defaultSort:{columnId:"_name"},headerPlacement:O,sortGroup:x?ike:void 0,onActivateRow:(q,Q)=>Y(Q,Q._path??""),onActivateSelection:o,rowsDrag:A!==void 0,rowClassName:()=>"classicyFileBrowserViewTableRow",selectionMode:"multi",selectionApiRef:X,selected:p,onSelectionChange:w,containerRef:h,scrollable:!1},`${s}_filebrowser_${e}`)});vx.displayName="ClassicyFileBrowserViewTable";const RZ=()=>{},zZ=()=>{},WZ=({fs:t,display:e="icons",path:n,appId:s,dirOnClickFunc:r,fileOnClickFunc:i,openItemsFunc:o,hideFilesCreatedAfter:a=null,showInvisible:c=!0,listViewOptions:l,iconViewOptions:d,now:u,selectionApiRef:p,selectedPaths:f,onSelectionChange:h,focusTargetRef:A,onMoveItems:m,onDeleteItems:y,itemContextMenu:C,commandsRef:v,onRenameItem:S,backgroundContextMenu:w,onPropertiesItems:k,onClipboardCommand:I,className:T,style:D})=>{const O=g.useRef(null),x=g.useRef(null),B=g.useRef(null),{showContextMenu:F}=ar(),z=gt(),V=px(z),P=Jd(z),W=g.useRef(f??[]),[K,L]=g.useState([]),M=V&&f===void 0,G=f!==void 0,Y=g.useCallback(ne=>{W.current=ne,G||L(ne),h?.(ne)},[h,G]),N=g.useRef([]),J=g.useCallback(ne=>{N.current=ne},[]),te=g.useCallback(()=>e==="list"?W.current:N.current,[e]);g.useImperativeHandle(v,()=>({selectedPaths:te,select:ne=>x.current?.select(ne),rename:ne=>x.current?.rename(ne),place:(ne,ue)=>x.current?.place(ne,ue),arrange:ne=>x.current?.arrange(ne),lineUp:()=>x.current?.lineUp(),display:()=>e}),[te,e]);const H=ne=>{!k||ne.defaultPrevented||ne.key!=="Enter"||!ne.altKey||ne.ctrlKey||ne.metaKey||ne.shiftKey||ne.target.closest("input, textarea")||(ne.preventDefault(),ne.stopPropagation(),k(te()))},X=ne=>{if(!k||!ne.altKey)return;const ue=ne.target,ke=ue.closest(`[${Bi}]`),fe=ke??ue.closest("tr[data-row-id]"),j=ke?ke.getAttribute(Bi):fe?.getAttribute("data-row-id");if(!fe||!j||!B.current?.contains(fe))return;ne.preventDefault(),ne.stopPropagation();const de=te();k(de.includes(j)?de:[j])},Z=ne=>{if(I&&!ne.defaultPrevented&&!ne.target.closest("input, textarea, [contenteditable='true']")){const fe=AM(ne.nativeEvent);if(fe){ne.preventDefault(),I(fe,te());return}}if(ne.key==="F2"&&e==="list"&&z.fileBrowser?.keys==="windows"&&!ne.defaultPrevented&&!ne.shiftKey&&!ne.altKey&&!ne.ctrlKey&&!ne.metaKey&&!ne.target.closest("input, textarea")){const fe=te();fe.length===1&&S&&(ne.preventDefault(),x.current?.rename(fe[0]));return}if(!y||ne.defaultPrevented||ne.key!=="Backspace"&&ne.key!=="Delete"||ne.altKey||ne.shiftKey||ne.target.closest("input, textarea, [contenteditable='true']"))return;const ke=te();ke.length!==0&&(ne.preventDefault(),y(ke))},[oe,he]=g.useState(null),ee=g.useRef(null);g.useEffect(()=>()=>ee.current?.(),[]);const ce=ne=>{if(e!=="list"||!V)return;const ue=B.current,ke=ne.target;if(!ue?.contains(ke))return;const fe=ne.button===2&&P;if(ne.button!==0&&!fe||ke.closest(`tr[data-row-id], thead, .classicyScrollAreaHead, [${Bi}], input, textarea, button`))return;const j=fe?{shiftKey:!1,metaKey:!1,ctrlKey:!1}:{shiftKey:ne.shiftKey,metaKey:ne.metaKey,ctrlKey:ne.ctrlKey},de=j.shiftKey||j.metaKey||j.ctrlKey,R=W.current,ge=de?R:[];!de&&R.length>0&&Y([]);const pe=z.fileBrowser?.keys??"mac";ee.current?.(),ee.current=FZ({holder:ue,start:ne,items:()=>ue.querySelectorAll(`.classicyFileBrowserViewTableRowContainer[${Bi}]`),onBox:he,onTouched:Ie=>{const Ge=dx(pe,ge,Ie,j);_E(Ge,W.current)||Y(Ge)},autoScroll:!0,onCancel:()=>Y(R),onEnd:()=>{ee.current=null}})},re=ne=>{if(ne.defaultPrevented)return;const ue=ne.target.closest(`[${Bi}]`),ke=ue?.getAttribute(Bi);if(!ue||!ke||!B.current?.contains(ue)){if(!w||ue||ne.target.closest("thead, .classicyScrollAreaHead"))return;const j=w([ne.clientX,ne.clientY]);if(!j||j.length===0)return;ne.preventDefault(),F(j,[ne.clientX,ne.clientY]);return}if(!C)return;const fe=C(ke,te());!fe||fe.length===0||(ne.preventDefault(),F(fe,[ne.clientX,ne.clientY]))},le=ye(ne=>ne.System.Manager.Appearance.activeTheme.desktop.iconSize),[Ce,De]=g.useState(()=>Kt("--desktop-icon-size",le)),Te=ye(ne=>ne.System.Manager.Appearance.activeTheme),q=l?.iconSize??"medium",Q=()=>Kt(TZ[q],0),[se,ae]=g.useState(Q);return g.useLayoutEffect(()=>{De(Kt("--desktop-icon-size",le)),ae(Q())},[le,Te,q]),b.jsxs("div",{ref:B,className:Ae("classicyFileBrowserFill",e==="list"&&"classicyFileBrowserFillList",T),style:D,[Ra]:n,onKeyDown:Z,onKeyDownCapture:H,onDoubleClickCapture:X,onContextMenu:re,onMouseDown:ce,children:[e==="list"?b.jsx(vx,{onMoveItems:m,fileOnClickFunc:i??zZ,dirOnClickFunc:r??RZ,openItemsFunc:o,fs:t,path:n,appId:s,iconSize:l?DZ(Ce,l.iconSize,se):se>0?se:18,holderRef:O,hideFilesCreatedAfter:a,showInvisible:c,listViewOptions:l,now:u,selectionApiRef:p,selectedPaths:f??(M?K:void 0),onSelectionChange:Y,focusTargetRef:A,onRenameItem:S,viewCommandsRef:x}):b.jsx(Cx,{onMoveItems:m,fileOnClickFunc:i??zZ,dirOnClickFunc:r??RZ,fs:t,path:n,appId:s,holderRef:O,hideFilesCreatedAfter:a,showInvisible:c,iconViewOptions:d,selectionApiRef:p,onRenameItem:S,openItemsFunc:o,onSelectionChange:J,viewCommandsRef:x}),oe&&b.jsx("div",{className:"classicyFileBrowserSelect","aria-hidden":!0,style:{left:oe.left,top:oe.top,width:oe.width,height:oe.height}})]})},Fi="start-menu_",VZ=`${Fi}control-panel_`,cke="ClassicyDesktopSetBalloonHelp",sv={id:"spacer"},lke="ControlStripManager.app",wx=(t,e)=>(t.title??"").localeCompare(e.title??"",void 0,{sensitivity:"base",numeric:!0})||t.id.localeCompare(e.id),Sx=t=>({id:`${t}_empty`,title:"(Empty)",disabled:!0}),uke=({icons:t,mountedApps:e,overrides:n})=>{const s=new Set,r=[];for(const i of t){if(!Zh(i)||!e.has(i.appId)||s.has(i.appId))continue;s.add(i.appId);const o=rs(n,i.appId,{name:i.appName,icon:i.icon});r.push({id:`${Fi}programs_${i.appId}`,title:o.name,image:o.icon,event:"ClassicyAppOpen",eventData:{app:{id:i.appId,name:i.appName,icon:i.icon}}})}return r.sort(wx)},UZ=({systemMenu:t,icons:e,mountedApps:n,overrides:s})=>{const r=new Set(e.filter(Zh).map(o=>o.appId)),i=t.filter(o=>{if(!o?.id?.startsWith(wa))return!1;const a=o.id.slice(wa.length);return!r.has(a)&&n.has(a)});return(T0(i,s)??[]).map(o=>({...o,id:`${VZ}${o.id.slice(wa.length)}`})).sort(wx)},dke=({documents:t=[],openDocument:e})=>t.map((n,s)=>({id:`${Fi}documents_${s}`,title:n.name,image:n.icon,onClickFunc:()=>e?.(n.path)})).sort(wx),Ex=(t,e,n,s,r,i)=>({id:`${Fi}${t}`,title:e,accessKey:n,image:s,onClickFunc:()=>{i({type:"ClassicyDesktopShowSystemDialog",dialog:r})}}),pke=t=>{const{systemMenu:e,disableBalloonHelp:n,images:s,dispatch:r}=t,i=[],o=e.find(m=>m?.id==="about"||m?.title==="About This Computer");o&&i.push({id:`${Fi}about`,title:o.title,image:s.about,...o.disabled?{disabled:!0}:{},...o.onClickFunc?{onClickFunc:o.onClickFunc}:{},...o.event?{event:o.event}:{},...o.eventData?{eventData:o.eventData}:{}},sv);const a=`${Fi}programs`,c=uke(t);i.push({id:a,title:"Programs",accessKey:"P",image:s.programs,menuChildren:c.length>0?c:[Sx(a)]});const l=`${Fi}documents`,d=dke(t);i.push({id:l,title:"Documents",accessKey:"D",image:s.documents,menuChildren:d.length>0?d:[Sx(l)]});const u=`${Fi}control-panel`,p=UZ(t),f=lT(n).find(m=>m.event===cke),h=p.find(m=>m.id===`${u}_${lke}`);i.push({id:`${Fi}settings`,title:"Settings",accessKey:"S",image:s.controlPanel,menuChildren:[{id:u,title:"Control Panel",accessKey:"C",image:s.controlPanel,menuChildren:p.length>0?p:[Sx(u)]},...h?[{...h,id:`${Fi}taskbar`,title:`${h.title}...`,accessKey:"T"}]:[],...f?[sv,{...f,id:`${Fi}balloons`,image:s.help}]:[]]}),i.push({id:`${Fi}help`,title:"Help",accessKey:"H",image:s.help,...t.helpTopics?{event:qc,eventData:{}}:{event:np,eventData:{topicId:nA}}}),i.push(Ex("run","Run...","R",s.run,"run",r)),i.push(sv);for(const m of _C(r,"start"))m.id!=="spacer"&&i.push({...m,image:m.id.endsWith("_special_empty_trash")?s.emptyTrash:s.resetPram});i.push(sv);const A=t.userName?.trim();return A&&i.push(Ex("log-off",`Log Off ${A}...`,"L",s.logOff,"logOff",r)),i.push(Ex("shut-down","Shut Down...","u",s.shutDown,"shutDown",r)),i},fke=({appId:t,op:e,dir:n,idx:s,closeFolder:r,closeAllFolders:i,closeWindow:o,setFolderView:a,openFolder:c,openFile:l,openItems:d,getHeaderString:u,fs:p,disableBalloonHelp:f,aboutMenuItem:h,openPreferences:A,viewType:m,iconViewOptions:y,listViewOptions:C,now:v,onMoveItems:S,trashItems:w,restoreItems:k,renameItem:I,itemContextMenu:T,trashIcon:D,windowsCommands:O,creatableTypes:x,newItem:B,createShortcuts:F,showProperties:z,cutItems:V,copyItems:P,pasteItems:W,pasteShortcuts:K})=>{const L=st(),M=tn(),G=dr(),Y=Hp(),N=g.useRef(null),J=hl(p,e),[te,H]=g.useState([]),X=uZ(p,e,te,O),Z=O?b.jsxs(b.Fragment,{children:[b.jsx("span",{className:"classicyWindowStatusPart",children:ix(n._count??0,n._countHidden??0,te.length)}),b.jsx("span",{className:"classicyWindowStatusPart",children:cZ(X)}),b.jsx("span",{className:"classicyWindowStatusPart",children:rx})]}):b.jsx("span",{children:u(n)}),oe=g.useRef(null),he=g.useRef(null),ee=ye(fe=>!!rn(fe.System.Manager.Applications.apps[t],e)?.focused),ce=g.useRef(m);g.useEffect(()=>{if(ce.current===m||(ce.current=m,!ee))return;const fe=he.current;if(!fe)return;const j=document.activeElement;j&&fe.closest(".classicyWindow")?.contains(j)||fe.focus({preventScroll:!0})},[m,ee]);const re=O&&jp(p,e),le=xC(),Ce=O&&le!==null&&GC(p,e),De=Ce&&GC(p,e,{shortcut:!0}),Te=g.useCallback((fe,j)=>[LY(fe,M,()=>W(e,N.current,j),{disabled:!Ce,shortcut:j===void 0}),RY(fe,M,()=>K(e,N.current,j),{disabled:!De})],[M,e,W,K,Ce,De]),Q=(m==="icons"?["name","kind","size","modified"]:["name",...C.columns.kind?["kind"]:[],...C.columns.size?["size"]:[],...C.columns.modified?["modified"]:[]]).join(","),se=g.useCallback(fe=>[{id:`${fe}_large_icons`,title:"Large Icons",...M("g")!==void 0?{accessKey:M("g")}:{},checked:m==="icons",mark:"bullet",onClickFunc:()=>a(e,"icons")},{id:`${fe}_details`,title:"Details",...M("D")!==void 0?{accessKey:M("D")}:{},checked:m==="list",mark:"bullet",onClickFunc:()=>a(e,"list")}],[M,m,a,e]),ae=g.useCallback(fe=>[OY(fe,M,Q.split(","),j=>N.current?.arrange(j)),FY(fe,M,()=>N.current?.lineUp(),m==="list")],[M,Q,m]),ne=g.useCallback(fe=>O?[{id:`${t}_${e}_ws_view`,title:"View",...M("V")!==void 0?{accessKey:M("V")}:{},menuChildren:se(`${t}_${e}_ws_view`)},{id:"spacer"},...ae(`${t}_${e}_ws`),{id:"spacer"},...Te(`${t}_${e}_ws`,fe),...re?[{id:"spacer"},zC(`${t}_${e}_ws`,M,x,j=>B(e,j,N.current,fe))]:[],{id:"spacer"},{id:`${t}_${e}_ws_properties`,title:Zl,...M("r")!==void 0?{accessKey:M("r")}:{},onClickFunc:()=>z([e])}]:void 0,[O,t,e,M,se,ae,re,x,B,Te,z]),ue=g.useCallback((fe,j)=>T(fe,j,N.current),[T]),ke=g.useMemo(()=>[{id:`${t}_${e}_file`,title:"File",accessKey:M("f"),menuChildren:O?[{id:`${t}_${e}_file_open`,title:"Open",...M("o")!==void 0?{accessKey:M("o")}:{},keyboardShortcut:G("finder_file_open","\u2318O"),onClickFunc:()=>d(N.current?.selectedPaths()??[])},{id:"spacer"},...J?[]:[zC(`${t}_${e}_file`,M,x,fe=>B(e,fe,N.current),!re),{id:"spacer"},tg(`${t}_${e}_file`,M,()=>F(N.current?.selectedPaths()??[],N.current)),WC(`${t}_${e}_file`,M,()=>w(N.current?.selectedPaths()??[])),VC(`${t}_${e}_file`,M,()=>{const fe=N.current?.selectedPaths()??[];fe.length===1&&eg(p,fe[0])&&N.current?.rename(fe[0])})],...e===an?[{id:`${t}_${e}_file_restore`,title:"Restore",...M("e")!==void 0?{accessKey:M("e")}:{},onClickFunc:()=>k(N.current?.selectedPaths()??[])}]:[],{id:`${t}_${e}_file_properties`,title:Zl,...M("r")!==void 0?{accessKey:M("r")}:{},onClickFunc:()=>{const fe=N.current?.selectedPaths()??[];z(fe.length>0?fe:[e])}},{id:"spacer"},{id:`${t}_${e}_file_closew`,title:"Close",...M("c")!==void 0?{accessKey:M("c")}:{},onClickFunc:()=>o(e,{type:"ClassicyAppFinderCloseFolder",path:e})}]:[Pr(`${t}_${e}_file_closew`,()=>o(e,{type:"ClassicyAppFinderCloseFolder",path:e}),M("c")),bp(`${t}_${e}_file_closews`,i),{id:"spacer"},{id:`${t}_${e}_file_move_to_trash`,title:"Move To Trash",keyboardShortcut:G("finder_file_move_to_trash","\u2303\u232B"),disabled:J,onClickFunc:()=>w(N.current?.selectedPaths()??[])},...e===an?[{id:`${t}_${e}_file_restore`,title:"Restore",onClickFunc:()=>k(N.current?.selectedPaths()??[])}]:[]]},{id:`${t}_${e}_edit`,title:"Edit",accessKey:M("e"),menuChildren:[...O?[zM(`${t}_${e}_edit`,M,()=>V(N.current?.selectedPaths()??[]),{shortcut:!0}),WM(`${t}_${e}_edit`,M,()=>P(N.current?.selectedPaths()??[]),{disabled:J,shortcut:!0}),...Te(`${t}_${e}_edit`),{id:"spacer"}]:[],{id:`${t}_${e}_edit_select_all`,title:"Select All",accessKey:M("a"),keyboardShortcut:G("finder_edit_select_all","\u2318A"),onClickFunc:()=>oe.current?.selectAll()},{id:"spacer"},{id:`${t}_${e}_edit_preferences`,title:"Preferences\u2026",onClickFunc:A}]},{id:`${t}_view`,title:"View",accessKey:M("v"),menuChildren:O?[...se(`${t}_${e}_view`),{id:"spacer"},...ae(`${t}_${e}_view`)]:[{id:`${t}_${e}_view_as_icons`,title:"View as Icons",checked:m==="icons",mark:"bullet",onClickFunc:()=>a(e,"icons")},{id:`${t}_${e}_view_as_list`,title:"View as List",checked:m==="list",mark:"bullet",onClickFunc:()=>a(e,"list")}]},{id:`${t}_${e}_special`,title:"Special",accessKey:M("s"),menuChildren:_C(L,`${t}_${e}`,Y)},{id:`${t}_${e}_help`,title:"Help",accessKey:M("h"),menuChildren:[{id:`${t}_${e}_help_balloon`,title:f?"Show Balloon Help":"Hide Balloon Help",event:"ClassicyDesktopSetBalloonHelp",eventData:{disableBalloonHelp:!f}},h]}],[t,e,o,i,a,f,h,A,m,J,w,k,L,M,O,d,x,B,re,p,se,ae,F,z,V,P,Te,G,Y]);return b.jsx(Qt,{id:e,title:e===an?Y:n._name,icon:e===an?D||n._icon||Tr(n._type):n._icon,appId:t,defaultWindow:!1,hidden:!1,initialSize:[425,300],initialPosition:[50+s*50,50+s*50],header:Z,headerVariant:O?"status":void 0,onCloseFunc:r,appMenu:ke,initialFocusRef:he,children:b.jsx(WZ,{appId:t,fs:p,path:e,dirOnClickFunc:c,fileOnClickFunc:l,openItemsFunc:d,display:m,iconViewOptions:y,listViewOptions:C,now:v,selectionApiRef:oe,focusTargetRef:he,onSelectionChange:O?H:void 0,onMoveItems:S,showInvisible:!1,onDeleteItems:J?void 0:w,itemContextMenu:ue,commandsRef:N,onRenameItem:I,backgroundContextMenu:O?ne:void 0,onPropertiesItems:O?fe=>z(fe.length>0?fe:[e]):void 0,onClipboardCommand:O?(fe,j)=>{fe==="cut"?V(j):fe==="copy"?J||P(j):W(e,N.current)}:void 0})})},hke=g.memo(fke),GZ=[],Ake=[],gke=({path:t,fs:e,...n})=>{const s=vZ(t,e),r=e.statDirShell(t);return r?b.jsx(hke,{...n,fs:e,op:t,dir:{...r,_size:s}}):null},mke=g.memo(gke),yke=({appId:t,fs:e,paths:n,trust:s})=>{const r=st(),i=Hp(),o=n.filter(l=>e.resolve(l)),{title:a,message:c}=EEe(e,o,i);return b.jsx(Ps,{id:"finder_confirm_delete",appId:t,alertType:"caution",movable:!0,title:a,label:c,buttons:[{id:"yes",label:"Yes",role:"default",onClick:()=>{o.length>0&&Zp(e,o,l=>r(l,s),{confirmed:!0,trust:s})}},{id:"no",label:"No",role:"cancel"}],onClose:()=>r({type:"ClassicyAppFinderConfirmDeleteClose"})})},bke=({appId:t,fs:e,paths:n})=>{const s=st();return b.jsx(Ps,{id:"finder_desktop_shortcut_offer",appId:t,alertType:"caution",movable:!0,title:CY,label:wY,buttons:[{id:"yes",label:"Yes",role:"default",onClick:()=>{RM(e,n.filter(r=>e.resolve(r)),s)}},{id:"no",label:"No",role:"cancel"}],onClose:()=>s({type:"ClassicyAppFinderOfferDesktopShortcutClose"})})},HZ=()=>{const t=et("icons","system.macos")??"",e=et("icons","system.mac")??"",n="Finder",s="Finder.app",r=st(),i=gt().finder?.commands==="windows",o=tn(),a=ye(R=>R.System.Manager.Applications.apps[s]),c=ex(a?.data??{})?a?.data:{},l=ye(R=>R.System.Manager.Desktop.disableBalloonHelp),d=ye(R=>R.System.Manager.DateAndTime),u=g.useMemo(()=>Up(d.dateTime,parseInt(d.timeZoneOffset,10)),[d.dateTime,d.timeZoneOffset]),p=Ep(),f=cr(s),{aboutMenuItem:h,aboutWindow:A}=lr(s,n,e),m=g.useRef(null);g.useEffect(()=>{const R=a.data??{},ge=ex(R)?R:{};if(!ge.openPaths)return;const pe=ge.openPaths,Ie=m.current;Ie&&Ie.length===pe.length&&Ie.every((Ge,He)=>Ge===pe[He])||(m.current=pe,r({type:"ClassicyAppFinderOpenFolders",paths:pe}))},[r,a.data]);const y=g.useCallback((R,ge)=>{r({type:"ClassicyAppFinderSetFolderView",path:R,viewType:ge})},[r]),C=a.windows,v=g.useCallback(R=>{r({type:"ClassicyAppFinderOpenFolder",path:R});const ge=rn({windows:C},R);ge&&(r({type:"ClassicyWindowOpen",app:{id:s},window:ge}),r({type:"ClassicyWindowFocus",app:{id:s},window:ge}))},[r,C]),S=g.useCallback(R=>{const ge=p.resolve(R);r({type:"ClassicyAppFinderOpenFile",file:ge,path:R})},[p,r]),w=g.useCallback(R=>{r({type:"ClassicyAppFinderCloseFolder",path:R})},[r]),k=g.useCallback(()=>{(c.openPaths??[]).forEach(ge=>{f(ge,{type:"ClassicyAppFinderCloseFolder",path:ge})})},[f,c.openPaths]),I=g.useCallback(()=>{r({type:"ClassicyAppFinderPreferencesOpen"})},[r]),T=JSON.stringify(Object.entries(p.filterByType("","drive")).map(([R,ge])=>[R,ge._icon]));g.useEffect(()=>{const R=JSON.parse(T),ge=[];return R.forEach(([pe,Ie])=>{ye.getState().System.Manager.Desktop.icons.some(He=>He.appId===s&&He.appName===pe)||ge.push(pe),r({type:"ClassicyDesktopIconAdd",app:{id:s,name:pe,icon:Ie},event:"ClassicyAppFinderOpenFolder",eventData:{path:pe},kind:"drive",filePath:pe,contextMenu:SD(pe,kp(),{open:i,openAccessKey:o("o"),createShortcut:i,createShortcutAccessKey:o("S"),properties:i,propertiesAccessKey:o("r")})})}),()=>{ge.forEach(pe=>{r({type:"ClassicyDesktopIconRemove",app:{id:s,name:pe}})})}},[T,r,i,o]);const D=Ih().startupDisk,O=D!==void 0?c.shellFolders??GZ:GZ,x=O.includes("controlPanel"),B=ye(R=>x?R.System.Manager.Desktop.systemMenu:void 0),F=ye(R=>x?R.System.Manager.Desktop.icons:Ake),z=Si(),V=ws(),P=g.useMemo(()=>O.includes("myComputer")?XY(p,va("system.folders.controlPanels"),Tr):[],[T,O.includes("myComputer")]),W=g.useMemo(()=>x?qY(UZ({systemMenu:B??[],icons:F,mountedApps:z,overrides:V}),VZ):[],[x,B,F,z,V]),K=g.useCallback(R=>{R.kind==="drive"&&R.path?v(R.path):r(R.open)},[v,r]),L=g.useCallback(R=>R.kind==="drive"&&R.path?SD(R.path,kp(),{open:i,openAccessKey:o("o"),createShortcut:i,createShortcutAccessKey:o("S"),properties:i,propertiesAccessKey:o("r")}):[{id:`${s}_${R.id}_open`,title:"Open",...o("o")!==void 0?{accessKey:o("o")}:{},...i?{isDefault:!0}:{},onClickFunc:()=>K(R)}],[i,o,K]),M=g.useMemo(()=>[{id:`${s}_shell_help_balloon`,title:l?"Show Balloon Help":"Hide Balloon Help",event:"ClassicyDesktopSetBalloonHelp",eventData:{disableBalloonHelp:!l}},h],[l,h]),G=g.useCallback((R,ge,pe,Ie,Ge="move")=>{YM(p,R,ge,r,Ge,{desktopLocation:_A(pe)}).length>0&&NM(Ie,r)},[p,r]),Y=tv(Al(p).length>0),N=Hp(),J=ske();g.useEffect(()=>{CM(p,J)},[p,J]),g.useEffect(()=>{r({type:"ClassicyDesktopIconAdd",app:{id:"Trash",name:"Trash",icon:Y},kind:"trash",filePath:an,noLaunch:!0,event:"ClassicyAppFinderOpenFolder",eventData:{path:an},contextMenu:[{id:"finder_trash_open",title:"Open",...o("o")!==void 0?{accessKey:o("o")}:{},isDefault:!0,onClickFunc:()=>r({type:"ClassicyAppFinderOpenFolder",path:an})},{id:"finder_trash_empty",title:`Empty ${N}`,...o("b")!==void 0&&/b/i.test(N)?{accessKey:o("b")}:{},confirms:!0,onClickFunc:()=>r({type:"ClassicyDesktopShowSystemDialog",dialog:"emptyTrash"})},...i?[{id:"spacer"},tg("finder_trash",o,()=>r({type:"ClassicyAppFinderOfferDesktopShortcut",paths:[an]})),{id:"spacer"},{id:"finder_trash_properties",title:Zl,...o("r")!==void 0?{accessKey:o("r")}:{},onClickFunc:()=>r(Mh({paths:[an]}))}]:[]]})},[Y,r,o,i,N]);const te=g.useCallback(R=>{const ge=R.filter(pe=>p.resolve(pe));ge.length>0&&Zp(p,ge,r)},[p,r]),H=g.useCallback(R=>{const ge=R.filter(pe=>JA(p,pe));ge.length>0&&yY(p,ge,r)},[p,r]),X=g.useCallback((R,ge)=>LC(p,R,ge,r),[p,r]),Z=g.useCallback(R=>{const ge=p.resolve(R);ge&&(ge._type===xe.Directory||ge._type===xe.Drive?v(R):S(R))},[p,v,S]),oe=BY(),he=g.useCallback((R,ge,pe,Ie)=>{if(!jp(p,R))return;const Ge=MY(p,R,ge);pe?.place(Ge,Ie),xY(p,Ge,ge)&&(pe?.select([Ge]),pe?.rename(Ge))},[p]),ee=g.useCallback((R,ge)=>{PY(p,R,r,ge)},[p,r]),ce=g.useCallback(R=>{UM(p,R)},[p]),re=g.useCallback(R=>{GM(p,R)},[p]),le=g.useCallback((R,ge,pe)=>{HM(p,{kind:"folder",path:R},r,{commands:ge,at:pe})},[p,r]),Ce=g.useCallback((R,ge,pe)=>{UY(p,{kind:"folder",path:R},r,{commands:ge,at:pe})},[p,r]),De=g.useCallback(R=>[zM("finder_item",o,()=>ce(R()),{disabled:!R().some(ge=>zY(p,ge))}),WM("finder_item",o,()=>re(R()),{disabled:!R().some(ge=>VM(p,ge))})],[p,o,ce,re]),Te=MEe(),q=g.useCallback((R,ge)=>{const pe=Te(p.resolve(R)?._type);if(pe.length===0)return[];const Ie=pe[0].appId;return DEe("finder_item",o,pe,()=>ge().filter(Ge=>Te(p.resolve(Ge)?._type)[0]?.appId===Ie),r)},[p,Te,o,r]),Q=g.useCallback(R=>{R.length>0&&r(Mh({paths:R}))},[r]),se=g.useCallback(R=>({id:"finder_item_properties_sheet",title:Zl,...o("r")!==void 0?{accessKey:o("r")}:{},onClickFunc:()=>Q(R())}),[o,Q]),ae=g.useCallback(R=>nZ(p.resolve(R),ye.getState().System.Manager.Applications)?"Open With\u2026":"Open",[p]),ne=g.useCallback(R=>{for(const ge of R)Z(ge)},[Z]),ue=g.useCallback((R,ge,pe)=>{const Ie=ge.includes(R)?ge:[R],Ge=i?vD(p.resolve(R)):void 0,He=i?Ge?[{id:"finder_item_properties",title:"Properties",accessKey:o("r"),isDefault:!0,onClickFunc:()=>Z(R)}]:[{id:"finder_item_open",title:ae(R),accessKey:o("o"),isDefault:!0,onClickFunc:()=>Z(R)}]:[],rt=i&&!Ge?[{id:"spacer"},se(()=>Ie)]:[];return JA(p,R)?[...He,{id:"finder_item_restore",title:"Restore",...o("e")!==void 0?{accessKey:o("e")}:{},onClickFunc:()=>H(Ie)},...i?[{id:"spacer"},De(()=>Ie)[0]]:[],...rt]:hl(p,R)?He.length>0?[...He,...rt]:void 0:i?[...He,...q(R,()=>Ie),{id:"spacer"},...De(()=>Ie),{id:"spacer"},tg("finder_item",o,()=>ee(Ie,pe)),WC("finder_item",o,()=>te(Ie)),VC("finder_item",o,()=>pe?.rename(R),Ie.length!==1||!eg(p,R)),...rt]:[...He,{id:"finder_item_move_to_trash",title:"Move To Trash",onClickFunc:()=>te(Ie)}]},[p,i,Z,H,te,o,q,ee,ae,se,De]),ke=g.useRef(Z);g.useLayoutEffect(()=>{ke.current=Z},[Z]);const fe=g.useCallback(R=>{const ge=()=>{const Ie=ye.getState().System.Manager.Desktop,Ge=new Set(Ie.selectedIcons??[]);return Ie.icons.flatMap(He=>He.filePath!==void 0&&He.appId.startsWith(Oi)&&Ge.has(He.appId)?[He.filePath]:[])},pe=()=>{const Ie=ge();return Ie.includes(R)?Ie:[R]};return[{id:"finder_item_open",title:ae(R),...o("o")!==void 0?{accessKey:o("o")}:{},isDefault:!0,onClickFunc:()=>ke.current(R)},...q(R,pe),{id:"spacer"},...De(pe),{id:"spacer"},tg("finder_item",o,()=>ee(pe(),null)),WC("finder_item",o,()=>te(pe())),VC("finder_item",o,()=>{pe().length===1&&eg(p,R)&&qC(`${Oi}${R}`)}),{id:"spacer"},se(pe)]},[te,o,p,q,ee,ae,se,De]);g.useEffect(()=>{const R=Yp(p),ge=R?p.filterByType(R,void 0,!1):{},pe=new Set(Object.keys(ge).map(Ie=>`${R}${p.separator}${Ie}`));for(const Ie of pe){const Ge=za(p,Ie);Ge&&r({...Ge,contextMenu:i?fe(Ie):null})}for(const Ie of ye.getState().System.Manager.Desktop.icons)Ie.appId.startsWith(Oi)&&!pe.has(Ie.appId.slice(Oi.length))&&r({type:"ClassicyDesktopIconRemove",app:{id:Ie.appId}})},[p,r,i,fe]);const j=g.useCallback(R=>{const ge=R._size===void 0?"Calculating\u2026":R._size===-1?"\u2014":p.formatSize(R._size);return R._count+" items"+(R._countHidden?` (${R._countHidden} hidden)`:"")+", "+ge},[p]),de=g.useMemo(()=>ZC(c),[c]);return b.jsxs(Fs,{id:s,name:n,icon:t,showDesktopIcon:!1,showInApplicationsFolder:!1,restoreWindowFocus:!1,defaultWindow:c.openPaths?.length?c.openPaths.at(0):"Macintosh HD",children:[c.openPaths&&c.openPaths.length>0?c.openPaths.map((R,ge)=>b.jsx(mke,{path:R,appId:s,idx:ge,closeFolder:w,closeAllFolders:k,closeWindow:f,setFolderView:y,openFolder:v,openFile:S,openItems:ne,getHeaderString:j,fs:p,disableBalloonHelp:l,aboutMenuItem:h,openPreferences:I,viewType:c.folderViews?.[R]??"list",iconViewOptions:de.icons,listViewOptions:de.list,now:u,onMoveItems:G,trashItems:te,restoreItems:H,renameItem:X,itemContextMenu:ue,trashIcon:Y,windowsCommands:i,creatableTypes:oe,newItem:he,createShortcuts:ee,showProperties:Q,cutItems:ce,copyItems:re,pasteItems:le,pasteShortcuts:Ce},`${n}_${R}`)):null,O.map((R,ge)=>b.jsx(CZ,{appId:s,folder:R,title:R==="myComputer"?D?.name??Qy:Qy,icon:R==="myComputer"?D?.icon??Tr(xe.Drive):va("system.folders.controlPanels"),items:R==="myComputer"?P:W,idx:(c.openPaths?.length??0)+ge,openItem:K,itemContextMenu:L,close:()=>f(Th(R),{type:Ky,folder:R}),onClosed:()=>r({type:Ky,folder:R}),windowsCommands:i,helpItems:M},`${n}_shell_${R}`)),c.confirmDelete?b.jsx(yke,{appId:s,fs:p,paths:c.confirmDelete.paths,trust:c.confirmDelete.trust}):null,c.desktopShortcutOffer?b.jsx(bke,{appId:s,fs:p,paths:c.desktopShortcutOffer.paths}):null,(c.properties??[]).map((R,ge)=>b.jsx(jY,{appId:s,fs:p,paths:R.paths,targetAppId:R.appId,index:ge,trashIcon:Y},R.key)),c.openWith?b.jsx(JY,{appId:s,fs:p,path:c.openWith.path}):null,A,a.data?.showAboutThisComputer?b.jsx(iZ,{}):null,c.showPreferences?b.jsx(aZ,{}):null]})},YZ="ClassicyAppHCEdit",ZZ=100;function Wr(t,e){const n=$t.isDraft(t.draft)?$t.current(t.draft):t.draft,s=$t.produce(n,e);s!==n&&(t.undo.push(n),t.undo.length>ZZ&&t.undo.shift(),t.redo=[],t.draft=s,t.dirty=!0)}function ku(t,e,n){const s=t.cards.find(i=>i.id===e);if(!s)return;if(n==="card")return s.parts??=[],s.parts;if(!s.background)return;const r=t.backgrounds?.find(i=>i.id===s.background);if(r)return r.parts??=[],r.parts}function rg(t,e,n){const s=t.cards.find(r=>r.id===e);if(s){if(n==="card")return s.parts;if(s.background)return t.backgrounds?.find(r=>r.id===s.background)?.parts}}function kx(t,e){const n=new Set;for(const r of t.cards)for(const i of r.parts??[])n.add(i.id);for(const r of t.backgrounds??[])for(const i of r.parts??[])n.add(i.id);let s=1;for(;n.has(`${e}${s}`);)s++;return`${e}${s}`}function jZ(t){const e=new Set(t.cards.map(s=>s.id));let n=1;for(;e.has(`card${n}`);)n++;return`card${n}`}const Ix=[{type:"button",label:"Button",defaultSize:[100,24]},{type:"field",label:"Field",defaultSize:[160,24]},{type:"checkbox",label:"Checkbox",defaultSize:[140,20]},{type:"radio",label:"Radio Group",defaultSize:[140,60],defaultOptions:{choices:["One","Two"]}},{type:"popup",label:"Pop-up Menu",defaultSize:[160,24],defaultOptions:{choices:["One","Two"]}},{type:"slider",label:"Slider",defaultSize:[160,24],defaultOptions:{min:0,max:100,step:1}},{type:"progress",label:"Progress Bar",defaultSize:[160,16],defaultOptions:{max:100}},{type:"label",label:"Label",defaultSize:[160,20],defaultContent:"Label"},{type:"image",label:"Image",defaultSize:[120,90],defaultOptions:{src:""}},{type:"group",label:"Group",defaultSize:[200,120]}];function KZ(t){return Ix.find(e=>e.type===t)}const Tx="application/x-hypercard-part-type",Cke=["nw","n","ne","e","se","s","sw","w"];function Dx(t,e){return rg(t.draft,t.currentCardId,t.layer)?.find(s=>s.id===e)?.rect??[0,0,120,60]}function Mx(t){const[e,n,s,r]=t.startRect;if(!t.handle)return[e+t.dx,n+t.dy,s,r];let[i,o,a,c]=[e,n,s,r];return t.handle.includes("w")&&(i=e+t.dx,a=s-t.dx),t.handle.includes("e")&&(a=s+t.dx),t.handle.includes("n")&&(o=n+t.dy,c=r-t.dy),t.handle.includes("s")&&(c=r+t.dy),[i,o,a,c]}const QZ=({stackId:t,edit:e,className:n,style:s})=>{const r=st(),[i,o]=g.useState(),a=mb(gt()),c=rg(e.draft,e.currentCardId,e.layer)??[],l=e.selectedPartId,d=(S,w)=>r({type:"ClassicyAppHCEditSetRect",stackId:t,partId:S,rect:w}),u=(S,w,k)=>{S.stopPropagation();try{S.currentTarget.setPointerCapture?.(S.pointerId)}catch{}k||r({type:"ClassicyAppHCEditSelect",stackId:t,partId:w}),o({partId:w,handle:k,startX:S.clientX,startY:S.clientY,startRect:Dx(e,w),dx:0,dy:0})},p=S=>{i&&o({...i,dx:S.clientX-i.startX,dy:S.clientY-i.startY})},f=()=>{i&&((i.dx!==0||i.dy!==0)&&d(i.partId,Mx(i)),o(void 0))};ql(i!==void 0,f);const h=(S,w)=>{const k=w.getBoundingClientRect();return[Math.round(S.clientX-k.left),Math.round(S.clientY-k.top)]},A=S=>{if(S.target===S.currentTarget){if(e.placing){const w=h(S,S.currentTarget);r({type:"ClassicyAppHCEditAddPart",stackId:t,partType:e.placing,at:w});return}r({type:"ClassicyAppHCEditSelect",stackId:t,partId:void 0})}},m=S=>{const w=S.dataTransfer?.getData(Tx);if(!w)return;S.preventDefault();const k=h(S,S.currentTarget);r({type:"ClassicyAppHCEditAddPart",stackId:t,partType:w,at:k})},y=S=>{const w=d0(S),k=S.key.toLowerCase();if(w&&k==="z"){S.preventDefault(),r({type:S.shiftKey?"ClassicyAppHCEditRedo":"ClassicyAppHCEditUndo",stackId:t});return}if(w&&k==="v"){r({type:"ClassicyAppHCEditPastePart",stackId:t});return}if(S.key==="Escape"&&e.placing&&a){S.preventDefault(),r({type:"ClassicyAppHCEditSetPlacing",stackId:t,partType:void 0});return}if(!l)return;if(w&&k==="c"){r({type:"ClassicyAppHCEditCopyPart",stackId:t,partId:l});return}if(S.key==="Delete"||S.key==="Backspace"){S.preventDefault(),r({type:"ClassicyAppHCEditDeletePart",stackId:t,partId:l});return}if(S.key==="Escape"){r({type:"ClassicyAppHCEditSelect",stackId:t,partId:void 0});return}const I=S.shiftKey?8:1,D={ArrowLeft:[-I,0],ArrowRight:[I,0],ArrowUp:[0,-I],ArrowDown:[0,I]}[S.key];if(!D)return;S.preventDefault();const[O,x,B,F]=Dx(e,l);d(l,[O+D[0],x+D[1],B,F])},C=S=>{const w=Dx(e,S);return i&&i.partId===S&&(i.dx!==0||i.dy!==0)?Mx(i):w},v=([S,w,k,I])=>({left:S,top:w,width:k,height:I});return b.jsxs("div",{className:Ae("classicyHyperCardEditorOverlay",n),style:s,tabIndex:0,onPointerDown:A,onPointerMove:p,onPointerUp:f,onKeyDown:y,onDragOver:S=>S.preventDefault(),onDrop:m,children:[c.map(S=>b.jsx("div",{className:"classicyHyperCardEditorHit","data-part-id":S.id,style:v(C(S.id)),onPointerDown:w=>u(w,S.id),onPointerMove:p,onPointerUp:f},S.id)),l&&c.some(S=>S.id===l)?b.jsx("div",{className:"classicyHyperCardEditorSelection",style:v(C(l)),children:Cke.map(S=>b.jsx("div",{className:"classicyHyperCardEditorHandle","data-handle":S,onPointerDown:w=>u(w,l,S),onPointerMove:p,onPointerUp:f},S))}):null]})},vke=/^(<=|>=|<>|==|!=|≠|&&|=|<|>|&|\+|-|\*|\/|\(|\))/;function wke(t){const e=[];let n=0;for(;n<t.length;){const s=t[n];if(s===" "||s===" "||s===`
81
81
  `||s==="\r"){n++;continue}if(s==='"'){let o=n+1,a="";for(;o<t.length&&t[o]!=='"';)a+=t[o],o++;e.push({t:"str",v:a}),n=o+1;continue}if(/[0-9]/.test(s)||s==="."&&/[0-9]/.test(t[n+1]??"")){const o=t.slice(n).match(/^[0-9]*\.?[0-9]+/);if(o){e.push({t:"num",v:parseFloat(o[0])}),n+=o[0].length;continue}}const r=t.slice(n).match(vke);if(r){e.push({t:"op",v:r[0]}),n+=r[0].length;continue}const i=t.slice(n).match(/^[A-Za-z_][A-Za-z0-9_.]*/);if(i){e.push({t:"word",v:i[0]}),n+=i[0].length;continue}n++}return e.push({t:"eof"}),e}const Ske=new Set(["and","or","not","is","mod"]);class Eke{constructor(e,n){this.toks=e,this.ctx=n}toks;ctx;pos=0;peek(){return this.toks[this.pos]}next(){return this.toks[this.pos++]}isWord(e){const n=this.peek();return n.t==="word"&&n.v.toLowerCase()===e}isOp(e){const n=this.peek();return n.t==="op"&&n.v===e}parse(){const e=this.parseOr();if(this.peek().t!=="eof")throw new Error("Unexpected trailing tokens");return e}parseOr(){let e=this.parseAnd();for(;this.isWord("or");){this.next();const n=this.parseAnd();e=Iu(e)||Iu(n)}return e}parseAnd(){let e=this.parseNot();for(;this.isWord("and");){this.next();const n=this.parseNot();e=Iu(e)&&Iu(n)}return e}parseNot(){return this.isWord("not")?(this.next(),!Iu(this.parseNot())):this.parseComparison()}parseComparison(){let e=this.parseConcat();for(;;){const n=this.peek();let s;if(n.t==="op"&&["=","==","<>","!=","\u2260","<",">","<=",">="].includes(n.v)?s=n.v:n.t==="word"&&n.v.toLowerCase()==="is"&&(s="="),!s)break;this.next();const r=this.parseConcat();e=kke(s,e,r)}return e}parseConcat(){let e=this.parseAdd();for(;this.isOp("&")||this.isOp("&&");){this.next();const n=this.parseAdd();e=Qp(e)+Qp(n)}return e}parseAdd(){let e=this.parseMul();for(;;)if(this.isOp("+"))this.next(),e=Mr(e)+Mr(this.parseMul());else if(this.isOp("-"))this.next(),e=Mr(e)-Mr(this.parseMul());else break;return e}parseMul(){let e=this.parseUnary();for(;;)if(this.isOp("*"))this.next(),e=Mr(e)*Mr(this.parseUnary());else if(this.isOp("/"))this.next(),e=Mr(e)/Mr(this.parseUnary());else if(this.isWord("mod"))this.next(),e=Mr(e)%Mr(this.parseUnary());else break;return e}parseUnary(){return this.isOp("-")?(this.next(),-Mr(this.parseUnary())):this.parsePrimary()}parsePrimary(){const e=this.next();if(e.t==="num"||e.t==="str")return e.v;if(e.t==="op"&&e.v==="("){const n=this.parseOr();if(!this.isOp(")"))throw new Error("Expected )");return this.next(),n}if(e.t==="word"){const n=e.v.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="empty")return"";if(n==="field"||n==="fld"||n==="card"||n==="bg"){const r=this.next(),i=r.t==="str"||r.t==="word"?String(r.v):"";return this.ctx.getField(i)??""}if(Ske.has(n))throw new Error(`Unexpected operator word "${e.v}"`);const s=this.ctx.getVar(e.v);return s!==void 0?s:e.v}throw new Error("Unexpected token in expression")}}function Mr(t){if(typeof t=="number")return t;if(typeof t=="boolean")return t?1:0;const e=parseFloat(t);return Number.isNaN(e)?0:e}function Qp(t){return typeof t=="string"?t:typeof t=="boolean"?t?"true":"false":String(t)}function Iu(t){if(typeof t=="boolean")return t;if(typeof t=="number")return t!==0;const e=t.toLowerCase().trim();if(e==="true")return!0;if(e==="false"||e==="")return!1;const n=parseFloat(e);return!Number.isNaN(n)&&n!==0}function JZ(t){return typeof t=="number"?!0:typeof t=="boolean"?!1:t.trim()!==""&&!Number.isNaN(Number(t))}function kke(t,e,n){const s=JZ(e)&&JZ(n),r=s?Mr(e):Qp(e),i=s?Mr(n):Qp(n);switch(t){case"=":case"==":return r===i;case"<>":case"!=":case"\u2260":return r!==i;case"<":return r<i;case">":return r>i;case"<=":return r<=i;case">=":return r>=i}return!1}const xx=Mr,Tu=Qp,XZ=Iu;function Wo(t,e){try{return new Eke(wke(t),e).parse()}catch{return t}}function qZ(t,e){return Qp(Wo(t,e))}function ig(t,e){return Mr(Wo(t,e))}function Bx(t,e){return Iu(Wo(t,e))}const _Z=new Map,$Z=new Map,ej=new Map,tj=new Map,nj=new Map;function Ike(t,e){_Z.set(t,e)}function sj(t){return _Z.get(t)}function Tke(t,e){$Z.set(t,e)}function rj(t){return $Z.get(t)}function Dke(t,e){ej.set(t,e)}function ij(t){return ej.get(t)}function Mke(t,e){tj.set(t,e)}function oj(t){return tj.get(t)}function xke(t,e,n){nj.set(t,{id:t,name:e,stack:n})}function aj(){return Array.from(nj.values())}const Ox=new Map,Fx=new Map;function Bke(t,e){Ox.set(t,e)}function Nx(t){return Ox.get(t)}function cj(){return Array.from(Ox,([t,e])=>({type:t,meta:e}))}function Oke(t,e){Fx.set(t,e)}function lj(t){return Fx.get(t)}function uj(){return Array.from(Fx,([t,e])=>({name:t,meta:e}))}const dj=new Map;function pj(t){dj.set(t.id,t)}function Px(){return Array.from(dj.values())}const ai={id:"HyperCard.app",name:"HyperCard",get icon(){return Jn("icons","system.files.application")??""}},fj="ClassicyAppHyperCard",hj=rr({activeStackId:We().optional().describe("Stack id of the frontmost stack window."),openStacks:ps(We(),rr({})).optional().describe("Runtime state of every open stack, keyed by stack id."),openFiles:bn(We()).optional().describe("Paths of .stack documents awaiting load."),edits:ps(We(),rr({})).optional().describe("Editor state per stack id, present while Edit mode is active.")});function og(){return{frames:[],status:"idle",steps:0,seq:0,pendingEffects:[],navDepth:0}}function Lx(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.openStacks!="object"||e.openStacks===null?!1:Object.values(e.openStacks).every(n=>typeof n=="object"&&n!==null&&typeof n.currentCardId=="string"&&typeof n.stack=="object")}function ag(t,e,n){return t.shared&&n?`bg:${n}:${t.id}`:`card:${e}:${t.id}`}function Aj(t,e){return t.cards.findIndex(n=>n.id===e)}function so(t,e){return t.cards.find(n=>n.id===e)}function rv(t,e){if(e.background)return t.backgrounds?.find(n=>n.id===e.background)}function gj(t,e,n){const s=Aj(t,e),r=t.cards.length;switch(n.trim().toLowerCase()){case"next":return t.cards[(s+1+r)%r]?.id;case"prev":case"previous":return t.cards[(s-1+r)%r]?.id;case"first":return t.cards[0]?.id;case"last":return t.cards[r-1]?.id;case"back":return}const i=so(t,n);return i?i.id:t.cards.find(a=>a.name===n)?.id}function Rx(t,e){const n=rv(t,e),s=(n?.parts??[]).map(i=>({part:i,backgroundId:n?.id})),r=(e.parts??[]).map(i=>({part:i}));return[...s,...r]}function cg(t,e,n){return Rx(t,e).find(s=>s.part.id===n)}const mj=1e5,yj=64,bj=1e5,Fke=200;function lg(t){return{getVar:e=>t.variables[e],getField:e=>zx(t,e)}}function zx(t,e){const n=so(t.stack,t.currentCardId);if(!n)return;const s=cg(t.stack,n,e);if(!s)return;const r=ag(s.part,t.currentCardId,s.backgroundId);return t.fieldValues[r]??s.part.content??""}function Wx(t,e,n){const s=so(t.stack,t.currentCardId);if(!s)return;const r=cg(t.stack,s,e);if(!r)return;const i=ag(r.part,t.currentCardId,r.backgroundId);t.fieldValues[i]=n,t.fieldRev[i]=(t.fieldRev[i]??0)+1}function Du(t,e,n){e.var?t.variables[e.var]=typeof n=="number"?n:Tu(n):e.field&&Wx(t,e.field,Tu(n))}function iv(t,e){return e.var?xx(t.variables[e.var]??0):e.field?xx(zx(t,e.field)??0):0}function Jp(t,e){return t?.[e]??[]}function Nke(t,e){const n=so(t.stack,e);if(!n)return[];const s=rv(t.stack,n);return[...Jp(s?.script,"onOpenBackground"),...Jp(s?.script,"onOpenCard"),...Jp(n.script,"onOpenCard")]}function Pke(t,e){const n=so(t.stack,e);if(!n)return[];const s=rv(t.stack,n);return[...Jp(n.script,"onCloseCard"),...Jp(s?.script,"onCloseCard")]}function ug(t){return`t${t.seq++}`}function dg(t,e){t.frames.push({kind:"seq",body:e,ip:0})}function Lke(t,e){const n=t.runtime,s=lg(t);switch(e.do){case"go":{const r=zke(t,e.to);if(!r)break;const i=n.pendingVisual;n.pendingVisual=void 0;const o=[{do:"@closeCard"},{do:"@switchCard",to:r.toCardId,back:r.back},...i?[{do:"@transition",effect:i}]:[],{do:"@openCard"}];dg(n,o);break}case"put":Du(t,e,Wo(e.value,s));break;case"add":Du(t,e,iv(t,e)+ig(e.value,s));break;case"subtract":Du(t,e,iv(t,e)-ig(e.value,s));break;case"multiply":Du(t,e,iv(t,e)*ig(e.value,s));break;case"divide":Du(t,e,iv(t,e)/ig(e.value,s));break;case"set":{const r=e.property.toLowerCase(),i=Wo(e.value,s);r==="visible"||r==="visibility"?e.part&&(t.partVisibility[e.part]=XZ(i)):(r==="text"||r==="content")&&e.part&&Wx(t,e.part,Tu(i));break}case"show":t.partVisibility[e.part]=!0;break;case"hide":t.partVisibility[e.part]=!1;break;case"beep":n.pendingEffects.push({id:n.seq++,kind:"beep"});break;case"play":n.pendingEffects.push({id:n.seq++,kind:"play",sound:e.sound});break;case"openApp":n.pendingEffects.push({id:n.seq++,kind:"openApp",appId:e.app,event:e.event,data:e.data});break;case"answer":{const r=ug(n);n.dialog={kind:"answer",message:Tu(Wo(e.message,s)),buttons:e.buttons??["OK"],token:r},n.status="awaitingDialog",n.resume={token:r,container:Cj(e)};break}case"ask":{const r=ug(n);n.dialog={kind:"ask",message:Tu(Wo(e.prompt,s)),defaultValue:e.default?Tu(Wo(e.default,s)):"",token:r},n.status="awaitingDialog",n.resume={token:r,container:Cj(e)};break}case"visual":n.pendingVisual=e.effect;break;case"wait":{const r=ug(n);n.wait={ms:Math.max(0,e.ms),token:r},n.status="awaitingWait",n.resume={token:r};break}case"if":{const r=Bx(e.condition,s)?e.then:e.else??[];dg(n,r);break}case"repeat":{const r=e.while!==void 0?Number.POSITIVE_INFINITY:Math.min(e.times??0,bj);n.frames.push({kind:"repeat",body:e.body,ip:0,remaining:r,while:e.while});break}case"@closeCard":dg(n,Pke(t,t.currentCardId));break;case"@switchCard":Wke(t,e.to,e.back);break;case"@transition":{const r=ug(n);n.transition={effect:e.effect,toCardId:t.currentCardId,token:r},n.status="awaitingTransition",n.resume={token:r};break}case"@openCard":dg(n,Nke(t,t.currentCardId));break;default:{const r=e,i=rj(r.do);i?i.run(Rke(t),r):Ve("warn","HyperCard",`Unknown command "${r.do}"`);break}}}function Rke(t){const e=t.runtime;return{getVar:n=>t.variables[n],setVar:(n,s)=>{t.variables[n]=s},getField:n=>zx(t,n),setField:(n,s)=>Wx(t,n,s),evaluate:n=>Wo(n,lg(t)),show:(n,s)=>{t.partVisibility[n]=s},go:n=>dg(e,[{do:"go",to:n}]),queueEffect:(n,s)=>{e.pendingEffects.push({id:e.seq++,kind:"custom",name:n,args:s??{}})},await:(n,s,r)=>{const i=ug(e);e.pendingEffects.push({id:e.seq++,kind:"custom",name:n,args:s??{},token:i}),e.status="awaitingCustom",e.resume={token:i,container:r}}}}function Cj(t){if(t.var)return{var:t.var};if(t.field)return{field:t.field}}function zke(t,e){if(e.trim().toLowerCase()==="back")return t.history.length===0?void 0:{toCardId:t.history[t.history.length-1],back:!0};const n=t.stack,s=n.cards.findIndex(o=>o.id===t.currentCardId),r=n.cards.length;let i;switch(e.trim().toLowerCase()){case"next":i=n.cards[(s+1+r)%r]?.id;break;case"prev":case"previous":i=n.cards[(s-1+r)%r]?.id;break;case"first":i=n.cards[0]?.id;break;case"last":i=n.cards[r-1]?.id;break;default:i=n.cards.find(o=>o.id===e)?.id??n.cards.find(o=>o.name===e)?.id}if(i)return{toCardId:i,back:!1}}function Wke(t,e,n){const s=t.runtime;if(s.navDepth+=1,s.navDepth>yj){vj(t);return}n?t.history.pop():(t.history.push(t.currentCardId),t.history.length>Fke&&t.history.shift()),t.currentCardId=e}function Vke(t){const e=t.runtime,n=e.frames[e.frames.length-1];if(!n){e.status="idle";return}if(n.kind==="seq"){if(n.ip>=n.body.length){e.frames.pop();return}Lke(t,n.body[n.ip++]);return}if(n.while!==void 0){if(!Bx(n.while,lg(t))){e.frames.pop();return}}else{if(n.remaining<=0){e.frames.pop();return}n.remaining-=1}e.frames.push({kind:"seq",body:n.body,ip:0})}function Xp(t){const e=t.runtime;for(;e.status==="running";){if(e.steps++>mj){vj(t);return}if(e.frames.length===0){e.status="idle",e.navDepth=0;return}Vke(t)}}function vj(t){const e=t.runtime;e.frames=[],e.status="idle",e.navDepth=0}function pg(t,e){const n=t.runtime;n.status==="idle"&&(n.frames=[{kind:"seq",body:e,ip:0}],n.status="running",n.steps=0,n.navDepth=0,Xp(t))}function wj(t){const e=t.stack.stackScript?.onOpenStack??[];pg(t,[...e,{do:"@openCard"}])}function Sj(t,e,n){const s=so(t.stack,t.currentCardId);if(!s)return;const r=cg(t.stack,s,e);if(!r)return;const i=Jp(r.part.script,n);i.length!==0&&pg(t,i)}function Ej(t,e,n){const s=t.runtime;if(s.status!=="awaitingDialog"||!s.dialog||n!==void 0&&s.resume?.token!==n)return;const r=s.resume?.container;t.variables.it=e,r&&Du(t,r,e),s.dialog=void 0,s.resume=void 0,s.status="running",Xp(t)}function kj(t,e){const n=t.runtime;n.status==="awaitingWait"&&(e!==void 0&&n.wait?.token!==e||(n.wait=void 0,n.resume=void 0,n.status="running",Xp(t)))}function Ij(t,e){const n=t.runtime;n.status==="awaitingTransition"&&(e!==void 0&&n.transition?.token!==e||(n.transition=void 0,n.resume=void 0,n.status="running",Xp(t)))}function Tj(t,e,n){const s=t.runtime;if(s.status!=="awaitingCustom"||n!==void 0&&s.resume?.token!==n)return;const r=s.resume?.container;t.variables.it=e,r&&Du(t,r,e),s.resume=void 0,s.status="running",Xp(t)}function Dj(t,e){const n=new Set(e);t.runtime.pendingEffects=t.runtime.pendingEffects.filter(s=>!n.has(s.id))}const ov=[512,342],av=["onOpenStack","onCloseStack","onOpenCard","onCloseCard","onOpenBackground","onMouseUp","onMouseDown","onIdle"];function cv(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Vx(t){const e=[];if(!cv(t))return{ok:!1,errors:["Stack must be a JSON object."]};if((typeof t.name!="string"||t.name.length===0)&&e.push("Stack.name must be a non-empty string."),!Array.isArray(t.cards)||t.cards.length===0)return e.push("Stack.cards must be a non-empty array."),{ok:!1,errors:e};const n=new Set;return t.cards.forEach((s,r)=>{if(!cv(s)){e.push(`Card ${r} must be an object.`);return}typeof s.id!="string"||s.id.length===0?e.push(`Card ${r} is missing a string id.`):n.has(s.id)?e.push(`Duplicate card id "${s.id}".`):n.add(s.id),s.parts!==void 0&&Mj(s.parts,`card "${String(s.id)}"`,e)}),t.backgrounds!==void 0&&(Array.isArray(t.backgrounds)?t.backgrounds.forEach((s,r)=>{if(!cv(s)||typeof s.id!="string"){e.push(`Background ${r} is missing a string id.`);return}s.parts!==void 0&&Mj(s.parts,`background "${s.id}"`,e)}):e.push("Stack.backgrounds must be an array.")),e.length>0?{ok:!1,errors:e}:{ok:!0,stack:t}}function Mj(t,e,n){if(!Array.isArray(t)){n.push(`Parts of ${e} must be an array.`);return}const s=new Set;t.forEach((r,i)=>{if(!cv(r)){n.push(`Part ${i} of ${e} must be an object.`);return}typeof r.id!="string"||r.id.length===0?n.push(`Part ${i} of ${e} is missing a string id.`):s.has(r.id)?n.push(`Duplicate part id "${r.id}" in ${e}.`):s.add(r.id),(typeof r.type!="string"||r.type.length===0)&&n.push(`Part "${String(r.id)}" of ${e} is missing a string type.`)})}const Uke=()=>typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("field-sizing","content"),Gke=200,Hke={small:"classicyTextEditorSizeSmall",medium:"classicyTextEditorSizeMedium",large:"classicyTextEditorSizeLarge"},fg=({id:t,content:e,prefillValue:n,disabled:s=!1,labelDisabled:r,autoHeight:i=!1,border:o=!1,fitsScrollBars:a=!1,fontSize:c="medium",labelTitle:l,labelSize:d="medium",labelPosition:u="above",onChangeFunc:p,initialCaret:f,onCaretSettled:h,initialScroll:A,onScrollSettled:m,className:y,style:C})=>{const[v,S]=g.useState(n??e??"");g.useEffect(()=>{S(n??e??"")},[n,e]);const w=g.useRef(null);g.useLayoutEffect(()=>{if(!i||Uke())return;const P=w.current?.querySelector("textarea.classicyTextEditor");if(!P)return;const W=()=>{P.style.height="0px",P.style.height=`${P.scrollHeight}px`};W();let K=P.getBoundingClientRect().width;const L=typeof ResizeObserver=="function"?new ResizeObserver(()=>{const G=P.getBoundingClientRect().width;G!==K&&(K=G,W())}):void 0;L?.observe(P);const M=typeof document<"u"?document.fonts:void 0;return M?.addEventListener?.("loadingdone",W),()=>{L?.disconnect(),M?.removeEventListener?.("loadingdone",W),P.style.removeProperty("height")}},[i,v]);const k=ZV(),I=DA(),T=g.useCallback(P=>{S(P.target.value),p?.(P)},[p]),D=g.useRef(f),O=g.useRef(0),x=g.useRef(null),B=g.useRef(null),F=g.useRef(h);F.current=h,g.useLayoutEffect(()=>{const P=w.current?.querySelector("textarea.classicyTextEditor"),W=D.current;if(!P||typeof W!="number"||!Number.isFinite(W)||W<=0)return;const K=Math.min(Math.floor(W),P.value.length),{scrollLeft:L,scrollTop:M}=P;P.setSelectionRange(K,K),P.scrollLeft=L,P.scrollTop=M,O.current=K},[]);const z=g.useCallback(()=>{B.current=null;const P=x.current;P===null||P===O.current||(O.current=P,F.current?.(P))},[]),V=g.useCallback(P=>{x.current=P.currentTarget.selectionStart,F.current&&(B.current!==null&&clearTimeout(B.current),B.current=setTimeout(z,Gke))},[z]);return g.useEffect(()=>()=>{B.current!==null&&(clearTimeout(B.current),z())},[z]),b.jsxs("div",{ref:w,className:Ae("classicyTextEditorHolder",Ns(u),y),style:C,children:[l&&b.jsx(kt,{label:l,labelFor:t,labelSize:d,disabled:r??s}),b.jsx(Os,{className:Ae("classicyTextEditorArea",i&&"classicyTextEditorAreaAutoHeight",o&&"classicyTextEditorBorder"),vertical:a?"always":"auto",horizontal:a?"always":"auto",initialScroll:A,onScrollSettled:m,renderViewport:P=>b.jsx("textarea",{ref:P.ref,onScroll:P.onScroll,onSelect:V,onDoubleClick:k,onMouseDown:I?.onMouseDown,onContextMenu:I?.onContextMenu,id:t,disabled:s,className:Ae(P.className,"classicyTextEditor",Hke[c],i&&"classicyTextEditorAutoHeight",o&&"classicyTextEditorBevel"),value:v,onChange:T})})]})};function Yke(t){const[e,n,s,r]=t.rect??[0,0,0,0],i={left:e,top:n};return s&&(i.width=s),r&&(i.height=r),i}const Ux=({open:t,stackId:e,editing:n=!1,className:s,style:r})=>{const i=st(),o=so(t.stack,t.currentCardId),[a,c]=t.stack.size??ov;if(!o)return null;const l=(f,h)=>{i({type:"ClassicyAppHyperCardEvent",stackId:e,partId:f,event:"onMouseUp",...h!==void 0?{value:h}:{}})},d=(f,h)=>{i({type:"ClassicyAppHyperCardCommitField",stackId:e,partId:f,value:h})},u=(f,h)=>{i({type:"ClassicyAppHyperCardEvent",stackId:e,partId:f,event:h??"onMouseUp"})},p=Rx(t.stack,o);return b.jsx("div",{className:Ae("classicyHyperCardCanvas",s),style:{width:a,height:c,...r},children:p.map(({part:f,backgroundId:h})=>{const A=t.partVisibility[f.id]??f.visible??!0;if(!A&&!n)return null;const m=ag(f,t.currentCardId,h),y=t.fieldRev[m]??0,C=t.fieldValues[m]??f.content??"",v=["classicyHyperCardPart",n?"classicyHyperCardPartInert":"",n&&!A?"classicyHyperCardPartHidden":""].filter(Boolean).join(" ");return b.jsx("div",{className:v,style:Yke(f),...n?{"data-part-id":f.id,inert:!0}:{},children:Zke(f,{value:C,revKey:`${m}:${y}`,fireEvent:l,commitField:d,fire:u,stackId:e,getVariable:S=>t.variables[S],resolve:S=>qZ(S,lg(t))})},f.id)})})};function Zke(t,e){switch(t.type){case"button":return b.jsx($e,{onClickFunc:()=>e.fireEvent(t.id),children:t.name??t.content??"Button"});case"checkbox":return b.jsx(qn,{id:t.id,label:t.name??t.content??"",checked:e.value==="true",onClickFunc:s=>e.fireEvent(t.id,String(s))});case"radio":{const s=xj(t.options?.choices);return b.jsx(il,{name:t.id,label:t.name??"",inputs:s.map(r=>({id:r.value,label:r.label,checked:r.value===e.value})),onClickFunc:r=>e.fireEvent(t.id,r)})}case"popup":{const s=xj(t.options?.choices);return b.jsx(on,{id:t.id,label:t.name??"",options:s,selected:e.value,onChangeFunc:r=>e.fireEvent(t.id,r.target.value)})}case"slider":return b.jsx(si,{id:t.id,labelTitle:t.name??"",value:Number(e.value)||0,min:lv(t.options?.min,0),max:lv(t.options?.max,100),step:lv(t.options?.step,1),onCommitFunc:s=>e.fireEvent(t.id,String(s))});case"progress":return b.jsx(KC,{value:Number(e.value)||0,max:lv(t.options?.max,100),label:t.name});case"label":return b.jsx(kt,{label:e.value||t.name||""});case"image":return b.jsx("img",{className:"classicyHyperCardImage",src:String(t.options?.src??""),alt:t.name??""});case"field":return b.jsx(jke,{part:t,value:e.value,revKey:e.revKey,onCommit:s=>e.commitField(t.id,s)});case"group":return b.jsx("div",{className:"classicyHyperCardGroup",children:t.name??""})}const n=sj(t.type);return n?b.jsx(n,{part:t,partId:t.id,stackId:e.stackId,options:t.options??{},locked:t.locked??!1,value:e.value,setValue:s=>e.commitField(t.id,s),fire:s=>e.fire(t.id,s),getVariable:e.getVariable,resolve:e.resolve}):b.jsxs("div",{className:"classicyHyperCardMissingPart",children:["Missing part \u201C",t.type,"\u201D"]})}const jke=({part:t,value:e,revKey:n,onCommit:s})=>{const r=g.useRef(e);if(g.useEffect(()=>{r.current=e},[e]),t.locked)return b.jsx(Os,{className:"classicyHyperCardLockedField",viewportClassName:"classicyHyperCardLockedFieldText",children:e});const i=!!t.options?.multiline,o=()=>s(r.current),a=c=>{r.current=c.target.value};return b.jsx("div",{className:"classicyHyperCardFieldWrap",onBlur:o,children:i?b.jsx(fg,{id:t.id,prefillValue:e,border:!0,onChangeFunc:a},n):b.jsx(ri,{id:t.id,prefillValue:e,onChangeFunc:a,onEnterFunc:o},n)})};function xj(t){return Array.isArray(t)?t.map(e=>{if(typeof e=="string")return{value:e,label:e};const n=e,s=String(n.value??n.id??n.label??"");return{value:s,label:String(n.label??s)}}):[]}function lv(t,e){const n=Number(t);return Number.isFinite(n)?n:e}function Kke(t){return{stackSource:"editor",stack:t.draft,currentCardId:t.currentCardId,history:[],variables:{...t.draft.variables??{}},fieldValues:{},partVisibility:{},fieldRev:{},runtime:og()}}const Bj=({stackId:t,edit:e,className:n,style:s})=>{const[r,i]=e.draft.size??ov;return b.jsxs("div",{className:Ae("classicyHyperCardEditorCanvas",n),style:{width:r,height:i,...s},children:[b.jsx(Ux,{open:Kke(e),stackId:t,editing:!0}),b.jsx(QZ,{stackId:t,edit:e})]})};function uv(t){return`${JSON.stringify(t,null," ")}
82
82
  `}function Oj(t){return`${t.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").split("-").filter(Boolean).join("-")||"untitled"}.stack.json`}function Fj(t){const e=Vx(JSON.parse(uv(t)));if(!e.ok)return e;const n=new Blob([uv(t)],{type:"application/json"}),s=URL.createObjectURL(n),r=document.createElement("a");return r.href=s,r.download=Oj(t),r.click(),URL.revokeObjectURL(s),{ok:!0}}const Nj={id:"download",label:"Download",canSave:()=>!0,save:async(t,e)=>{const n=Fj(t);return"errors"in n?{ok:!1,error:n.errors[0]}:{ok:!0}}};function Pj(){pj(Nj)}const Lj={radio:[{key:"choices",label:"Choices",kind:"choices"}],popup:[{key:"choices",label:"Choices",kind:"choices"}],slider:[{key:"min",label:"Minimum",kind:"number",default:0},{key:"max",label:"Maximum",kind:"number",default:100},{key:"step",label:"Step",kind:"number",default:1}],progress:[{key:"max",label:"Maximum",kind:"number",default:100}],image:[{key:"src",label:"Image URL",kind:"text"}],field:[{key:"multiline",label:"Multiline",kind:"checkbox"}]};function Rj(t){return Lj[t]??Nx(t)?.optionsSchema}function zj(){return[...Ix.map(t=>({type:t.type,label:t.label})),...cj().map(({type:t,meta:e})=>({type:t,label:e.label}))]}const ro=({id:t,label:e,value:n,onCommit:s,type:r})=>{let i=n;return b.jsx("div",{className:"classicyHyperCardInspectorField",onBlur:()=>{i!==n&&s(i)},onKeyDown:o=>{o.key==="Enter"&&i!==n&&s(i)},children:b.jsx(ri,{id:t,labelTitle:e,prefillValue:n,type:r,onChangeFunc:o=>{i=o.target.value}})})},Qke=[{key:"shape",label:"Shape",values:["rectangle","roundRect","transparent","default"]},{key:"align",label:"Align",values:["left","center","right"]},{key:"fontSize",label:"Font size",values:["small","medium","large"]}],Wj=({stackId:t,edit:e,className:n,style:s})=>{const r=st(),i=rg(e.draft,e.currentCardId,e.layer)??[],o=e.selectedPartId?i.find(d=>d.id===e.selectedPartId):void 0;return b.jsx("div",{className:Ae("classicyHyperCardInspector",n),style:s,children:o?a(o):l()});function a(d){const u=d.rect??[0,0,120,60],p=Rj(d.type)??[],f=new Set(p.map(y=>y.key)),h=Object.keys(d.options??{}).filter(y=>!f.has(y)),A=y=>r({type:"ClassicyAppHCEditSetPartProps",stackId:t,partId:d.id,props:y}),m=y=>`${d.id}:${y}`;return b.jsxs(b.Fragment,{children:[b.jsx(kt,{label:`${d.type} "${d.id}"`}),b.jsx(ro,{id:m("id"),label:"ID",value:d.id,onCommit:y=>A({id:y})},m("id")),b.jsx(ro,{id:m("name"),label:"Name",value:d.name??"",onCommit:y=>A({name:y})},m("name")),["x","y","w","h"].map((y,C)=>b.jsx(ro,{id:m(y),label:y.toUpperCase(),value:String(u[C]),type:"number",onCommit:v=>{const S=[...u];S[C]=Number(v),r({type:"ClassicyAppHCEditSetRect",stackId:t,partId:d.id,rect:S})}},m(y))),b.jsx(qn,{id:m("visible"),label:"Visible",checked:d.visible??!0,onClickFunc:y=>A({visible:y})}),b.jsx(qn,{id:m("locked"),label:"Locked",checked:d.locked??!1,onClickFunc:y=>A({locked:y})}),b.jsx(qn,{id:m("shared"),label:"Shared (background fields)",checked:d.shared??!1,onClickFunc:y=>A({shared:y})}),Qke.map(y=>b.jsx(on,{id:m(y.key),label:y.label,options:[{value:"",label:"(default)"},...y.values.map(C=>({value:C,label:C}))],selected:d.style?.[y.key]??"",onChangeFunc:C=>r({type:"ClassicyAppHCEditSetPartStyle",stackId:t,partId:d.id,style:{[y.key]:C.target.value}})},m(y.key))),b.jsx("div",{className:"classicyHyperCardInspectorField",children:b.jsx(ro,{id:m("content"),label:"Content",value:d.content??"",onCommit:y=>A({content:y})})},m("content")),p.map(y=>c(d,y)),h.map(y=>c(d,{key:y,label:y,kind:"json"})),b.jsx($e,{onClickFunc:()=>r({type:"ClassicyAppHCEditShowScript",stackId:t,target:{kind:"part",partId:d.id}}),children:"Script\u2026"})]})}function c(d,u){const p=`${d.id}:opt:${u.key}`,f=d.options?.[u.key]??u.default,h=A=>r({type:"ClassicyAppHCEditSetPartOption",stackId:t,partId:d.id,key:u.key,value:A});if(u.kind==="checkbox")return b.jsx(qn,{id:p,label:u.label,checked:!!f,onClickFunc:A=>h(A)},p);if(u.kind==="choices"){const A=Array.isArray(f)?f.map(String).join(`