@classicy/classicy 3.1.0 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classicy.es.js +1 -1
- package/dist/classicy.umd.js +1 -1
- package/dist/classicy.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/classicy.umd.js
CHANGED
|
@@ -69,7 +69,7 @@ This is a plain text file opened in SimpleText.`},"Release Notes.md":{_type:Gt.M
|
|
|
69
69
|
- **New:** SimpleText opens text and markdown files
|
|
70
70
|
- *Improved* desktop state persistence
|
|
71
71
|
`},"Sample.pdf":{_type:Gt.Pdf,_mimeType:"application/pdf",_icon:hN,_url:"https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf"},"Sample 2.pdf":{_type:Gt.Pdf,_mimeType:"application/pdf",_icon:hN,_url:"https://raw.githubusercontent.com/mozilla/pdf.js/master/test/pdfs/hello_world_rotated.pdf"},"Sample 3.pdf":{_type:Gt.Pdf,_mimeType:"application/pdf",_icon:hN,_data:"H4sIAAAAAAAAA21R0U7CMBR931ccH0g0Udtu3dCE8MCEkKiRwN4ID4VdcGS2Zi0G_HrTbRHibJrm9txzzz237c2eJnfiXgYCHGa9DwYDsOz0SWCpcqo0O7CZ2pFFCI45hsOAdO6JYaeg4bHnIrdYRp6-AkvNQTsIsFfKCzUyRyw5OCLOIaRcXQhG_wr6syLt2v5sTtYcqg1ZeN7EaNcEAnFr0G-WGu1IOwv5x7a86PJCeufeIROft64i9RGMsloslMi2CDkSjizH9ZTK0twiLZW1xeZ0dYNsj3HmVdvCVj_uTFF7ZIvD2tVXDwqwkbLUZKZUfpErNurC5bGibcCRBPx3IYnjKMYWZ-wRTUafsfihg4moywul6GBR1D9jrlJFSVU9xqL4JiRgc2P8T7bvaZ2qXO1T8n7Q643fJj-sv2hkTQIAAA"}},Users:{_type:Gt.Directory,_icon:Lu,Guest:{_type:Gt.File,_mimeType:"text/plain",_data:"File Contents"},Shared:{_type:Gt.File,_mimeType:"text/plain",_data:"File Contents"}},Videos:{_type:Gt.Directory,_icon:Lu,"BuckBunny.mov":{_type:Gt.File,_creator:"QuickTime",_format:"Video",_mimeType:"text/plain",_data:JSON.stringify({url:"https://cdn1.911realtime.org/transcoded/newsw/2001-09-11/NEWSW_20010911_040000_The_National.m3u8",name:"Buck Bunny",options:{forceHLS:!0,forceSafariHLS:!1},type:"video"})},"Monkees.mp3":{_type:Gt.File,_creator:"QuickTime",_format:"Audio",_mimeType:"text/plain",_data:JSON.stringify({url:"http://www.samisite.com/sound/cropShadesofGrayMonkees.mp3",name:"Monkees",type:"audio",subtitlesUrl:"/test.srt"})}}}};async function Ent(e){const t=new Blob([new Uint8Array(e)]).stream().pipeThrough(new CompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}async function Unt(e){const t=new Blob([new Uint8Array(e)]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())}function Bnt(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Pnt(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4,l=atob(t+"=".repeat(n));return Uint8Array.from(l,s=>s.charCodeAt(0))}async function Hnt(e){const t=e instanceof Uint8Array?e:new Uint8Array(e),n=await Ent(t);return Bnt(n)}async function Su(e){const t=Pnt(e);return Unt(t)}const Knt=Object.freeze(Object.values(Gt).filter(e=>e!==Gt.Drive)),Qnt=new Set([Gt.File,Gt.TextFile,Gt.Markdown,Gt.Pdf,Gt.Stack]),p3=new Set(["__proto__","constructor","prototype"]),rh=new Map,pN=new Map;function W3(e,t){let n=pN.get(e);return n||(n=new Set,pN.set(e,n)),n.add(t),()=>{n.delete(t)}}function G3(e){return rh.get(e)?.version??0}function qnt(){rh.clear()}const _nt=(e,t)=>e!==""&&!e.startsWith("_")&&typeof t=="object"&&t!==null&&t._derived===!0?void 0:t;class hd{storageKey;separator;seq=0;flushTimer=null;shared;get fs(){return this.shared.tree}set fs(t){this.shared.tree=t}constructor(t="classicyStorage",n=dh,l=":",s=[],i){this.storageKey=t,this.separator=l;try{const o=Number(localStorage.getItem(`${this.storageKey}:seq`));Number.isFinite(o)&&o>0&&(this.seq=o)}catch{}const c=rh.get(t);if(c&&(i===void 0||c.epoch===i)){this.shared=c;return}Z3(t);const a=this.readStoredTree()??b3(n);this.shared=c??{tree:a,version:0},this.shared.epoch=i,rh.set(t,this.shared),this.fs=a,h3(this.fs,s,l),this.persist()}readStoredTree(){if(typeof window>"u")return;const t=localStorage.getItem(this.storageKey);if(t)try{const n=JSON.parse(t);if(bN(n))return n;Wt("warn","ClassicyFileSystem","localStorage data failed validation, using defaults")}catch(n){Wt("error","ClassicyFileSystem","Failed to parse localStorage data, using defaults:",n)}}load(t){try{const n=JSON.parse(t);this.fs=n,this.notifyMutation("load","")}catch(n){throw Wt("error","ClassicyFileSystem","Failed to parse data in load()",n),n}}snapshot(){return JSON.stringify(this.fs,_nt,2)}persist(){try{localStorage.setItem(this.storageKey,this.snapshot())}catch(t){Wt("error","ClassicyFileSystem","Failed to persist filesystem to localStorage.",t)}}nextSeq(){let t=0;try{const n=Number(localStorage.getItem(`${this.storageKey}:seq`));Number.isFinite(n)&&n>0&&(t=n)}catch{}this.seq=Math.max(this.seq,t)+1;try{localStorage.setItem(`${this.storageKey}:seq`,String(this.seq))}catch{}return this.seq}notifyMutation(t,n,l={}){const s={seq:this.nextSeq(),op:t,path:n,timestamp:new Date().toISOString(),...l};for(const i of bd())ch(i,"onChange",s);this.scheduleFlush(),this.shared.version+=1;for(const i of pN.get(this.storageKey)??[])i()}setMetadata(t,n){const l=this.resolve(t);return l?(Object.assign(l,n),this.notifyMutation("meta",t,{metadata:n}),!0):!1}applyDerivedTree(t){this.fs=t}scheduleFlush(){this.flushTimer!==null&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(this.flushNow,d3()),u3(this.flushNow,this.storageKey)}prepareFlush(){return this.flushTimer!==null&&(clearTimeout(this.flushTimer),this.flushTimer=null),m3(this.flushNow),this.persist(),this.buildSnapshot()}flushNow=()=>{const t=this.prepareFlush();for(const n of bd())ch(n,"onSnapshot",t)};flushNowAsync=async()=>{const t=this.prepareFlush();return(await Promise.all(bd().map(l=>ch(l,"onSnapshot",t)))).every(Boolean)};buildSnapshot(){const t=this.snapshot();return{tree:JSON.parse(t),hash:mN(ZN(new TextEncoder().encode(t))),seq:this.seq,storageKey:this.storageKey,timestamp:new Date().toISOString()}}async reconcileWithAdapters(){const t=this.buildSnapshot();for(const n of bd())if(n.reconcile)try{const l=await n.reconcile(t);if(l?.action!=="replace")continue;if(!bN(l.tree)){Wt("error","ClassicyFileSystem",`adapter "${n.id}" reconcile returned an invalid tree; keeping local`);continue}return this.load(JSON.stringify(l.tree)),this.flushNow(),!0}catch(l){Wt("error","ClassicyFileSystem",`adapter "${n.id}" failed in reconcile`,l)}return!1}pathArray=t=>{const n=t.split(this.separator).filter(l=>l!=="");return n.some(l=>p3.has(l))?null:n};resolve(t){const n=this.pathArray(t);if(n!==null)return n.reduce((l,s)=>l&&Object.hasOwn(l,s)?l[s]:void 0,this.fs)}formatSize(t,n="bytes",l=2){if(!+t)return`0 ${n}`;const s=n==="bits"?["Bits","Kb","Mb","Gb","Tb","Pb","Eb","Zb","Yb"]:["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(t)/Math.log(1024));return t=n==="bits"?t*8:t,`${parseFloat((t/1024**i).toFixed(Math.max(0,l)))} ${s[i]}`}filterMetadata(t,n="remove"){const l={};return Object.entries(t).forEach(([s,i])=>{n==="only"?s.startsWith("_")&&(l[s]=i):s.startsWith("_")||(l[s]=i)}),l}filterByType(t,n=Knt,l=!0,s=null){const i={};if(!this.resolve(t))return i;const c=Array.isArray(n)?n:[n];return Object.entries(this.resolve(t)).forEach(([a,o])=>{o._invisible===!0&&!l||this.isCreatedAfter(o,s)||c.includes(o._type)&&(i[a]=o)}),i}isCreatedAfter(t,n){if(n==null)return!1;const l=t?._createdOn;if(l==null)return!1;const s=new Date(l).getTime();if(Number.isNaN(s))return!1;const i=new Date(n).getTime();return Number.isNaN(i)?!1:s>i}async statFile(t){const n=this.resolve(t);if(n)return n._size=await this.size(t),n}async size(t){const n=typeof t=="string"?this.resolve(t):t;if(!n)return-1;if("_data"in n)try{return(await Su(String(n._data))).byteLength}catch{return new Blob(String(n._data).split("")).size}if(n._type===Gt.Shortcut)return 0;if(typeof n._size=="number")return n._size;if(typeof n._url=="string"){try{const l=await fetch(n._url,{method:"HEAD",signal:AbortSignal.timeout(8e3)}),s=l.headers.get("Content-Length");if(l.ok&&s!==null){const i=Number(s);if(!Number.isNaN(i))return n._size=i,i}}catch{}return-1}return n._type===Gt.Directory?this.calculateSizeDir(n):-1}hash(t){if(typeof t=="string"){const n=this.readFile(t);return n===void 0?void 0:mN(ZN(new TextEncoder().encode(n)))}if("_data"in t)return mN(ZN(new TextEncoder().encode(String(t._data))))}readFile(t){if(typeof t=="string"){const n=this.resolve(t);return this.readFile(n)}if("_data"in t)return t._data}writeFile(t,n,l){const s=this.pathArray(t);if(s===null)return!1;const i=s.pop();if(!i)return!1;const c=s.join(this.separator);s.length>0&&!this.resolve(c)&&this.mkDir(c);const a=s.length===0?this.fs:this.resolve(c);return a[i]={_type:Gt.TextFile,_createdOn:new Date().toISOString(),...l,_data:n},this.notifyMutation("write",t,{data:n,metadata:l}),!0}move(t,n,l={}){const s=this.pathArray(t),i=this.pathArray(n);if(s===null||i===null||s.length<1)return{ok:!1,reason:"missing"};const c=s[s.length-1],a=l.name??c;if(a===""||a.startsWith("_")||a.includes(this.separator)||p3.has(a))return{ok:!1,reason:"missing"};const o=s.slice(0,-1),r=this.resolve(t),u=o.length===0?this.fs:this.resolve(o.join(this.separator)),d=i.length===0?void 0:this.resolve(n);if(!r||!u||!d)return{ok:!1,reason:"missing"};if(d._type!==Gt.Directory&&d._type!==Gt.Drive)return{ok:!1,reason:"not-a-folder"};const m=o.join(this.separator),Z=i.join(this.separator);if(m===Z&&a===c)return{ok:!1,reason:"same-folder"};if(i.length>=s.length&&s.every((W,y)=>i[y]===W))return{ok:!1,reason:"into-itself"};if(r._type===Gt.Drive||r._system===!0||r._readOnly===!0||u._readOnly===!0||d._readOnly===!0)return{ok:!1,reason:"locked"};if(Object.hasOwn(d,a))return{ok:!1,reason:"exists"};delete u[c],d[a]=r;const b={},h=[];for(const[W,y]of Object.entries(l.metadata??{}))y===void 0?(delete r[W],h.push(W)):(r[W]=y,b[W]=y);const p=[...i,a].join(this.separator);return this.notifyMutation("move",s.join(this.separator),{to:p,...Object.keys(b).length>0?{metadata:b}:{},...h.length>0?{unsetMetadata:h}:{}}),{ok:!0,path:p}}rmDir(t){const n=this.deletePropertyPath(this.fs,t);return this.notifyMutation("rmdir",t),n}mkDir(t){const n=this.pathArray(t);if(n===null)return;const l=()=>({_type:"directory",_icon:tn("icons","system.folders.directory")??""});let s={},i;for(let c=n.length-1;c>=0;c--)i=s,s=c===0?{}:l(),s[n[c]]=c===n.length-1?l():i;this.fs=this.deepMerge(s,this.fs),this.notifyMutation("mkdir",t)}async calculateSizeDir(t){const n=c=>{let a=[];for(const o of Object.keys(c))o==="_type"&&Qnt.has(c[o])?a.push(c):typeof c[o]=="object"&&c[o]!==null&&(a=a.concat(n(c[o])));return a},l=typeof t=="string"?this.resolve(t):t,s=n(l);return(await Promise.all(s.map(c=>this.size(c)))).reduce((c,a)=>a>0?c+a:c,0)}countVisibleFiles(t){const n=this.resolve(t);return n?Object.entries(this.filterMetadata(n)).map(([s,i])=>!i._invisible).filter(s=>s||void 0).length:0}countInvisibleFilesInDir(t){const n=this.resolve(t);return n?Object.entries(this.filterMetadata(n)).map(([s,i])=>i._invisible).filter(s=>s===!0).length:0}statDirShell(t){const n=this.resolve(t);if(!n)return;const l=this.filterMetadata(n,"only"),s=t.split(this.separator).slice(-1),i={_count:this.countVisibleFiles(t),_countHidden:this.countInvisibleFilesInDir(t),_name:s[0],_path:t,_type:Gt.Directory};return Object.entries(l).forEach(([c,a])=>{i[c]=a}),i}async statDir(t){const n=this.statDirShell(t);if(!n)return;const l=this.resolve(t);return n._size=await this.calculateSizeDir(l),n}deepMerge(t,n){return Object.keys(n).forEach(l=>{if(l==="__proto__"||l==="constructor"||l==="prototype")return;const s=t[l]instanceof Object,i=n[l]instanceof Object;if(s&&i){const c=Array.isArray(t[l]),a=Array.isArray(n[l]);c&&a?t[l]=Array.from(new Set(t[l].concat(n[l]))):!c&&!a?this.deepMerge(t[l],n[l]):t[l]=n[l]}else t[l]=n[l]}),t}deletePropertyPath(t,n){const l=n.split(":");for(let i=0;i<l.length-1;i++){const c=l[i];if(c==="__proto__"||c==="constructor"||c==="prototype"||(t=t[c],typeof t>"u"))return}const s=l.pop();return s&&s!=="__proto__"&&s!=="constructor"&&s!=="prototype"&&delete t[s],t}}function y3(e,t){return BG(e,t)}const N3="System Folder",uh="Control Strip Modules",Y3=(e,t=[],n=":")=>{const l={_type:Gt.Directory,_icon:Kl.system.folders.controlStrip,_readOnly:!0},s=new Set(t),i=c=>s.has(c)||Object.hasOwn(l,c);for(const c of e){const a=c.label??c.name,o=c.name!==a&&n!==""&&c.name.includes(n);let r;s.has(c.name)||o?(r=c.name!==a&&!i(a)?a:jG(`${a} (${c.id})`,i),KA(uh,c.name,c.id,a,r,{moduleId:c.id,appId:c.appId,name:c.name})):r=Object.hasOwn(l,c.name)?jG(`${c.name} (${c.id})`,i):c.name,l[r]={_type:Gt.Extension,_icon:c.icon,_creator:c.appId??"ControlStrip",_format:"ControlStripModule",_readOnly:!0,_nameLocked:!0,_derived:!0}}return l},X3=(e,t,n=":")=>{const l=Object.keys(e).find(o=>e[o]?._type===Gt.Drive);if(!l)return e;const s=e[l][N3],i=s?.[uh],c=Yb(i),a=t.length>0;return!a&&c===i?e:{...e,[l]:{...e[l],[N3]:{...s??{_type:Gt.Directory},[uh]:a?{...c,...Y3(t,kG(c),n)}:c}}}},g3="System Folder",M3=(e,t=ba,n=":",l=[])=>{const s={_type:Gt.Directory,_icon:Kl.system.folders.extensions,_readOnly:!0},i=e.filter(o=>o.extension),c=i.map(o=>ol(t,o.id,{name:o.name,icon:o.icon})),a=vG("Extensions",i.map((o,r)=>({appId:o.id,name:o.name,displayName:c[r].name})),l,n);return i.forEach((o,r)=>{s[a[r]]={_type:Gt.Extension,_icon:c[r].icon,_creator:o.id,_readOnly:!0,_nameLocked:!0,_derived:!0}}),s},T3=(e,t,n=ba,l=":")=>{const s=Object.keys(e).find(r=>e[r]?._type===Gt.Drive);if(!s)return e;const i=e[s][g3],c=i?.Extensions,a=Yb(c),o=t.some(r=>r.extension);return!o&&a===c?e:{...e,[s]:{...e[s],[g3]:{...i??{_type:Gt.Directory},Extensions:o?{...a,...M3(t,n,l,kG(a))}:a}}}},Cu=Y.createContext({mode:"merge"}),mh=new Set;function $nt(e){e?mh.delete(e):mh.clear()}function Zh(e,t){return e?t==="exclusive"?e:y3(dh,e):dh}function pd(e,t){const{defaultFileSystem:n,mode:l,seedMigrations:s}=Y.useContext(Cu),i=ut(p=>p.System.Manager.Desktop.icons.filter(W=>W.kind===$o).map(W=>`${W.appId}\0${W.appName}\0${W.icon}`).join("")),c=ut(p=>Object.values(p.System.Manager.Applications.apps).filter(W=>W.extension).map(W=>`${W.id}\0${W.name}\0${W.icon}`).join("")),a=nh(),o=Ub(),r=wi(),u=JSON.stringify(lh(a,{mountedApps:o}).map(({definition:p})=>({id:p.id,name:sh(p,r),label:p.label,icon:p.fileIcon??tn("icons","system.controlStrip.moduleFile")??"",appId:p.appId}))),d=ut(p=>p.System.Manager.Desktop.fsVersion??0),m=e??"classicyStorage",Z=Y.useCallback(p=>W3(m,p),[m]),b=Y.useSyncExternalStore(Z,()=>G3(m),()=>0),h=Y.useMemo(()=>{const p=Zh(n,l),W=new hd(e,p,t,s,d);return W.applyDerivedTree($A(W.fs,ut.getState().System.Manager.Desktop.icons,r,W.separator)),W.applyDerivedTree(T3(W.fs,Object.values(ut.getState().System.Manager.Applications.apps),r,W.separator)),W.applyDerivedTree(X3(W.fs,JSON.parse(u),W.separator)),W},[u,n,l,s,e,t,i,c,r,d,b]);return Y.useEffect(()=>{mh.has(h.storageKey)||(mh.add(h.storageKey),h.reconcileWithAdapters().then(p=>{p&&ty({type:"ClassicyDesktopFileSystemVersionBump"})}).catch(p=>{Wt("error","ClassicyFileSystem","boot reconciliation failed; keeping local",p)}))},[h]),h}function I3(e,t){const{defaultFileSystem:n,mode:l,seedMigrations:s}=Y.useContext(Cu),i=ut(c=>c.System.Manager.Desktop.fsVersion??0);return Y.useCallback(()=>new hd(e,Zh(n,l),t,s,i),[n,l,s,e,t,i])}function V3(e){const t=e.filterByType("",Gt.Drive);return Object.entries(t).map(([n,l],s)=>({name:n,type:typeof l._driveType=="string"?l._driveType:"Classicy Volume",bus:typeof l._bus=="string"?l._bus:"ATA",id:typeof l._scsiId=="string"?l._scsiId:String(s),lun:typeof l._lun=="string"?l._lun:"0"}))}function A3(e,t,n){const l={...e},s=n[t];if(s)l[t]=structuredClone(s);else if(l[t]){const i={};for(const[c,a]of Object.entries(l[t]))c.startsWith("_")&&(i[c]=a);l[t]=i}return l}function fu(){return bd().length>0}function w3(e,t){return[{id:`drive_${e}_initialize`,title:"Initialize\u2026",event:"ClassicyDesktopDriveSetupInitialize",eventData:{drive:e}},{id:`drive_${e}_sync`,title:"Sync",event:"ClassicyDesktopDriveSetupSync",eventData:{drive:e},disabled:!t},{id:`drive_${e}_backup`,title:"Backup",event:"ClassicyDesktopDriveSetupBackup",eventData:{drive:e},disabled:!t}]}const x3="DriveSetup.app",z3=()=>{const e=Ut(),t=pd(),{defaultFileSystem:n,mode:l}=Y.useContext(Cu),s=ut(u=>u.System.Manager.Desktop.driveSetupRequestId??0),[i,c]=Y.useState(null),[a,o]=Y.useState(null);Y.useEffect(()=>{if(s===0)return;const u=ut.getState().System.Manager.Desktop.driveSetupRequest;if(u){if(e({type:"ClassicyDesktopDriveSetupClearRequest"}),u.action==="initialize"){c(u.drive);return}if(!fu()){o({label:"Not connected",message:"No server is configured. Log in to sync or back up your files.",type:"stop"});return}u.action==="sync"?t.reconcileWithAdapters().then(d=>{d&&e({type:"ClassicyDesktopFileSystemVersionBump"}),o({label:"Sync complete",message:d?"The filesystem was updated from the server.":"The filesystem is already up to date.",type:"note"})}).catch(()=>o({label:"Sync failed",message:"Could not sync from the server. Your local data is unchanged.",type:"stop"})):u.action==="backup"&&t.flushNowAsync().then(d=>o(d?{label:"Backup complete",message:"The filesystem was pushed to the server.",type:"note"}:{label:"Backup failed",message:"Could not push your files to the server. Your local data is unchanged.",type:"stop"}))}},[s]);const r=async()=>{const u=i;if(c(null),!u)return;const d=Zh(n,l),m=t.snapshot(),Z=A3(JSON.parse(m),u,d);if(t.load(JSON.stringify(Z)),!fu()){t.flushNow(),window.location.reload();return}if(await t.flushNowAsync()){window.location.reload();return}t.load(m),t.flushNow(),o({label:"Could not initialize",message:`\u201C${u}\u201D was not initialized: the server could not be reached. Your files have not been changed.`,type:"stop"})};return G.jsxs(G.Fragment,{children:[i?G.jsx("div",{className:"classicyDesktopDialogOverlay",children:G.jsx(_l,{id:"drive_setup_initialize",appId:x3,alertType:"caution",label:"Initialize this disk?",message:`Initializing \u201C${i}\u201D will erase all data on it. This cannot be undone.`,defaultButtonId:"cancel",buttons:[{id:"cancel",label:"Cancel",role:"cancel"},{id:"initialize",label:"Initialize",role:"normal",onClick:()=>{r()}}],onClose:()=>c(null)})}):null,a?G.jsx("div",{className:"classicyDesktopDialogOverlay",children:G.jsx(_l,{id:"drive_setup_feedback",appId:x3,alertType:a.type,label:a.label,message:a.message,buttons:[{id:"ok",label:"OK",role:"default"}],onClose:()=>o(null)})}):null]})},L3=({drives:e,selected:t,onSelect:n,className:l,style:s})=>G.jsxs("div",{className:$("classicyDriveSetupList",l),style:s,children:[G.jsx(Ot,{label:"List of Drives"}),G.jsx("div",{className:"classicyDriveSetupListTable",children:G.jsxs("table",{className:"classicyDriveSetupListGrid",children:[G.jsx("thead",{className:"classicyDriveSetupListHead",children:G.jsxs("tr",{children:[G.jsx("th",{children:"Volume Name(s)"}),G.jsx("th",{children:"Type"}),G.jsx("th",{children:"Bus"}),G.jsx("th",{children:"ID"}),G.jsx("th",{children:"LUN"})]})}),G.jsx("tbody",{children:e.map(i=>G.jsxs("tr",{"aria-selected":t===i.name,className:$("classicyDriveSetupListRow",Xe({selected:t===i.name})),onClick:()=>n(i.name),children:[G.jsx("td",{children:i.name}),G.jsx("td",{children:i.type}),G.jsx("td",{children:i.bus}),G.jsx("td",{children:i.id}),G.jsx("td",{children:i.lun})]},i.name))})]})})]}),WN="DriveSetup.app";Ln({id:WN,description:"Disk utility: initialize the startup disk or sync it with its backend."});const ml=WN,Ta="Drive Setup",GN="DriveSetup_1",S3=()=>{const e=jt("icons","system.drives.disk")??"",t=Ut(),n=pd(),l=ut(W=>W.System.Manager.Desktop.fsVersion??0),s=Ut(),i=Il(ml,{name:Ta,icon:e}),{aboutMenuItem:c,aboutWindow:a}=ul(ml,Ta,e),o=Al(ml),[r,u]=Y.useState(null),d=Y.useMemo(()=>V3(n),[n,l]),m=fu(),Z=(W,y)=>{t({type:`ClassicyDesktopDriveSetup${W}`,drive:y})},b={id:`${ml}_functions`,title:"Functions",menuChildren:[{id:`${ml}_fn_initialize`,title:"Initialize\u2026",event:"ClassicyDesktopDriveSetupInitialize",eventData:{drive:r??""},disabled:!r},{id:`${ml}_fn_sync`,title:"Sync",event:"ClassicyDesktopDriveSetupSync",eventData:{drive:r??""},disabled:!m},{id:`${ml}_fn_backup`,title:"Backup",event:"ClassicyDesktopDriveSetupBackup",eventData:{drive:r??""},disabled:!m}]},h=[{id:`${ml}_file`,title:"File",menuChildren:[{...c,title:`About ${Ta}`},{...ts(`${ml}_close_window`,()=>o(GN,$l(ml,Ta,e))),keyboardShortcut:"\u2325W"},{id:"spacer"},{...wl(ml,Ta,e),keyboardShortcut:"\u2325Q"}]},b],p=()=>{s($l(ml,Ta,e))};return G.jsxs(G.Fragment,{children:[G.jsx(z3,{}),G.jsxs(vn,{id:ml,name:Ta,icon:e,defaultWindow:GN,showDesktopIcon:!1,showInApplicationsFolder:!0,addSystemMenu:!0,children:[G.jsx(ge,{id:GN,title:i.name,appId:ml,icon:i.icon,closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,initialSize:[440,0],initialPosition:[120,80],modal:!1,appMenu:h,backgroundColor:"var(--color-system-03)",children:G.jsxs("div",{className:"driveSetupContent",children:[G.jsx(L3,{drives:d,selected:r,onSelect:u}),G.jsxs("div",{className:"driveSetupButtons",children:[G.jsx(Ft,{disabled:!m,onClickFunc:()=>Z("Backup",r??""),children:"Backup"}),G.jsx(Ft,{disabled:!m,onClickFunc:()=>Z("Sync",r??""),children:"Sync"}),G.jsx(Ft,{disabled:!r,onClickFunc:()=>r&&Z("Initialize",r),children:"Initialize\u2026"}),G.jsx(Ft,{onClickFunc:()=>p(),children:"Quit"})]})]})}),a]})]})},Ru="ScreenSaverManager.app";Ln({id:Ru,description:"Control panel for the screen saver: pick a module and set idle timing."});const C3=(e,t,n)=>{if(t.length===0)return n;const l=e!==null&&typeof e=="object"?e:{},[s,...i]=t;return{...l,[s]:C3(l[s],i,n)}},f3=({saver:e,config:t,onChange:n})=>_b(e.configSchema)==="object"?G.jsx($b,{schema:e.configSchema,values:t,idPrefix:`ScreenSaver_${e.id}`,onChange:(l,s)=>n({[l[0]]:C3(t[l[0]],l.slice(1),s)})}):null,yN=(e,t)=>Hp(e,t),NN=e=>Kp().filter(t=>yN(t,e)),bh=(e,t)=>{const n=YT().filter(s=>yN(s,e)),l=s=>s===void 0?void 0:n.find(i=>i.id===s);return l(t)??l(Uo(e)?.defaultScreenSaver)??n[0]},R3=(e=ut.getState())=>al(e.System?.Manager?.Appearance?.packageId)?.id??pe,Fc="ScreenSaver.app",F3="Screen Saver",YN=5,hh=1,ph=240,Wd="ClassicyAppScreenSaverActivate",D3=jn({enabled:Qn().optional().describe("Master switch; false disables idle activation and Activate commands."),timeoutMinutes:Zn().optional().describe("Minutes of inactivity before the saver starts."),selectedSaver:Xt().optional().describe("Id of the registered screensaver to run."),active:Qn().optional().describe("Whether the saver is on screen right now (transient)."),saverConfigs:Tl(Xt(),Tl(Xt(),fo())).optional().describe("Saved options per saver id.")});function Fu(e){return e.enabled!==!1}function XN(e){const t=e.timeoutMinutes;return typeof t!="number"||!Number.isFinite(t)?YN:Math.min(Math.max(t,hh),ph)}const gN=(e,...t)=>{Wt("warn","ScreenSaver",e,...t)},k3=(e,t)=>{const n=e.System.Manager.Applications.apps[Fc];if(!n)return e;const l={...n.data??{}};switch(t.type){case Wd:{if(!Fu(l)||!bh(R3(e),l.selectedSaver))break;l.active=!0;break}case"ClassicyAppScreenSaverDeactivate":{l.active=!1;break}case"ClassicyAppScreenSaverSetSaver":{const s="saverId"in t&&typeof t.saverId=="string"?t.saverId:void 0;if(!s)break;if(!SZ(s)){gN("Unknown screensaver id",s);break}l.selectedSaver=s;break}case"ClassicyAppScreenSaverSetTimeout":{const s="minutes"in t&&typeof t.minutes=="number"?t.minutes:Number.NaN;if(!Number.isFinite(s))break;l.timeoutMinutes=Math.min(Math.max(s,hh),ph);break}case"ClassicyAppScreenSaverSetEnabled":{if(!("enabled"in t)||typeof t.enabled!="boolean")break;l.enabled=t.enabled,t.enabled||(l.active=!1);break}case"ClassicyAppScreenSaverSetConfig":{const s="saverId"in t&&typeof t.saverId=="string"?t.saverId:void 0,i="config"in t&&typeof t.config=="object"&&t.config!==null&&!Array.isArray(t.config)?t.config:void 0;if(!s||!i)break;const c=SZ(s);if(!c){gN("SetConfig for unknown screensaver id",s);break}const a={...c.defaultConfig??{},...l.saverConfigs?.[s]??{},...i};let o=a;if(c.configSchema){const r=c.configSchema.safeParse(a);if(!r.success){gN("SetConfig rejected by saver schema",s,r.error);break}o=r.data}l.saverConfigs={...l.saverConfigs??{},[s]:o};break}}return n.data=l,e};Ln({id:Fc,description:"Idle-activated full-screen screensavers with per-saver options.",prefix:"ClassicyAppScreenSaver",handler:k3,actions:{[Wd]:{description:"Start the screensaver immediately (ignored while disabled, or when the active appearance offers no saver).",scriptable:!0},ClassicyAppScreenSaverDeactivate:{description:"Dismiss the running screensaver."},ClassicyAppScreenSaverSetSaver:{description:"Choose which registered screensaver runs (it runs while the active appearance offers it).",params:ft({saverId:Xt().describe("Id of a registered screensaver.")})},ClassicyAppScreenSaverSetTimeout:{description:"Set the idle timeout before the saver starts.",params:ft({minutes:Zn().describe("Minutes of inactivity (clamped to 1\u2013240).")})},ClassicyAppScreenSaverSetEnabled:{description:"Turn the screensaver feature on or off (off also dismisses it).",params:ft({enabled:Qn().describe("Whether idle activation is enabled.")})},ClassicyAppScreenSaverSetConfig:{description:"Merge option values into a saver's saved config (validated against the saver's schema).",params:ft({saverId:Xt().describe("Id of the saver the options belong to."),config:Tl(Xt(),fo()).describe("Option values to merge into the saved config.")})}},state:D3});const Qs=Ru,Gd="Screen Saver",MN="ScreenSaverManager_1";function j3(){const e=Ut(),t=jt("icons","system.extensions.screensaver")??"",n=Il(Qs,{name:Gd,icon:t}),{aboutMenuItem:l,aboutWindow:s}=ul(Qs,Gd,t),i=Al(Qs),c=Yu(Qs),o=ut(p=>p.System.Manager.Applications.apps[Fc]?.data)??{},r=Ga().id;LZ();const u=NN(r),d=bh(r,o.selectedSaver),m=d?.id??"",Z=d?Qp(d,o.saverConfigs?.[d.id]):{},b=p=>{d&&e({type:"ClassicyAppScreenSaverSetConfig",saverId:d.id,config:p})},h=d?.configComponent;return G.jsxs(vn,{id:Qs,name:Gd,icon:t,defaultWindow:MN,showDesktopIcon:!1,showInApplicationsFolder:!1,addSystemMenu:!0,children:[G.jsx(ge,{id:MN,title:n.name,appId:Qs,icon:n.icon,closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,initialSize:[420,0],initialPosition:[320,80],modal:!1,backgroundColor:"var(--color-system-03)",appMenu:[{id:`${Qs}_file`,title:"File",menuChildren:[{...l,title:`About ${Gd}`},{...ts(`${Qs}_close_window`,()=>i(MN,$l(Qs,Gd,t))),keyboardShortcut:"\u2325W"},{id:"spacer"},{...wl(Qs,Gd,t),keyboardShortcut:"\u2325Q"}]},c],children:G.jsxs(bx,{className:"classicyScreenSaverManagerContent",children:[G.jsxs(Jn,{label:"Screen Saver",layout:"form",children:[G.jsx(Cc,{children:G.jsx(Xn,{id:"ScreenSaverManager_enabled",label:"Start screen saver when idle",checked:Fu(o),onClickFunc:p=>e({type:"ClassicyAppScreenSaverSetEnabled",enabled:p})})}),u.length===0?G.jsx(Cc,{children:G.jsx("span",{children:"This appearance has no screen savers."})}):G.jsx(Me,{id:"ScreenSaverManager_saver",label:"Screen saver",labelPosition:"left",options:u.map(p=>({value:p.id,label:p.name})),selected:m,onChangeFunc:p=>e({type:"ClassicyAppScreenSaverSetSaver",saverId:p.target.value})}),G.jsx(Li,{id:"ScreenSaverManager_timeout",labelTitle:"Minutes of inactivity",labelPosition:"left",minValue:hh,maxValue:ph,prefillValue:XN(o),onChangeFunc:p=>{const W=Number.parseInt(p.target.value,10);Number.isFinite(W)&&e({type:"ClassicyAppScreenSaverSetTimeout",minutes:W})}}),G.jsx(Cc,{justify:"end",children:G.jsx(Ft,{disabled:u.length===0,onClickFunc:()=>e({type:Wd}),children:"Test"})})]}),d&&G.jsx(Jn,{label:`Options for ${d.name}`,layout:"form",children:h?G.jsx(h,{config:Z,onChange:b}):d.configSchema?G.jsx(f3,{saver:d,config:Z,onChange:b}):G.jsx(Cc,{children:G.jsx("span",{children:"This screen saver has no options."})})},d.id)]})}),s]})}const TN="SoundManager.app";Ln({id:TN,description:"Control panel for alert sounds and system volume."});const Wh=({direction:e="right",open:t,defaultOpen:n=!1,onToggle:l,interactive:s=!0,className:i,style:c})=>{const[a,o]=Y.useState(n),{track:r}=Nn(),u=t!==void 0,d=u?t:a,m="classicyTriangle"+e.charAt(0).toUpperCase()+e.slice(1)+(d?"Open":"Closed");function Z(){const p=!d;r("click",{expanded:p,type:"ClassicyTriangle",direction:e}),u||o(p),l?.(p)}function b(p){switch(p.key){case"Enter":case" ":{Z();break}}}const h=G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 6.44 11.12",className:$("classicyTriangle",m,!s&&i),style:s?void 0:c,"aria-hidden":s?void 0:!0,children:[G.jsx("title",{children:"Toggle"}),G.jsx("polygon",{className:"classicyTriangleDropShadow",points:"6.44 6.05 1.17 1.07 .93 11.12 6.44 6.05"}),G.jsx("polygon",{className:"classicyTriangleOutline",points:"5.68 5.34 0 0 0 10.68 5.68 5.34"}),G.jsx("polygon",{className:"classicyTriangleHighlight",points:"4.79 5.34 .76 1.82 .76 8.86 4.79 5.34"}),G.jsx("polygon",{className:"classicyTriangleInner",points:"4.79 5.34 1.27 3.42 1.29 8.43 4.79 5.34"}),G.jsx("polygon",{className:"classicyTriangleShadow",points:".76 8.29 .76 8.86 4.79 5.34 4.47 5.05 .76 8.29"})]});return s?G.jsx("div",{role:"button","aria-expanded":d,tabIndex:0,className:i,style:c,onClick:Z,onKeyDown:b,children:h}):h},v3=({direction:e="right",label:t="",labelSize:n="medium",labelPosition:l="right",children:s,className:i,style:c})=>{const[a,o]=Y.useState(!1),{track:r}=Nn(),u={type:"ClassicyLabel",label:t},d=Y.useRef(null),m=Re("Disclosure",{},d);function Z(h){r("click",{expanded:h,...u}),m.emit(h?"expand":"collapse",kt()),o(h)}function b(h){switch(h.key){case"Enter":case" ":{h.preventDefault(),Z(!a);break}case"ArrowRight":{(h.metaKey||h.ctrlKey)&&!a&&(h.preventDefault(),Z(!0));break}case"ArrowLeft":{(h.metaKey||h.ctrlKey)&&a&&(h.preventDefault(),Z(!1));break}}}return G.jsxs("div",{...m.attrs,ref:d,className:$("classicyDisclosure",m.className,i),style:m.style?{...m.style,...c}:c,children:[G.jsxs("div",{role:"button",className:$("classicyDisclosureHeader",l==="left"&&"classicyDisclosureLabelLeft"),onClick:()=>Z(!a),tabIndex:0,"aria-expanded":a,onKeyDown:h=>b(h),children:[G.jsx(Wh,{direction:e,open:a,interactive:!1}),G.jsx(Ot,{label:t,labelSize:n})]}),G.jsx("div",{className:$("classicyDisclosureInner",a?"":"classicyDisclosureInnerClose",Xe({open:a})),children:s})]})},ns=TN,Ia="Sound Manager",J3="SoundManager_1",O3=()=>{const e=jt("icons","controlPanels.soundManager.app")??"",t=Ut(),n=ya(),l=ql(),s=Il(ns,{name:Ia,icon:e}),{aboutMenuItem:i,aboutWindow:c}=ul(ns,Ia,e),a=Al(ns),o=b=>{l(b?{type:"ClassicySoundEnableOne",enabled:"*"}:{type:"ClassicySoundDisableOne",disabled:"*"})},r=n.volume??100,u=Y.useCallback((b,h)=>{l(b?{type:"ClassicySoundEnableOne",enabled:h}:{type:"ClassicySoundDisableOne",disabled:h})},[l]),d=()=>{t($l(ns,Ia,e))},m=[{id:`${ns}_file`,title:"File",menuChildren:[{...i,title:`About ${Ia}`},{...ts(`${ns}_close_window`,()=>a(J3,$l(ns,Ia,e))),keyboardShortcut:"\u2325W"},{id:"spacer"},{...wl(ns,Ia,e),keyboardShortcut:"\u2325Q"}]}],Z=Y.useMemo(()=>{const b=new Map;for(const h of n.labels)h.group!=="Alert"&&(b.has(h.group)||b.set(h.group,[]),b.get(h.group)?.push(h));return b},[n.labels]);return G.jsxs(vn,{id:ns,name:Ia,icon:e,defaultWindow:"SoundManager_1",showDesktopIcon:!1,showInApplicationsFolder:!1,addSystemMenu:!0,children:[G.jsx(ge,{id:J3,title:s.name,appId:ns,icon:s.icon,closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,initialSize:[480,0],initialPosition:[300,50],modal:!1,appMenu:m,children:G.jsxs("div",{className:"classicySoundManagerContent",children:[G.jsx(Xn,{id:"disable_sounds",isDefault:!0,label:"Enable Interface Sounds",onClickFunc:o,checked:!n.disabled.includes("*")}),G.jsx(xl,{id:"sound_volume",labelTitle:"Volume:",labelPosition:"left",value:r,min:0,max:100,valueLabel:`${r}%`,onChangeFunc:b=>l({type:"ClassicyVolumeSet",volume:Number(b.target.value)}),onCommitFunc:()=>l({type:"ClassicyAlertSound"})}),G.jsx(v3,{label:"Disable Sounds",children:G.jsx("div",{className:"soundManagerControlGroupHolder",children:[...Z.entries()].map(([b,h])=>G.jsx(Jn,{label:b,columns:!0,children:h.map(p=>G.jsx(Xn,{id:`enable_sound_${p.id}`,label:p.label,checked:!n.disabled.includes("*")&&!n.disabled.includes(p.id),onClickFunc:W=>u(W,p.id)},`${ns}_${b}${p.id}`))},`${ns}_${b}`))})}),G.jsx(Ft,{isDefault:!1,onClickFunc:d,children:"Quit"})]})}),c]})};function E3(){return G.jsxs(G.Fragment,{children:[G.jsx(Kx,{}),G.jsx(O3,{}),G.jsx(c3,{}),G.jsx(S3,{}),G.jsx(j3,{}),G.jsx(e3,{})]})}function U3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,l)}return n}function Xs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?U3(Object(n),!0).forEach(function(l){tlt(e,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):U3(Object(n)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(n,l))})}return e}function tlt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var B3={},P3="https://www.googletagmanager.com/gtag/js",H3={debug_mode:!1,send_page_view:!1,anonymize_ip:!1,allow_google_signals:!0,allow_ad_personalization_signals:!0,cookie_flags:""},elt={gtagName:"gtag",dataLayerName:"ga4DataLayer",measurementIds:[],gtagConfig:H3};function nlt(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=0,n=IN(e.measurementIds),l=Xs(Xs({},elt),e);return{name:"google-analytics",config:l,initialize:function(i){var c=i.config,a=i.instance,o=c.dataLayerName,r=c.customScriptSrc,u=c.gtagName,d=c.gtagConfig,m=c.debug,Z=c.nonce,b=o?"&l=".concat(o):"",h=r||"".concat(P3,"?id=").concat(n[0]).concat(b);if(!Q3(h)){var p=document.createElement("script");p.async=!0,p.src=h,Z&&p.setAttribute("nonce",Z),document.body.appendChild(p)}window[o]||(window[o]=window[o]||[]),window[u]||(window[u]=function(){window[o].push(arguments)}),window[u]("js",new Date);var W=Xs(Xs({},H3),d||{});m===!0?W.debug_mode=!0:delete W.debug_mode;var y=a.user()||{},N=y.traits||{};Object.keys(N).length&&window[u]("set","user_properties",N);for(var X=0;X<n.length;X++)B3[n[X]]||(window[u]("config",n[X],W),B3[n[X]]=!0)},identify:function(i){var c=i.payload,a=i.config,o=a.gtagName;!window[o]||!n.length||(c.userId&&window[o]("set",{user_id:c.userId}),Object.keys(c.traits).length&&window[o]("set","user_properties",c.traits))},page:function(i){var c=i.payload,a=i.config,o=i.instance,r=a.gtagName,u=a.gtagConfig;if(!(!window[r]||!n.length)){var d=c.properties,m=d.send_to,Z=o.getState("context.campaign"),b={page_title:d.title,page_location:d.url,page_path:d.path||document.location.pathname,page_hash:d.hash,page_search:d.page_search,page_referrer:d.referrer},h=K3(Z),p=o.user("userId"),W=Xs(Xs(Xs(Xs({},m?{send_to:m}:{}),b),h),p?{user_id:p}:{});if(u&&u.send_page_view&&t===0){t++;return}window[r]("event","page_view",W),t++}},track:function(i){var c=i.payload,a=i.config,o=i.instance,r=c.properties,u=c.event,d=o.getState("context.campaign"),m=a.gtagName;if(!(!window[m]||!n.length)){var Z=K3(d),b=o.user("userId"),h=Xs(Xs(Xs({},r),Z),b?{user_id:b}:{});window[m]("event",u,h)}},loaded:function(){var i=l.dataLayerName,c=l.customScriptSrc,a=i&&window[i]&&Array.prototype.push===window[i].push;return Q3(c||P3)&&a},methods:{addTag:function(i){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};window[l.gtagName]&&(window[l.gtagName]("config",i,c),n&&!n.includes(i)&&(n=n.concat(i)))},disable:function(i){for(var c=i?IN(i):n,a=0;a<n.length;a++){var o=n[a];c.includes(o)&&(window["ga-disable-".concat(o)]=!0)}},enable:function(i){for(var c=i?IN(i):n,a=0;a<n.length;a++){var o=n[a];c.includes(o)&&(window["ga-disable-".concat(o)]=!1)}}}}}function IN(e){if(!e)throw new Error("No GA Measurement ID defined");if(Array.isArray(e))return e;if(typeof e=="string")return[e];throw new Error("GA Measurement ID must be string or array of strings")}function K3(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={},n=e.id,l=e.name,s=e.source,i=e.medium,c=e.content,a=e.keyword;return n&&(t.campaignId=n),l&&(t.campaignName=l),s&&(t.campaignSource=s),i&&(t.campaignMedium=i),c&&(t.campaignContent=c),a&&(t.campaignKeyword=a),t}function Q3(e){var t=document.querySelectorAll("script[src]"),n=new RegExp("^".concat(e));return!!Object.values(t).filter(function(l){return n.test(l.src)}).length}var llt=nlt;function q3(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,l)}return n}function Gh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?q3(Object(n),!0).forEach(function(l){slt(e,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q3(Object(n)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(n,l))})}return e}function slt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ilt={debug:!1,containerId:null,dataLayerName:"dataLayer",dataLayer:void 0,preview:void 0,auth:void 0,execution:"async"},yh;function clt(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t="https://www.googletagmanager.com/gtm.js";return{name:"google-tag-manager",config:Gh(Gh({},ilt),e),initialize:function(l){var s=l.config,i=s.containerId,c=s.dataLayerName,a=s.customScriptSrc,o=s.preview,r=s.auth,u=s.execution,d=s.nonce;if(!i)throw new Error("No google tag manager containerId defined");if(o&&!r)throw new Error("When enabling preview mode, both preview and auth parameters must be defined");var m=a||t;$3(i,m)||((function(Z,b,h,p,W){Z[p]=Z[p]||[],Z[p].push({"gtm.start":new Date().getTime(),event:"gtm.js"});var y=b.getElementsByTagName(h)[0],N=b.createElement(h),X=p!="dataLayer"?"&l="+p:"",g=o?">m_preview="+o+">m_auth="+r+">m_cookies_win=x":"";u&&(N[u]=!0),N.src="".concat(m,"?id=")+W+X+g,d&&N.setAttribute("nonce",d),y.parentNode.insertBefore(N,y)})(window,document,"script",c,i),yh=c,s.dataLayer=window[c])},page:function(l){var s=l.payload;l.options,l.instance;var i=l.config;typeof i.dataLayer<"u"&&i.dataLayer.push(s.properties)},track:function(l){var s=l.payload;l.options;var i=l.config;if(typeof i.dataLayer<"u"){var c=s.anonymousId,a=s.userId,o=s.properties,r=o;a&&(r.userId=a),c&&(r.anonymousId=c),o.category||(r.category="All"),i.debug&&console.log("dataLayer push",Gh({event:s.event},r)),i.dataLayer.push(Gh({event:s.event},r))}},loaded:function(){var l=!!yh&&!!(window[yh]&&Array.prototype.push!==window[yh].push);return $3(e.containerId,e.customScriptSrc||t)&&l}}}var _3={};function $3(e,t){var n=_3[e];if(!n){var l=t.replace(/^https?:\/\//,"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(l+".*[?&]id="+e),_3[e]=n}var s=document.querySelectorAll("script[src]");return!!Object.keys(s).filter(function(i){return(s[i].src||"").match(n)}).length}var alt=clt;function tz(e,t,n,l,s){for(t=t.split?t.split("."):t,l=0;l<t.length;l++)e=e?e[t[l]]:s;return e===s?n:e}var olt="function",dlt="string",gs="undefined",rlt="boolean",Nh="object",ult="array",mlt="number",Zlt="symbol",blt="null",ez="any",nz="*",Va="__",hlt="form",plt="input",Wlt="button",Glt="select",Yh=typeof process!==gs?process:{};Yh.env&&Yh.env.NODE_ENV;var Ms=typeof document!==gs;Yh.versions!=null&&Yh.versions.node!=null,typeof Deno!==gs&&Deno.core,Ms&&window.name==="nodejs"||typeof navigator!==gs&&typeof navigator.userAgent!==gs&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function lz(e,t){return t.charAt(0)[e]()+t.slice(1)}var ylt=lz.bind(null,"toUpperCase"),Nlt=lz.bind(null,"toLowerCase");function Ylt(e){return sz(e)?ylt(blt):typeof e===Nh?Ilt(e):Object.prototype.toString.call(e).slice(8,-1)}function Xh(e,t){t===void 0&&(t=!0);var n=Ylt(e);return t?Nlt(n):n}function Du(e,t){return typeof t===e}var qs=Du.bind(null,olt),yd=Du.bind(null,dlt),Nd=Du.bind(null,gs),Xlt=Du.bind(null,rlt);Du.bind(null,Zlt);function sz(e){return e===null}function glt(e){return Xh(e)===mlt&&!isNaN(e)}function Mlt(e){return Xh(e)===ult}function Zl(e){if(!Tlt(e))return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Tlt(e){return e&&(typeof e===Nh||e!==null)}function Ilt(e){return qs(e.constructor)?e.constructor.name:null}function Vlt(e){return e instanceof Error||yd(e.message)&&e.constructor&&glt(e.constructor.stackTraceLimit)}function iz(e,t){if(typeof t!="object"||sz(t))return!1;if(t instanceof e)return!0;var n=Xh(new e(""));if(Vlt(t))for(;t;){if(Xh(t)===n)return!0;t=Object.getPrototypeOf(t)}return!1}iz.bind(null,TypeError),iz.bind(null,SyntaxError);function gh(e,t){var n=e instanceof Element||e instanceof HTMLDocument;return n&&t?Alt(e,t):n}function Alt(e,t){return t===void 0&&(t=""),e&&e.nodeName===t.toUpperCase()}function Mh(e){var t=[].slice.call(arguments,1);return function(){return e.apply(void 0,[].slice.call(arguments).concat(t))}}Mh(gh,hlt),Mh(gh,Wlt),Mh(gh,plt),Mh(gh,Glt);function cz(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return null}}function wlt(){if(Ms){var e=navigator,t=e.languages;return e.userLanguage||(t&&t.length?t[0]:e.language)}}function xlt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}function zlt(e){return(function(t){for(var n,l=Object.create(null),s=/([^&=]+)=?([^&]*)/g;n=s.exec(t);){var i=cz(n[1]),c=cz(n[2]);if(i)if(i.substring(i.length-2)==="[]"){var a=l[i=i.substring(0,i.length-2)]||(l[i]=[]);l[i]=Array.isArray(a)?a:[],l[i].push(c)}else l[i]=c===""||c}for(var o in l){var r=o.split("[");r.length>1&&(Llt(l,r.map(function(u){return u.replace(/[?[\]\\ ]/g,"")}),l[o]),delete l[o])}return l})((function(t){return Ms&&window.location.search.substring(1)})())}function Llt(e,t,n){for(var l=t.length-1,s=0;s<l;++s){var i=t[s];if(i==="__proto__"||i==="constructor")break;i in e||(e[i]={}),e=e[i]}e[t[l]]=n}function Th(){for(var e="",t=0,n=4294967295*Math.random()|0;t++<36;){var l="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t-1],s=15&n;e+=l=="-"||l=="4"?l:(l=="x"?s:3&s|8).toString(16),n=t%8==0?4294967295*Math.random()|0:n>>4}return e}var Aa="global",Yd=Va+Aa+Va,Xd=typeof self===Nh&&self.self===self&&self||typeof global===Nh&&global[Aa]===global&&global||void 0;function wa(e){return Xd[Yd][e]}function xa(e,t){return Xd[Yd][e]=t}function gd(e){delete Xd[Yd][e]}function Md(e,t,n){var l;try{if(VN(e)){var s=window[e];l=s[t].bind(s)}}catch{}return l||n}Xd[Yd]||(Xd[Yd]={});var Ih={};function VN(e){if(typeof Ih[e]!==gs)return Ih[e];try{var t=window[e];t.setItem(gs,gs),t.removeItem(gs)}catch{return Ih[e]=!1}return Ih[e]=!0}function Bt(){return Bt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var l in n)({}).hasOwnProperty.call(n,l)&&(e[l]=n[l])}return e},Bt.apply(null,arguments)}var Dc="function",fi="undefined",ku="reducer",az="@@redux/",AN=az+"INIT",Slt=az+Math.random().toString(36),oz=(function(){return typeof Symbol===Dc&&Symbol.observable||"@@observable"})(),Vh=" != "+Dc;function dz(e,t,n){var l;if(typeof t===Dc&&typeof n===fi&&(n=t,t=void 0),typeof n!==fi){if(typeof n!==Dc)throw new Error("enhancer"+Vh);return n(dz)(e,t)}if(typeof e!==Dc)throw new Error(ku+Vh);var s=e,i=t,c=[],a=c,o=!1;function r(){a===c&&(a=c.slice())}function u(){return i}function d(Z){if(typeof Z!==Dc)throw new Error("Listener"+Vh);var b=!0;return r(),a.push(Z),function(){if(b){b=!1,r();var h=a.indexOf(Z);a.splice(h,1)}}}function m(Z){if(!Zl(Z))throw new Error("Act != obj");if(typeof Z.type===fi)throw new Error("ActType "+fi);if(o)throw new Error("Dispatch in "+ku);try{o=!0,i=s(i,Z)}finally{o=!1}for(var b=c=a,h=0;h<b.length;h++)(0,b[h])();return Z}return m({type:AN}),(l={dispatch:m,subscribe:d,getState:u,replaceReducer:function(Z){if(typeof Z!==Dc)throw new Error("next "+ku+Vh);s=Z,m({type:AN})}})[oz]=function(){var Z,b=d;return(Z={subscribe:function(h){if(typeof h!="object")throw new TypeError("Observer != obj");function p(){h.next&&h.next(u())}return p(),{unsubscribe:b(p)}}})[oz]=function(){return this},Z},l}function Clt(e,t){var n=t&&t.type;return"action "+(n&&n.toString()||"?")+ku+" "+e+" returns "+fi}function Td(){var e=[].slice.call(arguments);return e.length===0?function(t){return t}:e.length===1?e[0]:e.reduce(function(t,n){return function(){return t(n.apply(void 0,[].slice.call(arguments)))}})}function flt(){var e=arguments;return function(t){return function(n,l,s){var i,c=t(n,l,s),a=c.dispatch,o={getState:c.getState,dispatch:function(r){return a(r)}};return i=[].slice.call(e).map(function(r){return r(o)}),Bt({},c,{dispatch:a=Td.apply(void 0,i)(c.dispatch)})}}}var kc=Va+"anon_id",za=Va+"user_id",Id=Va+"user_traits",wN="analytics",jc="userId",Vd="anonymousId",Ah=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],xN=["name","EVENTS","config","loaded"],Pt=Ah.reduce(function(e,t){return e[t]=t,e},{registerPluginType:function(e){return"registerPlugin:"+e},pluginReadyType:function(e){return"ready:"+e}}),rz=/^utm_/,uz=/^an_prop_/,mz=/^an_trait_/;function Rlt(e){var t=e.storage.setItem;return function(n){return function(l){return function(s){if(s.type===Pt.bootstrap){var i=s.params,c=s.user,a=s.persistedUser,o=s.initialUser,r=a.userId===c.userId;a.anonymousId!==c.anonymousId&&t(kc,c.anonymousId),r||t(za,c.userId),o.traits&&t(Id,Bt({},r&&a.traits?a.traits:{},o.traits));var u=Object.keys(s.params);if(u.length){var d=i.an_uid,m=i.an_event,Z=u.reduce(function(b,h){if(h.match(rz)||h.match(/^(d|g)clid/)){var p=h.replace(rz,"");b.campaign[p==="campaign"?"name":p]=i[h]}return h.match(uz)&&(b.props[h.replace(uz,"")]=i[h]),h.match(mz)&&(b.traits[h.replace(mz,"")]=i[h]),b},{campaign:{},props:{},traits:{}});n.dispatch(Bt({type:Pt.params,raw:i},Z,d?{userId:d}:{})),d&&setTimeout(function(){return e.identify(d,Z.traits)},0),m&&setTimeout(function(){return e.track(m,Z.props)},0),Object.keys(Z.campaign).length&&n.dispatch({type:Pt.campaign,campaign:Z.campaign})}}return l(s)}}}}function Flt(e){return function(t,n){if(t===void 0&&(t={}),n===void 0&&(n={}),n.type===Pt.setItemEnd){if(n.key===kc)return Bt({},t,{anonymousId:n.value});if(n.key===za)return Bt({},t,{userId:n.value})}switch(n.type){case Pt.identify:return Object.assign({},t,{userId:n.userId,traits:Bt({},t.traits,n.traits)});case Pt.reset:return[za,kc,Id].forEach(function(l){e.removeItem(l)}),Object.assign({},t,{userId:null,anonymousId:null,traits:{}});default:return t}}}function Zz(e){return{userId:e.getItem(za),anonymousId:e.getItem(kc),traits:e.getItem(Id)}}var zN=function(e){return Va+"TEMP"+Va+e};function Dlt(e){var t=e.storage,n=t.setItem,l=t.removeItem,s=t.getItem;return function(i){return function(c){return function(a){var o=a.userId,r=a.traits,u=a.options;if(a.type===Pt.reset&&([za,Id,kc].forEach(function(Z){l(Z)}),[jc,Vd,"traits"].forEach(function(Z){gd(zN(Z))})),a.type===Pt.identify){s(kc)||n(kc,Th());var d=s(za),m=s(Id)||{};d&&d!==o&&i.dispatch({type:Pt.userIdChanged,old:{userId:d,traits:m},new:{userId:o,traits:r},options:u}),o&&n(za,o),r&&n(Id,Bt({},m,r))}return c(a)}}}}var ju={};function bz(e,t){ju[e]&&qs(ju[e])&&(ju[e](t),delete ju[e])}function hz(e,t,n){return new Promise(function(l,s){return t()?l(e):n<1?s(Bt({},e,{queue:!0})):new Promise(function(i){return setTimeout(i,10)}).then(function(i){return hz(e,t,n-10).then(l,s)})})}function klt(e){return{abort:e}}function pz(e,t,n){var l={},s=t(),i=e.getState(),c=i.plugins,a=i.queue,o=i.user;if(!i.context.offline&&a&&a.actions&&a.actions.length){var r=a.actions.reduce(function(d,m,Z){return c[m.plugin].loaded?(d.process.push(m),d.processIndex.push(Z)):(d.requeue.push(m),d.requeueIndex.push(Z)),d},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(r.processIndex&&r.processIndex.length){r.processIndex.forEach(function(d){var m=a.actions[d],Z=m.plugin,b=m.payload.type,h=s[Z][b];if(h&&qs(h)){var p,W=(function(X,g){return X===void 0&&(X={}),g===void 0&&(g={}),[jc,Vd].reduce(function(M,I){return X.hasOwnProperty(I)&&g[I]&&g[I]!==X[I]&&(M[I]=g[I]),M},X)})(m.payload,o),y=l[W.meta.rid];if(!y&&(p=h({payload:W,config:c[Z].config,instance:n,abort:klt}))&&Zl(p)&&p.abort)return void(l[W.meta.rid]=!0);if(!y){var N=b+":"+Z;e.dispatch(Bt({},W,{type:N,_:{called:N,from:"queueDrain"}}))}}});var u=a.actions.filter(function(d,m){return!~r.processIndex.indexOf(m)});a.actions=u}}}var LN=function(e){var t=e.data,n=e.action,l=e.instance,s=e.state,i=e.allPlugins,c=e.allMatches,a=e.store,o=e.EVENTS;try{var r=s.plugins,u=s.context,d=n.type,m=d.match(Ad),Z=t.exact.map(function(p){return p.pluginName});m&&(Z=c.during.map(function(p){return p.pluginName}));var b=(function(p,W){return function(y,N,X){var g=N.config,M=N.name,I=M+"."+y.type;X&&(I=X.event);var A=y.type.match(Ad)?(function(V,z,x,S,C){return function(k,v){var J=S?S.name:V,R=v&&vu(v)?v:x;if(S&&(!(R=v&&vu(v)?v:[V]).includes(V)||R.length!==1))throw new Error("Method "+z+" can only abort "+V+" plugin. "+JSON.stringify(R)+" input valid");return Bt({},C,{abort:{reason:k,plugins:R,caller:z,_:J}})}})(M,I,W,X,y):(function(V,z){return function(){throw new Error(V.type+" action not cancellable. Remove abort in "+z)}})(y,I);return{payload:jlt(y),instance:p,config:g||{},abort:A}}})(l,Z),h=t.exact.reduce(function(p,W){var y=W.pluginName,N=W.methodName,X=!1;return N.match(/^initialize/)||N.match(/^reset/)||(X=!r[y].loaded),u.offline&&N.match(/^(page|track|identify)/)&&(X=!0),p[""+y]=X,p},{});return Promise.resolve(t.exact.reduce(function(p,W,y){var N=W.pluginName;return Promise.resolve(p).then(function(X){function g(){return Promise.resolve(X)}var M=(function(){if(t.namespaced&&t.namespaced[N])return Promise.resolve(t.namespaced[N].reduce(function(I,A,V){return Promise.resolve(I).then(function(z){return A.method&&qs(A.method)?((function(k,v){var J=Mz(k);if(J&&J.name===v){var R=Mz(J.method);throw new Error([v+" plugin is calling method "+k,"Plugins cant call self","Use "+J.method+" "+(R?"or "+R.method:"")+" in "+v+" plugin insteadof "+k].join(`
|
|
72
|
-
`))}})(A.methodName,A.pluginName),Promise.resolve(A.method({payload:z,instance:l,abort:(x=z,S=N,C=A.pluginName,function(k,v){return Bt({},x,{abort:{reason:k,plugins:v||[S],caller:d,from:C||S}})}),config:yz(A.pluginName,r,i),plugins:r})).then(function(k){var v=Zl(k)?k:{};return Promise.resolve(Bt({},z,v))})):z;var x,S,C})},Promise.resolve(n))).then(function(I){X[N]=I});X[N]=n})();return M&&M.then?M.then(g):g()})},Promise.resolve({}))).then(function(p){return Promise.resolve(t.exact.reduce(function(W,y,N){try{var X=t.exact.length===N+1,g=y.pluginName,M=i[g];return Promise.resolve(W).then(function(I){var A=p[g]?p[g]:{};if(m&&(A=I),CN(A,g))return SN({data:A,method:d,instance:l,pluginName:g,store:a}),Promise.resolve(I);if(CN(I,g))return X&&SN({data:I,method:d,instance:l,store:a}),Promise.resolve(I);if(h.hasOwnProperty(g)&&h[g]===!0)return a.dispatch({type:"queue",plugin:g,payload:A,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(I);var V=b(p[g],i[g]);return Promise.resolve(M[d]({abort:V.abort,payload:A,instance:l,config:yz(g,r,i),plugins:r})).then(function(z){var x=Zl(z)?z:{},S=Bt({},I,x),C=p[g];if(CN(C,g))SN({data:C,method:d,instance:l,pluginName:g,store:a});else{var k=d+":"+g;(k.match(/:/g)||[]).length<2&&!d.match(Wz)&&!d.match(Gz)&&l.dispatch(Bt({},m?S:A,{type:k,_:{called:k,from:"submethod"}}))}return Promise.resolve(S)})})}catch(I){return Promise.reject(I)}},Promise.resolve(n))).then(function(W){if(!(d.match(Ad)||d.match(/^registerPlugin/)||d.match(Gz)||d.match(Wz)||d.match(/^params/)||d.match(/^userIdChanged/))){if(o.plugins.includes(d),W._&&W._.originalAction===d)return W;var y=Bt({},W,{_:{originalAction:W.type,called:W.type,from:"engineEnd"}});Xz(W,t.exact.length)&&!d.match(/End$/)&&(y=Bt({},y,{type:W.type+"Aborted"})),a.dispatch(y)}return W})})}catch(p){return Promise.reject(p)}},Ad=/Start$/,Wz=/^bootstrap/,Gz=/^ready/;function SN(e){var t=e.pluginName,n=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(Bt({},e.data,{type:n,_:{called:n,from:"abort"}}))}function yz(e,t,n){var l=t[e]||n[e];return l&&l.config?l.config:{}}function Nz(e,t){return t.reduce(function(n,l){return l[e]?n.concat({methodName:e,pluginName:l.name,method:l[e]}):n},[])}function Yz(e,t){var n=e.replace(Ad,""),l=t?":"+t:"";return[""+e+l,""+n+l,n+"End"+l]}function CN(e,t){var n=e.abort;return!!n&&(n===!0||gz(n,t)||n&&gz(n.plugins,t))}function Xz(e,t){var n=e.abort;if(!n)return!1;if(n===!0||yd(n))return!0;var l=n.plugins;return vu(n)&&n.length===t||vu(l)&&l.length===t}function vu(e){return Array.isArray(e)}function gz(e,t){return!(!e||!vu(e))&&e.includes(t)}function Mz(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function jlt(e){return Object.keys(e).reduce(function(t,n){return n==="type"||(t[n]=Zl(e[n])?Object.assign({},e[n]):e[n]),t},{})}function vlt(e,t,n){var l={};return function(s){return function(i){return function(c){try{var a,o=function(X){return a?X:i(d)},r=c.type,u=c.plugins,d=c;if(c.abort)return Promise.resolve(i(c));if(r===Pt.enablePlugin&&s.dispatch({type:Pt.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:c.meta}),r===Pt.disablePlugin&&setTimeout(function(){return bz(c.meta.rid,{payload:c})},0),r===Pt.initializeEnd){var m=t(),Z=Object.keys(m),b=Z.filter(function(X){return u.includes(X)}).map(function(X){return m[X]}),h=[],p=[],W=c.disabled,y=b.map(function(X){var g=X.loaded,M=X.name,I=X.config;return hz(X,function(){return g({config:I})},1e4).then(function(A){return l[M]||(s.dispatch({type:Pt.pluginReadyType(M),name:M,events:Object.keys(X).filter(function(V){return!xN.includes(V)})}),l[M]=!0),h=h.concat(M),X}).catch(function(A){if(A instanceof Error)throw new Error(A);return p=p.concat(A.name),A})});Promise.all(y).then(function(X){var g={plugins:h,failed:p,disabled:W};setTimeout(function(){Z.length===y.length+W.length&&s.dispatch(Bt({},{type:Pt.ready},g))},0)})}var N=(function(){if(r!==Pt.bootstrap)return/^ready:([^:]*)$/.test(r)&&setTimeout(function(){return pz(s,t,e)},0),Promise.resolve((function(X,g,M,I,A){try{var V=qs(g)?g():g,z=X.type,x=z.replace(Ad,"");if(X._&&X._.called)return Promise.resolve(X);var S=M.getState(),C=(J=V,(R=S.plugins)===void 0&&(R={}),(D=X.options)===void 0&&(D={}),Object.keys(J).filter(function(L){var w=D.plugins||{};return Xlt(w[L])?w[L]:w.all!==!1&&(!R[L]||R[L].enabled!==!1)}).map(function(L){return J[L]}));z===Pt.initializeStart&&X.fromEnable&&(C=Object.keys(S.plugins).filter(function(L){var w=S.plugins[L];return X.plugins.includes(L)&&!w.initialized}).map(function(L){return V[L]}));var k=C.map(function(L){return L.name}),v=(function(L,w){var j=Yz(L).map(function(B){return Nz(B,w)});return w.reduce(function(B,f){var U=f.name,_=Yz(L,U).map(function(gt){return Nz(gt,w)}),P=_[0],q=_[1],ot=_[2];return P.length&&(B.beforeNS[U]=P),q.length&&(B.duringNS[U]=q),ot.length&&(B.afterNS[U]=ot),B},{before:j[0],beforeNS:{},during:j[1],duringNS:{},after:j[2],afterNS:{}})})(z,C);return Promise.resolve(LN({action:X,data:{exact:v.before,namespaced:v.beforeNS},state:S,allPlugins:V,allMatches:v,instance:M,store:I,EVENTS:A})).then(function(L){function w(){var f=(function(){if(z.match(Ad))return Promise.resolve(LN({action:Bt({},j,{type:x+"End"}),data:{exact:v.after,namespaced:v.afterNS},state:S,allPlugins:V,allMatches:v,instance:M,store:I,EVENTS:A})).then(function(U){U.meta&&U.meta.hasCallback&&bz(U.meta.rid,{payload:U})})})();return f&&f.then?f.then(function(){return L}):L}if(Xz(L,k.length))return L;var j,B=(function(){if(z!==x)return Promise.resolve(LN({action:Bt({},L,{type:x}),data:{exact:v.during,namespaced:v.duringNS},state:S,allPlugins:V,allMatches:v,instance:M,store:I,EVENTS:A})).then(function(f){j=f});j=L})();return B&&B.then?B.then(w):w()})}catch(L){return Promise.reject(L)}var J,R,D})(c,t,e,s,n)).then(function(X){var g=i(X);return a=1,g})})();return Promise.resolve(N&&N.then?N.then(o):o(N))}catch(X){return Promise.reject(X)}}}}}function Jlt(e){return function(t){return function(n){return function(l){var s=l.type,i=l.key,c=l.value,a=l.options;if(s===Pt.setItem||s===Pt.removeItem){if(l.abort)return n(l);s===Pt.setItem?e.setItem(i,c,a):e.removeItem(i,a)}return n(l)}}}}var Olt=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,n){e[n]=e[n].concat(t)},this.removeMiddleware=function(t,n){var l=e[n].findIndex(function(s){return s===t});l!==-1&&(e[n]=[].concat(e[n].slice(0,l),e[n].slice(l+1)))},this.dynamicMiddlewares=function(t){return function(n){return function(l){return function(s){var i={getState:n.getState,dispatch:function(a){return n.dispatch(a)}},c=e[t].map(function(a){return a(i)});return Td.apply(void 0,c)(l)(s)}}}}};function Elt(e){return function(t,n){t===void 0&&(t={});var l={};if(n.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(n.type)){var s=Tz(n.type,"registerPlugin"),i=e()[s];if(!i||!s)return t;var c=n.enabled,a=i.config;return l[s]={enabled:c,initialized:!!c&&!i.initialize,loaded:!!c&&!!i.loaded({config:a}),config:a},Bt({},t,l)}if(/^initialize:([^:]*)$/.test(n.type)){var o=Tz(n.type,Pt.initialize),r=e()[o];return r&&o?(l[o]=Bt({},t[o],{initialized:!0,loaded:!!r.loaded({config:r.config})}),Bt({},t,l)):t}if(/^ready:([^:]*)$/.test(n.type))return l[n.name]=Bt({},t[n.name],{loaded:!0}),Bt({},t,l);switch(n.type){case Pt.disablePlugin:return Bt({},t,Iz(n.plugins,!1,t));case Pt.enablePlugin:return Bt({},t,Iz(n.plugins,!0,t));default:return t}}}function Tz(e,t){return e.substring(t.length+1,e.length)}function Iz(e,t,n){return e.reduce(function(l,s){return l[s]=Bt({},n[s],{enabled:t}),l},n)}function Vz(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var Ult={last:{},history:[]};function Blt(e,t){e===void 0&&(e=Ult);var n=t.options,l=t.meta;if(t.type===Pt.track){var s=Vz(Bt({event:t.event,properties:t.properties},Object.keys(n).length&&{options:n},{meta:l}));return Bt({},e,{last:s,history:e.history.concat(s)})}return e}var Plt={actions:[]};function Hlt(e,t){e===void 0&&(e=Plt);var n=t.payload;switch(t.type){case"queue":var l;return l=n&&n.type&&n.type===Pt.identify?[t].concat(e.actions):e.actions.concat(t),Bt({},e,{actions:l});case"dequeue":return[];default:return e}}var Az=/#.*$/;function Klt(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(Az,""):"")}var wz,xz,zz,Lz,Qlt=function(e){if(e===void 0&&(e={}),!Ms)return e;var t=document,n=t.title,l=t.referrer,s=window,i=s.location,c=s.innerWidth,a=s.innerHeight,o=i.hash,r=i.search,u=(function(m){var Z=(function(){if(Ms){for(var b,h=document.getElementsByTagName("link"),p=0;b=h[p];p++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}})();return Z?Z.match(/\?/)?Z:Z+m:window.location.href.replace(Az,"")})(r),d={title:n,url:u,path:Klt(u),hash:o,search:r,width:c,height:a};return l&&l!==""&&(d.referrer=l),Bt({},d,e)},qlt={last:{},history:[]};function _lt(e,t){e===void 0&&(e=qlt);var n=t.options;if(t.type===Pt.page){var l=Vz(Bt({properties:t.properties,meta:t.meta},Object.keys(n).length&&{options:n}));return Bt({},e,{last:l,history:e.history.concat(l)})}return e}wz=(function(){if(!Ms)return!1;var e=navigator.appVersion;return~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"})(),xz=Ms?document.referrer:null,zz=wlt(),Lz=xlt();var Sz={initialized:!1,sessionId:Th(),app:null,version:null,debug:!1,offline:!!Ms&&!navigator.onLine,os:{name:wz},userAgent:Ms?navigator.userAgent:"node",library:{name:wN,version:"0.13.1"},timezone:Lz,locale:zz,campaign:{},referrer:xz};function $lt(e,t){e===void 0&&(e=Sz);var n=e.initialized,l=t.campaign;switch(t.type){case Pt.campaign:return Bt({},e,{campaign:l});case Pt.offline:return Bt({},e,{offline:!0});case Pt.online:return Bt({},e,{offline:!1});default:return n?e:Bt({},Sz,e,{initialized:!0})}}var tst=["plugins","reducers","storage"];function est(e,t,n){if(Ms){var l=window[(n?"add":"remove")+"EventListener"];e.split(" ").forEach(function(s){l(s,t)})}}function nst(e){var t=est.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(n){return t(!1)}}function Cz(){return xa(wN,[]),function(e){return function(t,n,l){var s=e(t,n,l),i=s.dispatch;return Object.assign(s,{dispatch:function(c){return Xd[Yd][wN].push(c.action||c),i(c)}})}}}function fz(e){return function(){return Td(Td.apply(null,arguments),Cz())}}function fN(e){return e?Mlt(e)?e:[e]:[]}function Rz(e,t,n){e===void 0&&(e={});var l,s,i=Th();return t&&(ju[i]=(l=t,s=(function(c){for(var a,o=c||Array.prototype.slice.call(arguments),r=0;r<o.length;r++)if(qs(o[r])){a=o[r];break}return a})(n),function(c){s&&s(c),l(c)})),Bt({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function lst(e){e===void 0&&(e={});var t=e.reducers||{},n=e.initialUser||{},l=(e.plugins||[]).reduce(function(L,w){if(qs(w))return L.middlewares=L.middlewares.concat(w),L;if(w.NAMESPACE&&(w.name=w.NAMESPACE),!w.name)throw new Error("https://lytics.dev/errors/1");w.config||(w.config={});var j=w.EVENTS?Object.keys(w.EVENTS).map(function(U){return w.EVENTS[U]}):[];L.pluginEnabled[w.name]=!(w.enabled===!1||w.config.enabled===!1),delete w.enabled,w.methods&&(L.methods[w.name]=Object.keys(w.methods).reduce(function(U,_){var P;return U[_]=(P=w.methods[_],function(){for(var q=Array.prototype.slice.call(arguments),ot=new Array(P.length),gt=0;gt<q.length;gt++)ot[gt]=q[gt];return ot[ot.length]=g,P.apply({instance:g},ot)}),U},{}),delete w.methods);var B=Object.keys(w).concat(j),f=new Set(L.events.concat(B));if(L.events=Array.from(f),L.pluginsArray=L.pluginsArray.concat(w),L.plugins[w.name])throw new Error(w.name+"AlreadyLoaded");return L.plugins[w.name]=w,L.plugins[w.name].loaded||(L.plugins[w.name].loaded=function(){return!0}),L},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),s=e.storage?e.storage:{getItem:wa,setItem:xa,removeItem:gd},i=(function(L){return function(w,j,B){return j.getState("user")[w]||(B&&Zl(B)&&B[w]?B[w]:Zz(L)[w]||wa(zN(w))||null)}})(s),c=l.plugins,a=l.events.filter(function(L){return!xN.includes(L)}).sort(),o=new Set(a.concat(Ah).filter(function(L){return!xN.includes(L)})),r=Array.from(o).sort(),u=function(){return c},d=new Olt,m=d.addMiddleware,Z=d.removeMiddleware,b=d.dynamicMiddlewares,h=function(){throw new Error("Abort disabled inListener")},p=zlt(),W=Zz(s),y=Bt({},W,n,p.an_uid?{userId:p.an_uid}:{},p.an_aid?{anonymousId:p.an_aid}:{});y.anonymousId||(y.anonymousId=Th());var N=Bt({enable:function(L,w){return new Promise(function(j){v.dispatch({type:Pt.enablePlugin,plugins:fN(L),_:{originalAction:Pt.enablePlugin}},j,[w])})},disable:function(L,w){return new Promise(function(j){v.dispatch({type:Pt.disablePlugin,plugins:fN(L),_:{originalAction:Pt.disablePlugin}},j,[w])})}},l.methods),X=!1,g={identify:function(L,w,j,B){try{var f=yd(L)?L:null,U=Zl(L)?L:w,_=j||{},P=g.user();xa(zN(jc),f);var q=f||U.userId||i(jc,g,U);return Promise.resolve(new Promise(function(ot){v.dispatch(Bt({type:Pt.identifyStart,userId:q,traits:U||{},options:_,anonymousId:P.anonymousId},P.id&&P.id!==f&&{previousId:P.id}),ot,[w,j,B])}))}catch(ot){return Promise.reject(ot)}},track:function(L,w,j,B){try{var f=Zl(L)?L.event:L;if(!f||!yd(f))throw new Error("EventMissing");var U=Zl(L)?L:w||{},_=Zl(j)?j:{};return Promise.resolve(new Promise(function(P){v.dispatch({type:Pt.trackStart,event:f,properties:U,options:_,userId:i(jc,g,w),anonymousId:i(Vd,g,w)},P,[w,j,B])}))}catch(P){return Promise.reject(P)}},page:function(L,w,j){try{var B=Zl(L)?L:{},f=Zl(w)?w:{};return Promise.resolve(new Promise(function(U){v.dispatch({type:Pt.pageStart,properties:Qlt(B),options:f,userId:i(jc,g,B),anonymousId:i(Vd,g,B)},U,[L,w,j])}))}catch(U){return Promise.reject(U)}},user:function(L){if(L===jc||L==="id")return i(jc,g);if(L===Vd||L==="anonId")return i(Vd,g);var w=g.getState("user");return L?tz(w,L):w},reset:function(L){return new Promise(function(w){v.dispatch({type:Pt.resetStart},w,L)})},ready:function(L){return X&&L({plugins:N,instance:g}),g.on(Pt.ready,function(w){L&&L(w),X=!0})},on:function(L,w){if(!L||!qs(w))return!1;if(L===Pt.bootstrap)throw new Error(".on disabled for "+L);var j=/Start$|Start:/;if(L==="*"){var B=function(P){return function(q){return function(ot){return ot.type.match(j)&&w({payload:ot,instance:g,plugins:c}),q(ot)}}},f=function(P){return function(q){return function(ot){return ot.type.match(j)||w({payload:ot,instance:g,plugins:c}),q(ot)}}};return m(B,wh),m(f,xh),function(){Z(B,wh),Z(f,xh)}}var U=L.match(j)?wh:xh,_=function(P){return function(q){return function(ot){return ot.type===L&&w({payload:ot,instance:g,plugins:c,abort:h}),q(ot)}}};return m(_,U),function(){return Z(_,U)}},once:function(L,w){if(!L||!qs(w))return!1;if(L===Pt.bootstrap)throw new Error(".once disabled for "+L);var j=g.on(L,function(B){w({payload:B.payload,instance:g,plugins:c,abort:h}),j()});return j},getState:function(L){var w=v.getState();return L?tz(w,L):Object.assign({},w)},dispatch:function(L){var w=yd(L)?{type:L}:L;if(Ah.includes(w.type))throw new Error("reserved action "+w.type);var j=Bt({},w,{_:Bt({originalAction:w.type},L._||{})});v.dispatch(j)},enablePlugin:N.enable,disablePlugin:N.disable,plugins:N,storage:{getItem:s.getItem,setItem:function(L,w,j){v.dispatch({type:Pt.setItemStart,key:L,value:w,options:j})},removeItem:function(L,w){v.dispatch({type:Pt.removeItemStart,key:L,options:w})}},setAnonymousId:function(L,w){g.storage.setItem(kc,L,w)},events:{core:Ah,plugins:a}},M=l.middlewares.concat([function(L){return function(w){return function(j){return j.meta||(j.meta=Rz()),w(j)}}},b(wh),vlt(g,u,{all:r,plugins:a}),Jlt(s),Rlt(g),Dlt(g),b(xh)]),I={context:$lt,user:Flt(s),page:_lt,track:Blt,plugins:Elt(u),queue:Hlt},A=Td,V=Td;if(Ms&&e.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(A=z({trace:!0,traceLimit:25})),V=function(){return arguments.length===0?Cz():Zl(typeof arguments[0])?fz():fz().apply(null,arguments)}}var x,S=(function(L){return Object.keys(L).reduce(function(w,j){return tst.includes(j)||(w[j]=L[j]),w},{})})(e),C=l.pluginsArray.reduce(function(L,w){var j=w.name,B=w.config,f=w.loaded,U=l.pluginEnabled[j];return L[j]={enabled:U,initialized:!!U&&!w.initialize,loaded:!!f({config:B}),config:B},L},{}),k={context:S,user:y,plugins:C},v=dz((function(L){for(var w=Object.keys(L),j={},B=0;B<w.length;B++){var f=w[B];typeof L[f]===Dc&&(j[f]=L[f])}var U,_=Object.keys(j);try{(function(P){Object.keys(P).forEach(function(q){var ot=P[q];if(typeof ot(void 0,{type:AN})===fi||typeof ot(void 0,{type:Slt})===fi)throw new Error(ku+" "+q+" "+fi)})})(j)}catch(P){U=P}return function(P,q){if(P===void 0&&(P={}),U)throw U;for(var ot=!1,gt={},Zt=0;Zt<_.length;Zt++){var K=_[Zt],O=P[K],H=(0,j[K])(O,q);if(typeof H===fi){var et=Clt(K,q);throw new Error(et)}gt[K]=H,ot=ot||H!==O}return ot?gt:P}})(Bt({},I,t)),k,V(A(flt.apply(void 0,M))));v.dispatch=(x=v.dispatch,function(L,w,j){var B=Bt({},L,{meta:Rz(L.meta,w,fN(j))});return x.apply(null,[B])});var J=Object.keys(c);v.dispatch({type:Pt.bootstrap,plugins:J,config:S,params:p,user:y,initialUser:n,persistedUser:W});var R=J.filter(function(L){return l.pluginEnabled[L]}),D=J.filter(function(L){return!l.pluginEnabled[L]});return v.dispatch({type:Pt.registerPlugins,plugins:J,enabled:l.pluginEnabled}),l.pluginsArray.map(function(L,w){var j=L.bootstrap,B=L.config,f=L.name;j&&qs(j)&&j({instance:g,config:B,payload:L}),v.dispatch({type:Pt.registerPluginType(f),name:f,enabled:l.pluginEnabled[f],plugin:L}),l.pluginsArray.length===w+1&&v.dispatch({type:Pt.initializeStart,plugins:R,disabled:D})}),nst(function(L){v.dispatch({type:L?Pt.offline:Pt.online})}),(function(L,w,j){setInterval(function(){return pz(L,w,j)},3e3)})(v,u,g),g}var wh="before",xh="after",La="cookie",Sa=kz(),Fz=zh,sst=zh;function Dz(e){return Sa?zh(e,"",-1):gd(e)}function kz(){if(Sa!==void 0)return Sa;var e=La+La;try{zh(e,e),Sa=document.cookie.indexOf(e)!==-1,Dz(e)}catch{Sa=!1}return Sa}function zh(e,t,n,l,s,i){if(typeof window<"u"){var c=arguments.length>1;return Sa===!1&&(c?xa(e,t):wa(e)),c?document.cookie=e+"="+encodeURIComponent(t)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(l?"; path="+l:"")+(s?"; domain="+s:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var Ri="localStorage",ist=VN.bind(null,Ri);Md(Ri,"getItem",wa),Md(Ri,"setItem",xa),Md(Ri,"removeItem",gd);var Fi="sessionStorage",cst=VN.bind(null,Fi);Md(Fi,"getItem",wa),Md(Fi,"setItem",xa),Md(Fi,"removeItem",gd);function wd(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(Zl(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var ast=ist(),ost=cst(),dst=kz();function jz(e,t){if(e){var n=RN(t),l=!jN(n),s=FN(n)?wd(localStorage.getItem(e)):void 0;if(l&&!Nd(s))return s;var i=DN(n)?wd(Fz(e)):void 0;if(l&&i)return i;var c=kN(n)?wd(sessionStorage.getItem(e)):void 0;if(l&&c)return c;var a=wa(e);return l?a:{localStorage:s,sessionStorage:c,cookie:i,global:a}}}function rst(e,t,n){if(e&&!Nd(t)){var l={},s=RN(n),i=JSON.stringify(t),c=!jN(s);return FN(s)&&(l[Ri]=Sh(Ri,t,wd(localStorage.getItem(e))),localStorage.setItem(e,i),c)?l[Ri]:DN(s)&&(l[La]=Sh(La,t,wd(Fz(e))),sst(e,i),c)?l[La]:kN(s)&&(l[Fi]=Sh(Fi,t,wd(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),c)?l[Fi]:(l[Aa]=Sh(Aa,t,wa(e)),xa(e,t),c?l[Aa]:l)}}function ust(e,t){if(e){var n=RN(t),l=jz(e,nz),s={};return!Nd(l.localStorage)&&FN(n)&&(localStorage.removeItem(e),s[Ri]=l.localStorage),!Nd(l.cookie)&&DN(n)&&(Dz(e),s[La]=l.cookie),!Nd(l.sessionStorage)&&kN(n)&&(sessionStorage.removeItem(e),s[Fi]=l.sessionStorage),!Nd(l.global)&&Lh(n,Aa)&&(gd(e),s[Aa]=l.global),s}}function RN(e){return e?yd(e)?e:e.storage:ez}function FN(e){return ast&&Lh(e,Ri)}function DN(e){return dst&&Lh(e,La)}function kN(e){return ost&&Lh(e,Fi)}function jN(e){return e===nz||e==="all"}function Lh(e,t){return e===ez||e===t||jN(e)}function Sh(e,t,n){return{location:e,current:t,previous:n}}var mst={setItem:rst,getItem:jz,removeItem:ust};function Zst(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,l)}return n}function Jz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?vz(Object(n),!0).forEach(function(l){Zst(e,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vz(Object(n)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(n,l))})}return e}function bst(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:mst};return lst(Jz(Jz({},t),e))}const Oz=e=>{const t=jt("systemArt",e);return Y.useMemo(()=>t9(t),[t])},vc=({rows:e,art:t,className:n,style:l})=>{const s=Oz(t??"controlStripTab"),i=e??(t?s:[]),c=i[0]?.length??0,a=[];for(let o=0;o<i.length;o++){const r=i[o];let u=0;for(;u<r.length;){const d=r[u];let m=u+1;for(;m<r.length&&r[m]===d;)m++;d!=="."&&a.push(G.jsx("rect",{x:u,y:o,width:m-u,height:1,className:`classicyPixel${d}`},`${u}-${o}`)),u=m}}return G.jsx("svg",{className:n,style:l,width:c,height:i.length,viewBox:`0 0 ${c} ${i.length}`,shapeRendering:"crispEdges","aria-hidden":!0,focusable:!1,children:a})},hst=10,Ju=57,vN=(e,t,n)=>Math.min(n,Math.max(t,e)),Ez=({value:e,onChange:t,ariaLabel:n,min:l=0,max:s=100,step:i=1,disabled:c=!1,id:a,className:o,style:r})=>{const u=Y.useRef(null),d=Y.useRef(null),m=Y.useRef(0),Z=s-l||1,b=vN(e,l,s),h=Ju-Math.round((b-l)/Z*Ju),p=X=>vN(l+Math.round((X-l)/i)*i,l,s),W=(X,g)=>{const M=u.current;if(!M)return;const I=X-M.getBoundingClientRect().top-hst/2-g,A=Ju-vN(I,0,Ju),V=p(l+A/Ju*Z);V!==m.current&&(m.current=V,t(V))};Y.useEffect(()=>()=>d.current?.(),[]);const y=X=>{if(c||X.button!==0)return;X.preventDefault(),u.current?.focus();const g=qe("--pop-up-slider-track-top",void 0,u.current);m.current=b,W(X.clientY,g);const M=V=>W(V.clientY,g),I=()=>d.current?.();document.addEventListener("mousemove",M),document.addEventListener("mouseup",I);const A=Vl(I);d.current=()=>{A(),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",I),d.current=null}},N=X=>{if(c)return;const g={ArrowUp:i,ArrowRight:i,ArrowDown:-i,ArrowLeft:-i,PageUp:i*10,PageDown:-i*10};let M;X.key in g?M=p(b+g[X.key]):X.key==="Home"?M=l:X.key==="End"&&(M=s),M!==void 0&&(X.preventDefault(),M!==b&&t(M))};return G.jsxs("div",{ref:u,id:a,role:"slider",tabIndex:c?-1:0,"aria-label":n,"aria-valuemin":l,"aria-valuemax":s,"aria-valuenow":b,"aria-orientation":"vertical","aria-disabled":c||void 0,className:$("classicyPopUpSlider",Xe({disabled:c}),o),style:r,onMouseDown:y,onKeyDown:N,children:[G.jsx(vc,{art:"popUpSliderTrack",className:"classicyPopUpSliderTrack"}),G.jsx("span",{className:"classicyPopUpSliderThumb",style:{marginTop:h},children:G.jsx(vc,{art:"popUpSliderThumb"})})]})},Uz=()=>ya().disabled.includes("*"),pst=()=>{const{volume:e=100}=ya();return Uz()||e===0?Kl.system.controlStrip.soundOff:Kl.system.controlStrip.sound},Wst=()=>{const{volume:e=100}=ya(),t=ql(),n=Uz(),l=s=>{t({type:"ClassicyVolumeSet",volume:s}),n&&s>0&&t({type:"ClassicySoundEnableOne",enabled:"*"})};return G.jsx(Ez,{ariaLabel:"Volume",value:n?0:e,onChange:l})},Gst=eN({id:_y.sound,label:"Sound",order:10,icon:pst,fileIcon:Kl.controlPanels.soundManager.app,content:Wst}),Bz=({children:e,defaultMuted:t})=>{const n=ut(d=>d.System.Manager.Appearance?.activeTheme?.sound?.pack)??Gs,l=_W(),[s,i]=Y.useReducer(oy,sy,d=>i9(d,n,t));Y.useEffect(()=>{const d=mu(n)??mu(Gs);if(d){if(d.id===s.packId){!s.fallbackPlayer&&d.id!==Gs&&mu(Gs)&&i({type:"ClassicySoundLoadFallback"});return}i({type:"ClassicySoundLoad",pack:d,disabled:ut.getState().System.Manager.Appearance?.activeTheme?.sound?.disabled})}},[n,l,s.packId,s.fallbackPlayer]);const c=ut(d=>d.System.Manager.Appearance?.alertSound);Y.useEffect(()=>{c&&i({type:"ClassicySoundSetAlertSound",sound:c})},[c]);const a=ut(d=>d.System.Manager.Appearance?.alertVolume);Y.useEffect(()=>{typeof a=="number"&&i({type:"ClassicySoundSetAlertVolume",alertVolume:a})},[a]);const{soundPlayer:o,fallbackPlayer:r,volume:u}=s;return Y.useEffect(()=>{o?.volume(Zu(u)),r?.volume(Zu(u))},[o,r,u]),G.jsx(cy.Provider,{value:s,children:G.jsx(ay.Provider,{value:i,children:e})})},JN=Y.createContext({disableSimpleText:!1,disablePDFViewer:!1,disableMoviePlayer:!1,disablePictureViewer:!1,disableHyperCard:!1,disableWebViewer:!1}),yst=e=>{const t=localStorage.getItem(e);if(t)return t;const n=()=>{const s=new Uint8Array(16);return crypto.getRandomValues(s),Array.from(s,i=>i.toString(16).padStart(2,"0")).join("")},l=crypto?.randomUUID?.()??n();return localStorage.setItem(e,l),l},Nst=({children:e,gtmContainerId:t,gaMeasurementIds:n,appName:l="classicy",eventPrefix:s="classicy_",defaultState:i,defaultFileSystem:c,defaultFileSystemMode:a,defaultFileSystemSeedMigrations:o,disableSimpleText:r,disablePDFViewer:u,disableMoviePlayer:d,disablePictureViewer:m,disableHyperCard:Z,disableWebViewer:b,defaultMuted:h})=>{const p=Y.useRef(!1);Y.useEffect(()=>{p.current||!i||Jw()||Ow()||(p.current=!0,ut.setState(X=>jw(X,i)))},[i]);const W=Y.useMemo(()=>({defaultFileSystem:c,mode:a??"merge",seedMigrations:o}),[c,a,o]),y=Y.useMemo(()=>({disableSimpleText:r??!1,disablePDFViewer:u??!1,disableMoviePlayer:d??!1,disablePictureViewer:m??!1,disableHyperCard:Z??!1,disableWebViewer:b??!1}),[r,u,d,m,Z,b]),N=Y.useMemo(()=>{const X=[];return n&&n.length>0&&X.push(llt({measurementIds:n})),t&&X.push(alt({containerId:t})),bst({app:l,plugins:X})},[l,n,t]);return Y.useEffect(()=>{const X=yst(`${l}_user_id`);N.identify(X)},[N,l]),G.jsx(hy.Provider,{value:s,children:G.jsx(Cu.Provider,{value:W,children:G.jsx(JN.Provider,{value:y,children:G.jsx(Htt,{instance:N,children:G.jsx(Bz,{defaultMuted:h,children:e})})})})})};function ON(e){return`ClassicyApp${e}OpenFile`}function Pz(e){const t=QG(e);if(t)return t.prefixes.map(n=>`${n}OpenFile`).find(n=>{if(!Object.hasOwn(t.actions,n))return!1;const l=Tw(n);return l!==void 0&&t.prefixes.includes(l)})}function Hz(e,t,n,l){const s=MG(l),i=Pz(t.id);if(i)return HG(e,{type:i,app:{id:t.id},path:n},s);const c=ON(t.name);return qo(s,c)?du(e,{type:c,app:{id:t.id},path:n}):e}function xd(e,t){return new Date(new Date(e).getTime()+t*60*60*1e3)}function Kz(e,t){const n=xd(e,t),l=String(n.getUTCHours()).padStart(2,"0"),s=String(n.getUTCMinutes()).padStart(2,"0"),i=String(n.getUTCSeconds()).padStart(2,"0");return`${l}:${s}:${i}`}function EN(e,t){return new Date(e+(Date.now()-t))}function Yst(e){const t=e?.tick??!1,n=ut(I=>I.System.Manager.DateAndTime),l=Ut(),s=parseInt(n.timeZoneOffset,10),i=n.paused,[c,a]=Y.useState(()=>xd(n.dateTime,s)),o=Y.useRef(xd(n.dateTime,s).getTime()),r=Y.useRef(Date.now()),u=Y.useRef(s);u.current=s;const d=Y.useRef(i);d.current=i;const m=n.boundaryLocked,Z=n.minDateTime??null,b=n.maxDateTime??null,h=Y.useRef(m);h.current=m;const p=Y.useRef(Z);p.current=Z;const W=Y.useRef(b);W.current=b,Y.useEffect(()=>{const I=xd(n.dateTime,s).getTime();o.current=I,r.current=Date.now(),a(new Date(I))},[n.dateTime,s]),Y.useEffect(()=>{if(i){const I=o.current+(Date.now()-r.current);o.current=I,r.current=Date.now()}else r.current=Date.now()},[i]),Y.useEffect(()=>{if(!t)return;const I=setInterval(()=>{if(d.current||h.current)return;const A=EN(o.current,r.current),V=A.getTime(),z=V-u.current*36e5,x=p.current!==null?new Date(p.current).getTime():null,S=W.current!==null?new Date(W.current).getTime():null;if(x!==null&&z<x){l({type:"ClassicyManagerDateTimeSet",dateTime:new Date(x)});return}if(S!==null&&z>=S){l({type:"ClassicyManagerDateTimeSet",dateTime:new Date(S)});return}a(C=>Math.floor(C.getTime()/1e3)===Math.floor(V/1e3)?C:A)},250);return()=>clearInterval(I)},[t,l]);const y=Y.useCallback(I=>{l({type:"ClassicyManagerDateTimeSet",dateTime:I})},[l]),N=Y.useCallback(I=>{l({type:"ClassicyManagerDateTimeTZSet",tzOffset:I})},[l]),X=Y.useCallback(()=>l({type:"ClassicyManagerDateTimePause"}),[l]),g=Y.useCallback(()=>l({type:"ClassicyManagerDateTimeResume"}),[l]),M=Kz(c.toISOString(),0);return{dateTime:n.dateTime,tzOffset:s,localDate:c,localHMS:M,paused:i,boundaryLocked:m,setDateTime:y,setTzOffset:N,pause:X,resume:g}}const UN="about-balloon-help",BN=e=>`apple_guide_${e}`,PN=new Map;function Qz(e){PN.has(e.id)&&Wt("warn","AppleGuide","Replacing already-registered topic",e.id),PN.set(e.id,e)}function zd(e){return PN.get(e)}Qz({id:UN,title:"About Help",pages:[G.jsxs(G.Fragment,{children:[G.jsx("p",{children:"The Help menu includes:"}),G.jsxs("ul",{children:[G.jsx("li",{children:"Balloons\u2014to help you identify items on the screen."}),G.jsx("li",{children:"Help\u2014to guide you step-by-step through tasks."})]})]})]});const _s="AppleGuide.app",qz="Apple Guide",Ch="ClassicyAppAppleGuideShowTopic",_z=jn({openTopics:xn(Xt()).optional().describe("Topic ids with an open window, in the order they were opened."),pages:Tl(Xt(),Zn()).optional().describe("Current zero-based page index per topic id.")});function fh(e){return!(e===null||typeof e!="object"||"openTopics"in e&&(!Array.isArray(e.openTopics)||!e.openTopics.every(t=>typeof t=="string"))||"pages"in e&&(typeof e.pages!="object"||e.pages===null||Array.isArray(e.pages)||!Object.values(e.pages).every(t=>typeof t=="number"&&Number.isFinite(t))))}function Xst(e){const t=e.openTopics;if(!t||t.every(s=>zd(s)!==void 0))return e;const n=t.filter(s=>zd(s)!==void 0),l=e.pages?Object.fromEntries(Object.entries(e.pages).filter(([s])=>n.includes(s))):e.pages;return{...e,openTopics:n,pages:l}}const gst=e=>"topicId"in e&&typeof e.topicId=="string"?e.topicId:void 0,$z=(e,t)=>{const n=e.System.Manager.Applications.apps[_s];if(!n)return e;const l=n.data??{};let s=Xst(fh(l)?l:{});const i=gst(t);switch(t.type){case Ch:{if(!i)break;if(!zd(i)){Wt("warn","AppleGuide","Unknown topic id",i);break}const c=s.openTopics??[];return s={...s,openTopics:c.includes(i)?c:[...c,i],pages:{...s.pages??{},[i]:0}},n.data=s,xi(e,_s,BN(i))}case"ClassicyAppAppleGuideCloseTopic":{if(!i)break;s={...s,openTopics:(s.openTopics??[]).filter(c=>c!==i)};break}case"ClassicyAppAppleGuideSetPage":{if(!i)break;const c=zd(i);if(!c)break;const a="page"in t&&typeof t.page=="number"?t.page:0,o=Math.min(Math.max(a,0),Math.max(c.pages.length-1,0));s={...s,pages:{...s.pages??{},[i]:o}};break}}return n.data=s,e};Ln({id:_s,description:"Step-by-step system help topics (Apple Guide).",prefix:"ClassicyAppAppleGuide",handler:$z,actions:{[Ch]:{description:"Open (or re-focus) the window for a guide topic.",params:ft({topicId:Xt().describe("Id of the registered topic to show.")})},ClassicyAppAppleGuideCloseTopic:{description:"Close the window for an open guide topic.",params:ft({topicId:Xt().describe("Id of the topic to close.")})},ClassicyAppAppleGuideSetPage:{description:"Jump an open guide topic to a page (clamped to range).",params:ft({topicId:Xt().describe("Id of the topic to page."),page:Zn().describe("Zero-based page index to show.")})}},state:_z});const tL=({page:e,pageCount:t,onPageChange:n,pageClassName:l,className:s,style:i})=>{const c=e>0,a=e<t-1;return G.jsxs("div",{className:$("classicyPager",s),style:i,children:[G.jsx("button",{type:"button",className:"classicyPagerArrow classicyPagerArrowPrev","aria-label":"Previous page",disabled:!c,onClick:()=>n(e-1)}),G.jsx("span",{className:$("classicyPagerPage",l),children:e+1}),G.jsx("button",{type:"button",className:"classicyPagerArrow classicyPagerArrowNext","aria-label":"Next page",disabled:!a,onClick:()=>n(e+1)})]})},HN=3,Mst=(e,t)=>`${e.title}-${t}`,Tst={sm:"classicyAssistantAccessoryIconSm",md:"classicyAssistantAccessoryIconMd",lg:"classicyAssistantAccessoryIconLg"},KN=(e,t,n)=>Math.min(Math.max(e,t),n),eL=({pages:e,buttons:t,initialPage:n=0,page:l,onPageChange:s,className:i,style:c})=>{const a=Math.max(0,e.length-1),[o,r]=Y.useState(()=>KN(n,0,a)),u=ql(),d=Y.useRef(null),m=Re("Assistant",{},d),Z=l!==void 0,b=KN(Z?l:o,0,a),h=e[b];if(!h)return null;const p=(h.buttons??t??[]).slice();p.length>HN&&(Wt("warn","ClassicyAssistant",`page "${h.title}" has ${p.length} footer buttons; only the first ${HN} are shown.`),p.length=HN);const W=g=>{const M=KN(g,0,a);M!==b&&(m.emit("change",kt({page:M})),Z||r(M),s?.(M))},y=()=>{if(h.canAdvance&&h.canAdvance()===!1){u({type:"ClassicySoundPlayError"});return}W(b+1)},N=()=>W(b-1),X=g=>{g.key==="ArrowRight"?(g.preventDefault(),y()):g.key==="ArrowLeft"&&(g.preventDefault(),N())};return G.jsxs("div",{...m.attrs,ref:d,className:$("classicyAssistant",m.className,i),style:m.style?{...m.style,...c}:c,tabIndex:0,onKeyDown:X,children:[G.jsxs("section",{className:"classicyAssistantHeader","aria-live":"polite","aria-label":h.title,children:[h.labelIcon&&G.jsx("img",{className:"classicyAssistantHeaderLabelIcon",src:h.labelIcon,alt:"","aria-hidden":!0}),G.jsx("span",{className:"classicyAssistantHeaderTitle",children:h.title}),h.accessoryIcon&&G.jsx("img",{className:`classicyAssistantAccessoryIcon ${Tst[h.accessoryIconSize??"sm"]}`,src:h.accessoryIcon,alt:"","aria-hidden":!0})]}),G.jsx("div",{className:"classicyAssistantBody",role:"group","aria-label":h.title,children:h.content}),G.jsxs("div",{className:"classicyAssistantFooter",children:[G.jsx("div",{className:"classicyAssistantFooterButtons",children:p.map((g,M)=>G.jsx(Ft,{buttonSize:"small",disabled:g.disabled,onClickFunc:g.onClick,children:g.title},Mst(g,M)))}),G.jsx("div",{className:"classicyAssistantNav",children:G.jsx(tL,{page:b,pageCount:e.length,onPageChange:g=>g>b?y():N(),pageClassName:"classicyAssistantPageIndicator"})})]})]})},nL=({topicId:e,className:t,style:n})=>{const l=Ut(),s=ut(d=>d.System.Manager.Applications.apps[_s]?.data),i=zd(e),c=s??{},o=(fh(c)?c:{}).pages?.[e]??0;if(!i)return null;const r=i.pages.length-1,u=i.pages.map((d,m)=>({title:i.title,content:G.jsxs(G.Fragment,{children:[d,m===r&&G.jsx("p",{className:"appleGuideEnd",children:"- End -"})]})}));return G.jsx(ge,{id:BN(e),appId:_s,className:t,style:n,hideIcon:!0,closable:!0,zoomable:!0,collapsable:!0,resizable:!1,scrollable:!1,initialSize:[700,322],initialPosition:["center","center"],onCloseFunc:()=>l({type:"ClassicyAppAppleGuideCloseTopic",app:{id:_s},topicId:e}),children:G.jsx("div",{className:"appleGuideWindow",children:G.jsx(eL,{pages:u,page:o,onPageChange:d=>l({type:"ClassicyAppAppleGuideSetPage",app:{id:_s},topicId:e,page:d})})})})},lL=()=>{const e=jt("icons","system.extensions.appleGuide")??"",n=ut(i=>i.System.Manager.Applications.apps[_s]?.data)??{},s=(fh(n)?n:{}).openTopics??[];return G.jsx(vn,{id:_s,name:qz,icon:e,extension:!0,children:s.map(i=>G.jsx(nL,{topicId:i},i))})},sL={id:"spacer"},Ist=()=>{const e=Ut(),t=ut(a=>a.System.Manager.Applications.apps[Fc]?.data),n=t?.enabled??!0,l=Ga().id;LZ();const s=NN(l).length>0,i=t?.timeoutMinutes??YN,c=Il(Ru,{name:"Screen Saver",icon:Kl.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"},sL,{id:"screen-saver-sleep-now",title:"Sleep Now",disabled:!n||!s,onClickFunc:()=>e({type:Wd})},{id:"screen-saver-enabled",title:"Screen Saver On",checked:n,onClickFunc:()=>e({type:"ClassicyAppScreenSaverSetEnabled",enabled:!n})},sL,$x(e,c.name,{id:Ru,name:"Screen Saver",icon:Kl.system.extensions.screensaver})]},Vst=eN({id:_y.screenSaver,appId:Fc,label:"Screen Saver",order:20,icon:Kl.system.controlStrip.screenSaver,fileIcon:Kl.system.extensions.screensaver,menuItems:Ist}),Ast=(e,t)=>{const n=Ut(),l=Fu(e),s=XN(e)*6e4,i=e.active===!0,c=Y.useRef(Date.now()),a=Y.useRef(i);a.current=i,Y.useEffect(()=>{if(!l)return;const o=d=>{c.current=Date.now(),a.current&&((d.type==="keydown"||d.type==="mousedown")&&(d.preventDefault(),d.stopPropagation()),n({type:"ClassicyAppScreenSaverDeactivate"}))},r={capture:!0,passive:!0},u={capture:!0};return document.addEventListener("mousemove",o,r),document.addEventListener("wheel",o,r),document.addEventListener("touchstart",o,r),document.addEventListener("mousedown",o,u),document.addEventListener("keydown",o,u),()=>{document.removeEventListener("mousemove",o,r),document.removeEventListener("wheel",o,r),document.removeEventListener("touchstart",o,r),document.removeEventListener("mousedown",o,u),document.removeEventListener("keydown",o,u)}},[l,n]),Y.useEffect(()=>{if(!l||i||!t)return;let o;const r=()=>{const u=Date.now()-c.current;if(u>=s){n({type:Wd});return}o=setTimeout(r,s-u)};return o=setTimeout(r,s),()=>clearTimeout(o)},[l,i,t,s,n])},QN="classicyScreenSaverActive",iL="classicy-screen-saver-overlay",wst=()=>{Y.useEffect(()=>{const e=document.documentElement;return e.classList.add(QN),()=>{e.classList.remove(QN)}},[])},xst="(prefers-reduced-motion: reduce)",zst=(e,t)=>{Y.useEffect(()=>{const n=e.current;if(t===void 0||!n||typeof window.matchMedia!="function")return;const l=window.matchMedia(xst),s=new Set,i=r=>{if(r.playState!=="paused"){for(const u of s)u.effect?.target?.isConnected===!1&&s.delete(u);r.pause(),s.add(r)}},c=r=>{if(!r){for(const u of s)u.play();s.clear();return}if(typeof n.getAnimations=="function")for(const u of n.getAnimations({subtree:!0}))i(u)};l.matches&&c(!0);const a=r=>{if(l.matches)for(const u of r.target.getAnimations?.()??[])i(u)},o=r=>c(r.matches);return n.addEventListener("animationstart",a,!0),l.addEventListener?.("change",o),()=>{n.removeEventListener("animationstart",a,!0),l.removeEventListener?.("change",o)}},[e,t])},Lst=({data:e,saver:t})=>{wst();const n=Y.useRef(null),l=t?.component,s=Qp(t,e.saverConfigs?.[t.id]);return zst(n,t.id),G.jsx("div",{ref:n,id:iL,className:`classicyScreenSaverOverlay${t.transparentBackground?" classicyScreenSaverOverlayTransparent":""}`,role:"presentation",children:l?G.jsx(l,{config:s}):null})},cL=()=>{const e=jt("icons","system.extensions.screensaver")??"",n=ut(i=>i.System.Manager.Applications.apps[Fc]?.data)??{},l=Ga().id;LZ();const s=bh(l,n.selectedSaver);return Ast(n,s!==void 0),G.jsxs(G.Fragment,{children:[G.jsx(vn,{id:Fc,name:F3,icon:e,extension:!0}),n.active===!0&&Fu(n)&&s&&G.jsx(Lst,{data:n,saver:s})]})};function qN(e){return e!==null&&typeof e=="object"&&"openFiles"in e&&Array.isArray(e.openFiles)}const Ou=da([Xt().describe("A ClassicyFileSystem path to a media file."),jn({url:Xt().describe("Source URL of the media document."),name:Xt().optional().describe("Display name of the document."),type:Es(["audio","video","image"]).optional().describe("Media kind, when known."),icon:Xt().optional().describe("Icon shown for the document."),subtitlesUrl:Xt().optional().describe("URL of an optional subtitle track.")}).describe("A manually opened media document.")]),aL=jn({openFiles:xn(Ou).optional().describe("Media documents currently open in Movie Player.")}),bl={name:"Movie Player",id:"MoviePlayer.app",get icon(){return tn("icons","system.quicktime.player")??""}},Rh=Es(["icons","list"]),_N=Es(["small","medium","large"]),oL=Es(["none","grid","sorted"]),dL=Es(["name","modified","created","size","kind","label"]),$N=ft({arrangement:oL.default("none"),keepArrangedBy:dL.default("name"),iconSize:_N.default("large")}),tY=ft({modified:Qn().default(!0),created:Qn().default(!1),size:Qn().default(!0),kind:Qn().default(!0),label:Qn().default(!1),comments:Qn().default(!1),version:Qn().default(!1)}),eY=ft({useRelativeDate:Qn().default(!0),calculateFolderSizes:Qn().default(!1),iconSize:_N.default("medium"),columns:tY.default(tY.parse({}))}),Eu=ft({icons:$N.default($N.parse({})),list:eY.default(eY.parse({}))}),nY="finder_preferences",Fh=e=>{const t=Eu.safeParse(e.standardViews??{});return t.success?t.data:Eu.parse({})},lY=jn({openPaths:xn(Xt()).optional().describe("Folder paths with an open Finder window, in open order."),showAboutThisComputer:Qn().optional().describe("Whether the About This Computer window is open."),showPreferences:Qn().optional().describe("Whether the Finder Preferences window is open."),standardViews:Eu.optional().describe("Default view options applied to folders using standard views."),folderViews:Tl(Xt(),Rh).optional().describe("Explicit per-folder view type. A path absent from this map follows the standard views.")}),sY="finder_about_this_computer";function iY(e){return lY.safeParse(e).success}const Sst=e=>Array.isArray(e.moves)?e.moves.filter(t=>typeof t=="object"&&t!==null&&typeof t.from=="string"&&typeof t.to=="string"&&t.from!==""):[],rL=(e,t,n,l)=>{const s=ON(t);return qo(l,s)?du(e,{type:s,app:{id:"Finder.app"},path:n}):e},uL=(e,t,n)=>{const l="Finder.app";if(!e.System.Manager.Applications.apps[l])return e;const s=e.System.Manager.Applications.apps[l].data??{};let i=Sw(l,s)??{...s};switch(t.type){case"ClassicyAppFinderOpenFolder":{if(!Qo(t))break;if(!i.openPaths){i={...i,openPaths:[t.path]};break}i={...i,openPaths:Array.from(new Set([...i.openPaths,t.path]))};break}case"ClassicyAppFinderOpenFolders":{if(!IA(t))break;const c=i.openPaths??[];i={...i,openPaths:Array.from(new Set([...c,...t.paths]))};break}case"ClassicyAppFinderCloseFolder":{if(!Qo(t))break;const c=i.openPaths??[];i={...i,openPaths:c.filter(a=>a!==t.path)},yb(e.System.Manager.Applications.apps[l],t.path,{closed:!0,focused:!1});break}case"ClassicyAppFinderAboutThisComputerOpen":{i={...i,showAboutThisComputer:!0},e=xi(e,l,sY);break}case"ClassicyAppFinderAboutThisComputerClose":{i={...i,showAboutThisComputer:!1};break}case"ClassicyAppFinderPreferencesOpen":{i={...i,showPreferences:!0},e=xi(e,l,nY);break}case"ClassicyAppFinderPreferencesClose":{i={...i,showPreferences:!1};break}case"ClassicyAppFinderSetStandardViewOption":{const{view:c,option:a,value:o}=t;if(c!=="icons"&&c!=="list"||typeof a!="string")break;const r=a.split(".");if(r.length>2)break;const u=Fh(i),d=u[c];let m;if(r.length===1)m={...d,[r[0]]:o};else{const h=d[r[0]];if(typeof h!="object"||h===null)break;m={...d,[r[0]]:{...h,[r[1]]:o}}}const Z={...u,[c]:m},b=Eu.safeParse(Z);if(!b.success)break;i={...i,standardViews:b.data};break}case"ClassicyAppFinderSetFolderView":{if(!Qo(t))break;const c=t.viewType;if(c!=="icons"&&c!=="list")break;i={...i,folderViews:{...i.folderViews??{},[t.path]:c}};break}case"ClassicyAppFinderPathsMoved":{const c=Sst(t);if(c.length===0)break;const a=r=>{for(const{from:u,to:d}of c){if(r===u)return d;if(r.startsWith(`${u}:`))return d+r.slice(u.length)}return r},o=e.System.Manager.Applications.apps[l];for(const r of i.openPaths??[]){const u=a(r);if(u===r)continue;const d=zn(o,r);d&&(AG(o,r),VG(o,{...d,id:u}))}i={...i,...i.openPaths?{openPaths:i.openPaths.map(a)}:{},...i.folderViews?{folderViews:Object.fromEntries(Object.entries(i.folderViews).map(([r,u])=>[a(r),u]))}:{}};break}case"ClassicyAppFinderEmptyTrash":break;case"ClassicyAppFinderOpenFile":{const c=VA(t)?t.file:void 0;if(c?._system)return e.System.Manager.Desktop.errorDialog={message:"This file is used by the system software. It cannot be opened."},e;if(c?._type===Gt.Extension)return e.System.Manager.Desktop.errorDialog={title:"Library",message:"This file adds functionality to your computer. It cannot be opened."},e;if(c&&c._creator==="QuickTime"){let a;try{a=typeof c._data=="string"?JSON.parse(c._data):c._data}catch(o){Wt("warn","ClassicyFinder","failed to parse QuickTime file data",{error:o,file:c})}if(typeof a=="object"&&a!==null&&"url"in a&&typeof a.url=="string"&&Vb(a.url)){if(!qo(n,"ClassicyAppMoviePlayerOpenDocument"))return e;e=du(e,{type:"ClassicyAppOpen",app:bl}),e=PG(e,"ClassicyAppMoviePlayer",{type:"ClassicyAppMoviePlayerOpenDocument",document:a})}}else if(c&&c._type===Gt.AppShortcut){const a=typeof c._creator=="string"?c._creator:void 0,o=a?e.System.Manager.Applications.apps[a]:void 0;o?qn(e,o.id,o.name,o.icon):e.System.Manager.Desktop.errorDialog={message:"The application that created this item could not be found."}}else if(c&&c._type===Gt.Shortcut){if(typeof c._url!="string"||c._url==="")return e.System.Manager.Desktop.errorDialog={message:"The original item for this shortcut could not be found."},e;if(!qo(n,"ClassicyDesktopOpenUrl"))return e;const a=Qo(t)?t.path.split(":").pop()??t.path:c._url;e=UG(e,{type:"ClassicyDesktopOpenUrl",url:c._url,disposition:c._openIn,title:typeof c._label=="string"?c._label:a})}else if(c&&Qo(t)){const a=c._type,o=e.System.Manager.Applications.fileTypeHandlers[a],r=o?e.System.Manager.Applications.apps[o]:void 0;if(r&&r.id!==l)e=Hz(e,r,t.path,n);else if(r)e=rL(e,r.name,t.path,n);else{const u=e.System.Manager.Applications.apps[l];u?.handlesFileTypes?.includes(a)?e=rL(e,u.name,t.path,n):e.System.Manager.Desktop.errorDialog={message:"Finder cannot open the file type you requested."}}}return e}}return e.System.Manager.Applications.apps[l].data={...i},e};Ln({id:"Finder.app",description:"The system file browser: desktop, folders, and the Trash.",prefix:"ClassicyAppFinder",handler:uL,actions:{ClassicyAppFinderOpenFolder:{description:"Open a Finder window at the given folder path.",params:ft({path:Xt().describe("Absolute path of the folder to open.")})},ClassicyAppFinderOpenFolders:{description:"Open Finder windows for several folder paths at once.",params:ft({paths:xn(Xt()).describe("Absolute paths of the folders to open.")})},ClassicyAppFinderCloseFolder:{description:"Close the Finder window showing the given folder path.",params:ft({path:Xt().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:ft({view:Rh.describe("Which view's options to change."),option:Xt().describe("Dotted option path within that view, max one level deep."),value:fo().describe("New value; validated against the schema.")})},ClassicyAppFinderSetFolderView:{description:"Remember an explicit view type for one folder, overriding the standard views.",params:ft({path:Xt().describe("Absolute path of the folder."),viewType:Rh.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:ft({moves:xn(ft({from:Xt().describe("Path before the move."),to:Xt().describe("Path after the move.")})).describe("Each moved item's old and new path.")})},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:ft({file:jn({}).describe("The ClassicyFileSystem entry being opened."),path:Xt().optional().describe("Filesystem path of the entry, when known.")})}},state:lY});const Cst=()=>G.jsx("svg",{className:"classicyProgressChasingArrowsSpinner",viewBox:"0 0 32 32",width:"16",height:"16",role:"img","aria-hidden":"true",focusable:"false",children:G.jsxs("g",{fill:"currentColor",children:[G.jsx("path",{d:"M16 3a13 13 0 0 1 12.5 9.4l-3.8 1.1A9 9 0 0 0 16 7z"}),G.jsx("path",{d:"M24.7 9.5 30 12l-2 5.6z"}),G.jsx("path",{d:"M16 29A13 13 0 0 1 3.5 19.6l3.8-1.1A9 9 0 0 0 16 25z"}),G.jsx("path",{d:"M7.3 22.5 2 20l2-5.6z"})]})}),Dh=({max:e=100,value:t,indeterminate:n,chasingArrows:l,autoSwitch:s,label:i,labelPosition:c="above",labelAlign:a="left",className:o,style:r})=>{const d=n&&!(s&&t!==void 0),m=d?100:e,Z=d?100:t??0,b=i?void 0:o,h=i?void 0:r;let p;return l?p=G.jsx("div",{className:$("classicyProgress classicyProgressChasingArrows",b),style:h,role:"progressbar","aria-busy":"true","aria-label":i,children:G.jsx(Cst,{})}):p=G.jsx("div",{className:$("classicyProgress",d?"classicyProgressIndeterminate":"classicyProgressDeterminate",b),style:h,children:G.jsx("progress",{max:m,value:Z})}),i?G.jsxs("div",{className:$(Yn(c),Hb(a),o),style:r,children:[G.jsx(Ot,{label:i}),p]}):p},mL={version:"3.1.0",release:"Limelight"},cY=64,fst=20.5,Rst="Off",Fst="Finder.app",{version:Dst}=mL,kst=mL.release,ZL=({className:e,style:t})=>{const n=jt("icons","classicy.bg")??"",l=jt("systemArt","aboutLogo")??"",s=jt("icons","system.macos")??"",i=jt("icons","system.mac")??"",c=Ut(),[a,o]=Y.useState(fst);Y.useEffect(()=>{const m=performance;typeof m.measureUserAgentSpecificMemory=="function"?m.measureUserAgentSpecificMemory().then(Z=>o(Z.bytes/(1024*1024))).catch(()=>{Wt("info","Finder","Could not measure memory usage, using default value")}):Wt("info","Finder","Memory measurement API not available, using default value")},[]);const r=cY-a,u=Lw("Finder.app","ClassicyAppFinderAboutThisComputerOpen"),d=`Classicy ${Dst} (${kst})`;return G.jsx(ge,{id:sY,appId:Fst,className:e,style:t,hideIcon:!0,title:"About This Computer",closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,initialSize:[520,290],initialPosition:["center","center"],onCloseFunc:()=>c({type:"ClassicyAppFinderAboutThisComputerClose"}),children:G.jsxs("div",{className:"finderAboutThisComputer",children:[G.jsxs("div",{className:"finderAboutThisComputerHeader",children:[G.jsx("div",{className:"finderAboutThisComputerBanner",style:{backgroundSize:"cover",backgroundPosition:"bottom left",backgroundImage:`url("${n}")`,backgroundRepeat:"no-repeat"},children:G.jsx("img",{src:l,alt:"Classicy"})}),G.jsxs("div",{className:"finderAboutThisComputerVersion",children:[G.jsx("img",{src:s,alt:"Classicy"}),u?G.jsx(Gy,{title:u.title,content:u.content,children:G.jsx("span",{children:d})}):G.jsx("span",{children:d})]})]}),G.jsxs("div",{className:"finderAboutThisComputerInfo",children:[G.jsxs("div",{className:"finderAboutThisComputerMemoryStats",children:[G.jsxs("p",{children:[G.jsx("strong",{children:"Built-in Memory:"})," ",cY," MB"]}),G.jsxs("p",{children:[G.jsx("strong",{children:"Virtual Memory:"})," ",Rst]}),G.jsxs("p",{children:[G.jsx("strong",{children:"Largest Unused Block:"})," ",r.toFixed(1)," MB"]})]}),G.jsx("p",{className:"finderAboutThisComputerCopyright",children:"Not \u2122 & \xA9 Apple Computer, Inc. 1983\u20131999"})]}),G.jsx("div",{className:"finderAboutThisComputerUsage",children:G.jsxs("div",{className:"finderAboutThisComputerUsageItem",children:[G.jsx("img",{src:i,alt:"Classicy"}),G.jsx("span",{className:"finderAboutThisComputerUsageName",children:"Classicy"}),G.jsxs("span",{className:"finderAboutThisComputerUsageSize",children:[a.toFixed(1)," MB"]}),G.jsx("div",{className:"finderAboutThisComputerUsageBar",children:G.jsx(Dh,{value:a,max:cY})})]})})]})})},jst=[{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"}],vst=[{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"}],bL=e=>{const t=Ut(),[n,l]=Y.useState("icons"),s=Y.useCallback((o,r,u)=>{t({type:"ClassicyAppFinderSetStandardViewOption",view:o,option:r,value:u})},[t]),i=e.icons,c=e.list;return{title:"Views",children:Y.useMemo(()=>G.jsx("div",{className:"finderPreferencesViews",children:G.jsxs(Jn,{label:"View Options",children:[G.jsx(Me,{id:"finder_prefs_view_type",label:"View type:",labelPosition:"left",selected:n,options:[{value:"icons",label:"Icons"},{value:"list",label:"List"}],onChangeFunc:o=>l(o.target.value)}),n==="icons"?G.jsxs("div",{className:"finderPreferencesPane",children:[G.jsx("p",{className:"finderPreferencesGroupHeading",children:"Icon Arrangement:"}),G.jsx(Xa,{name:"finder_prefs_icon_arrangement",onClickFunc:o=>s("icons","arrangement",o.split("__").pop()),inputs:[{id:"finder_prefs_icon_arrangement__none",label:"None",checked:i.arrangement==="none"},{id:"finder_prefs_icon_arrangement__grid",label:"Always snap to grid",checked:i.arrangement==="grid"},{id:"finder_prefs_icon_arrangement__sorted",label:"Keep arranged:",checked:i.arrangement==="sorted"}]}),G.jsx(Me,{id:"finder_prefs_icon_sort",disabled:i.arrangement!=="sorted",selected:i.keepArrangedBy,options:jst,onChangeFunc:o=>s("icons","keepArrangedBy",o.target.value)}),G.jsx(Xa,{name:"finder_prefs_icon_size",onClickFunc:o=>s("icons","iconSize",o.split("__").pop()),inputs:[{id:"finder_prefs_icon_size__small",label:"Small icons",checked:i.iconSize==="small"},{id:"finder_prefs_icon_size__large",label:"Large icons",checked:i.iconSize!=="small"}]})]}):G.jsxs("div",{className:"finderPreferencesPane",children:[G.jsx(Xn,{id:"finder_prefs_relative_date",label:"Use relative date",checked:c.useRelativeDate,onClickFunc:o=>s("list","useRelativeDate",o)}),G.jsx(Xn,{id:"finder_prefs_folder_sizes",label:"Calculate folder sizes",checked:c.calculateFolderSizes,onClickFunc:o=>s("list","calculateFolderSizes",o)}),G.jsx("p",{className:"finderPreferencesGroupHeading",children:"Show Columns:"}),vst.map(({key:o,label:r})=>G.jsx(Xn,{id:`finder_prefs_column_${o}`,label:r,checked:c.columns[o]===!0,onClickFunc:u=>s("list",`columns.${o}`,u)},o)),G.jsx(Xa,{name:"finder_prefs_list_icon_size",onClickFunc:o=>s("list","iconSize",o.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"}]})]})]})}),[n,i,c,s])}},hL="Finder.app",pL=({className:e,style:t})=>{const n=jt("icons","system.help")??"",l=Ut(),s=ut(o=>o.System.Manager.Applications.apps[hL]?.data),i=Y.useMemo(()=>Fh(s??{}),[s]),c=bL(i),a=Y.useMemo(()=>[c],[c]);return G.jsx(ge,{id:nY,appId:hL,className:e,style:t,title:"Preferences",closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,modal:!1,initialSize:[470,0],initialPosition:["center","center"],onCloseFunc:()=>l({type:"ClassicyAppFinderPreferencesClose"}),children:G.jsxs("div",{className:"finderPreferences",children:[G.jsx(jy,{tabs:a}),G.jsxs("div",{className:"finderPreferencesFooter",children:[G.jsx("img",{className:"finderPreferencesHelpIcon",src:n,alt:"Help"}),G.jsx("p",{className:"finderPreferencesNote",children:"Changes are applied to all folders that are set to Standard views. Other folders are not affected."})]})]})})};function WL(e,t){const[n,l]=Y.useState(void 0);return Y.useEffect(()=>{let s=!1;l(void 0);const i=t.resolve(e);return i&&t.calculateSizeDir(i).then(c=>{s||l(c)}),()=>{s=!0}},[e,t]),n}const Uu={emptyTrash:"empty_trash",resetPram:"reset_pram"},aY=(e,t)=>[{id:`${t}_special_empty_trash`,title:"Empty Trash\u2026",onClickFunc:()=>{e({type:"ClassicyDesktopShowSystemDialog",dialog:"emptyTrash"})}},{id:"spacer"},{id:`${t}_special_reset_pram`,title:"Reset PRAM\u2026",onClickFunc:()=>{e({type:"ClassicyDesktopShowSystemDialog",dialog:"resetPram"})}}],GL=({itemCount:e,onEmpty:t,onClose:n,className:l,style:s})=>{if(e===0)return G.jsx(_l,{id:Uu.emptyTrash,appId:"Finder.app",alertType:"note",label:"The Trash is empty.",buttons:[{id:"ok",label:"OK",role:"default"}],onClose:n,className:l,style:s});const i=e===1?"1 item":`${e} items`;return G.jsx(_l,{id:Uu.emptyTrash,appId:"Finder.app",alertType:"caution",label:`The Trash contains ${i}. Are you sure you want to permanently remove ${e===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:t}],onClose:n,className:l,style:s})},Jst={small:.5,medium:1,large:1},Ost={small:.25,medium:.375,large:.667},yL=(e,t)=>Math.round(e*Jst[t]),NL=(e,t)=>Math.round(e*Ost[t]),kh=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"}),YL=e=>(t,n)=>{if(e==="name")return kh(t,n);const l=a=>{switch(e){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}},s=l(t),i=l(n);if(s===void 0&&i===void 0)return kh(t,n);if(s===void 0)return 1;if(i===void 0)return-1;if(typeof s=="string"&&typeof i=="string"){const a=s.localeCompare(i,void 0,{sensitivity:"base"});return a!==0?a:kh(t,n)}const c=Number(s)-Number(i);return c!==0?c:kh(t,n)},Est=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ust=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],oY=e=>{const t=e.getHours(),n=t>=12?"PM":"AM";return`${t%12===0?12:t%12}:${String(e.getMinutes()).padStart(2,"0")} ${n}`},XL=e=>`${Est[e.getDay()]}, ${Ust[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`,gL=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),dY=(e,t,n)=>{if(!e)return"\u2014";if(!n)return`${XL(e)}, ${oY(e)}`;if(gL(e,t))return`Today, ${oY(e)}`;const l=new Date(t.getFullYear(),t.getMonth(),t.getDate()-1);return gL(e,l)?`Yesterday, ${oY(e)}`:XL(e)},Di=e=>{if(e instanceof Date)return Number.isNaN(e.getTime())?void 0:e;if(typeof e=="string"||typeof e=="number"){const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}},ML=e=>e&&String(e[0]).toUpperCase()+String(e).slice(1),TL=e=>e==="app_shortcut"?"Application":ML(e.replaceAll("_"," ")),Ld=e=>e==="directory"?tn("icons","system.folders.directory")??"":tn("icons","system.files.file")??"",Bst=(e,t,n)=>[Math.floor(n[0]/(e*2+t)),Math.floor(n[1]/(e*2+t))],IL=(e,t)=>[e%t[0],Math.floor(e/t[0])],jh=(e,t)=>{const n=gb(e);return{size:qe("--desktop-icon-size",n.size,t),padding:qe("--desktop-icon-padding",n.padding,t),cell:qe("--desktop-icon-cell",n.cell,t)}},rY=(e,t,n=jh(e))=>{const l=t!==void 0?t*2:n.cell;return{origin:[n.padding,n.padding],pitch:[l,l]}},VL=(e,t,n,l,s,i=jh(e))=>{const{origin:c,pitch:a}=rY(e,s,i),o=[Math.floor(l[0]/(a[0]+i.padding)),Math.floor(l[1]/(a[1]+i.padding))],[r,u]=IL(t,o);return[c[0]+Math.floor(a[0]*r),c[1]+Math.floor(a[1]*u)]},Pst=127,Hst=[[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[-1,-1],[1,-1]];function AL(e,t,n){const l=(a,o)=>a>=0&&o>=0&&a<t&&o<n&&e[o*t+a]===1,s=new Uint8Array(t*n);for(let a=0;a<n;a++)for(let o=0;o<t;o++)l(o,a)&&(!l(o-1,a)||!l(o+1,a)||!l(o,a-1)||!l(o,a+1))&&(s[a*t+o]=1);const i=new Uint8Array(t*n),c=new Uint8Array(t*n);for(let a=0;a<s.length;a++){if(!s[a]||c[a])continue;let o=a,r=!0;for(;o!==-1;){c[o]=1,r&&(i[o]=1),r=!r;const u=o%t,d=(o-u)/t;let m=-1;for(const[Z,b]of Hst){const h=u+Z,p=d+b;if(h<0||p<0||h>=t||p>=n)continue;const W=p*t+h;if(s[W]&&!c[W]){m=W;break}}o=m}}return i}const wL=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?{left:t.left,top:t.top,width:t.width,height:t.height}:null};function xL(e){const t=e.map(b=>({image:b.image??null,imageBox:b.image?wL(b.image):null,labelBox:b.label?wL(b.label):null})),n=t.flatMap(b=>[b.imageBox,b.labelBox].filter(h=>h!==null));if(n.length===0)return null;const l=Math.floor(Math.min(...n.map(b=>b.left))),s=Math.floor(Math.min(...n.map(b=>b.top))),i=Math.ceil(Math.max(...n.map(b=>b.left+b.width))),c=Math.ceil(Math.max(...n.map(b=>b.top+b.height))),a=i-l,o=c-s,r=document.createElement("canvas");r.width=a,r.height=o;const u=r.getContext("2d",{willReadFrequently:!0});if(!u)return null;u.imageSmoothingEnabled=!1;for(const{image:b,imageBox:h}of t)!b||!h||u.drawImage(b,Math.round(h.left-l),Math.round(h.top-s),Math.round(h.width),Math.round(h.height));const d=new Uint8Array(a*o);try{const{data:b}=u.getImageData(0,0,a,o);for(let h=0;h<d.length;h++)b[h*4+3]>Pst&&(d[h]=1)}catch{for(const{imageBox:b}of t)b&&zL(d,a,b,l,s)}for(const{labelBox:b}of t)b&&zL(d,a,b,l,s);const m=AL(d,a,o);u.clearRect(0,0,a,o);const Z=u.createImageData(a,o);for(let b=0;b<m.length;b++)m[b]===1&&(Z.data[b*4+3]=255);return u.putImageData(Z,0,0),{canvas:r,left:l,top:s}}function zL(e,t,n,l,s){const i=Math.max(0,Math.round(n.left-l)),c=Math.max(0,Math.round(n.top-s)),a=Math.min(t,Math.round(n.left-l+n.width)),o=Math.min(e.length/t,Math.round(n.top-s+n.height));for(let r=c;r<o;r++)for(let u=i;u<a;u++)e[r*t+u]=1}const ki="data-classicy-file-path",Sd="data-classicy-drop-folder",uY="data-classicy-drop-desktop",LL=4,SL="classicyFileDropTarget",CL="classicyFileDragging",Kst=".classicyWindow, .classicyDesktopMenuBar, .classicyControlStrip, [role='dialog']",Qst=(e,t)=>typeof document<"u"&&document.elementsFromPoint?document.elementsFromPoint(e,t):[];function fL(e,t,{exclude:n,elementsFromPoint:l=Qst}={}){for(const s of l(e,t))if(!n?.contains(s)){for(let i=s;i;i=i.parentElement){const c=i.getAttribute(Sd);if(c!==null)return{destination:{kind:"folder",path:c},element:i};if(i.hasAttribute(uY))return{destination:{kind:"desktop"},element:i};if(i.matches(Kst))return null}return null}return null}function vh(e){const{start:t,source:n,elementsFromPoint:l}=e;let s=null,i=[0,0],c=null;const a=y=>{c!==y&&(c?.classList.remove(SL),c=y,c?.classList.add(SL))},o=(y,N)=>{s&&(s.style.transform=`translate(${y-i[0]}px, ${N-i[1]}px)`)},r=()=>{s=document.createElement("div"),s.className="classicyFileDragGhost",s.setAttribute("aria-hidden","true");const y=xL(e.parts);y&&(s.append(y.canvas),i=[t.clientX-y.left,t.clientY-y.top]),document.body.append(s),document.body.classList.add(CL)};let u=()=>{};const d=()=>{u(),document.removeEventListener("mousemove",b,!0),document.removeEventListener("mouseup",h,!0),document.removeEventListener("keydown",W,!0),a(null),s?.remove(),s=null,document.body.classList.remove(CL)},m=y=>{try{e.onEnd?.(y)}catch(N){Wt("error","ClassicyFileDrag","onEnd threw; ignored.",N)}},Z=(y,N)=>fL(y,N,{exclude:n,elementsFromPoint:l});function b(y){if(!s){if(Math.max(Math.abs(y.clientX-t.clientX),Math.abs(y.clientY-t.clientY))<LL)return;r(),e.onStart?.()}y.preventDefault(),o(y.clientX,y.clientY);const N=Z(y.clientX,y.clientY);a(N?.destination.kind==="folder"?N.element:null)}function h(y){const N=s!==null;if(d(),!N){e.onClick?.();return}const X=Z(y.clientX,y.clientY);m({dropped:X!==null,canceled:!1,lost:!1}),e.onDrop(X,[y.clientX,y.clientY],[y.clientX-i[0],y.clientY-i[1]])}const p=y=>{const N=s!==null;d(),N&&m({dropped:!1,canceled:!0,lost:y})};function W(y){y.key!=="Escape"||!s||(y.preventDefault(),y.stopPropagation(),p(!1))}return document.addEventListener("mousemove",b,!0),document.addEventListener("mouseup",h,!0),document.addEventListener("keydown",W,!0),u=Vl(()=>p(!0)),()=>p(!1)}function mY(e){return{onStart:()=>e("dragStart",{kind:"file"}),onEnd:({dropped:t,canceled:n,lost:l})=>e("dragEnd",{kind:"file",dropped:t,canceled:n,lost:l})}}function ZY(){const e=Y.useRef(null);return Y.useLayoutEffect(()=>()=>{e.current?.(),e.current=null},[]),Y.useCallback(t=>{e.current=t},[])}const bY=(e,t,n=[0,0])=>[n[0]+Math.round((e[0]-n[0])/t[0])*t[0],n[1]+Math.round((e[1]-n[1])/t[1])*t[1]],RL=({appId:e,name:t,icon:n,label:l,labelPosition:s="below",initialPosition:i=[0,0],holder:c,onClickFunc:a,invisible:o=!1,size:r,snapTo:u,snapOrigin:d,positionLocked:m=!1,dropFolderPath:Z,filePath:b,onFileDrag:h,className:p,style:W})=>{const[y,N]=Y.useState(i),[X,g]=Y.useState(!1),[M,I]=Y.useState(!1),A=Y.useRef(!1),V=Y.useRef(null),z=Re("Icon",{dragging:X,selected:M},V),x=Y.useRef(!1),S=ZY(),C=`${e}.shortcut`,{track:k}=Nn(),v={type:"ClassicyIcon",appId:e,name:t,icon:n,label:l},J=()=>{k("focus",v),z.emit("select",{selected:!M}),I(!M)},R=P=>{k("focus",v),I(P)},D=()=>{k("blur",v),I(!1)},L=()=>{a&&(z.emit("open",kt()),D(),a())},w=P=>{u&&A.current&&N(q=>bY(q,u,d)),A.current=!1,g(!1),x.current&&(x.current=!1,z.emit("dragEnd",{lost:P}))};Rb(X,()=>w(!0));const j=P=>{if(h){if(P.button!==0)return;const q=V.current,ot=vh({start:{clientX:P.clientX,clientY:P.clientY},parts:[{image:q?.querySelector("img"),label:q?.querySelector("p")}],source:q,...mY(z.emit),onDrop:(gt,Zt,K)=>{if(h(gt,Zt,K)||m)return;const O=[y[0]+Zt[0]-P.clientX,y[1]+Zt[1]-P.clientY];N(u?bY(O,u,d):O),R(!0)}});S(ot);return}m||(A.current=!1,g(!0),x.current=!0,z.emit("dragStart"))},B=P=>{c?.current&&X&&V.current&&(A.current=!0,R(!0),N([P.clientX-c.current.getBoundingClientRect().left-V.current.getBoundingClientRect().width/2,P.clientY-c.current.getBoundingClientRect().top-V.current.getBoundingClientRect().height/2]))},f=Y.useId(),U=G.jsx("p",{className:$(o?"classicyIconInvisible":""),children:l||t}),_=G.jsx("div",{className:$("classicyIconMaskOuter",o?"classicyIconInvisible":""),style:{"--classicy-icon-mask":`url("${n}")`},children:G.jsx("div",{className:"classicyIconMask",children:G.jsx("img",{src:n,alt:t})})});return G.jsxs("div",{...z.attrs,role:"button",tabIndex:0,ref:V,id:`${C}-${f}`,draggable:!1,...Z===void 0?{}:{[Sd]:Z},...b===void 0?{}:{[ki]:b},className:$("classicyIcon",z.className,Yn(s),p),style:{...Gu(z.style),left:`${y[0]}px`,top:`${y[1]}px`,...r===void 0?{}:{"--desktop-icon-size":`${r}px`},...Gu(W)},onClick:J,onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),L())},onMouseDown:j,onMouseMove:B,onMouseUp:()=>w(!1),onDoubleClick:L,children:[s==="above"?U:_,s==="above"?_:U]})},hY=Y.memo(({fs:e,path:t,appId:n,dirOnClickFunc:l,fileOnClickFunc:s,holderRef:i,hideFilesCreatedAfter:c=null,showInvisible:a=!0,iconViewOptions:o,onMoveItems:r,className:u,style:d})=>{const m=ut(g=>g.System.Manager.Appearance.activeTheme),Z=Y.useRef(null),b=i??Z,[h,p]=Y.useState([]),W=Y.useRef(null),y=o?.arrangement,N=o?.keepArrangedBy,X=o?.iconSize;return Y.useLayoutEffect(()=>{if(!b.current)return;const g=(J,R,D)=>{if(J._type==="directory")return l?l(`${R}:${D}`):void 0;if(s)return s(`${R}:${D}`)},M=[b.current.getBoundingClientRect().width,b.current.getBoundingClientRect().height],I=e.filterByType(t,void 0,a,c),A=Object.entries(I),V=y==="sorted"&&N?[...A].sort((J,R)=>YL(N)({name:J[0],modifiedOn:Di(J[1]._modifiedOn),createdOn:Di(J[1]._createdOn),size:J[1]._size,kind:J[1]._type,label:J[1]._label},{name:R[0],modifiedOn:Di(R[1]._modifiedOn),createdOn:Di(R[1]._createdOn),size:R[1]._size,kind:R[1]._type,label:R[1]._label})):A;W.current?.theme!==m&&(W.current={theme:m,metrics:jh(m)});const z=W.current.metrics,x=X?yL(z.size,X):void 0,S=rY(m,x,z),C=y==="grid"?S.pitch:void 0,k=y==="sorted",v=V.map(([J,R],D)=>{const L=`${t}${e.separator}${J}`;return{filePath:L,dropFolderPath:R._type==="directory"?L:void 0,onFileDrag:(w,j,B)=>w?.destination.kind==="folder"&&w.destination.path===t?!1:(w&&r&&r([L],w.destination,B),!0),appId:n,name:J,invisible:R._invisible,icon:R._icon||Ld(R._type),onClickFunc:()=>g(R,t,J),holder:b,initialPosition:VL(m,D,V.length,M,x,z),size:x,snapTo:C,snapOrigin:S.origin,positionLocked:k}});p(v)},[n,t,e,l,s,m,b.current,b,c,a,y,N,X,r]),G.jsx("div",{className:$("classicyFileBrowserFill",u),style:d,ref:b,children:h.map(g=>Y.createElement(RL,{...g,key:g.name}))})});hY.displayName="ClassicyFileBrowserViewIcons";function FL({columns:e,rows:t,getRowId:n,selectionMode:l="single",selected:s,onSelectionChange:i,onActivateRow:c,defaultSort:a,stickyHeader:o=!0,className:r,style:u,rowClassName:d,getSubRows:m,rowCanExpand:Z,expanded:b,onToggleRow:h,selectionApiRef:p,containerRef:W}){const y=jt("icons","ui.menuDropdownArrowUp")??"",[N,X]=Y.useState(a?[{id:a.columnId,desc:!!a.desc}]:[]),[g,M]=Y.useState([]),I=b??g,A=Y.useMemo(()=>Object.fromEntries(I.map(O=>[O,!0])),[I]),V=Y.useCallback(O=>{const H=!I.includes(O);M(H?[...I,O]:I.filter(et=>et!==O)),h?.(O,H)},[I,h]),[z,x]=Y.useState([]),[S,C]=Y.useState(),k=s??z,v=Y.useRef(void 0),J=Y.useRef(null),R=Y.useCallback(O=>{J.current=O,W&&(W.current=O)},[W]),D=Re("Table",{},J),L=Y.useRef(""),w=Y.useRef(void 0),j=Y.useMemo(()=>new Map(e.map(O=>[O.id,O])),[e]),B=Y.useMemo(()=>e.map(O=>({id:O.id,accessorFn:H=>O.accessor(H),enableSorting:O.sortable!==!1,enableResizing:O.resizable!==!1,...O.width!==void 0?{size:O.width}:{}})),[e]),f=zZ.useReactTable({data:t,columns:B,getRowId:n,getSubRows:m,...Z?{getRowCanExpand:O=>Z(O.original)}:{},getCoreRowModel:zZ.getCoreRowModel(),getSortedRowModel:zZ.getSortedRowModel(),getExpandedRowModel:zZ.getExpandedRowModel(),state:{sorting:N,expanded:A},onSortingChange:X,columnResizeMode:"onChange"}),U=Y.useRef(void 0),_=Y.useCallback(()=>{const O=U.current;if(!O)return;U.current=void 0;const H=new Event(O==="touch"?"touchend":"mouseup");O==="touch"&&Object.defineProperty(H,"touches",{value:[]}),document.dispatchEvent(H)},[]),P=f.getState().columnSizingInfo.isResizingColumn;Y.useEffect(()=>{if(!P)return;const O=Vl(_);return()=>{O(),f.getState().columnSizingInfo.isResizingColumn&&_()}},[P,f,_]);const q=Y.useCallback(O=>{x(O),i?.(O)},[i]),ot=Y.useCallback(()=>{l==="multi"&&q(f.getRowModel().rows.map(O=>O.id))},[l,q,f]);Y.useEffect(()=>{if(p)return p.current={selectAll:ot},()=>{p.current=null}},[p,ot]);const gt=(O,H)=>{if(l==="none")return;const et=f.getRowModel().rows,rt=at=>D.emit("select",kt({rowId:O,selected:at}));if(l==="multi"){if(H.shiftKey&&v.current){const at=et.findIndex(pt=>pt.id===v.current),tt=et.findIndex(pt=>pt.id===O);if(at>=0&&tt>=0){const[pt,_t]=at<=tt?[at,tt]:[tt,at];rt(!0),q(et.slice(pt,_t+1).map(lt=>lt.id));return}}if(H.metaKey||H.ctrlKey){v.current=O,rt(!k.includes(O)),q(k.includes(O)?k.filter(at=>at!==O):[...k,O]);return}}v.current=O,rt(!0),q([O])},Zt=(O,H)=>{C(O),gt(O,H),requestAnimationFrame(()=>{const et=J.current?.querySelector(`[data-row-id="${CSS.escape(O)}"]`);try{et?.scrollIntoView({block:"nearest"})}catch{}})},K=O=>{if(l==="none")return;const H=f.getRowModel().rows;if(H.length===0)return;const et=H.findIndex(Yt=>Yt.id===S),rt={shiftKey:O.shiftKey&&l==="multi",metaKey:!1,ctrlKey:!1};switch(O.key){case"ArrowDown":{O.preventDefault();const Yt=Math.min(et+1,H.length-1);Zt(H[Yt<0?0:Yt].id,rt);return}case"ArrowUp":{O.preventDefault();const Yt=et<0?0:Math.max(et-1,0);Zt(H[Yt].id,rt);return}case"Home":{O.preventDefault(),Zt(H[0].id,rt);return}case"End":{O.preventDefault(),Zt(H[H.length-1].id,rt);return}case"ArrowRight":{if((O.metaKey||O.ctrlKey)&&et>=0){const Yt=H[et];Yt.getCanExpand()&&!Yt.getIsExpanded()&&(O.preventDefault(),V(Yt.id))}return}case"ArrowLeft":{if((O.metaKey||O.ctrlKey)&&et>=0){const Yt=H[et];Yt.getCanExpand()&&Yt.getIsExpanded()&&(O.preventDefault(),V(Yt.id))}return}case"Enter":{if(et>=0){O.preventDefault();const Yt=H[et];c?.(Yt.id,Yt.original)}return}case"a":case"A":{if((O.metaKey||O.ctrlKey)&&l==="multi"){O.preventDefault(),ot();return}break}}if(!(O.key.length===1&&O.key!==" "&&!O.metaKey&&!O.ctrlKey&&!O.altKey))return;w.current&&clearTimeout(w.current),L.current+=O.key.toLowerCase(),w.current=setTimeout(()=>{L.current=""},700);const tt=L.current,pt=e[0];if(!pt)return;const _t=et<0?0:et,It=[...H.slice(_t+1),...H.slice(0,_t+1)].find(Yt=>`${pt.accessor(Yt.original)??""}`.toLowerCase().startsWith(tt));It&&Zt(It.id,{shiftKey:!1,metaKey:!1,ctrlKey:!1})};return G.jsx("div",{...D.attrs,ref:R,tabIndex:l==="none"?void 0:0,onKeyDown:K,className:$("classicyTableContainer",D.className,r),style:D.style?{...D.style,...u}:u,children:G.jsxs("table",{className:"classicyTable",children:[G.jsx("thead",{className:$("classicyTableHeader",o&&"classicyTableHeaderSticky"),children:f.getHeaderGroups().map(O=>G.jsx("tr",{className:"classicyTableHeaderGroup",children:O.headers.map(H=>{const et=N.length>0&&H.id===N[0].id;return G.jsx("th",{align:j.get(H.id)?.align??"left","aria-sort":et?N[0].desc?"descending":"ascending":void 0,style:{width:H.getSize()},className:$("classicyTableColumnHeader",H.column.getIsResizing()?"isResizing":"",Xe({selected:!!et})),onClick:()=>{if(!H.column.getCanSort())return;const rt=!(H.column.getIsSorted()===!1||H.column.getIsSorted()==="desc");H.column.toggleSorting(rt,!1),D.emit("change",{columnId:H.id,desc:rt})},children:G.jsxs("div",{className:"classicyTableHeaderCellContent",children:[!H.isPlaceholder&&G.jsx("span",{children:j.get(H.id)?.title??""}),et&&G.jsx("img",{src:`${y}`,alt:"Up Arrow",className:$("classicyTableSortArrow",N[0].desc?"":"classicyTableSortArrowAscending")}),H.column.getCanResize()&&G.jsx("div",{onMouseDown:rt=>{U.current="mouse",H.getResizeHandler()(rt)},onTouchStart:rt=>{U.current="touch",H.getResizeHandler()(rt)},className:$("resizer",H.column.getIsResizing()?"isResizing":"")})]})},H.id)})},O.id))}),G.jsx("tbody",{className:"classicyTableContent",children:f.getRowModel().rows.map(O=>G.jsx("tr",{"data-row-id":O.id,"data-selected":k.includes(O.id)||void 0,className:$("classicyTableRow",Xe({selected:k.includes(O.id)}),d?.(O.original,k.includes(O.id))),onClick:H=>{C(O.id),gt(O.id,H)},onDoubleClick:()=>c?.(O.id,O.original),children:O.getVisibleCells().map(H=>{const et=j.get(H.column.id);return G.jsx("td",{className:"classicyTableCell",style:{width:H.column.getSize(),textAlign:et?.align??"left"},children:et?.render?et.render(O.original,{depth:O.depth,canExpand:O.getCanExpand(),isExpanded:O.getIsExpanded(),toggle:()=>V(O.id),emitDrag:D.emit}):G.jsx("span",{children:`${H.getValue()??""}`})},H.id)})},O.id))})]})})}const qst={modified:!1,created:!1,size:!0,kind:!0,label:!1,comments:!1,version:!1},pY=Y.memo(({fs:e,path:t,iconSize:n=64,appId:l,dirOnClickFunc:s=()=>{},fileOnClickFunc:i=()=>{},hideFilesCreatedAfter:c=null,showInvisible:a=!0,listViewOptions:o,now:r,selectionApiRef:u,selectedPaths:d,onSelectionChange:m,focusTargetRef:Z,onMoveItems:b,className:h,style:p})=>{const W=Y.useRef(d??[]);Y.useEffect(()=>{d&&(W.current=d)},[d]);const y=Y.useCallback(D=>{W.current=D,m?.(D)},[m]),N=ZY(),X=Y.useCallback((D,L,w)=>{if(D.button!==0||!b)return;const j=W.current,B=j.includes(L)?j:[L],f=D.currentTarget.closest(".classicyFileBrowserViewTableContainer"),U=B.map(P=>Array.from(f?.querySelectorAll(`[${ki}]`)??[]).find(q=>q.getAttribute(ki)===P)).filter(P=>P!==void 0),_=vh({start:{clientX:D.clientX,clientY:D.clientY},parts:U.map(P=>({image:P.querySelector("img"),label:P.querySelector(".classicyFileBrowserViewTableRowIconLabel")})),source:D.currentTarget,...w&&mY(w),onDrop:(P,q,ot)=>{P&&(P.destination.kind==="folder"&&P.destination.path===t||b(B,P.destination,ot))}});N(_)},[b,t,N]),g=o?.columns??qst,M=o?.calculateFolderSizes??!0,I=o?.useRelativeDate??!0,A=r?.getTime(),V=Y.useMemo(()=>A===void 0?new Date:new Date(A),[A]),[z,x]=Y.useState([]),S=(D,L)=>D._type==="directory"?s(L):i(L),[C,k]=Y.useState(new Map),v=Y.useMemo(()=>new Set(z),[z]),J=Y.useMemo(()=>{const D=L=>{const w=e.filterByType(L,void 0,a,c);return Object.entries(w).map(([j,B])=>{const f=`${L}:${j}`,U={};for(const[P,q]of Object.entries(B))P.startsWith("_")&&(U[P]=q);U._name=j,U._path=f,U._size=C.has(f)?C.get(f):typeof B._size=="number"?B._size:void 0;const _=U;return B._type===Gt.Directory&&v.has(f)&&(_.subRows=D(f)),_})};return D(t)},[e,t,C,v,c,a]);Y.useEffect(()=>{if(!M)return;let D=!1;const L=[],w=j=>{j.forEach(B=>{typeof B._size!="number"&&B._path&&!C.has(B._path)&&L.push(B._path),B.subRows&&w(B.subRows)})};return w(J),L.forEach(j=>{e.size(j).then(B=>{D||k(f=>{if(f.has(j))return f;const U=new Map(f);return U.set(j,B),U})})}),()=>{D=!0}},[J,e,C,M]);const R=Y.useMemo(()=>{const D=[{id:"_name",title:"Filename",accessor:L=>L._name??"",render:(L,w)=>G.jsxs("div",{className:"classicyFileBrowserViewTableRowContainer",[ki]:L._path,...L._type===Gt.Directory&&L._path?{[Sd]:L._path}:{},onMouseDown:j=>L._path&&X(j,L._path,w.emitDrag),style:{paddingLeft:`calc(var(--window-control-size) * ${w.depth})`},children:[G.jsx("span",{className:"classicyFileBrowserViewTableDisclosure",children:w.canExpand&&G.jsx("span",{className:"classicyFileBrowserViewTableDisclosureTriangle",onClick:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),children:G.jsx(Wh,{direction:"right",open:w.isExpanded,onToggle:w.toggle})})}),G.jsx("img",{src:L._icon||Ld(L._type),width:n,alt:L._path,className:"classicyFileBrowserViewTableRowIcon"}),G.jsx("span",{className:"classicyFileBrowserViewTableRowIconLabel",children:L._name})]})}];return g.modified&&D.push({id:"_modifiedOn",title:"Date Modified",accessor:L=>Di(L._modifiedOn)?.getTime()??0,render:L=>G.jsx("span",{children:dY(Di(L._modifiedOn),V,I)})}),g.created&&D.push({id:"_createdOn",title:"Date Created",accessor:L=>Di(L._createdOn)?.getTime()??0,render:L=>G.jsx("span",{children:dY(Di(L._createdOn),V,I)})}),g.size&&D.push({id:"_size",title:"Size",accessor:L=>L._size,render:L=>G.jsx("span",{children:L._size===void 0?M?"Calculating\u2026":"\u2014":L._size===-1?"\u2014":e.formatSize(L._size)})}),g.kind&&D.push({id:"_type",title:"Kind",accessor:L=>L._type,render:L=>G.jsx("span",{children:TL(L._type)})}),g.label&&D.push({id:"_label",title:"Label",accessor:L=>L._label??"",render:L=>G.jsx("span",{children:L._label??"\u2014"})}),g.comments&&D.push({id:"_comments",title:"Comments",accessor:L=>L._comments??"",render:L=>G.jsx("span",{children:L._comments??"\u2014"})}),g.version&&D.push({id:"_version",title:"Version",accessor:L=>L._version??"",render:L=>G.jsx("span",{children:L._version??"\u2014"})}),D},[e,n,g,V,I,M,X]);return G.jsx(FL,{className:$("classicyFileBrowserViewTableContainer",h),style:p,columns:R,rows:J,getRowId:D=>D._path??"",getSubRows:D=>D.subRows,rowCanExpand:D=>D._type===Gt.Directory,expanded:z,onToggleRow:(D,L)=>x(w=>L?[...w,D]:w.filter(j=>j!==D)),defaultSort:{columnId:"_name"},onActivateRow:(D,L)=>S(L,L._path??""),rowClassName:()=>"classicyFileBrowserViewTableRow",selectionMode:"multi",selectionApiRef:u,selected:d,onSelectionChange:y,containerRef:Z},`${l}_filebrowser_${t}`)});pY.displayName="ClassicyFileBrowserViewTable";const DL=()=>{},kL=()=>{},jL=({fs:e,display:t="icons",path:n,appId:l,dirOnClickFunc:s,fileOnClickFunc:i,hideFilesCreatedAfter:c=null,showInvisible:a=!0,listViewOptions:o,iconViewOptions:r,now:u,selectionApiRef:d,selectedPaths:m,onSelectionChange:Z,focusTargetRef:b,onMoveItems:h,onDeleteItems:p,itemContextMenu:W,commandsRef:y,className:N,style:X})=>{const g=Y.useRef(null),M=Y.useRef(null),{showContextMenu:I}=Na(),A=Y.useRef(m??[]),V=Y.useCallback(J=>{A.current=J,Z?.(J)},[Z]),z=Y.useCallback(()=>t==="list"?A.current:Array.from(M.current?.querySelectorAll(`.classicyIcon.selected[${ki}]`)??[],J=>J.getAttribute(ki)??"").filter(Boolean),[t]);Y.useImperativeHandle(y,()=>({selectedPaths:z}),[z]);const x=J=>{if(!p||J.defaultPrevented||J.key!=="Backspace"&&J.key!=="Delete"||J.altKey||J.shiftKey||J.target.closest("input, textarea, [contenteditable='true']"))return;const D=z();D.length!==0&&(J.preventDefault(),p(D))},S=J=>{if(!W||J.defaultPrevented)return;const R=J.target.closest(`[${ki}]`),D=R?.getAttribute(ki);if(!R||!D||!M.current?.contains(R))return;const L=W(D,z());!L||L.length===0||(J.preventDefault(),I(L,[J.clientX,J.clientY]))},C=ut(J=>J.System.Manager.Appearance.activeTheme.desktop.iconSize),[k,v]=Y.useState(()=>qe("--desktop-icon-size",C));return Y.useLayoutEffect(()=>{v(qe("--desktop-icon-size",C))},[C]),G.jsx("div",{ref:M,className:$("classicyFileBrowserFill",N),style:X,[Sd]:n,onKeyDown:x,onContextMenu:S,children:t==="list"?G.jsx(pY,{onMoveItems:h,fileOnClickFunc:i??kL,dirOnClickFunc:s??DL,fs:e,path:n,appId:l,iconSize:o?NL(k,o.iconSize):18,holderRef:g,hideFilesCreatedAfter:c,showInvisible:a,listViewOptions:o,now:u,selectionApiRef:d,selectedPaths:m,onSelectionChange:V,focusTargetRef:b}):G.jsx(hY,{onMoveItems:h,fileOnClickFunc:i??kL,dirOnClickFunc:s??DL,fs:e,path:n,appId:l,holderRef:g,hideFilesCreatedAfter:c,showInvisible:a,iconViewOptions:r})})},hn="Trash",WY={_trashed:void 0,_trashedFrom:void 0,_trashedName:void 0,_trashedLocation:void 0},vL=(e,t)=>t.split(e.separator).pop()??t,JL=(e,t)=>t.split(e.separator).slice(0,-1).join(e.separator),Jh=(e,t)=>t===hn||t.startsWith(`${hn}${e.separator}`),Bu=(e,t)=>t!==hn&&JL(e,t)===hn;function GY(e){return e.resolve(hn)||(e.mkDir(hn),e.setMetadata(hn,{_icon:tn("systemArt","trashEmpty")??"",_system:!0,_nameLocked:!0,_invisible:!0})),hn}function Oh(e){const t=e.resolve(hn);return t?Object.keys(t).filter(n=>!n.startsWith("_")).map(n=>`${hn}${e.separator}${n}`):[]}const _st=(e,t)=>{const n=e.resolve(hn)??{};if(!Object.hasOwn(n,t))return t;const l=t.lastIndexOf("."),[s,i]=l>0?[t.slice(0,l),t.slice(l)]:[t,""];for(let c=2;;c++){const a=`${s} ${c}${i}`;if(!Object.hasOwn(n,a))return a}};function OL(e,t,n={}){GY(e);const l={moves:[]};for(const s of t){if(Jh(e,s))continue;const i=vL(e,s),c=_st(e,i),a=n[s],o=e.move(s,hn,{name:c,metadata:{_trashed:!0,_trashedFrom:JL(e,s),...c===i?{}:{_trashedName:i},...a?{_trashedLocation:a}:{}}});o.ok?l.moves.push({from:s,to:o.path}):l.refusal||(l.refusal={reason:o.reason,name:i})}return l}function EL(e,t){const n={moves:[]};for(const l of t){if(!Bu(e,l))continue;const s=e.resolve(l);if(!s)continue;const i=s._trashedName??vL(e,l),c=s._trashedFrom;if(typeof c!="string"||!e.resolve(c)){n.refusal??={reason:"no-origin",name:i};continue}const a=e.move(l,c,{name:i,metadata:WY});a.ok?n.moves.push({from:l,to:a.path}):n.refusal||(n.refusal={reason:a.reason,name:i})}return n}function UL(e){const t=Oh(e);for(const n of t)e.rmDir(n);return t.length}const BL="Desktop Folder",Eh="classicy-desktop-item:",PL=e=>Object.keys(e.filterByType("",Gt.Drive))[0],Uh=e=>{const t=PL(e);return t?`${t}${e.separator}${BL}`:void 0},HL=e=>{const t=Uh(e);if(t)return e.resolve(t)||(e.mkDir(t),e.setMetadata(t,{_invisible:!0})),t},Bh=(e,t,n)=>{const l=e.resolve(t);if(!l)return;const s=t.split(e.separator).pop()??t,i=l._type===Gt.Directory;return{type:"ClassicyDesktopIconAdd",app:{id:`${Eh}${t}`,name:s,icon:l._icon??Ld(l._type)},kind:i?"directory":"file",filePath:t,noLaunch:!0,...n?{location:n}:{}}},$st=(e,t,n)=>{switch(e){case"exists":return`An item named \u201C${t}\u201D already exists in \u201C${n}\u201D. It was not moved.`;case"into-itself":return`\u201C${t}\u201D can\u2019t be moved into itself.`;case"locked":return`\u201C${t}\u201D can\u2019t be moved, because it or \u201C${n}\u201D is locked or used by the system software.`;default:return`\u201C${t}\u201D could not be moved.`}},KL=e=>{const n=(typeof document<"u"?document.getElementById("classicyDesktop"):null)?.getBoundingClientRect();return[Math.round(e[0]-(n?.left??0)),Math.round(e[1]-(n?.top??0))]};function yY(e,t,n,l,{desktopLocation:s,desktopStep:i=72}={}){if(n.kind==="folder"&&n.path===hn)return Ph(e,t,l);const c=n.kind==="desktop"?HL(e):n.path;if(!c)return[];const a=[];let o=null;for(const r of t){if(r===c)continue;const u=e.move(r,c,Bu(e,r)?{metadata:WY}:{});u.ok?a.push({from:r,to:u.path}):u.reason!=="same-folder"&&!o&&(o={reason:u.reason,name:r.split(e.separator).pop()??r})}if(a.length>0&&(l({type:"ClassicyAppFinderPathsMoved",moves:a}),n.kind==="desktop"&&a.forEach(({to:r},u)=>{const d=s?[s[0],s[1]+u*i]:void 0,m=Bh(e,r,d);m&&l(m)})),o){const r=n.kind==="desktop"?"the desktop":c.split(e.separator).pop()??c;l({type:"ClassicyDesktopShowErrorDialog",message:$st(o.reason,o.name,r)})}return a}const tit=(e,t)=>e==="locked"?`\u201C${t}\u201D can\u2019t be moved to the Trash, because it is locked or used by the system software.`:`\u201C${t}\u201D could not be moved to the Trash.`,eit=e=>{const t=new Set(e),n={};for(const l of ut.getState().System.Manager.Desktop.icons)l.filePath&&t.has(l.filePath)&&l.location&&(n[l.filePath]=l.location);return n};function Ph(e,t,n){const{moves:l,refusal:s}=OL(e,t,eit(t));return l.length>0&&n({type:"ClassicyAppFinderPathsMoved",moves:l}),s&&n({type:"ClassicyDesktopShowErrorDialog",message:tit(s.reason,s.name)}),l}const nit=(e,t)=>{switch(e){case"no-origin":return`\u201C${t}\u201D can\u2019t be restored, because the folder it came from no longer exists. Drag it out of the Trash instead.`;case"exists":return`\u201C${t}\u201D can\u2019t be restored, because an item with that name is already where it came from.`;default:return`\u201C${t}\u201D could not be restored.`}};function QL(e,t,n){const l=Object.fromEntries(t.map(c=>[c,e.resolve(c)?._trashedLocation])),{moves:s,refusal:i}=EL(e,t);if(s.length>0){n({type:"ClassicyAppFinderPathsMoved",moves:s});const c=Uh(e);for(const{from:a,to:o}of s){const r=l[a];if(!c||o.split(e.separator).slice(0,-1).join(e.separator)!==c)continue;const u=Bh(e,o,Array.isArray(r)?r:void 0);u&&n(u)}}return i&&n({type:"ClassicyDesktopShowErrorDialog",message:nit(i.reason,i.name)}),s}const lit=({appId:e,op:t,dir:n,idx:l,closeFolder:s,closeAllFolders:i,closeWindow:c,setFolderView:a,openFolder:o,openFile:r,getHeaderString:u,fs:d,disableBalloonHelp:m,toggleBalloonHelp:Z,aboutMenuItem:b,openPreferences:h,viewType:p,iconViewOptions:W,listViewOptions:y,now:N,onMoveItems:X,trashItems:g,restoreItems:M,itemContextMenu:I})=>{const A=Ut(),V=Y.useRef(null),z=Jh(d,t),x=Y.useRef(null),S=Y.useRef(null),C=ut(J=>!!zn(J.System.Manager.Applications.apps[e],t)?.focused),k=Y.useRef(p);Y.useEffect(()=>{if(k.current===p||(k.current=p,!C))return;const J=S.current;if(!J)return;const R=document.activeElement;R&&J.closest(".classicyWindow")?.contains(R)||J.focus({preventScroll:!0})},[p,C]);const v=Y.useMemo(()=>[{id:`${e}_${t}_file`,title:"File",menuChildren:[ts(`${e}_${t}_file_closew`,()=>c(t,{type:"ClassicyAppFinderCloseFolder",path:t})),ud(`${e}_${t}_file_closews`,i),{id:"spacer"},{id:`${e}_${t}_file_move_to_trash`,title:"Move To Trash",keyboardShortcut:"\u2303\u232B",disabled:z,onClickFunc:()=>g(V.current?.selectedPaths()??[])},...t===hn?[{id:`${e}_${t}_file_restore`,title:"Restore",onClickFunc:()=>M(V.current?.selectedPaths()??[])}]:[]]},{id:`${e}_${t}_edit`,title:"Edit",menuChildren:[{id:`${e}_${t}_edit_select_all`,title:"Select All",keyboardShortcut:"\u2318A",disabled:p!=="list",onClickFunc:()=>x.current?.selectAll()},{id:"spacer"},{id:`${e}_${t}_edit_preferences`,title:"Preferences\u2026",onClickFunc:h}]},{id:`${e}_view`,title:"View",menuChildren:[{id:`${e}_${t}_view_as_icons`,title:"View as Icons",onClickFunc:()=>a(t,"icons")},{id:`${e}_${t}_view_as_list`,title:"View as List",onClickFunc:()=>a(t,"list")}]},{id:`${e}_${t}_special`,title:"Special",menuChildren:aY(A,`${e}_${t}`)},{id:`${e}_${t}_help`,title:"Help",menuChildren:[{id:`${e}_${t}_help_balloon`,title:m?"Show Balloon Help":"Hide Balloon Help",onClickFunc:Z},b]}],[e,t,c,i,a,m,Z,b,h,p,z,g,M,A]);return G.jsx(ge,{id:t,title:n._name,icon:n._icon,appId:e,defaultWindow:!1,hidden:!1,initialSize:[425,300],initialPosition:[50+l*50,50+l*50],header:G.jsx("span",{children:u(n)}),onCloseFunc:s,appMenu:v,initialFocusRef:S,children:G.jsx(jL,{appId:e,fs:d,path:t,dirOnClickFunc:o,fileOnClickFunc:r,display:p,iconViewOptions:W,listViewOptions:y,now:N,selectionApiRef:x,focusTargetRef:S,onMoveItems:X,showInvisible:!1,onDeleteItems:z?void 0:g,itemContextMenu:I,commandsRef:V})})},sit=Y.memo(lit),iit=({path:e,fs:t,...n})=>{const l=WL(e,t),s=t.statDirShell(e);return s?G.jsx(sit,{...n,fs:t,op:e,dir:{...s,_size:l}}):null},cit=Y.memo(iit),qL=()=>{const e=jt("icons","system.macos")??"",t=jt("icons","system.mac")??"",n="Finder",l="Finder.app",s=Ut(),i=ut(R=>R.System.Manager.Applications.apps[l]),c=iY(i?.data??{})?i?.data:{},a=ut(R=>R.System.Manager.Desktop.disableBalloonHelp),o=Y.useCallback(()=>{s({type:"ClassicyDesktopSetBalloonHelp",disableBalloonHelp:!a})},[s,a]),r=ut(R=>R.System.Manager.DateAndTime),u=Y.useMemo(()=>xd(r.dateTime,parseInt(r.timeZoneOffset,10)),[r.dateTime,r.timeZoneOffset]),d=pd(),m=Al(l),{aboutMenuItem:Z,aboutWindow:b}=ul(l,n,t),h=Y.useRef(null);Y.useEffect(()=>{const R=i.data??{},D=iY(R)?R:{};if(!D.openPaths)return;const L=D.openPaths,w=h.current;w&&w.length===L.length&&w.every((j,B)=>j===L[B])||(h.current=L,s({type:"ClassicyAppFinderOpenFolders",paths:L}))},[s,i.data]);const p=Y.useCallback((R,D)=>{s({type:"ClassicyAppFinderSetFolderView",path:R,viewType:D})},[s]),W=i.windows,y=Y.useCallback(R=>{s({type:"ClassicyAppFinderOpenFolder",path:R});const D=zn({windows:W},R);D&&(s({type:"ClassicyWindowOpen",app:{id:l},window:D}),s({type:"ClassicyWindowFocus",app:{id:l},window:D}))},[s,W]),N=Y.useCallback(R=>{const D=d.resolve(R);s({type:"ClassicyAppFinderOpenFile",file:D,path:R})},[d,s]),X=Y.useCallback(R=>{s({type:"ClassicyAppFinderCloseFolder",path:R})},[s]),g=Y.useCallback(()=>{(c.openPaths??[]).forEach(D=>{m(D,{type:"ClassicyAppFinderCloseFolder",path:D})})},[m,c.openPaths]),M=Y.useCallback(()=>{s({type:"ClassicyAppFinderPreferencesOpen"})},[s]),I=JSON.stringify(Object.entries(d.filterByType("","drive")).map(([R,D])=>[R,D._icon]));Y.useEffect(()=>{const R=JSON.parse(I),D=[];return R.forEach(([L,w])=>{ut.getState().System.Manager.Desktop.icons.some(B=>B.appId===l&&B.appName===L)||D.push(L),s({type:"ClassicyDesktopIconAdd",app:{id:l,name:L,icon:w},event:"ClassicyAppFinderOpenFolder",eventData:{path:L},kind:"drive",filePath:L,contextMenu:w3(L,fu())})}),()=>{D.forEach(L=>{s({type:"ClassicyDesktopIconRemove",app:{id:l,name:L}})})}},[I,s]);const A=Y.useCallback((R,D,L)=>{yY(d,R,D,s,{desktopLocation:KL(L)})},[d,s]);Y.useEffect(()=>{GY(d)},[d]);const V=Oh(d).length>0,z=jt("systemArt","trashFull")??"",x=jt("systemArt","trashEmpty")??"";Y.useEffect(()=>{s({type:"ClassicyDesktopIconAdd",app:{id:"Trash",name:"Trash",icon:V?z:x},kind:"trash",filePath:hn,noLaunch:!0,event:"ClassicyAppFinderOpenFolder",eventData:{path:hn},contextMenu:[{id:"finder_trash_open",title:"Open",onClickFunc:()=>s({type:"ClassicyAppFinderOpenFolder",path:hn})},{id:"finder_trash_empty",title:"Empty Trash\u2026",onClickFunc:()=>s({type:"ClassicyDesktopShowSystemDialog",dialog:"emptyTrash"})}]})},[V,z,x,s]);const S=Y.useCallback(R=>{const D=R.filter(L=>d.resolve(L));D.length>0&&Ph(d,D,s)},[d,s]),C=Y.useCallback(R=>{const D=R.filter(L=>Bu(d,L));D.length>0&&QL(d,D,s)},[d,s]),k=Y.useCallback((R,D)=>{const L=D.includes(R)?D:[R];if(Bu(d,R))return[{id:"finder_item_restore",title:"Restore",onClickFunc:()=>C(L)}];if(!Jh(d,R))return[{id:"finder_item_move_to_trash",title:"Move To Trash",onClickFunc:()=>S(L)}]},[d,C,S]);Y.useEffect(()=>{const R=Uh(d),D=R?d.filterByType(R,void 0,!1):{},L=new Set(Object.keys(D).map(w=>`${R}${d.separator}${w}`));for(const w of L){const j=Bh(d,w);j&&s(j)}for(const w of ut.getState().System.Manager.Desktop.icons)w.appId.startsWith(Eh)&&!L.has(w.appId.slice(Eh.length))&&s({type:"ClassicyDesktopIconRemove",app:{id:w.appId}})},[d,s]);const v=Y.useCallback(R=>{const D=R._size===void 0?"Calculating\u2026":R._size===-1?"\u2014":d.formatSize(R._size);return R._count+" items"+(R._countHidden?` (${R._countHidden} hidden)`:"")+", "+D},[d]),J=Y.useMemo(()=>Fh(c),[c]);return G.jsxs(vn,{id:l,name:n,icon:e,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,D)=>G.jsx(cit,{path:R,appId:l,idx:D,closeFolder:X,closeAllFolders:g,closeWindow:m,setFolderView:p,openFolder:y,openFile:N,getHeaderString:v,fs:d,disableBalloonHelp:a,toggleBalloonHelp:o,aboutMenuItem:Z,openPreferences:M,viewType:c.folderViews?.[R]??"list",iconViewOptions:J.icons,listViewOptions:J.list,now:u,onMoveItems:A,trashItems:S,restoreItems:C,itemContextMenu:k},`${n}_${R}`)):null,b,i.data?.showAboutThisComputer?G.jsx(ZL,{}):null,c.showPreferences?G.jsx(pL,{}):null]})},_L="ClassicyAppHCEdit",$L=100;function hl(e,t){const n=ae.isDraft(e.draft)?ae.current(e.draft):e.draft,l=ae.produce(n,t);l!==n&&(e.undo.push(n),e.undo.length>$L&&e.undo.shift(),e.redo=[],e.draft=l,e.dirty=!0)}function Ca(e,t,n){const l=e.cards.find(i=>i.id===t);if(!l)return;if(n==="card")return l.parts??=[],l.parts;if(!l.background)return;const s=e.backgrounds?.find(i=>i.id===l.background);if(s)return s.parts??=[],s.parts}function Pu(e,t,n){const l=e.cards.find(s=>s.id===t);if(l){if(n==="card")return l.parts;if(l.background)return e.backgrounds?.find(s=>s.id===l.background)?.parts}}function NY(e,t){const n=new Set;for(const s of e.cards)for(const i of s.parts??[])n.add(i.id);for(const s of e.backgrounds??[])for(const i of s.parts??[])n.add(i.id);let l=1;for(;n.has(`${t}${l}`);)l++;return`${t}${l}`}function tS(e){const t=new Set(e.cards.map(l=>l.id));let n=1;for(;t.has(`card${n}`);)n++;return`card${n}`}const YY=[{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 eS(e){return YY.find(t=>t.type===e)}const XY="application/x-hypercard-part-type",ait=["nw","n","ne","e","se","s","sw","w"];function gY(e,t){return Pu(e.draft,e.currentCardId,e.layer)?.find(l=>l.id===t)?.rect??[0,0,120,60]}function MY(e){const[t,n,l,s]=e.startRect;if(!e.handle)return[t+e.dx,n+e.dy,l,s];let[i,c,a,o]=[t,n,l,s];return e.handle.includes("w")&&(i=t+e.dx,a=l-e.dx),e.handle.includes("e")&&(a=l+e.dx),e.handle.includes("n")&&(c=n+e.dy,o=s-e.dy),e.handle.includes("s")&&(o=s+e.dy),[i,c,a,o]}const nS=({stackId:e,edit:t,className:n,style:l})=>{const s=Ut(),[i,c]=Y.useState(),a=Pu(t.draft,t.currentCardId,t.layer)??[],o=t.selectedPartId,r=(N,X)=>s({type:"ClassicyAppHCEditSetRect",stackId:e,partId:N,rect:X}),u=(N,X,g)=>{N.stopPropagation();try{N.currentTarget.setPointerCapture?.(N.pointerId)}catch{}g||s({type:"ClassicyAppHCEditSelect",stackId:e,partId:X}),c({partId:X,handle:g,startX:N.clientX,startY:N.clientY,startRect:gY(t,X),dx:0,dy:0})},d=N=>{i&&c({...i,dx:N.clientX-i.startX,dy:N.clientY-i.startY})},m=()=>{i&&((i.dx!==0||i.dy!==0)&&r(i.partId,MY(i)),c(void 0))};Rb(i!==void 0,m);const Z=(N,X)=>{const g=X.getBoundingClientRect();return[Math.round(N.clientX-g.left),Math.round(N.clientY-g.top)]},b=N=>{if(N.target===N.currentTarget){if(t.placing){const X=Z(N,N.currentTarget);s({type:"ClassicyAppHCEditAddPart",stackId:e,partType:t.placing,at:X});return}s({type:"ClassicyAppHCEditSelect",stackId:e,partId:void 0})}},h=N=>{const X=N.dataTransfer?.getData(XY);if(!X)return;N.preventDefault();const g=Z(N,N.currentTarget);s({type:"ClassicyAppHCEditAddPart",stackId:e,partType:X,at:g})},p=N=>{const X=N.metaKey||N.ctrlKey,g=N.key.toLowerCase();if(X&&g==="z"){N.preventDefault(),s({type:N.shiftKey?"ClassicyAppHCEditRedo":"ClassicyAppHCEditUndo",stackId:e});return}if(X&&g==="v"){s({type:"ClassicyAppHCEditPastePart",stackId:e});return}if(!o)return;if(X&&g==="c"){s({type:"ClassicyAppHCEditCopyPart",stackId:e,partId:o});return}if(N.key==="Delete"||N.key==="Backspace"){N.preventDefault(),s({type:"ClassicyAppHCEditDeletePart",stackId:e,partId:o});return}if(N.key==="Escape"){s({type:"ClassicyAppHCEditSelect",stackId:e,partId:void 0});return}const M=N.shiftKey?8:1,A={ArrowLeft:[-M,0],ArrowRight:[M,0],ArrowUp:[0,-M],ArrowDown:[0,M]}[N.key];if(!A)return;N.preventDefault();const[V,z,x,S]=gY(t,o);r(o,[V+A[0],z+A[1],x,S])},W=N=>{const X=gY(t,N);return i&&i.partId===N&&(i.dx!==0||i.dy!==0)?MY(i):X},y=([N,X,g,M])=>({left:N,top:X,width:g,height:M});return G.jsxs("div",{className:$("classicyHyperCardEditorOverlay",n),style:l,tabIndex:0,onPointerDown:b,onPointerMove:d,onPointerUp:m,onKeyDown:p,onDragOver:N=>N.preventDefault(),onDrop:h,children:[a.map(N=>G.jsx("div",{className:"classicyHyperCardEditorHit","data-part-id":N.id,style:y(W(N.id)),onPointerDown:X=>u(X,N.id),onPointerMove:d,onPointerUp:m},N.id)),o&&a.some(N=>N.id===o)?G.jsx("div",{className:"classicyHyperCardEditorSelection",style:y(W(o)),children:ait.map(N=>G.jsx("div",{className:"classicyHyperCardEditorHandle","data-handle":N,onPointerDown:X=>u(X,o,N),onPointerMove:d,onPointerUp:m},N))}):null]})},oit=/^(<=|>=|<>|==|!=|≠|&&|=|<|>|&|\+|-|\*|\/|\(|\))/;function dit(e){const t=[];let n=0;for(;n<e.length;){const l=e[n];if(l===" "||l===" "||l===`
|
|
72
|
+
`))}})(A.methodName,A.pluginName),Promise.resolve(A.method({payload:z,instance:l,abort:(x=z,S=N,C=A.pluginName,function(k,v){return Bt({},x,{abort:{reason:k,plugins:v||[S],caller:d,from:C||S}})}),config:yz(A.pluginName,r,i),plugins:r})).then(function(k){var v=Zl(k)?k:{};return Promise.resolve(Bt({},z,v))})):z;var x,S,C})},Promise.resolve(n))).then(function(I){X[N]=I});X[N]=n})();return M&&M.then?M.then(g):g()})},Promise.resolve({}))).then(function(p){return Promise.resolve(t.exact.reduce(function(W,y,N){try{var X=t.exact.length===N+1,g=y.pluginName,M=i[g];return Promise.resolve(W).then(function(I){var A=p[g]?p[g]:{};if(m&&(A=I),CN(A,g))return SN({data:A,method:d,instance:l,pluginName:g,store:a}),Promise.resolve(I);if(CN(I,g))return X&&SN({data:I,method:d,instance:l,store:a}),Promise.resolve(I);if(h.hasOwnProperty(g)&&h[g]===!0)return a.dispatch({type:"queue",plugin:g,payload:A,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(I);var V=b(p[g],i[g]);return Promise.resolve(M[d]({abort:V.abort,payload:A,instance:l,config:yz(g,r,i),plugins:r})).then(function(z){var x=Zl(z)?z:{},S=Bt({},I,x),C=p[g];if(CN(C,g))SN({data:C,method:d,instance:l,pluginName:g,store:a});else{var k=d+":"+g;(k.match(/:/g)||[]).length<2&&!d.match(Wz)&&!d.match(Gz)&&l.dispatch(Bt({},m?S:A,{type:k,_:{called:k,from:"submethod"}}))}return Promise.resolve(S)})})}catch(I){return Promise.reject(I)}},Promise.resolve(n))).then(function(W){if(!(d.match(Ad)||d.match(/^registerPlugin/)||d.match(Gz)||d.match(Wz)||d.match(/^params/)||d.match(/^userIdChanged/))){if(o.plugins.includes(d),W._&&W._.originalAction===d)return W;var y=Bt({},W,{_:{originalAction:W.type,called:W.type,from:"engineEnd"}});Xz(W,t.exact.length)&&!d.match(/End$/)&&(y=Bt({},y,{type:W.type+"Aborted"})),a.dispatch(y)}return W})})}catch(p){return Promise.reject(p)}},Ad=/Start$/,Wz=/^bootstrap/,Gz=/^ready/;function SN(e){var t=e.pluginName,n=e.method+"Aborted"+(t?":"+t:"");e.store.dispatch(Bt({},e.data,{type:n,_:{called:n,from:"abort"}}))}function yz(e,t,n){var l=t[e]||n[e];return l&&l.config?l.config:{}}function Nz(e,t){return t.reduce(function(n,l){return l[e]?n.concat({methodName:e,pluginName:l.name,method:l[e]}):n},[])}function Yz(e,t){var n=e.replace(Ad,""),l=t?":"+t:"";return[""+e+l,""+n+l,n+"End"+l]}function CN(e,t){var n=e.abort;return!!n&&(n===!0||gz(n,t)||n&&gz(n.plugins,t))}function Xz(e,t){var n=e.abort;if(!n)return!1;if(n===!0||yd(n))return!0;var l=n.plugins;return vu(n)&&n.length===t||vu(l)&&l.length===t}function vu(e){return Array.isArray(e)}function gz(e,t){return!(!e||!vu(e))&&e.includes(t)}function Mz(e){var t=e.match(/(.*):(.*)/);return!!t&&{method:t[1],name:t[2]}}function jlt(e){return Object.keys(e).reduce(function(t,n){return n==="type"||(t[n]=Zl(e[n])?Object.assign({},e[n]):e[n]),t},{})}function vlt(e,t,n){var l={};return function(s){return function(i){return function(c){try{var a,o=function(X){return a?X:i(d)},r=c.type,u=c.plugins,d=c;if(c.abort)return Promise.resolve(i(c));if(r===Pt.enablePlugin&&s.dispatch({type:Pt.initializeStart,plugins:u,disabled:[],fromEnable:!0,meta:c.meta}),r===Pt.disablePlugin&&setTimeout(function(){return bz(c.meta.rid,{payload:c})},0),r===Pt.initializeEnd){var m=t(),Z=Object.keys(m),b=Z.filter(function(X){return u.includes(X)}).map(function(X){return m[X]}),h=[],p=[],W=c.disabled,y=b.map(function(X){var g=X.loaded,M=X.name,I=X.config;return hz(X,function(){return g({config:I})},1e4).then(function(A){return l[M]||(s.dispatch({type:Pt.pluginReadyType(M),name:M,events:Object.keys(X).filter(function(V){return!xN.includes(V)})}),l[M]=!0),h=h.concat(M),X}).catch(function(A){if(A instanceof Error)throw new Error(A);return p=p.concat(A.name),A})});Promise.all(y).then(function(X){var g={plugins:h,failed:p,disabled:W};setTimeout(function(){Z.length===y.length+W.length&&s.dispatch(Bt({},{type:Pt.ready},g))},0)})}var N=(function(){if(r!==Pt.bootstrap)return/^ready:([^:]*)$/.test(r)&&setTimeout(function(){return pz(s,t,e)},0),Promise.resolve((function(X,g,M,I,A){try{var V=qs(g)?g():g,z=X.type,x=z.replace(Ad,"");if(X._&&X._.called)return Promise.resolve(X);var S=M.getState(),C=(J=V,(R=S.plugins)===void 0&&(R={}),(D=X.options)===void 0&&(D={}),Object.keys(J).filter(function(L){var w=D.plugins||{};return Xlt(w[L])?w[L]:w.all!==!1&&(!R[L]||R[L].enabled!==!1)}).map(function(L){return J[L]}));z===Pt.initializeStart&&X.fromEnable&&(C=Object.keys(S.plugins).filter(function(L){var w=S.plugins[L];return X.plugins.includes(L)&&!w.initialized}).map(function(L){return V[L]}));var k=C.map(function(L){return L.name}),v=(function(L,w){var j=Yz(L).map(function(B){return Nz(B,w)});return w.reduce(function(B,f){var U=f.name,_=Yz(L,U).map(function(gt){return Nz(gt,w)}),P=_[0],q=_[1],ot=_[2];return P.length&&(B.beforeNS[U]=P),q.length&&(B.duringNS[U]=q),ot.length&&(B.afterNS[U]=ot),B},{before:j[0],beforeNS:{},during:j[1],duringNS:{},after:j[2],afterNS:{}})})(z,C);return Promise.resolve(LN({action:X,data:{exact:v.before,namespaced:v.beforeNS},state:S,allPlugins:V,allMatches:v,instance:M,store:I,EVENTS:A})).then(function(L){function w(){var f=(function(){if(z.match(Ad))return Promise.resolve(LN({action:Bt({},j,{type:x+"End"}),data:{exact:v.after,namespaced:v.afterNS},state:S,allPlugins:V,allMatches:v,instance:M,store:I,EVENTS:A})).then(function(U){U.meta&&U.meta.hasCallback&&bz(U.meta.rid,{payload:U})})})();return f&&f.then?f.then(function(){return L}):L}if(Xz(L,k.length))return L;var j,B=(function(){if(z!==x)return Promise.resolve(LN({action:Bt({},L,{type:x}),data:{exact:v.during,namespaced:v.duringNS},state:S,allPlugins:V,allMatches:v,instance:M,store:I,EVENTS:A})).then(function(f){j=f});j=L})();return B&&B.then?B.then(w):w()})}catch(L){return Promise.reject(L)}var J,R,D})(c,t,e,s,n)).then(function(X){var g=i(X);return a=1,g})})();return Promise.resolve(N&&N.then?N.then(o):o(N))}catch(X){return Promise.reject(X)}}}}}function Jlt(e){return function(t){return function(n){return function(l){var s=l.type,i=l.key,c=l.value,a=l.options;if(s===Pt.setItem||s===Pt.removeItem){if(l.abort)return n(l);s===Pt.setItem?e.setItem(i,c,a):e.removeItem(i,a)}return n(l)}}}}var Olt=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(t,n){e[n]=e[n].concat(t)},this.removeMiddleware=function(t,n){var l=e[n].findIndex(function(s){return s===t});l!==-1&&(e[n]=[].concat(e[n].slice(0,l),e[n].slice(l+1)))},this.dynamicMiddlewares=function(t){return function(n){return function(l){return function(s){var i={getState:n.getState,dispatch:function(a){return n.dispatch(a)}},c=e[t].map(function(a){return a(i)});return Td.apply(void 0,c)(l)(s)}}}}};function Elt(e){return function(t,n){t===void 0&&(t={});var l={};if(n.type==="initialize:aborted")return t;if(/^registerPlugin:([^:]*)$/.test(n.type)){var s=Tz(n.type,"registerPlugin"),i=e()[s];if(!i||!s)return t;var c=n.enabled,a=i.config;return l[s]={enabled:c,initialized:!!c&&!i.initialize,loaded:!!c&&!!i.loaded({config:a}),config:a},Bt({},t,l)}if(/^initialize:([^:]*)$/.test(n.type)){var o=Tz(n.type,Pt.initialize),r=e()[o];return r&&o?(l[o]=Bt({},t[o],{initialized:!0,loaded:!!r.loaded({config:r.config})}),Bt({},t,l)):t}if(/^ready:([^:]*)$/.test(n.type))return l[n.name]=Bt({},t[n.name],{loaded:!0}),Bt({},t,l);switch(n.type){case Pt.disablePlugin:return Bt({},t,Iz(n.plugins,!1,t));case Pt.enablePlugin:return Bt({},t,Iz(n.plugins,!0,t));default:return t}}}function Tz(e,t){return e.substring(t.length+1,e.length)}function Iz(e,t,n){return e.reduce(function(l,s){return l[s]=Bt({},n[s],{enabled:t}),l},n)}function Vz(e){try{return JSON.parse(JSON.stringify(e))}catch{}return e}var Ult={last:{},history:[]};function Blt(e,t){e===void 0&&(e=Ult);var n=t.options,l=t.meta;if(t.type===Pt.track){var s=Vz(Bt({event:t.event,properties:t.properties},Object.keys(n).length&&{options:n},{meta:l}));return Bt({},e,{last:s,history:e.history.concat(s)})}return e}var Plt={actions:[]};function Hlt(e,t){e===void 0&&(e=Plt);var n=t.payload;switch(t.type){case"queue":var l;return l=n&&n.type&&n.type===Pt.identify?[t].concat(e.actions):e.actions.concat(t),Bt({},e,{actions:l});case"dequeue":return[];default:return e}}var Az=/#.*$/;function Klt(e){var t=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return"/"+(t&&t[3]?t[3].split("?")[0].replace(Az,""):"")}var wz,xz,zz,Lz,Qlt=function(e){if(e===void 0&&(e={}),!Ms)return e;var t=document,n=t.title,l=t.referrer,s=window,i=s.location,c=s.innerWidth,a=s.innerHeight,o=i.hash,r=i.search,u=(function(m){var Z=(function(){if(Ms){for(var b,h=document.getElementsByTagName("link"),p=0;b=h[p];p++)if(b.getAttribute("rel")==="canonical")return b.getAttribute("href")}})();return Z?Z.match(/\?/)?Z:Z+m:window.location.href.replace(Az,"")})(r),d={title:n,url:u,path:Klt(u),hash:o,search:r,width:c,height:a};return l&&l!==""&&(d.referrer=l),Bt({},d,e)},qlt={last:{},history:[]};function _lt(e,t){e===void 0&&(e=qlt);var n=t.options;if(t.type===Pt.page){var l=Vz(Bt({properties:t.properties,meta:t.meta},Object.keys(n).length&&{options:n}));return Bt({},e,{last:l,history:e.history.concat(l)})}return e}wz=(function(){if(!Ms)return!1;var e=navigator.appVersion;return~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"})(),xz=Ms?document.referrer:null,zz=wlt(),Lz=xlt();var Sz={initialized:!1,sessionId:Th(),app:null,version:null,debug:!1,offline:!!Ms&&!navigator.onLine,os:{name:wz},userAgent:Ms?navigator.userAgent:"node",library:{name:wN,version:"0.13.1"},timezone:Lz,locale:zz,campaign:{},referrer:xz};function $lt(e,t){e===void 0&&(e=Sz);var n=e.initialized,l=t.campaign;switch(t.type){case Pt.campaign:return Bt({},e,{campaign:l});case Pt.offline:return Bt({},e,{offline:!0});case Pt.online:return Bt({},e,{offline:!1});default:return n?e:Bt({},Sz,e,{initialized:!0})}}var tst=["plugins","reducers","storage"];function est(e,t,n){if(Ms){var l=window[(n?"add":"remove")+"EventListener"];e.split(" ").forEach(function(s){l(s,t)})}}function nst(e){var t=est.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(e)});return t(!0),function(n){return t(!1)}}function Cz(){return xa(wN,[]),function(e){return function(t,n,l){var s=e(t,n,l),i=s.dispatch;return Object.assign(s,{dispatch:function(c){return Xd[Yd][wN].push(c.action||c),i(c)}})}}}function fz(e){return function(){return Td(Td.apply(null,arguments),Cz())}}function fN(e){return e?Mlt(e)?e:[e]:[]}function Rz(e,t,n){e===void 0&&(e={});var l,s,i=Th();return t&&(ju[i]=(l=t,s=(function(c){for(var a,o=c||Array.prototype.slice.call(arguments),r=0;r<o.length;r++)if(qs(o[r])){a=o[r];break}return a})(n),function(c){s&&s(c),l(c)})),Bt({},e,{rid:i,ts:new Date().getTime()},t?{hasCallback:!0}:{})}function lst(e){e===void 0&&(e={});var t=e.reducers||{},n=e.initialUser||{},l=(e.plugins||[]).reduce(function(L,w){if(qs(w))return L.middlewares=L.middlewares.concat(w),L;if(w.NAMESPACE&&(w.name=w.NAMESPACE),!w.name)throw new Error("https://lytics.dev/errors/1");w.config||(w.config={});var j=w.EVENTS?Object.keys(w.EVENTS).map(function(U){return w.EVENTS[U]}):[];L.pluginEnabled[w.name]=!(w.enabled===!1||w.config.enabled===!1),delete w.enabled,w.methods&&(L.methods[w.name]=Object.keys(w.methods).reduce(function(U,_){var P;return U[_]=(P=w.methods[_],function(){for(var q=Array.prototype.slice.call(arguments),ot=new Array(P.length),gt=0;gt<q.length;gt++)ot[gt]=q[gt];return ot[ot.length]=g,P.apply({instance:g},ot)}),U},{}),delete w.methods);var B=Object.keys(w).concat(j),f=new Set(L.events.concat(B));if(L.events=Array.from(f),L.pluginsArray=L.pluginsArray.concat(w),L.plugins[w.name])throw new Error(w.name+"AlreadyLoaded");return L.plugins[w.name]=w,L.plugins[w.name].loaded||(L.plugins[w.name].loaded=function(){return!0}),L},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),s=e.storage?e.storage:{getItem:wa,setItem:xa,removeItem:gd},i=(function(L){return function(w,j,B){return j.getState("user")[w]||(B&&Zl(B)&&B[w]?B[w]:Zz(L)[w]||wa(zN(w))||null)}})(s),c=l.plugins,a=l.events.filter(function(L){return!xN.includes(L)}).sort(),o=new Set(a.concat(Ah).filter(function(L){return!xN.includes(L)})),r=Array.from(o).sort(),u=function(){return c},d=new Olt,m=d.addMiddleware,Z=d.removeMiddleware,b=d.dynamicMiddlewares,h=function(){throw new Error("Abort disabled inListener")},p=zlt(),W=Zz(s),y=Bt({},W,n,p.an_uid?{userId:p.an_uid}:{},p.an_aid?{anonymousId:p.an_aid}:{});y.anonymousId||(y.anonymousId=Th());var N=Bt({enable:function(L,w){return new Promise(function(j){v.dispatch({type:Pt.enablePlugin,plugins:fN(L),_:{originalAction:Pt.enablePlugin}},j,[w])})},disable:function(L,w){return new Promise(function(j){v.dispatch({type:Pt.disablePlugin,plugins:fN(L),_:{originalAction:Pt.disablePlugin}},j,[w])})}},l.methods),X=!1,g={identify:function(L,w,j,B){try{var f=yd(L)?L:null,U=Zl(L)?L:w,_=j||{},P=g.user();xa(zN(jc),f);var q=f||U.userId||i(jc,g,U);return Promise.resolve(new Promise(function(ot){v.dispatch(Bt({type:Pt.identifyStart,userId:q,traits:U||{},options:_,anonymousId:P.anonymousId},P.id&&P.id!==f&&{previousId:P.id}),ot,[w,j,B])}))}catch(ot){return Promise.reject(ot)}},track:function(L,w,j,B){try{var f=Zl(L)?L.event:L;if(!f||!yd(f))throw new Error("EventMissing");var U=Zl(L)?L:w||{},_=Zl(j)?j:{};return Promise.resolve(new Promise(function(P){v.dispatch({type:Pt.trackStart,event:f,properties:U,options:_,userId:i(jc,g,w),anonymousId:i(Vd,g,w)},P,[w,j,B])}))}catch(P){return Promise.reject(P)}},page:function(L,w,j){try{var B=Zl(L)?L:{},f=Zl(w)?w:{};return Promise.resolve(new Promise(function(U){v.dispatch({type:Pt.pageStart,properties:Qlt(B),options:f,userId:i(jc,g,B),anonymousId:i(Vd,g,B)},U,[L,w,j])}))}catch(U){return Promise.reject(U)}},user:function(L){if(L===jc||L==="id")return i(jc,g);if(L===Vd||L==="anonId")return i(Vd,g);var w=g.getState("user");return L?tz(w,L):w},reset:function(L){return new Promise(function(w){v.dispatch({type:Pt.resetStart},w,L)})},ready:function(L){return X&&L({plugins:N,instance:g}),g.on(Pt.ready,function(w){L&&L(w),X=!0})},on:function(L,w){if(!L||!qs(w))return!1;if(L===Pt.bootstrap)throw new Error(".on disabled for "+L);var j=/Start$|Start:/;if(L==="*"){var B=function(P){return function(q){return function(ot){return ot.type.match(j)&&w({payload:ot,instance:g,plugins:c}),q(ot)}}},f=function(P){return function(q){return function(ot){return ot.type.match(j)||w({payload:ot,instance:g,plugins:c}),q(ot)}}};return m(B,wh),m(f,xh),function(){Z(B,wh),Z(f,xh)}}var U=L.match(j)?wh:xh,_=function(P){return function(q){return function(ot){return ot.type===L&&w({payload:ot,instance:g,plugins:c,abort:h}),q(ot)}}};return m(_,U),function(){return Z(_,U)}},once:function(L,w){if(!L||!qs(w))return!1;if(L===Pt.bootstrap)throw new Error(".once disabled for "+L);var j=g.on(L,function(B){w({payload:B.payload,instance:g,plugins:c,abort:h}),j()});return j},getState:function(L){var w=v.getState();return L?tz(w,L):Object.assign({},w)},dispatch:function(L){var w=yd(L)?{type:L}:L;if(Ah.includes(w.type))throw new Error("reserved action "+w.type);var j=Bt({},w,{_:Bt({originalAction:w.type},L._||{})});v.dispatch(j)},enablePlugin:N.enable,disablePlugin:N.disable,plugins:N,storage:{getItem:s.getItem,setItem:function(L,w,j){v.dispatch({type:Pt.setItemStart,key:L,value:w,options:j})},removeItem:function(L,w){v.dispatch({type:Pt.removeItemStart,key:L,options:w})}},setAnonymousId:function(L,w){g.storage.setItem(kc,L,w)},events:{core:Ah,plugins:a}},M=l.middlewares.concat([function(L){return function(w){return function(j){return j.meta||(j.meta=Rz()),w(j)}}},b(wh),vlt(g,u,{all:r,plugins:a}),Jlt(s),Rlt(g),Dlt(g),b(xh)]),I={context:$lt,user:Flt(s),page:_lt,track:Blt,plugins:Elt(u),queue:Hlt},A=Td,V=Td;if(Ms&&e.debug){var z=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;z&&(A=z({trace:!0,traceLimit:25})),V=function(){return arguments.length===0?Cz():Zl(typeof arguments[0])?fz():fz().apply(null,arguments)}}var x,S=(function(L){return Object.keys(L).reduce(function(w,j){return tst.includes(j)||(w[j]=L[j]),w},{})})(e),C=l.pluginsArray.reduce(function(L,w){var j=w.name,B=w.config,f=w.loaded,U=l.pluginEnabled[j];return L[j]={enabled:U,initialized:!!U&&!w.initialize,loaded:!!f({config:B}),config:B},L},{}),k={context:S,user:y,plugins:C},v=dz((function(L){for(var w=Object.keys(L),j={},B=0;B<w.length;B++){var f=w[B];typeof L[f]===Dc&&(j[f]=L[f])}var U,_=Object.keys(j);try{(function(P){Object.keys(P).forEach(function(q){var ot=P[q];if(typeof ot(void 0,{type:AN})===fi||typeof ot(void 0,{type:Slt})===fi)throw new Error(ku+" "+q+" "+fi)})})(j)}catch(P){U=P}return function(P,q){if(P===void 0&&(P={}),U)throw U;for(var ot=!1,gt={},Zt=0;Zt<_.length;Zt++){var K=_[Zt],O=P[K],H=(0,j[K])(O,q);if(typeof H===fi){var et=Clt(K,q);throw new Error(et)}gt[K]=H,ot=ot||H!==O}return ot?gt:P}})(Bt({},I,t)),k,V(A(flt.apply(void 0,M))));v.dispatch=(x=v.dispatch,function(L,w,j){var B=Bt({},L,{meta:Rz(L.meta,w,fN(j))});return x.apply(null,[B])});var J=Object.keys(c);v.dispatch({type:Pt.bootstrap,plugins:J,config:S,params:p,user:y,initialUser:n,persistedUser:W});var R=J.filter(function(L){return l.pluginEnabled[L]}),D=J.filter(function(L){return!l.pluginEnabled[L]});return v.dispatch({type:Pt.registerPlugins,plugins:J,enabled:l.pluginEnabled}),l.pluginsArray.map(function(L,w){var j=L.bootstrap,B=L.config,f=L.name;j&&qs(j)&&j({instance:g,config:B,payload:L}),v.dispatch({type:Pt.registerPluginType(f),name:f,enabled:l.pluginEnabled[f],plugin:L}),l.pluginsArray.length===w+1&&v.dispatch({type:Pt.initializeStart,plugins:R,disabled:D})}),nst(function(L){v.dispatch({type:L?Pt.offline:Pt.online})}),(function(L,w,j){setInterval(function(){return pz(L,w,j)},3e3)})(v,u,g),g}var wh="before",xh="after",La="cookie",Sa=kz(),Fz=zh,sst=zh;function Dz(e){return Sa?zh(e,"",-1):gd(e)}function kz(){if(Sa!==void 0)return Sa;var e=La+La;try{zh(e,e),Sa=document.cookie.indexOf(e)!==-1,Dz(e)}catch{Sa=!1}return Sa}function zh(e,t,n,l,s,i){if(typeof window<"u"){var c=arguments.length>1;return Sa===!1&&(c?xa(e,t):wa(e)),c?document.cookie=e+"="+encodeURIComponent(t)+(n?"; expires="+new Date(+new Date+1e3*n).toUTCString()+(l?"; path="+l:"")+(s?"; domain="+s:"")+(i?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+e+"=")[1]||"").split(";")[0])}}var Ri="localStorage",ist=VN.bind(null,Ri);Md(Ri,"getItem",wa),Md(Ri,"setItem",xa),Md(Ri,"removeItem",gd);var Fi="sessionStorage",cst=VN.bind(null,Fi);Md(Fi,"getItem",wa),Md(Fi,"setItem",xa),Md(Fi,"removeItem",gd);function wd(e){var t=e;try{if((t=JSON.parse(e))==="true")return!0;if(t==="false")return!1;if(Zl(t))return t;parseFloat(t)===t&&(t=parseFloat(t))}catch{}if(t!==null&&t!=="")return t}var ast=ist(),ost=cst(),dst=kz();function jz(e,t){if(e){var n=RN(t),l=!jN(n),s=FN(n)?wd(localStorage.getItem(e)):void 0;if(l&&!Nd(s))return s;var i=DN(n)?wd(Fz(e)):void 0;if(l&&i)return i;var c=kN(n)?wd(sessionStorage.getItem(e)):void 0;if(l&&c)return c;var a=wa(e);return l?a:{localStorage:s,sessionStorage:c,cookie:i,global:a}}}function rst(e,t,n){if(e&&!Nd(t)){var l={},s=RN(n),i=JSON.stringify(t),c=!jN(s);return FN(s)&&(l[Ri]=Sh(Ri,t,wd(localStorage.getItem(e))),localStorage.setItem(e,i),c)?l[Ri]:DN(s)&&(l[La]=Sh(La,t,wd(Fz(e))),sst(e,i),c)?l[La]:kN(s)&&(l[Fi]=Sh(Fi,t,wd(sessionStorage.getItem(e))),sessionStorage.setItem(e,i),c)?l[Fi]:(l[Aa]=Sh(Aa,t,wa(e)),xa(e,t),c?l[Aa]:l)}}function ust(e,t){if(e){var n=RN(t),l=jz(e,nz),s={};return!Nd(l.localStorage)&&FN(n)&&(localStorage.removeItem(e),s[Ri]=l.localStorage),!Nd(l.cookie)&&DN(n)&&(Dz(e),s[La]=l.cookie),!Nd(l.sessionStorage)&&kN(n)&&(sessionStorage.removeItem(e),s[Fi]=l.sessionStorage),!Nd(l.global)&&Lh(n,Aa)&&(gd(e),s[Aa]=l.global),s}}function RN(e){return e?yd(e)?e:e.storage:ez}function FN(e){return ast&&Lh(e,Ri)}function DN(e){return dst&&Lh(e,La)}function kN(e){return ost&&Lh(e,Fi)}function jN(e){return e===nz||e==="all"}function Lh(e,t){return e===ez||e===t||jN(e)}function Sh(e,t,n){return{location:e,current:t,previous:n}}var mst={setItem:rst,getItem:jz,removeItem:ust};function Zst(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t&&(l=l.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,l)}return n}function Jz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?vz(Object(n),!0).forEach(function(l){Zst(e,l,n[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vz(Object(n)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(n,l))})}return e}function bst(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t={storage:mst};return lst(Jz(Jz({},t),e))}const Oz=e=>{const t=jt("systemArt",e);return Y.useMemo(()=>t9(t),[t])},vc=({rows:e,art:t,className:n,style:l})=>{const s=Oz(t??"controlStripTab"),i=e??(t?s:[]),c=i[0]?.length??0,a=[];for(let o=0;o<i.length;o++){const r=i[o];let u=0;for(;u<r.length;){const d=r[u];let m=u+1;for(;m<r.length&&r[m]===d;)m++;d!=="."&&a.push(G.jsx("rect",{x:u,y:o,width:m-u,height:1,className:`classicyPixel${d}`},`${u}-${o}`)),u=m}}return G.jsx("svg",{className:n,style:l,width:c,height:i.length,viewBox:`0 0 ${c} ${i.length}`,shapeRendering:"crispEdges","aria-hidden":!0,focusable:!1,children:a})},hst=10,Ju=57,vN=(e,t,n)=>Math.min(n,Math.max(t,e)),Ez=({value:e,onChange:t,ariaLabel:n,min:l=0,max:s=100,step:i=1,disabled:c=!1,id:a,className:o,style:r})=>{const u=Y.useRef(null),d=Y.useRef(null),m=Y.useRef(0),Z=s-l||1,b=vN(e,l,s),h=Ju-Math.round((b-l)/Z*Ju),p=X=>vN(l+Math.round((X-l)/i)*i,l,s),W=(X,g)=>{const M=u.current;if(!M)return;const I=X-M.getBoundingClientRect().top-hst/2-g,A=Ju-vN(I,0,Ju),V=p(l+A/Ju*Z);V!==m.current&&(m.current=V,t(V))};Y.useEffect(()=>()=>d.current?.(),[]);const y=X=>{if(c||X.button!==0)return;X.preventDefault(),u.current?.focus();const g=qe("--pop-up-slider-track-top",void 0,u.current);m.current=b,W(X.clientY,g);const M=V=>W(V.clientY,g),I=()=>d.current?.();document.addEventListener("mousemove",M),document.addEventListener("mouseup",I);const A=Vl(I);d.current=()=>{A(),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",I),d.current=null}},N=X=>{if(c)return;const g={ArrowUp:i,ArrowRight:i,ArrowDown:-i,ArrowLeft:-i,PageUp:i*10,PageDown:-i*10};let M;X.key in g?M=p(b+g[X.key]):X.key==="Home"?M=l:X.key==="End"&&(M=s),M!==void 0&&(X.preventDefault(),M!==b&&t(M))};return G.jsxs("div",{ref:u,id:a,role:"slider",tabIndex:c?-1:0,"aria-label":n,"aria-valuemin":l,"aria-valuemax":s,"aria-valuenow":b,"aria-orientation":"vertical","aria-disabled":c||void 0,className:$("classicyPopUpSlider",Xe({disabled:c}),o),style:r,onMouseDown:y,onKeyDown:N,children:[G.jsx(vc,{art:"popUpSliderTrack",className:"classicyPopUpSliderTrack"}),G.jsx("span",{className:"classicyPopUpSliderThumb",style:{marginTop:h},children:G.jsx(vc,{art:"popUpSliderThumb"})})]})},Uz=()=>ya().disabled.includes("*"),pst=()=>{const{volume:e=100}=ya();return Uz()||e===0?Kl.system.controlStrip.soundOff:Kl.system.controlStrip.sound},Wst=()=>{const{volume:e=100}=ya(),t=ql(),n=Uz(),l=s=>{t({type:"ClassicyVolumeSet",volume:s}),n&&s>0&&t({type:"ClassicySoundEnableOne",enabled:"*"})};return G.jsx(Ez,{ariaLabel:"Volume",value:n?0:e,onChange:l})},Gst=eN({id:_y.sound,label:"Sound",order:10,icon:pst,fileIcon:Kl.controlPanels.soundManager.app,content:Wst}),Bz=({children:e,defaultMuted:t})=>{const n=ut(d=>d.System.Manager.Appearance?.activeTheme?.sound?.pack)??Gs,l=_W(),[s,i]=Y.useReducer(oy,sy,d=>i9(d,n,t));Y.useEffect(()=>{const d=mu(n)??mu(Gs);if(d){if(d.id===s.packId){!s.fallbackPlayer&&d.id!==Gs&&mu(Gs)&&i({type:"ClassicySoundLoadFallback"});return}i({type:"ClassicySoundLoad",pack:d,disabled:ut.getState().System.Manager.Appearance?.activeTheme?.sound?.disabled})}},[n,l,s.packId,s.fallbackPlayer]);const c=ut(d=>d.System.Manager.Appearance?.alertSound);Y.useEffect(()=>{c&&i({type:"ClassicySoundSetAlertSound",sound:c})},[c]);const a=ut(d=>d.System.Manager.Appearance?.alertVolume);Y.useEffect(()=>{typeof a=="number"&&i({type:"ClassicySoundSetAlertVolume",alertVolume:a})},[a]);const{soundPlayer:o,fallbackPlayer:r,volume:u}=s;return Y.useEffect(()=>{o?.volume(Zu(u)),r?.volume(Zu(u))},[o,r,u]),G.jsx(cy.Provider,{value:s,children:G.jsx(ay.Provider,{value:i,children:e})})},JN=Y.createContext({disableSimpleText:!1,disablePDFViewer:!1,disableMoviePlayer:!1,disablePictureViewer:!1,disableHyperCard:!1,disableWebViewer:!1}),yst=e=>{const t=localStorage.getItem(e);if(t)return t;const n=()=>{const s=new Uint8Array(16);return crypto.getRandomValues(s),Array.from(s,i=>i.toString(16).padStart(2,"0")).join("")},l=crypto?.randomUUID?.()??n();return localStorage.setItem(e,l),l},Nst=({children:e,gtmContainerId:t,gaMeasurementIds:n,appName:l="classicy",eventPrefix:s="classicy_",defaultState:i,defaultFileSystem:c,defaultFileSystemMode:a,defaultFileSystemSeedMigrations:o,disableSimpleText:r,disablePDFViewer:u,disableMoviePlayer:d,disablePictureViewer:m,disableHyperCard:Z,disableWebViewer:b,defaultMuted:h})=>{const p=Y.useRef(!1);Y.useEffect(()=>{p.current||!i||Jw()||Ow()||(p.current=!0,ut.setState(X=>jw(X,i)))},[i]);const W=Y.useMemo(()=>({defaultFileSystem:c,mode:a??"merge",seedMigrations:o}),[c,a,o]),y=Y.useMemo(()=>({disableSimpleText:r??!1,disablePDFViewer:u??!1,disableMoviePlayer:d??!1,disablePictureViewer:m??!1,disableHyperCard:Z??!1,disableWebViewer:b??!1}),[r,u,d,m,Z,b]),N=Y.useMemo(()=>{const X=[];return n&&n.length>0&&X.push(llt({measurementIds:n})),t&&X.push(alt({containerId:t})),bst({app:l,plugins:X})},[l,n,t]);return Y.useEffect(()=>{const X=yst(`${l}_user_id`);N.identify(X)},[N,l]),G.jsx(hy.Provider,{value:s,children:G.jsx(Cu.Provider,{value:W,children:G.jsx(JN.Provider,{value:y,children:G.jsx(Htt,{instance:N,children:G.jsx(Bz,{defaultMuted:h,children:e})})})})})};function ON(e){return`ClassicyApp${e}OpenFile`}function Pz(e){const t=QG(e);if(t)return t.prefixes.map(n=>`${n}OpenFile`).find(n=>{if(!Object.hasOwn(t.actions,n))return!1;const l=Tw(n);return l!==void 0&&t.prefixes.includes(l)})}function Hz(e,t,n,l){const s=MG(l),i=Pz(t.id);if(i)return HG(e,{type:i,app:{id:t.id},path:n},s);const c=ON(t.name);return qo(s,c)?du(e,{type:c,app:{id:t.id},path:n}):e}function xd(e,t){return new Date(new Date(e).getTime()+t*60*60*1e3)}function Kz(e,t){const n=xd(e,t),l=String(n.getUTCHours()).padStart(2,"0"),s=String(n.getUTCMinutes()).padStart(2,"0"),i=String(n.getUTCSeconds()).padStart(2,"0");return`${l}:${s}:${i}`}function EN(e,t){return new Date(e+(Date.now()-t))}function Yst(e){const t=e?.tick??!1,n=ut(I=>I.System.Manager.DateAndTime),l=Ut(),s=parseInt(n.timeZoneOffset,10),i=n.paused,[c,a]=Y.useState(()=>xd(n.dateTime,s)),o=Y.useRef(xd(n.dateTime,s).getTime()),r=Y.useRef(Date.now()),u=Y.useRef(s);u.current=s;const d=Y.useRef(i);d.current=i;const m=n.boundaryLocked,Z=n.minDateTime??null,b=n.maxDateTime??null,h=Y.useRef(m);h.current=m;const p=Y.useRef(Z);p.current=Z;const W=Y.useRef(b);W.current=b,Y.useEffect(()=>{const I=xd(n.dateTime,s).getTime();o.current=I,r.current=Date.now(),a(new Date(I))},[n.dateTime,s]),Y.useEffect(()=>{if(i){const I=o.current+(Date.now()-r.current);o.current=I,r.current=Date.now()}else r.current=Date.now()},[i]),Y.useEffect(()=>{if(!t)return;const I=setInterval(()=>{if(d.current||h.current)return;const A=EN(o.current,r.current),V=A.getTime(),z=V-u.current*36e5,x=p.current!==null?new Date(p.current).getTime():null,S=W.current!==null?new Date(W.current).getTime():null;if(x!==null&&z<x){l({type:"ClassicyManagerDateTimeSet",dateTime:new Date(x)});return}if(S!==null&&z>=S){l({type:"ClassicyManagerDateTimeSet",dateTime:new Date(S)});return}a(C=>Math.floor(C.getTime()/1e3)===Math.floor(V/1e3)?C:A)},250);return()=>clearInterval(I)},[t,l]);const y=Y.useCallback(I=>{l({type:"ClassicyManagerDateTimeSet",dateTime:I})},[l]),N=Y.useCallback(I=>{l({type:"ClassicyManagerDateTimeTZSet",tzOffset:I})},[l]),X=Y.useCallback(()=>l({type:"ClassicyManagerDateTimePause"}),[l]),g=Y.useCallback(()=>l({type:"ClassicyManagerDateTimeResume"}),[l]),M=Kz(c.toISOString(),0);return{dateTime:n.dateTime,tzOffset:s,localDate:c,localHMS:M,paused:i,boundaryLocked:m,setDateTime:y,setTzOffset:N,pause:X,resume:g}}const UN="about-balloon-help",BN=e=>`apple_guide_${e}`,PN=new Map;function Qz(e){PN.has(e.id)&&Wt("warn","AppleGuide","Replacing already-registered topic",e.id),PN.set(e.id,e)}function zd(e){return PN.get(e)}Qz({id:UN,title:"About Help",pages:[G.jsxs(G.Fragment,{children:[G.jsx("p",{children:"The Help menu includes:"}),G.jsxs("ul",{children:[G.jsx("li",{children:"Balloons\u2014to help you identify items on the screen."}),G.jsx("li",{children:"Help\u2014to guide you step-by-step through tasks."})]})]})]});const _s="AppleGuide.app",qz="Apple Guide",Ch="ClassicyAppAppleGuideShowTopic",_z=jn({openTopics:xn(Xt()).optional().describe("Topic ids with an open window, in the order they were opened."),pages:Tl(Xt(),Zn()).optional().describe("Current zero-based page index per topic id.")});function fh(e){return!(e===null||typeof e!="object"||"openTopics"in e&&(!Array.isArray(e.openTopics)||!e.openTopics.every(t=>typeof t=="string"))||"pages"in e&&(typeof e.pages!="object"||e.pages===null||Array.isArray(e.pages)||!Object.values(e.pages).every(t=>typeof t=="number"&&Number.isFinite(t))))}function Xst(e){const t=e.openTopics;if(!t||t.every(s=>zd(s)!==void 0))return e;const n=t.filter(s=>zd(s)!==void 0),l=e.pages?Object.fromEntries(Object.entries(e.pages).filter(([s])=>n.includes(s))):e.pages;return{...e,openTopics:n,pages:l}}const gst=e=>"topicId"in e&&typeof e.topicId=="string"?e.topicId:void 0,$z=(e,t)=>{const n=e.System.Manager.Applications.apps[_s];if(!n)return e;const l=n.data??{};let s=Xst(fh(l)?l:{});const i=gst(t);switch(t.type){case Ch:{if(!i)break;if(!zd(i)){Wt("warn","AppleGuide","Unknown topic id",i);break}const c=s.openTopics??[];return s={...s,openTopics:c.includes(i)?c:[...c,i],pages:{...s.pages??{},[i]:0}},n.data=s,xi(e,_s,BN(i))}case"ClassicyAppAppleGuideCloseTopic":{if(!i)break;s={...s,openTopics:(s.openTopics??[]).filter(c=>c!==i)};break}case"ClassicyAppAppleGuideSetPage":{if(!i)break;const c=zd(i);if(!c)break;const a="page"in t&&typeof t.page=="number"?t.page:0,o=Math.min(Math.max(a,0),Math.max(c.pages.length-1,0));s={...s,pages:{...s.pages??{},[i]:o}};break}}return n.data=s,e};Ln({id:_s,description:"Step-by-step system help topics (Apple Guide).",prefix:"ClassicyAppAppleGuide",handler:$z,actions:{[Ch]:{description:"Open (or re-focus) the window for a guide topic.",params:ft({topicId:Xt().describe("Id of the registered topic to show.")})},ClassicyAppAppleGuideCloseTopic:{description:"Close the window for an open guide topic.",params:ft({topicId:Xt().describe("Id of the topic to close.")})},ClassicyAppAppleGuideSetPage:{description:"Jump an open guide topic to a page (clamped to range).",params:ft({topicId:Xt().describe("Id of the topic to page."),page:Zn().describe("Zero-based page index to show.")})}},state:_z});const tL=({page:e,pageCount:t,onPageChange:n,pageClassName:l,className:s,style:i})=>{const c=e>0,a=e<t-1;return G.jsxs("div",{className:$("classicyPager",s),style:i,children:[G.jsx("button",{type:"button",className:"classicyPagerArrow classicyPagerArrowPrev","aria-label":"Previous page",disabled:!c,onClick:()=>n(e-1)}),G.jsx("span",{className:$("classicyPagerPage",l),children:e+1}),G.jsx("button",{type:"button",className:"classicyPagerArrow classicyPagerArrowNext","aria-label":"Next page",disabled:!a,onClick:()=>n(e+1)})]})},HN=3,Mst=(e,t)=>`${e.title}-${t}`,Tst={sm:"classicyAssistantAccessoryIconSm",md:"classicyAssistantAccessoryIconMd",lg:"classicyAssistantAccessoryIconLg"},KN=(e,t,n)=>Math.min(Math.max(e,t),n),eL=({pages:e,buttons:t,initialPage:n=0,page:l,onPageChange:s,className:i,style:c})=>{const a=Math.max(0,e.length-1),[o,r]=Y.useState(()=>KN(n,0,a)),u=ql(),d=Y.useRef(null),m=Re("Assistant",{},d),Z=l!==void 0,b=KN(Z?l:o,0,a),h=e[b];if(!h)return null;const p=(h.buttons??t??[]).slice();p.length>HN&&(Wt("warn","ClassicyAssistant",`page "${h.title}" has ${p.length} footer buttons; only the first ${HN} are shown.`),p.length=HN);const W=g=>{const M=KN(g,0,a);M!==b&&(m.emit("change",kt({page:M})),Z||r(M),s?.(M))},y=()=>{if(h.canAdvance&&h.canAdvance()===!1){u({type:"ClassicySoundPlayError"});return}W(b+1)},N=()=>W(b-1),X=g=>{g.key==="ArrowRight"?(g.preventDefault(),y()):g.key==="ArrowLeft"&&(g.preventDefault(),N())};return G.jsxs("div",{...m.attrs,ref:d,className:$("classicyAssistant",m.className,i),style:m.style?{...m.style,...c}:c,tabIndex:0,onKeyDown:X,children:[G.jsxs("section",{className:"classicyAssistantHeader","aria-live":"polite","aria-label":h.title,children:[h.labelIcon&&G.jsx("img",{className:"classicyAssistantHeaderLabelIcon",src:h.labelIcon,alt:"","aria-hidden":!0}),G.jsx("span",{className:"classicyAssistantHeaderTitle",children:h.title}),h.accessoryIcon&&G.jsx("img",{className:`classicyAssistantAccessoryIcon ${Tst[h.accessoryIconSize??"sm"]}`,src:h.accessoryIcon,alt:"","aria-hidden":!0})]}),G.jsx("div",{className:"classicyAssistantBody",role:"group","aria-label":h.title,children:h.content}),G.jsxs("div",{className:"classicyAssistantFooter",children:[G.jsx("div",{className:"classicyAssistantFooterButtons",children:p.map((g,M)=>G.jsx(Ft,{buttonSize:"small",disabled:g.disabled,onClickFunc:g.onClick,children:g.title},Mst(g,M)))}),G.jsx("div",{className:"classicyAssistantNav",children:G.jsx(tL,{page:b,pageCount:e.length,onPageChange:g=>g>b?y():N(),pageClassName:"classicyAssistantPageIndicator"})})]})]})},nL=({topicId:e,className:t,style:n})=>{const l=Ut(),s=ut(d=>d.System.Manager.Applications.apps[_s]?.data),i=zd(e),c=s??{},o=(fh(c)?c:{}).pages?.[e]??0;if(!i)return null;const r=i.pages.length-1,u=i.pages.map((d,m)=>({title:i.title,content:G.jsxs(G.Fragment,{children:[d,m===r&&G.jsx("p",{className:"appleGuideEnd",children:"- End -"})]})}));return G.jsx(ge,{id:BN(e),appId:_s,className:t,style:n,hideIcon:!0,closable:!0,zoomable:!0,collapsable:!0,resizable:!1,scrollable:!1,initialSize:[700,322],initialPosition:["center","center"],onCloseFunc:()=>l({type:"ClassicyAppAppleGuideCloseTopic",app:{id:_s},topicId:e}),children:G.jsx("div",{className:"appleGuideWindow",children:G.jsx(eL,{pages:u,page:o,onPageChange:d=>l({type:"ClassicyAppAppleGuideSetPage",app:{id:_s},topicId:e,page:d})})})})},lL=()=>{const e=jt("icons","system.extensions.appleGuide")??"",n=ut(i=>i.System.Manager.Applications.apps[_s]?.data)??{},s=(fh(n)?n:{}).openTopics??[];return G.jsx(vn,{id:_s,name:qz,icon:e,extension:!0,children:s.map(i=>G.jsx(nL,{topicId:i},i))})},sL={id:"spacer"},Ist=()=>{const e=Ut(),t=ut(a=>a.System.Manager.Applications.apps[Fc]?.data),n=t?.enabled??!0,l=Ga().id;LZ();const s=NN(l).length>0,i=t?.timeoutMinutes??YN,c=Il(Ru,{name:"Screen Saver",icon:Kl.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"},sL,{id:"screen-saver-sleep-now",title:"Sleep Now",disabled:!n||!s,onClickFunc:()=>e({type:Wd})},{id:"screen-saver-enabled",title:"Screen Saver On",checked:n,onClickFunc:()=>e({type:"ClassicyAppScreenSaverSetEnabled",enabled:!n})},sL,$x(e,c.name,{id:Ru,name:"Screen Saver",icon:Kl.system.extensions.screensaver})]},Vst=eN({id:_y.screenSaver,appId:Fc,label:"Screen Saver",order:20,icon:Kl.system.controlStrip.screenSaver,fileIcon:Kl.system.extensions.screensaver,menuItems:Ist}),Ast=(e,t)=>{const n=Ut(),l=Fu(e),s=XN(e)*6e4,i=e.active===!0,c=Y.useRef(Date.now()),a=Y.useRef(i);a.current=i,Y.useEffect(()=>{if(!l)return;const o=d=>{c.current=Date.now(),a.current&&((d.type==="keydown"||d.type==="mousedown")&&(d.preventDefault(),d.stopPropagation()),n({type:"ClassicyAppScreenSaverDeactivate"}))},r={capture:!0,passive:!0},u={capture:!0};return document.addEventListener("mousemove",o,r),document.addEventListener("wheel",o,r),document.addEventListener("touchstart",o,r),document.addEventListener("mousedown",o,u),document.addEventListener("keydown",o,u),()=>{document.removeEventListener("mousemove",o,r),document.removeEventListener("wheel",o,r),document.removeEventListener("touchstart",o,r),document.removeEventListener("mousedown",o,u),document.removeEventListener("keydown",o,u)}},[l,n]),Y.useEffect(()=>{if(!l||i||!t)return;let o;const r=()=>{const u=Date.now()-c.current;if(u>=s){n({type:Wd});return}o=setTimeout(r,s-u)};return o=setTimeout(r,s),()=>clearTimeout(o)},[l,i,t,s,n])},QN="classicyScreenSaverActive",iL="classicy-screen-saver-overlay",wst=()=>{Y.useEffect(()=>{const e=document.documentElement;return e.classList.add(QN),()=>{e.classList.remove(QN)}},[])},xst="(prefers-reduced-motion: reduce)",zst=(e,t)=>{Y.useEffect(()=>{const n=e.current;if(t===void 0||!n||typeof window.matchMedia!="function")return;const l=window.matchMedia(xst),s=new Set,i=r=>{if(r.playState!=="paused"){for(const u of s)u.effect?.target?.isConnected===!1&&s.delete(u);r.pause(),s.add(r)}},c=r=>{if(!r){for(const u of s)u.play();s.clear();return}if(typeof n.getAnimations=="function")for(const u of n.getAnimations({subtree:!0}))i(u)};l.matches&&c(!0);const a=r=>{if(l.matches)for(const u of r.target.getAnimations?.()??[])i(u)},o=r=>c(r.matches);return n.addEventListener("animationstart",a,!0),l.addEventListener?.("change",o),()=>{n.removeEventListener("animationstart",a,!0),l.removeEventListener?.("change",o)}},[e,t])},Lst=({data:e,saver:t})=>{wst();const n=Y.useRef(null),l=t?.component,s=Qp(t,e.saverConfigs?.[t.id]);return zst(n,t.id),G.jsx("div",{ref:n,id:iL,className:`classicyScreenSaverOverlay${t.transparentBackground?" classicyScreenSaverOverlayTransparent":""}`,role:"presentation",children:l?G.jsx(l,{config:s}):null})},cL=()=>{const e=jt("icons","system.extensions.screensaver")??"",n=ut(i=>i.System.Manager.Applications.apps[Fc]?.data)??{},l=Ga().id;LZ();const s=bh(l,n.selectedSaver);return Ast(n,s!==void 0),G.jsxs(G.Fragment,{children:[G.jsx(vn,{id:Fc,name:F3,icon:e,extension:!0}),n.active===!0&&Fu(n)&&s&&G.jsx(Lst,{data:n,saver:s})]})};function qN(e){return e!==null&&typeof e=="object"&&"openFiles"in e&&Array.isArray(e.openFiles)}const Ou=da([Xt().describe("A ClassicyFileSystem path to a media file."),jn({url:Xt().describe("Source URL of the media document."),name:Xt().optional().describe("Display name of the document."),type:Es(["audio","video","image"]).optional().describe("Media kind, when known."),icon:Xt().optional().describe("Icon shown for the document."),subtitlesUrl:Xt().optional().describe("URL of an optional subtitle track.")}).describe("A manually opened media document.")]),aL=jn({openFiles:xn(Ou).optional().describe("Media documents currently open in Movie Player.")}),bl={name:"Movie Player",id:"MoviePlayer.app",get icon(){return tn("icons","system.quicktime.player")??""}},Rh=Es(["icons","list"]),_N=Es(["small","medium","large"]),oL=Es(["none","grid","sorted"]),dL=Es(["name","modified","created","size","kind","label"]),$N=ft({arrangement:oL.default("none"),keepArrangedBy:dL.default("name"),iconSize:_N.default("large")}),tY=ft({modified:Qn().default(!0),created:Qn().default(!1),size:Qn().default(!0),kind:Qn().default(!0),label:Qn().default(!1),comments:Qn().default(!1),version:Qn().default(!1)}),eY=ft({useRelativeDate:Qn().default(!0),calculateFolderSizes:Qn().default(!1),iconSize:_N.default("medium"),columns:tY.default(tY.parse({}))}),Eu=ft({icons:$N.default($N.parse({})),list:eY.default(eY.parse({}))}),nY="finder_preferences",Fh=e=>{const t=Eu.safeParse(e.standardViews??{});return t.success?t.data:Eu.parse({})},lY=jn({openPaths:xn(Xt()).optional().describe("Folder paths with an open Finder window, in open order."),showAboutThisComputer:Qn().optional().describe("Whether the About This Computer window is open."),showPreferences:Qn().optional().describe("Whether the Finder Preferences window is open."),standardViews:Eu.optional().describe("Default view options applied to folders using standard views."),folderViews:Tl(Xt(),Rh).optional().describe("Explicit per-folder view type. A path absent from this map follows the standard views.")}),sY="finder_about_this_computer";function iY(e){return lY.safeParse(e).success}const Sst=e=>Array.isArray(e.moves)?e.moves.filter(t=>typeof t=="object"&&t!==null&&typeof t.from=="string"&&typeof t.to=="string"&&t.from!==""):[],rL=(e,t,n,l)=>{const s=ON(t);return qo(l,s)?du(e,{type:s,app:{id:"Finder.app"},path:n}):e},uL=(e,t,n)=>{const l="Finder.app";if(!e.System.Manager.Applications.apps[l])return e;const s=e.System.Manager.Applications.apps[l].data??{};let i=Sw(l,s)??{...s};switch(t.type){case"ClassicyAppFinderOpenFolder":{if(!Qo(t))break;if(!i.openPaths){i={...i,openPaths:[t.path]};break}i={...i,openPaths:Array.from(new Set([...i.openPaths,t.path]))};break}case"ClassicyAppFinderOpenFolders":{if(!IA(t))break;const c=i.openPaths??[];i={...i,openPaths:Array.from(new Set([...c,...t.paths]))};break}case"ClassicyAppFinderCloseFolder":{if(!Qo(t))break;const c=i.openPaths??[];i={...i,openPaths:c.filter(a=>a!==t.path)},yb(e.System.Manager.Applications.apps[l],t.path,{closed:!0,focused:!1});break}case"ClassicyAppFinderAboutThisComputerOpen":{i={...i,showAboutThisComputer:!0},e=xi(e,l,sY);break}case"ClassicyAppFinderAboutThisComputerClose":{i={...i,showAboutThisComputer:!1};break}case"ClassicyAppFinderPreferencesOpen":{i={...i,showPreferences:!0},e=xi(e,l,nY);break}case"ClassicyAppFinderPreferencesClose":{i={...i,showPreferences:!1};break}case"ClassicyAppFinderSetStandardViewOption":{const{view:c,option:a,value:o}=t;if(c!=="icons"&&c!=="list"||typeof a!="string")break;const r=a.split(".");if(r.length>2)break;const u=Fh(i),d=u[c];let m;if(r.length===1)m={...d,[r[0]]:o};else{const h=d[r[0]];if(typeof h!="object"||h===null)break;m={...d,[r[0]]:{...h,[r[1]]:o}}}const Z={...u,[c]:m},b=Eu.safeParse(Z);if(!b.success)break;i={...i,standardViews:b.data};break}case"ClassicyAppFinderSetFolderView":{if(!Qo(t))break;const c=t.viewType;if(c!=="icons"&&c!=="list")break;i={...i,folderViews:{...i.folderViews??{},[t.path]:c}};break}case"ClassicyAppFinderPathsMoved":{const c=Sst(t);if(c.length===0)break;const a=r=>{for(const{from:u,to:d}of c){if(r===u)return d;if(r.startsWith(`${u}:`))return d+r.slice(u.length)}return r},o=e.System.Manager.Applications.apps[l];for(const r of i.openPaths??[]){const u=a(r);if(u===r)continue;const d=zn(o,r);d&&(AG(o,r),VG(o,{...d,id:u}))}i={...i,...i.openPaths?{openPaths:i.openPaths.map(a)}:{},...i.folderViews?{folderViews:Object.fromEntries(Object.entries(i.folderViews).map(([r,u])=>[a(r),u]))}:{}};break}case"ClassicyAppFinderEmptyTrash":break;case"ClassicyAppFinderOpenFile":{const c=VA(t)?t.file:void 0;if(c?._system)return e.System.Manager.Desktop.errorDialog={message:"This file is used by the system software. It cannot be opened."},e;if(c?._type===Gt.Extension)return e.System.Manager.Desktop.errorDialog={title:"Library",message:"This file adds functionality to your computer. It cannot be opened."},e;if(c&&c._creator==="QuickTime"){let a;try{a=typeof c._data=="string"?JSON.parse(c._data):c._data}catch(o){Wt("warn","ClassicyFinder","failed to parse QuickTime file data",{error:o,file:c})}if(typeof a=="object"&&a!==null&&"url"in a&&typeof a.url=="string"&&Vb(a.url)){if(!qo(n,"ClassicyAppMoviePlayerOpenDocument"))return e;e=du(e,{type:"ClassicyAppOpen",app:bl}),e=PG(e,"ClassicyAppMoviePlayer",{type:"ClassicyAppMoviePlayerOpenDocument",document:a})}}else if(c&&c._type===Gt.AppShortcut){const a=typeof c._creator=="string"?c._creator:void 0,o=a?e.System.Manager.Applications.apps[a]:void 0;o?qn(e,o.id,o.name,o.icon):e.System.Manager.Desktop.errorDialog={message:"The application that created this item could not be found."}}else if(c&&c._type===Gt.Shortcut){if(typeof c._url!="string"||c._url==="")return e.System.Manager.Desktop.errorDialog={message:"The original item for this shortcut could not be found."},e;if(!qo(n,"ClassicyDesktopOpenUrl"))return e;const a=Qo(t)?t.path.split(":").pop()??t.path:c._url;e=UG(e,{type:"ClassicyDesktopOpenUrl",url:c._url,disposition:c._openIn,title:typeof c._label=="string"?c._label:a})}else if(c&&Qo(t)){const a=c._type,o=e.System.Manager.Applications.fileTypeHandlers[a],r=o?e.System.Manager.Applications.apps[o]:void 0;if(r&&r.id!==l)e=Hz(e,r,t.path,n);else if(r)e=rL(e,r.name,t.path,n);else{const u=e.System.Manager.Applications.apps[l];u?.handlesFileTypes?.includes(a)?e=rL(e,u.name,t.path,n):e.System.Manager.Desktop.errorDialog={message:"Finder cannot open the file type you requested."}}}return e}}return e.System.Manager.Applications.apps[l].data={...i},e};Ln({id:"Finder.app",description:"The system file browser: desktop, folders, and the Trash.",prefix:"ClassicyAppFinder",handler:uL,actions:{ClassicyAppFinderOpenFolder:{description:"Open a Finder window at the given folder path.",params:ft({path:Xt().describe("Absolute path of the folder to open.")})},ClassicyAppFinderOpenFolders:{description:"Open Finder windows for several folder paths at once.",params:ft({paths:xn(Xt()).describe("Absolute paths of the folders to open.")})},ClassicyAppFinderCloseFolder:{description:"Close the Finder window showing the given folder path.",params:ft({path:Xt().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:ft({view:Rh.describe("Which view's options to change."),option:Xt().describe("Dotted option path within that view, max one level deep."),value:fo().describe("New value; validated against the schema.")})},ClassicyAppFinderSetFolderView:{description:"Remember an explicit view type for one folder, overriding the standard views.",params:ft({path:Xt().describe("Absolute path of the folder."),viewType:Rh.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:ft({moves:xn(ft({from:Xt().describe("Path before the move."),to:Xt().describe("Path after the move.")})).describe("Each moved item's old and new path.")})},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:ft({file:jn({}).describe("The ClassicyFileSystem entry being opened."),path:Xt().optional().describe("Filesystem path of the entry, when known.")})}},state:lY});const Cst=()=>G.jsx("svg",{className:"classicyProgressChasingArrowsSpinner",viewBox:"0 0 32 32",width:"16",height:"16",role:"img","aria-hidden":"true",focusable:"false",children:G.jsxs("g",{fill:"currentColor",children:[G.jsx("path",{d:"M16 3a13 13 0 0 1 12.5 9.4l-3.8 1.1A9 9 0 0 0 16 7z"}),G.jsx("path",{d:"M24.7 9.5 30 12l-2 5.6z"}),G.jsx("path",{d:"M16 29A13 13 0 0 1 3.5 19.6l3.8-1.1A9 9 0 0 0 16 25z"}),G.jsx("path",{d:"M7.3 22.5 2 20l2-5.6z"})]})}),Dh=({max:e=100,value:t,indeterminate:n,chasingArrows:l,autoSwitch:s,label:i,labelPosition:c="above",labelAlign:a="left",className:o,style:r})=>{const d=n&&!(s&&t!==void 0),m=d?100:e,Z=d?100:t??0,b=i?void 0:o,h=i?void 0:r;let p;return l?p=G.jsx("div",{className:$("classicyProgress classicyProgressChasingArrows",b),style:h,role:"progressbar","aria-busy":"true","aria-label":i,children:G.jsx(Cst,{})}):p=G.jsx("div",{className:$("classicyProgress",d?"classicyProgressIndeterminate":"classicyProgressDeterminate",b),style:h,children:G.jsx("progress",{max:m,value:Z})}),i?G.jsxs("div",{className:$(Yn(c),Hb(a),o),style:r,children:[G.jsx(Ot,{label:i}),p]}):p},mL={version:"3.1.1",release:"LU1"},cY=64,fst=20.5,Rst="Off",Fst="Finder.app",{version:Dst}=mL,kst=mL.release,ZL=({className:e,style:t})=>{const n=jt("icons","classicy.bg")??"",l=jt("systemArt","aboutLogo")??"",s=jt("icons","system.macos")??"",i=jt("icons","system.mac")??"",c=Ut(),[a,o]=Y.useState(fst);Y.useEffect(()=>{const m=performance;typeof m.measureUserAgentSpecificMemory=="function"?m.measureUserAgentSpecificMemory().then(Z=>o(Z.bytes/(1024*1024))).catch(()=>{Wt("info","Finder","Could not measure memory usage, using default value")}):Wt("info","Finder","Memory measurement API not available, using default value")},[]);const r=cY-a,u=Lw("Finder.app","ClassicyAppFinderAboutThisComputerOpen"),d=`Classicy ${Dst} (${kst})`;return G.jsx(ge,{id:sY,appId:Fst,className:e,style:t,hideIcon:!0,title:"About This Computer",closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,initialSize:[520,290],initialPosition:["center","center"],onCloseFunc:()=>c({type:"ClassicyAppFinderAboutThisComputerClose"}),children:G.jsxs("div",{className:"finderAboutThisComputer",children:[G.jsxs("div",{className:"finderAboutThisComputerHeader",children:[G.jsx("div",{className:"finderAboutThisComputerBanner",style:{backgroundSize:"cover",backgroundPosition:"bottom left",backgroundImage:`url("${n}")`,backgroundRepeat:"no-repeat"},children:G.jsx("img",{src:l,alt:"Classicy"})}),G.jsxs("div",{className:"finderAboutThisComputerVersion",children:[G.jsx("img",{src:s,alt:"Classicy"}),u?G.jsx(Gy,{title:u.title,content:u.content,children:G.jsx("span",{children:d})}):G.jsx("span",{children:d})]})]}),G.jsxs("div",{className:"finderAboutThisComputerInfo",children:[G.jsxs("div",{className:"finderAboutThisComputerMemoryStats",children:[G.jsxs("p",{children:[G.jsx("strong",{children:"Built-in Memory:"})," ",cY," MB"]}),G.jsxs("p",{children:[G.jsx("strong",{children:"Virtual Memory:"})," ",Rst]}),G.jsxs("p",{children:[G.jsx("strong",{children:"Largest Unused Block:"})," ",r.toFixed(1)," MB"]})]}),G.jsx("p",{className:"finderAboutThisComputerCopyright",children:"Not \u2122 & \xA9 Apple Computer, Inc. 1983\u20131999"})]}),G.jsx("div",{className:"finderAboutThisComputerUsage",children:G.jsxs("div",{className:"finderAboutThisComputerUsageItem",children:[G.jsx("img",{src:i,alt:"Classicy"}),G.jsx("span",{className:"finderAboutThisComputerUsageName",children:"Classicy"}),G.jsxs("span",{className:"finderAboutThisComputerUsageSize",children:[a.toFixed(1)," MB"]}),G.jsx("div",{className:"finderAboutThisComputerUsageBar",children:G.jsx(Dh,{value:a,max:cY})})]})})]})})},jst=[{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"}],vst=[{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"}],bL=e=>{const t=Ut(),[n,l]=Y.useState("icons"),s=Y.useCallback((o,r,u)=>{t({type:"ClassicyAppFinderSetStandardViewOption",view:o,option:r,value:u})},[t]),i=e.icons,c=e.list;return{title:"Views",children:Y.useMemo(()=>G.jsx("div",{className:"finderPreferencesViews",children:G.jsxs(Jn,{label:"View Options",children:[G.jsx(Me,{id:"finder_prefs_view_type",label:"View type:",labelPosition:"left",selected:n,options:[{value:"icons",label:"Icons"},{value:"list",label:"List"}],onChangeFunc:o=>l(o.target.value)}),n==="icons"?G.jsxs("div",{className:"finderPreferencesPane",children:[G.jsx("p",{className:"finderPreferencesGroupHeading",children:"Icon Arrangement:"}),G.jsx(Xa,{name:"finder_prefs_icon_arrangement",onClickFunc:o=>s("icons","arrangement",o.split("__").pop()),inputs:[{id:"finder_prefs_icon_arrangement__none",label:"None",checked:i.arrangement==="none"},{id:"finder_prefs_icon_arrangement__grid",label:"Always snap to grid",checked:i.arrangement==="grid"},{id:"finder_prefs_icon_arrangement__sorted",label:"Keep arranged:",checked:i.arrangement==="sorted"}]}),G.jsx(Me,{id:"finder_prefs_icon_sort",disabled:i.arrangement!=="sorted",selected:i.keepArrangedBy,options:jst,onChangeFunc:o=>s("icons","keepArrangedBy",o.target.value)}),G.jsx(Xa,{name:"finder_prefs_icon_size",onClickFunc:o=>s("icons","iconSize",o.split("__").pop()),inputs:[{id:"finder_prefs_icon_size__small",label:"Small icons",checked:i.iconSize==="small"},{id:"finder_prefs_icon_size__large",label:"Large icons",checked:i.iconSize!=="small"}]})]}):G.jsxs("div",{className:"finderPreferencesPane",children:[G.jsx(Xn,{id:"finder_prefs_relative_date",label:"Use relative date",checked:c.useRelativeDate,onClickFunc:o=>s("list","useRelativeDate",o)}),G.jsx(Xn,{id:"finder_prefs_folder_sizes",label:"Calculate folder sizes",checked:c.calculateFolderSizes,onClickFunc:o=>s("list","calculateFolderSizes",o)}),G.jsx("p",{className:"finderPreferencesGroupHeading",children:"Show Columns:"}),vst.map(({key:o,label:r})=>G.jsx(Xn,{id:`finder_prefs_column_${o}`,label:r,checked:c.columns[o]===!0,onClickFunc:u=>s("list",`columns.${o}`,u)},o)),G.jsx(Xa,{name:"finder_prefs_list_icon_size",onClickFunc:o=>s("list","iconSize",o.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"}]})]})]})}),[n,i,c,s])}},hL="Finder.app",pL=({className:e,style:t})=>{const n=jt("icons","system.help")??"",l=Ut(),s=ut(o=>o.System.Manager.Applications.apps[hL]?.data),i=Y.useMemo(()=>Fh(s??{}),[s]),c=bL(i),a=Y.useMemo(()=>[c],[c]);return G.jsx(ge,{id:nY,appId:hL,className:e,style:t,title:"Preferences",closable:!0,resizable:!1,zoomable:!1,scrollable:!1,collapsable:!1,modal:!1,initialSize:[470,0],initialPosition:["center","center"],onCloseFunc:()=>l({type:"ClassicyAppFinderPreferencesClose"}),children:G.jsxs("div",{className:"finderPreferences",children:[G.jsx(jy,{tabs:a}),G.jsxs("div",{className:"finderPreferencesFooter",children:[G.jsx("img",{className:"finderPreferencesHelpIcon",src:n,alt:"Help"}),G.jsx("p",{className:"finderPreferencesNote",children:"Changes are applied to all folders that are set to Standard views. Other folders are not affected."})]})]})})};function WL(e,t){const[n,l]=Y.useState(void 0);return Y.useEffect(()=>{let s=!1;l(void 0);const i=t.resolve(e);return i&&t.calculateSizeDir(i).then(c=>{s||l(c)}),()=>{s=!0}},[e,t]),n}const Uu={emptyTrash:"empty_trash",resetPram:"reset_pram"},aY=(e,t)=>[{id:`${t}_special_empty_trash`,title:"Empty Trash\u2026",onClickFunc:()=>{e({type:"ClassicyDesktopShowSystemDialog",dialog:"emptyTrash"})}},{id:"spacer"},{id:`${t}_special_reset_pram`,title:"Reset PRAM\u2026",onClickFunc:()=>{e({type:"ClassicyDesktopShowSystemDialog",dialog:"resetPram"})}}],GL=({itemCount:e,onEmpty:t,onClose:n,className:l,style:s})=>{if(e===0)return G.jsx(_l,{id:Uu.emptyTrash,appId:"Finder.app",alertType:"note",label:"The Trash is empty.",buttons:[{id:"ok",label:"OK",role:"default"}],onClose:n,className:l,style:s});const i=e===1?"1 item":`${e} items`;return G.jsx(_l,{id:Uu.emptyTrash,appId:"Finder.app",alertType:"caution",label:`The Trash contains ${i}. Are you sure you want to permanently remove ${e===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:t}],onClose:n,className:l,style:s})},Jst={small:.5,medium:1,large:1},Ost={small:.25,medium:.375,large:.667},yL=(e,t)=>Math.round(e*Jst[t]),NL=(e,t)=>Math.round(e*Ost[t]),kh=(e,t)=>e.name.localeCompare(t.name,void 0,{sensitivity:"base"}),YL=e=>(t,n)=>{if(e==="name")return kh(t,n);const l=a=>{switch(e){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}},s=l(t),i=l(n);if(s===void 0&&i===void 0)return kh(t,n);if(s===void 0)return 1;if(i===void 0)return-1;if(typeof s=="string"&&typeof i=="string"){const a=s.localeCompare(i,void 0,{sensitivity:"base"});return a!==0?a:kh(t,n)}const c=Number(s)-Number(i);return c!==0?c:kh(t,n)},Est=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Ust=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],oY=e=>{const t=e.getHours(),n=t>=12?"PM":"AM";return`${t%12===0?12:t%12}:${String(e.getMinutes()).padStart(2,"0")} ${n}`},XL=e=>`${Est[e.getDay()]}, ${Ust[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`,gL=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),dY=(e,t,n)=>{if(!e)return"\u2014";if(!n)return`${XL(e)}, ${oY(e)}`;if(gL(e,t))return`Today, ${oY(e)}`;const l=new Date(t.getFullYear(),t.getMonth(),t.getDate()-1);return gL(e,l)?`Yesterday, ${oY(e)}`:XL(e)},Di=e=>{if(e instanceof Date)return Number.isNaN(e.getTime())?void 0:e;if(typeof e=="string"||typeof e=="number"){const t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}},ML=e=>e&&String(e[0]).toUpperCase()+String(e).slice(1),TL=e=>e==="app_shortcut"?"Application":ML(e.replaceAll("_"," ")),Ld=e=>e==="directory"?tn("icons","system.folders.directory")??"":tn("icons","system.files.file")??"",Bst=(e,t,n)=>[Math.floor(n[0]/(e*2+t)),Math.floor(n[1]/(e*2+t))],IL=(e,t)=>[e%t[0],Math.floor(e/t[0])],jh=(e,t)=>{const n=gb(e);return{size:qe("--desktop-icon-size",n.size,t),padding:qe("--desktop-icon-padding",n.padding,t),cell:qe("--desktop-icon-cell",n.cell,t)}},rY=(e,t,n=jh(e))=>{const l=t!==void 0?t*2:n.cell;return{origin:[n.padding,n.padding],pitch:[l,l]}},VL=(e,t,n,l,s,i=jh(e))=>{const{origin:c,pitch:a}=rY(e,s,i),o=[Math.floor(l[0]/(a[0]+i.padding)),Math.floor(l[1]/(a[1]+i.padding))],[r,u]=IL(t,o);return[c[0]+Math.floor(a[0]*r),c[1]+Math.floor(a[1]*u)]},Pst=127,Hst=[[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[-1,-1],[1,-1]];function AL(e,t,n){const l=(a,o)=>a>=0&&o>=0&&a<t&&o<n&&e[o*t+a]===1,s=new Uint8Array(t*n);for(let a=0;a<n;a++)for(let o=0;o<t;o++)l(o,a)&&(!l(o-1,a)||!l(o+1,a)||!l(o,a-1)||!l(o,a+1))&&(s[a*t+o]=1);const i=new Uint8Array(t*n),c=new Uint8Array(t*n);for(let a=0;a<s.length;a++){if(!s[a]||c[a])continue;let o=a,r=!0;for(;o!==-1;){c[o]=1,r&&(i[o]=1),r=!r;const u=o%t,d=(o-u)/t;let m=-1;for(const[Z,b]of Hst){const h=u+Z,p=d+b;if(h<0||p<0||h>=t||p>=n)continue;const W=p*t+h;if(s[W]&&!c[W]){m=W;break}}o=m}}return i}const wL=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?{left:t.left,top:t.top,width:t.width,height:t.height}:null};function xL(e){const t=e.map(b=>({image:b.image??null,imageBox:b.image?wL(b.image):null,labelBox:b.label?wL(b.label):null})),n=t.flatMap(b=>[b.imageBox,b.labelBox].filter(h=>h!==null));if(n.length===0)return null;const l=Math.floor(Math.min(...n.map(b=>b.left))),s=Math.floor(Math.min(...n.map(b=>b.top))),i=Math.ceil(Math.max(...n.map(b=>b.left+b.width))),c=Math.ceil(Math.max(...n.map(b=>b.top+b.height))),a=i-l,o=c-s,r=document.createElement("canvas");r.width=a,r.height=o;const u=r.getContext("2d",{willReadFrequently:!0});if(!u)return null;u.imageSmoothingEnabled=!1;for(const{image:b,imageBox:h}of t)!b||!h||u.drawImage(b,Math.round(h.left-l),Math.round(h.top-s),Math.round(h.width),Math.round(h.height));const d=new Uint8Array(a*o);try{const{data:b}=u.getImageData(0,0,a,o);for(let h=0;h<d.length;h++)b[h*4+3]>Pst&&(d[h]=1)}catch{for(const{imageBox:b}of t)b&&zL(d,a,b,l,s)}for(const{labelBox:b}of t)b&&zL(d,a,b,l,s);const m=AL(d,a,o);u.clearRect(0,0,a,o);const Z=u.createImageData(a,o);for(let b=0;b<m.length;b++)m[b]===1&&(Z.data[b*4+3]=255);return u.putImageData(Z,0,0),{canvas:r,left:l,top:s}}function zL(e,t,n,l,s){const i=Math.max(0,Math.round(n.left-l)),c=Math.max(0,Math.round(n.top-s)),a=Math.min(t,Math.round(n.left-l+n.width)),o=Math.min(e.length/t,Math.round(n.top-s+n.height));for(let r=c;r<o;r++)for(let u=i;u<a;u++)e[r*t+u]=1}const ki="data-classicy-file-path",Sd="data-classicy-drop-folder",uY="data-classicy-drop-desktop",LL=4,SL="classicyFileDropTarget",CL="classicyFileDragging",Kst=".classicyWindow, .classicyDesktopMenuBar, .classicyControlStrip, [role='dialog']",Qst=(e,t)=>typeof document<"u"&&document.elementsFromPoint?document.elementsFromPoint(e,t):[];function fL(e,t,{exclude:n,elementsFromPoint:l=Qst}={}){for(const s of l(e,t))if(!n?.contains(s)){for(let i=s;i;i=i.parentElement){const c=i.getAttribute(Sd);if(c!==null)return{destination:{kind:"folder",path:c},element:i};if(i.hasAttribute(uY))return{destination:{kind:"desktop"},element:i};if(i.matches(Kst))return null}return null}return null}function vh(e){const{start:t,source:n,elementsFromPoint:l}=e;let s=null,i=[0,0],c=null;const a=y=>{c!==y&&(c?.classList.remove(SL),c=y,c?.classList.add(SL))},o=(y,N)=>{s&&(s.style.transform=`translate(${y-i[0]}px, ${N-i[1]}px)`)},r=()=>{s=document.createElement("div"),s.className="classicyFileDragGhost",s.setAttribute("aria-hidden","true");const y=xL(e.parts);y&&(s.append(y.canvas),i=[t.clientX-y.left,t.clientY-y.top]),document.body.append(s),document.body.classList.add(CL)};let u=()=>{};const d=()=>{u(),document.removeEventListener("mousemove",b,!0),document.removeEventListener("mouseup",h,!0),document.removeEventListener("keydown",W,!0),a(null),s?.remove(),s=null,document.body.classList.remove(CL)},m=y=>{try{e.onEnd?.(y)}catch(N){Wt("error","ClassicyFileDrag","onEnd threw; ignored.",N)}},Z=(y,N)=>fL(y,N,{exclude:n,elementsFromPoint:l});function b(y){if(!s){if(Math.max(Math.abs(y.clientX-t.clientX),Math.abs(y.clientY-t.clientY))<LL)return;r(),e.onStart?.()}y.preventDefault(),o(y.clientX,y.clientY);const N=Z(y.clientX,y.clientY);a(N?.destination.kind==="folder"?N.element:null)}function h(y){const N=s!==null;if(d(),!N){e.onClick?.();return}const X=Z(y.clientX,y.clientY);m({dropped:X!==null,canceled:!1,lost:!1}),e.onDrop(X,[y.clientX,y.clientY],[y.clientX-i[0],y.clientY-i[1]])}const p=y=>{const N=s!==null;d(),N&&m({dropped:!1,canceled:!0,lost:y})};function W(y){y.key!=="Escape"||!s||(y.preventDefault(),y.stopPropagation(),p(!1))}return document.addEventListener("mousemove",b,!0),document.addEventListener("mouseup",h,!0),document.addEventListener("keydown",W,!0),u=Vl(()=>p(!0)),()=>p(!1)}function mY(e){return{onStart:()=>e("dragStart",{kind:"file"}),onEnd:({dropped:t,canceled:n,lost:l})=>e("dragEnd",{kind:"file",dropped:t,canceled:n,lost:l})}}function ZY(){const e=Y.useRef(null);return Y.useLayoutEffect(()=>()=>{e.current?.(),e.current=null},[]),Y.useCallback(t=>{e.current=t},[])}const bY=(e,t,n=[0,0])=>[n[0]+Math.round((e[0]-n[0])/t[0])*t[0],n[1]+Math.round((e[1]-n[1])/t[1])*t[1]],RL=({appId:e,name:t,icon:n,label:l,labelPosition:s="below",initialPosition:i=[0,0],holder:c,onClickFunc:a,invisible:o=!1,size:r,snapTo:u,snapOrigin:d,positionLocked:m=!1,dropFolderPath:Z,filePath:b,onFileDrag:h,className:p,style:W})=>{const[y,N]=Y.useState(i),[X,g]=Y.useState(!1),[M,I]=Y.useState(!1),A=Y.useRef(!1),V=Y.useRef(null),z=Re("Icon",{dragging:X,selected:M},V),x=Y.useRef(!1),S=ZY(),C=`${e}.shortcut`,{track:k}=Nn(),v={type:"ClassicyIcon",appId:e,name:t,icon:n,label:l},J=()=>{k("focus",v),z.emit("select",{selected:!M}),I(!M)},R=P=>{k("focus",v),I(P)},D=()=>{k("blur",v),I(!1)},L=()=>{a&&(z.emit("open",kt()),D(),a())},w=P=>{u&&A.current&&N(q=>bY(q,u,d)),A.current=!1,g(!1),x.current&&(x.current=!1,z.emit("dragEnd",{lost:P}))};Rb(X,()=>w(!0));const j=P=>{if(h){if(P.button!==0)return;const q=V.current,ot=vh({start:{clientX:P.clientX,clientY:P.clientY},parts:[{image:q?.querySelector("img"),label:q?.querySelector("p")}],source:q,...mY(z.emit),onDrop:(gt,Zt,K)=>{if(h(gt,Zt,K)||m)return;const O=[y[0]+Zt[0]-P.clientX,y[1]+Zt[1]-P.clientY];N(u?bY(O,u,d):O),R(!0)}});S(ot);return}m||(A.current=!1,g(!0),x.current=!0,z.emit("dragStart"))},B=P=>{c?.current&&X&&V.current&&(A.current=!0,R(!0),N([P.clientX-c.current.getBoundingClientRect().left-V.current.getBoundingClientRect().width/2,P.clientY-c.current.getBoundingClientRect().top-V.current.getBoundingClientRect().height/2]))},f=Y.useId(),U=G.jsx("p",{className:$(o?"classicyIconInvisible":""),children:l||t}),_=G.jsx("div",{className:$("classicyIconMaskOuter",o?"classicyIconInvisible":""),style:{"--classicy-icon-mask":`url("${n}")`},children:G.jsx("div",{className:"classicyIconMask",children:G.jsx("img",{src:n,alt:t})})});return G.jsxs("div",{...z.attrs,role:"button",tabIndex:0,ref:V,id:`${C}-${f}`,draggable:!1,...Z===void 0?{}:{[Sd]:Z},...b===void 0?{}:{[ki]:b},className:$("classicyIcon",z.className,Yn(s),p),style:{...Gu(z.style),left:`${y[0]}px`,top:`${y[1]}px`,...r===void 0?{}:{"--desktop-icon-size":`${r}px`},...Gu(W)},onClick:J,onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),L())},onMouseDown:j,onMouseMove:B,onMouseUp:()=>w(!1),onDoubleClick:L,children:[s==="above"?U:_,s==="above"?_:U]})},hY=Y.memo(({fs:e,path:t,appId:n,dirOnClickFunc:l,fileOnClickFunc:s,holderRef:i,hideFilesCreatedAfter:c=null,showInvisible:a=!0,iconViewOptions:o,onMoveItems:r,className:u,style:d})=>{const m=ut(g=>g.System.Manager.Appearance.activeTheme),Z=Y.useRef(null),b=i??Z,[h,p]=Y.useState([]),W=Y.useRef(null),y=o?.arrangement,N=o?.keepArrangedBy,X=o?.iconSize;return Y.useLayoutEffect(()=>{if(!b.current)return;const g=(J,R,D)=>{if(J._type==="directory")return l?l(`${R}:${D}`):void 0;if(s)return s(`${R}:${D}`)},M=[b.current.getBoundingClientRect().width,b.current.getBoundingClientRect().height],I=e.filterByType(t,void 0,a,c),A=Object.entries(I),V=y==="sorted"&&N?[...A].sort((J,R)=>YL(N)({name:J[0],modifiedOn:Di(J[1]._modifiedOn),createdOn:Di(J[1]._createdOn),size:J[1]._size,kind:J[1]._type,label:J[1]._label},{name:R[0],modifiedOn:Di(R[1]._modifiedOn),createdOn:Di(R[1]._createdOn),size:R[1]._size,kind:R[1]._type,label:R[1]._label})):A;W.current?.theme!==m&&(W.current={theme:m,metrics:jh(m)});const z=W.current.metrics,x=X?yL(z.size,X):void 0,S=rY(m,x,z),C=y==="grid"?S.pitch:void 0,k=y==="sorted",v=V.map(([J,R],D)=>{const L=`${t}${e.separator}${J}`;return{filePath:L,dropFolderPath:R._type==="directory"?L:void 0,onFileDrag:(w,j,B)=>w?.destination.kind==="folder"&&w.destination.path===t?!1:(w&&r&&r([L],w.destination,B),!0),appId:n,name:J,invisible:R._invisible,icon:R._icon||Ld(R._type),onClickFunc:()=>g(R,t,J),holder:b,initialPosition:VL(m,D,V.length,M,x,z),size:x,snapTo:C,snapOrigin:S.origin,positionLocked:k}});p(v)},[n,t,e,l,s,m,b.current,b,c,a,y,N,X,r]),G.jsx("div",{className:$("classicyFileBrowserFill",u),style:d,ref:b,children:h.map(g=>Y.createElement(RL,{...g,key:g.name}))})});hY.displayName="ClassicyFileBrowserViewIcons";function FL({columns:e,rows:t,getRowId:n,selectionMode:l="single",selected:s,onSelectionChange:i,onActivateRow:c,defaultSort:a,stickyHeader:o=!0,className:r,style:u,rowClassName:d,getSubRows:m,rowCanExpand:Z,expanded:b,onToggleRow:h,selectionApiRef:p,containerRef:W}){const y=jt("icons","ui.menuDropdownArrowUp")??"",[N,X]=Y.useState(a?[{id:a.columnId,desc:!!a.desc}]:[]),[g,M]=Y.useState([]),I=b??g,A=Y.useMemo(()=>Object.fromEntries(I.map(O=>[O,!0])),[I]),V=Y.useCallback(O=>{const H=!I.includes(O);M(H?[...I,O]:I.filter(et=>et!==O)),h?.(O,H)},[I,h]),[z,x]=Y.useState([]),[S,C]=Y.useState(),k=s??z,v=Y.useRef(void 0),J=Y.useRef(null),R=Y.useCallback(O=>{J.current=O,W&&(W.current=O)},[W]),D=Re("Table",{},J),L=Y.useRef(""),w=Y.useRef(void 0),j=Y.useMemo(()=>new Map(e.map(O=>[O.id,O])),[e]),B=Y.useMemo(()=>e.map(O=>({id:O.id,accessorFn:H=>O.accessor(H),enableSorting:O.sortable!==!1,enableResizing:O.resizable!==!1,...O.width!==void 0?{size:O.width}:{}})),[e]),f=zZ.useReactTable({data:t,columns:B,getRowId:n,getSubRows:m,...Z?{getRowCanExpand:O=>Z(O.original)}:{},getCoreRowModel:zZ.getCoreRowModel(),getSortedRowModel:zZ.getSortedRowModel(),getExpandedRowModel:zZ.getExpandedRowModel(),state:{sorting:N,expanded:A},onSortingChange:X,columnResizeMode:"onChange"}),U=Y.useRef(void 0),_=Y.useCallback(()=>{const O=U.current;if(!O)return;U.current=void 0;const H=new Event(O==="touch"?"touchend":"mouseup");O==="touch"&&Object.defineProperty(H,"touches",{value:[]}),document.dispatchEvent(H)},[]),P=f.getState().columnSizingInfo.isResizingColumn;Y.useEffect(()=>{if(!P)return;const O=Vl(_);return()=>{O(),f.getState().columnSizingInfo.isResizingColumn&&_()}},[P,f,_]);const q=Y.useCallback(O=>{x(O),i?.(O)},[i]),ot=Y.useCallback(()=>{l==="multi"&&q(f.getRowModel().rows.map(O=>O.id))},[l,q,f]);Y.useEffect(()=>{if(p)return p.current={selectAll:ot},()=>{p.current=null}},[p,ot]);const gt=(O,H)=>{if(l==="none")return;const et=f.getRowModel().rows,rt=at=>D.emit("select",kt({rowId:O,selected:at}));if(l==="multi"){if(H.shiftKey&&v.current){const at=et.findIndex(pt=>pt.id===v.current),tt=et.findIndex(pt=>pt.id===O);if(at>=0&&tt>=0){const[pt,_t]=at<=tt?[at,tt]:[tt,at];rt(!0),q(et.slice(pt,_t+1).map(lt=>lt.id));return}}if(H.metaKey||H.ctrlKey){v.current=O,rt(!k.includes(O)),q(k.includes(O)?k.filter(at=>at!==O):[...k,O]);return}}v.current=O,rt(!0),q([O])},Zt=(O,H)=>{C(O),gt(O,H),requestAnimationFrame(()=>{const et=J.current?.querySelector(`[data-row-id="${CSS.escape(O)}"]`);try{et?.scrollIntoView({block:"nearest"})}catch{}})},K=O=>{if(l==="none")return;const H=f.getRowModel().rows;if(H.length===0)return;const et=H.findIndex(Yt=>Yt.id===S),rt={shiftKey:O.shiftKey&&l==="multi",metaKey:!1,ctrlKey:!1};switch(O.key){case"ArrowDown":{O.preventDefault();const Yt=Math.min(et+1,H.length-1);Zt(H[Yt<0?0:Yt].id,rt);return}case"ArrowUp":{O.preventDefault();const Yt=et<0?0:Math.max(et-1,0);Zt(H[Yt].id,rt);return}case"Home":{O.preventDefault(),Zt(H[0].id,rt);return}case"End":{O.preventDefault(),Zt(H[H.length-1].id,rt);return}case"ArrowRight":{if((O.metaKey||O.ctrlKey)&&et>=0){const Yt=H[et];Yt.getCanExpand()&&!Yt.getIsExpanded()&&(O.preventDefault(),V(Yt.id))}return}case"ArrowLeft":{if((O.metaKey||O.ctrlKey)&&et>=0){const Yt=H[et];Yt.getCanExpand()&&Yt.getIsExpanded()&&(O.preventDefault(),V(Yt.id))}return}case"Enter":{if(et>=0){O.preventDefault();const Yt=H[et];c?.(Yt.id,Yt.original)}return}case"a":case"A":{if((O.metaKey||O.ctrlKey)&&l==="multi"){O.preventDefault(),ot();return}break}}if(!(O.key.length===1&&O.key!==" "&&!O.metaKey&&!O.ctrlKey&&!O.altKey))return;w.current&&clearTimeout(w.current),L.current+=O.key.toLowerCase(),w.current=setTimeout(()=>{L.current=""},700);const tt=L.current,pt=e[0];if(!pt)return;const _t=et<0?0:et,It=[...H.slice(_t+1),...H.slice(0,_t+1)].find(Yt=>`${pt.accessor(Yt.original)??""}`.toLowerCase().startsWith(tt));It&&Zt(It.id,{shiftKey:!1,metaKey:!1,ctrlKey:!1})};return G.jsx("div",{...D.attrs,ref:R,tabIndex:l==="none"?void 0:0,onKeyDown:K,className:$("classicyTableContainer",D.className,r),style:D.style?{...D.style,...u}:u,children:G.jsxs("table",{className:"classicyTable",children:[G.jsx("thead",{className:$("classicyTableHeader",o&&"classicyTableHeaderSticky"),children:f.getHeaderGroups().map(O=>G.jsx("tr",{className:"classicyTableHeaderGroup",children:O.headers.map(H=>{const et=N.length>0&&H.id===N[0].id;return G.jsx("th",{align:j.get(H.id)?.align??"left","aria-sort":et?N[0].desc?"descending":"ascending":void 0,style:{width:H.getSize()},className:$("classicyTableColumnHeader",H.column.getIsResizing()?"isResizing":"",Xe({selected:!!et})),onClick:()=>{if(!H.column.getCanSort())return;const rt=!(H.column.getIsSorted()===!1||H.column.getIsSorted()==="desc");H.column.toggleSorting(rt,!1),D.emit("change",{columnId:H.id,desc:rt})},children:G.jsxs("div",{className:"classicyTableHeaderCellContent",children:[!H.isPlaceholder&&G.jsx("span",{children:j.get(H.id)?.title??""}),et&&G.jsx("img",{src:`${y}`,alt:"Up Arrow",className:$("classicyTableSortArrow",N[0].desc?"":"classicyTableSortArrowAscending")}),H.column.getCanResize()&&G.jsx("div",{onMouseDown:rt=>{U.current="mouse",H.getResizeHandler()(rt)},onTouchStart:rt=>{U.current="touch",H.getResizeHandler()(rt)},className:$("resizer",H.column.getIsResizing()?"isResizing":"")})]})},H.id)})},O.id))}),G.jsx("tbody",{className:"classicyTableContent",children:f.getRowModel().rows.map(O=>G.jsx("tr",{"data-row-id":O.id,"data-selected":k.includes(O.id)||void 0,className:$("classicyTableRow",Xe({selected:k.includes(O.id)}),d?.(O.original,k.includes(O.id))),onClick:H=>{C(O.id),gt(O.id,H)},onDoubleClick:()=>c?.(O.id,O.original),children:O.getVisibleCells().map(H=>{const et=j.get(H.column.id);return G.jsx("td",{className:"classicyTableCell",style:{width:H.column.getSize(),textAlign:et?.align??"left"},children:et?.render?et.render(O.original,{depth:O.depth,canExpand:O.getCanExpand(),isExpanded:O.getIsExpanded(),toggle:()=>V(O.id),emitDrag:D.emit}):G.jsx("span",{children:`${H.getValue()??""}`})},H.id)})},O.id))})]})})}const qst={modified:!1,created:!1,size:!0,kind:!0,label:!1,comments:!1,version:!1},pY=Y.memo(({fs:e,path:t,iconSize:n=64,appId:l,dirOnClickFunc:s=()=>{},fileOnClickFunc:i=()=>{},hideFilesCreatedAfter:c=null,showInvisible:a=!0,listViewOptions:o,now:r,selectionApiRef:u,selectedPaths:d,onSelectionChange:m,focusTargetRef:Z,onMoveItems:b,className:h,style:p})=>{const W=Y.useRef(d??[]);Y.useEffect(()=>{d&&(W.current=d)},[d]);const y=Y.useCallback(D=>{W.current=D,m?.(D)},[m]),N=ZY(),X=Y.useCallback((D,L,w)=>{if(D.button!==0||!b)return;const j=W.current,B=j.includes(L)?j:[L],f=D.currentTarget.closest(".classicyFileBrowserViewTableContainer"),U=B.map(P=>Array.from(f?.querySelectorAll(`[${ki}]`)??[]).find(q=>q.getAttribute(ki)===P)).filter(P=>P!==void 0),_=vh({start:{clientX:D.clientX,clientY:D.clientY},parts:U.map(P=>({image:P.querySelector("img"),label:P.querySelector(".classicyFileBrowserViewTableRowIconLabel")})),source:D.currentTarget,...w&&mY(w),onDrop:(P,q,ot)=>{P&&(P.destination.kind==="folder"&&P.destination.path===t||b(B,P.destination,ot))}});N(_)},[b,t,N]),g=o?.columns??qst,M=o?.calculateFolderSizes??!0,I=o?.useRelativeDate??!0,A=r?.getTime(),V=Y.useMemo(()=>A===void 0?new Date:new Date(A),[A]),[z,x]=Y.useState([]),S=(D,L)=>D._type==="directory"?s(L):i(L),[C,k]=Y.useState(new Map),v=Y.useMemo(()=>new Set(z),[z]),J=Y.useMemo(()=>{const D=L=>{const w=e.filterByType(L,void 0,a,c);return Object.entries(w).map(([j,B])=>{const f=`${L}:${j}`,U={};for(const[P,q]of Object.entries(B))P.startsWith("_")&&(U[P]=q);U._name=j,U._path=f,U._size=C.has(f)?C.get(f):typeof B._size=="number"?B._size:void 0;const _=U;return B._type===Gt.Directory&&v.has(f)&&(_.subRows=D(f)),_})};return D(t)},[e,t,C,v,c,a]);Y.useEffect(()=>{if(!M)return;let D=!1;const L=[],w=j=>{j.forEach(B=>{typeof B._size!="number"&&B._path&&!C.has(B._path)&&L.push(B._path),B.subRows&&w(B.subRows)})};return w(J),L.forEach(j=>{e.size(j).then(B=>{D||k(f=>{if(f.has(j))return f;const U=new Map(f);return U.set(j,B),U})})}),()=>{D=!0}},[J,e,C,M]);const R=Y.useMemo(()=>{const D=[{id:"_name",title:"Filename",accessor:L=>L._name??"",render:(L,w)=>G.jsxs("div",{className:"classicyFileBrowserViewTableRowContainer",[ki]:L._path,...L._type===Gt.Directory&&L._path?{[Sd]:L._path}:{},onMouseDown:j=>L._path&&X(j,L._path,w.emitDrag),style:{paddingLeft:`calc(var(--window-control-size) * ${w.depth})`},children:[G.jsx("span",{className:"classicyFileBrowserViewTableDisclosure",children:w.canExpand&&G.jsx("span",{className:"classicyFileBrowserViewTableDisclosureTriangle",onClick:j=>j.stopPropagation(),onMouseDown:j=>j.stopPropagation(),children:G.jsx(Wh,{direction:"right",open:w.isExpanded,onToggle:w.toggle})})}),G.jsx("img",{src:L._icon||Ld(L._type),width:n,alt:L._path,className:"classicyFileBrowserViewTableRowIcon"}),G.jsx("span",{className:"classicyFileBrowserViewTableRowIconLabel",children:L._name})]})}];return g.modified&&D.push({id:"_modifiedOn",title:"Date Modified",accessor:L=>Di(L._modifiedOn)?.getTime()??0,render:L=>G.jsx("span",{children:dY(Di(L._modifiedOn),V,I)})}),g.created&&D.push({id:"_createdOn",title:"Date Created",accessor:L=>Di(L._createdOn)?.getTime()??0,render:L=>G.jsx("span",{children:dY(Di(L._createdOn),V,I)})}),g.size&&D.push({id:"_size",title:"Size",accessor:L=>L._size,render:L=>G.jsx("span",{children:L._size===void 0?M?"Calculating\u2026":"\u2014":L._size===-1?"\u2014":e.formatSize(L._size)})}),g.kind&&D.push({id:"_type",title:"Kind",accessor:L=>L._type,render:L=>G.jsx("span",{children:TL(L._type)})}),g.label&&D.push({id:"_label",title:"Label",accessor:L=>L._label??"",render:L=>G.jsx("span",{children:L._label??"\u2014"})}),g.comments&&D.push({id:"_comments",title:"Comments",accessor:L=>L._comments??"",render:L=>G.jsx("span",{children:L._comments??"\u2014"})}),g.version&&D.push({id:"_version",title:"Version",accessor:L=>L._version??"",render:L=>G.jsx("span",{children:L._version??"\u2014"})}),D},[e,n,g,V,I,M,X]);return G.jsx(FL,{className:$("classicyFileBrowserViewTableContainer",h),style:p,columns:R,rows:J,getRowId:D=>D._path??"",getSubRows:D=>D.subRows,rowCanExpand:D=>D._type===Gt.Directory,expanded:z,onToggleRow:(D,L)=>x(w=>L?[...w,D]:w.filter(j=>j!==D)),defaultSort:{columnId:"_name"},onActivateRow:(D,L)=>S(L,L._path??""),rowClassName:()=>"classicyFileBrowserViewTableRow",selectionMode:"multi",selectionApiRef:u,selected:d,onSelectionChange:y,containerRef:Z},`${l}_filebrowser_${t}`)});pY.displayName="ClassicyFileBrowserViewTable";const DL=()=>{},kL=()=>{},jL=({fs:e,display:t="icons",path:n,appId:l,dirOnClickFunc:s,fileOnClickFunc:i,hideFilesCreatedAfter:c=null,showInvisible:a=!0,listViewOptions:o,iconViewOptions:r,now:u,selectionApiRef:d,selectedPaths:m,onSelectionChange:Z,focusTargetRef:b,onMoveItems:h,onDeleteItems:p,itemContextMenu:W,commandsRef:y,className:N,style:X})=>{const g=Y.useRef(null),M=Y.useRef(null),{showContextMenu:I}=Na(),A=Y.useRef(m??[]),V=Y.useCallback(J=>{A.current=J,Z?.(J)},[Z]),z=Y.useCallback(()=>t==="list"?A.current:Array.from(M.current?.querySelectorAll(`.classicyIcon.selected[${ki}]`)??[],J=>J.getAttribute(ki)??"").filter(Boolean),[t]);Y.useImperativeHandle(y,()=>({selectedPaths:z}),[z]);const x=J=>{if(!p||J.defaultPrevented||J.key!=="Backspace"&&J.key!=="Delete"||J.altKey||J.shiftKey||J.target.closest("input, textarea, [contenteditable='true']"))return;const D=z();D.length!==0&&(J.preventDefault(),p(D))},S=J=>{if(!W||J.defaultPrevented)return;const R=J.target.closest(`[${ki}]`),D=R?.getAttribute(ki);if(!R||!D||!M.current?.contains(R))return;const L=W(D,z());!L||L.length===0||(J.preventDefault(),I(L,[J.clientX,J.clientY]))},C=ut(J=>J.System.Manager.Appearance.activeTheme.desktop.iconSize),[k,v]=Y.useState(()=>qe("--desktop-icon-size",C));return Y.useLayoutEffect(()=>{v(qe("--desktop-icon-size",C))},[C]),G.jsx("div",{ref:M,className:$("classicyFileBrowserFill",N),style:X,[Sd]:n,onKeyDown:x,onContextMenu:S,children:t==="list"?G.jsx(pY,{onMoveItems:h,fileOnClickFunc:i??kL,dirOnClickFunc:s??DL,fs:e,path:n,appId:l,iconSize:o?NL(k,o.iconSize):18,holderRef:g,hideFilesCreatedAfter:c,showInvisible:a,listViewOptions:o,now:u,selectionApiRef:d,selectedPaths:m,onSelectionChange:V,focusTargetRef:b}):G.jsx(hY,{onMoveItems:h,fileOnClickFunc:i??kL,dirOnClickFunc:s??DL,fs:e,path:n,appId:l,holderRef:g,hideFilesCreatedAfter:c,showInvisible:a,iconViewOptions:r})})},hn="Trash",WY={_trashed:void 0,_trashedFrom:void 0,_trashedName:void 0,_trashedLocation:void 0},vL=(e,t)=>t.split(e.separator).pop()??t,JL=(e,t)=>t.split(e.separator).slice(0,-1).join(e.separator),Jh=(e,t)=>t===hn||t.startsWith(`${hn}${e.separator}`),Bu=(e,t)=>t!==hn&&JL(e,t)===hn;function GY(e){return e.resolve(hn)||(e.mkDir(hn),e.setMetadata(hn,{_icon:tn("systemArt","trashEmpty")??"",_system:!0,_nameLocked:!0,_invisible:!0})),hn}function Oh(e){const t=e.resolve(hn);return t?Object.keys(t).filter(n=>!n.startsWith("_")).map(n=>`${hn}${e.separator}${n}`):[]}const _st=(e,t)=>{const n=e.resolve(hn)??{};if(!Object.hasOwn(n,t))return t;const l=t.lastIndexOf("."),[s,i]=l>0?[t.slice(0,l),t.slice(l)]:[t,""];for(let c=2;;c++){const a=`${s} ${c}${i}`;if(!Object.hasOwn(n,a))return a}};function OL(e,t,n={}){GY(e);const l={moves:[]};for(const s of t){if(Jh(e,s))continue;const i=vL(e,s),c=_st(e,i),a=n[s],o=e.move(s,hn,{name:c,metadata:{_trashed:!0,_trashedFrom:JL(e,s),...c===i?{}:{_trashedName:i},...a?{_trashedLocation:a}:{}}});o.ok?l.moves.push({from:s,to:o.path}):l.refusal||(l.refusal={reason:o.reason,name:i})}return l}function EL(e,t){const n={moves:[]};for(const l of t){if(!Bu(e,l))continue;const s=e.resolve(l);if(!s)continue;const i=s._trashedName??vL(e,l),c=s._trashedFrom;if(typeof c!="string"||!e.resolve(c)){n.refusal??={reason:"no-origin",name:i};continue}const a=e.move(l,c,{name:i,metadata:WY});a.ok?n.moves.push({from:l,to:a.path}):n.refusal||(n.refusal={reason:a.reason,name:i})}return n}function UL(e){const t=Oh(e);for(const n of t)e.rmDir(n);return t.length}const BL="Desktop Folder",Eh="classicy-desktop-item:",PL=e=>Object.keys(e.filterByType("",Gt.Drive))[0],Uh=e=>{const t=PL(e);return t?`${t}${e.separator}${BL}`:void 0},HL=e=>{const t=Uh(e);if(t)return e.resolve(t)||(e.mkDir(t),e.setMetadata(t,{_invisible:!0})),t},Bh=(e,t,n)=>{const l=e.resolve(t);if(!l)return;const s=t.split(e.separator).pop()??t,i=l._type===Gt.Directory;return{type:"ClassicyDesktopIconAdd",app:{id:`${Eh}${t}`,name:s,icon:l._icon??Ld(l._type)},kind:i?"directory":"file",filePath:t,noLaunch:!0,...n?{location:n}:{}}},$st=(e,t,n)=>{switch(e){case"exists":return`An item named \u201C${t}\u201D already exists in \u201C${n}\u201D. It was not moved.`;case"into-itself":return`\u201C${t}\u201D can\u2019t be moved into itself.`;case"locked":return`\u201C${t}\u201D can\u2019t be moved, because it or \u201C${n}\u201D is locked or used by the system software.`;default:return`\u201C${t}\u201D could not be moved.`}},KL=e=>{const n=(typeof document<"u"?document.getElementById("classicyDesktop"):null)?.getBoundingClientRect();return[Math.round(e[0]-(n?.left??0)),Math.round(e[1]-(n?.top??0))]};function yY(e,t,n,l,{desktopLocation:s,desktopStep:i=72}={}){if(n.kind==="folder"&&n.path===hn)return Ph(e,t,l);const c=n.kind==="desktop"?HL(e):n.path;if(!c)return[];const a=[];let o=null;for(const r of t){if(r===c)continue;const u=e.move(r,c,Bu(e,r)?{metadata:WY}:{});u.ok?a.push({from:r,to:u.path}):u.reason!=="same-folder"&&!o&&(o={reason:u.reason,name:r.split(e.separator).pop()??r})}if(a.length>0&&(l({type:"ClassicyAppFinderPathsMoved",moves:a}),n.kind==="desktop"&&a.forEach(({to:r},u)=>{const d=s?[s[0],s[1]+u*i]:void 0,m=Bh(e,r,d);m&&l(m)})),o){const r=n.kind==="desktop"?"the desktop":c.split(e.separator).pop()??c;l({type:"ClassicyDesktopShowErrorDialog",message:$st(o.reason,o.name,r)})}return a}const tit=(e,t)=>e==="locked"?`\u201C${t}\u201D can\u2019t be moved to the Trash, because it is locked or used by the system software.`:`\u201C${t}\u201D could not be moved to the Trash.`,eit=e=>{const t=new Set(e),n={};for(const l of ut.getState().System.Manager.Desktop.icons)l.filePath&&t.has(l.filePath)&&l.location&&(n[l.filePath]=l.location);return n};function Ph(e,t,n){const{moves:l,refusal:s}=OL(e,t,eit(t));return l.length>0&&n({type:"ClassicyAppFinderPathsMoved",moves:l}),s&&n({type:"ClassicyDesktopShowErrorDialog",message:tit(s.reason,s.name)}),l}const nit=(e,t)=>{switch(e){case"no-origin":return`\u201C${t}\u201D can\u2019t be restored, because the folder it came from no longer exists. Drag it out of the Trash instead.`;case"exists":return`\u201C${t}\u201D can\u2019t be restored, because an item with that name is already where it came from.`;default:return`\u201C${t}\u201D could not be restored.`}};function QL(e,t,n){const l=Object.fromEntries(t.map(c=>[c,e.resolve(c)?._trashedLocation])),{moves:s,refusal:i}=EL(e,t);if(s.length>0){n({type:"ClassicyAppFinderPathsMoved",moves:s});const c=Uh(e);for(const{from:a,to:o}of s){const r=l[a];if(!c||o.split(e.separator).slice(0,-1).join(e.separator)!==c)continue;const u=Bh(e,o,Array.isArray(r)?r:void 0);u&&n(u)}}return i&&n({type:"ClassicyDesktopShowErrorDialog",message:nit(i.reason,i.name)}),s}const lit=({appId:e,op:t,dir:n,idx:l,closeFolder:s,closeAllFolders:i,closeWindow:c,setFolderView:a,openFolder:o,openFile:r,getHeaderString:u,fs:d,disableBalloonHelp:m,toggleBalloonHelp:Z,aboutMenuItem:b,openPreferences:h,viewType:p,iconViewOptions:W,listViewOptions:y,now:N,onMoveItems:X,trashItems:g,restoreItems:M,itemContextMenu:I})=>{const A=Ut(),V=Y.useRef(null),z=Jh(d,t),x=Y.useRef(null),S=Y.useRef(null),C=ut(J=>!!zn(J.System.Manager.Applications.apps[e],t)?.focused),k=Y.useRef(p);Y.useEffect(()=>{if(k.current===p||(k.current=p,!C))return;const J=S.current;if(!J)return;const R=document.activeElement;R&&J.closest(".classicyWindow")?.contains(R)||J.focus({preventScroll:!0})},[p,C]);const v=Y.useMemo(()=>[{id:`${e}_${t}_file`,title:"File",menuChildren:[ts(`${e}_${t}_file_closew`,()=>c(t,{type:"ClassicyAppFinderCloseFolder",path:t})),ud(`${e}_${t}_file_closews`,i),{id:"spacer"},{id:`${e}_${t}_file_move_to_trash`,title:"Move To Trash",keyboardShortcut:"\u2303\u232B",disabled:z,onClickFunc:()=>g(V.current?.selectedPaths()??[])},...t===hn?[{id:`${e}_${t}_file_restore`,title:"Restore",onClickFunc:()=>M(V.current?.selectedPaths()??[])}]:[]]},{id:`${e}_${t}_edit`,title:"Edit",menuChildren:[{id:`${e}_${t}_edit_select_all`,title:"Select All",keyboardShortcut:"\u2318A",disabled:p!=="list",onClickFunc:()=>x.current?.selectAll()},{id:"spacer"},{id:`${e}_${t}_edit_preferences`,title:"Preferences\u2026",onClickFunc:h}]},{id:`${e}_view`,title:"View",menuChildren:[{id:`${e}_${t}_view_as_icons`,title:"View as Icons",onClickFunc:()=>a(t,"icons")},{id:`${e}_${t}_view_as_list`,title:"View as List",onClickFunc:()=>a(t,"list")}]},{id:`${e}_${t}_special`,title:"Special",menuChildren:aY(A,`${e}_${t}`)},{id:`${e}_${t}_help`,title:"Help",menuChildren:[{id:`${e}_${t}_help_balloon`,title:m?"Show Balloon Help":"Hide Balloon Help",onClickFunc:Z},b]}],[e,t,c,i,a,m,Z,b,h,p,z,g,M,A]);return G.jsx(ge,{id:t,title:n._name,icon:n._icon,appId:e,defaultWindow:!1,hidden:!1,initialSize:[425,300],initialPosition:[50+l*50,50+l*50],header:G.jsx("span",{children:u(n)}),onCloseFunc:s,appMenu:v,initialFocusRef:S,children:G.jsx(jL,{appId:e,fs:d,path:t,dirOnClickFunc:o,fileOnClickFunc:r,display:p,iconViewOptions:W,listViewOptions:y,now:N,selectionApiRef:x,focusTargetRef:S,onMoveItems:X,showInvisible:!1,onDeleteItems:z?void 0:g,itemContextMenu:I,commandsRef:V})})},sit=Y.memo(lit),iit=({path:e,fs:t,...n})=>{const l=WL(e,t),s=t.statDirShell(e);return s?G.jsx(sit,{...n,fs:t,op:e,dir:{...s,_size:l}}):null},cit=Y.memo(iit),qL=()=>{const e=jt("icons","system.macos")??"",t=jt("icons","system.mac")??"",n="Finder",l="Finder.app",s=Ut(),i=ut(R=>R.System.Manager.Applications.apps[l]),c=iY(i?.data??{})?i?.data:{},a=ut(R=>R.System.Manager.Desktop.disableBalloonHelp),o=Y.useCallback(()=>{s({type:"ClassicyDesktopSetBalloonHelp",disableBalloonHelp:!a})},[s,a]),r=ut(R=>R.System.Manager.DateAndTime),u=Y.useMemo(()=>xd(r.dateTime,parseInt(r.timeZoneOffset,10)),[r.dateTime,r.timeZoneOffset]),d=pd(),m=Al(l),{aboutMenuItem:Z,aboutWindow:b}=ul(l,n,t),h=Y.useRef(null);Y.useEffect(()=>{const R=i.data??{},D=iY(R)?R:{};if(!D.openPaths)return;const L=D.openPaths,w=h.current;w&&w.length===L.length&&w.every((j,B)=>j===L[B])||(h.current=L,s({type:"ClassicyAppFinderOpenFolders",paths:L}))},[s,i.data]);const p=Y.useCallback((R,D)=>{s({type:"ClassicyAppFinderSetFolderView",path:R,viewType:D})},[s]),W=i.windows,y=Y.useCallback(R=>{s({type:"ClassicyAppFinderOpenFolder",path:R});const D=zn({windows:W},R);D&&(s({type:"ClassicyWindowOpen",app:{id:l},window:D}),s({type:"ClassicyWindowFocus",app:{id:l},window:D}))},[s,W]),N=Y.useCallback(R=>{const D=d.resolve(R);s({type:"ClassicyAppFinderOpenFile",file:D,path:R})},[d,s]),X=Y.useCallback(R=>{s({type:"ClassicyAppFinderCloseFolder",path:R})},[s]),g=Y.useCallback(()=>{(c.openPaths??[]).forEach(D=>{m(D,{type:"ClassicyAppFinderCloseFolder",path:D})})},[m,c.openPaths]),M=Y.useCallback(()=>{s({type:"ClassicyAppFinderPreferencesOpen"})},[s]),I=JSON.stringify(Object.entries(d.filterByType("","drive")).map(([R,D])=>[R,D._icon]));Y.useEffect(()=>{const R=JSON.parse(I),D=[];return R.forEach(([L,w])=>{ut.getState().System.Manager.Desktop.icons.some(B=>B.appId===l&&B.appName===L)||D.push(L),s({type:"ClassicyDesktopIconAdd",app:{id:l,name:L,icon:w},event:"ClassicyAppFinderOpenFolder",eventData:{path:L},kind:"drive",filePath:L,contextMenu:w3(L,fu())})}),()=>{D.forEach(L=>{s({type:"ClassicyDesktopIconRemove",app:{id:l,name:L}})})}},[I,s]);const A=Y.useCallback((R,D,L)=>{yY(d,R,D,s,{desktopLocation:KL(L)})},[d,s]);Y.useEffect(()=>{GY(d)},[d]);const V=Oh(d).length>0,z=jt("systemArt","trashFull")??"",x=jt("systemArt","trashEmpty")??"";Y.useEffect(()=>{s({type:"ClassicyDesktopIconAdd",app:{id:"Trash",name:"Trash",icon:V?z:x},kind:"trash",filePath:hn,noLaunch:!0,event:"ClassicyAppFinderOpenFolder",eventData:{path:hn},contextMenu:[{id:"finder_trash_open",title:"Open",onClickFunc:()=>s({type:"ClassicyAppFinderOpenFolder",path:hn})},{id:"finder_trash_empty",title:"Empty Trash\u2026",onClickFunc:()=>s({type:"ClassicyDesktopShowSystemDialog",dialog:"emptyTrash"})}]})},[V,z,x,s]);const S=Y.useCallback(R=>{const D=R.filter(L=>d.resolve(L));D.length>0&&Ph(d,D,s)},[d,s]),C=Y.useCallback(R=>{const D=R.filter(L=>Bu(d,L));D.length>0&&QL(d,D,s)},[d,s]),k=Y.useCallback((R,D)=>{const L=D.includes(R)?D:[R];if(Bu(d,R))return[{id:"finder_item_restore",title:"Restore",onClickFunc:()=>C(L)}];if(!Jh(d,R))return[{id:"finder_item_move_to_trash",title:"Move To Trash",onClickFunc:()=>S(L)}]},[d,C,S]);Y.useEffect(()=>{const R=Uh(d),D=R?d.filterByType(R,void 0,!1):{},L=new Set(Object.keys(D).map(w=>`${R}${d.separator}${w}`));for(const w of L){const j=Bh(d,w);j&&s(j)}for(const w of ut.getState().System.Manager.Desktop.icons)w.appId.startsWith(Eh)&&!L.has(w.appId.slice(Eh.length))&&s({type:"ClassicyDesktopIconRemove",app:{id:w.appId}})},[d,s]);const v=Y.useCallback(R=>{const D=R._size===void 0?"Calculating\u2026":R._size===-1?"\u2014":d.formatSize(R._size);return R._count+" items"+(R._countHidden?` (${R._countHidden} hidden)`:"")+", "+D},[d]),J=Y.useMemo(()=>Fh(c),[c]);return G.jsxs(vn,{id:l,name:n,icon:e,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,D)=>G.jsx(cit,{path:R,appId:l,idx:D,closeFolder:X,closeAllFolders:g,closeWindow:m,setFolderView:p,openFolder:y,openFile:N,getHeaderString:v,fs:d,disableBalloonHelp:a,toggleBalloonHelp:o,aboutMenuItem:Z,openPreferences:M,viewType:c.folderViews?.[R]??"list",iconViewOptions:J.icons,listViewOptions:J.list,now:u,onMoveItems:A,trashItems:S,restoreItems:C,itemContextMenu:k},`${n}_${R}`)):null,b,i.data?.showAboutThisComputer?G.jsx(ZL,{}):null,c.showPreferences?G.jsx(pL,{}):null]})},_L="ClassicyAppHCEdit",$L=100;function hl(e,t){const n=ae.isDraft(e.draft)?ae.current(e.draft):e.draft,l=ae.produce(n,t);l!==n&&(e.undo.push(n),e.undo.length>$L&&e.undo.shift(),e.redo=[],e.draft=l,e.dirty=!0)}function Ca(e,t,n){const l=e.cards.find(i=>i.id===t);if(!l)return;if(n==="card")return l.parts??=[],l.parts;if(!l.background)return;const s=e.backgrounds?.find(i=>i.id===l.background);if(s)return s.parts??=[],s.parts}function Pu(e,t,n){const l=e.cards.find(s=>s.id===t);if(l){if(n==="card")return l.parts;if(l.background)return e.backgrounds?.find(s=>s.id===l.background)?.parts}}function NY(e,t){const n=new Set;for(const s of e.cards)for(const i of s.parts??[])n.add(i.id);for(const s of e.backgrounds??[])for(const i of s.parts??[])n.add(i.id);let l=1;for(;n.has(`${t}${l}`);)l++;return`${t}${l}`}function tS(e){const t=new Set(e.cards.map(l=>l.id));let n=1;for(;t.has(`card${n}`);)n++;return`card${n}`}const YY=[{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 eS(e){return YY.find(t=>t.type===e)}const XY="application/x-hypercard-part-type",ait=["nw","n","ne","e","se","s","sw","w"];function gY(e,t){return Pu(e.draft,e.currentCardId,e.layer)?.find(l=>l.id===t)?.rect??[0,0,120,60]}function MY(e){const[t,n,l,s]=e.startRect;if(!e.handle)return[t+e.dx,n+e.dy,l,s];let[i,c,a,o]=[t,n,l,s];return e.handle.includes("w")&&(i=t+e.dx,a=l-e.dx),e.handle.includes("e")&&(a=l+e.dx),e.handle.includes("n")&&(c=n+e.dy,o=s-e.dy),e.handle.includes("s")&&(o=s+e.dy),[i,c,a,o]}const nS=({stackId:e,edit:t,className:n,style:l})=>{const s=Ut(),[i,c]=Y.useState(),a=Pu(t.draft,t.currentCardId,t.layer)??[],o=t.selectedPartId,r=(N,X)=>s({type:"ClassicyAppHCEditSetRect",stackId:e,partId:N,rect:X}),u=(N,X,g)=>{N.stopPropagation();try{N.currentTarget.setPointerCapture?.(N.pointerId)}catch{}g||s({type:"ClassicyAppHCEditSelect",stackId:e,partId:X}),c({partId:X,handle:g,startX:N.clientX,startY:N.clientY,startRect:gY(t,X),dx:0,dy:0})},d=N=>{i&&c({...i,dx:N.clientX-i.startX,dy:N.clientY-i.startY})},m=()=>{i&&((i.dx!==0||i.dy!==0)&&r(i.partId,MY(i)),c(void 0))};Rb(i!==void 0,m);const Z=(N,X)=>{const g=X.getBoundingClientRect();return[Math.round(N.clientX-g.left),Math.round(N.clientY-g.top)]},b=N=>{if(N.target===N.currentTarget){if(t.placing){const X=Z(N,N.currentTarget);s({type:"ClassicyAppHCEditAddPart",stackId:e,partType:t.placing,at:X});return}s({type:"ClassicyAppHCEditSelect",stackId:e,partId:void 0})}},h=N=>{const X=N.dataTransfer?.getData(XY);if(!X)return;N.preventDefault();const g=Z(N,N.currentTarget);s({type:"ClassicyAppHCEditAddPart",stackId:e,partType:X,at:g})},p=N=>{const X=N.metaKey||N.ctrlKey,g=N.key.toLowerCase();if(X&&g==="z"){N.preventDefault(),s({type:N.shiftKey?"ClassicyAppHCEditRedo":"ClassicyAppHCEditUndo",stackId:e});return}if(X&&g==="v"){s({type:"ClassicyAppHCEditPastePart",stackId:e});return}if(!o)return;if(X&&g==="c"){s({type:"ClassicyAppHCEditCopyPart",stackId:e,partId:o});return}if(N.key==="Delete"||N.key==="Backspace"){N.preventDefault(),s({type:"ClassicyAppHCEditDeletePart",stackId:e,partId:o});return}if(N.key==="Escape"){s({type:"ClassicyAppHCEditSelect",stackId:e,partId:void 0});return}const M=N.shiftKey?8:1,A={ArrowLeft:[-M,0],ArrowRight:[M,0],ArrowUp:[0,-M],ArrowDown:[0,M]}[N.key];if(!A)return;N.preventDefault();const[V,z,x,S]=gY(t,o);r(o,[V+A[0],z+A[1],x,S])},W=N=>{const X=gY(t,N);return i&&i.partId===N&&(i.dx!==0||i.dy!==0)?MY(i):X},y=([N,X,g,M])=>({left:N,top:X,width:g,height:M});return G.jsxs("div",{className:$("classicyHyperCardEditorOverlay",n),style:l,tabIndex:0,onPointerDown:b,onPointerMove:d,onPointerUp:m,onKeyDown:p,onDragOver:N=>N.preventDefault(),onDrop:h,children:[a.map(N=>G.jsx("div",{className:"classicyHyperCardEditorHit","data-part-id":N.id,style:y(W(N.id)),onPointerDown:X=>u(X,N.id),onPointerMove:d,onPointerUp:m},N.id)),o&&a.some(N=>N.id===o)?G.jsx("div",{className:"classicyHyperCardEditorSelection",style:y(W(o)),children:ait.map(N=>G.jsx("div",{className:"classicyHyperCardEditorHandle","data-handle":N,onPointerDown:X=>u(X,o,N),onPointerMove:d,onPointerUp:m},N))}):null]})},oit=/^(<=|>=|<>|==|!=|≠|&&|=|<|>|&|\+|-|\*|\/|\(|\))/;function dit(e){const t=[];let n=0;for(;n<e.length;){const l=e[n];if(l===" "||l===" "||l===`
|
|
73
73
|
`||l==="\r"){n++;continue}if(l==='"'){let c=n+1,a="";for(;c<e.length&&e[c]!=='"';)a+=e[c],c++;t.push({t:"str",v:a}),n=c+1;continue}if(/[0-9]/.test(l)||l==="."&&/[0-9]/.test(e[n+1]??"")){const c=e.slice(n).match(/^[0-9]*\.?[0-9]+/);if(c){t.push({t:"num",v:parseFloat(c[0])}),n+=c[0].length;continue}}const s=e.slice(n).match(oit);if(s){t.push({t:"op",v:s[0]}),n+=s[0].length;continue}const i=e.slice(n).match(/^[A-Za-z_][A-Za-z0-9_.]*/);if(i){t.push({t:"word",v:i[0]}),n+=i[0].length;continue}n++}return t.push({t:"eof"}),t}const rit=new Set(["and","or","not","is","mod"]);class uit{constructor(t,n){this.toks=t,this.ctx=n}toks;ctx;pos=0;peek(){return this.toks[this.pos]}next(){return this.toks[this.pos++]}isWord(t){const n=this.peek();return n.t==="word"&&n.v.toLowerCase()===t}isOp(t){const n=this.peek();return n.t==="op"&&n.v===t}parse(){const t=this.parseOr();if(this.peek().t!=="eof")throw new Error("Unexpected trailing tokens");return t}parseOr(){let t=this.parseAnd();for(;this.isWord("or");){this.next();const n=this.parseAnd();t=fa(t)||fa(n)}return t}parseAnd(){let t=this.parseNot();for(;this.isWord("and");){this.next();const n=this.parseNot();t=fa(t)&&fa(n)}return t}parseNot(){return this.isWord("not")?(this.next(),!fa(this.parseNot())):this.parseComparison()}parseComparison(){let t=this.parseConcat();for(;;){const n=this.peek();let l;if(n.t==="op"&&["=","==","<>","!=","\u2260","<",">","<=",">="].includes(n.v)?l=n.v:n.t==="word"&&n.v.toLowerCase()==="is"&&(l="="),!l)break;this.next();const s=this.parseConcat();t=mit(l,t,s)}return t}parseConcat(){let t=this.parseAdd();for(;this.isOp("&")||this.isOp("&&");){this.next();const n=this.parseAdd();t=Cd(t)+Cd(n)}return t}parseAdd(){let t=this.parseMul();for(;;)if(this.isOp("+"))this.next(),t=_n(t)+_n(this.parseMul());else if(this.isOp("-"))this.next(),t=_n(t)-_n(this.parseMul());else break;return t}parseMul(){let t=this.parseUnary();for(;;)if(this.isOp("*"))this.next(),t=_n(t)*_n(this.parseUnary());else if(this.isOp("/"))this.next(),t=_n(t)/_n(this.parseUnary());else if(this.isWord("mod"))this.next(),t=_n(t)%_n(this.parseUnary());else break;return t}parseUnary(){return this.isOp("-")?(this.next(),-_n(this.parseUnary())):this.parsePrimary()}parsePrimary(){const t=this.next();if(t.t==="num"||t.t==="str")return t.v;if(t.t==="op"&&t.v==="("){const n=this.parseOr();if(!this.isOp(")"))throw new Error("Expected )");return this.next(),n}if(t.t==="word"){const n=t.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 s=this.next(),i=s.t==="str"||s.t==="word"?String(s.v):"";return this.ctx.getField(i)??""}if(rit.has(n))throw new Error(`Unexpected operator word "${t.v}"`);const l=this.ctx.getVar(t.v);return l!==void 0?l:t.v}throw new Error("Unexpected token in expression")}}function _n(e){if(typeof e=="number")return e;if(typeof e=="boolean")return e?1:0;const t=parseFloat(e);return Number.isNaN(t)?0:t}function Cd(e){return typeof e=="string"?e:typeof e=="boolean"?e?"true":"false":String(e)}function fa(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;const t=e.toLowerCase().trim();if(t==="true")return!0;if(t==="false"||t==="")return!1;const n=parseFloat(t);return!Number.isNaN(n)&&n!==0}function lS(e){return typeof e=="number"?!0:typeof e=="boolean"?!1:e.trim()!==""&&!Number.isNaN(Number(e))}function mit(e,t,n){const l=lS(t)&&lS(n),s=l?_n(t):Cd(t),i=l?_n(n):Cd(n);switch(e){case"=":case"==":return s===i;case"<>":case"!=":case"\u2260":return s!==i;case"<":return s<i;case">":return s>i;case"<=":return s<=i;case">=":return s>=i}return!1}const TY=_n,Ra=Cd,sS=fa;function $s(e,t){try{return new uit(dit(e),t).parse()}catch{return e}}function iS(e,t){return Cd($s(e,t))}function Hu(e,t){return _n($s(e,t))}function IY(e,t){return fa($s(e,t))}const cS=new Map,aS=new Map,oS=new Map,dS=new Map,rS=new Map;function Zit(e,t){cS.set(e,t)}function uS(e){return cS.get(e)}function bit(e,t){aS.set(e,t)}function mS(e){return aS.get(e)}function hit(e,t){oS.set(e,t)}function ZS(e){return oS.get(e)}function pit(e,t){dS.set(e,t)}function bS(e){return dS.get(e)}function Wit(e,t,n){rS.set(e,{id:e,name:t,stack:n})}function hS(){return Array.from(rS.values())}const VY=new Map,AY=new Map;function Git(e,t){VY.set(e,t)}function wY(e){return VY.get(e)}function pS(){return Array.from(VY,([e,t])=>({type:e,meta:t}))}function yit(e,t){AY.set(e,t)}function WS(e){return AY.get(e)}function GS(){return Array.from(AY,([e,t])=>({name:e,meta:t}))}const yS=new Map;function NS(e){yS.set(e.id,e)}function xY(){return Array.from(yS.values())}const ls={id:"HyperCard.app",name:"HyperCard",get icon(){return tn("icons","system.files.application")??""}},YS="ClassicyAppHyperCard",XS=jn({activeStackId:Xt().optional().describe("Stack id of the frontmost stack window."),openStacks:Tl(Xt(),jn({})).optional().describe("Runtime state of every open stack, keyed by stack id."),openFiles:xn(Xt()).optional().describe("Paths of .stack documents awaiting load."),edits:Tl(Xt(),jn({})).optional().describe("Editor state per stack id, present while Edit mode is active.")});function Ku(){return{frames:[],status:"idle",steps:0,seq:0,pendingEffects:[],navDepth:0}}function zY(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.openStacks!="object"||t.openStacks===null?!1:Object.values(t.openStacks).every(n=>typeof n=="object"&&n!==null&&typeof n.currentCardId=="string"&&typeof n.stack=="object")}function Qu(e,t,n){return e.shared&&n?`bg:${n}:${e.id}`:`card:${t}:${e.id}`}function gS(e,t){return e.cards.findIndex(n=>n.id===t)}function Ts(e,t){return e.cards.find(n=>n.id===t)}function Hh(e,t){if(t.background)return e.backgrounds?.find(n=>n.id===t.background)}function MS(e,t,n){const l=gS(e,t),s=e.cards.length;switch(n.trim().toLowerCase()){case"next":return e.cards[(l+1+s)%s]?.id;case"prev":case"previous":return e.cards[(l-1+s)%s]?.id;case"first":return e.cards[0]?.id;case"last":return e.cards[s-1]?.id;case"back":return}const i=Ts(e,n);return i?i.id:e.cards.find(a=>a.name===n)?.id}function LY(e,t){const n=Hh(e,t),l=(n?.parts??[]).map(i=>({part:i,backgroundId:n?.id})),s=(t.parts??[]).map(i=>({part:i}));return[...l,...s]}function qu(e,t,n){return LY(e,t).find(l=>l.part.id===n)}const TS=1e5,IS=64,VS=1e5,Nit=200;function _u(e){return{getVar:t=>e.variables[t],getField:t=>SY(e,t)}}function SY(e,t){const n=Ts(e.stack,e.currentCardId);if(!n)return;const l=qu(e.stack,n,t);if(!l)return;const s=Qu(l.part,e.currentCardId,l.backgroundId);return e.fieldValues[s]??l.part.content??""}function CY(e,t,n){const l=Ts(e.stack,e.currentCardId);if(!l)return;const s=qu(e.stack,l,t);if(!s)return;const i=Qu(s.part,e.currentCardId,s.backgroundId);e.fieldValues[i]=n,e.fieldRev[i]=(e.fieldRev[i]??0)+1}function Fa(e,t,n){t.var?e.variables[t.var]=typeof n=="number"?n:Ra(n):t.field&&CY(e,t.field,Ra(n))}function Kh(e,t){return t.var?TY(e.variables[t.var]??0):t.field?TY(SY(e,t.field)??0):0}function fd(e,t){return e?.[t]??[]}function Yit(e,t){const n=Ts(e.stack,t);if(!n)return[];const l=Hh(e.stack,n);return[...fd(l?.script,"onOpenBackground"),...fd(l?.script,"onOpenCard"),...fd(n.script,"onOpenCard")]}function Xit(e,t){const n=Ts(e.stack,t);if(!n)return[];const l=Hh(e.stack,n);return[...fd(n.script,"onCloseCard"),...fd(l?.script,"onCloseCard")]}function $u(e){return`t${e.seq++}`}function tm(e,t){e.frames.push({kind:"seq",body:t,ip:0})}function git(e,t){const n=e.runtime,l=_u(e);switch(t.do){case"go":{const s=Tit(e,t.to);if(!s)break;const i=n.pendingVisual;n.pendingVisual=void 0;const c=[{do:"@closeCard"},{do:"@switchCard",to:s.toCardId,back:s.back},...i?[{do:"@transition",effect:i}]:[],{do:"@openCard"}];tm(n,c);break}case"put":Fa(e,t,$s(t.value,l));break;case"add":Fa(e,t,Kh(e,t)+Hu(t.value,l));break;case"subtract":Fa(e,t,Kh(e,t)-Hu(t.value,l));break;case"multiply":Fa(e,t,Kh(e,t)*Hu(t.value,l));break;case"divide":Fa(e,t,Kh(e,t)/Hu(t.value,l));break;case"set":{const s=t.property.toLowerCase(),i=$s(t.value,l);s==="visible"||s==="visibility"?t.part&&(e.partVisibility[t.part]=sS(i)):(s==="text"||s==="content")&&t.part&&CY(e,t.part,Ra(i));break}case"show":e.partVisibility[t.part]=!0;break;case"hide":e.partVisibility[t.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:t.sound});break;case"openApp":n.pendingEffects.push({id:n.seq++,kind:"openApp",appId:t.app,event:t.event,data:t.data});break;case"answer":{const s=$u(n);n.dialog={kind:"answer",message:Ra($s(t.message,l)),buttons:t.buttons??["OK"],token:s},n.status="awaitingDialog",n.resume={token:s,container:AS(t)};break}case"ask":{const s=$u(n);n.dialog={kind:"ask",message:Ra($s(t.prompt,l)),defaultValue:t.default?Ra($s(t.default,l)):"",token:s},n.status="awaitingDialog",n.resume={token:s,container:AS(t)};break}case"visual":n.pendingVisual=t.effect;break;case"wait":{const s=$u(n);n.wait={ms:Math.max(0,t.ms),token:s},n.status="awaitingWait",n.resume={token:s};break}case"if":{const s=IY(t.condition,l)?t.then:t.else??[];tm(n,s);break}case"repeat":{const s=t.while!==void 0?Number.POSITIVE_INFINITY:Math.min(t.times??0,VS);n.frames.push({kind:"repeat",body:t.body,ip:0,remaining:s,while:t.while});break}case"@closeCard":tm(n,Xit(e,e.currentCardId));break;case"@switchCard":Iit(e,t.to,t.back);break;case"@transition":{const s=$u(n);n.transition={effect:t.effect,toCardId:e.currentCardId,token:s},n.status="awaitingTransition",n.resume={token:s};break}case"@openCard":tm(n,Yit(e,e.currentCardId));break;default:{const s=t,i=mS(s.do);i?i.run(Mit(e),s):Wt("warn","HyperCard",`Unknown command "${s.do}"`);break}}}function Mit(e){const t=e.runtime;return{getVar:n=>e.variables[n],setVar:(n,l)=>{e.variables[n]=l},getField:n=>SY(e,n),setField:(n,l)=>CY(e,n,l),evaluate:n=>$s(n,_u(e)),show:(n,l)=>{e.partVisibility[n]=l},go:n=>tm(t,[{do:"go",to:n}]),queueEffect:(n,l)=>{t.pendingEffects.push({id:t.seq++,kind:"custom",name:n,args:l??{}})},await:(n,l,s)=>{const i=$u(t);t.pendingEffects.push({id:t.seq++,kind:"custom",name:n,args:l??{},token:i}),t.status="awaitingCustom",t.resume={token:i,container:s}}}}function AS(e){if(e.var)return{var:e.var};if(e.field)return{field:e.field}}function Tit(e,t){if(t.trim().toLowerCase()==="back")return e.history.length===0?void 0:{toCardId:e.history[e.history.length-1],back:!0};const n=e.stack,l=n.cards.findIndex(c=>c.id===e.currentCardId),s=n.cards.length;let i;switch(t.trim().toLowerCase()){case"next":i=n.cards[(l+1+s)%s]?.id;break;case"prev":case"previous":i=n.cards[(l-1+s)%s]?.id;break;case"first":i=n.cards[0]?.id;break;case"last":i=n.cards[s-1]?.id;break;default:i=n.cards.find(c=>c.id===t)?.id??n.cards.find(c=>c.name===t)?.id}if(i)return{toCardId:i,back:!1}}function Iit(e,t,n){const l=e.runtime;if(l.navDepth+=1,l.navDepth>IS){wS(e);return}n?e.history.pop():(e.history.push(e.currentCardId),e.history.length>Nit&&e.history.shift()),e.currentCardId=t}function Vit(e){const t=e.runtime,n=t.frames[t.frames.length-1];if(!n){t.status="idle";return}if(n.kind==="seq"){if(n.ip>=n.body.length){t.frames.pop();return}git(e,n.body[n.ip++]);return}if(n.while!==void 0){if(!IY(n.while,_u(e))){t.frames.pop();return}}else{if(n.remaining<=0){t.frames.pop();return}n.remaining-=1}t.frames.push({kind:"seq",body:n.body,ip:0})}function Rd(e){const t=e.runtime;for(;t.status==="running";){if(t.steps++>TS){wS(e);return}if(t.frames.length===0){t.status="idle",t.navDepth=0;return}Vit(e)}}function wS(e){const t=e.runtime;t.frames=[],t.status="idle",t.navDepth=0}function em(e,t){const n=e.runtime;n.status==="idle"&&(n.frames=[{kind:"seq",body:t,ip:0}],n.status="running",n.steps=0,n.navDepth=0,Rd(e))}function xS(e){const t=e.stack.stackScript?.onOpenStack??[];em(e,[...t,{do:"@openCard"}])}function zS(e,t,n){const l=Ts(e.stack,e.currentCardId);if(!l)return;const s=qu(e.stack,l,t);if(!s)return;const i=fd(s.part.script,n);i.length!==0&&em(e,i)}function LS(e,t,n){const l=e.runtime;if(l.status!=="awaitingDialog"||!l.dialog||n!==void 0&&l.resume?.token!==n)return;const s=l.resume?.container;e.variables.it=t,s&&Fa(e,s,t),l.dialog=void 0,l.resume=void 0,l.status="running",Rd(e)}function SS(e,t){const n=e.runtime;n.status==="awaitingWait"&&(t!==void 0&&n.wait?.token!==t||(n.wait=void 0,n.resume=void 0,n.status="running",Rd(e)))}function CS(e,t){const n=e.runtime;n.status==="awaitingTransition"&&(t!==void 0&&n.transition?.token!==t||(n.transition=void 0,n.resume=void 0,n.status="running",Rd(e)))}function fS(e,t,n){const l=e.runtime;if(l.status!=="awaitingCustom"||n!==void 0&&l.resume?.token!==n)return;const s=l.resume?.container;e.variables.it=t,s&&Fa(e,s,t),l.resume=void 0,l.status="running",Rd(e)}function RS(e,t){const n=new Set(t);e.runtime.pendingEffects=e.runtime.pendingEffects.filter(l=>!n.has(l.id))}const Qh=[512,342],qh=["onOpenStack","onCloseStack","onOpenCard","onCloseCard","onOpenBackground","onMouseUp","onMouseDown","onIdle"];function _h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fY(e){const t=[];if(!_h(e))return{ok:!1,errors:["Stack must be a JSON object."]};if((typeof e.name!="string"||e.name.length===0)&&t.push("Stack.name must be a non-empty string."),!Array.isArray(e.cards)||e.cards.length===0)return t.push("Stack.cards must be a non-empty array."),{ok:!1,errors:t};const n=new Set;return e.cards.forEach((l,s)=>{if(!_h(l)){t.push(`Card ${s} must be an object.`);return}typeof l.id!="string"||l.id.length===0?t.push(`Card ${s} is missing a string id.`):n.has(l.id)?t.push(`Duplicate card id "${l.id}".`):n.add(l.id),l.parts!==void 0&&FS(l.parts,`card "${String(l.id)}"`,t)}),e.backgrounds!==void 0&&(Array.isArray(e.backgrounds)?e.backgrounds.forEach((l,s)=>{if(!_h(l)||typeof l.id!="string"){t.push(`Background ${s} is missing a string id.`);return}l.parts!==void 0&&FS(l.parts,`background "${l.id}"`,t)}):t.push("Stack.backgrounds must be an array.")),t.length>0?{ok:!1,errors:t}:{ok:!0,stack:e}}function FS(e,t,n){if(!Array.isArray(e)){n.push(`Parts of ${t} must be an array.`);return}const l=new Set;e.forEach((s,i)=>{if(!_h(s)){n.push(`Part ${i} of ${t} must be an object.`);return}typeof s.id!="string"||s.id.length===0?n.push(`Part ${i} of ${t} is missing a string id.`):l.has(s.id)?n.push(`Duplicate part id "${s.id}" in ${t}.`):l.add(s.id),(typeof s.type!="string"||s.type.length===0)&&n.push(`Part "${String(s.id)}" of ${t} is missing a string type.`)})}const Ait={small:"classicyTextEditorSizeSmall",medium:"classicyTextEditorSizeMedium",large:"classicyTextEditorSizeLarge"},nm=({id:e,content:t,prefillValue:n,disabled:l=!1,labelDisabled:s,autoHeight:i=!1,border:c=!1,fontSize:a="medium",labelTitle:o,labelSize:r="medium",labelPosition:u="above",onChangeFunc:d,className:m,style:Z})=>{const[b,h]=Y.useState(n??t??"");Y.useEffect(()=>{h(n??t??"")},[n,t]);const p=Y.useCallback(W=>{h(W.target.value),d?.(W)},[d]);return G.jsxs("div",{className:$("classicyTextEditorHolder",Yn(u),m),style:Z,children:[o&&G.jsx(Ot,{label:o,labelFor:e,labelSize:r,disabled:s??l}),G.jsx("textarea",{id:e,disabled:l,className:$("classicyTextEditor",Ait[a],i&&"classicyTextEditorAutoHeight",c&&"classicyTextEditorBorder"),value:b,onChange:p})]})};function wit(e){const[t,n,l,s]=e.rect??[0,0,0,0],i={left:t,top:n};return l&&(i.width=l),s&&(i.height=s),i}const RY=({open:e,stackId:t,editing:n=!1,className:l,style:s})=>{const i=Ut(),c=Ts(e.stack,e.currentCardId),[a,o]=e.stack.size??Qh;if(!c)return null;const r=(Z,b)=>{i({type:"ClassicyAppHyperCardEvent",stackId:t,partId:Z,event:"onMouseUp",...b!==void 0?{value:b}:{}})},u=(Z,b)=>{i({type:"ClassicyAppHyperCardCommitField",stackId:t,partId:Z,value:b})},d=(Z,b)=>{i({type:"ClassicyAppHyperCardEvent",stackId:t,partId:Z,event:b??"onMouseUp"})},m=LY(e.stack,c);return G.jsx("div",{className:$("classicyHyperCardCanvas",l),style:{width:a,height:o,...s},children:m.map(({part:Z,backgroundId:b})=>{const h=e.partVisibility[Z.id]??Z.visible??!0;if(!h&&!n)return null;const p=Qu(Z,e.currentCardId,b),W=e.fieldRev[p]??0,y=e.fieldValues[p]??Z.content??"",N=["classicyHyperCardPart",n?"classicyHyperCardPartInert":"",n&&!h?"classicyHyperCardPartHidden":""].filter(Boolean).join(" ");return G.jsx("div",{className:N,style:wit(Z),...n?{"data-part-id":Z.id,inert:!0}:{},children:xit(Z,{value:y,revKey:`${p}:${W}`,fireEvent:r,commitField:u,fire:d,stackId:t,getVariable:X=>e.variables[X],resolve:X=>iS(X,_u(e))})},Z.id)})})};function xit(e,t){switch(e.type){case"button":return G.jsx(Ft,{onClickFunc:()=>t.fireEvent(e.id),children:e.name??e.content??"Button"});case"checkbox":return G.jsx(Xn,{id:e.id,label:e.name??e.content??"",checked:t.value==="true",onClickFunc:l=>t.fireEvent(e.id,String(l))});case"radio":{const l=DS(e.options?.choices);return G.jsx(Xa,{name:e.id,label:e.name??"",inputs:l.map(s=>({id:s.value,label:s.label,checked:s.value===t.value})),onClickFunc:s=>t.fireEvent(e.id,s)})}case"popup":{const l=DS(e.options?.choices);return G.jsx(Me,{id:e.id,label:e.name??"",options:l,selected:t.value,onChangeFunc:s=>t.fireEvent(e.id,s.target.value)})}case"slider":return G.jsx(xl,{id:e.id,labelTitle:e.name??"",value:Number(t.value)||0,min:$h(e.options?.min,0),max:$h(e.options?.max,100),step:$h(e.options?.step,1),onCommitFunc:l=>t.fireEvent(e.id,String(l))});case"progress":return G.jsx(Dh,{value:Number(t.value)||0,max:$h(e.options?.max,100),label:e.name});case"label":return G.jsx(Ot,{label:t.value||e.name||""});case"image":return G.jsx("img",{className:"classicyHyperCardImage",src:String(e.options?.src??""),alt:e.name??""});case"field":return G.jsx(zit,{part:e,value:t.value,revKey:t.revKey,onCommit:l=>t.commitField(e.id,l)});case"group":return G.jsx("div",{className:"classicyHyperCardGroup",children:e.name??""})}const n=uS(e.type);return n?G.jsx(n,{part:e,partId:e.id,stackId:t.stackId,options:e.options??{},locked:e.locked??!1,value:t.value,setValue:l=>t.commitField(e.id,l),fire:l=>t.fire(e.id,l),getVariable:t.getVariable,resolve:t.resolve}):G.jsxs("div",{className:"classicyHyperCardMissingPart",children:["Missing part \u201C",e.type,"\u201D"]})}const zit=({part:e,value:t,revKey:n,onCommit:l})=>{const s=Y.useRef(t);if(Y.useEffect(()=>{s.current=t},[t]),e.locked)return G.jsx("div",{className:"classicyHyperCardLockedField",children:t});const i=!!e.options?.multiline,c=()=>l(s.current),a=o=>{s.current=o.target.value};return G.jsx("div",{className:"classicyHyperCardFieldWrap",onBlur:c,children:i?G.jsx(nm,{id:e.id,prefillValue:t,border:!0,onChangeFunc:a},n):G.jsx(es,{id:e.id,prefillValue:t,onChangeFunc:a,onEnterFunc:c},n)})};function DS(e){return Array.isArray(e)?e.map(t=>{if(typeof t=="string")return{value:t,label:t};const n=t,l=String(n.value??n.id??n.label??"");return{value:l,label:String(n.label??l)}}):[]}function $h(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Lit(e){return{stackSource:"editor",stack:e.draft,currentCardId:e.currentCardId,history:[],variables:{...e.draft.variables??{}},fieldValues:{},partVisibility:{},fieldRev:{},runtime:Ku()}}const kS=({stackId:e,edit:t,className:n,style:l})=>{const[s,i]=t.draft.size??Qh;return G.jsxs("div",{className:$("classicyHyperCardEditorCanvas",n),style:{width:s,height:i,...l},children:[G.jsx(RY,{open:Lit(t),stackId:e,editing:!0}),G.jsx(nS,{stackId:e,edit:t})]})};function t2(e){return`${JSON.stringify(e,null," ")}
|
|
74
74
|
`}function jS(e){return`${e.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").split("-").filter(Boolean).join("-")||"untitled"}.stack.json`}function vS(e){const t=fY(JSON.parse(t2(e)));if(!t.ok)return t;const n=new Blob([t2(e)],{type:"application/json"}),l=URL.createObjectURL(n),s=document.createElement("a");return s.href=l,s.download=jS(e),s.click(),URL.revokeObjectURL(l),{ok:!0}}const JS={id:"download",label:"Download",canSave:()=>!0,save:async(e,t)=>{const n=vS(e);return"errors"in n?{ok:!1,error:n.errors[0]}:{ok:!0}}};function OS(){NS(JS)}const ES={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 US(e){return ES[e]??wY(e)?.optionsSchema}function BS(){return[...YY.map(e=>({type:e.type,label:e.label})),...pS().map(({type:e,meta:t})=>({type:e,label:t.label}))]}const Is=({id:e,label:t,value:n,onCommit:l,type:s})=>{let i=n;return G.jsx("div",{className:"classicyHyperCardInspectorField",onBlur:()=>{i!==n&&l(i)},onKeyDown:c=>{c.key==="Enter"&&i!==n&&l(i)},children:G.jsx(es,{id:e,labelTitle:t,prefillValue:n,type:s,onChangeFunc:c=>{i=c.target.value}})})},Sit=[{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"]}],PS=({stackId:e,edit:t,className:n,style:l})=>{const s=Ut(),i=Pu(t.draft,t.currentCardId,t.layer)??[],c=t.selectedPartId?i.find(u=>u.id===t.selectedPartId):void 0;return G.jsx("div",{className:$("classicyHyperCardInspector",n),style:l,children:c?a(c):r()});function a(u){const d=u.rect??[0,0,120,60],m=US(u.type)??[],Z=new Set(m.map(W=>W.key)),b=Object.keys(u.options??{}).filter(W=>!Z.has(W)),h=W=>s({type:"ClassicyAppHCEditSetPartProps",stackId:e,partId:u.id,props:W}),p=W=>`${u.id}:${W}`;return G.jsxs(G.Fragment,{children:[G.jsx(Ot,{label:`${u.type} "${u.id}"`}),G.jsx(Is,{id:p("id"),label:"ID",value:u.id,onCommit:W=>h({id:W})},p("id")),G.jsx(Is,{id:p("name"),label:"Name",value:u.name??"",onCommit:W=>h({name:W})},p("name")),["x","y","w","h"].map((W,y)=>G.jsx(Is,{id:p(W),label:W.toUpperCase(),value:String(d[y]),type:"number",onCommit:N=>{const X=[...d];X[y]=Number(N),s({type:"ClassicyAppHCEditSetRect",stackId:e,partId:u.id,rect:X})}},p(W))),G.jsx(Xn,{id:p("visible"),label:"Visible",checked:u.visible??!0,onClickFunc:W=>h({visible:W})}),G.jsx(Xn,{id:p("locked"),label:"Locked",checked:u.locked??!1,onClickFunc:W=>h({locked:W})}),G.jsx(Xn,{id:p("shared"),label:"Shared (background fields)",checked:u.shared??!1,onClickFunc:W=>h({shared:W})}),Sit.map(W=>G.jsx(Me,{id:p(W.key),label:W.label,options:[{value:"",label:"(default)"},...W.values.map(y=>({value:y,label:y}))],selected:u.style?.[W.key]??"",onChangeFunc:y=>s({type:"ClassicyAppHCEditSetPartStyle",stackId:e,partId:u.id,style:{[W.key]:y.target.value}})},p(W.key))),G.jsx("div",{className:"classicyHyperCardInspectorField",children:G.jsx(Is,{id:p("content"),label:"Content",value:u.content??"",onCommit:W=>h({content:W})})},p("content")),m.map(W=>o(u,W)),b.map(W=>o(u,{key:W,label:W,kind:"json"})),G.jsx(Ft,{onClickFunc:()=>s({type:"ClassicyAppHCEditShowScript",stackId:e,target:{kind:"part",partId:u.id}}),children:"Script\u2026"})]})}function o(u,d){const m=`${u.id}:opt:${d.key}`,Z=u.options?.[d.key]??d.default,b=h=>s({type:"ClassicyAppHCEditSetPartOption",stackId:e,partId:u.id,key:d.key,value:h});if(d.kind==="checkbox")return G.jsx(Xn,{id:m,label:d.label,checked:!!Z,onClickFunc:h=>b(h)},m);if(d.kind==="choices"){const h=Array.isArray(Z)?Z.map(String).join(`
|
|
75
75
|
`):"";let p=h;return G.jsx("div",{className:"classicyHyperCardInspectorField",onBlur:()=>{p!==h&&b(p.split(`
|