@stacksjs/desktop 0.2.662 → 0.2.663
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/index.js +1 -1
- package/dist/native-tray.d.ts +3 -3
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -342,4 +342,4 @@ window.stxDialog = {
|
|
|
342
342
|
background: #555;
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
-
`;var $n={async enable(){if(!r("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!r("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!r("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};function X(){if(!r("window"))return null;return window.craft.window}function w(e){let t=X();if(!t)return Promise.resolve();try{return Promise.resolve(e(t)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var Kn={get available(){return X()!==null},open(e){let t=()=>{if(typeof window<"u"&&e.url)window.open(e.url,e.name);return{name:e.name}},n=X();if(!n?.open)return Promise.resolve(t());return n.open(e).then((i)=>({name:i?.name||e.name})).catch(t)},close:()=>w((e)=>e.close?.()),show:()=>w((e)=>e.show?.()),hide:()=>w((e)=>e.hide?.()),focus:()=>w((e)=>e.focus?.()),minimize:()=>w((e)=>e.minimize?.()),maximize:()=>w((e)=>e.maximize?.()),center:()=>w((e)=>e.center?.()),startDrag:()=>w((e)=>e.startDrag?.()),setTitle:(e)=>w((t)=>t.setTitle?.(e)),setSize:(e,t)=>w((n)=>n.setSize?.(e,t)),setAppearance:(e)=>w((t)=>t.setAppearance?.(e))};async function J(e){if(!r("tray"))return;let t=window.craft.tray;await e(t)}var Gn={setIcon:(e)=>J((t)=>t.setIcon({icon:e})),setTitle:(e)=>J((t)=>t.setTitle({title:e})),setTooltip:(e)=>J((t)=>t.setTooltip({tooltip:e}))};var Qn={async connectionType(){if(r("network"))return await window.craft.network.connectionType();return he()},async wifiSSID(){if(r("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(r("network")){let e=await window.craft.network.wifiSignalStrength();return typeof e==="number"?e:void 0}return},async ipAddress(){if(r("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(r("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(r("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(r("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(r("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(r("network"))await window.craft.network.openPreferences()},onChange(e){if(r("network"))return a("craft:networkChange",e);if(typeof window>"u")return()=>{};let t=()=>e({type:he(),online:!0}),n=()=>e({type:"none",online:!1});return window.addEventListener("online",t),window.addEventListener("offline",n),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}};function he(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let e=navigator.connection;if(!e)return"unknown";let t=String(e.type||e.effectiveType||"unknown").toLowerCase();if(t==="wifi"||t==="cellular"||t==="ethernet"||t==="bluetooth"||t==="none")return t;return"unknown"}var ti={async show(e){if(!e.title)throw Error("notification title is required");if(r("notifications")){await window.craft.notifications.show(e);return}if(typeof window<"u"&&"Notification"in window){let t=window.Notification;if(t.permission==="granted")new t(e.title,{body:e.body,icon:e.icon});else if(t.permission==="default"){if(await t.requestPermission()==="granted")new t(e.title,{body:e.body,icon:e.icon})}}},async schedule(e){if(r("notifications")){let i={...e};if(i.triggerAt instanceof Date)i.triggerAt=i.triggerAt.toISOString();await window.craft.notifications.schedule(i);return}let t=gt(e.triggerAt),n=Math.max(0,t-Date.now());setTimeout(()=>{this.show(e).catch(()=>{})},n)},async cancel(e){if(r("notifications"))await window.craft.notifications.cancel(e)},async cancelAll(){if(r("notifications"))await window.craft.notifications.cancelAll()},async setBadge(e){let t=Math.max(0,Math.round(Number.isFinite(e)?e:0));if(r("notifications")){await window.craft.notifications.setBadge(t);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(t)}catch{}},async clearBadge(){if(r("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(r("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let e=window.Notification;if(e.permission==="granted")return!0;if(e.permission==="denied")return!1;return await e.requestPermission()==="granted"}return!1},async registerCategories(e){if(!Array.isArray(e)||e.length===0)return;if(r("notifications")){let t=window.craft.notifications.registerCategories;if(typeof t==="function")await t(e)}},onActionClicked(e){return a("craft:notification:actionClicked",e)},onReply(e){return a("craft:notification:reply",e)}};function gt(e){if(e==null)return Date.now();if(e instanceof Date)return e.getTime();if(typeof e==="number")return e;let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}var ii={async countPages(e){if(!e)throw Error("pdf.countPages: path is required");if(!r("pdf"))return 0;return await window.craft.pdf.countPages(e)},async extractText(e){if(!e)throw Error("pdf.extractText: path is required");if(!r("pdf"))return"";return await window.craft.pdf.extractText(e)}};var si={async check(e){if(r("permissions"))return await window.craft.permissions.check(e);return await ve(e)},async request(e){if(r("permissions"))return await window.craft.permissions.request(e);return await wt(e)},async openSettings(e){if(r("permissions"))await window.craft.permissions.openSettings(e)}};async function ve(e){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let t=await navigator.permissions.query({name:e});return ht(t.state)}catch{return"not-supported"}}async function wt(e){if(e==="notifications"&&typeof window<"u"&&"Notification"in window){let t=await window.Notification.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"undetermined"}return await ve(e)}function ht(e){if(e==="granted")return"granted";if(e==="denied")return"denied";if(e==="prompt")return"undetermined";return"undetermined"}var li={async print(){if(r("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(e){if(!e)throw Error("printToPDF: path is required");let t=e.startsWith("/"),n=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\");if(!t&&!n)throw Error("printToPDF: path must be absolute");let i=await l("printing").printToPDF(e);return{ok:!!(i&&i.ok),path:i?.path}}};var pi={async getDisplays(){if(r("screen"))return await window.craft.screen.getDisplays();return ye()},async getPrimary(){if(r("screen")){let e=await window.craft.screen.getPrimary();return e&&typeof e.width==="number"?e:null}return ye()[0]??null},onChange(e){if(r("screen"))return a("craft:screen:change",()=>e());if(typeof window>"u")return()=>{};let t=()=>e();return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}};function ye(){if(typeof window>"u"||!window.screen)return[];let e=window.screen;return[{id:0,x:e.left??0,y:e.top??0,width:e.width||0,height:e.height||0,workX:e.availLeft??0,workY:e.availTop??0,workWidth:e.availWidth??e.width??0,workHeight:e.availHeight??e.height??0,scaleFactor:window.devicePixelRatio||1}]}var wi={async captureScreen(){if(!r("screenCapture"))return null;let e=await window.craft.screenCapture.captureScreen();return e?String(e):null},async captureWindow(e){if(!r("screenCapture"))return null;if(!Number.isFinite(e)||e<=0)throw Error("captureWindow: id must be a positive number");let t=await window.craft.screenCapture.captureWindow(e);return t?String(t):null},async listWindows(){if(!r("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var vt=250,yt=60000,Z=2000,be={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function bt(){return{...be,signals:{...be.signals},sources:[]}}var Q={async getState(){if(!r("screenSharing"))return bt();return await window.craft.screenSharing.getState()},async watch(e=Z){let t=Number.isFinite(e)?Math.min(yt,Math.max(vt,Math.round(e))):Z;if(!r("screenSharing"))return t;let n=await window.craft.screenSharing.watch(t);return n&&n.intervalMs||t},async stop(){if(!r("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(e){return a("craft:screenSharing:change",e)}};async function yi(e,t=Z){let n=Q.onChange(e);try{await Q.watch(t)}catch(o){throw n(),o}let i;return()=>{if(!i)n(),i=Q.stop();return i}}var Pi={async list(){if(!r("serial"))return[];return await window.craft.serial.list()},async open(e,t=9600){if(!e)throw Error("serial.open: path is required");if(!r("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(e,t)},async write(e,t){if(!e)throw Error("serial.write: id is required");if(!r("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(e,t)},async close(e){if(!r("serial"))return;await window.craft.serial.close(e)},onData(e){return a("craft:serial:data",e)}};var Ii={async register(e){if(!e)throw Error("serviceMenu.register: name is required");if(!r("serviceMenu"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serviceMenu.register(e)},async unregister(e){if(!e)throw Error("serviceMenu.unregister: name is required");if(!r("serviceMenu"))return;await window.craft.serviceMenu.unregister(e)},onInvoked(e){return a("craft:serviceMenu:invoked",e)}};var E=new Set,xe=!1;function xt(){if(xe)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(e)=>{let t=e.detail;if(t?.id)E.delete(t.id)}),xe=!0}var Pt=new Set(["javascript:","data:","file:","vbscript:"]),Ci={async openExternal(e){let t=e.trim().toLowerCase();for(let n of Pt)if(t.startsWith(n))throw Error(`shell.openExternal: ${n} URLs are blocked for safety`);if(r("shell")){await window.craft.shell.openExternal(e);return}if(typeof window<"u"&&typeof window.open==="function")window.open(e,"_blank","noopener,noreferrer")},async openPath(e){await l("shell").openPath(e)},async showInFinder(e){await l("shell").showInFinder(e)},async spawn(e,t,n=[],i={}){if(xt(),!e||typeof e!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!t||typeof t!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(n))throw Error("shell.spawn: args must be an array");for(let o of n)if(typeof o!=="string")throw Error("shell.spawn: args entries must be strings");if(E.has(e))throw Error(`shell.spawn: id "${e}" is already in use — call kill(id) first or pick a different id`);E.add(e);try{await l("shell").spawn(e,t,n,i)}catch(o){throw E.delete(e),o}},async kill(e){await l("shell").kill(e),E.delete(e)},async getEnv(e){if(r("shell")){let t=await window.craft.shell.getEnv(e);return t==null?void 0:String(t)}return},async setEnv(e,t){await l("shell").setEnv(e,t)},onStdout(e){return a("craft:shell:stdout",e)},onStderr(e){return a("craft:shell:stderr",e)},onExit(e){return a("craft:shell:exit",e)}};function ee(e){if(e===null||e===void 0||e===0)return"";return String(e)}function Pe(e){return e.map((t)=>({id:t.id,header:t.header,items:t.items.map((n)=>({id:n.id,label:n.label,icon:n.icon,badge:ee(n.badge)||void 0}))}))}function Se(e){return JSON.stringify(e.map((t)=>[t.id,t.header??"",t.items.map((n)=>[n.id,n.label,n.icon??""])]))}function Ae(e){return new Map(e.flatMap((t)=>t.items.map((n)=>[n.id,ee(n.badge)])))}var St={available(){return r("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(e){if(!St.available())return null;let t=window.craft?.nativeUI;if(!t)return null;let n=t.createSidebar({id:e.id,sections:Pe(e.sections),selected:e.selected}),i=e.sections,o=new Set;return n.onSelect((s)=>{for(let c of[...o])c(s)}),{id:n.id,update(s){if(Se(s)===Se(i)){let c=Ae(i);for(let[d,u]of Ae(s))if(c.get(d)!==u)n.updateItem(d,{badge:u})}else n.setSections(Pe(s));i=s},updateItem(s,c){n.updateItem(s,{...c.label!==void 0?{label:c.label}:{},...c.icon!==void 0?{icon:c.icon}:{},..."badge"in c?{badge:ee(c.badge)}:{}}),i=i.map((d)=>({...d,items:d.items.map((u)=>u.id===s?{...u,...c}:u)}))},select(s){n.setSelectedItem(s)},onSelect(s){return o.add(s),()=>o.delete(s)},destroy(){o.clear(),n.destroy()}}}};var Ri={async speak(e,t){if(!e)throw Error("speech.speak: text is required");if(r("speech")){await window.craft.speech.speak(e,t);return}if(typeof window<"u"&&window.speechSynthesis){let n=new window.SpeechSynthesisUtterance(e);if(t){if(t.rate!=null)n.rate=t.rate;if(t.pitch!=null)n.pitch=t.pitch;if(t.volume!=null)n.volume=t.volume;if(t.voice){let o=window.speechSynthesis.getVoices().find((s)=>s.voiceURI===t.voice||s.name===t.voice||s.lang===t.voice);if(o)n.voice=o}}window.speechSynthesis.speak(n)}},async stop(){if(r("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(r("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(r("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(r("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(r("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((t)=>({id:t.voiceURI||t.name,name:t.name,language:t.lang||"",quality:"default"}));return[]}};var _i={async isAvailable(){if(!r("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(e){if(!r("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(e)},async stop(){if(r("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(e){return a("craft:speechRecognition:partial",e)},onFinal(e){return a("craft:speechRecognition:final",e)}};var qi={async index(e){if(!r("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(e)},async remove(e){if(!r("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(e)},async removeAll(){if(!r("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var Wi={async get(e){if(!e)throw Error("tags.get: path is required");if(!r("tags"))return[];return await window.craft.tags.get(e)},async set(e,t){if(!e)throw Error("tags.set: path is required");if(!r("tags"))return!1;let n=Array.isArray(t)?t:[String(t)];return await window.craft.tags.set(e,n)},async clear(e){if(!e)throw Error("tags.clear: path is required");if(!r("tags"))return!1;return await window.craft.tags.clear(e)}};var ji={get(){if(r("theme"))try{return window.craft.theme.get()}catch{}return{appearance:At()}},onChange(e){if(e(this.get()),r("theme"))return a("craft:theme",e);if(typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>e({appearance:t.matches?"dark":"light"});return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}return()=>{}},async current(){return this.get()}};function At(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}class Ie{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(e){if(this._duration=e.duration,this._tickInterval=e.tickInterval||1000,this._remaining=e.duration,e.onComplete)this._completionHandlers.add(e.onComplete);if(e.onTick)this._tickHandlers.add(e.onTick);if(e.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 e=Date.now()-this._lastTick;return Math.max(0,this._remaining-e)}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 e=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-e),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(e){return this._completionHandlers.add(e),()=>{this._completionHandlers.delete(e)}}onTick(e){return this._tickHandlers.add(e),()=>{this._tickHandlers.delete(e)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let e=Date.now(),t=e-this._lastTick;this._lastTick=e,this._remaining=Math.max(0,this._remaining-t);for(let n of this._tickHandlers)try{n(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let n of this._completionHandlers)try{n()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class ke{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(e){if(this._interval=e.interval,this._handler=e.handler,this._immediate=e.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 Vi(e){return new Ie(e)}function Yi(e){return new ke(e)}function Gi(e){return new Promise((t)=>setTimeout(t,e))}function Xi(e){let t=Math.ceil(e/1000),n=Math.floor(t/3600),i=Math.floor(t%3600/60),o=t%60;if(n>0)return`${n}:${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`;return`${i}:${String(o).padStart(2,"0")}`}function Ji(e){let t=Math.ceil(e/1000),n=Math.floor(t/3600),i=Math.floor(t%3600/60),o=t%60;if(n>0){if(i>0)return`${n}h ${i}m`;return`${n}h`}if(i>0){if(o>0)return`${i}m ${o}s`;return`${i}m`}return`${o}s`}var eo={async addItem(e){if(r("touchbar"))await window.craft.touchbar.addItem(e)},async removeItem(e){if(r("touchbar"))await window.craft.touchbar.removeItem(e)},async updateItem(e,t){if(r("touchbar"))await window.craft.touchbar.updateItem(e,t)},async setLabel(e,t){if(r("touchbar"))await window.craft.touchbar.setLabel(e,t)},async setIcon(e,t){if(r("touchbar"))await window.craft.touchbar.setIcon(e,t)},async setEnabled(e,t){if(r("touchbar"))await window.craft.touchbar.setEnabled(e,t)},async setSliderValue(e,t){if(r("touchbar"))await window.craft.touchbar.setSliderValue(e,t)},async clear(){if(r("touchbar"))await window.craft.touchbar.clear()},async show(){if(r("touchbar"))await window.craft.touchbar.show()},async hide(){if(r("touchbar"))await window.craft.touchbar.hide()},onAction(e){return a("craft:touchbar:action",e)}};var no={async checkForUpdates(){if(!r("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!r("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(e){if(!r("updater"))return;await window.craft.updater.setAutomaticChecks(e)},async setCheckInterval(e){if(!r("updater"))return;if(!Number.isFinite(e))throw Error("setCheckInterval: must be a finite number");let t=e<=0?0:Math.max(60,Math.round(e));await window.craft.updater.setCheckInterval(t)},async setFeedURL(e){if(!r("updater"))return;await window.craft.updater.setFeedURL(e)},async getLastUpdateCheckDate(){if(!r("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!r("updater"))return null;let e=await window.craft.updater.getUpdateInfo();if(!e||typeof e.version!=="string"||e.version.length===0)return null;return e},onAvailable(e){return a("craft:updateAvailable",e)},onDownloaded(e){return a("craft:updateDownloaded",e)},async verifySignature({payload:e,signatureB64:t,publicKeyB64:n}){let i=Ee(e),o;try{o=await crypto.subtle.importKey("raw",N(n),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",o,N(t),i)}catch{return!1}},async verifyDownload({url:e,signatureB64:t,publicKeyB64:n,fetchInit:i}){let o;try{o=await fetch(e,i)}catch{return{ok:!1,reason:"fetch-failed"}}if(!o.ok)return{ok:!1,reason:"http-error",status:o.status};let s=new Uint8Array(await o.arrayBuffer()),c;try{c=await crypto.subtle.importKey("raw",N(n),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let d=!1;try{d=await crypto.subtle.verify("Ed25519",c,N(t),Ee(s))}catch{d=!1}if(!d)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:s}}};function Ee(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t);return n.set(e),n}function N(e){if(typeof atob==="function"){let i=atob(e),o=new ArrayBuffer(i.length),s=new Uint8Array(o);for(let c=0;c<i.length;c++)s[c]=i.charCodeAt(c);return s}let t=Buffer.from(e,"base64"),n=new ArrayBuffer(t.length);return new Uint8Array(n).set(t),new Uint8Array(n)}var ao={async recognizeText(e){if(!e)throw Error("vision.recognizeText: path is required");if(!r("vision"))return[];return await window.craft.vision.recognizeText(e)},async detectFaces(e){if(!e)throw Error("vision.detectFaces: path is required");if(!r("vision"))return[];return await window.craft.vision.detectFaces(e)},async detectBarcodes(e){if(!e)throw Error("vision.detectBarcodes: path is required");if(!r("vision"))return[];return await window.craft.vision.detectBarcodes(e)}};var lo={onFocus(e){if(r("window"))return a("craft:window:focus",()=>e());return te("focus",e)},onBlur(e){if(r("window"))return a("craft:window:blur",()=>e());return te("blur",e)},onResize(e){if(r("window"))return a("craft:window:resize",e);if(typeof window>"u")return()=>{};let t=()=>e({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},onMove(e){if(r("window"))return a("craft:window:move",e);return()=>{}},onClose(e){if(r("window"))return a("craft:window:close",()=>e());return te("beforeunload",e)},onMinimize(e){if(r("window"))return a("craft:window:minimize",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="hidden")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},onRestore(e){if(r("window"))return a("craft:window:restore",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="visible")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)}};function te(e,t){if(typeof window>"u")return()=>{};let n=()=>t();return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function It(e,t={}){if(!Number.isInteger(e)||e<0||e>86400000)return Promise.reject(RangeError("delayMs must be an integer between 0 and 86400000"));let{signal:n}=t,i=()=>new DOMException("Background delay aborted","AbortError");if(n?.aborted)return Promise.reject(i());if(r("timers"))return l("timers").sleep(e,t);if(typeof window<"u"&&window.craft)return Promise.reject(Error("Native background deadlines require a Craft runtime with timers.sleep support"));return new Promise((o,s)=>{let c=setTimeout(()=>{n?.removeEventListener("abort",d),o()},e);function d(){clearTimeout(c),n?.removeEventListener("abort",d),s(i())}n?.addEventListener("abort",d,{once:!0})})}export{Z as DEFAULT_WATCH_INTERVAL_MS,yt as MAX_WATCH_INTERVAL_MS,vt as MIN_WATCH_INTERVAL_MS,Un as MODAL_STYLES,Ot as TOAST_STYLES,_n as alert,qt as app,Wt as appleScript,jt as audio,It as backgroundDelay,Yt as battery,Jt as biometric,er as bluetooth,nr as bonjour,lr as clipboard,qn as closeAllModals,On as confirm,pr as contextMenu,wr as continuityCamera,yr as coreml,R as crashReporter,Yi as createInterval,Vi as createTimer,Ar as deepLinks,Gi as delay,Tt as dismissAlertById,Rt as dismissAllAlerts,_r as dragOut,Ur as fileAssociations,me as focus,zr as focusShortcutsReady,Ji as formatCompact,en as formatShortcut,Xi as formatTime,Vr as fs,Lt as getActiveAlertCount,Nn as getActiveModalCount,ar as getCapabilities,Ne as getCapability,Rr as getDialogBridgeScript,nn as getRegisteredHotkeys,Xr as globalShortcuts,O as handoff,$r as hasFocusShortcuts,cn as iap,sr as isAvailable,Fr as isDragOutAvailable,un as keychain,mn as liveActivities,hn as localServer,bn as location,Sn as log,En as menu,Bn as midi,$n as nativeAutoLaunch,Gn as nativeTray,Kn as nativeWindow,Qn as network,ti as notifications,Dt as notify,rt as parseShortcut,ii as pdf,si as permissions,li as printing,Fn as prompt,ze as redactPII,tn as registerHotkey,kt as requestNotificationPermission,pi as screen,wi as screenCapture,Q as screenSharing,Pi as serial,Ii as serviceMenu,Ci as shell,oe as showAlert,Mr as showAlertDialog,Cr as showColorPicker,Br as showConfirmDialog,Dr as showErrorDialog,Rn as showErrorModal,Bt as showErrorToast,pt as showInfoModal,Et as showInfoToast,L as showMessageBox,k as showModal,kr as showOpenDialog,mt as showQuestionModal,Er as showSaveDialog,Ln as showSuccessModal,Ct as showSuccessToast,D as showToast,Tr as showWarningDialog,Tn as showWarningModal,Mt as showWarningToast,St as sidebar,je as signPayload,Ri as speech,_i as speechRecognition,qi as spotlight,kn as standardMenus,Wi as tags,ji as theme,eo as touchbar,rn as unregisterAllHotkeys,at as unregisterHotkey,no as updater,ao as vision,yi as watchScreenSharing,lo as windowEvents};
|
|
345
|
+
`;var $n={async enable(){if(!r("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!r("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!r("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};function X(){if(!r("window"))return null;return window.craft.window}function w(e){let t=X();if(!t)return Promise.resolve();try{return Promise.resolve(e(t)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var Kn={get available(){return X()!==null},open(e){let t=()=>{if(typeof window<"u"&&e.url)window.open(e.url,e.name);return{name:e.name}},n=X();if(!n?.open)return Promise.resolve(t());return n.open(e).then((i)=>({name:i?.name||e.name})).catch(t)},close:()=>w((e)=>e.close?.()),show:()=>w((e)=>e.show?.()),hide:()=>w((e)=>e.hide?.()),focus:()=>w((e)=>e.focus?.()),minimize:()=>w((e)=>e.minimize?.()),maximize:()=>w((e)=>e.maximize?.()),center:()=>w((e)=>e.center?.()),startDrag:()=>w((e)=>e.startDrag?.()),setTitle:(e)=>w((t)=>t.setTitle?.(e)),setSize:(e,t)=>w((n)=>n.setSize?.(e,t)),setAppearance:(e)=>w((t)=>t.setAppearance?.(e))};async function J(e){if(!r("tray"))return;let t=window.craft.tray;await e(t)}var Gn={setIcon:(e)=>J((t)=>t.setIcon(e)),setTitle:(e)=>J((t)=>t.setTitle(e)),setTooltip:(e)=>J((t)=>t.setTooltip(e))};var Qn={async connectionType(){if(r("network"))return await window.craft.network.connectionType();return he()},async wifiSSID(){if(r("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(r("network")){let e=await window.craft.network.wifiSignalStrength();return typeof e==="number"?e:void 0}return},async ipAddress(){if(r("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(r("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(r("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(r("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(r("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(r("network"))await window.craft.network.openPreferences()},onChange(e){if(r("network"))return a("craft:networkChange",e);if(typeof window>"u")return()=>{};let t=()=>e({type:he(),online:!0}),n=()=>e({type:"none",online:!1});return window.addEventListener("online",t),window.addEventListener("offline",n),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}};function he(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let e=navigator.connection;if(!e)return"unknown";let t=String(e.type||e.effectiveType||"unknown").toLowerCase();if(t==="wifi"||t==="cellular"||t==="ethernet"||t==="bluetooth"||t==="none")return t;return"unknown"}var ti={async show(e){if(!e.title)throw Error("notification title is required");if(r("notifications")){await window.craft.notifications.show(e);return}if(typeof window<"u"&&"Notification"in window){let t=window.Notification;if(t.permission==="granted")new t(e.title,{body:e.body,icon:e.icon});else if(t.permission==="default"){if(await t.requestPermission()==="granted")new t(e.title,{body:e.body,icon:e.icon})}}},async schedule(e){if(r("notifications")){let i={...e};if(i.triggerAt instanceof Date)i.triggerAt=i.triggerAt.toISOString();await window.craft.notifications.schedule(i);return}let t=gt(e.triggerAt),n=Math.max(0,t-Date.now());setTimeout(()=>{this.show(e).catch(()=>{})},n)},async cancel(e){if(r("notifications"))await window.craft.notifications.cancel(e)},async cancelAll(){if(r("notifications"))await window.craft.notifications.cancelAll()},async setBadge(e){let t=Math.max(0,Math.round(Number.isFinite(e)?e:0));if(r("notifications")){await window.craft.notifications.setBadge(t);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(t)}catch{}},async clearBadge(){if(r("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(r("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let e=window.Notification;if(e.permission==="granted")return!0;if(e.permission==="denied")return!1;return await e.requestPermission()==="granted"}return!1},async registerCategories(e){if(!Array.isArray(e)||e.length===0)return;if(r("notifications")){let t=window.craft.notifications.registerCategories;if(typeof t==="function")await t(e)}},onActionClicked(e){return a("craft:notification:actionClicked",e)},onReply(e){return a("craft:notification:reply",e)}};function gt(e){if(e==null)return Date.now();if(e instanceof Date)return e.getTime();if(typeof e==="number")return e;let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}var ii={async countPages(e){if(!e)throw Error("pdf.countPages: path is required");if(!r("pdf"))return 0;return await window.craft.pdf.countPages(e)},async extractText(e){if(!e)throw Error("pdf.extractText: path is required");if(!r("pdf"))return"";return await window.craft.pdf.extractText(e)}};var si={async check(e){if(r("permissions"))return await window.craft.permissions.check(e);return await ve(e)},async request(e){if(r("permissions"))return await window.craft.permissions.request(e);return await wt(e)},async openSettings(e){if(r("permissions"))await window.craft.permissions.openSettings(e)}};async function ve(e){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let t=await navigator.permissions.query({name:e});return ht(t.state)}catch{return"not-supported"}}async function wt(e){if(e==="notifications"&&typeof window<"u"&&"Notification"in window){let t=await window.Notification.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"undetermined"}return await ve(e)}function ht(e){if(e==="granted")return"granted";if(e==="denied")return"denied";if(e==="prompt")return"undetermined";return"undetermined"}var li={async print(){if(r("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(e){if(!e)throw Error("printToPDF: path is required");let t=e.startsWith("/"),n=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\");if(!t&&!n)throw Error("printToPDF: path must be absolute");let i=await l("printing").printToPDF(e);return{ok:!!(i&&i.ok),path:i?.path}}};var pi={async getDisplays(){if(r("screen"))return await window.craft.screen.getDisplays();return ye()},async getPrimary(){if(r("screen")){let e=await window.craft.screen.getPrimary();return e&&typeof e.width==="number"?e:null}return ye()[0]??null},onChange(e){if(r("screen"))return a("craft:screen:change",()=>e());if(typeof window>"u")return()=>{};let t=()=>e();return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}};function ye(){if(typeof window>"u"||!window.screen)return[];let e=window.screen;return[{id:0,x:e.left??0,y:e.top??0,width:e.width||0,height:e.height||0,workX:e.availLeft??0,workY:e.availTop??0,workWidth:e.availWidth??e.width??0,workHeight:e.availHeight??e.height??0,scaleFactor:window.devicePixelRatio||1}]}var wi={async captureScreen(){if(!r("screenCapture"))return null;let e=await window.craft.screenCapture.captureScreen();return e?String(e):null},async captureWindow(e){if(!r("screenCapture"))return null;if(!Number.isFinite(e)||e<=0)throw Error("captureWindow: id must be a positive number");let t=await window.craft.screenCapture.captureWindow(e);return t?String(t):null},async listWindows(){if(!r("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var vt=250,yt=60000,Z=2000,be={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function bt(){return{...be,signals:{...be.signals},sources:[]}}var Q={async getState(){if(!r("screenSharing"))return bt();return await window.craft.screenSharing.getState()},async watch(e=Z){let t=Number.isFinite(e)?Math.min(yt,Math.max(vt,Math.round(e))):Z;if(!r("screenSharing"))return t;let n=await window.craft.screenSharing.watch(t);return n&&n.intervalMs||t},async stop(){if(!r("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(e){return a("craft:screenSharing:change",e)}};async function yi(e,t=Z){let n=Q.onChange(e);try{await Q.watch(t)}catch(o){throw n(),o}let i;return()=>{if(!i)n(),i=Q.stop();return i}}var Pi={async list(){if(!r("serial"))return[];return await window.craft.serial.list()},async open(e,t=9600){if(!e)throw Error("serial.open: path is required");if(!r("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.open(e,t)},async write(e,t){if(!e)throw Error("serial.write: id is required");if(!r("serial"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serial.write(e,t)},async close(e){if(!r("serial"))return;await window.craft.serial.close(e)},onData(e){return a("craft:serial:data",e)}};var Ii={async register(e){if(!e)throw Error("serviceMenu.register: name is required");if(!r("serviceMenu"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.serviceMenu.register(e)},async unregister(e){if(!e)throw Error("serviceMenu.unregister: name is required");if(!r("serviceMenu"))return;await window.craft.serviceMenu.unregister(e)},onInvoked(e){return a("craft:serviceMenu:invoked",e)}};var E=new Set,xe=!1;function xt(){if(xe)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(e)=>{let t=e.detail;if(t?.id)E.delete(t.id)}),xe=!0}var Pt=new Set(["javascript:","data:","file:","vbscript:"]),Ci={async openExternal(e){let t=e.trim().toLowerCase();for(let n of Pt)if(t.startsWith(n))throw Error(`shell.openExternal: ${n} URLs are blocked for safety`);if(r("shell")){await window.craft.shell.openExternal(e);return}if(typeof window<"u"&&typeof window.open==="function")window.open(e,"_blank","noopener,noreferrer")},async openPath(e){await l("shell").openPath(e)},async showInFinder(e){await l("shell").showInFinder(e)},async spawn(e,t,n=[],i={}){if(xt(),!e||typeof e!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!t||typeof t!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(n))throw Error("shell.spawn: args must be an array");for(let o of n)if(typeof o!=="string")throw Error("shell.spawn: args entries must be strings");if(E.has(e))throw Error(`shell.spawn: id "${e}" is already in use — call kill(id) first or pick a different id`);E.add(e);try{await l("shell").spawn(e,t,n,i)}catch(o){throw E.delete(e),o}},async kill(e){await l("shell").kill(e),E.delete(e)},async getEnv(e){if(r("shell")){let t=await window.craft.shell.getEnv(e);return t==null?void 0:String(t)}return},async setEnv(e,t){await l("shell").setEnv(e,t)},onStdout(e){return a("craft:shell:stdout",e)},onStderr(e){return a("craft:shell:stderr",e)},onExit(e){return a("craft:shell:exit",e)}};function ee(e){if(e===null||e===void 0||e===0)return"";return String(e)}function Pe(e){return e.map((t)=>({id:t.id,header:t.header,items:t.items.map((n)=>({id:n.id,label:n.label,icon:n.icon,badge:ee(n.badge)||void 0}))}))}function Se(e){return JSON.stringify(e.map((t)=>[t.id,t.header??"",t.items.map((n)=>[n.id,n.label,n.icon??""])]))}function Ae(e){return new Map(e.flatMap((t)=>t.items.map((n)=>[n.id,ee(n.badge)])))}var St={available(){return r("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(e){if(!St.available())return null;let t=window.craft?.nativeUI;if(!t)return null;let n=t.createSidebar({id:e.id,sections:Pe(e.sections),selected:e.selected}),i=e.sections,o=new Set;return n.onSelect((s)=>{for(let c of[...o])c(s)}),{id:n.id,update(s){if(Se(s)===Se(i)){let c=Ae(i);for(let[d,u]of Ae(s))if(c.get(d)!==u)n.updateItem(d,{badge:u})}else n.setSections(Pe(s));i=s},updateItem(s,c){n.updateItem(s,{...c.label!==void 0?{label:c.label}:{},...c.icon!==void 0?{icon:c.icon}:{},..."badge"in c?{badge:ee(c.badge)}:{}}),i=i.map((d)=>({...d,items:d.items.map((u)=>u.id===s?{...u,...c}:u)}))},select(s){n.setSelectedItem(s)},onSelect(s){return o.add(s),()=>o.delete(s)},destroy(){o.clear(),n.destroy()}}}};var Ri={async speak(e,t){if(!e)throw Error("speech.speak: text is required");if(r("speech")){await window.craft.speech.speak(e,t);return}if(typeof window<"u"&&window.speechSynthesis){let n=new window.SpeechSynthesisUtterance(e);if(t){if(t.rate!=null)n.rate=t.rate;if(t.pitch!=null)n.pitch=t.pitch;if(t.volume!=null)n.volume=t.volume;if(t.voice){let o=window.speechSynthesis.getVoices().find((s)=>s.voiceURI===t.voice||s.name===t.voice||s.lang===t.voice);if(o)n.voice=o}}window.speechSynthesis.speak(n)}},async stop(){if(r("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(r("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(r("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(r("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(r("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((t)=>({id:t.voiceURI||t.name,name:t.name,language:t.lang||"",quality:"default"}));return[]}};var _i={async isAvailable(){if(!r("speechRecognition"))return!1;return await window.craft.speechRecognition.isAvailable()},async start(e){if(!r("speechRecognition"))return{started:!1,reason:"bridge unavailable"};return await window.craft.speechRecognition.start(e)},async stop(){if(r("speechRecognition"))await window.craft.speechRecognition.stop()},onPartial(e){return a("craft:speechRecognition:partial",e)},onFinal(e){return a("craft:speechRecognition:final",e)}};var qi={async index(e){if(!r("spotlight"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.spotlight.index(e)},async remove(e){if(!r("spotlight"))return{ok:!1};return await window.craft.spotlight.remove(e)},async removeAll(){if(!r("spotlight"))return{ok:!1};return await window.craft.spotlight.removeAll()}};var Wi={async get(e){if(!e)throw Error("tags.get: path is required");if(!r("tags"))return[];return await window.craft.tags.get(e)},async set(e,t){if(!e)throw Error("tags.set: path is required");if(!r("tags"))return!1;let n=Array.isArray(t)?t:[String(t)];return await window.craft.tags.set(e,n)},async clear(e){if(!e)throw Error("tags.clear: path is required");if(!r("tags"))return!1;return await window.craft.tags.clear(e)}};var ji={get(){if(r("theme"))try{return window.craft.theme.get()}catch{}return{appearance:At()}},onChange(e){if(e(this.get()),r("theme"))return a("craft:theme",e);if(typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>e({appearance:t.matches?"dark":"light"});return t.addEventListener("change",n),()=>t.removeEventListener("change",n)}return()=>{}},async current(){return this.get()}};function At(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}class Ie{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(e){if(this._duration=e.duration,this._tickInterval=e.tickInterval||1000,this._remaining=e.duration,e.onComplete)this._completionHandlers.add(e.onComplete);if(e.onTick)this._tickHandlers.add(e.onTick);if(e.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 e=Date.now()-this._lastTick;return Math.max(0,this._remaining-e)}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 e=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-e),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(e){return this._completionHandlers.add(e),()=>{this._completionHandlers.delete(e)}}onTick(e){return this._tickHandlers.add(e),()=>{this._tickHandlers.delete(e)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let e=Date.now(),t=e-this._lastTick;this._lastTick=e,this._remaining=Math.max(0,this._remaining-t);for(let n of this._tickHandlers)try{n(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let n of this._completionHandlers)try{n()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class ke{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(e){if(this._interval=e.interval,this._handler=e.handler,this._immediate=e.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 Vi(e){return new Ie(e)}function Yi(e){return new ke(e)}function Gi(e){return new Promise((t)=>setTimeout(t,e))}function Xi(e){let t=Math.ceil(e/1000),n=Math.floor(t/3600),i=Math.floor(t%3600/60),o=t%60;if(n>0)return`${n}:${String(i).padStart(2,"0")}:${String(o).padStart(2,"0")}`;return`${i}:${String(o).padStart(2,"0")}`}function Ji(e){let t=Math.ceil(e/1000),n=Math.floor(t/3600),i=Math.floor(t%3600/60),o=t%60;if(n>0){if(i>0)return`${n}h ${i}m`;return`${n}h`}if(i>0){if(o>0)return`${i}m ${o}s`;return`${i}m`}return`${o}s`}var eo={async addItem(e){if(r("touchbar"))await window.craft.touchbar.addItem(e)},async removeItem(e){if(r("touchbar"))await window.craft.touchbar.removeItem(e)},async updateItem(e,t){if(r("touchbar"))await window.craft.touchbar.updateItem(e,t)},async setLabel(e,t){if(r("touchbar"))await window.craft.touchbar.setLabel(e,t)},async setIcon(e,t){if(r("touchbar"))await window.craft.touchbar.setIcon(e,t)},async setEnabled(e,t){if(r("touchbar"))await window.craft.touchbar.setEnabled(e,t)},async setSliderValue(e,t){if(r("touchbar"))await window.craft.touchbar.setSliderValue(e,t)},async clear(){if(r("touchbar"))await window.craft.touchbar.clear()},async show(){if(r("touchbar"))await window.craft.touchbar.show()},async hide(){if(r("touchbar"))await window.craft.touchbar.hide()},onAction(e){return a("craft:touchbar:action",e)}};var no={async checkForUpdates(){if(!r("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!r("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(e){if(!r("updater"))return;await window.craft.updater.setAutomaticChecks(e)},async setCheckInterval(e){if(!r("updater"))return;if(!Number.isFinite(e))throw Error("setCheckInterval: must be a finite number");let t=e<=0?0:Math.max(60,Math.round(e));await window.craft.updater.setCheckInterval(t)},async setFeedURL(e){if(!r("updater"))return;await window.craft.updater.setFeedURL(e)},async getLastUpdateCheckDate(){if(!r("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!r("updater"))return null;let e=await window.craft.updater.getUpdateInfo();if(!e||typeof e.version!=="string"||e.version.length===0)return null;return e},onAvailable(e){return a("craft:updateAvailable",e)},onDownloaded(e){return a("craft:updateDownloaded",e)},async verifySignature({payload:e,signatureB64:t,publicKeyB64:n}){let i=Ee(e),o;try{o=await crypto.subtle.importKey("raw",N(n),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",o,N(t),i)}catch{return!1}},async verifyDownload({url:e,signatureB64:t,publicKeyB64:n,fetchInit:i}){let o;try{o=await fetch(e,i)}catch{return{ok:!1,reason:"fetch-failed"}}if(!o.ok)return{ok:!1,reason:"http-error",status:o.status};let s=new Uint8Array(await o.arrayBuffer()),c;try{c=await crypto.subtle.importKey("raw",N(n),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let d=!1;try{d=await crypto.subtle.verify("Ed25519",c,N(t),Ee(s))}catch{d=!1}if(!d)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:s}}};function Ee(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t);return n.set(e),n}function N(e){if(typeof atob==="function"){let i=atob(e),o=new ArrayBuffer(i.length),s=new Uint8Array(o);for(let c=0;c<i.length;c++)s[c]=i.charCodeAt(c);return s}let t=Buffer.from(e,"base64"),n=new ArrayBuffer(t.length);return new Uint8Array(n).set(t),new Uint8Array(n)}var ao={async recognizeText(e){if(!e)throw Error("vision.recognizeText: path is required");if(!r("vision"))return[];return await window.craft.vision.recognizeText(e)},async detectFaces(e){if(!e)throw Error("vision.detectFaces: path is required");if(!r("vision"))return[];return await window.craft.vision.detectFaces(e)},async detectBarcodes(e){if(!e)throw Error("vision.detectBarcodes: path is required");if(!r("vision"))return[];return await window.craft.vision.detectBarcodes(e)}};var lo={onFocus(e){if(r("window"))return a("craft:window:focus",()=>e());return te("focus",e)},onBlur(e){if(r("window"))return a("craft:window:blur",()=>e());return te("blur",e)},onResize(e){if(r("window"))return a("craft:window:resize",e);if(typeof window>"u")return()=>{};let t=()=>e({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},onMove(e){if(r("window"))return a("craft:window:move",e);return()=>{}},onClose(e){if(r("window"))return a("craft:window:close",()=>e());return te("beforeunload",e)},onMinimize(e){if(r("window"))return a("craft:window:minimize",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="hidden")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},onRestore(e){if(r("window"))return a("craft:window:restore",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="visible")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)}};function te(e,t){if(typeof window>"u")return()=>{};let n=()=>t();return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function It(e,t={}){if(!Number.isInteger(e)||e<0||e>86400000)return Promise.reject(RangeError("delayMs must be an integer between 0 and 86400000"));let{signal:n}=t,i=()=>new DOMException("Background delay aborted","AbortError");if(n?.aborted)return Promise.reject(i());if(r("timers"))return l("timers").sleep(e,t);if(typeof window<"u"&&window.craft)return Promise.reject(Error("Native background deadlines require a Craft runtime with timers.sleep support"));return new Promise((o,s)=>{let c=setTimeout(()=>{n?.removeEventListener("abort",d),o()},e);function d(){clearTimeout(c),n?.removeEventListener("abort",d),s(i())}n?.addEventListener("abort",d,{once:!0})})}export{Z as DEFAULT_WATCH_INTERVAL_MS,yt as MAX_WATCH_INTERVAL_MS,vt as MIN_WATCH_INTERVAL_MS,Un as MODAL_STYLES,Ot as TOAST_STYLES,_n as alert,qt as app,Wt as appleScript,jt as audio,It as backgroundDelay,Yt as battery,Jt as biometric,er as bluetooth,nr as bonjour,lr as clipboard,qn as closeAllModals,On as confirm,pr as contextMenu,wr as continuityCamera,yr as coreml,R as crashReporter,Yi as createInterval,Vi as createTimer,Ar as deepLinks,Gi as delay,Tt as dismissAlertById,Rt as dismissAllAlerts,_r as dragOut,Ur as fileAssociations,me as focus,zr as focusShortcutsReady,Ji as formatCompact,en as formatShortcut,Xi as formatTime,Vr as fs,Lt as getActiveAlertCount,Nn as getActiveModalCount,ar as getCapabilities,Ne as getCapability,Rr as getDialogBridgeScript,nn as getRegisteredHotkeys,Xr as globalShortcuts,O as handoff,$r as hasFocusShortcuts,cn as iap,sr as isAvailable,Fr as isDragOutAvailable,un as keychain,mn as liveActivities,hn as localServer,bn as location,Sn as log,En as menu,Bn as midi,$n as nativeAutoLaunch,Gn as nativeTray,Kn as nativeWindow,Qn as network,ti as notifications,Dt as notify,rt as parseShortcut,ii as pdf,si as permissions,li as printing,Fn as prompt,ze as redactPII,tn as registerHotkey,kt as requestNotificationPermission,pi as screen,wi as screenCapture,Q as screenSharing,Pi as serial,Ii as serviceMenu,Ci as shell,oe as showAlert,Mr as showAlertDialog,Cr as showColorPicker,Br as showConfirmDialog,Dr as showErrorDialog,Rn as showErrorModal,Bt as showErrorToast,pt as showInfoModal,Et as showInfoToast,L as showMessageBox,k as showModal,kr as showOpenDialog,mt as showQuestionModal,Er as showSaveDialog,Ln as showSuccessModal,Ct as showSuccessToast,D as showToast,Tr as showWarningDialog,Tn as showWarningModal,Mt as showWarningToast,St as sidebar,je as signPayload,Ri as speech,_i as speechRecognition,qi as spotlight,kn as standardMenus,Wi as tags,ji as theme,eo as touchbar,rn as unregisterAllHotkeys,at as unregisterHotkey,no as updater,ao as vision,yi as watchScreenSharing,lo as windowEvents};
|
package/dist/index.js
CHANGED
|
@@ -923,7 +923,7 @@ NoDisplay=true`:""}
|
|
|
923
923
|
`;if(!U(i))st(i,{recursive:!0});lt(n,l,"utf-8")}else if(U(n))ct(n)}async function vo(e){return U(ut(e))}async function Po(e){let t=pt(e);if(!U(t))return!1;try{let r=bo(t,"utf-8");if(r.includes("X-GNOME-Autostart-enabled=false"))return!1;if(r.includes("Hidden=true"))return!1;return!0}catch{return!1}}function So(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function ko(e,t={}){let r=dt();switch(r){case"darwin":return xo(e,t);case"linux":return yo(e,t);default:throw Error(`Auto-launch is not yet supported on ${r}`)}}async function Ao(e){let t=e||"StxApp";switch(dt()){case"darwin":return vo(t);case"linux":return Po(t);default:return!1}}var O=new Map,Co=0,ae=!1;function ft(e){let t=e.split("+").map((n)=>n.trim()),r={key:"",meta:!1,ctrl:!1,shift:!1,alt:!1};for(let n of t){let i=n.toLowerCase();switch(i){case"cmd":case"command":case"meta":case"\u2318":r.meta=!0;break;case"ctrl":case"control":case"\u2303":r.ctrl=!0;break;case"shift":case"\u21E7":r.shift=!0;break;case"alt":case"option":case"opt":case"\u2325":r.alt=!0;break;case"cmdorctrl":case"commandorcontrol":if(typeof process<"u"&&process.platform==="darwin")r.meta=!0;else r.ctrl=!0;break;default:r.key=i}}return r}function Io(e){let t=[];if(e.ctrl)t.push("\u2303");if(e.alt)t.push("\u2325");if(e.shift)t.push("\u21E7");if(e.meta)t.push("\u2318");return t.push(e.key.toUpperCase()),t.join("")}function $o(e,t){if(t.meta!==e.metaKey)return!1;if(t.ctrl!==e.ctrlKey)return!1;if(t.shift!==e.shiftKey)return!1;if(t.alt!==e.altKey)return!1;return e.key.toLowerCase()===t.key||e.code.toLowerCase()===`key${t.key}`}function mt(e){for(let[,t]of O)if($o(e,t.parsed)){e.preventDefault(),e.stopPropagation();try{t.handler()}catch{}break}}function To(){if(ae)return;if(typeof document>"u")return;document.addEventListener("keydown",mt,!0),ae=!0}function ke(){if(!ae)return;if(typeof document>"u")return;document.removeEventListener("keydown",mt,!0),ae=!1}async function Eo(e,t){if(typeof window>"u")return!1;let r=window.craft;if(!r?.hotkeys?.register)return!1;try{return await r.hotkeys.register(e,t),!0}catch{return!1}}async function Ae(e){if(typeof window>"u")return;let t=window.craft;if(!t?.hotkeys?.unregister)return;try{await t.hotkeys.unregister(e)}catch{}}function Mo(e,t){let r=`hotkey_${++Co}_${Date.now()}`,n=ft(e);O.set(r,{shortcut:e,handler:t,parsed:n}),Eo(r,e),To();let i={shortcut:e,id:r,unregister(){gt(i)}};return i}function gt(e){if(O.delete(e.id),Ae(e.id),O.size===0)ke()}function Do(){for(let[e]of O)Ae(e);O.clear(),ke()}function Bo(){return Array.from(O.entries()).map(([e,t])=>({shortcut:t.shortcut,id:e,unregister(){if(O.delete(e),Ae(e),O.size===0)ke()}}))}class ht{_duration;_tickInterval;_remaining;_running=!1;_paused=!1;_complete=!1;_intervalId=null;_lastTick=0;_completionHandlers=new Set;_tickHandlers=new Set;constructor(e){if(this._duration=e.duration,this._tickInterval=e.tickInterval||1000,this._remaining=e.duration,e.onComplete)this._completionHandlers.add(e.onComplete);if(e.onTick)this._tickHandlers.add(e.onTick);if(e.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 e=Date.now()-this._lastTick;return Math.max(0,this._remaining-e)}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 e=Date.now()-this._lastTick;this._remaining=Math.max(0,this._remaining-e),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(e){return this._completionHandlers.add(e),()=>{this._completionHandlers.delete(e)}}onTick(e){return this._tickHandlers.add(e),()=>{this._tickHandlers.delete(e)}}_startInterval(){this._clearInterval(),this._intervalId=setInterval(()=>{let e=Date.now(),t=e-this._lastTick;this._lastTick=e,this._remaining=Math.max(0,this._remaining-t);for(let r of this._tickHandlers)try{r(this._remaining)}catch{}if(this._remaining<=0){this._clearInterval(),this._running=!1,this._complete=!0;for(let r of this._completionHandlers)try{r()}catch{}}},this._tickInterval)}_clearInterval(){if(this._intervalId!==null)clearInterval(this._intervalId),this._intervalId=null}}class wt{_interval;_handler;_immediate;_running=!1;_intervalId=null;constructor(e){if(this._interval=e.interval,this._handler=e.handler,this._immediate=e.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 Oo(e){return new ht(e)}function Ro(e){return new wt(e)}function Lo(e){return new Promise((t)=>setTimeout(t,e))}function _o(e){let t=Math.ceil(e/1000),r=Math.floor(t/3600),n=Math.floor(t%3600/60),i=t%60;if(r>0)return`${r}:${String(n).padStart(2,"0")}:${String(i).padStart(2,"0")}`;return`${n}:${String(i).padStart(2,"0")}`}function No(e){let t=Math.ceil(e/1000),r=Math.floor(t/3600),n=Math.floor(t%3600/60),i=t%60;if(r>0){if(n>0)return`${r}h ${n}m`;return`${r}h`}if(n>0){if(i>0)return`${n}m ${i}s`;return`${n}m`}return`${i}s`}function o(e){if(typeof window>"u")return!1;let t=window.craft;return!!(t&&t[e])}function y(e){if(!o(e))throw Error(`craft.${e} is not available \u2014 this API requires a Craft native window`);return window.craft[e]}function g(e,t){if(typeof window>"u")return()=>{};let r=(n)=>t(n.detail??{});return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}var Fo={async writeText(e){if(o("clipboard")){await window.craft.clipboard.writeText(e);return}if(typeof navigator<"u"&&navigator.clipboard)await navigator.clipboard.writeText(e)},async readText(){if(o("clipboard")){let e=await window.craft.clipboard.readText();return typeof e==="string"?e:""}if(typeof navigator<"u"&&navigator.clipboard?.readText)try{return await navigator.clipboard.readText()}catch{return""}return""},async writeHTML(e){if(o("clipboard")){await window.craft.clipboard.writeHTML(e);return}if(typeof navigator<"u"&&navigator.clipboard?.write)try{let t=new window.ClipboardItem({"text/html":new Blob([e],{type:"text/html"}),"text/plain":new Blob([Wo(e)],{type:"text/plain"})});await navigator.clipboard.write([t])}catch{}},async readHTML(){if(o("clipboard")){let e=await window.craft.clipboard.readHTML();return typeof e==="string"?e:""}if(typeof navigator<"u"&&navigator.clipboard?.read)try{let e=await navigator.clipboard.read();for(let t of e)if(t.types.includes("text/html"))return await(await t.getType("text/html")).text()}catch{}return""},async clear(){if(o("clipboard")){await window.craft.clipboard.clear();return}if(typeof navigator<"u"&&navigator.clipboard?.writeText)try{await navigator.clipboard.writeText("")}catch{}},async hasText(){if(o("clipboard"))return await window.craft.clipboard.hasText();return(await this.readText()).length>0},async hasHTML(){if(o("clipboard"))return await window.craft.clipboard.hasHTML();return(await this.readHTML()).length>0},async hasImage(){if(o("clipboard"))return await window.craft.clipboard.hasImage();return!1}};function Wo(e){return e.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<\/?(br|p|div|li|h[1-6])\b[^>]*>/gi,`
|
|
924
924
|
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/\n{3,}/g,`
|
|
925
925
|
|
|
926
|
-
`).trim()}var zo={async show(e){if(!e.title)throw Error("notification title is required");if(o("notifications")){await window.craft.notifications.show(e);return}if(typeof window<"u"&&"Notification"in window){let t=window.Notification;if(t.permission==="granted")new t(e.title,{body:e.body,icon:e.icon});else if(t.permission==="default"){if(await t.requestPermission()==="granted")new t(e.title,{body:e.body,icon:e.icon})}}},async schedule(e){if(o("notifications")){let n={...e};if(n.triggerAt instanceof Date)n.triggerAt=n.triggerAt.toISOString();await window.craft.notifications.schedule(n);return}let t=Ho(e.triggerAt),r=Math.max(0,t-Date.now());setTimeout(()=>{this.show(e).catch(()=>{})},r)},async cancel(e){if(o("notifications"))await window.craft.notifications.cancel(e)},async cancelAll(){if(o("notifications"))await window.craft.notifications.cancelAll()},async setBadge(e){let t=Math.max(0,Math.round(Number.isFinite(e)?e:0));if(o("notifications")){await window.craft.notifications.setBadge(t);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(t)}catch{}},async clearBadge(){if(o("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(o("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let e=window.Notification;if(e.permission==="granted")return!0;if(e.permission==="denied")return!1;return await e.requestPermission()==="granted"}return!1},async registerCategories(e){if(!Array.isArray(e)||e.length===0)return;if(o("notifications")){let t=window.craft.notifications.registerCategories;if(typeof t==="function")await t(e)}},onActionClicked(e){return g("craft:notification:actionClicked",e)},onReply(e){return g("craft:notification:reply",e)}};function Ho(e){if(e==null)return Date.now();if(e instanceof Date)return e.getTime();if(typeof e==="number")return e;let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}var Uo={async readFile(e){let t=await y("fs").readFile(e);return t&&t.data||""},async readBuffer(e){let t=await y("fs").readFile(e),r=t&&t.data||"";if(t&&t.base64===!0)return Vo(r);return new TextEncoder().encode(r)},async writeFile(e,t){await y("fs").writeFile(e,t)},async writeBuffer(e,t){let r=qo(t),n=y("fs");if(typeof n.writeFileBytes==="function")await n.writeFileBytes(e,r);else await n.writeFile(e,r)},async copy(e,t){if(e===t)throw Error("fs.copy: source and destination must differ");await y("fs").copy(e,t)},async move(e,t){if(e===t)throw Error("fs.move: source and destination must differ");await y("fs").move(e,t)},async appendFile(e,t){await y("fs").appendFile(e,t)},async deleteFile(e){await y("fs").deleteFile(e)},async exists(e){return await y("fs").exists(e)},async stat(e){return jo(await y("fs").stat(e))},async readDir(e){let t=await y("fs").readDir(e),r=t&&t.entries||[],n=e.endsWith("/")?e.slice(0,-1):e;return r.map((i)=>({name:i.name,path:`${n}/${i.name}`,isDirectory:!!i.isDirectory}))},async mkdir(e,t){await y("fs").mkdir(e,t)},async rmdir(e,t){await y("fs").rmdir(e,t)},async watch(e,t){await y("fs").watch(e,t)},async unwatch(e){await y("fs").unwatch(e)},onChange(e){return g("craft:fs:change",e)},async watchTree(e,t,r){let n=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,i=y("fs");await i.watch(e,n,{recursive:!!t.recursive});let a=t.kinds&&t.kinds.length>0?new Set(t.kinds):null,s=Math.max(0,Math.floor(t.coalesceMs??0)),c=[],l=null,d=!1,p=()=>{if(l=null,c.length===0)return;let u=c;c=[];try{r(u)}catch{}},f=g("craft:fs:change",(u)=>{if(d)return;if(u.id!==n)return;if(a&&u.kind&&!a.has(u.kind))return;if(c.push(u),s===0){p();return}if(l==null)l=setTimeout(p,s)});return{id:n,async stop(){if(d)return;if(d=!0,f(),l)clearTimeout(l),l=null;if(c.length>0)p();try{await i.unwatch(n)}catch{}}}},async homeDir(){return await y("fs").homeDir()},async tempDir(){return await y("fs").tempDir()},async appDataDir(){return await y("fs").appDataDir()}};function qo(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return typeof btoa==="function"?btoa(t):Buffer.from(e).toString("base64")}function Vo(e){let t=typeof atob==="function"?atob(e):Buffer.from(e,"base64").toString("binary"),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function jo(e){return{isFile:!!e.isFile,isDirectory:!!e.isDirectory,isSymlink:!!e.isSymlink,size:Number(e.size)||0,modifiedAt:e.modifiedAt!=null?e.modifiedAt<1000000000000?e.modifiedAt*1000:e.modifiedAt:0}}var Y=new Set,bt=!1;function Ko(){if(bt)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(e)=>{let t=e.detail;if(t?.id)Y.delete(t.id)}),bt=!0}var Go=new Set(["javascript:","data:","file:","vbscript:"]),Yo={async openExternal(e){let t=e.trim().toLowerCase();for(let r of Go)if(t.startsWith(r))throw Error(`shell.openExternal: ${r} URLs are blocked for safety`);if(o("shell")){await window.craft.shell.openExternal(e);return}if(typeof window<"u"&&typeof window.open==="function")window.open(e,"_blank","noopener,noreferrer")},async openPath(e){await y("shell").openPath(e)},async showInFinder(e){await y("shell").showInFinder(e)},async spawn(e,t,r=[],n={}){if(Ko(),!e||typeof e!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!t||typeof t!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(r))throw Error("shell.spawn: args must be an array");for(let i of r)if(typeof i!=="string")throw Error("shell.spawn: args entries must be strings");if(Y.has(e))throw Error(`shell.spawn: id "${e}" is already in use \u2014 call kill(id) first or pick a different id`);Y.add(e);try{await y("shell").spawn(e,t,r,n)}catch(i){throw Y.delete(e),i}},async kill(e){await y("shell").kill(e),Y.delete(e)},async getEnv(e){if(o("shell")){let t=await window.craft.shell.getEnv(e);return t==null?void 0:String(t)}return},async setEnv(e,t){await y("shell").setEnv(e,t)},onStdout(e){return g("craft:shell:stdout",e)},onStderr(e){return g("craft:shell:stderr",e)},onExit(e){return g("craft:shell:exit",e)}};function F(){return window.craft.shortcuts}var Xo={async register(e,t,r){if(!o("shortcuts"))return;await F().register(e,t,r)},async unregister(e){if(!o("shortcuts"))return;await F().unregister(e)},async unregisterAll(){if(!o("shortcuts"))return;await F().unregisterAll()},async enable(e){if(!o("shortcuts"))return;await F().enable(e)},async disable(e){if(!o("shortcuts"))return;await F().disable(e)},async isRegistered(e){if(!o("shortcuts"))return!1;return await F().isRegistered(e)},async list(){if(!o("shortcuts"))return[];return await F().list()},on(e){return g("craft:shortcut",e)}};var Jo={get(){if(o("theme"))try{return window.craft.theme.get()}catch{}return{appearance:Qo()}},onChange(e){if(e(this.get()),o("theme"))return g("craft:theme",e);if(typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>e({appearance:t.matches?"dark":"light"});return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}return()=>{}},async current(){return this.get()}};function Qo(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function Zo(e,t={}){if(!o("dragOut"))throw Error("dragOut requires a Craft native window");let r=Array.isArray(e)?e:[e];if(r.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(r,t)}function ei(){return o("dragOut")}var ti={onUrl(e){if(!o("deepLink"))return()=>{};return g("craft:deepLink",e)},getInitialUrl(){if(typeof window>"u")return null;if(o("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let e=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return e},isAvailable(){return o("deepLink")}};var ri={async isCharging(){if(o("power"))return await window.craft.power.isCharging();let e=await se();return e?!!e.charging:!1},async isPluggedIn(){if(o("power"))return await window.craft.power.isPluggedIn();let e=await se();return e?!!e.charging||e.level>=0.999:!1},async isLowPowerMode(){if(o("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(o("power")){let t=await window.craft.power.batteryLevel();return typeof t==="number"?t:null}let e=await se();return e?e.level:null},async timeRemaining(){if(o("power")){let r=await window.craft.power.timeRemaining();return typeof r==="number"?r:null}let e=await se();if(!e)return null;let t=e.charging?e.chargingTime:e.dischargingTime;return Number.isFinite(t)?Math.round(t/60):null},async thermalState(){if(o("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(o("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(e="app is busy"){if(o("power")){await window.craft.power.preventSleep(e);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let t=window;if(t.__craftWebWakeLock?.release){try{await t.__craftWebWakeLock.release()}catch{}t.__craftWebWakeLock=null}try{let r=await navigator.wakeLock.request("screen");t.__craftWebWakeLock=r}catch{}},async allowSleep(){if(o("power")){await window.craft.power.allowSleep();return}let e=window.__craftWebWakeLock;if(e&&typeof e.release==="function"){try{await e.release()}catch{}window.__craftWebWakeLock=null}},onSleep(e){return g("craft:powerSleep",e)},onWake(e){return g("craft:powerWake",e)}};async function se(){if(typeof navigator>"u")return null;let e=navigator;if(typeof e.getBattery!=="function")return null;try{return await e.getBattery()}catch{return null}}var ni={async connectionType(){if(o("network"))return await window.craft.network.connectionType();return xt()},async wifiSSID(){if(o("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(o("network")){let e=await window.craft.network.wifiSignalStrength();return typeof e==="number"?e:void 0}return},async ipAddress(){if(o("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(o("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(o("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(o("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(o("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(o("network"))await window.craft.network.openPreferences()},onChange(e){if(o("network"))return g("craft:networkChange",e);if(typeof window>"u")return()=>{};let t=()=>e({type:xt(),online:!0}),r=()=>e({type:"none",online:!1});return window.addEventListener("online",t),window.addEventListener("offline",r),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}};function xt(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let e=navigator.connection;if(!e)return"unknown";let t=String(e.type||e.effectiveType||"unknown").toLowerCase();if(t==="wifi"||t==="cellular"||t==="ethernet"||t==="bluetooth"||t==="none")return t;return"unknown"}var oi={async checkForUpdates(){if(!o("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!o("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(e){if(!o("updater"))return;await window.craft.updater.setAutomaticChecks(e)},async setCheckInterval(e){if(!o("updater"))return;if(!Number.isFinite(e))throw Error("setCheckInterval: must be a finite number");let t=e<=0?0:Math.max(60,Math.round(e));await window.craft.updater.setCheckInterval(t)},async setFeedURL(e){if(!o("updater"))return;await window.craft.updater.setFeedURL(e)},async getLastUpdateCheckDate(){if(!o("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!o("updater"))return null;let e=await window.craft.updater.getUpdateInfo();if(!e||typeof e.version!=="string"||e.version.length===0)return null;return e},onAvailable(e){return g("craft:updateAvailable",e)},onDownloaded(e){return g("craft:updateDownloaded",e)},async verifySignature({payload:e,signatureB64:t,publicKeyB64:r}){let n=yt(e),i;try{i=await crypto.subtle.importKey("raw",ce(r),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",i,ce(t),n)}catch{return!1}},async verifyDownload({url:e,signatureB64:t,publicKeyB64:r,fetchInit:n}){let i;try{i=await fetch(e,n)}catch{return{ok:!1,reason:"fetch-failed"}}if(!i.ok)return{ok:!1,reason:"http-error",status:i.status};let a=new Uint8Array(await i.arrayBuffer()),s;try{s=await crypto.subtle.importKey("raw",ce(r),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let c=!1;try{c=await crypto.subtle.verify("Ed25519",s,ce(t),yt(a))}catch{c=!1}if(!c)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:a}}};function yt(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=new ArrayBuffer(e.byteLength),r=new Uint8Array(t);return r.set(e),r}function ce(e){if(typeof atob==="function"){let n=atob(e),i=new ArrayBuffer(n.length),a=new Uint8Array(i);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);return a}let t=Buffer.from(e,"base64"),r=new ArrayBuffer(t.length);return new Uint8Array(r).set(t),new Uint8Array(r)}var ii={onFocus(e){if(o("window"))return g("craft:window:focus",()=>e());return Ce("focus",e)},onBlur(e){if(o("window"))return g("craft:window:blur",()=>e());return Ce("blur",e)},onResize(e){if(o("window"))return g("craft:window:resize",e);if(typeof window>"u")return()=>{};let t=()=>e({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},onMove(e){if(o("window"))return g("craft:window:move",e);return()=>{}},onClose(e){if(o("window"))return g("craft:window:close",()=>e());return Ce("beforeunload",e)},onMinimize(e){if(o("window"))return g("craft:window:minimize",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="hidden")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},onRestore(e){if(o("window"))return g("craft:window:restore",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="visible")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)}};function Ce(e,t){if(typeof window>"u")return()=>{};let r=()=>t();return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}var vt={name:"",version:"0.0.0"},ai={async hideDockIcon(){if(o("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(o("app"))await window.craft.app.showDockIcon()},async quit(){if(o("app"))await window.craft.app.quit()},async getInfo(){if(!o("app"))return vt;let e=await window.craft.app.getInfo();return{...vt,...e||{}}},async notify(e){if(!e.title)throw Error("notify: title is required");if(o("app"))await window.craft.app.notify(e)},async setBadge(e){if(o("app"))await window.craft.app.setBadge(e)},async bounce(e="informational"){if(o("app"))await window.craft.app.bounce(e)}};var si={app(e,t={}){return{label:e,items:[{label:`About ${e}`,role:"about"},{separator:!0},...t.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:t.settings},{separator:!0}]:[],{label:`Hide ${e}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${e}`,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(e,t={}){return[this.app(e,t),this.edit()]}},ci=0;function li(e){let t=new Map;return{payload:{menus:e.menus.map((n)=>({label:n.label,items:n.items.map((i)=>{let{onClick:a,...s}=i;if(s.separator)return s;let c=s.id??`stx.menu.${ci++}`;if(a)t.set(c,a);return{...s,id:c}})}))},handlers:t}}var Ie=null,di={async set(e){if(!o("menu"))return!1;let{payload:t,handlers:r}=li(e);if(Ie?.(),Ie=null,r.size>0)Ie=g("craft:menu:action",(n)=>{r.get(n.id)?.()});return await window.craft.menu.set(t),!0},async setDock(e){if(o("menu"))await window.craft.menu.setDock(e)},async addItem(e,t){if(o("menu"))await window.craft.menu.addItem(e,t)},async removeItem(e){if(o("menu"))await window.craft.menu.removeItem(e)},async enableItem(e){if(o("menu"))await window.craft.menu.enableItem(e)},async disableItem(e){if(o("menu"))await window.craft.menu.disableItem(e)},async checkItem(e){if(o("menu"))await window.craft.menu.checkItem(e)},async uncheckItem(e){if(o("menu"))await window.craft.menu.uncheckItem(e)},async setItemLabel(e,t){if(o("menu"))await window.craft.menu.setItemLabel(e,t)},async clearDock(){if(o("menu"))await window.craft.menu.clearDock()},onAction(e){return g("craft:menu:action",e)}};function St(e){if(e.separator)return{id:e.id||"",title:"",type:"separator"};return{id:e.id||"",title:e.title||"",icon:e.icon,shortcut:e.shortcut,enabled:e.disabled?!1:void 0,checked:e.checked?!0:void 0,type:e.submenu?"submenu":void 0,submenu:e.submenu?.map(St)}}async function Pt(e){if(!e.items||e.items.length===0)throw Error("contextMenu.show requires at least one item");if(!o("nativeUI"))return null;let t=window.craft?.nativeUI;if(!t)return null;let r=await t.showContextMenu({targetId:e.targetId||"",targetType:"general",x:Math.round(e.x),y:Math.round(e.y),items:e.items.map(St)});return{id:typeof r?.id==="string"?r.id:null,targetId:r?.targetId}}var ui={available(){return o("nativeUI")},async show(e){return await Pt(e)!==null},async pick(e){return(await Pt(e))?.id??null},onAction(e){return g("craft:contextmenu:action",(t)=>{if(typeof t.id==="string")e({id:t.id,targetId:t.targetId??""})})}};function $e(e){if(e===null||e===void 0||e===0)return"";return String(e)}function kt(e){return e.map((t)=>({id:t.id,header:t.header,items:t.items.map((r)=>({id:r.id,label:r.label,icon:r.icon,badge:$e(r.badge)||void 0}))}))}function At(e){return JSON.stringify(e.map((t)=>[t.id,t.header??"",t.items.map((r)=>[r.id,r.label,r.icon??""])]))}function Ct(e){return new Map(e.flatMap((t)=>t.items.map((r)=>[r.id,$e(r.badge)])))}var It={available(){return o("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(e){if(!It.available())return null;let t=window.craft?.nativeUI;if(!t)return null;let r=t.createSidebar({id:e.id,sections:kt(e.sections),selected:e.selected}),n=e.sections,i=new Set;return r.onSelect((a)=>{for(let s of[...i])s(a)}),{id:r.id,update(a){if(At(a)===At(n)){let s=Ct(n);for(let[c,l]of Ct(a))if(s.get(c)!==l)r.updateItem(c,{badge:l})}else r.setSections(kt(a));n=a},updateItem(a,s){r.updateItem(a,{...s.label!==void 0?{label:s.label}:{},...s.icon!==void 0?{icon:s.icon}:{},..."badge"in s?{badge:$e(s.badge)}:{}}),n=n.map((c)=>({...c,items:c.items.map((l)=>l.id===a?{...l,...s}:l)}))},select(a){r.setSelectedItem(a)},onSelect(a){return i.add(a),()=>i.delete(a)},destroy(){i.clear(),r.destroy()}}}};var pi={accentColor:()=>T("system","accentColor",()=>""),highlightColor:()=>T("system","highlightColor",()=>""),language:()=>T("system","language",()=>{if(typeof navigator>"u")return"";return navigator.language?.split("-")[0]||""}),locale:()=>T("system","locale",()=>{if(typeof navigator>"u")return"";return navigator.language||""}),timezone:()=>T("system","timezone",()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}),is24HourTime:()=>T("system","is24HourTime",()=>{try{let e=new Intl.DateTimeFormat([],{hour:"numeric"}).resolvedOptions();return e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!1}}),reduceMotion:()=>T("system","reduceMotion",()=>Te("(prefers-reduced-motion: reduce)")),reduceTransparency:()=>T("system","reduceTransparency",()=>Te("(prefers-reduced-transparency: reduce)")),increaseContrast:()=>T("system","increaseContrast",()=>Te("(prefers-contrast: more)")),systemVersion:()=>T("system","systemVersion",()=>""),hostname:()=>T("system","hostname",()=>""),username:()=>T("system","username",()=>""),async openPreferences(){if(o("system"))await window.craft.system.openPreferences()}};async function T(e,t,r){if(o(e))return await window.craft[e][t]();return await r()}function Te(e){if(typeof window>"u"||!window.matchMedia)return!1;return window.matchMedia(e).matches}var fi={async getDisplays(){if(o("screen"))return await window.craft.screen.getDisplays();return $t()},async getPrimary(){if(o("screen")){let e=await window.craft.screen.getPrimary();return e&&typeof e.width==="number"?e:null}return $t()[0]??null},onChange(e){if(o("screen"))return g("craft:screen:change",()=>e());if(typeof window>"u")return()=>{};let t=()=>e();return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}};function $t(){if(typeof window>"u"||!window.screen)return[];let e=window.screen;return[{id:0,x:e.left??0,y:e.top??0,width:e.width||0,height:e.height||0,workX:e.availLeft??0,workY:e.availTop??0,workWidth:e.availWidth??e.width??0,workHeight:e.availHeight??e.height??0,scaleFactor:window.devicePixelRatio||1}]}var mi={async set(e,t,r){if(!e)throw Error("keychain.set: service is required");if(!t)throw Error("keychain.set: account is required");await y("keychain").set(e,t,r)},async get(e,t){if(!e)throw Error("keychain.get: service is required");if(!t)throw Error("keychain.get: account is required");let r=await y("keychain").get(e,t);return typeof r==="string"?r:null},async delete(e,t){if(!e)throw Error("keychain.delete: service is required");if(!t)throw Error("keychain.delete: account is required");await y("keychain").delete(e,t)},async has(e,t){if(!e)throw Error("keychain.has: service is required");if(!t)throw Error("keychain.has: account is required");return await y("keychain").has(e,t)}};var gi={async check(e){if(o("permissions"))return await window.craft.permissions.check(e);return await Tt(e)},async request(e){if(o("permissions"))return await window.craft.permissions.request(e);return await hi(e)},async openSettings(e){if(o("permissions"))await window.craft.permissions.openSettings(e)}};async function Tt(e){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let t=await navigator.permissions.query({name:e});return wi(t.state)}catch{return"not-supported"}}async function hi(e){if(e==="notifications"&&typeof window<"u"&&"Notification"in window){let t=await window.Notification.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"undetermined"}return await Tt(e)}function wi(e){if(e==="granted")return"granted";if(e==="denied")return"denied";if(e==="prompt")return"undetermined";return"undetermined"}var bi={async print(){if(o("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(e){if(!e)throw Error("printToPDF: path is required");let t=e.startsWith("/"),r=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\");if(!t&&!r)throw Error("printToPDF: path must be absolute");let n=await y("printing").printToPDF(e);return{ok:!!(n&&n.ok),path:n?.path}}};var xi={async enable(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};async function Ee(e){if(!o("tray"))return;let t=window.craft.tray;await e(t)}var yi={setIcon:(e)=>Ee((t)=>t.setIcon({icon:e})),setTitle:(e)=>Ee((t)=>t.setTitle({title:e})),setTooltip:(e)=>Ee((t)=>t.setTooltip({tooltip:e}))};function Me(){if(!o("window"))return null;return window.craft.window}function M(e){let t=Me();if(!t)return Promise.resolve();try{return Promise.resolve(e(t)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var vi={get available(){return Me()!==null},open(e){let t=()=>{if(typeof window<"u"&&e.url)window.open(e.url,e.name);return{name:e.name}},r=Me();if(!r?.open)return Promise.resolve(t());return r.open(e).then((n)=>({name:n?.name||e.name})).catch(t)},close:()=>M((e)=>e.close?.()),show:()=>M((e)=>e.show?.()),hide:()=>M((e)=>e.hide?.()),focus:()=>M((e)=>e.focus?.()),minimize:()=>M((e)=>e.minimize?.()),maximize:()=>M((e)=>e.maximize?.()),center:()=>M((e)=>e.center?.()),startDrag:()=>M((e)=>e.startDrag?.()),setTitle:(e)=>M((t)=>t.setTitle?.(e)),setSize:(e,t)=>M((r)=>r.setSize?.(e,t)),setAppearance:(e)=>M((t)=>t.setAppearance?.(e))};var Pi={async addItem(e){if(o("touchbar"))await window.craft.touchbar.addItem(e)},async removeItem(e){if(o("touchbar"))await window.craft.touchbar.removeItem(e)},async updateItem(e,t){if(o("touchbar"))await window.craft.touchbar.updateItem(e,t)},async setLabel(e,t){if(o("touchbar"))await window.craft.touchbar.setLabel(e,t)},async setIcon(e,t){if(o("touchbar"))await window.craft.touchbar.setIcon(e,t)},async setEnabled(e,t){if(o("touchbar"))await window.craft.touchbar.setEnabled(e,t)},async setSliderValue(e,t){if(o("touchbar"))await window.craft.touchbar.setSliderValue(e,t)},async clear(){if(o("touchbar"))await window.craft.touchbar.clear()},async show(){if(o("touchbar"))await window.craft.touchbar.show()},async hide(){if(o("touchbar"))await window.craft.touchbar.hide()},onAction(e){return g("craft:touchbar:action",e)}};var Si=/^[\da-f]*$/i;function ki(e,t){if(typeof t!=="string"||!Si.test(t)||t.length%2!==0)throw Error(`${e}: must be a hex string with even length, got ${JSON.stringify(t)}`)}var Ai={async isEnabled(){return o("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return o("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return o("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return o("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(o("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(o("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return o("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(e){if(o("bluetooth"))await window.craft.bluetooth.connect(e)},async disconnect(e){if(o("bluetooth"))await window.craft.bluetooth.disconnect(e)},async openPreferences(){if(o("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(e){if(!e)throw Error("bluetooth.discoverServices: deviceId is required");if(!o("bluetooth"))return[];let t=await window.craft.bluetooth.discoverServices(e);return Array.isArray(t)?t:[]},async discoverCharacteristics(e,t){if(!e||!t)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!o("bluetooth"))return[];let r=await window.craft.bluetooth.discoverCharacteristics(e,t);return Array.isArray(r)?r:[]},async readCharacteristic(e,t,r){if(!e||!t||!r)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(e,t,r)},async writeCharacteristic(e,t,r,n,i="with-response"){if(!e||!t||!r)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(ki("bluetooth.writeCharacteristic.valueHex",n),!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(e,t,r,n,i)},async setCharacteristicNotify(e,t,r,n){if(!e||!t||!r)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(e,t,r,n)},onDeviceFound(e){return g("craft:bluetooth:deviceFound",e)},onDeviceConnected(e){return g("craft:bluetooth:deviceConnected",e)},onDeviceDisconnected(e){return g("craft:bluetooth:deviceDisconnected",e)},onCharacteristicValue(e){return g("craft:bluetooth:characteristicValue",e)}};var Ci={async speak(e,t){if(!e)throw Error("speech.speak: text is required");if(o("speech")){await window.craft.speech.speak(e,t);return}if(typeof window<"u"&&window.speechSynthesis){let r=new window.SpeechSynthesisUtterance(e);if(t){if(t.rate!=null)r.rate=t.rate;if(t.pitch!=null)r.pitch=t.pitch;if(t.volume!=null)r.volume=t.volume;if(t.voice){let i=window.speechSynthesis.getVoices().find((a)=>a.voiceURI===t.voice||a.name===t.voice||a.lang===t.voice);if(i)r.voice=i}}window.speechSynthesis.speak(r)}},async stop(){if(o("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(o("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(o("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(o("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(o("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((t)=>({id:t.voiceURI||t.name,name:t.name,language:t.lang||"",quality:"default"}));return[]}};var X=[],De=!0,Be,Oe,J={async report(e){if(o("crashReporter")){await window.craft.crashReporter.report(e);return}if(!De)return;let t=e instanceof Error?{timestamp:Date.now(),severity:"error",message:e.message,source:"js",stack:e.stack||"",userId:Be,appVersion:Oe}:{timestamp:Date.now(),severity:e.severity||"error",message:e.message||"",source:e.source||"js",stack:e.stack||"",userId:Be,appVersion:Oe};if(X.length>=64)X.shift();X.push(t)},async flush(){if(o("crashReporter"))return await window.craft.crashReporter.flush();return[...X]},async clear(){if(o("crashReporter")){await window.craft.crashReporter.clear();return}X.length=0},async setEnabled(e){if(o("crashReporter")){await window.craft.crashReporter.setEnabled(e);return}De=e},async isEnabled(){if(o("crashReporter"))return await window.craft.crashReporter.isEnabled();return De},async setUser(e){if(o("crashReporter")){await window.craft.crashReporter.setUser(e);return}Be=e||void 0},async setAppVersion(e){if(o("crashReporter")){await window.craft.crashReporter.setAppVersion(e);return}Oe=e||void 0},attachGlobalHandlers(){if(o("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let e=(r)=>{J.report({severity:"error",message:r.message,source:"js",stack:r.error?.stack||`${r.message}
|
|
926
|
+
`).trim()}var zo={async show(e){if(!e.title)throw Error("notification title is required");if(o("notifications")){await window.craft.notifications.show(e);return}if(typeof window<"u"&&"Notification"in window){let t=window.Notification;if(t.permission==="granted")new t(e.title,{body:e.body,icon:e.icon});else if(t.permission==="default"){if(await t.requestPermission()==="granted")new t(e.title,{body:e.body,icon:e.icon})}}},async schedule(e){if(o("notifications")){let n={...e};if(n.triggerAt instanceof Date)n.triggerAt=n.triggerAt.toISOString();await window.craft.notifications.schedule(n);return}let t=Ho(e.triggerAt),r=Math.max(0,t-Date.now());setTimeout(()=>{this.show(e).catch(()=>{})},r)},async cancel(e){if(o("notifications"))await window.craft.notifications.cancel(e)},async cancelAll(){if(o("notifications"))await window.craft.notifications.cancelAll()},async setBadge(e){let t=Math.max(0,Math.round(Number.isFinite(e)?e:0));if(o("notifications")){await window.craft.notifications.setBadge(t);return}if(typeof navigator<"u"&&navigator.setAppBadge)try{await navigator.setAppBadge(t)}catch{}},async clearBadge(){if(o("notifications")){await window.craft.notifications.clearBadge();return}if(typeof navigator<"u"&&navigator.clearAppBadge)try{await navigator.clearAppBadge()}catch{}},async requestPermission(){if(o("notifications"))return await window.craft.notifications.requestPermission();if(typeof window<"u"&&"Notification"in window){let e=window.Notification;if(e.permission==="granted")return!0;if(e.permission==="denied")return!1;return await e.requestPermission()==="granted"}return!1},async registerCategories(e){if(!Array.isArray(e)||e.length===0)return;if(o("notifications")){let t=window.craft.notifications.registerCategories;if(typeof t==="function")await t(e)}},onActionClicked(e){return g("craft:notification:actionClicked",e)},onReply(e){return g("craft:notification:reply",e)}};function Ho(e){if(e==null)return Date.now();if(e instanceof Date)return e.getTime();if(typeof e==="number")return e;let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}var Uo={async readFile(e){let t=await y("fs").readFile(e);return t&&t.data||""},async readBuffer(e){let t=await y("fs").readFile(e),r=t&&t.data||"";if(t&&t.base64===!0)return Vo(r);return new TextEncoder().encode(r)},async writeFile(e,t){await y("fs").writeFile(e,t)},async writeBuffer(e,t){let r=qo(t),n=y("fs");if(typeof n.writeFileBytes==="function")await n.writeFileBytes(e,r);else await n.writeFile(e,r)},async copy(e,t){if(e===t)throw Error("fs.copy: source and destination must differ");await y("fs").copy(e,t)},async move(e,t){if(e===t)throw Error("fs.move: source and destination must differ");await y("fs").move(e,t)},async appendFile(e,t){await y("fs").appendFile(e,t)},async deleteFile(e){await y("fs").deleteFile(e)},async exists(e){return await y("fs").exists(e)},async stat(e){return jo(await y("fs").stat(e))},async readDir(e){let t=await y("fs").readDir(e),r=t&&t.entries||[],n=e.endsWith("/")?e.slice(0,-1):e;return r.map((i)=>({name:i.name,path:`${n}/${i.name}`,isDirectory:!!i.isDirectory}))},async mkdir(e,t){await y("fs").mkdir(e,t)},async rmdir(e,t){await y("fs").rmdir(e,t)},async watch(e,t){await y("fs").watch(e,t)},async unwatch(e){await y("fs").unwatch(e)},onChange(e){return g("craft:fs:change",e)},async watchTree(e,t,r){let n=`watch-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,i=y("fs");await i.watch(e,n,{recursive:!!t.recursive});let a=t.kinds&&t.kinds.length>0?new Set(t.kinds):null,s=Math.max(0,Math.floor(t.coalesceMs??0)),c=[],l=null,d=!1,p=()=>{if(l=null,c.length===0)return;let u=c;c=[];try{r(u)}catch{}},f=g("craft:fs:change",(u)=>{if(d)return;if(u.id!==n)return;if(a&&u.kind&&!a.has(u.kind))return;if(c.push(u),s===0){p();return}if(l==null)l=setTimeout(p,s)});return{id:n,async stop(){if(d)return;if(d=!0,f(),l)clearTimeout(l),l=null;if(c.length>0)p();try{await i.unwatch(n)}catch{}}}},async homeDir(){return await y("fs").homeDir()},async tempDir(){return await y("fs").tempDir()},async appDataDir(){return await y("fs").appDataDir()}};function qo(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return typeof btoa==="function"?btoa(t):Buffer.from(e).toString("base64")}function Vo(e){let t=typeof atob==="function"?atob(e):Buffer.from(e,"base64").toString("binary"),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function jo(e){return{isFile:!!e.isFile,isDirectory:!!e.isDirectory,isSymlink:!!e.isSymlink,size:Number(e.size)||0,modifiedAt:e.modifiedAt!=null?e.modifiedAt<1000000000000?e.modifiedAt*1000:e.modifiedAt:0}}var Y=new Set,bt=!1;function Ko(){if(bt)return;if(typeof window>"u"||typeof window.addEventListener!=="function")return;window.addEventListener("craft:shell:exit",(e)=>{let t=e.detail;if(t?.id)Y.delete(t.id)}),bt=!0}var Go=new Set(["javascript:","data:","file:","vbscript:"]),Yo={async openExternal(e){let t=e.trim().toLowerCase();for(let r of Go)if(t.startsWith(r))throw Error(`shell.openExternal: ${r} URLs are blocked for safety`);if(o("shell")){await window.craft.shell.openExternal(e);return}if(typeof window<"u"&&typeof window.open==="function")window.open(e,"_blank","noopener,noreferrer")},async openPath(e){await y("shell").openPath(e)},async showInFinder(e){await y("shell").showInFinder(e)},async spawn(e,t,r=[],n={}){if(Ko(),!e||typeof e!=="string")throw Error("shell.spawn: id must be a non-empty string");if(!t||typeof t!=="string")throw Error("shell.spawn: command must be a non-empty string");if(!Array.isArray(r))throw Error("shell.spawn: args must be an array");for(let i of r)if(typeof i!=="string")throw Error("shell.spawn: args entries must be strings");if(Y.has(e))throw Error(`shell.spawn: id "${e}" is already in use \u2014 call kill(id) first or pick a different id`);Y.add(e);try{await y("shell").spawn(e,t,r,n)}catch(i){throw Y.delete(e),i}},async kill(e){await y("shell").kill(e),Y.delete(e)},async getEnv(e){if(o("shell")){let t=await window.craft.shell.getEnv(e);return t==null?void 0:String(t)}return},async setEnv(e,t){await y("shell").setEnv(e,t)},onStdout(e){return g("craft:shell:stdout",e)},onStderr(e){return g("craft:shell:stderr",e)},onExit(e){return g("craft:shell:exit",e)}};function F(){return window.craft.shortcuts}var Xo={async register(e,t,r){if(!o("shortcuts"))return;await F().register(e,t,r)},async unregister(e){if(!o("shortcuts"))return;await F().unregister(e)},async unregisterAll(){if(!o("shortcuts"))return;await F().unregisterAll()},async enable(e){if(!o("shortcuts"))return;await F().enable(e)},async disable(e){if(!o("shortcuts"))return;await F().disable(e)},async isRegistered(e){if(!o("shortcuts"))return!1;return await F().isRegistered(e)},async list(){if(!o("shortcuts"))return[];return await F().list()},on(e){return g("craft:shortcut",e)}};var Jo={get(){if(o("theme"))try{return window.craft.theme.get()}catch{}return{appearance:Qo()}},onChange(e){if(e(this.get()),o("theme"))return g("craft:theme",e);if(typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>e({appearance:t.matches?"dark":"light"});return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}return()=>{}},async current(){return this.get()}};function Qo(){if(typeof window>"u"||!window.matchMedia)return"light";return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}async function Zo(e,t={}){if(!o("dragOut"))throw Error("dragOut requires a Craft native window");let r=Array.isArray(e)?e:[e];if(r.length===0)throw Error("dragOut: at least one path required");await window.craft.dragOut.start(r,t)}function ei(){return o("dragOut")}var ti={onUrl(e){if(!o("deepLink"))return()=>{};return g("craft:deepLink",e)},getInitialUrl(){if(typeof window>"u")return null;if(o("deepLink"))try{return window.craft.deepLink.getInitialUrl()}catch{return null}return window.__craftPendingDeepLink||null},consumeInitialUrl(){let e=this.getInitialUrl();if(typeof window<"u")window.__craftPendingDeepLink=void 0;return e},isAvailable(){return o("deepLink")}};var ri={async isCharging(){if(o("power"))return await window.craft.power.isCharging();let e=await se();return e?!!e.charging:!1},async isPluggedIn(){if(o("power"))return await window.craft.power.isPluggedIn();let e=await se();return e?!!e.charging||e.level>=0.999:!1},async isLowPowerMode(){if(o("power"))return await window.craft.power.isLowPowerMode();return!1},async level(){if(o("power")){let t=await window.craft.power.batteryLevel();return typeof t==="number"?t:null}let e=await se();return e?e.level:null},async timeRemaining(){if(o("power")){let r=await window.craft.power.timeRemaining();return typeof r==="number"?r:null}let e=await se();if(!e)return null;let t=e.charging?e.chargingTime:e.dischargingTime;return Number.isFinite(t)?Math.round(t/60):null},async thermalState(){if(o("power"))return await window.craft.power.thermalState()||"unknown";return"unknown"},async uptimeSeconds(){if(o("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(e="app is busy"){if(o("power")){await window.craft.power.preventSleep(e);return}if(typeof navigator>"u"||!navigator.wakeLock)return;let t=window;if(t.__craftWebWakeLock?.release){try{await t.__craftWebWakeLock.release()}catch{}t.__craftWebWakeLock=null}try{let r=await navigator.wakeLock.request("screen");t.__craftWebWakeLock=r}catch{}},async allowSleep(){if(o("power")){await window.craft.power.allowSleep();return}let e=window.__craftWebWakeLock;if(e&&typeof e.release==="function"){try{await e.release()}catch{}window.__craftWebWakeLock=null}},onSleep(e){return g("craft:powerSleep",e)},onWake(e){return g("craft:powerWake",e)}};async function se(){if(typeof navigator>"u")return null;let e=navigator;if(typeof e.getBattery!=="function")return null;try{return await e.getBattery()}catch{return null}}var ni={async connectionType(){if(o("network"))return await window.craft.network.connectionType();return xt()},async wifiSSID(){if(o("network"))return await window.craft.network.wifiSSID()||void 0;return},async wifiSignalStrength(){if(o("network")){let e=await window.craft.network.wifiSignalStrength();return typeof e==="number"?e:void 0}return},async ipAddress(){if(o("network"))return await window.craft.network.ipAddress();return""},async macAddress(){if(o("network"))return await window.craft.network.macAddress();return""},async interfaces(){if(o("network"))return await window.craft.network.interfaces();return[]},async isVPNConnected(){if(o("network"))return await window.craft.network.isVPNConnected();return!1},async proxySettings(){if(o("network"))return await window.craft.network.proxySettings()||{};return{}},async openPreferences(){if(o("network"))await window.craft.network.openPreferences()},onChange(e){if(o("network"))return g("craft:networkChange",e);if(typeof window>"u")return()=>{};let t=()=>e({type:xt(),online:!0}),r=()=>e({type:"none",online:!1});return window.addEventListener("online",t),window.addEventListener("offline",r),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}};function xt(){if(typeof navigator>"u")return"unknown";if(navigator.onLine===!1)return"none";let e=navigator.connection;if(!e)return"unknown";let t=String(e.type||e.effectiveType||"unknown").toLowerCase();if(t==="wifi"||t==="cellular"||t==="ethernet"||t==="bluetooth"||t==="none")return t;return"unknown"}var oi={async checkForUpdates(){if(!o("updater"))return;await window.craft.updater.checkForUpdates()},async checkInBackground(){if(!o("updater"))return;await window.craft.updater.checkInBackground()},async setAutomaticChecks(e){if(!o("updater"))return;await window.craft.updater.setAutomaticChecks(e)},async setCheckInterval(e){if(!o("updater"))return;if(!Number.isFinite(e))throw Error("setCheckInterval: must be a finite number");let t=e<=0?0:Math.max(60,Math.round(e));await window.craft.updater.setCheckInterval(t)},async setFeedURL(e){if(!o("updater"))return;await window.craft.updater.setFeedURL(e)},async getLastUpdateCheckDate(){if(!o("updater"))return null;return await window.craft.updater.getLastUpdateCheckDate()||null},async getUpdateInfo(){if(!o("updater"))return null;let e=await window.craft.updater.getUpdateInfo();if(!e||typeof e.version!=="string"||e.version.length===0)return null;return e},onAvailable(e){return g("craft:updateAvailable",e)},onDownloaded(e){return g("craft:updateDownloaded",e)},async verifySignature({payload:e,signatureB64:t,publicKeyB64:r}){let n=yt(e),i;try{i=await crypto.subtle.importKey("raw",ce(r),{name:"Ed25519"},!1,["verify"])}catch{return!1}try{return await crypto.subtle.verify("Ed25519",i,ce(t),n)}catch{return!1}},async verifyDownload({url:e,signatureB64:t,publicKeyB64:r,fetchInit:n}){let i;try{i=await fetch(e,n)}catch{return{ok:!1,reason:"fetch-failed"}}if(!i.ok)return{ok:!1,reason:"http-error",status:i.status};let a=new Uint8Array(await i.arrayBuffer()),s;try{s=await crypto.subtle.importKey("raw",ce(r),{name:"Ed25519"},!1,["verify"])}catch{return{ok:!1,reason:"bad-key"}}let c=!1;try{c=await crypto.subtle.verify("Ed25519",s,ce(t),yt(a))}catch{c=!1}if(!c)return{ok:!1,reason:"bad-signature"};return{ok:!0,payload:a}}};function yt(e){if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=new ArrayBuffer(e.byteLength),r=new Uint8Array(t);return r.set(e),r}function ce(e){if(typeof atob==="function"){let n=atob(e),i=new ArrayBuffer(n.length),a=new Uint8Array(i);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);return a}let t=Buffer.from(e,"base64"),r=new ArrayBuffer(t.length);return new Uint8Array(r).set(t),new Uint8Array(r)}var ii={onFocus(e){if(o("window"))return g("craft:window:focus",()=>e());return Ce("focus",e)},onBlur(e){if(o("window"))return g("craft:window:blur",()=>e());return Ce("blur",e)},onResize(e){if(o("window"))return g("craft:window:resize",e);if(typeof window>"u")return()=>{};let t=()=>e({width:window.innerWidth,height:window.innerHeight});return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},onMove(e){if(o("window"))return g("craft:window:move",e);return()=>{}},onClose(e){if(o("window"))return g("craft:window:close",()=>e());return Ce("beforeunload",e)},onMinimize(e){if(o("window"))return g("craft:window:minimize",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="hidden")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},onRestore(e){if(o("window"))return g("craft:window:restore",()=>e());if(typeof document>"u")return()=>{};let t=()=>{if(document.visibilityState==="visible")e()};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)}};function Ce(e,t){if(typeof window>"u")return()=>{};let r=()=>t();return window.addEventListener(e,r),()=>window.removeEventListener(e,r)}var vt={name:"",version:"0.0.0"},ai={async hideDockIcon(){if(o("app"))await window.craft.app.hideDockIcon()},async showDockIcon(){if(o("app"))await window.craft.app.showDockIcon()},async quit(){if(o("app"))await window.craft.app.quit()},async getInfo(){if(!o("app"))return vt;let e=await window.craft.app.getInfo();return{...vt,...e||{}}},async notify(e){if(!e.title)throw Error("notify: title is required");if(o("app"))await window.craft.app.notify(e)},async setBadge(e){if(o("app"))await window.craft.app.setBadge(e)},async bounce(e="informational"){if(o("app"))await window.craft.app.bounce(e)}};var si={app(e,t={}){return{label:e,items:[{label:`About ${e}`,role:"about"},{separator:!0},...t.settings?[{id:"stx.menu.settings",label:"Settings\u2026",shortcut:"cmd+,",onClick:t.settings},{separator:!0}]:[],{label:`Hide ${e}`,role:"hide",shortcut:"cmd+h"},{label:"Hide Others",role:"hideOthers",shortcut:"cmd+alt+h"},{label:"Show All",role:"showAll"},{separator:!0},{label:`Quit ${e}`,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(e,t={}){return[this.app(e,t),this.edit()]}},ci=0;function li(e){let t=new Map;return{payload:{menus:e.menus.map((n)=>({label:n.label,items:n.items.map((i)=>{let{onClick:a,...s}=i;if(s.separator)return s;let c=s.id??`stx.menu.${ci++}`;if(a)t.set(c,a);return{...s,id:c}})}))},handlers:t}}var Ie=null,di={async set(e){if(!o("menu"))return!1;let{payload:t,handlers:r}=li(e);if(Ie?.(),Ie=null,r.size>0)Ie=g("craft:menu:action",(n)=>{r.get(n.id)?.()});return await window.craft.menu.set(t),!0},async setDock(e){if(o("menu"))await window.craft.menu.setDock(e)},async addItem(e,t){if(o("menu"))await window.craft.menu.addItem(e,t)},async removeItem(e){if(o("menu"))await window.craft.menu.removeItem(e)},async enableItem(e){if(o("menu"))await window.craft.menu.enableItem(e)},async disableItem(e){if(o("menu"))await window.craft.menu.disableItem(e)},async checkItem(e){if(o("menu"))await window.craft.menu.checkItem(e)},async uncheckItem(e){if(o("menu"))await window.craft.menu.uncheckItem(e)},async setItemLabel(e,t){if(o("menu"))await window.craft.menu.setItemLabel(e,t)},async clearDock(){if(o("menu"))await window.craft.menu.clearDock()},onAction(e){return g("craft:menu:action",e)}};function St(e){if(e.separator)return{id:e.id||"",title:"",type:"separator"};return{id:e.id||"",title:e.title||"",icon:e.icon,shortcut:e.shortcut,enabled:e.disabled?!1:void 0,checked:e.checked?!0:void 0,type:e.submenu?"submenu":void 0,submenu:e.submenu?.map(St)}}async function Pt(e){if(!e.items||e.items.length===0)throw Error("contextMenu.show requires at least one item");if(!o("nativeUI"))return null;let t=window.craft?.nativeUI;if(!t)return null;let r=await t.showContextMenu({targetId:e.targetId||"",targetType:"general",x:Math.round(e.x),y:Math.round(e.y),items:e.items.map(St)});return{id:typeof r?.id==="string"?r.id:null,targetId:r?.targetId}}var ui={available(){return o("nativeUI")},async show(e){return await Pt(e)!==null},async pick(e){return(await Pt(e))?.id??null},onAction(e){return g("craft:contextmenu:action",(t)=>{if(typeof t.id==="string")e({id:t.id,targetId:t.targetId??""})})}};function $e(e){if(e===null||e===void 0||e===0)return"";return String(e)}function kt(e){return e.map((t)=>({id:t.id,header:t.header,items:t.items.map((r)=>({id:r.id,label:r.label,icon:r.icon,badge:$e(r.badge)||void 0}))}))}function At(e){return JSON.stringify(e.map((t)=>[t.id,t.header??"",t.items.map((r)=>[r.id,r.label,r.icon??""])]))}function Ct(e){return new Map(e.flatMap((t)=>t.items.map((r)=>[r.id,$e(r.badge)])))}var It={available(){return o("nativeUI")&&typeof window.craft?.nativeUI?._emitSidebarSelect==="function"},create(e){if(!It.available())return null;let t=window.craft?.nativeUI;if(!t)return null;let r=t.createSidebar({id:e.id,sections:kt(e.sections),selected:e.selected}),n=e.sections,i=new Set;return r.onSelect((a)=>{for(let s of[...i])s(a)}),{id:r.id,update(a){if(At(a)===At(n)){let s=Ct(n);for(let[c,l]of Ct(a))if(s.get(c)!==l)r.updateItem(c,{badge:l})}else r.setSections(kt(a));n=a},updateItem(a,s){r.updateItem(a,{...s.label!==void 0?{label:s.label}:{},...s.icon!==void 0?{icon:s.icon}:{},..."badge"in s?{badge:$e(s.badge)}:{}}),n=n.map((c)=>({...c,items:c.items.map((l)=>l.id===a?{...l,...s}:l)}))},select(a){r.setSelectedItem(a)},onSelect(a){return i.add(a),()=>i.delete(a)},destroy(){i.clear(),r.destroy()}}}};var pi={accentColor:()=>T("system","accentColor",()=>""),highlightColor:()=>T("system","highlightColor",()=>""),language:()=>T("system","language",()=>{if(typeof navigator>"u")return"";return navigator.language?.split("-")[0]||""}),locale:()=>T("system","locale",()=>{if(typeof navigator>"u")return"";return navigator.language||""}),timezone:()=>T("system","timezone",()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||""}catch{return""}}),is24HourTime:()=>T("system","is24HourTime",()=>{try{let e=new Intl.DateTimeFormat([],{hour:"numeric"}).resolvedOptions();return e.hourCycle==="h23"||e.hourCycle==="h24"}catch{return!1}}),reduceMotion:()=>T("system","reduceMotion",()=>Te("(prefers-reduced-motion: reduce)")),reduceTransparency:()=>T("system","reduceTransparency",()=>Te("(prefers-reduced-transparency: reduce)")),increaseContrast:()=>T("system","increaseContrast",()=>Te("(prefers-contrast: more)")),systemVersion:()=>T("system","systemVersion",()=>""),hostname:()=>T("system","hostname",()=>""),username:()=>T("system","username",()=>""),async openPreferences(){if(o("system"))await window.craft.system.openPreferences()}};async function T(e,t,r){if(o(e))return await window.craft[e][t]();return await r()}function Te(e){if(typeof window>"u"||!window.matchMedia)return!1;return window.matchMedia(e).matches}var fi={async getDisplays(){if(o("screen"))return await window.craft.screen.getDisplays();return $t()},async getPrimary(){if(o("screen")){let e=await window.craft.screen.getPrimary();return e&&typeof e.width==="number"?e:null}return $t()[0]??null},onChange(e){if(o("screen"))return g("craft:screen:change",()=>e());if(typeof window>"u")return()=>{};let t=()=>e();return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}};function $t(){if(typeof window>"u"||!window.screen)return[];let e=window.screen;return[{id:0,x:e.left??0,y:e.top??0,width:e.width||0,height:e.height||0,workX:e.availLeft??0,workY:e.availTop??0,workWidth:e.availWidth??e.width??0,workHeight:e.availHeight??e.height??0,scaleFactor:window.devicePixelRatio||1}]}var mi={async set(e,t,r){if(!e)throw Error("keychain.set: service is required");if(!t)throw Error("keychain.set: account is required");await y("keychain").set(e,t,r)},async get(e,t){if(!e)throw Error("keychain.get: service is required");if(!t)throw Error("keychain.get: account is required");let r=await y("keychain").get(e,t);return typeof r==="string"?r:null},async delete(e,t){if(!e)throw Error("keychain.delete: service is required");if(!t)throw Error("keychain.delete: account is required");await y("keychain").delete(e,t)},async has(e,t){if(!e)throw Error("keychain.has: service is required");if(!t)throw Error("keychain.has: account is required");return await y("keychain").has(e,t)}};var gi={async check(e){if(o("permissions"))return await window.craft.permissions.check(e);return await Tt(e)},async request(e){if(o("permissions"))return await window.craft.permissions.request(e);return await hi(e)},async openSettings(e){if(o("permissions"))await window.craft.permissions.openSettings(e)}};async function Tt(e){if(typeof navigator>"u"||!navigator.permissions?.query)return"not-supported";try{let t=await navigator.permissions.query({name:e});return wi(t.state)}catch{return"not-supported"}}async function hi(e){if(e==="notifications"&&typeof window<"u"&&"Notification"in window){let t=await window.Notification.requestPermission();return t==="granted"?"granted":t==="denied"?"denied":"undetermined"}return await Tt(e)}function wi(e){if(e==="granted")return"granted";if(e==="denied")return"denied";if(e==="prompt")return"undetermined";return"undetermined"}var bi={async print(){if(o("printing")){await window.craft.printing.print();return}if(typeof window<"u"&&typeof window.print==="function")window.print()},async printToPDF(e){if(!e)throw Error("printToPDF: path is required");let t=e.startsWith("/"),r=/^[a-zA-Z]:[\\/]/.test(e)||e.startsWith("\\\\");if(!t&&!r)throw Error("printToPDF: path must be absolute");let n=await y("printing").printToPDF(e);return{ok:!!(n&&n.ok),path:n?.path}}};var xi={async enable(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.enable()},async disable(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.disable()},async isEnabled(){if(!o("autoLaunch"))return!1;return await window.craft.autoLaunch.isEnabled()}};async function Ee(e){if(!o("tray"))return;let t=window.craft.tray;await e(t)}var yi={setIcon:(e)=>Ee((t)=>t.setIcon(e)),setTitle:(e)=>Ee((t)=>t.setTitle(e)),setTooltip:(e)=>Ee((t)=>t.setTooltip(e))};function Me(){if(!o("window"))return null;return window.craft.window}function M(e){let t=Me();if(!t)return Promise.resolve();try{return Promise.resolve(e(t)).then(()=>{return},()=>{return})}catch{return Promise.resolve()}}var vi={get available(){return Me()!==null},open(e){let t=()=>{if(typeof window<"u"&&e.url)window.open(e.url,e.name);return{name:e.name}},r=Me();if(!r?.open)return Promise.resolve(t());return r.open(e).then((n)=>({name:n?.name||e.name})).catch(t)},close:()=>M((e)=>e.close?.()),show:()=>M((e)=>e.show?.()),hide:()=>M((e)=>e.hide?.()),focus:()=>M((e)=>e.focus?.()),minimize:()=>M((e)=>e.minimize?.()),maximize:()=>M((e)=>e.maximize?.()),center:()=>M((e)=>e.center?.()),startDrag:()=>M((e)=>e.startDrag?.()),setTitle:(e)=>M((t)=>t.setTitle?.(e)),setSize:(e,t)=>M((r)=>r.setSize?.(e,t)),setAppearance:(e)=>M((t)=>t.setAppearance?.(e))};var Pi={async addItem(e){if(o("touchbar"))await window.craft.touchbar.addItem(e)},async removeItem(e){if(o("touchbar"))await window.craft.touchbar.removeItem(e)},async updateItem(e,t){if(o("touchbar"))await window.craft.touchbar.updateItem(e,t)},async setLabel(e,t){if(o("touchbar"))await window.craft.touchbar.setLabel(e,t)},async setIcon(e,t){if(o("touchbar"))await window.craft.touchbar.setIcon(e,t)},async setEnabled(e,t){if(o("touchbar"))await window.craft.touchbar.setEnabled(e,t)},async setSliderValue(e,t){if(o("touchbar"))await window.craft.touchbar.setSliderValue(e,t)},async clear(){if(o("touchbar"))await window.craft.touchbar.clear()},async show(){if(o("touchbar"))await window.craft.touchbar.show()},async hide(){if(o("touchbar"))await window.craft.touchbar.hide()},onAction(e){return g("craft:touchbar:action",e)}};var Si=/^[\da-f]*$/i;function ki(e,t){if(typeof t!=="string"||!Si.test(t)||t.length%2!==0)throw Error(`${e}: must be a hex string with even length, got ${JSON.stringify(t)}`)}var Ai={async isEnabled(){return o("bluetooth")?await window.craft.bluetooth.isEnabled():!1},async powerState(){return o("bluetooth")?await window.craft.bluetooth.powerState():"unknown"},async connectedDevices(){return o("bluetooth")?await window.craft.bluetooth.connectedDevices():[]},async pairedDevices(){return o("bluetooth")?await window.craft.bluetooth.pairedDevices():[]},async startDiscovery(){if(o("bluetooth"))await window.craft.bluetooth.startDiscovery()},async stopDiscovery(){if(o("bluetooth"))await window.craft.bluetooth.stopDiscovery()},async isDiscovering(){return o("bluetooth")?await window.craft.bluetooth.isDiscovering():!1},async connect(e){if(o("bluetooth"))await window.craft.bluetooth.connect(e)},async disconnect(e){if(o("bluetooth"))await window.craft.bluetooth.disconnect(e)},async openPreferences(){if(o("bluetooth"))await window.craft.bluetooth.openPreferences()},async discoverServices(e){if(!e)throw Error("bluetooth.discoverServices: deviceId is required");if(!o("bluetooth"))return[];let t=await window.craft.bluetooth.discoverServices(e);return Array.isArray(t)?t:[]},async discoverCharacteristics(e,t){if(!e||!t)throw Error("bluetooth.discoverCharacteristics: deviceId and serviceUuid are required");if(!o("bluetooth"))return[];let r=await window.craft.bluetooth.discoverCharacteristics(e,t);return Array.isArray(r)?r:[]},async readCharacteristic(e,t,r){if(!e||!t||!r)throw Error("bluetooth.readCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.readCharacteristic(e,t,r)},async writeCharacteristic(e,t,r,n,i="with-response"){if(!e||!t||!r)throw Error("bluetooth.writeCharacteristic: deviceId, serviceUuid, characteristicUuid are required");if(ki("bluetooth.writeCharacteristic.valueHex",n),!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.writeCharacteristic(e,t,r,n,i)},async setCharacteristicNotify(e,t,r,n){if(!e||!t||!r)throw Error("bluetooth.setCharacteristicNotify: deviceId, serviceUuid, characteristicUuid are required");if(!o("bluetooth"))return{ok:!1,reason:"bridge unavailable"};return await window.craft.bluetooth.setCharacteristicNotify(e,t,r,n)},onDeviceFound(e){return g("craft:bluetooth:deviceFound",e)},onDeviceConnected(e){return g("craft:bluetooth:deviceConnected",e)},onDeviceDisconnected(e){return g("craft:bluetooth:deviceDisconnected",e)},onCharacteristicValue(e){return g("craft:bluetooth:characteristicValue",e)}};var Ci={async speak(e,t){if(!e)throw Error("speech.speak: text is required");if(o("speech")){await window.craft.speech.speak(e,t);return}if(typeof window<"u"&&window.speechSynthesis){let r=new window.SpeechSynthesisUtterance(e);if(t){if(t.rate!=null)r.rate=t.rate;if(t.pitch!=null)r.pitch=t.pitch;if(t.volume!=null)r.volume=t.volume;if(t.voice){let i=window.speechSynthesis.getVoices().find((a)=>a.voiceURI===t.voice||a.name===t.voice||a.lang===t.voice);if(i)r.voice=i}}window.speechSynthesis.speak(r)}},async stop(){if(o("speech")){await window.craft.speech.stop();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.cancel()},async pause(){if(o("speech")){await window.craft.speech.pause();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.pause()},async resume(){if(o("speech")){await window.craft.speech.resume();return}if(typeof window<"u"&&window.speechSynthesis)window.speechSynthesis.resume()},async isSpeaking(){if(o("speech"))return await window.craft.speech.isSpeaking();if(typeof window<"u"&&window.speechSynthesis)return!!window.speechSynthesis.speaking;return!1},async getVoices(){if(o("speech"))return await window.craft.speech.getVoices();if(typeof window<"u"&&window.speechSynthesis)return window.speechSynthesis.getVoices().map((t)=>({id:t.voiceURI||t.name,name:t.name,language:t.lang||"",quality:"default"}));return[]}};var X=[],De=!0,Be,Oe,J={async report(e){if(o("crashReporter")){await window.craft.crashReporter.report(e);return}if(!De)return;let t=e instanceof Error?{timestamp:Date.now(),severity:"error",message:e.message,source:"js",stack:e.stack||"",userId:Be,appVersion:Oe}:{timestamp:Date.now(),severity:e.severity||"error",message:e.message||"",source:e.source||"js",stack:e.stack||"",userId:Be,appVersion:Oe};if(X.length>=64)X.shift();X.push(t)},async flush(){if(o("crashReporter"))return await window.craft.crashReporter.flush();return[...X]},async clear(){if(o("crashReporter")){await window.craft.crashReporter.clear();return}X.length=0},async setEnabled(e){if(o("crashReporter")){await window.craft.crashReporter.setEnabled(e);return}De=e},async isEnabled(){if(o("crashReporter"))return await window.craft.crashReporter.isEnabled();return De},async setUser(e){if(o("crashReporter")){await window.craft.crashReporter.setUser(e);return}Be=e||void 0},async setAppVersion(e){if(o("crashReporter")){await window.craft.crashReporter.setAppVersion(e);return}Oe=e||void 0},attachGlobalHandlers(){if(o("crashReporter")&&window.craft.crashReporter.attachGlobalHandlers)return window.craft.crashReporter.attachGlobalHandlers();if(typeof window>"u")return()=>{};let e=(r)=>{J.report({severity:"error",message:r.message,source:"js",stack:r.error?.stack||`${r.message}
|
|
927
927
|
at ${r.filename}:${r.lineno}:${r.colno}`}).catch(()=>{})},t=(r)=>{let n=r.reason;J.report({severity:"error",message:n?.message||String(n),source:"js",stack:n?.stack||""}).catch(()=>{})};return window.addEventListener("error",e),window.addEventListener("unhandledrejection",t),()=>{window.removeEventListener("error",e),window.removeEventListener("unhandledrejection",t)}},forwardTo(e){return Di(e)}},Ii="craft:crashReporter:pending",$i=/[\w.+-]+@[\w-]+\.[\w.-]+/g,Ti=/\b(?:\d{1,3}\.){3}\d{1,3}\b/g,Ei=/\/(?:Users|home)\/[^\s/'"`]+/g;function Mt(e){let t=(r)=>r.replace($i,"<email>").replace(Ti,"<ip>").replace(Ei,"/<home>");return{...e,message:t(e.message),stack:t(e.stack)}}async function Dt(e,t){let r=new TextEncoder,n=await crypto.subtle.importKey("raw",r.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),i=await crypto.subtle.sign("HMAC",n,r.encode(t));return[...new Uint8Array(i)].map((a)=>a.toString(16).padStart(2,"0")).join("")}function Mi(e){if(!e||typeof localStorage>"u")return[];try{let t=localStorage.getItem(e);if(!t)return[];let r=JSON.parse(t);return Array.isArray(r)?r:[]}catch{return[]}}function Et(e,t){if(!e||typeof localStorage>"u")return;try{if(t.length===0)localStorage.removeItem(e);else localStorage.setItem(e,JSON.stringify(t))}catch{}}function Di(e){let{endpoint:t,intervalMs:r=60000,signingSecret:n,redact:i=!0,headers:a={},maxRetries:s=5,persistKey:c}=e,l=c===null?null:c??Ii,d=Mi(l),p=!1,f=null,u=null,h=typeof i==="function"?i:i===!1?(S)=>S:Mt;async function w(S){let k=JSON.stringify({entries:S}),D={"Content-Type":"application/json",...a};if(n)D["X-Craft-Signature"]=await Dt(n,k);let Z=0,B=1000;while(!p)try{let W=await fetch(t,{method:"POST",headers:D,body:k});if(W.ok)return;if(W.status>=400&&W.status<500)return;throw Error(`HTTP ${W.status}`)}catch(W){if(Z+=1,Z>s)throw d=[...S,...d],Et(l,d),W;await new Promise((Ft)=>{setTimeout(Ft,B)}),B=Math.min(B*2,60000)}}async function P(){if(p||u)return u??void 0;let S=await J.flush();if(S.length>0)await J.clear();if(d=[...d,...S.map((D)=>h(D))],d.length===0)return;let k=d;return d=[],Et(l,d),u=w(k).catch(()=>{}).finally(()=>{u=null}),u}if(r>0)f=setInterval(()=>{P().catch(()=>{})},r);return{async flushNow(){await P()},stop(){if(p=!0,f)clearInterval(f);f=null},pending(){return[...d]}}}var Bi={async isAvailable(){if(!o("iap"))return!1;return await window.craft.iap.isAvailable()},async getProducts(e){if(!o("iap"))return[];let t=Array.isArray(e)?e:[String(e)];return await window.craft.iap.getProducts(t)},async purchase(e){if(!o("iap"))return{queued:!1,productId:e,reason:"IAP bridge not available"};let t=await window.craft.iap.purchase(e);return{queued:!!(t&&t.queued),productId:t?.productId,reason:t?.reason}},async restorePurchases(){if(!o("iap"))return{ok:!1};let e=await window.craft.iap.restorePurchases();return{ok:!!(e&&e.ok)}},async finishTransaction(e){if(!o("iap"))return;await window.craft.iap.finishTransaction(e)},async getReceiptData(){if(!o("iap"))return null;let e=await window.craft.iap.getReceiptData();return e?String(e):null},onPurchased(e){return g("craft:iap:purchased",e)},onFailed(e){return g("craft:iap:failed",e)},onRestored(e){return g("craft:iap:restored",e)},onProductsLoaded(e){return g("craft:iap:productsLoaded",(t)=>e(t.products||[]))},onRefunded(e){return g("craft:iap:refunded",e)},onSubscriptionStatusChanged(e){return g("craft:iap:subscriptionStatusChanged",e)},async getActiveSubscriptions(){if(!o("iap"))return[];let e=window.craft.iap.getActiveSubscriptions;if(typeof e!=="function")return[];let t=await e();return Array.isArray(t)?t:[]},async isEligibleForIntroOffer(e){if(!o("iap"))return!1;let t=window.craft.iap.isEligibleForIntroOffer;if(typeof t!=="function")return!1;return!!await t(e)}};var Q={async startActivity(e,t){if(!e)throw Error("handoff.startActivity: type is required");if(!o("handoff"))return!1;let r=await window.craft.handoff.startActivity(e,t);return typeof r==="boolean"?r:!!(r&&r.ok)},async updateActivity(e){if(!o("handoff"))return!1;let t=await window.craft.handoff.updateActivity(e);return typeof t==="boolean"?t:!!(t&&t.ok)},async stopActivity(){if(!o("handoff"))return;await window.craft.handoff.stopActivity()},async getCurrentActivity(){if(!o("handoff"))return null;let e=await window.craft.handoff.getCurrentActivity();return e&&typeof e.type==="string"?e:null},onIncoming(e){return g("craft:handoff:incoming",e)}};var Oi={async start(e,t){return Q.startActivity(e,{title:t?.title,webpageURL:t?.webpageURL,userInfo:t?.state})},async update(e){return Q.updateActivity({title:e.title,webpageURL:e.webpageURL,userInfo:e.state})},async stop(){await Q.stopActivity()}};var Ri={async requestPermission(e="whenInUse"){if(o("location"))return await window.craft.location.requestPermission(e);if(typeof navigator<"u"&&navigator.geolocation)return"undetermined";return"not-supported"},async getAuthorization(){if(o("location"))return await window.craft.location.getAuthorization();return"unknown"},async getCurrentLocation(){if(o("location"))return await window.craft.location.getCurrentLocation();if(typeof navigator<"u"&&navigator.geolocation)return navigator.geolocation.getCurrentPosition((e)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:e.coords.latitude,longitude:e.coords.longitude,altitude:e.coords.altitude,horizontalAccuracy:e.coords.accuracy,verticalAccuracy:e.coords.altitudeAccuracy,speed:e.coords.speed}}))},(e)=>{window.dispatchEvent(new CustomEvent("craft:location:error",{detail:{message:e.message||String(e)}}))}),{requested:!0};return{requested:!1}},async startWatching(e){if(o("location"))return await window.craft.location.startWatching(e);if(typeof navigator<"u"&&navigator.geolocation){let t=navigator.geolocation.watchPosition((r)=>{window.dispatchEvent(new CustomEvent("craft:location:update",{detail:{latitude:r.coords.latitude,longitude:r.coords.longitude,altitude:r.coords.altitude,horizontalAccuracy:r.coords.accuracy,verticalAccuracy:r.coords.altitudeAccuracy,speed:r.coords.speed}}))});return window.__craftWebLocationWatchId=t,!0}return!1},async stopWatching(){if(o("location")){await window.craft.location.stopWatching();return}if(typeof navigator<"u"&&navigator.geolocation){let e=window.__craftWebLocationWatchId;if(e!=null)navigator.geolocation.clearWatch(e),window.__craftWebLocationWatchId=null}},onUpdate(e){return g("craft:location:update",e)},onError(e){return g("craft:location:error",e)},onAuthChanged(e){return g("craft:location:authChanged",e)}};var Li={async captureScreen(){if(!o("screenCapture"))return null;let e=await window.craft.screenCapture.captureScreen();return e?String(e):null},async captureWindow(e){if(!o("screenCapture"))return null;if(!Number.isFinite(e)||e<=0)throw Error("captureWindow: id must be a positive number");let t=await window.craft.screenCapture.captureWindow(e);return t?String(t):null},async listWindows(){if(!o("screenCapture"))return[];return await window.craft.screenCapture.listWindows()}};var Ot=250,Rt=60000,de=2000,Bt={sharing:!1,signals:{systemScreenShare:!1,remoteSession:!1,conferenceSharing:!1,screenRecording:!1},sources:[]};function _i(){return{...Bt,signals:{...Bt.signals},sources:[]}}var le={async getState(){if(!o("screenSharing"))return _i();return await window.craft.screenSharing.getState()},async watch(e=de){let t=Number.isFinite(e)?Math.min(Rt,Math.max(Ot,Math.round(e))):de;if(!o("screenSharing"))return t;let r=await window.craft.screenSharing.watch(t);return r&&r.intervalMs||t},async stop(){if(!o("screenSharing"))return;await window.craft.screenSharing.unwatch()},onChange(e){return g("craft:screenSharing:change",e)}};async function Ni(e,t=de){let r=le.onChange(e);try{await le.watch(t)}catch(i){throw r(),i}let n;return()=>{if(!n)r(),n=le.stop();return n}}var Fi={supported:!1,isFocused:null,authorization:"unsupported"};function Lt(){return{ok:!1,error:"Focus control is only available in a Craft window on macOS"}}var Re={async getStatus(){if(!o("focus"))return{...Fi};return await window.craft.focus.getStatus()},async requestAuthorization(){if(!o("focus"))return"unsupported";return await window.craft.focus.requestAuthorization()},async setEnabled(e,t={}){if(!o("focus"))return Lt();if(!(e?t.onShortcut:t.offShortcut))return{ok:!1,error:`focus.setEnabled: no ${e?"onShortcut":"offShortcut"} configured`};return await window.craft.focus.setEnabled(e,t)},async runShortcut(e){if(!o("focus"))return Lt();if(!e)throw Error("focus.runShortcut: name is required");return await window.craft.focus.runShortcut(e)},async listShortcuts(){if(!o("focus"))return[];return await window.craft.focus.listShortcuts()},async listShortcutsResult(){if(!o("focus"))return{canList:!1,shortcuts:[]};let t=await window.craft.focus.listShortcutsResult?.();return{canList:Boolean(t?.canList),shortcuts:t?.shortcuts??[]}}};async function Wi(...e){if(e.length===0)return!1;let t=new Set(await Re.listShortcuts());return e.every((r)=>t.has(r))}async function zi(...e){if(e.length===0)return!1;let{canList:t,shortcuts:r}=await Re.listShortcutsResult();if(!t)return"unknown";let n=new Set(r);return e.every((i)=>n.has(i))}var Hi={async start(e=0,t="127.0.0.1"){if(!o("localServer"))return{port:0,started:!1,reason:"bridge unavailable"};return await window.craft.localServer.start(e,t)},async stop(){if(!o("localServer"))return;await window.craft.localServer.stop()},async respond(e){if(!o("localServer"))return;await window.craft.localServer.respond(e||{status:200,body:"OK"})},onRequest(e){return g("craft:localServer:request",e)},async awaitOAuthCallback(e={}){y("localServer");let{port:t=0,host:r="127.0.0.1",timeoutMs:n=300000,successHTML:i}=e,a=await this.start(t,r);if(!a.started)throw Error(`localServer: start failed${a.reason?` \u2014 ${a.reason}`:""}`);return new Promise((s,c)=>{let l=setTimeout(()=>{d(),this.stop().catch(()=>{}),c(Error("localServer: OAuth callback timed out"))},n),d=this.onRequest(({url:p})=>{clearTimeout(l),d();let f=i??`<!doctype html><meta charset="utf-8"><title>Done</title>
|
|
928
928
|
<style>body{font-family:-apple-system,BlinkMacSystemFont,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7}</style>
|
|
929
929
|
<div><h1>You can close this tab.</h1><p>Returning to the app\u2026</p></div>
|
package/dist/native-tray.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const nativeTray: {
|
|
|
17
17
|
};
|
|
18
18
|
/** Update the existing Craft status item from its page, without host imports. */
|
|
19
19
|
declare interface CraftTrayNamespace {
|
|
20
|
-
setIcon: (
|
|
21
|
-
setTitle: (
|
|
22
|
-
setTooltip: (
|
|
20
|
+
setIcon: (icon: string) => Promise<unknown>
|
|
21
|
+
setTitle: (title: string) => Promise<unknown>
|
|
22
|
+
setTooltip: (tooltip: string) => Promise<unknown>
|
|
23
23
|
}
|
package/package.json
CHANGED