palmier 0.8.4 → 0.8.6
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/platform/macos.js +11 -0
- package/dist/pwa/assets/{index-499vYQvR.js → index-BiAE5qeC.js} +2 -2
- package/dist/pwa/assets/{web-CyJutAy4.js → web-DYwZE4qa.js} +1 -1
- package/dist/pwa/assets/{web-Bp48ONY3.js → web-nSzKzI8x.js} +1 -1
- package/dist/pwa/index.html +1 -1
- package/dist/pwa/service-worker.js +1 -1
- package/package.json +1 -1
- package/palmier-server/pwa/src/constants.ts +1 -1
- package/palmier-server/spec.md +3 -3
- package/src/platform/macos.ts +9 -0
package/dist/platform/macos.js
CHANGED
|
@@ -19,6 +19,9 @@ function taskLabel(taskId) {
|
|
|
19
19
|
function taskPlistPath(taskId) {
|
|
20
20
|
return path.join(AGENT_DIR, `${taskLabel(taskId)}.plist`);
|
|
21
21
|
}
|
|
22
|
+
function taskLogPath(taskId) {
|
|
23
|
+
return path.join(CONFIG_DIR, `task-${taskId}.log`);
|
|
24
|
+
}
|
|
22
25
|
function guiDomain() {
|
|
23
26
|
const uid = process.getuid?.();
|
|
24
27
|
if (uid === undefined)
|
|
@@ -205,12 +208,16 @@ export class MacOsPlatform {
|
|
|
205
208
|
const label = taskLabel(taskId);
|
|
206
209
|
const plistPath = taskPlistPath(taskId);
|
|
207
210
|
const palmierBin = process.argv[1] || "palmier";
|
|
211
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
212
|
+
const logPath = taskLogPath(taskId);
|
|
208
213
|
const dict = {
|
|
209
214
|
Label: label,
|
|
210
215
|
ProgramArguments: [process.execPath, palmierBin, "run", taskId],
|
|
211
216
|
WorkingDirectory: config.projectRoot,
|
|
212
217
|
RunAtLoad: false,
|
|
213
218
|
EnvironmentVariables: { PATH: process.env.PATH || "/usr/local/bin:/usr/bin:/bin" },
|
|
219
|
+
StandardOutPath: logPath,
|
|
220
|
+
StandardErrorPath: logPath,
|
|
214
221
|
};
|
|
215
222
|
const scheduleType = task.frontmatter.schedule_type;
|
|
216
223
|
const scheduleValues = task.frontmatter.schedule_values;
|
|
@@ -242,6 +249,10 @@ export class MacOsPlatform {
|
|
|
242
249
|
fs.unlinkSync(taskPlistPath(taskId));
|
|
243
250
|
}
|
|
244
251
|
catch { /* ignore */ }
|
|
252
|
+
try {
|
|
253
|
+
fs.unlinkSync(taskLogPath(taskId));
|
|
254
|
+
}
|
|
255
|
+
catch { /* ignore */ }
|
|
245
256
|
}
|
|
246
257
|
async startTask(taskId) {
|
|
247
258
|
await execAsync(`launchctl kickstart ${guiDomain()}/${taskLabel(taskId)}`);
|
|
@@ -87,7 +87,7 @@ ${f.stack}`),m.unsubscribe(),c.reject(d)):(d=sx(y),d?(f&&(d.stack+=`
|
|
|
87
87
|
${f.stack}`),c.reject(d)):c.resolve(y))}});return m.requestSubject=n,this.protocol.publish(n,r,{reply:u,headers:s.headers}),c}else{const u=new ox(this.protocol.muxSubscriptions,n,s,l);this.protocol.request(u);try{this.publish(n,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:s.headers})}catch(f){u.cancel(f)}const c=Promise.race([u.timer,u.deferred]);return c.catch(()=>{u.cancel()}),c}}flush(){return this.isClosed()?Promise.reject(je.errorForCode(Ee.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(je.errorForCode(Ee.ConnectionClosed)):this.isDraining()?Promise.reject(je.errorForCode(Ee.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const n=this.protocol.getServer();return n?n.listen:""}status(){const n=new tn;return n.iterClosed.then(()=>{const r=this.listeners.indexOf(n);this.listeners.splice(r,1)}),this.listeners.push(n),n}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((r,s)=>r==="time"?new Date(Date.parse(s)):s)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(n={}){const r=new OE(this,n);if(n.checkAPI!==!1)try{await r.getAccountInfo()}catch(s){const l=s;throw l.code===Ee.NoResponders&&(l.code=Ee.JetStreamNotEnabled),l}return r}jetstream(n={}){return new Ud(this,n)}getServerVersion(){const n=this.info;return n?fs(n.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw je.errorForCode(Ee.Disconnect);const n=Date.now();return await this.flush(),Date.now()-n}get features(){return this.protocol.features}get services(){return this._services||(this._services=new LE(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(je.errorForCode(Ee.ConnectionClosed)):this.isDraining()?Promise.reject(je.errorForCode(Ee.ConnectionDraining)):this.protocol.reconnect()}}class LE{constructor(n){C(this,"nc");this.nc=n}add(n){try{return new $l(this.nc,n).start()}catch(r){return Promise.reject(r)}}client(n,r){return new mE(this.nc,n,r)}}class zE{constructor(n,r,s){C(this,"bucket");C(this,"sm");C(this,"prefixLen");this.bucket=n,this.prefixLen=r,this.sm=s}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(Lu)||"PUT"}get length(){const n=this.sm.header.get(yn.MessageSizeHdr)||"";return n!==""?parseInt(n,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class UE{constructor(n,r,s){C(this,"bucket");C(this,"key");C(this,"sm");this.bucket=n,this.key=r,this.sm=s}get value(){return this.sm.data}get created(){return new Date(Rd(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var n;return((n=this.sm.headers)==null?void 0:n.get(Lu))||"PUT"}get delta(){return this.sm.info.pending}get length(){var r;const n=((r=this.sm.headers)==null?void 0:r.get(yn.MessageSizeHdr))||"";return n!==""?parseInt(n,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class wx extends m2{constructor(r,s,l){super(r.nc,s,l);C(this,"js");C(this,"monitor");this.js=r,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(r){this.sub.info=r}get info(){return this.sub.info}_resetOrderedConsumer(r){if(this.info===null||this.sub.isClosed())return;const s=Zr(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,s);const u=this.info;u.config.name=Bi.next(),u.ordered_consumer_sequence.delivery_seq=0,u.flow_control.heartbeat_count=0,u.flow_control.fc_count=0,u.flow_control.consumer_restarts++,u.deliver=s,u.config.deliver_subject=s,u.config.deliver_policy=$t.StartSequence,u.config.opt_start_seq=r;const c={};c.stream_name=this.info.stream,c.config=u.config;const f=`${u.api.prefix}.CONSUMER.CREATE.${u.stream}`;this.js._request(f,c,{retries:-1}).then(m=>{const d=m,y=this.sub.info;y.last=d,this.info.config=d.config,this.info.name=d.name}).catch(m=>{const d=new je(`unable to recreate ordered consumer ${u.stream} at seq ${r}`,Ee.RequestError,m);this.sub.callback(d,{})})}_maybeSetupHbMonitoring(){var s,l;const r=((l=(s=this.info)==null?void 0:s.config)==null?void 0:l.idle_heartbeat)||0;r&&this._setupHbMonitoring(Rd(r))}_setupHbMonitoring(r,s=0){const l={cancelAfter:0,maxOut:2};s&&(l.cancelAfter=s);const u=this.sub,c=f=>{var y,g,x,w;const m=J_(409,`${nr.IdleHeartbeatMissed}: ${f}`,this.sub.subject);if(!((y=this.info)==null?void 0:y.ordered))this.sub.callback(null,m);else{if(!this.js.nc.protocol.connected)return!1;const E=((x=(g=this.info)==null?void 0:g.ordered_consumer_sequence)==null?void 0:x.stream_seq)||0;return this._resetOrderedConsumer(E+1),(w=this.monitor)==null||w.restart(),!1}return!u.noIterator};this.monitor=new Dd(r,c,l)}_checkHbOrderConsumer(r){const s=r.headers.get(yn.ConsumerStalledHdr);s!==""&&this.js.nc.publish(s);const l=parseInt(r.headers.get(yn.LastConsumerSeqHdr),10),u=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,l!==u.delivery_seq&&this._resetOrderedConsumer(u.stream_seq+1),!1}_checkOrderedConsumer(r){const s=this.info.ordered_consumer_sequence,l=r.info.streamSequence,u=r.info.deliverySequence;return u!=s.delivery_seq+1?(this._resetOrderedConsumer(s.stream_seq+1),!1):(s.delivery_seq=u,s.stream_seq=l,!0)}async destroy(){this.isClosed()||await this.drain();const r=this.sub.info,s=r.config.durable_name||r.name,l=`${r.api.prefix}.CONSUMER.DELETE.${r.stream}.${s}`;await r.api._request(l)}async consumerInfo(){const r=this.sub.info,s=r.config.durable_name||r.name,l=`${r.api.prefix}.CONSUMER.INFO.${r.stream}.${s}`,u=await r.api._request(l);return r.last=u,u}}class BE extends wx{constructor(n,r,s){super(n,r,s)}pull(n={batch:1}){const{stream:r,config:s,name:l}=this.sub.info,u=s.durable_name??l,c={};if(c.batch=n.batch||1,c.no_wait=n.no_wait||!1,(n.max_bytes??0)>0){const d=this.js.nc.features.get(at.JS_PULL_MAX_BYTES);if(!d.ok)throw new Error(`max_bytes is only supported on servers ${d.min} or better`);c.max_bytes=n.max_bytes}let f=0;n.expires&&n.expires>0&&(f=n.expires,c.expires=Lt(f));let m=0;if(n.idle_heartbeat&&n.idle_heartbeat>0&&(m=n.idle_heartbeat,c.idle_heartbeat=Lt(m)),m&&f===0)throw new Error("idle_heartbeat requires expires");if(m>f)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),f&&m&&(this.monitor?this.monitor._change(m,f):this._setupHbMonitoring(m,f));const d=this.info.api,y=`${d.prefix}.CONSUMER.MSG.NEXT.${r}.${u}`,g=this.sub.subject;d.nc.publish(y,d.jc.encode(c),{reply:g})}}}function PE(e,n){return e?HE(n):qE(n)}function qE(e){return(n,r)=>n?[n,null]:(n=sa(r),n?[n,null]:[null,Ul(r,e)])}function HE(e){return(n,r)=>{if(n)return[n,null];const s=sa(r);return s!==null?[Sx(s),null]:[null,Ul(r,e)]}}function Sx(e){if(e!==null)switch(e.code){case Ee.JetStream404NoMessages:case Ee.JetStream408RequestTimeout:return null;case Ee.JetStream409:return X_(e)?e:null;default:return e}return null}function IE(e){e&&e.ack()}function FE(e){const n=e.split(".");if(n.length===9&&n.splice(2,0,"_",""),n.length<11||n[0]!=="$JS"||n[1]!=="ACK")throw new Error("not js message");const r={};return r.domain=n[2]==="_"?"":n[2],r.account_hash=n[3],r.stream=n[4],r.consumer=n[5],r.deliveryCount=parseInt(n[6],10),r.redeliveryCount=r.deliveryCount,r.redelivered=r.deliveryCount>1,r.streamSequence=parseInt(n[7],10),r.deliverySequence=parseInt(n[8],10),r.timestampNanos=parseInt(n[9],10),r.pending=parseInt(n[10],10),r}class $E{constructor(n,r){C(this,"msg");C(this,"di");C(this,"didAck");C(this,"timeout");this.msg=n,this.didAck=!1,this.timeout=r}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=FE(this.reply)),this.di}get redelivered(){return this.info.deliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(n){this.didAck||(this.didAck=!this.isWIP(n),this.msg.respond(n))}isWIP(n){return n.length===4&&n[0]===yl[0]&&n[1]===yl[1]&&n[2]===yl[2]&&n[3]===yl[3]}async ackAck(n){var s;n=n||{},n.timeout=n.timeout||this.timeout;const r=zt();if(this.didAck)r.resolve(!1);else if(this.didAck=!0,this.msg.reply){const u=this.msg.publisher,c=!((s=u.options)!=null&&s.noAsyncTraces),f=new ox(u.muxSubscriptions,this.msg.reply,{timeout:n.timeout},c);u.request(f);try{u.publish(this.msg.reply,T0,{reply:`${u.muxSubscriptions.baseInbox}${f.token}`})}catch(m){f.cancel(m)}try{await Promise.race([f.timer,f.deferred]),r.resolve(!0)}catch(m){f.cancel(m),r.reject(m)}}else r.resolve(!1);return r}ack(){this.doAck(T0)}nak(n){let r=EE;n&&(r=ju().encode(`-NAK ${JSON.stringify({delay:Lt(n)})}`)),this.doAck(r)}working(){this.doAck(yl)}next(n,r={batch:1}){const s={};s.batch=r.batch||1,s.no_wait=r.no_wait||!1,r.expires&&r.expires>0&&(s.expires=Lt(r.expires));const l=dr().encode(s),u=da.concat(kE,AE,l),c=n?{reply:n}:void 0;this.msg.respond(u,c)}term(n=""){let r=CE;(n==null?void 0:n.length)>0&&(r=ju().encode(`+TERM ${n}`)),this.doAck(r)}json(){return this.msg.json()}string(){return this.msg.string()}}const YE="1.30.3",GE="nats.ws";class VE{constructor(){C(this,"version");C(this,"lang");C(this,"closeError");C(this,"connected");C(this,"done");C(this,"socket");C(this,"options");C(this,"socketClosed");C(this,"encrypted");C(this,"peeked");C(this,"yields");C(this,"signal");C(this,"closedNotification");this.version=YE,this.lang=GE,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=zt(),this.closedNotification=zt()}async connect(n,r){const s=zt();if(r.tls)return s.reject(new je("tls",Ee.InvalidOption)),s;this.options=r;const l=n.src;if(r.wsFactory){const{socket:u,encrypted:c}=await r.wsFactory(n.src,r);this.socket=u,this.encrypted=c}else this.encrypted=l.indexOf("wss://")===0,this.socket=new WebSocket(l);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=u=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(u.data)),this.peeked){this.signal.resolve();return}const c=da.concat(...this.yields),f=v2(c);if(f!==""){const m=aE.exec(f);if(!m){r.debug&&console.error("!!!",cu(c)),s.reject(new Error("unexpected response from server"));return}try{const d=JSON.parse(m[1]);iE(d,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),s.resolve()}catch(d){s.reject(d);return}}},this.socket.onclose=u=>{if(this.isDiscarded())return;this.socketClosed=!0;let c;this.done||(u.wasClean||(c=new Error(u.reason)),this._closed(c))},this.socket.onerror=u=>{if(this.isDiscarded())return;const c=u,f=new je(c.message,Ee.Unknown,new Error(c.error));s.reject(f)},s}disconnect(){this._closed(void 0,!0)}async _closed(n,r=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=n,!n)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await xa(100);this.done=!0;try{this.socket.close(n?1002:1e3,n?n.message:void 0)}catch{}r&&this.closedNotification.resolve(n)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const n=this.yields;this.yields=[];for(let r=0;r<n.length;r++)this.options.debug&&console.info(`> ${cu(n[r])}`),yield n[r];if(this.done)break;this.yields.length===0&&(n.length=0,this.yields=n,this.signal=zt())}}isEncrypted(){return this.connected&&this.encrypted}send(n){if(!this.isDiscarded())try{this.socket.send(n.buffer),this.options.debug&&console.info(`< ${cu(n)}`);return}catch(r){this.options.debug&&console.error(`!!! ${cu(n)}: ${r}`)}}close(n){return this._closed(n,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var n;this.done=!0;try{(n=this.socket)==null||n.close()}catch{}}}function JE(e,n){/^(.*:\/\/)(.*)/.test(e)||(typeof n=="boolean"?e=`${n===!0?"https":"http"}://${e}`:e=`https://${e}`);let s=new URL(e);const l=s.protocol.toLowerCase();l==="ws:"&&(n=!1),l==="wss:"&&(n=!0),l!=="https:"&&l!=="http"&&(e=e.replace(/^(.*:\/\/)(.*)/gm,"$2"),s=new URL(`http://${e}`));let u,c;const f=s.hostname,m=s.pathname,d=s.search||"";switch(l){case"http:":case"ws:":case"nats:":c=s.port||"80",u="ws:";break;case"https:":case"wss:":case"tls:":c=s.port||"443",u="wss:";break;default:c=s.port||n===!0?"443":"80",u=n===!0?"wss:":"ws:";break}return`${u}//${f}:${c}${m}${d}`}function _x(e={}){return p2({defaultPort:443,urlParseFn:JE,factory:()=>new VE}),Bd.connect(e)}/*! Capacitor: https://capacitorjs.com/ - MIT License */var ma;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(ma||(ma={}));class Ch extends Error{constructor(n,r,s){super(n),this.message=n,this.code=r,this.data=s}}const XE=e=>{var n,r;return e!=null&&e.androidBridge?"android":!((r=(n=e==null?void 0:e.webkit)===null||n===void 0?void 0:n.messageHandlers)===null||r===void 0)&&r.bridge?"ios":"web"},KE=e=>{const n=e.CapacitorCustomPlatform||null,r=e.Capacitor||{},s=r.Plugins=r.Plugins||{},l=()=>n!==null?n.name:XE(e),u=()=>l()!=="web",c=g=>{const x=d.get(g);return!!(x!=null&&x.platforms.has(l())||f(g))},f=g=>{var x;return(x=r.PluginHeaders)===null||x===void 0?void 0:x.find(w=>w.name===g)},m=g=>e.console.error(g),d=new Map,y=(g,x={})=>{const w=d.get(g);if(w)return console.warn(`Capacitor plugin "${g}" already registered. Cannot register plugins twice.`),w.proxy;const E=l(),M=f(g);let P;const z=async()=>(!P&&E in x?P=typeof x[E]=="function"?P=await x[E]():P=x[E]:n!==null&&!P&&"web"in x&&(P=typeof x.web=="function"?P=await x.web():P=x.web),P),I=(J,F)=>{var L,W;if(M){const Q=M==null?void 0:M.methods.find(oe=>F===oe.name);if(Q)return Q.rtype==="promise"?oe=>r.nativePromise(g,F.toString(),oe):(oe,ae)=>r.nativeCallback(g,F.toString(),oe,ae);if(J)return(L=J[F])===null||L===void 0?void 0:L.bind(J)}else{if(J)return(W=J[F])===null||W===void 0?void 0:W.bind(J);throw new Ch(`"${g}" plugin is not implemented on ${E}`,ma.Unimplemented)}},j=J=>{let F;const L=(...W)=>{const Q=z().then(oe=>{const ae=I(oe,J);if(ae){const G=ae(...W);return F=G==null?void 0:G.remove,G}else throw new Ch(`"${g}.${J}()" is not implemented on ${E}`,ma.Unimplemented)});return J==="addListener"&&(Q.remove=async()=>F()),Q};return L.toString=()=>`${J.toString()}() { [capacitor code] }`,Object.defineProperty(L,"name",{value:J,writable:!1,configurable:!1}),L},K=j("addListener"),B=j("removeListener"),R=(J,F)=>{const L=K({eventName:J},F),W=async()=>{const oe=await L;B({eventName:J,callbackId:oe},F)},Q=new Promise(oe=>L.then(()=>oe({remove:W})));return Q.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await W()},Q},Y=new Proxy({},{get(J,F){switch(F){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return M?R:K;case"removeListener":return B;default:return j(F)}}});return s[g]=Y,d.set(g,{name:g,proxy:Y,platforms:new Set([...Object.keys(x),...M?[E]:[]])}),Y};return r.convertFileSrc||(r.convertFileSrc=g=>g),r.getPlatform=l,r.handleError=m,r.isNativePlatform=u,r.isPluginAvailable=c,r.registerPlugin=y,r.Exception=Ch,r.DEBUG=!!r.DEBUG,r.isLoggingEnabled=!!r.isLoggingEnabled,r},QE=e=>e.Capacitor=KE(e),pr=QE(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),va=pr.registerPlugin;class Pd{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(n,r){let s=!1;this.listeners[n]||(this.listeners[n]=[],s=!0),this.listeners[n].push(r);const u=this.windowListeners[n];u&&!u.registered&&this.addWindowListener(u),s&&this.sendRetainedArgumentsForEvent(n);const c=async()=>this.removeListener(n,r);return Promise.resolve({remove:c})}async removeAllListeners(){this.listeners={};for(const n in this.windowListeners)this.removeWindowListener(this.windowListeners[n]);this.windowListeners={}}notifyListeners(n,r,s){const l=this.listeners[n];if(!l){if(s){let u=this.retainedEventArguments[n];u||(u=[]),u.push(r),this.retainedEventArguments[n]=u}return}l.forEach(u=>u(r))}hasListeners(n){var r;return!!(!((r=this.listeners[n])===null||r===void 0)&&r.length)}registerWindowListener(n,r){this.windowListeners[r]={registered:!1,windowEventName:n,pluginEventName:r,handler:s=>{this.notifyListeners(r,s)}}}unimplemented(n="not implemented"){return new pr.Exception(n,ma.Unimplemented)}unavailable(n="not available"){return new pr.Exception(n,ma.Unavailable)}async removeListener(n,r){const s=this.listeners[n];if(!s)return;const l=s.indexOf(r);this.listeners[n].splice(l,1),this.listeners[n].length||this.removeWindowListener(this.windowListeners[n])}addWindowListener(n){window.addEventListener(n.windowEventName,n.handler),n.registered=!0}removeWindowListener(n){n&&(window.removeEventListener(n.windowEventName,n.handler),n.registered=!1)}sendRetainedArgumentsForEvent(n){const r=this.retainedEventArguments[n];r&&(delete this.retainedEventArguments[n],r.forEach(s=>{this.notifyListeners(n,s)}))}}const N0=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),O0=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class ZE extends Pd{async getCookies(){const n=document.cookie,r={};return n.split(";").forEach(s=>{if(s.length<=0)return;let[l,u]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");l=O0(l).trim(),u=O0(u).trim(),r[l]=u}),r}async setCookie(n){try{const r=N0(n.key),s=N0(n.value),l=n.expires?`; expires=${n.expires.replace("expires=","")}`:"",u=(n.path||"/").replace("path=",""),c=n.url!=null&&n.url.length>0?`domain=${n.url}`:"";document.cookie=`${r}=${s||""}${l}; path=${u}; ${c};`}catch(r){return Promise.reject(r)}}async deleteCookie(n){try{document.cookie=`${n.key}=; Max-Age=0`}catch(r){return Promise.reject(r)}}async clearCookies(){try{const n=document.cookie.split(";")||[];for(const r of n)document.cookie=r.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(n){return Promise.reject(n)}}async clearAllCookies(){try{await this.clearCookies()}catch(n){return Promise.reject(n)}}}va("CapacitorCookies",{web:()=>new ZE});const WE=async e=>new Promise((n,r)=>{const s=new FileReader;s.onload=()=>{const l=s.result;n(l.indexOf(",")>=0?l.split(",")[1]:l)},s.onerror=l=>r(l),s.readAsDataURL(e)}),ek=(e={})=>{const n=Object.keys(e);return Object.keys(e).map(l=>l.toLocaleLowerCase()).reduce((l,u,c)=>(l[u]=e[n[c]],l),{})},tk=(e,n=!0)=>e?Object.entries(e).reduce((s,l)=>{const[u,c]=l;let f,m;return Array.isArray(c)?(m="",c.forEach(d=>{f=n?encodeURIComponent(d):d,m+=`${u}=${f}&`}),m.slice(0,-1)):(f=n?encodeURIComponent(c):c,m=`${u}=${f}`),`${s}&${m}`},"").substr(1):null,nk=(e,n={})=>{const r=Object.assign({method:e.method||"GET",headers:e.headers},n),l=ek(e.headers)["content-type"]||"";if(typeof e.data=="string")r.body=e.data;else if(l.includes("application/x-www-form-urlencoded")){const u=new URLSearchParams;for(const[c,f]of Object.entries(e.data||{}))u.set(c,f);r.body=u.toString()}else if(l.includes("multipart/form-data")||e.data instanceof FormData){const u=new FormData;if(e.data instanceof FormData)e.data.forEach((f,m)=>{u.append(m,f)});else for(const f of Object.keys(e.data))u.append(f,e.data[f]);r.body=u;const c=new Headers(r.headers);c.delete("content-type"),r.headers=c}else(l.includes("application/json")||typeof e.data=="object")&&(r.body=JSON.stringify(e.data));return r};class rk extends Pd{async request(n){const r=nk(n,n.webFetchExtra),s=tk(n.params,n.shouldEncodeUrlParams),l=s?`${n.url}?${s}`:n.url,u=await fetch(l,r),c=u.headers.get("content-type")||"";let{responseType:f="text"}=u.ok?n:{};c.includes("application/json")&&(f="json");let m,d;switch(f){case"arraybuffer":case"blob":d=await u.blob(),m=await WE(d);break;case"json":m=await u.json();break;case"document":case"text":default:m=await u.text()}const y={};return u.headers.forEach((g,x)=>{y[x]=g}),{data:m,headers:y,status:u.status,url:u.url}}async get(n){return this.request(Object.assign(Object.assign({},n),{method:"GET"}))}async post(n){return this.request(Object.assign(Object.assign({},n),{method:"POST"}))}async put(n){return this.request(Object.assign(Object.assign({},n),{method:"PUT"}))}async patch(n){return this.request(Object.assign(Object.assign({},n),{method:"PATCH"}))}async delete(n){return this.request(Object.assign(Object.assign({},n),{method:"DELETE"}))}}va("CapacitorHttp",{web:()=>new rk});var R0;(function(e){e.Dark="DARK",e.Light="LIGHT",e.Default="DEFAULT"})(R0||(R0={}));var M0;(function(e){e.StatusBar="StatusBar",e.NavigationBar="NavigationBar"})(M0||(M0={}));class ik extends Pd{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}}va("SystemBars",{web:()=>new ik});const zu=pr.isNativePlatform()?"https://app.palmier.me":"";async function Ex(e,n,r,s){const l=`${zu}${n}`;console.log(`[API] ${e} ${l}`);const c=await fetch(l,{method:e,headers:{"Content-Type":"application/json"},body:r!=null?JSON.stringify(r):void 0});if(!c.ok){const f=await c.text();let m;try{const d=JSON.parse(f);m=d.error??d.message??f}catch{m=f}throw console.error(`[API] ${e} ${n} failed:`,c.status,m),new Error(m||`Request failed with status ${c.status}`)}return console.log(`[API] ${e} ${n} ->`,c.status),c.json()}function sk(e,n,r){return Ex("POST",e,n)}function ak(e,n){return Ex("GET",e,void 0)}const kx=N.createContext({connected:!1,mode:"disconnected",nc:null,request(){return Promise.reject(new Error("No host connection"))},subscribeEvents(){return()=>{}},activeHost:null,unauthorized:!1}),lk=2e3,Ah=6e3;function ok({children:e}){const{getActiveHost:n}=ba(),r=n(),[s,l]=N.useState(null),[u,c]=N.useState(!1),f=N.useRef(null),[m,d]=N.useState(!1),[y,g]=N.useState(!1),x=N.useRef(ju()),w=N.useRef(new Set),E=N.useRef(0),M=r!=null&&!!r.directUrl,P=r?M?m?"direct":"disconnected":u?"nats":"disconnected":"disconnected",z=P!=="disconnected";N.useEffect(()=>{g(!1)},[r==null?void 0:r.hostId,r==null?void 0:r.clientToken]),N.useEffect(()=>{if(M){f.current&&(f.current.close().catch(()=>{}),f.current=null,l(null),c(!1));return}if(!r)return;let K=!1;async function B(){try{const R=await fetch(`${zu}/api/nats-credentials/${r.hostId}`);if(!R.ok){console.error("[NATS] Failed to fetch credentials");return}const Y=await R.json();if(!Y.natsWsUrl){console.warn("[NATS] No WebSocket URL configured");return}if(K)return;console.log("[NATS] Connecting to",Y.natsWsUrl);const J=await _x({servers:Y.natsWsUrl,authenticator:mx(Y.natsJwt,new TextEncoder().encode(Y.natsNkeySeed))});if(K){J.close().catch(()=>{});return}console.log("[NATS] Connected"),f.current=J,l(J),c(!0),J.closed().then(()=>{console.log("[NATS] Connection closed"),K||(l(null),c(!1),f.current=null)})}catch(R){console.error("[NATS] Connection failed:",R),K||c(!1)}}return B(),()=>{K=!0,f.current&&(f.current.close().catch(()=>{}),f.current=null,l(null),c(!1))}},[M,r]),N.useEffect(()=>{if(!r||!M){d(!1);return}const K=new AbortController;async function B(){var F;const Y=new AbortController,J=setTimeout(()=>Y.abort(),lk);K.signal.addEventListener("abort",()=>Y.abort());try{const L=await fetch(`${r.directUrl}/events`,{headers:{Authorization:`Bearer ${r.clientToken}`},signal:Y.signal});return clearTimeout(J),L.ok?((F=L.body)==null?void 0:F.getReader())??null:null}catch{return clearTimeout(J),null}}async function R(Y){d(!0),console.log("[HOST] SSE connected to",r.directUrl),E.current=Date.now();function J(){setTimeout(()=>{K.signal.aborted||Date.now()-E.current<Ah||(console.log("[HOST] Heartbeat timeout — no data for",Ah/1e3,"s"),K.abort(),d(!1),console.log("[HOST] Direct host unreachable"))},Ah)}J();const F=new TextDecoder;let L="";try{for(;;){const{done:W,value:Q}=await Y.read();if(W)break;L+=F.decode(Q,{stream:!0}),E.current=Date.now(),J();const oe=L.split(`
|
|
88
88
|
`);L=oe.pop()??"";for(const ae of oe)if(ae.startsWith("data: ")){const G=ae.slice(6);try{const H=JSON.parse(G);if(H.task_id&&H.event_type){const X=`host-event.${r.hostId}.${H.task_id}`;for(const ue of w.current)ue({subject:X,data:x.current.encode(G)})}}catch{}}}}catch{}}return(async()=>{const Y=await B();Y&&await R(Y)})(),()=>{K.abort(),d(!1)}},[r,M]);const I=N.useCallback(async(K,B,R)=>{if(!r)throw new Error("No active host");function Y(oe){oe&&typeof oe=="object"&&oe.error==="Unauthorized"&&g(!0)}if(M){console.log(`[HOST/HTTP] → ${K}`,B??"");const oe=await fetch(`${r.directUrl}/rpc/${K}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.clientToken}`},body:B!=null?JSON.stringify(B):void 0,signal:R!=null&&R.timeout?AbortSignal.timeout(R.timeout):void 0});if(oe.status===401)throw g(!0),new Error("Unauthorized");const ae=await oe.json();return Y(ae),console.log(`[HOST/HTTP] ← ${K}`,ae),ae}if(!f.current)throw new Error("Not connected");const J=`host.${r.hostId}.rpc.${K}`,F={...B??{},clientToken:r.clientToken},L=x.current.encode(JSON.stringify(F));console.log(`[HOST/NATS] → ${K}`,B??"");const W=await f.current.request(J,L,{timeout:(R==null?void 0:R.timeout)??1e4}),Q=JSON.parse(x.current.decode(W.data));return Y(Q),console.log(`[HOST/NATS] ← ${K}`,Q),Q},[r,M]),j=N.useCallback((K,B)=>{if(M)return w.current.add(B),()=>{w.current.delete(B)};if(f.current){const R=f.current.subscribe(`host-event.${K}.>`);let Y=!1;return(async()=>{try{for await(const J of R){if(Y)break;B({subject:J.subject,data:J.data})}}catch{}})(),()=>{Y=!0,R.unsubscribe()}}return()=>{}},[r,M]);return b.jsx(kx.Provider,{value:{connected:z,mode:P,nc:s,request:I,subscribeEvents:j,activeHost:r,unauthorized:y},children:e})}function Yl(){return N.useContext(kx)}const Ut=pr.isNativePlatform()?va("Device"):null;function Uu(e){const n=new Date(e),r=new Date,s=n.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return n.toDateString()===r.toDateString()?s:`${n.toLocaleDateString(void 0,{month:"short",day:"numeric"})} ${s}`}const Cx={};function uk(e){for(const n of e)Cx[n.key]=n.label}function hd(e){return Cx[e]??e}const ck=()=>window.matchMedia("(max-width: 600px)").matches;function fk({task:e,lastEvent:n,onEdit:r,onDelete:s,onViewRun:l}){var oe;const{request:u}=Yl(),[c,f]=N.useState(!1),[m,d]=N.useState(!1),[y,g]=N.useState(!1),x=N.useRef(null),w=(n==null?void 0:n.running_state)==="started",E=(((oe=e.schedule_values)==null?void 0:oe.length)??0)>0,M=e.schedule_type==="on_new_notification"||e.schedule_type==="on_new_sms",z=!!e.schedule_enabled&&!!e.schedule_type&&(E||M)?w?"var(--color-success)":(n==null?void 0:n.running_state)==="failed"?"var(--color-error)":"var(--color-success)":"var(--color-text-secondary)";N.useEffect(()=>{if(!m)return;function ae(G){x.current&&!x.current.contains(G.target)&&d(!1)}return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[m]);function I(){ck()?g(!0):d(ae=>!ae)}function j(){d(!1),g(!1)}async function K(){if(j(),!!confirm("Abort this task?")){f(!0);try{await u("task.abort",{id:e.id})}catch(ae){console.error("Abort failed:",ae)}finally{f(!1)}}}async function B(){j();try{const ae=await u("task.run",{id:e.id});l(e.id,ae.run_id)}catch(ae){console.error("Run failed:",ae)}}async function R(){if(j(),!!confirm("Delete this task? Results and reports will be kept."))try{await u("task.delete",{id:e.id}),s(e.id)}catch(ae){console.error("Delete failed:",ae)}}const Y={started:"Started",finished:"Finished",aborted:"Aborted",failed:"Failed"};function J(ae,G){if(ae==="specific_times"){const ve=new Date(G);return{kind:"specific_times",detail:isNaN(ve.getTime())?G:`${ve.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})} at ${ve.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}`}}const H=G.split(" ");if(H.length!==5)return{kind:"unknown",detail:G};const[X,ue,_e,,_]=H,D=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];if(ue==="*")return{kind:"hourly",detail:""};const ee=new Date;ee.setHours(Number(ue),Number(X),0,0);const A=ee.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return _!=="*"?{kind:"weekly",detail:`${D[Number(_)]??_} at ${A}`}:_e!=="*"?{kind:"monthly",detail:`day ${_e} at ${A}`}:{kind:"daily",detail:A}}function F(ae,G){const H=J(ae,G);return H.kind==="hourly"?"Every hour":H.kind==="specific_times"?`Once on ${H.detail}`:`${H.kind.charAt(0).toUpperCase()+H.kind.slice(1)}: ${H.detail}`}function L(ae,G){if(!ae)return"";if(ae==="on_new_notification")return"On new notification";if(ae==="on_new_sms")return"On new SMS";if(!G||G.length===0)return"";if(G.length===1)return F(ae,G[0]);const H=G.map(ue=>J(ae,ue));if(new Set(H.map(ue=>ue.kind)).size===1){const ue=H[0].kind;if(ue==="hourly")return"Every hour";const _e=H.map(_=>_.detail);return`${ue.charAt(0).toUpperCase()+ue.slice(1)}: ${_e.join(", ")}`}return G.map(ue=>F(ae,ue)).join(", ")}const W=L(e.schedule_type,e.schedule_values),Q=b.jsxs(b.Fragment,{children:[b.jsxs("button",{onClick:()=>{j(),r(e)},children:[b.jsx("span",{className:"menu-icon",children:"✎"}),"Edit"]}),b.jsxs("button",{onClick:()=>{j(),l(e.id)},children:[b.jsx("span",{className:"menu-icon",children:"📄"}),"View All Runs"]}),w?b.jsxs("button",{className:"menu-item-danger",onClick:K,disabled:c,children:[b.jsx("span",{className:"menu-icon",children:"◼"}),"Abort"]}):b.jsxs(b.Fragment,{children:[b.jsxs("button",{onClick:B,children:[b.jsx("span",{className:"menu-icon",children:"▶"}),"Run Now"]}),b.jsxs("button",{className:"menu-item-danger",onClick:R,children:[b.jsx("span",{className:"menu-icon",children:"🗑"}),"Delete"]})]})]});return b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"task-card",onClick:()=>l(e.id,"latest"),children:[b.jsxs("div",{className:"task-card-header",children:[b.jsxs("div",{className:"task-card-title-row",children:[w?b.jsx("span",{className:"status-spinner",children:b.jsx("span",{})}):b.jsx("span",{className:"status-dot",style:{backgroundColor:z}}),b.jsx("h3",{className:"task-card-name",children:e.name||e.user_prompt})]}),b.jsx("div",{className:"task-card-actions",onClick:ae=>ae.stopPropagation(),children:b.jsxs("div",{className:"task-card-menu",ref:x,children:[b.jsx("button",{className:"task-card-menu-btn",onClick:I,"aria-label":"Task actions",children:"⋮"}),m&&b.jsx("div",{className:"task-card-menu-dropdown",children:Q})]})})]}),b.jsxs("div",{className:"task-card-meta",children:[e.agent&&b.jsx("span",{className:"task-card-agent",children:hd(e.agent)}),n&&Y[n.running_state]&&b.jsxs("span",{className:"task-card-last-event",children:[Y[n.running_state]," ",Uu(n.time_stamp)]}),e.schedule_type&&(E||M)&&b.jsx("span",{className:"task-card-triggers",children:e.schedule_enabled?W:"Schedule disabled"})]})]}),y&&ca.createPortal(b.jsx("div",{className:"bottom-sheet-overlay",onClick:()=>g(!1),children:b.jsxs("div",{className:"bottom-sheet",onClick:ae=>ae.stopPropagation(),children:[b.jsx("div",{className:"bottom-sheet-handle"}),b.jsx("div",{className:"bottom-sheet-title",children:e.name||e.user_prompt}),b.jsx("div",{className:"bottom-sheet-actions",children:Q})]})}),document.body)]})}function hk({permissions:e}){return b.jsxs("div",{className:"plan-dialog",children:[b.jsx("h2",{children:"Granted Permissions"}),b.jsx("div",{className:"plan-dialog-scroll",children:e&&e.length>0?b.jsx("div",{className:"permissions-section",children:b.jsx("ul",{className:"permissions-list",children:e.map((n,r)=>b.jsxs("li",{className:"permission-item",children:[b.jsx("span",{className:"permission-tool",children:n.name}),b.jsx("span",{className:"permission-desc",children:n.description})]},r))})}):b.jsx("p",{className:"plan-empty",children:"No permissions have been granted for this task."})}),b.jsx("div",{className:"plan-dialog-actions",children:b.jsx("button",{className:"btn btn-secondary",onClick:()=>history.back(),children:"Back"})})]})}const Ws=[];function dk(){const e=Ws.pop();e&&(e.pushed.current=!1,e.close())}let D0=!1;function mk(){D0||(D0=!0,window.addEventListener("popstate",dk))}function L0(e,n){const r=N.useRef(!1),s=N.useRef(n);s.current=n;const l=N.useCallback(()=>s.current(),[]),u=N.useRef({close:l,pushed:r});u.current.close=l,N.useEffect(()=>{if(e&&!r.current)mk(),history.pushState({modal:!0},""),Ws.push(u.current),r.current=!0;else if(!e&&r.current){r.current=!1;const c=Ws.indexOf(u.current);c!==-1&&Ws.splice(c,1),history.back()}},[e,l]),N.useEffect(()=>{const c=u.current;return()=>{if(r.current){r.current=!1;const f=Ws.indexOf(c);f!==-1&&Ws.splice(f,1),history.back()}}},[])}const pk=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],gk=["specific_times","hourly","daily","weekly","monthly"];function mu(e){return gk.includes(e)}function yk(e){return e==="on_new_notification"||e==="on_new_sms"}function Qr(e="daily"){return{schedule:e,time:"00:00",dayOfWeek:"1",dayOfMonth:"1",onceDate:"",onceTime:"00:00"}}function bk(e){const n=e.split(" ");if(n.length!==5)return Qr();const[r,s,l,,u]=n;if(s==="*")return Qr("hourly");const c=`${s.padStart(2,"0")}:${r.padStart(2,"0")}`;return u!=="*"?{...Qr("weekly"),time:c,dayOfWeek:u}:l!=="*"?{...Qr("monthly"),time:c,dayOfMonth:l}:{...Qr("daily"),time:c}}function Ax(e,n){if(e==="specific_times"){const[r,s]=n.split("T");return{...Qr("specific_times"),onceDate:r??"",onceTime:(s??"09:00").slice(0,5)}}return bk(n)}function xk(e){const[n,r]=e.time.split(":").map(Number);switch(e.schedule){case"hourly":return"0 * * * *";case"daily":return`${r} ${n} * * *`;case"weekly":return`${r} ${n} * * ${e.dayOfWeek}`;case"monthly":return`${r} ${n} ${e.dayOfMonth} * *`;default:return"0 * * * *"}}function vk(e){return e.schedule==="specific_times"?e.onceDate?`${e.onceDate}T${e.onceTime}`:null:xk(e)}function Th(e){return e==="specific_times"?"specific_times":e==="on_new_notification"?"on_new_notification":e==="on_new_sms"?"on_new_sms":"crons"}function jh(e){var s;if(!e)return"daily";if(e.command)return"command";const n=e.schedule_type;if(n==="on_new_notification"||n==="on_new_sms")return n;if(n!=="crons"&&n!=="specific_times")return"ondemand";const r=(s=e.schedule_values)==null?void 0:s[0];return r?Ax(n,r).schedule:"ondemand"}function wk({initial:e,agents:n,hostPlatform:r,isNotificationListener:s,onSaved:l,onRun:u,onCancel:c}){var Yt;const{request:f}=Yl(),m=()=>{var Se;const ge=localStorage.getItem("palmier:lastAgent"),ze=n.map(ft=>ft.key);return ge&&ze.includes(ge)?ge:((Se=n[0])==null?void 0:Se.key)??""},[d,y]=N.useState((e==null?void 0:e.user_prompt)??""),[g,x]=N.useState((e==null?void 0:e.agent)??m()),w=!!((Yt=e==null?void 0:e.permissions)!=null&&Yt.length),[E,M]=N.useState(!1),P=N.useCallback(()=>M(!1),[]);L0(E,P);const[z,I]=N.useState(null),[j,K]=N.useState(()=>jh(e)),[B,R]=N.useState(()=>{const ge=e==null?void 0:e.schedule_type,ze=e==null?void 0:e.schedule_values;if(ze&&(ge==="crons"||ge==="specific_times"))return ze.map(ft=>Ax(ge,ft));const Se=jh(e);return mu(Se)?[Qr(Se)]:[]}),[Y,J]=N.useState((e==null?void 0:e.requires_confirmation)??!1),[F,L]=N.useState((e==null?void 0:e.schedule_enabled)??!0),[W,Q]=N.useState((e==null?void 0:e.yolo_mode)??!1),[oe,ae]=N.useState((e==null?void 0:e.foreground_mode)??!1),[G,H]=N.useState((e==null?void 0:e.command)??""),[X,ue]=N.useState(!1),_e=(e==null?void 0:e.schedule_type)==="on_new_notification"&&e.schedule_values&&e.schedule_values.length>0?e.schedule_values[0]:"",[_,D]=N.useState(_e),[ee,A]=N.useState([]),[ve,Ae]=N.useState(!1),[Te,Me]=N.useState(!1),[He,be]=N.useState(""),De=N.useCallback(()=>Me(!1),[]);L0(Te,De),N.useEffect(()=>{if(j!=="on_new_notification"||!s||!pr.isNativePlatform()||!Ut)return;let ge=!1;return Ae(!0),Ut.getInstalledApps().then(({apps:ze})=>{if(ge)return;const Se="com.palmier.app",ft=ze.filter(pt=>pt.packageName!==Se).sort((pt,Tn)=>(pt.appName||pt.packageName).localeCompare(Tn.appName||Tn.packageName));A(ft)}).catch(()=>{}).finally(()=>{ge||Ae(!1)}),()=>{ge=!0}},[j,s]);const Ze=(e==null?void 0:e.schedule_type)==="on_new_sms"&&e.schedule_values&&e.schedule_values.length>0?e.schedule_values[0]:"",[dt,lt]=N.useState(Ze),ct=N.useRef(null),Fe=mu(j),Ue=j==="command",tt=yk(j),mt=n.find(ge=>ge.key===g),st=!!(mt!=null&&mt.supportsYolo);N.useEffect(()=>{!st&&W&&Q(!1)},[st,W]);const Mt=!!e,yt=jh(e),$n=!Mt||d!==((e==null?void 0:e.user_prompt)??"")||g!==((e==null?void 0:e.agent)??"")||j!==yt||Y!==((e==null?void 0:e.requires_confirmation)??!1)||F!==((e==null?void 0:e.schedule_enabled)??!0)||W!==((e==null?void 0:e.yolo_mode)??!1)||oe!==((e==null?void 0:e.foreground_mode)??!1)||Ue&&G!==((e==null?void 0:e.command)??"")||Fe&&(JSON.stringify($e())!==JSON.stringify((e==null?void 0:e.schedule_values)??[])||Th(j)!==((e==null?void 0:e.schedule_type)??void 0))||tt&&j!==(e==null?void 0:e.schedule_type)||j==="on_new_notification"&&_.trim()!==_e.trim()||j==="on_new_sms"&&dt.trim()!==Ze.trim(),gr=Fe&&B.some(ge=>ge.schedule==="specific_times"&&(!ge.onceDate||new Date(`${ge.onceDate}T${ge.onceTime}`)<=new Date)),vt=$n&&!!d.trim()&&!gr&&(!Ue||!!G.trim())&&(!Fe||B.length>0);function An(ge,ze){R(Se=>Se.map((ft,pt)=>pt===ge?{...ft,...ze}:ft))}function fe(ge){R(ze=>ze.filter((Se,ft)=>ft!==ge))}function we(){mu(j)&&R(ge=>[...ge,ge.length>0?{...ge[ge.length-1]}:Qr(j)])}function Be(ge){K(ge),mu(ge)?R([Qr(ge)]):(R([]),J(!1)),ge==="command"?setTimeout(()=>{var ze;return(ze=ct.current)==null?void 0:ze.focus()},0):H(""),ge!=="on_new_notification"&&D(_e),ge!=="on_new_sms"&<(Ze)}function $e(){return B.flatMap(ge=>{const ze=vk(ge);return ze?[ze]:[]})}function rt(){return W?confirm(`Yolo mode is enabled. The agent will auto-approve all tool calls — it can read, write, delete files, run arbitrary commands, and access the network without asking for permission.
|
|
89
89
|
|
|
90
|
-
Are you sure you want to continue?`):!0}async function nn(){ue(!0),I(null);try{const ge=Fe?$e():j==="on_new_notification"&&_.trim()?[_.trim()]:j==="on_new_sms"&&dt.trim()?[dt.trim()]:[],ze=Fe||tt?Th(j):null,Se={user_prompt:d,agent:g,schedule_type:ze,schedule_values:ge.length>0?ge:null,schedule_enabled:j!=="ondemand"&&F,requires_confirmation:Fe?Y:!1,yolo_mode:W,foreground_mode:oe,command:Ue?G:""};Mt&&(Se.id=e.id);const pt=await f(Mt?"task.update":"task.create",Se,{timeout:45e3});if(pt.error){I(pt.error);return}if(Mt||localStorage.setItem("palmier:lastAgent",g),Ue&&!Mt){l(pt);try{const Tn=await f("task.run",{id:pt.id});Tn.run_id?u(pt.id,Tn.run_id):Tn.error||u(pt.id)}catch{}return}l(pt)}catch(ge){I(ge instanceof Error?ge.message:String(ge))}finally{ue(!1)}}const bn=Mt?"Save":Ue?"Run":(Fe||tt)&&F?"Schedule":"Save";return b.jsxs("div",{className:"task-form-overlay",children:[b.jsx("div",{className:"task-form",children:E?b.jsx(hk,{permissions:e==null?void 0:e.permissions}):b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"task-form-header",children:b.jsx("h2",{children:e?"Edit Task":"New Task"})}),z&&b.jsx("div",{className:"form-error",children:z}),b.jsx("textarea",{autoFocus:!e,className:"form-textarea",value:d,onChange:ge=>y(ge.target.value),placeholder:Ue?"If the input email contains an event, create a calendar entry for it.":"Research today's top AI news and write a summary.",rows:4,disabled:X}),b.jsxs("div",{className:"plan-actions",children:[b.jsxs("div",{className:"agent-picker-section-inline",children:[b.jsx("span",{className:"agent-picker-label",children:"Run with"}),b.jsx("select",{className:"form-select form-select-sm",value:g,onChange:ge=>x(ge.target.value),disabled:X,children:n.map(ge=>b.jsx("option",{value:ge.key,children:ge.label},ge.key))})]}),st&&b.jsxs("label",{className:"yolo-inline",style:{marginLeft:"auto"},children:[b.jsx("input",{type:"checkbox",checked:W,onChange:ge=>Q(ge.target.checked),disabled:X}),"Yolo"]}),st&&W&&b.jsx("p",{className:"yolo-warning",children:"The agent will auto-approve all tool calls without asking for permission."}),w&&b.jsx("div",{className:"granted-permissions-row",children:b.jsx("button",{className:"btn btn-link",onClick:()=>M(!0),children:"Granted Permissions"})})]}),b.jsx("div",{className:"toggles-group",children:b.jsxs("div",{className:"schedule-section",children:[b.jsx("h3",{className:"schedule-section-title",children:"Schedule"}),b.jsxs("select",{className:"form-select",value:j,onChange:ge=>Be(ge.target.value),disabled:X,children:[b.jsx("option",{value:"ondemand",children:"On Demand"}),b.jsx("option",{value:"specific_times",children:"Specific Times"}),b.jsx("option",{value:"hourly",children:"Hourly"}),b.jsx("option",{value:"daily",children:"Daily"}),b.jsx("option",{value:"weekly",children:"Weekly"}),b.jsx("option",{value:"monthly",children:"Monthly"}),b.jsx("option",{value:"on_new_notification",children:"On New Notification"}),b.jsx("option",{value:"on_new_sms",children:"On New SMS"}),b.jsx("option",{value:"command",children:"Command-triggered"})]}),tt&&b.jsxs("div",{className:"schedule-reactive",children:[b.jsxs("p",{className:"command-help-text",children:[j==="on_new_notification"?"Runs each time a new push notification arrives on the paired Android device.":"Runs each time a new SMS arrives on the paired Android device."," ","The triggering payload is spliced into your task prompt — reference it as “the new ",j==="on_new_notification"?"notification":"SMS","”."]}),j==="on_new_notification"&&(()=>{const ge=ee.find(Se=>Se.packageName===_),ze=(ge==null?void 0:ge.appName)||_;return b.jsxs(b.Fragment,{children:[s?_.trim()?b.jsxs("div",{className:"app-filter-selected",children:[b.jsx("span",{className:"app-filter-selected-name",children:ze}),(ge==null?void 0:ge.appName)&&b.jsx("span",{className:"app-filter-selected-pkg",children:ge.packageName}),b.jsx("button",{type:"button",className:"app-filter-selected-clear",onClick:()=>D(""),"aria-label":"Clear app filter",disabled:X,children:"✕"})]}):b.jsx("button",{type:"button",className:"btn btn-link app-filter-trigger",onClick:()=>{be(""),Me(!0)},disabled:X,children:"Select app"}):b.jsx("input",{className:"form-input",type:"text",value:_,onChange:Se=>D(Se.target.value),placeholder:"App (optional), e.g. com.google.android.gm",disabled:X}),b.jsx("p",{className:"command-help-text app-filter-help",children:_.trim()?`Only notifications from ${ze} will trigger this task.`:"Every notification from your device triggers this task."})]})})(),j==="on_new_sms"&&b.jsxs(b.Fragment,{children:[b.jsx("input",{className:"form-input",type:"text",value:dt,onChange:ge=>lt(ge.target.value),placeholder:"From (optional), e.g. +1 555-1234)",disabled:X}),b.jsx("p",{className:"command-help-text app-filter-help",children:dt.trim()?`Only SMS from ${dt.trim()} will trigger this task. Formatting (spaces, dashes, parens) is ignored.`:"Every SMS that arrives on your device triggers this task."})]})]}),Ue&&b.jsxs("div",{className:"schedule-reactive",children:[b.jsx("p",{className:"command-help-text",children:"Runs a command and invokes the task for each line of output. Use “the input” in your task description to reference each line."}),b.jsx("input",{ref:ct,className:"form-input form-input-mono",type:"text",value:G,onChange:ge=>H(ge.target.value),placeholder:"gws gmail +watch --project my-project",disabled:X})]}),Fe&&j!=="hourly"&&b.jsxs(b.Fragment,{children:[B.map((ge,ze)=>b.jsxs("div",{className:"trigger-row-card",children:[b.jsxs("div",{className:"trigger-row-content",children:[j==="daily"&&b.jsx("input",{className:"form-input",type:"time",value:ge.time,onChange:Se=>An(ze,{time:Se.target.value})}),j==="weekly"&&b.jsxs("div",{className:"trigger-row-top",children:[b.jsx("select",{className:"form-select",value:ge.dayOfWeek,onChange:Se=>An(ze,{dayOfWeek:Se.target.value}),children:pk.map((Se,ft)=>b.jsx("option",{value:String(ft),children:Se},ft))}),b.jsx("input",{className:"form-input",type:"time",value:ge.time,onChange:Se=>An(ze,{time:Se.target.value})})]}),j==="monthly"&&b.jsxs("div",{className:"trigger-row-top",children:[b.jsx("select",{className:"form-select",value:ge.dayOfMonth,onChange:Se=>An(ze,{dayOfMonth:Se.target.value}),children:Array.from({length:28},(Se,ft)=>ft+1).map(Se=>b.jsxs("option",{value:String(Se),children:["Day ",Se]},Se))}),b.jsx("input",{className:"form-input",type:"time",value:ge.time,onChange:Se=>An(ze,{time:Se.target.value})})]}),j==="specific_times"&&b.jsxs("div",{className:"trigger-row-top",children:[b.jsx("input",{className:"form-input",type:"date",value:ge.onceDate,min:new Date().toISOString().split("T")[0],onChange:Se=>An(ze,{onceDate:Se.target.value})}),b.jsx("input",{className:"form-input",type:"time",value:ge.onceTime,min:ge.onceDate===new Date().toISOString().split("T")[0]?new Date().toTimeString().slice(0,5):void 0,onChange:Se=>An(ze,{onceTime:Se.target.value})})]})]}),B.length>1&&b.jsx("button",{className:"trigger-remove-btn",onClick:()=>fe(ze),title:"Remove trigger",children:"×"})]},ze)),b.jsx("button",{className:"trigger-add-btn",onClick:we,children:"+ Add"})]}),r==="win32"&&b.jsxs("label",{className:"toggle-label",children:[b.jsx("input",{type:"checkbox",checked:oe,onChange:ge=>ae(ge.target.checked),disabled:X}),"Run in the foreground (host must login to Windows)"]}),Fe&&b.jsxs("label",{className:"toggle-label",children:[b.jsx("input",{type:"checkbox",checked:Y,onChange:ge=>J(ge.target.checked),disabled:X}),"Confirm before each run"]}),j!=="ondemand"&&b.jsxs("label",{className:"toggle-label",children:[b.jsx("input",{type:"checkbox",checked:F,onChange:ge=>L(ge.target.checked),disabled:X}),"Enabled"]})]})}),!W&&mt&&!mt.supportsPermissions&&b.jsxs("div",{className:"form-warning",children:["Palmier does not support runtime permission granting for ",mt.label,". The task may fail if required permissions are not pre-configured."]}),b.jsxs("div",{className:"form-actions",children:[b.jsxs("button",{className:"btn btn-primary",onClick:()=>rt()&&nn(),disabled:!vt||X,children:[X&&b.jsx("span",{className:"btn-spinner"}),bn]}),b.jsx("button",{className:"btn btn-secondary",onClick:()=>{$n&&d.trim()&&!confirm("You have unsaved changes. Discard?")||c()},style:{marginLeft:"auto"},children:"Cancel"})]})]})}),Te&&(()=>{const ge=He.trim().toLowerCase(),ze=ge?ee.filter(Se=>Se.packageName.toLowerCase().includes(ge)||Se.appName.toLowerCase().includes(ge)):ee;return b.jsx("div",{className:"app-filter-overlay",onClick:De,children:b.jsxs("div",{className:"app-filter-dialog",onClick:Se=>Se.stopPropagation(),children:[b.jsxs("div",{className:"app-filter-header",children:[b.jsx("h2",{children:"Select app"}),b.jsx("button",{className:"app-filter-close",onClick:De,"aria-label":"Close",children:b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:b.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),b.jsx("input",{className:"form-input app-filter-search",type:"text",value:He,onChange:Se=>be(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&He.trim()&&(D(He.trim()),De())},placeholder:"Search or type a package name",autoFocus:!0}),b.jsxs("ul",{className:"app-filter-list",children:[ve&&ee.length===0?Array.from({length:6}).map((Se,ft)=>b.jsx("li",{className:"app-filter-row app-filter-skeleton",children:b.jsx("div",{className:"app-filter-skeleton-bar"})},`sk-${ft}`)):ze.length===0&&!He.trim()?b.jsx("li",{className:"app-filter-empty",children:"No apps"}):ze.map(Se=>b.jsx("li",{className:"app-filter-row",onClick:()=>{D(Se.packageName),De()},children:b.jsxs("div",{className:"app-filter-row-labels",children:[b.jsx("div",{className:"app-filter-row-name",children:Se.appName||Se.packageName}),Se.appName&&b.jsx("div",{className:"app-filter-row-pkg",children:Se.packageName})]})},Se.packageName)),He.trim()&&b.jsx("li",{className:"app-filter-row",onClick:()=>{D(He.trim()),De()},children:b.jsx("div",{className:"app-filter-row-labels",children:b.jsx("div",{className:"app-filter-row-name",children:He.trim()})})})]})]})})})()]})}function Tx({pullDistance:e,refreshing:n,threshold:r}){const s=e>0||n,l=e>=r;return b.jsx("div",{className:"pull-to-refresh",style:{transform:`translateY(${e}px)`,opacity:s?Math.min(1,e/30):0},"aria-hidden":!s,children:b.jsx("div",{className:"pull-to-refresh-badge",children:n?b.jsx("div",{className:"spinner"}):b.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s"},children:[b.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b.jsx("polyline",{points:"19 12 12 19 5 12"})]})})})}function jx({onRefresh:e,threshold:n=70,maxPull:r=110,enabled:s=!0}){const[l,u]=N.useState(0),[c,f]=N.useState(!1),m=N.useRef(null),d=N.useRef(!1),y=N.useRef(0),g=N.useRef(!1),x=N.useRef(e);return N.useEffect(()=>{x.current=e}),N.useEffect(()=>{if(!s)return;const w=P=>{if(g.current||window.scrollY>0){m.current=null;return}m.current=P.touches[0].clientY,d.current=!1,y.current=0},E=P=>{if(g.current||m.current==null)return;const z=P.touches[0].clientY-m.current;if(z<=0){d.current=!1,y.current=0,u(0);return}d.current=!0;const I=Math.min(r,z*.5);y.current=I,u(I),P.cancelable&&P.preventDefault()},M=()=>{if(!d.current){m.current=null,u(0);return}const P=y.current;m.current=null,d.current=!1,y.current=0,P>=n?(g.current=!0,f(!0),u(n),Promise.resolve(x.current()).catch(()=>{}).finally(()=>{g.current=!1,f(!1),u(0)})):u(0)};return window.addEventListener("touchstart",w,{passive:!0}),window.addEventListener("touchmove",E,{passive:!1}),window.addEventListener("touchend",M,{passive:!0}),window.addEventListener("touchcancel",M,{passive:!0}),()=>{window.removeEventListener("touchstart",w),window.removeEventListener("touchmove",E),window.removeEventListener("touchend",M),window.removeEventListener("touchcancel",M)}},[s,n,r]),{pullDistance:l,refreshing:c,threshold:n}}function Sk({connected:e,hostId:n,request:r,subscribeEvents:s,agents:l,hostPlatform:u,isNotificationListener:c,onViewRun:f}){const[m,d]=N.useState([]),[y,g]=N.useState(!1),[x,w]=N.useState(null),[E,M]=N.useState(new Map),[P,z]=N.useState(!1),[I,j]=N.useState(void 0),K=N.useCallback(()=>{z(!1),j(void 0)},[]),B=N.useCallback(async()=>{if(e){g(!0),w(null);try{const L=(await r("task.list")).tasks??[],W=new Map;for(const Q of L)Q.status&&W.set(Q.id,Q.status);M(W),d(L)}catch(F){const L=F instanceof Error?F.message:String(F);L==="Not connected"||L.includes("503")||L.toLowerCase().includes("no responders")?w(null):w(L),d([])}finally{g(!1)}}},[e,n,r]);N.useEffect(()=>{e?B():(d([]),g(!1))},[e,n,B]);const R=jx({onRefresh:B,enabled:e});N.useEffect(()=>!e||!n?void 0:s(n,async L=>{const W=L.subject.split(".");if(W.length<3)return;const Q=W.slice(2).join(".");let oe={};try{oe=JSON.parse(new TextDecoder().decode(L.data))}catch{return}const ae=oe.event_type;if(!(ae!=="running-state"&&ae!=="permission-resolved"))try{const G=await r("task.status",{id:Q},{timeout:5e3});if(G.error)return;M(H=>{const X=new Map(H);return X.set(Q,G),X})}catch{}}),[e,n,s,r]);function Y(F){d(L=>{const W=L.findIndex(Q=>Q.id===F.id);if(W>=0){const Q=[...L];return Q[W]=F,Q}return[F,...L]}),z(!1),j(void 0)}function J(F){d(L=>L.filter(W=>W.id!==F)),M(L=>{const W=new Map(L);return W.delete(F),W})}return b.jsxs(b.Fragment,{children:[b.jsx(Tx,{pullDistance:R.pullDistance,refreshing:R.refreshing,threshold:R.threshold}),x&&b.jsxs("div",{className:"form-error",children:[x,x.toLowerCase().includes("failed to fetch")&&b.jsxs(b.Fragment,{children:[" ",b.jsx("a",{href:"#",onClick:F=>{F.preventDefault(),window.location.reload()},children:"Reload"})]})]}),y&&!m.length?b.jsx("div",{className:"task-list",children:[0,1,2].map(F=>b.jsxs("div",{className:"task-card",style:{pointerEvents:"none"},children:[b.jsx("div",{className:"task-card-header",children:b.jsxs("div",{className:"task-card-title-row",children:[b.jsx("div",{className:"skeleton-line",style:{width:10,height:10,borderRadius:"50%"}}),b.jsx("div",{className:"skeleton-line",style:{width:`${60+F*12}%`}})]})}),b.jsxs("div",{className:"task-card-meta",children:[b.jsx("div",{className:"skeleton-line",style:{width:"30%"}}),b.jsx("div",{className:"skeleton-line",style:{width:"25%"}})]})]},F))}):m.length===0?b.jsxs("div",{className:"empty-state",children:[b.jsx("p",{className:"empty-state-text",children:"No tasks yet"}),b.jsx("p",{className:"empty-state-hint",children:"Tap the + button to create your first task."})]}):b.jsx("div",{className:"task-list",children:m.map(F=>b.jsx(fk,{task:F,lastEvent:E.get(F.id),onEdit:async L=>{try{const W=await r("task.get",{id:L.id});j(W.error?L:W)}catch{j(L)}z(!0)},onDelete:J,onViewRun:f},F.id))}),b.jsx("button",{className:"fab",onClick:()=>{j(void 0),z(!0)},"aria-label":"New task",title:"New task",children:b.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),P&&b.jsx(wk,{initial:I,agents:l,hostPlatform:u,isNotificationListener:c,onSaved:Y,onRun:f,onCancel:K})]})}let oa=null;function z0(e){oa&&(e.preventDefault(),e.returnValue="")}function Nh(e){const n=!!oa;oa=e;const r=!!oa;r&&!n?window.addEventListener("beforeunload",z0):!r&&n&&window.removeEventListener("beforeunload",z0)}function hs(){return oa?window.confirm(oa):!0}function _k(){const e=ti(),r=Tr().pathname.startsWith("/tasks"),s=!r;function l(u){hs()&&e(u)}return b.jsxs(b.Fragment,{children:[b.jsxs("button",{className:`tab-btn ${s?"tab-btn-active":""}`,onClick:()=>l("/"),children:[b.jsx("svg",{className:"tab-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:b.jsx("path",{d:"M2 8H4.5L6 4L8 12L10 6L11.5 8H14"})}),"Sessions"]}),b.jsxs("button",{className:`tab-btn ${r?"tab-btn-active":""}`,onClick:()=>l("/tasks"),children:[b.jsxs("svg",{className:"tab-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),b.jsx("path",{d:"M5.5 8L7 9.5L10.5 6"})]}),"Tasks"]})]})}function Nx(e){const[n,r]=N.useState(()=>window.matchMedia(e).matches);return N.useEffect(()=>{const s=window.matchMedia(e),l=u=>r(u.matches);return s.addEventListener("change",l),r(s.matches),()=>s.removeEventListener("change",l)},[e]),n}const Ek="modulepreload",kk=function(e){return"/"+e},U0={},Ox=function(n,r,s){let l=Promise.resolve();if(r&&r.length>0){let c=function(d){return Promise.all(d.map(y=>Promise.resolve(y).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));l=c(r.map(d=>{if(d=kk(d),d in U0)return;U0[d]=!0;const y=d.endsWith(".css"),g=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${g}`))return;const x=document.createElement("link");if(x.rel=y?"stylesheet":Ek,y||(x.as="script"),x.crossOrigin="",x.href=d,m&&x.setAttribute("nonce",m),document.head.appendChild(x),y)return new Promise((w,E)=>{x.addEventListener("load",w),x.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${d}`)))})}))}function u(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return l.then(c=>{for(const f of c||[])f.status==="rejected"&&u(f.reason);return n().catch(u)})},Ck=va("App",{web:()=>Ox(()=>import("./web-Bp48ONY3.js"),[]).then(e=>new e.AppWeb)}),pu=pr.isNativePlatform(),Ak=["Device","Data","Messaging"],Oh=[{capability:"sms-read",label:"Read SMS",group:"Messaging",permission:"smsRead"},{capability:"sms-send",label:"Send SMS",group:"Messaging",permission:"smsSend"},{capability:"send-email",label:"Send Email",group:"Messaging",permission:"postNotifications"},{capability:"notifications",label:"Read Notifications",group:"Data",permission:"notificationListener"},{capability:"contacts",label:"Manage Contacts",group:"Data",permission:"contacts"},{capability:"calendar",label:"Manage Calendar",group:"Data",permission:"calendar"},{capability:"location",label:"Get Location",group:"Device",permission:"location",enableMethod:"device.location.enable",disableMethod:"device.location.disable",enableParams:e=>({fcmToken:e}),disableParams:()=>({})},{capability:"battery",label:"Read Battery Status",group:"Device"},{capability:"dnd",label:"Set Ringer Mode",group:"Device",permission:"dnd"},{capability:"alarm",label:"Trigger Alarms",group:"Device",needsFullScreenIntent:!0}];function Rx({capabilityTokens:e,activeClientToken:n,request:r,onCapabilityTokensChange:s}){const[l,u]=N.useState(null),[c,f]=N.useState(null),[m,d]=N.useState(null),[y,g]=N.useState(null);N.useEffect(()=>{if(!pu||!Ut){g(new Set);return}Ut.getSupportedPermissions().then(({types:j})=>g(new Set(j))).catch(()=>g(new Set))},[]);function x(j){return!!(n&&(e==null?void 0:e[j])===n)}function w(j){return y?y.size===0?!0:!(j.permission&&!y.has(j.permission)||j.needsFullScreenIntent&&!y.has("fullScreenIntent")):!1}function E(j,K){const B={};for(const[R,Y]of Object.entries(e??{}))B[R]=Y??null;B[j]=K?n??null:null,s(B)}N.useEffect(()=>{if(!pu||!Ut||!x("location"))return;function K(){Ut.checkPermission({type:"location"}).then(({granted:R})=>{R||r("device.location.disable").then(()=>{E("location",!1)}).catch(()=>{})})}K();const B=Ck.addListener("resume",K);return()=>{B.then(R=>R.remove())}},[e,n]),N.useEffect(()=>{if(!pu||!Ut)return;const j=Oh.map(K=>K.capability).filter(K=>(e==null?void 0:e[K])===n);Ut.setEnabledCapabilities({capabilities:j}).catch(()=>{})},[e,n]);async function M(j,K=!1){var Y,J;const B=x(j.capability);if(B&&!K){d(j);return}if(!B&&!!(e!=null&&e[j.capability])&&e[j.capability]!==n&&!K){f(j);return}u(j.capability);try{if(B){const oe=j.disableMethod??"device.capability.disable",ae=((Y=j.disableParams)==null?void 0:Y.call(j))??{capability:j.capability};await r(oe,ae),E(j.capability,!1);return}if(Ut&&j.capability==="send-email")try{const oe=await Ut.hasEmailClient();if(oe.supported&&!oe.available){alert("No email app is installed on this device. Install one (e.g. Gmail) before enabling Sending Email.");return}}catch{}if(Ut&&j.permission){const oe=await Ut.checkPermission({type:j.permission});if(!oe.supported){console.warn(`Native build does not support permission '${j.permission}'`);return}if(!oe.granted&&!(await Ut.requestPermission({type:j.permission})).granted)return}if(Ut&&j.needsFullScreenIntent){const oe=await Ut.checkPermission({type:"fullScreenIntent"});if(!oe.supported){console.warn("Native build does not support fullScreenIntent");return}if(!oe.granted&&!(await Ut.requestPermission({type:"fullScreenIntent"})).granted)return}if(!Ut)return;const{token:F}=await Ut.getFcmToken();if(!F){console.warn("No FCM token available");return}const L=Oh.map(oe=>oe.capability).filter(oe=>oe===j.capability||(e==null?void 0:e[oe])===n);await Ut.setEnabledCapabilities({capabilities:L});const W=j.enableMethod??"device.capability.enable",Q=((J=j.enableParams)==null?void 0:J.call(j,F))??{capability:j.capability,fcmToken:F};await r(W,Q),E(j.capability,!0)}catch(F){console.error(`Failed to toggle ${j.capability}:`,F)}finally{u(null)}}const P=Ak.map(j=>({group:j,items:Oh.filter(K=>K.group===j&&w(K))})).filter(j=>j.items.length>0);if(!pu||P.length===0)return null;const z=c&&ca.createPortal(b.jsx("div",{className:"confirm-modal-overlay",onClick:()=>f(null),children:b.jsxs("div",{className:"confirm-modal",onClick:j=>j.stopPropagation(),children:[b.jsxs("h2",{className:"confirm-modal-title",children:["Switch ",c.label," to this device?"]}),b.jsxs("p",{className:"confirm-modal-message",children:[c.label," is currently enabled on another device. Switching will make this device the one the host uses for ",c.label,", and it will be disabled on the other device."]}),b.jsxs("div",{className:"confirm-modal-actions",children:[b.jsx("button",{className:"btn btn-secondary",onClick:()=>f(null),children:"Cancel"}),b.jsx("button",{className:"btn btn-primary",onClick:()=>{const j=c;f(null),M(j,!0)},children:"Switch"})]})]})}),document.body),I=m&&ca.createPortal(b.jsx("div",{className:"confirm-modal-overlay",onClick:()=>d(null),children:b.jsxs("div",{className:"confirm-modal",onClick:j=>j.stopPropagation(),children:[b.jsxs("h2",{className:"confirm-modal-title",children:["Disable ",m.label,"?"]}),b.jsxs("p",{className:"confirm-modal-message",children:["Agents running on the host will no longer be able to use ",m.label," until it is re-enabled on a device."]}),b.jsxs("div",{className:"confirm-modal-actions",children:[b.jsx("button",{className:"btn btn-secondary",onClick:()=>d(null),children:"Cancel"}),b.jsx("button",{className:"btn btn-danger",onClick:()=>{const j=m;d(null),M(j,!0)},children:"Disable"})]})]})}),document.body);return b.jsxs(b.Fragment,{children:[P.map(({group:j,items:K},B)=>b.jsx("div",{className:B>0?"drawer-toggle-group drawer-toggle-group-divided":"drawer-toggle-group",children:K.map(R=>{const Y=x(R.capability);return b.jsxs("label",{className:"drawer-toggle",children:[b.jsx("span",{className:"drawer-toggle-label",children:R.label}),b.jsx("button",{className:`toggle-switch ${Y?"toggle-switch-on":""}`,onClick:()=>M(R),disabled:l===R.capability,role:"switch","aria-checked":Y,children:b.jsx("span",{className:"toggle-switch-thumb"})})]},R.capability)})},j)),z,I]})}const B0=!!window.__PALMIER_SERVE__,Tk=pr.isNativePlatform();function P0({daemonVersion:e,capabilityTokens:n,activeClientToken:r,request:s,onCapabilityTokensChange:l}){var H;const{pairedHosts:u,activeHostId:c,setActiveHostId:f,removePairedHost:m,renamePairedHost:d}=ba(),y=ti(),g=Nx("(min-width: 768px)"),[x,w]=N.useState(!1),[E,M]=N.useState(!1),[P,z]=N.useState(null),[I,j]=N.useState(""),[K,B]=N.useState(null),R=N.useRef(null),Y=N.useRef(null),J=N.useCallback(()=>{M(!0)},[]);function F(){E&&(w(!1),M(!1))}function L(){M(!1),w(!0)}function W(X,ue){z(X),j(ue)}function Q(){P&&I.trim()&&d(P,I.trim()),z(null),j("")}function oe(){z(null),j("")}N.useEffect(()=>{P&&Y.current&&(Y.current.focus(),Y.current.select())},[P]),N.useEffect(()=>{if(!x||E)return;function X(ue){ue.key==="Escape"&&J()}return document.addEventListener("keydown",X),()=>{document.removeEventListener("keydown",X)}},[x,E,J]);const ae=b.jsxs(b.Fragment,{children:[!g&&b.jsx("button",{className:"drawer-close-btn",onClick:J,"aria-label":"Close menu",children:b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:b.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),!B0&&u.length>0&&b.jsxs("div",{className:"drawer-section",children:[b.jsx("h3",{className:"drawer-section-label",children:"Hosts"}),b.jsx("div",{className:"host-picker-inline",children:b.jsx("div",{className:"host-picker-list",role:"listbox",children:u.map(X=>{const ue=X.hostId===c,_e=P===X.hostId,_=X.name||X.hostId.slice(0,8);return b.jsx("div",{className:"host-picker-item-wrapper",children:b.jsxs("div",{className:`host-picker-item ${ue?"host-picker-item-active":""}`,onClick:()=>{if(!_e&&!ue){if(!hs())return;f(X.hostId),g||J()}},role:"option","aria-selected":ue,children:[_e?b.jsx("input",{ref:Y,className:"form-input host-picker-rename-input",type:"text",value:I,onChange:D=>j(D.target.value),onKeyDown:D=>{D.key==="Enter"&&Q(),D.key==="Escape"&&oe()},onBlur:Q,onClick:D=>D.stopPropagation()}):b.jsx("span",{className:"host-picker-item-name",children:_}),b.jsxs("div",{className:"host-picker-item-actions",children:[ue&&!_e&&b.jsx("button",{className:"host-picker-edit-btn",onClick:D=>{D.stopPropagation(),W(X.hostId,_)},"aria-label":"Rename host",children:b.jsx("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:b.jsx("path",{d:"M9.5 1.5L11.5 3.5M1.5 11.5L2 9L9 2L11 4L4 11L1.5 11.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!ue&&b.jsx("button",{className:"host-picker-delete-btn",onClick:D=>{D.stopPropagation(),B(X.hostId)},"aria-label":`Unpair ${_}`,children:b.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:b.jsx("path",{d:"M4 5.5V11C4 11.2761 4.22386 11.5 4.5 11.5H9.5C9.77614 11.5 10 11.2761 10 11V5.5M3 4H11M5.5 4V3C5.5 2.72386 5.72386 2.5 6 2.5H8C8.27614 2.5 8.5 2.72386 8.5 3V4M6.5 6.5V9.5M7.5 6.5V9.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})},X.hostId)})})})]}),!B0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"drawer-divider"}),b.jsx("div",{className:"drawer-section",children:b.jsx("button",{className:"btn btn-primary btn-full",onClick:()=>{hs()&&(y("/pair"),g||J())},children:"Pair New Host"})})]}),Tk&&s&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"drawer-divider"}),b.jsxs("div",{className:"drawer-section",children:[b.jsx("h3",{className:"drawer-section-label",children:"Host capabilities on this device"}),b.jsx(Rx,{capabilityTokens:n,activeClientToken:r,request:s,onCapabilityTokensChange:X=>l==null?void 0:l(X)})]})]}),b.jsxs("div",{className:"drawer-footer",children:[e&&b.jsxs("div",{className:"drawer-version",children:["Palmier v",e]}),b.jsxs("div",{className:"drawer-legal",children:[b.jsx("a",{href:"https://www.palmier.me/terms",target:"_blank",rel:"noopener noreferrer",children:"Terms"}),b.jsx("span",{className:"drawer-legal-sep",children:"·"}),b.jsx("a",{href:"https://www.palmier.me/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy"})]})]})]}),G=K&&ca.createPortal(b.jsx("div",{className:"confirm-modal-overlay",onClick:()=>B(null),children:b.jsxs("div",{className:"confirm-modal",onClick:X=>X.stopPropagation(),children:[b.jsx("h2",{className:"confirm-modal-title",children:"Delete host?"}),b.jsxs("p",{className:"confirm-modal-message",children:['"',((H=u.find(X=>X.hostId===K))==null?void 0:H.name)||K.slice(0,8),'" will be unpaired from this device.']}),b.jsxs("div",{className:"confirm-modal-actions",children:[b.jsx("button",{className:"btn btn-secondary",onClick:()=>B(null),children:"Cancel"}),b.jsx("button",{className:"btn btn-danger",onClick:()=>{m(K),B(null)},children:"Delete"})]})]})}),document.body);return g?b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"drawer-panel drawer-panel-desktop",ref:R,children:ae}),G]}):b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"hamburger-btn",onClick:L,"aria-label":"Open menu",children:b.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:b.jsx("path",{d:"M3 5H17M3 10H17M3 15H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),x&&ca.createPortal(b.jsx("div",{className:`drawer-overlay ${E?"drawer-overlay-closing":""}`,onClick:J,onAnimationEnd:F,children:b.jsx("div",{className:`drawer-panel ${E?"drawer-panel-closing":""}`,ref:R,onClick:X=>X.stopPropagation(),children:ae})}),document.body),G]})}function q0(e){var s;const n=localStorage.getItem("palmier:lastAgent"),r=e.map(l=>l.key);return n&&r.includes(n)?n:((s=e[0])==null?void 0:s.key)??""}function jk({agents:e,hostPlatform:n,onStarted:r}){const{request:s}=Yl(),[l,u]=N.useState(""),[c,f]=N.useState(()=>q0(e)),[m,d]=N.useState(!1),[y,g]=N.useState(!1),[x,w]=N.useState(null);N.useEffect(()=>{e.length&&(e.find(K=>K.key===c)||f(q0(e)))},[e,c]),N.useEffect(()=>{const K=l.trim().length>0;return Nh(K?"Your session draft will be lost. Continue?":null),()=>Nh(null)},[l]);const E=e.find(K=>K.key===c),M=!!(E!=null&&E.supportsYolo);N.useEffect(()=>{!M&&m&&d(!1)},[M,m]);const P=!!l.trim()&&!!c&&!y;function z(){return m?confirm(`Yolo mode is enabled. The agent will auto-approve all tool calls — it can read, write, delete files, run arbitrary commands, and access the network without asking for permission.
|
|
90
|
+
Are you sure you want to continue?`):!0}async function nn(){ue(!0),I(null);try{const ge=Fe?$e():j==="on_new_notification"&&_.trim()?[_.trim()]:j==="on_new_sms"&&dt.trim()?[dt.trim()]:[],ze=Fe||tt?Th(j):null,Se={user_prompt:d,agent:g,schedule_type:ze,schedule_values:ge.length>0?ge:null,schedule_enabled:j!=="ondemand"&&F,requires_confirmation:Fe?Y:!1,yolo_mode:W,foreground_mode:oe,command:Ue?G:""};Mt&&(Se.id=e.id);const pt=await f(Mt?"task.update":"task.create",Se,{timeout:45e3});if(pt.error){I(pt.error);return}if(Mt||localStorage.setItem("palmier:lastAgent",g),Ue&&!Mt){l(pt);try{const Tn=await f("task.run",{id:pt.id});Tn.run_id?u(pt.id,Tn.run_id):Tn.error||u(pt.id)}catch{}return}l(pt)}catch(ge){I(ge instanceof Error?ge.message:String(ge))}finally{ue(!1)}}const bn=Mt?"Save":Ue?"Run":(Fe||tt)&&F?"Schedule":"Save";return b.jsxs("div",{className:"task-form-overlay",children:[b.jsx("div",{className:"task-form",children:E?b.jsx(hk,{permissions:e==null?void 0:e.permissions}):b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"task-form-header",children:b.jsx("h2",{children:e?"Edit Task":"New Task"})}),z&&b.jsx("div",{className:"form-error",children:z}),b.jsx("textarea",{autoFocus:!e,className:"form-textarea",value:d,onChange:ge=>y(ge.target.value),placeholder:Ue?"If the input email contains an event, create a calendar entry for it.":"Research today's top AI news and write a summary.",rows:4,disabled:X}),b.jsxs("div",{className:"plan-actions",children:[b.jsxs("div",{className:"agent-picker-section-inline",children:[b.jsx("span",{className:"agent-picker-label",children:"Run with"}),b.jsx("select",{className:"form-select form-select-sm",value:g,onChange:ge=>x(ge.target.value),disabled:X,children:n.map(ge=>b.jsx("option",{value:ge.key,children:ge.label},ge.key))})]}),st&&b.jsxs("label",{className:"yolo-inline",style:{marginLeft:"auto"},children:[b.jsx("input",{type:"checkbox",checked:W,onChange:ge=>Q(ge.target.checked),disabled:X}),"Yolo"]}),st&&W&&b.jsx("p",{className:"yolo-warning",children:"The agent will auto-approve all tool calls without asking for permission."}),w&&b.jsx("div",{className:"granted-permissions-row",children:b.jsx("button",{className:"btn btn-link",onClick:()=>M(!0),children:"Granted Permissions"})})]}),b.jsx("div",{className:"toggles-group",children:b.jsxs("div",{className:"schedule-section",children:[b.jsx("h3",{className:"schedule-section-title",children:"Schedule"}),b.jsxs("select",{className:"form-select",value:j,onChange:ge=>Be(ge.target.value),disabled:X,children:[b.jsx("option",{value:"ondemand",children:"On Demand"}),b.jsx("option",{value:"specific_times",children:"Specific Times"}),b.jsx("option",{value:"hourly",children:"Hourly"}),b.jsx("option",{value:"daily",children:"Daily"}),b.jsx("option",{value:"weekly",children:"Weekly"}),b.jsx("option",{value:"monthly",children:"Monthly"}),b.jsx("option",{value:"on_new_notification",children:"On New Notification"}),b.jsx("option",{value:"on_new_sms",children:"On New SMS"}),b.jsx("option",{value:"command",children:"Command-triggered"})]}),tt&&b.jsxs("div",{className:"schedule-reactive",children:[b.jsxs("p",{className:"command-help-text",children:[j==="on_new_notification"?"Runs each time a new push notification arrives on the paired Android device.":"Runs each time a new SMS arrives on the paired Android device."," ","The triggering payload is spliced into your task prompt — reference it as “the new ",j==="on_new_notification"?"notification":"SMS","”."]}),j==="on_new_notification"&&(()=>{const ge=ee.find(Se=>Se.packageName===_),ze=(ge==null?void 0:ge.appName)||_;return b.jsxs(b.Fragment,{children:[s?_.trim()?b.jsxs("div",{className:"app-filter-selected",children:[b.jsx("span",{className:"app-filter-selected-name",children:ze}),(ge==null?void 0:ge.appName)&&b.jsx("span",{className:"app-filter-selected-pkg",children:ge.packageName}),b.jsx("button",{type:"button",className:"app-filter-selected-clear",onClick:()=>D(""),"aria-label":"Clear app filter",disabled:X,children:"✕"})]}):b.jsx("button",{type:"button",className:"btn btn-link app-filter-trigger",onClick:()=>{be(""),Me(!0)},disabled:X,children:"Select app"}):b.jsx("input",{className:"form-input",type:"text",value:_,onChange:Se=>D(Se.target.value),placeholder:"App (optional), e.g. com.google.android.gm",disabled:X}),b.jsx("p",{className:"command-help-text app-filter-help",children:_.trim()?`Only notifications from ${ze} will trigger this task.`:"Every notification from your device triggers this task."})]})})(),j==="on_new_sms"&&b.jsxs(b.Fragment,{children:[b.jsx("input",{className:"form-input",type:"text",value:dt,onChange:ge=>lt(ge.target.value),placeholder:"From (optional), e.g. +1 555-1234)",disabled:X}),b.jsx("p",{className:"command-help-text app-filter-help",children:dt.trim()?`Only SMS from ${dt.trim()} will trigger this task. Formatting (spaces, dashes, parens) is ignored.`:"Every SMS that arrives on your device triggers this task."})]})]}),Ue&&b.jsxs("div",{className:"schedule-reactive",children:[b.jsx("p",{className:"command-help-text",children:"Runs a command and invokes the task for each line of output. Use “the input” in your task description to reference each line."}),b.jsx("input",{ref:ct,className:"form-input form-input-mono",type:"text",value:G,onChange:ge=>H(ge.target.value),placeholder:"gws gmail +watch --project my-project",disabled:X})]}),Fe&&j!=="hourly"&&b.jsxs(b.Fragment,{children:[B.map((ge,ze)=>b.jsxs("div",{className:"trigger-row-card",children:[b.jsxs("div",{className:"trigger-row-content",children:[j==="daily"&&b.jsx("input",{className:"form-input",type:"time",value:ge.time,onChange:Se=>An(ze,{time:Se.target.value})}),j==="weekly"&&b.jsxs("div",{className:"trigger-row-top",children:[b.jsx("select",{className:"form-select",value:ge.dayOfWeek,onChange:Se=>An(ze,{dayOfWeek:Se.target.value}),children:pk.map((Se,ft)=>b.jsx("option",{value:String(ft),children:Se},ft))}),b.jsx("input",{className:"form-input",type:"time",value:ge.time,onChange:Se=>An(ze,{time:Se.target.value})})]}),j==="monthly"&&b.jsxs("div",{className:"trigger-row-top",children:[b.jsx("select",{className:"form-select",value:ge.dayOfMonth,onChange:Se=>An(ze,{dayOfMonth:Se.target.value}),children:Array.from({length:28},(Se,ft)=>ft+1).map(Se=>b.jsxs("option",{value:String(Se),children:["Day ",Se]},Se))}),b.jsx("input",{className:"form-input",type:"time",value:ge.time,onChange:Se=>An(ze,{time:Se.target.value})})]}),j==="specific_times"&&b.jsxs("div",{className:"trigger-row-top",children:[b.jsx("input",{className:"form-input",type:"date",value:ge.onceDate,min:new Date().toISOString().split("T")[0],onChange:Se=>An(ze,{onceDate:Se.target.value})}),b.jsx("input",{className:"form-input",type:"time",value:ge.onceTime,min:ge.onceDate===new Date().toISOString().split("T")[0]?new Date().toTimeString().slice(0,5):void 0,onChange:Se=>An(ze,{onceTime:Se.target.value})})]})]}),B.length>1&&b.jsx("button",{className:"trigger-remove-btn",onClick:()=>fe(ze),title:"Remove trigger",children:"×"})]},ze)),b.jsx("button",{className:"trigger-add-btn",onClick:we,children:"+ Add"})]}),r==="win32"&&b.jsxs("label",{className:"toggle-label",children:[b.jsx("input",{type:"checkbox",checked:oe,onChange:ge=>ae(ge.target.checked),disabled:X}),"Run in the foreground (host must login to Windows)"]}),Fe&&b.jsxs("label",{className:"toggle-label",children:[b.jsx("input",{type:"checkbox",checked:Y,onChange:ge=>J(ge.target.checked),disabled:X}),"Confirm before each run"]}),j!=="ondemand"&&b.jsxs("label",{className:"toggle-label",children:[b.jsx("input",{type:"checkbox",checked:F,onChange:ge=>L(ge.target.checked),disabled:X}),"Enabled"]})]})}),!W&&mt&&!mt.supportsPermissions&&b.jsxs("div",{className:"form-warning",children:["Palmier does not support runtime permission granting for ",mt.label,". The task may fail if required permissions are not pre-configured."]}),b.jsxs("div",{className:"form-actions",children:[b.jsxs("button",{className:"btn btn-primary",onClick:()=>rt()&&nn(),disabled:!vt||X,children:[X&&b.jsx("span",{className:"btn-spinner"}),bn]}),b.jsx("button",{className:"btn btn-secondary",onClick:()=>{$n&&d.trim()&&!confirm("You have unsaved changes. Discard?")||c()},style:{marginLeft:"auto"},children:"Cancel"})]})]})}),Te&&(()=>{const ge=He.trim().toLowerCase(),ze=ge?ee.filter(Se=>Se.packageName.toLowerCase().includes(ge)||Se.appName.toLowerCase().includes(ge)):ee;return b.jsx("div",{className:"app-filter-overlay",onClick:De,children:b.jsxs("div",{className:"app-filter-dialog",onClick:Se=>Se.stopPropagation(),children:[b.jsxs("div",{className:"app-filter-header",children:[b.jsx("h2",{children:"Select app"}),b.jsx("button",{className:"app-filter-close",onClick:De,"aria-label":"Close",children:b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:b.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),b.jsx("input",{className:"form-input app-filter-search",type:"text",value:He,onChange:Se=>be(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&He.trim()&&(D(He.trim()),De())},placeholder:"Search or type a package name",autoFocus:!0}),b.jsxs("ul",{className:"app-filter-list",children:[ve&&ee.length===0?Array.from({length:6}).map((Se,ft)=>b.jsx("li",{className:"app-filter-row app-filter-skeleton",children:b.jsx("div",{className:"app-filter-skeleton-bar"})},`sk-${ft}`)):ze.length===0&&!He.trim()?b.jsx("li",{className:"app-filter-empty",children:"No apps"}):ze.map(Se=>b.jsx("li",{className:"app-filter-row",onClick:()=>{D(Se.packageName),De()},children:b.jsxs("div",{className:"app-filter-row-labels",children:[b.jsx("div",{className:"app-filter-row-name",children:Se.appName||Se.packageName}),Se.appName&&b.jsx("div",{className:"app-filter-row-pkg",children:Se.packageName})]})},Se.packageName)),He.trim()&&b.jsx("li",{className:"app-filter-row",onClick:()=>{D(He.trim()),De()},children:b.jsx("div",{className:"app-filter-row-labels",children:b.jsx("div",{className:"app-filter-row-name",children:He.trim()})})})]})]})})})()]})}function Tx({pullDistance:e,refreshing:n,threshold:r}){const s=e>0||n,l=e>=r;return b.jsx("div",{className:"pull-to-refresh",style:{transform:`translateY(${e}px)`,opacity:s?Math.min(1,e/30):0},"aria-hidden":!s,children:b.jsx("div",{className:"pull-to-refresh-badge",children:n?b.jsx("div",{className:"spinner"}):b.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:l?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s"},children:[b.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b.jsx("polyline",{points:"19 12 12 19 5 12"})]})})})}function jx({onRefresh:e,threshold:n=70,maxPull:r=110,enabled:s=!0}){const[l,u]=N.useState(0),[c,f]=N.useState(!1),m=N.useRef(null),d=N.useRef(!1),y=N.useRef(0),g=N.useRef(!1),x=N.useRef(e);return N.useEffect(()=>{x.current=e}),N.useEffect(()=>{if(!s)return;const w=P=>{if(g.current||window.scrollY>0){m.current=null;return}m.current=P.touches[0].clientY,d.current=!1,y.current=0},E=P=>{if(g.current||m.current==null)return;const z=P.touches[0].clientY-m.current;if(z<=0){d.current=!1,y.current=0,u(0);return}d.current=!0;const I=Math.min(r,z*.5);y.current=I,u(I),P.cancelable&&P.preventDefault()},M=()=>{if(!d.current){m.current=null,u(0);return}const P=y.current;m.current=null,d.current=!1,y.current=0,P>=n?(g.current=!0,f(!0),u(n),Promise.resolve(x.current()).catch(()=>{}).finally(()=>{g.current=!1,f(!1),u(0)})):u(0)};return window.addEventListener("touchstart",w,{passive:!0}),window.addEventListener("touchmove",E,{passive:!1}),window.addEventListener("touchend",M,{passive:!0}),window.addEventListener("touchcancel",M,{passive:!0}),()=>{window.removeEventListener("touchstart",w),window.removeEventListener("touchmove",E),window.removeEventListener("touchend",M),window.removeEventListener("touchcancel",M)}},[s,n,r]),{pullDistance:l,refreshing:c,threshold:n}}function Sk({connected:e,hostId:n,request:r,subscribeEvents:s,agents:l,hostPlatform:u,isNotificationListener:c,onViewRun:f}){const[m,d]=N.useState([]),[y,g]=N.useState(!1),[x,w]=N.useState(null),[E,M]=N.useState(new Map),[P,z]=N.useState(!1),[I,j]=N.useState(void 0),K=N.useCallback(()=>{z(!1),j(void 0)},[]),B=N.useCallback(async()=>{if(e){g(!0),w(null);try{const L=(await r("task.list")).tasks??[],W=new Map;for(const Q of L)Q.status&&W.set(Q.id,Q.status);M(W),d(L)}catch(F){const L=F instanceof Error?F.message:String(F);L==="Not connected"||L.includes("503")||L.toLowerCase().includes("no responders")?w(null):w(L),d([])}finally{g(!1)}}},[e,n,r]);N.useEffect(()=>{e?B():(d([]),g(!1))},[e,n,B]);const R=jx({onRefresh:B,enabled:e});N.useEffect(()=>!e||!n?void 0:s(n,async L=>{const W=L.subject.split(".");if(W.length<3)return;const Q=W.slice(2).join(".");let oe={};try{oe=JSON.parse(new TextDecoder().decode(L.data))}catch{return}const ae=oe.event_type;if(!(ae!=="running-state"&&ae!=="permission-resolved"))try{const G=await r("task.status",{id:Q},{timeout:5e3});if(G.error)return;M(H=>{const X=new Map(H);return X.set(Q,G),X})}catch{}}),[e,n,s,r]);function Y(F){d(L=>{const W=L.findIndex(Q=>Q.id===F.id);if(W>=0){const Q=[...L];return Q[W]=F,Q}return[F,...L]}),z(!1),j(void 0)}function J(F){d(L=>L.filter(W=>W.id!==F)),M(L=>{const W=new Map(L);return W.delete(F),W})}return b.jsxs(b.Fragment,{children:[b.jsx(Tx,{pullDistance:R.pullDistance,refreshing:R.refreshing,threshold:R.threshold}),x&&b.jsxs("div",{className:"form-error",children:[x,x.toLowerCase().includes("failed to fetch")&&b.jsxs(b.Fragment,{children:[" ",b.jsx("a",{href:"#",onClick:F=>{F.preventDefault(),window.location.reload()},children:"Reload"})]})]}),y&&!m.length?b.jsx("div",{className:"task-list",children:[0,1,2].map(F=>b.jsxs("div",{className:"task-card",style:{pointerEvents:"none"},children:[b.jsx("div",{className:"task-card-header",children:b.jsxs("div",{className:"task-card-title-row",children:[b.jsx("div",{className:"skeleton-line",style:{width:10,height:10,borderRadius:"50%"}}),b.jsx("div",{className:"skeleton-line",style:{width:`${60+F*12}%`}})]})}),b.jsxs("div",{className:"task-card-meta",children:[b.jsx("div",{className:"skeleton-line",style:{width:"30%"}}),b.jsx("div",{className:"skeleton-line",style:{width:"25%"}})]})]},F))}):m.length===0?b.jsxs("div",{className:"empty-state",children:[b.jsx("p",{className:"empty-state-text",children:"No tasks yet"}),b.jsx("p",{className:"empty-state-hint",children:"Tap the + button to create your first task."})]}):b.jsx("div",{className:"task-list",children:m.map(F=>b.jsx(fk,{task:F,lastEvent:E.get(F.id),onEdit:async L=>{try{const W=await r("task.get",{id:L.id});j(W.error?L:W)}catch{j(L)}z(!0)},onDelete:J,onViewRun:f},F.id))}),b.jsx("button",{className:"fab",onClick:()=>{j(void 0),z(!0)},"aria-label":"New task",title:"New task",children:b.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),P&&b.jsx(wk,{initial:I,agents:l,hostPlatform:u,isNotificationListener:c,onSaved:Y,onRun:f,onCancel:K})]})}let oa=null;function z0(e){oa&&(e.preventDefault(),e.returnValue="")}function Nh(e){const n=!!oa;oa=e;const r=!!oa;r&&!n?window.addEventListener("beforeunload",z0):!r&&n&&window.removeEventListener("beforeunload",z0)}function hs(){return oa?window.confirm(oa):!0}function _k(){const e=ti(),r=Tr().pathname.startsWith("/tasks"),s=!r;function l(u){hs()&&e(u)}return b.jsxs(b.Fragment,{children:[b.jsxs("button",{className:`tab-btn ${s?"tab-btn-active":""}`,onClick:()=>l("/"),children:[b.jsx("svg",{className:"tab-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:b.jsx("path",{d:"M2 8H4.5L6 4L8 12L10 6L11.5 8H14"})}),"Sessions"]}),b.jsxs("button",{className:`tab-btn ${r?"tab-btn-active":""}`,onClick:()=>l("/tasks"),children:[b.jsxs("svg",{className:"tab-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),b.jsx("path",{d:"M5.5 8L7 9.5L10.5 6"})]}),"Tasks"]})]})}function Nx(e){const[n,r]=N.useState(()=>window.matchMedia(e).matches);return N.useEffect(()=>{const s=window.matchMedia(e),l=u=>r(u.matches);return s.addEventListener("change",l),r(s.matches),()=>s.removeEventListener("change",l)},[e]),n}const Ek="modulepreload",kk=function(e){return"/"+e},U0={},Ox=function(n,r,s){let l=Promise.resolve();if(r&&r.length>0){let c=function(d){return Promise.all(d.map(y=>Promise.resolve(y).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));l=c(r.map(d=>{if(d=kk(d),d in U0)return;U0[d]=!0;const y=d.endsWith(".css"),g=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${g}`))return;const x=document.createElement("link");if(x.rel=y?"stylesheet":Ek,y||(x.as="script"),x.crossOrigin="",x.href=d,m&&x.setAttribute("nonce",m),document.head.appendChild(x),y)return new Promise((w,E)=>{x.addEventListener("load",w),x.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${d}`)))})}))}function u(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return l.then(c=>{for(const f of c||[])f.status==="rejected"&&u(f.reason);return n().catch(u)})},Ck=va("App",{web:()=>Ox(()=>import("./web-nSzKzI8x.js"),[]).then(e=>new e.AppWeb)}),pu=pr.isNativePlatform(),Ak=["Device","Data","Messaging"],Oh=[{capability:"sms-read",label:"Read SMS",group:"Messaging",permission:"smsRead"},{capability:"sms-send",label:"Send SMS",group:"Messaging",permission:"smsSend"},{capability:"send-email",label:"Send Email",group:"Messaging",permission:"postNotifications"},{capability:"notifications",label:"Read Notifications",group:"Data",permission:"notificationListener"},{capability:"contacts",label:"Manage Contacts",group:"Data",permission:"contacts"},{capability:"calendar",label:"Manage Calendar",group:"Data",permission:"calendar"},{capability:"location",label:"Get Location",group:"Device",permission:"location",enableMethod:"device.location.enable",disableMethod:"device.location.disable",enableParams:e=>({fcmToken:e}),disableParams:()=>({})},{capability:"battery",label:"Read Battery Status",group:"Device"},{capability:"dnd",label:"Set Ringer Mode",group:"Device",permission:"dnd"},{capability:"alarm",label:"Trigger Alarms",group:"Device",needsFullScreenIntent:!0}];function Rx({capabilityTokens:e,activeClientToken:n,request:r,onCapabilityTokensChange:s}){const[l,u]=N.useState(null),[c,f]=N.useState(null),[m,d]=N.useState(null),[y,g]=N.useState(null);N.useEffect(()=>{if(!pu||!Ut){g(new Set);return}Ut.getSupportedPermissions().then(({types:j})=>g(new Set(j))).catch(()=>g(new Set))},[]);function x(j){return!!(n&&(e==null?void 0:e[j])===n)}function w(j){return y?y.size===0?!0:!(j.permission&&!y.has(j.permission)||j.needsFullScreenIntent&&!y.has("fullScreenIntent")):!1}function E(j,K){const B={};for(const[R,Y]of Object.entries(e??{}))B[R]=Y??null;B[j]=K?n??null:null,s(B)}N.useEffect(()=>{if(!pu||!Ut||!x("location"))return;function K(){Ut.checkPermission({type:"location"}).then(({granted:R})=>{R||r("device.location.disable").then(()=>{E("location",!1)}).catch(()=>{})})}K();const B=Ck.addListener("resume",K);return()=>{B.then(R=>R.remove())}},[e,n]),N.useEffect(()=>{if(!pu||!Ut)return;const j=Oh.map(K=>K.capability).filter(K=>(e==null?void 0:e[K])===n);Ut.setEnabledCapabilities({capabilities:j}).catch(()=>{})},[e,n]);async function M(j,K=!1){var Y,J;const B=x(j.capability);if(B&&!K){d(j);return}if(!B&&!!(e!=null&&e[j.capability])&&e[j.capability]!==n&&!K){f(j);return}u(j.capability);try{if(B){const oe=j.disableMethod??"device.capability.disable",ae=((Y=j.disableParams)==null?void 0:Y.call(j))??{capability:j.capability};await r(oe,ae),E(j.capability,!1);return}if(Ut&&j.capability==="send-email")try{const oe=await Ut.hasEmailClient();if(oe.supported&&!oe.available){alert("No email app is installed on this device. Install one (e.g. Gmail) before enabling Sending Email.");return}}catch{}if(Ut&&j.permission){const oe=await Ut.checkPermission({type:j.permission});if(!oe.supported){console.warn(`Native build does not support permission '${j.permission}'`);return}if(!oe.granted&&!(await Ut.requestPermission({type:j.permission})).granted)return}if(Ut&&j.needsFullScreenIntent){const oe=await Ut.checkPermission({type:"fullScreenIntent"});if(!oe.supported){console.warn("Native build does not support fullScreenIntent");return}if(!oe.granted&&!(await Ut.requestPermission({type:"fullScreenIntent"})).granted)return}if(!Ut)return;const{token:F}=await Ut.getFcmToken();if(!F){console.warn("No FCM token available");return}const L=Oh.map(oe=>oe.capability).filter(oe=>oe===j.capability||(e==null?void 0:e[oe])===n);await Ut.setEnabledCapabilities({capabilities:L});const W=j.enableMethod??"device.capability.enable",Q=((J=j.enableParams)==null?void 0:J.call(j,F))??{capability:j.capability,fcmToken:F};await r(W,Q),E(j.capability,!0)}catch(F){console.error(`Failed to toggle ${j.capability}:`,F)}finally{u(null)}}const P=Ak.map(j=>({group:j,items:Oh.filter(K=>K.group===j&&w(K))})).filter(j=>j.items.length>0);if(!pu||P.length===0)return null;const z=c&&ca.createPortal(b.jsx("div",{className:"confirm-modal-overlay",onClick:()=>f(null),children:b.jsxs("div",{className:"confirm-modal",onClick:j=>j.stopPropagation(),children:[b.jsxs("h2",{className:"confirm-modal-title",children:["Switch ",c.label," to this device?"]}),b.jsxs("p",{className:"confirm-modal-message",children:[c.label," is currently enabled on another device. Switching will make this device the one the host uses for ",c.label,", and it will be disabled on the other device."]}),b.jsxs("div",{className:"confirm-modal-actions",children:[b.jsx("button",{className:"btn btn-secondary",onClick:()=>f(null),children:"Cancel"}),b.jsx("button",{className:"btn btn-primary",onClick:()=>{const j=c;f(null),M(j,!0)},children:"Switch"})]})]})}),document.body),I=m&&ca.createPortal(b.jsx("div",{className:"confirm-modal-overlay",onClick:()=>d(null),children:b.jsxs("div",{className:"confirm-modal",onClick:j=>j.stopPropagation(),children:[b.jsxs("h2",{className:"confirm-modal-title",children:["Disable ",m.label,"?"]}),b.jsxs("p",{className:"confirm-modal-message",children:["Agents running on the host will no longer be able to use ",m.label," until it is re-enabled on a device."]}),b.jsxs("div",{className:"confirm-modal-actions",children:[b.jsx("button",{className:"btn btn-secondary",onClick:()=>d(null),children:"Cancel"}),b.jsx("button",{className:"btn btn-danger",onClick:()=>{const j=m;d(null),M(j,!0)},children:"Disable"})]})]})}),document.body);return b.jsxs(b.Fragment,{children:[P.map(({group:j,items:K},B)=>b.jsx("div",{className:B>0?"drawer-toggle-group drawer-toggle-group-divided":"drawer-toggle-group",children:K.map(R=>{const Y=x(R.capability);return b.jsxs("label",{className:"drawer-toggle",children:[b.jsx("span",{className:"drawer-toggle-label",children:R.label}),b.jsx("button",{className:`toggle-switch ${Y?"toggle-switch-on":""}`,onClick:()=>M(R),disabled:l===R.capability,role:"switch","aria-checked":Y,children:b.jsx("span",{className:"toggle-switch-thumb"})})]},R.capability)})},j)),z,I]})}const B0=!!window.__PALMIER_SERVE__,Tk=pr.isNativePlatform();function P0({daemonVersion:e,capabilityTokens:n,activeClientToken:r,request:s,onCapabilityTokensChange:l}){var H;const{pairedHosts:u,activeHostId:c,setActiveHostId:f,removePairedHost:m,renamePairedHost:d}=ba(),y=ti(),g=Nx("(min-width: 768px)"),[x,w]=N.useState(!1),[E,M]=N.useState(!1),[P,z]=N.useState(null),[I,j]=N.useState(""),[K,B]=N.useState(null),R=N.useRef(null),Y=N.useRef(null),J=N.useCallback(()=>{M(!0)},[]);function F(){E&&(w(!1),M(!1))}function L(){M(!1),w(!0)}function W(X,ue){z(X),j(ue)}function Q(){P&&I.trim()&&d(P,I.trim()),z(null),j("")}function oe(){z(null),j("")}N.useEffect(()=>{P&&Y.current&&(Y.current.focus(),Y.current.select())},[P]),N.useEffect(()=>{if(!x||E)return;function X(ue){ue.key==="Escape"&&J()}return document.addEventListener("keydown",X),()=>{document.removeEventListener("keydown",X)}},[x,E,J]);const ae=b.jsxs(b.Fragment,{children:[!g&&b.jsx("button",{className:"drawer-close-btn",onClick:J,"aria-label":"Close menu",children:b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:b.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),!B0&&u.length>0&&b.jsxs("div",{className:"drawer-section",children:[b.jsx("h3",{className:"drawer-section-label",children:"Hosts"}),b.jsx("div",{className:"host-picker-inline",children:b.jsx("div",{className:"host-picker-list",role:"listbox",children:u.map(X=>{const ue=X.hostId===c,_e=P===X.hostId,_=X.name||X.hostId.slice(0,8);return b.jsx("div",{className:"host-picker-item-wrapper",children:b.jsxs("div",{className:`host-picker-item ${ue?"host-picker-item-active":""}`,onClick:()=>{if(!_e&&!ue){if(!hs())return;f(X.hostId),g||J()}},role:"option","aria-selected":ue,children:[_e?b.jsx("input",{ref:Y,className:"form-input host-picker-rename-input",type:"text",value:I,onChange:D=>j(D.target.value),onKeyDown:D=>{D.key==="Enter"&&Q(),D.key==="Escape"&&oe()},onBlur:Q,onClick:D=>D.stopPropagation()}):b.jsx("span",{className:"host-picker-item-name",children:_}),b.jsxs("div",{className:"host-picker-item-actions",children:[ue&&!_e&&b.jsx("button",{className:"host-picker-edit-btn",onClick:D=>{D.stopPropagation(),W(X.hostId,_)},"aria-label":"Rename host",children:b.jsx("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:b.jsx("path",{d:"M9.5 1.5L11.5 3.5M1.5 11.5L2 9L9 2L11 4L4 11L1.5 11.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!ue&&b.jsx("button",{className:"host-picker-delete-btn",onClick:D=>{D.stopPropagation(),B(X.hostId)},"aria-label":`Unpair ${_}`,children:b.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:b.jsx("path",{d:"M4 5.5V11C4 11.2761 4.22386 11.5 4.5 11.5H9.5C9.77614 11.5 10 11.2761 10 11V5.5M3 4H11M5.5 4V3C5.5 2.72386 5.72386 2.5 6 2.5H8C8.27614 2.5 8.5 2.72386 8.5 3V4M6.5 6.5V9.5M7.5 6.5V9.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})},X.hostId)})})})]}),!B0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"drawer-divider"}),b.jsx("div",{className:"drawer-section",children:b.jsx("button",{className:"btn btn-primary btn-full",onClick:()=>{hs()&&(y("/pair"),g||J())},children:"Pair New Host"})})]}),Tk&&s&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"drawer-divider"}),b.jsxs("div",{className:"drawer-section",children:[b.jsx("h3",{className:"drawer-section-label",children:"Host capabilities on this device"}),b.jsx(Rx,{capabilityTokens:n,activeClientToken:r,request:s,onCapabilityTokensChange:X=>l==null?void 0:l(X)})]})]}),b.jsxs("div",{className:"drawer-footer",children:[e&&b.jsxs("div",{className:"drawer-version",children:["Palmier v",e]}),b.jsxs("div",{className:"drawer-legal",children:[b.jsx("a",{href:"https://www.palmier.me/terms",target:"_blank",rel:"noopener noreferrer",children:"Terms"}),b.jsx("span",{className:"drawer-legal-sep",children:"·"}),b.jsx("a",{href:"https://www.palmier.me/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy"})]})]})]}),G=K&&ca.createPortal(b.jsx("div",{className:"confirm-modal-overlay",onClick:()=>B(null),children:b.jsxs("div",{className:"confirm-modal",onClick:X=>X.stopPropagation(),children:[b.jsx("h2",{className:"confirm-modal-title",children:"Delete host?"}),b.jsxs("p",{className:"confirm-modal-message",children:['"',((H=u.find(X=>X.hostId===K))==null?void 0:H.name)||K.slice(0,8),'" will be unpaired from this device.']}),b.jsxs("div",{className:"confirm-modal-actions",children:[b.jsx("button",{className:"btn btn-secondary",onClick:()=>B(null),children:"Cancel"}),b.jsx("button",{className:"btn btn-danger",onClick:()=>{m(K),B(null)},children:"Delete"})]})]})}),document.body);return g?b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"drawer-panel drawer-panel-desktop",ref:R,children:ae}),G]}):b.jsxs(b.Fragment,{children:[b.jsx("button",{className:"hamburger-btn",onClick:L,"aria-label":"Open menu",children:b.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:b.jsx("path",{d:"M3 5H17M3 10H17M3 15H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),x&&ca.createPortal(b.jsx("div",{className:`drawer-overlay ${E?"drawer-overlay-closing":""}`,onClick:J,onAnimationEnd:F,children:b.jsx("div",{className:`drawer-panel ${E?"drawer-panel-closing":""}`,ref:R,onClick:X=>X.stopPropagation(),children:ae})}),document.body),G]})}function q0(e){var s;const n=localStorage.getItem("palmier:lastAgent"),r=e.map(l=>l.key);return n&&r.includes(n)?n:((s=e[0])==null?void 0:s.key)??""}function jk({agents:e,hostPlatform:n,onStarted:r}){const{request:s}=Yl(),[l,u]=N.useState(""),[c,f]=N.useState(()=>q0(e)),[m,d]=N.useState(!1),[y,g]=N.useState(!1),[x,w]=N.useState(null);N.useEffect(()=>{e.length&&(e.find(K=>K.key===c)||f(q0(e)))},[e,c]),N.useEffect(()=>{const K=l.trim().length>0;return Nh(K?"Your session draft will be lost. Continue?":null),()=>Nh(null)},[l]);const E=e.find(K=>K.key===c),M=!!(E!=null&&E.supportsYolo);N.useEffect(()=>{!M&&m&&d(!1)},[M,m]);const P=!!l.trim()&&!!c&&!y;function z(){return m?confirm(`Yolo mode is enabled. The agent will auto-approve all tool calls — it can read, write, delete files, run arbitrary commands, and access the network without asking for permission.
|
|
91
91
|
|
|
92
92
|
Are you sure you want to continue?`):!0}async function I(){if(!(!P||!z())){g(!0),w(null);try{const K=await s("task.run_oneoff",{user_prompt:l,agent:c,yolo_mode:m,...n==="win32"?{foreground_mode:!0}:{}});if(K.error){w(K.error);return}localStorage.setItem("palmier:lastAgent",c),u(""),Nh(null),K.task_id&&r(K.task_id,K.run_id)}catch(K){w(K instanceof Error?K.message:String(K))}finally{g(!1)}}}function j(K){K.key==="Enter"&&(K.metaKey||K.ctrlKey)&&(K.preventDefault(),I())}return b.jsxs("div",{className:"session-composer",children:[x&&b.jsx("div",{className:"form-error",children:x}),b.jsx("textarea",{className:"session-composer-textarea",value:l,onChange:K=>u(K.target.value),onKeyDown:j,placeholder:"What can I do for you?",rows:3,disabled:y}),b.jsxs("div",{className:"session-composer-controls",children:[b.jsxs("div",{className:"agent-picker-section-inline",children:[b.jsx("span",{className:"agent-picker-label",children:"Run with"}),b.jsx("select",{className:"form-select form-select-sm",value:c,onChange:K=>f(K.target.value),disabled:y||!e.length,children:e.map(K=>b.jsx("option",{value:K.key,children:K.label},K.key))})]}),M&&b.jsxs("label",{className:"session-composer-yolo",children:[b.jsx("input",{type:"checkbox",checked:m,onChange:K=>d(K.target.checked),disabled:y}),"Yolo"]}),b.jsx("button",{className:"btn btn-primary chat-send-btn",onClick:I,disabled:!P,"aria-label":"Run session",title:"Run session",children:y?b.jsx("span",{className:"btn-spinner"}):b.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),b.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),M&&m&&b.jsx("p",{className:"command-help-text",children:"The agent will auto-approve all tool calls without asking for permission."})]})}const us=88,H0=6;function Nk({id:e,revealedId:n,setRevealedId:r,onDelete:s,onClick:l,children:u,actionLabel:c="Delete"}){const f=n===e,[m,d]=N.useState(0),[y,g]=N.useState(!1),x=N.useRef(0),w=N.useRef(0),E=N.useRef(null),M=N.useRef(0),P=N.useRef(!1),z=N.useRef(null);N.useEffect(()=>{f||d(0)},[f]),N.useEffect(()=>{if(!f)return;function Y(J){var F;(F=z.current)!=null&&F.contains(J.target)||r(null)}return document.addEventListener("pointerdown",Y),()=>document.removeEventListener("pointerdown",Y)},[f,r]);function I(Y){Y.button!==void 0&&Y.button!==0||(x.current=Y.clientX,w.current=Y.clientY,E.current=null,M.current=f?-us:0,P.current=!1)}function j(Y){if(Y.pointerType==="mouse"&&Y.buttons===0)return;const J=Y.clientX-x.current,F=Y.clientY-w.current;if(E.current===null){if(Math.abs(J)<H0&&Math.abs(F)<H0)return;if(E.current=Math.abs(J)>Math.abs(F)?"x":"y",E.current==="x")try{Y.currentTarget.setPointerCapture(Y.pointerId)}catch{}}if(E.current!=="x")return;P.current=!0,y||g(!0);let L=M.current+J;L>0&&(L=L/4),L<-us&&(L=-us+(L+us)/4),d(L)}function K(){if(E.current!=="x"){g(!1);return}E.current=null,g(!1),m<=-44?(d(-us),r(e)):(d(0),f&&r(null))}function B(Y){if(P.current){P.current=!1,Y.stopPropagation(),Y.preventDefault();return}f&&(Y.stopPropagation(),Y.preventDefault(),r(null))}const R=m!==0?m:f?-us:0;return b.jsxs("div",{ref:z,className:"swipe-row",children:[b.jsx("button",{type:"button",className:"swipe-row-action",style:{width:us},onClick:Y=>{Y.stopPropagation(),s()},tabIndex:f?0:-1,"aria-hidden":!f,children:c}),b.jsx("div",{className:`swipe-row-content ${y?"swipe-row-content-dragging":""}`,style:{transform:`translateX(${R}px)`},onPointerDown:I,onPointerMove:j,onPointerUp:K,onPointerCancel:K,onClickCapture:B,onClick:l,children:u})]})}const Ok=10;function Rk({connected:e,hostId:n,request:r,subscribeEvents:s,agents:l,hostPlatform:u,filterTaskId:c,onClearFilter:f}){const[m,d]=N.useState([]),[y,g]=N.useState(0),[x,w]=N.useState(!1),[E,M]=N.useState(!1),[P,z]=N.useState(null),I=ti();async function j(G){const H=`${G.task_id}:${G.run_id}`;d(X=>X.filter(ue=>`${ue.task_id}:${ue.run_id}`!==H)),g(X=>Math.max(0,X-1)),z(null);try{await r("taskrun.delete",{task_id:G.task_id,run_id:G.run_id})}catch(X){console.error("Failed to delete run:",X),d(ue=>[G,...ue]),g(ue=>ue+1)}}const K=N.useRef(null),B=N.useCallback(G=>{const H={offset:G,limit:Ok};return c&&(H.task_id=c),H},[c]),R=N.useCallback(async(G,H)=>{if(e){H?M(!0):w(!0);try{const X=await r("taskrun.list",B(G)),ue=X.entries??[];g(X.total??0),d(H?_e=>{const _=new Set(_e.map(ee=>`${ee.task_id}:${ee.run_id}`)),D=ue.filter(ee=>!_.has(`${ee.task_id}:${ee.run_id}`));return[..._e,...D]}:ue)}catch(X){X instanceof Error&&X.message==="Not connected"||console.error("Failed to load runs:",X)}finally{w(!1),M(!1)}}},[e,r,B]);N.useEffect(()=>{e?(d([]),g(0),R(0,!1)):(d([]),g(0))},[e,n,R,c]);const Y=jx({onRefresh:()=>R(0,!1),enabled:e});N.useEffect(()=>!e||!n?void 0:s(n,async H=>{try{const X=JSON.parse(new TextDecoder().decode(H.data));if(X.event_type==="running-state"&&X.running_state&&["monitoring","started","finished","failed","aborted"].includes(X.running_state)){const ue=await r("taskrun.list",B(0)),_e=ue.entries??[];g(ue.total??0),d(_=>{const D=new Map(_e.map(Ae=>[`${Ae.task_id}:${Ae.run_id}`,Ae])),ee=_.map(Ae=>{const Te=`${Ae.task_id}:${Ae.run_id}`;return D.get(Te)??Ae}),A=new Set(ee.map(Ae=>`${Ae.task_id}:${Ae.run_id}`));return[..._e.filter(Ae=>!A.has(`${Ae.task_id}:${Ae.run_id}`)),...ee]})}}catch{}}),[e,n,s,r]),N.useEffect(()=>{const G=K.current;if(!G)return;const H=new IntersectionObserver(X=>{X[0].isIntersecting&&!E&&m.length<y&&R(m.length,!0)},{threshold:.1});return H.observe(G),()=>H.disconnect()},[m.length,y,E,R]);function J(G,H){if(!G||!H)return"";const X=Math.round((H-G)/1e3);if(X<60)return`${X}s`;const ue=Math.floor(X/60),_e=X%60;return`${ue}m ${_e}s`}const F={monitoring:"Monitoring",started:"Running",finished:"Finished",failed:"Failed",aborted:"Aborted"};function L(G,H){hs()&&I(`/runs/${G}/${encodeURIComponent(H)}`)}const W=!c&&b.jsx(jk,{agents:l,hostPlatform:u,onStarted:(G,H)=>{I(H?`/runs/${encodeURIComponent(G)}/${encodeURIComponent(H)}`:`/runs/${encodeURIComponent(G)}`)}}),Q=b.jsx(Tx,{pullDistance:Y.pullDistance,refreshing:Y.refreshing,threshold:Y.threshold}),oe=c&&f&&b.jsx("div",{style:{marginBottom:"var(--space-sm)"},children:b.jsxs("span",{className:"sessions-filter-chip",children:["Filtered by task",b.jsx("button",{onClick:f,"aria-label":"Clear filter",children:"×"})]})});function ae(G){if(G==="failed")return"var(--color-error)";if(G==="aborted")return"var(--color-warning, #d97706)"}return x&&m.length===0&&e?b.jsxs(b.Fragment,{children:[Q,W,b.jsx("div",{className:"task-list",children:[0,1,2].map(G=>b.jsxs("div",{className:"task-card",style:{pointerEvents:"none"},children:[b.jsx("div",{className:"task-card-header",children:b.jsx("div",{className:"task-card-title-row",children:b.jsx("div",{className:"skeleton-line",style:{width:`${70+G*10}%`}})})}),b.jsx("div",{className:"task-card-meta",children:b.jsx("div",{className:"skeleton-line",style:{width:"45%"}})})]},G))})]}):!e||x&&m.length===0?b.jsxs(b.Fragment,{children:[Q,W,b.jsx("div",{className:"sessions-view",children:b.jsxs("div",{className:"empty-state",children:[b.jsx("p",{className:"empty-state-text",children:"Sessions"}),b.jsx("p",{className:"empty-state-hint",children:"Your sessions will appear here"})]})})]}):m.length===0?b.jsxs(b.Fragment,{children:[Q,W,oe,b.jsx("div",{className:"sessions-view",children:b.jsxs("div",{className:"empty-state",children:[b.jsx("p",{className:"empty-state-text",children:"No sessions yet"}),b.jsx("p",{className:"empty-state-hint",children:c?"This task hasn't been executed yet. Run it from the task menu or wait for its next trigger.":"Your sessions will appear here."})]})})]}):b.jsxs(b.Fragment,{children:[Q,W,oe,b.jsxs("div",{className:"task-list",children:[m.map((G,H)=>{const X=`${G.task_id}:${G.run_id}`;return b.jsx(Nk,{id:X,revealedId:P,setRevealedId:z,onDelete:()=>j(G),onClick:()=>!G.error&&L(G.task_id,G.run_id),children:b.jsxs("div",{className:"sessions-card",children:[b.jsxs("div",{className:"sessions-card-body",children:[b.jsx("h3",{className:"sessions-card-name",children:G.task_name||G.task_id}),b.jsxs("div",{className:"sessions-card-meta",children:[G.running_state==="started"?b.jsx("span",{className:"status-spinner","aria-label":"Running",children:b.jsx("span",{})}):b.jsx("span",{style:{color:ae(G.running_state)},children:F[G.running_state??""]??G.running_state}),G.end_time&&b.jsx("span",{children:Uu(G.end_time)}),G.start_time&&G.end_time&&b.jsx("span",{style:{color:"var(--color-muted)"},children:J(G.start_time,G.end_time)}),G.error&&b.jsx("span",{style:{color:"var(--color-muted)"},children:G.error})]})]}),b.jsx("span",{className:"sessions-card-chevron",children:"›"})]})},`${X}-${H}`)}),b.jsx("div",{ref:K,style:{height:1}}),E&&b.jsx("div",{className:"loading-state",style:{padding:"var(--space-md)"},children:b.jsx("div",{className:"spinner"})})]})]})}function Mk(e,n){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const Dk=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Lk=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zk={};function I0(e,n){return(zk.jsx?Lk:Dk).test(e)}const Uk=/[ \t\n\f\r]/g;function Bk(e){return typeof e=="object"?e.type==="text"?F0(e.value):!1:F0(e)}function F0(e){return e.replace(Uk,"")===""}class Gl{constructor(n,r,s){this.normal=r,this.property=n,s&&(this.space=s)}}Gl.prototype.normal={};Gl.prototype.property={};Gl.prototype.space=void 0;function Mx(e,n){const r={},s={};for(const l of e)Object.assign(r,l.property),Object.assign(s,l.normal);return new Gl(r,s,n)}function dd(e){return e.toLowerCase()}class Cn{constructor(n,r){this.attribute=r,this.property=n}}Cn.prototype.attribute="";Cn.prototype.booleanish=!1;Cn.prototype.boolean=!1;Cn.prototype.commaOrSpaceSeparated=!1;Cn.prototype.commaSeparated=!1;Cn.prototype.defined=!1;Cn.prototype.mustUseProperty=!1;Cn.prototype.number=!1;Cn.prototype.overloadedBoolean=!1;Cn.prototype.property="";Cn.prototype.spaceSeparated=!1;Cn.prototype.space=void 0;let Pk=0;const Ve=ms(),Kt=ms(),md=ms(),xe=ms(),jt=ms(),ua=ms(),Un=ms();function ms(){return 2**++Pk}const pd=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ve,booleanish:Kt,commaOrSpaceSeparated:Un,commaSeparated:ua,number:xe,overloadedBoolean:md,spaceSeparated:jt},Symbol.toStringTag,{value:"Module"})),Rh=Object.keys(pd);class qd extends Cn{constructor(n,r,s,l){let u=-1;if(super(n,r),$0(this,"space",l),typeof s=="number")for(;++u<Rh.length;){const c=Rh[u];$0(this,Rh[u],(s&pd[c])===pd[c])}}}qd.prototype.defined=!0;function $0(e,n,r){r&&(e[n]=r)}function wa(e){const n={},r={};for(const[s,l]of Object.entries(e.properties)){const u=new qd(s,e.transform(e.attributes||{},s),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(u.mustUseProperty=!0),n[s]=u,r[dd(s)]=s,r[dd(u.attribute)]=s}return new Gl(n,r,e.space)}const Dx=wa({properties:{ariaActiveDescendant:null,ariaAtomic:Kt,ariaAutoComplete:null,ariaBusy:Kt,ariaChecked:Kt,ariaColCount:xe,ariaColIndex:xe,ariaColSpan:xe,ariaControls:jt,ariaCurrent:null,ariaDescribedBy:jt,ariaDetails:null,ariaDisabled:Kt,ariaDropEffect:jt,ariaErrorMessage:null,ariaExpanded:Kt,ariaFlowTo:jt,ariaGrabbed:Kt,ariaHasPopup:null,ariaHidden:Kt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:jt,ariaLevel:xe,ariaLive:null,ariaModal:Kt,ariaMultiLine:Kt,ariaMultiSelectable:Kt,ariaOrientation:null,ariaOwns:jt,ariaPlaceholder:null,ariaPosInSet:xe,ariaPressed:Kt,ariaReadOnly:Kt,ariaRelevant:null,ariaRequired:Kt,ariaRoleDescription:jt,ariaRowCount:xe,ariaRowIndex:xe,ariaRowSpan:xe,ariaSelected:Kt,ariaSetSize:xe,ariaSort:null,ariaValueMax:xe,ariaValueMin:xe,ariaValueNow:xe,ariaValueText:null,role:null},transform(e,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function Lx(e,n){return n in e?e[n]:n}function zx(e,n){return Lx(e,n.toLowerCase())}const qk=wa({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ua,acceptCharset:jt,accessKey:jt,action:null,allow:null,allowFullScreen:Ve,allowPaymentRequest:Ve,allowUserMedia:Ve,alt:null,as:null,async:Ve,autoCapitalize:null,autoComplete:jt,autoFocus:Ve,autoPlay:Ve,blocking:jt,capture:null,charSet:null,checked:Ve,cite:null,className:jt,cols:xe,colSpan:null,content:null,contentEditable:Kt,controls:Ve,controlsList:jt,coords:xe|ua,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ve,defer:Ve,dir:null,dirName:null,disabled:Ve,download:md,draggable:Kt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ve,formTarget:null,headers:jt,height:xe,hidden:md,high:xe,href:null,hrefLang:null,htmlFor:jt,httpEquiv:jt,id:null,imageSizes:null,imageSrcSet:null,inert:Ve,inputMode:null,integrity:null,is:null,isMap:Ve,itemId:null,itemProp:jt,itemRef:jt,itemScope:Ve,itemType:jt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ve,low:xe,manifest:null,max:null,maxLength:xe,media:null,method:null,min:null,minLength:xe,multiple:Ve,muted:Ve,name:null,nonce:null,noModule:Ve,noValidate:Ve,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ve,optimum:xe,pattern:null,ping:jt,placeholder:null,playsInline:Ve,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ve,referrerPolicy:null,rel:jt,required:Ve,reversed:Ve,rows:xe,rowSpan:xe,sandbox:jt,scope:null,scoped:Ve,seamless:Ve,selected:Ve,shadowRootClonable:Ve,shadowRootDelegatesFocus:Ve,shadowRootMode:null,shape:null,size:xe,sizes:null,slot:null,span:xe,spellCheck:Kt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:xe,step:null,style:null,tabIndex:xe,target:null,title:null,translate:null,type:null,typeMustMatch:Ve,useMap:null,value:Kt,width:xe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:jt,axis:null,background:null,bgColor:null,border:xe,borderColor:null,bottomMargin:xe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ve,declare:Ve,event:null,face:null,frame:null,frameBorder:null,hSpace:xe,leftMargin:xe,link:null,longDesc:null,lowSrc:null,marginHeight:xe,marginWidth:xe,noResize:Ve,noHref:Ve,noShade:Ve,noWrap:Ve,object:null,profile:null,prompt:null,rev:null,rightMargin:xe,rules:null,scheme:null,scrolling:Kt,standby:null,summary:null,text:null,topMargin:xe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:xe,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ve,disableRemotePlayback:Ve,prefix:null,property:null,results:xe,security:null,unselectable:null},space:"html",transform:zx}),Hk=wa({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Un,accentHeight:xe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:xe,amplitude:xe,arabicForm:null,ascent:xe,attributeName:null,attributeType:null,azimuth:xe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:xe,by:null,calcMode:null,capHeight:xe,className:jt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:xe,diffuseConstant:xe,direction:null,display:null,dur:null,divisor:xe,dominantBaseline:null,download:Ve,dx:null,dy:null,edgeMode:null,editable:null,elevation:xe,enableBackground:null,end:null,event:null,exponent:xe,externalResourcesRequired:null,fill:null,fillOpacity:xe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ua,g2:ua,glyphName:ua,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:xe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:xe,horizOriginX:xe,horizOriginY:xe,id:null,ideographic:xe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:xe,k:xe,k1:xe,k2:xe,k3:xe,k4:xe,kernelMatrix:Un,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:xe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:xe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:xe,overlineThickness:xe,paintOrder:null,panose1:null,path:null,pathLength:xe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:jt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:xe,pointsAtY:xe,pointsAtZ:xe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Un,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Un,rev:Un,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Un,requiredFeatures:Un,requiredFonts:Un,requiredFormats:Un,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:xe,specularExponent:xe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:xe,strikethroughThickness:xe,string:null,stroke:null,strokeDashArray:Un,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:xe,strokeOpacity:xe,strokeWidth:null,style:null,surfaceScale:xe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Un,tabIndex:xe,tableValues:null,target:null,targetX:xe,targetY:xe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Un,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:xe,underlineThickness:xe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:xe,values:null,vAlphabetic:xe,vMathematical:xe,vectorEffect:null,vHanging:xe,vIdeographic:xe,version:null,vertAdvY:xe,vertOriginX:xe,vertOriginY:xe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:xe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Lx}),Ux=wa({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,n){return"xlink:"+n.slice(5).toLowerCase()}}),Bx=wa({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:zx}),Px=wa({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,n){return"xml:"+n.slice(3).toLowerCase()}}),Ik={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Fk=/[A-Z]/g,Y0=/-[a-z]/g,$k=/^data[-\w.:]+$/i;function Yk(e,n){const r=dd(n);let s=n,l=Cn;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&$k.test(n)){if(n.charAt(4)==="-"){const u=n.slice(5).replace(Y0,Vk);s="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=n.slice(4);if(!Y0.test(u)){let c=u.replace(Fk,Gk);c.charAt(0)!=="-"&&(c="-"+c),n="data"+c}}l=qd}return new l(s,n)}function Gk(e){return"-"+e.toLowerCase()}function Vk(e){return e.charAt(1).toUpperCase()}const Jk=Mx([Dx,qk,Ux,Bx,Px],"html"),Hd=Mx([Dx,Hk,Ux,Bx,Px],"svg");function Xk(e){return e.join(" ").trim()}var Qs={},Mh,G0;function Kk(){if(G0)return Mh;G0=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,r=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
|
|
93
93
|
`,d="/",y="*",g="",x="comment",w="declaration";function E(P,z){if(typeof P!="string")throw new TypeError("First argument must be a string");if(!P)return[];z=z||{};var I=1,j=1;function K(ae){var G=ae.match(n);G&&(I+=G.length);var H=ae.lastIndexOf(m);j=~H?ae.length-H:j+ae.length}function B(){var ae={line:I,column:j};return function(G){return G.position=new R(ae),F(),G}}function R(ae){this.start=ae,this.end={line:I,column:j},this.source=z.source}R.prototype.content=P;function Y(ae){var G=new Error(z.source+":"+I+":"+j+": "+ae);if(G.reason=ae,G.filename=z.source,G.line=I,G.column=j,G.source=P,!z.silent)throw G}function J(ae){var G=ae.exec(P);if(G){var H=G[0];return K(H),P=P.slice(H.length),G}}function F(){J(r)}function L(ae){var G;for(ae=ae||[];G=W();)G!==!1&&ae.push(G);return ae}function W(){var ae=B();if(!(d!=P.charAt(0)||y!=P.charAt(1))){for(var G=2;g!=P.charAt(G)&&(y!=P.charAt(G)||d!=P.charAt(G+1));)++G;if(G+=2,g===P.charAt(G-1))return Y("End of comment missing");var H=P.slice(2,G-2);return j+=2,K(H),P=P.slice(G),j+=2,ae({type:x,comment:H})}}function Q(){var ae=B(),G=J(s);if(G){if(W(),!J(l))return Y("property missing ':'");var H=J(u),X=ae({type:w,property:M(G[0].replace(e,g)),value:H?M(H[0].replace(e,g)):g});return J(c),X}}function oe(){var ae=[];L(ae);for(var G;G=Q();)G!==!1&&(ae.push(G),L(ae));return ae}return F(),oe()}function M(P){return P?P.replace(f,g):g}return Mh=E,Mh}var V0;function Qk(){if(V0)return Qs;V0=1;var e=Qs&&Qs.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.default=r;const n=e(Kk());function r(s,l){let u=null;if(!s||typeof s!="string")return u;const c=(0,n.default)(s),f=typeof l=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:d,value:y}=m;f?l(d,y,m):y&&(u=u||{},u[d]=y)}),u}return Qs}var bl={},J0;function Zk(){if(J0)return bl;J0=1,Object.defineProperty(bl,"__esModule",{value:!0}),bl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,u=function(d){return!d||r.test(d)||e.test(d)},c=function(d,y){return y.toUpperCase()},f=function(d,y){return"".concat(y,"-")},m=function(d,y){return y===void 0&&(y={}),u(d)?d:(d=d.toLowerCase(),y.reactCompat?d=d.replace(l,f):d=d.replace(s,f),d.replace(n,c))};return bl.camelCase=m,bl}var xl,X0;function Wk(){if(X0)return xl;X0=1;var e=xl&&xl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}},n=e(Qk()),r=Zk();function s(l,u){var c={};return!l||typeof l!="string"||(0,n.default)(l,function(f,m){f&&m&&(c[(0,r.camelCase)(f,u)]=m)}),c}return s.default=s,xl=s,xl}var eC=Wk();const tC=Db(eC),qx=Hx("end"),Id=Hx("start");function Hx(e){return n;function n(r){const s=r&&r.position&&r.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function nC(e){const n=Id(e),r=qx(e);if(n&&r)return{start:n,end:r}}function Nl(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?K0(e.position):"start"in e||"end"in e?K0(e):"line"in e||"column"in e?gd(e):""}function gd(e){return Q0(e&&e.line)+":"+Q0(e&&e.column)}function K0(e){return gd(e&&e.start)+"-"+gd(e&&e.end)}function Q0(e){return e&&typeof e=="number"?e:1}class fn extends Error{constructor(n,r,s){super(),typeof r=="string"&&(s=r,r=void 0);let l="",u={},c=!1;if(r&&("line"in r&&"column"in r?u={place:r}:"start"in r&&"end"in r?u={place:r}:"type"in r?u={ancestors:[r],place:r.position}:u={...r}),typeof n=="string"?l=n:!u.cause&&n&&(c=!0,l=n.message,u.cause=n),!u.ruleId&&!u.source&&typeof s=="string"){const m=s.indexOf(":");m===-1?u.ruleId=s:(u.source=s.slice(0,m),u.ruleId=s.slice(m+1))}if(!u.place&&u.ancestors&&u.ancestors){const m=u.ancestors[u.ancestors.length-1];m&&(u.place=m.position)}const f=u.place&&"start"in u.place?u.place.start:u.place;this.ancestors=u.ancestors||void 0,this.cause=u.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=l,this.line=f?f.line:void 0,this.name=Nl(u.place)||"1:1",this.place=u.place||void 0,this.reason=this.message,this.ruleId=u.ruleId||void 0,this.source=u.source||void 0,this.stack=c&&u.cause&&typeof u.cause.stack=="string"?u.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}fn.prototype.file="";fn.prototype.name="";fn.prototype.reason="";fn.prototype.message="";fn.prototype.stack="";fn.prototype.column=void 0;fn.prototype.line=void 0;fn.prototype.ancestors=void 0;fn.prototype.cause=void 0;fn.prototype.fatal=void 0;fn.prototype.place=void 0;fn.prototype.ruleId=void 0;fn.prototype.source=void 0;const Fd={}.hasOwnProperty,rC=new Map,iC=/[A-Z]/g,sC=new Set(["table","tbody","thead","tfoot","tr"]),aC=new Set(["td","th"]),Ix="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function lC(e,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=n.filePath||void 0;let s;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=pC(r,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=mC(r,n.jsx,n.jsxs)}const l={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:s,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?Hd:Jk,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},u=Fx(l,e,void 0);return u&&typeof u!="string"?u:l.create(e,l.Fragment,{children:u||void 0},void 0)}function Fx(e,n,r){if(n.type==="element")return oC(e,n,r);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return uC(e,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return fC(e,n,r);if(n.type==="mdxjsEsm")return cC(e,n);if(n.type==="root")return hC(e,n,r);if(n.type==="text")return dC(e,n)}function oC(e,n,r){const s=e.schema;let l=s;n.tagName.toLowerCase()==="svg"&&s.space==="html"&&(l=Hd,e.schema=l),e.ancestors.push(n);const u=Yx(e,n.tagName,!1),c=gC(e,n);let f=Yd(e,n);return sC.has(n.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!Bk(m):!0})),$x(e,c,u,n),$d(c,f),e.ancestors.pop(),e.schema=s,e.create(n,u,c,r)}function uC(e,n){if(n.data&&n.data.estree&&e.evaluater){const s=n.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}Bl(e,n.position)}function cC(e,n){if(n.data&&n.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(n.data.estree);Bl(e,n.position)}function fC(e,n,r){const s=e.schema;let l=s;n.name==="svg"&&s.space==="html"&&(l=Hd,e.schema=l),e.ancestors.push(n);const u=n.name===null?e.Fragment:Yx(e,n.name,!0),c=yC(e,n),f=Yd(e,n);return $x(e,c,u,n),$d(c,f),e.ancestors.pop(),e.schema=s,e.create(n,u,c,r)}function hC(e,n,r){const s={};return $d(s,Yd(e,n)),e.create(n,e.Fragment,s,r)}function dC(e,n){return n.value}function $x(e,n,r,s){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(n.node=s)}function $d(e,n){if(n.length>0){const r=n.length>1?n:n[0];r&&(e.children=r)}}function mC(e,n,r){return s;function s(l,u,c,f){const d=Array.isArray(c.children)?r:n;return f?d(u,c,f):d(u,c)}}function pC(e,n){return r;function r(s,l,u,c){const f=Array.isArray(u.children),m=Id(s);return n(l,u,c,f,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function gC(e,n){const r={};let s,l;for(l in n.properties)if(l!=="children"&&Fd.call(n.properties,l)){const u=bC(e,l,n.properties[l]);if(u){const[c,f]=u;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&aC.has(n.tagName)?s=f:r[c]=f}}if(s){const u=r.style||(r.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return r}function yC(e,n){const r={};for(const s of n.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const u=s.data.estree.body[0];u.type;const c=u.expression;c.type;const f=c.properties[0];f.type,Object.assign(r,e.evaluater.evaluateExpression(f.argument))}else Bl(e,n.position);else{const l=s.name;let u;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,u=e.evaluater.evaluateExpression(f.expression)}else Bl(e,n.position);else u=s.value===null?!0:s.value;r[l]=u}return r}function Yd(e,n){const r=[];let s=-1;const l=e.passKeys?new Map:rC;for(;++s<n.children.length;){const u=n.children[s];let c;if(e.passKeys){const m=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(m){const d=l.get(m)||0;c=m+"-"+d,l.set(m,d+1)}}const f=Fx(e,u,c);f!==void 0&&r.push(f)}return r}function bC(e,n,r){const s=Yk(e.schema,n);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=s.commaSeparated?Mk(r):Xk(r)),s.property==="style"){let l=typeof r=="object"?r:xC(e,String(r));return e.stylePropertyNameCase==="css"&&(l=vC(l)),["style",l]}return[e.elementAttributeNameCase==="react"&&s.space?Ik[s.property]||s.property:s.attribute,r]}}function xC(e,n){try{return tC(n,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};const s=r,l=new fn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=Ix+"#cannot-parse-style-attribute",l}}function Yx(e,n,r){let s;if(!r)s={type:"Literal",value:n};else if(n.includes(".")){const l=n.split(".");let u=-1,c;for(;++u<l.length;){const f=I0(l[u])?{type:"Identifier",name:l[u]}:{type:"Literal",value:l[u]};c=c?{type:"MemberExpression",object:c,property:f,computed:!!(u&&f.type==="Literal"),optional:!1}:f}s=c}else s=I0(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(s.type==="Literal"){const l=s.value;return Fd.call(e.components,l)?e.components[l]:l}if(e.evaluater)return e.evaluater.evaluateExpression(s);Bl(e)}function Bl(e,n){const r=new fn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=Ix+"#cannot-handle-mdx-estrees-without-createevaluater",r}function vC(e){const n={};let r;for(r in e)Fd.call(e,r)&&(n[wC(r)]=e[r]);return n}function wC(e){let n=e.replace(iC,SC);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function SC(e){return"-"+e.toLowerCase()}const Dh={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},_C={};function Gd(e,n){const r=_C,s=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,l=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return Gx(e,s,l)}function Gx(e,n,r){if(EC(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Z0(e.children,n,r)}return Array.isArray(e)?Z0(e,n,r):""}function Z0(e,n,r){const s=[];let l=-1;for(;++l<e.length;)s[l]=Gx(e[l],n,r);return s.join("")}function EC(e){return!!(e&&typeof e=="object")}const W0=document.createElement("i");function Vd(e){const n="&"+e+";";W0.innerHTML=n;const r=W0.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===n?!1:r}function In(e,n,r,s){const l=e.length;let u=0,c;if(n<0?n=-n>l?0:l+n:n=n>l?l:n,r=r>0?r:0,s.length<1e4)c=Array.from(s),c.unshift(n,r),e.splice(...c);else for(r&&e.splice(n,r);u<s.length;)c=s.slice(u,u+1e4),c.unshift(n,0),e.splice(...c),u+=1e4,n+=1e4}function rr(e,n){return e.length>0?(In(e,e.length,0,n),e):n}const eb={}.hasOwnProperty;function Vx(e){const n={};let r=-1;for(;++r<e.length;)kC(n,e[r]);return n}function kC(e,n){let r;for(r in n){const l=(eb.call(e,r)?e[r]:void 0)||(e[r]={}),u=n[r];let c;if(u)for(c in u){eb.call(l,c)||(l[c]=[]);const f=u[c];CC(l[c],Array.isArray(f)?f:f?[f]:[])}}}function CC(e,n){let r=-1;const s=[];for(;++r<n.length;)(n[r].add==="after"?e:s).push(n[r]);In(e,0,0,s)}function Jx(e,n){const r=Number.parseInt(e,n);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function mr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const gn=Hi(/[A-Za-z]/),cn=Hi(/[\dA-Za-z]/),AC=Hi(/[#-'*+\--9=?A-Z^-~]/);function Bu(e){return e!==null&&(e<32||e===127)}const yd=Hi(/\d/),TC=Hi(/[\dA-Fa-f]/),jC=Hi(/[!-/:-@[-`{-~]/);function Pe(e){return e!==null&&e<-2}function Tt(e){return e!==null&&(e<0||e===32)}function Qe(e){return e===-2||e===-1||e===32}const Xu=Hi(new RegExp("\\p{P}|\\p{S}","u")),ds=Hi(/\s/);function Hi(e){return n;function n(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function Sa(e){const n=[];let r=-1,s=0,l=0;for(;++r<e.length;){const u=e.charCodeAt(r);let c="";if(u===37&&cn(e.charCodeAt(r+1))&&cn(e.charCodeAt(r+2)))l=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(c=String.fromCharCode(u));else if(u>55295&&u<57344){const f=e.charCodeAt(r+1);u<56320&&f>56319&&f<57344?(c=String.fromCharCode(u,f),l=1):c="�"}else c=String.fromCharCode(u);c&&(n.push(e.slice(s,r),encodeURIComponent(c)),s=r+l+1,c=""),l&&(r+=l,l=0)}return n.join("")+e.slice(s)}function it(e,n,r,s){const l=s?s-1:Number.POSITIVE_INFINITY;let u=0;return c;function c(m){return Qe(m)?(e.enter(r),f(m)):n(m)}function f(m){return Qe(m)&&u++<l?(e.consume(m),f):(e.exit(r),n(m))}}const NC={tokenize:OC};function OC(e){const n=e.attempt(this.parser.constructs.contentInitial,s,l);let r;return n;function s(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),it(e,n,"linePrefix")}function l(f){return e.enter("paragraph"),u(f)}function u(f){const m=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=m),r=m,c(f)}function c(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return Pe(f)?(e.consume(f),e.exit("chunkText"),u):(e.consume(f),c)}}const RC={tokenize:MC},tb={tokenize:DC};function MC(e){const n=this,r=[];let s=0,l,u,c;return f;function f(j){if(s<r.length){const K=r[s];return n.containerState=K[1],e.attempt(K[0].continuation,m,d)(j)}return d(j)}function m(j){if(s++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,l&&I();const K=n.events.length;let B=K,R;for(;B--;)if(n.events[B][0]==="exit"&&n.events[B][1].type==="chunkFlow"){R=n.events[B][1].end;break}z(s);let Y=K;for(;Y<n.events.length;)n.events[Y][1].end={...R},Y++;return In(n.events,B+1,0,n.events.slice(K)),n.events.length=Y,d(j)}return f(j)}function d(j){if(s===r.length){if(!l)return x(j);if(l.currentConstruct&&l.currentConstruct.concrete)return E(j);n.interrupt=!!(l.currentConstruct&&!l._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(tb,y,g)(j)}function y(j){return l&&I(),z(s),x(j)}function g(j){return n.parser.lazy[n.now().line]=s!==r.length,c=n.now().offset,E(j)}function x(j){return n.containerState={},e.attempt(tb,w,E)(j)}function w(j){return s++,r.push([n.currentConstruct,n.containerState]),x(j)}function E(j){if(j===null){l&&I(),z(0),e.consume(j);return}return l=l||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:l,contentType:"flow",previous:u}),M(j)}function M(j){if(j===null){P(e.exit("chunkFlow"),!0),z(0),e.consume(j);return}return Pe(j)?(e.consume(j),P(e.exit("chunkFlow")),s=0,n.interrupt=void 0,f):(e.consume(j),M)}function P(j,K){const B=n.sliceStream(j);if(K&&B.push(null),j.previous=u,u&&(u.next=j),u=j,l.defineSkip(j.start),l.write(B),n.parser.lazy[j.start.line]){let R=l.events.length;for(;R--;)if(l.events[R][1].start.offset<c&&(!l.events[R][1].end||l.events[R][1].end.offset>c))return;const Y=n.events.length;let J=Y,F,L;for(;J--;)if(n.events[J][0]==="exit"&&n.events[J][1].type==="chunkFlow"){if(F){L=n.events[J][1].end;break}F=!0}for(z(s),R=Y;R<n.events.length;)n.events[R][1].end={...L},R++;In(n.events,J+1,0,n.events.slice(Y)),n.events.length=R}}function z(j){let K=r.length;for(;K-- >j;){const B=r[K];n.containerState=B[1],B[0].exit.call(n,e)}r.length=j}function I(){l.write([null]),u=void 0,l=void 0,n.containerState._closeFlow=void 0}}function DC(e,n,r){return it(e,e.attempt(this.parser.constructs.document,n,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function pa(e){if(e===null||Tt(e)||ds(e))return 1;if(Xu(e))return 2}function Ku(e,n,r){const s=[];let l=-1;for(;++l<e.length;){const u=e[l].resolveAll;u&&!s.includes(u)&&(n=u(n,r),s.push(u))}return n}const bd={name:"attention",resolveAll:LC,tokenize:zC};function LC(e,n){let r=-1,s,l,u,c,f,m,d,y;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(s=r;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&n.sliceSerialize(e[s][1]).charCodeAt(0)===n.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[s][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;m=e[s][1].end.offset-e[s][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const g={...e[s][1].end},x={...e[r][1].start};nb(g,-m),nb(x,m),c={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[s][1].end}},f={type:m>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:x},u={type:m>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[r][1].start}},l={type:m>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[s][1].end={...c.start},e[r][1].start={...f.end},d=[],e[s][1].end.offset-e[s][1].start.offset&&(d=rr(d,[["enter",e[s][1],n],["exit",e[s][1],n]])),d=rr(d,[["enter",l,n],["enter",c,n],["exit",c,n],["enter",u,n]]),d=rr(d,Ku(n.parser.constructs.insideSpan.null,e.slice(s+1,r),n)),d=rr(d,[["exit",u,n],["enter",f,n],["exit",f,n],["exit",l,n]]),e[r][1].end.offset-e[r][1].start.offset?(y=2,d=rr(d,[["enter",e[r][1],n],["exit",e[r][1],n]])):y=0,In(e,s-1,r-s+3,d),r=s+d.length-y-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function zC(e,n){const r=this.parser.constructs.attentionMarkers.null,s=this.previous,l=pa(s);let u;return c;function c(m){return u=m,e.enter("attentionSequence"),f(m)}function f(m){if(m===u)return e.consume(m),f;const d=e.exit("attentionSequence"),y=pa(m),g=!y||y===2&&l||r.includes(m),x=!l||l===2&&y||r.includes(s);return d._open=!!(u===42?g:g&&(l||!x)),d._close=!!(u===42?x:x&&(y||!g)),n(m)}}function nb(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const UC={name:"autolink",tokenize:BC};function BC(e,n,r){let s=0;return l;function l(w){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),u}function u(w){return gn(w)?(e.consume(w),c):w===64?r(w):d(w)}function c(w){return w===43||w===45||w===46||cn(w)?(s=1,f(w)):d(w)}function f(w){return w===58?(e.consume(w),s=0,m):(w===43||w===45||w===46||cn(w))&&s++<32?(e.consume(w),f):(s=0,d(w))}function m(w){return w===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.exit("autolink"),n):w===null||w===32||w===60||Bu(w)?r(w):(e.consume(w),m)}function d(w){return w===64?(e.consume(w),y):AC(w)?(e.consume(w),d):r(w)}function y(w){return cn(w)?g(w):r(w)}function g(w){return w===46?(e.consume(w),s=0,y):w===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(w),e.exit("autolinkMarker"),e.exit("autolink"),n):x(w)}function x(w){if((w===45||cn(w))&&s++<63){const E=w===45?x:g;return e.consume(w),E}return r(w)}}const Vl={partial:!0,tokenize:PC};function PC(e,n,r){return s;function s(u){return Qe(u)?it(e,l,"linePrefix")(u):l(u)}function l(u){return u===null||Pe(u)?n(u):r(u)}}const Xx={continuation:{tokenize:HC},exit:IC,name:"blockQuote",tokenize:qC};function qC(e,n,r){const s=this;return l;function l(c){if(c===62){const f=s.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),u}return r(c)}function u(c){return Qe(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(c))}}function HC(e,n,r){const s=this;return l;function l(c){return Qe(c)?it(e,u,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):u(c)}function u(c){return e.attempt(Xx,n,r)(c)}}function IC(e){e.exit("blockQuote")}const Kx={name:"characterEscape",tokenize:FC};function FC(e,n,r){return s;function s(u){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(u),e.exit("escapeMarker"),l}function l(u){return jC(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):r(u)}}const Qx={name:"characterReference",tokenize:$C};function $C(e,n,r){const s=this;let l=0,u,c;return f;function f(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),u=31,c=cn,y(g))}function d(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,c=TC,y):(e.enter("characterReferenceValue"),u=7,c=yd,y(g))}function y(g){if(g===59&&l){const x=e.exit("characterReferenceValue");return c===cn&&!Vd(s.sliceSerialize(x))?r(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return c(g)&&l++<u?(e.consume(g),y):r(g)}}const rb={partial:!0,tokenize:GC},ib={concrete:!0,name:"codeFenced",tokenize:YC};function YC(e,n,r){const s=this,l={partial:!0,tokenize:B};let u=0,c=0,f;return m;function m(R){return d(R)}function d(R){const Y=s.events[s.events.length-1];return u=Y&&Y[1].type==="linePrefix"?Y[2].sliceSerialize(Y[1],!0).length:0,f=R,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),y(R)}function y(R){return R===f?(c++,e.consume(R),y):c<3?r(R):(e.exit("codeFencedFenceSequence"),Qe(R)?it(e,g,"whitespace")(R):g(R))}function g(R){return R===null||Pe(R)?(e.exit("codeFencedFence"),s.interrupt?n(R):e.check(rb,M,K)(R)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(R))}function x(R){return R===null||Pe(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(R)):Qe(R)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),it(e,w,"whitespace")(R)):R===96&&R===f?r(R):(e.consume(R),x)}function w(R){return R===null||Pe(R)?g(R):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),E(R))}function E(R){return R===null||Pe(R)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(R)):R===96&&R===f?r(R):(e.consume(R),E)}function M(R){return e.attempt(l,K,P)(R)}function P(R){return e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),z}function z(R){return u>0&&Qe(R)?it(e,I,"linePrefix",u+1)(R):I(R)}function I(R){return R===null||Pe(R)?e.check(rb,M,K)(R):(e.enter("codeFlowValue"),j(R))}function j(R){return R===null||Pe(R)?(e.exit("codeFlowValue"),I(R)):(e.consume(R),j)}function K(R){return e.exit("codeFenced"),n(R)}function B(R,Y,J){let F=0;return L;function L(G){return R.enter("lineEnding"),R.consume(G),R.exit("lineEnding"),W}function W(G){return R.enter("codeFencedFence"),Qe(G)?it(R,Q,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(G):Q(G)}function Q(G){return G===f?(R.enter("codeFencedFenceSequence"),oe(G)):J(G)}function oe(G){return G===f?(F++,R.consume(G),oe):F>=c?(R.exit("codeFencedFenceSequence"),Qe(G)?it(R,ae,"whitespace")(G):ae(G)):J(G)}function ae(G){return G===null||Pe(G)?(R.exit("codeFencedFence"),Y(G)):J(G)}}}function GC(e,n,r){const s=this;return l;function l(c){return c===null?r(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u)}function u(c){return s.parser.lazy[s.now().line]?r(c):n(c)}}const Lh={name:"codeIndented",tokenize:JC},VC={partial:!0,tokenize:XC};function JC(e,n,r){const s=this;return l;function l(d){return e.enter("codeIndented"),it(e,u,"linePrefix",5)(d)}function u(d){const y=s.events[s.events.length-1];return y&&y[1].type==="linePrefix"&&y[2].sliceSerialize(y[1],!0).length>=4?c(d):r(d)}function c(d){return d===null?m(d):Pe(d)?e.attempt(VC,c,m)(d):(e.enter("codeFlowValue"),f(d))}function f(d){return d===null||Pe(d)?(e.exit("codeFlowValue"),c(d)):(e.consume(d),f)}function m(d){return e.exit("codeIndented"),n(d)}}function XC(e,n,r){const s=this;return l;function l(c){return s.parser.lazy[s.now().line]?r(c):Pe(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):it(e,u,"linePrefix",5)(c)}function u(c){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?n(c):Pe(c)?l(c):r(c)}}const KC={name:"codeText",previous:ZC,resolve:QC,tokenize:WC};function QC(e){let n=e.length-4,r=3,s,l;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(s=r;++s<n;)if(e[s][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[n][1].type="codeTextPadding",r+=2,n-=2;break}}for(s=r-1,n++;++s<=n;)l===void 0?s!==n&&e[s][1].type!=="lineEnding"&&(l=s):(s===n||e[s][1].type==="lineEnding")&&(e[l][1].type="codeTextData",s!==l+2&&(e[l][1].end=e[s-1][1].end,e.splice(l+2,s-l-2),n-=s-l-2,s=l+2),l=void 0);return e}function ZC(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function WC(e,n,r){let s=0,l,u;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),f(g)}function f(g){return g===96?(e.consume(g),s++,f):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?r(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(u=e.enter("codeTextSequence"),l=0,y(g)):Pe(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),d(g))}function d(g){return g===null||g===32||g===96||Pe(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),d)}function y(g){return g===96?(e.consume(g),l++,y):l===s?(e.exit("codeTextSequence"),e.exit("codeText"),n(g)):(u.type="codeTextData",d(g))}}class eA{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,r){const s=r??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(n,s):n>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(n,r,s){const l=r||0;this.setCursor(Math.trunc(n));const u=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return s&&vl(this.left,s),u.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),vl(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),vl(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){const r=this.left.splice(n,Number.POSITIVE_INFINITY);vl(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);vl(this.left,r.reverse())}}}function vl(e,n){let r=0;if(n.length<1e4)e.push(...n);else for(;r<n.length;)e.push(...n.slice(r,r+1e4)),r+=1e4}function Zx(e){const n={};let r=-1,s,l,u,c,f,m,d;const y=new eA(e);for(;++r<y.length;){for(;r in n;)r=n[r];if(s=y.get(r),r&&s[1].type==="chunkFlow"&&y.get(r-1)[1].type==="listItemPrefix"&&(m=s[1]._tokenizer.events,u=0,u<m.length&&m[u][1].type==="lineEndingBlank"&&(u+=2),u<m.length&&m[u][1].type==="content"))for(;++u<m.length&&m[u][1].type!=="content";)m[u][1].type==="chunkText"&&(m[u][1]._isInFirstContentOfListItem=!0,u++);if(s[0]==="enter")s[1].contentType&&(Object.assign(n,tA(y,r)),r=n[r],d=!0);else if(s[1]._container){for(u=r,l=void 0;u--;)if(c=y.get(u),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(l&&(y.get(l)[1].type="lineEndingBlank"),c[1].type="lineEnding",l=u);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;l&&(s[1].end={...y.get(l)[1].start},f=y.slice(l,r),f.unshift(s),y.splice(l,r-l+1,f))}}return In(e,0,Number.POSITIVE_INFINITY,y.slice(0)),!d}function tA(e,n){const r=e.get(n)[1],s=e.get(n)[2];let l=n-1;const u=[];let c=r._tokenizer;c||(c=s.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const f=c.events,m=[],d={};let y,g,x=-1,w=r,E=0,M=0;const P=[M];for(;w;){for(;e.get(++l)[1]!==w;);u.push(l),w._tokenizer||(y=s.sliceStream(w),w.next||y.push(null),g&&c.defineSkip(w.start),w._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(y),w._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=w,w=w.next}for(w=r;++x<f.length;)f[x][0]==="exit"&&f[x-1][0]==="enter"&&f[x][1].type===f[x-1][1].type&&f[x][1].start.line!==f[x][1].end.line&&(M=x+1,P.push(M),w._tokenizer=void 0,w.previous=void 0,w=w.next);for(c.events=[],w?(w._tokenizer=void 0,w.previous=void 0):P.pop(),x=P.length;x--;){const z=f.slice(P[x],P[x+1]),I=u.pop();m.push([I,I+z.length-1]),e.splice(I,2,z)}for(m.reverse(),x=-1;++x<m.length;)d[E+m[x][0]]=E+m[x][1],E+=m[x][1]-m[x][0]-1;return d}const nA={resolve:iA,tokenize:sA},rA={partial:!0,tokenize:aA};function iA(e){return Zx(e),e}function sA(e,n){let r;return s;function s(f){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),l(f)}function l(f){return f===null?u(f):Pe(f)?e.check(rA,c,u)(f):(e.consume(f),l)}function u(f){return e.exit("chunkContent"),e.exit("content"),n(f)}function c(f){return e.consume(f),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,l}}function aA(e,n,r){const s=this;return l;function l(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),it(e,u,"linePrefix")}function u(c){if(c===null||Pe(c))return r(c);const f=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?n(c):e.interrupt(s.parser.constructs.flow,r,n)(c)}}function Wx(e,n,r,s,l,u,c,f,m){const d=m||Number.POSITIVE_INFINITY;let y=0;return g;function g(z){return z===60?(e.enter(s),e.enter(l),e.enter(u),e.consume(z),e.exit(u),x):z===null||z===32||z===41||Bu(z)?r(z):(e.enter(s),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),M(z))}function x(z){return z===62?(e.enter(u),e.consume(z),e.exit(u),e.exit(l),e.exit(s),n):(e.enter(f),e.enter("chunkString",{contentType:"string"}),w(z))}function w(z){return z===62?(e.exit("chunkString"),e.exit(f),x(z)):z===null||z===60||Pe(z)?r(z):(e.consume(z),z===92?E:w)}function E(z){return z===60||z===62||z===92?(e.consume(z),w):w(z)}function M(z){return!y&&(z===null||z===41||Tt(z))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(s),n(z)):y<d&&z===40?(e.consume(z),y++,M):z===41?(e.consume(z),y--,M):z===null||z===32||z===40||Bu(z)?r(z):(e.consume(z),z===92?P:M)}function P(z){return z===40||z===41||z===92?(e.consume(z),M):M(z)}}function e1(e,n,r,s,l,u){const c=this;let f=0,m;return d;function d(w){return e.enter(s),e.enter(l),e.consume(w),e.exit(l),e.enter(u),y}function y(w){return f>999||w===null||w===91||w===93&&!m||w===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?r(w):w===93?(e.exit(u),e.enter(l),e.consume(w),e.exit(l),e.exit(s),n):Pe(w)?(e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),y):(e.enter("chunkString",{contentType:"string"}),g(w))}function g(w){return w===null||w===91||w===93||Pe(w)||f++>999?(e.exit("chunkString"),y(w)):(e.consume(w),m||(m=!Qe(w)),w===92?x:g)}function x(w){return w===91||w===92||w===93?(e.consume(w),f++,g):g(w)}}function t1(e,n,r,s,l,u){let c;return f;function f(x){return x===34||x===39||x===40?(e.enter(s),e.enter(l),e.consume(x),e.exit(l),c=x===40?41:x,m):r(x)}function m(x){return x===c?(e.enter(l),e.consume(x),e.exit(l),e.exit(s),n):(e.enter(u),d(x))}function d(x){return x===c?(e.exit(u),m(c)):x===null?r(x):Pe(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),it(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),y(x))}function y(x){return x===c||x===null||Pe(x)?(e.exit("chunkString"),d(x)):(e.consume(x),x===92?g:y)}function g(x){return x===c||x===92?(e.consume(x),y):y(x)}}function Ol(e,n){let r;return s;function s(l){return Pe(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),r=!0,s):Qe(l)?it(e,s,r?"linePrefix":"lineSuffix")(l):n(l)}}const lA={name:"definition",tokenize:uA},oA={partial:!0,tokenize:cA};function uA(e,n,r){const s=this;let l;return u;function u(w){return e.enter("definition"),c(w)}function c(w){return e1.call(s,e,f,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(w)}function f(w){return l=mr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),m):r(w)}function m(w){return Tt(w)?Ol(e,d)(w):d(w)}function d(w){return Wx(e,y,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(w)}function y(w){return e.attempt(oA,g,g)(w)}function g(w){return Qe(w)?it(e,x,"whitespace")(w):x(w)}function x(w){return w===null||Pe(w)?(e.exit("definition"),s.parser.defined.push(l),n(w)):r(w)}}function cA(e,n,r){return s;function s(f){return Tt(f)?Ol(e,l)(f):r(f)}function l(f){return t1(e,u,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function u(f){return Qe(f)?it(e,c,"whitespace")(f):c(f)}function c(f){return f===null||Pe(f)?n(f):r(f)}}const fA={name:"hardBreakEscape",tokenize:hA};function hA(e,n,r){return s;function s(u){return e.enter("hardBreakEscape"),e.consume(u),l}function l(u){return Pe(u)?(e.exit("hardBreakEscape"),n(u)):r(u)}}const dA={name:"headingAtx",resolve:mA,tokenize:pA};function mA(e,n){let r=e.length-2,s=3,l,u;return e[s][1].type==="whitespace"&&(s+=2),r-2>s&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(s===r-1||r-4>s&&e[r-2][1].type==="whitespace")&&(r-=s+1===r?2:4),r>s&&(l={type:"atxHeadingText",start:e[s][1].start,end:e[r][1].end},u={type:"chunkText",start:e[s][1].start,end:e[r][1].end,contentType:"text"},In(e,s,r-s+1,[["enter",l,n],["enter",u,n],["exit",u,n],["exit",l,n]])),e}function pA(e,n,r){let s=0;return l;function l(y){return e.enter("atxHeading"),u(y)}function u(y){return e.enter("atxHeadingSequence"),c(y)}function c(y){return y===35&&s++<6?(e.consume(y),c):y===null||Tt(y)?(e.exit("atxHeadingSequence"),f(y)):r(y)}function f(y){return y===35?(e.enter("atxHeadingSequence"),m(y)):y===null||Pe(y)?(e.exit("atxHeading"),n(y)):Qe(y)?it(e,f,"whitespace")(y):(e.enter("atxHeadingText"),d(y))}function m(y){return y===35?(e.consume(y),m):(e.exit("atxHeadingSequence"),f(y))}function d(y){return y===null||y===35||Tt(y)?(e.exit("atxHeadingText"),f(y)):(e.consume(y),d)}}const gA=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],sb=["pre","script","style","textarea"],yA={concrete:!0,name:"htmlFlow",resolveTo:vA,tokenize:wA},bA={partial:!0,tokenize:_A},xA={partial:!0,tokenize:SA};function vA(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function wA(e,n,r){const s=this;let l,u,c,f,m;return d;function d(A){return y(A)}function y(A){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(A),g}function g(A){return A===33?(e.consume(A),x):A===47?(e.consume(A),u=!0,M):A===63?(e.consume(A),l=3,s.interrupt?n:_):gn(A)?(e.consume(A),c=String.fromCharCode(A),P):r(A)}function x(A){return A===45?(e.consume(A),l=2,w):A===91?(e.consume(A),l=5,f=0,E):gn(A)?(e.consume(A),l=4,s.interrupt?n:_):r(A)}function w(A){return A===45?(e.consume(A),s.interrupt?n:_):r(A)}function E(A){const ve="CDATA[";return A===ve.charCodeAt(f++)?(e.consume(A),f===ve.length?s.interrupt?n:Q:E):r(A)}function M(A){return gn(A)?(e.consume(A),c=String.fromCharCode(A),P):r(A)}function P(A){if(A===null||A===47||A===62||Tt(A)){const ve=A===47,Ae=c.toLowerCase();return!ve&&!u&&sb.includes(Ae)?(l=1,s.interrupt?n(A):Q(A)):gA.includes(c.toLowerCase())?(l=6,ve?(e.consume(A),z):s.interrupt?n(A):Q(A)):(l=7,s.interrupt&&!s.parser.lazy[s.now().line]?r(A):u?I(A):j(A))}return A===45||cn(A)?(e.consume(A),c+=String.fromCharCode(A),P):r(A)}function z(A){return A===62?(e.consume(A),s.interrupt?n:Q):r(A)}function I(A){return Qe(A)?(e.consume(A),I):L(A)}function j(A){return A===47?(e.consume(A),L):A===58||A===95||gn(A)?(e.consume(A),K):Qe(A)?(e.consume(A),j):L(A)}function K(A){return A===45||A===46||A===58||A===95||cn(A)?(e.consume(A),K):B(A)}function B(A){return A===61?(e.consume(A),R):Qe(A)?(e.consume(A),B):j(A)}function R(A){return A===null||A===60||A===61||A===62||A===96?r(A):A===34||A===39?(e.consume(A),m=A,Y):Qe(A)?(e.consume(A),R):J(A)}function Y(A){return A===m?(e.consume(A),m=null,F):A===null||Pe(A)?r(A):(e.consume(A),Y)}function J(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||Tt(A)?B(A):(e.consume(A),J)}function F(A){return A===47||A===62||Qe(A)?j(A):r(A)}function L(A){return A===62?(e.consume(A),W):r(A)}function W(A){return A===null||Pe(A)?Q(A):Qe(A)?(e.consume(A),W):r(A)}function Q(A){return A===45&&l===2?(e.consume(A),H):A===60&&l===1?(e.consume(A),X):A===62&&l===4?(e.consume(A),D):A===63&&l===3?(e.consume(A),_):A===93&&l===5?(e.consume(A),_e):Pe(A)&&(l===6||l===7)?(e.exit("htmlFlowData"),e.check(bA,ee,oe)(A)):A===null||Pe(A)?(e.exit("htmlFlowData"),oe(A)):(e.consume(A),Q)}function oe(A){return e.check(xA,ae,ee)(A)}function ae(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),G}function G(A){return A===null||Pe(A)?oe(A):(e.enter("htmlFlowData"),Q(A))}function H(A){return A===45?(e.consume(A),_):Q(A)}function X(A){return A===47?(e.consume(A),c="",ue):Q(A)}function ue(A){if(A===62){const ve=c.toLowerCase();return sb.includes(ve)?(e.consume(A),D):Q(A)}return gn(A)&&c.length<8?(e.consume(A),c+=String.fromCharCode(A),ue):Q(A)}function _e(A){return A===93?(e.consume(A),_):Q(A)}function _(A){return A===62?(e.consume(A),D):A===45&&l===2?(e.consume(A),_):Q(A)}function D(A){return A===null||Pe(A)?(e.exit("htmlFlowData"),ee(A)):(e.consume(A),D)}function ee(A){return e.exit("htmlFlow"),n(A)}}function SA(e,n,r){const s=this;return l;function l(c){return Pe(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u):r(c)}function u(c){return s.parser.lazy[s.now().line]?r(c):n(c)}}function _A(e,n,r){return s;function s(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),e.attempt(Vl,n,r)}}const EA={name:"htmlText",tokenize:kA};function kA(e,n,r){const s=this;let l,u,c;return f;function f(_){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(_),m}function m(_){return _===33?(e.consume(_),d):_===47?(e.consume(_),B):_===63?(e.consume(_),j):gn(_)?(e.consume(_),J):r(_)}function d(_){return _===45?(e.consume(_),y):_===91?(e.consume(_),u=0,E):gn(_)?(e.consume(_),I):r(_)}function y(_){return _===45?(e.consume(_),w):r(_)}function g(_){return _===null?r(_):_===45?(e.consume(_),x):Pe(_)?(c=g,X(_)):(e.consume(_),g)}function x(_){return _===45?(e.consume(_),w):g(_)}function w(_){return _===62?H(_):_===45?x(_):g(_)}function E(_){const D="CDATA[";return _===D.charCodeAt(u++)?(e.consume(_),u===D.length?M:E):r(_)}function M(_){return _===null?r(_):_===93?(e.consume(_),P):Pe(_)?(c=M,X(_)):(e.consume(_),M)}function P(_){return _===93?(e.consume(_),z):M(_)}function z(_){return _===62?H(_):_===93?(e.consume(_),z):M(_)}function I(_){return _===null||_===62?H(_):Pe(_)?(c=I,X(_)):(e.consume(_),I)}function j(_){return _===null?r(_):_===63?(e.consume(_),K):Pe(_)?(c=j,X(_)):(e.consume(_),j)}function K(_){return _===62?H(_):j(_)}function B(_){return gn(_)?(e.consume(_),R):r(_)}function R(_){return _===45||cn(_)?(e.consume(_),R):Y(_)}function Y(_){return Pe(_)?(c=Y,X(_)):Qe(_)?(e.consume(_),Y):H(_)}function J(_){return _===45||cn(_)?(e.consume(_),J):_===47||_===62||Tt(_)?F(_):r(_)}function F(_){return _===47?(e.consume(_),H):_===58||_===95||gn(_)?(e.consume(_),L):Pe(_)?(c=F,X(_)):Qe(_)?(e.consume(_),F):H(_)}function L(_){return _===45||_===46||_===58||_===95||cn(_)?(e.consume(_),L):W(_)}function W(_){return _===61?(e.consume(_),Q):Pe(_)?(c=W,X(_)):Qe(_)?(e.consume(_),W):F(_)}function Q(_){return _===null||_===60||_===61||_===62||_===96?r(_):_===34||_===39?(e.consume(_),l=_,oe):Pe(_)?(c=Q,X(_)):Qe(_)?(e.consume(_),Q):(e.consume(_),ae)}function oe(_){return _===l?(e.consume(_),l=void 0,G):_===null?r(_):Pe(_)?(c=oe,X(_)):(e.consume(_),oe)}function ae(_){return _===null||_===34||_===39||_===60||_===61||_===96?r(_):_===47||_===62||Tt(_)?F(_):(e.consume(_),ae)}function G(_){return _===47||_===62||Tt(_)?F(_):r(_)}function H(_){return _===62?(e.consume(_),e.exit("htmlTextData"),e.exit("htmlText"),n):r(_)}function X(_){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),ue}function ue(_){return Qe(_)?it(e,_e,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):_e(_)}function _e(_){return e.enter("htmlTextData"),c(_)}}const Jd={name:"labelEnd",resolveAll:jA,resolveTo:NA,tokenize:OA},CA={tokenize:RA},AA={tokenize:MA},TA={tokenize:DA};function jA(e){let n=-1;const r=[];for(;++n<e.length;){const s=e[n][1];if(r.push(e[n]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const l=s.type==="labelImage"?4:2;s.type="data",n+=l}}return e.length!==r.length&&In(e,0,e.length,r),e}function NA(e,n){let r=e.length,s=0,l,u,c,f;for(;r--;)if(l=e[r][1],u){if(l.type==="link"||l.type==="labelLink"&&l._inactive)break;e[r][0]==="enter"&&l.type==="labelLink"&&(l._inactive=!0)}else if(c){if(e[r][0]==="enter"&&(l.type==="labelImage"||l.type==="labelLink")&&!l._balanced&&(u=r,l.type!=="labelLink")){s=2;break}}else l.type==="labelEnd"&&(c=r);const m={type:e[u][1].type==="labelLink"?"link":"image",start:{...e[u][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[u][1].start},end:{...e[c][1].end}},y={type:"labelText",start:{...e[u+s+2][1].end},end:{...e[c-2][1].start}};return f=[["enter",m,n],["enter",d,n]],f=rr(f,e.slice(u+1,u+s+3)),f=rr(f,[["enter",y,n]]),f=rr(f,Ku(n.parser.constructs.insideSpan.null,e.slice(u+s+4,c-3),n)),f=rr(f,[["exit",y,n],e[c-2],e[c-1],["exit",d,n]]),f=rr(f,e.slice(c+1)),f=rr(f,[["exit",m,n]]),In(e,u,e.length,f),e}function OA(e,n,r){const s=this;let l=s.events.length,u,c;for(;l--;)if((s.events[l][1].type==="labelImage"||s.events[l][1].type==="labelLink")&&!s.events[l][1]._balanced){u=s.events[l][1];break}return f;function f(x){return u?u._inactive?g(x):(c=s.parser.defined.includes(mr(s.sliceSerialize({start:u.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),m):r(x)}function m(x){return x===40?e.attempt(CA,y,c?y:g)(x):x===91?e.attempt(AA,y,c?d:g)(x):c?y(x):g(x)}function d(x){return e.attempt(TA,y,g)(x)}function y(x){return n(x)}function g(x){return u._balanced=!0,r(x)}}function RA(e,n,r){return s;function s(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),l}function l(g){return Tt(g)?Ol(e,u)(g):u(g)}function u(g){return g===41?y(g):Wx(e,c,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return Tt(g)?Ol(e,m)(g):y(g)}function f(g){return r(g)}function m(g){return g===34||g===39||g===40?t1(e,d,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):y(g)}function d(g){return Tt(g)?Ol(e,y)(g):y(g)}function y(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),n):r(g)}}function MA(e,n,r){const s=this;return l;function l(f){return e1.call(s,e,u,c,"reference","referenceMarker","referenceString")(f)}function u(f){return s.parser.defined.includes(mr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?n(f):r(f)}function c(f){return r(f)}}function DA(e,n,r){return s;function s(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),l}function l(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),n):r(u)}}const LA={name:"labelStartImage",resolveAll:Jd.resolveAll,tokenize:zA};function zA(e,n,r){const s=this;return l;function l(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),u}function u(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),c):r(f)}function c(f){return f===94&&"_hiddenFootnoteSupport"in s.parser.constructs?r(f):n(f)}}const UA={name:"labelStartLink",resolveAll:Jd.resolveAll,tokenize:BA};function BA(e,n,r){const s=this;return l;function l(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),u}function u(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?r(c):n(c)}}const zh={name:"lineEnding",tokenize:PA};function PA(e,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),it(e,n,"linePrefix")}}const Eu={name:"thematicBreak",tokenize:qA};function qA(e,n,r){let s=0,l;return u;function u(d){return e.enter("thematicBreak"),c(d)}function c(d){return l=d,f(d)}function f(d){return d===l?(e.enter("thematicBreakSequence"),m(d)):s>=3&&(d===null||Pe(d))?(e.exit("thematicBreak"),n(d)):r(d)}function m(d){return d===l?(e.consume(d),s++,m):(e.exit("thematicBreakSequence"),Qe(d)?it(e,f,"whitespace")(d):f(d))}}const kn={continuation:{tokenize:$A},exit:GA,name:"list",tokenize:FA},HA={partial:!0,tokenize:VA},IA={partial:!0,tokenize:YA};function FA(e,n,r){const s=this,l=s.events[s.events.length-1];let u=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,c=0;return f;function f(w){const E=s.containerState.type||(w===42||w===43||w===45?"listUnordered":"listOrdered");if(E==="listUnordered"?!s.containerState.marker||w===s.containerState.marker:yd(w)){if(s.containerState.type||(s.containerState.type=E,e.enter(E,{_container:!0})),E==="listUnordered")return e.enter("listItemPrefix"),w===42||w===45?e.check(Eu,r,d)(w):d(w);if(!s.interrupt||w===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(w)}return r(w)}function m(w){return yd(w)&&++c<10?(e.consume(w),m):(!s.interrupt||c<2)&&(s.containerState.marker?w===s.containerState.marker:w===41||w===46)?(e.exit("listItemValue"),d(w)):r(w)}function d(w){return e.enter("listItemMarker"),e.consume(w),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||w,e.check(Vl,s.interrupt?r:y,e.attempt(HA,x,g))}function y(w){return s.containerState.initialBlankLine=!0,u++,x(w)}function g(w){return Qe(w)?(e.enter("listItemPrefixWhitespace"),e.consume(w),e.exit("listItemPrefixWhitespace"),x):r(w)}function x(w){return s.containerState.size=u+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(w)}}function $A(e,n,r){const s=this;return s.containerState._closeFlow=void 0,e.check(Vl,l,u);function l(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,it(e,n,"listItemIndent",s.containerState.size+1)(f)}function u(f){return s.containerState.furtherBlankLines||!Qe(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(IA,n,c)(f))}function c(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,it(e,e.attempt(kn,n,r),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function YA(e,n,r){const s=this;return it(e,l,"listItemIndent",s.containerState.size+1);function l(u){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?n(u):r(u)}}function GA(e){e.exit(this.containerState.type)}function VA(e,n,r){const s=this;return it(e,l,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(u){const c=s.events[s.events.length-1];return!Qe(u)&&c&&c[1].type==="listItemPrefixWhitespace"?n(u):r(u)}}const ab={name:"setextUnderline",resolveTo:JA,tokenize:XA};function JA(e,n){let r=e.length,s,l,u;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){s=r;break}e[r][1].type==="paragraph"&&(l=r)}else e[r][1].type==="content"&&e.splice(r,1),!u&&e[r][1].type==="definition"&&(u=r);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[l][1].type="setextHeadingText",u?(e.splice(l,0,["enter",c,n]),e.splice(u+1,0,["exit",e[s][1],n]),e[s][1].end={...e[u][1].end}):e[s][1]=c,e.push(["exit",c,n]),e}function XA(e,n,r){const s=this;let l;return u;function u(d){let y=s.events.length,g;for(;y--;)if(s.events[y][1].type!=="lineEnding"&&s.events[y][1].type!=="linePrefix"&&s.events[y][1].type!=="content"){g=s.events[y][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||g)?(e.enter("setextHeadingLine"),l=d,c(d)):r(d)}function c(d){return e.enter("setextHeadingLineSequence"),f(d)}function f(d){return d===l?(e.consume(d),f):(e.exit("setextHeadingLineSequence"),Qe(d)?it(e,m,"lineSuffix")(d):m(d))}function m(d){return d===null||Pe(d)?(e.exit("setextHeadingLine"),n(d)):r(d)}}const KA={tokenize:QA};function QA(e){const n=this,r=e.attempt(Vl,s,e.attempt(this.parser.constructs.flowInitial,l,it(e,e.attempt(this.parser.constructs.flow,l,e.attempt(nA,l)),"linePrefix")));return r;function s(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),n.currentConstruct=void 0,r}function l(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),n.currentConstruct=void 0,r}}const ZA={resolveAll:r1()},WA=n1("string"),eT=n1("text");function n1(e){return{resolveAll:r1(e==="text"?tT:void 0),tokenize:n};function n(r){const s=this,l=this.parser.constructs[e],u=r.attempt(l,c,f);return c;function c(y){return d(y)?u(y):f(y)}function f(y){if(y===null){r.consume(y);return}return r.enter("data"),r.consume(y),m}function m(y){return d(y)?(r.exit("data"),u(y)):(r.consume(y),m)}function d(y){if(y===null)return!0;const g=l[y];let x=-1;if(g)for(;++x<g.length;){const w=g[x];if(!w.previous||w.previous.call(s,s.previous))return!0}return!1}}}function r1(e){return n;function n(r,s){let l=-1,u;for(;++l<=r.length;)u===void 0?r[l]&&r[l][1].type==="data"&&(u=l,l++):(!r[l]||r[l][1].type!=="data")&&(l!==u+2&&(r[u][1].end=r[l-1][1].end,r.splice(u+2,l-u-2),l=u+2),u=void 0);return e?e(r,s):r}}function tT(e,n){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const s=e[r-1][1],l=n.sliceStream(s);let u=l.length,c=-1,f=0,m;for(;u--;){const d=l[u];if(typeof d=="string"){for(c=d.length;d.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-1}else if(d===-2)m=!0,f++;else if(d!==-1){u++;break}}if(n._contentTypeTextTrailing&&r===e.length&&(f=0),f){const d={type:r===e.length||m||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?c:s.start._bufferIndex+c,_index:s.start._index+u,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...d.start},s.start.offset===s.end.offset?Object.assign(s,d):(e.splice(r,0,["enter",d,n],["exit",d,n]),r+=2)}r++}return e}const nT={42:kn,43:kn,45:kn,48:kn,49:kn,50:kn,51:kn,52:kn,53:kn,54:kn,55:kn,56:kn,57:kn,62:Xx},rT={91:lA},iT={[-2]:Lh,[-1]:Lh,32:Lh},sT={35:dA,42:Eu,45:[ab,Eu],60:yA,61:ab,95:Eu,96:ib,126:ib},aT={38:Qx,92:Kx},lT={[-5]:zh,[-4]:zh,[-3]:zh,33:LA,38:Qx,42:bd,60:[UC,EA],91:UA,92:[fA,Kx],93:Jd,95:bd,96:KC},oT={null:[bd,ZA]},uT={null:[42,95]},cT={null:[]},fT=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:uT,contentInitial:rT,disable:cT,document:nT,flow:sT,flowInitial:iT,insideSpan:oT,string:aT,text:lT},Symbol.toStringTag,{value:"Module"}));function hT(e,n,r){let s={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const l={},u=[];let c=[],f=[];const m={attempt:Y(B),check:Y(R),consume:I,enter:j,exit:K,interrupt:Y(R,{interrupt:!0})},d={code:null,containerState:{},defineSkip:M,events:[],now:E,parser:e,previous:null,sliceSerialize:x,sliceStream:w,write:g};let y=n.tokenize.call(d,m);return n.resolveAll&&u.push(n),d;function g(W){return c=rr(c,W),P(),c[c.length-1]!==null?[]:(J(n,0),d.events=Ku(u,d.events,d),d.events)}function x(W,Q){return mT(w(W),Q)}function w(W){return dT(c,W)}function E(){const{_bufferIndex:W,_index:Q,line:oe,column:ae,offset:G}=s;return{_bufferIndex:W,_index:Q,line:oe,column:ae,offset:G}}function M(W){l[W.line]=W.column,L()}function P(){let W;for(;s._index<c.length;){const Q=c[s._index];if(typeof Q=="string")for(W=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===W&&s._bufferIndex<Q.length;)z(Q.charCodeAt(s._bufferIndex));else z(Q)}}function z(W){y=y(W)}function I(W){Pe(W)?(s.line++,s.column=1,s.offset+=W===-3?2:1,L()):W!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),d.previous=W}function j(W,Q){const oe=Q||{};return oe.type=W,oe.start=E(),d.events.push(["enter",oe,d]),f.push(oe),oe}function K(W){const Q=f.pop();return Q.end=E(),d.events.push(["exit",Q,d]),Q}function B(W,Q){J(W,Q.from)}function R(W,Q){Q.restore()}function Y(W,Q){return oe;function oe(ae,G,H){let X,ue,_e,_;return Array.isArray(ae)?ee(ae):"tokenize"in ae?ee([ae]):D(ae);function D(Te){return Me;function Me(He){const be=He!==null&&Te[He],De=He!==null&&Te.null,Ze=[...Array.isArray(be)?be:be?[be]:[],...Array.isArray(De)?De:De?[De]:[]];return ee(Ze)(He)}}function ee(Te){return X=Te,ue=0,Te.length===0?H:A(Te[ue])}function A(Te){return Me;function Me(He){return _=F(),_e=Te,Te.partial||(d.currentConstruct=Te),Te.name&&d.parser.constructs.disable.null.includes(Te.name)?Ae():Te.tokenize.call(Q?Object.assign(Object.create(d),Q):d,m,ve,Ae)(He)}}function ve(Te){return W(_e,_),G}function Ae(Te){return _.restore(),++ue<X.length?A(X[ue]):H}}}function J(W,Q){W.resolveAll&&!u.includes(W)&&u.push(W),W.resolve&&In(d.events,Q,d.events.length-Q,W.resolve(d.events.slice(Q),d)),W.resolveTo&&(d.events=W.resolveTo(d.events,d))}function F(){const W=E(),Q=d.previous,oe=d.currentConstruct,ae=d.events.length,G=Array.from(f);return{from:ae,restore:H};function H(){s=W,d.previous=Q,d.currentConstruct=oe,d.events.length=ae,f=G,L()}}function L(){s.line in l&&s.column<2&&(s.column=l[s.line],s.offset+=l[s.line]-1)}}function dT(e,n){const r=n.start._index,s=n.start._bufferIndex,l=n.end._index,u=n.end._bufferIndex;let c;if(r===l)c=[e[r].slice(s,u)];else{if(c=e.slice(r,l),s>-1){const f=c[0];typeof f=="string"?c[0]=f.slice(s):c.shift()}u>0&&c.push(e[l].slice(0,u))}return c}function mT(e,n){let r=-1;const s=[];let l;for(;++r<e.length;){const u=e[r];let c;if(typeof u=="string")c=u;else switch(u){case-5:{c="\r";break}case-4:{c=`
|
|
@@ -117,4 +117,4 @@ Are you sure you want to continue?`):!0}async function I(){if(!(!P||!z())){g(!0)
|
|
|
117
117
|
`))+1))}const c="#".repeat(l),f=r.enter("headingAtx"),m=r.enter("phrasing");u.move(c+" ");let d=r.containerPhrasing(e,{before:"# ",after:`
|
|
118
118
|
`,...u.current()});return/^[\t ]/.test(d)&&(d=Pl(d.charCodeAt(0))+d.slice(1)),d=d?c+" "+d:c,r.options.closeAtx&&(d+=" "+c),m(),f(),d}v1.peek=FN;function v1(e){return e.value||""}function FN(){return"<"}w1.peek=$N;function w1(e,n,r,s){const l=tm(r),u=l==='"'?"Quote":"Apostrophe",c=r.enter("image");let f=r.enter("label");const m=r.createTracker(s);let d=m.move("![");return d+=m.move(r.safe(e.alt,{before:d,after:"]",...m.current()})),d+=m.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=r.enter("destinationLiteral"),d+=m.move("<"),d+=m.move(r.safe(e.url,{before:d,after:">",...m.current()})),d+=m.move(">")):(f=r.enter("destinationRaw"),d+=m.move(r.safe(e.url,{before:d,after:e.title?" ":")",...m.current()}))),f(),e.title&&(f=r.enter(`title${u}`),d+=m.move(" "+l),d+=m.move(r.safe(e.title,{before:d,after:l,...m.current()})),d+=m.move(l),f()),d+=m.move(")"),c(),d}function $N(){return"!"}S1.peek=YN;function S1(e,n,r,s){const l=e.referenceType,u=r.enter("imageReference");let c=r.enter("label");const f=r.createTracker(s);let m=f.move("![");const d=r.safe(e.alt,{before:m,after:"]",...f.current()});m+=f.move(d+"]["),c();const y=r.stack;r.stack=[],c=r.enter("reference");const g=r.safe(r.associationId(e),{before:m,after:"]",...f.current()});return c(),r.stack=y,u(),l==="full"||!d||d!==g?m+=f.move(g+"]"):l==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function YN(){return"!"}_1.peek=GN;function _1(e,n,r){let s=e.value||"",l="`",u=-1;for(;new RegExp("(^|[^`])"+l+"([^`]|$)").test(s);)l+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++u<r.unsafe.length;){const c=r.unsafe[u],f=r.compilePattern(c);let m;if(c.atBreak)for(;m=f.exec(s);){let d=m.index;s.charCodeAt(d)===10&&s.charCodeAt(d-1)===13&&d--,s=s.slice(0,d)+" "+s.slice(m.index+1)}}return l+s+l}function GN(){return"`"}function E1(e,n){const r=Gd(e);return!!(!n.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(r===e.url||"mailto:"+r===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}k1.peek=VN;function k1(e,n,r,s){const l=tm(r),u=l==='"'?"Quote":"Apostrophe",c=r.createTracker(s);let f,m;if(E1(e,r)){const y=r.stack;r.stack=[],f=r.enter("autolink");let g=c.move("<");return g+=c.move(r.containerPhrasing(e,{before:g,after:">",...c.current()})),g+=c.move(">"),f(),r.stack=y,g}f=r.enter("link"),m=r.enter("label");let d=c.move("[");return d+=c.move(r.containerPhrasing(e,{before:d,after:"](",...c.current()})),d+=c.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=r.enter("destinationLiteral"),d+=c.move("<"),d+=c.move(r.safe(e.url,{before:d,after:">",...c.current()})),d+=c.move(">")):(m=r.enter("destinationRaw"),d+=c.move(r.safe(e.url,{before:d,after:e.title?" ":")",...c.current()}))),m(),e.title&&(m=r.enter(`title${u}`),d+=c.move(" "+l),d+=c.move(r.safe(e.title,{before:d,after:l,...c.current()})),d+=c.move(l),m()),d+=c.move(")"),f(),d}function VN(e,n,r){return E1(e,r)?"<":"["}C1.peek=JN;function C1(e,n,r,s){const l=e.referenceType,u=r.enter("linkReference");let c=r.enter("label");const f=r.createTracker(s);let m=f.move("[");const d=r.containerPhrasing(e,{before:m,after:"]",...f.current()});m+=f.move(d+"]["),c();const y=r.stack;r.stack=[],c=r.enter("reference");const g=r.safe(r.associationId(e),{before:m,after:"]",...f.current()});return c(),r.stack=y,u(),l==="full"||!d||d!==g?m+=f.move(g+"]"):l==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function JN(){return"["}function nm(e){const n=e.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function XN(e){const n=nm(e),r=e.options.bulletOther;if(!r)return n==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+r+"`) to be different");return r}function KN(e){const n=e.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function A1(e){const n=e.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function QN(e,n,r,s){const l=r.enter("list"),u=r.bulletCurrent;let c=e.ordered?KN(r):nm(r);const f=e.ordered?c==="."?")":".":XN(r);let m=n&&r.bulletLastUsed?c===r.bulletLastUsed:!1;if(!e.ordered){const y=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&y&&(!y.children||!y.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(m=!0),A1(r)===c&&y){let g=-1;for(;++g<e.children.length;){const x=e.children[g];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(c=f),r.bulletCurrent=c;const d=r.containerFlow(e,s);return r.bulletLastUsed=c,r.bulletCurrent=u,l(),d}function ZN(e){const n=e.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function WN(e,n,r,s){const l=ZN(r);let u=r.bulletCurrent||nm(r);n&&n.type==="list"&&n.ordered&&(u=(typeof n.start=="number"&&n.start>-1?n.start:1)+(r.options.incrementListMarker===!1?0:n.children.indexOf(e))+u);let c=u.length+1;(l==="tab"||l==="mixed"&&(n&&n.type==="list"&&n.spread||e.spread))&&(c=Math.ceil(c/4)*4);const f=r.createTracker(s);f.move(u+" ".repeat(c-u.length)),f.shift(c);const m=r.enter("listItem"),d=r.indentLines(r.containerFlow(e,f.current()),y);return m(),d;function y(g,x,w){return x?(w?"":" ".repeat(c))+g:(w?u:u+" ".repeat(c-u.length))+g}}function e3(e,n,r,s){const l=r.enter("paragraph"),u=r.enter("phrasing"),c=r.containerPhrasing(e,s);return u(),l(),c}const t3=Zu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function n3(e,n,r,s){return(e.children.some(function(c){return t3(c)})?r.containerPhrasing:r.containerFlow).call(r,e,s)}function r3(e){const n=e.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}T1.peek=i3;function T1(e,n,r,s){const l=r3(r),u=r.enter("strong"),c=r.createTracker(s),f=c.move(l+l);let m=c.move(r.containerPhrasing(e,{after:l,before:f,...c.current()}));const d=m.charCodeAt(0),y=Hu(s.before.charCodeAt(s.before.length-1),d,l);y.inside&&(m=Pl(d)+m.slice(1));const g=m.charCodeAt(m.length-1),x=Hu(s.after.charCodeAt(0),g,l);x.inside&&(m=m.slice(0,-1)+Pl(g));const w=c.move(l+l);return u(),r.attentionEncodeSurroundingInfo={after:x.outside,before:y.outside},f+m+w}function i3(e,n,r){return r.options.strong||"*"}function s3(e,n,r,s){return r.safe(e.value,s)}function a3(e){const n=e.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function l3(e,n,r){const s=(A1(r)+(r.options.ruleSpaces?" ":"")).repeat(a3(r));return r.options.ruleSpaces?s.slice(0,-1):s}const j1={blockquote:NN,break:Tb,code:zN,definition:BN,emphasis:x1,hardBreak:Tb,heading:IN,html:v1,image:w1,imageReference:S1,inlineCode:_1,link:k1,linkReference:C1,list:QN,listItem:WN,paragraph:e3,root:n3,strong:T1,text:s3,thematicBreak:l3};function o3(){return{enter:{table:u3,tableData:jb,tableHeader:jb,tableRow:f3},exit:{codeText:h3,table:c3,tableData:Jh,tableHeader:Jh,tableRow:Jh}}}function u3(e){const n=e._align;this.enter({type:"table",align:n.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function c3(e){this.exit(e),this.data.inTable=void 0}function f3(e){this.enter({type:"tableRow",children:[]},e)}function Jh(e){this.exit(e)}function jb(e){this.enter({type:"tableCell",children:[]},e)}function h3(e){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,d3));const r=this.stack[this.stack.length-1];r.type,r.value=n,this.exit(e)}function d3(e,n){return n==="|"?n:e}function m3(e){const n=e||{},r=n.tableCellPadding,s=n.tablePipeAlign,l=n.stringLength,u=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
119
119
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:c,tableCell:m,tableRow:f}};function c(w,E,M,P){return d(y(w,M,P),w.align)}function f(w,E,M,P){const z=g(w,M,P),I=d([z]);return I.slice(0,I.indexOf(`
|
|
120
|
-
`))}function m(w,E,M,P){const z=M.enter("tableCell"),I=M.enter("phrasing"),j=M.containerPhrasing(w,{...P,before:u,after:u});return I(),z(),j}function d(w,E){return TN(w,{align:E,alignDelimiters:s,padding:r,stringLength:l})}function y(w,E,M){const P=w.children;let z=-1;const I=[],j=E.enter("table");for(;++z<P.length;)I[z]=g(P[z],E,M);return j(),I}function g(w,E,M){const P=w.children;let z=-1;const I=[],j=E.enter("tableRow");for(;++z<P.length;)I[z]=m(P[z],w,E,M);return j(),I}function x(w,E,M){let P=j1.inlineCode(w,E,M);return M.stack.includes("tableCell")&&(P=P.replace(/\|/g,"\\$&")),P}}function p3(){return{exit:{taskListCheckValueChecked:Nb,taskListCheckValueUnchecked:Nb,paragraph:y3}}}function g3(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:b3}}}function Nb(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function y3(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const s=r.children[0];if(s&&s.type==="text"){const l=n.children;let u=-1,c;for(;++u<l.length;){const f=l[u];if(f.type==="paragraph"){c=f;break}}c===r&&(s.value=s.value.slice(1),s.value.length===0?r.children.shift():r.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,r.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function b3(e,n,r,s){const l=e.children[0],u=typeof e.checked=="boolean"&&l&&l.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",f=r.createTracker(s);u&&f.move(c);let m=j1.listItem(e,n,r,{...s,...f.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),m;function d(y){return y+c}}function x3(){return[Qj(),bN(),SN(),o3(),p3()]}function v3(e){return{extensions:[Zj(),xN(e),_N(),m3(e),g3()]}}const w3={tokenize:A3,partial:!0},N1={tokenize:T3,partial:!0},O1={tokenize:j3,partial:!0},R1={tokenize:N3,partial:!0},S3={tokenize:O3,partial:!0},M1={name:"wwwAutolink",tokenize:k3,previous:L1},D1={name:"protocolAutolink",tokenize:C3,previous:z1},ni={name:"emailAutolink",tokenize:E3,previous:U1},jr={};function _3(){return{text:jr}}let cs=48;for(;cs<123;)jr[cs]=ni,cs++,cs===58?cs=65:cs===91&&(cs=97);jr[43]=ni;jr[45]=ni;jr[46]=ni;jr[95]=ni;jr[72]=[ni,D1];jr[104]=[ni,D1];jr[87]=[ni,M1];jr[119]=[ni,M1];function E3(e,n,r){const s=this;let l,u;return c;function c(g){return!_d(g)||!U1.call(s,s.previous)||rm(s.events)?r(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return _d(g)?(e.consume(g),f):g===64?(e.consume(g),m):r(g)}function m(g){return g===46?e.check(S3,y,d)(g):g===45||g===95||cn(g)?(u=!0,e.consume(g),m):y(g)}function d(g){return e.consume(g),l=!0,m}function y(g){return u&&l&&gn(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(g)):r(g)}}function k3(e,n,r){const s=this;return l;function l(c){return c!==87&&c!==119||!L1.call(s,s.previous)||rm(s.events)?r(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(w3,e.attempt(N1,e.attempt(O1,u),r),r)(c))}function u(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function C3(e,n,r){const s=this;let l="",u=!1;return c;function c(g){return(g===72||g===104)&&z1.call(s,s.previous)&&!rm(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),l+=String.fromCodePoint(g),e.consume(g),f):r(g)}function f(g){if(gn(g)&&l.length<5)return l+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const x=l.toLowerCase();if(x==="http"||x==="https")return e.consume(g),m}return r(g)}function m(g){return g===47?(e.consume(g),u?d:(u=!0,m)):r(g)}function d(g){return g===null||Bu(g)||Tt(g)||ds(g)||Xu(g)?r(g):e.attempt(N1,e.attempt(O1,y),r)(g)}function y(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(g)}}function A3(e,n,r){let s=0;return l;function l(c){return(c===87||c===119)&&s<3?(s++,e.consume(c),l):c===46&&s===3?(e.consume(c),u):r(c)}function u(c){return c===null?r(c):n(c)}}function T3(e,n,r){let s,l,u;return c;function c(d){return d===46||d===95?e.check(R1,m,f)(d):d===null||Tt(d)||ds(d)||d!==45&&Xu(d)?m(d):(u=!0,e.consume(d),c)}function f(d){return d===95?s=!0:(l=s,s=void 0),e.consume(d),c}function m(d){return l||s||!u?r(d):n(d)}}function j3(e,n){let r=0,s=0;return l;function l(c){return c===40?(r++,e.consume(c),l):c===41&&s<r?u(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(R1,n,u)(c):c===null||Tt(c)||ds(c)?n(c):(e.consume(c),l)}function u(c){return c===41&&s++,e.consume(c),l}}function N3(e,n,r){return s;function s(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),s):f===38?(e.consume(f),u):f===93?(e.consume(f),l):f===60||f===null||Tt(f)||ds(f)?n(f):r(f)}function l(f){return f===null||f===40||f===91||Tt(f)||ds(f)?n(f):s(f)}function u(f){return gn(f)?c(f):r(f)}function c(f){return f===59?(e.consume(f),s):gn(f)?(e.consume(f),c):r(f)}}function O3(e,n,r){return s;function s(u){return e.consume(u),l}function l(u){return cn(u)?r(u):n(u)}}function L1(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tt(e)}function z1(e){return!gn(e)}function U1(e){return!(e===47||_d(e))}function _d(e){return e===43||e===45||e===46||e===95||cn(e)}function rm(e){let n=e.length,r=!1;for(;n--;){const s=e[n][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){r=!0;break}if(s._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const R3={tokenize:q3,partial:!0};function M3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:U3,continuation:{tokenize:B3},exit:P3}},text:{91:{name:"gfmFootnoteCall",tokenize:z3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:D3,resolveTo:L3}}}}function D3(e,n,r){const s=this;let l=s.events.length;const u=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;l--;){const m=s.events[l][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return f;function f(m){if(!c||!c._balanced)return r(m);const d=mr(s.sliceSerialize({start:c.end,end:s.now()}));return d.codePointAt(0)!==94||!u.includes(d.slice(1))?r(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function L3(e,n){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[r+1],e[r+2],["enter",s,n],e[r+3],e[r+4],["enter",l,n],["exit",l,n],["enter",u,n],["enter",c,n],["exit",c,n],["exit",u,n],e[e.length-2],e[e.length-1],["exit",s,n]];return e.splice(r,e.length-r+1,...f),e}function z3(e,n,r){const s=this,l=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let u=0,c;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?r(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(g){if(u>999||g===93&&!c||g===null||g===91||Tt(g))return r(g);if(g===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return l.includes(mr(s.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):r(g)}return Tt(g)||(c=!0),u++,e.consume(g),g===92?y:d}function y(g){return g===91||g===92||g===93?(e.consume(g),u++,d):d(g)}}function U3(e,n,r){const s=this,l=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let u,c=0,f;return m;function m(E){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(E){return E===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",y):r(E)}function y(E){if(c>999||E===93&&!f||E===null||E===91||Tt(E))return r(E);if(E===93){e.exit("chunkString");const M=e.exit("gfmFootnoteDefinitionLabelString");return u=mr(s.sliceSerialize(M)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return Tt(E)||(f=!0),c++,e.consume(E),E===92?g:y}function g(E){return E===91||E===92||E===93?(e.consume(E),c++,y):y(E)}function x(E){return E===58?(e.enter("definitionMarker"),e.consume(E),e.exit("definitionMarker"),l.includes(u)||l.push(u),it(e,w,"gfmFootnoteDefinitionWhitespace")):r(E)}function w(E){return n(E)}}function B3(e,n,r){return e.check(Vl,n,e.attempt(R3,n,r))}function P3(e){e.exit("gfmFootnoteDefinition")}function q3(e,n,r){const s=this;return it(e,l,"gfmFootnoteDefinitionIndent",5);function l(u){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(u):r(u)}}function H3(e){let r=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:u,resolveAll:l};return r==null&&(r=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function l(c,f){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let d=m;for(;d--;)if(c[d][0]==="exit"&&c[d][1].type==="strikethroughSequenceTemporary"&&c[d][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[d][1].end.offset-c[d][1].start.offset){c[m][1].type="strikethroughSequence",c[d][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[d][1].start),end:Object.assign({},c[m][1].end)},g={type:"strikethroughText",start:Object.assign({},c[d][1].end),end:Object.assign({},c[m][1].start)},x=[["enter",y,f],["enter",c[d][1],f],["exit",c[d][1],f],["enter",g,f]],w=f.parser.constructs.insideSpan.null;w&&In(x,x.length,0,Ku(w,c.slice(d+1,m),f)),In(x,x.length,0,[["exit",g,f],["enter",c[m][1],f],["exit",c[m][1],f],["exit",y,f]]),In(c,d-1,m-d+3,x),m=d+x.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function u(c,f,m){const d=this.previous,y=this.events;let g=0;return x;function x(E){return d===126&&y[y.length-1][1].type!=="characterEscape"?m(E):(c.enter("strikethroughSequenceTemporary"),w(E))}function w(E){const M=pa(d);if(E===126)return g>1?m(E):(c.consume(E),g++,w);if(g<2&&!r)return m(E);const P=c.exit("strikethroughSequenceTemporary"),z=pa(E);return P._open=!z||z===2&&!!M,P._close=!M||M===2&&!!z,f(E)}}}class I3{constructor(){this.map=[]}add(n,r,s){F3(this,n,r,s)}consume(n){if(this.map.sort(function(u,c){return u[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const s=[];for(;r>0;)r-=1,s.push(n.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),n.length=this.map[r][0];s.push(n.slice()),n.length=0;let l=s.pop();for(;l;){for(const u of l)n.push(u);l=s.pop()}this.map.length=0}}function F3(e,n,r,s){let l=0;if(!(r===0&&s.length===0)){for(;l<e.map.length;){if(e.map[l][0]===n){e.map[l][1]+=r,e.map[l][2].push(...s);return}l+=1}e.map.push([n,r,s])}}function $3(e,n){let r=!1;const s=[];for(;n<e.length;){const l=e[n];if(r){if(l[0]==="enter")l[1].type==="tableContent"&&s.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(l[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const u=s.length-1;s[u]=s[u]==="left"?"center":"right"}}else if(l[1].type==="tableDelimiterRow")break}else l[0]==="enter"&&l[1].type==="tableDelimiterRow"&&(r=!0);n+=1}return s}function Y3(){return{flow:{null:{name:"table",tokenize:G3,resolveAll:V3}}}}function G3(e,n,r){const s=this;let l=0,u=0,c;return f;function f(L){let W=s.events.length-1;for(;W>-1;){const ae=s.events[W][1].type;if(ae==="lineEnding"||ae==="linePrefix")W--;else break}const Q=W>-1?s.events[W][1].type:null,oe=Q==="tableHead"||Q==="tableRow"?R:m;return oe===R&&s.parser.lazy[s.now().line]?r(L):oe(L)}function m(L){return e.enter("tableHead"),e.enter("tableRow"),d(L)}function d(L){return L===124||(c=!0,u+=1),y(L)}function y(L){return L===null?r(L):Pe(L)?u>1?(u=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),w):r(L):Qe(L)?it(e,y,"whitespace")(L):(u+=1,c&&(c=!1,l+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),c=!0,y):(e.enter("data"),g(L)))}function g(L){return L===null||L===124||Tt(L)?(e.exit("data"),y(L)):(e.consume(L),L===92?x:g)}function x(L){return L===92||L===124?(e.consume(L),g):g(L)}function w(L){return s.interrupt=!1,s.parser.lazy[s.now().line]?r(L):(e.enter("tableDelimiterRow"),c=!1,Qe(L)?it(e,E,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):E(L))}function E(L){return L===45||L===58?P(L):L===124?(c=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),M):B(L)}function M(L){return Qe(L)?it(e,P,"whitespace")(L):P(L)}function P(L){return L===58?(u+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),z):L===45?(u+=1,z(L)):L===null||Pe(L)?K(L):B(L)}function z(L){return L===45?(e.enter("tableDelimiterFiller"),I(L)):B(L)}function I(L){return L===45?(e.consume(L),I):L===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),j):(e.exit("tableDelimiterFiller"),j(L))}function j(L){return Qe(L)?it(e,K,"whitespace")(L):K(L)}function K(L){return L===124?E(L):L===null||Pe(L)?!c||l!==u?B(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(L)):B(L)}function B(L){return r(L)}function R(L){return e.enter("tableRow"),Y(L)}function Y(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),Y):L===null||Pe(L)?(e.exit("tableRow"),n(L)):Qe(L)?it(e,Y,"whitespace")(L):(e.enter("data"),J(L))}function J(L){return L===null||L===124||Tt(L)?(e.exit("data"),Y(L)):(e.consume(L),L===92?F:J)}function F(L){return L===92||L===124?(e.consume(L),J):J(L)}}function V3(e,n){let r=-1,s=!0,l=0,u=[0,0,0,0],c=[0,0,0,0],f=!1,m=0,d,y,g;const x=new I3;for(;++r<e.length;){const w=e[r],E=w[1];w[0]==="enter"?E.type==="tableHead"?(f=!1,m!==0&&(Ob(x,n,m,d,y),y=void 0,m=0),d={type:"table",start:Object.assign({},E.start),end:Object.assign({},E.end)},x.add(r,0,[["enter",d,n]])):E.type==="tableRow"||E.type==="tableDelimiterRow"?(s=!0,g=void 0,u=[0,0,0,0],c=[0,r+1,0,0],f&&(f=!1,y={type:"tableBody",start:Object.assign({},E.start),end:Object.assign({},E.end)},x.add(r,0,[["enter",y,n]])),l=E.type==="tableDelimiterRow"?2:y?3:1):l&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")?(s=!1,c[2]===0&&(u[1]!==0&&(c[0]=c[1],g=xu(x,n,u,l,void 0,g),u=[0,0,0,0]),c[2]=r)):E.type==="tableCellDivider"&&(s?s=!1:(u[1]!==0&&(c[0]=c[1],g=xu(x,n,u,l,void 0,g)),u=c,c=[u[1],r,0,0])):E.type==="tableHead"?(f=!0,m=r):E.type==="tableRow"||E.type==="tableDelimiterRow"?(m=r,u[1]!==0?(c[0]=c[1],g=xu(x,n,u,l,r,g)):c[1]!==0&&(g=xu(x,n,c,l,r,g)),l=0):l&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")&&(c[3]=r)}for(m!==0&&Ob(x,n,m,d,y),x.consume(n.events),r=-1;++r<n.events.length;){const w=n.events[r];w[0]==="enter"&&w[1].type==="table"&&(w[1]._align=$3(n.events,r))}return e}function xu(e,n,r,s,l,u){const c=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",f="tableContent";r[0]!==0&&(u.end=Object.assign({},ea(n.events,r[0])),e.add(r[0],0,[["exit",u,n]]));const m=ea(n.events,r[1]);if(u={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(r[1],0,[["enter",u,n]]),r[2]!==0){const d=ea(n.events,r[2]),y=ea(n.events,r[3]),g={type:f,start:Object.assign({},d),end:Object.assign({},y)};if(e.add(r[2],0,[["enter",g,n]]),s!==2){const x=n.events[r[2]],w=n.events[r[3]];if(x[1].end=Object.assign({},w[1].end),x[1].type="chunkText",x[1].contentType="text",r[3]>r[2]+1){const E=r[2]+1,M=r[3]-r[2]-1;e.add(E,M,[])}}e.add(r[3]+1,0,[["exit",g,n]])}return l!==void 0&&(u.end=Object.assign({},ea(n.events,l)),e.add(l,0,[["exit",u,n]]),u=void 0),u}function Ob(e,n,r,s,l){const u=[],c=ea(n.events,r);l&&(l.end=Object.assign({},c),u.push(["exit",l,n])),s.end=Object.assign({},c),u.push(["exit",s,n]),e.add(r+1,0,u)}function ea(e,n){const r=e[n],s=r[0]==="enter"?"start":"end";return r[1][s]}const J3={name:"tasklistCheck",tokenize:K3};function X3(){return{text:{91:J3}}}function K3(e,n,r){const s=this;return l;function l(m){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?r(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),u)}function u(m){return Tt(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):r(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):r(m)}function f(m){return Pe(m)?n(m):Qe(m)?e.check({tokenize:Q3},n,r)(m):r(m)}}function Q3(e,n,r){return it(e,s,"whitespace");function s(l){return l===null?r(l):n(l)}}function Z3(e){return Vx([_3(),M3(),H3(e),Y3(),X3()])}const W3={};function Rb(e){const n=this,r=e||W3,s=n.data(),l=s.micromarkExtensions||(s.micromarkExtensions=[]),u=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);l.push(Z3(r)),u.push(x3()),c.push(v3(r))}function eO(e){m1(e,[/\r?\n|\r/g,tO])}function tO(){return{type:"break"}}function Mb(){return function(e){eO(e)}}function nO({connected:e,hostId:n,request:r,subscribeEvents:s,taskId:l,runId:u}){const c=ti(),[f,m]=N.useState(!0),[d,y]=N.useState([]),[g,x]=N.useState(),[w,E]=N.useState(),M=g==="started"||g==="monitoring",P=g==="followup",z=g==="started"||g==="followup",[I,j]=N.useState(null),[K,B]=N.useState(!1),[R,Y]=N.useState(""),[J,F]=N.useState(!1),L=N.useRef(null),W=N.useRef(null),Q=N.useRef(null),[oe,ae]=N.useState(u==="latest"?void 0:u),G=u==="latest"&&oe===null;N.useEffect(()=>{if(u!=="latest"){ae(u);return}e&&(ae(void 0),r("taskrun.list",{task_id:l,limit:1}).then(_=>{var D,ee;return ae(((ee=(D=_.entries)==null?void 0:D[0])==null?void 0:ee.run_id)??null)}).catch(()=>ae(null)))},[u,l,e,r]);async function H(){if(oe)try{const _=await r("task.result",{id:l,run_id:oe});if(_.error){console.error("No result:",_.error),c("/runs",{replace:!0});return}y(_.messages??[]),x(_.running_state),E(_.agent)}catch(_){console.error("Failed to load result:",_),c("/runs",{replace:!0})}finally{m(!1)}}async function X(_){var D;if(oe)try{const A=(D=(await r("task.reports",{id:l,run_id:oe,report_files:[_]})).reports)==null?void 0:D[0];A!=null&&A.data_url?j({file:_,data_url:A.data_url}):j({file:_,content:(A==null?void 0:A.content)??"Report not found."})}catch{j({file:_,content:"Failed to load report."})}}N.useEffect(()=>{!e||!oe||(m(!0),H())},[e,l,oe]),N.useEffect(()=>!e||!n||!oe?void 0:s(n,async D=>{try{const ee=JSON.parse(new TextDecoder().decode(D.data));if(ee.event_type!=="running-state"&&ee.event_type!=="result-updated"||D.subject.split(".").pop()!==l||ee.event_type==="result-updated"&&ee.run_id&&ee.run_id!==oe)return;H()}catch{}}),[e,n,l,oe,s,r]),N.useEffect(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},[d]),N.useEffect(()=>{f||G||!oe||Q.current!==oe&&(Q.current=oe,requestAnimationFrame(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight),window.scrollTo({top:document.documentElement.scrollHeight,behavior:"auto"})}))},[f,G,oe]);function ue(_){if(_==="input")return"User Input";if(_==="permission")return"Permission";if(_==="confirmation")return"Confirmation"}function _e(_){return _==="started"?"Task started":_==="finished"?"Task finished":_==="failed"?"Task failed":_==="error"?"Command failed":_==="aborted"?"Task aborted":_==="confirmation"?"Task confirmed":_==="stopped"?"Follow-up stopped":_??""}return b.jsxs("div",{className:"run-detail",children:[b.jsxs("button",{className:"run-detail-back",onClick:()=>c(-1),children:[b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:b.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back"]}),G?b.jsxs("div",{className:"empty-state",children:[b.jsx("p",{className:"empty-state-text",children:"No runs yet"}),b.jsx("p",{className:"empty-state-hint",children:"This task hasn't been executed yet. Run it from the task menu or wait for its next trigger."})]}):f?b.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)",padding:"var(--space-sm) 0"},children:[b.jsx("div",{className:"skeleton-line",style:{width:"40%"}}),b.jsx("div",{className:"skeleton-line",style:{width:"55%"}}),b.jsx("div",{className:"skeleton-line",style:{width:"100%",height:"8rem",marginTop:"var(--space-sm)"}})]}):b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"chat-thread",ref:L,children:[d.map((_,D)=>{const ee=z&&_.role==="assistant"&&!d.slice(D+1).some(A=>A.role==="assistant"||A.role==="user");return _.role==="status"&&_.type==="monitoring"?null:_.role==="status"?b.jsxs("div",{className:`chat-status${_.type==="error"?" chat-status--error":""}`,children:[b.jsxs("div",{children:[_e(_.type),_.time>0&&b.jsx("span",{className:"chat-status-time",children:Uu(_.time)})]}),_.content&&b.jsx("pre",{className:"chat-status-detail",children:_.content})]},D):b.jsxs("div",{className:`chat-message chat-message--${_.role}`,children:[_.role==="assistant"&&w&&b.jsx("div",{className:"chat-message-agent",children:hd(w)}),b.jsxs("div",{className:"chat-message-content",children:[b.jsx(Eb,{remarkPlugins:[Rb,Mb],children:_.content}),ee&&b.jsxs("div",{className:"chat-typing-indicator",children:[b.jsx("span",{}),b.jsx("span",{}),b.jsx("span",{})]})]}),_.attachments&&_.attachments.length>0&&b.jsx("div",{className:"chat-message-attachments",children:_.attachments.map(A=>b.jsx("button",{className:"chat-attachment-chip",onClick:()=>X(A),children:A},A))}),b.jsxs("div",{className:"chat-message-meta",children:[ue(_.type)&&b.jsx("span",{className:"chat-message-type",children:ue(_.type)}),_.time>0&&b.jsx("span",{children:Uu(_.time)})]})]},D)}),z&&(()=>{const _=d.filter(D=>D.role!=="status");return _.length===0||_[_.length-1].role!=="assistant"})()&&b.jsxs("div",{className:"chat-message chat-message--assistant",children:[w&&b.jsx("div",{className:"chat-message-agent",children:hd(w)}),b.jsxs("div",{className:"chat-typing-indicator",children:[b.jsx("span",{}),b.jsx("span",{}),b.jsx("span",{})]})]}),g==="monitoring"&&b.jsxs("div",{className:"chat-monitoring-indicator",children:[b.jsx("span",{className:"chat-monitoring-dot"}),"Monitoring command output"]})]}),M?b.jsx("div",{className:"chat-abort-bar",children:b.jsx("button",{className:"btn btn-secondary chat-abort-btn",disabled:K,onClick:async()=>{if(confirm("Abort this task?")){B(!0);try{await r("task.abort",{id:l})}catch(_){console.error("Abort failed:",_)}finally{B(!1)}}},children:K?"Aborting...":"Abort Task"})}):P?b.jsx("div",{className:"chat-input-bar",children:b.jsx("button",{className:"btn btn-secondary chat-stop-btn",disabled:K,onClick:async()=>{B(!0);try{await r("task.stop_followup",{id:l,run_id:oe})}catch(_){console.error("Stop failed:",_)}finally{B(!1)}},children:b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:b.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})})}):b.jsxs("form",{className:"chat-input-bar",onSubmit:async _=>{_.preventDefault();const D=R.trim();if(!(!D||J)){F(!0);try{await r("task.followup",{id:l,run_id:oe,message:D}),Y("")}catch(ee){console.error("Follow-up failed:",ee)}finally{F(!1)}}},children:[b.jsx("input",{ref:W,className:"chat-input",type:"text",placeholder:"Follow-up message",value:R,onChange:_=>Y(_.target.value),disabled:J}),b.jsx("button",{className:"btn btn-primary chat-send-btn",type:"submit",disabled:!R.trim()||J,children:b.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),b.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]}),I&&b.jsx("div",{className:"report-dialog-overlay",onClick:()=>j(null),children:b.jsxs("div",{className:"report-dialog",onClick:_=>_.stopPropagation(),children:[b.jsxs("div",{className:"report-dialog-header",children:[b.jsx("span",{className:"report-dialog-title",children:I.file}),b.jsx("button",{className:"report-dialog-close",onClick:()=>j(null),"aria-label":"Close",children:b.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),b.jsx("div",{className:"report-dialog-body",children:I.data_url?b.jsx("img",{src:I.data_url,alt:I.file,style:{maxWidth:"100%",height:"auto"}}):b.jsx(Eb,{remarkPlugins:[Rb,Mb],components:{a:({..._})=>b.jsx("a",{..._,target:"_blank",rel:"noopener noreferrer"})},children:I.content??""})})]})})]})}function rO(){const{getActiveHost:e}=ba(),n=e(),r=N.useRef(null);N.useEffect(()=>{if(pr.isNativePlatform()||!n||n.directUrl||r.current===n.hostId)return;async function s(){var l;try{if(!("serviceWorker"in navigator)||!("PushManager"in window)){console.warn("[Push] Push notifications not supported");return}const u=await navigator.serviceWorker.ready;(l=u.active)==null||l.postMessage({type:"set-host-id",hostId:n.hostId});let c=await u.pushManager.getSubscription();if(!c){const{publicKey:m}=await ak("/api/push/vapid-key");if(!m){console.warn("[Push] No VAPID public key configured on server");return}if(await Notification.requestPermission()!=="granted"){console.log("[Push] Permission denied");return}c=await u.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:m})}const f=c.toJSON();await sk("/api/push/subscribe",{hostId:n.hostId,endpoint:f.endpoint,keys:{p256dh:f.keys.p256dh,auth:f.keys.auth}}),r.current=n.hostId}catch(u){console.error("[Push] Subscription failed:",u)}}s()},[n])}const iO="0.8.3";function sO(e,n){if(e.includes("-"))return!1;const r=e.split(".").map(Number),s=n.split(".").map(Number);for(let l=0;l<3;l++){if((r[l]??0)<(s[l]??0))return!0;if((r[l]??0)>(s[l]??0))return!1}return!1}function Sl(){var He;const{pairedHosts:e,activeHostId:n,removePairedHost:r}=ba(),{connected:s,request:l,subscribeEvents:u,unauthorized:c}=Yl(),f=ti(),m=Tr(),d=BS(),y=Nx("(min-width: 768px)"),g=m.pathname.startsWith("/tasks"),x=d.runId?void 0:d.taskId,w=!!(d.taskId&&d.runId),[E,M]=N.useState(!1),[P,z]=N.useState(!1),[I,j]=N.useState(null),[K,B]=N.useState(null),[R,Y]=N.useState({}),[J,F]=N.useState([]),[L,W]=N.useState(),[Q,oe]=N.useState(new Map),[ae,G]=N.useState(new Map),[H,X]=N.useState(new Map),[ue,_e]=N.useState(new Map);rO(),N.useEffect(()=>{window.scrollTo(0,0)},[n]),N.useEffect(()=>{s&&l("host.info").then(be=>{var Fe,Ue,tt,mt,st,Mt;F(be.agents??[]),W(be.host_platform),Y(be.capability_tokens??{}),uk(be.agents??[]);const De=be.version??null;B(De),M(!!De&&sO(De,iO));const Ze=new Map,dt=new Map,lt=new Map,ct=new Map;for(const yt of be.pending_prompts??[])if(yt.type==="confirmation")Ze.set(yt.key,{description:((Fe=yt.meta)==null?void 0:Fe.description)??"",sessionName:(Ue=yt.meta)==null?void 0:Ue.session_name});else if(yt.type==="permission")dt.set(yt.key,{permissions:yt.params??[],sessionName:(tt=yt.meta)==null?void 0:tt.session_name});else if(yt.type==="input"){const $n=yt.params??((mt=yt.meta)==null?void 0:mt.input_questions)??[];lt.set(yt.key,{questions:$n,description:(st=yt.meta)==null?void 0:st.description,sessionName:(Mt=yt.meta)==null?void 0:Mt.session_name}),ct.set(yt.key,new Array($n.length).fill(""))}oe(Ze),G(dt),X(lt),_e(ct)}).catch(()=>{})},[s,n,l]),N.useEffect(()=>!s||!n?void 0:u(n,De=>{const Ze=De.subject.split(".");if(Ze.length<3)return;const dt=Ze.slice(2).join(".");let lt={};try{lt=JSON.parse(new TextDecoder().decode(De.data))}catch{return}const ct=lt.event_type,Fe=lt.session_id;if(ct==="input-request"&&Fe){const Ue=lt.input_questions,tt=lt.session_name,mt=lt.description;Ue!=null&&Ue.length&&(X(st=>{if(st.has(Fe))return st;const Mt=new Map(st);return Mt.set(Fe,{questions:Ue,description:mt,sessionName:tt}),Mt}),_e(st=>{if(st.has(Fe))return st;const Mt=new Map(st);return Mt.set(Fe,new Array(Ue.length).fill("")),Mt}));return}if(ct==="input-resolved"&&Fe){X(Ue=>{if(!Ue.has(Fe))return Ue;const tt=new Map(Ue);return tt.delete(Fe),tt}),_e(Ue=>{const tt=new Map(Ue);return tt.delete(Fe),tt});return}if(ct==="confirm-request"&&Fe){const Ue=lt.description,tt=lt.session_name;Ue&&oe(mt=>{if(mt.has(Fe))return mt;const st=new Map(mt);return st.set(Fe,{description:Ue,sessionName:tt}),st});return}if(ct==="confirm-resolved"&&Fe){oe(Ue=>{if(!Ue.has(Fe))return Ue;const tt=new Map(Ue);return tt.delete(Fe),tt});return}if(ct==="permission-request"){const Ue=lt.required_permissions,tt=lt.session_name;Ue!=null&&Ue.length&&G(mt=>{if(mt.has(dt))return mt;const st=new Map(mt);return st.set(dt,{permissions:Ue,sessionName:tt}),st});return}if(ct==="permission-resolved"){G(Ue=>{if(!Ue.has(dt))return Ue;const tt=new Map(Ue);return tt.delete(dt),tt});return}}),[s,n,u]);async function _(be,De){try{await l("task.user_input",{id:be,value:[De]})}catch(Ze){console.error("[Dashboard] Failed to respond to confirmation:",Ze)}}async function D(be,De){try{await l("task.user_input",{id:be,value:[De]})}catch(Ze){console.error("[Dashboard] Failed to respond to permission request:",Ze)}}async function ee(be,De){try{await l("task.user_input",{id:be,value:De})}catch(Ze){console.error("[Dashboard] Failed to respond to input request:",Ze)}}function A(be,De){hs()&&f(De?`/runs/${encodeURIComponent(be)}/${encodeURIComponent(De)}`:`/runs/${encodeURIComponent(be)}`)}async function ve(){z(!0),j(null);try{const be=await l("host.update");if(be.error){j(be.error),z(!1);return}}catch{}setTimeout(()=>window.location.reload(),15e3)}const Ae=e.length>0,Te=Ae&&s&&n&&!c,Me=((He=e.find(be=>be.hostId===n))==null?void 0:He.clientToken)??null;return b.jsxs("div",{className:"dashboard",children:[y&&b.jsx(P0,{daemonVersion:K,capabilityTokens:R,activeClientToken:Me,request:l,onCapabilityTokensChange:Y}),b.jsxs("div",{className:"dashboard-content",children:[b.jsxs("header",{className:"app-header",children:[b.jsxs("div",{className:"app-title-bar",children:[!y&&b.jsx(P0,{daemonVersion:K,capabilityTokens:R,activeClientToken:Me,request:l,onCapabilityTokensChange:Y}),b.jsx("h1",{className:"app-title",children:"Palmier"})]}),b.jsx("div",{className:"tab-bar",children:b.jsx(_k,{})})]}),b.jsx("main",{className:"dashboard-main",children:c?b.jsxs("div",{className:"revoked-state",children:[b.jsx("div",{className:"revoked-icon",children:b.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),b.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}),b.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"18"})]})}),b.jsx("h2",{className:"revoked-title",children:"Client Revoked"}),b.jsx("p",{className:"revoked-description",children:"This client was revoked by the host. To reconnect, generate a new pairing code on the host machine."}),b.jsx("div",{className:"revoked-command",children:b.jsx("code",{children:"palmier pair"})}),b.jsxs("div",{className:"revoked-actions",children:[b.jsx("button",{className:"btn btn-primary",onClick:()=>{hs()&&f("/pair")},children:"Re-pair Device"}),b.jsx("button",{className:"btn btn-secondary",onClick:()=>{n&&r(n)},children:"Remove Host"})]})]}):Te?b.jsxs(b.Fragment,{children:[g&&!w&&b.jsx(Sk,{connected:s,hostId:n,request:l,subscribeEvents:u,agents:J,hostPlatform:L,isNotificationListener:!!Me&&R.notifications===Me,onViewRun:A}),w?b.jsx(nO,{connected:s,hostId:n,request:l,subscribeEvents:u,taskId:d.taskId,runId:decodeURIComponent(d.runId)}):g?null:b.jsx(Rk,{connected:s,hostId:n,request:l,subscribeEvents:u,agents:J,hostPlatform:L,filterTaskId:x,onClearFilter:()=>{hs()&&f("/")}})]}):b.jsxs("div",{className:"empty-state",children:[b.jsx("p",{children:Ae?"Connecting to host...":"No host computer paired yet."}),!Ae&&b.jsx("button",{className:"btn btn-primary",onClick:()=>f("/pair"),children:"Pair Host"})]})}),E&&!P&&!I&&b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Update Required"}),b.jsxs("p",{className:"confirm-modal-message",children:["Your Palmier host",K?` (v${K})`:""," is too old for this version of the app. Please update to continue."]}),b.jsx("div",{className:"confirm-modal-actions",children:b.jsx("button",{className:"btn btn-primary",onClick:ve,children:"Update Now"})})]})}),P&&b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Updating..."}),b.jsx("p",{className:"confirm-modal-message",children:"Installing update and restarting daemon. Please wait..."})]})}),I&&b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Update Failed"}),b.jsx("p",{className:"confirm-modal-message",style:{whiteSpace:"pre-line"},children:I}),b.jsx("div",{className:"confirm-modal-actions",children:b.jsx("button",{className:"btn btn-secondary",onClick:()=>{j(null)},children:"Retry"})})]})})]}),ca.createPortal(b.jsxs(b.Fragment,{children:[[...Q.entries()].map(([be,{description:De,sessionName:Ze}])=>b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Confirmation Required"}),Ze&&b.jsx("p",{className:"confirm-modal-subtitle",children:Ze}),b.jsx("p",{className:"confirm-modal-message",children:De}),b.jsxs("div",{className:"confirm-modal-actions",children:[b.jsx("button",{className:"btn btn-primary",onClick:()=>_(be,"confirmed"),children:"Confirm"}),b.jsx("button",{className:"btn btn-secondary",onClick:()=>_(be,"aborted"),children:"Abort"})]})]})},be)),[...ae.entries()].map(([be,{permissions:De,sessionName:Ze}])=>b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal permission-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Permission Required"}),b.jsx("p",{className:"confirm-modal-message",children:b.jsx("strong",{children:Ze||be})}),b.jsx("div",{className:"permission-list",children:De.map((dt,lt)=>b.jsxs("div",{className:"permission-item",children:[b.jsx("span",{className:"permission-name",children:dt.name}),dt.description&&b.jsx("span",{className:"permission-desc",children:dt.description})]},lt))}),b.jsxs("div",{className:"permission-actions",children:[b.jsx("button",{className:"btn btn-primary",onClick:()=>D(be,"granted"),children:"Allow Once"}),b.jsx("button",{className:"btn btn-secondary",onClick:()=>D(be,"granted_all"),children:"Allow Always"})]}),b.jsx("button",{className:"permission-abort-link",onClick:()=>D(be,"aborted"),children:"Deny & Abort Task"})]})},be)),[...H.entries()].map(([be,{questions:De,description:Ze,sessionName:dt}])=>{const lt=ue.get(be)??new Array(De.length).fill("");return b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal input-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Input Required"}),dt&&b.jsx("p",{className:"confirm-modal-subtitle",children:dt}),Ze&&b.jsx("p",{className:"confirm-modal-message",children:Ze}),b.jsx("div",{className:"input-list",children:De.map((ct,Fe)=>b.jsxs("div",{className:"input-item",children:[b.jsx("label",{className:"input-label",children:ct}),b.jsx("input",{type:"text",className:"input-field",value:lt[Fe]??"",onChange:Ue=>{_e(tt=>{const mt=new Map(tt),st=[...mt.get(be)??[]];return st[Fe]=Ue.target.value,mt.set(be,st),mt})},autoFocus:Fe===0})]},Fe))}),b.jsx("div",{className:"input-actions",children:b.jsx("button",{className:"btn btn-primary",disabled:lt.some(ct=>!ct.trim()),onClick:()=>ee(be,lt),children:"Submit"})}),b.jsx("button",{className:"permission-abort-link",onClick:()=>ee(be,["aborted"]),children:"Cancel"})]})},be)})]}),document.body)]})}const aO=va("Preferences",{web:()=>Ox(()=>import("./web-CyJutAy4.js"),[]).then(e=>new e.PreferencesWeb)}),_l=!!window.__PALMIER_SERVE__;function lO(){const[e,n]=N.useState(""),[r,s]=N.useState(!1),[l,u]=N.useState(null),{addPairedHost:c}=ba(),f=ti();async function m(){const d=e.trim().toUpperCase();if(!d){u("Enter a pairing code.");return}s(!0),u(null);try{let y;if(_l){const x=await fetch("/pair",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:d,label:navigator.userAgent})});if(!x.ok){const w=await x.json().catch(()=>({error:"Connection failed"}));throw new Error(w.error||`HTTP ${x.status}`)}y=await x.json()}else{const x=await fetch(`${zu}/api/config`);if(!x.ok)throw new Error("Failed to fetch server config");const w=await x.json();if(!w.natsWsUrl)throw new Error("Server has no NATS WebSocket URL configured");const E=await _x({servers:w.natsWsUrl,authenticator:mx(w.natsJwt,new TextEncoder().encode(w.natsNkeySeed))}),M=ju(),P=`pair.${d}`,z=await E.request(P,M.encode(JSON.stringify({label:navigator.userAgent})),{timeout:1e4});y=JSON.parse(M.decode(z.data)),await E.close()}const g={hostId:y.hostId,clientToken:y.clientToken,directUrl:_l?window.location.origin:void 0,...y.hostName?{name:y.hostName}:{}};if(c(g),pr.isNativePlatform()&&Ut){await aO.set({key:"hostId",value:y.hostId});try{const{token:x}=await Ut.getFcmToken();await fetch(`${zu}/api/fcm/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hostId:y.hostId,fcmToken:x})})}catch(x){console.warn("FCM token registration failed:",x)}}f(pr.isNativePlatform()?"/pair/setup":"/")}catch(y){const g=y instanceof Error?y.message:String(y);g.includes("timeout")||g.includes("TIMEOUT")||g.includes("503")||g.toLowerCase().includes("no responders")?u("Code not found or expired. Check the code and try again."):u(g)}finally{s(!1)}}return b.jsx("div",{className:"pair-page",children:b.jsxs("div",{className:"pair-card",children:[b.jsxs("div",{className:"pair-header",children:[b.jsx("h1",{className:"pair-title",children:_l?"Pair":"Pair with Host"}),b.jsx("p",{className:"pair-subtitle",children:_l?"Enter the pairing code shown in your terminal.":"Connect this device to a Palmier host"})]}),!_l&&b.jsxs("div",{className:"pair-instructions",children:[b.jsxs("div",{className:"pair-instruction-block",children:[b.jsx("h3",{className:"pair-instruction-heading",children:"Setting up a new host?"}),b.jsxs("ol",{className:"pair-steps",children:[b.jsxs("li",{children:["Install at least one agent CLI (e.g., ",b.jsx("a",{href:"https://www.palmier.me/agents",target:"_blank",rel:"noopener noreferrer",children:"Claude Code, Gemini CLI, Codex CLI"}),")"]}),b.jsxs("li",{children:["Install Palmier on your host machine:",b.jsx("code",{className:"pair-command",children:"npm install -g palmier"})]}),b.jsxs("li",{children:["Run the setup wizard:",b.jsx("code",{className:"pair-command",children:"palmier init"})]}),b.jsx("li",{children:"A pairing code will display automatically"})]})]}),b.jsx("div",{className:"pair-instruction-divider"}),b.jsxs("div",{className:"pair-instruction-block",children:[b.jsx("h3",{className:"pair-instruction-heading",children:"Pairing an existing host?"}),b.jsxs("ol",{className:"pair-steps",children:[b.jsxs("li",{children:["Run ",b.jsx("code",{children:"palmier pair"})," on the host machine"]}),b.jsx("li",{children:"Enter the 6-character code below"})]})]})]}),b.jsxs("div",{className:"pair-form",children:[b.jsxs("label",{className:"form-label",htmlFor:"pair-code",children:["Pairing code",b.jsx("input",{id:"pair-code",type:"text",maxLength:6,value:e,onChange:d=>n(d.target.value.toUpperCase()),placeholder:"A7K9M2",className:"form-input form-input-mono pair-code-input",autoFocus:!0,autoComplete:"off",disabled:r})]}),l&&b.jsx("p",{className:"pair-error",children:l}),b.jsxs("button",{className:"btn btn-primary btn-full",onClick:m,disabled:r||!e.trim(),children:[r&&b.jsx("span",{className:"btn-spinner"}),r?"Pairing...":"Pair"]}),b.jsx("button",{className:"btn btn-secondary btn-full",onClick:()=>f("/"),disabled:r,children:"Cancel"}),b.jsxs("p",{className:"pair-consent",children:["By pairing, you agree to our"," ",b.jsx("a",{href:"https://www.palmier.me/terms",target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})," and"," ",b.jsx("a",{href:"https://www.palmier.me/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"}),"."]})]})]})})}function oO(){const e=ti(),{connected:n,request:r}=Yl(),{getActiveHost:s}=ba(),l=s(),u=(l==null?void 0:l.clientToken)??null,[c,f]=N.useState({}),[m,d]=N.useState(!1);return N.useEffect(()=>{l||e("/",{replace:!0})},[l,e]),N.useEffect(()=>{if(!n||!l)return;let y=!1;return r("host.info").then(g=>{y||(f(g.capability_tokens??{}),d(!0))}).catch(()=>{y||d(!0)}),()=>{y=!0}},[n,l,r]),b.jsx("div",{className:"pair-setup",children:b.jsxs("div",{className:"pair-setup-inner",children:[b.jsx("h1",{className:"pair-setup-title",children:"What capabilities of this device do you want your host computer to have?"}),b.jsx("p",{className:"pair-setup-description",children:"You can change these later from the menu."}),m?b.jsx(Rx,{capabilityTokens:c,activeClientToken:u,request:r,onCapabilityTokensChange:f}):b.jsx("div",{className:"pair-setup-loading",children:"Connecting to host…"}),b.jsx("div",{className:"pair-setup-actions",children:b.jsx("button",{className:"btn btn-primary btn-full",onClick:()=>e("/",{replace:!0}),children:"Finish"})})]})})}function uO(){const e=ti();return N.useEffect(()=>{if(!Ut)return;const n=Ut.addListener("deepLink",({path:r})=>e(r));return()=>{n.then(r=>r.remove())}},[e]),null}function cO(){return b.jsx(U_,{children:b.jsxs(ok,{children:[b.jsx(uO,{}),b.jsxs(WS,{children:[b.jsx(Mi,{path:"/",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/tasks",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/runs",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/runs/:taskId",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/runs/:taskId/:runId",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/pair",element:b.jsx(lO,{})}),b.jsx(Mi,{path:"/pair/setup",element:b.jsx(oO,{})})]})]})})}tS.createRoot(document.getElementById("root")).render(b.jsx(N.StrictMode,{children:b.jsx(__,{children:b.jsx(cO,{})})}));export{Pd as W};
|
|
120
|
+
`))}function m(w,E,M,P){const z=M.enter("tableCell"),I=M.enter("phrasing"),j=M.containerPhrasing(w,{...P,before:u,after:u});return I(),z(),j}function d(w,E){return TN(w,{align:E,alignDelimiters:s,padding:r,stringLength:l})}function y(w,E,M){const P=w.children;let z=-1;const I=[],j=E.enter("table");for(;++z<P.length;)I[z]=g(P[z],E,M);return j(),I}function g(w,E,M){const P=w.children;let z=-1;const I=[],j=E.enter("tableRow");for(;++z<P.length;)I[z]=m(P[z],w,E,M);return j(),I}function x(w,E,M){let P=j1.inlineCode(w,E,M);return M.stack.includes("tableCell")&&(P=P.replace(/\|/g,"\\$&")),P}}function p3(){return{exit:{taskListCheckValueChecked:Nb,taskListCheckValueUnchecked:Nb,paragraph:y3}}}function g3(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:b3}}}function Nb(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function y3(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const s=r.children[0];if(s&&s.type==="text"){const l=n.children;let u=-1,c;for(;++u<l.length;){const f=l[u];if(f.type==="paragraph"){c=f;break}}c===r&&(s.value=s.value.slice(1),s.value.length===0?r.children.shift():r.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,r.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function b3(e,n,r,s){const l=e.children[0],u=typeof e.checked=="boolean"&&l&&l.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",f=r.createTracker(s);u&&f.move(c);let m=j1.listItem(e,n,r,{...s,...f.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),m;function d(y){return y+c}}function x3(){return[Qj(),bN(),SN(),o3(),p3()]}function v3(e){return{extensions:[Zj(),xN(e),_N(),m3(e),g3()]}}const w3={tokenize:A3,partial:!0},N1={tokenize:T3,partial:!0},O1={tokenize:j3,partial:!0},R1={tokenize:N3,partial:!0},S3={tokenize:O3,partial:!0},M1={name:"wwwAutolink",tokenize:k3,previous:L1},D1={name:"protocolAutolink",tokenize:C3,previous:z1},ni={name:"emailAutolink",tokenize:E3,previous:U1},jr={};function _3(){return{text:jr}}let cs=48;for(;cs<123;)jr[cs]=ni,cs++,cs===58?cs=65:cs===91&&(cs=97);jr[43]=ni;jr[45]=ni;jr[46]=ni;jr[95]=ni;jr[72]=[ni,D1];jr[104]=[ni,D1];jr[87]=[ni,M1];jr[119]=[ni,M1];function E3(e,n,r){const s=this;let l,u;return c;function c(g){return!_d(g)||!U1.call(s,s.previous)||rm(s.events)?r(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return _d(g)?(e.consume(g),f):g===64?(e.consume(g),m):r(g)}function m(g){return g===46?e.check(S3,y,d)(g):g===45||g===95||cn(g)?(u=!0,e.consume(g),m):y(g)}function d(g){return e.consume(g),l=!0,m}function y(g){return u&&l&&gn(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(g)):r(g)}}function k3(e,n,r){const s=this;return l;function l(c){return c!==87&&c!==119||!L1.call(s,s.previous)||rm(s.events)?r(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(w3,e.attempt(N1,e.attempt(O1,u),r),r)(c))}function u(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function C3(e,n,r){const s=this;let l="",u=!1;return c;function c(g){return(g===72||g===104)&&z1.call(s,s.previous)&&!rm(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),l+=String.fromCodePoint(g),e.consume(g),f):r(g)}function f(g){if(gn(g)&&l.length<5)return l+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const x=l.toLowerCase();if(x==="http"||x==="https")return e.consume(g),m}return r(g)}function m(g){return g===47?(e.consume(g),u?d:(u=!0,m)):r(g)}function d(g){return g===null||Bu(g)||Tt(g)||ds(g)||Xu(g)?r(g):e.attempt(N1,e.attempt(O1,y),r)(g)}function y(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(g)}}function A3(e,n,r){let s=0;return l;function l(c){return(c===87||c===119)&&s<3?(s++,e.consume(c),l):c===46&&s===3?(e.consume(c),u):r(c)}function u(c){return c===null?r(c):n(c)}}function T3(e,n,r){let s,l,u;return c;function c(d){return d===46||d===95?e.check(R1,m,f)(d):d===null||Tt(d)||ds(d)||d!==45&&Xu(d)?m(d):(u=!0,e.consume(d),c)}function f(d){return d===95?s=!0:(l=s,s=void 0),e.consume(d),c}function m(d){return l||s||!u?r(d):n(d)}}function j3(e,n){let r=0,s=0;return l;function l(c){return c===40?(r++,e.consume(c),l):c===41&&s<r?u(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(R1,n,u)(c):c===null||Tt(c)||ds(c)?n(c):(e.consume(c),l)}function u(c){return c===41&&s++,e.consume(c),l}}function N3(e,n,r){return s;function s(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),s):f===38?(e.consume(f),u):f===93?(e.consume(f),l):f===60||f===null||Tt(f)||ds(f)?n(f):r(f)}function l(f){return f===null||f===40||f===91||Tt(f)||ds(f)?n(f):s(f)}function u(f){return gn(f)?c(f):r(f)}function c(f){return f===59?(e.consume(f),s):gn(f)?(e.consume(f),c):r(f)}}function O3(e,n,r){return s;function s(u){return e.consume(u),l}function l(u){return cn(u)?r(u):n(u)}}function L1(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tt(e)}function z1(e){return!gn(e)}function U1(e){return!(e===47||_d(e))}function _d(e){return e===43||e===45||e===46||e===95||cn(e)}function rm(e){let n=e.length,r=!1;for(;n--;){const s=e[n][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){r=!0;break}if(s._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const R3={tokenize:q3,partial:!0};function M3(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:U3,continuation:{tokenize:B3},exit:P3}},text:{91:{name:"gfmFootnoteCall",tokenize:z3},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:D3,resolveTo:L3}}}}function D3(e,n,r){const s=this;let l=s.events.length;const u=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;l--;){const m=s.events[l][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return f;function f(m){if(!c||!c._balanced)return r(m);const d=mr(s.sliceSerialize({start:c.end,end:s.now()}));return d.codePointAt(0)!==94||!u.includes(d.slice(1))?r(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function L3(e,n){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[r+1],e[r+2],["enter",s,n],e[r+3],e[r+4],["enter",l,n],["exit",l,n],["enter",u,n],["enter",c,n],["exit",c,n],["exit",u,n],e[e.length-2],e[e.length-1],["exit",s,n]];return e.splice(r,e.length-r+1,...f),e}function z3(e,n,r){const s=this,l=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let u=0,c;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?r(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(g){if(u>999||g===93&&!c||g===null||g===91||Tt(g))return r(g);if(g===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return l.includes(mr(s.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):r(g)}return Tt(g)||(c=!0),u++,e.consume(g),g===92?y:d}function y(g){return g===91||g===92||g===93?(e.consume(g),u++,d):d(g)}}function U3(e,n,r){const s=this,l=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let u,c=0,f;return m;function m(E){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(E){return E===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",y):r(E)}function y(E){if(c>999||E===93&&!f||E===null||E===91||Tt(E))return r(E);if(E===93){e.exit("chunkString");const M=e.exit("gfmFootnoteDefinitionLabelString");return u=mr(s.sliceSerialize(M)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),x}return Tt(E)||(f=!0),c++,e.consume(E),E===92?g:y}function g(E){return E===91||E===92||E===93?(e.consume(E),c++,y):y(E)}function x(E){return E===58?(e.enter("definitionMarker"),e.consume(E),e.exit("definitionMarker"),l.includes(u)||l.push(u),it(e,w,"gfmFootnoteDefinitionWhitespace")):r(E)}function w(E){return n(E)}}function B3(e,n,r){return e.check(Vl,n,e.attempt(R3,n,r))}function P3(e){e.exit("gfmFootnoteDefinition")}function q3(e,n,r){const s=this;return it(e,l,"gfmFootnoteDefinitionIndent",5);function l(u){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(u):r(u)}}function H3(e){let r=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:u,resolveAll:l};return r==null&&(r=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function l(c,f){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let d=m;for(;d--;)if(c[d][0]==="exit"&&c[d][1].type==="strikethroughSequenceTemporary"&&c[d][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[d][1].end.offset-c[d][1].start.offset){c[m][1].type="strikethroughSequence",c[d][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[d][1].start),end:Object.assign({},c[m][1].end)},g={type:"strikethroughText",start:Object.assign({},c[d][1].end),end:Object.assign({},c[m][1].start)},x=[["enter",y,f],["enter",c[d][1],f],["exit",c[d][1],f],["enter",g,f]],w=f.parser.constructs.insideSpan.null;w&&In(x,x.length,0,Ku(w,c.slice(d+1,m),f)),In(x,x.length,0,[["exit",g,f],["enter",c[m][1],f],["exit",c[m][1],f],["exit",y,f]]),In(c,d-1,m-d+3,x),m=d+x.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function u(c,f,m){const d=this.previous,y=this.events;let g=0;return x;function x(E){return d===126&&y[y.length-1][1].type!=="characterEscape"?m(E):(c.enter("strikethroughSequenceTemporary"),w(E))}function w(E){const M=pa(d);if(E===126)return g>1?m(E):(c.consume(E),g++,w);if(g<2&&!r)return m(E);const P=c.exit("strikethroughSequenceTemporary"),z=pa(E);return P._open=!z||z===2&&!!M,P._close=!M||M===2&&!!z,f(E)}}}class I3{constructor(){this.map=[]}add(n,r,s){F3(this,n,r,s)}consume(n){if(this.map.sort(function(u,c){return u[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const s=[];for(;r>0;)r-=1,s.push(n.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),n.length=this.map[r][0];s.push(n.slice()),n.length=0;let l=s.pop();for(;l;){for(const u of l)n.push(u);l=s.pop()}this.map.length=0}}function F3(e,n,r,s){let l=0;if(!(r===0&&s.length===0)){for(;l<e.map.length;){if(e.map[l][0]===n){e.map[l][1]+=r,e.map[l][2].push(...s);return}l+=1}e.map.push([n,r,s])}}function $3(e,n){let r=!1;const s=[];for(;n<e.length;){const l=e[n];if(r){if(l[0]==="enter")l[1].type==="tableContent"&&s.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(l[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const u=s.length-1;s[u]=s[u]==="left"?"center":"right"}}else if(l[1].type==="tableDelimiterRow")break}else l[0]==="enter"&&l[1].type==="tableDelimiterRow"&&(r=!0);n+=1}return s}function Y3(){return{flow:{null:{name:"table",tokenize:G3,resolveAll:V3}}}}function G3(e,n,r){const s=this;let l=0,u=0,c;return f;function f(L){let W=s.events.length-1;for(;W>-1;){const ae=s.events[W][1].type;if(ae==="lineEnding"||ae==="linePrefix")W--;else break}const Q=W>-1?s.events[W][1].type:null,oe=Q==="tableHead"||Q==="tableRow"?R:m;return oe===R&&s.parser.lazy[s.now().line]?r(L):oe(L)}function m(L){return e.enter("tableHead"),e.enter("tableRow"),d(L)}function d(L){return L===124||(c=!0,u+=1),y(L)}function y(L){return L===null?r(L):Pe(L)?u>1?(u=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),w):r(L):Qe(L)?it(e,y,"whitespace")(L):(u+=1,c&&(c=!1,l+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),c=!0,y):(e.enter("data"),g(L)))}function g(L){return L===null||L===124||Tt(L)?(e.exit("data"),y(L)):(e.consume(L),L===92?x:g)}function x(L){return L===92||L===124?(e.consume(L),g):g(L)}function w(L){return s.interrupt=!1,s.parser.lazy[s.now().line]?r(L):(e.enter("tableDelimiterRow"),c=!1,Qe(L)?it(e,E,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):E(L))}function E(L){return L===45||L===58?P(L):L===124?(c=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),M):B(L)}function M(L){return Qe(L)?it(e,P,"whitespace")(L):P(L)}function P(L){return L===58?(u+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),z):L===45?(u+=1,z(L)):L===null||Pe(L)?K(L):B(L)}function z(L){return L===45?(e.enter("tableDelimiterFiller"),I(L)):B(L)}function I(L){return L===45?(e.consume(L),I):L===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),j):(e.exit("tableDelimiterFiller"),j(L))}function j(L){return Qe(L)?it(e,K,"whitespace")(L):K(L)}function K(L){return L===124?E(L):L===null||Pe(L)?!c||l!==u?B(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(L)):B(L)}function B(L){return r(L)}function R(L){return e.enter("tableRow"),Y(L)}function Y(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),Y):L===null||Pe(L)?(e.exit("tableRow"),n(L)):Qe(L)?it(e,Y,"whitespace")(L):(e.enter("data"),J(L))}function J(L){return L===null||L===124||Tt(L)?(e.exit("data"),Y(L)):(e.consume(L),L===92?F:J)}function F(L){return L===92||L===124?(e.consume(L),J):J(L)}}function V3(e,n){let r=-1,s=!0,l=0,u=[0,0,0,0],c=[0,0,0,0],f=!1,m=0,d,y,g;const x=new I3;for(;++r<e.length;){const w=e[r],E=w[1];w[0]==="enter"?E.type==="tableHead"?(f=!1,m!==0&&(Ob(x,n,m,d,y),y=void 0,m=0),d={type:"table",start:Object.assign({},E.start),end:Object.assign({},E.end)},x.add(r,0,[["enter",d,n]])):E.type==="tableRow"||E.type==="tableDelimiterRow"?(s=!0,g=void 0,u=[0,0,0,0],c=[0,r+1,0,0],f&&(f=!1,y={type:"tableBody",start:Object.assign({},E.start),end:Object.assign({},E.end)},x.add(r,0,[["enter",y,n]])),l=E.type==="tableDelimiterRow"?2:y?3:1):l&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")?(s=!1,c[2]===0&&(u[1]!==0&&(c[0]=c[1],g=xu(x,n,u,l,void 0,g),u=[0,0,0,0]),c[2]=r)):E.type==="tableCellDivider"&&(s?s=!1:(u[1]!==0&&(c[0]=c[1],g=xu(x,n,u,l,void 0,g)),u=c,c=[u[1],r,0,0])):E.type==="tableHead"?(f=!0,m=r):E.type==="tableRow"||E.type==="tableDelimiterRow"?(m=r,u[1]!==0?(c[0]=c[1],g=xu(x,n,u,l,r,g)):c[1]!==0&&(g=xu(x,n,c,l,r,g)),l=0):l&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")&&(c[3]=r)}for(m!==0&&Ob(x,n,m,d,y),x.consume(n.events),r=-1;++r<n.events.length;){const w=n.events[r];w[0]==="enter"&&w[1].type==="table"&&(w[1]._align=$3(n.events,r))}return e}function xu(e,n,r,s,l,u){const c=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",f="tableContent";r[0]!==0&&(u.end=Object.assign({},ea(n.events,r[0])),e.add(r[0],0,[["exit",u,n]]));const m=ea(n.events,r[1]);if(u={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(r[1],0,[["enter",u,n]]),r[2]!==0){const d=ea(n.events,r[2]),y=ea(n.events,r[3]),g={type:f,start:Object.assign({},d),end:Object.assign({},y)};if(e.add(r[2],0,[["enter",g,n]]),s!==2){const x=n.events[r[2]],w=n.events[r[3]];if(x[1].end=Object.assign({},w[1].end),x[1].type="chunkText",x[1].contentType="text",r[3]>r[2]+1){const E=r[2]+1,M=r[3]-r[2]-1;e.add(E,M,[])}}e.add(r[3]+1,0,[["exit",g,n]])}return l!==void 0&&(u.end=Object.assign({},ea(n.events,l)),e.add(l,0,[["exit",u,n]]),u=void 0),u}function Ob(e,n,r,s,l){const u=[],c=ea(n.events,r);l&&(l.end=Object.assign({},c),u.push(["exit",l,n])),s.end=Object.assign({},c),u.push(["exit",s,n]),e.add(r+1,0,u)}function ea(e,n){const r=e[n],s=r[0]==="enter"?"start":"end";return r[1][s]}const J3={name:"tasklistCheck",tokenize:K3};function X3(){return{text:{91:J3}}}function K3(e,n,r){const s=this;return l;function l(m){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?r(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),u)}function u(m){return Tt(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):r(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):r(m)}function f(m){return Pe(m)?n(m):Qe(m)?e.check({tokenize:Q3},n,r)(m):r(m)}}function Q3(e,n,r){return it(e,s,"whitespace");function s(l){return l===null?r(l):n(l)}}function Z3(e){return Vx([_3(),M3(),H3(e),Y3(),X3()])}const W3={};function Rb(e){const n=this,r=e||W3,s=n.data(),l=s.micromarkExtensions||(s.micromarkExtensions=[]),u=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);l.push(Z3(r)),u.push(x3()),c.push(v3(r))}function eO(e){m1(e,[/\r?\n|\r/g,tO])}function tO(){return{type:"break"}}function Mb(){return function(e){eO(e)}}function nO({connected:e,hostId:n,request:r,subscribeEvents:s,taskId:l,runId:u}){const c=ti(),[f,m]=N.useState(!0),[d,y]=N.useState([]),[g,x]=N.useState(),[w,E]=N.useState(),M=g==="started"||g==="monitoring",P=g==="followup",z=g==="started"||g==="followup",[I,j]=N.useState(null),[K,B]=N.useState(!1),[R,Y]=N.useState(""),[J,F]=N.useState(!1),L=N.useRef(null),W=N.useRef(null),Q=N.useRef(null),[oe,ae]=N.useState(u==="latest"?void 0:u),G=u==="latest"&&oe===null;N.useEffect(()=>{if(u!=="latest"){ae(u);return}e&&(ae(void 0),r("taskrun.list",{task_id:l,limit:1}).then(_=>{var D,ee;return ae(((ee=(D=_.entries)==null?void 0:D[0])==null?void 0:ee.run_id)??null)}).catch(()=>ae(null)))},[u,l,e,r]);async function H(){if(oe)try{const _=await r("task.result",{id:l,run_id:oe});if(_.error){console.error("No result:",_.error),c("/runs",{replace:!0});return}y(_.messages??[]),x(_.running_state),E(_.agent)}catch(_){console.error("Failed to load result:",_),c("/runs",{replace:!0})}finally{m(!1)}}async function X(_){var D;if(oe)try{const A=(D=(await r("task.reports",{id:l,run_id:oe,report_files:[_]})).reports)==null?void 0:D[0];A!=null&&A.data_url?j({file:_,data_url:A.data_url}):j({file:_,content:(A==null?void 0:A.content)??"Report not found."})}catch{j({file:_,content:"Failed to load report."})}}N.useEffect(()=>{!e||!oe||(m(!0),H())},[e,l,oe]),N.useEffect(()=>!e||!n||!oe?void 0:s(n,async D=>{try{const ee=JSON.parse(new TextDecoder().decode(D.data));if(ee.event_type!=="running-state"&&ee.event_type!=="result-updated"||D.subject.split(".").pop()!==l||ee.event_type==="result-updated"&&ee.run_id&&ee.run_id!==oe)return;H()}catch{}}),[e,n,l,oe,s,r]),N.useEffect(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight)},[d]),N.useEffect(()=>{f||G||!oe||Q.current!==oe&&(Q.current=oe,requestAnimationFrame(()=>{L.current&&(L.current.scrollTop=L.current.scrollHeight),window.scrollTo({top:document.documentElement.scrollHeight,behavior:"auto"})}))},[f,G,oe]);function ue(_){if(_==="input")return"User Input";if(_==="permission")return"Permission";if(_==="confirmation")return"Confirmation"}function _e(_){return _==="started"?"Task started":_==="finished"?"Task finished":_==="failed"?"Task failed":_==="error"?"Command failed":_==="aborted"?"Task aborted":_==="confirmation"?"Task confirmed":_==="stopped"?"Follow-up stopped":_??""}return b.jsxs("div",{className:"run-detail",children:[b.jsxs("button",{className:"run-detail-back",onClick:()=>c(-1),children:[b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:b.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back"]}),G?b.jsxs("div",{className:"empty-state",children:[b.jsx("p",{className:"empty-state-text",children:"No runs yet"}),b.jsx("p",{className:"empty-state-hint",children:"This task hasn't been executed yet. Run it from the task menu or wait for its next trigger."})]}):f?b.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)",padding:"var(--space-sm) 0"},children:[b.jsx("div",{className:"skeleton-line",style:{width:"40%"}}),b.jsx("div",{className:"skeleton-line",style:{width:"55%"}}),b.jsx("div",{className:"skeleton-line",style:{width:"100%",height:"8rem",marginTop:"var(--space-sm)"}})]}):b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"chat-thread",ref:L,children:[d.map((_,D)=>{const ee=z&&_.role==="assistant"&&!d.slice(D+1).some(A=>A.role==="assistant"||A.role==="user");return _.role==="status"&&_.type==="monitoring"?null:_.role==="status"?b.jsxs("div",{className:`chat-status${_.type==="error"?" chat-status--error":""}`,children:[b.jsxs("div",{children:[_e(_.type),_.time>0&&b.jsx("span",{className:"chat-status-time",children:Uu(_.time)})]}),_.content&&b.jsx("pre",{className:"chat-status-detail",children:_.content})]},D):b.jsxs("div",{className:`chat-message chat-message--${_.role}`,children:[_.role==="assistant"&&w&&b.jsx("div",{className:"chat-message-agent",children:hd(w)}),b.jsxs("div",{className:"chat-message-content",children:[b.jsx(Eb,{remarkPlugins:[Rb,Mb],children:_.content}),ee&&b.jsxs("div",{className:"chat-typing-indicator",children:[b.jsx("span",{}),b.jsx("span",{}),b.jsx("span",{})]})]}),_.attachments&&_.attachments.length>0&&b.jsx("div",{className:"chat-message-attachments",children:_.attachments.map(A=>b.jsx("button",{className:"chat-attachment-chip",onClick:()=>X(A),children:A},A))}),b.jsxs("div",{className:"chat-message-meta",children:[ue(_.type)&&b.jsx("span",{className:"chat-message-type",children:ue(_.type)}),_.time>0&&b.jsx("span",{children:Uu(_.time)})]})]},D)}),z&&(()=>{const _=d.filter(D=>D.role!=="status");return _.length===0||_[_.length-1].role!=="assistant"})()&&b.jsxs("div",{className:"chat-message chat-message--assistant",children:[w&&b.jsx("div",{className:"chat-message-agent",children:hd(w)}),b.jsxs("div",{className:"chat-typing-indicator",children:[b.jsx("span",{}),b.jsx("span",{}),b.jsx("span",{})]})]}),g==="monitoring"&&b.jsxs("div",{className:"chat-monitoring-indicator",children:[b.jsx("span",{className:"chat-monitoring-dot"}),"Monitoring command output"]})]}),M?b.jsx("div",{className:"chat-abort-bar",children:b.jsx("button",{className:"btn btn-secondary chat-abort-btn",disabled:K,onClick:async()=>{if(confirm("Abort this task?")){B(!0);try{await r("task.abort",{id:l})}catch(_){console.error("Abort failed:",_)}finally{B(!1)}}},children:K?"Aborting...":"Abort Task"})}):P?b.jsx("div",{className:"chat-input-bar",children:b.jsx("button",{className:"btn btn-secondary chat-stop-btn",disabled:K,onClick:async()=>{B(!0);try{await r("task.stop_followup",{id:l,run_id:oe})}catch(_){console.error("Stop failed:",_)}finally{B(!1)}},children:b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:b.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})})}):b.jsxs("form",{className:"chat-input-bar",onSubmit:async _=>{_.preventDefault();const D=R.trim();if(!(!D||J)){F(!0);try{await r("task.followup",{id:l,run_id:oe,message:D}),Y("")}catch(ee){console.error("Follow-up failed:",ee)}finally{F(!1)}}},children:[b.jsx("input",{ref:W,className:"chat-input",type:"text",placeholder:"Follow-up message",value:R,onChange:_=>Y(_.target.value),disabled:J}),b.jsx("button",{className:"btn btn-primary chat-send-btn",type:"submit",disabled:!R.trim()||J,children:b.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),b.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]}),I&&b.jsx("div",{className:"report-dialog-overlay",onClick:()=>j(null),children:b.jsxs("div",{className:"report-dialog",onClick:_=>_.stopPropagation(),children:[b.jsxs("div",{className:"report-dialog-header",children:[b.jsx("span",{className:"report-dialog-title",children:I.file}),b.jsx("button",{className:"report-dialog-close",onClick:()=>j(null),"aria-label":"Close",children:b.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),b.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),b.jsx("div",{className:"report-dialog-body",children:I.data_url?b.jsx("img",{src:I.data_url,alt:I.file,style:{maxWidth:"100%",height:"auto"}}):b.jsx(Eb,{remarkPlugins:[Rb,Mb],components:{a:({..._})=>b.jsx("a",{..._,target:"_blank",rel:"noopener noreferrer"})},children:I.content??""})})]})})]})}function rO(){const{getActiveHost:e}=ba(),n=e(),r=N.useRef(null);N.useEffect(()=>{if(pr.isNativePlatform()||!n||n.directUrl||r.current===n.hostId)return;async function s(){var l;try{if(!("serviceWorker"in navigator)||!("PushManager"in window)){console.warn("[Push] Push notifications not supported");return}const u=await navigator.serviceWorker.ready;(l=u.active)==null||l.postMessage({type:"set-host-id",hostId:n.hostId});let c=await u.pushManager.getSubscription();if(!c){const{publicKey:m}=await ak("/api/push/vapid-key");if(!m){console.warn("[Push] No VAPID public key configured on server");return}if(await Notification.requestPermission()!=="granted"){console.log("[Push] Permission denied");return}c=await u.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:m})}const f=c.toJSON();await sk("/api/push/subscribe",{hostId:n.hostId,endpoint:f.endpoint,keys:{p256dh:f.keys.p256dh,auth:f.keys.auth}}),r.current=n.hostId}catch(u){console.error("[Push] Subscription failed:",u)}}s()},[n])}const iO="0.8.5";function sO(e,n){if(e.includes("-"))return!1;const r=e.split(".").map(Number),s=n.split(".").map(Number);for(let l=0;l<3;l++){if((r[l]??0)<(s[l]??0))return!0;if((r[l]??0)>(s[l]??0))return!1}return!1}function Sl(){var He;const{pairedHosts:e,activeHostId:n,removePairedHost:r}=ba(),{connected:s,request:l,subscribeEvents:u,unauthorized:c}=Yl(),f=ti(),m=Tr(),d=BS(),y=Nx("(min-width: 768px)"),g=m.pathname.startsWith("/tasks"),x=d.runId?void 0:d.taskId,w=!!(d.taskId&&d.runId),[E,M]=N.useState(!1),[P,z]=N.useState(!1),[I,j]=N.useState(null),[K,B]=N.useState(null),[R,Y]=N.useState({}),[J,F]=N.useState([]),[L,W]=N.useState(),[Q,oe]=N.useState(new Map),[ae,G]=N.useState(new Map),[H,X]=N.useState(new Map),[ue,_e]=N.useState(new Map);rO(),N.useEffect(()=>{window.scrollTo(0,0)},[n]),N.useEffect(()=>{s&&l("host.info").then(be=>{var Fe,Ue,tt,mt,st,Mt;F(be.agents??[]),W(be.host_platform),Y(be.capability_tokens??{}),uk(be.agents??[]);const De=be.version??null;B(De),M(!!De&&sO(De,iO));const Ze=new Map,dt=new Map,lt=new Map,ct=new Map;for(const yt of be.pending_prompts??[])if(yt.type==="confirmation")Ze.set(yt.key,{description:((Fe=yt.meta)==null?void 0:Fe.description)??"",sessionName:(Ue=yt.meta)==null?void 0:Ue.session_name});else if(yt.type==="permission")dt.set(yt.key,{permissions:yt.params??[],sessionName:(tt=yt.meta)==null?void 0:tt.session_name});else if(yt.type==="input"){const $n=yt.params??((mt=yt.meta)==null?void 0:mt.input_questions)??[];lt.set(yt.key,{questions:$n,description:(st=yt.meta)==null?void 0:st.description,sessionName:(Mt=yt.meta)==null?void 0:Mt.session_name}),ct.set(yt.key,new Array($n.length).fill(""))}oe(Ze),G(dt),X(lt),_e(ct)}).catch(()=>{})},[s,n,l]),N.useEffect(()=>!s||!n?void 0:u(n,De=>{const Ze=De.subject.split(".");if(Ze.length<3)return;const dt=Ze.slice(2).join(".");let lt={};try{lt=JSON.parse(new TextDecoder().decode(De.data))}catch{return}const ct=lt.event_type,Fe=lt.session_id;if(ct==="input-request"&&Fe){const Ue=lt.input_questions,tt=lt.session_name,mt=lt.description;Ue!=null&&Ue.length&&(X(st=>{if(st.has(Fe))return st;const Mt=new Map(st);return Mt.set(Fe,{questions:Ue,description:mt,sessionName:tt}),Mt}),_e(st=>{if(st.has(Fe))return st;const Mt=new Map(st);return Mt.set(Fe,new Array(Ue.length).fill("")),Mt}));return}if(ct==="input-resolved"&&Fe){X(Ue=>{if(!Ue.has(Fe))return Ue;const tt=new Map(Ue);return tt.delete(Fe),tt}),_e(Ue=>{const tt=new Map(Ue);return tt.delete(Fe),tt});return}if(ct==="confirm-request"&&Fe){const Ue=lt.description,tt=lt.session_name;Ue&&oe(mt=>{if(mt.has(Fe))return mt;const st=new Map(mt);return st.set(Fe,{description:Ue,sessionName:tt}),st});return}if(ct==="confirm-resolved"&&Fe){oe(Ue=>{if(!Ue.has(Fe))return Ue;const tt=new Map(Ue);return tt.delete(Fe),tt});return}if(ct==="permission-request"){const Ue=lt.required_permissions,tt=lt.session_name;Ue!=null&&Ue.length&&G(mt=>{if(mt.has(dt))return mt;const st=new Map(mt);return st.set(dt,{permissions:Ue,sessionName:tt}),st});return}if(ct==="permission-resolved"){G(Ue=>{if(!Ue.has(dt))return Ue;const tt=new Map(Ue);return tt.delete(dt),tt});return}}),[s,n,u]);async function _(be,De){try{await l("task.user_input",{id:be,value:[De]})}catch(Ze){console.error("[Dashboard] Failed to respond to confirmation:",Ze)}}async function D(be,De){try{await l("task.user_input",{id:be,value:[De]})}catch(Ze){console.error("[Dashboard] Failed to respond to permission request:",Ze)}}async function ee(be,De){try{await l("task.user_input",{id:be,value:De})}catch(Ze){console.error("[Dashboard] Failed to respond to input request:",Ze)}}function A(be,De){hs()&&f(De?`/runs/${encodeURIComponent(be)}/${encodeURIComponent(De)}`:`/runs/${encodeURIComponent(be)}`)}async function ve(){z(!0),j(null);try{const be=await l("host.update");if(be.error){j(be.error),z(!1);return}}catch{}setTimeout(()=>window.location.reload(),15e3)}const Ae=e.length>0,Te=Ae&&s&&n&&!c,Me=((He=e.find(be=>be.hostId===n))==null?void 0:He.clientToken)??null;return b.jsxs("div",{className:"dashboard",children:[y&&b.jsx(P0,{daemonVersion:K,capabilityTokens:R,activeClientToken:Me,request:l,onCapabilityTokensChange:Y}),b.jsxs("div",{className:"dashboard-content",children:[b.jsxs("header",{className:"app-header",children:[b.jsxs("div",{className:"app-title-bar",children:[!y&&b.jsx(P0,{daemonVersion:K,capabilityTokens:R,activeClientToken:Me,request:l,onCapabilityTokensChange:Y}),b.jsx("h1",{className:"app-title",children:"Palmier"})]}),b.jsx("div",{className:"tab-bar",children:b.jsx(_k,{})})]}),b.jsx("main",{className:"dashboard-main",children:c?b.jsxs("div",{className:"revoked-state",children:[b.jsx("div",{className:"revoked-icon",children:b.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[b.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),b.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}),b.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"18"})]})}),b.jsx("h2",{className:"revoked-title",children:"Client Revoked"}),b.jsx("p",{className:"revoked-description",children:"This client was revoked by the host. To reconnect, generate a new pairing code on the host machine."}),b.jsx("div",{className:"revoked-command",children:b.jsx("code",{children:"palmier pair"})}),b.jsxs("div",{className:"revoked-actions",children:[b.jsx("button",{className:"btn btn-primary",onClick:()=>{hs()&&f("/pair")},children:"Re-pair Device"}),b.jsx("button",{className:"btn btn-secondary",onClick:()=>{n&&r(n)},children:"Remove Host"})]})]}):Te?b.jsxs(b.Fragment,{children:[g&&!w&&b.jsx(Sk,{connected:s,hostId:n,request:l,subscribeEvents:u,agents:J,hostPlatform:L,isNotificationListener:!!Me&&R.notifications===Me,onViewRun:A}),w?b.jsx(nO,{connected:s,hostId:n,request:l,subscribeEvents:u,taskId:d.taskId,runId:decodeURIComponent(d.runId)}):g?null:b.jsx(Rk,{connected:s,hostId:n,request:l,subscribeEvents:u,agents:J,hostPlatform:L,filterTaskId:x,onClearFilter:()=>{hs()&&f("/")}})]}):b.jsxs("div",{className:"empty-state",children:[b.jsx("p",{children:Ae?"Connecting to host...":"No host computer paired yet."}),!Ae&&b.jsx("button",{className:"btn btn-primary",onClick:()=>f("/pair"),children:"Pair Host"})]})}),E&&!P&&!I&&b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Update Required"}),b.jsxs("p",{className:"confirm-modal-message",children:["Your Palmier host",K?` (v${K})`:""," is too old for this version of the app. Please update to continue."]}),b.jsx("div",{className:"confirm-modal-actions",children:b.jsx("button",{className:"btn btn-primary",onClick:ve,children:"Update Now"})})]})}),P&&b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Updating..."}),b.jsx("p",{className:"confirm-modal-message",children:"Installing update and restarting daemon. Please wait..."})]})}),I&&b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Update Failed"}),b.jsx("p",{className:"confirm-modal-message",style:{whiteSpace:"pre-line"},children:I}),b.jsx("div",{className:"confirm-modal-actions",children:b.jsx("button",{className:"btn btn-secondary",onClick:()=>{j(null)},children:"Retry"})})]})})]}),ca.createPortal(b.jsxs(b.Fragment,{children:[[...Q.entries()].map(([be,{description:De,sessionName:Ze}])=>b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Confirmation Required"}),Ze&&b.jsx("p",{className:"confirm-modal-subtitle",children:Ze}),b.jsx("p",{className:"confirm-modal-message",children:De}),b.jsxs("div",{className:"confirm-modal-actions",children:[b.jsx("button",{className:"btn btn-primary",onClick:()=>_(be,"confirmed"),children:"Confirm"}),b.jsx("button",{className:"btn btn-secondary",onClick:()=>_(be,"aborted"),children:"Abort"})]})]})},be)),[...ae.entries()].map(([be,{permissions:De,sessionName:Ze}])=>b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal permission-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Permission Required"}),b.jsx("p",{className:"confirm-modal-message",children:b.jsx("strong",{children:Ze||be})}),b.jsx("div",{className:"permission-list",children:De.map((dt,lt)=>b.jsxs("div",{className:"permission-item",children:[b.jsx("span",{className:"permission-name",children:dt.name}),dt.description&&b.jsx("span",{className:"permission-desc",children:dt.description})]},lt))}),b.jsxs("div",{className:"permission-actions",children:[b.jsx("button",{className:"btn btn-primary",onClick:()=>D(be,"granted"),children:"Allow Once"}),b.jsx("button",{className:"btn btn-secondary",onClick:()=>D(be,"granted_all"),children:"Allow Always"})]}),b.jsx("button",{className:"permission-abort-link",onClick:()=>D(be,"aborted"),children:"Deny & Abort Task"})]})},be)),[...H.entries()].map(([be,{questions:De,description:Ze,sessionName:dt}])=>{const lt=ue.get(be)??new Array(De.length).fill("");return b.jsx("div",{className:"confirm-modal-overlay",children:b.jsxs("div",{className:"confirm-modal input-modal",children:[b.jsx("h2",{className:"confirm-modal-title",children:"Input Required"}),dt&&b.jsx("p",{className:"confirm-modal-subtitle",children:dt}),Ze&&b.jsx("p",{className:"confirm-modal-message",children:Ze}),b.jsx("div",{className:"input-list",children:De.map((ct,Fe)=>b.jsxs("div",{className:"input-item",children:[b.jsx("label",{className:"input-label",children:ct}),b.jsx("input",{type:"text",className:"input-field",value:lt[Fe]??"",onChange:Ue=>{_e(tt=>{const mt=new Map(tt),st=[...mt.get(be)??[]];return st[Fe]=Ue.target.value,mt.set(be,st),mt})},autoFocus:Fe===0})]},Fe))}),b.jsx("div",{className:"input-actions",children:b.jsx("button",{className:"btn btn-primary",disabled:lt.some(ct=>!ct.trim()),onClick:()=>ee(be,lt),children:"Submit"})}),b.jsx("button",{className:"permission-abort-link",onClick:()=>ee(be,["aborted"]),children:"Cancel"})]})},be)})]}),document.body)]})}const aO=va("Preferences",{web:()=>Ox(()=>import("./web-DYwZE4qa.js"),[]).then(e=>new e.PreferencesWeb)}),_l=!!window.__PALMIER_SERVE__;function lO(){const[e,n]=N.useState(""),[r,s]=N.useState(!1),[l,u]=N.useState(null),{addPairedHost:c}=ba(),f=ti();async function m(){const d=e.trim().toUpperCase();if(!d){u("Enter a pairing code.");return}s(!0),u(null);try{let y;if(_l){const x=await fetch("/pair",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:d,label:navigator.userAgent})});if(!x.ok){const w=await x.json().catch(()=>({error:"Connection failed"}));throw new Error(w.error||`HTTP ${x.status}`)}y=await x.json()}else{const x=await fetch(`${zu}/api/config`);if(!x.ok)throw new Error("Failed to fetch server config");const w=await x.json();if(!w.natsWsUrl)throw new Error("Server has no NATS WebSocket URL configured");const E=await _x({servers:w.natsWsUrl,authenticator:mx(w.natsJwt,new TextEncoder().encode(w.natsNkeySeed))}),M=ju(),P=`pair.${d}`,z=await E.request(P,M.encode(JSON.stringify({label:navigator.userAgent})),{timeout:1e4});y=JSON.parse(M.decode(z.data)),await E.close()}const g={hostId:y.hostId,clientToken:y.clientToken,directUrl:_l?window.location.origin:void 0,...y.hostName?{name:y.hostName}:{}};if(c(g),pr.isNativePlatform()&&Ut){await aO.set({key:"hostId",value:y.hostId});try{const{token:x}=await Ut.getFcmToken();await fetch(`${zu}/api/fcm/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hostId:y.hostId,fcmToken:x})})}catch(x){console.warn("FCM token registration failed:",x)}}f(pr.isNativePlatform()?"/pair/setup":"/")}catch(y){const g=y instanceof Error?y.message:String(y);g.includes("timeout")||g.includes("TIMEOUT")||g.includes("503")||g.toLowerCase().includes("no responders")?u("Code not found or expired. Check the code and try again."):u(g)}finally{s(!1)}}return b.jsx("div",{className:"pair-page",children:b.jsxs("div",{className:"pair-card",children:[b.jsxs("div",{className:"pair-header",children:[b.jsx("h1",{className:"pair-title",children:_l?"Pair":"Pair with Host"}),b.jsx("p",{className:"pair-subtitle",children:_l?"Enter the pairing code shown in your terminal.":"Connect this device to a Palmier host"})]}),!_l&&b.jsxs("div",{className:"pair-instructions",children:[b.jsxs("div",{className:"pair-instruction-block",children:[b.jsx("h3",{className:"pair-instruction-heading",children:"Setting up a new host?"}),b.jsxs("ol",{className:"pair-steps",children:[b.jsxs("li",{children:["Install at least one agent CLI (e.g., ",b.jsx("a",{href:"https://www.palmier.me/agents",target:"_blank",rel:"noopener noreferrer",children:"Claude Code, Gemini CLI, Codex CLI"}),")"]}),b.jsxs("li",{children:["Install Palmier on your host machine:",b.jsx("code",{className:"pair-command",children:"npm install -g palmier"})]}),b.jsxs("li",{children:["Run the setup wizard:",b.jsx("code",{className:"pair-command",children:"palmier init"})]}),b.jsx("li",{children:"A pairing code will display automatically"})]})]}),b.jsx("div",{className:"pair-instruction-divider"}),b.jsxs("div",{className:"pair-instruction-block",children:[b.jsx("h3",{className:"pair-instruction-heading",children:"Pairing an existing host?"}),b.jsxs("ol",{className:"pair-steps",children:[b.jsxs("li",{children:["Run ",b.jsx("code",{children:"palmier pair"})," on the host machine"]}),b.jsx("li",{children:"Enter the 6-character code below"})]})]})]}),b.jsxs("div",{className:"pair-form",children:[b.jsxs("label",{className:"form-label",htmlFor:"pair-code",children:["Pairing code",b.jsx("input",{id:"pair-code",type:"text",maxLength:6,value:e,onChange:d=>n(d.target.value.toUpperCase()),placeholder:"A7K9M2",className:"form-input form-input-mono pair-code-input",autoFocus:!0,autoComplete:"off",disabled:r})]}),l&&b.jsx("p",{className:"pair-error",children:l}),b.jsxs("button",{className:"btn btn-primary btn-full",onClick:m,disabled:r||!e.trim(),children:[r&&b.jsx("span",{className:"btn-spinner"}),r?"Pairing...":"Pair"]}),b.jsx("button",{className:"btn btn-secondary btn-full",onClick:()=>f("/"),disabled:r,children:"Cancel"}),b.jsxs("p",{className:"pair-consent",children:["By pairing, you agree to our"," ",b.jsx("a",{href:"https://www.palmier.me/terms",target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})," and"," ",b.jsx("a",{href:"https://www.palmier.me/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"}),"."]})]})]})})}function oO(){const e=ti(),{connected:n,request:r}=Yl(),{getActiveHost:s}=ba(),l=s(),u=(l==null?void 0:l.clientToken)??null,[c,f]=N.useState({}),[m,d]=N.useState(!1);return N.useEffect(()=>{l||e("/",{replace:!0})},[l,e]),N.useEffect(()=>{if(!n||!l)return;let y=!1;return r("host.info").then(g=>{y||(f(g.capability_tokens??{}),d(!0))}).catch(()=>{y||d(!0)}),()=>{y=!0}},[n,l,r]),b.jsx("div",{className:"pair-setup",children:b.jsxs("div",{className:"pair-setup-inner",children:[b.jsx("h1",{className:"pair-setup-title",children:"What capabilities of this device do you want your host computer to have?"}),b.jsx("p",{className:"pair-setup-description",children:"You can change these later from the menu."}),m?b.jsx(Rx,{capabilityTokens:c,activeClientToken:u,request:r,onCapabilityTokensChange:f}):b.jsx("div",{className:"pair-setup-loading",children:"Connecting to host…"}),b.jsx("div",{className:"pair-setup-actions",children:b.jsx("button",{className:"btn btn-primary btn-full",onClick:()=>e("/",{replace:!0}),children:"Finish"})})]})})}function uO(){const e=ti();return N.useEffect(()=>{if(!Ut)return;const n=Ut.addListener("deepLink",({path:r})=>e(r));return()=>{n.then(r=>r.remove())}},[e]),null}function cO(){return b.jsx(U_,{children:b.jsxs(ok,{children:[b.jsx(uO,{}),b.jsxs(WS,{children:[b.jsx(Mi,{path:"/",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/tasks",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/runs",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/runs/:taskId",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/runs/:taskId/:runId",element:b.jsx(Sl,{})}),b.jsx(Mi,{path:"/pair",element:b.jsx(lO,{})}),b.jsx(Mi,{path:"/pair/setup",element:b.jsx(oO,{})})]})]})})}tS.createRoot(document.getElementById("root")).render(b.jsx(N.StrictMode,{children:b.jsx(__,{children:b.jsx(cO,{})})}));export{Pd as W};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as p}from"./index-
|
|
1
|
+
import{W as p}from"./index-BiAE5qeC.js";class f extends p{constructor(){super(...arguments),this.group="CapacitorStorage"}async configure({group:e}){typeof e=="string"&&(this.group=e)}async get(e){return{value:this.impl.getItem(this.applyPrefix(e.key))}}async set(e){this.impl.setItem(this.applyPrefix(e.key),e.value)}async remove(e){this.impl.removeItem(this.applyPrefix(e.key))}async keys(){return{keys:this.rawKeys().map(t=>t.substring(this.prefix.length))}}async clear(){for(const e of this.rawKeys())this.impl.removeItem(e)}async migrate(){var e;const t=[],s=[],n="_cap_",o=Object.keys(this.impl).filter(i=>i.indexOf(n)===0);for(const i of o){const r=i.substring(n.length),a=(e=this.impl.getItem(i))!==null&&e!==void 0?e:"",{value:l}=await this.get({key:r});typeof l=="string"?s.push(r):(await this.set({key:r,value:a}),t.push(r))}return{migrated:t,existing:s}}async removeOld(){const e="_cap_",t=Object.keys(this.impl).filter(s=>s.indexOf(e)===0);for(const s of t)this.impl.removeItem(s)}get impl(){return window.localStorage}get prefix(){return this.group==="NativeStorage"?"":`${this.group}.`}rawKeys(){return Object.keys(this.impl).filter(e=>e.indexOf(this.prefix)===0)}applyPrefix(e){return this.prefix+e}}export{f as PreferencesWeb};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as t}from"./index-
|
|
1
|
+
import{W as t}from"./index-BiAE5qeC.js";class s extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}export{s as AppWeb};
|
package/dist/pwa/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
9
9
|
<title>Palmier</title>
|
|
10
10
|
<meta name="description" content="Remote control for AI agents running on your own machine. Schedule tasks, approve permissions, and get push notifications." />
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-BiAE5qeC.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-UaZFu6XL.css">
|
|
13
13
|
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
|
14
14
|
<body>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
try{self["workbox:core:7.3.0"]&&_()}catch{}const N=(n,...e)=>{let t=n;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},E=N;class h extends Error{constructor(e,t){const s=E(e,t);super(s),this.name=e,this.details=t}}const f={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration<"u"?registration.scope:""},U=n=>[f.prefix,n,f.suffix].filter(e=>e&&e.length>0).join("-"),O=n=>{for(const e of Object.keys(f))n(e)},L={updateDetails:n=>{O(e=>{typeof n[e]=="string"&&(f[e]=n[e])})},getGoogleAnalyticsName:n=>n||U(f.googleAnalytics),getPrecacheName:n=>n||U(f.precache),getPrefix:()=>f.prefix,getRuntimeName:n=>n||U(f.runtime),getSuffix:()=>f.suffix};function v(n,e){const t=e();return n.waitUntil(t),t}try{self["workbox:precaching:7.3.0"]&&_()}catch{}const A="__WB_REVISION__";function M(n){if(!n)throw new h("add-to-cache-list-unexpected-type",{entry:n});if(typeof n=="string"){const i=new URL(n,location.href);return{cacheKey:i.href,url:i.href}}const{revision:e,url:t}=n;if(!t)throw new h("add-to-cache-list-unexpected-type",{entry:n});if(!e){const i=new URL(t,location.href);return{cacheKey:i.href,url:i.href}}const s=new URL(t,location.href),a=new URL(t,location.href);return s.searchParams.set(A,e),{cacheKey:s.href,url:a.href}}class W{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:e,state:t})=>{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:s})=>{if(e.type==="install"&&t&&t.originalRequest&&t.originalRequest instanceof Request){const a=t.originalRequest.url;s?this.notUpdatedURLs.push(a):this.updatedURLs.push(a)}return s}}}class q{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:t,params:s})=>{const a=(s==null?void 0:s.cacheKey)||this._precacheController.getCacheKeyForURL(t.url);return a?new Request(a,{headers:t.headers}):t},this._precacheController=e}}let w;function S(){if(w===void 0){const n=new Response("");if("body"in n)try{new Response(n.body),w=!0}catch{w=!1}w=!1}return w}async function j(n,e){let t=null;if(n.url&&(t=new URL(n.url).origin),t!==self.location.origin)throw new h("cross-origin-copy-response",{origin:t});const s=n.clone(),i={headers:new Headers(s.headers),status:s.status,statusText:s.statusText},r=S()?s.body:await s.blob();return new Response(r,i)}const D=n=>new URL(String(n),location.href).href.replace(new RegExp(`^${location.origin}`),"");function T(n,e){const t=new URL(n);for(const s of e)t.searchParams.delete(s);return t.href}async function H(n,e,t,s){const a=T(e.url,t);if(e.url===a)return n.match(e,s);const i=Object.assign(Object.assign({},s),{ignoreSearch:!0}),r=await n.keys(e,i);for(const c of r){const o=T(c.url,t);if(a===o)return n.match(c,s)}}class F{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}const B=new Set;async function $(){for(const n of B)await n()}function V(n){return new Promise(e=>setTimeout(e,n))}try{self["workbox:strategies:7.3.0"]&&_()}catch{}function C(n){return typeof n=="string"?new Request(n):n}class G{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new F,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const s of this._plugins)this._pluginStateMap.set(s,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:t}=this;let s=C(e);if(s.mode==="navigate"&&t instanceof FetchEvent&&t.preloadResponse){const r=await t.preloadResponse;if(r)return r}const a=this.hasCallback("fetchDidFail")?s.clone():null;try{for(const r of this.iterateCallbacks("requestWillFetch"))s=await r({request:s.clone(),event:t})}catch(r){if(r instanceof Error)throw new h("plugin-error-request-will-fetch",{thrownErrorMessage:r.message})}const i=s.clone();try{let r;r=await fetch(s,s.mode==="navigate"?void 0:this._strategy.fetchOptions);for(const c of this.iterateCallbacks("fetchDidSucceed"))r=await c({event:t,request:i,response:r});return r}catch(r){throw a&&await this.runCallbacks("fetchDidFail",{error:r,event:t,originalRequest:a.clone(),request:i.clone()}),r}}async fetchAndCachePut(e){const t=await this.fetch(e),s=t.clone();return this.waitUntil(this.cachePut(e,s)),t}async cacheMatch(e){const t=C(e);let s;const{cacheName:a,matchOptions:i}=this._strategy,r=await this.getCacheKey(t,"read"),c=Object.assign(Object.assign({},i),{cacheName:a});s=await caches.match(r,c);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await o({cacheName:a,matchOptions:i,cachedResponse:s,request:r,event:this.event})||void 0;return s}async cachePut(e,t){const s=C(e);await V(0);const a=await this.getCacheKey(s,"write");if(!t)throw new h("cache-put-with-no-response",{url:D(a.url)});const i=await this._ensureResponseSafeToCache(t);if(!i)return!1;const{cacheName:r,matchOptions:c}=this._strategy,o=await self.caches.open(r),l=this.hasCallback("cacheDidUpdate"),d=l?await H(o,a.clone(),["__WB_REVISION__"],c):null;try{await o.put(a,l?i.clone():i)}catch(u){if(u instanceof Error)throw u.name==="QuotaExceededError"&&await $(),u}for(const u of this.iterateCallbacks("cacheDidUpdate"))await u({cacheName:r,oldResponse:d,newResponse:i.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){const s=`${e.url} | ${t}`;if(!this._cacheKeys[s]){let a=e;for(const i of this.iterateCallbacks("cacheKeyWillBeUsed"))a=C(await i({mode:t,request:a,event:this.event,params:this.params}));this._cacheKeys[s]=a}return this._cacheKeys[s]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const s of this.iterateCallbacks(e))await s(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if(typeof t[e]=="function"){const s=this._pluginStateMap.get(t);yield i=>{const r=Object.assign(Object.assign({},i),{state:s});return t[e](r)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){for(;this._extendLifetimePromises.length;){const e=this._extendLifetimePromises.splice(0),s=(await Promise.allSettled(e)).find(a=>a.status==="rejected");if(s)throw s.reason}}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,s=!1;for(const a of this.iterateCallbacks("cacheWillUpdate"))if(t=await a({request:this.request,response:t,event:this.event})||void 0,s=!0,!t)break;return s||t&&t.status!==200&&(t=void 0),t}}class J{constructor(e={}){this.cacheName=L.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,s=typeof e.request=="string"?new Request(e.request):e.request,a="params"in e?e.params:void 0,i=new G(this,{event:t,request:s,params:a}),r=this._getResponse(i,s,t),c=this._awaitComplete(r,i,s,t);return[r,c]}async _getResponse(e,t,s){await e.runCallbacks("handlerWillStart",{event:s,request:t});let a;try{if(a=await this._handle(t,e),!a||a.type==="error")throw new h("no-response",{url:t.url})}catch(i){if(i instanceof Error){for(const r of e.iterateCallbacks("handlerDidError"))if(a=await r({error:i,event:s,request:t}),a)break}if(!a)throw i}for(const i of e.iterateCallbacks("handlerWillRespond"))a=await i({event:s,request:t,response:a});return a}async _awaitComplete(e,t,s,a){let i,r;try{i=await e}catch{}try{await t.runCallbacks("handlerDidRespond",{event:a,request:s,response:i}),await t.doneWaiting()}catch(c){c instanceof Error&&(r=c)}if(await t.runCallbacks("handlerDidComplete",{event:a,request:s,response:i,error:r}),t.destroy(),r)throw r}}class p extends J{constructor(e={}){e.cacheName=L.getPrecacheName(e.cacheName),super(e),this._fallbackToNetwork=e.fallbackToNetwork!==!1,this.plugins.push(p.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const s=await t.cacheMatch(e);return s||(t.event&&t.event.type==="install"?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,t){let s;const a=t.params||{};if(this._fallbackToNetwork){const i=a.integrity,r=e.integrity,c=!r||r===i;s=await t.fetch(new Request(e,{integrity:e.mode!=="no-cors"?r||i:void 0})),i&&c&&e.mode!=="no-cors"&&(this._useDefaultCacheabilityPluginIfNeeded(),await t.cachePut(e,s.clone()))}else throw new h("missing-precache-entry",{cacheName:this.cacheName,url:e.url});return s}async _handleInstall(e,t){this._useDefaultCacheabilityPluginIfNeeded();const s=await t.fetch(e);if(!await t.cachePut(e,s.clone()))throw new h("bad-precaching-response",{url:e.url,status:s.status});return s}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[s,a]of this.plugins.entries())a!==p.copyRedirectedCacheableResponsesPlugin&&(a===p.defaultPrecacheCacheabilityPlugin&&(e=s),a.cacheWillUpdate&&t++);t===0?this.plugins.push(p.defaultPrecacheCacheabilityPlugin):t>1&&e!==null&&this.plugins.splice(e,1)}}p.defaultPrecacheCacheabilityPlugin={async cacheWillUpdate({response:n}){return!n||n.status>=400?null:n}};p.copyRedirectedCacheableResponsesPlugin={async cacheWillUpdate({response:n}){return n.redirected?await j(n):n}};class Q{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:s=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new p({cacheName:L.getPrecacheName(e),plugins:[...t,new q({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const t=[];for(const s of e){typeof s=="string"?t.push(s):s&&s.revision===void 0&&t.push(s.url);const{cacheKey:a,url:i}=M(s),r=typeof s!="string"&&s.revision?"reload":"default";if(this._urlsToCacheKeys.has(i)&&this._urlsToCacheKeys.get(i)!==a)throw new h("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(i),secondEntry:a});if(typeof s!="string"&&s.integrity){if(this._cacheKeysToIntegrities.has(a)&&this._cacheKeysToIntegrities.get(a)!==s.integrity)throw new h("add-to-cache-list-conflicting-integrities",{url:i});this._cacheKeysToIntegrities.set(a,s.integrity)}if(this._urlsToCacheKeys.set(i,a),this._urlsToCacheModes.set(i,r),t.length>0){const c=`Workbox is precaching URLs without revision info: ${t.join(", ")}
|
|
2
|
-
This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return v(e,async()=>{const t=new W;this.strategy.plugins.push(t);for(const[i,r]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(r),o=this._urlsToCacheModes.get(i),l=new Request(i,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:r},request:l,event:e}))}const{updatedURLs:s,notUpdatedURLs:a}=t;return{updatedURLs:s,notUpdatedURLs:a}})}activate(e){return v(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),s=await t.keys(),a=new Set(this._urlsToCacheKeys.values()),i=[];for(const r of s)a.has(r.url)||(await t.delete(r),i.push(r.url));return{deletedURLs:i}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s)return(await self.caches.open(this.strategy.cacheName)).match(s)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new h("non-precached-url",{url:e});return s=>(s.request=new Request(e),s.params=Object.assign({cacheKey:t},s.params),this.strategy.handle(s))}}let k;const x=()=>(k||(k=new Q),k);try{self["workbox:routing:7.3.0"]&&_()}catch{}const I="GET",b=n=>n&&typeof n=="object"?n:{handle:n};class R{constructor(e,t,s=I){this.handler=b(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=b(e)}}class z extends R{constructor(e,t,s){const a=({url:i})=>{const r=e.exec(i.href);if(r&&!(i.origin!==location.origin&&r.index!==0))return r.slice(1)};super(a,t,s)}}class X{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,s=Promise.all(t.urlsToCache.map(a=>{typeof a=="string"&&(a=[a]);const i=new Request(...a);return this.handleRequest({request:i,event:e})}));e.waitUntil(s),e.ports&&e.ports[0]&&s.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return;const a=s.origin===location.origin,{params:i,route:r}=this.findMatchingRoute({event:t,request:e,sameOrigin:a,url:s});let c=r&&r.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let l;try{l=c.handle({url:s,request:e,event:t,params:i})}catch(u){l=Promise.reject(u)}const d=r&&r.catchHandler;return l instanceof Promise&&(this._catchHandler||d)&&(l=l.catch(async u=>{if(d)try{return await d.handle({url:s,request:e,event:t,params:i})}catch(g){g instanceof Error&&(u=g)}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw u})),l}findMatchingRoute({url:e,sameOrigin:t,request:s,event:a}){const i=this._routes.get(s.method)||[];for(const r of i){let c;const o=r.match({url:e,sameOrigin:t,request:s,event:a});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:r,params:c}}return{}}setDefaultHandler(e,t=I){this._defaultHandlerMap.set(t,b(e))}setCatchHandler(e){this._catchHandler=b(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new h("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new h("unregister-route-route-not-registered")}}let m;const Y=()=>(m||(m=new X,m.addFetchListener(),m.addCacheListener()),m);function Z(n,e,t){let s;if(typeof n=="string"){const i=new URL(n,location.href),r=({url:c})=>c.href===i.href;s=new R(r,e,t)}else if(n instanceof RegExp)s=new z(n,e,t);else if(typeof n=="function")s=new R(n,e,t);else if(n instanceof R)s=n;else throw new h("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return Y().registerRoute(s),s}function ee(n,e=[]){for(const t of[...n.searchParams.keys()])e.some(s=>s.test(t))&&n.searchParams.delete(t);return n}function*te(n,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:s=!0,urlManipulation:a}={}){const i=new URL(n,location.href);i.hash="",yield i.href;const r=ee(i,e);if(yield r.href,t&&r.pathname.endsWith("/")){const c=new URL(r.href);c.pathname+=t,yield c.href}if(s){const c=new URL(r.href);c.pathname+=".html",yield c.href}if(a){const c=a({url:i});for(const o of c)yield o.href}}class se extends R{constructor(e,t){const s=({request:a})=>{const i=e.getURLsToCacheKeys();for(const r of te(a.url,t)){const c=i.get(r);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(s,e.strategy)}}function ne(n){const e=x(),t=new se(e,n);Z(t)}function ae(n){x().precache(n)}function ie(n,e){ae(n),ne(e)}ie([{"revision":"38013143dc2183340ede8bc1c5124507","url":"registerSW.js"},{"revision":"
|
|
2
|
+
This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return v(e,async()=>{const t=new W;this.strategy.plugins.push(t);for(const[i,r]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(r),o=this._urlsToCacheModes.get(i),l=new Request(i,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:r},request:l,event:e}))}const{updatedURLs:s,notUpdatedURLs:a}=t;return{updatedURLs:s,notUpdatedURLs:a}})}activate(e){return v(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),s=await t.keys(),a=new Set(this._urlsToCacheKeys.values()),i=[];for(const r of s)a.has(r.url)||(await t.delete(r),i.push(r.url));return{deletedURLs:i}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s)return(await self.caches.open(this.strategy.cacheName)).match(s)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new h("non-precached-url",{url:e});return s=>(s.request=new Request(e),s.params=Object.assign({cacheKey:t},s.params),this.strategy.handle(s))}}let k;const x=()=>(k||(k=new Q),k);try{self["workbox:routing:7.3.0"]&&_()}catch{}const I="GET",b=n=>n&&typeof n=="object"?n:{handle:n};class R{constructor(e,t,s=I){this.handler=b(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=b(e)}}class z extends R{constructor(e,t,s){const a=({url:i})=>{const r=e.exec(i.href);if(r&&!(i.origin!==location.origin&&r.index!==0))return r.slice(1)};super(a,t,s)}}class X{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,s=Promise.all(t.urlsToCache.map(a=>{typeof a=="string"&&(a=[a]);const i=new Request(...a);return this.handleRequest({request:i,event:e})}));e.waitUntil(s),e.ports&&e.ports[0]&&s.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return;const a=s.origin===location.origin,{params:i,route:r}=this.findMatchingRoute({event:t,request:e,sameOrigin:a,url:s});let c=r&&r.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let l;try{l=c.handle({url:s,request:e,event:t,params:i})}catch(u){l=Promise.reject(u)}const d=r&&r.catchHandler;return l instanceof Promise&&(this._catchHandler||d)&&(l=l.catch(async u=>{if(d)try{return await d.handle({url:s,request:e,event:t,params:i})}catch(g){g instanceof Error&&(u=g)}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw u})),l}findMatchingRoute({url:e,sameOrigin:t,request:s,event:a}){const i=this._routes.get(s.method)||[];for(const r of i){let c;const o=r.match({url:e,sameOrigin:t,request:s,event:a});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:r,params:c}}return{}}setDefaultHandler(e,t=I){this._defaultHandlerMap.set(t,b(e))}setCatchHandler(e){this._catchHandler=b(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new h("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new h("unregister-route-route-not-registered")}}let m;const Y=()=>(m||(m=new X,m.addFetchListener(),m.addCacheListener()),m);function Z(n,e,t){let s;if(typeof n=="string"){const i=new URL(n,location.href),r=({url:c})=>c.href===i.href;s=new R(r,e,t)}else if(n instanceof RegExp)s=new z(n,e,t);else if(typeof n=="function")s=new R(n,e,t);else if(n instanceof R)s=n;else throw new h("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return Y().registerRoute(s),s}function ee(n,e=[]){for(const t of[...n.searchParams.keys()])e.some(s=>s.test(t))&&n.searchParams.delete(t);return n}function*te(n,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:s=!0,urlManipulation:a}={}){const i=new URL(n,location.href);i.hash="",yield i.href;const r=ee(i,e);if(yield r.href,t&&r.pathname.endsWith("/")){const c=new URL(r.href);c.pathname+=t,yield c.href}if(s){const c=new URL(r.href);c.pathname+=".html",yield c.href}if(a){const c=a({url:i});for(const o of c)yield o.href}}class se extends R{constructor(e,t){const s=({request:a})=>{const i=e.getURLsToCacheKeys();for(const r of te(a.url,t)){const c=i.get(r);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(s,e.strategy)}}function ne(n){const e=x(),t=new se(e,n);Z(t)}function ae(n){x().precache(n)}function ie(n,e){ae(n),ne(e)}ie([{"revision":"38013143dc2183340ede8bc1c5124507","url":"registerSW.js"},{"revision":"b7daecf6640dbc1ee79c2839562fc4bd","url":"index.html"},{"revision":null,"url":"assets/web-nSzKzI8x.js"},{"revision":null,"url":"assets/web-DYwZE4qa.js"},{"revision":null,"url":"assets/index-UaZFu6XL.css"},{"revision":null,"url":"assets/index-BiAE5qeC.js"},{"revision":"fcc457fce855ad0df7178e0786c0d4ef","url":"apple-touch-icon.png"},{"revision":"276650c30bc4effc7d649ec66519aab6","url":"favicon.ico"},{"revision":"2e46512b835c05e17787059909305f22","url":"pwa-192x192.png"},{"revision":"ec5652b5834b4711337743e80e506a41","url":"pwa-512x512.png"},{"revision":"9f51698004b9cc4d787c75695b74de9d","url":"manifest.webmanifest"}]);const re="/api/push/respond";self.addEventListener("message",n=>{});self.addEventListener("push",n=>{var r;if(!n.data)return;let e;try{e=n.data.json()}catch{e={title:"Palmier",body:n.data.text()}}const t=e.type??((r=e.data)==null?void 0:r.type);if(t==="confirm-dismiss"||t==="permission-dismiss"||t==="input-dismiss"){const c=e.data??e,o=c.host_id,l=c.session_id,d=c.task_id;n.waitUntil(self.registration.getNotifications().then(u=>{var g,P,K;for(const y of u)if(((g=y.data)==null?void 0:g.host_id)===o){if(l&&((P=y.data)==null?void 0:P.session_id)===l){y.close();continue}d&&((K=y.data)==null?void 0:K.task_id)===d&&y.close()}}));return}const s=e.title??"Palmier";let a=e.body??"";!a&&t==="confirm"&&(a="A task requires confirmation to run."),!a&&t==="permission"&&(a="A task needs additional permissions to continue."),!a&&t==="input"&&(a="A task needs your input to continue.");const i={body:a,icon:"/pwa-192x192.png",badge:"/pwa-192x192.png",data:e.data??e,vibrate:[100,50,100]};t==="confirm"&&(i.actions=[{action:"confirm",title:"Confirm"},{action:"abort",title:"Abort"}]),n.waitUntil(self.registration.showNotification(s,i))});self.addEventListener("notificationclick",n=>{const e=n.notification;e.close();const t=e.data??{},s=n.action;if(s&&t.type==="confirm"&&t.session_id&&t.host_id){const a=s==="confirm"?"confirmed":"aborted";n.waitUntil(fetch(re,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:t.session_id,host_id:t.host_id,response:a})}).catch(i=>{console.error("Failed to send push response:",i)}))}else{const a=t.task_id,i=t.run_id,r=a&&i?`/runs/${encodeURIComponent(a)}/${encodeURIComponent(i)}`:a?`/runs/${encodeURIComponent(a)}/latest`:"/";n.waitUntil(self.clients.matchAll({type:"window",includeUncontrolled:!0}).then(c=>{for(const o of c)if(o.url.includes(self.location.origin)&&"focus"in o)return o.navigate(r),o.focus();return self.clients.openWindow(r)}))}});self.addEventListener("install",()=>{self.skipWaiting()});self.addEventListener("activate",n=>{n.waitUntil(self.clients.claim())});
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Bump when a breaking host change is made. */
|
|
2
|
-
export const MIN_HOST_VERSION = "0.8.
|
|
2
|
+
export const MIN_HOST_VERSION = "0.8.5";
|
package/palmier-server/spec.md
CHANGED
|
@@ -8,7 +8,7 @@ The system relies on a publish-subscribe model utilizing NATS to bypass firewall
|
|
|
8
8
|
|
|
9
9
|
### 1.1 Platform Support
|
|
10
10
|
|
|
11
|
-
The host supports **Linux** (systemd) and **Windows** (Task Scheduler for both daemon and task triggers).
|
|
11
|
+
The host supports **Linux** (systemd), **macOS** (launchd user LaunchAgent), and **Windows** (Task Scheduler for both daemon and task triggers). OS-specific details in this spec use Linux examples unless noted otherwise; the `PlatformService` abstraction handles cross-platform differences. macOS LaunchAgents run only while the user is logged into the GUI session — there is no user-level equivalent of Linux's `loginctl enable-linger`, so scheduled tasks stay dormant after reboot until the user logs in.
|
|
12
12
|
|
|
13
13
|
### 1.2 Components
|
|
14
14
|
|
|
@@ -94,7 +94,7 @@ Each host machine is provisioned via `palmier init`, an interactive wizard that
|
|
|
94
94
|
3. Shows a summary of task storage directory, local access URL, LAN URL (if enabled), detected agents, and any existing tasks to recover. Asks for confirmation before proceeding.
|
|
95
95
|
4. Registers with the Palmier server via `POST <url>/api/hosts/register` — server returns `{ hostId, natsUrl, natsWsUrl, natsJwt, natsNkeySeed }`.
|
|
96
96
|
5. Saves config to `~/.config/palmier/host.json` (includes `httpPort`, `lanEnabled`, NATS credentials).
|
|
97
|
-
6. Installs a systemd user service (Linux) or Task Scheduler entry (Windows) and auto-enters pair mode.
|
|
97
|
+
6. Installs a systemd user service (Linux), user LaunchAgent (macOS), or Task Scheduler entry (Windows) and auto-enters pair mode.
|
|
98
98
|
|
|
99
99
|
The daemon automatically recovers existing tasks by reinstalling their system timers on startup.
|
|
100
100
|
|
|
@@ -424,7 +424,7 @@ When a task has a `command` field set, `palmier run` enters command-triggered mo
|
|
|
424
424
|
|
|
425
425
|
* **Crash Detection:** The `palmier serve` daemon polls every 30 seconds, querying the system scheduler to detect tasks whose process exited without updating `status.json`. Detected crashes append a failed status entry to the existing RESULT file and broadcast the failure. This also runs at daemon startup to catch crashes that occurred while the daemon was offline.
|
|
426
426
|
|
|
427
|
-
* **Process Tracking:** Each `palmier run` process writes its PID to `status.json`. On abort, `taskkill /pid <pid> /f /t` (Windows)
|
|
427
|
+
* **Process Tracking:** Each `palmier run` process writes its PID to `status.json`. On abort, `taskkill /pid <pid> /f /t` (Windows), `systemctl --user stop` (Linux), or `launchctl kill SIGTERM gui/$UID/<label>` (macOS, with a PID-based SIGTERM fallback) kills the process tree. On Windows, tasks use S4U LogonType in Task Scheduler to run without visible console windows.
|
|
428
428
|
|
|
429
429
|
* **No Remote Timeout:** If a confirmation request is sent to the user's devices and the user does not respond, the task continues to wait indefinitely. The user can always respond via the PWA. There is no automatic deny-on-timeout.
|
|
430
430
|
|
package/src/platform/macos.ts
CHANGED
|
@@ -27,6 +27,10 @@ function taskPlistPath(taskId: string): string {
|
|
|
27
27
|
return path.join(AGENT_DIR, `${taskLabel(taskId)}.plist`);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function taskLogPath(taskId: string): string {
|
|
31
|
+
return path.join(CONFIG_DIR, `task-${taskId}.log`);
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
function guiDomain(): string {
|
|
31
35
|
const uid = process.getuid?.();
|
|
32
36
|
if (uid === undefined) throw new Error("getuid() unavailable — macOS platform requires POSIX uid");
|
|
@@ -225,12 +229,16 @@ export class MacOsPlatform implements PlatformService {
|
|
|
225
229
|
const plistPath = taskPlistPath(taskId);
|
|
226
230
|
const palmierBin = process.argv[1] || "palmier";
|
|
227
231
|
|
|
232
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
233
|
+
const logPath = taskLogPath(taskId);
|
|
228
234
|
const dict: Record<string, unknown> = {
|
|
229
235
|
Label: label,
|
|
230
236
|
ProgramArguments: [process.execPath, palmierBin, "run", taskId],
|
|
231
237
|
WorkingDirectory: config.projectRoot,
|
|
232
238
|
RunAtLoad: false,
|
|
233
239
|
EnvironmentVariables: { PATH: process.env.PATH || "/usr/local/bin:/usr/bin:/bin" },
|
|
240
|
+
StandardOutPath: logPath,
|
|
241
|
+
StandardErrorPath: logPath,
|
|
234
242
|
};
|
|
235
243
|
|
|
236
244
|
const scheduleType = task.frontmatter.schedule_type;
|
|
@@ -263,6 +271,7 @@ export class MacOsPlatform implements PlatformService {
|
|
|
263
271
|
const domain = guiDomain();
|
|
264
272
|
runLaunchctl(["bootout", `${domain}/${taskLabel(taskId)}`], { ignoreFailure: true });
|
|
265
273
|
try { fs.unlinkSync(taskPlistPath(taskId)); } catch { /* ignore */ }
|
|
274
|
+
try { fs.unlinkSync(taskLogPath(taskId)); } catch { /* ignore */ }
|
|
266
275
|
}
|
|
267
276
|
|
|
268
277
|
async startTask(taskId: string): Promise<void> {
|