@stacksjs/desktop 0.2.361 → 0.2.363
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/browser.js +1 -1
- package/dist/{chunk-mzeptpc2.js → chunk-hgcnqp53.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/menu.d.ts +10 -3
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$ as Az,$a as AA,A as jq,Aa as $z,B as xq,Ba as jz,C as kq,Ca as xz,D as yq,Da as kz,E as wq,Ea as yz,F as fq,Fa as wz,G as gq,Ga as fz,H as vq,Ha as gz,I as bq,Ia as vz,J as mq,Ja as bz,K as dq,Ka as mz,L as hq,La as dz,M as uq,Ma as hz,N as pq,Na as uz,O as lq,Oa as pz,P as cq,Pa as lz,Q as nq,Qa as cz,R as rq,Ra as nz,S as aq,Sa as rz,T as sq,Ta as az,U as oq,Ua as sz,V as tq,Va as oz,W as iq,Wa as tz,X as eq,Xa as iz,Ya as ez,Z as qz,Za as qA,_ as zz,_a as zA,a as Cq,aa as Bz,ab as BA,b as Dq,ba as Cz,bb as CA,c as Eq,ca as Dz,cb as DA,d as Fq,da as Ez,db as EA,e as Gq,ea as Fz,eb as FA,f as Hq,fa as Gz,fb as GA,g as Iq,ga as Hz,h as Jq,ha as Iz,i as Kq,ia as Jz,j as Lq,ja as Kz,k as Mq,ka as Lz,l as Nq,la as Mz,m as Oq,ma as Nz,n as Pq,na as Oz,o as Qq,oa as Pz,p as Rq,pa as Qz,q as Sq,qa as Rz,r as Tq,ra as Sz,s as Uq,sa as Tz,t as Vq,ta as Uz,u as Wq,ua as Vz,v as Xq,va as Wz,w as Yq,wa as Xz,x as Zq,xa as Yz,y as _q,ya as Zz,z as $q,za as _z}from"./chunk-
|
|
2
|
+
import{$ as Az,$a as AA,A as jq,Aa as $z,B as xq,Ba as jz,C as kq,Ca as xz,D as yq,Da as kz,E as wq,Ea as yz,F as fq,Fa as wz,G as gq,Ga as fz,H as vq,Ha as gz,I as bq,Ia as vz,J as mq,Ja as bz,K as dq,Ka as mz,L as hq,La as dz,M as uq,Ma as hz,N as pq,Na as uz,O as lq,Oa as pz,P as cq,Pa as lz,Q as nq,Qa as cz,R as rq,Ra as nz,S as aq,Sa as rz,T as sq,Ta as az,U as oq,Ua as sz,V as tq,Va as oz,W as iq,Wa as tz,X as eq,Xa as iz,Ya as ez,Z as qz,Za as qA,_ as zz,_a as zA,a as Cq,aa as Bz,ab as BA,b as Dq,ba as Cz,bb as CA,c as Eq,ca as Dz,cb as DA,d as Fq,da as Ez,db as EA,e as Gq,ea as Fz,eb as FA,f as Hq,fa as Gz,fb as GA,g as Iq,ga as Hz,h as Jq,ha as Iz,i as Kq,ia as Jz,j as Lq,ja as Kz,k as Mq,ka as Lz,l as Nq,la as Mz,m as Oq,ma as Nz,n as Pq,na as Oz,o as Qq,oa as Pz,p as Rq,pa as Qz,q as Sq,qa as Rz,r as Tq,ra as Sz,s as Uq,sa as Tz,t as Vq,ta as Uz,u as Wq,ua as Vz,v as Xq,va as Wz,w as Yq,wa as Xz,x as Zq,xa as Yz,y as _q,ya as Zz,z as $q,za as _z}from"./chunk-hgcnqp53.js";import"./chunk-gzgq8v6d.js";export{Kz as windowEvents,mz as watchScreenSharing,qA as vision,Jz as updater,nq as unregisterHotkey,rq as unregisterAllHotkeys,Wz as touchbar,Dz as theme,az as tags,Mz as standardMenus,iz as spotlight,ez as speechRecognition,Yz as speech,$z as signPayload,Pz as sidebar,Hq as showWarningToast,Qq as showWarningModal,fq as showWarningDialog,Eq as showToast,Gq as showSuccessToast,Sq as showSuccessModal,$q as showSaveDialog,Tq as showQuestionModal,_q as showOpenDialog,Oq as showModal,jq as showMessageBox,Fq as showInfoToast,Pq as showInfoModal,Iq as showErrorToast,Rq as showErrorModal,wq as showErrorDialog,yq as showConfirmDialog,xq as showColorPicker,kq as showAlertDialog,Dq as showAlert,Bz as shell,CA as serviceMenu,DA as serial,bz as screenSharing,wz as screenCapture,Qz as screen,Cq as requestNotificationPermission,cq as registerHotkey,_z as redactPII,Wq as prompt,Tz as printing,Sz as permissions,sz as pdf,pq as parseShortcut,Jq as notify,zz as notifications,Iz as network,Vz as nativeWindow,Uz as nativeAutoLaunch,zA as midi,Nz as menu,oz as log,yz as location,pz as localServer,kz as liveActivities,Rz as keychain,Fz as isDragOutAvailable,mq as isCaffeinated,GA as isAvailable,jz as iap,hz as hasFocusShortcuts,xz as handoff,Cz as globalShortcuts,aq as getRegisteredHotkeys,gq as getDialogBridgeScript,FA as getCapability,EA as getCapabilities,dq as getCaffeinateStatus,Xq as getActiveModalCount,Mq as getActiveAlertCount,Az as fs,iq as formatTime,lq as formatShortcut,hq as formatRemainingTime,uq as formatDuration,eq as formatCompact,uz as focusShortcutsReady,dz as focus,rz as fileAssociations,Ez as dragOut,Lq as dismissAllAlerts,Kq as dismissAlertById,tq as delay,Gz as deepLinks,bq as decaffeinate,sq as createTimer,oq as createInterval,Zz as crashReporter,AA as coreml,BA as continuityCamera,Oz as contextMenu,Uq as confirm,Yq as closeAllModals,qz as clipboard,vq as caffeinate,tz as bonjour,Xz as bluetooth,lz as biometric,Hz as battery,cz as audio,nz as appleScript,Lz as app,Vq as alert,Nq as TOAST_STYLES,Zq as MODAL_STYLES,fz as MIN_WATCH_INTERVAL_MS,gz as MAX_WATCH_INTERVAL_MS,vz as DEFAULT_WATCH_INTERVAL_MS};
|
|
@@ -307,7 +307,7 @@ window.stxDialog = {
|
|
|
307
307
|
`}var p=null,W=null;class XZ{_process;_startedAt;_endsAt;_options;_expireHandlers=[];_expireTimer=null;_stopped=!1;constructor(Z,$){this._process=Z,this._options=$,this._startedAt=new Date;let Y=$.duration;if(Y&&Y>0){let z=Y*60*1000;this._endsAt=new Date(this._startedAt.getTime()+z),this._expireTimer=setTimeout(()=>{this._stopped=!0;for(let G of this._expireHandlers)try{G()}catch{}},z)}else this._endsAt=null}get pid(){return this._process.pid}get startedAt(){return this._startedAt}get endsAt(){return this._endsAt}get options(){return{...this._options}}get isActive(){if(this._stopped)return!1;return this._process.exitCode===null}get remainingMs(){if(!this._endsAt)return null;let Z=this._endsAt.getTime()-Date.now();return Math.max(0,Z)}get elapsedMs(){return Date.now()-this._startedAt.getTime()}stop(){if(this._stopped)return;if(this._stopped=!0,this._expireTimer)clearTimeout(this._expireTimer),this._expireTimer=null;try{this._process.kill()}catch{}}onExpire(Z){this._expireHandlers.push(Z)}}function e4(Z={}){hZ();let{duration:$,preventDisplaySleep:Y=!0,preventIdleSleep:z=!0,preventSystemSleep:G=!0,preventDiskSleep:X=!1,assertUserActivity:O=!0}=Z,P=[];if(Y)P.push("-d");if(z)P.push("-i");if(G)P.push("-s");if(X)P.push("-m");if(O)P.push("-u");let F=[...P];if($&&$>0)F.push("-t",String($*60));let j=Bun.spawn(["/usr/bin/caffeinate",...F],{stdio:["ignore","ignore","ignore"]}),R=new XZ(j,Z);return p=j,W=R,R}function hZ(Z){if(Z){if(Z.stop(),W===Z)p=null,W=null;return}if(W)W.stop();p=null,W=null}function Z8(){return W!==null&&W.isActive}function $8(){if(!W||!W.isActive)return{active:!1,instance:null,startedAt:null,endsAt:null,durationMinutes:null};let $=W.options.duration;return{active:!0,instance:W,startedAt:W.startedAt,endsAt:W.endsAt,durationMinutes:$&&$>0?$:-1}}function J8(Z){let $=Z||W;if(!$||!$.isActive)return"0:00";let Y=$.remainingMs;if(Y===null)return"\u221E";let z=Math.ceil(Y/1000),G=Math.floor(z/3600),X=Math.floor(z%3600/60),O=z%60;if(G>0)return`${G}:${String(X).padStart(2,"0")}:${String(O).padStart(2,"0")}`;return`${X}:${String(O).padStart(2,"0")}`}function Y8(Z){if(Z<=0||Z===-1)return"Indefinitely";if(Z<60)return`${Z} minutes`;if(Z===60)return"1 hour";if(Z%60===0)return`${Z/60} hours`;let $=Math.floor(Z/60),Y=Z%60;return`${$}h ${Y}m`}var N=new Map,cZ=0,v=!1;function pZ(Z){let $=Z.split("+").map((z)=>z.trim()),Y={key:"",meta:!1,ctrl:!1,shift:!1,alt:!1};for(let z of $){let G=z.toLowerCase();switch(G){case"cmd":case"command":case"meta":case"\u2318":Y.meta=!0;break;case"ctrl":case"control":case"\u2303":Y.ctrl=!0;break;case"shift":case"\u21E7":Y.shift=!0;break;case"alt":case"option":case"opt":case"\u2325":Y.alt=!0;break;case"cmdorctrl":case"commandorcontrol":if(typeof process<"u"&&process.platform==="darwin")Y.meta=!0;else Y.ctrl=!0;break;default:Y.key=G}}return Y}function G8(Z){let $=[];if(Z.ctrl)$.push("\u2303");if(Z.alt)$.push("\u2325");if(Z.shift)$.push("\u21E7");if(Z.meta)$.push("\u2318");return $.push(Z.key.toUpperCase()),$.join("")}function dZ(Z,$){if($.meta!==Z.metaKey)return!1;if($.ctrl!==Z.ctrlKey)return!1;if($.shift!==Z.shiftKey)return!1;if($.alt!==Z.altKey)return!1;return Z.key.toLowerCase()===$.key||Z.code.toLowerCase()===`key${$.key}`}function PZ(Z){for(let[,$]of N)if(dZ(Z,$.parsed)){Z.preventDefault(),Z.stopPropagation();try{$.handler()}catch{}break}}function rZ(){if(v)return;if(typeof document>"u")return;document.addEventListener("keydown",PZ,!0),v=!0}function d(){if(!v)return;if(typeof document>"u")return;document.removeEventListener("keydown",PZ,!0),v=!1}async function nZ(Z,$){if(typeof window>"u")return!1;let Y=window.craft;if(!Y?.hotkeys?.register)return!1;try{return await Y.hotkeys.register(Z,$),!0}catch{return!1}}async function r(Z){if(typeof window>"u")return;let $=window.craft;if(!$?.hotkeys?.unregister)return;try{await $.hotkeys.unregister(Z)}catch{}}function Q8(Z,$){let Y=`hotkey_${++cZ}_${Date.now()}`,z=pZ(Z);N.set(Y,{shortcut:Z,handler:$,parsed:z}),nZ(Y,Z),rZ();let G={shortcut:Z,id:Y,unregister(){oZ(G)}};return G}function oZ(Z){if(N.delete(Z.id),r(Z.id),N.size===0)d()}function X8(){for(let[Z]of N)r(Z);N.clear(),d()}function P8(){return Array.from(N.entries()).map(([Z,$])=>({shortcut:$.shortcut,id:Z,unregister(){if(N.delete(Z),r(Z),N.size===0)d()}}))}class OZ{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(Z){if(this._duration=Z.duration,this._tickInterval=Z.tickInterval||1000,this._remaining=Z.duration,Z.onComplete)this._completionHandlers.add(Z.onComplete);if(Z.onTick)this._tickHandlers.add(Z.onTick);if(Z.autoStart)this.start()}get isRunning(){return this._running&&!this._paused}get isPaused(){return this._paused}get isComplete(){return this._complete}get remaining(){if(this._running&&!this._paused){let Z=Date.now()-this._lastTick;return Math.max(0,this._remaining-Z)}return Math.max(0,this._remaining)}get elapsed(){return this._duration-this.remaining}get duration(){return this._duration}get progress(){if(this._duration===0)return 1;return Math.min(1,this.elapsed/this._duration)}start(){if(this._running)return;this._running=!0,this._paused=!1,this._complete=!1,this._lastTick=Date.now(),this._startInterval()}stop(){this._clearInterval(),this._running=!1,this._paused=!1,this._remaining=this._duration}pause(){if(!this._running||this._paused)return;let Z=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-Z),this._clearInterval(),this._paused=!0}resume(){if(!this._paused)return;this._paused=!1,this._lastTick=Date.now(),this._startInterval()}reset(){this._clearInterval(),this._running=!1,this._paused=!1,this._complete=!1,this._remaining=this._duration}onComplete(Z){return this._completionHandlers.add(Z),()=>{this._completionHandlers.delete(Z)}}onTick(Z){return this._tickHandlers.add(Z),()=>{this._tickHandlers.delete(Z)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let Z=Date.now(),$=Z-this._lastTick;this._lastTick=Z,this._remaining=Math.max(0,this._remaining-$);for(let Y of this._tickHandlers)try{Y(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let Y of this._completionHandlers)try{Y()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class VZ{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(Z){if(this._interval=Z.interval,this._handler=Z.handler,this._immediate=Z.immediate!==!1,this._immediate)this.start()}get isRunning(){return this._running}start(){if(this._running)return;this._running=!0,this._intervalId=setInterval(()=>{try{this._handler()}catch{}},this._interval)}stop(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null;this._running=!1}}function V8(Z){return new OZ(Z)}function F8(Z){return new VZ(Z)}function j8(Z){return new Promise(($)=>setTimeout($,Z))}function W8(Z){let $=Math.ceil(Z/1000),Y=Math.floor($/3600),z=Math.floor($%3600/60),G=$%60;if(Y>0)return`${Y}:${String(z).padStart(2,"0")}:${String(G).padStart(2,"0")}`;return`${z}:${String(G).padStart(2,"0")}`}function K8(Z){let $=Math.ceil(Z/1000),Y=Math.floor($/3600),z=Math.floor($%3600/60),G=$%60;if(Y>0){if(z>0)return`${Y}h ${z}m`;return`${Y}h`}if(z>0){if(G>0)return`${z}m ${G}s`;return`${z}m`}return`${G}s`}function J(Z){if(typeof window>"u")return!1;let $=window.craft;return!!($&&$[Z])}function V(Z){if(!J(Z))throw Error(`craft.${Z} is not available \u2014 this API requires a Craft native window`);return window.craft[Z]}function Q(Z,$){if(typeof window>"u")return()=>{};let Y=(z)=>$(z.detail??{});return window.addEventListener(Z,Y),()=>window.removeEventListener(Z,Y)}var N8={async writeText(Z){if(J("clipboard")){await window.craft.clipboard.writeText(Z);return}if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(Z)},async readText(){if(J("clipboard")){let Z=await window.craft.clipboard.readText();return typeof Z==="string"?Z:""}if(typeof navigator<"u"&&navigator.clipboard?.readText)try{return await navigator.clipboard.readText()}catch{return""}return""},async writeHTML(Z){if(J("clipboard")){await window.craft.clipboard.writeHTML(Z);return}if(typeof navigator<"u"&&navigator.clipboard?.write)try{let $=new window.ClipboardItem({"text/html":new Blob([Z],{type:"text/html"}),"text/plain":new Blob([aZ(Z)],{type:"text/plain"})});await navigator.clipboard.write([$])}catch{}},async readHTML(){if(J("clipboard")){let Z=await window.craft.clipboard.readHTML();return typeof Z==="string"?Z:""}if(typeof navigator<"u"&&navigator.clipboard?.read)try{let Z=await navigator.clipboard.read();for(let $ of Z)if($.types.includes("text/html"))return await(await $.getType("text/html")).text()}catch{}return""},async clear(){if(J("clipboard")){await window.craft.clipboard.clear();return}if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText("")}catch{}},async hasText(){if(J("clipboard"))return await window.craft.clipboard.hasText();return(await this.readText()).length>0},async hasHTML(){if(J("clipboard"))return await window.craft.clipboard.hasHTML();return(await this.readHTML()).length>0},async hasImage(){if(J("clipboard"))return await window.craft.clipboard.hasImage();return!1}};function aZ(Z){return Z.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<\/?(br|p|div|li|h[1-6])\b[^>]*>/gi,`
|
|
308
308
|
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/\n{3,}/g,`
|
|
309
309
|
|
|
310
|
-
`).trim()}var H8={async show(Z){if(!Z.title)throw Error("notification title is required");if(J("notifications")){await window.craft.notifications.show(Z);return}if(typeof window<"u"&&"Notification"in window){let $=window.Notification;if($.permission==="granted")new $(Z.title,{body:Z.body,icon:Z.icon});else if($.permission==="default"){if(await $.requestPermission()==="granted")new $(Z.title,{body:Z.body,icon:Z.icon})}}},async schedule(Z){if(J("notifications")){let z={...Z};if(z.triggerAt instanceof Date)z.triggerAt=z.triggerAt.toISOString();await window.craft.notifications.schedule(z);return}let $=iZ(Z.triggerAt),Y=Math.max(0,$-Date.now());setTimeout(()=>{this.show(Z).catch(()=>{})},Y)},async cancel(Z){if(J("notifications"))await window.craft.notifications.cancel(Z)},async cancelAll(){if(J("notifications"))await window.craft.notifications.cancelAll()},async setBadge(Z){let $=Math.max(0,Math.round(Number.isFinite(Z)?Z:0));if(J("notifications")){await window.craft.notifications.setBadge($);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge($)}catch{}},async clearBadge(){if(J("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(J("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let Z=window.Notification;if(Z.permission==="granted")return!0;if(Z.permission==="denied")return!1;return await Z.requestPermission()==="granted"}return!1},async registerCategories(Z){if(!Array.isArray(Z)||Z.length===0)return;if(J("notifications")){let $=window.craft.notifications.registerCategories;if(typeof $==="function")await $(Z)}},onActionClicked(Z){return Q("craft:notification:actionClicked",Z)},onReply(Z){return Q("craft:notification:reply",Z)}};function iZ(Z){if(Z==null)return Date.now();if(Z instanceof Date)return Z.getTime();if(typeof Z==="number")return Z;let $=Date.parse(Z);return Number.isNaN($)?Date.now():$}var S8={async readFile(Z){let $=await V("fs").readFile(Z);return $&&$.data||""},async readBuffer(Z){let $=await V("fs").readFile(Z),Y=$&&$.data||"";if($&&$.base64===!0)return tZ(Y);return new TextEncoder().encode(Y)},async writeFile(Z,$){await V("fs").writeFile(Z,$)},async writeBuffer(Z,$){let Y=sZ($),z=V("fs");if(typeof z.writeFileBytes==="function")await z.writeFileBytes(Z,Y);else await z.writeFile(Z,Y)},async copy(Z,$){if(Z===$)throw Error("fs.copy: source and destination must differ");await V("fs").copy(Z,$)},async move(Z,$){if(Z===$)throw Error("fs.move: source and destination must differ");await V("fs").move(Z,$)},async appendFile(Z,$){await V("fs").appendFile(Z,$)},async deleteFile(Z){await V("fs").deleteFile(Z)},async exists(Z){return await V("fs").exists(Z)},async stat(Z){return eZ(await V("fs").stat(Z))},async readDir(Z){let $=await V("fs").readDir(Z),Y=$&&$.entries||[],z=Z.endsWith("/")?Z.slice(0,-1):Z;return Y.map((G)=>({name:G.name,path:`${z}/${G.name}`,isDirectory:!!G.isDirectory}))},async mkdir(Z,$){await V("fs").mkdir(Z,$)},async rmdir(Z,$){await V("fs").rmdir(Z,$)},async watch(Z,$){await V("fs").watch(Z,$)},async unwatch(Z){await V("fs").unwatch(Z)},onChange(Z){return Q("craft:fs:change",Z)},async watchTree(Z,$,Y){let z=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,G=V("fs");await G.watch(Z,z,{recursive:!!$.recursive});let X=$.kinds&&$.kinds.length>0?new Set($.kinds):null,O=Math.max(0,Math.floor($.coalesceMs??0)),P=[],F=null,j=!1,R=()=>{if(F=null,P.length===0)return;let L=P;P=[];try{Y(L)}catch{}},q=Q("craft:fs:change",(L)=>{if(j)return;if(L.id!==z)return;if(X&&L.kind&&!X.has(L.kind))return;if(P.push(L),O===0){R();return}if(F==null)F=setTimeout(R,O)});return{id:z,async stop(){if(j)return;if(j=!0,q(),F)clearTimeout(F),F=null;if(P.length>0)R();try{await G.unwatch(z)}catch{}}}},async homeDir(){return await V("fs").homeDir()},async tempDir(){return await V("fs").tempDir()},async appDataDir(){return await V("fs").appDataDir()}};function sZ(Z){let $="";for(let Y=0;Y<Z.length;Y++)$+=String.fromCharCode(Z[Y]);return typeof btoa==="function"?btoa($):Buffer.from(Z).toString("base64")}function tZ(Z){let $=typeof atob==="function"?atob(Z):Buffer.from(Z,"base64").toString("binary"),Y=new Uint8Array($.length);for(let z=0;z<$.length;z++)Y[z]=$.charCodeAt(z);return Y}function eZ(Z){return{isFile:!!Z.isFile,isDirectory:!!Z.isDirectory,isSymlink:!!Z.isSymlink,size:Number(Z.size)||0,modifiedAt:Z.modifiedAt!=null?Z.modifiedAt<1000000000000?Z.modifiedAt*1000:Z.modifiedAt:0}}var _=new Set,FZ=!1;function Z4(){if(FZ)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(Z)=>{let $=Z.detail;if($?.id)_.delete($.id)}),FZ=!0}var $4=new Set(["javascript:","data:","file:","vbscript:"]),_8={async openExternal(Z){let $=Z.trim().toLowerCase();for(let Y of $4)if($.startsWith(Y))throw Error(`shell.openExternal: ${Y} URLs are blocked for safety`);if(J("shell")){await window.craft.shell.openExternal(Z);return}if(typeof window<"u"&&typeof window.open==="function")window.open(Z,"_blank","noopener,noreferrer")},async openPath(Z){await V("shell").openPath(Z)},async showInFinder(Z){await V("shell").showInFinder(Z)},async spawn(Z,$,Y=[],z={}){if(Z4(),!Z||typeof Z!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!$||typeof $!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(Y))throw Error("shell.spawn: args must be an array");for(let G of Y)if(typeof G!=="string")throw Error("shell.spawn: args entries must be strings");if(_.has(Z))throw Error(`shell.spawn: id "${Z}" is already in use \u2014 call kill(id) first or pick a different id`);_.add(Z);try{await V("shell").spawn(Z,$,Y,z)}catch(G){throw _.delete(Z),G}},async kill(Z){await V("shell").kill(Z),_.delete(Z)},async getEnv(Z){if(J("shell")){let $=await window.craft.shell.getEnv(Z);return $==null?void 0:String($)}return},async setEnv(Z,$){await V("shell").setEnv(Z,$)},onStdout(Z){return Q("craft:shell:stdout",Z)},onStderr(Z){return Q("craft:shell:stderr",Z)},onExit(Z){return Q("craft:shell:exit",Z)}};function S(){return window.craft.shortcuts}var C8={async register(Z,$,Y){if(!J("shortcuts"))return;await S().register(Z,$,Y)},async unregister(Z){if(!J("shortcuts"))return;await S().unregister(Z)},async unregisterAll(){if(!J("shortcuts"))return;await S().unregisterAll()},async enable(Z){if(!J("shortcuts"))return;await S().enable(Z)},async disable(Z){if(!J("shortcuts"))return;await S().disable(Z)},async isRegistered(Z){if(!J("shortcuts"))return!1;return await S().isRegistered(Z)},async list(){if(!J("shortcuts"))return[];return await S().list()},on(Z){return Q("craft:shortcut",Z)}};var y8={get(){if(J("theme"))try{return window.craft.theme.get()}catch{}return{appearance:J4()}},onChange(Z){if(Z(this.get()),J("theme"))return Q("craft:theme",Z);if(typeof window<"u"&&window.matchMedia){let $=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>Z({appearance:$.matches?"dark":"light"});return $.addEventListener("change",Y),()=>$.removeEventListener("change",Y)}return()=>{}},async current(){return this.get()}};function J4(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function v8(Z,$={}){if(!J("dragOut"))throw Error("dragOut requires a Craft native window");let Y=Array.isArray(Z)?Z:[Z];if(Y.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(Y,$)}function m8(){return J("dragOut")}var l8={onUrl(Z){if(!J("deepLink"))return()=>{};return Q("craft:deepLink",Z)},getInitialUrl(){if(typeof window>"u")return null;if(J("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let Z=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return Z},isAvailable(){return J("deepLink")}};var c8={async isCharging(){if(J("power"))return await window.craft.power.isCharging();let Z=await m();return Z?!!Z.charging:!1},async isPluggedIn(){if(J("power"))return await window.craft.power.isPluggedIn();let Z=await m();return Z?!!Z.charging||Z.level>=0.999:!1},async isLowPowerMode(){if(J("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(J("power")){let $=await window.craft.power.batteryLevel();return typeof $==="number"?$:null}let Z=await m();return Z?Z.level:null},async timeRemaining(){if(J("power")){let Y=await window.craft.power.timeRemaining();return typeof Y==="number"?Y:null}let Z=await m();if(!Z)return null;let $=Z.charging?Z.chargingTime:Z.dischargingTime;return Number.isFinite($)?Math.round($/60):null},async thermalState(){if(J("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(J("power"))return await window.craft.power.uptimeSeconds();if(typeof performance<"u"&&typeof performance.now==="function")return Math.round(performance.now()/1000);return 0},async preventSleep(Z="app is busy"){if(J("power")){await window.craft.power.preventSleep(Z);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let $=window;if($.__craftWebWakeLock?.release){try{await $.__craftWebWakeLock.release()}catch{}$.__craftWebWakeLock=null}try{let Y=await navigator.wakeLock.request("screen");$.__craftWebWakeLock=Y}catch{}},async allowSleep(){if(J("power")){await window.craft.power.allowSleep();return}let Z=window.__craftWebWakeLock;if(Z&&typeof Z.release==="function"){try{await Z.release()}catch{}window.__craftWebWakeLock=null}},onSleep(Z){return Q("craft:powerSleep",Z)},onWake(Z){return Q("craft:powerWake",Z)}};async function m(){if(typeof navigator>"u")return null;let Z=navigator;if(typeof Z.getBattery!=="function")return null;try{return await Z.getBattery()}catch{return null}}var r8={async connectionType(){if(J("network"))return await window.craft.network.connectionType();return jZ()},async wifiSSID(){if(J("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(J("network")){let Z=await window.craft.network.wifiSignalStrength();return typeof Z==="number"?Z:void 0}return},async ipAddress(){if(J("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(J("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(J("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(J("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(J("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(J("network"))await window.craft.network.openPreferences()},onChange(Z){if(J("network"))return Q("craft:networkChange",Z);if(typeof window>"u")return()=>{};let $=()=>Z({type:jZ(),online:!0}),Y=()=>Z({type:"none",online:!1});return window.addEventListener("online",$),window.addEventListener("offline",Y),()=>{window.removeEventListener("online",$),window.removeEventListener("offline",Y)}}};function jZ(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let Z=navigator.connection;if(!Z)return"unknown";let $=String(Z.type||Z.effectiveType||"unknown").toLowerCase();if($==="wifi"||$==="cellular"||$==="ethernet"||$==="bluetooth"||$==="none")return $;return"unknown"}var a8={async checkForUpdates(){if(!J("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!J("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(Z){if(!J("updater"))return;await window.craft.updater.setAutomaticChecks(Z)},async setCheckInterval(Z){if(!J("updater"))return;if(!Number.isFinite(Z))throw Error("setCheckInterval: must be a finite number");let $=Z<=0?0:Math.max(60,Math.round(Z));await window.craft.updater.setCheckInterval($)},async setFeedURL(Z){if(!J("updater"))return;await window.craft.updater.setFeedURL(Z)},async getLastUpdateCheckDate(){if(!J("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!J("updater"))return null;let Z=await window.craft.updater.getUpdateInfo();if(!Z||typeof Z.version!=="string"||Z.version.length===0)return null;return Z},onAvailable(Z){return Q("craft:updateAvailable",Z)},onDownloaded(Z){return Q("craft:updateDownloaded",Z)},async verifySignature({payload:Z,signatureB64:$,publicKeyB64:Y}){let z=WZ(Z),G;try{G=await crypto.subtle.importKey("raw",b(Y),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",G,b($),z)}catch{return!1}},async verifyDownload({url:Z,signatureB64:$,publicKeyB64:Y,fetchInit:z}){let G;try{G=await fetch(Z,z)}catch{return{ok:!1,reason:"fetch-failed"}}if(!G.ok)return{ok:!1,reason:"http-error",status:G.status};let X=new Uint8Array(await G.arrayBuffer()),O;try{O=await crypto.subtle.importKey("raw",b(Y),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let P=!1;try{P=await crypto.subtle.verify("Ed25519",O,b($),WZ(X))}catch{P=!1}if(!P)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:X}}};function WZ(Z){if(Z instanceof ArrayBuffer)return new Uint8Array(Z);let $=new ArrayBuffer(Z.byteLength),Y=new Uint8Array($);return Y.set(Z),Y}function b(Z){if(typeof atob==="function"){let z=atob(Z),G=new ArrayBuffer(z.length),X=new Uint8Array(G);for(let O=0;O<z.length;O++)X[O]=z.charCodeAt(O);return X}let $=Buffer.from(Z,"base64"),Y=new ArrayBuffer($.length);return new Uint8Array(Y).set($),new Uint8Array(Y)}var t8={onFocus(Z){if(J("window"))return Q("craft:window:focus",()=>Z());return n("focus",Z)},onBlur(Z){if(J("window"))return Q("craft:window:blur",()=>Z());return n("blur",Z)},onResize(Z){if(J("window"))return Q("craft:window:resize",Z);if(typeof window>"u")return()=>{};let $=()=>Z({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)},onMove(Z){if(J("window"))return Q("craft:window:move",Z);return()=>{}},onClose(Z){if(J("window"))return Q("craft:window:close",()=>Z());return n("beforeunload",Z)},onMinimize(Z){if(J("window"))return Q("craft:window:minimize",()=>Z());if(typeof document>"u")return()=>{};let $=()=>{if(document.visibilityState==="hidden")Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)},onRestore(Z){if(J("window"))return Q("craft:window:restore",()=>Z());if(typeof document>"u")return()=>{};let $=()=>{if(document.visibilityState==="visible")Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)}};function n(Z,$){if(typeof window>"u")return()=>{};let Y=()=>$();return window.addEventListener(Z,Y),()=>window.removeEventListener(Z,Y)}var KZ={name:"",version:"0.0.0"},$$={async hideDockIcon(){if(J("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(J("app"))await window.craft.app.showDockIcon()},async quit(){if(J("app"))await window.craft.app.quit()},async getInfo(){if(!J("app"))return KZ;let Z=await window.craft.app.getInfo();return{...KZ,...Z||{}}},async notify(Z){if(!Z.title)throw Error("notify: title is required");if(J("app"))await window.craft.app.notify(Z)},async setBadge(Z){if(J("app"))await window.craft.app.setBadge(Z)},async bounce(Z="informational"){if(J("app"))await window.craft.app.bounce(Z)}};var z$={app(Z){return{label:Z,items:[{label:`About ${Z}`,role:"about"},{separator:!0},{label:`Hide ${Z}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${Z}`,role:"quit",shortcut:"cmd+q"}]}},edit(){return{label:"Edit",items:[{label:"Undo",role:"undo",shortcut:"cmd+z"},{label:"Redo",role:"redo",shortcut:"cmd+shift+z"},{separator:!0},{label:"Cut",role:"cut",shortcut:"cmd+x"},{label:"Copy",role:"copy",shortcut:"cmd+c"},{label:"Paste",role:"paste",shortcut:"cmd+v"},{label:"Select All",role:"selectAll",shortcut:"cmd+a"}]}},window(){return{label:"Window",items:[{label:"Minimize",role:"minimize",shortcut:"cmd+m"},{label:"Zoom",role:"zoom"},{separator:!0},{label:"Close Window",role:"close",shortcut:"cmd+w"}]}},leading(Z){return[this.app(Z),this.edit()]}},Y4=0;function z4(Z){let $=new Map;return{payload:{menus:Z.menus.map((z)=>({label:z.label,items:z.items.map((G)=>{let{onClick:X,...O}=G;if(O.separator)return O;let P=O.id??`stx.menu.${Y4++}`;if(X)$.set(P,X);return{...O,id:P}})}))},handlers:$}}var o=null,G$={async set(Z){if(!J("menu"))return!1;let{payload:$,handlers:Y}=z4(Z);if(o?.(),o=null,Y.size>0)o=Q("craft:menu:action",(z)=>{Y.get(z.id)?.()});return await window.craft.menu.set($),!0},async setDock(Z){if(J("menu"))await window.craft.menu.setDock(Z)},async addItem(Z,$){if(J("menu"))await window.craft.menu.addItem(Z,$)},async removeItem(Z){if(J("menu"))await window.craft.menu.removeItem(Z)},async enableItem(Z){if(J("menu"))await window.craft.menu.enableItem(Z)},async disableItem(Z){if(J("menu"))await window.craft.menu.disableItem(Z)},async checkItem(Z){if(J("menu"))await window.craft.menu.checkItem(Z)},async uncheckItem(Z){if(J("menu"))await window.craft.menu.uncheckItem(Z)},async setItemLabel(Z,$){if(J("menu"))await window.craft.menu.setItemLabel(Z,$)},async clearDock(){if(J("menu"))await window.craft.menu.clearDock()},onAction(Z){return Q("craft:menu:action",Z)}};function LZ(Z){if(Z.separator)return{id:Z.id||"",title:"",type:"separator"};return{id:Z.id||"",title:Z.title||"",icon:Z.icon,shortcut:Z.shortcut,enabled:Z.disabled?!1:void 0,checked:Z.checked?!0:void 0,type:Z.submenu?"submenu":void 0,submenu:Z.submenu?.map(LZ)}}async function RZ(Z){if(!Z.items||Z.items.length===0)throw Error("contextMenu.show requires at least one item");if(!J("nativeUI"))return null;let $=await window.craft.nativeUI.showContextMenu({targetId:Z.targetId||"",targetType:"general",x:Math.round(Z.x),y:Math.round(Z.y),items:Z.items.map(LZ)});return{id:typeof $?.id==="string"?$.id:null,targetId:$?.targetId}}var P$={available(){return J("nativeUI")},async show(Z){return await RZ(Z)!==null},async pick(Z){return(await RZ(Z))?.id??null},onAction(Z){return Q("craft:contextmenu:action",($)=>{if(typeof $.id==="string")Z({id:$.id,targetId:$.targetId??""})})}};function a(Z){if(Z===null||Z===void 0||Z===0)return"";return String(Z)}function DZ(Z){return Z.map(($)=>({id:$.id,header:$.header,items:$.items.map((Y)=>({id:Y.id,label:Y.label,icon:Y.icon,badge:a(Y.badge)||void 0}))}))}function NZ(Z){return JSON.stringify(Z.map(($)=>[$.id,$.header??"",$.items.map((Y)=>[Y.id,Y.label,Y.icon??""])]))}function kZ(Z){return new Map(Z.flatMap(($)=>$.items.map((Y)=>[Y.id,a(Y.badge)])))}var G4={available(){return J("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(Z){if(!G4.available())return null;let $=window.craft.nativeUI.createSidebar({id:Z.id,sections:DZ(Z.sections),selected:Z.selected}),Y=Z.sections,z=new Set;return $.onSelect((G)=>{for(let X of[...z])X(G)}),{id:$.id,update(G){if(NZ(G)===NZ(Y)){let X=kZ(Y);for(let[O,P]of kZ(G))if(X.get(O)!==P)$.updateItem(O,{badge:P})}else $.setSections(DZ(G));Y=G},updateItem(G,X){$.updateItem(G,{...X.label!==void 0?{label:X.label}:{},...X.icon!==void 0?{icon:X.icon}:{},..."badge"in X?{badge:a(X.badge)}:{}}),Y=Y.map((O)=>({...O,items:O.items.map((P)=>P.id===G?{...P,...X}:P)}))},select(G){$.setSelectedItem(G)},onSelect(G){return z.add(G),()=>z.delete(G)},destroy(){z.clear(),$.destroy()}}}};var W$={async getDisplays(){if(J("screen"))return await window.craft.screen.getDisplays();return qZ()},async getPrimary(){if(J("screen")){let Z=await window.craft.screen.getPrimary();return Z&&typeof Z.width==="number"?Z:null}return qZ()[0]??null},onChange(Z){if(J("screen"))return Q("craft:screen:change",()=>Z());if(typeof window>"u")return()=>{};let $=()=>Z();return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}};function qZ(){if(typeof window>"u"||!window.screen)return[];let Z=window.screen;return[{id:0,x:Z.left??0,y:Z.top??0,width:Z.width||0,height:Z.height||0,workX:Z.availLeft??0,workY:Z.availTop??0,workWidth:Z.availWidth??Z.width??0,workHeight:Z.availHeight??Z.height??0,scaleFactor:window.devicePixelRatio||1}]}var L$={async set(Z,$,Y){if(!Z)throw Error("keychain.set: service is required");if(!$)throw Error("keychain.set: account is required");await V("keychain").set(Z,$,Y)},async get(Z,$){if(!Z)throw Error("keychain.get: service is required");if(!$)throw Error("keychain.get: account is required");let Y=await V("keychain").get(Z,$);return typeof Y==="string"?Y:null},async delete(Z,$){if(!Z)throw Error("keychain.delete: service is required");if(!$)throw Error("keychain.delete: account is required");await V("keychain").delete(Z,$)},async has(Z,$){if(!Z)throw Error("keychain.has: service is required");if(!$)throw Error("keychain.has: account is required");return await V("keychain").has(Z,$)}};var k$={async check(Z){if(J("permissions"))return await window.craft.permissions.check(Z);return await HZ(Z)},async request(Z){if(J("permissions"))return await window.craft.permissions.request(Z);return await Q4(Z)},async openSettings(Z){if(J("permissions"))await window.craft.permissions.openSettings(Z)}};async function HZ(Z){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let $=await navigator.permissions.query({name:Z});return X4($.state)}catch{return"not-supported"}}async function Q4(Z){if(Z==="notifications"&&typeof window<"u"&&"Notification"in window){let $=await window.Notification.requestPermission();return $==="granted"?"granted":$==="denied"?"denied":"undetermined"}return await HZ(Z)}function X4(Z){if(Z==="granted")return"granted";if(Z==="denied")return"denied";if(Z==="prompt")return"undetermined";return"undetermined"}var U$={async print(){if(J("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(Z){if(!Z)throw Error("printToPDF: path is required");let $=Z.startsWith("/"),Y=/^[a-zA-Z]:[\\/]/.test(Z)||Z.startsWith("\\\\");if(!$&&!Y)throw Error("printToPDF: path must be absolute");let z=await V("printing").printToPDF(Z);return{ok:!!(z&&z.ok),path:z?.path}}};var A$={async enable(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};function i(){if(!J("window"))return null;return window.craft.window}function k(Z){let $=i();if(!$)return Promise.resolve();try{return Promise.resolve(Z($)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var x$={get available(){return i()!==null},open(Z){let $=()=>{if(typeof window<"u"&&Z.url)window.open(Z.url,Z.name);return{name:Z.name}},Y=i();if(!Y?.open)return Promise.resolve($());return Y.open(Z).then((z)=>({name:z?.name||Z.name})).catch($)},close:()=>k((Z)=>Z.close?.()),focus:()=>k((Z)=>Z.focus?.()),minimize:()=>k((Z)=>Z.minimize?.()),maximize:()=>k((Z)=>Z.maximize?.()),center:()=>k((Z)=>Z.center?.()),startDrag:()=>k((Z)=>Z.startDrag?.()),setTitle:(Z)=>k(($)=>$.setTitle?.(Z)),setSize:(Z,$)=>k((Y)=>Y.setSize?.(Z,$)),setAppearance:(Z)=>k(($)=>$.setAppearance?.(Z))};var w$={async addItem(Z){if(J("touchbar"))await window.craft.touchbar.addItem(Z)},async removeItem(Z){if(J("touchbar"))await window.craft.touchbar.removeItem(Z)},async updateItem(Z,$){if(J("touchbar"))await window.craft.touchbar.updateItem(Z,$)},async setLabel(Z,$){if(J("touchbar"))await window.craft.touchbar.setLabel(Z,$)},async setIcon(Z,$){if(J("touchbar"))await window.craft.touchbar.setIcon(Z,$)},async setEnabled(Z,$){if(J("touchbar"))await window.craft.touchbar.setEnabled(Z,$)},async setSliderValue(Z,$){if(J("touchbar"))await window.craft.touchbar.setSliderValue(Z,$)},async clear(){if(J("touchbar"))await window.craft.touchbar.clear()},async show(){if(J("touchbar"))await window.craft.touchbar.show()},async hide(){if(J("touchbar"))await window.craft.touchbar.hide()},onAction(Z){return Q("craft:touchbar:action",Z)}};var P4=/^[\da-f]*$/i;function O4(Z,$){if(typeof $!=="string"||!P4.test($)||$.length%2!==0)throw Error(`${Z}: must be a hex string with even length, got ${JSON.stringify($)}`)}var f$={async isEnabled(){return J("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return J("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return J("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return J("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(J("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(J("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return J("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(Z){if(J("bluetooth"))await window.craft.bluetooth.connect(Z)},async disconnect(Z){if(J("bluetooth"))await window.craft.bluetooth.disconnect(Z)},async openPreferences(){if(J("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(Z){if(!Z)throw Error("bluetooth.discoverServices: deviceId is required");if(!J("bluetooth"))return[];let $=await window.craft.bluetooth.discoverServices(Z);return Array.isArray($)?$:[]},async discoverCharacteristics(Z,$){if(!Z||!$)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!J("bluetooth"))return[];let Y=await window.craft.bluetooth.discoverCharacteristics(Z,$);return Array.isArray(Y)?Y:[]},async readCharacteristic(Z,$,Y){if(!Z||!$||!Y)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(Z,$,Y)},async writeCharacteristic(Z,$,Y,z,G="with-response"){if(!Z||!$||!Y)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(O4("bluetooth.writeCharacteristic.valueHex",z),!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(Z,$,Y,z,G)},async setCharacteristicNotify(Z,$,Y,z){if(!Z||!$||!Y)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(Z,$,Y,z)},onDeviceFound(Z){return Q("craft:bluetooth:deviceFound",Z)},onDeviceConnected(Z){return Q("craft:bluetooth:deviceConnected",Z)},onDeviceDisconnected(Z){return Q("craft:bluetooth:deviceDisconnected",Z)},onCharacteristicValue(Z){return Q("craft:bluetooth:characteristicValue",Z)}};var m$={async speak(Z,$){if(!Z)throw Error("speech.speak: text is required");if(J("speech")){await window.craft.speech.speak(Z,$);return}if(typeof window<"u"&&window.speechSynthesis){let Y=new window.SpeechSynthesisUtterance(Z);if($){if($.rate!=null)Y.rate=$.rate;if($.pitch!=null)Y.pitch=$.pitch;if($.volume!=null)Y.volume=$.volume;if($.voice){let G=window.speechSynthesis.getVoices().find((X)=>X.voiceURI===$.voice||X.name===$.voice||X.lang===$.voice);if(G)Y.voice=G}}window.speechSynthesis.speak(Y)}},async stop(){if(J("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(J("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(J("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(J("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(J("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map(($)=>({id:$.voiceURI||$.name,name:$.name,language:$.lang||"",quality:"default"}));return[]}};var x=[],s=!0,t,e,u={async report(Z){if(J("crashReporter")){await window.craft.crashReporter.report(Z);return}if(!s)return;let $=Z instanceof Error?{timestamp:Date.now(),severity:"error",message:Z.message,source:"js",stack:Z.stack||"",userId:t,appVersion:e}:{timestamp:Date.now(),severity:Z.severity||"error",message:Z.message||"",source:Z.source||"js",stack:Z.stack||"",userId:t,appVersion:e};if(x.length>=64)x.shift();x.push($)},async flush(){if(J("crashReporter"))return await window.craft.crashReporter.flush();return[...x]},async clear(){if(J("crashReporter")){await window.craft.crashReporter.clear();return}x.length=0},async setEnabled(Z){if(J("crashReporter")){await window.craft.crashReporter.setEnabled(Z);return}s=Z},async isEnabled(){if(J("crashReporter"))return await window.craft.crashReporter.isEnabled();return s},async setUser(Z){if(J("crashReporter")){await window.craft.crashReporter.setUser(Z);return}t=Z||void 0},async setAppVersion(Z){if(J("crashReporter")){await window.craft.crashReporter.setAppVersion(Z);return}e=Z||void 0},attachGlobalHandlers(){if(J("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let Z=(Y)=>{u.report({severity:"error",message:Y.message,source:"js",stack:Y.error?.stack||`${Y.message}
|
|
310
|
+
`).trim()}var H8={async show(Z){if(!Z.title)throw Error("notification title is required");if(J("notifications")){await window.craft.notifications.show(Z);return}if(typeof window<"u"&&"Notification"in window){let $=window.Notification;if($.permission==="granted")new $(Z.title,{body:Z.body,icon:Z.icon});else if($.permission==="default"){if(await $.requestPermission()==="granted")new $(Z.title,{body:Z.body,icon:Z.icon})}}},async schedule(Z){if(J("notifications")){let z={...Z};if(z.triggerAt instanceof Date)z.triggerAt=z.triggerAt.toISOString();await window.craft.notifications.schedule(z);return}let $=iZ(Z.triggerAt),Y=Math.max(0,$-Date.now());setTimeout(()=>{this.show(Z).catch(()=>{})},Y)},async cancel(Z){if(J("notifications"))await window.craft.notifications.cancel(Z)},async cancelAll(){if(J("notifications"))await window.craft.notifications.cancelAll()},async setBadge(Z){let $=Math.max(0,Math.round(Number.isFinite(Z)?Z:0));if(J("notifications")){await window.craft.notifications.setBadge($);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge($)}catch{}},async clearBadge(){if(J("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(J("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let Z=window.Notification;if(Z.permission==="granted")return!0;if(Z.permission==="denied")return!1;return await Z.requestPermission()==="granted"}return!1},async registerCategories(Z){if(!Array.isArray(Z)||Z.length===0)return;if(J("notifications")){let $=window.craft.notifications.registerCategories;if(typeof $==="function")await $(Z)}},onActionClicked(Z){return Q("craft:notification:actionClicked",Z)},onReply(Z){return Q("craft:notification:reply",Z)}};function iZ(Z){if(Z==null)return Date.now();if(Z instanceof Date)return Z.getTime();if(typeof Z==="number")return Z;let $=Date.parse(Z);return Number.isNaN($)?Date.now():$}var S8={async readFile(Z){let $=await V("fs").readFile(Z);return $&&$.data||""},async readBuffer(Z){let $=await V("fs").readFile(Z),Y=$&&$.data||"";if($&&$.base64===!0)return tZ(Y);return new TextEncoder().encode(Y)},async writeFile(Z,$){await V("fs").writeFile(Z,$)},async writeBuffer(Z,$){let Y=sZ($),z=V("fs");if(typeof z.writeFileBytes==="function")await z.writeFileBytes(Z,Y);else await z.writeFile(Z,Y)},async copy(Z,$){if(Z===$)throw Error("fs.copy: source and destination must differ");await V("fs").copy(Z,$)},async move(Z,$){if(Z===$)throw Error("fs.move: source and destination must differ");await V("fs").move(Z,$)},async appendFile(Z,$){await V("fs").appendFile(Z,$)},async deleteFile(Z){await V("fs").deleteFile(Z)},async exists(Z){return await V("fs").exists(Z)},async stat(Z){return eZ(await V("fs").stat(Z))},async readDir(Z){let $=await V("fs").readDir(Z),Y=$&&$.entries||[],z=Z.endsWith("/")?Z.slice(0,-1):Z;return Y.map((G)=>({name:G.name,path:`${z}/${G.name}`,isDirectory:!!G.isDirectory}))},async mkdir(Z,$){await V("fs").mkdir(Z,$)},async rmdir(Z,$){await V("fs").rmdir(Z,$)},async watch(Z,$){await V("fs").watch(Z,$)},async unwatch(Z){await V("fs").unwatch(Z)},onChange(Z){return Q("craft:fs:change",Z)},async watchTree(Z,$,Y){let z=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,G=V("fs");await G.watch(Z,z,{recursive:!!$.recursive});let X=$.kinds&&$.kinds.length>0?new Set($.kinds):null,O=Math.max(0,Math.floor($.coalesceMs??0)),P=[],F=null,j=!1,R=()=>{if(F=null,P.length===0)return;let L=P;P=[];try{Y(L)}catch{}},q=Q("craft:fs:change",(L)=>{if(j)return;if(L.id!==z)return;if(X&&L.kind&&!X.has(L.kind))return;if(P.push(L),O===0){R();return}if(F==null)F=setTimeout(R,O)});return{id:z,async stop(){if(j)return;if(j=!0,q(),F)clearTimeout(F),F=null;if(P.length>0)R();try{await G.unwatch(z)}catch{}}}},async homeDir(){return await V("fs").homeDir()},async tempDir(){return await V("fs").tempDir()},async appDataDir(){return await V("fs").appDataDir()}};function sZ(Z){let $="";for(let Y=0;Y<Z.length;Y++)$+=String.fromCharCode(Z[Y]);return typeof btoa==="function"?btoa($):Buffer.from(Z).toString("base64")}function tZ(Z){let $=typeof atob==="function"?atob(Z):Buffer.from(Z,"base64").toString("binary"),Y=new Uint8Array($.length);for(let z=0;z<$.length;z++)Y[z]=$.charCodeAt(z);return Y}function eZ(Z){return{isFile:!!Z.isFile,isDirectory:!!Z.isDirectory,isSymlink:!!Z.isSymlink,size:Number(Z.size)||0,modifiedAt:Z.modifiedAt!=null?Z.modifiedAt<1000000000000?Z.modifiedAt*1000:Z.modifiedAt:0}}var _=new Set,FZ=!1;function Z4(){if(FZ)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(Z)=>{let $=Z.detail;if($?.id)_.delete($.id)}),FZ=!0}var $4=new Set(["javascript:","data:","file:","vbscript:"]),_8={async openExternal(Z){let $=Z.trim().toLowerCase();for(let Y of $4)if($.startsWith(Y))throw Error(`shell.openExternal: ${Y} URLs are blocked for safety`);if(J("shell")){await window.craft.shell.openExternal(Z);return}if(typeof window<"u"&&typeof window.open==="function")window.open(Z,"_blank","noopener,noreferrer")},async openPath(Z){await V("shell").openPath(Z)},async showInFinder(Z){await V("shell").showInFinder(Z)},async spawn(Z,$,Y=[],z={}){if(Z4(),!Z||typeof Z!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!$||typeof $!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(Y))throw Error("shell.spawn: args must be an array");for(let G of Y)if(typeof G!=="string")throw Error("shell.spawn: args entries must be strings");if(_.has(Z))throw Error(`shell.spawn: id "${Z}" is already in use \u2014 call kill(id) first or pick a different id`);_.add(Z);try{await V("shell").spawn(Z,$,Y,z)}catch(G){throw _.delete(Z),G}},async kill(Z){await V("shell").kill(Z),_.delete(Z)},async getEnv(Z){if(J("shell")){let $=await window.craft.shell.getEnv(Z);return $==null?void 0:String($)}return},async setEnv(Z,$){await V("shell").setEnv(Z,$)},onStdout(Z){return Q("craft:shell:stdout",Z)},onStderr(Z){return Q("craft:shell:stderr",Z)},onExit(Z){return Q("craft:shell:exit",Z)}};function S(){return window.craft.shortcuts}var C8={async register(Z,$,Y){if(!J("shortcuts"))return;await S().register(Z,$,Y)},async unregister(Z){if(!J("shortcuts"))return;await S().unregister(Z)},async unregisterAll(){if(!J("shortcuts"))return;await S().unregisterAll()},async enable(Z){if(!J("shortcuts"))return;await S().enable(Z)},async disable(Z){if(!J("shortcuts"))return;await S().disable(Z)},async isRegistered(Z){if(!J("shortcuts"))return!1;return await S().isRegistered(Z)},async list(){if(!J("shortcuts"))return[];return await S().list()},on(Z){return Q("craft:shortcut",Z)}};var y8={get(){if(J("theme"))try{return window.craft.theme.get()}catch{}return{appearance:J4()}},onChange(Z){if(Z(this.get()),J("theme"))return Q("craft:theme",Z);if(typeof window<"u"&&window.matchMedia){let $=window.matchMedia("(prefers-color-scheme: dark)"),Y=()=>Z({appearance:$.matches?"dark":"light"});return $.addEventListener("change",Y),()=>$.removeEventListener("change",Y)}return()=>{}},async current(){return this.get()}};function J4(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function v8(Z,$={}){if(!J("dragOut"))throw Error("dragOut requires a Craft native window");let Y=Array.isArray(Z)?Z:[Z];if(Y.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(Y,$)}function m8(){return J("dragOut")}var l8={onUrl(Z){if(!J("deepLink"))return()=>{};return Q("craft:deepLink",Z)},getInitialUrl(){if(typeof window>"u")return null;if(J("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let Z=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return Z},isAvailable(){return J("deepLink")}};var c8={async isCharging(){if(J("power"))return await window.craft.power.isCharging();let Z=await m();return Z?!!Z.charging:!1},async isPluggedIn(){if(J("power"))return await window.craft.power.isPluggedIn();let Z=await m();return Z?!!Z.charging||Z.level>=0.999:!1},async isLowPowerMode(){if(J("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(J("power")){let $=await window.craft.power.batteryLevel();return typeof $==="number"?$:null}let Z=await m();return Z?Z.level:null},async timeRemaining(){if(J("power")){let Y=await window.craft.power.timeRemaining();return typeof Y==="number"?Y:null}let Z=await m();if(!Z)return null;let $=Z.charging?Z.chargingTime:Z.dischargingTime;return Number.isFinite($)?Math.round($/60):null},async thermalState(){if(J("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(J("power"))return await window.craft.power.uptimeSeconds();if(typeof performance<"u"&&typeof performance.now==="function")return Math.round(performance.now()/1000);return 0},async preventSleep(Z="app is busy"){if(J("power")){await window.craft.power.preventSleep(Z);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let $=window;if($.__craftWebWakeLock?.release){try{await $.__craftWebWakeLock.release()}catch{}$.__craftWebWakeLock=null}try{let Y=await navigator.wakeLock.request("screen");$.__craftWebWakeLock=Y}catch{}},async allowSleep(){if(J("power")){await window.craft.power.allowSleep();return}let Z=window.__craftWebWakeLock;if(Z&&typeof Z.release==="function"){try{await Z.release()}catch{}window.__craftWebWakeLock=null}},onSleep(Z){return Q("craft:powerSleep",Z)},onWake(Z){return Q("craft:powerWake",Z)}};async function m(){if(typeof navigator>"u")return null;let Z=navigator;if(typeof Z.getBattery!=="function")return null;try{return await Z.getBattery()}catch{return null}}var r8={async connectionType(){if(J("network"))return await window.craft.network.connectionType();return jZ()},async wifiSSID(){if(J("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(J("network")){let Z=await window.craft.network.wifiSignalStrength();return typeof Z==="number"?Z:void 0}return},async ipAddress(){if(J("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(J("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(J("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(J("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(J("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(J("network"))await window.craft.network.openPreferences()},onChange(Z){if(J("network"))return Q("craft:networkChange",Z);if(typeof window>"u")return()=>{};let $=()=>Z({type:jZ(),online:!0}),Y=()=>Z({type:"none",online:!1});return window.addEventListener("online",$),window.addEventListener("offline",Y),()=>{window.removeEventListener("online",$),window.removeEventListener("offline",Y)}}};function jZ(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let Z=navigator.connection;if(!Z)return"unknown";let $=String(Z.type||Z.effectiveType||"unknown").toLowerCase();if($==="wifi"||$==="cellular"||$==="ethernet"||$==="bluetooth"||$==="none")return $;return"unknown"}var a8={async checkForUpdates(){if(!J("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!J("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(Z){if(!J("updater"))return;await window.craft.updater.setAutomaticChecks(Z)},async setCheckInterval(Z){if(!J("updater"))return;if(!Number.isFinite(Z))throw Error("setCheckInterval: must be a finite number");let $=Z<=0?0:Math.max(60,Math.round(Z));await window.craft.updater.setCheckInterval($)},async setFeedURL(Z){if(!J("updater"))return;await window.craft.updater.setFeedURL(Z)},async getLastUpdateCheckDate(){if(!J("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!J("updater"))return null;let Z=await window.craft.updater.getUpdateInfo();if(!Z||typeof Z.version!=="string"||Z.version.length===0)return null;return Z},onAvailable(Z){return Q("craft:updateAvailable",Z)},onDownloaded(Z){return Q("craft:updateDownloaded",Z)},async verifySignature({payload:Z,signatureB64:$,publicKeyB64:Y}){let z=WZ(Z),G;try{G=await crypto.subtle.importKey("raw",b(Y),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",G,b($),z)}catch{return!1}},async verifyDownload({url:Z,signatureB64:$,publicKeyB64:Y,fetchInit:z}){let G;try{G=await fetch(Z,z)}catch{return{ok:!1,reason:"fetch-failed"}}if(!G.ok)return{ok:!1,reason:"http-error",status:G.status};let X=new Uint8Array(await G.arrayBuffer()),O;try{O=await crypto.subtle.importKey("raw",b(Y),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let P=!1;try{P=await crypto.subtle.verify("Ed25519",O,b($),WZ(X))}catch{P=!1}if(!P)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:X}}};function WZ(Z){if(Z instanceof ArrayBuffer)return new Uint8Array(Z);let $=new ArrayBuffer(Z.byteLength),Y=new Uint8Array($);return Y.set(Z),Y}function b(Z){if(typeof atob==="function"){let z=atob(Z),G=new ArrayBuffer(z.length),X=new Uint8Array(G);for(let O=0;O<z.length;O++)X[O]=z.charCodeAt(O);return X}let $=Buffer.from(Z,"base64"),Y=new ArrayBuffer($.length);return new Uint8Array(Y).set($),new Uint8Array(Y)}var t8={onFocus(Z){if(J("window"))return Q("craft:window:focus",()=>Z());return n("focus",Z)},onBlur(Z){if(J("window"))return Q("craft:window:blur",()=>Z());return n("blur",Z)},onResize(Z){if(J("window"))return Q("craft:window:resize",Z);if(typeof window>"u")return()=>{};let $=()=>Z({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)},onMove(Z){if(J("window"))return Q("craft:window:move",Z);return()=>{}},onClose(Z){if(J("window"))return Q("craft:window:close",()=>Z());return n("beforeunload",Z)},onMinimize(Z){if(J("window"))return Q("craft:window:minimize",()=>Z());if(typeof document>"u")return()=>{};let $=()=>{if(document.visibilityState==="hidden")Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)},onRestore(Z){if(J("window"))return Q("craft:window:restore",()=>Z());if(typeof document>"u")return()=>{};let $=()=>{if(document.visibilityState==="visible")Z()};return document.addEventListener("visibilitychange",$),()=>document.removeEventListener("visibilitychange",$)}};function n(Z,$){if(typeof window>"u")return()=>{};let Y=()=>$();return window.addEventListener(Z,Y),()=>window.removeEventListener(Z,Y)}var KZ={name:"",version:"0.0.0"},$$={async hideDockIcon(){if(J("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(J("app"))await window.craft.app.showDockIcon()},async quit(){if(J("app"))await window.craft.app.quit()},async getInfo(){if(!J("app"))return KZ;let Z=await window.craft.app.getInfo();return{...KZ,...Z||{}}},async notify(Z){if(!Z.title)throw Error("notify: title is required");if(J("app"))await window.craft.app.notify(Z)},async setBadge(Z){if(J("app"))await window.craft.app.setBadge(Z)},async bounce(Z="informational"){if(J("app"))await window.craft.app.bounce(Z)}};var z$={app(Z,$={}){return{label:Z,items:[{label:`About ${Z}`,role:"about"},{separator:!0},...$.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:$.settings},{separator:!0}]:[],{label:`Hide ${Z}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${Z}`,role:"quit",shortcut:"cmd+q"}]}},edit(){return{label:"Edit",items:[{label:"Undo",role:"undo",shortcut:"cmd+z"},{label:"Redo",role:"redo",shortcut:"cmd+shift+z"},{separator:!0},{label:"Cut",role:"cut",shortcut:"cmd+x"},{label:"Copy",role:"copy",shortcut:"cmd+c"},{label:"Paste",role:"paste",shortcut:"cmd+v"},{label:"Select All",role:"selectAll",shortcut:"cmd+a"}]}},window(){return{label:"Window",items:[{label:"Minimize",role:"minimize",shortcut:"cmd+m"},{label:"Zoom",role:"zoom"},{separator:!0},{label:"Close Window",role:"close",shortcut:"cmd+w"}]}},leading(Z,$={}){return[this.app(Z,$),this.edit()]}},Y4=0;function z4(Z){let $=new Map;return{payload:{menus:Z.menus.map((z)=>({label:z.label,items:z.items.map((G)=>{let{onClick:X,...O}=G;if(O.separator)return O;let P=O.id??`stx.menu.${Y4++}`;if(X)$.set(P,X);return{...O,id:P}})}))},handlers:$}}var o=null,G$={async set(Z){if(!J("menu"))return!1;let{payload:$,handlers:Y}=z4(Z);if(o?.(),o=null,Y.size>0)o=Q("craft:menu:action",(z)=>{Y.get(z.id)?.()});return await window.craft.menu.set($),!0},async setDock(Z){if(J("menu"))await window.craft.menu.setDock(Z)},async addItem(Z,$){if(J("menu"))await window.craft.menu.addItem(Z,$)},async removeItem(Z){if(J("menu"))await window.craft.menu.removeItem(Z)},async enableItem(Z){if(J("menu"))await window.craft.menu.enableItem(Z)},async disableItem(Z){if(J("menu"))await window.craft.menu.disableItem(Z)},async checkItem(Z){if(J("menu"))await window.craft.menu.checkItem(Z)},async uncheckItem(Z){if(J("menu"))await window.craft.menu.uncheckItem(Z)},async setItemLabel(Z,$){if(J("menu"))await window.craft.menu.setItemLabel(Z,$)},async clearDock(){if(J("menu"))await window.craft.menu.clearDock()},onAction(Z){return Q("craft:menu:action",Z)}};function LZ(Z){if(Z.separator)return{id:Z.id||"",title:"",type:"separator"};return{id:Z.id||"",title:Z.title||"",icon:Z.icon,shortcut:Z.shortcut,enabled:Z.disabled?!1:void 0,checked:Z.checked?!0:void 0,type:Z.submenu?"submenu":void 0,submenu:Z.submenu?.map(LZ)}}async function RZ(Z){if(!Z.items||Z.items.length===0)throw Error("contextMenu.show requires at least one item");if(!J("nativeUI"))return null;let $=await window.craft.nativeUI.showContextMenu({targetId:Z.targetId||"",targetType:"general",x:Math.round(Z.x),y:Math.round(Z.y),items:Z.items.map(LZ)});return{id:typeof $?.id==="string"?$.id:null,targetId:$?.targetId}}var P$={available(){return J("nativeUI")},async show(Z){return await RZ(Z)!==null},async pick(Z){return(await RZ(Z))?.id??null},onAction(Z){return Q("craft:contextmenu:action",($)=>{if(typeof $.id==="string")Z({id:$.id,targetId:$.targetId??""})})}};function a(Z){if(Z===null||Z===void 0||Z===0)return"";return String(Z)}function DZ(Z){return Z.map(($)=>({id:$.id,header:$.header,items:$.items.map((Y)=>({id:Y.id,label:Y.label,icon:Y.icon,badge:a(Y.badge)||void 0}))}))}function NZ(Z){return JSON.stringify(Z.map(($)=>[$.id,$.header??"",$.items.map((Y)=>[Y.id,Y.label,Y.icon??""])]))}function kZ(Z){return new Map(Z.flatMap(($)=>$.items.map((Y)=>[Y.id,a(Y.badge)])))}var G4={available(){return J("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(Z){if(!G4.available())return null;let $=window.craft.nativeUI.createSidebar({id:Z.id,sections:DZ(Z.sections),selected:Z.selected}),Y=Z.sections,z=new Set;return $.onSelect((G)=>{for(let X of[...z])X(G)}),{id:$.id,update(G){if(NZ(G)===NZ(Y)){let X=kZ(Y);for(let[O,P]of kZ(G))if(X.get(O)!==P)$.updateItem(O,{badge:P})}else $.setSections(DZ(G));Y=G},updateItem(G,X){$.updateItem(G,{...X.label!==void 0?{label:X.label}:{},...X.icon!==void 0?{icon:X.icon}:{},..."badge"in X?{badge:a(X.badge)}:{}}),Y=Y.map((O)=>({...O,items:O.items.map((P)=>P.id===G?{...P,...X}:P)}))},select(G){$.setSelectedItem(G)},onSelect(G){return z.add(G),()=>z.delete(G)},destroy(){z.clear(),$.destroy()}}}};var W$={async getDisplays(){if(J("screen"))return await window.craft.screen.getDisplays();return qZ()},async getPrimary(){if(J("screen")){let Z=await window.craft.screen.getPrimary();return Z&&typeof Z.width==="number"?Z:null}return qZ()[0]??null},onChange(Z){if(J("screen"))return Q("craft:screen:change",()=>Z());if(typeof window>"u")return()=>{};let $=()=>Z();return window.addEventListener("resize",$),()=>window.removeEventListener("resize",$)}};function qZ(){if(typeof window>"u"||!window.screen)return[];let Z=window.screen;return[{id:0,x:Z.left??0,y:Z.top??0,width:Z.width||0,height:Z.height||0,workX:Z.availLeft??0,workY:Z.availTop??0,workWidth:Z.availWidth??Z.width??0,workHeight:Z.availHeight??Z.height??0,scaleFactor:window.devicePixelRatio||1}]}var L$={async set(Z,$,Y){if(!Z)throw Error("keychain.set: service is required");if(!$)throw Error("keychain.set: account is required");await V("keychain").set(Z,$,Y)},async get(Z,$){if(!Z)throw Error("keychain.get: service is required");if(!$)throw Error("keychain.get: account is required");let Y=await V("keychain").get(Z,$);return typeof Y==="string"?Y:null},async delete(Z,$){if(!Z)throw Error("keychain.delete: service is required");if(!$)throw Error("keychain.delete: account is required");await V("keychain").delete(Z,$)},async has(Z,$){if(!Z)throw Error("keychain.has: service is required");if(!$)throw Error("keychain.has: account is required");return await V("keychain").has(Z,$)}};var k$={async check(Z){if(J("permissions"))return await window.craft.permissions.check(Z);return await HZ(Z)},async request(Z){if(J("permissions"))return await window.craft.permissions.request(Z);return await Q4(Z)},async openSettings(Z){if(J("permissions"))await window.craft.permissions.openSettings(Z)}};async function HZ(Z){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let $=await navigator.permissions.query({name:Z});return X4($.state)}catch{return"not-supported"}}async function Q4(Z){if(Z==="notifications"&&typeof window<"u"&&"Notification"in window){let $=await window.Notification.requestPermission();return $==="granted"?"granted":$==="denied"?"denied":"undetermined"}return await HZ(Z)}function X4(Z){if(Z==="granted")return"granted";if(Z==="denied")return"denied";if(Z==="prompt")return"undetermined";return"undetermined"}var U$={async print(){if(J("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(Z){if(!Z)throw Error("printToPDF: path is required");let $=Z.startsWith("/"),Y=/^[a-zA-Z]:[\\/]/.test(Z)||Z.startsWith("\\\\");if(!$&&!Y)throw Error("printToPDF: path must be absolute");let z=await V("printing").printToPDF(Z);return{ok:!!(z&&z.ok),path:z?.path}}};var A$={async enable(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!J("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};function i(){if(!J("window"))return null;return window.craft.window}function k(Z){let $=i();if(!$)return Promise.resolve();try{return Promise.resolve(Z($)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var x$={get available(){return i()!==null},open(Z){let $=()=>{if(typeof window<"u"&&Z.url)window.open(Z.url,Z.name);return{name:Z.name}},Y=i();if(!Y?.open)return Promise.resolve($());return Y.open(Z).then((z)=>({name:z?.name||Z.name})).catch($)},close:()=>k((Z)=>Z.close?.()),focus:()=>k((Z)=>Z.focus?.()),minimize:()=>k((Z)=>Z.minimize?.()),maximize:()=>k((Z)=>Z.maximize?.()),center:()=>k((Z)=>Z.center?.()),startDrag:()=>k((Z)=>Z.startDrag?.()),setTitle:(Z)=>k(($)=>$.setTitle?.(Z)),setSize:(Z,$)=>k((Y)=>Y.setSize?.(Z,$)),setAppearance:(Z)=>k(($)=>$.setAppearance?.(Z))};var w$={async addItem(Z){if(J("touchbar"))await window.craft.touchbar.addItem(Z)},async removeItem(Z){if(J("touchbar"))await window.craft.touchbar.removeItem(Z)},async updateItem(Z,$){if(J("touchbar"))await window.craft.touchbar.updateItem(Z,$)},async setLabel(Z,$){if(J("touchbar"))await window.craft.touchbar.setLabel(Z,$)},async setIcon(Z,$){if(J("touchbar"))await window.craft.touchbar.setIcon(Z,$)},async setEnabled(Z,$){if(J("touchbar"))await window.craft.touchbar.setEnabled(Z,$)},async setSliderValue(Z,$){if(J("touchbar"))await window.craft.touchbar.setSliderValue(Z,$)},async clear(){if(J("touchbar"))await window.craft.touchbar.clear()},async show(){if(J("touchbar"))await window.craft.touchbar.show()},async hide(){if(J("touchbar"))await window.craft.touchbar.hide()},onAction(Z){return Q("craft:touchbar:action",Z)}};var P4=/^[\da-f]*$/i;function O4(Z,$){if(typeof $!=="string"||!P4.test($)||$.length%2!==0)throw Error(`${Z}: must be a hex string with even length, got ${JSON.stringify($)}`)}var f$={async isEnabled(){return J("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return J("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return J("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return J("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(J("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(J("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return J("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(Z){if(J("bluetooth"))await window.craft.bluetooth.connect(Z)},async disconnect(Z){if(J("bluetooth"))await window.craft.bluetooth.disconnect(Z)},async openPreferences(){if(J("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(Z){if(!Z)throw Error("bluetooth.discoverServices: deviceId is required");if(!J("bluetooth"))return[];let $=await window.craft.bluetooth.discoverServices(Z);return Array.isArray($)?$:[]},async discoverCharacteristics(Z,$){if(!Z||!$)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!J("bluetooth"))return[];let Y=await window.craft.bluetooth.discoverCharacteristics(Z,$);return Array.isArray(Y)?Y:[]},async readCharacteristic(Z,$,Y){if(!Z||!$||!Y)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(Z,$,Y)},async writeCharacteristic(Z,$,Y,z,G="with-response"){if(!Z||!$||!Y)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(O4("bluetooth.writeCharacteristic.valueHex",z),!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(Z,$,Y,z,G)},async setCharacteristicNotify(Z,$,Y,z){if(!Z||!$||!Y)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!J("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(Z,$,Y,z)},onDeviceFound(Z){return Q("craft:bluetooth:deviceFound",Z)},onDeviceConnected(Z){return Q("craft:bluetooth:deviceConnected",Z)},onDeviceDisconnected(Z){return Q("craft:bluetooth:deviceDisconnected",Z)},onCharacteristicValue(Z){return Q("craft:bluetooth:characteristicValue",Z)}};var m$={async speak(Z,$){if(!Z)throw Error("speech.speak: text is required");if(J("speech")){await window.craft.speech.speak(Z,$);return}if(typeof window<"u"&&window.speechSynthesis){let Y=new window.SpeechSynthesisUtterance(Z);if($){if($.rate!=null)Y.rate=$.rate;if($.pitch!=null)Y.pitch=$.pitch;if($.volume!=null)Y.volume=$.volume;if($.voice){let G=window.speechSynthesis.getVoices().find((X)=>X.voiceURI===$.voice||X.name===$.voice||X.lang===$.voice);if(G)Y.voice=G}}window.speechSynthesis.speak(Y)}},async stop(){if(J("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(J("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(J("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(J("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(J("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map(($)=>({id:$.voiceURI||$.name,name:$.name,language:$.lang||"",quality:"default"}));return[]}};var x=[],s=!0,t,e,u={async report(Z){if(J("crashReporter")){await window.craft.crashReporter.report(Z);return}if(!s)return;let $=Z instanceof Error?{timestamp:Date.now(),severity:"error",message:Z.message,source:"js",stack:Z.stack||"",userId:t,appVersion:e}:{timestamp:Date.now(),severity:Z.severity||"error",message:Z.message||"",source:Z.source||"js",stack:Z.stack||"",userId:t,appVersion:e};if(x.length>=64)x.shift();x.push($)},async flush(){if(J("crashReporter"))return await window.craft.crashReporter.flush();return[...x]},async clear(){if(J("crashReporter")){await window.craft.crashReporter.clear();return}x.length=0},async setEnabled(Z){if(J("crashReporter")){await window.craft.crashReporter.setEnabled(Z);return}s=Z},async isEnabled(){if(J("crashReporter"))return await window.craft.crashReporter.isEnabled();return s},async setUser(Z){if(J("crashReporter")){await window.craft.crashReporter.setUser(Z);return}t=Z||void 0},async setAppVersion(Z){if(J("crashReporter")){await window.craft.crashReporter.setAppVersion(Z);return}e=Z||void 0},attachGlobalHandlers(){if(J("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let Z=(Y)=>{u.report({severity:"error",message:Y.message,source:"js",stack:Y.error?.stack||`${Y.message}
|
|
311
311
|
at ${Y.filename}:${Y.lineno}:${Y.colno}`}).catch(()=>{})},$=(Y)=>{let z=Y.reason;u.report({severity:"error",message:z?.message||String(z),source:"js",stack:z?.stack||""}).catch(()=>{})};return window.addEventListener("error",Z),window.addEventListener("unhandledrejection",$),()=>{window.removeEventListener("error",Z),window.removeEventListener("unhandledrejection",$)}},forwardTo(Z){return D4(Z)}},V4="craft:crashReporter:pending",F4=/[\w.+-]+@[\w-]+\.[\w.-]+/g,j4=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,W4=/\/(?:Users|home)\/[^\s/'"`]+/g;function K4(Z){let $=(Y)=>Y.replace(F4,"<email>").replace(j4,"<ip>").replace(W4,"/<home>");return{...Z,message:$(Z.message),stack:$(Z.stack)}}async function R4(Z,$){let Y=new TextEncoder,z=await crypto.subtle.importKey("raw",Y.encode(Z),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),G=await crypto.subtle.sign("HMAC",z,Y.encode($));return[...new Uint8Array(G)].map((X)=>X.toString(16).padStart(2,"0")).join("")}function L4(Z){if(!Z||typeof localStorage>"u")return[];try{let $=localStorage.getItem(Z);if(!$)return[];let Y=JSON.parse($);return Array.isArray(Y)?Y:[]}catch{return[]}}function UZ(Z,$){if(!Z||typeof localStorage>"u")return;try{if($.length===0)localStorage.removeItem(Z);else localStorage.setItem(Z,JSON.stringify($))}catch{}}function D4(Z){let{endpoint:$,intervalMs:Y=60000,signingSecret:z,redact:G=!0,headers:X={},maxRetries:O=5,persistKey:P}=Z,F=P===null?null:P??V4,j=L4(F),R=!1,q=null,L=null,xZ=typeof G==="function"?G:G===!1?(H)=>H:K4;async function EZ(H){let E=JSON.stringify({entries:H}),C={"Content-Type":"application/json",...X};if(z)C["X-Craft-Signature"]=await R4(z,E);let JZ=0,g=1000;while(!R)try{let A=await fetch($,{method:"POST",headers:C,body:E});if(A.ok)return;if(A.status>=400&&A.status<500)return;throw Error(`HTTP ${A.status}`)}catch(A){if(JZ+=1,JZ>O)throw j=[...H,...j],UZ(F,j),A;await new Promise((CZ)=>{setTimeout(CZ,g)}),g=Math.min(g*2,60000)}}async function $Z(){if(R||L)return L??void 0;let H=await u.flush();if(H.length>0)await u.clear();if(j=[...j,...H.map((C)=>xZ(C))],j.length===0)return;let E=j;return j=[],UZ(F,j),L=EZ(E).catch(()=>{}).finally(()=>{L=null}),L}if(Y>0)q=setInterval(()=>{$Z().catch(()=>{})},Y);return{async flushNow(){await $Z()},stop(){if(R=!0,q)clearInterval(q);q=null},pending(){return[...j]}}}var c$={async isAvailable(){if(!J("iap"))return!1;return await window.craft.iap.isAvailable()},async getProducts(Z){if(!J("iap"))return[];let $=Array.isArray(Z)?Z:[String(Z)];return await window.craft.iap.getProducts($)},async purchase(Z){if(!J("iap"))return{queued:!1,productId:Z,reason:"IAP bridge not available"};let $=await window.craft.iap.purchase(Z);return{queued:!!($&&$.queued),productId:$?.productId,reason:$?.reason}},async restorePurchases(){if(!J("iap"))return{ok:!1};let Z=await window.craft.iap.restorePurchases();return{ok:!!(Z&&Z.ok)}},async finishTransaction(Z){if(!J("iap"))return;await window.craft.iap.finishTransaction(Z)},async getReceiptData(){if(!J("iap"))return null;let Z=await window.craft.iap.getReceiptData();return Z?String(Z):null},onPurchased(Z){return Q("craft:iap:purchased",Z)},onFailed(Z){return Q("craft:iap:failed",Z)},onRestored(Z){return Q("craft:iap:restored",Z)},onProductsLoaded(Z){return Q("craft:iap:productsLoaded",($)=>Z($.products||[]))},onRefunded(Z){return Q("craft:iap:refunded",Z)},onSubscriptionStatusChanged(Z){return Q("craft:iap:subscriptionStatusChanged",Z)},async getActiveSubscriptions(){if(!J("iap"))return[];let Z=window.craft.iap.getActiveSubscriptions;if(typeof Z!=="function")return[];let $=await Z();return Array.isArray($)?$:[]},async isEligibleForIntroOffer(Z){if(!J("iap"))return!1;let $=window.craft.iap.isEligibleForIntroOffer;if(typeof $!=="function")return!1;return!!await $(Z)}};var l={async startActivity(Z,$){if(!Z)throw Error("handoff.startActivity: type is required");if(!J("handoff"))return!1;let Y=await window.craft.handoff.startActivity(Z,$);return typeof Y==="boolean"?Y:!!(Y&&Y.ok)},async updateActivity(Z){if(!J("handoff"))return!1;let $=await window.craft.handoff.updateActivity(Z);return typeof $==="boolean"?$:!!($&&$.ok)},async stopActivity(){if(!J("handoff"))return;await window.craft.handoff.stopActivity()},async getCurrentActivity(){if(!J("handoff"))return null;let Z=await window.craft.handoff.getCurrentActivity();return Z&&typeof Z.type==="string"?Z:null},onIncoming(Z){return Q("craft:handoff:incoming",Z)}};var o$={async start(Z,$){return l.startActivity(Z,{title:$?.title,webpageURL:$?.webpageURL,userInfo:$?.state})},async update(Z){return l.updateActivity({title:Z.title,webpageURL:Z.webpageURL,userInfo:Z.state})},async stop(){await l.stopActivity()}};var s$={async requestPermission(Z="whenInUse"){if(J("location"))return await window.craft.location.requestPermission(Z);if(typeof navigator<"u"&&navigator.geolocation)return"undetermined";return"not-supported"},async getAuthorization(){if(J("location"))return await window.craft.location.getAuthorization();return"unknown"},async getCurrentLocation(){if(J("location"))return await window.craft.location.getCurrentLocation();if(typeof navigator<"u"&&navigator.geolocation)return navigator.geolocation.getCurrentPosition((Z)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:Z.coords.latitude,longitude:Z.coords.longitude,altitude:Z.coords.altitude,horizontalAccuracy:Z.coords.accuracy,verticalAccuracy:Z.coords.altitudeAccuracy,speed:Z.coords.speed}}))},(Z)=>{window.dispatchEvent(new CustomEvent("craft:location:error",{detail:{message:Z.message||String(Z)}}))}),{requested:!0};return{requested:!1}},async startWatching(Z){if(J("location"))return await window.craft.location.startWatching(Z);if(typeof navigator<"u"&&navigator.geolocation){let $=navigator.geolocation.watchPosition((Y)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:Y.coords.latitude,longitude:Y.coords.longitude,altitude:Y.coords.altitude,horizontalAccuracy:Y.coords.accuracy,verticalAccuracy:Y.coords.altitudeAccuracy,speed:Y.coords.speed}}))});return window.__craftWebLocationWatchId=$,!0}return!1},async stopWatching(){if(J("location")){await window.craft.location.stopWatching();return}if(typeof navigator<"u"&&navigator.geolocation){let Z=window.__craftWebLocationWatchId;if(Z!=null)navigator.geolocation.clearWatch(Z),window.__craftWebLocationWatchId=null}},onUpdate(Z){return Q("craft:location:update",Z)},onError(Z){return Q("craft:location:error",Z)},onAuthChanged(Z){return Q("craft:location:authChanged",Z)}};var ZJ={async captureScreen(){if(!J("screenCapture"))return null;let Z=await window.craft.screenCapture.captureScreen();return Z?String(Z):null},async captureWindow(Z){if(!J("screenCapture"))return null;if(!Number.isFinite(Z)||Z<=0)throw Error("captureWindow: id must be a positive number");let $=await window.craft.screenCapture.captureWindow(Z);return $?String($):null},async listWindows(){if(!J("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var N4=250,k4=60000,SZ=2000,MZ={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function q4(){return{...MZ,signals:{...MZ.signals},sources:[]}}var ZZ={async getState(){if(!J("screenSharing"))return q4();return await window.craft.screenSharing.getState()},async watch(Z=SZ){let $=Math.min(k4,Math.max(N4,Math.round(Z)));if(!J("screenSharing"))return $;let Y=await window.craft.screenSharing.watch($);return Y&&Y.intervalMs||$},async stop(){if(!J("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(Z){return Q("craft:screenSharing:change",Z)}};async function YJ(Z,$=SZ){let Y=ZZ.onChange(Z);return await ZZ.watch($),()=>{Y(),ZZ.stop()}}var H4={supported:!1,isFocused:null,authorization:"unsupported"};function AZ(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var TZ={async getStatus(){if(!J("focus"))return{...H4};return await window.craft.focus.getStatus()},async requestAuthorization(){if(!J("focus"))return"unsupported";return await window.craft.focus.requestAuthorization()},async setEnabled(Z,$={}){if(!J("focus"))return AZ();if(!(Z?$.onShortcut:$.offShortcut))return{ok:!1,error:`focus.setEnabled: no ${Z?"onShortcut":"offShortcut"} configured`};return await window.craft.focus.setEnabled(Z,$)},async runShortcut(Z){if(!J("focus"))return AZ();if(!Z)throw Error("focus.runShortcut: name is required");return await window.craft.focus.runShortcut(Z)},async listShortcuts(){if(!J("focus"))return[];return await window.craft.focus.listShortcuts()},async listShortcutsResult(){if(!J("focus"))return{canList:!1,shortcuts:[]};let $=await window.craft.focus.listShortcutsResult?.();return{canList:Boolean($?.canList),shortcuts:$?.shortcuts??[]}}};async function QJ(...Z){if(Z.length===0)return!1;let $=new Set(await TZ.listShortcuts());return Z.every((Y)=>$.has(Y))}async function XJ(...Z){if(Z.length===0)return!1;let{canList:$,shortcuts:Y}=await TZ.listShortcutsResult();if(!$)return"unknown";let z=new Set(Y);return Z.every((G)=>z.has(G))}var VJ={async start(Z=0,$="127.0.0.1"){if(!J("localServer"))return{port:0,started:!1,reason:"bridge unavailable"};return await window.craft.localServer.start(Z,$)},async stop(){if(!J("localServer"))return;await window.craft.localServer.stop()},async respond(Z){if(!J("localServer"))return;await window.craft.localServer.respond(Z||{status:200,body:"OK"})},onRequest(Z){return Q("craft:localServer:request",Z)},async awaitOAuthCallback(Z={}){V("localServer");let{port:$=0,host:Y="127.0.0.1",timeoutMs:z=300000,successHTML:G}=Z,X=await this.start($,Y);if(!X.started)throw Error(`localServer: start failed${X.reason?` \u2014 ${X.reason}`:""}`);return new Promise((O,P)=>{let F=setTimeout(()=>{j(),this.stop().catch(()=>{}),P(Error("localServer: OAuth callback timed out"))},z),j=this.onRequest(({url:R})=>{clearTimeout(F),j();let q=G??`<!doctype html><meta charset="utf-8"><title>Done</title>
|
|
312
312
|
<style>body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7}</style>
|
|
313
313
|
<div><h1>You can close this tab.</h1><p>Returning to the app\u2026</p></div>
|
package/dist/index.d.ts
CHANGED
|
@@ -155,7 +155,7 @@ export type {
|
|
|
155
155
|
} from './updater';
|
|
156
156
|
export type { WindowEvents, WindowPosition, WindowSize } from './window-events';
|
|
157
157
|
export type { AppAPI, AppInfo, AppNotifyOptions } from './app-info';
|
|
158
|
-
export type { ApplicationMenu, Menu, MenuActionEvent, MenuAPI, MenuItem, MenuRole } from './menu';
|
|
158
|
+
export type { ApplicationMenu, Menu, MenuActionEvent, MenuAPI, MenuItem, MenuRole, StandardMenuOptions } from './menu';
|
|
159
159
|
export type {
|
|
160
160
|
ContextMenuAPI,
|
|
161
161
|
ContextMenuActionEvent,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$ as Q1,$a as Q2,A as x0,Aa as C1,B as H0,Ba as x1,C as v0,Ca as H1,D as w0,Da as v1,E as f0,Ea as w1,F as S0,Fa as f1,G as g0,Ga as S1,H as b0,Ha as g1,I as y0,Ia as b1,J as u0,Ja as y1,K as h0,Ka as u1,L as m0,La as h1,M as c0,Ma as m1,N as d0,Na as c1,O as p0,Oa as d1,P as r0,Pa as p1,Q as n0,Qa as r1,R as o0,Ra as n1,S as l0,Sa as o1,T as a0,Ta as l1,U as i0,Ua as a1,V as s0,Va as i1,W as t0,Wa as s1,X as e0,Xa as t1,Y as n,Ya as e1,Z as Y1,Za as Y2,_ as Z1,_a as Z2,a as $0,aa as X1,ab as X2,b as J0,ba as $1,bb as $2,c as G0,ca as J1,cb as J2,d as R0,da as G1,db as G2,e as q0,ea as R1,eb as R2,f as K0,fa as q1,fb as q2,g as U0,ga as K1,h as _0,ha as U1,i as E0,ia as _1,j as F0,ja as E1,k as j0,ka as F1,l as B0,la as j1,m as V0,ma as B1,n as O0,na as V1,o as z0,oa as O1,p as M0,pa as z1,q as L0,qa as M1,r as T0,ra as L1,s as D0,sa as T1,t as W0,ta as D1,u as P0,ua as W1,v as A0,va as P1,w as N0,wa as A1,x as I0,xa as N1,y as k0,ya as I1,z as C0,za as k1}from"./chunk-
|
|
2
|
+
import{$ as Q1,$a as Q2,A as x0,Aa as C1,B as H0,Ba as x1,C as v0,Ca as H1,D as w0,Da as v1,E as f0,Ea as w1,F as S0,Fa as f1,G as g0,Ga as S1,H as b0,Ha as g1,I as y0,Ia as b1,J as u0,Ja as y1,K as h0,Ka as u1,L as m0,La as h1,M as c0,Ma as m1,N as d0,Na as c1,O as p0,Oa as d1,P as r0,Pa as p1,Q as n0,Qa as r1,R as o0,Ra as n1,S as l0,Sa as o1,T as a0,Ta as l1,U as i0,Ua as a1,V as s0,Va as i1,W as t0,Wa as s1,X as e0,Xa as t1,Y as n,Ya as e1,Z as Y1,Za as Y2,_ as Z1,_a as Z2,a as $0,aa as X1,ab as X2,b as J0,ba as $1,bb as $2,c as G0,ca as J1,cb as J2,d as R0,da as G1,db as G2,e as q0,ea as R1,eb as R2,f as K0,fa as q1,fb as q2,g as U0,ga as K1,h as _0,ha as U1,i as E0,ia as _1,j as F0,ja as E1,k as j0,ka as F1,l as B0,la as j1,m as V0,ma as B1,n as O0,na as V1,o as z0,oa as O1,p as M0,pa as z1,q as L0,qa as M1,r as T0,ra as L1,s as D0,sa as T1,t as W0,ta as D1,u as P0,ua as W1,v as A0,va as P1,w as N0,wa as A1,x as I0,xa as N1,y as k0,ya as I1,z as C0,za as k1}from"./chunk-hgcnqp53.js";import{gb as N}from"./chunk-gzgq8v6d.js";function z(Y="stx"){return`${Y}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function F(Y){return Y.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function O(...Y){return Y.filter(Boolean).join(" ")}function V(Y){if(!Y)return"";return Object.entries(Y).map(([Z,Q])=>`${Z.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${Q}`).join("; ")}function OY(Y){let{text:Z,variant:Q="primary",size:X="medium",disabled:$=!1,loading:J=!1,icon:K,iconPosition:R="left",id:G=z("btn"),className:_,style:U}=Y,E=O("stx-button",`stx-button--${Q}`,`stx-button--${X}`,$&&"stx-button--disabled",J&&"stx-button--loading",_),q=V(U),j=K?`<span class="stx-button-icon">${K}</span>`:"",B=J?'<span class="stx-button-spinner"></span>':"",M=R==="left"?`${j}${B}<span class="stx-button-text">${F(Z)}</span>`:`<span class="stx-button-text">${F(Z)}</span>${j}${B}`;return`<button id="${G}" class="${E}" ${$||J?"disabled":""} ${q?`style='${q}'`:""}>${M}</button>`}function zY(Y){let{value:Z="",placeholder:Q="",type:X="text",disabled:$=!1,readonly:J=!1,maxLength:K,minLength:R,pattern:G,required:_=!1,autocomplete:U,label:E,error:q,hint:j,id:B=z("input"),className:M,style:L}=Y,T=O("stx-input",q&&"stx-input--error",$&&"stx-input--disabled",M),w=V(L),VY=[`type="${X}"`,`id="${B}"`,`class="${T}"`,Z&&`value="${F(Z)}"`,Q&&`placeholder="${F(Q)}"`,$&&"disabled",J&&"readonly",_&&"required",K&&`maxlength="${K}"`,R&&`minlength="${R}"`,G&&`pattern="${F(G)}"`,U&&`autocomplete="${U}"`,w&&`style="${w}"`].filter(Boolean).join(" "),x="";if(E)x+=`<label class="stx-input-label" for="${B}">${F(E)}</label>`;if(x+=`<input ${VY} />`,q)x+=`<div class="stx-input-error">${F(q)}</div>`;else if(j)x+=`<div class="stx-input-hint">${F(j)}</div>`;return`<div class="stx-input-wrapper">${x}</div>`}function MY(Y){let{checked:Z=!1,label:Q,disabled:X=!1,indeterminate:$=!1,id:J=z("checkbox"),className:K,style:R}=Y,G=O("stx-checkbox",X&&"stx-checkbox--disabled",K),_=V(R),U=['type="checkbox"',`id="${J}"`,Z&&"checked",X&&"disabled",$&&'data-indeterminate="true"'].filter(Boolean).join(" ");return`
|
|
3
3
|
<label class="${G}" ${_?`style="${_}"`:""}>
|
|
4
4
|
<input ${U} />
|
|
5
5
|
<span class="stx-checkbox-box"></span>
|
package/dist/menu.d.ts
CHANGED
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
* menu — which it only does for menus it recognises.
|
|
10
10
|
*/
|
|
11
11
|
export declare const standardMenus: {
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The application menu. Must be first in the bar; AppKit titles it for you.
|
|
14
|
+
* Pass `settings` and it gets "Settings…" with Cmd+, after About, where
|
|
15
|
+
* every Mac app keeps it.
|
|
16
|
+
*/
|
|
17
|
+
app: (appName: string, options?: StandardMenuOptions) => Menu;
|
|
14
18
|
/** Undo/redo and the clipboard. Roles throughout, which is the only way these work. */
|
|
15
19
|
edit: () => Menu;
|
|
16
20
|
/** Minimise, zoom and close. */
|
|
@@ -21,7 +25,7 @@ export declare const standardMenus: {
|
|
|
21
25
|
* Spread this first and add your own menus after: the app menu has to be
|
|
22
26
|
* index zero, and Edit is the one people notice missing.
|
|
23
27
|
*/
|
|
24
|
-
leading: (appName: string) => Menu[]
|
|
28
|
+
leading: (appName: string, options?: StandardMenuOptions) => Menu[]
|
|
25
29
|
};
|
|
26
30
|
export declare const menu: MenuAPI;
|
|
27
31
|
export declare interface MenuItem {
|
|
@@ -73,6 +77,9 @@ export declare interface MenuAPI {
|
|
|
73
77
|
clearDock: () => Promise<void>
|
|
74
78
|
onAction: (cb: (event: MenuActionEvent) => void) => () => void
|
|
75
79
|
}
|
|
80
|
+
export declare interface StandardMenuOptions {
|
|
81
|
+
settings?: () => void
|
|
82
|
+
}
|
|
76
83
|
/**
|
|
77
84
|
* The stock behaviours macOS already knows how to perform.
|
|
78
85
|
*
|
package/package.json
CHANGED