home-hosted 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -36,12 +36,12 @@ Right: ${t}`,Hw=(e,t)=>`The intersection of two ordered unions is indeterminate:
36
36
  Left: ${e}
37
37
  Right: ${t}`,Uw={implementation:dS({kind:`unit`,hasAssociatedError:!0,keys:{unit:{preserveUndefined:!0,serialize:e=>e instanceof Date?e.toISOString():lS(e)}},normalize:e=>e,defaults:{description:e=>xx(e.unit),problem:({expected:e,actual:t})=>`${e===t?`must be reference equal to ${e} (serialized to the same value)`:`must be ${e} (was ${t})`}`},intersections:{unit:(e,t)=>J.init(`unit`,e,t),...cw(`unit`,(e,t)=>{if(t.allows(e.unit))return e;let n=t.hasKind(`intersection`)?t.basis:t;if(n){let t=n.hasKind(`domain`)?n:q.intrinsic.object;if(e.domain!==t.domain){let n=e.domain===`undefined`||e.domain===`null`||e.domain===`boolean`?e.domain:q.intrinsic[e.domain];return J.init(`domain`,n,t)}}return J.init(`assignability`,e,t.hasKind(`intersection`)?t.children.find(t=>!t.allows(e.unit)):t)})}}),Node:class extends hw{compiledValue=this.json.unit;serializedValue=typeof this.unit==`string`||this.unit instanceof Date?JSON.stringify(this.compiledValue):`${this.compiledValue}`;compiledCondition=Ww(this.unit,this.serializedValue);compiledNegation=Ww(this.unit,this.serializedValue,`negated`);expression=xx(this.unit);domain=Gy(this.unit);get defaultShortDescription(){return this.domain===`object`?Ky.object:this.description}innerToJsonSchema(e){return this.unit===null?{type:`null`}:q.intrinsic.jsonPrimitive.allows(this.unit)?{const:this.unit}:e.fallback.unit({code:`unit`,base:{},unit:this.unit})}traverseAllows=this.unit instanceof Date?e=>e instanceof Date&&e.toISOString()===this.compiledValue:Number.isNaN(this.unit)?e=>Number.isNaN(e):e=>e===this.unit}},Ww=(e,t,n)=>{if(e instanceof Date){let e=`data instanceof Date && data.toISOString() === ${t}`;return n?`!(${e})`:e}return Number.isNaN(e)?`${n?`!`:``}Number.isNaN(data)`:`data ${n?`!`:`=`}== ${t}`},Gw={implementation:dS({kind:`index`,hasAssociatedError:!1,intersectionIsOpen:!0,keys:{signature:{child:!0,parse:(e,t)=>{let n=t.$.parseSchema(e);if(!n.extends(q.intrinsic.key))return K(qw(n.expression));let r=n.branches.filter(e=>e.hasKind(`unit`));return r.length?K(Kw(r.map(e=>xx(e.unit)))):n}},value:{child:!0,parse:(e,t)=>t.$.parseSchema(e)}},normalize:e=>e,defaults:{description:e=>`[${e.signature.expression}]: ${e.value.description}`},intersections:{index:(e,t,n)=>{if(e.signature.equals(t.signature)){let r=VS(e.value,t.value,n),i=r instanceof J?q.intrinsic.never.internal:r;return n.$.node(`index`,{signature:e.signature,value:i})}return e.signature.extends(t.signature)&&e.value.subsumes(t.value)?t:t.signature.extends(e.signature)&&t.value.subsumes(e.value)?e:null}}}),Node:class extends KS{impliedBasis=q.intrinsic.object.internal;expression=`[${this.signature.expression}]: ${this.value.expression}`;flatRefs=Ry(this.value.flatRefs.map(e=>jS([this.signature,...e.path],e.node)),jS([this.signature],this.value));traverseAllows=(e,t)=>lb(e).every(e=>!this.signature.traverseAllows(e[0],t)||wS(e[0],()=>this.value.traverseAllows(e[1],t),t));traverseApply=(e,t)=>{for(let n of lb(e))this.signature.traverseAllows(n[0],t)&&wS(n[0],()=>this.value.traverseApply(n[1],t),t)};_transform(e,t){t.path.push(this.signature);let n=super._transform(e,t);return t.path.pop(),n}compile(){}}},Kw=e=>`Index keys ${e.join(`, `)} should be specified as named props.`,qw=e=>`Indexed key definition '${e}' must be a string or symbol`,Jw={implementation:dS({kind:`required`,hasAssociatedError:!0,intersectionIsOpen:!0,keys:{key:{},value:{child:!0,parse:(e,t)=>t.$.parseSchema(e)}},normalize:e=>e,defaults:{description:e=>`${e.compiledKey}: ${e.value.description}`,expected:e=>e.missingValueDescription,actual:()=>`missing`},intersections:{required:UC,optional:UC}}),Node:class extends WC{expression=`${this.compiledKey}: ${this.value.expression}`;errorContext=Object.freeze({code:`required`,missingValueDescription:this.value.defaultShortDescription,relativePath:[this.key],meta:this.meta});compiledErrorContext=uS(this.errorContext)}},Yw=dS({kind:`sequence`,hasAssociatedError:!1,collapsibleKey:`variadic`,keys:{prefix:{child:!0,parse:(e,t)=>{if(e.length!==0)return e.map(e=>t.$.parseSchema(e))}},optionals:{child:!0,parse:(e,t)=>{if(e.length!==0)return e.map(e=>t.$.parseSchema(e))}},defaultables:{child:e=>e.map(e=>e[0]),parse:(e,t)=>{if(e.length!==0)return e.map(e=>{let n=t.$.parseSchema(e[0]);return XC(n,e[1],null),[n,e[1]]})},serialize:e=>e.map(e=>[e[0].collapsibleJson,lS(e[1])]),reduceIo:(e,t,n)=>{if(e===`in`){t.optionals=n.map(e=>e[0].rawIn);return}t.prefix=n.map(e=>e[0].rawOut)}},variadic:{child:!0,parse:(e,t)=>t.$.parseSchema(e,t)},minVariadicLength:{parse:e=>e===0?void 0:e},postfix:{child:!0,parse:(e,t)=>{if(e.length!==0)return e.map(e=>t.$.parseSchema(e))}}},normalize:e=>{if(typeof e==`string`)return{variadic:e};if(`variadic`in e||`prefix`in e||`defaultables`in e||`optionals`in e||`postfix`in e||`minVariadicLength`in e){if(e.postfix?.length){if(!e.variadic)return K(rT);if(e.optionals?.length||e.defaultables?.length)return K(nT)}return e.minVariadicLength&&!e.variadic?K(`minVariadicLength may not be specified without a variadic element`):e}return{variadic:e}},reduce:(e,t)=>{let n=e.minVariadicLength??0,r=e.prefix?.slice()??[],i=e.defaultables?.slice()??[],a=e.optionals?.slice()??[],o=e.postfix?.slice()??[];if(e.variadic){for(;a[a.length-1]?.equals(e.variadic);)a.pop();if(a.length===0&&i.length===0)for(;r[r.length-1]?.equals(e.variadic);)r.pop(),n++;for(;o[0]?.equals(e.variadic);)o.shift(),n++}else a.length===0&&i.length===0&&r.push(...o.splice(0));if(n!==e.minVariadicLength||e.prefix&&e.prefix.length!==r.length)return t.node(`sequence`,{...e,prefix:r,defaultables:i,optionals:a,postfix:o,minVariadicLength:n},{prereduced:!0})},defaults:{description:e=>e.isVariadicOnly?`${e.variadic.nestableExpression}[]`:`[${e.tuple.map(e=>e.kind===`defaultables`?`${e.node.nestableExpression} = ${xx(e.default)}`:e.kind===`optionals`?`${e.node.nestableExpression}?`:e.kind===`variadic`?`...${e.node.nestableExpression}[]`:e.node.expression).join(`, `)}]`},intersections:{sequence:(e,t,n)=>{let r=iT({l:e.tuple,r:t.tuple,disjoint:new J,result:[],fixedVariants:[],ctx:n}),i=r.disjoint.length===0?[r,...r.fixedVariants]:r.fixedVariants;return i.length===0?r.disjoint:i.length===1?n.$.node(`sequence`,tT(i[0].result)):n.$.node(`union`,i.map(e=>({proto:Array,sequence:tT(e.result)})))}}}),Xw=class extends KS{impliedBasis=q.intrinsic.Array.internal;tuple=eT(this.inner);prefixLength=this.prefix?.length??0;defaultablesLength=this.defaultables?.length??0;optionalsLength=this.optionals?.length??0;postfixLength=this.postfix?.length??0;defaultablesAndOptionals=[];prevariadic=this.tuple.filter(e=>e.kind===`defaultables`||e.kind===`optionals`?(this.defaultablesAndOptionals.push(e.node),!0):e.kind===`prefix`);variadicOrPostfix=zy(this.variadic&&[this.variadic],this.postfix);flatRefs=this.addFlatRefs();addFlatRefs(){return NS(this.flatRefs,this.prevariadic.flatMap((e,t)=>Ry(e.node.flatRefs.map(e=>jS([`${t}`,...e.path],e.node)),jS([`${t}`],e.node)))),NS(this.flatRefs,this.variadicOrPostfix.flatMap(e=>Ry(e.flatRefs.map(e=>jS([q.intrinsic.nonNegativeIntegerString.internal,...e.path],e.node)),jS([q.intrinsic.nonNegativeIntegerString.internal],e)))),this.flatRefs}isVariadicOnly=this.prevariadic.length+this.postfixLength===0;minVariadicLength=this.inner.minVariadicLength??0;minLength=this.prefixLength+this.minVariadicLength+this.postfixLength;minLengthNode=this.minLength===0?null:this.$.node(`minLength`,this.minLength);maxLength=this.variadic?null:this.tuple.length;maxLengthNode=this.maxLength===null?null:this.$.node(`maxLength`,this.maxLength);impliedSiblings=this.minLengthNode?this.maxLengthNode?[this.minLengthNode,this.maxLengthNode]:[this.minLengthNode]:this.maxLengthNode?[this.maxLengthNode]:[];defaultValueMorphs=Qw(this);defaultValueMorphsReference=this.defaultValueMorphs.length?zx(this.defaultValueMorphs):void 0;elementAtIndex(e,t){if(t<this.prevariadic.length)return this.tuple[t];let n=e.length-this.postfixLength;return t>=n?{kind:`postfix`,node:this.postfix[t-n]}:{kind:`variadic`,node:this.variadic??Yy(`Unexpected attempt to access index ${t} on ${this}`)}}traverseAllows=(e,t)=>{for(let n=0;n<e.length;n++)if(!this.elementAtIndex(e,n).node.traverseAllows(e[n],t))return!1;return!0};traverseApply=(e,t)=>{let n=0;for(;n<e.length;n++)wS(n,()=>this.elementAtIndex(e,n).node.traverseApply(e[n],t),t)};get element(){return this.cacheGetter(`element`,this.$.node(`union`,this.children))}compile(e){if(this.prefix)for(let[t,n]of this.prefix.entries())e.traverseKey(`${t}`,`data[${t}]`,n);for(let[t,n]of this.defaultablesAndOptionals.entries()){let r=`${t+this.prefixLength}`;e.if(`${r} >= data.length`,()=>e.traversalKind===`Allows`?e.return(!0):e.return()),e.traverseKey(r,`data[${r}]`,n)}if(this.variadic&&(this.postfix&&e.const(`firstPostfixIndex`,`data.length${this.postfix?`- ${this.postfix.length}`:``}`),e.for(`i < ${this.postfix?`firstPostfixIndex`:`data.length`}`,()=>e.traverseKey(`i`,`data[i]`,this.variadic),this.prevariadic.length),this.postfix))for(let[t,n]of this.postfix.entries()){let r=`firstPostfixIndex + ${t}`;e.traverseKey(r,`data[${r}]`,n)}e.traversalKind===`Allows`&&e.return(!0)}_transform(e,t){t.path.push(q.intrinsic.nonNegativeIntegerString.internal);let n=super._transform(e,t);return t.path.pop(),n}expression=this.description;reduceJsonSchema(e,t){let n=t.target===`draft-07`;if(this.prevariadic.length){let r=this.prevariadic.map(e=>{let n=e.node.toJsonSchemaRecurse(t);if(e.kind===`defaultables`){let r=typeof e.default==`function`?e.default():e.default;n.default=q.intrinsic.jsonData.allows(r)?r:t.fallback.defaultValue({code:`defaultValue`,base:n,value:r})}return n});n?e.items=r:e.prefixItems=r}if(this.minLength&&(e.minItems=this.minLength),this.variadic){let r=this.variadic.toJsonSchemaRecurse(t);if(n&&this.prevariadic.length?e.additionalItems=r:e.items=r,this.maxLength&&(e.maxItems=this.maxLength),this.postfix){let n=this.postfix.map(e=>e.toJsonSchemaRecurse(t));e=t.fallback.arrayPostfix({code:`arrayPostfix`,base:e,elements:n})}}else n?e.additionalItems=!1:e.items=!1,delete e.maxItems;return e}},Zw={},Qw=e=>{if(!e.defaultables)return[];let t=[],n=`[`,r=e.prefixLength+e.defaultablesLength-1;for(let i=e.prefixLength;i<=r;i++){let[r,a]=e.defaultables[i-e.prefixLength];t.push(YC(i,r,a)),n+=`${i}: ${r.id} = ${lS(a)}, `}return n+=`]`,Zw[n]??=t},$w={implementation:Yw,Node:Xw},eT=e=>{let t=[];if(e.prefix)for(let n of e.prefix)t.push({kind:`prefix`,node:n});if(e.defaultables)for(let[n,r]of e.defaultables)t.push({kind:`defaultables`,node:n,default:r});if(e.optionals)for(let n of e.optionals)t.push({kind:`optionals`,node:n});if(e.variadic&&t.push({kind:`variadic`,node:e.variadic}),e.postfix)for(let n of e.postfix)t.push({kind:`postfix`,node:n});return t},tT=e=>e.reduce((e,t)=>(t.kind===`variadic`?e.variadic=t.node:t.kind===`defaultables`?e.defaultables=Ry(e.defaultables,[[t.node,t.default]]):e[t.kind]=Ry(e[t.kind],t.node),e),{}),nT=`A postfix required element cannot follow an optional or defaultable element`,rT=`A postfix element requires a variadic element`,iT=e=>{let[t,...n]=e.l,[r,...i]=e.r;if(!t||!r)return e;let a=n[n.length-1]?.kind===`postfix`,o=i[i.length-1]?.kind===`postfix`,s=t.kind===`prefix`||r.kind===`prefix`?`prefix`:t.kind===`postfix`||r.kind===`postfix`?`postfix`:t.kind===`variadic`&&r.kind===`variadic`?`variadic`:a||o?`prefix`:t.kind===`defaultables`||r.kind===`defaultables`?`defaultables`:`optionals`;if(t.kind===`prefix`&&r.kind===`variadic`&&o){let t=iT({...e,fixedVariants:[],r:i.map(e=>({...e,kind:`prefix`}))});t.disjoint.length===0&&e.fixedVariants.push(t)}else if(r.kind===`prefix`&&t.kind===`variadic`&&a){let t=iT({...e,fixedVariants:[],l:n.map(e=>({...e,kind:`prefix`}))});t.disjoint.length===0&&e.fixedVariants.push(t)}let c=VS(t.node,r.node,e.ctx);if(c instanceof J){if(s===`prefix`||s===`postfix`)e.disjoint.push(...c.withPrefixKey(s===`prefix`?e.result.length:`-${n.length+1}`,aT(t)&&aT(r)?`required`:`optional`)),e.result=[...e.result,{kind:s,node:q.intrinsic.never.internal}];else if(s===`optionals`||s===`defaultables`)return e;else return iT({...e,fixedVariants:[],l:n.map(e=>({...e,kind:`prefix`})),r:n.map(e=>({...e,kind:`prefix`}))})}else s===`defaultables`?(t.kind===`defaultables`&&r.kind===`defaultables`&&t.default!==r.default&&K(GC(t.default,r.default)),e.result=[...e.result,{kind:s,node:c,default:t.kind===`defaultables`?t.default:r.kind===`defaultables`?r.default:Yy(`Unexpected defaultable intersection from ${t.kind} and ${r.kind} elements.`)}]):e.result=[...e.result,{kind:s,node:c}];let l=e.l.length,u=e.r.length;return(t.kind!==`variadic`||l>=u&&(r.kind===`variadic`||u===1))&&(e.l=n),(r.kind!==`variadic`||u>=l&&(t.kind===`variadic`||l===1))&&(e.r=i),iT(e)},aT=e=>e.kind===`prefix`||e.kind===`postfix`,oT=e=>t=>{if(t.props.length||t.index){let n=t.index?.map(t=>t[e])??[];for(let r of t.props)n.push(r[e]);t.undeclared&&n.push(`+ (undeclared): ${t.undeclared}`);let r=`{ ${n.join(`, `)} }`;return t.sequence?`${r} & ${t.sequence.description}`:r}return t.sequence?.description??`{}`},sT=oT(`description`),cT=oT(`expression`),lT=(e,t,n)=>{let r=e.required?`required`:`optional`;if(!t.signature.allows(e.key))return null;let i=zS(e.value,t.value,n);return i instanceof J?r===`optional`?n.node(`optional`,{key:e.key,value:q.intrinsic.never.internal}):i.withPrefixKey(e.key,e.kind):null},uT=dS({kind:`structure`,hasAssociatedError:!1,normalize:e=>e,applyConfig:(e,t)=>!e.undeclared&&t.onUndeclaredKey!==`ignore`?{...e,undeclared:t.onUndeclaredKey}:e,keys:{required:{child:!0,parse:JS(`required`),reduceIo:(e,t,n)=>{t.required=Ry(t.required,n.map(t=>e===`in`?t.rawIn:t.rawOut))}},optional:{child:!0,parse:JS(`optional`),reduceIo:(e,t,n)=>{if(e===`in`){t.optional=n.map(e=>e.rawIn);return}for(let e of n)t[e.outProp.kind]=Ry(t[e.outProp.kind],e.outProp.rawOut)}},index:{child:!0,parse:JS(`index`)},sequence:{child:!0,parse:JS(`sequence`)},undeclared:{parse:e=>e===`ignore`?void 0:e,reduceIo:(e,t,n)=>{if(n===`reject`){t.undeclared=`reject`;return}e===`in`?delete t.undeclared:t.undeclared=`reject`}}},defaults:{description:sT},intersections:{structure:(e,t,n)=>{let r={...e.inner},i={...t.inner},a=new J;if(e.undeclared){let r=e.keyof();for(let e of t.requiredKeys)r.allows(e)||a.add(`presence`,q.intrinsic.never.internal,t.propsByKey[e].value,{path:[e]});i.optional&&=i.optional.filter(e=>r.allows(e.key)),i.index&&=i.index.flatMap(e=>{if(e.signature.extends(r))return e;let t=zS(r,e.signature,n.$);if(t instanceof J)return[];let a=yT(t,e.value,n.$);return a.required&&(i.required=zy(i.required,a.required)),a.optional&&(i.optional=zy(i.optional,a.optional)),a.index??[]})}if(t.undeclared){let i=t.keyof();for(let t of e.requiredKeys)i.allows(t)||a.add(`presence`,e.propsByKey[t].value,q.intrinsic.never.internal,{path:[t]});r.optional&&=r.optional.filter(e=>i.allows(e.key)),r.index&&=r.index.flatMap(e=>{if(e.signature.extends(i))return e;let t=zS(i,e.signature,n.$);if(t instanceof J)return[];let a=yT(t,e.value,n.$);return a.required&&(r.required=zy(r.required,a.required)),a.optional&&(r.optional=zy(r.optional,a.optional)),a.index??[]})}let o={};(e.undeclared||t.undeclared)&&(o.undeclared=e.undeclared===`reject`||t.undeclared===`reject`?`reject`:`delete`);let s=YS({kind:`structure`,baseInner:o,l:XS(r),r:XS(i),roots:[],ctx:n});return s instanceof J&&a.push(...s),a.length?a:s}},reduce:(e,t)=>{if(!e.required&&!e.optional)return;let n=Object.create(null),r=!1,i=e.optional?[...e.optional]:[];if(e.required)for(let r=0;r<e.required.length;r++){let i=e.required[r];if(i.key in n&&K(ST(i.key)),n[i.key]=!0,e.index)for(let n of e.index){let e=lT(i,n,t);if(e instanceof J)return e}}if(e.optional)for(let a=0;a<e.optional.length;a++){let o=e.optional[a];if(o.key in n&&K(ST(o.key)),n[o.key]=!0,e.index)for(let n of e.index){let e=lT(o,n,t);if(e instanceof J)return e;e!==null&&(i[a]=e,r=!0)}}if(r)return t.node(`structure`,{...e,optional:i},{prereduced:!0})}}),dT=class extends KS{impliedBasis=q.intrinsic.object.internal;impliedSiblings=this.children.flatMap(e=>e.impliedSiblings??[]);props=zy(this.required,this.optional);propsByKey=$y(this.props,(e,t)=>[t.key,t]);propsByKeyReference=zx(this.propsByKey);expression=cT(this);requiredKeys=this.required?.map(e=>e.key)??[];optionalKeys=this.optional?.map(e=>e.key)??[];literalKeys=[...this.requiredKeys,...this.optionalKeys];_keyof;keyof(){if(this._keyof)return this._keyof;let e=this.$.units(this.literalKeys).branches;if(this.index)for(let{signature:t}of this.index)e=e.concat(t.branches);return this._keyof=this.$.node(`union`,e)}map(e){return this.$.node(`structure`,this.props.flatMap(e).reduce((e,t)=>{let n=this.propsByKey[t.key];if(Yx(t))return t.kind!==`required`&&t.kind!==`optional`?K(`Map result must have kind "required" or "optional" (was ${t.kind})`):(e[t.kind]=Ry(e[t.kind],t),e);let r=t.kind??n?.kind??`required`,i=$y(t,(e,t)=>e in KC.implementation.keys?[e,t]:[]);return e[r]=Ry(e[r],this.$.node(r,i)),e},{}))}assertHasKeys(e){let t=e.filter(e=>!iw(e,this.keyof()));if(t.length)return K(xT(this.expression,t))}get(e,...t){let n,r=!1,i=_T(e);if((typeof i==`string`||typeof i==`symbol`)&&this.propsByKey[i]&&(n=this.propsByKey[i].value,r=this.propsByKey[i].required),this.index)for(let e of this.index)iw(i,e.signature)&&(n=n?.and(e.value)??e.value);if(this.sequence&&iw(i,q.intrinsic.nonNegativeIntegerString)){if(Jx(i,`root`))this.sequence.variadic&&(n=n?.and(this.sequence.element)??this.sequence.element);else{let e=Number.parseInt(i);if(e<this.sequence.prevariadic.length){let t=this.sequence.prevariadic[e].node;n=n?.and(t)??t,r||=e<this.sequence.prefixLength}else if(this.sequence.variadic){let e=this.$.node(`union`,this.sequence.variadicOrPostfix);n=n?.and(e)??e}}}if(!n)return this.sequence?.variadic&&Jx(i,`root`)&&i.extends(q.intrinsic.number)?K(vT(i.expression,this.sequence.expression)):K(xT(this.expression,[i]));let a=n.get(...t);return r?a:a.or(q.intrinsic.undefined)}pick(...e){return this.assertHasKeys(e),this.$.node(`structure`,this.filterKeys(`pick`,e))}omit(...e){return this.assertHasKeys(e),this.$.node(`structure`,this.filterKeys(`omit`,e))}optionalize(){let{required:e,...t}=this.inner;return this.$.node(`structure`,{...t,optional:this.props.map(e=>e.hasKind(`required`)?this.$.node(`optional`,e.inner):e)})}require(){let{optional:e,...t}=this.inner;return this.$.node(`structure`,{...t,required:this.props.map(e=>e.hasKind(`optional`)?{key:e.key,value:e.value}:e)})}merge(e){let t=this.filterKeys(`omit`,[e.keyof()]);return e.required&&(t.required=Ry(t.required,e.required)),e.optional&&(t.optional=Ry(t.optional,e.optional)),e.index&&(t.index=Ry(t.index,e.index)),e.sequence&&(t.sequence=e.sequence),e.undeclared?t.undeclared=e.undeclared:delete t.undeclared,this.$.node(`structure`,t)}filterKeys(e,t){let n=Kx(this.inner),r=n=>{let r=t.some(e=>iw(n,e));return e===`pick`?r:!r};return n.required&&=n.required.filter(e=>r(e.key)),n.optional&&=n.optional.filter(e=>r(e.key)),n.index&&=n.index.filter(e=>r(e.signature)),n}traverseAllows=(e,t)=>this._traverse(`Allows`,e,t);traverseApply=(e,t)=>this._traverse(`Apply`,e,t);_traverse=(e,t,n)=>{let r=n?.currentErrorCount??0;for(let i=0;i<this.props.length;i++)if(e===`Allows`){if(!this.props[i].traverseAllows(t,n))return!1}else if(this.props[i].traverseApply(t,n),n.failFast&&n.currentErrorCount>r)return!1;if(this.sequence){if(e===`Allows`){if(!this.sequence.traverseAllows(t,n))return!1}else if(this.sequence.traverseApply(t,n),n.failFast&&n.currentErrorCount>r)return!1}if(this.index||this.undeclared===`reject`){let i=Object.keys(t);i.push(...Object.getOwnPropertySymbols(t));for(let a=0;a<i.length;a++){let o=i[a];if(this.index){for(let i of this.index)if(i.signature.traverseAllows(o,n)){if(e===`Allows`){if(!wS(o,()=>i.value.traverseAllows(t[o],n),n))return!1}else if(wS(o,()=>i.value.traverseApply(t[o],n),n),n.failFast&&n.currentErrorCount>r)return!1}}if(this.undeclared===`reject`&&!this.declaresKey(o)&&(e===`Allows`||(n.errorFromNodeContext({code:`predicate`,expected:`removed`,actual:``,relativePath:[o],meta:this.meta}),n.failFast)))return!1}}return this.structuralMorph&&n&&!n.hasError()&&n.queueMorphs([this.structuralMorph]),!0};get defaultable(){return this.cacheGetter(`defaultable`,this.optional?.filter(e=>e.hasDefault())??[])}declaresKey=e=>e in this.propsByKey||this.index?.some(t=>t.signature.allows(e))||this.sequence!==void 0&&q.intrinsic.nonNegativeIntegerString.allows(e);_compileDeclaresKey(e){let t=[];if(this.props.length&&t.push(`k in ${this.propsByKeyReference}`),this.index)for(let n of this.index)t.push(e.invoke(n.signature,{kind:`Allows`,arg:`k`}));return this.sequence&&t.push(`$ark.intrinsic.nonNegativeIntegerString.allows(k)`),t.join(` || `)||`false`}get structuralMorph(){return this.cacheGetter(`structuralMorph`,mT(this))}structuralMorphRef=this.structuralMorph&&zx(this.structuralMorph);compile(e){e.traversalKind===`Apply`&&e.initializeErrorCount();for(let t of this.props)e.check(t),e.traversalKind===`Apply`&&e.returnIfFailFast();if(this.sequence&&(e.check(this.sequence),e.traversalKind===`Apply`&&e.returnIfFailFast()),(this.index||this.undeclared===`reject`)&&(e.const(`keys`,`Object.keys(data)`),e.line(`keys.push(...Object.getOwnPropertySymbols(data))`),e.for(`i < keys.length`,()=>this.compileExhaustiveEntry(e))),e.traversalKind===`Allows`)return e.return(!0);this.structuralMorphRef&&e.if(`ctx && !ctx.hasError()`,()=>(e.line(`ctx.queueMorphs([`),hT(e,this),e.line(`])`)))}compileExhaustiveEntry(e){if(e.const(`k`,`keys[i]`),this.index)for(let t of this.index)e.if(`${e.invoke(t.signature,{arg:`k`,kind:`Allows`})}`,()=>e.traverseKey(`k`,`data[k]`,t.value));return this.undeclared===`reject`&&e.if(`!(${this._compileDeclaresKey(e)})`,()=>e.traversalKind===`Allows`?e.return(!1):e.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if(`ctx.failFast`,()=>e.return())),e}reduceJsonSchema(e,t){switch(e.type){case`object`:return this.reduceObjectJsonSchema(e,t);case`array`:let n=this.sequence?.reduceJsonSchema(e,t)??e;return this.props.length||this.index?t.fallback.arrayObject({code:`arrayObject`,base:n,object:this.reduceObjectJsonSchema({type:`object`},t)}):n;default:return fS.throwInternalOperandError(`structure`,e)}}reduceObjectJsonSchema(e,t){if(this.props.length){e.properties={};for(let n of this.props){let r=n.value.toJsonSchemaRecurse(t);if(typeof n.key==`symbol`){t.fallback.symbolKey({code:`symbolKey`,base:e,key:n.key,value:r,optional:n.optional});continue}if(n.hasDefault()){let e=typeof n.default==`function`?n.default():n.default;r.default=q.intrinsic.jsonData.allows(e)?e:t.fallback.defaultValue({code:`defaultValue`,base:r,value:e})}e.properties[n.key]=r}this.requiredKeys.length&&e.properties&&(e.required=this.requiredKeys.filter(t=>typeof t==`string`&&t in e.properties))}if(this.index)for(let n of this.index){let r=n.value.toJsonSchemaRecurse(t);if(n.signature.equals(q.intrinsic.string)){e.additionalProperties=r;continue}for(let i of n.signature.branches){if(!i.extends(q.intrinsic.string)){e=t.fallback.symbolKey({code:`symbolKey`,base:e,key:null,value:r,optional:!1});continue}let n={type:`string`};if(i.hasKind(`morph`)&&(n=t.fallback.morph({code:`morph`,base:i.rawIn.toJsonSchemaRecurse(t),out:i.rawOut.toJsonSchemaRecurse(t)})),!i.hasKind(`intersection`))return Yy(`Unexpected index branch kind ${i.kind}.`);let{pattern:a}=i.inner;if(a){let i=Object.assign(n,{pattern:a[0].rule});for(let e=1;e<a.length;e++)n=t.fallback.patternIntersection({code:`patternIntersection`,base:i,pattern:a[e].rule});e.patternProperties??={},e.patternProperties[i.pattern]=r}}}return this.undeclared&&!e.additionalProperties&&(e.additionalProperties=!1),e}},fT={},pT=e=>{let t=``;for(let n=0;n<e.defaultable.length;n++)t+=e.defaultable[n].defaultValueMorphRef;if(e.sequence?.defaultValueMorphsReference&&(t+=e.sequence?.defaultValueMorphsReference),e.undeclared===`delete`){if(t+=`delete !(`,e.required)for(let n of e.required)t+=n.compiledKey+` | `;if(e.optional)for(let n of e.optional)t+=n.compiledKey+` | `;if(e.index)for(let n of e.index)t+=n.signature.id+` | `;if(e.sequence){if(e.sequence.maxLength===null)t+=eE.nonNegativeIntegerString.id;else for(let n=0;n<e.sequence.tuple.length;n++)t+=n+` | `}t+=`)`}return t},mT=e=>{let t=pT(e);return t?fT[t]?fT[t]:fT[t]=(t,n)=>{for(let r=0;r<e.defaultable.length;r++)e.defaultable[r].key in t||e.defaultable[r].defaultValueMorph(t,n);if(e.sequence?.defaultables)for(let r=t.length-e.sequence.prefixLength;r<e.sequence.defaultables.length;r++)e.sequence.defaultValueMorphs[r](t,n);if(e.undeclared===`delete`)for(let n in t)e.declaresKey(n)||delete t[n];return t}:void 0},hT=(e,t)=>{let n=`(data${t.defaultable.some(e=>e.defaultValueMorph.length===2)||t.sequence?.defaultValueMorphs.some(e=>e.length===2)?`, ctx`:``})`;return e.block(`${n} => `,e=>{for(let r=0;r<t.defaultable.length;r++){let{serializedKey:i,defaultValueMorphRef:a}=t.defaultable[r];e.if(`!(${i} in data)`,e=>e.line(`${a}${n}`))}return t.sequence?.defaultables&&e.for(`i < ${t.sequence.defaultables.length}`,e=>e.line(`${t.sequence.defaultValueMorphsReference}[i]${n}`),`data.length - ${t.sequence.prefixLength}`),t.undeclared===`delete`&&e.forIn(`data`,e=>e.if(`!(${t._compileDeclaresKey(e)})`,e=>e.line(`delete data[k]`))),e.return(`data`)})},gT={implementation:uT,Node:dT},_T=e=>(Jx(e,`root`)&&e.hasKind(`unit`)&&(e=e.unit),typeof e==`number`&&(e=`${e}`),e),vT=(e,t)=>`${e} is not allowed as an array index on ${t}. Use the 'nonNegativeIntegerString' keyword instead.`,yT=(e,t,n)=>{let[r,i]=Py(e.branches,e=>e.hasKind(`unit`));if(!r.length)return{index:n.node(`index`,{signature:e,value:t})};let a={};for(let e of r){let r=n.node(`required`,{key:e.unit,value:t});a[r.kind]=Ry(a[r.kind],r)}return i.length&&(a.index=n.node(`index`,{signature:i,value:t})),a},bT=e=>Jx(e,`root`)?e.expression:xx(e),xT=(e,t)=>`Key${t.length===1?``:`s`} ${t.map(bT).join(`, `)} ${t.length===1?`does`:`do`} not exist on ${e}`,ST=e=>`Duplicate key ${Vx(e)}`,CT={...OC,alias:mw.implementation,domain:gw.implementation,unit:Uw.implementation,proto:Sw.implementation,union:Mw.implementation,morph:bw.implementation,intersection:_w.implementation,divisor:aC.implementation,pattern:AC.implementation,predicate:iC.implementation,required:Jw.implementation,optional:KC.implementation,index:Gw.implementation,sequence:$w.implementation,structure:gT.implementation};q.defaultConfig=db(Object.assign($y(CT,(e,t)=>[e,t.defaults]),{jitless:Pb(),clone:Ob,onUndeclaredKey:`ignore`,exactOptionalPropertyTypes:!0,numberAllowsNaN:!1,dateAllowsInvalid:!1,onFail:null,keywords:{},toJsonSchema:fS.defaultConfig})),q.resolvedConfig=pS(q.defaultConfig,q.config);var wT={...kC,alias:mw.Node,domain:gw.Node,unit:Uw.Node,proto:Sw.Node,union:Mw.Node,morph:bw.Node,intersection:_w.Node,divisor:aC.Node,pattern:AC.Node,predicate:iC.Node,required:Jw.Node,optional:KC.Node,index:Gw.Node,sequence:$w.Node,structure:gT.Node},TT=class extends rb{get[qx](){return`module`}},ET=(e,t)=>new TT($y(e,(e,n)=>[e,Jx(n,`module`)?ET(n,t):t.bindReference(n)])),DT=e=>xb(e)?e:`branches`in e&&xb(e.branches)?e.branches:void 0,OT=(e,t)=>K(`Node of kind ${t} is not valid as a ${e} definition`),kT=e=>`#${e} duplicates public alias ${e}`,AT={};q.ambient??={};var jT,MT=`function $`,NT=e=>PT(e,FT(e)),PT=(e,t,n)=>{let r=t.write(MT,4),i=t.compile()();for(let t of e)(!t.precompilation||n&&t.$===n)&&(t.traverseAllows=i[`${t.id}Allows`].bind(i),t.isRoot()&&!t.allowsRequiresContext&&(t.allows=t.traverseAllows),t.traverseApply=i[`${t.id}Apply`].bind(i),i[`${t.id}Optimistic`]&&(t.traverseOptimistic=i[`${t.id}Optimistic`].bind(i)),t.precompilation=r)},FT=e=>new Bx().return(e.reduce((e,t)=>{let n=new Gx({kind:`Allows`}).indent();t.compile(n);let r=n.write(`${t.id}Allows`),i=new Gx({kind:`Apply`}).indent();t.compile(i);let a=`${e}${r},\n${i.write(`${t.id}Apply`)},\n`;if(!t.hasKind(`union`))return a;let o=new Gx({kind:`Allows`,optimistic:!0}).indent();return t.compile(o),`${a}${o.write(`${t.id}Optimistic`)},\n`},`{
38
38
  `)+`}`),IT=class{config;resolvedConfig;name;get[qx](){return`scope`}referencesById={};references=[];resolutions={};exportedNames=[];aliases={};resolved=!1;nodesByHash={};intrinsic;constructor(e,t){this.config=pS(q.config,t),this.resolvedConfig=pS(q.resolvedConfig,t),this.name=this.resolvedConfig.name??`anonymousScope${Object.keys(AT).length}`,this.name in AT&&K(`A Scope already named ${this.name} already exists`),AT[this.name]=this;let n=Object.entries(e).map(e=>this.preparseOwnAliasEntry(...e));for(let[e,t]of n){let n=e;if(e[0]===`#`?(n=e.slice(1),n in this.aliases&&K(kT(n)),this.aliases[n]=t):(n in this.aliases&&K(kT(e)),this.aliases[n]=t,this.exportedNames.push(n)),!Jx(t,`module`)&&!Jx(t,`generic`)&&!jb(t)){let e=this.preparseOwnDefinitionFormat(t,{alias:n});this.resolutions[n]=Jx(e,`root`)?this.bindReference(e):this.createParseContext(e).id}}jT??=this.node(`union`,{branches:[`string`,`number`,`object`,`bigint`,`symbol`,{unit:!0},{unit:!1},{unit:void 0},{unit:null}]},{prereduced:!0}),this.nodesByHash[jT.hash]=this.node(`intersection`,{},{prereduced:!0}),this.intrinsic=q.intrinsic?$y(q.intrinsic,(e,t)=>e.startsWith(`json`)?[]:[e,this.bindReference(t)]):{}}cacheGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}get internal(){return this}_json;get json(){return this._json||this.export(),this._json}defineSchema(e){return e}generic=(...e)=>{let t=this;return(n,r)=>new nC(e,r?new tC(n):n,t,t,r??null)};units=(e,t)=>{let n=[];for(let t of e)n.includes(t)||n.push(t);let r=n.map(e=>this.node(`unit`,{unit:e},t));return this.node(`union`,r,{...t,prereduced:!0})};lazyResolutions=[];lazilyResolve(e,t){let n=this.node(`alias`,{reference:t??`synthetic`,resolve:e},{prereduced:!0});return this.resolved||this.lazyResolutions.push(n),n}schema=(e,t)=>this.finalize(this.parseSchema(e,t));parseSchema=(e,t)=>this.node(jC(e),e,t);preparseNode(e,t,n){let r=typeof e==`string`?e:jC(t,e);if(Yx(t)&&t.kind===r)return t;if(r===`alias`&&!n?.prereduced){let{reference:e}=mw.implementation.normalize(t,this);if(e.startsWith(`$`)){let n=this.resolveRoot(e.slice(1));t=n,r=n.kind}}else if(r===`union`&&Wy(t,`object`)){let e=DT(t);e?.length===1&&(t=e[0],r=jC(t))}if(Yx(t)&&t.kind===r)return t;let i=CT[r].normalize?.(t,this)??t;return Yx(i)?i.kind===r?i:OT(r,i.kind):{...n,$:this,kind:r,def:i,prefix:n.alias??r}}bindReference(e){let t;return t=Yx(e)?e.$===this?e:new e.constructor(e.attachments,this):e.$===this?e:new nC(e.params,e.bodyDef,e.$,this,e.hkt),this.resolved||Object.assign(this.referencesById,t.referencesById),t}resolveRoot(e){return this.maybeResolveRoot(e)??K(WT(e))}maybeResolveRoot(e){let t=this.maybeResolve(e);if(!Jx(t,`generic`))return t}maybeResolveSubalias(e){return BT(this.aliases,e)??BT(this.ambient,e)}get ambient(){return q.ambient}maybeResolve(e){let t=this.resolutions[e];if(t){if(typeof t!=`string`)return this.bindReference(t);let n=IC[t];if(Jx(n,`root`))return this.resolutions[e]=n;if(Jx(n,`context`)){if(n.phase===`resolving`)return this.node(`alias`,{reference:`$${e}`},{prereduced:!0});if(n.phase===`resolved`)return Yy(`Unexpected resolved context for was uncached by its scope: ${xx(n)}`);n.phase=`resolving`;let t=this.bindReference(this.parseOwnDefinitionFormat(n.def,n));return n.phase=`resolved`,IC[t.id]=t,IC[n.id]=t,this.resolutions[e]=t}return Yy(`Unexpected nodesById entry for ${t}: ${xx(n)}`)}let n=this.aliases[e]??this.ambient?.[e];return n?(n=this.normalizeRootScopeValue(n),Jx(n,`generic`)?this.resolutions[e]=this.bindReference(n):Jx(n,`module`)?(n.root||K(KT(e)),this.resolutions[e]=this.bindReference(n.root)):this.resolutions[e]=this.parse(n,{alias:e})):this.maybeResolveSubalias(e)}createParseContext(e){let t=e.id??LC(e.prefix);return IC[t]=Object.assign(e,{[qx]:`context`,$:this,id:t,phase:`unresolved`})}traversal(e){return new CS(e,this.resolvedConfig)}import(...e){return new TT($y(this.export(...e),(e,t)=>[`#${e}`,t]))}precompilation;_exportedResolutions;_exports;export(...e){if(!this._exports){this._exports={};for(let e of this.exportedNames){let t=this.aliases[e];this._exports[e]=Jx(t,`module`)?ET(t,this):RT(this.maybeResolve(e))}for(let e of this.lazyResolutions)e.resolution;if(this._exportedResolutions=UT(this,this._exports),this._json=zT(this._exportedResolutions),Object.assign(this.resolutions,this._exportedResolutions),this.references=Object.values(this.referencesById),!this.resolvedConfig.jitless){let e=FT(this.references);this.precompilation=e.write(MT,4),PT(this.references,e,this)}this.resolved=!0}return new TT($y(e.length?e:this.exportedNames,(e,t)=>[t,this._exports[t]]))}resolve(e){return this.export()[e]}node=(e,t,n={})=>{let r=this.preparseNode(e,t,n);if(Yx(r))return this.bindReference(r);let i=this.createParseContext(r),a=RC(i),o=this.bindReference(a);return IC[i.id]=o};parse=(e,t={})=>this.finalize(this.parseDefinition(e,t));parseDefinition(e,t={}){if(Jx(e,`root`))return this.bindReference(e);let n=this.preparseOwnDefinitionFormat(e,t);if(Jx(n,`root`))return this.bindReference(n);let r=this.createParseContext(n);IC[r.id]=r;let i=this.bindReference(this.parseOwnDefinitionFormat(e,r));return i.isCyclic&&(i=BC(i,r.id)),IC[r.id]=i,i}finalize(e){return RT(e),!e.precompilation&&!this.resolvedConfig.jitless&&NT(e.references),e}},LT=class extends IT{parseOwnDefinitionFormat(e,t){return RC(t)}preparseOwnDefinitionFormat(e,t){return this.preparseNode(jC(e),e,t)}preparseOwnAliasEntry(e,t){return[e,t]}normalizeRootScopeValue(e){return e}},RT=e=>{let t=e.references.filter(e=>e.hasKind(`alias`));for(let n of t){Object.assign(n.referencesById,n.resolution.referencesById);for(let t of e.references)n.id in t.referencesById&&Object.assign(t.referencesById,n.referencesById)}return e},zT=e=>$y(e,(e,t)=>[e,Jx(t,`root`)||Jx(t,`generic`)?t.json:Jx(t,`module`)?zT(t):Yy(`Unexpected resolution ${xx(t)}`)]),BT=(e,t)=>{let n=t.indexOf(`.`);if(n===-1)return;let r=t.slice(0,n),i=e[r];if(i===void 0)return;if(!Jx(i,`module`))return K(GT(r));let a=t.slice(n+1),o=i[a];if(o===void 0)return BT(i,a);if(Jx(o,`root`)||Jx(o,`generic`))return o;if(Jx(o,`module`))return o.root??K(KT(t));Yy(`Unexpected resolution for alias '${t}': ${xx(o)}`)},VT=(e,t)=>new LT(e,t),HT=new LT({}),UT=(e,t)=>{let n={};for(let r in t){let i=t[r];if(Jx(i,`module`)){let t=$y(UT(e,i),(e,t)=>[`${r}.${e}`,t]);Object.assign(n,t)}else Jx(i,`root`)||Jx(i,`generic`)?n[r]=i:Yy(`Unexpected scope resolution ${xx(i)}`)}return n},WT=e=>`'${e}' is unresolvable`,GT=e=>`'${e}' must reference a module to be accessed using dot syntax`,KT=e=>`Reference to submodule '${e}' must specify an alias`;HT.export();var qT=HT.schema,JT=HT.node;HT.defineSchema;var YT=HT.generic,XT=`^(?:0|[1-9]\\d*)$`;zx(new RegExp(XT));var ZT=VT({bigint:`bigint`,boolean:[{unit:!1},{unit:!0}],false:{unit:!1},never:[],null:{unit:null},number:`number`,object:`object`,string:`string`,symbol:`symbol`,true:{unit:!0},unknown:{},undefined:{unit:void 0},Array,Date},{prereducedAliases:!0}).export();q.intrinsic={...ZT};var QT=VT({integer:{domain:`number`,divisor:1},lengthBoundable:[`string`,Array],key:[`string`,`symbol`],nonNegativeIntegerString:{domain:`string`,pattern:XT}},{prereducedAliases:!0}).export();Object.assign(q.intrinsic,QT);var $T=VT({jsonPrimitive:[`string`,`number`,{unit:!0},{unit:!1},{unit:null}],jsonObject:{domain:`object`,index:{signature:`string`,value:`$jsonData`}},jsonData:[`$jsonPrimitive`,`$jsonObject`]},{prereducedAliases:!0}).export(),eE={...ZT,...QT,...$T,emptyStructure:JT(`structure`,{},{prereduced:!0})};q.intrinsic={...eE};var tE=((e,t)=>new RegExp(e,t));Object.assign(tE,{as:tE});var nE=e=>typeof e==`string`&&e[0]===`d`&&(e[1]===`'`||e[1]===`"`)&&e[e.length-1]===e[1],rE=e=>e.toString()!==`Invalid Date`,iE=e=>e.slice(2,-1),aE=e=>`'${e}' could not be parsed by the Date constructor`,oE=(e,t)=>sE(e,t),sE=(e,t)=>{let n=new Date(e);if(rE(n))return n;let r=cx(e);if(r!==void 0){let e=new Date(r);if(rE(e))return e}return t?K(t===!0?aE(e):t):void 0},cE=qT({proto:`Array`,sequence:`string`,required:{key:`groups`,value:[`object`,{unit:void 0}]}}),lE=(e,t)=>{let n=e.scanner.shiftUntilEscapable(hE[mE[t]]);if(e.scanner.lookahead===``)return e.error(_E(n,t));if(e.scanner.shift(),t in pE){let r;try{r=new RegExp(n)}catch(e){K(String(e))}e.root=e.ctx.$.node(`intersection`,{domain:`string`,pattern:n},{prereduced:!0}),t===`x/`&&(e.root=e.ctx.$.node(`morph`,{in:e.root,morphs:e=>r.exec(e),declaredOut:cE}))}else if(tb(t,uE))e.root=e.ctx.$.node(`unit`,{unit:n});else{let t=oE(n,aE(n));e.root=e.ctx.$.node(`unit`,{meta:n,unit:t})}},uE={"'":1,'"':1},dE={"/":1,"'":1,'"':1},fE={"d'":`'`,'d"':`"`,"'":`'`,'"':`"`},pE={"/":`/`,"x/":`/`},mE={...fE,...pE},hE={"'":e=>e.lookahead===`'`,'"':e=>e.lookahead===`"`,"/":e=>e.lookahead===`/`},gE={'"':`double-quote`,"'":`single-quote`,"/":`forward slash`},_E=(e,t)=>`${t}${e} requires a closing ${gE[mE[t]]}`,vE=e=>`Private type references should not include '#'. Use '${e}' instead.`,yE=`Optional definitions like 'string?' are only valid as properties in an object or tuple`,bE=`Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple`,xE={"<":1,">":1,"=":1,"|":1,"&":1,")":1,"[":1,"%":1,",":1,":":1,"?":1,"#":1,...Hb},SE=(e,t)=>e===`>`?t[0]===`=`?t[1]===`=`:t.trimStart()===``||tb(t.trimStart()[0],xE):e===`=`?t[0]!==`=`:e===`,`||e===`?`,CE=(e,t,n)=>wE(e,t,n,[]),wE=(e,t,n,r)=>{let i=n.parseUntilFinalizer();return r.push(i.root),i.finalizer===`>`?r.length===t.params.length?r:n.error(TE(e,t.names,r.map(e=>e.expression))):i.finalizer===`,`?wE(e,t,n,r):i.error(Px(`>`))},TE=(e,t,n)=>`${e}<${t.join(`, `)}> requires exactly ${t.length} args (got ${n.length}${n.length===0?``:`: ${n.join(`, `)}`})`,EE=e=>{let t=e.scanner.shiftUntilLookahead(xE);t===`keyof`?e.addPrefix(`keyof`):e.root=OE(e,t)},DE=(e,t,n)=>(n.scanner.shiftUntilNonWhitespace(),n.scanner.shift()===`<`?t(...CE(e,t,n)):n.error(TE(e,t.names,[]))),OE=(e,t)=>kE(e,t)??AE(e,t)??e.error(t===``?e.scanner.lookahead===`#`?vE(e.shiftedBy(1).scanner.shiftUntilLookahead(xE)):jE(e):WT(t)),kE=(e,t)=>{if(e.ctx.args?.[t]){let n=e.ctx.args[t];return typeof n==`string`?e.ctx.$.node(`alias`,{reference:n},{prereduced:!0}):n}let n=e.ctx.$.maybeResolve(t);if(Jx(n,`root`))return n;if(n!==void 0)return Jx(n,`generic`)?DE(t,n,e):K(`Unexpected resolution ${xx(n)}`)},AE=(e,t)=>{let n=lx(t);if(n!==void 0)return e.ctx.$.node(`unit`,{unit:n});let r=fx(t);if(r!==void 0)return e.ctx.$.node(`unit`,{unit:r})},jE=e=>{let t=e.previousOperator();return t?ME(t,e.scanner.unscanned):NE(e.scanner.unscanned)},ME=(e,t=``)=>`Token '${e}' requires a right operand${t?` before '${t}'`:``}`,NE=e=>`Expected an expression${e?` before '${e}'`:``}`,PE=e=>e.scanner.lookahead===``?e.error(jE(e)):e.scanner.lookahead===`(`?e.shiftedBy(1).reduceGroupOpen():e.scanner.lookaheadIsIn(dE)?lE(e,e.scanner.shift()):e.scanner.lookaheadIsIn(Hb)?PE(e.shiftedBy(1)):e.scanner.lookahead===`d`?e.scanner.nextLookahead in uE?lE(e,`${e.scanner.shift()}${e.scanner.shift()}`):EE(e):e.scanner.lookahead===`x`&&e.scanner.nextLookahead===`/`?e.shiftedBy(2)&&lE(e,`x/`):EE(e),FE={">":!0,">=":!0},IE={"<":!0,"<=":!0},LE={"<":`>`,">":`<`,"<=":`>=`,">=":`<=`,"==":`==`},RE=(e,t)=>`Left bounds are only valid when paired with right bounds (try ...${t}${e})`,zE=e=>`Left-bounded expressions must specify their limits using < or <= (was ${e})`,BE=(e,t,n,r)=>`An expression may have at most one left bound (parsed ${e}${LE[t]}, ${n}${LE[r]})`,VE=(e,t)=>{let n=UE(e,t);if(e.root.hasKind(`unit`)){if(typeof e.root.unit==`number`){e.reduceLeftBound(e.root.unit,n),e.unsetRoot();return}if(e.root.unit instanceof Date){let t=`d'${e.root.description??e.root.unit.toISOString()}'`;e.unsetRoot(),e.reduceLeftBound(t,n);return}}return KE(e,n)},HE={"<":1,">":1,"=":1},UE=(e,t)=>e.scanner.lookaheadIs(`=`)?`${t}${e.scanner.shift()}`:t,WE=(e,t,n,r)=>n.extends(q.intrinsic.number)?typeof t==`number`?e===`==`?[`min`,`max`]:e[0]===`>`?[`min`]:[`max`]:K(qE(e,t,r)):n.extends(q.intrinsic.lengthBoundable)?typeof t==`number`?e===`==`?[`exactLength`]:e[0]===`>`?[`minLength`]:[`maxLength`]:K(qE(e,t,r)):n.extends(q.intrinsic.Date)?e===`==`?[`after`,`before`]:e[0]===`>`?[`after`]:[`before`]:K(bC(n.expression)),GE=e=>({rule:nE(e.limit)?iE(e.limit):e.limit,exclusive:e.comparator.length===1}),KE=(e,t)=>{let n=e.unsetRoot(),r=e.scanner.location;e.parseOperand();let i=e.unsetRoot(),a=e.scanner.sliceChars(r,e.scanner.location);if(e.root=n,!i.hasKind(`unit`)||typeof i.unit!=`number`&&!(i.unit instanceof Date))return e.error(qE(t,a,`right`));let o=i.unit,s=t.length===1,c=WE(t,typeof o==`number`?o:a,n,`right`);for(let n of c)e.constrainRoot(n,t===`==`?{rule:o}:{rule:o,exclusive:s});if(!e.branches.leftBound)return;if(!tb(t,IE))return e.error(zE(t));let l=WE(e.branches.leftBound.comparator,e.branches.leftBound.limit,n,`left`);e.constrainRoot(l[0],GE(e.branches.leftBound)),e.branches.leftBound=null},qE=(e,t,n)=>`Comparator ${n===`left`?LE[e]:e} must be ${n===`left`?`preceded`:`followed`} by a corresponding literal (was ${t})`,JE=e=>{e.scanner.shiftUntilNonWhitespace();let t=e.scanner.shiftUntilLookahead(xE);e.root=e.root.brand(t)},YE=e=>{e.scanner.shiftUntilNonWhitespace();let t=e.scanner.shiftUntilLookahead(xE),n=ux(t,{errorOnFail:XE(t)});n===0&&e.error(XE(0)),e.root=e.root.constrain(`divisor`,n)},XE=e=>`% operator must be followed by a non-zero integer literal (was ${e})`,ZE=e=>{let t=e.scanner.shift();return t===``?e.finalize(``):t===`[`?e.scanner.shift()===`]`?e.setRoot(e.root.array()):e.error($E):t===`|`?e.scanner.lookahead===`>`?e.shiftedBy(1).pushRootToBranch(`|>`):e.pushRootToBranch(t):t===`&`?e.pushRootToBranch(t):t===`)`?e.finalizeGroup():SE(t,e.scanner.unscanned)?e.finalize(t):tb(t,HE)?VE(e,t):t===`%`?YE(e):t===`#`?JE(e):t in Hb?ZE(e):e.error(QE(t))},QE=(e,t=``)=>`'${e}' is not allowed here${t&&` (should be ${t})`}`,$E=`Missing expected ']'`,eD=e=>{let t=e.unsetRoot();e.parseOperand();let n=e.unsetRoot();return n.hasKind(`unit`)?[t,`=`,n.unit instanceof Date?()=>new Date(n.unit):n.unit]:e.error(tD(n.expression))},tD=e=>`Default value '${e}' must be a literal value`,nD=(e,t)=>{let n=t.$.maybeResolveRoot(e);if(n)return n;if(e.endsWith(`[]`)){let n=t.$.maybeResolveRoot(e.slice(0,-2));if(n)return n.array()}let r=new oD(new Mx(e),t),i=rD(r);return r.finalizer===`>`&&K(QE(`>`)),i},rD=e=>{e.parseOperand();let t=iD(e).root;return t?(e.finalizer===`=`?t=eD(e):e.finalizer===`?`&&(t=[t,`?`]),e.scanner.shiftUntilNonWhitespace(),e.scanner.lookahead&&K(QE(e.scanner.lookahead)),t):Yy(`Root was unexpectedly unset after parsing string '${e.scanner.scanned}'`)},iD=e=>{for(;e.finalizer===void 0;)aD(e);return e},aD=e=>e.hasRoot()?e.parseOperator():e.parseOperand(),oD=class e{root;branches={prefixes:[],leftBound:null,intersection:null,union:null,pipe:null};finalizer;groups=[];scanner;ctx;constructor(e,t){this.scanner=e,this.ctx=t}error(e){return K(e)}hasRoot(){return this.root!==void 0}setRoot(e){this.root=e}unsetRoot(){let e=this.root;return this.root=void 0,e}constrainRoot(...e){this.root=this.root.constrain(e[0],e[1])}finalize(e){if(this.groups.length)return this.error(Px(`)`));this.finalizeBranches(),this.finalizer=e}reduceLeftBound(e,t){let n=LE[t];if(!tb(n,FE))return this.error(zE(t));if(this.branches.leftBound)return this.error(BE(this.branches.leftBound.limit,this.branches.leftBound.comparator,e,n));this.branches.leftBound={comparator:n,limit:e}}finalizeBranches(){if(this.assertRangeUnset(),this.branches.pipe){this.pushRootToBranch(`|>`),this.root=this.branches.pipe;return}if(this.branches.union){this.pushRootToBranch(`|`),this.root=this.branches.union;return}if(this.branches.intersection){this.pushRootToBranch(`&`),this.root=this.branches.intersection;return}this.applyPrefixes()}finalizeGroup(){this.finalizeBranches();let e=this.groups.pop();if(!e)return this.error(Nx(`)`,this.scanner.unscanned));this.branches=e}addPrefix(e){this.branches.prefixes.push(e)}applyPrefixes(){for(;this.branches.prefixes.length;){let e=this.branches.prefixes.pop();this.root=e===`keyof`?this.root.keyof():Yy(`Unexpected prefix '${e}'`)}}pushRootToBranch(e){this.assertRangeUnset(),this.applyPrefixes();let t=this.root;this.root=void 0,this.branches.intersection=this.branches.intersection?.rawAnd(t)??t,e!==`&`&&(this.branches.union=this.branches.union?.rawOr(this.branches.intersection)??this.branches.intersection,this.branches.intersection=null,e!==`|`&&(this.branches.pipe=this.branches.pipe?.rawPipeOnce(this.branches.union)??this.branches.union,this.branches.union=null))}parseUntilFinalizer(){return iD(new e(this.scanner,this.ctx))}parseOperator(){return ZE(this)}parseOperand(){return PE(this)}assertRangeUnset(){if(this.branches.leftBound)return this.error(RE(this.branches.leftBound.limit,this.branches.leftBound.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={prefixes:[],leftBound:null,union:null,intersection:null,pipe:null}}previousOperator(){return this.branches.leftBound?.comparator??this.branches.prefixes[this.branches.prefixes.length-1]??(this.branches.intersection?`&`:this.branches.union?`|`:this.branches.pipe?`|>`:void 0)}shiftedBy(e){return this.scanner.jumpForward(e),this}},sD=`An empty string is not a valid generic parameter name`,cD=(e,t,n)=>{e.shiftUntilNonWhitespace();let r=e.shiftUntilLookahead(xE);return r===``?e.lookahead===``&&t.length?t:K(sD):(e.shiftUntilNonWhitespace(),uD(e,r,t,n))},lD=`extends `,uD=(e,t,n,r)=>{if(e.shiftUntilNonWhitespace(),e.unscanned.startsWith(lD))e.jumpForward(8);else return e.lookahead===`,`&&e.shift(),n.push(t),cD(e,n,r);let i=iD(new oD(e,r));return n.push([t,i.root]),cD(e,n,r)},dD=class extends Nb{constructor(e){let t=(...t)=>{let n=t.indexOf(`:`),r=n===-1?t.length-1:n-1,i=t.slice(0,r+1),a=e.parse(i).assertHasKind(`intersection`),o=e.intrinsic.unknown;if(n!==-1){if(n!==t.length-2)return K(pD);o=e.parse(t[n+1])}return e=>new fD(e,a,o)};super(t,{attach:{$:e,raw:t}})}},fD=class extends Nb{raw;params;returns;expression;constructor(e,t,n){let r=`typed ${e.name}`,i={[r]:(...r)=>{let i=e(...t.assert(r));return n.assert(i)}}[r];super(i),this.raw=e,this.params=t,this.returns=n;let a=t.expression;a[0]===`[`&&a[a.length-1]===`]`?a=a.slice(1,-1):a.endsWith(`[]`)&&(a=`...${a}`),this.expression=`(${a}) => ${n?.expression??`unknown`}`}},pD=`":" must be followed by exactly one return type e.g:
39
- fn("string", ":", "number")(s => s.length)`,mD=class extends Nb{$;constructor(e){super((...t)=>new hD(e)(...t),{bind:e}),this.$=e}in(e){return new hD(this.$,e===void 0?void 0:this.$.parse(e))}at(e,t){return new hD(this.$).at(e,t)}case(e,t){return new hD(this.$).case(e,t)}},hD=class extends Nb{$;in;key;branches=[];constructor(e,t){super(e=>this.caseEntries(Object.entries(e).map(([e,t])=>e==="default"?[e,t]:[this.$.parse(e),t]))),this.$=e,this.in=t}at(e,t){return this.key&&K(vD),this.branches.length&&K(_D),this.key=e,t?this.match(t):this}case(e,t){return this.caseEntry(this.$.parse(e),t)}caseEntry(e,t){let n=(this.key?this.$.parse({[this.key]:e}):e).pipe(t);return this.branches.push(n),this}match(e){return this(e)}strings(e){return this.caseEntries(Object.entries(e).map(([e,t])=>e==="default"?[e,t]:[this.$.node(`unit`,{unit:e}),t]))}caseEntries(e){for(let t=0;t<e.length;t++){let[n,r]=e[t];if(n==="default")return t!==e.length-1&&K(`default may only be specified as the last key of a switch definition`),this.default(r);if(typeof r!=`function`)return K(`Value for case "${n}" must be a function (was ${Gy(r)})`);this.caseEntry(n,r)}return this}default(e){typeof e==`function`&&this.case(eE.unknown,e);let t={branches:this.branches,ordered:!0};(e===`never`||e===`assert`)&&(t.meta={onFail:gD});let n=this.$.node(`union`,t);if(!this.in)return this.$.finalize(n);let r=this.in.pipe(n);return(e===`never`||e===`assert`)&&(r=r.configureReferences({onFail:gD},`self`)),this.$.finalize(r)}},gD=e=>e.throw(),_D=`A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')`,vD=`At most one key matcher may be specified per expression`,yD=(e,t)=>{if(xb(e)){if(e[1]===`=`)return[t.$.parseOwnDefinitionFormat(e[0],t),`=`,e[2]];if(e[1]===`?`)return[t.$.parseOwnDefinitionFormat(e[0],t),`?`]}return nO(e,t)},bD=`Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }`,xD=`Only required keys may specify default values, e.g. { value: 'number = 0' }`,SD=(e,t)=>{let n,r={},i=lb(e);for(let[e,a]of i){let i=ED(e);if(i.kind===`spread`){if(!cb(r))return K(TD);let e=t.$.parseOwnDefinitionFormat(a,t);if(e.equals(eE.object))continue;if(!e.hasKind(`intersection`)||!e.basis?.equals(eE.object))return K(DD(e.expression));n=e.structure;continue}if(i.kind===`undeclared`){a!==`reject`&&a!==`delete`&&a!==`ignore`&&K(wD(a)),r.undeclared=a;continue}let o=yD(a,t),s=i;if(i.kind===`required`){xb(o)?CD(r,`optional`,o[1]===`=`?{key:i.normalized,value:o[0],default:o[2]}:{key:i.normalized,value:o[0]},t):CD(r,`required`,{key:i.normalized,value:o},t);continue}if(xb(o)&&(o[1]===`?`&&K(bD),o[1]===`=`&&K(xD)),i.kind===`optional`){CD(r,`optional`,{key:i.normalized,value:o},t);continue}let c=yT(t.$.parseOwnDefinitionFormat(s.normalized,t),o,t.$);c.index&&(r.index=Ry(r.index,c.index)),c.required&&(r.required=Ry(r.required,c.required))}let a=t.$.node(`structure`,r);return t.$.parseSchema({domain:`object`,structure:n?.merge(a)??a})},CD=(e,t,n,r)=>{e[t]=Ry(e[t],r.$.node(t,n))},wD=e=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${xx(e)})`,TD=`Spread operator may only be used as the first key in an object`,ED=e=>typeof e==`symbol`?{kind:`required`,normalized:e}:e[e.length-1]===`?`?e[e.length-2]===`\\`?{kind:`required`,normalized:`${e.slice(0,-2)}?`}:{kind:`optional`,normalized:e.slice(0,-1)}:e[0]===`[`&&e[e.length-1]===`]`?{kind:`index`,normalized:e.slice(1,-1)}:e[0]===`\\`&&e[1]===`[`&&e[e.length-1]===`]`?{kind:`required`,normalized:e.slice(1)}:e===`...`?{kind:`spread`}:e===`+`?{kind:`undeclared`}:{kind:`required`,normalized:e===`\\...`?`...`:e===`\\+`?`+`:e},DD=e=>`Spread operand must resolve to an object literal type (was ${e})`,OD=(e,t)=>HD(e)?VD[e[0]](e,t):BD(e)?zD[e[1]](e,t):null,kD=(e,t)=>t.$.parseOwnDefinitionFormat(e[1],t).keyof(),AD=(e,t)=>{if(e[2]===void 0)return K(ME(e[1],``));let n=t.$.parseOwnDefinitionFormat(e[0],t),r=t.$.parseOwnDefinitionFormat(e[2],t);if(e[1]===`|`)return t.$.node(`union`,{branches:[n,r]});let i=e[1]===`&`?zS(n,r,t.$):BS(n,r,t.$);return i instanceof J?i.throw():i},jD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).array(),MD=(e,t)=>typeof e[2]==`function`?t.$.parseOwnDefinitionFormat(e[0],t).pipe(e[2]):K(ND(`=>`,e[2])),ND=(e,t)=>`${e===`:`?`Narrow`:`Morph`} expression requires a function following '${e}' (was ${typeof t})`,PD=(e,t)=>typeof e[2]==`function`?t.$.parseOwnDefinitionFormat(e[0],t).constrain(`predicate`,e[2]):K(ND(`:`,e[2])),FD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).configure(e[2],e[3]),ID=e=>e,LD=ID({"[]":jD,"?":()=>K(yE)}),RD=ID({"|":AD,"&":AD,":":PD,"=>":MD,"|>":AD,"@":FD,"=":()=>K(bE)}),zD={...LD,...RD},BD=e=>zD[e[1]]!==void 0,VD=(e=>e)({keyof:kD,instanceof:(e,t)=>{if(typeof e[1]!=`function`)return K(UD(bb(e[1])));let n=e.slice(1).map(e=>typeof e==`function`?t.$.node(`proto`,{proto:e}):K(UD(bb(e))));return n.length===1?n[0]:t.$.node(`union`,{branches:n})},"===":(e,t)=>t.$.units(e.slice(1))}),HD=e=>VD[e[0]]!==void 0,UD=e=>`Expected a constructor following 'instanceof' operator (was ${e})`,WD=(e,t)=>{let n=[{}],r=0;for(;r<e.length;){let i=!1;e[r]===`...`&&r<e.length-1&&(i=!0,r++);let a=yD(e[r],t),[o,s,c]=xb(a)?a:[a];if(r++,i){if(!o.extends(q.intrinsic.Array))return K(XD(o.expression));n=n.flatMap(e=>o.distribute(t=>YD(Kx(e),t)))}else n=n.map(e=>s===`?`?KD(e,o):s===`=`?qD(e,o,c):GD(e,o))}return t.$.parseSchema(n.map(e=>cb(e)?{proto:Array,exactLength:0}:{proto:Array,sequence:e}))},GD=(e,t)=>e.defaultables||e.optionals?K(e.variadic?nT:QD):(e.variadic?e.postfix=Ry(e.postfix,t):e.prefix=Ry(e.prefix,t),e),KD=(e,t)=>e.variadic?K($D):(e.optionals=Ry(e.optionals,t),e),qD=(e,t,n)=>e.variadic?K($D):e.optionals?K(eO):(e.defaultables=Ry(e.defaultables,[[t,n]]),e),JD=(e,t)=>(e.postfix&&K(ZD),e.variadic?e.variadic.equals(t)||K(ZD):e.variadic=t.internal,e),YD=(e,t)=>{let n=t.select({method:`find`,kind:`sequence`});if(!n)return JD(e,q.intrinsic.unknown);if(n.prefix)for(let t of n.prefix)GD(e,t);if(n.optionals)for(let t of n.optionals)KD(e,t);if(n.variadic&&JD(e,n.variadic),n.postfix)for(let t of n.postfix)GD(e,t);return e},XD=e=>`Spread element must be an array (was ${e})`,ZD=`A tuple may have at most one variadic element`,QD=`A required element may not follow an optional element`,$D=`An optional element may not follow a variadic element`,eO=`A defaultable element may not follow an optional element without a default`,tO={},nO=(e,t)=>{if(typeof e==`string`){if(t.args&&Object.keys(t.args).some(t=>e.includes(t)))return nD(e,t);let n=tO[t.$.name]??={};return n[e]??=nD(e,t)}return Wy(e,`object`)?rO(e,t):K(oO(Gy(e)))},rO=(e,t)=>{let n=yb(e);switch(n){case void 0:return Jx(e,`root`)?e:`~standard`in e?iO(e,t):SD(e,t);case`Array`:return aO(e,t);case`RegExp`:return t.$.node(`intersection`,{domain:`string`,pattern:e},{prereduced:!0});case`Function`:{let t=jb(e)?e():e;return Jx(t,`root`)?t:K(oO(`Function`))}default:return K(oO(n??xx(e)))}},iO=(e,t)=>t.$.intrinsic.unknown.pipe((t,n)=>{let r=e[`~standard`].validate(t);if(!r.issues)return r.value;for(let{message:e,path:t}of r.issues)t&&t.length?n.error({problem:Rb(e),relativePath:t.map(e=>typeof e==`object`?e.key:e)}):n.error({message:e})}),aO=(e,t)=>OD(e,t)??WD(e,t),oO=e=>`Type definitions must be strings or objects (was ${e})`,sO=class extends Nb{constructor(e){let t=Object.assign({errors:bS,hkt:Fb,$:e,raw:e.parse,module:e.constructor.module,scope:e.constructor.scope,declare:e.declare,define:e.define,match:e.match,generic:e.generic,schema:e.schema,keywords:e.ambient,unit:e.unit,enumerated:e.enumerated,instanceOf:e.instanceOf,valueOf:e.valueOf,or:e.or,and:e.and,merge:e.merge,pipe:e.pipe,fn:e.fn},e.ambientAttachments);super((...t)=>{if(t.length===1)return e.parse(t[0]);if(t.length===2&&typeof t[0]==`string`&&t[0][0]===`<`&&t[0][t[0].length-1]===`>`){let n=t[0].slice(1,-1);return new nC(e.parseGenericParams(n,{}),t[1],e,e,null)}return e.parse(t)},{attach:t})}},cO=q,lO=class e extends IT{get ambientAttachments(){if(cO.typeAttachments)return this.cacheGetter(`ambientAttachments`,$y(cO.typeAttachments,(e,t)=>[e,this.bindReference(t)]))}preparseOwnAliasEntry(e,t){let n=e.indexOf(`<`);if(n===-1){if(Jx(t,`module`)||Jx(t,`generic`))return[e,t];let n=this.name===`ark`?e:e===`root`?this.name:`${this.name}.${e}`,r=this.resolvedConfig.keywords?.[n];return r&&(t=[t,`@`,r]),[e,t]}e[e.length-1]!==`>`&&K(`'>' must be the last character of a generic declaration in a scope`);let r=e.slice(0,n),i=e.slice(n+1,-1);return[r,()=>eC(this.parseGenericParams(i,{alias:r}),t,this)]}parseGenericParams(e,t){return cD(new Mx(e),[],this.createParseContext({...t,def:e,prefix:`generic`}))}normalizeRootScopeValue(e){return jb(e)&&!Jx(e,`generic`)?e():e}preparseOwnDefinitionFormat(e,t){return{...t,def:e,prefix:t.alias??`type`}}parseOwnDefinitionFormat(e,t){!(t.alias&&t.alias in this.aliases)&&!t.args&&(t.args={this:t.id});let n=nO(e,t);if(xb(n)){if(n[1]===`=`)return K(bE);if(n[1]===`?`)return K(yE)}return n}unit=e=>this.units([e]);valueOf=e=>this.units(pb(e));enumerated=(...e)=>this.units(e);instanceOf=e=>this.node(`proto`,{proto:e},{prereduced:!0});or=(...e)=>this.schema(e.map(e=>this.parse(e)));and=(...e)=>e.reduce((e,t)=>e.and(this.parse(t)),this.intrinsic.unknown);merge=(...e)=>e.reduce((e,t)=>e.merge(this.parse(t)),this.intrinsic.object);pipe=(...e)=>this.intrinsic.unknown.pipe(...e);fn=new dD(this);match=new mD(this);declare=()=>({type:this.type});define(e){return e}type=new sO(this);static scope=((t,n={})=>new e(t,n));static module=((e,t={})=>this.scope(e,t).export())},uO=Object.assign(lO.scope,{define:e=>e}),dO=lO,fO=class extends Fb{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'},pO=YT([`base`,eE.object],[`props`,eE.object])(e=>e.base.merge(e.props),fO),mO=dO.module({Key:eE.key,Merge:pO}),hO=class extends Fb{},gO=YT(`element`)(e=>{let t=e.element.exclude(eE.Array),n=t.array();return t.rawOr(n).pipe(Ny).distribute(e=>e.assertHasKind(`morph`).declareOut(n),qT)},hO),_O=dO.module({root:eE.Array,readonly:`root`,index:eE.nonNegativeIntegerString,liftFrom:gO},{name:`Array`}),vO=qT([`string`,px.FileConstructor]),yO=qT({meta:`an object representing parsed form data`,domain:`object`,index:{signature:`string`,value:vO.rawOr(vO.array())}}),bO=dO.module({root:[`instanceof`,FormData],value:vO,parsed:yO,parse:qT({in:FormData,morphs:e=>{let t={};for(let[n,r]of e)if(n in t){let e=t[n];typeof e==`string`||e instanceof px.FileConstructor?t[n]=[e,r]:e.push(r)}else t[n]=r;return t},declaredOut:yO})},{name:`FormData`}),xO=dO.module({Int8:[`instanceof`,Int8Array],Uint8:[`instanceof`,Uint8Array],Uint8Clamped:[`instanceof`,Uint8ClampedArray],Int16:[`instanceof`,Int16Array],Uint16:[`instanceof`,Uint16Array],Int32:[`instanceof`,Int32Array],Uint32:[`instanceof`,Uint32Array],Float32:[`instanceof`,Float32Array],Float64:[`instanceof`,Float64Array],BigInt64:[`instanceof`,BigInt64Array],BigUint64:[`instanceof`,BigUint64Array]},{name:`TypedArray`}),SO={Boolean:1,Number:1,String:1},CO=dO.module({...$y({...mb,...gb},(e,t)=>e in SO?[]:[e,[`instanceof`,t]]),Array:_O,TypedArray:xO,FormData:bO}),wO=qT({domain:{domain:`number`,meta:`a number representing a Unix timestamp`},divisor:{rule:1,meta:`an integer representing a Unix timestamp`},min:{rule:-864e13,meta:`a Unix timestamp after -8640000000000000`},max:{rule:864e13,meta:`a Unix timestamp before 8640000000000000`},meta:`an integer representing a safe Unix timestamp`}),TO=qT({domain:`number`,divisor:1}),EO=dO.module({root:eE.number,integer:TO,epoch:wO,safe:qT({domain:{domain:`number`,numberAllowsNaN:!1},min:-(2**53-1),max:2**53-1}),NaN:[`===`,NaN],Infinity:[`===`,1/0],NegativeInfinity:[`===`,-1/0]},{name:`number`}),DO=(e,t,n)=>{let r={domain:`string`,pattern:{rule:e.source,flags:e.flags,meta:t}};return n&&(r.meta={format:n}),JT(`intersection`,r)},OO=DO($b,`a well-formed integer string`),kO=dO.module({root:OO,parse:qT({in:OO,morphs:(e,t)=>{let n=Number.parseInt(e);return Number.isSafeInteger(n)?n:t.error(`an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER`)},declaredOut:eE.integer})},{name:`string.integer`}),AO=DO(/^[\dA-Fa-f]+$/,`hex characters only`),jO=dO.module({root:DO(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,`base64-encoded`),url:DO(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,`base64url-encoded`)},{name:`string.base64`}),MO=DO(/^[A-Z].*$/,`capitalized`),NO=dO.module({root:qT({in:`string`,morphs:e=>e.charAt(0).toUpperCase()+e.slice(1),declaredOut:MO}),preformatted:MO},{name:`string.capitalize`}),PO=qT({domain:`string`,pattern:{meta:`a credit card number`,rule:`^(?:4\\d{12}(?:\\d{3,6})?|5[1-5]\\d{14}|(222[1-9]|22[3-9]\\d|2[3-6]\\d{2}|27[01]\\d|2720)\\d{12}|6(?:011|5\\d\\d)\\d{12,15}|3[47]\\d{13}|3(?:0[0-5]|[68]\\d)\\d{11}|(?:2131|1800|35\\d{3})\\d{11}|6[27]\\d{14}|^(81\\d{14,17}))$`},predicate:{meta:`a credit card number`,predicate:e=>{let t=e.replace(/[ -]+/g,``),n=0,r,i,a=!1;for(let e=t.length-1;e>=0;e--)r=t.substring(e,e+1),i=Number.parseInt(r,10),a?(i*=2,n+=i>=10?i%10+1:i):n+=i,a=!a;return!!(n%10==0&&t)}}}),FO=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,IO=qT({domain:`string`,predicate:{meta:`a parsable date`,predicate:e=>!Number.isNaN(new Date(e).valueOf())}}).assertHasKind(`intersection`),LO=kO.root.internal.narrow((e,t)=>{let n=Number.parseInt(e),r=EO.epoch(n);return r instanceof bS?(t.errors.merge(r),!1):!0}).configure({description:`an integer string representing a safe Unix timestamp`},`self`).assertHasKind(`intersection`),RO=dO.module({root:LO,parse:qT({in:LO,morphs:e=>new Date(e),declaredOut:eE.Date})},{name:`string.date.epoch`}),zO=DO(FO,`an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date`).internal.assertHasKind(`intersection`),BO=dO.module({root:zO,parse:qT({in:zO,morphs:e=>new Date(e),declaredOut:eE.Date})},{name:`string.date.iso`}),VO=dO.module({root:IO,parse:qT({declaredIn:IO,in:`string`,morphs:(e,t)=>{let n=new Date(e);return Number.isNaN(n.valueOf())?t.error(`a parsable date`):n},declaredOut:eE.Date}),iso:BO,epoch:RO},{name:`string.date`}),HO=DO(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,`an email address`,`email`),UO=`(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])`,WO=`(${UO}[.]){3}${UO}`,GO=RegExp(`^${WO}$`),KO=`(?:[0-9a-fA-F]{1,4})`,qO=RegExp(`^((?:${KO}:){7}(?:${KO}|:)|(?:${KO}:){6}(?:${WO}|:${KO}|:)|(?:${KO}:){5}(?::${WO}|(:${KO}){1,2}|:)|(?:${KO}:){4}(?:(:${KO}){0,1}:${WO}|(:${KO}){1,3}|:)|(?:${KO}:){3}(?:(:${KO}){0,2}:${WO}|(:${KO}){1,4}|:)|(?:${KO}:){2}(?:(:${KO}){0,3}:${WO}|(:${KO}){1,5}|:)|(?:${KO}:){1}(?:(:${KO}){0,4}:${WO}|(:${KO}){1,6}|:)|(?::((?::${KO}){0,5}:${WO}|(?::${KO}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?\$`),JO=dO.module({root:[`v4 | v6`,`@`,`an IP address`],v4:DO(GO,`an IPv4 address`,`ipv4`),v6:DO(qO,`an IPv6 address`,`ipv6`)},{name:`string.ip`}),YO=`a JSON string`,XO=e=>{if(!(e instanceof SyntaxError))throw e;return`must be ${YO} (${e})`},ZO=qT({meta:YO,domain:`string`,predicate:{meta:YO,predicate:(e,t)=>{try{return JSON.parse(e),!0}catch(e){return t.reject({code:`predicate`,expected:YO,problem:XO(e)})}}}}),QO=dO.module({root:ZO,parse:qT({meta:`safe JSON string parser`,in:`string`,morphs:(e,t)=>{if(e.length===0)return t.error({code:`predicate`,expected:YO,actual:`empty`});try{return JSON.parse(e)}catch(e){return t.error({code:`predicate`,expected:YO,problem:XO(e)})}},declaredOut:eE.jsonObject})},{name:`string.json`}),$O=DO(/^[a-z]*$/,`only lowercase letters`),ek=dO.module({root:qT({in:`string`,morphs:e=>e.toLowerCase(),declaredOut:$O}),preformatted:$O},{name:`string.lower`}),tk=[`NFC`,`NFD`,`NFKC`,`NFKD`],nk=$y(tk,(e,t)=>[t,qT({domain:`string`,predicate:e=>e.normalize(t)===e,meta:`${t}-normalized unicode`})]),rk=$y(tk,(e,t)=>[t,qT({in:`string`,morphs:e=>e.normalize(t),declaredOut:nk[t]})]),ik=dO.module({root:rk.NFC,preformatted:nk.NFC},{name:`string.normalize.NFC`}),ak=dO.module({root:rk.NFD,preformatted:nk.NFD},{name:`string.normalize.NFD`}),ok=dO.module({root:rk.NFKC,preformatted:nk.NFKC},{name:`string.normalize.NFKC`}),sk=dO.module({root:rk.NFKD,preformatted:nk.NFKD},{name:`string.normalize.NFKD`}),ck=dO.module({root:`NFC`,NFC:ik,NFD:ak,NFKC:ok,NFKD:sk},{name:`string.normalize`}),lk=DO(Xb,`a well-formed numeric string`),uk=dO.module({root:lk,parse:qT({in:lk,morphs:e=>Number.parseFloat(e),declaredOut:eE.number})},{name:`string.numeric`}),dk=`a regex pattern`,fk=qT({domain:`string`,predicate:{meta:dk,predicate:(e,t)=>{try{return new RegExp(e),!0}catch(e){return t.reject({code:`predicate`,expected:dk,problem:String(e)})}}},meta:{format:`regex`}}),pk=DO(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,`a semantic version (see https://semver.org/)`),mk=DO(/^\S.*\S$|^\S?$/,`trimmed`),hk=dO.module({root:qT({in:`string`,morphs:e=>e.trim(),declaredOut:mk}),preformatted:mk},{name:`string.trim`}),gk=DO(/^[A-Z]*$/,`only uppercase letters`),_k=dO.module({root:qT({in:`string`,morphs:e=>e.toUpperCase(),declaredOut:gk}),preformatted:gk},{name:`string.upper`}),vk=qT({domain:`string`,predicate:{meta:`a URL string`,predicate:e=>URL.canParse(e)},meta:{format:`uri`}}),yk=dO.module({root:vk,parse:qT({declaredIn:vk,in:`string`,morphs:(e,t)=>{try{return new URL(e)}catch{return t.error(`a URL string`)}},declaredOut:qT(URL)})},{name:`string.url`}),bk=dO.module({root:[`versioned | nil | max`,`@`,{description:`a UUID`,format:`uuid`}],"#nil":`'00000000-0000-0000-0000-000000000000'`,"#max":`'ffffffff-ffff-ffff-ffff-ffffffffffff'`,"#versioned":/^[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,v1:DO(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv1`),v2:DO(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv2`),v3:DO(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv3`),v4:DO(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv4`),v5:DO(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv5`),v6:DO(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv6`),v7:DO(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv7`),v8:DO(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv8`)},{name:`string.uuid`}),xk=dO.module({root:eE.string,alpha:DO(/^[A-Za-z]*$/,`only letters`),alphanumeric:DO(/^[\dA-Za-z]*$/,`only letters and digits 0-9`),hex:AO,base64:jO,capitalize:NO,creditCard:PO,date:VO,digits:DO(/^\d*$/,`only digits 0-9`),email:HO,integer:kO,ip:JO,json:QO,lower:ek,normalize:ck,numeric:uk,regex:fk,semver:pk,trim:hk,upper:_k,url:yk,uuid:bk},{name:`string`}),Sk=dO.module({bigint:eE.bigint,boolean:eE.boolean,false:eE.false,never:eE.never,null:eE.null,number:eE.number,object:eE.object,string:eE.string,symbol:eE.symbol,true:eE.true,unknown:eE.unknown,undefined:eE.undefined}),Ck=dO.module({root:eE.unknown,any:eE.unknown},{name:`unknown`}),wk=dO.module({root:eE.jsonObject,stringify:JT(`morph`,{in:eE.jsonObject,morphs:e=>JSON.stringify(e),declaredOut:eE.string})},{name:`object.json`}),Tk=dO.module({root:eE.object,json:wk},{name:`object`}),Ek=class extends Fb{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'},Dk=YT([`K`,eE.key],`V`)(e=>({domain:`object`,index:{signature:e.K,value:e.V}}),Ek),Ok=class extends Fb{description='pick a set of properties from an object like `Pick(User, "name | age")`'},kk=YT([`T`,eE.object],[`K`,eE.key])(e=>e.T.pick(e.K),Ok),Ak=class extends Fb{description='omit a set of properties from an object like `Omit(User, "age")`'},jk=YT([`T`,eE.object],[`K`,eE.key])(e=>e.T.omit(e.K),Ak),Mk=class extends Fb{description="make all named properties of an object optional like `Partial(User)`"},Nk=YT([`T`,eE.object])(e=>e.T.partial(),Mk),Pk=class extends Fb{description="make all named properties of an object required like `Required(User)`"},Fk=YT([`T`,eE.object])(e=>e.T.required(),Pk),Ik=class extends Fb{description='exclude branches of a union like `Exclude("boolean", "true")`'},Lk=YT(`T`,`U`)(e=>e.T.exclude(e.U),Ik),Rk=class extends Fb{description='extract branches of a union like `Extract("0 | false | 1", "number")`'},zk=YT(`T`,`U`)(e=>e.T.extract(e.U),Rk),Bk=dO.module({Exclude:Lk,Extract:zk,Omit:jk,Partial:Nk,Pick:kk,Record:Dk,Required:Fk}),Vk=uO({...Sk,...Bk,...CO,...mO,string:xk,number:EO,object:Tk,unknown:Ck},{prereducedAliases:!0,name:`ark`}),Hk=Vk.export();Object.assign(cO.ambient,Hk),cO.typeAttachments={string:Hk.string.root,number:Hk.number.root,bigint:Hk.bigint,boolean:Hk.boolean,symbol:Hk.symbol,undefined:Hk.undefined,null:Hk.null,object:Hk.object.root,unknown:Hk.unknown.root,false:Hk.false,true:Hk.true,never:Hk.never,arrayIndex:Hk.Array.index,Key:Hk.Key,Record:Hk.Record,Array:Hk.Array.root,Date:Hk.Date};var Y=Object.assign(Vk.type,cO.typeAttachments);Vk.match,Vk.fn,Vk.generic,Vk.schema,Vk.define,Vk.declare;var Uk=Y(`"local" | "lan" | /^\\d{1,3}(?:\\.\\d{1,3}){3}$/`);function Wk(e){let t=Uk(e);return t instanceof Y.errors?null:t}var Gk=Y(`1 <= number.integer <= 65535 | null`),Kk=Y({enabled:`boolean = true`,maxRetries:`number.integer >= 0 = 3`,baseDelayMs:`number >= 0 = 1000`,factor:`number >= 1 = 2`,maxDelayMs:`number >= 0 = 30000`,resetAfterMs:`number >= 0 = 60000`}).onUndeclaredKey(`reject`),qk=Y({path:`string = "/"`,method:`"GET" | "HEAD" = "GET"`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer = 400`,expectBody:`string = ""`}).onUndeclaredKey(`reject`),Jk=Y({maxRssBytes:`number.integer >= 0 = 0`}).onUndeclaredKey(`reject`),Yk=Y({enabled:`boolean = true`,mode:`"port" | "http" = "port"`,http:qk.default(()=>({})),intervalMs:`number >= 500 = 5000`,timeoutMs:`number >= 100 = 1500`,unhealthyThreshold:`number.integer >= 1 = 3`,forceRestartAfterMs:`number >= 0 = 0`,startTimeoutMs:`number >= 0 = 20000`}).onUndeclaredKey(`reject`),Xk=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL" = "SIGTERM"`,killGroup:`boolean = true`,graceMs:`number >= 0 = 5000`,killPortHolders:`boolean = false`}).onUndeclaredKey(`reject`),Zk=Y({command:`string`,args:Y(`string[]`).default(()=>[]),env:Y(`Record<string, string>`).default(()=>({})),timeoutMs:`number >= 1000 = 120000`,runOnce:`boolean = true`}).onUndeclaredKey(`reject`).or(Y(`null`)),Qk=Y(`50 <= number.integer <= 100000`),$k=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,label:`string?`,enabled:`boolean = true`,autostart:`boolean = false`,command:`string >= 1`,args:Y(`string[]`).default(()=>[]),cwd:`string = "."`,env:Y(`Record<string, string>`).default(()=>({})),dataEnvs:Y(`Record<string, string>`).default(()=>({})),bootstrap:Zk.optional(),port:Gk.optional(),bind:Uk.default(()=>`local`),onPortConflict:`"block" | "warn" | "follow" | "reclaim" = "block"`,restart:Kk.default(()=>({})),health:Yk.default(()=>({})),stop:Xk.default(()=>({})),logBufferLines:Qk.default(()=>500),dependsOn:Y(`string[]`).default(()=>[]),envFile:`string = ""`,resources:Jk.default(()=>({})),backupPaths:Y(`string[]`).default(()=>[])}).onUndeclaredKey(`reject`),eA=Y({enabled:`boolean = true`,sessionTtlMs:`number >= 60000 = 604800000`,cookieSecure:`"auto" | "always" | "never" = "auto"`,trustProxy:`boolean = false`,maxLoginAttempts:`number.integer >= 1 = 5`,lockoutMs:`number >= 1000 = 60000`}).onUndeclaredKey(`reject`);Y({telegram:Y({enabled:`boolean = false`,chatId:`string = ""`,onCrash:`boolean = true`,onUnhealthy:`boolean = true`,onForcedRestart:`boolean = true`,onRecovered:`boolean = false`,onHost:`boolean = true`,cooldownMs:`number >= 0 = 120000`}).onUndeclaredKey(`reject`).default(()=>({}))}).onUndeclaredKey(`reject`);var tA=Y({persist:`boolean = true`,maxBytes:`10000 <= number <= 100000000 = 2000000`,keep:`1 <= number.integer <= 10 = 3`}).onUndeclaredKey(`reject`),nA=Y({enabled:`boolean = false`}).onUndeclaredKey(`reject`);Y({enabled:`boolean = true`,intervalMs:`number >= 5000 = 15000`,diskPaths:Y(`string[]`).default(()=>[`.`]),diskUsedPercent:`number >= 0 = 90`,memoryUsedPercent:`number >= 0 = 90`,swapUsedPercent:`number >= 0 = 50`,loadPerCpu:`number >= 0 = 2`,tempCelsius:`number >= 0 = 85`}).onUndeclaredKey(`reject`),Y({enabled:`boolean = true`,dir:`string = ".backups"`,keep:`number.integer >= 1 = 5`,includePaths:Y(`string[]`).default(()=>[])}).onUndeclaredKey(`reject`),Y({label:`1 <= string <= 60 = "home-hosted"`,port:`1 <= number.integer <= 65535 = 3999`,host:Uk.default(()=>`local`),openBrowser:`boolean = false`,auth:eA.default(()=>({})),tls:nA.default(()=>({}))}).onUndeclaredKey(`reject`);var rA=Y({enabled:`boolean = true`,autostart:`boolean = false`,bind:Uk.default(()=>`local`),onPortConflict:`"block" | "warn" | "follow" | "reclaim" = "block"`,restart:Kk.default(()=>({})),health:Yk.default(()=>({})),stop:Xk.default(()=>({})),logBufferLines:Qk.default(()=>500)}).onUndeclaredKey(`reject`),iA=Y({enabled:`boolean?`,maxRetries:`number.integer >= 0?`,baseDelayMs:`number >= 0?`,factor:`number >= 1?`,maxDelayMs:`number >= 0?`,resetAfterMs:`number >= 0?`}).onUndeclaredKey(`reject`),aA=Y({path:`string?`,method:`"GET" | "HEAD"?`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer?`,expectBody:`string?`}).onUndeclaredKey(`reject`),oA=Y({maxRssBytes:`number.integer >= 0?`}).onUndeclaredKey(`reject`),sA=Y({enabled:`boolean?`,mode:`"port" | "http"?`,http:aA.optional(),intervalMs:`number >= 500?`,timeoutMs:`number >= 100?`,unhealthyThreshold:`number.integer >= 1?`,forceRestartAfterMs:`number >= 0?`,startTimeoutMs:`number >= 0?`}).onUndeclaredKey(`reject`),cA=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL"?`,killGroup:`boolean?`,graceMs:`number >= 0?`,killPortHolders:`boolean?`}).onUndeclaredKey(`reject`),lA=Y({enabled:`boolean?`,sessionTtlMs:`number >= 60000?`,cookieSecure:`"auto" | "always" | "never"?`,trustProxy:`boolean?`,maxLoginAttempts:`number.integer >= 1?`,lockoutMs:`number >= 1000?`}).onUndeclaredKey(`reject`),uA=Y({telegram:Y({enabled:`boolean?`,chatId:`string?`,onCrash:`boolean?`,onUnhealthy:`boolean?`,onForcedRestart:`boolean?`,onRecovered:`boolean?`,onHost:`boolean?`,cooldownMs:`number >= 0?`}).onUndeclaredKey(`reject`).optional()}).onUndeclaredKey(`reject`),dA=Y({enabled:`boolean?`,intervalMs:`number >= 5000?`,diskPaths:Y(`string[]`).optional(),diskUsedPercent:`number >= 0?`,memoryUsedPercent:`number >= 0?`,swapUsedPercent:`number >= 0?`,loadPerCpu:`number >= 0?`,tempCelsius:`number >= 0?`}).onUndeclaredKey(`reject`),fA=Y({enabled:`boolean?`,dir:`string?`,keep:`number.integer >= 1?`,includePaths:Y(`string[]`).optional()}).onUndeclaredKey(`reject`),pA=Y({persist:`boolean?`,maxBytes:`10000 <= number <= 100000000?`,keep:`1 <= number.integer <= 10?`}).onUndeclaredKey(`reject`),mA=Y({enabled:`boolean?`}).onUndeclaredKey(`reject`),hA=Y({label:`1 <= string <= 60?`,port:`1 <= number.integer <= 65535?`,host:Uk.optional(),openBrowser:`boolean?`,auth:lA.optional(),tls:mA.optional()}).onUndeclaredKey(`reject`),gA=Y({enabled:`boolean?`,autostart:`boolean?`,bind:Uk.optional(),onPortConflict:`"block" | "warn" | "follow" | "reclaim"?`,restart:iA.optional(),health:sA.optional(),stop:cA.optional(),logBufferLines:Qk.optional()}).onUndeclaredKey(`reject`),_A={label:`string?`,enabled:`boolean?`,autostart:`boolean?`,command:`string?`,args:`string[]?`,cwd:`string?`,env:`Record<string, string>?`,dataEnvs:`Record<string, string>?`,bootstrap:Zk.optional(),port:Gk.optional(),bind:Uk.optional(),onPortConflict:`"block" | "warn" | "follow" | "reclaim"?`,restart:iA.optional(),health:sA.optional(),stop:cA.optional(),logBufferLines:Qk.optional(),dependsOn:Y(`string[]`).optional(),envFile:`string?`,resources:oA.optional(),backupPaths:Y(`string[]`).optional()},vA=Y(_A).onUndeclaredKey(`reject`);Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,..._A,command:`string`}).onUndeclaredKey(`reject`);var yA=Y({control:hA.optional(),defaults:gA.optional(),logs:pA.optional(),notifications:uA.optional(),host:dA.optional(),backups:fA.optional()}).onUndeclaredKey(`reject`),bA=Y({enabled:`boolean`,passwordSet:`boolean`,passwordUpdatedAt:`number | null`,apiTokenSet:`boolean?`,usingDefaultPassword:`boolean`,exposed:`boolean`,blockedReason:`string | null`,sessionTtlMs:`number`,cookieSecure:`string`,trustProxy:`boolean`,maxLoginAttempts:`number`,lockoutMs:`number`}),xA=Y({enabled:`boolean`,certPresent:`boolean`,subject:`string | null`,issuer:`string | null`,validFrom:`string | null`,validTo:`string | null`,daysRemaining:`number | null`,fingerprint:`string | null`,keyMatches:`boolean | null`,error:`string | null`}),SA=Y({telegram:Y({enabled:`boolean`,tokenSet:`boolean`,chatId:`string`,onCrash:`boolean`,onUnhealthy:`boolean`,onForcedRestart:`boolean`,onRecovered:`boolean`,onHost:`boolean`,cooldownMs:`number`,lastResult:`string | null`,lastResultAt:`number | null`})});Y({authenticated:`boolean`,authRequired:`boolean`,passwordSet:`boolean`,apiTokenSet:`boolean?`,usingDefaultPassword:`boolean`,defaultPassword:`string | null`,sessionTtlMs:`number`});var CA=Y({password:`string`}).onUndeclaredKey(`reject`),wA=Y(`1 <= string <= 512`),TA=Y({currentPassword:`string?`,newPassword:wA}).onUndeclaredKey(`reject`),EA=Y(`"stopped" | "starting" | "running" | "stopping" | "backoff" | "crashed" | "conflict"`),DA=Y(`"disabled" | "unknown" | "healthy" | "unhealthy"`),OA=Y(`"unknown" | "free" | "in-use"`),kA=Y({ts:`number`,stream:Y(`"stdout" | "stderr" | "system"`),text:`string`}),AA=Y({windowMs:`number`,uptimeRatio:`number | null`,restarts:`number`,crashes:`number`,forcedRestarts:`number`,lastCrashAt:`number | null`,lastExitAt:`number | null`,lastRuntimeMs:`number | null`,events:Y({serverId:`string`,ts:`number`,type:`"start" | "exit" | "crash" | "forced-restart" | "unhealthy" | "recovered"`,detail:`string`,runtimeMs:`number?`}).array()}),jA=Y({cpuPercent:`number | null`,rssBytes:`number | null`,processes:`number`,sampledAt:`number`}),MA=Y({path:`string`,totalBytes:`number`,freeBytes:`number`,usedPercent:`number`}),NA=Y({enabled:`boolean`,cpus:`number`,loadAvg:Y(`number[]`),uptimeMs:`number`,memoryUsedPercent:`number`,swapUsedPercent:`number`,tempCelsius:`number | null`,disks:MA.array(),alerts:Y(`string[]`),sampledAt:`number | null`}),PA=Y({name:`string`,sizeBytes:`number`,createdAt:`number`,encrypted:`boolean`}),FA=Y({path:`string`,origin:`string`,included:`boolean`,note:`string | null`}),IA=Y({enabled:`boolean`,dir:`string`,keep:`number`,includePaths:Y(`string[]`),paths:FA.array(),files:PA.array()});Y({dryRun:`boolean`,encrypted:`boolean`,needsPassword:`boolean`,items:Y({id:`string`,label:`string`,kind:`"config" | "secrets" | "tls" | "data"`,restorable:`boolean`,selected:`boolean`,note:`string | null`}).array(),applied:Y(`string[]`),skipped:Y(`string[]`),restartRequired:`boolean`,reloaded:`boolean`,error:`string?`}),Y({password:wA.optional()}).onUndeclaredKey(`reject`),Y({name:`string?`,password:wA.optional(),include:Y(`string[]`).optional()}).onUndeclaredKey(`reject`);var LA=Y({id:`string`,config:$k,bindHost:`string`,url:`string | null`,status:EA,health:DA,portState:OA,pid:`number | null`,adopted:`boolean?`,startedAt:`number | null`,exitCode:`number | null`,exitSignal:`string | null`,restarts:`number`,maxRetries:`number`,lastError:`string | null`,nextRetryAt:`number | null`,unhealthySince:`number | null`,bufferedLines:`number`,history:AA,responseMs:`number | null`,resources:jA.or(Y(`null`))}),RA=Y({control:Y({label:`string`,port:`number`,host:`string`,bindHost:`string`,url:`string`,openBrowser:`boolean`,restartRequired:`boolean`,protocol:`string`,auth:bA,tls:xA}),defaults:rA,logs:tA,notifications:SA,host:NA,backups:IA,configPath:`string`,configError:`string | null`,projectDir:`string`,dataRoot:`string`,logsDir:`string`,servers:LA.array()}),zA=Y({type:`"hello" | "state" | "log" | "server"`,ts:`number`,serverId:`string?`,state:RA.optional(),server:LA.optional(),lines:kA.array().optional()});Y({limit:`string?`}),Y({ok:`boolean`,port:`number | null`,terminated:`number[]`,forced:`number[]`,skipped:`number[]`,free:`boolean`}),Y({tail:`string?`,search:`string?`,stream:`"stdout" | "stderr" | "system"?`});var BA=Y({servers:Y({serverId:`string`,label:`string`,status:EA,enabled:`boolean`,sizeBytes:`number`,files:Y({name:`string`,sizeBytes:`number`}).array()}).array()}),VA=Y({serverId:`string`,enabled:`boolean`,sizeBytes:`number`,files:Y(`string[]`),searched:`number | null`,lines:kA.array()});Y({botToken:`string?`,chatId:`string?`}).onUndeclaredKey(`reject`),Y({botToken:`string >= 1`}).onUndeclaredKey(`reject`),Y({message:`string`,code:`string`,detail:`unknown`}).onUndeclaredKey(`reject`),Y({custom:`boolean`,dir:`string`,meta:Y({name:`string`,version:`string | null`,uploadedAt:`number`,files:`number.integer >= 1`}).or(Y(`null`))}),Y({certificate:`string >= 1`,privateKey:`string >= 1`}).onUndeclaredKey(`reject`);var HA=/^[\w!#$%&'*.^`|~+-]+$/,UA=(e,t,n={})=>{if(!HA.test(e))throw Error(`Invalid cookie name`);let r=`${e}=${t}`;if(e.startsWith(`__Secure-`)&&!n.secure)throw Error(`__Secure- Cookie must have Secure attributes`);if(e.startsWith(`__Host-`)){if(!n.secure)throw Error(`__Host- Cookie must have Secure attributes`);if(n.path!==`/`)throw Error(`__Host- Cookie must have Path attributes with "/"`);if(n.domain)throw Error(`__Host- Cookie must not have Domain attributes`)}for(let e of[`domain`,`path`,`sameSite`,`priority`])if(n[e]&&/[;\r\n]/.test(n[e]))throw Error(`${e} must not contain ";", "\\r", or "\\n"`);if(n&&typeof n.maxAge==`number`&&n.maxAge>=0){if(n.maxAge>3456e4)throw Error(`Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.`);r+=`; Max-Age=${n.maxAge|0}`}if(n.domain&&n.prefix!==`host`&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw Error(`Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.priority&&(r+=`; Priority=${n.priority.charAt(0).toUpperCase()+n.priority.slice(1)}`),n.partitioned){if(!n.secure)throw Error(`Partitioned Cookie must have Secure attributes`);r+=`; Partitioned`}return r},WA=(e,t,n)=>(t=encodeURIComponent(t),UA(e,t,n)),GA=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),KA=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??(?=/|$)`);e=e.replace(t,()=>r?`/${r}`:``)}return e},qA=e=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(r!==void 0){if(Array.isArray(r))for(let e of r)e!==void 0&&t.append(n,e);else t.set(n,r)}return t},JA=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},YA=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function XA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ZA(e,t){if(!XA(e)&&!XA(t))return t;let n={...e};for(let e in t){let r=t[e];n[e]=XA(n[e])&&XA(r)?ZA(n[e],r):r}return n}var QA=(e,t)=>new Proxy(()=>{},{get(n,r){if(typeof r==`string`&&r!==`then`)return QA(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}}),$A=(e,t)=>{let n=t.toString();return n?`${e}?${n}`:e},ej=class{url;method;buildSearchParams;queryParams=void 0;pathParams={};rBody;cType=void 0;constructor(e,t,n){this.url=e,this.method=t,this.buildSearchParams=n.buildSearchParams}fetch=async(e,t)=>{if(e){if(e.query&&(this.queryParams=this.buildSearchParams(e.query)),e.form){let t=new FormData;for(let[n,r]of Object.entries(e.form))if(r!==void 0){if(Array.isArray(r))for(let e of r)e!==void 0&&t.append(n,e);else t.append(n,r)}this.rBody=t}e.json!==void 0&&(this.rBody=JSON.stringify(e.json),this.cType=`application/json`),e.param&&(this.pathParams=e.param)}let n=this.method.toUpperCase(),r={...e?.header,...typeof t?.headers==`function`?await t.headers():t?.headers};if(e?.cookie){let t=[];for(let[n,r]of Object.entries(e.cookie))r!==void 0&&t.push(WA(n,r));t.length>0&&(r.Cookie=t.join(`; `))}this.cType&&(r[`Content-Type`]=this.cType);let i=new Headers;for(let[e,t]of Object.entries(r))t!==void 0&&i.set(e,t);let a=this.url;a=YA(a),a=KA(a,this.pathParams),this.queryParams&&(a=$A(a,this.queryParams)),n=this.method.toUpperCase();let o=n!==`GET`&&n!==`HEAD`;return(t?.fetch||fetch)(a,{body:o?this.rBody:void 0,method:n,headers:i,...t?.init})}},tj=((e,t)=>QA(function n(r){let i=t?.buildSearchParams??qA,a=[...r.path],o=a.slice(-3).reverse();if(o[0]===`toString`)return o[1]===`name`?o[2]||``:n.toString();if(o[0]===`valueOf`)return o[1]===`name`?o[2]||``:n;let s=``;if(/^\$/.test(o[0])){let e=a.pop();e&&(s=e.replace(/^\$/,``))}let c=GA(e,a.join(`/`));if(s===`url`||s===`path`){let t=YA(c);return r.args[0]&&(r.args[0].param&&(t=KA(t,r.args[0].param)),r.args[0].query&&(t=$A(t,i(r.args[0].query)))),s===`url`?new URL(t):t.slice(e.replace(/\/+$/,``).length).replace(/^\/?/,`/`)}if(s===`ws`){let e=YA(c),n=JA(r.args[0]?.param?KA(e,r.args[0].param):e,`ws`),a=new URL(n),o=r.args[0]?.query;return o&&i(o).forEach((e,t)=>{a.searchParams.append(t,e)}),((...e)=>t?.webSocket!==void 0&&typeof t.webSocket==`function`?t.webSocket(...e):new WebSocket(...e))(a.toString())}let l=new ej(c,s,{buildSearchParams:i});if(s){t??={};let e={...r.args[1]},n=t.headers,i=e.headers;n&&i&&(e.headers=async()=>({...typeof n==`function`?await n():n,...typeof i==`function`?await i():i}));let a=ZA(t,e);return l.fetch(r.args[0],a)}return l},[]))(typeof window>`u`?`http://127.0.0.1`:window.location.origin),nj=class extends Error{name=`AuthRequiredError`;constructor(){super(`authentication required`)}};function rj(e){return typeof e==`object`&&!!e}async function ij(e,t){let n=await fetch(e,{...t,headers:{"Content-Type":`application/json`,...t?.headers}}),r=await n.text(),i=r.length>0?JSON.parse(r):null;if(!n.ok){if(n.status===401&&rj(i)&&i.code===`AUTH_REQUIRED`)throw new nj;let e=rj(i)&&typeof i.message==`string`?i.message:rj(i)&&`error`in i?String(i.error):`request failed with ${n.status}`;throw Error(e)}return i}async function aj(){let e=RA(await ij(`/api/state`));if(e instanceof Y.errors)throw Error(`state contract mismatch: ${e.summary}`);return e}function oj(){return ij(`/api/auth/session`)}function sj(e){let t=CA({password:e});if(t instanceof Y.errors)throw Error(t.summary);return ij(`/api/auth/login`,{method:`POST`,body:JSON.stringify(t)})}function cj(){return ij(`/api/auth/logout`,{method:`POST`})}function lj(e,t){let n=TA(e===void 0?{newPassword:t}:{currentPassword:e,newPassword:t});if(n instanceof Y.errors)throw Error(n.summary);return ij(`/api/auth/password`,{method:`POST`,body:JSON.stringify(n)})}function uj(){return ij(`/api/auth/password`,{method:`DELETE`})}function dj(){return ij(`/api/settings`)}function fj(e){let t=yA(e);if(t instanceof Y.errors)throw Error(t.summary);return ij(`/api/settings`,{method:`PATCH`,body:JSON.stringify(t)})}async function pj(){let e=BA(await ij(`/api/logs`));if(e instanceof Y.errors)throw Error(`logs contract mismatch: ${e.summary}`);return e.servers}async function mj(e,t){let n=new URLSearchParams;t.tail!==void 0&&n.set(`tail`,String(t.tail)),t.search!==void 0&&t.search.length>0&&n.set(`search`,t.search),t.stream!==void 0&&t.stream.length>0&&n.set(`stream`,t.stream);let r=VA(await ij(`/api/logs/${encodeURIComponent(e)}?${n.toString()}`));if(r instanceof Y.errors)throw Error(`log history contract mismatch: ${r.summary}`);return r}function hj(e){return ij(`/api/logs/${encodeURIComponent(e)}`,{method:`DELETE`})}function gj(e,t){return`/api/logs/${encodeURIComponent(e)}/download?file=${encodeURIComponent(t)}`}function _j(e){return ij(`/api/backups`,{method:`POST`,body:JSON.stringify(e===void 0||e.length===0?{}:{password:e})})}function vj(e){return ij(`/api/backups/${encodeURIComponent(e)}`,{method:`DELETE`})}function yj(e){return`/api/backups/${encodeURIComponent(e)}/download`}function bj(e){let t={};return e.password!==void 0&&e.password.length>0&&(t.password=e.password),e.include!==void 0&&(t.include=e.include),t}function xj(e,t,n={}){return ij(`/api/backups/restore?confirm=${t}`,{method:`POST`,body:JSON.stringify({name:e,...bj(n)})})}async function Sj(e,t,n={}){let r=new FormData;r.append(`file`,e),n.password!==void 0&&n.password.length>0&&r.append(`password`,n.password),n.include!==void 0&&r.append(`include`,JSON.stringify(n.include));let i=await fetch(`/api/backups/restore?confirm=${t}`,{method:`POST`,body:r}),a=await i.json().catch(()=>null);if(!i.ok)throw Error(a?.error??`restore failed with ${i.status}`);return a}function Cj(e){return ij(`/api/notifications/token`,{method:`PUT`,body:JSON.stringify({botToken:e})})}function wj(){return ij(`/api/notifications/token`,{method:`DELETE`})}function Tj(e){return ij(`/api/notifications/test`,{method:`POST`,body:JSON.stringify(e)})}function Ej(e){return ij(`/api/notifications/detect-chats`,{method:`POST`,body:JSON.stringify(e)})}async function Dj(e){let t=new FormData;t.append(`file`,e);let n=await fetch(`/api/settings/ui`,{method:`POST`,body:t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.message??r?.error??`the upload failed with ${n.status}`);return r}function Oj(){return ij(`/api/settings/ui`,{method:`DELETE`})}function kj(e,t){return ij(`/api/settings/tls`,{method:`POST`,body:JSON.stringify({certificate:e,privateKey:t})})}function Aj(){return ij(`/api/settings/tls`,{method:`DELETE`})}async function jj(e,t){let n=await tj.api.servers[`:id`][t].$post({param:{id:e}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.message??`request failed with ${n.status}`);return r??{ok:!0}}function Mj(){return ij(`/api/servers/start-all`,{method:`POST`})}async function Nj(e){let t=await tj.api.servers[`:id`][`free-port`].$post({param:{id:e}}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.message??`request failed with ${t.status}`);return n??{ok:!0,port:null,terminated:[],forced:[],skipped:[],free:!1}}function Pj(){return ij(`/api/servers/stop-all`,{method:`POST`})}function Fj(e){return ij(`/api/servers/${encodeURIComponent(e)}/clear-logs`,{method:`POST`})}function Ij(e,t){return ij(`/api/servers/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function Lj(e){return ij(`/api/servers/${encodeURIComponent(e)}`,{method:`DELETE`})}function Rj(e){return ij(`/api/servers`,{method:`POST`,body:JSON.stringify(e)})}var zj=j(null),Bj=j(null);function Vj(){async function e(){try{zj.value=await oj()}catch{zj.value=null}}async function t(e){Bj.value=null;try{return zj.value=await sj(e),!0}catch(e){return Bj.value=e instanceof Error?e.message:String(e),!1}}async function n(){try{await cj()}finally{await e()}}function r(){zj.value={authenticated:!1,authRequired:!0,passwordSet:zj.value?.passwordSet??!0,apiTokenSet:zj.value?.apiTokenSet??!1,usingDefaultPassword:zj.value?.usingDefaultPassword??!1,defaultPassword:zj.value?.defaultPassword??null,sessionTtlMs:zj.value?.sessionTtlMs??0}}async function i(t,n){Bj.value=null;try{return await lj(t,n),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}async function a(){Bj.value=null;try{return await uj(),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}return{session:nn(zj),error:nn(Bj),refresh:e,login:t,logout:n,requireLogin:r,setPassword:i,clearPassword:a}}var Hj=j([]),Uj=1;function Wj(e){Hj.value=Hj.value.filter(t=>t.id!==e)}function Gj(e,t=4800){let n=Uj++;return Hj.value=[...Hj.value,{...e,id:n}],t>0&&setTimeout(Wj,t,n),n}function Kj(){return{toasts:nn(Hj),dismiss:Wj,push:Gj,success:(e,t)=>Gj({tone:`ok`,title:e,description:t}),failure:(e,t)=>Gj({tone:`danger`,title:e,description:t},9e3),info:(e,t)=>Gj({tone:`info`,title:e,description:t}),warn:(e,t)=>Gj({tone:`warn`,title:e,description:t},7e3)}}var qj=4e3;function Jj(){return en({ts:[],cpu:[],rss:[],probe:[],lastSampledAt:-1})}function Yj(e){let t=e.ts.length-120;t<=0||(e.ts.splice(0,t),e.cpu.splice(0,t),e.rss.splice(0,t),e.probe.splice(0,t))}function Xj(e,t,n){let r=t.resources?.sampledAt??0,i=e.ts[e.ts.length-1]??0;if(!(r!==e.lastSampledAt||n-i>=qj)){e.probe.length>0&&(e.probe[e.probe.length-1]=t.responseMs);return}e.lastSampledAt=r,e.ts.push(n);let a=t.status===`running`;e.cpu.push(a?t.resources?.cpuPercent??null:null),e.rss.push(a?t.resources?.rssBytes??null:null),e.probe.push(t.responseMs),Yj(e)}function Zj(e){let t=0;for(let n of e)n!==null&&n>t&&(t=n);return t}function Qj(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n!=null)return n}return null}var $j=8e3,eM=j(null),tM=j(`connecting`),nM=j(null),rM=j(Date.now()),iM=new Map,aM=Kj(),oM=new Map,sM=j(0),cM=null,lM=null;function uM(e){let t=oM.get(e);if(t)return t;let n={lines:[],version:j(0),refs:0,source:null};return oM.set(e,n),n}function dM(e,t){let n=uM(e),r=n.lines.concat(t);n.lines=r.length>8e3?r.slice(r.length-$j):r,n.version.value+=1,sM.value+=1}function fM(e){return oM.get(e)?.lines??[]}function pM(e){let t=oM.get(e);t&&(t.lines=[],t.version.value+=1,sM.value+=1)}function mM(e){let t=iM.get(e);if(t)return t;let n=Jj();return iM.set(e,n),n}function hM(e){Xj(mM(e.id),e,Date.now())}function gM(e){let t=eM.value;if(!t)return;let n=t.servers.findIndex(t=>t.id===e.id);n===-1?t.servers.push(e):t.servers[n]=e}function _M(e){let t;try{t=JSON.parse(e)}catch{return}let n=zA(t);if(n instanceof Y.errors){console.warn(`[home-hosted] ignored malformed SSE frame`,n.summary);return}if(n.type===`hello`||n.type===`state`){if(n.state){eM.value=n.state;for(let e of eM.value.servers)hM(e)}return}if(n.type===`server`&&n.server){let e=n.server;gM(e),hM(e);return}n.type===`log`&&n.serverId&&n.lines&&dM(n.serverId,n.lines)}function vM(e,t){let n=new EventSource(`/api/servers/${encodeURIComponent(e)}/stream`),r=e=>_M(e.data);for(let e of[`log`,`server`])n.addEventListener(e,r);n.onerror=()=>{},t.source=n}function yM(e){let t=uM(e);t.refs+=1,t.source||vM(e,t)}function bM(e){let t=oM.get(e);t&&(t.refs=Math.max(0,t.refs-1),t.refs===0&&(t.source?.close(),t.source=null))}function xM(){if(cM)return;lM??=setInterval(()=>{rM.value=Date.now()},1e3);let e=new EventSource(`/api/events?logs=0`);cM=e,tM.value=`connecting`,e.onopen=()=>{tM.value=`open`},e.onerror=()=>{tM.value=`closed`};for(let t of[`hello`,`state`,`server`,`log`])e.addEventListener(t,e=>{_M(e.data)})}function SM(){cM?.close(),cM=null,lM&&clearInterval(lM),lM=null}function CM(e){let t=W(()=>vn(e)),n=null;return Ar(t,e=>{n!==null&&n!==e&&bM(n),n=e,e!==null&&e.length>0&&yM(e)},{immediate:!0}),ze(()=>{n!==null&&bM(n),n=null}),{version:W(()=>{let e=t.value;return sM.value,e===null?0:oM.get(e)?.version.value??0}),lines(){let e=t.value;return e===null?[]:fM(e)},count:W(()=>{let e=t.value;return sM.value,e===null?0:oM.get(e)?.lines.length??0}),clear(){let e=t.value;e!==null&&pM(e)}}}function wM(){let e=W(()=>eM.value?.servers??[]),t=W(()=>eM.value?.control??null),n=W(()=>eM.value?.defaults??null),r=W(()=>eM.value?.host??null),i=W(()=>eM.value?.backups??null),a=W(()=>eM.value?.notifications??null),o=W(()=>eM.value?.logs??null),s=W(()=>eM.value?.configError??null);function c(e){return eM.value?.servers.find(t=>t.id===e)}function l(e){return mM(e)}async function u(e,t){nM.value=null;try{let n=await e();eM.value=await aj();let r=typeof t.success==`function`?t.success(n):t.success;return r&&aM.success(r),n}catch(e){if(e instanceof nj){Vj().requireLogin();return}let n=e instanceof Error?e.message:String(e);nM.value=n,aM.failure(t.title,n);return}}return{appState:nn(eM),servers:e,control:t,defaults:n,host:r,backups:i,notifications:a,logsConfig:o,configError:s,connection:nn(tM),lastError:nn(nM),now:nn(rM),serverById:c,seriesOf:l,refresh:(e=`Refresh failed`)=>u(async()=>{},{title:e}),start:e=>u(()=>jj(e,`start`),{title:`Could not start ${e}`}),stop:e=>u(()=>jj(e,`stop`),{title:`Could not stop ${e}`}),restart:e=>u(()=>jj(e,`restart`),{title:`Could not restart ${e}`}),startAll:()=>u(()=>Mj(),{title:`Could not start every server`,success:`Starting every enabled server`}),stopAll:()=>u(()=>Pj(),{title:`Could not stop every server`,success:`Stopping every server`}),setAutostart:(e,t)=>u(()=>Ij(e,{autostart:t}),{title:`Could not change autostart for ${e}`}),setEnabled:(e,t)=>u(()=>Ij(e,{enabled:t}),{title:`Could not change ${e}`}),freePort:e=>u(()=>Nj(e),{title:`Could not free the port for ${e}`,success:t=>t.free?`Port ${t.port} is free — start ${e} now`:`Port ${t.port} is still held`}),setBind:(e,t)=>{let n=Wk(t);return n===null?(aM.failure(`Could not change the bind for ${e}`,`"${t}" is not a bind value`),Promise.resolve(void 0)):u(()=>Ij(e,{bind:n}),{title:`Could not change the bind for ${e}`})},saveConfig:(e,t)=>u(()=>Ij(e,t),{title:`Could not save ${e}`,success:`${e} updated`}),saveSettings:e=>u(()=>fj(e),{title:`Could not save the settings`}),clearLogs:e=>u(async()=>{await Fj(e),pM(e)},{title:`Could not clear the logs for ${e}`,success:`Buffer cleared`}),create:e=>u(()=>Rj(e),{title:`Could not add the server`,success:`Server added`}),remove:e=>u(async()=>{await Lj(e),bM(e),oM.delete(e),iM.delete(e)},{title:`Could not remove ${e}`,success:`${e} removed`})}}var TM=`hh.theme`;function EM(){try{let e=localStorage.getItem(TM);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var DM=j(EM()),OM=j(typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches),kM=!1;function AM(){kM||typeof matchMedia>`u`||(kM=!0,matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{OM.value=e.matches,MM()}))}var jM=W(()=>DM.value===`system`?OM.value:DM.value===`dark`);function MM(){typeof document<`u`&&document.documentElement.classList.toggle(`dark`,jM.value)}function NM(){AM(),MM();function e(e){DM.value=e;try{localStorage.setItem(TM,e)}catch{}MM()}return{preference:DM,isDark:jM,setPreference:e,cycle(){e(DM.value===`light`?`dark`:DM.value===`dark`?`system`:`light`)}}}function PM(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=PM(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function FM(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=PM(e))&&(r&&(r+=` `),r+=t);return r}var IM=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},LM=(e,t)=>({classGroupId:e,validator:t}),RM=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),zM=`-`,BM=[],VM=`arbitrary..`,HM=e=>{let t=GM(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return WM(e);let n=e.split(zM);return UM(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?IM(i,t):t:i||BM}return n[e]||BM}}},UM=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=UM(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(zM):e.slice(t).join(zM),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},WM=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?VM+r:void 0})(),GM=e=>{let{theme:t,classGroups:n}=e;return KM(n,t)},KM=(e,t)=>{let n=RM();for(let r in e){let i=e[r];qM(i,n,r,t)}return n},qM=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];JM(i,t,n,r)}},JM=(e,t,n,r)=>{if(typeof e==`string`){YM(e,t,n);return}if(typeof e==`function`){XM(e,t,n,r);return}ZM(e,t,n,r)},YM=(e,t,n)=>{let r=e===``?t:QM(t,e);r.classGroupId=n},XM=(e,t,n,r)=>{if($M(e)){qM(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(LM(n,e))},ZM=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];qM(o,QM(t,a),n,r)}},QM=(e,t)=>{let n=e,r=t.split(zM),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=RM(),n.nextPart.set(t,i)),n=i}return n},$M=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,eN=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},tN=`!`,nN=`:`,rN=[],iN=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),aN=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===nN){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(tN)?(c=s.slice(0,-1),l=!0):s.startsWith(tN)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return iN(t,l,c,u)};if(t){let e=t+nN,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):iN(rN,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},oN=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},sN=e=>({cache:eN(e.cacheSize),parseClassName:aN(e),sortModifiers:oN(e),postfixLookupClassGroupIds:cN(e),...HM(e)}),cN=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},lN=/\s+/,uN=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(lN),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+tN:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},dN=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=fN(n))&&(i&&(i+=` `),i+=r);return i},fN=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=fN(e[r]))&&(n&&(n+=` `),n+=t);return n},pN=(e,...t)=>{let n,r,i,a,o=o=>(n=sN(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=uN(e,n);return i(e,a),a};return a=o,(...e)=>a(dN(...e))},mN=[],hN=e=>{let t=t=>t[e]||mN;return t.isThemeGetter=!0,t.themeKey=e,t},gN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,_N=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,yN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,SN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,CN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,wN=e=>vN.test(e),TN=e=>!!e&&!Number.isNaN(Number(e)),EN=e=>!!e&&Number.isInteger(Number(e)),DN=e=>e.endsWith(`%`)&&TN(e.slice(0,-1)),ON=e=>yN.test(e),kN=()=>!0,AN=e=>bN.test(e)&&!xN.test(e),jN=()=>!1,MN=e=>SN.test(e),NN=e=>CN.test(e),PN=e=>!X(e)&&!Z(e),FN=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),IN=e=>ZN(e,tP,jN),X=e=>gN.test(e),LN=e=>ZN(e,nP,AN),RN=e=>ZN(e,rP,TN),zN=e=>ZN(e,aP,kN),BN=e=>ZN(e,iP,jN),VN=e=>ZN(e,$N,jN),HN=e=>ZN(e,eP,NN),UN=e=>ZN(e,oP,MN),Z=e=>_N.test(e),WN=e=>QN(e,nP),GN=e=>QN(e,iP),KN=e=>QN(e,$N),qN=e=>QN(e,tP),JN=e=>QN(e,eP),YN=e=>QN(e,oP,!0),XN=e=>QN(e,aP,!0),ZN=(e,t,n)=>{let r=gN.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},QN=(e,t,n=!1)=>{let r=_N.exec(e);return r?r[1]?t(r[1]):n:!1},$N=e=>e===`position`||e===`percentage`,eP=e=>e===`image`||e===`url`,tP=e=>e===`length`||e===`size`||e===`bg-size`,nP=e=>e===`length`,rP=e=>e===`number`,iP=e=>e===`family-name`,aP=e=>e===`number`||e===`weight`,oP=e=>e===`shadow`,sP=pN(()=>{let e=hN(`color`),t=hN(`font`),n=hN(`text`),r=hN(`font-weight`),i=hN(`tracking`),a=hN(`leading`),o=hN(`breakpoint`),s=hN(`container`),c=hN(`spacing`),l=hN(`radius`),u=hN(`shadow`),d=hN(`inset-shadow`),f=hN(`text-shadow`),p=hN(`drop-shadow`),m=hN(`blur`),h=hN(`perspective`),g=hN(`aspect`),_=hN(`ease`),v=hN(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),Z,X],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[Z,X,c],T=()=>[wN,`full`,`auto`,...w()],ee=()=>[EN,`none`,`subgrid`,Z,X],E=()=>[`auto`,{span:[`full`,EN,Z,X]},EN,Z,X],te=()=>[EN,`auto`,Z,X],ne=()=>[`auto`,`min`,`max`,`fr`,Z,X],re=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ie=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],ae=()=>[`auto`,...w()],oe=()=>[wN,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],se=()=>[s,wN,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],ce=()=>[wN,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],D=()=>[e,Z,X],le=()=>[...b(),KN,VN,{position:[Z,X]}],ue=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],de=()=>[`auto`,`cover`,`contain`,qN,IN,{size:[Z,X]}],fe=()=>[DN,WN,LN],pe=()=>[``,`none`,`full`,l,Z,X],me=()=>[``,TN,WN,LN],he=()=>[`solid`,`dashed`,`dotted`,`double`],ge=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],_e=()=>[TN,DN,KN,VN],ve=()=>[``,`none`,m,Z,X],ye=()=>[`none`,TN,Z,X],be=()=>[`none`,TN,Z,X],O=()=>[TN,Z,X],xe=()=>[wN,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[ON],breakpoint:[ON],color:[kN],container:[ON],"drop-shadow":[ON],ease:[`in`,`out`,`in-out`],font:[PN],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[ON],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[ON],shadow:[ON],spacing:[`px`,TN],text:[ON],"text-shadow":[ON],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,wN,X,Z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Z,X]}],"container-named":[FN],columns:[{columns:[TN,`auto`,X,Z,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[EN,`auto`,Z,X]}],basis:[{basis:[wN,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[TN,wN,`auto`,`initial`,`none`,X]}],grow:[{grow:[``,TN,Z,X]}],shrink:[{shrink:[``,TN,Z,X]}],order:[{order:[EN,`first`,`last`,`none`,Z,X]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:E()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:E()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...re(),`normal`]}],"justify-items":[{"justify-items":[...ie(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ie()]}],"align-content":[{content:[`normal`,...re()]}],"align-items":[{items:[...ie(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ie(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":re()}],"place-items":[{"place-items":[...ie(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ie()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:ae()}],mx:[{mx:ae()}],my:[{my:ae()}],ms:[{ms:ae()}],me:[{me:ae()}],mbs:[{mbs:ae()}],mbe:[{mbe:ae()}],mt:[{mt:ae()}],mr:[{mr:ae()}],mb:[{mb:ae()}],ml:[{ml:ae()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:oe()}],"inline-size":[{inline:[`auto`,...se()]}],"min-inline-size":[{"min-inline":[`auto`,...se()]}],"max-inline-size":[{"max-inline":[`none`,...se()]}],"block-size":[{block:[`auto`,...ce()]}],"min-block-size":[{"min-block":[`auto`,...ce()]}],"max-block-size":[{"max-block":[`none`,...ce()]}],w:[{w:[s,`screen`,...oe()]}],"min-w":[{"min-w":[s,`screen`,`none`,...oe()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...oe()]}],h:[{h:[`screen`,`lh`,...oe()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...oe()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...oe()]}],"font-size":[{text:[`base`,n,WN,LN]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,XN,zN]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,DN,X]}],"font-family":[{font:[GN,BN,t]}],"font-features":[{"font-features":[X]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,Z,X]}],"line-clamp":[{"line-clamp":[TN,`none`,Z,RN]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,Z,X]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,Z,X]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...he(),`wavy`]}],"text-decoration-thickness":[{decoration:[TN,`from-font`,`auto`,Z,LN]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[TN,`auto`,Z,X]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[EN,Z,X]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Z,X]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,Z,X]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:le()}],"bg-repeat":[{bg:ue()}],"bg-size":[{bg:de()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},EN,Z,X],radial:[``,Z,X],conic:[``,EN,Z,X]},JN,HN]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:fe()}],"gradient-via-pos":[{via:fe()}],"gradient-to-pos":[{to:fe()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:pe()}],"rounded-s":[{"rounded-s":pe()}],"rounded-e":[{"rounded-e":pe()}],"rounded-t":[{"rounded-t":pe()}],"rounded-r":[{"rounded-r":pe()}],"rounded-b":[{"rounded-b":pe()}],"rounded-l":[{"rounded-l":pe()}],"rounded-ss":[{"rounded-ss":pe()}],"rounded-se":[{"rounded-se":pe()}],"rounded-ee":[{"rounded-ee":pe()}],"rounded-es":[{"rounded-es":pe()}],"rounded-tl":[{"rounded-tl":pe()}],"rounded-tr":[{"rounded-tr":pe()}],"rounded-br":[{"rounded-br":pe()}],"rounded-bl":[{"rounded-bl":pe()}],"border-w":[{border:me()}],"border-w-x":[{"border-x":me()}],"border-w-y":[{"border-y":me()}],"border-w-s":[{"border-s":me()}],"border-w-e":[{"border-e":me()}],"border-w-bs":[{"border-bs":me()}],"border-w-be":[{"border-be":me()}],"border-w-t":[{"border-t":me()}],"border-w-r":[{"border-r":me()}],"border-w-b":[{"border-b":me()}],"border-w-l":[{"border-l":me()}],"divide-x":[{"divide-x":me()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":me()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...he(),`hidden`,`none`]}],"divide-style":[{divide:[...he(),`hidden`,`none`]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...he(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[TN,Z,X]}],"outline-w":[{outline:[``,TN,WN,LN]}],"outline-color":[{outline:D()}],shadow:[{shadow:[``,`inner`,`none`,u,YN,UN]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":[`none`,d,YN,UN]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:me()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[TN,LN]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":me()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":[`none`,f,YN,UN]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[TN,Z,X]}],"mix-blend":[{"mix-blend":[...ge(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ge()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[TN]}],"mask-image-linear-from-pos":[{"mask-linear-from":_e()}],"mask-image-linear-to-pos":[{"mask-linear-to":_e()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":_e()}],"mask-image-t-to-pos":[{"mask-t-to":_e()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":_e()}],"mask-image-r-to-pos":[{"mask-r-to":_e()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":_e()}],"mask-image-b-to-pos":[{"mask-b-to":_e()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":_e()}],"mask-image-l-to-pos":[{"mask-l-to":_e()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":_e()}],"mask-image-x-to-pos":[{"mask-x-to":_e()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":_e()}],"mask-image-y-to-pos":[{"mask-y-to":_e()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Z,X]}],"mask-image-radial-from-pos":[{"mask-radial-from":_e()}],"mask-image-radial-to-pos":[{"mask-radial-to":_e()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[TN]}],"mask-image-conic-from-pos":[{"mask-conic-from":_e()}],"mask-image-conic-to-pos":[{"mask-conic-to":_e()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:le()}],"mask-repeat":[{mask:ue()}],"mask-size":[{mask:de()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Z,X]}],filter:[{filter:[``,`none`,Z,X]}],blur:[{blur:ve()}],brightness:[{brightness:[TN,Z,X]}],contrast:[{contrast:[TN,Z,X]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,YN,UN]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:[``,TN,Z,X]}],"hue-rotate":[{"hue-rotate":[TN,Z,X]}],invert:[{invert:[``,TN,Z,X]}],saturate:[{saturate:[TN,Z,X]}],sepia:[{sepia:[``,TN,Z,X]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Z,X]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[TN,Z,X]}],"backdrop-contrast":[{"backdrop-contrast":[TN,Z,X]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,TN,Z,X]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[TN,Z,X]}],"backdrop-invert":[{"backdrop-invert":[``,TN,Z,X]}],"backdrop-opacity":[{"backdrop-opacity":[TN,Z,X]}],"backdrop-saturate":[{"backdrop-saturate":[TN,Z,X]}],"backdrop-sepia":[{"backdrop-sepia":[``,TN,Z,X]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,Z,X]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[TN,`initial`,Z,X]}],ease:[{ease:[`linear`,`initial`,_,Z,X]}],delay:[{delay:[TN,Z,X]}],animate:[{animate:[`none`,v,Z,X]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Z,X]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ye()}],"rotate-x":[{"rotate-x":ye()}],"rotate-y":[{"rotate-y":ye()}],"rotate-z":[{"rotate-z":ye()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":[`scale-3d`],skew:[{skew:O()}],"skew-x":[{"skew-x":O()}],"skew-y":[{"skew-y":O()}],transform:[{transform:[Z,X,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":[`translate-none`],zoom:[{zoom:[EN,Z,X]}],accent:[{accent:D()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,Z,X]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":D()}],"scrollbar-track-color":[{"scrollbar-track":D()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,Z,X]}],fill:[{fill:[`none`,...D()]}],"stroke-w":[{stroke:[TN,WN,LN,RN]}],stroke:[{stroke:[`none`,...D()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Q(...e){return sP(FM(e))}var cP={stopped:{label:`Stopped`,tone:`neutral`,transitional:!1},starting:{label:`Starting`,tone:`warn`,transitional:!0},running:{label:`Running`,tone:`ok`,transitional:!1},stopping:{label:`Stopping`,tone:`warn`,transitional:!0},backoff:{label:`Restarting`,tone:`warn`,transitional:!0},crashed:{label:`Crashed`,tone:`danger`,transitional:!1},conflict:{label:`Port conflict`,tone:`danger`,transitional:!1}},lP={disabled:{label:`Not checked`,tone:`neutral`},unknown:{label:`Not probed`,tone:`neutral`},healthy:{label:`Healthy`,tone:`ok`},unhealthy:{label:`Unhealthy`,tone:`danger`}},uP={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},dP={ok:`bg-ok-soft text-ok border-ok/25`,warn:`bg-warn-soft text-warn border-warn/25`,danger:`bg-danger-soft text-danger border-danger/25`,info:`bg-info-soft text-info border-info/25`,neutral:`bg-hover text-muted border-line`,accent:`bg-accent-soft text-accent border-accent/25`},fP={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,info:`bg-info`,neutral:`bg-faint`,accent:`bg-accent`};function pP(e,t){return e===`crashed`||e===`conflict`||t===`unhealthy`?`danger`:e===`starting`||e===`stopping`||e===`backoff`?`warn`:e===`running`?`ok`:`neutral`}var mP={start:`Started`,exit:`Exited`,crash:`Crashed`,"forced-restart":`Forced restart`,unhealthy:`Unhealthy`,recovered:`Recovered`},hP={start:`ok`,exit:`neutral`,crash:`danger`,"forced-restart":`warn`,unhealthy:`warn`,recovered:`info`},gP={class:`flex items-center gap-2.5 border-b border-line px-3.5`},_P={key:0,class:`px-3 py-8 text-center text-xs text-muted`},vP={class:`px-2.5 pb-1 pt-2.5 text-2xs font-medium text-faint`},yP=[`data-active`,`onMousemove`,`onClick`],bP={class:`min-w-0 flex-1 truncate text-sm`},xP={key:0,class:`shrink-0 font-mono text-2xs text-faint`},SP={class:`flex items-center gap-3 border-t border-line bg-panel-2 px-3.5 py-2 text-2xs text-faint`},CP={class:`ml-auto font-mono`},wP=P({__name:`CommandPalette`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:[`update:open`],setup(e){let t=so(e,`open`),n=Rg(),r=wM(),i=NM(),a=j(``),o=j(0),s=j(null),c=j(null);function l(e){n.push(e)}function u(e){e(),t.value=!1}let d=[`stopped`,`crashed`,`conflict`],f=[`running`,`starting`,`backoff`],p=W(()=>{let e=[],t=r.appState.value?.servers??[];for(let n of t){let t=n.config.label??n.id,i=cP[n.status].label;e.push({id:`open:${n.id}`,title:`Open ${t}`,group:`Servers`,icon:by,detail:`${n.id} · ${i}`,keywords:`server detail ${n.id} show`,run:()=>l(`/servers/${n.id}`)}),e.push({id:`logs:${n.id}`,title:`Logs for ${t}`,group:`Servers`,icon:Dy,detail:n.id,keywords:`log tail output ${n.id}`,run:()=>l(`/logs?server=${encodeURIComponent(n.id)}`)}),d.includes(n.status)&&n.config.enabled&&e.push({id:`start:${n.id}`,title:`Start ${t}`,group:`Actions`,icon:fy,detail:n.id,keywords:`run launch ${n.id}`,run:()=>u(()=>void r.start(n.id))}),f.includes(n.status)&&e.push({id:`stop:${n.id}`,title:`Stop ${t}`,group:`Actions`,icon:Ty,detail:n.id,keywords:`halt kill ${n.id}`,run:()=>u(()=>void r.stop(n.id))}),n.config.enabled&&e.push({id:`restart:${n.id}`,title:`Restart ${t}`,group:`Actions`,icon:_y,detail:n.id,keywords:`bounce reload ${n.id}`,run:()=>u(()=>void r.restart(n.id))})}e.push({id:`nav:overview`,title:`Go to Overview`,group:`Navigate`,icon:ty,keywords:`dashboard home`,run:()=>l(`/`)},{id:`nav:servers`,title:`Go to Servers`,group:`Navigate`,icon:by,keywords:`processes list`,run:()=>l(`/servers`)},{id:`nav:logs`,title:`Go to Logs`,group:`Navigate`,icon:vy,keywords:`output files tail`,run:()=>l(`/logs`)},{id:`nav:settings`,title:`Go to Settings`,group:`Navigate`,icon:wy,keywords:`config panel`,run:()=>l(`/settings`)},{id:`act:start-all`,title:`Start every enabled server`,group:`Actions`,icon:fy,keywords:`boot all`,run:()=>u(()=>void r.startAll())},{id:`act:stop-all`,title:`Stop every server`,group:`Actions`,icon:Ty,keywords:`halt all`,run:()=>u(()=>void r.stopAll())});for(let[t,n]of[[`listener`,`Listener`],[`authentication`,`Authentication`],[`password`,`Password`],[`defaults`,`Server defaults`],[`logs`,`Log storage`],[`notifications`,`Telegram notifications`],[`host`,`Host vitals`],[`backups`,`Backups`],[`tls`,`TLS`],[`paths`,`Paths`]])e.push({id:`set:${t}`,title:`Setting: ${n}`,group:`Settings`,icon:wy,keywords:`configure ${t}`,run:()=>l(`/settings?section=${t}`)});let n=[[`light`,`Light`,Ey],[`dark`,`Dark`,cy],[`system`,`System`,sy]];for(let[t,r,a]of n)e.push({id:`theme:${t}`,title:`${r} theme`,group:`Appearance`,icon:a,keywords:`colour color dark light mode appearance`,run:()=>u(()=>i.setPreference(t))});return e}),m=W(()=>{let e=a.value.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.length===0?p.value.slice(0,40):p.value.map(t=>{let n=`${t.title} ${t.detail??``} ${t.keywords??``} ${t.group}`.toLowerCase(),r=0;for(let t of e){let e=n.indexOf(t);if(e===-1)return null;r+=e===0?0:e}return{command:t,score:r}}).filter(e=>e!==null).sort((e,t)=>e.score-t.score).slice(0,40).map(e=>e.command)}),h=W(()=>{let e=new Map;for(let t of m.value){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]}),g=W(()=>h.value.flatMap(([,e])=>e));Ar(m,()=>{o.value=0}),Ar(t,async e=>{e&&(a.value=``,o.value=0,await nr(),s.value?.focus())});function _(e){let t=g.value.length;t!==0&&(o.value=(o.value+e+t)%t,nr(()=>{c.value?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})}))}function v(e){e.key===`ArrowDown`?(e.preventDefault(),_(1)):e.key===`ArrowUp`?(e.preventDefault(),_(-1)):e.key===`Enter`&&(e.preventDefault(),g.value[o.value]?.run())}function y(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t.value=!t.value)}return ta(()=>window.addEventListener(`keydown`,y)),ze(()=>window.removeEventListener(`keydown`,y)),(e,n)=>(L(),z(M(lf),{open:t.value,"onUpdate:open":n[2]||=e=>t.value=e},{default:N(()=>[V(M(Yf),null,{default:N(()=>[V(M(qf),{class:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px] data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`}),V(M(Wf),{class:`fixed left-1/2 top-[10vh] z-50 w-[min(94vw,38rem)] -translate-x-1/2 overflow-hidden rounded-panel border border-line bg-panel shadow-float data-[state=open]:animate-[hh-pop-in_150ms_var(--ease-out-quick)]`,onOpenAutoFocus:n[1]||=lu(()=>{},[`prevent`]),onKeydown:v},{default:N(()=>[V(M(Xf),{class:`sr-only`},{default:N(()=>[...n[3]||=[H(` Command palette `,-1)]]),_:1}),B(`div`,gP,[V(M(yy),{class:`size-4 shrink-0 text-faint`}),br(B(`input`,{ref_key:`input`,ref:s,"onUpdate:modelValue":n[0]||=e=>a.value=e,type:`text`,placeholder:`Jump to a server, run an action, open a setting…`,class:`h-12 w-full bg-transparent text-sm text-ink outline-none placeholder:text-faint`,autocomplete:`off`,spellcheck:`false`},null,512),[[Jl,a.value]]),n[4]||=B(`kbd`,{class:`shrink-0 rounded border border-line bg-page px-1.5 py-0.5 font-mono text-2xs text-faint`},`esc`,-1)]),B(`div`,{ref_key:`list`,ref:c,class:`max-h-[min(60vh,26rem)] overflow-y-auto p-1.5`},[g.value.length===0?(L(),R(`p`,_P,` Nothing matches “`+k(a.value)+`”. `,1)):U(``,!0),(L(!0),R(I,null,va(h.value,([e,t])=>(L(),R(I,{key:e},[B(`p`,vP,k(e),1),(L(!0),R(I,null,va(t,e=>(L(),R(`button`,{key:e.id,type:`button`,"data-active":g.value[o.value]?.id===e.id,class:O(M(Q)(`flex w-full items-center gap-2.5 rounded-control px-2.5 py-2 text-left transition-colors duration-100`,g.value[o.value]?.id===e.id?`bg-accent-soft text-ink`:`text-muted hover:bg-hover`)),onMousemove:t=>o.value=g.value.findIndex(t=>t.id===e.id),onClick:t=>e.run()},[(L(),z(ma(e.icon),{class:O([`size-4 shrink-0`,g.value[o.value]?.id===e.id?`text-accent`:`text-faint`])},null,8,[`class`])),B(`span`,bP,k(e.title),1),e.detail?(L(),R(`span`,xP,k(e.detail),1)):U(``,!0),V(M(Lv),{class:O([`size-3.5 shrink-0 text-faint opacity-0 transition-opacity duration-100`,{"opacity-100":g.value[o.value]?.id===e.id}])},null,8,[`class`])],42,yP))),128))],64))),128))],512),B(`div`,SP,[n[5]||=B(`span`,null,[B(`kbd`,{class:`font-mono`},`↑↓`),H(` navigate`)],-1),n[6]||=B(`span`,null,[B(`kbd`,{class:`font-mono`},`↵`),H(` run`)],-1),B(`span`,CP,k(g.value.length)+` results`,1)])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),TP={viewBox:`0 0 80 80`,class:`size-full -rotate-0`},EP=[`stroke-dasharray`],DP=[`stroke-dasharray`],OP={class:`absolute inset-0 grid place-items-center`},kP={class:`font-mono text-sm font-semibold tabular-nums text-ink`},AP={class:`text-2xs font-medium text-faint`},jP=34,MP=.75,NP=P({__name:`Gauge`,props:{value:{},label:{},display:{default:void 0},size:{default:74},tone:{default:void 0},warnAt:{default:75},dangerAt:{default:90}},setup(e){let t=e,n=2*Math.PI*jP,r=W(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(1,Math.max(0,t.value/100))*MP),i=W(()=>t.tone?t.tone:t.value===null||!Number.isFinite(t.value)?`neutral`:t.value>=t.dangerAt?`danger`:t.value>=t.warnAt?`warn`:`ok`),a={ok:`stroke-ok`,warn:`stroke-warn`,danger:`stroke-danger`,info:`stroke-info`,neutral:`stroke-faint`,accent:`stroke-accent`};return(e,o)=>(L(),R(`div`,{class:O(M(Q)(`flex flex-col items-center gap-1`))},[B(`div`,{class:`relative`,style:ge({width:`${t.size}px`,height:`${t.size}px`})},[(L(),R(`svg`,TP,[B(`circle`,{cx:`40`,cy:`40`,r:jP,fill:`none`,class:`stroke-line-soft`,"stroke-width":6,"stroke-dasharray":`${MP*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,8,EP),B(`circle`,{cx:`40`,cy:`40`,r:jP,fill:`none`,class:O([a[i.value],`transition-[stroke-dasharray] duration-300 ease-out`]),"stroke-width":6,"stroke-dasharray":`${r.value*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,10,DP)])),B(`div`,OP,[B(`span`,kP,k(t.display??(t.value===null?`—`:`${Math.round(t.value)}%`)),1)])],4),B(`span`,AP,k(t.label),1)],2))}}),PP={class:`rounded-panel border border-line bg-panel-2/70 p-3`},FP={class:`mb-2 flex items-center justify-between`},IP={key:0,class:`text-2xs text-faint`},LP={key:0,class:`grid grid-cols-2 gap-x-1 gap-y-2`},RP={key:1,class:`py-3 text-center text-2xs text-faint`},zP={key:2,class:`mt-2 flex items-start gap-1.5 rounded-control bg-danger-soft px-2 py-1.5`},BP={class:`text-2xs leading-4 text-danger`},VP=2,HP=85,UP=P({__name:`InstrumentCluster`,props:{host:{}},setup(e){let t=e,n=W(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=W(()=>n.value===null?null:n.value/VP*100),i=W(()=>n.value===null?`—`:n.value.toFixed(2)),a=W(()=>{let e=t.host?.disks??[];return e.length===0?null:Math.max(...e.map(e=>e.usedPercent))}),o=W(()=>{let e=t.host?.tempCelsius??null;return e===null?null:e/HP*100}),s=W(()=>{let e=t.host?.tempCelsius??null;return e===null?`n/a`:`${Math.round(e)}°`});return(e,n)=>(L(),R(`div`,PP,[B(`div`,FP,[n[0]||=B(`span`,{class:`text-2xs font-medium text-faint`},`Host vitals`,-1),t.host?.enabled===!1?(L(),R(`span`,IP,`off`)):U(``,!0)]),t.host?.enabled?(L(),R(`div`,LP,[V(NP,{value:r.value,label:`Load / cpu`,display:i.value,size:58,"warn-at":70,"danger-at":100},null,8,[`value`,`display`]),V(NP,{value:t.host?.memoryUsedPercent??null,label:`Memory`,size:58},null,8,[`value`]),V(NP,{value:a.value,label:`Disk`,size:58},null,8,[`value`]),V(NP,{value:o.value,label:`CPU temp`,display:s.value,size:58},null,8,[`value`,`display`])])):(L(),R(`p`,RP,` Sampling is disabled in Settings. `)),t.host&&t.host.alerts.length>0?(L(),R(`div`,zP,[n[1]||=B(`span`,{class:`mt-1 size-1.5 shrink-0 rounded-full bg-danger`},null,-1),B(`span`,BP,k(t.host.alerts.join(` · `)),1)])):U(``,!0)]))}}),WP={class:`flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3`},GP={class:`flex items-center gap-2 px-1 pt-1`},KP={class:`min-w-0`},qP={class:`truncate text-2xs text-faint`},JP={class:`flex flex-col gap-0.5`},YP={class:`mt-auto flex flex-col gap-3`},XP={class:`flex items-center gap-2 rounded-control border border-line bg-panel-2/70 px-2.5 py-2`},ZP={class:`relative flex size-2 shrink-0`},QP={class:`text-2xs text-muted`},$P=[`title`],eF=P({__name:`SideNav`,props:{host:{},connection:{},panelLabel:{},planLabel:{},running:{},total:{}},emits:[`navigate`,`close`],setup(e,{emit:t}){let n=e,r=t,i=zg(),a=[{to:`/`,label:`Overview`,icon:ty,exact:!0},{to:`/servers`,label:`Servers`,icon:by,exact:!1},{to:`/logs`,label:`Logs`,icon:vy,exact:!1},{to:`/settings`,label:`Settings`,icon:wy,exact:!1}];function o(e){return e.exact?i.path===e.to:i.path===e.to||i.path.startsWith(`${e.to}/`)}let s=W(()=>({open:{label:`Live`,dot:`bg-ok`},connecting:{label:`Connecting`,dot:`bg-warn`},closed:{label:`Reconnecting`,dot:`bg-danger`}})[n.connection]);return(e,t)=>{let i=fa(`RouterLink`);return L(),R(`div`,WP,[B(`div`,GP,[t[3]||=Os(`<span class="grid size-8 shrink-0 place-items-center rounded-[9px] border border-accent/30 bg-accent-soft text-accent"><svg viewBox="0 0 24 24" class="size-4.5" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M4 15.5a8 8 0 1 1 16 0"></path><path d="M12 15.5 15.6 10.2"></path><circle cx="12" cy="15.5" r="1.3" fill="currentColor" stroke="none"></circle></svg></span>`,1),B(`div`,KP,[t[2]||=B(`p`,{class:`truncate text-sm font-semibold tracking-tight text-ink`},` home-hosted `,-1),B(`p`,qP,k(n.panelLabel),1)]),B(`button`,{type:`button`,class:`ml-auto grid size-7 place-items-center rounded-control text-muted hover:bg-hover hover:text-ink lg:hidden`,"aria-label":`Close navigation`,onClick:t[0]||=e=>r(`close`)},[V(M(My),{class:`size-4`})])]),B(`nav`,JP,[(L(),R(I,null,va(a,e=>V(i,{key:e.to,to:e.to,class:O(M(Q)(`group flex items-center gap-2.5 rounded-control px-2.5 py-1.5 text-sm transition-colors duration-150`,o(e)?`bg-accent-soft font-medium text-accent`:`text-muted hover:bg-hover hover:text-ink`)),onClick:t[1]||=e=>r(`navigate`)},{default:N(()=>[(L(),z(ma(e.icon),{class:`size-4 shrink-0`,"stroke-width":o(e)?2.1:1.8},null,8,[`stroke-width`])),H(` `+k(e.label)+` `,1),e.to===`/servers`?(L(),R(`span`,{key:0,class:O([`ml-auto font-mono text-2xs tabular-nums`,o(e)?`text-accent`:`text-faint`])},k(n.running)+`/`+k(n.total),3)):U(``,!0)]),_:2},1032,[`to`,`class`])),64))]),B(`div`,YP,[V(UP,{host:n.host},null,8,[`host`]),B(`div`,XP,[B(`span`,ZP,[B(`span`,{class:O(M(Q)(`absolute inset-0 rounded-full`,s.value.dot,n.connection!==`open`&&`animate-ping opacity-60`))},null,2),B(`span`,{class:O(M(Q)(`relative size-2 rounded-full`,s.value.dot))},null,2)]),B(`span`,QP,k(s.value.label),1),B(`span`,{class:`ml-auto truncate font-mono text-2xs text-faint`,title:n.planLabel},k(n.planLabel),9,$P)])])])}}}),tF={key:0,class:`flex flex-col gap-px border-b border-line bg-panel/60`},nF={class:`text-2xs leading-4`},rF={class:`font-medium`},iF={key:0,class:`opacity-80`},aF=P({__name:`SystemNotices`,props:{control:{},configError:{},configPath:{}},setup(e){let t=e,n=W(()=>{let e=[],n=t.control?.auth;return t.configError&&e.push({id:`config`,tone:`danger`,text:`The config could not be read: ${t.configError}`,hint:`Fix ${t.configPath??`servers.config.json`} and restart the panel.`}),n&&(n.blockedReason&&e.push({id:`blocked`,tone:`danger`,text:n.blockedReason}),n.usingDefaultPassword?e.push({id:`default-password`,tone:`warn`,text:`This panel is still on its default password.`,hint:`Change it in Settings — binding beyond 127.0.0.1 stays refused until you do.`}):n.enabled&&!n.passwordSet&&e.push({id:`no-password`,tone:`warn`,text:`Authentication is on but no password is set, so nothing is being asked for.`,hint:`Set one in Settings to actually lock the panel.`}),n.exposed&&e.push({id:`exposed`,tone:`warn`,text:`This panel is reachable beyond 127.0.0.1.`,hint:`Keep the password strong, or put a TLS-terminating proxy in front of it.`}),!n.enabled&&!n.exposed&&e.push({id:`auth-off`,tone:`info`,text:`Authentication is disabled — the panel is only protected by its loopback bind.`})),e}),r={warn:{wrap:`border-warn/25 bg-warn-soft text-warn`,icon:jy},danger:{wrap:`border-danger/25 bg-danger-soft text-danger`,icon:zv},info:{wrap:`border-line bg-panel-2 text-muted`,icon:zv}};return(e,t)=>n.value.length>0?(L(),R(`div`,tF,[(L(!0),R(I,null,va(n.value,e=>(L(),R(`div`,{key:e.id,class:O([`flex items-start gap-2 px-3 py-1.5 sm:px-4`,r[e.tone].wrap])},[(L(),z(ma(r[e.tone].icon),{class:`mt-0.5 size-3.5 shrink-0`})),B(`p`,nF,[B(`span`,rF,k(e.text),1),e.hint?(L(),R(`span`,iF,k(e.hint),1)):U(``,!0)])],2))),128))])):U(``,!0)}}),oF={class:`pointer-events-none fixed bottom-4 right-4 z-[60] flex w-[min(92vw,22rem)] flex-col gap-2`,role:`status`,"aria-live":`polite`},sF={class:`min-w-0 flex-1`},cF={class:`text-xs font-medium text-ink`},lF={key:0,class:`mt-0.5 break-words text-2xs leading-4 text-muted`},uF=[`onClick`],dF=P({__name:`ToastStack`,setup(e){let{toasts:t,dismiss:n}=Kj(),r={ok:Bv,danger:Vv,warn:jy,info:ey,accent:ey,neutral:ey},i={ok:`text-ok`,danger:`text-danger`,warn:`text-warn`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},a=W(()=>t.value);return(e,t)=>(L(),R(`div`,oF,[V(Il,{"enter-active-class":`transition duration-150 ease-out`,"enter-from-class":`translate-x-2 opacity-0`,"leave-active-class":`transition duration-100 ease-in`,"leave-to-class":`translate-x-2 opacity-0`},{default:N(()=>[(L(!0),R(I,null,va(a.value,e=>(L(),R(`div`,{key:e.id,class:`pointer-events-auto flex items-start gap-2.5 rounded-panel border border-line bg-raise p-3 shadow-float`},[(L(),z(ma(r[e.tone]),{class:O(M(Q)(`mt-0.5 size-4 shrink-0`,i[e.tone]))},null,8,[`class`])),B(`div`,sF,[B(`p`,cF,k(e.title),1),e.description?(L(),R(`p`,lF,k(e.description),1)):U(``,!0)]),B(`button`,{type:`button`,class:`-mr-1 -mt-0.5 grid size-6 shrink-0 place-items-center rounded-control text-faint transition-colors duration-150 hover:bg-hover hover:text-ink`,"aria-label":`Dismiss`,onClick:t=>M(n)(e.id)},[V(M(My),{class:`size-3.5`})],8,uF)]))),128))]),_:1})]))}}),fF=`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60 focus-visible:ring-offset-2 focus-visible:ring-offset-page`,pF=`text-xs font-medium text-muted`,mF=`text-2xs leading-4 text-faint`,hF=[`w-full min-w-0 rounded-control border border-line bg-page/60 px-2.5 py-1.5 text-sm text-ink`,`placeholder:text-faint transition-colors duration-150`,`hover:border-line/80 hover:bg-page`,`focus:border-accent focus:bg-page focus:outline-none focus:ring-2 focus:ring-accent/25`,`disabled:cursor-not-allowed disabled:opacity-50`,`aria-[invalid=true]:border-danger aria-[invalid=true]:focus:ring-danger/25`].join(` `),gF=`${hF} font-mono text-xs`,_F=[`type`,`disabled`,`aria-busy`],$=P({inheritAttrs:!1,__name:`AppButton`,props:{variant:{default:`secondary`},size:{default:`sm`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},setup(e){let t=e,n=Fa(),r={primary:`bg-accent text-accent-ink border-transparent hover:brightness-110 active:brightness-95 shadow-[inset_0_1px_0_rgb(255_255_255/0.14)]`,secondary:`bg-raise text-ink border-line hover:bg-hover`,ghost:`bg-transparent text-muted border-transparent hover:bg-hover hover:text-ink`,danger:`bg-danger text-white border-transparent hover:brightness-110 active:brightness-95`,"danger-ghost":`bg-transparent text-danger border-danger/30 hover:bg-danger-soft`},i={xs:`h-6 gap-1 px-1.5 text-2xs`,sm:`h-8 gap-1.5 px-2.5 text-xs`,md:`h-9 gap-2 px-3.5 text-sm`,icon:`h-9 w-9 justify-center`,"icon-sm":`h-8 w-8 justify-center`},a=W(()=>Q(`inline-flex select-none items-center rounded-control border font-medium whitespace-nowrap`,`transition-[background-color,border-color,color,filter,opacity] duration-150 ease-out`,`disabled:pointer-events-none disabled:opacity-45`,r[t.variant],i[t.size],t.block&&`w-full`,fF,n.class));return(e,r)=>(L(),R(`button`,Ms({...M(n),class:void 0},{type:t.type,class:a.value,disabled:t.disabled||t.loading,"aria-busy":t.loading||void 0}),[t.loading?(L(),z(M(ny),{key:0,class:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`})):U(``,!0),F(e.$slots,`default`)],16,_F))}}),vF=P({__name:`Tip`,props:{label:{},side:{default:`top`},disabled:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),z(M(gg),{"delay-duration":350},{default:N(()=>[V(M(xg),{"as-child":``},{default:N(()=>[F(t.$slots,`default`)]),_:3}),e.disabled?U(``,!0):(L(),z(M(bg),{key:0},{default:N(()=>[V(M(yg),{side:e.side,"side-offset":6,class:`z-50 max-w-64 rounded-control border border-line bg-raise px-2 py-1 text-2xs text-ink shadow-float data-[state=delayed-open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[H(k(e.label),1)]),_:1},8,[`side`])]),_:1}))]),_:3}))}}),yF={class:`flex h-13 shrink-0 items-center gap-3 border-b border-line bg-panel/80 px-3 backdrop-blur-sm sm:px-4`},bF={class:`truncate text-sm font-semibold tracking-tight text-ink`},xF={class:`ml-auto flex items-center gap-1.5`},SF={class:`hidden items-center gap-1.5 rounded-control border border-line bg-panel-2 px-2 py-1.5 md:flex`},CF={class:`font-mono text-2xs text-muted`},wF={class:`px-2 py-1.5`},TF={class:`truncate font-mono text-2xs text-muted`},EF=P({__name:`TopBar`,props:{panelUrl:{},connection:{},authenticated:{type:Boolean}},emits:[`menu`,`palette`,`signOut`],setup(e,{emit:t}){let n=e,r=t,i=zg(),a=NM(),o=W(()=>i.name===`server-detail`?`Servers / ${String(i.params.id??``)}`:String(i.meta.title??`home-hosted`)),s=W(()=>a.preference.value===`dark`?cy:a.preference.value===`light`?Ey:sy),c=W(()=>`Theme: ${a.preference.value}`),l=W(()=>({open:`bg-ok`,connecting:`bg-warn`,closed:`bg-danger`})[n.connection]),u=W(()=>({open:`Live updates`,connecting:`Connecting`,closed:`Reconnecting`})[n.connection]);return(t,i)=>(L(),R(`header`,yF,[B(`button`,{type:`button`,class:`grid size-8 shrink-0 place-items-center rounded-control text-muted hover:bg-hover hover:text-ink lg:hidden`,"aria-label":`Open navigation`,onClick:i[0]||=e=>r(`menu`)},[V(M(ay),{class:`size-4`})]),B(`h1`,bF,k(o.value),1),B(`div`,xF,[B(`button`,{type:`button`,class:O(M(Q)(`hidden h-8 items-center gap-2 rounded-control border border-line bg-panel-2 px-2.5 text-xs text-faint transition-colors duration-150 hover:border-line hover:text-muted sm:flex`,M(fF))),onClick:i[1]||=e=>r(`palette`)},[V(M(yy),{class:`size-3.5`}),i[5]||=B(`span`,{class:`pr-6`},`Search or run a command`,-1),i[6]||=B(`kbd`,{class:`rounded border border-line bg-page px-1 py-0.5 font-mono text-2xs text-faint`},`⌘K`,-1)],2),V(vF,{label:u.value},{default:N(()=>[B(`span`,SF,[B(`span`,{class:O(M(Q)(`size-1.5 rounded-full`,l.value))},null,2),B(`span`,CF,k(e.panelUrl),1)])]),_:1},8,[`label`]),V(vF,{label:c.value},{default:N(()=>[V($,{variant:`ghost`,size:`icon-sm`,"aria-label":c.value,onClick:i[2]||=e=>M(a).cycle()},{default:N(()=>[(L(),z(ma(s.value),{class:`size-4`}))]),_:1},8,[`aria-label`])]),_:1},8,[`label`]),n.authenticated?(L(),z(M(eg),{key:0},{default:N(()=>[V(M(ag),{"as-child":``},{default:N(()=>[V($,{variant:`ghost`,size:`icon-sm`,"aria-label":`Account`},{default:N(()=>[...i[7]||=[B(`span`,{class:`grid size-5 place-items-center rounded-full bg-accent-soft font-mono text-2xs font-semibold text-accent`},`hh`,-1)]]),_:1})]),_:1}),V(M(rg),null,{default:N(()=>[V(M(tg),{"side-offset":6,align:`end`,class:`z-50 min-w-44 rounded-panel border border-line bg-raise p-1 shadow-float data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[B(`div`,wF,[i[8]||=B(`p`,{class:`text-2xs text-faint`},` Signed in `,-1),B(`p`,TF,k(n.panelUrl),1)]),V(M(ig),{class:`my-1 h-px bg-line`}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:i[3]||=e=>r(`signOut`)},{default:N(()=>[V(M(iy),{class:`size-3.5`}),i[9]||=H(` Sign out `,-1)]),_:1})]),_:1})]),_:1})]),_:1})):U(``,!0),V(vF,{label:`Command palette`},{default:N(()=>[V($,{variant:`ghost`,size:`icon-sm`,class:`sm:hidden`,"aria-label":`Open the command palette`,onClick:i[4]||=e=>r(`palette`)},{default:N(()=>[V(M(Wv),{class:`size-4`})]),_:1})]),_:1})])]))}}),DF={key:1,class:`flex h-dvh overflow-hidden bg-page`},OF={class:`hidden w-60 shrink-0 border-r border-line bg-panel/50 lg:block`},kF={key:0,class:`fixed inset-y-0 left-0 z-40 w-64 border-r border-line bg-panel lg:hidden`},AF={class:`flex min-w-0 flex-1 flex-col`},jF=P({__name:`App`,setup(e){let t=zg(),n=Rg(),r=wM(),{session:i,logout:a}=Vj(),o=j(!1),s=j(!1),c=W(()=>i.value?.authenticated===!0),l=W(()=>i.value?.authRequired===!0),u=W(()=>t.name===`login`),d=W(()=>t.name===`logs`),f=W(()=>r.servers.value),p=W(()=>f.value.filter(e=>e.status===`running`).length),m=W(()=>r.control.value?.url??`—`),h=W(()=>r.host.value),g=W(()=>r.control.value?.label??`home-hosted`);return Ar([l,c],([e,t])=>{if(i.value!==null){if(e&&!t){SM(),n.push({name:`login`});return}xM()}},{immediate:!0}),Ar(()=>t.fullPath,()=>{s.value=!1}),ta(async()=>{(!l.value||c.value)&&await r.refresh()}),ze(()=>SM()),(e,t)=>{let n=fa(`RouterView`);return L(),z(M(fg),{"delay-duration":300},{default:N(()=>[u.value?(L(),z(n,{key:0})):(L(),R(`div`,DF,[B(`aside`,OF,[V(eF,{host:h.value,connection:M(r).connection.value,"panel-label":g.value,"plan-label":m.value,running:p.value,total:f.value.length},null,8,[`host`,`connection`,`panel-label`,`plan-label`,`running`,`total`])]),V(Dc,{"enter-active-class":`transition-opacity duration-150`,"leave-active-class":`transition-opacity duration-100`,"enter-from-class":`opacity-0`,"leave-to-class":`opacity-0`},{default:N(()=>[s.value?(L(),R(`div`,{key:0,class:`fixed inset-0 z-40 bg-black/45 lg:hidden`,onClick:t[0]||=e=>s.value=!1})):U(``,!0)]),_:1}),V(Dc,{"enter-active-class":`transition-transform duration-150 ease-out`,"leave-active-class":`transition-transform duration-100 ease-in`,"enter-from-class":`-translate-x-full`,"leave-to-class":`-translate-x-full`},{default:N(()=>[s.value?(L(),R(`aside`,kF,[V(eF,{host:h.value,connection:M(r).connection.value,"panel-label":g.value,"plan-label":m.value,running:p.value,total:f.value.length,onNavigate:t[1]||=e=>s.value=!1,onClose:t[2]||=e=>s.value=!1},null,8,[`host`,`connection`,`panel-label`,`plan-label`,`running`,`total`])])):U(``,!0)]),_:1}),B(`div`,AF,[V(EF,{"panel-url":m.value,connection:M(r).connection.value,authenticated:c.value,onMenu:t[3]||=e=>s.value=!0,onPalette:t[4]||=e=>o.value=!0,onSignOut:t[5]||=e=>M(a)()},null,8,[`panel-url`,`connection`,`authenticated`]),c.value?(L(),z(aF,{key:0,control:M(r).control.value,"config-error":M(r).configError.value,"config-path":M(r).appState.value?.configPath},null,8,[`control`,`config-error`,`config-path`])):U(``,!0),B(`main`,{class:O(M(Q)(`min-h-0 flex-1`,d.value?`overflow-hidden`:`overflow-y-auto`))},[V(n)],2)])])),V(wP,{open:o.value,"onUpdate:open":t[6]||=e=>o.value=e},null,8,[`open`]),V(dF)]),_:1})}}}),MF={key:0,class:`size-1.5 shrink-0 rounded-full bg-current`},NF=P({__name:`ToneBadge`,props:{tone:{default:`neutral`},dot:{type:Boolean,default:!1},mono:{type:Boolean,default:!1},plain:{type:Boolean,default:!1}},setup(e){let t=e,n=W(()=>Q(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium whitespace-nowrap`,t.plain?Q(`border-transparent bg-transparent`,dP[t.tone].split(` `).filter(e=>e.startsWith(`text-`)).join(` `)):dP[t.tone],t.mono&&`font-mono`));return(e,r)=>(L(),R(`span`,{class:O(n.value)},[t.dot?(L(),R(`span`,MF)):U(``,!0),F(e.$slots,`default`)],2))}}),PF={class:`relative flex min-h-dvh items-center justify-center overflow-hidden bg-page px-4 py-10`},FF={class:`hh-enter relative w-full max-w-md`},IF={class:`rounded-panel border border-line bg-panel/95 p-5 shadow-float backdrop-blur-sm`},LF={class:`flex items-start justify-between gap-3`},RF={class:`min-w-0`},zF={class:`text-base font-semibold text-ink`},BF={class:`mt-1 text-xs leading-relaxed text-muted`},VF={class:`flex flex-col gap-1.5`},HF={class:`relative`},UF=[`type`],WF=[`aria-label`],GF={key:0,class:`rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`},KF={key:1,class:`mt-5`},qF={class:`mt-4 space-y-2`},JF={key:0,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},YF={class:`text-2xs leading-4 text-warn`},XF={class:`ml-1 rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},ZF={key:1,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},QF={key:2,class:`flex items-start gap-2 rounded-control border border-line-soft bg-panel-2 px-2.5 py-2`},$F={class:`text-2xs leading-4 text-muted`},eI={class:`mt-4 flex items-center justify-center gap-2 text-2xs text-faint`},tI={class:`font-mono`},nI=P({__name:`LoginView`,setup(e){let t=zg(),n=Rg(),r=wM(),{session:i,error:a,login:o,refresh:s}=Vj(),c=j(``),l=j(!1),u=j(!1),d=W(()=>i.value?.passwordSet===!1),f=W(()=>i.value!==null&&!i.value.authRequired),p=W(()=>i.value?.usingDefaultPassword===!0&&i.value.defaultPassword!==null),m=W(()=>r.control.value?.auth.exposed===!0),h=W(()=>r.control.value?.url??`—`),g=W(()=>d.value?`This panel has no password yet`:f.value?`Authentication is turned off`:`Sign in to continue`),_=W(()=>d.value?`Anything on this machine can reach it. Set a password right after you are in.`:f.value?`The panel only listens on loopback, which is the only thing protecting it right now.`:`The control panel is protected. Enter the password to continue.`);async function v(){l.value=!0;try{if(await o(c.value)){c.value=``;let e=typeof t.query.next==`string`?t.query.next:`/`;await n.push(e)}}finally{l.value=!1}}async function y(){await s(),await n.push(`/`)}return ta(async()=>{i.value===null&&await s()}),(e,t)=>(L(),R(`div`,PF,[t[11]||=B(`div`,{class:`bg-instrument pointer-events-none absolute inset-0 opacity-60`},null,-1),t[12]||=B(`div`,{class:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center,transparent_15%,var(--page)_78%)]`},null,-1),B(`div`,FF,[t[10]||=Os(`<div class="mb-6 flex items-center gap-3"><span class="grid size-11 shrink-0 place-items-center rounded-panel border border-accent/30 bg-accent-soft text-accent"><svg viewBox="0 0 24 24" class="size-6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><path d="M4 15.5a8 8 0 1 1 16 0"></path><path d="M12 15.5 15.6 10.2"></path><circle cx="12" cy="15.5" r="1.3" fill="currentColor" stroke="none"></circle></svg></span><div><p class="text-lg font-semibold tracking-tight text-ink"> home-hosted </p><p class="text-xs text-muted"> Process supervisor control panel </p></div></div>`,1),B(`section`,IF,[B(`div`,LF,[B(`div`,RF,[B(`h1`,zF,k(g.value),1),B(`p`,BF,k(_.value),1)]),m.value?(L(),z(NF,{key:0,tone:`warn`,dot:``},{default:N(()=>[...t[2]||=[H(` Exposed `,-1)]]),_:1})):U(``,!0)]),f.value?(L(),R(`div`,KF,[V($,{variant:`primary`,size:`md`,block:``,onClick:y},{default:N(()=>[...t[4]||=[H(` Open the dashboard `,-1)]]),_:1})])):(L(),R(`form`,{key:0,class:`mt-5 space-y-3`,onSubmit:lu(v,[`prevent`])},[B(`div`,VF,[B(`label`,{for:`hh-password`,class:O(M(pF))},`Password`,2),B(`div`,HF,[br(B(`input`,{id:`hh-password`,"onUpdate:modelValue":t[0]||=e=>c.value=e,type:u.value?`text`:`password`,autocomplete:`current-password`,autofocus:``,required:``,class:O(M(Q)(M(hF),`pr-9`))},null,10,UF),[[ru,c.value]]),B(`button`,{type:`button`,class:`absolute right-1 top-1/2 grid size-7 -translate-y-1/2 place-items-center rounded-control text-faint transition-colors duration-150 hover:text-ink`,"aria-label":u.value?`Hide password`:`Show password`,onClick:t[1]||=e=>u.value=!u.value},[u.value?(L(),z(M(Xv),{key:0,class:`size-3.5`})):(L(),z(M(Zv),{key:1,class:`size-3.5`}))],8,WF)])]),M(a)?(L(),R(`p`,GF,k(M(a)),1)):U(``,!0),V($,{type:`submit`,variant:`primary`,size:`md`,block:``,loading:l.value},{default:N(()=>[V(M(ry),{class:`size-3.5`}),t[3]||=H(` Sign in `,-1)]),_:1},8,[`loading`])],32)),B(`div`,qF,[p.value?(L(),R(`div`,JF,[V(M(xy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),B(`p`,YF,[t[5]||=H(` Still on the default password `,-1),B(`code`,XF,k(M(i)?.defaultPassword),1),t[6]||=H(`. Change it under Settings — binding beyond 127.0.0.1 stays refused until you do. `,-1)])])):d.value?(L(),R(`div`,ZF,[V(M(Cy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),t[7]||=B(`p`,{class:`text-2xs leading-4 text-warn`},[H(` No password is set. Open Settings from this machine to add one, or run `),B(`code`,{class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},`pnpm run auth:set-password`),H(`. `)],-1)])):(L(),R(`div`,QF,[V(M(Sy),{class:`mt-0.5 size-3.5 shrink-0 text-ok`}),B(`p`,$F,` Sessions last `+k(Math.round((M(i)?.sessionTtlMs??0)/864e5))+` days. Signing out clears this browser only. `,1)]))])]),B(`p`,eI,[B(`span`,tI,k(h.value),1),t[8]||=B(`span`,{"aria-hidden":`true`},`·`,-1),t[9]||=B(`span`,null,`served from this machine`,-1)])])]))}}),rI=[`#3f4a5c`,`#f07178`,`#7fd88f`,`#e6b673`,`#82aaff`,`#c792ea`,`#7fdbca`,`#c7d2e3`,`#5a6779`,`#ff8b92`,`#9ae6a8`,`#f2c98a`,`#9dbaff`,`#d7aef0`,`#9ce9dc`,`#eef3fb`],iI=[`#4b5563`,`#c0392b`,`#1c7c3f`,`#9a6700`,`#2f5fe0`,`#7c3aed`,`#0b6f89`,`#334155`,`#6b7280`,`#d64535`,`#22854a`,`#a8620d`,`#3f6bff`,`#8b5cf6`,`#0e7d9c`,`#0f1722`],aI=/\u001B\[([0-9;]*)m/g,oI=/\u001B(?:\[[0-9;?]*[A-HJKSTfhilmnprsu]|\][^\u0007\u001B]*(?:\u0007|\u001B\\)?|[()][0-9A-Z])/g;function sI(e){return Math.max(0,Math.min(255,e))}function cI(e){return e===0?0:55+e*40}function lI(e,t){let n=t?rI:iI;if(e<16)return n[e]??n[7];if(e<232){let t=e-16;return`rgb(${cI(Math.floor(t/36))} ${cI(Math.floor(t%36/6))} ${cI(t%6)})`}let r=8+(e-232)*10;return`rgb(${r} ${r} ${r})`}function uI(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}}function dI(e,t,n){let r=t.length===0?[0]:t.split(`;`).map(e=>e.length===0?0:Number(e));for(let t=0;t<r.length;t+=1){let i=r[t];if(i===0)Object.assign(e,uI());else if(i===1)e.bold=!0;else if(i===2)e.dim=!0;else if(i===3)e.italic=!0;else if(i===4)e.underline=!0;else if(i===22)e.bold=!1,e.dim=!1;else if(i===23)e.italic=!1;else if(i===24)e.underline=!1;else if(i===39)e.fg=null;else if(i===49)e.bg=null;else if(i>=30&&i<=37)e.fg=(n?rI:iI)[i-30]??null;else if(i>=90&&i<=97)e.fg=(n?rI:iI)[i-90+8]??null;else if(i>=40&&i<=47)e.bg=(n?rI:iI)[i-40]??null;else if(i>=100&&i<=107)e.bg=(n?rI:iI)[i-100+8]??null;else if(i===38||i===48){let a=i===38?`fg`:`bg`,o=r[t+1];o===5&&r[t+2]!==void 0?(e[a]=lI(sI(r[t+2]),n),t+=2):o===2&&(e[a]=`rgb(${sI(r[t+2]??0)} ${sI(r[t+3]??0)} ${sI(r[t+4]??0)})`,t+=4)}}}function fI(e,t,n){if(t.length===0)return;let r=e[e.length-1];if(r&&r.fg===n.fg&&r.bg===n.bg&&r.bold===n.bold&&r.dim===n.dim&&r.italic===n.italic&&r.underline===n.underline){r.text+=t;return}e.push({text:t,...n})}function pI(e){return e.includes(`\x1B`)}function mI(e,t=!0){if(!pI(e))return[{text:e,fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}];let n=[],r=uI(),i=0;aI.lastIndex=0;let a=aI.exec(e);for(;a!==null;)fI(n,e.slice(i,a.index).replace(oI,``),r),dI(r,a[1]??``,t),i=a.index+a[0].length,a=aI.exec(e);return fI(n,e.slice(i).replace(oI,``),r),n}function hI(e){let t=new Date(e);return`${t.toLocaleTimeString(void 0,{hour12:!1})}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function gI(e){return new Date(e).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}function _I(e){if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function vI(e,t){let n=Math.max(0,e-t);return n<1e3?`now`:n<6e4?`in ${Math.ceil(n/1e3)}s`:`in ${Math.ceil(n/6e4)}m`}function yI(e){return e===null?`—`:`${(e*100).toFixed(e>=.999?0:1)}%`}function bI(e,t){if(e===null)return`never`;let n=Math.max(0,t-e);return n<6e4?`${Math.floor(n/1e3)}s ago`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}function xI(e){return Number.isFinite(e)?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KiB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(2)} GiB`:`—`}function SI(e){if(e===null||!Number.isFinite(e))return`—`;let t=Math.abs(e);return t<1e3?`${e} B`:t<1e6?`${(e/1e3).toFixed(0)} kB`:t<1e9?`${(e/1e3/1e3).toFixed(1)} MB`:`${(e/1e3/1e3/1e3).toFixed(2)} GB`}function CI(e){return e===null||!Number.isFinite(e)?`—`:e>=100?`${Math.round(e)}%`:`${e.toFixed(1)}%`}var wI={class:`flex h-5 w-max min-w-full items-center gap-2 whitespace-pre px-2 font-mono text-xs leading-5`},TI={key:0,class:`shrink-0 select-none text-faint`},EI={class:`min-w-0`},DI=P({__name:`LogRow`,props:{line:{},query:{},dark:{type:Boolean},showTime:{type:Boolean}},setup(e){let t=e,n=W(()=>mI(t.line.text,t.dark)),r=W(()=>{let e=t.query.trim().toLowerCase(),r=[];for(let t of n.value){if(e.length===0){r.push({text:t.text,hit:!1,span:t});continue}let n=t.text.toLowerCase(),i=0,a=n.indexOf(e);for(;a!==-1;)a>i&&r.push({text:t.text.slice(i,a),hit:!1,span:t}),r.push({text:t.text.slice(a,a+e.length),hit:!0,span:t}),i=a+e.length,a=n.indexOf(e,i);i<t.text.length&&r.push({text:t.text.slice(i),hit:!1,span:t})}return r}),i={stdout:`bg-transparent`,stderr:`bg-danger`,system:`bg-info`};function a(e){let t={};return e.span.fg&&(t.color=e.span.fg),e.span.bg&&(t.backgroundColor=e.span.bg),e.span.bold&&(t.fontWeight=`600`),e.span.dim&&(t.opacity=`0.62`),e.span.italic&&(t.fontStyle=`italic`),e.span.underline&&(t.textDecoration=`underline`),e.hit&&(t.backgroundColor=`var(--warn)`,t.color=`var(--accent-ink)`,t.borderRadius=`2px`),t}return(e,n)=>(L(),R(`div`,wI,[t.showTime?(L(),R(`span`,TI,k(M(hI)(t.line.ts)),1)):U(``,!0),B(`span`,{class:O([`h-3.5 w-0.5 shrink-0 rounded-full`,[i[t.line.stream]]]),"aria-hidden":`true`},null,2),B(`span`,EI,[(L(!0),R(I,null,va(r.value,(e,t)=>(L(),R(`span`,{key:t,style:ge(a(e))},k(e.text),5))),128))])]))}}),OI={class:`inline-flex items-center gap-0.5 rounded-control border border-line bg-panel-2 p-0.5`},kI=[`aria-pressed`,`onClick`],AI=P({__name:`SegmentedControl`,props:za({options:{},size:{default:`sm`}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`);return(e,r)=>(L(),R(`div`,OI,[(L(!0),R(I,null,va(t.options,e=>(L(),R(`button`,{key:e.value,type:`button`,class:O(M(Q)(`rounded-[5px] font-medium transition-colors duration-150`,t.size===`sm`?`h-6 px-2 text-2xs`:`h-7 px-2.5 text-xs`,n.value===e.value?`bg-raise text-ink shadow-card`:`text-muted hover:text-ink`)),"aria-pressed":n.value===e.value,onClick:t=>n.value=e.value},k(e.label),11,kI))),128))]))}}),jI={class:`flex min-h-0 flex-col overflow-hidden rounded-panel border border-line bg-panel`},MI={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel-2/60 px-2.5 py-2`},NI={class:`relative min-w-40 flex-1 sm:max-w-72`},PI={class:`absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5`},FI={key:0,class:`px-1 font-mono text-2xs tabular-nums text-faint`},II={class:`ml-auto flex items-center gap-1.5`},LI=[`href`,`download`],RI={class:`relative min-h-0 flex-1`},zI={key:0,class:`px-3 py-6 text-center text-xs text-faint`},BI={class:`flex items-center gap-3 border-t border-line bg-panel-2/60 px-2.5 py-1.5 text-2xs text-faint`},VI={class:`flex items-center gap-1.5`},HI={class:`font-mono tabular-nums`},UI={key:0,class:`font-mono tabular-nums`},WI=20,GI=12,KI=P({__name:`LogViewer`,props:{lines:{},version:{default:0},live:{type:Boolean,default:!1},emptyHint:{default:`No output yet.`},clearable:{type:Boolean,default:!1},downloadUrl:{default:void 0},downloadName:{default:void 0},minHeight:{default:`16rem`}},emits:[`clear`],setup(e,{emit:t}){let n=e,r=t,i=NM(),a=j(null),o=j(0),s=j(320),c=j(!0),l=j(`all`),u=j(``),d=j(!0),f=j(0),p=W(()=>{n.version;let e=u.value.trim().toLowerCase(),t=l.value;return e.length===0&&t===`all`?n.lines:n.lines.filter(n=>!(t!==`all`&&n.stream!==t||e.length>0&&!n.text.toLowerCase().includes(e)))}),m=W(()=>p.value.length),h=W(()=>{let e=u.value.trim().toLowerCase();if(e.length===0)return[];let t=[],n=p.value;for(let r=0;r<n.length;r+=1)n[r].text.toLowerCase().includes(e)&&t.push(r);return t}),g=W(()=>Math.max(0,Math.floor(o.value/WI)-GI)),_=W(()=>Math.min(m.value,Math.ceil((o.value+s.value)/WI)+GI)),v=W(()=>p.value.slice(g.value,_.value)),y=W(()=>h.value[f.value]??-1);function b(){let e=a.value;if(!e)return;o.value=e.scrollTop;let t=e.scrollHeight-e.scrollTop-e.clientHeight;c.value=t<12}function x(){let e=a.value;e&&(e.scrollTop=e.scrollHeight,o.value=e.scrollTop,c.value=!0)}function S(e){let t=a.value;t&&(t.scrollTop=Math.max(0,e*WI-t.clientHeight/2),o.value=t.scrollTop,c.value=!1)}function C(e){let t=h.value.length;t!==0&&(f.value=(f.value+e+t)%t,S(h.value[f.value]))}Ar(m,()=>{c.value&&(f.value=0,requestAnimationFrame(x))}),Ar(h,()=>{f.value=0,h.value.length>0&&u.value.trim().length>0&&requestAnimationFrame(()=>S(h.value[0]))}),Ar(l,()=>{c.value=!0,requestAnimationFrame(x)});let w=null;ta(()=>{let e=a.value;e&&(s.value=e.clientHeight,w=new ResizeObserver(()=>{a.value&&(s.value=a.value.clientHeight)}),w.observe(e),x())}),ze(()=>{w?.disconnect(),w=null});let T=[{value:`all`,label:`All`},{value:`stdout`,label:`out`},{value:`stderr`,label:`err`},{value:`system`,label:`sys`}];return(e,t)=>(L(),R(`div`,jI,[B(`header`,MI,[V(AI,{modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,options:T},null,8,[`modelValue`]),B(`div`,NI,[V(M(yy),{class:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),br(B(`input`,{"onUpdate:modelValue":t[1]||=e=>u.value=e,type:`search`,placeholder:`Search this output`,class:O([`h-7 py-0 pl-7 text-xs`,[M(hF)]]),"aria-label":`Search the log output`,onKeydown:t[2]||=du(lu(e=>C(e.shiftKey?-1:1),[`prevent`]),[`enter`])},null,34),[[Jl,u.value]]),B(`div`,PI,[u.value.trim().length>0?(L(),R(`span`,FI,k(h.value.length===0?`0`:`${f.value+1}/${h.value.length}`),1)):U(``,!0),u.value.length>0?(L(),R(`button`,{key:1,type:`button`,class:`grid size-5 place-items-center rounded text-faint hover:text-ink`,"aria-label":`Clear the search`,onClick:t[3]||=e=>u.value=``},[V(M(My),{class:`size-3`})])):U(``,!0),h.value.length>0?(L(),R(`button`,{key:2,type:`button`,class:`grid size-5 place-items-center rounded text-faint hover:text-ink`,"aria-label":`Previous match`,onClick:t[4]||=e=>C(-1)},[V(M(Rv),{class:`size-3`})])):U(``,!0),h.value.length>0?(L(),R(`button`,{key:3,type:`button`,class:`grid size-5 place-items-center rounded text-faint hover:text-ink`,"aria-label":`Next match`,onClick:t[5]||=e=>C(1)},[V(M(Fv),{class:`size-3`})])):U(``,!0)])]),B(`div`,II,[V(vF,{label:d.value?`Hide timestamps`:`Show timestamps`},{default:N(()=>[V($,{size:`xs`,variant:`ghost`,onClick:t[6]||=e=>d.value=!d.value},{default:N(()=>[V(M(Hv),{class:O(M(Q)(`size-3`,d.value?`fill-accent text-accent`:`text-faint`))},null,8,[`class`]),t[9]||=H(` ts `,-1)]),_:1})]),_:1},8,[`label`]),V($,{size:`xs`,variant:c.value?`secondary`:`primary`,onClick:t[7]||=e=>c.value?c.value=!1:x()},{default:N(()=>[(L(),z(ma(c.value?M(uy):M(fy)),{class:`size-3`})),H(` `+k(c.value?`Pause`:`Follow`),1)]),_:1},8,[`variant`]),n.clearable?(L(),z(vF,{key:0,label:`Clear the in-memory buffer`},{default:N(()=>[V($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Clear the log buffer`,onClick:t[8]||=e=>r(`clear`)},{default:N(()=>[V(M(Ay),{class:`size-3.5`})]),_:1})]),_:1})):U(``,!0),n.downloadUrl?(L(),z(vF,{key:1,label:`Download the persisted file`},{default:N(()=>[B(`a`,{href:n.downloadUrl,download:n.downloadName},[V($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Download the log file`},{default:N(()=>[V(M(Nv),{class:`size-3.5`})]),_:1})],8,LI)]),_:1})):U(``,!0)])]),B(`div`,RI,[B(`div`,{ref_key:`scroller`,ref:a,class:`h-full overflow-auto overscroll-contain bg-page/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/50`,style:ge({minHeight:n.minHeight}),tabindex:`0`,role:`log`,"aria-label":`Log output`,onScrollPassive:b},[m.value===0?(L(),R(`p`,zI,k(n.lines.length===0?n.emptyHint:`Nothing matches that search or stream filter.`),1)):(L(),R(`div`,{key:1,class:`relative w-full`,style:ge({height:`${m.value*WI}px`})},[(L(!0),R(I,null,va(v.value,(e,t)=>(L(),R(`div`,{key:g.value+t,class:O([`absolute left-0 top-0`,g.value+t===y.value&&`bg-warn/10`]),style:ge({transform:`translateY(${(g.value+t)*WI}px)`})},[V(DI,{line:e,query:u.value,dark:M(i).isDark.value,"show-time":d.value},null,8,[`line`,`query`,`dark`,`show-time`])],6))),128))],4))],36),V(Dc,{"enter-active-class":`transition duration-150`,"leave-active-class":`transition duration-100`,"enter-from-class":`opacity-0 translate-y-1`,"leave-to-class":`opacity-0 translate-y-1`},{default:N(()=>[!c.value&&m.value>0?(L(),R(`button`,{key:0,type:`button`,class:`absolute bottom-3 right-4 flex items-center gap-1.5 rounded-full border border-line bg-raise px-2.5 py-1 text-2xs text-muted shadow-float transition-colors duration-150 hover:text-ink`,onClick:x},[V(M(Nv),{class:`size-3`}),t[10]||=H(` Jump to latest `,-1)])):U(``,!0)]),_:1})]),B(`footer`,BI,[B(`span`,VI,[B(`span`,{class:O(M(Q)(`size-1.5 rounded-full`,n.live?c.value?`bg-ok`:`bg-warn`:`bg-faint`))},null,2),H(` `+k(n.live?c.value?`streaming`:`paused`:`snapshot`),1)]),B(`span`,HI,k(m.value===n.lines.length?`${m.value} lines`:`${m.value} of ${n.lines.length} lines`),1),u.value.trim().length>0?(L(),R(`span`,UI,k(h.value.length)+` matches`,1)):U(``,!0),B(`span`,{class:`ml-auto hidden font-mono tabular-nums sm:inline`},`row height `+k(WI)+`px · windowed`)])]))}}),qI={key:0,class:`grid size-10 place-items-center rounded-full border border-line bg-panel-2 text-faint`},JI={class:`max-w-sm space-y-1`},YI={class:`text-sm font-medium text-ink`},XI={key:0,class:`text-xs leading-relaxed text-muted`},ZI={key:1,class:`flex items-center gap-2`},QI=P({__name:`EmptyState`,props:{title:{},description:{default:void 0},compact:{type:Boolean,default:!1}},setup(e){return(e,t)=>(L(),R(`div`,{class:O(M(Q)(`flex flex-col items-center justify-center gap-3 text-center`,e.$props.compact?`px-4 py-8`:`px-6 py-14`))},[e.$slots.icon?(L(),R(`div`,qI,[F(e.$slots,`icon`)])):U(``,!0),B(`div`,JI,[B(`p`,YI,k(e.$props.title),1),e.$props.description?(L(),R(`p`,XI,k(e.$props.description),1)):U(``,!0)]),e.$slots.action?(L(),R(`div`,ZI,[F(e.$slots,`action`)])):U(``,!0)],2))}}),$I={class:`flex items-start justify-between gap-4 border-b border-line px-4 py-3`},eL={class:`min-w-0`},tL={class:`max-h-[calc(88dvh-3.25rem)] overflow-y-auto px-4 py-3.5`},nL={key:0,class:`flex items-center justify-end gap-2 border-t border-line bg-panel-2 px-4 py-3`},rL=P({__name:`Modal`,props:za({title:{},description:{default:void 0},width:{default:`w-[min(92vw,34rem)]`}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:[`update:open`],setup(e){let t=e,n=so(e,`open`);return(e,r)=>(L(),z(M(lf),{open:n.value,"onUpdate:open":r[0]||=e=>n.value=e},{default:N(()=>[V(M(Yf),null,{default:N(()=>[V(M(qf),{class:`fixed inset-0 z-50 bg-black/45 backdrop-blur-[1px] data-[state=closed]:animate-[hh-fade-out_120ms_ease-in] data-[state=open]:animate-[hh-fade-in_150ms_ease-out]`}),V(M(Wf),{class:O(M(Q)(`fixed left-1/2 top-1/2 z-50 max-h-[88dvh] -translate-x-1/2 -translate-y-1/2 overflow-hidden`,`rounded-panel border border-line bg-panel shadow-float`,`data-[state=closed]:animate-[hh-pop-out_120ms_ease-in] data-[state=open]:animate-[hh-pop-in_160ms_var(--ease-out-quick)]`,t.width))},{default:N(()=>[B(`header`,$I,[B(`div`,eL,[V(M(Xf),{class:`text-sm font-semibold text-ink`},{default:N(()=>[H(k(t.title),1)]),_:1}),t.description?(L(),z(M(Gf),{key:0,class:`mt-0.5 text-xs text-muted`},{default:N(()=>[H(k(t.description),1)]),_:1})):U(``,!0)]),V(M(uf),{class:O(M(Q)(`-mr-1 -mt-0.5 grid size-7 shrink-0 place-items-center rounded-control text-muted transition-colors duration-150 hover:bg-hover hover:text-ink`,M(fF))),"aria-label":`Close`},{default:N(()=>[V(M(My),{class:`size-4`})]),_:1},8,[`class`])]),B(`div`,tL,[F(e.$slots,`default`)]),e.$slots.footer?(L(),R(`footer`,nL,[F(e.$slots,`footer`)])):U(``,!0)]),_:3},8,[`class`])]),_:3})]),_:3},8,[`open`]))}}),iL=[`for`],aL={class:`relative`},oL=[`id`],sL=[`value`,`disabled`],cL={key:1,class:`text-2xs text-danger`},lL=P({inheritAttrs:!1,__name:`SelectField`,props:za({label:{default:void 0},hint:{default:void 0},error:{default:null},options:{},wide:{type:Boolean,default:!1},mono:{type:Boolean,default:!1}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`),r=li();return(e,i)=>(L(),R(`div`,{class:O(M(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(L(),R(`label`,{key:0,for:M(r),class:O(M(pF))},k(t.label),11,iL)):U(``,!0),B(`div`,aL,[br(B(`select`,Ms({id:M(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,class:M(Q)(M(hF),`cursor-pointer appearance-none pr-7`,t.mono&&`font-mono text-xs`,t.error&&`border-danger`)},e.$attrs),[(L(!0),R(I,null,va(t.options,e=>(L(),R(`option`,{key:e.value,value:e.value,disabled:e.disabled},k(e.label),9,sL))),128))],16,oL),[[Ql,n.value]]),V(M(Fv),{class:`pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`,"aria-hidden":`true`})]),t.error?(L(),R(`p`,cL,k(t.error),1)):t.hint?(L(),R(`p`,{key:2,class:O(M(mF))},k(t.hint),3)):U(``,!0)],2))}}),uL=P({__name:`Skeleton`,props:{class:{default:`h-4 w-24`},rounded:{default:`rounded`}},setup(e){return(t,n)=>(L(),R(`span`,{class:O(M(Q)(`block animate-pulse bg-line-soft`,e.rounded,t.$props.class)),style:{"animation-duration":`1.4s`},"aria-hidden":`true`},null,2))}}),dL={class:`flex h-full min-h-0`},fL={class:`hidden w-64 shrink-0 flex-col border-r border-line bg-panel/40 md:flex`},pL={class:`border-b border-line px-3 py-2.5`},mL={class:`mt-0.5 text-2xs text-faint`},hL={class:`min-h-0 flex-1 overflow-y-auto p-1.5`},gL={key:0,class:`space-y-1.5 p-1.5`},_L=[`onClick`],vL={class:`min-w-0 flex-1`},yL={class:`block truncate font-mono text-2xs text-faint`},bL={class:`flex min-w-0 flex-1 flex-col`},xL={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel/40 px-3 py-2.5`},SL={class:`min-w-0`},CL={class:`truncate text-sm font-semibold text-ink`},wL={key:0,class:`ml-1.5 font-mono text-2xs font-normal text-faint`},TL={key:0,class:`flex flex-wrap items-center gap-1.5 border-b border-line-soft bg-panel-2/40 px-3 py-2`},EL=[`href`,`download`],DL={class:`text-faint`},OL={key:1,class:`text-2xs text-faint`},kL={key:2,class:`ml-auto font-mono text-2xs text-faint`},AL={key:1,class:`flex items-center gap-1.5 border-b border-danger/25 bg-danger-soft px-3 py-2 text-2xs text-danger`},jL={class:`min-h-0 flex-1 p-3`},ML=P({__name:`LogsView`,setup(e){let t=zg(),n=Rg(),r=j([]),i=j(null),a=j(`disk`),o=j(`2000`),s=j(!1),c=j(null),l=j([]),u=j(0),d=j(!1),f=j(!0),p=W(()=>r.value.find(e=>e.serverId===i.value)??null),m=CM(()=>a.value===`live`?i.value:null),h=m.version,g=W(()=>(h.value,m.lines())),_=W(()=>a.value===`live`?g.value:l.value),v=W(()=>a.value===`live`?h.value:u.value),y=[{value:`200`,label:`200 lines`},{value:`500`,label:`500 lines`},{value:`2000`,label:`2000 lines`},{value:`5000`,label:`5000 lines`}],b=W(()=>r.value.reduce((e,t)=>e+t.sizeBytes,0)),x=W(()=>r.value.filter(e=>e.files.length>0).length);async function S(){f.value=!0;try{r.value=await pj();let e=typeof t.query.server==`string`?t.query.server:null,n=e&&r.value.some(t=>t.serverId===e)?e:i.value&&r.value.some(e=>e.serverId===i.value)?i.value:r.value[0]?.serverId??null;i.value=n}catch(e){c.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}async function C(){let e=i.value;if(e!==null&&a.value!==`live`){s.value=!0,c.value=null;try{let t=await mj(e,{tail:Number(o.value)});l.value=t.lines,u.value+=1}catch(e){c.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}}async function w(){let e=i.value;if(e!==null){d.value=!1;try{await hj(e),l.value=[],u.value+=1,await S()}catch(e){c.value=e instanceof Error?e.message:String(e)}}}function T(e){i.value=e,a.value===`live`&&(l.value=[]),n.replace({query:{...t.query,server:e}})}return Ar([i,o,a],()=>{a.value===`disk`&&C()},{immediate:!1}),ta(async()=>{await S(),a.value===`disk`&&await C()}),(e,t)=>(L(),R(`div`,dL,[B(`aside`,fL,[B(`div`,pL,[t[5]||=B(`p`,{class:`text-xs font-semibold text-ink`},` Persisted logs `,-1),B(`p`,mL,k(x.value)+` of `+k(r.value.length)+` servers on disk · `+k(M(xI)(b.value)),1)]),B(`div`,hL,[f.value?(L(),R(`div`,gL,[(L(),R(I,null,va(5,e=>V(uL,{key:e,class:`h-10 w-full`,rounded:`rounded-control`})),64))])):(L(!0),R(I,{key:1},va(r.value,e=>(L(),R(`button`,{key:e.serverId,type:`button`,class:O(M(Q)(`flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors duration-150`,e.serverId===i.value?`bg-accent-soft`:`hover:bg-hover`)),onClick:t=>T(e.serverId)},[B(`span`,{class:O(M(Q)(`size-1.5 shrink-0 rounded-full`,M(fP)[M(cP)[e.status].tone]))},null,2),B(`span`,vL,[B(`span`,{class:O(M(Q)(`block truncate text-xs`,e.serverId===i.value?`font-medium text-accent`:`text-ink`))},k(e.label),3),B(`span`,yL,k(e.files.length>0?`${e.files.length} file${e.files.length===1?``:`s`} · ${M(xI)(e.sizeBytes)}`:`nothing persisted`),1)])],10,_L))),128)),!f.value&&r.value.length===0?(L(),z(QI,{key:2,compact:``,title:`No servers`,description:`Add one and its output will be persisted here.`})):U(``,!0)]),t[6]||=B(`div`,{class:`border-t border-line p-2.5`},[B(`p`,{class:`text-2xs leading-4 text-faint`},` Rotation and retention are set under Settings → Log storage. `)],-1)]),B(`div`,bL,[B(`header`,xL,[B(`div`,SL,[B(`h1`,CL,[H(k(p.value?.label??`Logs`)+` `,1),p.value?(L(),R(`span`,wL,k(p.value.serverId),1)):U(``,!0)])]),V(AI,{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,class:`ml-auto`,options:[{value:`disk`,label:`Persisted`},{value:`live`,label:`Live stream`}]},null,8,[`modelValue`]),a.value===`disk`?(L(),z(lL,{key:0,modelValue:o.value,"onUpdate:modelValue":t[1]||=e=>o.value=e,options:y,class:`w-32`,"aria-label":`Tail size`},null,8,[`modelValue`])):U(``,!0),a.value===`disk`?(L(),z($,{key:1,size:`sm`,loading:s.value,onClick:C},{default:N(()=>[V(M(hy),{class:`size-3.5`}),t[7]||=H(`Reload `,-1)]),_:1},8,[`loading`])):U(``,!0),a.value===`disk`?(L(),z($,{key:2,size:`sm`,variant:`ghost`,disabled:!p.value||p.value.files.length===0,onClick:t[2]||=e=>d.value=!0},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),t[8]||=H(`Clear file `,-1)]),_:1},8,[`disabled`])):U(``,!0)]),p.value?(L(),R(`div`,TL,[V(M(Qv),{class:`size-3.5 shrink-0 text-faint`}),p.value.files.length>0?(L(!0),R(I,{key:0},va(p.value.files,e=>(L(),R(`a`,{key:e.name,href:gj(p.value.serverId,e.name),download:e.name,class:`inline-flex items-center gap-1 rounded-full border border-line px-2 py-0.5 font-mono text-2xs text-muted transition-colors duration-150 hover:border-accent/40 hover:text-accent`},[H(k(e.name)+` `,1),B(`span`,DL,k(M(xI)(e.sizeBytes)),1),V(M(Nv),{class:`size-3`})],8,EL))),128)):(L(),R(`span`,OL,` Nothing on disk for this server — persistence is off, or it has not written anything yet. `)),a.value===`disk`&&l.value.length>0?(L(),R(`span`,kL,` loaded `+k(l.value.length)+` lines `,1)):U(``,!0)])):U(``,!0),c.value?(L(),R(`p`,AL,[V(M(zv),{class:`size-3.5`}),H(` `+k(c.value),1)])):U(``,!0),B(`div`,jL,[p.value?s.value&&_.value.length===0?(L(),z(uL,{key:1,class:`h-full w-full`,rounded:`rounded-panel`})):(L(),z(KI,{key:2,lines:_.value,version:v.value,live:a.value===`live`,class:`h-full`,"empty-hint":a.value===`live`?`Connected — waiting for output.`:`The persisted file is empty.`,"min-height":`100%`},null,8,[`lines`,`version`,`live`,`empty-hint`])):(L(),z(QI,{key:0,title:`Pick a server`,description:`Persisted output and live streams are per server. Choose one from the list.`},{icon:N(()=>[V(M(vy),{class:`size-4`})]),_:1}))])]),V(rL,{open:d.value,"onUpdate:open":t[4]||=e=>d.value=e,title:`Clear the persisted log file?`,description:`${p.value?.serverId??``} — the file on disk is truncated. The process keeps running and new lines are written from here on.`,width:`w-[min(92vw,26rem)]`},{footer:N(()=>[V($,{variant:`ghost`,onClick:t[3]||=e=>d.value=!1},{default:N(()=>[...t[9]||=[H(` Keep it `,-1)]]),_:1}),V($,{variant:`danger`,onClick:w},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),t[10]||=H(`Clear `,-1)]),_:1})]),default:N(()=>[t[11]||=B(`p`,{class:`text-xs text-muted`},` Download it first if the output is still needed — this cannot be undone from the panel. `,-1)]),_:1},8,[`open`,`description`])]))}}),NL=P({__name:`Meter`,props:{value:{},warnAt:{default:75},dangerAt:{default:90},height:{default:`h-1.5`},class:{default:void 0}},setup(e){let t=e,n=W(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(100,Math.max(0,t.value))),r=W(()=>t.value===null?`neutral`:t.value>=t.dangerAt?`danger`:t.value>=t.warnAt?`warn`:`ok`),i={ok:`bg-ok/80`,warn:`bg-warn/85`,danger:`bg-danger/85`,info:`bg-info/80`,neutral:`bg-faint/60`,accent:`bg-accent/80`};return(e,a)=>(L(),R(`div`,{class:O(M(Q)(`w-full overflow-hidden rounded-full bg-line-soft`,t.height,t.class))},[B(`div`,{class:O(M(Q)(`h-full rounded-full transition-[width] duration-300 ease-out`,i[r.value])),style:ge({width:`${n.value}%`})},null,6)],2))}}),PL={key:1,class:`space-y-4`},FL={class:`grid grid-cols-2 gap-3 sm:grid-cols-4`},IL={class:`grid grid-cols-2 gap-x-4 gap-y-2 border-t border-line-soft pt-3 sm:grid-cols-4`},LL={class:`flex items-center gap-1 text-2xs text-faint`},RL={class:`font-mono text-xs text-ink`},zL={class:`font-mono text-xs tabular-nums text-ink`},BL={class:`flex items-center gap-1 text-2xs text-faint`},VL={class:`font-mono text-xs text-ink`},HL={class:`flex items-center gap-1 text-2xs text-faint`},UL={class:`font-mono text-xs text-ink`},WL={class:`space-y-2 border-t border-line-soft pt-3`},GL={class:`flex items-center gap-1.5 text-2xs font-medium text-faint`},KL={class:`flex items-baseline justify-between gap-2`},qL=[`title`],JL={class:`shrink-0 font-mono text-2xs tabular-nums text-faint`},YL={key:0,class:`space-y-1 rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2`},XL=P({__name:`HostVitalsPanel`,props:{host:{},now:{}},setup(e){let t=e,n=W(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=W(()=>t.host?.loadAvg.map(e=>e.toFixed(2)).join(` `)??`—`);return(e,i)=>!t.host||!t.host.enabled?(L(),z(QI,{key:0,compact:``,title:`Host sampling is off`,description:`Turn it on in Settings to collect load, memory, disk and temperature.`})):(L(),R(`div`,PL,[B(`div`,FL,[V(NP,{value:n.value===null?null:n.value/2*100,label:`Load / cpu`,display:n.value===null?`—`:n.value.toFixed(2),size:72,"warn-at":70,"danger-at":100},null,8,[`value`,`display`]),V(NP,{value:t.host.memoryUsedPercent,label:`Memory`,size:72},null,8,[`value`]),V(NP,{value:t.host.swapUsedPercent,label:`Swap`,size:72,"warn-at":50},null,8,[`value`]),V(NP,{value:t.host.tempCelsius===null?null:t.host.tempCelsius/85*100,label:`CPU temp`,display:t.host.tempCelsius===null?`n/a`:`${Math.round(t.host.tempCelsius)}°C`,size:72},null,8,[`value`,`display`])]),B(`dl`,IL,[B(`div`,null,[B(`dt`,LL,[V(M(Kv),{class:`size-3`}),i[0]||=H(`CPUs `,-1)]),B(`dd`,RL,k(t.host.cpus),1)]),B(`div`,null,[i[1]||=B(`dt`,{class:`text-2xs text-faint`},` Load 1 / 5 / 15 `,-1),B(`dd`,zL,k(r.value),1)]),B(`div`,null,[B(`dt`,BL,[V(M(oy),{class:`size-3`}),i[2]||=H(`Memory used `,-1)]),B(`dd`,VL,k(t.host.memoryUsedPercent.toFixed(0))+`% `,1)]),B(`div`,null,[B(`dt`,HL,[V(M(Oy),{class:`size-3`}),i[3]||=H(`Sampled `,-1)]),B(`dd`,UL,k(M(bI)(t.host.sampledAt,t.now)),1)])]),B(`div`,WL,[B(`p`,GL,[V(M($v),{class:`size-3`}),i[4]||=H(`Filesystems `,-1)]),(L(!0),R(I,null,va(t.host.disks,e=>(L(),R(`div`,{key:e.path,class:`space-y-1`},[B(`div`,KL,[B(`span`,{class:`truncate font-mono text-2xs text-muted`,title:e.path},k(e.path),9,qL),B(`span`,JL,k(M(xI)(e.totalBytes-e.freeBytes))+` / `+k(M(xI)(e.totalBytes))+` · `+k(e.usedPercent.toFixed(0))+`% `,1)]),V(NL,{value:e.usedPercent},null,8,[`value`])]))),128))]),t.host.alerts.length>0?(L(),R(`div`,YL,[i[5]||=B(`p`,{class:`text-2xs font-medium text-danger`},` Thresholds breached `,-1),(L(!0),R(I,null,va(t.host.alerts,e=>(L(),R(`p`,{key:e,class:`text-2xs text-danger`},k(e),1))),128))])):U(``,!0)]))}}),ZL={key:1,class:`flex flex-col`},QL={class:`min-w-0 flex-1`},$L={class:`flex items-baseline gap-1.5`},eR={class:`truncate text-xs font-medium text-ink`},tR=[`title`],nR={key:0,class:`text-muted`},rR={class:`shrink-0 pt-0.5 text-2xs text-faint`},iR=P({__name:`ActivityFeed`,props:{servers:{},now:{},limit:{default:12},serverId:{default:void 0}},setup(e){let t=e,n={start:fy,exit:Ty,crash:zv,"forced-restart":_y,unhealthy:jy,recovered:Bv},r=W(()=>{let e=[];for(let n of t.servers)if(t.serverId===void 0||n.id===t.serverId)for(let t of n.history.events)e.push({...t,label:n.config.label??n.id});return e.sort((e,t)=>t.ts-e.ts).slice(0,t.limit)});return(e,i)=>{let a=fa(`RouterLink`);return r.value.length===0?(L(),z(QI,{key:0,compact:``,title:`No events in the last 24 hours`,description:`Starts, exits, crashes and recoveries show up here as they happen.`})):(L(),R(`ol`,ZL,[(L(!0),R(I,null,va(r.value,(e,r)=>(L(),R(`li`,{key:`${e.serverId}-${e.ts}-${r}`,class:O([`flex items-start gap-2.5 border-line-soft py-2`,r>0&&`border-t`])},[(L(),z(ma(n[e.type]),{class:O(M(Q)(`mt-0.5 size-3.5 shrink-0`,M(uP)[M(hP)[e.type]]))},null,8,[`class`])),B(`div`,QL,[B(`p`,$L,[B(`span`,eR,k(M(mP)[e.type]),1),V(a,{to:`/servers/${e.serverId}`,class:`truncate text-2xs text-muted hover:text-accent`},{default:N(()=>[H(k(e.label),1)]),_:2},1032,[`to`])]),B(`p`,{class:`mt-0.5 truncate font-mono text-2xs text-faint`,title:e.detail},[H(k(e.detail)+` `,1),e.runtimeMs===void 0?U(``,!0):(L(),R(`span`,nR,` · ran `+k(M(_I)(e.runtimeMs)),1))],8,tR)]),B(`span`,rR,k(M(bI)(e.ts,t.now)),1)],2))),128))]))}}}),aR={class:`mb-3 flex items-start justify-between gap-3`},oR={class:`min-w-0`},sR={class:`text-xs font-semibold text-ink`},cR={key:0,class:`mt-0.5 text-2xs leading-4 text-muted`},lR={class:`flex shrink-0 items-center gap-2`},uR=P({__name:`FieldGroup`,props:{title:{},description:{default:void 0},columns:{default:2},dense:{type:Boolean,default:!1},class:{default:void 0}},setup(e){let t=e,n=W(()=>({1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3`})[t.columns]);return(e,r)=>(L(),R(`section`,{class:O(M(Q)(`rounded-panel border border-line bg-panel-2/40`,t.dense?`p-3`:`p-3.5`,t.class))},[B(`header`,aR,[B(`div`,oR,[B(`h3`,sR,k(t.title),1),t.description?(L(),R(`p`,cR,k(t.description),1)):U(``,!0)]),B(`div`,lR,[F(e.$slots,`actions`)])]),B(`div`,{class:O(M(Q)(`grid gap-3`,n.value))},[F(e.$slots,`default`)],2)],2))}}),dR=[`for`],fR=[`id`,`step`,`min`,`max`,`aria-invalid`],pR={key:1,class:`text-2xs text-danger`},mR=P({inheritAttrs:!1,__name:`NumberField`,props:za({label:{default:void 0},hint:{default:void 0},error:{default:null},wide:{type:Boolean,default:!1},nullable:{type:Boolean,default:!1},step:{default:void 0},min:{default:void 0},max:{default:void 0}},{modelValue:{default:null},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`),r=li(),i=W({get:()=>n.value===null||n.value===void 0?``:String(n.value),set:e=>{let r=e.trim();if(r.length===0){n.value=t.nullable?null:NaN;return}let i=Number(r);n.value=Number.isNaN(i)?NaN:i}}),a=W(()=>n.value!==null&&Number.isNaN(n.value));return(e,n)=>(L(),R(`div`,{class:O(M(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(L(),R(`label`,{key:0,for:M(r),class:O(M(pF))},k(t.label),11,dR)):U(``,!0),br(B(`input`,Ms({id:M(r),"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`number`,inputmode:`numeric`,step:t.step,min:t.min,max:t.max,class:M(Q)(M(hF),`font-mono tabular-nums`,(t.error||a.value)&&`border-danger`),"aria-invalid":t.error||a.value?!0:void 0},e.$attrs),null,16,fR),[[Jl,i.value]]),t.error?(L(),R(`p`,pR,k(t.error),1)):t.hint?(L(),R(`p`,{key:2,class:O(M(mF))},k(t.hint),3)):U(``,!0)],2))}}),hR=[`for`],gR=[`id`,`rows`,`placeholder`],_R={key:1,class:`text-2xs text-danger`},vR=P({inheritAttrs:!1,__name:`TextAreaField`,props:za({label:{default:void 0},hint:{default:void 0},error:{default:null},rows:{default:3},placeholder:{default:void 0},wide:{type:Boolean,default:!0},mono:{type:Boolean,default:!0}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`),r=li();return(e,i)=>(L(),R(`div`,{class:O(M(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(L(),R(`label`,{key:0,for:M(r),class:O(M(pF))},k(t.label),11,hR)):U(``,!0),br(B(`textarea`,Ms({id:M(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,rows:t.rows,placeholder:t.placeholder,spellcheck:`false`,class:M(Q)(t.mono?M(gF):`font-sans`,`resize-y leading-relaxed`,t.error&&`border-danger`)},e.$attrs),null,16,gR),[[Jl,n.value]]),t.error?(L(),R(`p`,_R,k(t.error),1)):t.hint?(L(),R(`p`,{key:2,class:O(M(mF))},k(t.hint),3)):U(``,!0)],2))}}),yR=[`for`],bR=[`id`,`aria-invalid`,`aria-describedby`],xR=[`id`],SR=[`id`],CR=P({inheritAttrs:!1,__name:`TextField`,props:za({label:{default:void 0},hint:{default:void 0},error:{default:null},wide:{type:Boolean,default:!1}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`),r=li(),i=W(()=>t.hint||t.error?`${r}-hint`:void 0);return(e,a)=>(L(),R(`div`,{class:O(M(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(L(),R(`label`,{key:0,for:M(r),class:O(M(pF))},k(t.label),11,yR)):U(``,!0),br(B(`input`,Ms({id:M(r),"onUpdate:modelValue":a[0]||=e=>n.value=e,class:M(Q)(M(hF),t.error&&`border-danger`),"aria-invalid":t.error?!0:void 0,"aria-describedby":i.value},e.$attrs),null,16,bR),[[ru,n.value]]),t.error?(L(),R(`p`,{key:1,id:`${M(r)}-hint`,class:`text-2xs text-danger`},k(t.error),9,xR)):t.hint?(L(),R(`p`,{key:2,id:`${M(r)}-hint`,class:O(M(mF))},k(t.hint),11,SR)):U(``,!0)],2))}}),wR={class:`block text-xs text-ink`},TR={key:0,class:`block text-2xs text-faint`},ER=P({__name:`ToggleSwitch`,props:za({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1},trailing:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`);return(e,r)=>(L(),R(`div`,{class:O(M(Q)(`flex items-center gap-2.5`,t.trailing&&`flex-row-reverse justify-end`))},[V(M(cg),{modelValue:n.value,"onUpdate:modelValue":r[0]||=e=>n.value=e,disabled:t.disabled,class:O(M(Q)(`relative inline-flex h-[18px] w-8 shrink-0 cursor-pointer items-center rounded-full border transition-colors duration-150`,`data-[state=checked]:border-accent data-[state=checked]:bg-accent`,`data-[state=unchecked]:border-line data-[state=unchecked]:bg-line-soft`,`disabled:cursor-not-allowed disabled:opacity-45`,M(fF)))},{default:N(()=>[V(M(lg),{class:`block size-3 translate-x-[3px] rounded-full bg-white shadow-sm transition-transform duration-150 ease-out data-[state=checked]:translate-x-[16px]`})]),_:1},8,[`modelValue`,`disabled`,`class`]),B(`label`,{class:`min-w-0 cursor-pointer select-none`,onClick:r[1]||=e=>!t.disabled&&(n.value=!n.value)},[B(`span`,wR,k(t.label),1),t.hint?(L(),R(`span`,TR,k(t.hint),1)):U(``,!0)])],2))}}),DR={class:`flex flex-col gap-2 rounded-panel border border-line bg-panel-2/40 p-3`},OR={class:`rounded-panel border border-line-soft bg-panel-2/40 p-3`},kR={class:`mt-1.5 flex flex-wrap gap-1`},AR={key:0,class:`rounded-control border border-danger/40 bg-danger-soft px-2.5 py-1.5 font-mono text-2xs leading-4 text-danger`},jR=P({__name:`AddServerDialog`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:za([`created`],[`update:open`]),setup(e,{emit:t}){let n=t,r=so(e,`open`),i=wM(),a=j(!1),o=j(null),s=/^[a-z0-9][a-z0-9_-]*$/,c=[`{port}`,`{host}`,`{home}`,`{projectDir}`,`{dataRoot}`,`{id}`,`{label}`,`{cwd}`,`{bind}`,`{lanIp}`],l=en({id:``,label:``,command:``,args:``,cwd:``,port:null,bind:`local`,autostart:!1});function u(){return{id:``,label:``,command:``,args:``,cwd:``,port:null,bind:`local`,autostart:!1}}let d=W(()=>l.port===null||l.port===void 0||Number.isNaN(l.port)||Number.isInteger(l.port)&&l.port>=1&&l.port<=65535?null:`Port must be a whole number between 1 and 65535.`);function f(){Object.assign(l,u()),o.value=null}Ar(r,e=>{e&&f()});function p(){return{id:l.id.trim(),label:l.label.trim().length>0?l.label.trim():void 0,command:l.command.trim(),args:l.args.split(`
40
- `).map(e=>e.trim()).filter(e=>e.length>0),cwd:l.cwd.trim().length>0?l.cwd.trim():void 0,...l.port===null?{}:{port:l.port},bind:l.bind,autostart:l.autostart}}function m(){return l.id.trim().length===0?`An id is required — it is the key this server lives under.`:s.test(l.id.trim())?l.command.trim().length===0?`A command is required — the executable the supervisor spawns.`:d.value===null?null:d.value:`The id must start with a lowercase letter or digit and contain only lowercase letters, digits, dashes and underscores.`}async function h(){o.value=null;let e=m();if(e!==null){o.value=e;return}a.value=!0;try{if(await i.create(p()),i.lastError.value!==null){o.value=i.lastError.value;return}n(`created`),r.value=!1,f()}finally{a.value=!1}}return(e,t)=>(L(),z(rL,{open:r.value,"onUpdate:open":t[9]||=e=>r.value=e,title:`Add a server`,description:`Appends an entry to servers.config.json; every policy you leave out is inherited from the defaults.`,width:`w-[min(94vw,40rem)]`},{footer:N(()=>[V($,{variant:`ghost`,onClick:t[8]||=e=>r.value=!1},{default:N(()=>[...t[12]||=[H(` Cancel `,-1)]]),_:1}),V($,{type:`submit`,form:`add-server-form`,variant:`primary`,loading:a.value},{default:N(()=>[...t[13]||=[H(` Add to servers.config.json `,-1)]]),_:1},8,[`loading`])]),default:N(()=>[B(`form`,{id:`add-server-form`,class:`flex flex-col gap-3`,onSubmit:lu(h,[`prevent`])},[V(uR,{title:`Identity`,columns:2,dense:``},{default:N(()=>[V(CR,{modelValue:l.id,"onUpdate:modelValue":t[0]||=e=>l.id=e,label:`Id`,placeholder:`my-server`,hint:`Lowercase letters, digits, dashes and underscores; used in URLs and logs.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(CR,{modelValue:l.label,"onUpdate:modelValue":t[1]||=e=>l.label=e,label:`Label`,placeholder:`My server`,hint:`Shown in the panel; defaults to the id.`},null,8,[`modelValue`])]),_:1}),V(uR,{title:`Process`,columns:2,dense:``},{default:N(()=>[V(CR,{modelValue:l.command,"onUpdate:modelValue":t[2]||=e=>l.command=e,label:`Command`,placeholder:`node`,hint:`Spawned without a shell.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(CR,{modelValue:l.cwd,"onUpdate:modelValue":t[3]||=e=>l.cwd=e,label:`Working directory`,placeholder:`.`,hint:`Relative paths resolve under projectDir.`,class:`font-mono text-xs`},null,8,[`modelValue`])]),_:1}),V(vR,{modelValue:l.args,"onUpdate:modelValue":t[4]||=e=>l.args=e,label:`Arguments`,rows:3,hint:`One argument per line; whitespace inside a line is preserved.`,placeholder:`-p
41
- {port}`},null,8,[`modelValue`]),V(uR,{title:`Port & lifecycle`,columns:2,dense:``},{default:N(()=>[V(mR,{modelValue:l.port,"onUpdate:modelValue":t[5]||=e=>l.port=e,label:`Port`,nullable:``,min:1,max:65535,error:d.value,hint:`Blank means the server has no port to probe or preflight.`},null,8,[`modelValue`,`error`]),V(lL,{modelValue:l.bind,"onUpdate:modelValue":t[6]||=e=>l.bind=e,label:`Bind address`,options:[{value:`local`,label:`local — 127.0.0.1`},{value:`lan`,label:`lan — 0.0.0.0`}],hint:`lan exposes it to the network; only do that behind auth.`},null,8,[`modelValue`])]),_:1}),B(`div`,DR,[V(ER,{modelValue:l.autostart,"onUpdate:modelValue":t[7]||=e=>l.autostart=e,label:`Autostart with up`,hint:`Start it whenever the control plane comes up.`},null,8,[`modelValue`]),t[10]||=B(`p`,{class:`text-2xs leading-4 text-faint`},[H(` Everything this entry does not set — restart, health, stop, resources — is inherited from `),B(`span`,{class:`font-mono`},`Settings → Defaults`),H(`, and can be overridden afterwards from the server's own editor. `)],-1)]),B(`div`,OR,[t[11]||=B(`p`,{class:`text-2xs font-medium text-muted`},` Available argument placeholders `,-1),B(`div`,kR,[(L(),R(I,null,va(c,e=>B(`code`,{key:e,class:`rounded-control border border-line bg-raise px-1.5 py-0.5 font-mono text-2xs text-ink`},k(e),1)),64))])]),o.value?(L(),R(`p`,AR,k(o.value),1)):U(``,!0)],32)]),_:1},8,[`open`]))}}),MR={class:`text-xs font-semibold text-ink`},NR={class:`mt-2.5 flex justify-end gap-1.5`},PR=P({__name:`KillPortButton`,props:{port:{},busy:{type:Boolean,default:!1}},emits:[`confirm`],setup(e,{emit:t}){let n=e,r=t,i=j(!1);function a(){i.value=!1,r(`confirm`)}return(e,t)=>(L(),z(M(Wh),{open:i.value,"onUpdate:open":t[0]||=e=>i.value=e},{default:N(()=>[V(M(Zh),{"as-child":``},{default:N(()=>[V($,{variant:`danger-ghost`,size:`xs`,loading:n.busy},{default:N(()=>[H(` Kill what holds port `+k(n.port),1)]),_:1},8,[`loading`])]),_:1}),V(M(Xh),null,{default:N(()=>[V(M(Yh),{"side-offset":6,align:`start`,class:`z-50 w-64 rounded-panel border border-line bg-raise p-3 shadow-float focus-visible:outline-none data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[B(`p`,MR,` Kill the process on port `+k(n.port)+`? `,1),t[3]||=B(`p`,{class:`mt-1 text-2xs leading-4 text-muted`},` It is asked to stop first, and killed only if it ignores that. Anything this panel supervises is refused, so a managed server cannot be lost this way. `,-1),B(`div`,NR,[V(M(Gh),{"as-child":``},{default:N(()=>[V($,{size:`xs`,variant:`ghost`},{default:N(()=>[...t[1]||=[H(` Keep it `,-1)]]),_:1})]),_:1}),V($,{size:`xs`,variant:`danger`,loading:n.busy,onClick:a},{default:N(()=>[...t[2]||=[H(` Kill it `,-1)]]),_:1},8,[`loading`])])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),FR=[`viewBox`],IR=[`id`],LR=[`stop-color`],RR=[`stop-color`],zR=[`d`,`fill`],BR=[`d`,`stroke`,`stroke-width`],VR=[`x1`,`x2`,`y2`,`stroke`],HR=[`cx`,`cy`,`fill`],UR={key:0,class:`absolute inset-x-0 top-1/2 border-t border-dashed border-line`},WR=100,GR=P({__name:`Sparkline`,props:za({values:{},height:{default:34},max:{default:null},min:{default:null},fill:{type:Boolean,default:!0},strokeWidth:{default:1.5},color:{default:void 0},class:{default:void 0},interactive:{type:Boolean,default:!1}},{hoverIndex:{default:null},hoverIndexModifiers:{}}),emits:[`update:hoverIndex`],setup(e){let t=e,n=so(e,`hoverIndex`),r=li(),i=j(null),a=W(()=>{let e=t.values.filter(e=>e!==null&&Number.isFinite(e)),n=t.max??(e.length>0?Math.max(...e):1),r=t.min??0;return{bottom:r,ceiling:n===r?r+1:n}}),o=W(()=>{let e=t.values,{bottom:n,ceiling:r}=a.value,i=r-n,o=e.length>1?WR/(e.length-1):WR,s=e=>t.height-(e-n)/i*t.height,c=[],l=[],u=()=>{if(l.length===0)return;let e=l.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(2)} ${e.y.toFixed(2)}`).join(` `),n=l[0],r=`${e} L${l[l.length-1].x.toFixed(2)} ${t.height} L${n.x.toFixed(2)} ${t.height} Z`;c.push({line:e,area:r}),l=[]};return e.forEach((e,t)=>{if(e===null||!Number.isFinite(e)){u();return}l.push({x:t*o,y:s(e)})}),u(),c}),s=W(()=>n.value===null||t.values.length<2?null:n.value/(t.values.length-1)*WR),c=W(()=>{let e=n.value;if(e===null)return null;let r=t.values[e];if(r==null||!Number.isFinite(r))return null;let{bottom:i,ceiling:o}=a.value;return t.height-(r-i)/(o-i)*t.height});function l(e){if(!t.interactive||!i.value||t.values.length===0)return;let r=i.value.getBoundingClientRect();if(r.width===0)return;let a=Math.min(1,Math.max(0,(e.clientX-r.left)/r.width));n.value=Math.round(a*(t.values.length-1))}function u(){n.value=null}return(e,n)=>(L(),R(`div`,{ref_key:`track`,ref:i,class:O(M(Q)(`relative w-full`,t.class)),style:ge({height:`${t.height}px`}),onMousemove:l,onMouseleave:u},[(L(),R(`svg`,{viewBox:`0 0 ${WR} ${t.height}`,preserveAspectRatio:`none`,class:`block size-full overflow-visible`,role:`img`,"aria-hidden":`true`},[B(`defs`,null,[B(`linearGradient`,{id:M(r),x1:`0`,y1:`0`,x2:`0`,y2:`1`},[B(`stop`,{offset:`0%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0.26`},null,8,LR),B(`stop`,{offset:`100%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0`},null,8,RR)],8,IR)]),(L(!0),R(I,null,va(o.value,(e,n)=>(L(),R(I,{key:n},[t.fill?(L(),R(`path`,{key:0,d:e.area,fill:`url(#${M(r)})`,stroke:`none`},null,8,zR)):U(``,!0),B(`path`,{d:e.line,fill:`none`,stroke:t.color??`currentColor`,"stroke-width":t.strokeWidth,"stroke-linecap":`round`,"stroke-linejoin":`round`,"vector-effect":`non-scaling-stroke`},null,8,BR)],64))),128)),s.value===null?U(``,!0):(L(),R(`line`,{key:0,x1:s.value,x2:s.value,y1:`0`,y2:t.height,stroke:t.color??`currentColor`,"stroke-width":`1`,"stroke-dasharray":`2 2`,"vector-effect":`non-scaling-stroke`,opacity:`0.5`},null,8,VR)),s.value!==null&&c.value!==null?(L(),R(`circle`,{key:1,cx:s.value,cy:c.value,r:`2`,fill:t.color??`currentColor`,"vector-effect":`non-scaling-stroke`},null,8,HR)):U(``,!0)],8,FR)),o.value.length===0?(L(),R(`div`,UR)):U(``,!0)],38))}}),KR={class:`min-w-0`},qR={class:`flex items-baseline justify-between gap-2`},JR={class:`truncate text-2xs font-medium text-faint`},YR={class:`flex shrink-0 items-baseline gap-1.5`},XR={key:0,class:`font-mono text-2xs text-faint`},ZR=P({__name:`MetricSpark`,props:{label:{},values:{},format:{},max:{default:null},colorClass:{default:`text-accent`},height:{default:30},sampleMs:{default:5e3},emptyHint:{default:`collecting…`}},setup(e){let t=e,n=j(null),r=W(()=>Qj(t.values)),i=W(()=>t.values.some(e=>e!==null)),a=W(()=>{let e=n.value;return e!==null&&t.values[e]!==void 0?t.values[e]??null:r.value}),o=W(()=>{let e=n.value;if(e===null)return null;let r=t.values.length-1-e;if(r<=0)return null;let i=Math.round(r*t.sampleMs/1e3);return i<60?`−${i}s`:`−${Math.round(i/60)}m`});return(e,r)=>(L(),R(`div`,KR,[B(`div`,qR,[B(`span`,JR,k(t.label),1),B(`span`,YR,[o.value?(L(),R(`span`,XR,k(o.value),1)):U(``,!0),B(`span`,{class:O(M(Q)(`font-mono text-xs font-medium tabular-nums`,i.value?`text-ink`:`text-faint`))},k(i.value?t.format(a.value):t.emptyHint),3)])]),V(GR,{"hover-index":n.value,"onUpdate:hoverIndex":r[0]||=e=>n.value=e,values:t.values,height:t.height,max:t.max,interactive:``,class:O(M(Q)(`mt-1`,t.colorClass))},null,8,[`hover-index`,`values`,`height`,`max`,`class`])]))}}),QR={class:`inline-flex flex-wrap items-center gap-1.5`},$R={class:`relative flex size-1.5`},ez={key:0,class:`absolute inset-0 rounded-full bg-current opacity-60`,style:{animation:`hh-pulse-ring 1.6s ease-out infinite`}},tz=P({__name:`StatusPill`,props:{status:{},health:{default:null},showHealth:{type:Boolean,default:!0}},setup(e){let t=e,n=W(()=>cP[t.status]),r=W(()=>t.health?lP[t.health]:null),i=W(()=>t.showHealth&&r.value!==null&&t.health!==`disabled`&&t.health!==`unknown`&&(r.value.tone===`danger`||r.value.tone===`warn`)),a=W(()=>n.value.transitional);return(e,t)=>(L(),R(`span`,QR,[B(`span`,{class:O(M(Q)(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium`,M(dP)[n.value.tone]))},[B(`span`,$R,[a.value?(L(),R(`span`,ez)):U(``,!0),B(`span`,{class:O(M(Q)(`relative size-1.5 rounded-full`,M(fP)[n.value.tone]))},null,2)]),H(` `+k(n.value.label),1)],2),i.value&&r.value?(L(),R(`span`,{key:0,class:O(M(Q)(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium`,M(dP)[r.value.tone]))},k(r.value.label),3)):U(``,!0)]))}}),nz={class:`flex items-start justify-between gap-3 px-4 pb-2.5 pt-3.5`},rz={class:`min-w-0`},iz={class:`flex items-center gap-2`},az=[`href`,`title`,`aria-label`],oz={class:`mt-0.5 flex items-center gap-1.5 truncate font-mono text-2xs text-faint`},sz={class:`text-muted`},cz={key:1,class:`rounded bg-hover px-1 py-px text-muted`},lz={key:2,class:`rounded bg-accent-soft px-1 py-px text-accent`},uz=[`title`],dz={key:0,class:`space-y-2.5 border-y border-line-soft px-4 py-3`},fz={class:`grid grid-cols-2 gap-x-4 gap-y-2`},pz={key:1,class:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 pt-2.5`},mz={class:`text-muted`},hz={class:`text-faint`},gz={key:2,class:`flex flex-col gap-1 px-4 pt-2.5`},_z={key:0,class:`flex items-start gap-1.5 text-2xs leading-4 text-danger`},vz={class:`min-w-0 break-words`},yz={key:2,class:`text-2xs leading-4 text-warn`},bz={key:3,class:`text-2xs leading-4 text-warn`},xz={class:`grid grid-cols-2 gap-x-4 gap-y-1 px-4 py-3 sm:grid-cols-4`},Sz={class:`truncate text-2xs text-faint`},Cz={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},wz={class:`mt-auto flex items-center gap-1.5 border-t border-line-soft px-4 py-2.5`},Tz={class:`grid grid-cols-2 gap-2 text-xs`},Ez={class:`font-mono text-ink`},Dz={class:`text-ink capitalize`},Oz=P({__name:`ServerCard`,props:{server:{},series:{},now:{},variant:{default:`default`}},setup(e){let t=e,n={start:fy,exit:Ty,crash:zv,"forced-restart":_y,unhealthy:jy,recovered:Bv},r=wM(),i=j(!1),a=j(!1),o=W(()=>t.server.config),s=W(()=>o.value.label&&o.value.label.length>0?o.value.label:t.server.id),c=W(()=>`${o.value.command} ${o.value.args.join(` `)}`.trim()),l=W(()=>pP(t.server.status,t.server.health)),u=W(()=>t.server.status===`running`),d=W(()=>o.value.enabled&&[`stopped`,`crashed`,`conflict`].includes(t.server.status)),f=W(()=>[`running`,`starting`,`backoff`].includes(t.server.status)),p=W(()=>t.server.startedAt===null||!u.value?`—`:_I(t.now-t.server.startedAt)),m=W(()=>t.server.nextRetryAt===null?null:vI(t.server.nextRetryAt,t.now)),h=W(()=>t.server.unhealthySince===null?null:_I(t.now-t.server.unhealthySince)),g=W(()=>t.series?.cpu??[]),_=W(()=>t.series?.rss??[]),v=W(()=>t.series?.probe??[]),y=W(()=>[...t.server.history.events].slice(-3).reverse()),b=W(()=>{let e=t.server,n=[{key:`pid`,label:`PID`,value:e.pid===null?`—`:String(e.pid)},{key:`uptime`,label:`Uptime`,value:p.value},{key:`restarts`,label:`Restarts`,value:`${e.restarts}/${e.maxRetries}`},{key:`port`,label:`Port`,value:e.portState},{key:`uptime24`,label:`24h up`,value:yI(e.history.uptimeRatio)},{key:`probe`,label:`Probe`,value:e.responseMs===null?`—`:`${e.responseMs} ms`},{key:`rss`,label:`RSS`,value:SI(e.resources?.rssBytes??null)},{key:`procs`,label:`Procs`,value:e.resources?String(e.resources.processes):`—`}];return e.history.crashes>0&&n.splice(5,0,{key:`crashes`,label:`24h crashes`,value:String(e.history.crashes)}),e.history.lastCrashAt!==null&&n.push({key:`lastcrash`,label:`Last crash`,value:bI(e.history.lastCrashAt,t.now)}),n});async function x(e){i.value=!0;try{await r[e](t.server.id)}finally{i.value=!1}}async function S(){i.value=!0;try{await r.freePort(t.server.id)}finally{i.value=!1}}async function C(e){let n=!(e===`enabled`?o.value.enabled:o.value.autostart);e===`enabled`?await r.setEnabled(t.server.id,n):await r.setAutostart(t.server.id,n)}async function w(){a.value=!1,await r.remove(t.server.id)}return(u,p)=>{let T=fa(`RouterLink`);return L(),R(`article`,{class:O(M(Q)(`group relative flex flex-col rounded-panel border bg-panel shadow-card transition-colors duration-150`,`hover:border-line/90`,t.server.status===`crashed`||t.server.status===`conflict`?`border-danger/30`:`border-line`,!o.value.enabled&&`opacity-70`))},[B(`span`,{class:O(M(Q)(`absolute inset-y-3 left-0 w-0.5 rounded-full`,{"bg-ok":l.value===`ok`,"bg-warn":l.value===`warn`,"bg-danger":l.value===`danger`,"bg-faint/50":l.value===`neutral`,"bg-accent":l.value===`accent`||l.value===`info`}))},null,2),B(`header`,nz,[B(`div`,rz,[B(`div`,iz,[V(T,{to:`/servers/${e.server.id}`,class:`truncate text-sm font-semibold tracking-tight text-ink hover:text-accent`},{default:N(()=>[H(k(s.value),1)]),_:1},8,[`to`]),e.server.url?(L(),R(`a`,{key:0,href:e.server.url,target:`_blank`,rel:`noreferrer`,class:`shrink-0 text-faint transition-colors duration-150 hover:text-accent`,title:e.server.url,"aria-label":`Open ${e.server.url}`},[V(M(Yv),{class:`size-3.5`})],8,az)):U(``,!0)]),B(`p`,oz,[B(`span`,null,k(e.server.id),1),o.value.port===null?U(``,!0):(L(),R(I,{key:0},[p[9]||=B(`span`,{"aria-hidden":`true`},`·`,-1),B(`span`,sz,`:`+k(o.value.port),1)],64)),p[10]||=B(`span`,{"aria-hidden":`true`},`·`,-1),B(`span`,null,k(e.server.bindHost),1),o.value.enabled?U(``,!0):(L(),R(`span`,cz,`disabled`)),o.value.autostart?(L(),R(`span`,lz,`autostart`)):U(``,!0)])]),V(tz,{status:e.server.status,health:e.server.health},null,8,[`status`,`health`]),e.server.adopted?(L(),z(vF,{key:0,label:`This process replaced itself: the panel adopted the successor instead of starting a second copy. Stop still works, its output stays where the successor sent it.`},{default:N(()=>[...p[11]||=[B(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):U(``,!0)]),B(`p`,{class:`truncate px-4 pb-3 font-mono text-2xs text-muted`,title:c.value},k(c.value),9,uz),t.variant===`compact`?U(``,!0):(L(),R(`div`,dz,[B(`div`,fz,[V(ZR,{label:`CPU`,values:g.value,format:M(CI),max:100,"color-class":`text-cpu`},null,8,[`values`,`format`]),V(ZR,{label:`Memory`,values:_.value,format:M(SI),"color-class":`text-mem`},null,8,[`values`,`format`])]),V(ZR,{label:`Health probe`,values:v.value,format:e=>e===null?`—`:`${e} ms`,height:22,"color-class":`text-probe`,"empty-hint":`not probed`},null,8,[`values`,`format`])])),y.value.length>0?(L(),R(`div`,pz,[(L(!0),R(I,null,va(y.value,e=>(L(),R(`span`,{key:`${e.ts}`,class:`inline-flex items-center gap-1 text-2xs`},[(L(),z(ma(n[e.type]),{class:O(M(Q)(`size-3`,M(uP)[M(hP)[e.type]]))},null,8,[`class`])),B(`span`,mz,k(M(mP)[e.type]),1),B(`span`,hz,k(M(bI)(e.ts,t.now)),1)]))),128))])):U(``,!0),e.server.lastError||h.value||m.value?(L(),R(`div`,gz,[e.server.lastError?(L(),R(`p`,_z,[V(M(zv),{class:`mt-0.5 size-3 shrink-0`}),B(`span`,vz,k(e.server.lastError),1)])):U(``,!0),e.server.status===`conflict`&&o.value.port!==null?(L(),z(PR,{key:1,port:o.value.port,busy:i.value,class:`self-start`,onConfirm:S},null,8,[`port`,`busy`])):U(``,!0),h.value?(L(),R(`p`,yz,` Unhealthy for `+k(h.value),1)):U(``,!0),m.value?(L(),R(`p`,bz,` Next attempt `+k(m.value),1)):U(``,!0)])):U(``,!0),B(`dl`,xz,[(L(!0),R(I,null,va(b.value,e=>(L(),R(`div`,{key:e.key,class:`min-w-0`},[B(`dt`,Sz,k(e.label),1),B(`dd`,Cz,k(e.value),1)]))),128))]),B(`div`,wz,[V($,{variant:`primary`,size:`xs`,disabled:i.value||!d.value,onClick:p[0]||=e=>x(`start`)},{default:N(()=>[V(M(fy),{class:`size-3`}),p[12]||=H(`Start `,-1)]),_:1},8,[`disabled`]),V($,{size:`xs`,disabled:i.value||!f.value,onClick:p[1]||=e=>x(`stop`)},{default:N(()=>[V(M(Ty),{class:`size-3`}),p[13]||=H(`Stop `,-1)]),_:1},8,[`disabled`]),V($,{size:`xs`,disabled:i.value||!o.value.enabled,onClick:p[2]||=e=>x(`restart`)},{default:N(()=>[V(M(_y),{class:`size-3`}),p[14]||=H(`Restart `,-1)]),_:1},8,[`disabled`]),V(vF,{label:`Live logs and full telemetry`},{default:N(()=>[V(T,{to:`/servers/${e.server.id}`},{default:N(()=>[V($,{size:`xs`,variant:`ghost`},{default:N(()=>[V(M(vy),{class:`size-3`}),p[15]||=H(`Details `,-1)]),_:1})]),_:1},8,[`to`])]),_:1}),V(M(eg),null,{default:N(()=>[V(M(ag),{"as-child":``},{default:N(()=>[V($,{size:`icon-sm`,variant:`ghost`,class:`ml-auto`,"aria-label":`More actions for ${s.value}`},{default:N(()=>[V(M(Jv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),V(M(rg),null,{default:N(()=>[V(M(tg),{"side-offset":4,align:`end`,class:`z-50 min-w-52 rounded-panel border border-line bg-raise p-1 shadow-float data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:p[3]||=e=>C(`enabled`)},{default:N(()=>[V(M(my),{class:`size-3.5`}),H(` `+k(o.value.enabled?`Disable server`:`Enable server`),1)]),_:1}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:p[4]||=e=>C(`autostart`)},{default:N(()=>[V(M(fy),{class:`size-3.5`}),H(` `+k(o.value.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:p[5]||=t=>M(r).clearLogs(e.server.id)},{default:N(()=>[V(M(vy),{class:`size-3.5`}),p[16]||=H(` Clear log buffer `,-1)]),_:1}),V(M(ig),{class:`my-1 h-px bg-line`}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-danger outline-none data-[highlighted]:bg-danger-soft`,onSelect:p[6]||=e=>a.value=!0},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),p[17]||=H(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),V(rL,{open:a.value,"onUpdate:open":p[8]||=e=>a.value=e,title:`Remove this server?`,description:`${s.value} is removed from servers.config.json. Its process is stopped and its persisted logs stay on disk.`,width:`w-[min(92vw,26rem)]`},{footer:N(()=>[V($,{variant:`ghost`,onClick:p[7]||=e=>a.value=!1},{default:N(()=>[...p[20]||=[H(` Keep it `,-1)]]),_:1}),V($,{variant:`danger`,onClick:w},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),p[21]||=H(`Remove `,-1)]),_:1})]),default:N(()=>[B(`dl`,Tz,[B(`div`,null,[p[18]||=B(`dt`,{class:`text-faint`},` id `,-1),B(`dd`,Ez,k(e.server.id),1)]),B(`div`,null,[p[19]||=B(`dt`,{class:`text-faint`},` status `,-1),B(`dd`,Dz,k(e.server.status),1)])])]),_:1},8,[`open`,`description`])],2)}}}),kz={class:`flex flex-wrap items-start justify-between gap-3`},Az={class:`min-w-0`},jz={class:`flex flex-wrap items-center gap-x-3 gap-y-1.5`},Mz={class:`text-2xl font-semibold tracking-tight text-ink`},Nz={key:1,class:`mt-1 max-w-2xl text-xs leading-relaxed text-muted`},Pz={class:`flex shrink-0 flex-wrap items-center gap-2`},Fz=P({__name:`PageHeader`,props:{title:{},description:{default:void 0},backTo:{default:void 0},backLabel:{default:`Back`}},setup(e){return(e,t)=>{let n=fa(`RouterLink`);return L(),R(`header`,kz,[B(`div`,Az,[e.$props.backTo?(L(),z(n,{key:0,to:e.$props.backTo,class:`mb-1 inline-flex items-center gap-1 text-2xs text-muted transition-colors duration-150 hover:text-ink`},{default:N(()=>[V(M(Iv),{class:`size-3`}),H(` `+k(e.$props.backLabel),1)]),_:1},8,[`to`])):U(``,!0),B(`div`,jz,[B(`h1`,Mz,k(e.$props.title),1),F(e.$slots,`badges`)]),e.$props.description?(L(),R(`p`,Nz,k(e.$props.description),1)):U(``,!0)]),B(`div`,Pz,[F(e.$slots,`actions`)])])}}}),Iz={key:0,class:`mb-3 flex items-start justify-between gap-3`},Lz={class:`min-w-0`},Rz={class:`flex shrink-0 items-center gap-1.5`},zz=P({__name:`Panel`,props:{padded:{type:Boolean,default:!0},class:{}},setup(e){return(e,t)=>(L(),R(`section`,{class:O(M(sP)(`rounded-panel border border-line bg-panel shadow-card`,e.$props.padded&&`p-4`,e.$props.class))},[e.$slots.header||e.$slots.actions?(L(),R(`header`,Iz,[B(`div`,Lz,[F(e.$slots,`header`)]),B(`div`,Rz,[F(e.$slots,`actions`)])])):U(``,!0),F(e.$slots,`default`)],2))}}),Bz={class:`min-w-0`},Vz={class:`truncate text-2xs font-medium text-faint`},Hz={key:0,class:`mt-0.5 truncate text-2xs text-muted`},Uz=P({__name:`StatTile`,props:{label:{},value:{},hint:{default:void 0},tone:{default:`neutral`},mono:{type:Boolean,default:!0}},setup(e){return(e,t)=>(L(),R(`div`,Bz,[B(`p`,Vz,k(e.$props.label),1),B(`p`,{class:O(M(Q)(`mt-0.5 truncate text-xl font-semibold tracking-tight`,e.$props.mono&&`font-mono tabular-nums`,e.$props.tone===`neutral`?`text-ink`:M(uP)[e.$props.tone]))},k(e.$props.value),3),e.$props.hint?(L(),R(`p`,Hz,k(e.$props.hint),1)):U(``,!0)]))}}),Wz=j(null),Gz=j(`unknown`),Kz=null;async function qz(){try{let e=await(await fetch(`/healthz`,{cache:`no-store`})).json();typeof e.uptimeMs==`number`&&(Wz.value=Date.now()-e.uptimeMs),Gz.value=e.status===`degraded`?`degraded`:`ok`}catch{Gz.value=`unknown`}}function Jz(){return Kz??=qz().finally(()=>{Kz=null}),{startedAt:Wz,status:Gz,refresh:qz}}var Yz={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},Xz={key:0,class:`grid grid-cols-2 gap-4 p-4 sm:grid-cols-3 lg:grid-cols-6`},Zz={key:1,class:`grid grid-cols-2 divide-line-soft sm:grid-cols-3 sm:divide-x lg:grid-cols-6`},Qz={class:`p-4`},$z={class:`p-4`},eB={class:`p-4`},tB={class:`p-4`},nB={class:`p-4`},rB={class:`p-4`},iB={key:0,class:`flex items-start gap-2.5 rounded-panel border border-danger/25 bg-danger-soft px-3.5 py-3`},aB={class:`min-w-0`},oB={class:`text-xs font-medium text-danger`},sB={class:`mt-0.5 flex flex-wrap gap-x-2 text-2xs text-danger`},cB={class:`space-y-3`},lB={class:`flex items-center justify-between`},uB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},dB={key:0,class:`grid gap-4 lg:grid-cols-2`},fB={key:2,class:`grid gap-4 lg:grid-cols-2`},pB={class:`grid gap-4 lg:grid-cols-3`},mB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},hB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},gB={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-faint`},_B={class:`flex items-center gap-1`},vB={class:`font-mono`},yB=P({__name:`OverviewView`,setup(e){let{servers:t,host:n,now:r,appState:i,seriesOf:a,startAll:o,stopAll:s}=wM(),c=Jz(),l=j(!1),u=W(()=>i.value===null),d=W(()=>t.value.filter(e=>e.status===`running`)),f=W(()=>t.value.filter(e=>[`stopped`,`stopping`].includes(e.status))),p=W(()=>t.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`)),m=W(()=>{let e=0;for(let t of d.value){let n=t.resources?.rssBytes;typeof n==`number`&&(e+=n)}return e}),h=W(()=>{let e=0;for(let n of t.value){let t=Zj(a(n.id).rss);t>e&&(e=t)}return e}),g=W(()=>c.startedAt.value===null?`—`:_I(r.value-c.startedAt.value)),_=W(()=>n.value?.enabled?_I(n.value.uptimeMs):`—`),v=W(()=>{let e=0;for(let t of d.value)e+=t.resources?.cpuPercent??0;return e});return ta(async()=>{await c.refresh()}),(e,y)=>{let b=fa(`RouterLink`);return L(),R(`div`,Yz,[V(Fz,{title:`Overview`,description:`Live state of everything this panel supervises, refreshed over a single event stream.`},{actions:N(()=>[V($,{variant:`ghost`,onClick:y[0]||=e=>M(o)()},{default:N(()=>[V(M(fy),{class:`size-3.5`}),y[5]||=H(`Start all `,-1)]),_:1}),V($,{variant:`ghost`,onClick:y[1]||=e=>M(s)()},{default:N(()=>[V(M(Ty),{class:`size-3.5`}),y[6]||=H(`Stop all `,-1)]),_:1}),V($,{variant:`primary`,onClick:y[2]||=e=>l.value=!0},{default:N(()=>[V(M(py),{class:`size-3.5`}),y[7]||=H(`Add server `,-1)]),_:1})]),_:1}),V(zz,{class:`p-0`},{default:N(()=>[u.value?(L(),R(`div`,Xz,[(L(),R(I,null,va(6,e=>B(`div`,{key:e,class:`space-y-2`},[V(uL,{class:`h-2.5 w-16`}),V(uL,{class:`h-6 w-20`})])),64))])):(L(),R(`div`,Zz,[B(`div`,Qz,[V(Uz,{label:`Running`,value:`${d.value.length}/${M(t).length}`,tone:`ok`,hint:`${M(t).length-d.value.length} not up`},null,8,[`value`,`hint`])]),B(`div`,$z,[V(Uz,{label:`Stopped`,value:String(f.value.length),hint:`${M(t).filter(e=>e.config.enabled).length} enabled`},null,8,[`value`,`hint`])]),B(`div`,eB,[V(Uz,{label:`Needs attention`,value:String(p.value.length),tone:p.value.length>0?`danger`:`ok`,hint:p.value.length===0?`nothing is broken`:`crashed or unhealthy`},null,8,[`value`,`tone`,`hint`])]),B(`div`,tB,[V(Uz,{label:`Process memory`,value:M(SI)(m.value),hint:h.value>0?`peak ${M(SI)(h.value)}`:`across the tree`},null,8,[`value`,`hint`])]),B(`div`,nB,[V(Uz,{label:`Panel uptime`,value:g.value,hint:M(c).status.value===`degraded`?`degraded`:`serving`},null,8,[`value`,`hint`])]),B(`div`,rB,[V(Uz,{label:`Host uptime`,value:_.value,hint:M(n)?.enabled?`${v.value.toFixed(1)}% cpu now`:`sampling off`},null,8,[`value`,`hint`])])]))]),_:1}),p.value.length>0?(L(),R(`div`,iB,[V(M(zv),{class:`mt-0.5 size-4 shrink-0 text-danger`}),B(`div`,aB,[B(`p`,oB,k(p.value.length)+` server`+k(p.value.length===1?``:`s`)+` need a look `,1),B(`p`,sB,[(L(!0),R(I,null,va(p.value,e=>(L(),z(b,{key:e.id,to:`/servers/${e.id}`,class:`font-mono underline-offset-2 hover:underline`},{default:N(()=>[H(k(e.id),1)]),_:2},1032,[`to`]))),128))])])])):U(``,!0),B(`section`,cB,[B(`div`,lB,[B(`h2`,uB,[V(M(by),{class:`size-3.5 text-faint`}),y[8]||=H(` Servers `,-1)]),V(b,{to:`/servers`,class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:N(()=>[...y[9]||=[H(` Open the full list `,-1)]]),_:1})]),u.value?(L(),R(`div`,dB,[(L(),R(I,null,va(4,e=>V(uL,{key:e,class:`h-64 w-full`,rounded:`rounded-panel`})),64))])):M(t).length===0?(L(),z(QI,{key:1,title:`No servers yet`,description:`Add the first process this panel should keep alive.`},{icon:N(()=>[V(M(by),{class:`size-4`})]),action:N(()=>[V($,{variant:`primary`,onClick:y[3]||=e=>l.value=!0},{default:N(()=>[V(M(py),{class:`size-3.5`}),y[10]||=H(`Add a server `,-1)]),_:1})]),_:1})):(L(),R(`div`,fB,[(L(!0),R(I,null,va(M(t),e=>(L(),z(Oz,{key:e.id,server:e,series:M(a)(e.id),now:M(r)},null,8,[`server`,`series`,`now`]))),128))]))]),B(`div`,pB,[V(zz,{class:`lg:col-span-2`},{header:N(()=>[B(`h2`,mB,[V(M(Kv),{class:`size-3.5 text-faint`}),y[11]||=H(` Host vitals `,-1)])]),default:N(()=>[V(XL,{host:M(n),now:M(r)},null,8,[`host`,`now`])]),_:1}),V(zz,null,{header:N(()=>[B(`h2`,hB,[V(M(jv),{class:`size-3.5 text-faint`}),y[12]||=H(` Recent activity `,-1)])]),actions:N(()=>[V(b,{to:`/logs`,class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:N(()=>[...y[13]||=[H(` Logs `,-1)]]),_:1})]),default:N(()=>[V(iR,{servers:M(t),now:M(r),limit:10},null,8,[`servers`,`now`])]),_:1})]),B(`p`,gB,[B(`span`,_B,[V(M(ky),{class:`size-3`}),y[14]||=H(`resource history is sampled every 5 s and kept for this session`,-1)]),B(`span`,vB,k(M(i)?.control.url),1),B(`span`,{class:O(M(Q)(`flex items-center gap-1`,M(c).status.value===`degraded`&&`text-danger`))},[B(`span`,{class:O(M(Q)(`size-1.5 rounded-full`,M(c).status.value===`degraded`?`bg-danger`:`bg-ok`))},null,2),H(` panel `+k(M(c).status.value),1)],2)]),V(jR,{open:l.value,"onUpdate:open":y[4]||=e=>l.value=e},null,8,[`open`])])}}}),bB=[`restart`,`health`,`stop`];function xB(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function SB(e,t,n=[]){let r={};for(let[i,a]of Object.entries(t)){if(n.includes(i)){let t=e[i]??{},n={};for(let[e,r]of Object.entries(a??{}))t[e]!==r&&(n[e]=r);Object.keys(n).length>0&&(r[i]=n);continue}xB(e[i],a)||(r[i]=a)}return r}function CB(e,t){let n=e;return SB({...n,label:n.label??``},t,bB)}var wB=[`disabled`],TB={class:`min-w-0`},EB={class:`text-ink`},DB=P({__name:`CheckField`,props:za({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1},wide:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`);return(e,r)=>(L(),R(`label`,{class:O(M(Q)(`flex cursor-pointer select-none items-start gap-2 rounded-control px-2 py-1.5 text-xs transition-colors duration-150`,`hover:bg-hover`,t.disabled&&`cursor-not-allowed opacity-50 hover:bg-transparent`,t.wide&&`sm:col-span-2`))},[br(B(`input`,{"onUpdate:modelValue":r[0]||=e=>n.value=e,type:`checkbox`,disabled:t.disabled,class:`mt-0.5 size-3.5 shrink-0 cursor-pointer appearance-none rounded-[4px] border border-line bg-page checked:border-accent checked:bg-accent checked:bg-[length:9px] checked:bg-center checked:bg-no-repeat checked:[background-image:url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22white%22 stroke-width=%224%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22M20 6 9 17l-5-5%22/></svg>')] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:cursor-not-allowed`},null,8,wB),[[Yl,n.value]]),B(`span`,TB,[B(`span`,EB,k(t.label),1),t.hint?(L(),R(`span`,{key:0,class:O([`mt-0.5 block`,[M(mF)]])},k(t.hint),3)):U(``,!0),F(e.$slots,`default`)])],2))}}),OB=P({__name:`LifecycleFields`,props:za({showHttp:{type:Boolean,default:!0}},{restart:{required:!0},restartModifiers:{},health:{required:!0},healthModifiers:{},stop:{required:!0},stopModifiers:{}}),emits:[`update:restart`,`update:health`,`update:stop`],setup(e){let t=so(e,`restart`),n=so(e,`health`),r=so(e,`stop`);function i(e,t,n=0){return W({get:e,set:e=>t(e??n)})}let a=i(()=>t.value.maxRetries,e=>t.value.maxRetries=e),o=i(()=>t.value.baseDelayMs,e=>t.value.baseDelayMs=e),s=i(()=>t.value.factor,e=>t.value.factor=e,1),c=i(()=>t.value.maxDelayMs,e=>t.value.maxDelayMs=e),l=i(()=>t.value.resetAfterMs,e=>t.value.resetAfterMs=e),u=i(()=>n.value.intervalMs,e=>n.value.intervalMs=e,500),d=i(()=>n.value.timeoutMs,e=>n.value.timeoutMs=e,100),f=i(()=>n.value.unhealthyThreshold,e=>n.value.unhealthyThreshold=e,1),p=i(()=>n.value.forceRestartAfterMs,e=>n.value.forceRestartAfterMs=e),m=i(()=>n.value.startTimeoutMs,e=>n.value.startTimeoutMs=e),h=W({get:()=>n.value.http.expectStatus??null,set:e=>{e===null||Number.isNaN(e)?delete n.value.http.expectStatus:n.value.http.expectStatus=e}}),g=i(()=>n.value.http.expectStatusBelow,e=>n.value.http.expectStatusBelow=e,400),_=i(()=>r.value.graceMs,e=>r.value.graceMs=e),v=[{value:`SIGTERM`,label:`SIGTERM — ask it to stop`},{value:`SIGINT`,label:`SIGINT — interrupt (Ctrl-C)`},{value:`SIGKILL`,label:`SIGKILL — kill immediately`}];return(i,y)=>(L(),R(I,null,[V(uR,{title:`Restart policy`,description:`Backoff between attempts after a crash.`,columns:3},{default:N(()=>[V(DB,{modelValue:t.value.enabled,"onUpdate:modelValue":y[0]||=e=>t.value.enabled=e,label:`Restart on crash`,wide:``},null,8,[`modelValue`]),V(mR,{modelValue:M(a),"onUpdate:modelValue":y[1]||=e=>A(a)?a.value=e:null,label:`Max retries`,min:0,hint:`Attempts before the server is left crashed.`},null,8,[`modelValue`]),V(mR,{modelValue:M(o),"onUpdate:modelValue":y[2]||=e=>A(o)?o.value=e:null,label:`Base delay (ms)`,min:0},null,8,[`modelValue`]),V(mR,{modelValue:M(s),"onUpdate:modelValue":y[3]||=e=>A(s)?s.value=e:null,label:`Backoff factor`,min:1,step:.1},null,8,[`modelValue`]),V(mR,{modelValue:M(c),"onUpdate:modelValue":y[4]||=e=>A(c)?c.value=e:null,label:`Max delay (ms)`,min:0},null,8,[`modelValue`]),V(mR,{modelValue:M(l),"onUpdate:modelValue":y[5]||=e=>A(l)?l.value=e:null,label:`Reset after (ms)`,min:0,hint:`A run this long clears the retry counter.`},null,8,[`modelValue`])]),_:1}),V(uR,{title:`Health check`,description:`How readiness is probed once the process is up.`,columns:3},{default:N(()=>[V(DB,{modelValue:n.value.enabled,"onUpdate:modelValue":y[6]||=e=>n.value.enabled=e,label:`Probe this server`,wide:``},null,8,[`modelValue`]),V(lL,{modelValue:n.value.mode,"onUpdate:modelValue":y[7]||=e=>n.value.mode=e,label:`Probe type`,options:[{value:`port`,label:`TCP port — connection only`},{value:`http`,label:`HTTP request — assert a response`}]},null,8,[`modelValue`]),V(mR,{modelValue:M(u),"onUpdate:modelValue":y[8]||=e=>A(u)?u.value=e:null,label:`Interval (ms)`,min:500,step:100},null,8,[`modelValue`]),V(mR,{modelValue:M(d),"onUpdate:modelValue":y[9]||=e=>A(d)?d.value=e:null,label:`Timeout (ms)`,min:100,step:100},null,8,[`modelValue`]),V(mR,{modelValue:M(f),"onUpdate:modelValue":y[10]||=e=>A(f)?f.value=e:null,label:`Unhealthy after`,min:1,hint:`Consecutive failed probes.`},null,8,[`modelValue`]),V(mR,{modelValue:M(p),"onUpdate:modelValue":y[11]||=e=>A(p)?p.value=e:null,label:`Force restart after (ms)`,min:0,hint:`0 disables it.`},null,8,[`modelValue`]),V(mR,{modelValue:M(m),"onUpdate:modelValue":y[12]||=e=>A(m)?m.value=e:null,label:`Start timeout (ms)`,min:0},null,8,[`modelValue`]),e.showHttp&&n.value.mode===`http`?(L(),R(I,{key:0},[V(CR,{modelValue:n.value.http.path,"onUpdate:modelValue":y[13]||=e=>n.value.http.path=e,label:`HTTP path`,placeholder:`/healthz`},null,8,[`modelValue`]),V(lL,{modelValue:n.value.http.method,"onUpdate:modelValue":y[14]||=e=>n.value.http.method=e,label:`HTTP method`,options:[{value:`GET`,label:`GET`},{value:`HEAD`,label:`HEAD`}]},null,8,[`modelValue`]),V(mR,{modelValue:h.value,"onUpdate:modelValue":y[15]||=e=>h.value=e,label:`Expect status`,nullable:``,hint:`Blank accepts anything below.`},null,8,[`modelValue`]),V(mR,{modelValue:M(g),"onUpdate:modelValue":y[16]||=e=>A(g)?g.value=e:null,label:`Healthy below status`,min:100},null,8,[`modelValue`]),V(CR,{modelValue:n.value.http.expectBody,"onUpdate:modelValue":y[17]||=e=>n.value.http.expectBody=e,label:`Body must contain`,placeholder:`optional substring`,wide:``},null,8,[`modelValue`])],64)):U(``,!0)]),_:1}),V(uR,{title:`Stop behaviour`,description:`How the process tree is asked to go away.`,columns:3},{default:N(()=>[V(lL,{modelValue:r.value.signal,"onUpdate:modelValue":y[18]||=e=>r.value.signal=e,label:`Signal`,options:v},null,8,[`modelValue`]),V(mR,{modelValue:M(_),"onUpdate:modelValue":y[19]||=e=>A(_)?_.value=e:null,label:`Grace period (ms)`,min:0},null,8,[`modelValue`]),V(DB,{modelValue:r.value.killGroup,"onUpdate:modelValue":y[20]||=e=>r.value.killGroup=e,label:`Kill the whole process group`},null,8,[`modelValue`]),V(DB,{modelValue:r.value.killPortHolders,"onUpdate:modelValue":y[21]||=e=>r.value.killPortHolders=e,label:`Also kill whatever holds the port`,wide:``},null,8,[`modelValue`])]),_:1})],64))}}),kB={class:`mb-4 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`},AB={class:`flex items-center gap-2`},jB={key:0,class:`text-2xs text-warn`},MB={key:1,class:`text-2xs text-faint`},NB={class:`flex flex-col gap-3`},PB={key:0,class:`mt-3 rounded-control border border-danger/40 bg-danger-soft px-2.5 py-1.5 font-mono text-2xs leading-4 text-danger`},FB={class:`mt-4 flex items-center justify-end gap-2 border-t border-line pt-3.5`},IB=[`disabled`],LB=P({__name:`ServerConfigEditor`,props:{serverId:{},config:{}},emits:[`saved`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=[`restart`,`health`,`stop`],a=wM(),o=j(!1),s=j(null);function c(e){return e.split(`
39
+ fn("string", ":", "number")(s => s.length)`,mD=class extends Nb{$;constructor(e){super((...t)=>new hD(e)(...t),{bind:e}),this.$=e}in(e){return new hD(this.$,e===void 0?void 0:this.$.parse(e))}at(e,t){return new hD(this.$).at(e,t)}case(e,t){return new hD(this.$).case(e,t)}},hD=class extends Nb{$;in;key;branches=[];constructor(e,t){super(e=>this.caseEntries(Object.entries(e).map(([e,t])=>e==="default"?[e,t]:[this.$.parse(e),t]))),this.$=e,this.in=t}at(e,t){return this.key&&K(vD),this.branches.length&&K(_D),this.key=e,t?this.match(t):this}case(e,t){return this.caseEntry(this.$.parse(e),t)}caseEntry(e,t){let n=(this.key?this.$.parse({[this.key]:e}):e).pipe(t);return this.branches.push(n),this}match(e){return this(e)}strings(e){return this.caseEntries(Object.entries(e).map(([e,t])=>e==="default"?[e,t]:[this.$.node(`unit`,{unit:e}),t]))}caseEntries(e){for(let t=0;t<e.length;t++){let[n,r]=e[t];if(n==="default")return t!==e.length-1&&K(`default may only be specified as the last key of a switch definition`),this.default(r);if(typeof r!=`function`)return K(`Value for case "${n}" must be a function (was ${Gy(r)})`);this.caseEntry(n,r)}return this}default(e){typeof e==`function`&&this.case(eE.unknown,e);let t={branches:this.branches,ordered:!0};(e===`never`||e===`assert`)&&(t.meta={onFail:gD});let n=this.$.node(`union`,t);if(!this.in)return this.$.finalize(n);let r=this.in.pipe(n);return(e===`never`||e===`assert`)&&(r=r.configureReferences({onFail:gD},`self`)),this.$.finalize(r)}},gD=e=>e.throw(),_D=`A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')`,vD=`At most one key matcher may be specified per expression`,yD=(e,t)=>{if(xb(e)){if(e[1]===`=`)return[t.$.parseOwnDefinitionFormat(e[0],t),`=`,e[2]];if(e[1]===`?`)return[t.$.parseOwnDefinitionFormat(e[0],t),`?`]}return nO(e,t)},bD=`Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }`,xD=`Only required keys may specify default values, e.g. { value: 'number = 0' }`,SD=(e,t)=>{let n,r={},i=lb(e);for(let[e,a]of i){let i=ED(e);if(i.kind===`spread`){if(!cb(r))return K(TD);let e=t.$.parseOwnDefinitionFormat(a,t);if(e.equals(eE.object))continue;if(!e.hasKind(`intersection`)||!e.basis?.equals(eE.object))return K(DD(e.expression));n=e.structure;continue}if(i.kind===`undeclared`){a!==`reject`&&a!==`delete`&&a!==`ignore`&&K(wD(a)),r.undeclared=a;continue}let o=yD(a,t),s=i;if(i.kind===`required`){xb(o)?CD(r,`optional`,o[1]===`=`?{key:i.normalized,value:o[0],default:o[2]}:{key:i.normalized,value:o[0]},t):CD(r,`required`,{key:i.normalized,value:o},t);continue}if(xb(o)&&(o[1]===`?`&&K(bD),o[1]===`=`&&K(xD)),i.kind===`optional`){CD(r,`optional`,{key:i.normalized,value:o},t);continue}let c=yT(t.$.parseOwnDefinitionFormat(s.normalized,t),o,t.$);c.index&&(r.index=Ry(r.index,c.index)),c.required&&(r.required=Ry(r.required,c.required))}let a=t.$.node(`structure`,r);return t.$.parseSchema({domain:`object`,structure:n?.merge(a)??a})},CD=(e,t,n,r)=>{e[t]=Ry(e[t],r.$.node(t,n))},wD=e=>`Value of '+' key must be 'reject', 'delete', or 'ignore' (was ${xx(e)})`,TD=`Spread operator may only be used as the first key in an object`,ED=e=>typeof e==`symbol`?{kind:`required`,normalized:e}:e[e.length-1]===`?`?e[e.length-2]===`\\`?{kind:`required`,normalized:`${e.slice(0,-2)}?`}:{kind:`optional`,normalized:e.slice(0,-1)}:e[0]===`[`&&e[e.length-1]===`]`?{kind:`index`,normalized:e.slice(1,-1)}:e[0]===`\\`&&e[1]===`[`&&e[e.length-1]===`]`?{kind:`required`,normalized:e.slice(1)}:e===`...`?{kind:`spread`}:e===`+`?{kind:`undeclared`}:{kind:`required`,normalized:e===`\\...`?`...`:e===`\\+`?`+`:e},DD=e=>`Spread operand must resolve to an object literal type (was ${e})`,OD=(e,t)=>HD(e)?VD[e[0]](e,t):BD(e)?zD[e[1]](e,t):null,kD=(e,t)=>t.$.parseOwnDefinitionFormat(e[1],t).keyof(),AD=(e,t)=>{if(e[2]===void 0)return K(ME(e[1],``));let n=t.$.parseOwnDefinitionFormat(e[0],t),r=t.$.parseOwnDefinitionFormat(e[2],t);if(e[1]===`|`)return t.$.node(`union`,{branches:[n,r]});let i=e[1]===`&`?zS(n,r,t.$):BS(n,r,t.$);return i instanceof J?i.throw():i},jD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).array(),MD=(e,t)=>typeof e[2]==`function`?t.$.parseOwnDefinitionFormat(e[0],t).pipe(e[2]):K(ND(`=>`,e[2])),ND=(e,t)=>`${e===`:`?`Narrow`:`Morph`} expression requires a function following '${e}' (was ${typeof t})`,PD=(e,t)=>typeof e[2]==`function`?t.$.parseOwnDefinitionFormat(e[0],t).constrain(`predicate`,e[2]):K(ND(`:`,e[2])),FD=(e,t)=>t.$.parseOwnDefinitionFormat(e[0],t).configure(e[2],e[3]),ID=e=>e,LD=ID({"[]":jD,"?":()=>K(yE)}),RD=ID({"|":AD,"&":AD,":":PD,"=>":MD,"|>":AD,"@":FD,"=":()=>K(bE)}),zD={...LD,...RD},BD=e=>zD[e[1]]!==void 0,VD=(e=>e)({keyof:kD,instanceof:(e,t)=>{if(typeof e[1]!=`function`)return K(UD(bb(e[1])));let n=e.slice(1).map(e=>typeof e==`function`?t.$.node(`proto`,{proto:e}):K(UD(bb(e))));return n.length===1?n[0]:t.$.node(`union`,{branches:n})},"===":(e,t)=>t.$.units(e.slice(1))}),HD=e=>VD[e[0]]!==void 0,UD=e=>`Expected a constructor following 'instanceof' operator (was ${e})`,WD=(e,t)=>{let n=[{}],r=0;for(;r<e.length;){let i=!1;e[r]===`...`&&r<e.length-1&&(i=!0,r++);let a=yD(e[r],t),[o,s,c]=xb(a)?a:[a];if(r++,i){if(!o.extends(q.intrinsic.Array))return K(XD(o.expression));n=n.flatMap(e=>o.distribute(t=>YD(Kx(e),t)))}else n=n.map(e=>s===`?`?KD(e,o):s===`=`?qD(e,o,c):GD(e,o))}return t.$.parseSchema(n.map(e=>cb(e)?{proto:Array,exactLength:0}:{proto:Array,sequence:e}))},GD=(e,t)=>e.defaultables||e.optionals?K(e.variadic?nT:QD):(e.variadic?e.postfix=Ry(e.postfix,t):e.prefix=Ry(e.prefix,t),e),KD=(e,t)=>e.variadic?K($D):(e.optionals=Ry(e.optionals,t),e),qD=(e,t,n)=>e.variadic?K($D):e.optionals?K(eO):(e.defaultables=Ry(e.defaultables,[[t,n]]),e),JD=(e,t)=>(e.postfix&&K(ZD),e.variadic?e.variadic.equals(t)||K(ZD):e.variadic=t.internal,e),YD=(e,t)=>{let n=t.select({method:`find`,kind:`sequence`});if(!n)return JD(e,q.intrinsic.unknown);if(n.prefix)for(let t of n.prefix)GD(e,t);if(n.optionals)for(let t of n.optionals)KD(e,t);if(n.variadic&&JD(e,n.variadic),n.postfix)for(let t of n.postfix)GD(e,t);return e},XD=e=>`Spread element must be an array (was ${e})`,ZD=`A tuple may have at most one variadic element`,QD=`A required element may not follow an optional element`,$D=`An optional element may not follow a variadic element`,eO=`A defaultable element may not follow an optional element without a default`,tO={},nO=(e,t)=>{if(typeof e==`string`){if(t.args&&Object.keys(t.args).some(t=>e.includes(t)))return nD(e,t);let n=tO[t.$.name]??={};return n[e]??=nD(e,t)}return Wy(e,`object`)?rO(e,t):K(oO(Gy(e)))},rO=(e,t)=>{let n=yb(e);switch(n){case void 0:return Jx(e,`root`)?e:`~standard`in e?iO(e,t):SD(e,t);case`Array`:return aO(e,t);case`RegExp`:return t.$.node(`intersection`,{domain:`string`,pattern:e},{prereduced:!0});case`Function`:{let t=jb(e)?e():e;return Jx(t,`root`)?t:K(oO(`Function`))}default:return K(oO(n??xx(e)))}},iO=(e,t)=>t.$.intrinsic.unknown.pipe((t,n)=>{let r=e[`~standard`].validate(t);if(!r.issues)return r.value;for(let{message:e,path:t}of r.issues)t&&t.length?n.error({problem:Rb(e),relativePath:t.map(e=>typeof e==`object`?e.key:e)}):n.error({message:e})}),aO=(e,t)=>OD(e,t)??WD(e,t),oO=e=>`Type definitions must be strings or objects (was ${e})`,sO=class extends Nb{constructor(e){let t=Object.assign({errors:bS,hkt:Fb,$:e,raw:e.parse,module:e.constructor.module,scope:e.constructor.scope,declare:e.declare,define:e.define,match:e.match,generic:e.generic,schema:e.schema,keywords:e.ambient,unit:e.unit,enumerated:e.enumerated,instanceOf:e.instanceOf,valueOf:e.valueOf,or:e.or,and:e.and,merge:e.merge,pipe:e.pipe,fn:e.fn},e.ambientAttachments);super((...t)=>{if(t.length===1)return e.parse(t[0]);if(t.length===2&&typeof t[0]==`string`&&t[0][0]===`<`&&t[0][t[0].length-1]===`>`){let n=t[0].slice(1,-1);return new nC(e.parseGenericParams(n,{}),t[1],e,e,null)}return e.parse(t)},{attach:t})}},cO=q,lO=class e extends IT{get ambientAttachments(){if(cO.typeAttachments)return this.cacheGetter(`ambientAttachments`,$y(cO.typeAttachments,(e,t)=>[e,this.bindReference(t)]))}preparseOwnAliasEntry(e,t){let n=e.indexOf(`<`);if(n===-1){if(Jx(t,`module`)||Jx(t,`generic`))return[e,t];let n=this.name===`ark`?e:e===`root`?this.name:`${this.name}.${e}`,r=this.resolvedConfig.keywords?.[n];return r&&(t=[t,`@`,r]),[e,t]}e[e.length-1]!==`>`&&K(`'>' must be the last character of a generic declaration in a scope`);let r=e.slice(0,n),i=e.slice(n+1,-1);return[r,()=>eC(this.parseGenericParams(i,{alias:r}),t,this)]}parseGenericParams(e,t){return cD(new Mx(e),[],this.createParseContext({...t,def:e,prefix:`generic`}))}normalizeRootScopeValue(e){return jb(e)&&!Jx(e,`generic`)?e():e}preparseOwnDefinitionFormat(e,t){return{...t,def:e,prefix:t.alias??`type`}}parseOwnDefinitionFormat(e,t){!(t.alias&&t.alias in this.aliases)&&!t.args&&(t.args={this:t.id});let n=nO(e,t);if(xb(n)){if(n[1]===`=`)return K(bE);if(n[1]===`?`)return K(yE)}return n}unit=e=>this.units([e]);valueOf=e=>this.units(pb(e));enumerated=(...e)=>this.units(e);instanceOf=e=>this.node(`proto`,{proto:e},{prereduced:!0});or=(...e)=>this.schema(e.map(e=>this.parse(e)));and=(...e)=>e.reduce((e,t)=>e.and(this.parse(t)),this.intrinsic.unknown);merge=(...e)=>e.reduce((e,t)=>e.merge(this.parse(t)),this.intrinsic.object);pipe=(...e)=>this.intrinsic.unknown.pipe(...e);fn=new dD(this);match=new mD(this);declare=()=>({type:this.type});define(e){return e}type=new sO(this);static scope=((t,n={})=>new e(t,n));static module=((e,t={})=>this.scope(e,t).export())},uO=Object.assign(lO.scope,{define:e=>e}),dO=lO,fO=class extends Fb{description='merge an object\'s properties onto another like `Merge(User, { isAdmin: "true" })`'},pO=YT([`base`,eE.object],[`props`,eE.object])(e=>e.base.merge(e.props),fO),mO=dO.module({Key:eE.key,Merge:pO}),hO=class extends Fb{},gO=YT(`element`)(e=>{let t=e.element.exclude(eE.Array),n=t.array();return t.rawOr(n).pipe(Ny).distribute(e=>e.assertHasKind(`morph`).declareOut(n),qT)},hO),_O=dO.module({root:eE.Array,readonly:`root`,index:eE.nonNegativeIntegerString,liftFrom:gO},{name:`Array`}),vO=qT([`string`,px.FileConstructor]),yO=qT({meta:`an object representing parsed form data`,domain:`object`,index:{signature:`string`,value:vO.rawOr(vO.array())}}),bO=dO.module({root:[`instanceof`,FormData],value:vO,parsed:yO,parse:qT({in:FormData,morphs:e=>{let t={};for(let[n,r]of e)if(n in t){let e=t[n];typeof e==`string`||e instanceof px.FileConstructor?t[n]=[e,r]:e.push(r)}else t[n]=r;return t},declaredOut:yO})},{name:`FormData`}),xO=dO.module({Int8:[`instanceof`,Int8Array],Uint8:[`instanceof`,Uint8Array],Uint8Clamped:[`instanceof`,Uint8ClampedArray],Int16:[`instanceof`,Int16Array],Uint16:[`instanceof`,Uint16Array],Int32:[`instanceof`,Int32Array],Uint32:[`instanceof`,Uint32Array],Float32:[`instanceof`,Float32Array],Float64:[`instanceof`,Float64Array],BigInt64:[`instanceof`,BigInt64Array],BigUint64:[`instanceof`,BigUint64Array]},{name:`TypedArray`}),SO={Boolean:1,Number:1,String:1},CO=dO.module({...$y({...mb,...gb},(e,t)=>e in SO?[]:[e,[`instanceof`,t]]),Array:_O,TypedArray:xO,FormData:bO}),wO=qT({domain:{domain:`number`,meta:`a number representing a Unix timestamp`},divisor:{rule:1,meta:`an integer representing a Unix timestamp`},min:{rule:-864e13,meta:`a Unix timestamp after -8640000000000000`},max:{rule:864e13,meta:`a Unix timestamp before 8640000000000000`},meta:`an integer representing a safe Unix timestamp`}),TO=qT({domain:`number`,divisor:1}),EO=dO.module({root:eE.number,integer:TO,epoch:wO,safe:qT({domain:{domain:`number`,numberAllowsNaN:!1},min:-(2**53-1),max:2**53-1}),NaN:[`===`,NaN],Infinity:[`===`,1/0],NegativeInfinity:[`===`,-1/0]},{name:`number`}),DO=(e,t,n)=>{let r={domain:`string`,pattern:{rule:e.source,flags:e.flags,meta:t}};return n&&(r.meta={format:n}),JT(`intersection`,r)},OO=DO($b,`a well-formed integer string`),kO=dO.module({root:OO,parse:qT({in:OO,morphs:(e,t)=>{let n=Number.parseInt(e);return Number.isSafeInteger(n)?n:t.error(`an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER`)},declaredOut:eE.integer})},{name:`string.integer`}),AO=DO(/^[\dA-Fa-f]+$/,`hex characters only`),jO=dO.module({root:DO(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/,`base64-encoded`),url:DO(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/,`base64url-encoded`)},{name:`string.base64`}),MO=DO(/^[A-Z].*$/,`capitalized`),NO=dO.module({root:qT({in:`string`,morphs:e=>e.charAt(0).toUpperCase()+e.slice(1),declaredOut:MO}),preformatted:MO},{name:`string.capitalize`}),PO=qT({domain:`string`,pattern:{meta:`a credit card number`,rule:`^(?:4\\d{12}(?:\\d{3,6})?|5[1-5]\\d{14}|(222[1-9]|22[3-9]\\d|2[3-6]\\d{2}|27[01]\\d|2720)\\d{12}|6(?:011|5\\d\\d)\\d{12,15}|3[47]\\d{13}|3(?:0[0-5]|[68]\\d)\\d{11}|(?:2131|1800|35\\d{3})\\d{11}|6[27]\\d{14}|^(81\\d{14,17}))$`},predicate:{meta:`a credit card number`,predicate:e=>{let t=e.replace(/[ -]+/g,``),n=0,r,i,a=!1;for(let e=t.length-1;e>=0;e--)r=t.substring(e,e+1),i=Number.parseInt(r,10),a?(i*=2,n+=i>=10?i%10+1:i):n+=i,a=!a;return!!(n%10==0&&t)}}}),FO=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))(T((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([,.]\d+(?!:))?)?(\17[0-5]\d([,.]\d+)?)?([Zz]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,IO=qT({domain:`string`,predicate:{meta:`a parsable date`,predicate:e=>!Number.isNaN(new Date(e).valueOf())}}).assertHasKind(`intersection`),LO=kO.root.internal.narrow((e,t)=>{let n=Number.parseInt(e),r=EO.epoch(n);return r instanceof bS?(t.errors.merge(r),!1):!0}).configure({description:`an integer string representing a safe Unix timestamp`},`self`).assertHasKind(`intersection`),RO=dO.module({root:LO,parse:qT({in:LO,morphs:e=>new Date(e),declaredOut:eE.Date})},{name:`string.date.epoch`}),zO=DO(FO,`an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date`).internal.assertHasKind(`intersection`),BO=dO.module({root:zO,parse:qT({in:zO,morphs:e=>new Date(e),declaredOut:eE.Date})},{name:`string.date.iso`}),VO=dO.module({root:IO,parse:qT({declaredIn:IO,in:`string`,morphs:(e,t)=>{let n=new Date(e);return Number.isNaN(n.valueOf())?t.error(`a parsable date`):n},declaredOut:eE.Date}),iso:BO,epoch:RO},{name:`string.date`}),HO=DO(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/,`an email address`,`email`),UO=`(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])`,WO=`(${UO}[.]){3}${UO}`,GO=RegExp(`^${WO}$`),KO=`(?:[0-9a-fA-F]{1,4})`,qO=RegExp(`^((?:${KO}:){7}(?:${KO}|:)|(?:${KO}:){6}(?:${WO}|:${KO}|:)|(?:${KO}:){5}(?::${WO}|(:${KO}){1,2}|:)|(?:${KO}:){4}(?:(:${KO}){0,1}:${WO}|(:${KO}){1,3}|:)|(?:${KO}:){3}(?:(:${KO}){0,2}:${WO}|(:${KO}){1,4}|:)|(?:${KO}:){2}(?:(:${KO}){0,3}:${WO}|(:${KO}){1,5}|:)|(?:${KO}:){1}(?:(:${KO}){0,4}:${WO}|(:${KO}){1,6}|:)|(?::((?::${KO}){0,5}:${WO}|(?::${KO}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?\$`),JO=dO.module({root:[`v4 | v6`,`@`,`an IP address`],v4:DO(GO,`an IPv4 address`,`ipv4`),v6:DO(qO,`an IPv6 address`,`ipv6`)},{name:`string.ip`}),YO=`a JSON string`,XO=e=>{if(!(e instanceof SyntaxError))throw e;return`must be ${YO} (${e})`},ZO=qT({meta:YO,domain:`string`,predicate:{meta:YO,predicate:(e,t)=>{try{return JSON.parse(e),!0}catch(e){return t.reject({code:`predicate`,expected:YO,problem:XO(e)})}}}}),QO=dO.module({root:ZO,parse:qT({meta:`safe JSON string parser`,in:`string`,morphs:(e,t)=>{if(e.length===0)return t.error({code:`predicate`,expected:YO,actual:`empty`});try{return JSON.parse(e)}catch(e){return t.error({code:`predicate`,expected:YO,problem:XO(e)})}},declaredOut:eE.jsonObject})},{name:`string.json`}),$O=DO(/^[a-z]*$/,`only lowercase letters`),ek=dO.module({root:qT({in:`string`,morphs:e=>e.toLowerCase(),declaredOut:$O}),preformatted:$O},{name:`string.lower`}),tk=[`NFC`,`NFD`,`NFKC`,`NFKD`],nk=$y(tk,(e,t)=>[t,qT({domain:`string`,predicate:e=>e.normalize(t)===e,meta:`${t}-normalized unicode`})]),rk=$y(tk,(e,t)=>[t,qT({in:`string`,morphs:e=>e.normalize(t),declaredOut:nk[t]})]),ik=dO.module({root:rk.NFC,preformatted:nk.NFC},{name:`string.normalize.NFC`}),ak=dO.module({root:rk.NFD,preformatted:nk.NFD},{name:`string.normalize.NFD`}),ok=dO.module({root:rk.NFKC,preformatted:nk.NFKC},{name:`string.normalize.NFKC`}),sk=dO.module({root:rk.NFKD,preformatted:nk.NFKD},{name:`string.normalize.NFKD`}),ck=dO.module({root:`NFC`,NFC:ik,NFD:ak,NFKC:ok,NFKD:sk},{name:`string.normalize`}),lk=DO(Xb,`a well-formed numeric string`),uk=dO.module({root:lk,parse:qT({in:lk,morphs:e=>Number.parseFloat(e),declaredOut:eE.number})},{name:`string.numeric`}),dk=`a regex pattern`,fk=qT({domain:`string`,predicate:{meta:dk,predicate:(e,t)=>{try{return new RegExp(e),!0}catch(e){return t.reject({code:`predicate`,expected:dk,problem:String(e)})}}},meta:{format:`regex`}}),pk=DO(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][\dA-Za-z-]*))*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?$/,`a semantic version (see https://semver.org/)`),mk=DO(/^\S.*\S$|^\S?$/,`trimmed`),hk=dO.module({root:qT({in:`string`,morphs:e=>e.trim(),declaredOut:mk}),preformatted:mk},{name:`string.trim`}),gk=DO(/^[A-Z]*$/,`only uppercase letters`),_k=dO.module({root:qT({in:`string`,morphs:e=>e.toUpperCase(),declaredOut:gk}),preformatted:gk},{name:`string.upper`}),vk=qT({domain:`string`,predicate:{meta:`a URL string`,predicate:e=>URL.canParse(e)},meta:{format:`uri`}}),yk=dO.module({root:vk,parse:qT({declaredIn:vk,in:`string`,morphs:(e,t)=>{try{return new URL(e)}catch{return t.error(`a URL string`)}},declaredOut:qT(URL)})},{name:`string.url`}),bk=dO.module({root:[`versioned | nil | max`,`@`,{description:`a UUID`,format:`uuid`}],"#nil":`'00000000-0000-0000-0000-000000000000'`,"#max":`'ffffffff-ffff-ffff-ffff-ffffffffffff'`,"#versioned":/^[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,v1:DO(/^[\da-f]{8}-[\da-f]{4}-1[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv1`),v2:DO(/^[\da-f]{8}-[\da-f]{4}-2[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv2`),v3:DO(/^[\da-f]{8}-[\da-f]{4}-3[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv3`),v4:DO(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv4`),v5:DO(/^[\da-f]{8}-[\da-f]{4}-5[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv5`),v6:DO(/^[\da-f]{8}-[\da-f]{4}-6[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv6`),v7:DO(/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv7`),v8:DO(/^[\da-f]{8}-[\da-f]{4}-8[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,`a UUIDv8`)},{name:`string.uuid`}),xk=dO.module({root:eE.string,alpha:DO(/^[A-Za-z]*$/,`only letters`),alphanumeric:DO(/^[\dA-Za-z]*$/,`only letters and digits 0-9`),hex:AO,base64:jO,capitalize:NO,creditCard:PO,date:VO,digits:DO(/^\d*$/,`only digits 0-9`),email:HO,integer:kO,ip:JO,json:QO,lower:ek,normalize:ck,numeric:uk,regex:fk,semver:pk,trim:hk,upper:_k,url:yk,uuid:bk},{name:`string`}),Sk=dO.module({bigint:eE.bigint,boolean:eE.boolean,false:eE.false,never:eE.never,null:eE.null,number:eE.number,object:eE.object,string:eE.string,symbol:eE.symbol,true:eE.true,unknown:eE.unknown,undefined:eE.undefined}),Ck=dO.module({root:eE.unknown,any:eE.unknown},{name:`unknown`}),wk=dO.module({root:eE.jsonObject,stringify:JT(`morph`,{in:eE.jsonObject,morphs:e=>JSON.stringify(e),declaredOut:eE.string})},{name:`object.json`}),Tk=dO.module({root:eE.object,json:wk},{name:`object`}),Ek=class extends Fb{description='instantiate an object from an index signature and corresponding value type like `Record("string", "number")`'},Dk=YT([`K`,eE.key],`V`)(e=>({domain:`object`,index:{signature:e.K,value:e.V}}),Ek),Ok=class extends Fb{description='pick a set of properties from an object like `Pick(User, "name | age")`'},kk=YT([`T`,eE.object],[`K`,eE.key])(e=>e.T.pick(e.K),Ok),Ak=class extends Fb{description='omit a set of properties from an object like `Omit(User, "age")`'},jk=YT([`T`,eE.object],[`K`,eE.key])(e=>e.T.omit(e.K),Ak),Mk=class extends Fb{description="make all named properties of an object optional like `Partial(User)`"},Nk=YT([`T`,eE.object])(e=>e.T.partial(),Mk),Pk=class extends Fb{description="make all named properties of an object required like `Required(User)`"},Fk=YT([`T`,eE.object])(e=>e.T.required(),Pk),Ik=class extends Fb{description='exclude branches of a union like `Exclude("boolean", "true")`'},Lk=YT(`T`,`U`)(e=>e.T.exclude(e.U),Ik),Rk=class extends Fb{description='extract branches of a union like `Extract("0 | false | 1", "number")`'},zk=YT(`T`,`U`)(e=>e.T.extract(e.U),Rk),Bk=dO.module({Exclude:Lk,Extract:zk,Omit:jk,Partial:Nk,Pick:kk,Record:Dk,Required:Fk}),Vk=uO({...Sk,...Bk,...CO,...mO,string:xk,number:EO,object:Tk,unknown:Ck},{prereducedAliases:!0,name:`ark`}),Hk=Vk.export();Object.assign(cO.ambient,Hk),cO.typeAttachments={string:Hk.string.root,number:Hk.number.root,bigint:Hk.bigint,boolean:Hk.boolean,symbol:Hk.symbol,undefined:Hk.undefined,null:Hk.null,object:Hk.object.root,unknown:Hk.unknown.root,false:Hk.false,true:Hk.true,never:Hk.never,arrayIndex:Hk.Array.index,Key:Hk.Key,Record:Hk.Record,Array:Hk.Array.root,Date:Hk.Date};var Y=Object.assign(Vk.type,cO.typeAttachments);Vk.match,Vk.fn,Vk.generic,Vk.schema,Vk.define,Vk.declare;var Uk=Y(`"local" | "lan" | /^\\d{1,3}(?:\\.\\d{1,3}){3}$/`);function Wk(e){let t=Uk(e);return t instanceof Y.errors?null:t}var Gk=Y(`1 <= number.integer <= 65535 | null`),Kk=Y({enabled:`boolean = true`,maxRetries:`number.integer >= 0 = 3`,baseDelayMs:`number >= 0 = 1000`,factor:`number >= 1 = 2`,maxDelayMs:`number >= 0 = 30000`,resetAfterMs:`number >= 0 = 60000`}).onUndeclaredKey(`reject`),qk=Y({path:`string = "/"`,method:`"GET" | "HEAD" = "GET"`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer = 400`,expectBody:`string = ""`}).onUndeclaredKey(`reject`),Jk=Y({maxRssBytes:`number.integer >= 0 = 0`}).onUndeclaredKey(`reject`),Yk=Y({enabled:`boolean = true`,mode:`"port" | "http" = "port"`,http:qk.default(()=>({})),intervalMs:`number >= 500 = 5000`,timeoutMs:`number >= 100 = 1500`,unhealthyThreshold:`number.integer >= 1 = 3`,forceRestartAfterMs:`number >= 0 = 0`,startTimeoutMs:`number >= 0 = 20000`}).onUndeclaredKey(`reject`),Xk=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL" = "SIGTERM"`,killGroup:`boolean = true`,graceMs:`number >= 0 = 5000`,killPortHolders:`boolean = false`}).onUndeclaredKey(`reject`),Zk=Y({command:`string`,args:Y(`string[]`).default(()=>[]),env:Y(`Record<string, string>`).default(()=>({})),timeoutMs:`number >= 1000 = 120000`,runOnce:`boolean = true`}).onUndeclaredKey(`reject`).or(Y(`null`)),Qk=Y(`50 <= number.integer <= 100000`),$k=Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,label:`string?`,enabled:`boolean = true`,autostart:`boolean = false`,command:`string >= 1`,args:Y(`string[]`).default(()=>[]),cwd:`string = "."`,env:Y(`Record<string, string>`).default(()=>({})),dataEnvs:Y(`Record<string, string>`).default(()=>({})),bootstrap:Zk.optional(),port:Gk.optional(),bind:Uk.default(()=>`local`),onPortConflict:`"block" | "warn" | "follow" | "reclaim" = "block"`,restart:Kk.default(()=>({})),health:Yk.default(()=>({})),stop:Xk.default(()=>({})),logBufferLines:Qk.default(()=>500),dependsOn:Y(`string[]`).default(()=>[]),envFile:`string = ""`,resources:Jk.default(()=>({})),backupPaths:Y(`string[]`).default(()=>[])}).onUndeclaredKey(`reject`),eA=Y({enabled:`boolean = true`,sessionTtlMs:`number >= 60000 = 604800000`,cookieSecure:`"auto" | "always" | "never" = "auto"`,trustProxy:`boolean = false`,maxLoginAttempts:`number.integer >= 1 = 5`,lockoutMs:`number >= 1000 = 60000`}).onUndeclaredKey(`reject`);Y({telegram:Y({enabled:`boolean = false`,chatId:`string = ""`,onCrash:`boolean = true`,onUnhealthy:`boolean = true`,onForcedRestart:`boolean = true`,onRecovered:`boolean = false`,onHost:`boolean = true`,cooldownMs:`number >= 0 = 120000`}).onUndeclaredKey(`reject`).default(()=>({}))}).onUndeclaredKey(`reject`);var tA=Y({persist:`boolean = true`,maxBytes:`10000 <= number <= 100000000 = 2000000`,keep:`1 <= number.integer <= 10 = 3`}).onUndeclaredKey(`reject`),nA=Y({enabled:`boolean = false`}).onUndeclaredKey(`reject`);Y({enabled:`boolean = true`,intervalMs:`number >= 5000 = 15000`,diskPaths:Y(`string[]`).default(()=>[`.`]),diskUsedPercent:`number >= 0 = 90`,memoryUsedPercent:`number >= 0 = 90`,swapUsedPercent:`number >= 0 = 50`,loadPerCpu:`number >= 0 = 2`,tempCelsius:`number >= 0 = 85`}).onUndeclaredKey(`reject`),Y({enabled:`boolean = true`,dir:`string = ".backups"`,keep:`number.integer >= 1 = 5`,includePaths:Y(`string[]`).default(()=>[])}).onUndeclaredKey(`reject`),Y({label:`1 <= string <= 60 = "home-hosted"`,port:`1 <= number.integer <= 65535 = 3999`,host:Uk.default(()=>`local`),openBrowser:`boolean = false`,auth:eA.default(()=>({})),tls:nA.default(()=>({}))}).onUndeclaredKey(`reject`);var rA=Y({enabled:`boolean = true`,autostart:`boolean = false`,bind:Uk.default(()=>`local`),onPortConflict:`"block" | "warn" | "follow" | "reclaim" = "block"`,restart:Kk.default(()=>({})),health:Yk.default(()=>({})),stop:Xk.default(()=>({})),logBufferLines:Qk.default(()=>500)}).onUndeclaredKey(`reject`),iA=Y({enabled:`boolean?`,maxRetries:`number.integer >= 0?`,baseDelayMs:`number >= 0?`,factor:`number >= 1?`,maxDelayMs:`number >= 0?`,resetAfterMs:`number >= 0?`}).onUndeclaredKey(`reject`),aA=Y({path:`string?`,method:`"GET" | "HEAD"?`,expectStatus:`number.integer | null?`,expectStatusBelow:`number.integer?`,expectBody:`string?`}).onUndeclaredKey(`reject`),oA=Y({maxRssBytes:`number.integer >= 0?`}).onUndeclaredKey(`reject`),sA=Y({enabled:`boolean?`,mode:`"port" | "http"?`,http:aA.optional(),intervalMs:`number >= 500?`,timeoutMs:`number >= 100?`,unhealthyThreshold:`number.integer >= 1?`,forceRestartAfterMs:`number >= 0?`,startTimeoutMs:`number >= 0?`}).onUndeclaredKey(`reject`),cA=Y({signal:`"SIGTERM" | "SIGINT" | "SIGKILL"?`,killGroup:`boolean?`,graceMs:`number >= 0?`,killPortHolders:`boolean?`}).onUndeclaredKey(`reject`),lA=Y({enabled:`boolean?`,sessionTtlMs:`number >= 60000?`,cookieSecure:`"auto" | "always" | "never"?`,trustProxy:`boolean?`,maxLoginAttempts:`number.integer >= 1?`,lockoutMs:`number >= 1000?`}).onUndeclaredKey(`reject`),uA=Y({telegram:Y({enabled:`boolean?`,chatId:`string?`,onCrash:`boolean?`,onUnhealthy:`boolean?`,onForcedRestart:`boolean?`,onRecovered:`boolean?`,onHost:`boolean?`,cooldownMs:`number >= 0?`}).onUndeclaredKey(`reject`).optional()}).onUndeclaredKey(`reject`),dA=Y({enabled:`boolean?`,intervalMs:`number >= 5000?`,diskPaths:Y(`string[]`).optional(),diskUsedPercent:`number >= 0?`,memoryUsedPercent:`number >= 0?`,swapUsedPercent:`number >= 0?`,loadPerCpu:`number >= 0?`,tempCelsius:`number >= 0?`}).onUndeclaredKey(`reject`),fA=Y({enabled:`boolean?`,dir:`string?`,keep:`number.integer >= 1?`,includePaths:Y(`string[]`).optional()}).onUndeclaredKey(`reject`),pA=Y({persist:`boolean?`,maxBytes:`10000 <= number <= 100000000?`,keep:`1 <= number.integer <= 10?`}).onUndeclaredKey(`reject`),mA=Y({enabled:`boolean?`}).onUndeclaredKey(`reject`),hA=Y({label:`1 <= string <= 60?`,port:`1 <= number.integer <= 65535?`,host:Uk.optional(),openBrowser:`boolean?`,auth:lA.optional(),tls:mA.optional()}).onUndeclaredKey(`reject`),gA=Y({enabled:`boolean?`,autostart:`boolean?`,bind:Uk.optional(),onPortConflict:`"block" | "warn" | "follow" | "reclaim"?`,restart:iA.optional(),health:sA.optional(),stop:cA.optional(),logBufferLines:Qk.optional()}).onUndeclaredKey(`reject`),_A={label:`string?`,enabled:`boolean?`,autostart:`boolean?`,command:`string?`,args:`string[]?`,cwd:`string?`,env:`Record<string, string>?`,dataEnvs:`Record<string, string>?`,bootstrap:Zk.optional(),port:Gk.optional(),bind:Uk.optional(),onPortConflict:`"block" | "warn" | "follow" | "reclaim"?`,restart:iA.optional(),health:sA.optional(),stop:cA.optional(),logBufferLines:Qk.optional(),dependsOn:Y(`string[]`).optional(),envFile:`string?`,resources:oA.optional(),backupPaths:Y(`string[]`).optional()},vA=Y(_A).onUndeclaredKey(`reject`);Y({id:`/^[a-z0-9][a-z0-9_-]*$/`,..._A,command:`string`}).onUndeclaredKey(`reject`);var yA=Y({control:hA.optional(),defaults:gA.optional(),logs:pA.optional(),notifications:uA.optional(),host:dA.optional(),backups:fA.optional()}).onUndeclaredKey(`reject`),bA=Y({enabled:`boolean`,passwordSet:`boolean`,passwordUpdatedAt:`number | null`,apiTokenSet:`boolean?`,usingDefaultPassword:`boolean`,exposed:`boolean`,blockedReason:`string | null`,sessionTtlMs:`number`,cookieSecure:`string`,trustProxy:`boolean`,maxLoginAttempts:`number`,lockoutMs:`number`}),xA=Y({enabled:`boolean`,certPresent:`boolean`,subject:`string | null`,issuer:`string | null`,validFrom:`string | null`,validTo:`string | null`,daysRemaining:`number | null`,fingerprint:`string | null`,keyMatches:`boolean | null`,error:`string | null`}),SA=Y({telegram:Y({enabled:`boolean`,tokenSet:`boolean`,chatId:`string`,onCrash:`boolean`,onUnhealthy:`boolean`,onForcedRestart:`boolean`,onRecovered:`boolean`,onHost:`boolean`,cooldownMs:`number`,lastResult:`string | null`,lastResultAt:`number | null`})});Y({authenticated:`boolean`,authRequired:`boolean`,passwordSet:`boolean`,apiTokenSet:`boolean?`,usingDefaultPassword:`boolean`,defaultPassword:`string | null`,sessionTtlMs:`number`});var CA=Y({password:`string`}).onUndeclaredKey(`reject`),wA=Y(`1 <= string <= 512`),TA=Y({currentPassword:`string?`,newPassword:wA}).onUndeclaredKey(`reject`),EA=Y(`"stopped" | "starting" | "running" | "stopping" | "backoff" | "crashed" | "conflict"`),DA=Y(`"disabled" | "unknown" | "healthy" | "unhealthy"`),OA=Y(`"unknown" | "free" | "in-use"`),kA=Y({ts:`number`,stream:Y(`"stdout" | "stderr" | "system"`),text:`string`}),AA=Y({windowMs:`number`,uptimeRatio:`number | null`,restarts:`number`,crashes:`number`,forcedRestarts:`number`,lastCrashAt:`number | null`,lastExitAt:`number | null`,lastRuntimeMs:`number | null`,events:Y({serverId:`string`,ts:`number`,type:`"start" | "exit" | "crash" | "forced-restart" | "unhealthy" | "recovered"`,detail:`string`,runtimeMs:`number?`}).array()}),jA=Y({cpuPercent:`number | null`,rssBytes:`number | null`,processes:`number`,sampledAt:`number`}),MA=Y({path:`string`,totalBytes:`number`,freeBytes:`number`,usedPercent:`number`}),NA=Y({enabled:`boolean`,cpus:`number`,loadAvg:Y(`number[]`),uptimeMs:`number`,memoryUsedPercent:`number`,swapUsedPercent:`number`,tempCelsius:`number | null`,disks:MA.array(),alerts:Y(`string[]`),sampledAt:`number | null`}),PA=Y({name:`string`,sizeBytes:`number`,createdAt:`number`,encrypted:`boolean`}),FA=Y({path:`string`,origin:`string`,included:`boolean`,note:`string | null`}),IA=Y({enabled:`boolean`,dir:`string`,keep:`number`,includePaths:Y(`string[]`),paths:FA.array(),files:PA.array()});Y({dryRun:`boolean`,encrypted:`boolean`,needsPassword:`boolean`,items:Y({id:`string`,label:`string`,kind:`"config" | "secrets" | "tls" | "data"`,restorable:`boolean`,selected:`boolean`,note:`string | null`}).array(),applied:Y(`string[]`),skipped:Y(`string[]`),restartRequired:`boolean`,reloaded:`boolean`,error:`string?`}),Y({password:wA.optional()}).onUndeclaredKey(`reject`),Y({name:`string?`,password:wA.optional(),include:Y(`string[]`).optional()}).onUndeclaredKey(`reject`);var LA=Y({id:`string`,config:$k,bindHost:`string`,url:`string | null`,status:EA,health:DA,portState:OA,pid:`number | null`,adopted:`boolean?`,startedAt:`number | null`,exitCode:`number | null`,exitSignal:`string | null`,restarts:`number`,maxRetries:`number`,lastError:`string | null`,nextRetryAt:`number | null`,unhealthySince:`number | null`,bufferedLines:`number`,history:AA,responseMs:`number | null`,resources:jA.or(Y(`null`))}),RA=Y({control:Y({label:`string`,port:`number`,host:`string`,bindHost:`string`,url:`string`,openBrowser:`boolean`,restartRequired:`boolean`,protocol:`string`,auth:bA,tls:xA}),defaults:rA,logs:tA,notifications:SA,host:NA,backups:IA,configPath:`string`,configError:`string | null`,projectDir:`string`,dataRoot:`string`,logsDir:`string`,servers:LA.array()}),zA=Y({type:`"hello" | "state" | "log" | "server"`,ts:`number`,serverId:`string?`,state:RA.optional(),server:LA.optional(),lines:kA.array().optional()});Y({limit:`string?`}),Y({ok:`boolean`,port:`number | null`,terminated:`number[]`,forced:`number[]`,skipped:`number[]`,free:`boolean`}),Y({tail:`string?`,search:`string?`,stream:`"stdout" | "stderr" | "system"?`});var BA=Y({servers:Y({serverId:`string`,label:`string`,status:EA,enabled:`boolean`,sizeBytes:`number`,files:Y({name:`string`,sizeBytes:`number`}).array()}).array()}),VA=Y({serverId:`string`,enabled:`boolean`,sizeBytes:`number`,files:Y(`string[]`),searched:`number | null`,lines:kA.array()});Y({botToken:`string?`,chatId:`string?`}).onUndeclaredKey(`reject`),Y({botToken:`string >= 1`}).onUndeclaredKey(`reject`),Y({message:`string`,code:`string`,detail:`unknown`}).onUndeclaredKey(`reject`),Y({custom:`boolean`,dir:`string`,meta:Y({name:`string`,version:`string | null`,uploadedAt:`number`,files:`number.integer >= 1`}).or(Y(`null`))}),Y({certificate:`string >= 1`,privateKey:`string >= 1`}).onUndeclaredKey(`reject`);var HA=/^[\w!#$%&'*.^`|~+-]+$/,UA=(e,t,n={})=>{if(!HA.test(e))throw Error(`Invalid cookie name`);let r=`${e}=${t}`;if(e.startsWith(`__Secure-`)&&!n.secure)throw Error(`__Secure- Cookie must have Secure attributes`);if(e.startsWith(`__Host-`)){if(!n.secure)throw Error(`__Host- Cookie must have Secure attributes`);if(n.path!==`/`)throw Error(`__Host- Cookie must have Path attributes with "/"`);if(n.domain)throw Error(`__Host- Cookie must not have Domain attributes`)}for(let e of[`domain`,`path`,`sameSite`,`priority`])if(n[e]&&/[;\r\n]/.test(n[e]))throw Error(`${e} must not contain ";", "\\r", or "\\n"`);if(n&&typeof n.maxAge==`number`&&n.maxAge>=0){if(n.maxAge>3456e4)throw Error(`Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.`);r+=`; Max-Age=${n.maxAge|0}`}if(n.domain&&n.prefix!==`host`&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw Error(`Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.priority&&(r+=`; Priority=${n.priority.charAt(0).toUpperCase()+n.priority.slice(1)}`),n.partitioned){if(!n.secure)throw Error(`Partitioned Cookie must have Secure attributes`);r+=`; Partitioned`}return r},WA=(e,t,n)=>(t=encodeURIComponent(t),UA(e,t,n)),GA=(e,t)=>(e=e.replace(/\/+$/,``),e+=`/`,t=t.replace(/^\/+/,``),e+t),KA=(e,t)=>{for(let[n,r]of Object.entries(t)){let t=RegExp(`/:`+n+`(?:{[^/]+})?\\??(?=/|$)`);e=e.replace(t,()=>r?`/${r}`:``)}return e},qA=e=>{let t=new URLSearchParams;for(let[n,r]of Object.entries(e))if(r!==void 0){if(Array.isArray(r))for(let e of r)e!==void 0&&t.append(n,e);else t.set(n,r)}return t},JA=(e,t)=>{switch(t){case`ws`:return e.replace(/^http/,`ws`);case`http`:return e.replace(/^ws/,`http`)}},YA=e=>/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(e)?e.replace(/\/index(?=\?|$)/,`/`):e.replace(/\/index(?=\?|$)/,``);function XA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ZA(e,t){if(!XA(e)&&!XA(t))return t;let n={...e};for(let e in t){let r=t[e];n[e]=XA(n[e])&&XA(r)?ZA(n[e],r):r}return n}var QA=(e,t)=>new Proxy(()=>{},{get(n,r){if(typeof r==`string`&&r!==`then`)return QA(e,[...t,r])},apply(n,r,i){return e({path:t,args:i})}}),$A=(e,t)=>{let n=t.toString();return n?`${e}?${n}`:e},ej=class{url;method;buildSearchParams;queryParams=void 0;pathParams={};rBody;cType=void 0;constructor(e,t,n){this.url=e,this.method=t,this.buildSearchParams=n.buildSearchParams}fetch=async(e,t)=>{if(e){if(e.query&&(this.queryParams=this.buildSearchParams(e.query)),e.form){let t=new FormData;for(let[n,r]of Object.entries(e.form))if(r!==void 0){if(Array.isArray(r))for(let e of r)e!==void 0&&t.append(n,e);else t.append(n,r)}this.rBody=t}e.json!==void 0&&(this.rBody=JSON.stringify(e.json),this.cType=`application/json`),e.param&&(this.pathParams=e.param)}let n=this.method.toUpperCase(),r={...e?.header,...typeof t?.headers==`function`?await t.headers():t?.headers};if(e?.cookie){let t=[];for(let[n,r]of Object.entries(e.cookie))r!==void 0&&t.push(WA(n,r));t.length>0&&(r.Cookie=t.join(`; `))}this.cType&&(r[`Content-Type`]=this.cType);let i=new Headers;for(let[e,t]of Object.entries(r))t!==void 0&&i.set(e,t);let a=this.url;a=YA(a),a=KA(a,this.pathParams),this.queryParams&&(a=$A(a,this.queryParams)),n=this.method.toUpperCase();let o=n!==`GET`&&n!==`HEAD`;return(t?.fetch||fetch)(a,{body:o?this.rBody:void 0,method:n,headers:i,...t?.init})}},tj=((e,t)=>QA(function n(r){let i=t?.buildSearchParams??qA,a=[...r.path],o=a.slice(-3).reverse();if(o[0]===`toString`)return o[1]===`name`?o[2]||``:n.toString();if(o[0]===`valueOf`)return o[1]===`name`?o[2]||``:n;let s=``;if(/^\$/.test(o[0])){let e=a.pop();e&&(s=e.replace(/^\$/,``))}let c=GA(e,a.join(`/`));if(s===`url`||s===`path`){let t=YA(c);return r.args[0]&&(r.args[0].param&&(t=KA(t,r.args[0].param)),r.args[0].query&&(t=$A(t,i(r.args[0].query)))),s===`url`?new URL(t):t.slice(e.replace(/\/+$/,``).length).replace(/^\/?/,`/`)}if(s===`ws`){let e=YA(c),n=JA(r.args[0]?.param?KA(e,r.args[0].param):e,`ws`),a=new URL(n),o=r.args[0]?.query;return o&&i(o).forEach((e,t)=>{a.searchParams.append(t,e)}),((...e)=>t?.webSocket!==void 0&&typeof t.webSocket==`function`?t.webSocket(...e):new WebSocket(...e))(a.toString())}let l=new ej(c,s,{buildSearchParams:i});if(s){t??={};let e={...r.args[1]},n=t.headers,i=e.headers;n&&i&&(e.headers=async()=>({...typeof n==`function`?await n():n,...typeof i==`function`?await i():i}));let a=ZA(t,e);return l.fetch(r.args[0],a)}return l},[]))(typeof window>`u`?`http://127.0.0.1`:window.location.origin),nj=class extends Error{name=`AuthRequiredError`;constructor(){super(`authentication required`)}};function rj(e){return typeof e==`object`&&!!e}async function ij(e,t){let n=await fetch(e,{...t,headers:{"Content-Type":`application/json`,...t?.headers}}),r=await n.text(),i=r.length>0?JSON.parse(r):null;if(!n.ok){if(n.status===401&&rj(i)&&i.code===`AUTH_REQUIRED`)throw new nj;let e=rj(i)&&typeof i.message==`string`?i.message:rj(i)&&`error`in i?String(i.error):`request failed with ${n.status}`;throw Error(e)}return i}async function aj(){let e=RA(await ij(`/api/state`));if(e instanceof Y.errors)throw Error(`state contract mismatch: ${e.summary}`);return e}function oj(){return ij(`/api/auth/session`)}function sj(e){let t=CA({password:e});if(t instanceof Y.errors)throw Error(t.summary);return ij(`/api/auth/login`,{method:`POST`,body:JSON.stringify(t)})}function cj(){return ij(`/api/auth/logout`,{method:`POST`})}function lj(e,t){let n=TA(e===void 0?{newPassword:t}:{currentPassword:e,newPassword:t});if(n instanceof Y.errors)throw Error(n.summary);return ij(`/api/auth/password`,{method:`POST`,body:JSON.stringify(n)})}function uj(){return ij(`/api/auth/password`,{method:`DELETE`})}function dj(){return ij(`/api/settings`)}function fj(e){let t=yA(e);if(t instanceof Y.errors)throw Error(t.summary);return ij(`/api/settings`,{method:`PATCH`,body:JSON.stringify(t)})}async function pj(){let e=BA(await ij(`/api/logs`));if(e instanceof Y.errors)throw Error(`logs contract mismatch: ${e.summary}`);return e.servers}async function mj(e,t){let n=new URLSearchParams;t.tail!==void 0&&n.set(`tail`,String(t.tail)),t.search!==void 0&&t.search.length>0&&n.set(`search`,t.search),t.stream!==void 0&&t.stream.length>0&&n.set(`stream`,t.stream);let r=VA(await ij(`/api/logs/${encodeURIComponent(e)}?${n.toString()}`));if(r instanceof Y.errors)throw Error(`log history contract mismatch: ${r.summary}`);return r}function hj(e){return ij(`/api/logs/${encodeURIComponent(e)}`,{method:`DELETE`})}function gj(e,t){return`/api/logs/${encodeURIComponent(e)}/download?file=${encodeURIComponent(t)}`}function _j(e){return ij(`/api/backups`,{method:`POST`,body:JSON.stringify(e===void 0||e.length===0?{}:{password:e})})}function vj(e){return ij(`/api/backups/${encodeURIComponent(e)}`,{method:`DELETE`})}function yj(e){return`/api/backups/${encodeURIComponent(e)}/download`}function bj(e){let t={};return e.password!==void 0&&e.password.length>0&&(t.password=e.password),e.include!==void 0&&(t.include=e.include),t}function xj(e,t,n={}){return ij(`/api/backups/restore?confirm=${t}`,{method:`POST`,body:JSON.stringify({name:e,...bj(n)})})}async function Sj(e,t,n={}){let r=new FormData;r.append(`file`,e),n.password!==void 0&&n.password.length>0&&r.append(`password`,n.password),n.include!==void 0&&r.append(`include`,JSON.stringify(n.include));let i=await fetch(`/api/backups/restore?confirm=${t}`,{method:`POST`,body:r}),a=await i.json().catch(()=>null);if(!i.ok)throw Error(a?.error??`restore failed with ${i.status}`);return a}function Cj(e){return ij(`/api/notifications/token`,{method:`PUT`,body:JSON.stringify({botToken:e})})}function wj(){return ij(`/api/notifications/token`,{method:`DELETE`})}function Tj(e){return ij(`/api/notifications/test`,{method:`POST`,body:JSON.stringify(e)})}function Ej(e){return ij(`/api/notifications/detect-chats`,{method:`POST`,body:JSON.stringify(e)})}async function Dj(e){let t=new FormData;t.append(`file`,e);let n=await fetch(`/api/settings/ui`,{method:`POST`,body:t}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.message??r?.error??`the upload failed with ${n.status}`);return r}function Oj(){return ij(`/api/settings/ui`,{method:`DELETE`})}function kj(e,t){return ij(`/api/settings/tls`,{method:`POST`,body:JSON.stringify({certificate:e,privateKey:t})})}function Aj(){return ij(`/api/settings/tls`,{method:`DELETE`})}async function jj(e,t){let n=await tj.api.servers[`:id`][t].$post({param:{id:e}}),r=await n.json().catch(()=>null);if(!n.ok)throw Error(r?.message??`request failed with ${n.status}`);return r??{ok:!0}}function Mj(){return ij(`/api/servers/start-all`,{method:`POST`})}async function Nj(e){let t=await tj.api.servers[`:id`][`free-port`].$post({param:{id:e}}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.message??`request failed with ${t.status}`);return n??{ok:!0,port:null,terminated:[],forced:[],skipped:[],free:!1}}function Pj(){return ij(`/api/servers/stop-all`,{method:`POST`})}function Fj(e){return ij(`/api/servers/${encodeURIComponent(e)}/clear-logs`,{method:`POST`})}function Ij(e,t){return ij(`/api/servers/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function Lj(e){return ij(`/api/servers/${encodeURIComponent(e)}`,{method:`DELETE`})}function Rj(e){return ij(`/api/servers`,{method:`POST`,body:JSON.stringify(e)})}var zj=j(null),Bj=j(null);function Vj(){async function e(){try{zj.value=await oj()}catch{zj.value=null}}async function t(e){Bj.value=null;try{return zj.value=await sj(e),!0}catch(e){return Bj.value=e instanceof Error?e.message:String(e),!1}}async function n(){try{await cj()}finally{await e()}}function r(){zj.value={authenticated:!1,authRequired:!0,passwordSet:zj.value?.passwordSet??!0,apiTokenSet:zj.value?.apiTokenSet??!1,usingDefaultPassword:zj.value?.usingDefaultPassword??!1,defaultPassword:zj.value?.defaultPassword??null,sessionTtlMs:zj.value?.sessionTtlMs??0}}async function i(t,n){Bj.value=null;try{return await lj(t,n),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}async function a(){Bj.value=null;try{return await uj(),await e(),null}catch(e){return e instanceof Error?e.message:String(e)}}return{session:nn(zj),error:nn(Bj),refresh:e,login:t,logout:n,requireLogin:r,setPassword:i,clearPassword:a}}var Hj=j([]),Uj=1;function Wj(e){Hj.value=Hj.value.filter(t=>t.id!==e)}function Gj(e,t=4800){let n=Uj++;return Hj.value=[...Hj.value,{...e,id:n}],t>0&&setTimeout(Wj,t,n),n}function Kj(){return{toasts:nn(Hj),dismiss:Wj,push:Gj,success:(e,t)=>Gj({tone:`ok`,title:e,description:t}),failure:(e,t)=>Gj({tone:`danger`,title:e,description:t},9e3),info:(e,t)=>Gj({tone:`info`,title:e,description:t}),warn:(e,t)=>Gj({tone:`warn`,title:e,description:t},7e3)}}var qj=4e3;function Jj(){return en({ts:[],cpu:[],rss:[],probe:[],lastSampledAt:-1})}function Yj(e){let t=e.ts.length-120;t<=0||(e.ts.splice(0,t),e.cpu.splice(0,t),e.rss.splice(0,t),e.probe.splice(0,t))}function Xj(e,t,n){let r=t.resources?.sampledAt??0,i=e.ts[e.ts.length-1]??0;if(!(r!==e.lastSampledAt||n-i>=qj)){e.probe.length>0&&(e.probe[e.probe.length-1]=t.responseMs);return}e.lastSampledAt=r,e.ts.push(n);let a=t.status===`running`;e.cpu.push(a?t.resources?.cpuPercent??null:null),e.rss.push(a?t.resources?.rssBytes??null:null),e.probe.push(t.responseMs),Yj(e)}function Zj(e){let t=0;for(let n of e)n!==null&&n>t&&(t=n);return t}function Qj(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n!=null)return n}return null}var $j=8e3,eM=j(null),tM=j(`connecting`),nM=j(null),rM=j(Date.now()),iM=new Map,aM=Kj(),oM=new Map,sM=j(0),cM=null,lM=null;function uM(e){let t=oM.get(e);if(t)return t;let n={lines:[],version:j(0),refs:0,source:null};return oM.set(e,n),n}function dM(e,t){let n=uM(e),r=n.lines.concat(t);n.lines=r.length>8e3?r.slice(r.length-$j):r,n.version.value+=1,sM.value+=1}function fM(e){return oM.get(e)?.lines??[]}function pM(e){let t=oM.get(e);t&&(t.lines=[],t.version.value+=1,sM.value+=1)}function mM(e){let t=iM.get(e);if(t)return t;let n=Jj();return iM.set(e,n),n}function hM(e){Xj(mM(e.id),e,Date.now())}function gM(e){let t=eM.value;if(!t)return;let n=t.servers.findIndex(t=>t.id===e.id);n===-1?t.servers.push(e):t.servers[n]=e}function _M(e){let t;try{t=JSON.parse(e)}catch{return}let n=zA(t);if(n instanceof Y.errors){console.warn(`[home-hosted] ignored malformed SSE frame`,n.summary);return}if(n.type===`hello`||n.type===`state`){if(n.state){eM.value=n.state;for(let e of eM.value.servers)hM(e)}return}if(n.type===`server`&&n.server){let e=n.server;gM(e),hM(e);return}n.type===`log`&&n.serverId&&n.lines&&dM(n.serverId,n.lines)}function vM(e,t){let n=new EventSource(`/api/servers/${encodeURIComponent(e)}/stream`),r=e=>_M(e.data);for(let e of[`log`,`server`])n.addEventListener(e,r);n.onerror=()=>{},t.source=n}function yM(e){let t=uM(e);t.refs+=1,t.source||vM(e,t)}function bM(e){let t=oM.get(e);t&&(t.refs=Math.max(0,t.refs-1),t.refs===0&&(t.source?.close(),t.source=null))}function xM(){if(cM)return;lM??=setInterval(()=>{rM.value=Date.now()},1e3);let e=new EventSource(`/api/events?logs=0`);cM=e,tM.value=`connecting`,e.onopen=()=>{tM.value=`open`},e.onerror=()=>{tM.value=`closed`};for(let t of[`hello`,`state`,`server`,`log`])e.addEventListener(t,e=>{_M(e.data)})}function SM(){cM?.close(),cM=null,lM&&clearInterval(lM),lM=null}function CM(e){let t=W(()=>vn(e)),n=null;return Ar(t,e=>{n!==null&&n!==e&&bM(n),n=e,e!==null&&e.length>0&&yM(e)},{immediate:!0}),ze(()=>{n!==null&&bM(n),n=null}),{version:W(()=>{let e=t.value;return sM.value,e===null?0:oM.get(e)?.version.value??0}),lines(){let e=t.value;return e===null?[]:fM(e)},count:W(()=>{let e=t.value;return sM.value,e===null?0:oM.get(e)?.lines.length??0}),clear(){let e=t.value;e!==null&&pM(e)}}}function wM(){let e=W(()=>eM.value?.servers??[]),t=W(()=>eM.value?.control??null),n=W(()=>eM.value?.defaults??null),r=W(()=>eM.value?.host??null),i=W(()=>eM.value?.backups??null),a=W(()=>eM.value?.notifications??null),o=W(()=>eM.value?.logs??null),s=W(()=>eM.value?.configError??null);function c(e){return eM.value?.servers.find(t=>t.id===e)}function l(e){return mM(e)}async function u(e,t){nM.value=null;try{let n=await e();eM.value=await aj();let r=typeof t.success==`function`?t.success(n):t.success;return r&&aM.success(r),n}catch(e){if(e instanceof nj){Vj().requireLogin();return}let n=e instanceof Error?e.message:String(e);nM.value=n,aM.failure(t.title,n);return}}return{appState:nn(eM),servers:e,control:t,defaults:n,host:r,backups:i,notifications:a,logsConfig:o,configError:s,connection:nn(tM),lastError:nn(nM),now:nn(rM),serverById:c,seriesOf:l,refresh:(e=`Refresh failed`)=>u(async()=>{},{title:e}),start:e=>u(()=>jj(e,`start`),{title:`Could not start ${e}`}),stop:e=>u(()=>jj(e,`stop`),{title:`Could not stop ${e}`}),restart:e=>u(()=>jj(e,`restart`),{title:`Could not restart ${e}`}),startAll:()=>u(()=>Mj(),{title:`Could not start every server`,success:`Starting every enabled server`}),stopAll:()=>u(()=>Pj(),{title:`Could not stop every server`,success:`Stopping every server`}),setAutostart:(e,t)=>u(()=>Ij(e,{autostart:t}),{title:`Could not change autostart for ${e}`}),setEnabled:(e,t)=>u(()=>Ij(e,{enabled:t}),{title:`Could not change ${e}`}),freePort:e=>u(()=>Nj(e),{title:`Could not free the port for ${e}`,success:t=>t.free?`Port ${t.port} is free — start ${e} now`:`Port ${t.port} is still held`}),setBind:(e,t)=>{let n=Wk(t);return n===null?(aM.failure(`Could not change the bind for ${e}`,`"${t}" is not a bind value`),Promise.resolve(void 0)):u(()=>Ij(e,{bind:n}),{title:`Could not change the bind for ${e}`})},saveConfig:(e,t)=>u(()=>Ij(e,t),{title:`Could not save ${e}`,success:`${e} updated`}),saveSettings:e=>u(()=>fj(e),{title:`Could not save the settings`}),clearLogs:e=>u(async()=>{await Fj(e),pM(e)},{title:`Could not clear the logs for ${e}`,success:`Buffer cleared`}),create:e=>u(()=>Rj(e),{title:`Could not add the server`,success:`Server added`}),remove:e=>u(async()=>{await Lj(e),bM(e),oM.delete(e),iM.delete(e)},{title:`Could not remove ${e}`,success:`${e} removed`})}}var TM=`hh.theme`;function EM(){try{let e=localStorage.getItem(TM);if(e===`light`||e===`dark`||e===`system`)return e}catch{}return`system`}var DM=j(EM()),OM=j(typeof matchMedia<`u`&&matchMedia(`(prefers-color-scheme: dark)`).matches),kM=!1;function AM(){kM||typeof matchMedia>`u`||(kM=!0,matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{OM.value=e.matches,MM()}))}var jM=W(()=>DM.value===`system`?OM.value:DM.value===`dark`);function MM(){typeof document<`u`&&document.documentElement.classList.toggle(`dark`,jM.value)}function NM(){AM(),MM();function e(e){DM.value=e;try{localStorage.setItem(TM,e)}catch{}MM()}return{preference:DM,isDark:jM,setPreference:e,cycle(){e(DM.value===`light`?`dark`:DM.value===`dark`?`system`:`light`)}}}function PM(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=PM(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function FM(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=PM(e))&&(r&&(r+=` `),r+=t);return r}var IM=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},LM=(e,t)=>({classGroupId:e,validator:t}),RM=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),zM=`-`,BM=[],VM=`arbitrary..`,HM=e=>{let t=GM(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return WM(e);let n=e.split(zM);return UM(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?IM(i,t):t:i||BM}return n[e]||BM}}},UM=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=UM(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(zM):e.slice(t).join(zM),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},WM=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?VM+r:void 0})(),GM=e=>{let{theme:t,classGroups:n}=e;return KM(n,t)},KM=(e,t)=>{let n=RM();for(let r in e){let i=e[r];qM(i,n,r,t)}return n},qM=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];JM(i,t,n,r)}},JM=(e,t,n,r)=>{if(typeof e==`string`){YM(e,t,n);return}if(typeof e==`function`){XM(e,t,n,r);return}ZM(e,t,n,r)},YM=(e,t,n)=>{let r=e===``?t:QM(t,e);r.classGroupId=n},XM=(e,t,n,r)=>{if($M(e)){qM(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(LM(n,e))},ZM=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];qM(o,QM(t,a),n,r)}},QM=(e,t)=>{let n=e,r=t.split(zM),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=RM(),n.nextPart.set(t,i)),n=i}return n},$M=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,eN=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},tN=`!`,nN=`:`,rN=[],iN=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),aN=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===nN){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(tN)?(c=s.slice(0,-1),l=!0):s.startsWith(tN)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return iN(t,l,c,u)};if(t){let e=t+nN,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):iN(rN,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},oN=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},sN=e=>({cache:eN(e.cacheSize),parseClassName:aN(e),sortModifiers:oN(e),postfixLookupClassGroupIds:cN(e),...HM(e)}),cN=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},lN=/\s+/,uN=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(lN),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+tN:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},dN=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=fN(n))&&(i&&(i+=` `),i+=r);return i},fN=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=fN(e[r]))&&(n&&(n+=` `),n+=t);return n},pN=(e,...t)=>{let n,r,i,a,o=o=>(n=sN(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=uN(e,n);return i(e,a),a};return a=o,(...e)=>a(dN(...e))},mN=[],hN=e=>{let t=t=>t[e]||mN;return t.isThemeGetter=!0,t.themeKey=e,t},gN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,_N=/^\((?:(\w[\w-]*):)?(.+)\)$/i,vN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,yN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,SN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,CN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,wN=e=>vN.test(e),TN=e=>!!e&&!Number.isNaN(Number(e)),EN=e=>!!e&&Number.isInteger(Number(e)),DN=e=>e.endsWith(`%`)&&TN(e.slice(0,-1)),ON=e=>yN.test(e),kN=()=>!0,AN=e=>bN.test(e)&&!xN.test(e),jN=()=>!1,MN=e=>SN.test(e),NN=e=>CN.test(e),PN=e=>!X(e)&&!Z(e),FN=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),IN=e=>ZN(e,tP,jN),X=e=>gN.test(e),LN=e=>ZN(e,nP,AN),RN=e=>ZN(e,rP,TN),zN=e=>ZN(e,aP,kN),BN=e=>ZN(e,iP,jN),VN=e=>ZN(e,$N,jN),HN=e=>ZN(e,eP,NN),UN=e=>ZN(e,oP,MN),Z=e=>_N.test(e),WN=e=>QN(e,nP),GN=e=>QN(e,iP),KN=e=>QN(e,$N),qN=e=>QN(e,tP),JN=e=>QN(e,eP),YN=e=>QN(e,oP,!0),XN=e=>QN(e,aP,!0),ZN=(e,t,n)=>{let r=gN.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},QN=(e,t,n=!1)=>{let r=_N.exec(e);return r?r[1]?t(r[1]):n:!1},$N=e=>e===`position`||e===`percentage`,eP=e=>e===`image`||e===`url`,tP=e=>e===`length`||e===`size`||e===`bg-size`,nP=e=>e===`length`,rP=e=>e===`number`,iP=e=>e===`family-name`,aP=e=>e===`number`||e===`weight`,oP=e=>e===`shadow`,sP=pN(()=>{let e=hN(`color`),t=hN(`font`),n=hN(`text`),r=hN(`font-weight`),i=hN(`tracking`),a=hN(`leading`),o=hN(`breakpoint`),s=hN(`container`),c=hN(`spacing`),l=hN(`radius`),u=hN(`shadow`),d=hN(`inset-shadow`),f=hN(`text-shadow`),p=hN(`drop-shadow`),m=hN(`blur`),h=hN(`perspective`),g=hN(`aspect`),_=hN(`ease`),v=hN(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),Z,X],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[Z,X,c],T=()=>[wN,`full`,`auto`,...w()],ee=()=>[EN,`none`,`subgrid`,Z,X],E=()=>[`auto`,{span:[`full`,EN,Z,X]},EN,Z,X],te=()=>[EN,`auto`,Z,X],ne=()=>[`auto`,`min`,`max`,`fr`,Z,X],re=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ie=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],ae=()=>[`auto`,...w()],oe=()=>[wN,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],se=()=>[s,wN,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],ce=()=>[wN,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],D=()=>[e,Z,X],le=()=>[...b(),KN,VN,{position:[Z,X]}],ue=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],de=()=>[`auto`,`cover`,`contain`,qN,IN,{size:[Z,X]}],fe=()=>[DN,WN,LN],pe=()=>[``,`none`,`full`,l,Z,X],me=()=>[``,TN,WN,LN],he=()=>[`solid`,`dashed`,`dotted`,`double`],ge=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],_e=()=>[TN,DN,KN,VN],ve=()=>[``,`none`,m,Z,X],ye=()=>[`none`,TN,Z,X],be=()=>[`none`,TN,Z,X],O=()=>[TN,Z,X],xe=()=>[wN,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[ON],breakpoint:[ON],color:[kN],container:[ON],"drop-shadow":[ON],ease:[`in`,`out`,`in-out`],font:[PN],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[ON],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[ON],shadow:[ON],spacing:[`px`,TN],text:[ON],"text-shadow":[ON],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,wN,X,Z,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Z,X]}],"container-named":[FN],columns:[{columns:[TN,`auto`,X,Z,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[EN,`auto`,Z,X]}],basis:[{basis:[wN,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[TN,wN,`auto`,`initial`,`none`,X]}],grow:[{grow:[``,TN,Z,X]}],shrink:[{shrink:[``,TN,Z,X]}],order:[{order:[EN,`first`,`last`,`none`,Z,X]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:E()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:E()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...re(),`normal`]}],"justify-items":[{"justify-items":[...ie(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ie()]}],"align-content":[{content:[`normal`,...re()]}],"align-items":[{items:[...ie(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ie(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":re()}],"place-items":[{"place-items":[...ie(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ie()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:ae()}],mx:[{mx:ae()}],my:[{my:ae()}],ms:[{ms:ae()}],me:[{me:ae()}],mbs:[{mbs:ae()}],mbe:[{mbe:ae()}],mt:[{mt:ae()}],mr:[{mr:ae()}],mb:[{mb:ae()}],ml:[{ml:ae()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:oe()}],"inline-size":[{inline:[`auto`,...se()]}],"min-inline-size":[{"min-inline":[`auto`,...se()]}],"max-inline-size":[{"max-inline":[`none`,...se()]}],"block-size":[{block:[`auto`,...ce()]}],"min-block-size":[{"min-block":[`auto`,...ce()]}],"max-block-size":[{"max-block":[`none`,...ce()]}],w:[{w:[s,`screen`,...oe()]}],"min-w":[{"min-w":[s,`screen`,`none`,...oe()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...oe()]}],h:[{h:[`screen`,`lh`,...oe()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...oe()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...oe()]}],"font-size":[{text:[`base`,n,WN,LN]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,XN,zN]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,DN,X]}],"font-family":[{font:[GN,BN,t]}],"font-features":[{"font-features":[X]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,Z,X]}],"line-clamp":[{"line-clamp":[TN,`none`,Z,RN]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,Z,X]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,Z,X]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...he(),`wavy`]}],"text-decoration-thickness":[{decoration:[TN,`from-font`,`auto`,Z,LN]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[TN,`auto`,Z,X]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[EN,Z,X]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Z,X]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,Z,X]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:le()}],"bg-repeat":[{bg:ue()}],"bg-size":[{bg:de()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},EN,Z,X],radial:[``,Z,X],conic:[``,EN,Z,X]},JN,HN]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:fe()}],"gradient-via-pos":[{via:fe()}],"gradient-to-pos":[{to:fe()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:pe()}],"rounded-s":[{"rounded-s":pe()}],"rounded-e":[{"rounded-e":pe()}],"rounded-t":[{"rounded-t":pe()}],"rounded-r":[{"rounded-r":pe()}],"rounded-b":[{"rounded-b":pe()}],"rounded-l":[{"rounded-l":pe()}],"rounded-ss":[{"rounded-ss":pe()}],"rounded-se":[{"rounded-se":pe()}],"rounded-ee":[{"rounded-ee":pe()}],"rounded-es":[{"rounded-es":pe()}],"rounded-tl":[{"rounded-tl":pe()}],"rounded-tr":[{"rounded-tr":pe()}],"rounded-br":[{"rounded-br":pe()}],"rounded-bl":[{"rounded-bl":pe()}],"border-w":[{border:me()}],"border-w-x":[{"border-x":me()}],"border-w-y":[{"border-y":me()}],"border-w-s":[{"border-s":me()}],"border-w-e":[{"border-e":me()}],"border-w-bs":[{"border-bs":me()}],"border-w-be":[{"border-be":me()}],"border-w-t":[{"border-t":me()}],"border-w-r":[{"border-r":me()}],"border-w-b":[{"border-b":me()}],"border-w-l":[{"border-l":me()}],"divide-x":[{"divide-x":me()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":me()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...he(),`hidden`,`none`]}],"divide-style":[{divide:[...he(),`hidden`,`none`]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...he(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[TN,Z,X]}],"outline-w":[{outline:[``,TN,WN,LN]}],"outline-color":[{outline:D()}],shadow:[{shadow:[``,`inner`,`none`,u,YN,UN]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":[`none`,d,YN,UN]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:me()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[TN,LN]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":me()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":[`none`,f,YN,UN]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[TN,Z,X]}],"mix-blend":[{"mix-blend":[...ge(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ge()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[TN]}],"mask-image-linear-from-pos":[{"mask-linear-from":_e()}],"mask-image-linear-to-pos":[{"mask-linear-to":_e()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":_e()}],"mask-image-t-to-pos":[{"mask-t-to":_e()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":_e()}],"mask-image-r-to-pos":[{"mask-r-to":_e()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":_e()}],"mask-image-b-to-pos":[{"mask-b-to":_e()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":_e()}],"mask-image-l-to-pos":[{"mask-l-to":_e()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":_e()}],"mask-image-x-to-pos":[{"mask-x-to":_e()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":_e()}],"mask-image-y-to-pos":[{"mask-y-to":_e()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[Z,X]}],"mask-image-radial-from-pos":[{"mask-radial-from":_e()}],"mask-image-radial-to-pos":[{"mask-radial-to":_e()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[TN]}],"mask-image-conic-from-pos":[{"mask-conic-from":_e()}],"mask-image-conic-to-pos":[{"mask-conic-to":_e()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:le()}],"mask-repeat":[{mask:ue()}],"mask-size":[{mask:de()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Z,X]}],filter:[{filter:[``,`none`,Z,X]}],blur:[{blur:ve()}],brightness:[{brightness:[TN,Z,X]}],contrast:[{contrast:[TN,Z,X]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,YN,UN]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:[``,TN,Z,X]}],"hue-rotate":[{"hue-rotate":[TN,Z,X]}],invert:[{invert:[``,TN,Z,X]}],saturate:[{saturate:[TN,Z,X]}],sepia:[{sepia:[``,TN,Z,X]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Z,X]}],"backdrop-blur":[{"backdrop-blur":ve()}],"backdrop-brightness":[{"backdrop-brightness":[TN,Z,X]}],"backdrop-contrast":[{"backdrop-contrast":[TN,Z,X]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,TN,Z,X]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[TN,Z,X]}],"backdrop-invert":[{"backdrop-invert":[``,TN,Z,X]}],"backdrop-opacity":[{"backdrop-opacity":[TN,Z,X]}],"backdrop-saturate":[{"backdrop-saturate":[TN,Z,X]}],"backdrop-sepia":[{"backdrop-sepia":[``,TN,Z,X]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,Z,X]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[TN,`initial`,Z,X]}],ease:[{ease:[`linear`,`initial`,_,Z,X]}],delay:[{delay:[TN,Z,X]}],animate:[{animate:[`none`,v,Z,X]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Z,X]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ye()}],"rotate-x":[{"rotate-x":ye()}],"rotate-y":[{"rotate-y":ye()}],"rotate-z":[{"rotate-z":ye()}],scale:[{scale:be()}],"scale-x":[{"scale-x":be()}],"scale-y":[{"scale-y":be()}],"scale-z":[{"scale-z":be()}],"scale-3d":[`scale-3d`],skew:[{skew:O()}],"skew-x":[{"skew-x":O()}],"skew-y":[{"skew-y":O()}],transform:[{transform:[Z,X,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:xe()}],"translate-x":[{"translate-x":xe()}],"translate-y":[{"translate-y":xe()}],"translate-z":[{"translate-z":xe()}],"translate-none":[`translate-none`],zoom:[{zoom:[EN,Z,X]}],accent:[{accent:D()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,Z,X]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":D()}],"scrollbar-track-color":[{"scrollbar-track":D()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,Z,X]}],fill:[{fill:[`none`,...D()]}],"stroke-w":[{stroke:[TN,WN,LN,RN]}],stroke:[{stroke:[`none`,...D()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Q(...e){return sP(FM(e))}var cP={stopped:{label:`Stopped`,tone:`neutral`,transitional:!1},starting:{label:`Starting`,tone:`warn`,transitional:!0},running:{label:`Running`,tone:`ok`,transitional:!1},stopping:{label:`Stopping`,tone:`warn`,transitional:!0},backoff:{label:`Restarting`,tone:`warn`,transitional:!0},crashed:{label:`Crashed`,tone:`danger`,transitional:!1},conflict:{label:`Port conflict`,tone:`danger`,transitional:!1}},lP={disabled:{label:`Not checked`,tone:`neutral`},unknown:{label:`Not probed`,tone:`neutral`},healthy:{label:`Healthy`,tone:`ok`},unhealthy:{label:`Unhealthy`,tone:`danger`}},uP={ok:`text-ok`,warn:`text-warn`,danger:`text-danger`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},dP={ok:`bg-ok-soft text-ok border-ok/25`,warn:`bg-warn-soft text-warn border-warn/25`,danger:`bg-danger-soft text-danger border-danger/25`,info:`bg-info-soft text-info border-info/25`,neutral:`bg-hover text-muted border-line`,accent:`bg-accent-soft text-accent border-accent/25`},fP={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,info:`bg-info`,neutral:`bg-faint`,accent:`bg-accent`};function pP(e,t){return e===`crashed`||e===`conflict`||t===`unhealthy`?`danger`:e===`starting`||e===`stopping`||e===`backoff`?`warn`:e===`running`?`ok`:`neutral`}var mP={start:`Started`,exit:`Exited`,crash:`Crashed`,"forced-restart":`Forced restart`,unhealthy:`Unhealthy`,recovered:`Recovered`},hP={start:`ok`,exit:`neutral`,crash:`danger`,"forced-restart":`warn`,unhealthy:`warn`,recovered:`info`},gP={class:`flex items-center gap-2.5 border-b border-line px-3.5`},_P={key:0,class:`px-3 py-8 text-center text-xs text-muted`},vP={class:`px-2.5 pb-1 pt-2.5 text-2xs font-medium text-faint`},yP=[`data-active`,`onMousemove`,`onClick`],bP={class:`min-w-0 flex-1 truncate text-sm`},xP={key:0,class:`shrink-0 font-mono text-2xs text-faint`},SP={class:`flex items-center gap-3 border-t border-line bg-panel-2 px-3.5 py-2 text-2xs text-faint`},CP={class:`ml-auto font-mono`},wP=P({__name:`CommandPalette`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:[`update:open`],setup(e){let t=so(e,`open`),n=Rg(),r=wM(),i=NM(),a=j(``),o=j(0),s=j(null),c=j(null);function l(e){n.push(e)}function u(e){e(),t.value=!1}let d=[`stopped`,`crashed`,`conflict`],f=[`running`,`starting`,`backoff`],p=W(()=>{let e=[],t=r.appState.value?.servers??[];for(let n of t){let t=n.config.label??n.id,i=cP[n.status].label;e.push({id:`open:${n.id}`,title:`Open ${t}`,group:`Servers`,icon:by,detail:`${n.id} · ${i}`,keywords:`server detail ${n.id} show`,run:()=>l(`/servers/${n.id}`)}),e.push({id:`logs:${n.id}`,title:`Logs for ${t}`,group:`Servers`,icon:Dy,detail:n.id,keywords:`log tail output ${n.id}`,run:()=>l(`/logs?server=${encodeURIComponent(n.id)}`)}),d.includes(n.status)&&n.config.enabled&&e.push({id:`start:${n.id}`,title:`Start ${t}`,group:`Actions`,icon:fy,detail:n.id,keywords:`run launch ${n.id}`,run:()=>u(()=>void r.start(n.id))}),f.includes(n.status)&&e.push({id:`stop:${n.id}`,title:`Stop ${t}`,group:`Actions`,icon:Ty,detail:n.id,keywords:`halt kill ${n.id}`,run:()=>u(()=>void r.stop(n.id))}),n.config.enabled&&e.push({id:`restart:${n.id}`,title:`Restart ${t}`,group:`Actions`,icon:_y,detail:n.id,keywords:`bounce reload ${n.id}`,run:()=>u(()=>void r.restart(n.id))})}e.push({id:`nav:overview`,title:`Go to Overview`,group:`Navigate`,icon:ty,keywords:`dashboard home`,run:()=>l(`/`)},{id:`nav:servers`,title:`Go to Servers`,group:`Navigate`,icon:by,keywords:`processes list`,run:()=>l(`/servers`)},{id:`nav:logs`,title:`Go to Logs`,group:`Navigate`,icon:vy,keywords:`output files tail`,run:()=>l(`/logs`)},{id:`nav:settings`,title:`Go to Settings`,group:`Navigate`,icon:wy,keywords:`config panel`,run:()=>l(`/settings`)},{id:`act:start-all`,title:`Start every enabled server`,group:`Actions`,icon:fy,keywords:`boot all`,run:()=>u(()=>void r.startAll())},{id:`act:stop-all`,title:`Stop every server`,group:`Actions`,icon:Ty,keywords:`halt all`,run:()=>u(()=>void r.stopAll())});for(let[t,n]of[[`listener`,`Listener`],[`authentication`,`Authentication`],[`password`,`Password`],[`defaults`,`Server defaults`],[`logs`,`Log storage`],[`notifications`,`Telegram notifications`],[`host`,`Host vitals`],[`backups`,`Backups`],[`tls`,`TLS`],[`paths`,`Paths`]])e.push({id:`set:${t}`,title:`Setting: ${n}`,group:`Settings`,icon:wy,keywords:`configure ${t}`,run:()=>l(`/settings?section=${t}`)});let n=[[`light`,`Light`,Ey],[`dark`,`Dark`,cy],[`system`,`System`,sy]];for(let[t,r,a]of n)e.push({id:`theme:${t}`,title:`${r} theme`,group:`Appearance`,icon:a,keywords:`colour color dark light mode appearance`,run:()=>u(()=>i.setPreference(t))});return e}),m=W(()=>{let e=a.value.trim().toLowerCase().split(/\s+/).filter(Boolean);return e.length===0?p.value.slice(0,40):p.value.map(t=>{let n=`${t.title} ${t.detail??``} ${t.keywords??``} ${t.group}`.toLowerCase(),r=0;for(let t of e){let e=n.indexOf(t);if(e===-1)return null;r+=e===0?0:e}return{command:t,score:r}}).filter(e=>e!==null).sort((e,t)=>e.score-t.score).slice(0,40).map(e=>e.command)}),h=W(()=>{let e=new Map;for(let t of m.value){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]}),g=W(()=>h.value.flatMap(([,e])=>e));Ar(m,()=>{o.value=0}),Ar(t,async e=>{e&&(a.value=``,o.value=0,await nr(),s.value?.focus())});function _(e){let t=g.value.length;t!==0&&(o.value=(o.value+e+t)%t,nr(()=>{c.value?.querySelector(`[data-active="true"]`)?.scrollIntoView({block:`nearest`})}))}function v(e){e.key===`ArrowDown`?(e.preventDefault(),_(1)):e.key===`ArrowUp`?(e.preventDefault(),_(-1)):e.key===`Enter`&&(e.preventDefault(),g.value[o.value]?.run())}function y(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),t.value=!t.value)}return ta(()=>window.addEventListener(`keydown`,y)),ze(()=>window.removeEventListener(`keydown`,y)),(e,n)=>(L(),z(M(lf),{open:t.value,"onUpdate:open":n[2]||=e=>t.value=e},{default:N(()=>[V(M(Yf),null,{default:N(()=>[V(M(qf),{class:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px] data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`}),V(M(Wf),{class:`fixed left-1/2 top-[10vh] z-50 w-[min(94vw,38rem)] -translate-x-1/2 overflow-hidden rounded-panel border border-line bg-panel shadow-float data-[state=open]:animate-[hh-pop-in_150ms_var(--ease-out-quick)]`,onOpenAutoFocus:n[1]||=lu(()=>{},[`prevent`]),onKeydown:v},{default:N(()=>[V(M(Xf),{class:`sr-only`},{default:N(()=>[...n[3]||=[H(` Command palette `,-1)]]),_:1}),B(`div`,gP,[V(M(yy),{class:`size-4 shrink-0 text-faint`}),br(B(`input`,{ref_key:`input`,ref:s,"onUpdate:modelValue":n[0]||=e=>a.value=e,type:`text`,placeholder:`Jump to a server, run an action, open a setting…`,class:`h-12 w-full bg-transparent text-sm text-ink outline-none placeholder:text-faint`,autocomplete:`off`,spellcheck:`false`},null,512),[[Jl,a.value]]),n[4]||=B(`kbd`,{class:`shrink-0 rounded border border-line bg-page px-1.5 py-0.5 font-mono text-2xs text-faint`},`esc`,-1)]),B(`div`,{ref_key:`list`,ref:c,class:`max-h-[min(60vh,26rem)] overflow-y-auto p-1.5`},[g.value.length===0?(L(),R(`p`,_P,` Nothing matches “`+k(a.value)+`”. `,1)):U(``,!0),(L(!0),R(I,null,va(h.value,([e,t])=>(L(),R(I,{key:e},[B(`p`,vP,k(e),1),(L(!0),R(I,null,va(t,e=>(L(),R(`button`,{key:e.id,type:`button`,"data-active":g.value[o.value]?.id===e.id,class:O(M(Q)(`flex w-full items-center gap-2.5 rounded-control px-2.5 py-2 text-left transition-colors duration-100`,g.value[o.value]?.id===e.id?`bg-accent-soft text-ink`:`text-muted hover:bg-hover`)),onMousemove:t=>o.value=g.value.findIndex(t=>t.id===e.id),onClick:t=>e.run()},[(L(),z(ma(e.icon),{class:O([`size-4 shrink-0`,g.value[o.value]?.id===e.id?`text-accent`:`text-faint`])},null,8,[`class`])),B(`span`,bP,k(e.title),1),e.detail?(L(),R(`span`,xP,k(e.detail),1)):U(``,!0),V(M(Lv),{class:O([`size-3.5 shrink-0 text-faint opacity-0 transition-opacity duration-100`,{"opacity-100":g.value[o.value]?.id===e.id}])},null,8,[`class`])],42,yP))),128))],64))),128))],512),B(`div`,SP,[n[5]||=B(`span`,null,[B(`kbd`,{class:`font-mono`},`↑↓`),H(` navigate`)],-1),n[6]||=B(`span`,null,[B(`kbd`,{class:`font-mono`},`↵`),H(` run`)],-1),B(`span`,CP,k(g.value.length)+` results`,1)])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),TP={viewBox:`0 0 80 80`,class:`size-full -rotate-0`},EP=[`stroke-dasharray`],DP=[`stroke-dasharray`],OP={class:`absolute inset-0 grid place-items-center`},kP={class:`font-mono text-sm font-semibold tabular-nums text-ink`},AP={class:`text-2xs font-medium text-faint`},jP=34,MP=.75,NP=P({__name:`Gauge`,props:{value:{},label:{},display:{default:void 0},size:{default:74},tone:{default:void 0},warnAt:{default:75},dangerAt:{default:90}},setup(e){let t=e,n=2*Math.PI*jP,r=W(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(1,Math.max(0,t.value/100))*MP),i=W(()=>t.tone?t.tone:t.value===null||!Number.isFinite(t.value)?`neutral`:t.value>=t.dangerAt?`danger`:t.value>=t.warnAt?`warn`:`ok`),a={ok:`stroke-ok`,warn:`stroke-warn`,danger:`stroke-danger`,info:`stroke-info`,neutral:`stroke-faint`,accent:`stroke-accent`};return(e,o)=>(L(),R(`div`,{class:O(M(Q)(`flex flex-col items-center gap-1`))},[B(`div`,{class:`relative`,style:ge({width:`${t.size}px`,height:`${t.size}px`})},[(L(),R(`svg`,TP,[B(`circle`,{cx:`40`,cy:`40`,r:jP,fill:`none`,class:`stroke-line-soft`,"stroke-width":6,"stroke-dasharray":`${MP*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,8,EP),B(`circle`,{cx:`40`,cy:`40`,r:jP,fill:`none`,class:O([a[i.value],`transition-[stroke-dasharray] duration-300 ease-out`]),"stroke-width":6,"stroke-dasharray":`${r.value*n} ${n}`,transform:`rotate(135 40 40)`,"stroke-linecap":`round`},null,10,DP)])),B(`div`,OP,[B(`span`,kP,k(t.display??(t.value===null?`—`:`${Math.round(t.value)}%`)),1)])],4),B(`span`,AP,k(t.label),1)],2))}}),PP={class:`rounded-panel border border-line bg-panel-2/70 p-3`},FP={class:`mb-2 flex items-center justify-between`},IP={key:0,class:`text-2xs text-faint`},LP={key:0,class:`grid grid-cols-2 gap-x-1 gap-y-2`},RP={key:1,class:`py-3 text-center text-2xs text-faint`},zP={key:2,class:`mt-2 flex items-start gap-1.5 rounded-control bg-danger-soft px-2 py-1.5`},BP={class:`text-2xs leading-4 text-danger`},VP=2,HP=85,UP=P({__name:`InstrumentCluster`,props:{host:{}},setup(e){let t=e,n=W(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=W(()=>n.value===null?null:n.value/VP*100),i=W(()=>n.value===null?`—`:n.value.toFixed(2)),a=W(()=>{let e=t.host?.disks??[];return e.length===0?null:Math.max(...e.map(e=>e.usedPercent))}),o=W(()=>{let e=t.host?.tempCelsius??null;return e===null?null:e/HP*100}),s=W(()=>{let e=t.host?.tempCelsius??null;return e===null?`n/a`:`${Math.round(e)}°`});return(e,n)=>(L(),R(`div`,PP,[B(`div`,FP,[n[0]||=B(`span`,{class:`text-2xs font-medium text-faint`},`Host vitals`,-1),t.host?.enabled===!1?(L(),R(`span`,IP,`off`)):U(``,!0)]),t.host?.enabled?(L(),R(`div`,LP,[V(NP,{value:r.value,label:`Load / cpu`,display:i.value,size:58,"warn-at":70,"danger-at":100},null,8,[`value`,`display`]),V(NP,{value:t.host?.memoryUsedPercent??null,label:`Memory`,size:58},null,8,[`value`]),V(NP,{value:a.value,label:`Disk`,size:58},null,8,[`value`]),V(NP,{value:o.value,label:`CPU temp`,display:s.value,size:58},null,8,[`value`,`display`])])):(L(),R(`p`,RP,` Sampling is disabled in Settings. `)),t.host&&t.host.alerts.length>0?(L(),R(`div`,zP,[n[1]||=B(`span`,{class:`mt-1 size-1.5 shrink-0 rounded-full bg-danger`},null,-1),B(`span`,BP,k(t.host.alerts.join(` · `)),1)])):U(``,!0)]))}}),WP={class:`flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3`},GP={class:`flex items-center gap-2 px-1 pt-1`},KP={class:`min-w-0`},qP={class:`truncate text-2xs text-faint`},JP={class:`flex flex-col gap-0.5`},YP={class:`mt-auto flex flex-col gap-3`},XP={class:`flex items-center gap-2 rounded-control border border-line bg-panel-2/70 px-2.5 py-2`},ZP={class:`relative flex size-2 shrink-0`},QP={class:`text-2xs text-muted`},$P=[`title`],eF=P({__name:`SideNav`,props:{host:{},connection:{},panelLabel:{},planLabel:{},running:{},total:{}},emits:[`navigate`,`close`],setup(e,{emit:t}){let n=e,r=t,i=zg(),a=[{to:`/`,label:`Overview`,icon:ty,exact:!0},{to:`/servers`,label:`Servers`,icon:by,exact:!1},{to:`/logs`,label:`Logs`,icon:vy,exact:!1},{to:`/settings`,label:`Settings`,icon:wy,exact:!1}];function o(e){return e.exact?i.path===e.to:i.path===e.to||i.path.startsWith(`${e.to}/`)}let s=W(()=>({open:{label:`Live`,dot:`bg-ok`},connecting:{label:`Connecting`,dot:`bg-warn`},closed:{label:`Reconnecting`,dot:`bg-danger`}})[n.connection]);return(e,t)=>{let i=fa(`RouterLink`);return L(),R(`div`,WP,[B(`div`,GP,[t[3]||=Os(`<span class="grid size-8 shrink-0 place-items-center rounded-[9px] border border-accent/30 bg-accent-soft text-accent"><svg viewBox="0 0 24 24" class="size-4.5" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M4 15.5a8 8 0 1 1 16 0"></path><path d="M12 15.5 15.6 10.2"></path><circle cx="12" cy="15.5" r="1.3" fill="currentColor" stroke="none"></circle></svg></span>`,1),B(`div`,KP,[t[2]||=B(`p`,{class:`truncate text-sm font-semibold tracking-tight text-ink`},` home-hosted `,-1),B(`p`,qP,k(n.panelLabel),1)]),B(`button`,{type:`button`,class:`ml-auto grid size-7 place-items-center rounded-control text-muted hover:bg-hover hover:text-ink lg:hidden`,"aria-label":`Close navigation`,onClick:t[0]||=e=>r(`close`)},[V(M(My),{class:`size-4`})])]),B(`nav`,JP,[(L(),R(I,null,va(a,e=>V(i,{key:e.to,to:e.to,class:O(M(Q)(`group flex items-center gap-2.5 rounded-control px-2.5 py-1.5 text-sm transition-colors duration-150`,o(e)?`bg-accent-soft font-medium text-accent`:`text-muted hover:bg-hover hover:text-ink`)),onClick:t[1]||=e=>r(`navigate`)},{default:N(()=>[(L(),z(ma(e.icon),{class:`size-4 shrink-0`,"stroke-width":o(e)?2.1:1.8},null,8,[`stroke-width`])),H(` `+k(e.label)+` `,1),e.to===`/servers`?(L(),R(`span`,{key:0,class:O([`ml-auto font-mono text-2xs tabular-nums`,o(e)?`text-accent`:`text-faint`])},k(n.running)+`/`+k(n.total),3)):U(``,!0)]),_:2},1032,[`to`,`class`])),64))]),B(`div`,YP,[V(UP,{host:n.host},null,8,[`host`]),B(`div`,XP,[B(`span`,ZP,[B(`span`,{class:O(M(Q)(`absolute inset-0 rounded-full`,s.value.dot,n.connection!==`open`&&`animate-ping opacity-60`))},null,2),B(`span`,{class:O(M(Q)(`relative size-2 rounded-full`,s.value.dot))},null,2)]),B(`span`,QP,k(s.value.label),1),B(`span`,{class:`ml-auto truncate font-mono text-2xs text-faint`,title:n.planLabel},k(n.planLabel),9,$P)])])])}}}),tF={key:0,class:`flex flex-col gap-px border-b border-line bg-panel/60`},nF={class:`text-2xs leading-4`},rF={class:`font-medium`},iF={key:0,class:`opacity-80`},aF=P({__name:`SystemNotices`,props:{control:{},configError:{},configPath:{}},setup(e){let t=e,n=W(()=>{let e=[],n=t.control?.auth;return t.configError&&e.push({id:`config`,tone:`danger`,text:`The config could not be read: ${t.configError}`,hint:`Fix ${t.configPath??`servers.config.json`} and restart the panel.`}),n&&(n.blockedReason&&e.push({id:`blocked`,tone:`danger`,text:n.blockedReason}),n.usingDefaultPassword?e.push({id:`default-password`,tone:`warn`,text:`This panel is still on its default password.`,hint:`Change it in Settings — binding beyond 127.0.0.1 stays refused until you do.`}):n.enabled&&!n.passwordSet&&e.push({id:`no-password`,tone:`warn`,text:`Authentication is on but no password is set, so nothing is being asked for.`,hint:`Set one in Settings to actually lock the panel.`}),n.exposed&&e.push({id:`exposed`,tone:`warn`,text:`This panel is reachable beyond 127.0.0.1.`,hint:`Keep the password strong, or put a TLS-terminating proxy in front of it.`}),!n.enabled&&!n.exposed&&e.push({id:`auth-off`,tone:`info`,text:`Authentication is disabled — the panel is only protected by its loopback bind.`})),e}),r={warn:{wrap:`border-warn/25 bg-warn-soft text-warn`,icon:jy},danger:{wrap:`border-danger/25 bg-danger-soft text-danger`,icon:zv},info:{wrap:`border-line bg-panel-2 text-muted`,icon:zv}};return(e,t)=>n.value.length>0?(L(),R(`div`,tF,[(L(!0),R(I,null,va(n.value,e=>(L(),R(`div`,{key:e.id,class:O([`flex items-start gap-2 px-3 py-1.5 sm:px-4`,r[e.tone].wrap])},[(L(),z(ma(r[e.tone].icon),{class:`mt-0.5 size-3.5 shrink-0`})),B(`p`,nF,[B(`span`,rF,k(e.text),1),e.hint?(L(),R(`span`,iF,k(e.hint),1)):U(``,!0)])],2))),128))])):U(``,!0)}}),oF={class:`pointer-events-none fixed bottom-4 right-4 z-[60] flex w-[min(92vw,22rem)] flex-col gap-2`,role:`status`,"aria-live":`polite`},sF={class:`min-w-0 flex-1`},cF={class:`text-xs font-medium text-ink`},lF={key:0,class:`mt-0.5 break-words text-2xs leading-4 text-muted`},uF=[`onClick`],dF=P({__name:`ToastStack`,setup(e){let{toasts:t,dismiss:n}=Kj(),r={ok:Bv,danger:Vv,warn:jy,info:ey,accent:ey,neutral:ey},i={ok:`text-ok`,danger:`text-danger`,warn:`text-warn`,info:`text-info`,neutral:`text-muted`,accent:`text-accent`},a=W(()=>t.value);return(e,t)=>(L(),R(`div`,oF,[V(Il,{"enter-active-class":`transition duration-150 ease-out`,"enter-from-class":`translate-x-2 opacity-0`,"leave-active-class":`transition duration-100 ease-in`,"leave-to-class":`translate-x-2 opacity-0`},{default:N(()=>[(L(!0),R(I,null,va(a.value,e=>(L(),R(`div`,{key:e.id,class:`pointer-events-auto flex items-start gap-2.5 rounded-panel border border-line bg-raise p-3 shadow-float`},[(L(),z(ma(r[e.tone]),{class:O(M(Q)(`mt-0.5 size-4 shrink-0`,i[e.tone]))},null,8,[`class`])),B(`div`,sF,[B(`p`,cF,k(e.title),1),e.description?(L(),R(`p`,lF,k(e.description),1)):U(``,!0)]),B(`button`,{type:`button`,class:`-mr-1 -mt-0.5 grid size-6 shrink-0 place-items-center rounded-control text-faint transition-colors duration-150 hover:bg-hover hover:text-ink`,"aria-label":`Dismiss`,onClick:t=>M(n)(e.id)},[V(M(My),{class:`size-3.5`})],8,uF)]))),128))]),_:1})]))}}),fF=`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60 focus-visible:ring-offset-2 focus-visible:ring-offset-page`,pF=`text-xs font-medium text-muted`,mF=`text-2xs leading-4 text-faint`,hF=[`w-full min-w-0 rounded-control border border-line bg-page/60 px-2.5 py-1.5 text-sm text-ink`,`placeholder:text-faint transition-colors duration-150`,`hover:border-line/80 hover:bg-page`,`focus:border-accent focus:bg-page focus:outline-none focus:ring-2 focus:ring-accent/25`,`disabled:cursor-not-allowed disabled:opacity-50`,`aria-[invalid=true]:border-danger aria-[invalid=true]:focus:ring-danger/25`].join(` `),gF=`${hF} font-mono text-xs`,_F=[`type`,`disabled`,`aria-busy`],$=P({inheritAttrs:!1,__name:`AppButton`,props:{variant:{default:`secondary`},size:{default:`sm`},type:{default:`button`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},setup(e){let t=e,n=Fa(),r={primary:`bg-accent text-accent-ink border-transparent hover:brightness-110 active:brightness-95 shadow-[inset_0_1px_0_rgb(255_255_255/0.14)]`,secondary:`bg-raise text-ink border-line hover:bg-hover`,ghost:`bg-transparent text-muted border-transparent hover:bg-hover hover:text-ink`,danger:`bg-danger text-white border-transparent hover:brightness-110 active:brightness-95`,"danger-ghost":`bg-transparent text-danger border-danger/30 hover:bg-danger-soft`},i={xs:`h-6 gap-1 px-1.5 text-2xs`,sm:`h-8 gap-1.5 px-2.5 text-xs`,md:`h-9 gap-2 px-3.5 text-sm`,icon:`h-9 w-9 justify-center`,"icon-sm":`h-8 w-8 justify-center`},a=W(()=>Q(`inline-flex select-none items-center rounded-control border font-medium whitespace-nowrap`,`transition-[background-color,border-color,color,filter,opacity] duration-150 ease-out`,`disabled:pointer-events-none disabled:opacity-45`,r[t.variant],i[t.size],t.block&&`w-full`,fF,n.class));return(e,r)=>(L(),R(`button`,Ms({...M(n),class:void 0},{type:t.type,class:a.value,disabled:t.disabled||t.loading,"aria-busy":t.loading||void 0}),[t.loading?(L(),z(M(ny),{key:0,class:`size-3.5 shrink-0 animate-spin`,"aria-hidden":`true`})):U(``,!0),F(e.$slots,`default`)],16,_F))}}),vF=P({__name:`Tip`,props:{label:{},side:{default:`top`},disabled:{type:Boolean,default:!1}},setup(e){return(t,n)=>(L(),z(M(gg),{"delay-duration":350},{default:N(()=>[V(M(xg),{"as-child":``},{default:N(()=>[F(t.$slots,`default`)]),_:3}),e.disabled?U(``,!0):(L(),z(M(bg),{key:0},{default:N(()=>[V(M(yg),{side:e.side,"side-offset":6,class:`z-50 max-w-64 rounded-control border border-line bg-raise px-2 py-1 text-2xs text-ink shadow-float data-[state=delayed-open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[H(k(e.label),1)]),_:1},8,[`side`])]),_:1}))]),_:3}))}}),yF={class:`flex h-13 shrink-0 items-center gap-3 border-b border-line bg-panel/80 px-3 backdrop-blur-sm sm:px-4`},bF={class:`truncate text-sm font-semibold tracking-tight text-ink`},xF={class:`ml-auto flex items-center gap-1.5`},SF={class:`hidden items-center gap-1.5 rounded-control border border-line bg-panel-2 px-2 py-1.5 md:flex`},CF={class:`font-mono text-2xs text-muted`},wF={class:`px-2 py-1.5`},TF={class:`truncate font-mono text-2xs text-muted`},EF=P({__name:`TopBar`,props:{panelUrl:{},connection:{},authenticated:{type:Boolean}},emits:[`menu`,`palette`,`signOut`],setup(e,{emit:t}){let n=e,r=t,i=zg(),a=NM(),o=W(()=>i.name===`server-detail`?`Servers / ${String(i.params.id??``)}`:String(i.meta.title??`home-hosted`)),s=W(()=>a.preference.value===`dark`?cy:a.preference.value===`light`?Ey:sy),c=W(()=>`Theme: ${a.preference.value}`),l=W(()=>({open:`bg-ok`,connecting:`bg-warn`,closed:`bg-danger`})[n.connection]),u=W(()=>({open:`Live updates`,connecting:`Connecting`,closed:`Reconnecting`})[n.connection]);return(t,i)=>(L(),R(`header`,yF,[B(`button`,{type:`button`,class:`grid size-8 shrink-0 place-items-center rounded-control text-muted hover:bg-hover hover:text-ink lg:hidden`,"aria-label":`Open navigation`,onClick:i[0]||=e=>r(`menu`)},[V(M(ay),{class:`size-4`})]),B(`h1`,bF,k(o.value),1),B(`div`,xF,[B(`button`,{type:`button`,class:O(M(Q)(`hidden h-8 items-center gap-2 rounded-control border border-line bg-panel-2 px-2.5 text-xs text-faint transition-colors duration-150 hover:border-line hover:text-muted sm:flex`,M(fF))),onClick:i[1]||=e=>r(`palette`)},[V(M(yy),{class:`size-3.5`}),i[5]||=B(`span`,{class:`pr-6`},`Search or run a command`,-1),i[6]||=B(`kbd`,{class:`rounded border border-line bg-page px-1 py-0.5 font-mono text-2xs text-faint`},`⌘K`,-1)],2),V(vF,{label:u.value},{default:N(()=>[B(`span`,SF,[B(`span`,{class:O(M(Q)(`size-1.5 rounded-full`,l.value))},null,2),B(`span`,CF,k(e.panelUrl),1)])]),_:1},8,[`label`]),V(vF,{label:c.value},{default:N(()=>[V($,{variant:`ghost`,size:`icon-sm`,"aria-label":c.value,onClick:i[2]||=e=>M(a).cycle()},{default:N(()=>[(L(),z(ma(s.value),{class:`size-4`}))]),_:1},8,[`aria-label`])]),_:1},8,[`label`]),n.authenticated?(L(),z(M(eg),{key:0},{default:N(()=>[V(M(ag),{"as-child":``},{default:N(()=>[V($,{variant:`ghost`,size:`icon-sm`,"aria-label":`Account`},{default:N(()=>[...i[7]||=[B(`span`,{class:`grid size-5 place-items-center rounded-full bg-accent-soft font-mono text-2xs font-semibold text-accent`},`hh`,-1)]]),_:1})]),_:1}),V(M(rg),null,{default:N(()=>[V(M(tg),{"side-offset":6,align:`end`,class:`z-50 min-w-44 rounded-panel border border-line bg-raise p-1 shadow-float data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[B(`div`,wF,[i[8]||=B(`p`,{class:`text-2xs text-faint`},` Signed in `,-1),B(`p`,TF,k(n.panelUrl),1)]),V(M(ig),{class:`my-1 h-px bg-line`}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:i[3]||=e=>r(`signOut`)},{default:N(()=>[V(M(iy),{class:`size-3.5`}),i[9]||=H(` Sign out `,-1)]),_:1})]),_:1})]),_:1})]),_:1})):U(``,!0),V(vF,{label:`Command palette`},{default:N(()=>[V($,{variant:`ghost`,size:`icon-sm`,class:`sm:hidden`,"aria-label":`Open the command palette`,onClick:i[4]||=e=>r(`palette`)},{default:N(()=>[V(M(Wv),{class:`size-4`})]),_:1})]),_:1})])]))}}),DF={key:1,class:`flex h-dvh overflow-hidden bg-page`},OF={class:`hidden w-60 shrink-0 border-r border-line bg-panel/50 lg:block`},kF={key:0,class:`fixed inset-y-0 left-0 z-40 w-64 border-r border-line bg-panel lg:hidden`},AF={class:`flex min-w-0 flex-1 flex-col`},jF=P({__name:`App`,setup(e){let t=zg(),n=Rg(),r=wM(),{session:i,logout:a}=Vj(),o=j(!1),s=j(!1),c=W(()=>i.value?.authenticated===!0),l=W(()=>i.value?.authRequired===!0),u=W(()=>t.name===`login`),d=W(()=>t.name===`logs`),f=W(()=>r.servers.value),p=W(()=>f.value.filter(e=>e.status===`running`).length),m=W(()=>r.control.value?.url??`—`),h=W(()=>r.host.value),g=W(()=>r.control.value?.label??`home-hosted`);return Ar([l,c],([e,t])=>{if(i.value!==null){if(e&&!t){SM(),n.push({name:`login`});return}xM()}},{immediate:!0}),Ar(()=>t.fullPath,()=>{s.value=!1}),ta(async()=>{(!l.value||c.value)&&await r.refresh()}),ze(()=>SM()),(e,t)=>{let n=fa(`RouterView`);return L(),z(M(fg),{"delay-duration":300},{default:N(()=>[u.value?(L(),z(n,{key:0})):(L(),R(`div`,DF,[B(`aside`,OF,[V(eF,{host:h.value,connection:M(r).connection.value,"panel-label":g.value,"plan-label":m.value,running:p.value,total:f.value.length},null,8,[`host`,`connection`,`panel-label`,`plan-label`,`running`,`total`])]),V(Dc,{"enter-active-class":`transition-opacity duration-150`,"leave-active-class":`transition-opacity duration-100`,"enter-from-class":`opacity-0`,"leave-to-class":`opacity-0`},{default:N(()=>[s.value?(L(),R(`div`,{key:0,class:`fixed inset-0 z-40 bg-black/45 lg:hidden`,onClick:t[0]||=e=>s.value=!1})):U(``,!0)]),_:1}),V(Dc,{"enter-active-class":`transition-transform duration-150 ease-out`,"leave-active-class":`transition-transform duration-100 ease-in`,"enter-from-class":`-translate-x-full`,"leave-to-class":`-translate-x-full`},{default:N(()=>[s.value?(L(),R(`aside`,kF,[V(eF,{host:h.value,connection:M(r).connection.value,"panel-label":g.value,"plan-label":m.value,running:p.value,total:f.value.length,onNavigate:t[1]||=e=>s.value=!1,onClose:t[2]||=e=>s.value=!1},null,8,[`host`,`connection`,`panel-label`,`plan-label`,`running`,`total`])])):U(``,!0)]),_:1}),B(`div`,AF,[V(EF,{"panel-url":m.value,connection:M(r).connection.value,authenticated:c.value,onMenu:t[3]||=e=>s.value=!0,onPalette:t[4]||=e=>o.value=!0,onSignOut:t[5]||=e=>M(a)()},null,8,[`panel-url`,`connection`,`authenticated`]),c.value?(L(),z(aF,{key:0,control:M(r).control.value,"config-error":M(r).configError.value,"config-path":M(r).appState.value?.configPath},null,8,[`control`,`config-error`,`config-path`])):U(``,!0),B(`main`,{class:O(M(Q)(`min-h-0 flex-1`,d.value?`overflow-hidden`:`overflow-y-auto`))},[V(n)],2)])])),V(wP,{open:o.value,"onUpdate:open":t[6]||=e=>o.value=e},null,8,[`open`]),V(dF)]),_:1})}}}),MF={key:0,class:`size-1.5 shrink-0 rounded-full bg-current`},NF=P({__name:`ToneBadge`,props:{tone:{default:`neutral`},dot:{type:Boolean,default:!1},mono:{type:Boolean,default:!1},plain:{type:Boolean,default:!1}},setup(e){let t=e,n=W(()=>Q(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium whitespace-nowrap`,t.plain?Q(`border-transparent bg-transparent`,dP[t.tone].split(` `).filter(e=>e.startsWith(`text-`)).join(` `)):dP[t.tone],t.mono&&`font-mono`));return(e,r)=>(L(),R(`span`,{class:O(n.value)},[t.dot?(L(),R(`span`,MF)):U(``,!0),F(e.$slots,`default`)],2))}}),PF={class:`relative flex min-h-dvh items-center justify-center overflow-hidden bg-page px-4 py-10`},FF={class:`hh-enter relative w-full max-w-md`},IF={class:`rounded-panel border border-line bg-panel/95 p-5 shadow-float backdrop-blur-sm`},LF={class:`flex items-start justify-between gap-3`},RF={class:`min-w-0`},zF={class:`text-base font-semibold text-ink`},BF={class:`mt-1 text-xs leading-relaxed text-muted`},VF={class:`flex flex-col gap-1.5`},HF={class:`relative`},UF=[`type`],WF=[`aria-label`],GF={key:0,class:`rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2 text-xs text-danger`},KF={key:1,class:`mt-5`},qF={class:`mt-4 space-y-2`},JF={key:0,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},YF={class:`text-2xs leading-4 text-warn`},XF={class:`ml-1 rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},ZF={key:1,class:`flex items-start gap-2 rounded-control border border-warn/25 bg-warn-soft px-2.5 py-2`},QF={key:2,class:`flex items-start gap-2 rounded-control border border-line-soft bg-panel-2 px-2.5 py-2`},$F={class:`text-2xs leading-4 text-muted`},eI={class:`mt-4 flex items-center justify-center gap-2 text-2xs text-faint`},tI={class:`font-mono`},nI=P({__name:`LoginView`,setup(e){let t=zg(),n=Rg(),r=wM(),{session:i,error:a,login:o,refresh:s}=Vj(),c=j(``),l=j(!1),u=j(!1),d=W(()=>i.value?.passwordSet===!1),f=W(()=>i.value!==null&&!i.value.authRequired),p=W(()=>i.value?.usingDefaultPassword===!0&&i.value.defaultPassword!==null),m=W(()=>r.control.value?.auth.exposed===!0),h=W(()=>r.control.value?.url??`—`),g=W(()=>d.value?`This panel has no password yet`:f.value?`Authentication is turned off`:`Sign in to continue`),_=W(()=>d.value?`Anything on this machine can reach it. Set a password right after you are in.`:f.value?`The panel only listens on loopback, which is the only thing protecting it right now.`:`The control panel is protected. Enter the password to continue.`);async function v(){l.value=!0;try{if(await o(c.value)){c.value=``;let e=typeof t.query.next==`string`?t.query.next:`/`;await n.push(e)}}finally{l.value=!1}}async function y(){await s(),await n.push(`/`)}return ta(async()=>{i.value===null&&await s()}),(e,t)=>(L(),R(`div`,PF,[t[11]||=B(`div`,{class:`bg-instrument pointer-events-none absolute inset-0 opacity-60`},null,-1),t[12]||=B(`div`,{class:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center,transparent_15%,var(--page)_78%)]`},null,-1),B(`div`,FF,[t[10]||=Os(`<div class="mb-6 flex items-center gap-3"><span class="grid size-11 shrink-0 place-items-center rounded-panel border border-accent/30 bg-accent-soft text-accent"><svg viewBox="0 0 24 24" class="size-6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><path d="M4 15.5a8 8 0 1 1 16 0"></path><path d="M12 15.5 15.6 10.2"></path><circle cx="12" cy="15.5" r="1.3" fill="currentColor" stroke="none"></circle></svg></span><div><p class="text-lg font-semibold tracking-tight text-ink"> home-hosted </p><p class="text-xs text-muted"> Process supervisor control panel </p></div></div>`,1),B(`section`,IF,[B(`div`,LF,[B(`div`,RF,[B(`h1`,zF,k(g.value),1),B(`p`,BF,k(_.value),1)]),m.value?(L(),z(NF,{key:0,tone:`warn`,dot:``},{default:N(()=>[...t[2]||=[H(` Exposed `,-1)]]),_:1})):U(``,!0)]),f.value?(L(),R(`div`,KF,[V($,{variant:`primary`,size:`md`,block:``,onClick:y},{default:N(()=>[...t[4]||=[H(` Open the dashboard `,-1)]]),_:1})])):(L(),R(`form`,{key:0,class:`mt-5 space-y-3`,onSubmit:lu(v,[`prevent`])},[B(`div`,VF,[B(`label`,{for:`hh-password`,class:O(M(pF))},`Password`,2),B(`div`,HF,[br(B(`input`,{id:`hh-password`,"onUpdate:modelValue":t[0]||=e=>c.value=e,type:u.value?`text`:`password`,autocomplete:`current-password`,autofocus:``,required:``,class:O(M(Q)(M(hF),`pr-9`))},null,10,UF),[[ru,c.value]]),B(`button`,{type:`button`,class:`absolute right-1 top-1/2 grid size-7 -translate-y-1/2 place-items-center rounded-control text-faint transition-colors duration-150 hover:text-ink`,"aria-label":u.value?`Hide password`:`Show password`,onClick:t[1]||=e=>u.value=!u.value},[u.value?(L(),z(M(Xv),{key:0,class:`size-3.5`})):(L(),z(M(Zv),{key:1,class:`size-3.5`}))],8,WF)])]),M(a)?(L(),R(`p`,GF,k(M(a)),1)):U(``,!0),V($,{type:`submit`,variant:`primary`,size:`md`,block:``,loading:l.value},{default:N(()=>[V(M(ry),{class:`size-3.5`}),t[3]||=H(` Sign in `,-1)]),_:1},8,[`loading`])],32)),B(`div`,qF,[p.value?(L(),R(`div`,JF,[V(M(xy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),B(`p`,YF,[t[5]||=H(` Still on the default password `,-1),B(`code`,XF,k(M(i)?.defaultPassword),1),t[6]||=H(`. Change it under Settings — binding beyond 127.0.0.1 stays refused until you do. `,-1)])])):d.value?(L(),R(`div`,ZF,[V(M(Cy),{class:`mt-0.5 size-3.5 shrink-0 text-warn`}),t[7]||=B(`p`,{class:`text-2xs leading-4 text-warn`},[H(` No password is set. Open Settings from this machine to add one, or run `),B(`code`,{class:`rounded bg-black/10 px-1 py-0.5 font-mono dark:bg-white/10`},`pnpm run auth:set-password`),H(`. `)],-1)])):(L(),R(`div`,QF,[V(M(Sy),{class:`mt-0.5 size-3.5 shrink-0 text-ok`}),B(`p`,$F,` Sessions last `+k(Math.round((M(i)?.sessionTtlMs??0)/864e5))+` days. Signing out clears this browser only. `,1)]))])]),B(`p`,eI,[B(`span`,tI,k(h.value),1),t[8]||=B(`span`,{"aria-hidden":`true`},`·`,-1),t[9]||=B(`span`,null,`served from this machine`,-1)])])]))}}),rI=[`#3f4a5c`,`#f07178`,`#7fd88f`,`#e6b673`,`#82aaff`,`#c792ea`,`#7fdbca`,`#c7d2e3`,`#5a6779`,`#ff8b92`,`#9ae6a8`,`#f2c98a`,`#9dbaff`,`#d7aef0`,`#9ce9dc`,`#eef3fb`],iI=[`#4b5563`,`#c0392b`,`#1c7c3f`,`#9a6700`,`#2f5fe0`,`#7c3aed`,`#0b6f89`,`#334155`,`#6b7280`,`#d64535`,`#22854a`,`#a8620d`,`#3f6bff`,`#8b5cf6`,`#0e7d9c`,`#0f1722`],aI=/\u001B\[([0-9;]*)m/g,oI=/\u001B(?:\[[0-9;?]*[A-HJKSTfhilmnprsu]|\][^\u0007\u001B]*(?:\u0007|\u001B\\)?|[()][0-9A-Z])/g;function sI(e){return Math.max(0,Math.min(255,e))}function cI(e){return e===0?0:55+e*40}function lI(e,t){let n=t?rI:iI;if(e<16)return n[e]??n[7];if(e<232){let t=e-16;return`rgb(${cI(Math.floor(t/36))} ${cI(Math.floor(t%36/6))} ${cI(t%6)})`}let r=8+(e-232)*10;return`rgb(${r} ${r} ${r})`}function uI(){return{fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}}function dI(e,t,n){let r=t.length===0?[0]:t.split(`;`).map(e=>e.length===0?0:Number(e));for(let t=0;t<r.length;t+=1){let i=r[t];if(i===0)Object.assign(e,uI());else if(i===1)e.bold=!0;else if(i===2)e.dim=!0;else if(i===3)e.italic=!0;else if(i===4)e.underline=!0;else if(i===22)e.bold=!1,e.dim=!1;else if(i===23)e.italic=!1;else if(i===24)e.underline=!1;else if(i===39)e.fg=null;else if(i===49)e.bg=null;else if(i>=30&&i<=37)e.fg=(n?rI:iI)[i-30]??null;else if(i>=90&&i<=97)e.fg=(n?rI:iI)[i-90+8]??null;else if(i>=40&&i<=47)e.bg=(n?rI:iI)[i-40]??null;else if(i>=100&&i<=107)e.bg=(n?rI:iI)[i-100+8]??null;else if(i===38||i===48){let a=i===38?`fg`:`bg`,o=r[t+1];o===5&&r[t+2]!==void 0?(e[a]=lI(sI(r[t+2]),n),t+=2):o===2&&(e[a]=`rgb(${sI(r[t+2]??0)} ${sI(r[t+3]??0)} ${sI(r[t+4]??0)})`,t+=4)}}}function fI(e,t,n){if(t.length===0)return;let r=e[e.length-1];if(r&&r.fg===n.fg&&r.bg===n.bg&&r.bold===n.bold&&r.dim===n.dim&&r.italic===n.italic&&r.underline===n.underline){r.text+=t;return}e.push({text:t,...n})}function pI(e){return e.includes(`\x1B`)}function mI(e,t=!0){if(!pI(e))return[{text:e,fg:null,bg:null,bold:!1,dim:!1,italic:!1,underline:!1}];let n=[],r=uI(),i=0;aI.lastIndex=0;let a=aI.exec(e);for(;a!==null;)fI(n,e.slice(i,a.index).replace(oI,``),r),dI(r,a[1]??``,t),i=a.index+a[0].length,a=aI.exec(e);return fI(n,e.slice(i).replace(oI,``),r),n}function hI(e){let t=new Date(e);return`${t.toLocaleTimeString(void 0,{hour12:!1})}.${String(t.getMilliseconds()).padStart(3,`0`)}`}function gI(e){return new Date(e).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}function _I(e){if(!Number.isFinite(e)||e<0)return`—`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function vI(e,t){let n=Math.max(0,e-t);return n<1e3?`now`:n<6e4?`in ${Math.ceil(n/1e3)}s`:`in ${Math.ceil(n/6e4)}m`}function yI(e){return e===null?`—`:`${(e*100).toFixed(e>=.999?0:1)}%`}function bI(e,t){if(e===null)return`never`;let n=Math.max(0,t-e);return n<6e4?`${Math.floor(n/1e3)}s ago`:n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}function xI(e){return Number.isFinite(e)?e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(0)} KiB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(2)} GiB`:`—`}function SI(e){if(e===null||!Number.isFinite(e))return`—`;let t=Math.abs(e);return t<1e3?`${e} B`:t<1e6?`${(e/1e3).toFixed(0)} kB`:t<1e9?`${(e/1e3/1e3).toFixed(1)} MB`:`${(e/1e3/1e3/1e3).toFixed(2)} GB`}function CI(e){return e===null||!Number.isFinite(e)?`—`:e>=100?`${Math.round(e)}%`:`${e.toFixed(1)}%`}var wI={class:`flex h-5 w-max min-w-full items-center gap-2 whitespace-pre px-2 font-mono text-xs leading-5`},TI={key:0,class:`shrink-0 select-none text-faint`},EI={class:`min-w-0`},DI=P({__name:`LogRow`,props:{line:{},query:{},dark:{type:Boolean},showTime:{type:Boolean}},setup(e){let t=e,n=W(()=>mI(t.line.text,t.dark)),r=W(()=>{let e=t.query.trim().toLowerCase(),r=[];for(let t of n.value){if(e.length===0){r.push({text:t.text,hit:!1,span:t});continue}let n=t.text.toLowerCase(),i=0,a=n.indexOf(e);for(;a!==-1;)a>i&&r.push({text:t.text.slice(i,a),hit:!1,span:t}),r.push({text:t.text.slice(a,a+e.length),hit:!0,span:t}),i=a+e.length,a=n.indexOf(e,i);i<t.text.length&&r.push({text:t.text.slice(i),hit:!1,span:t})}return r}),i={stdout:`bg-transparent`,stderr:`bg-danger`,system:`bg-info`};function a(e){let t={};return e.span.fg&&(t.color=e.span.fg),e.span.bg&&(t.backgroundColor=e.span.bg),e.span.bold&&(t.fontWeight=`600`),e.span.dim&&(t.opacity=`0.62`),e.span.italic&&(t.fontStyle=`italic`),e.span.underline&&(t.textDecoration=`underline`),e.hit&&(t.backgroundColor=`var(--warn)`,t.color=`var(--accent-ink)`,t.borderRadius=`2px`),t}return(e,n)=>(L(),R(`div`,wI,[t.showTime?(L(),R(`span`,TI,k(M(hI)(t.line.ts)),1)):U(``,!0),B(`span`,{class:O([`h-3.5 w-0.5 shrink-0 rounded-full`,[i[t.line.stream]]]),"aria-hidden":`true`},null,2),B(`span`,EI,[(L(!0),R(I,null,va(r.value,(e,t)=>(L(),R(`span`,{key:t,style:ge(a(e))},k(e.text),5))),128))])]))}}),OI={class:`inline-flex items-center gap-0.5 rounded-control border border-line bg-panel-2 p-0.5`},kI=[`aria-pressed`,`onClick`],AI=P({__name:`SegmentedControl`,props:za({options:{},size:{default:`sm`}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`);return(e,r)=>(L(),R(`div`,OI,[(L(!0),R(I,null,va(t.options,e=>(L(),R(`button`,{key:e.value,type:`button`,class:O(M(Q)(`rounded-[5px] font-medium transition-colors duration-150`,t.size===`sm`?`h-6 px-2 text-2xs`:`h-7 px-2.5 text-xs`,n.value===e.value?`bg-raise text-ink shadow-card`:`text-muted hover:text-ink`)),"aria-pressed":n.value===e.value,onClick:t=>n.value=e.value},k(e.label),11,kI))),128))]))}}),jI={class:`flex min-h-0 flex-col overflow-hidden rounded-panel border border-line bg-panel`},MI={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel-2/60 px-2.5 py-2`},NI={class:`relative min-w-40 flex-1 sm:max-w-72`},PI={class:`absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5`},FI={key:0,class:`px-1 font-mono text-2xs tabular-nums text-faint`},II={class:`ml-auto flex items-center gap-1.5`},LI=[`href`,`download`],RI={class:`relative min-h-0 flex-1`},zI={key:0,class:`px-3 py-6 text-center text-xs text-faint`},BI={class:`flex items-center gap-3 border-t border-line bg-panel-2/60 px-2.5 py-1.5 text-2xs text-faint`},VI={class:`flex items-center gap-1.5`},HI={class:`font-mono tabular-nums`},UI={key:0,class:`font-mono tabular-nums`},WI=20,GI=12,KI=P({__name:`LogViewer`,props:{lines:{},version:{default:0},live:{type:Boolean,default:!1},emptyHint:{default:`No output yet.`},clearable:{type:Boolean,default:!1},downloadUrl:{default:void 0},downloadName:{default:void 0},minHeight:{default:`16rem`}},emits:[`clear`],setup(e,{emit:t}){let n=e,r=t,i=NM(),a=j(null),o=j(0),s=j(320),c=j(!0),l=j(`all`),u=j(``),d=j(!0),f=j(0),p=W(()=>{n.version;let e=u.value.trim().toLowerCase(),t=l.value;return e.length===0&&t===`all`?n.lines:n.lines.filter(n=>!(t!==`all`&&n.stream!==t||e.length>0&&!n.text.toLowerCase().includes(e)))}),m=W(()=>p.value.length),h=W(()=>{let e=u.value.trim().toLowerCase();if(e.length===0)return[];let t=[],n=p.value;for(let r=0;r<n.length;r+=1)n[r].text.toLowerCase().includes(e)&&t.push(r);return t}),g=W(()=>Math.max(0,Math.floor(o.value/WI)-GI)),_=W(()=>Math.min(m.value,Math.ceil((o.value+s.value)/WI)+GI)),v=W(()=>p.value.slice(g.value,_.value)),y=W(()=>h.value[f.value]??-1);function b(){let e=a.value;if(!e)return;o.value=e.scrollTop;let t=e.scrollHeight-e.scrollTop-e.clientHeight;c.value=t<12}function x(){let e=a.value;e&&(e.scrollTop=e.scrollHeight,o.value=e.scrollTop,c.value=!0)}function S(e){let t=a.value;t&&(t.scrollTop=Math.max(0,e*WI-t.clientHeight/2),o.value=t.scrollTop,c.value=!1)}function C(e){let t=h.value.length;t!==0&&(f.value=(f.value+e+t)%t,S(h.value[f.value]))}Ar(m,()=>{c.value&&(f.value=0,requestAnimationFrame(x))}),Ar(h,()=>{f.value=0,h.value.length>0&&u.value.trim().length>0&&requestAnimationFrame(()=>S(h.value[0]))}),Ar(l,()=>{c.value=!0,requestAnimationFrame(x)});let w=null;ta(()=>{let e=a.value;e&&(s.value=e.clientHeight,w=new ResizeObserver(()=>{a.value&&(s.value=a.value.clientHeight)}),w.observe(e),x())}),ze(()=>{w?.disconnect(),w=null});let T=[{value:`all`,label:`All`},{value:`stdout`,label:`out`},{value:`stderr`,label:`err`},{value:`system`,label:`sys`}];return(e,t)=>(L(),R(`div`,jI,[B(`header`,MI,[V(AI,{modelValue:l.value,"onUpdate:modelValue":t[0]||=e=>l.value=e,options:T},null,8,[`modelValue`]),B(`div`,NI,[V(M(yy),{class:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),br(B(`input`,{"onUpdate:modelValue":t[1]||=e=>u.value=e,type:`search`,placeholder:`Search this output`,class:O([`h-7 py-0 pl-7 text-xs`,[M(hF)]]),"aria-label":`Search the log output`,onKeydown:t[2]||=du(lu(e=>C(e.shiftKey?-1:1),[`prevent`]),[`enter`])},null,34),[[Jl,u.value]]),B(`div`,PI,[u.value.trim().length>0?(L(),R(`span`,FI,k(h.value.length===0?`0`:`${f.value+1}/${h.value.length}`),1)):U(``,!0),u.value.length>0?(L(),R(`button`,{key:1,type:`button`,class:`grid size-5 place-items-center rounded text-faint hover:text-ink`,"aria-label":`Clear the search`,onClick:t[3]||=e=>u.value=``},[V(M(My),{class:`size-3`})])):U(``,!0),h.value.length>0?(L(),R(`button`,{key:2,type:`button`,class:`grid size-5 place-items-center rounded text-faint hover:text-ink`,"aria-label":`Previous match`,onClick:t[4]||=e=>C(-1)},[V(M(Rv),{class:`size-3`})])):U(``,!0),h.value.length>0?(L(),R(`button`,{key:3,type:`button`,class:`grid size-5 place-items-center rounded text-faint hover:text-ink`,"aria-label":`Next match`,onClick:t[5]||=e=>C(1)},[V(M(Fv),{class:`size-3`})])):U(``,!0)])]),B(`div`,II,[V(vF,{label:d.value?`Hide timestamps`:`Show timestamps`},{default:N(()=>[V($,{size:`xs`,variant:`ghost`,onClick:t[6]||=e=>d.value=!d.value},{default:N(()=>[V(M(Hv),{class:O(M(Q)(`size-3`,d.value?`fill-accent text-accent`:`text-faint`))},null,8,[`class`]),t[9]||=H(` ts `,-1)]),_:1})]),_:1},8,[`label`]),V($,{size:`xs`,variant:c.value?`secondary`:`primary`,onClick:t[7]||=e=>c.value?c.value=!1:x()},{default:N(()=>[(L(),z(ma(c.value?M(uy):M(fy)),{class:`size-3`})),H(` `+k(c.value?`Pause`:`Follow`),1)]),_:1},8,[`variant`]),n.clearable?(L(),z(vF,{key:0,label:`Clear the in-memory buffer`},{default:N(()=>[V($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Clear the log buffer`,onClick:t[8]||=e=>r(`clear`)},{default:N(()=>[V(M(Ay),{class:`size-3.5`})]),_:1})]),_:1})):U(``,!0),n.downloadUrl?(L(),z(vF,{key:1,label:`Download the persisted file`},{default:N(()=>[B(`a`,{href:n.downloadUrl,download:n.downloadName},[V($,{size:`icon-sm`,variant:`ghost`,"aria-label":`Download the log file`},{default:N(()=>[V(M(Nv),{class:`size-3.5`})]),_:1})],8,LI)]),_:1})):U(``,!0)])]),B(`div`,RI,[B(`div`,{ref_key:`scroller`,ref:a,class:`h-full overflow-auto overscroll-contain bg-page/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/50`,style:ge({minHeight:n.minHeight}),tabindex:`0`,role:`log`,"aria-label":`Log output`,onScrollPassive:b},[m.value===0?(L(),R(`p`,zI,k(n.lines.length===0?n.emptyHint:`Nothing matches that search or stream filter.`),1)):(L(),R(`div`,{key:1,class:`relative w-full`,style:ge({height:`${m.value*WI}px`})},[(L(!0),R(I,null,va(v.value,(e,t)=>(L(),R(`div`,{key:g.value+t,class:O([`absolute left-0 top-0`,g.value+t===y.value&&`bg-warn/10`]),style:ge({transform:`translateY(${(g.value+t)*WI}px)`})},[V(DI,{line:e,query:u.value,dark:M(i).isDark.value,"show-time":d.value},null,8,[`line`,`query`,`dark`,`show-time`])],6))),128))],4))],36),V(Dc,{"enter-active-class":`transition duration-150`,"leave-active-class":`transition duration-100`,"enter-from-class":`opacity-0 translate-y-1`,"leave-to-class":`opacity-0 translate-y-1`},{default:N(()=>[!c.value&&m.value>0?(L(),R(`button`,{key:0,type:`button`,class:`absolute bottom-3 right-4 flex items-center gap-1.5 rounded-full border border-line bg-raise px-2.5 py-1 text-2xs text-muted shadow-float transition-colors duration-150 hover:text-ink`,onClick:x},[V(M(Nv),{class:`size-3`}),t[10]||=H(` Jump to latest `,-1)])):U(``,!0)]),_:1})]),B(`footer`,BI,[B(`span`,VI,[B(`span`,{class:O(M(Q)(`size-1.5 rounded-full`,n.live?c.value?`bg-ok`:`bg-warn`:`bg-faint`))},null,2),H(` `+k(n.live?c.value?`streaming`:`paused`:`snapshot`),1)]),B(`span`,HI,k(m.value===n.lines.length?`${m.value} lines`:`${m.value} of ${n.lines.length} lines`),1),u.value.trim().length>0?(L(),R(`span`,UI,k(h.value.length)+` matches`,1)):U(``,!0),B(`span`,{class:`ml-auto hidden font-mono tabular-nums sm:inline`},`row height `+k(WI)+`px · windowed`)])]))}}),qI={key:0,class:`grid size-10 place-items-center rounded-full border border-line bg-panel-2 text-faint`},JI={class:`max-w-sm space-y-1`},YI={class:`text-sm font-medium text-ink`},XI={key:0,class:`text-xs leading-relaxed text-muted`},ZI={key:1,class:`flex items-center gap-2`},QI=P({__name:`EmptyState`,props:{title:{},description:{default:void 0},compact:{type:Boolean,default:!1}},setup(e){return(e,t)=>(L(),R(`div`,{class:O(M(Q)(`flex flex-col items-center justify-center gap-3 text-center`,e.$props.compact?`px-4 py-8`:`px-6 py-14`))},[e.$slots.icon?(L(),R(`div`,qI,[F(e.$slots,`icon`)])):U(``,!0),B(`div`,JI,[B(`p`,YI,k(e.$props.title),1),e.$props.description?(L(),R(`p`,XI,k(e.$props.description),1)):U(``,!0)]),e.$slots.action?(L(),R(`div`,ZI,[F(e.$slots,`action`)])):U(``,!0)],2))}}),$I={class:`flex items-start justify-between gap-4 border-b border-line px-4 py-3`},eL={class:`min-w-0`},tL={class:`max-h-[calc(88dvh-3.25rem)] overflow-y-auto px-4 py-3.5`},nL={key:0,class:`flex items-center justify-end gap-2 border-t border-line bg-panel-2 px-4 py-3`},rL=P({__name:`Modal`,props:za({title:{},description:{default:void 0},width:{default:`w-[min(92vw,34rem)]`}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:[`update:open`],setup(e){let t=e,n=so(e,`open`);return(e,r)=>(L(),z(M(lf),{open:n.value,"onUpdate:open":r[0]||=e=>n.value=e},{default:N(()=>[V(M(Yf),null,{default:N(()=>[V(M(qf),{class:`fixed inset-0 z-50 bg-black/45 backdrop-blur-[1px] data-[state=closed]:animate-[hh-fade-out_120ms_ease-in] data-[state=open]:animate-[hh-fade-in_150ms_ease-out]`}),V(M(Wf),{class:O(M(Q)(`fixed left-1/2 top-1/2 z-50 max-h-[88dvh] -translate-x-1/2 -translate-y-1/2 overflow-hidden`,`rounded-panel border border-line bg-panel shadow-float`,`data-[state=closed]:animate-[hh-pop-out_120ms_ease-in] data-[state=open]:animate-[hh-pop-in_160ms_var(--ease-out-quick)]`,t.width))},{default:N(()=>[B(`header`,$I,[B(`div`,eL,[V(M(Xf),{class:`text-sm font-semibold text-ink`},{default:N(()=>[H(k(t.title),1)]),_:1}),t.description?(L(),z(M(Gf),{key:0,class:`mt-0.5 text-xs text-muted`},{default:N(()=>[H(k(t.description),1)]),_:1})):U(``,!0)]),V(M(uf),{class:O(M(Q)(`-mr-1 -mt-0.5 grid size-7 shrink-0 place-items-center rounded-control text-muted transition-colors duration-150 hover:bg-hover hover:text-ink`,M(fF))),"aria-label":`Close`},{default:N(()=>[V(M(My),{class:`size-4`})]),_:1},8,[`class`])]),B(`div`,tL,[F(e.$slots,`default`)]),e.$slots.footer?(L(),R(`footer`,nL,[F(e.$slots,`footer`)])):U(``,!0)]),_:3},8,[`class`])]),_:3})]),_:3},8,[`open`]))}}),iL=[`for`],aL={class:`relative`},oL=[`id`],sL=[`value`,`disabled`],cL={key:1,class:`text-2xs text-danger`},lL=P({inheritAttrs:!1,__name:`SelectField`,props:za({label:{default:void 0},hint:{default:void 0},error:{default:null},options:{},wide:{type:Boolean,default:!1},mono:{type:Boolean,default:!1}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`),r=li();return(e,i)=>(L(),R(`div`,{class:O(M(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(L(),R(`label`,{key:0,for:M(r),class:O(M(pF))},k(t.label),11,iL)):U(``,!0),B(`div`,aL,[br(B(`select`,Ms({id:M(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,class:M(Q)(M(hF),`cursor-pointer appearance-none pr-7`,t.mono&&`font-mono text-xs`,t.error&&`border-danger`)},e.$attrs),[(L(!0),R(I,null,va(t.options,e=>(L(),R(`option`,{key:e.value,value:e.value,disabled:e.disabled},k(e.label),9,sL))),128))],16,oL),[[Ql,n.value]]),V(M(Fv),{class:`pointer-events-none absolute right-2 top-1/2 size-3.5 -translate-y-1/2 text-faint`,"aria-hidden":`true`})]),t.error?(L(),R(`p`,cL,k(t.error),1)):t.hint?(L(),R(`p`,{key:2,class:O(M(mF))},k(t.hint),3)):U(``,!0)],2))}}),uL=P({__name:`Skeleton`,props:{class:{default:`h-4 w-24`},rounded:{default:`rounded`}},setup(e){return(t,n)=>(L(),R(`span`,{class:O(M(Q)(`block animate-pulse bg-line-soft`,e.rounded,t.$props.class)),style:{"animation-duration":`1.4s`},"aria-hidden":`true`},null,2))}}),dL={class:`flex h-full min-h-0`},fL={class:`hidden w-64 shrink-0 flex-col border-r border-line bg-panel/40 md:flex`},pL={class:`border-b border-line px-3 py-2.5`},mL={class:`mt-0.5 text-2xs text-faint`},hL={class:`min-h-0 flex-1 overflow-y-auto p-1.5`},gL={key:0,class:`space-y-1.5 p-1.5`},_L=[`onClick`],vL={class:`min-w-0 flex-1`},yL={class:`block truncate font-mono text-2xs text-faint`},bL={class:`flex min-w-0 flex-1 flex-col`},xL={class:`flex flex-wrap items-center gap-2 border-b border-line bg-panel/40 px-3 py-2.5`},SL={class:`min-w-0`},CL={class:`truncate text-sm font-semibold text-ink`},wL={key:0,class:`ml-1.5 font-mono text-2xs font-normal text-faint`},TL={key:0,class:`flex flex-wrap items-center gap-1.5 border-b border-line-soft bg-panel-2/40 px-3 py-2`},EL=[`href`,`download`],DL={class:`text-faint`},OL={key:1,class:`text-2xs text-faint`},kL={key:2,class:`ml-auto font-mono text-2xs text-faint`},AL={key:1,class:`flex items-center gap-1.5 border-b border-danger/25 bg-danger-soft px-3 py-2 text-2xs text-danger`},jL={class:`min-h-0 flex-1 p-3`},ML=P({__name:`LogsView`,setup(e){let t=zg(),n=Rg(),r=j([]),i=j(null),a=j(`disk`),o=j(`2000`),s=j(!1),c=j(null),l=j([]),u=j(0),d=j(!1),f=j(!0),p=W(()=>r.value.find(e=>e.serverId===i.value)??null),m=CM(()=>a.value===`live`?i.value:null),h=m.version,g=W(()=>(h.value,m.lines())),_=W(()=>a.value===`live`?g.value:l.value),v=W(()=>a.value===`live`?h.value:u.value),y=[{value:`200`,label:`200 lines`},{value:`500`,label:`500 lines`},{value:`2000`,label:`2000 lines`},{value:`5000`,label:`5000 lines`}],b=W(()=>r.value.reduce((e,t)=>e+t.sizeBytes,0)),x=W(()=>r.value.filter(e=>e.files.length>0).length);async function S(){f.value=!0;try{r.value=await pj();let e=typeof t.query.server==`string`?t.query.server:null,n=e&&r.value.some(t=>t.serverId===e)?e:i.value&&r.value.some(e=>e.serverId===i.value)?i.value:r.value[0]?.serverId??null;i.value=n}catch(e){c.value=e instanceof Error?e.message:String(e)}finally{f.value=!1}}async function C(){let e=i.value;if(e!==null&&a.value!==`live`){s.value=!0,c.value=null;try{let t=await mj(e,{tail:Number(o.value)});l.value=t.lines,u.value+=1}catch(e){c.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}}async function w(){let e=i.value;if(e!==null){d.value=!1;try{await hj(e),l.value=[],u.value+=1,await S()}catch(e){c.value=e instanceof Error?e.message:String(e)}}}function T(e){i.value=e,a.value===`live`&&(l.value=[]),n.replace({query:{...t.query,server:e}})}return Ar([i,o,a],()=>{a.value===`disk`&&C()},{immediate:!1}),ta(async()=>{await S(),a.value===`disk`&&await C()}),(e,t)=>(L(),R(`div`,dL,[B(`aside`,fL,[B(`div`,pL,[t[5]||=B(`p`,{class:`text-xs font-semibold text-ink`},` Persisted logs `,-1),B(`p`,mL,k(x.value)+` of `+k(r.value.length)+` servers on disk · `+k(M(xI)(b.value)),1)]),B(`div`,hL,[f.value?(L(),R(`div`,gL,[(L(),R(I,null,va(5,e=>V(uL,{key:e,class:`h-10 w-full`,rounded:`rounded-control`})),64))])):(L(!0),R(I,{key:1},va(r.value,e=>(L(),R(`button`,{key:e.serverId,type:`button`,class:O(M(Q)(`flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors duration-150`,e.serverId===i.value?`bg-accent-soft`:`hover:bg-hover`)),onClick:t=>T(e.serverId)},[B(`span`,{class:O(M(Q)(`size-1.5 shrink-0 rounded-full`,M(fP)[M(cP)[e.status].tone]))},null,2),B(`span`,vL,[B(`span`,{class:O(M(Q)(`block truncate text-xs`,e.serverId===i.value?`font-medium text-accent`:`text-ink`))},k(e.label),3),B(`span`,yL,k(e.files.length>0?`${e.files.length} file${e.files.length===1?``:`s`} · ${M(xI)(e.sizeBytes)}`:`nothing persisted`),1)])],10,_L))),128)),!f.value&&r.value.length===0?(L(),z(QI,{key:2,compact:``,title:`No servers`,description:`Add one and its output will be persisted here.`})):U(``,!0)]),t[6]||=B(`div`,{class:`border-t border-line p-2.5`},[B(`p`,{class:`text-2xs leading-4 text-faint`},` Rotation and retention are set under Settings → Log storage. `)],-1)]),B(`div`,bL,[B(`header`,xL,[B(`div`,SL,[B(`h1`,CL,[H(k(p.value?.label??`Logs`)+` `,1),p.value?(L(),R(`span`,wL,k(p.value.serverId),1)):U(``,!0)])]),V(AI,{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,class:`ml-auto`,options:[{value:`disk`,label:`Persisted`},{value:`live`,label:`Live stream`}]},null,8,[`modelValue`]),a.value===`disk`?(L(),z(lL,{key:0,modelValue:o.value,"onUpdate:modelValue":t[1]||=e=>o.value=e,options:y,class:`w-32`,"aria-label":`Tail size`},null,8,[`modelValue`])):U(``,!0),a.value===`disk`?(L(),z($,{key:1,size:`sm`,loading:s.value,onClick:C},{default:N(()=>[V(M(hy),{class:`size-3.5`}),t[7]||=H(`Reload `,-1)]),_:1},8,[`loading`])):U(``,!0),a.value===`disk`?(L(),z($,{key:2,size:`sm`,variant:`ghost`,disabled:!p.value||p.value.files.length===0,onClick:t[2]||=e=>d.value=!0},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),t[8]||=H(`Clear file `,-1)]),_:1},8,[`disabled`])):U(``,!0)]),p.value?(L(),R(`div`,TL,[V(M(Qv),{class:`size-3.5 shrink-0 text-faint`}),p.value.files.length>0?(L(!0),R(I,{key:0},va(p.value.files,e=>(L(),R(`a`,{key:e.name,href:gj(p.value.serverId,e.name),download:e.name,class:`inline-flex items-center gap-1 rounded-full border border-line px-2 py-0.5 font-mono text-2xs text-muted transition-colors duration-150 hover:border-accent/40 hover:text-accent`},[H(k(e.name)+` `,1),B(`span`,DL,k(M(xI)(e.sizeBytes)),1),V(M(Nv),{class:`size-3`})],8,EL))),128)):(L(),R(`span`,OL,` Nothing on disk for this server — persistence is off, or it has not written anything yet. `)),a.value===`disk`&&l.value.length>0?(L(),R(`span`,kL,` loaded `+k(l.value.length)+` lines `,1)):U(``,!0)])):U(``,!0),c.value?(L(),R(`p`,AL,[V(M(zv),{class:`size-3.5`}),H(` `+k(c.value),1)])):U(``,!0),B(`div`,jL,[p.value?s.value&&_.value.length===0?(L(),z(uL,{key:1,class:`h-full w-full`,rounded:`rounded-panel`})):(L(),z(KI,{key:2,lines:_.value,version:v.value,live:a.value===`live`,class:`h-full`,"empty-hint":a.value===`live`?`Connected — waiting for output.`:`The persisted file is empty.`,"min-height":`100%`},null,8,[`lines`,`version`,`live`,`empty-hint`])):(L(),z(QI,{key:0,title:`Pick a server`,description:`Persisted output and live streams are per server. Choose one from the list.`},{icon:N(()=>[V(M(vy),{class:`size-4`})]),_:1}))])]),V(rL,{open:d.value,"onUpdate:open":t[4]||=e=>d.value=e,title:`Clear the persisted log file?`,description:`${p.value?.serverId??``} — the file on disk is truncated. The process keeps running and new lines are written from here on.`,width:`w-[min(92vw,26rem)]`},{footer:N(()=>[V($,{variant:`ghost`,onClick:t[3]||=e=>d.value=!1},{default:N(()=>[...t[9]||=[H(` Keep it `,-1)]]),_:1}),V($,{variant:`danger`,onClick:w},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),t[10]||=H(`Clear `,-1)]),_:1})]),default:N(()=>[t[11]||=B(`p`,{class:`text-xs text-muted`},` Download it first if the output is still needed — this cannot be undone from the panel. `,-1)]),_:1},8,[`open`,`description`])]))}}),NL=P({__name:`Meter`,props:{value:{},warnAt:{default:75},dangerAt:{default:90},height:{default:`h-1.5`},class:{default:void 0}},setup(e){let t=e,n=W(()=>t.value===null||!Number.isFinite(t.value)?0:Math.min(100,Math.max(0,t.value))),r=W(()=>t.value===null?`neutral`:t.value>=t.dangerAt?`danger`:t.value>=t.warnAt?`warn`:`ok`),i={ok:`bg-ok/80`,warn:`bg-warn/85`,danger:`bg-danger/85`,info:`bg-info/80`,neutral:`bg-faint/60`,accent:`bg-accent/80`};return(e,a)=>(L(),R(`div`,{class:O(M(Q)(`w-full overflow-hidden rounded-full bg-line-soft`,t.height,t.class))},[B(`div`,{class:O(M(Q)(`h-full rounded-full transition-[width] duration-300 ease-out`,i[r.value])),style:ge({width:`${n.value}%`})},null,6)],2))}}),PL={key:1,class:`space-y-4`},FL={class:`grid grid-cols-2 gap-3 sm:grid-cols-4`},IL={class:`grid grid-cols-2 gap-x-4 gap-y-2 border-t border-line-soft pt-3 sm:grid-cols-4`},LL={class:`flex items-center gap-1 text-2xs text-faint`},RL={class:`font-mono text-xs text-ink`},zL={class:`font-mono text-xs tabular-nums text-ink`},BL={class:`flex items-center gap-1 text-2xs text-faint`},VL={class:`font-mono text-xs text-ink`},HL={class:`flex items-center gap-1 text-2xs text-faint`},UL={class:`font-mono text-xs text-ink`},WL={class:`space-y-2 border-t border-line-soft pt-3`},GL={class:`flex items-center gap-1.5 text-2xs font-medium text-faint`},KL={class:`flex items-baseline justify-between gap-2`},qL=[`title`],JL={class:`shrink-0 font-mono text-2xs tabular-nums text-faint`},YL={key:0,class:`space-y-1 rounded-control border border-danger/25 bg-danger-soft px-2.5 py-2`},XL=P({__name:`HostVitalsPanel`,props:{host:{},now:{}},setup(e){let t=e,n=W(()=>{let e=t.host;return e?(e.loadAvg[0]??0)/Math.max(1,e.cpus):null}),r=W(()=>t.host?.loadAvg.map(e=>e.toFixed(2)).join(` `)??`—`);return(e,i)=>!t.host||!t.host.enabled?(L(),z(QI,{key:0,compact:``,title:`Host sampling is off`,description:`Turn it on in Settings to collect load, memory, disk and temperature.`})):(L(),R(`div`,PL,[B(`div`,FL,[V(NP,{value:n.value===null?null:n.value/2*100,label:`Load / cpu`,display:n.value===null?`—`:n.value.toFixed(2),size:72,"warn-at":70,"danger-at":100},null,8,[`value`,`display`]),V(NP,{value:t.host.memoryUsedPercent,label:`Memory`,size:72},null,8,[`value`]),V(NP,{value:t.host.swapUsedPercent,label:`Swap`,size:72,"warn-at":50},null,8,[`value`]),V(NP,{value:t.host.tempCelsius===null?null:t.host.tempCelsius/85*100,label:`CPU temp`,display:t.host.tempCelsius===null?`n/a`:`${Math.round(t.host.tempCelsius)}°C`,size:72},null,8,[`value`,`display`])]),B(`dl`,IL,[B(`div`,null,[B(`dt`,LL,[V(M(Kv),{class:`size-3`}),i[0]||=H(`CPUs `,-1)]),B(`dd`,RL,k(t.host.cpus),1)]),B(`div`,null,[i[1]||=B(`dt`,{class:`text-2xs text-faint`},` Load 1 / 5 / 15 `,-1),B(`dd`,zL,k(r.value),1)]),B(`div`,null,[B(`dt`,BL,[V(M(oy),{class:`size-3`}),i[2]||=H(`Memory used `,-1)]),B(`dd`,VL,k(t.host.memoryUsedPercent.toFixed(0))+`% `,1)]),B(`div`,null,[B(`dt`,HL,[V(M(Oy),{class:`size-3`}),i[3]||=H(`Sampled `,-1)]),B(`dd`,UL,k(M(bI)(t.host.sampledAt,t.now)),1)])]),B(`div`,WL,[B(`p`,GL,[V(M($v),{class:`size-3`}),i[4]||=H(`Filesystems `,-1)]),(L(!0),R(I,null,va(t.host.disks,e=>(L(),R(`div`,{key:e.path,class:`space-y-1`},[B(`div`,KL,[B(`span`,{class:`truncate font-mono text-2xs text-muted`,title:e.path},k(e.path),9,qL),B(`span`,JL,k(M(xI)(e.totalBytes-e.freeBytes))+` / `+k(M(xI)(e.totalBytes))+` · `+k(e.usedPercent.toFixed(0))+`% `,1)]),V(NL,{value:e.usedPercent},null,8,[`value`])]))),128))]),t.host.alerts.length>0?(L(),R(`div`,YL,[i[5]||=B(`p`,{class:`text-2xs font-medium text-danger`},` Thresholds breached `,-1),(L(!0),R(I,null,va(t.host.alerts,e=>(L(),R(`p`,{key:e,class:`text-2xs text-danger`},k(e),1))),128))])):U(``,!0)]))}}),ZL={key:1,class:`flex flex-col`},QL={class:`min-w-0 flex-1`},$L={class:`flex items-baseline gap-1.5`},eR={class:`truncate text-xs font-medium text-ink`},tR=[`title`],nR={key:0,class:`text-muted`},rR={class:`shrink-0 pt-0.5 text-2xs text-faint`},iR=P({__name:`ActivityFeed`,props:{servers:{},now:{},limit:{default:12},serverId:{default:void 0}},setup(e){let t=e,n={start:fy,exit:Ty,crash:zv,"forced-restart":_y,unhealthy:jy,recovered:Bv},r=W(()=>{let e=[];for(let n of t.servers)if(t.serverId===void 0||n.id===t.serverId)for(let t of n.history.events)e.push({...t,label:n.config.label??n.id});return e.sort((e,t)=>t.ts-e.ts).slice(0,t.limit)});return(e,i)=>{let a=fa(`RouterLink`);return r.value.length===0?(L(),z(QI,{key:0,compact:``,title:`No events in the last 24 hours`,description:`Starts, exits, crashes and recoveries show up here as they happen.`})):(L(),R(`ol`,ZL,[(L(!0),R(I,null,va(r.value,(e,r)=>(L(),R(`li`,{key:`${e.serverId}-${e.ts}-${r}`,class:O([`flex items-start gap-2.5 border-line-soft py-2`,r>0&&`border-t`])},[(L(),z(ma(n[e.type]),{class:O(M(Q)(`mt-0.5 size-3.5 shrink-0`,M(uP)[M(hP)[e.type]]))},null,8,[`class`])),B(`div`,QL,[B(`p`,$L,[B(`span`,eR,k(M(mP)[e.type]),1),V(a,{to:`/servers/${e.serverId}`,class:`truncate text-2xs text-muted hover:text-accent`},{default:N(()=>[H(k(e.label),1)]),_:2},1032,[`to`])]),B(`p`,{class:`mt-0.5 truncate font-mono text-2xs text-faint`,title:e.detail},[H(k(e.detail)+` `,1),e.runtimeMs===void 0?U(``,!0):(L(),R(`span`,nR,` · ran `+k(M(_I)(e.runtimeMs)),1))],8,tR)]),B(`span`,rR,k(M(bI)(e.ts,t.now)),1)],2))),128))]))}}}),aR={class:`mb-3 flex items-start justify-between gap-3`},oR={class:`min-w-0`},sR={class:`text-xs font-semibold text-ink`},cR={key:0,class:`mt-0.5 text-2xs leading-4 text-muted`},lR={class:`flex shrink-0 items-center gap-2`},uR=P({__name:`FieldGroup`,props:{title:{},description:{default:void 0},columns:{default:2},dense:{type:Boolean,default:!1},class:{default:void 0}},setup(e){let t=e,n=W(()=>({1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3`})[t.columns]);return(e,r)=>(L(),R(`section`,{class:O(M(Q)(`rounded-panel border border-line bg-panel-2/40`,t.dense?`p-3`:`p-3.5`,t.class))},[B(`header`,aR,[B(`div`,oR,[B(`h3`,sR,k(t.title),1),t.description?(L(),R(`p`,cR,k(t.description),1)):U(``,!0)]),B(`div`,lR,[F(e.$slots,`actions`)])]),B(`div`,{class:O(M(Q)(`grid gap-3`,n.value))},[F(e.$slots,`default`)],2)],2))}});function dR(e){return e==null||Number.isNaN(e)?``:String(e)}function fR(e,t){let n=String(e??``).trim();if(n.length===0)return t?null:NaN;let r=Number(n);return Number.isNaN(r)?NaN:r}var pR=[`for`],mR=[`id`,`step`,`min`,`max`,`aria-invalid`],hR={key:1,class:`text-2xs text-danger`},gR=P({inheritAttrs:!1,__name:`NumberField`,props:za({label:{default:void 0},hint:{default:void 0},error:{default:null},wide:{type:Boolean,default:!1},nullable:{type:Boolean,default:!1},step:{default:void 0},min:{default:void 0},max:{default:void 0}},{modelValue:{default:null},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`),r=li(),i=W({get:()=>dR(n.value),set:e=>{n.value=fR(e,t.nullable)}}),a=W(()=>n.value!==null&&Number.isNaN(n.value));return(e,n)=>(L(),R(`div`,{class:O(M(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(L(),R(`label`,{key:0,for:M(r),class:O(M(pF))},k(t.label),11,pR)):U(``,!0),br(B(`input`,Ms({id:M(r),"onUpdate:modelValue":n[0]||=e=>i.value=e,type:`number`,inputmode:`numeric`,step:t.step,min:t.min,max:t.max,class:M(Q)(M(hF),`font-mono tabular-nums`,(t.error||a.value)&&`border-danger`),"aria-invalid":t.error||a.value?!0:void 0},e.$attrs),null,16,mR),[[Jl,i.value]]),t.error?(L(),R(`p`,hR,k(t.error),1)):t.hint?(L(),R(`p`,{key:2,class:O(M(mF))},k(t.hint),3)):U(``,!0)],2))}}),_R=[`for`],vR=[`id`,`rows`,`placeholder`],yR={key:1,class:`text-2xs text-danger`},bR=P({inheritAttrs:!1,__name:`TextAreaField`,props:za({label:{default:void 0},hint:{default:void 0},error:{default:null},rows:{default:3},placeholder:{default:void 0},wide:{type:Boolean,default:!0},mono:{type:Boolean,default:!0}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`),r=li();return(e,i)=>(L(),R(`div`,{class:O(M(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(L(),R(`label`,{key:0,for:M(r),class:O(M(pF))},k(t.label),11,_R)):U(``,!0),br(B(`textarea`,Ms({id:M(r),"onUpdate:modelValue":i[0]||=e=>n.value=e,rows:t.rows,placeholder:t.placeholder,spellcheck:`false`,class:M(Q)(t.mono?M(gF):`font-sans`,`resize-y leading-relaxed`,t.error&&`border-danger`)},e.$attrs),null,16,vR),[[Jl,n.value]]),t.error?(L(),R(`p`,yR,k(t.error),1)):t.hint?(L(),R(`p`,{key:2,class:O(M(mF))},k(t.hint),3)):U(``,!0)],2))}}),xR=[`for`],SR=[`id`,`aria-invalid`,`aria-describedby`],CR=[`id`],wR=[`id`],TR=P({inheritAttrs:!1,__name:`TextField`,props:za({label:{default:void 0},hint:{default:void 0},error:{default:null},wide:{type:Boolean,default:!1}},{modelValue:{default:``},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`),r=li(),i=W(()=>t.hint||t.error?`${r}-hint`:void 0);return(e,a)=>(L(),R(`div`,{class:O(M(Q)(`flex min-w-0 flex-col gap-1`,t.wide&&`sm:col-span-2`))},[t.label?(L(),R(`label`,{key:0,for:M(r),class:O(M(pF))},k(t.label),11,xR)):U(``,!0),br(B(`input`,Ms({id:M(r),"onUpdate:modelValue":a[0]||=e=>n.value=e,class:M(Q)(M(hF),t.error&&`border-danger`),"aria-invalid":t.error?!0:void 0,"aria-describedby":i.value},e.$attrs),null,16,SR),[[ru,n.value]]),t.error?(L(),R(`p`,{key:1,id:`${M(r)}-hint`,class:`text-2xs text-danger`},k(t.error),9,CR)):t.hint?(L(),R(`p`,{key:2,id:`${M(r)}-hint`,class:O(M(mF))},k(t.hint),11,wR)):U(``,!0)],2))}}),ER={class:`block text-xs text-ink`},DR={key:0,class:`block text-2xs text-faint`},OR=P({__name:`ToggleSwitch`,props:za({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1},trailing:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`);return(e,r)=>(L(),R(`div`,{class:O(M(Q)(`flex items-center gap-2.5`,t.trailing&&`flex-row-reverse justify-end`))},[V(M(cg),{modelValue:n.value,"onUpdate:modelValue":r[0]||=e=>n.value=e,disabled:t.disabled,class:O(M(Q)(`relative inline-flex h-[18px] w-8 shrink-0 cursor-pointer items-center rounded-full border transition-colors duration-150`,`data-[state=checked]:border-accent data-[state=checked]:bg-accent`,`data-[state=unchecked]:border-line data-[state=unchecked]:bg-line-soft`,`disabled:cursor-not-allowed disabled:opacity-45`,M(fF)))},{default:N(()=>[V(M(lg),{class:`block size-3 translate-x-[3px] rounded-full bg-white shadow-sm transition-transform duration-150 ease-out data-[state=checked]:translate-x-[16px]`})]),_:1},8,[`modelValue`,`disabled`,`class`]),B(`label`,{class:`min-w-0 cursor-pointer select-none`,onClick:r[1]||=e=>!t.disabled&&(n.value=!n.value)},[B(`span`,ER,k(t.label),1),t.hint?(L(),R(`span`,DR,k(t.hint),1)):U(``,!0)])],2))}}),kR={class:`flex flex-col gap-2 rounded-panel border border-line bg-panel-2/40 p-3`},AR={class:`rounded-panel border border-line-soft bg-panel-2/40 p-3`},jR={class:`mt-1.5 flex flex-wrap gap-1`},MR={key:0,class:`rounded-control border border-danger/40 bg-danger-soft px-2.5 py-1.5 font-mono text-2xs leading-4 text-danger`},NR=P({__name:`AddServerDialog`,props:{open:{type:Boolean,default:!1},openModifiers:{}},emits:za([`created`],[`update:open`]),setup(e,{emit:t}){let n=t,r=so(e,`open`),i=wM(),a=j(!1),o=j(null),s=/^[a-z0-9][a-z0-9_-]*$/,c=[`{port}`,`{host}`,`{home}`,`{projectDir}`,`{dataRoot}`,`{id}`,`{label}`,`{cwd}`,`{bind}`,`{lanIp}`],l=en({id:``,label:``,command:``,args:``,cwd:``,port:null,bind:`local`,autostart:!1});function u(){return{id:``,label:``,command:``,args:``,cwd:``,port:null,bind:`local`,autostart:!1}}let d=W(()=>l.port===null||l.port===void 0||Number.isNaN(l.port)||Number.isInteger(l.port)&&l.port>=1&&l.port<=65535?null:`Port must be a whole number between 1 and 65535.`);function f(){Object.assign(l,u()),o.value=null}Ar(r,e=>{e&&f()});function p(){return{id:l.id.trim(),label:l.label.trim().length>0?l.label.trim():void 0,command:l.command.trim(),args:l.args.split(`
40
+ `).map(e=>e.trim()).filter(e=>e.length>0),cwd:l.cwd.trim().length>0?l.cwd.trim():void 0,...l.port===null?{}:{port:l.port},bind:l.bind,autostart:l.autostart}}function m(){return l.id.trim().length===0?`An id is required — it is the key this server lives under.`:s.test(l.id.trim())?l.command.trim().length===0?`A command is required — the executable the supervisor spawns.`:d.value===null?null:d.value:`The id must start with a lowercase letter or digit and contain only lowercase letters, digits, dashes and underscores.`}async function h(){o.value=null;let e=m();if(e!==null){o.value=e;return}a.value=!0;try{if(await i.create(p()),i.lastError.value!==null){o.value=i.lastError.value;return}n(`created`),r.value=!1,f()}finally{a.value=!1}}return(e,t)=>(L(),z(rL,{open:r.value,"onUpdate:open":t[9]||=e=>r.value=e,title:`Add a server`,description:`Appends an entry to servers.config.json; every policy you leave out is inherited from the defaults.`,width:`w-[min(94vw,40rem)]`},{footer:N(()=>[V($,{variant:`ghost`,onClick:t[8]||=e=>r.value=!1},{default:N(()=>[...t[12]||=[H(` Cancel `,-1)]]),_:1}),V($,{type:`submit`,form:`add-server-form`,variant:`primary`,loading:a.value},{default:N(()=>[...t[13]||=[H(` Add to servers.config.json `,-1)]]),_:1},8,[`loading`])]),default:N(()=>[B(`form`,{id:`add-server-form`,class:`flex flex-col gap-3`,onSubmit:lu(h,[`prevent`])},[V(uR,{title:`Identity`,columns:2,dense:``},{default:N(()=>[V(TR,{modelValue:l.id,"onUpdate:modelValue":t[0]||=e=>l.id=e,label:`Id`,placeholder:`my-server`,hint:`Lowercase letters, digits, dashes and underscores; used in URLs and logs.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(TR,{modelValue:l.label,"onUpdate:modelValue":t[1]||=e=>l.label=e,label:`Label`,placeholder:`My server`,hint:`Shown in the panel; defaults to the id.`},null,8,[`modelValue`])]),_:1}),V(uR,{title:`Process`,columns:2,dense:``},{default:N(()=>[V(TR,{modelValue:l.command,"onUpdate:modelValue":t[2]||=e=>l.command=e,label:`Command`,placeholder:`node`,hint:`Spawned without a shell.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(TR,{modelValue:l.cwd,"onUpdate:modelValue":t[3]||=e=>l.cwd=e,label:`Working directory`,placeholder:`.`,hint:`Relative paths resolve under projectDir.`,class:`font-mono text-xs`},null,8,[`modelValue`])]),_:1}),V(bR,{modelValue:l.args,"onUpdate:modelValue":t[4]||=e=>l.args=e,label:`Arguments`,rows:3,hint:`One argument per line; whitespace inside a line is preserved.`,placeholder:`-p
41
+ {port}`},null,8,[`modelValue`]),V(uR,{title:`Port & lifecycle`,columns:2,dense:``},{default:N(()=>[V(gR,{modelValue:l.port,"onUpdate:modelValue":t[5]||=e=>l.port=e,label:`Port`,nullable:``,min:1,max:65535,error:d.value,hint:`Blank means the server has no port to probe or preflight.`},null,8,[`modelValue`,`error`]),V(lL,{modelValue:l.bind,"onUpdate:modelValue":t[6]||=e=>l.bind=e,label:`Bind address`,options:[{value:`local`,label:`local — 127.0.0.1`},{value:`lan`,label:`lan — 0.0.0.0`}],hint:`lan exposes it to the network; only do that behind auth.`},null,8,[`modelValue`])]),_:1}),B(`div`,kR,[V(OR,{modelValue:l.autostart,"onUpdate:modelValue":t[7]||=e=>l.autostart=e,label:`Autostart with up`,hint:`Start it whenever the control plane comes up.`},null,8,[`modelValue`]),t[10]||=B(`p`,{class:`text-2xs leading-4 text-faint`},[H(` Everything this entry does not set — restart, health, stop, resources — is inherited from `),B(`span`,{class:`font-mono`},`Settings → Defaults`),H(`, and can be overridden afterwards from the server's own editor. `)],-1)]),B(`div`,AR,[t[11]||=B(`p`,{class:`text-2xs font-medium text-muted`},` Available argument placeholders `,-1),B(`div`,jR,[(L(),R(I,null,va(c,e=>B(`code`,{key:e,class:`rounded-control border border-line bg-raise px-1.5 py-0.5 font-mono text-2xs text-ink`},k(e),1)),64))])]),o.value?(L(),R(`p`,MR,k(o.value),1)):U(``,!0)],32)]),_:1},8,[`open`]))}}),PR={class:`text-xs font-semibold text-ink`},FR={class:`mt-2.5 flex justify-end gap-1.5`},IR=P({__name:`KillPortButton`,props:{port:{},busy:{type:Boolean,default:!1}},emits:[`confirm`],setup(e,{emit:t}){let n=e,r=t,i=j(!1);function a(){i.value=!1,r(`confirm`)}return(e,t)=>(L(),z(M(Wh),{open:i.value,"onUpdate:open":t[0]||=e=>i.value=e},{default:N(()=>[V(M(Zh),{"as-child":``},{default:N(()=>[V($,{variant:`danger-ghost`,size:`xs`,loading:n.busy},{default:N(()=>[H(` Kill what holds port `+k(n.port),1)]),_:1},8,[`loading`])]),_:1}),V(M(Xh),null,{default:N(()=>[V(M(Yh),{"side-offset":6,align:`start`,class:`z-50 w-64 rounded-panel border border-line bg-raise p-3 shadow-float focus-visible:outline-none data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[B(`p`,PR,` Kill the process on port `+k(n.port)+`? `,1),t[3]||=B(`p`,{class:`mt-1 text-2xs leading-4 text-muted`},` It is asked to stop first, and killed only if it ignores that. Anything this panel supervises is refused, so a managed server cannot be lost this way. `,-1),B(`div`,FR,[V(M(Gh),{"as-child":``},{default:N(()=>[V($,{size:`xs`,variant:`ghost`},{default:N(()=>[...t[1]||=[H(` Keep it `,-1)]]),_:1})]),_:1}),V($,{size:`xs`,variant:`danger`,loading:n.busy,onClick:a},{default:N(()=>[...t[2]||=[H(` Kill it `,-1)]]),_:1},8,[`loading`])])]),_:1})]),_:1})]),_:1},8,[`open`]))}}),LR=[`viewBox`],RR=[`id`],zR=[`stop-color`],BR=[`stop-color`],VR=[`d`,`fill`],HR=[`d`,`stroke`,`stroke-width`],UR=[`x1`,`x2`,`y2`,`stroke`],WR=[`cx`,`cy`,`fill`],GR={key:0,class:`absolute inset-x-0 top-1/2 border-t border-dashed border-line`},KR=100,qR=P({__name:`Sparkline`,props:za({values:{},height:{default:34},max:{default:null},min:{default:null},fill:{type:Boolean,default:!0},strokeWidth:{default:1.5},color:{default:void 0},class:{default:void 0},interactive:{type:Boolean,default:!1}},{hoverIndex:{default:null},hoverIndexModifiers:{}}),emits:[`update:hoverIndex`],setup(e){let t=e,n=so(e,`hoverIndex`),r=li(),i=j(null),a=W(()=>{let e=t.values.filter(e=>e!==null&&Number.isFinite(e)),n=t.max??(e.length>0?Math.max(...e):1),r=t.min??0;return{bottom:r,ceiling:n===r?r+1:n}}),o=W(()=>{let e=t.values,{bottom:n,ceiling:r}=a.value,i=r-n,o=e.length>1?KR/(e.length-1):KR,s=e=>t.height-(e-n)/i*t.height,c=[],l=[],u=()=>{if(l.length===0)return;let e=l.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(2)} ${e.y.toFixed(2)}`).join(` `),n=l[0],r=`${e} L${l[l.length-1].x.toFixed(2)} ${t.height} L${n.x.toFixed(2)} ${t.height} Z`;c.push({line:e,area:r}),l=[]};return e.forEach((e,t)=>{if(e===null||!Number.isFinite(e)){u();return}l.push({x:t*o,y:s(e)})}),u(),c}),s=W(()=>n.value===null||t.values.length<2?null:n.value/(t.values.length-1)*KR),c=W(()=>{let e=n.value;if(e===null)return null;let r=t.values[e];if(r==null||!Number.isFinite(r))return null;let{bottom:i,ceiling:o}=a.value;return t.height-(r-i)/(o-i)*t.height});function l(e){if(!t.interactive||!i.value||t.values.length===0)return;let r=i.value.getBoundingClientRect();if(r.width===0)return;let a=Math.min(1,Math.max(0,(e.clientX-r.left)/r.width));n.value=Math.round(a*(t.values.length-1))}function u(){n.value=null}return(e,n)=>(L(),R(`div`,{ref_key:`track`,ref:i,class:O(M(Q)(`relative w-full`,t.class)),style:ge({height:`${t.height}px`}),onMousemove:l,onMouseleave:u},[(L(),R(`svg`,{viewBox:`0 0 ${KR} ${t.height}`,preserveAspectRatio:`none`,class:`block size-full overflow-visible`,role:`img`,"aria-hidden":`true`},[B(`defs`,null,[B(`linearGradient`,{id:M(r),x1:`0`,y1:`0`,x2:`0`,y2:`1`},[B(`stop`,{offset:`0%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0.26`},null,8,zR),B(`stop`,{offset:`100%`,"stop-color":t.color??`currentColor`,"stop-opacity":`0`},null,8,BR)],8,RR)]),(L(!0),R(I,null,va(o.value,(e,n)=>(L(),R(I,{key:n},[t.fill?(L(),R(`path`,{key:0,d:e.area,fill:`url(#${M(r)})`,stroke:`none`},null,8,VR)):U(``,!0),B(`path`,{d:e.line,fill:`none`,stroke:t.color??`currentColor`,"stroke-width":t.strokeWidth,"stroke-linecap":`round`,"stroke-linejoin":`round`,"vector-effect":`non-scaling-stroke`},null,8,HR)],64))),128)),s.value===null?U(``,!0):(L(),R(`line`,{key:0,x1:s.value,x2:s.value,y1:`0`,y2:t.height,stroke:t.color??`currentColor`,"stroke-width":`1`,"stroke-dasharray":`2 2`,"vector-effect":`non-scaling-stroke`,opacity:`0.5`},null,8,UR)),s.value!==null&&c.value!==null?(L(),R(`circle`,{key:1,cx:s.value,cy:c.value,r:`2`,fill:t.color??`currentColor`,"vector-effect":`non-scaling-stroke`},null,8,WR)):U(``,!0)],8,LR)),o.value.length===0?(L(),R(`div`,GR)):U(``,!0)],38))}}),JR={class:`min-w-0`},YR={class:`flex items-baseline justify-between gap-2`},XR={class:`truncate text-2xs font-medium text-faint`},ZR={class:`flex shrink-0 items-baseline gap-1.5`},QR={key:0,class:`font-mono text-2xs text-faint`},$R=P({__name:`MetricSpark`,props:{label:{},values:{},format:{},max:{default:null},colorClass:{default:`text-accent`},height:{default:30},sampleMs:{default:5e3},emptyHint:{default:`collecting…`}},setup(e){let t=e,n=j(null),r=W(()=>Qj(t.values)),i=W(()=>t.values.some(e=>e!==null)),a=W(()=>{let e=n.value;return e!==null&&t.values[e]!==void 0?t.values[e]??null:r.value}),o=W(()=>{let e=n.value;if(e===null)return null;let r=t.values.length-1-e;if(r<=0)return null;let i=Math.round(r*t.sampleMs/1e3);return i<60?`−${i}s`:`−${Math.round(i/60)}m`});return(e,r)=>(L(),R(`div`,JR,[B(`div`,YR,[B(`span`,XR,k(t.label),1),B(`span`,ZR,[o.value?(L(),R(`span`,QR,k(o.value),1)):U(``,!0),B(`span`,{class:O(M(Q)(`font-mono text-xs font-medium tabular-nums`,i.value?`text-ink`:`text-faint`))},k(i.value?t.format(a.value):t.emptyHint),3)])]),V(qR,{"hover-index":n.value,"onUpdate:hoverIndex":r[0]||=e=>n.value=e,values:t.values,height:t.height,max:t.max,interactive:``,class:O(M(Q)(`mt-1`,t.colorClass))},null,8,[`hover-index`,`values`,`height`,`max`,`class`])]))}}),ez={class:`inline-flex flex-wrap items-center gap-1.5`},tz={class:`relative flex size-1.5`},nz={key:0,class:`absolute inset-0 rounded-full bg-current opacity-60`,style:{animation:`hh-pulse-ring 1.6s ease-out infinite`}},rz=P({__name:`StatusPill`,props:{status:{},health:{default:null},showHealth:{type:Boolean,default:!0}},setup(e){let t=e,n=W(()=>cP[t.status]),r=W(()=>t.health?lP[t.health]:null),i=W(()=>t.showHealth&&r.value!==null&&t.health!==`disabled`&&t.health!==`unknown`&&(r.value.tone===`danger`||r.value.tone===`warn`)),a=W(()=>n.value.transitional);return(e,t)=>(L(),R(`span`,ez,[B(`span`,{class:O(M(Q)(`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-2xs font-medium`,M(dP)[n.value.tone]))},[B(`span`,tz,[a.value?(L(),R(`span`,nz)):U(``,!0),B(`span`,{class:O(M(Q)(`relative size-1.5 rounded-full`,M(fP)[n.value.tone]))},null,2)]),H(` `+k(n.value.label),1)],2),i.value&&r.value?(L(),R(`span`,{key:0,class:O(M(Q)(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium`,M(dP)[r.value.tone]))},k(r.value.label),3)):U(``,!0)]))}}),iz={class:`flex items-start justify-between gap-3 px-4 pb-2.5 pt-3.5`},az={class:`min-w-0`},oz={class:`flex items-center gap-2`},sz=[`href`,`title`,`aria-label`],cz={class:`mt-0.5 flex items-center gap-1.5 truncate font-mono text-2xs text-faint`},lz={class:`text-muted`},uz={key:1,class:`rounded bg-hover px-1 py-px text-muted`},dz={key:2,class:`rounded bg-accent-soft px-1 py-px text-accent`},fz=[`title`],pz={key:0,class:`space-y-2.5 border-y border-line-soft px-4 py-3`},mz={class:`grid grid-cols-2 gap-x-4 gap-y-2`},hz={key:1,class:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 pt-2.5`},gz={class:`text-muted`},_z={class:`text-faint`},vz={key:2,class:`flex flex-col gap-1 px-4 pt-2.5`},yz={key:0,class:`flex items-start gap-1.5 text-2xs leading-4 text-danger`},bz={class:`min-w-0 break-words`},xz={key:2,class:`text-2xs leading-4 text-warn`},Sz={key:3,class:`text-2xs leading-4 text-warn`},Cz={class:`grid grid-cols-2 gap-x-4 gap-y-1 px-4 py-3 sm:grid-cols-4`},wz={class:`truncate text-2xs text-faint`},Tz={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},Ez={class:`mt-auto flex items-center gap-1.5 border-t border-line-soft px-4 py-2.5`},Dz={class:`grid grid-cols-2 gap-2 text-xs`},Oz={class:`font-mono text-ink`},kz={class:`text-ink capitalize`},Az=P({__name:`ServerCard`,props:{server:{},series:{},now:{},variant:{default:`default`}},setup(e){let t=e,n={start:fy,exit:Ty,crash:zv,"forced-restart":_y,unhealthy:jy,recovered:Bv},r=wM(),i=j(!1),a=j(!1),o=W(()=>t.server.config),s=W(()=>o.value.label&&o.value.label.length>0?o.value.label:t.server.id),c=W(()=>`${o.value.command} ${o.value.args.join(` `)}`.trim()),l=W(()=>pP(t.server.status,t.server.health)),u=W(()=>t.server.status===`running`),d=W(()=>o.value.enabled&&[`stopped`,`crashed`,`conflict`].includes(t.server.status)),f=W(()=>[`running`,`starting`,`backoff`].includes(t.server.status)),p=W(()=>t.server.startedAt===null||!u.value?`—`:_I(t.now-t.server.startedAt)),m=W(()=>t.server.nextRetryAt===null?null:vI(t.server.nextRetryAt,t.now)),h=W(()=>t.server.unhealthySince===null?null:_I(t.now-t.server.unhealthySince)),g=W(()=>t.series?.cpu??[]),_=W(()=>t.series?.rss??[]),v=W(()=>t.series?.probe??[]),y=W(()=>[...t.server.history.events].slice(-3).reverse()),b=W(()=>{let e=t.server,n=[{key:`pid`,label:`PID`,value:e.pid===null?`—`:String(e.pid)},{key:`uptime`,label:`Uptime`,value:p.value},{key:`restarts`,label:`Restarts`,value:`${e.restarts}/${e.maxRetries}`},{key:`port`,label:`Port`,value:e.portState},{key:`uptime24`,label:`24h up`,value:yI(e.history.uptimeRatio)},{key:`probe`,label:`Probe`,value:e.responseMs===null?`—`:`${e.responseMs} ms`},{key:`rss`,label:`RSS`,value:SI(e.resources?.rssBytes??null)},{key:`procs`,label:`Procs`,value:e.resources?String(e.resources.processes):`—`}];return e.history.crashes>0&&n.splice(5,0,{key:`crashes`,label:`24h crashes`,value:String(e.history.crashes)}),e.history.lastCrashAt!==null&&n.push({key:`lastcrash`,label:`Last crash`,value:bI(e.history.lastCrashAt,t.now)}),n});async function x(e){i.value=!0;try{await r[e](t.server.id)}finally{i.value=!1}}async function S(){i.value=!0;try{await r.freePort(t.server.id)}finally{i.value=!1}}async function C(e){let n=!(e===`enabled`?o.value.enabled:o.value.autostart);e===`enabled`?await r.setEnabled(t.server.id,n):await r.setAutostart(t.server.id,n)}async function w(){a.value=!1,await r.remove(t.server.id)}return(u,p)=>{let T=fa(`RouterLink`);return L(),R(`article`,{class:O(M(Q)(`group relative flex flex-col rounded-panel border bg-panel shadow-card transition-colors duration-150`,`hover:border-line/90`,t.server.status===`crashed`||t.server.status===`conflict`?`border-danger/30`:`border-line`,!o.value.enabled&&`opacity-70`))},[B(`span`,{class:O(M(Q)(`absolute inset-y-3 left-0 w-0.5 rounded-full`,{"bg-ok":l.value===`ok`,"bg-warn":l.value===`warn`,"bg-danger":l.value===`danger`,"bg-faint/50":l.value===`neutral`,"bg-accent":l.value===`accent`||l.value===`info`}))},null,2),B(`header`,iz,[B(`div`,az,[B(`div`,oz,[V(T,{to:`/servers/${e.server.id}`,class:`truncate text-sm font-semibold tracking-tight text-ink hover:text-accent`},{default:N(()=>[H(k(s.value),1)]),_:1},8,[`to`]),e.server.url?(L(),R(`a`,{key:0,href:e.server.url,target:`_blank`,rel:`noreferrer`,class:`shrink-0 text-faint transition-colors duration-150 hover:text-accent`,title:e.server.url,"aria-label":`Open ${e.server.url}`},[V(M(Yv),{class:`size-3.5`})],8,sz)):U(``,!0)]),B(`p`,cz,[B(`span`,null,k(e.server.id),1),o.value.port===null?U(``,!0):(L(),R(I,{key:0},[p[9]||=B(`span`,{"aria-hidden":`true`},`·`,-1),B(`span`,lz,`:`+k(o.value.port),1)],64)),p[10]||=B(`span`,{"aria-hidden":`true`},`·`,-1),B(`span`,null,k(e.server.bindHost),1),o.value.enabled?U(``,!0):(L(),R(`span`,uz,`disabled`)),o.value.autostart?(L(),R(`span`,dz,`autostart`)):U(``,!0)])]),V(rz,{status:e.server.status,health:e.server.health},null,8,[`status`,`health`]),e.server.adopted?(L(),z(vF,{key:0,label:`This process replaced itself: the panel adopted the successor instead of starting a second copy. Stop still works, its output stays where the successor sent it.`},{default:N(()=>[...p[11]||=[B(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):U(``,!0)]),B(`p`,{class:`truncate px-4 pb-3 font-mono text-2xs text-muted`,title:c.value},k(c.value),9,fz),t.variant===`compact`?U(``,!0):(L(),R(`div`,pz,[B(`div`,mz,[V($R,{label:`CPU`,values:g.value,format:M(CI),max:100,"color-class":`text-cpu`},null,8,[`values`,`format`]),V($R,{label:`Memory`,values:_.value,format:M(SI),"color-class":`text-mem`},null,8,[`values`,`format`])]),V($R,{label:`Health probe`,values:v.value,format:e=>e===null?`—`:`${e} ms`,height:22,"color-class":`text-probe`,"empty-hint":`not probed`},null,8,[`values`,`format`])])),y.value.length>0?(L(),R(`div`,hz,[(L(!0),R(I,null,va(y.value,e=>(L(),R(`span`,{key:`${e.ts}`,class:`inline-flex items-center gap-1 text-2xs`},[(L(),z(ma(n[e.type]),{class:O(M(Q)(`size-3`,M(uP)[M(hP)[e.type]]))},null,8,[`class`])),B(`span`,gz,k(M(mP)[e.type]),1),B(`span`,_z,k(M(bI)(e.ts,t.now)),1)]))),128))])):U(``,!0),e.server.lastError||h.value||m.value?(L(),R(`div`,vz,[e.server.lastError?(L(),R(`p`,yz,[V(M(zv),{class:`mt-0.5 size-3 shrink-0`}),B(`span`,bz,k(e.server.lastError),1)])):U(``,!0),e.server.status===`conflict`&&o.value.port!==null?(L(),z(IR,{key:1,port:o.value.port,busy:i.value,class:`self-start`,onConfirm:S},null,8,[`port`,`busy`])):U(``,!0),h.value?(L(),R(`p`,xz,` Unhealthy for `+k(h.value),1)):U(``,!0),m.value?(L(),R(`p`,Sz,` Next attempt `+k(m.value),1)):U(``,!0)])):U(``,!0),B(`dl`,Cz,[(L(!0),R(I,null,va(b.value,e=>(L(),R(`div`,{key:e.key,class:`min-w-0`},[B(`dt`,wz,k(e.label),1),B(`dd`,Tz,k(e.value),1)]))),128))]),B(`div`,Ez,[V($,{variant:`primary`,size:`xs`,disabled:i.value||!d.value,onClick:p[0]||=e=>x(`start`)},{default:N(()=>[V(M(fy),{class:`size-3`}),p[12]||=H(`Start `,-1)]),_:1},8,[`disabled`]),V($,{size:`xs`,disabled:i.value||!f.value,onClick:p[1]||=e=>x(`stop`)},{default:N(()=>[V(M(Ty),{class:`size-3`}),p[13]||=H(`Stop `,-1)]),_:1},8,[`disabled`]),V($,{size:`xs`,disabled:i.value||!o.value.enabled,onClick:p[2]||=e=>x(`restart`)},{default:N(()=>[V(M(_y),{class:`size-3`}),p[14]||=H(`Restart `,-1)]),_:1},8,[`disabled`]),V(vF,{label:`Live logs and full telemetry`},{default:N(()=>[V(T,{to:`/servers/${e.server.id}`},{default:N(()=>[V($,{size:`xs`,variant:`ghost`},{default:N(()=>[V(M(vy),{class:`size-3`}),p[15]||=H(`Details `,-1)]),_:1})]),_:1},8,[`to`])]),_:1}),V(M(eg),null,{default:N(()=>[V(M(ag),{"as-child":``},{default:N(()=>[V($,{size:`icon-sm`,variant:`ghost`,class:`ml-auto`,"aria-label":`More actions for ${s.value}`},{default:N(()=>[V(M(Jv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),V(M(rg),null,{default:N(()=>[V(M(tg),{"side-offset":4,align:`end`,class:`z-50 min-w-52 rounded-panel border border-line bg-raise p-1 shadow-float data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:p[3]||=e=>C(`enabled`)},{default:N(()=>[V(M(my),{class:`size-3.5`}),H(` `+k(o.value.enabled?`Disable server`:`Enable server`),1)]),_:1}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:p[4]||=e=>C(`autostart`)},{default:N(()=>[V(M(fy),{class:`size-3.5`}),H(` `+k(o.value.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:p[5]||=t=>M(r).clearLogs(e.server.id)},{default:N(()=>[V(M(vy),{class:`size-3.5`}),p[16]||=H(` Clear log buffer `,-1)]),_:1}),V(M(ig),{class:`my-1 h-px bg-line`}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-danger outline-none data-[highlighted]:bg-danger-soft`,onSelect:p[6]||=e=>a.value=!0},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),p[17]||=H(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),V(rL,{open:a.value,"onUpdate:open":p[8]||=e=>a.value=e,title:`Remove this server?`,description:`${s.value} is removed from servers.config.json. Its process is stopped and its persisted logs stay on disk.`,width:`w-[min(92vw,26rem)]`},{footer:N(()=>[V($,{variant:`ghost`,onClick:p[7]||=e=>a.value=!1},{default:N(()=>[...p[20]||=[H(` Keep it `,-1)]]),_:1}),V($,{variant:`danger`,onClick:w},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),p[21]||=H(`Remove `,-1)]),_:1})]),default:N(()=>[B(`dl`,Dz,[B(`div`,null,[p[18]||=B(`dt`,{class:`text-faint`},` id `,-1),B(`dd`,Oz,k(e.server.id),1)]),B(`div`,null,[p[19]||=B(`dt`,{class:`text-faint`},` status `,-1),B(`dd`,kz,k(e.server.status),1)])])]),_:1},8,[`open`,`description`])],2)}}}),jz={class:`flex flex-wrap items-start justify-between gap-3`},Mz={class:`min-w-0`},Nz={class:`flex flex-wrap items-center gap-x-3 gap-y-1.5`},Pz={class:`text-2xl font-semibold tracking-tight text-ink`},Fz={key:1,class:`mt-1 max-w-2xl text-xs leading-relaxed text-muted`},Iz={class:`flex shrink-0 flex-wrap items-center gap-2`},Lz=P({__name:`PageHeader`,props:{title:{},description:{default:void 0},backTo:{default:void 0},backLabel:{default:`Back`}},setup(e){return(e,t)=>{let n=fa(`RouterLink`);return L(),R(`header`,jz,[B(`div`,Mz,[e.$props.backTo?(L(),z(n,{key:0,to:e.$props.backTo,class:`mb-1 inline-flex items-center gap-1 text-2xs text-muted transition-colors duration-150 hover:text-ink`},{default:N(()=>[V(M(Iv),{class:`size-3`}),H(` `+k(e.$props.backLabel),1)]),_:1},8,[`to`])):U(``,!0),B(`div`,Nz,[B(`h1`,Pz,k(e.$props.title),1),F(e.$slots,`badges`)]),e.$props.description?(L(),R(`p`,Fz,k(e.$props.description),1)):U(``,!0)]),B(`div`,Iz,[F(e.$slots,`actions`)])])}}}),Rz={key:0,class:`mb-3 flex items-start justify-between gap-3`},zz={class:`min-w-0`},Bz={class:`flex shrink-0 items-center gap-1.5`},Vz=P({__name:`Panel`,props:{padded:{type:Boolean,default:!0},class:{}},setup(e){return(e,t)=>(L(),R(`section`,{class:O(M(sP)(`rounded-panel border border-line bg-panel shadow-card`,e.$props.padded&&`p-4`,e.$props.class))},[e.$slots.header||e.$slots.actions?(L(),R(`header`,Rz,[B(`div`,zz,[F(e.$slots,`header`)]),B(`div`,Bz,[F(e.$slots,`actions`)])])):U(``,!0),F(e.$slots,`default`)],2))}}),Hz={class:`min-w-0`},Uz={class:`truncate text-2xs font-medium text-faint`},Wz={key:0,class:`mt-0.5 truncate text-2xs text-muted`},Gz=P({__name:`StatTile`,props:{label:{},value:{},hint:{default:void 0},tone:{default:`neutral`},mono:{type:Boolean,default:!0}},setup(e){return(e,t)=>(L(),R(`div`,Hz,[B(`p`,Uz,k(e.$props.label),1),B(`p`,{class:O(M(Q)(`mt-0.5 truncate text-xl font-semibold tracking-tight`,e.$props.mono&&`font-mono tabular-nums`,e.$props.tone===`neutral`?`text-ink`:M(uP)[e.$props.tone]))},k(e.$props.value),3),e.$props.hint?(L(),R(`p`,Wz,k(e.$props.hint),1)):U(``,!0)]))}}),Kz=j(null),qz=j(`unknown`),Jz=null;async function Yz(){try{let e=await(await fetch(`/healthz`,{cache:`no-store`})).json();typeof e.uptimeMs==`number`&&(Kz.value=Date.now()-e.uptimeMs),qz.value=e.status===`degraded`?`degraded`:`ok`}catch{qz.value=`unknown`}}function Xz(){return Jz??=Yz().finally(()=>{Jz=null}),{startedAt:Kz,status:qz,refresh:Yz}}var Zz={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},Qz={key:0,class:`grid grid-cols-2 gap-4 p-4 sm:grid-cols-3 lg:grid-cols-6`},$z={key:1,class:`grid grid-cols-2 divide-line-soft sm:grid-cols-3 sm:divide-x lg:grid-cols-6`},eB={class:`p-4`},tB={class:`p-4`},nB={class:`p-4`},rB={class:`p-4`},iB={class:`p-4`},aB={class:`p-4`},oB={key:0,class:`flex items-start gap-2.5 rounded-panel border border-danger/25 bg-danger-soft px-3.5 py-3`},sB={class:`min-w-0`},cB={class:`text-xs font-medium text-danger`},lB={class:`mt-0.5 flex flex-wrap gap-x-2 text-2xs text-danger`},uB={class:`space-y-3`},dB={class:`flex items-center justify-between`},fB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},pB={key:0,class:`grid gap-4 lg:grid-cols-2`},mB={key:2,class:`grid gap-4 lg:grid-cols-2`},hB={class:`grid gap-4 lg:grid-cols-3`},gB={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},_B={class:`flex items-center gap-1.5 text-sm font-semibold text-ink`},vB={class:`flex flex-wrap items-center gap-x-3 gap-y-1 text-2xs text-faint`},yB={class:`flex items-center gap-1`},bB={class:`font-mono`},xB=P({__name:`OverviewView`,setup(e){let{servers:t,host:n,now:r,appState:i,seriesOf:a,startAll:o,stopAll:s}=wM(),c=Xz(),l=j(!1),u=W(()=>i.value===null),d=W(()=>t.value.filter(e=>e.status===`running`)),f=W(()=>t.value.filter(e=>[`stopped`,`stopping`].includes(e.status))),p=W(()=>t.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`)),m=W(()=>{let e=0;for(let t of d.value){let n=t.resources?.rssBytes;typeof n==`number`&&(e+=n)}return e}),h=W(()=>{let e=0;for(let n of t.value){let t=Zj(a(n.id).rss);t>e&&(e=t)}return e}),g=W(()=>c.startedAt.value===null?`—`:_I(r.value-c.startedAt.value)),_=W(()=>n.value?.enabled?_I(n.value.uptimeMs):`—`),v=W(()=>{let e=0;for(let t of d.value)e+=t.resources?.cpuPercent??0;return e});return ta(async()=>{await c.refresh()}),(e,y)=>{let b=fa(`RouterLink`);return L(),R(`div`,Zz,[V(Lz,{title:`Overview`,description:`Live state of everything this panel supervises, refreshed over a single event stream.`},{actions:N(()=>[V($,{variant:`ghost`,onClick:y[0]||=e=>M(o)()},{default:N(()=>[V(M(fy),{class:`size-3.5`}),y[5]||=H(`Start all `,-1)]),_:1}),V($,{variant:`ghost`,onClick:y[1]||=e=>M(s)()},{default:N(()=>[V(M(Ty),{class:`size-3.5`}),y[6]||=H(`Stop all `,-1)]),_:1}),V($,{variant:`primary`,onClick:y[2]||=e=>l.value=!0},{default:N(()=>[V(M(py),{class:`size-3.5`}),y[7]||=H(`Add server `,-1)]),_:1})]),_:1}),V(Vz,{class:`p-0`},{default:N(()=>[u.value?(L(),R(`div`,Qz,[(L(),R(I,null,va(6,e=>B(`div`,{key:e,class:`space-y-2`},[V(uL,{class:`h-2.5 w-16`}),V(uL,{class:`h-6 w-20`})])),64))])):(L(),R(`div`,$z,[B(`div`,eB,[V(Gz,{label:`Running`,value:`${d.value.length}/${M(t).length}`,tone:`ok`,hint:`${M(t).length-d.value.length} not up`},null,8,[`value`,`hint`])]),B(`div`,tB,[V(Gz,{label:`Stopped`,value:String(f.value.length),hint:`${M(t).filter(e=>e.config.enabled).length} enabled`},null,8,[`value`,`hint`])]),B(`div`,nB,[V(Gz,{label:`Needs attention`,value:String(p.value.length),tone:p.value.length>0?`danger`:`ok`,hint:p.value.length===0?`nothing is broken`:`crashed or unhealthy`},null,8,[`value`,`tone`,`hint`])]),B(`div`,rB,[V(Gz,{label:`Process memory`,value:M(SI)(m.value),hint:h.value>0?`peak ${M(SI)(h.value)}`:`across the tree`},null,8,[`value`,`hint`])]),B(`div`,iB,[V(Gz,{label:`Panel uptime`,value:g.value,hint:M(c).status.value===`degraded`?`degraded`:`serving`},null,8,[`value`,`hint`])]),B(`div`,aB,[V(Gz,{label:`Host uptime`,value:_.value,hint:M(n)?.enabled?`${v.value.toFixed(1)}% cpu now`:`sampling off`},null,8,[`value`,`hint`])])]))]),_:1}),p.value.length>0?(L(),R(`div`,oB,[V(M(zv),{class:`mt-0.5 size-4 shrink-0 text-danger`}),B(`div`,sB,[B(`p`,cB,k(p.value.length)+` server`+k(p.value.length===1?``:`s`)+` need a look `,1),B(`p`,lB,[(L(!0),R(I,null,va(p.value,e=>(L(),z(b,{key:e.id,to:`/servers/${e.id}`,class:`font-mono underline-offset-2 hover:underline`},{default:N(()=>[H(k(e.id),1)]),_:2},1032,[`to`]))),128))])])])):U(``,!0),B(`section`,uB,[B(`div`,dB,[B(`h2`,fB,[V(M(by),{class:`size-3.5 text-faint`}),y[8]||=H(` Servers `,-1)]),V(b,{to:`/servers`,class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:N(()=>[...y[9]||=[H(` Open the full list `,-1)]]),_:1})]),u.value?(L(),R(`div`,pB,[(L(),R(I,null,va(4,e=>V(uL,{key:e,class:`h-64 w-full`,rounded:`rounded-panel`})),64))])):M(t).length===0?(L(),z(QI,{key:1,title:`No servers yet`,description:`Add the first process this panel should keep alive.`},{icon:N(()=>[V(M(by),{class:`size-4`})]),action:N(()=>[V($,{variant:`primary`,onClick:y[3]||=e=>l.value=!0},{default:N(()=>[V(M(py),{class:`size-3.5`}),y[10]||=H(`Add a server `,-1)]),_:1})]),_:1})):(L(),R(`div`,mB,[(L(!0),R(I,null,va(M(t),e=>(L(),z(Az,{key:e.id,server:e,series:M(a)(e.id),now:M(r)},null,8,[`server`,`series`,`now`]))),128))]))]),B(`div`,hB,[V(Vz,{class:`lg:col-span-2`},{header:N(()=>[B(`h2`,gB,[V(M(Kv),{class:`size-3.5 text-faint`}),y[11]||=H(` Host vitals `,-1)])]),default:N(()=>[V(XL,{host:M(n),now:M(r)},null,8,[`host`,`now`])]),_:1}),V(Vz,null,{header:N(()=>[B(`h2`,_B,[V(M(jv),{class:`size-3.5 text-faint`}),y[12]||=H(` Recent activity `,-1)])]),actions:N(()=>[V(b,{to:`/logs`,class:`text-2xs text-muted transition-colors duration-150 hover:text-accent`},{default:N(()=>[...y[13]||=[H(` Logs `,-1)]]),_:1})]),default:N(()=>[V(iR,{servers:M(t),now:M(r),limit:10},null,8,[`servers`,`now`])]),_:1})]),B(`p`,vB,[B(`span`,yB,[V(M(ky),{class:`size-3`}),y[14]||=H(`resource history is sampled every 5 s and kept for this session`,-1)]),B(`span`,bB,k(M(i)?.control.url),1),B(`span`,{class:O(M(Q)(`flex items-center gap-1`,M(c).status.value===`degraded`&&`text-danger`))},[B(`span`,{class:O(M(Q)(`size-1.5 rounded-full`,M(c).status.value===`degraded`?`bg-danger`:`bg-ok`))},null,2),H(` panel `+k(M(c).status.value),1)],2)]),V(NR,{open:l.value,"onUpdate:open":y[4]||=e=>l.value=e},null,8,[`open`])])}}}),SB=[`restart`,`health`,`stop`];function CB(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function wB(e,t,n=[]){let r={};for(let[i,a]of Object.entries(t)){if(n.includes(i)){let t=e[i]??{},n={};for(let[e,r]of Object.entries(a??{}))t[e]!==r&&(n[e]=r);Object.keys(n).length>0&&(r[i]=n);continue}CB(e[i],a)||(r[i]=a)}return r}function TB(e,t){let n=e;return wB({...n,label:n.label??``},t,SB)}var EB=[`disabled`],DB={class:`min-w-0`},OB={class:`text-ink`},kB=P({__name:`CheckField`,props:za({label:{},hint:{default:void 0},disabled:{type:Boolean,default:!1},wide:{type:Boolean,default:!1}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=so(e,`modelValue`);return(e,r)=>(L(),R(`label`,{class:O(M(Q)(`flex cursor-pointer select-none items-start gap-2 rounded-control px-2 py-1.5 text-xs transition-colors duration-150`,`hover:bg-hover`,t.disabled&&`cursor-not-allowed opacity-50 hover:bg-transparent`,t.wide&&`sm:col-span-2`))},[br(B(`input`,{"onUpdate:modelValue":r[0]||=e=>n.value=e,type:`checkbox`,disabled:t.disabled,class:`mt-0.5 size-3.5 shrink-0 cursor-pointer appearance-none rounded-[4px] border border-line bg-page checked:border-accent checked:bg-accent checked:bg-[length:9px] checked:bg-center checked:bg-no-repeat checked:[background-image:url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22none%22 stroke=%22white%22 stroke-width=%224%22 stroke-linecap=%22round%22 stroke-linejoin=%22round%22><path d=%22M20 6 9 17l-5-5%22/></svg>')] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:cursor-not-allowed`},null,8,EB),[[Yl,n.value]]),B(`span`,DB,[B(`span`,OB,k(t.label),1),t.hint?(L(),R(`span`,{key:0,class:O([`mt-0.5 block`,[M(mF)]])},k(t.hint),3)):U(``,!0),F(e.$slots,`default`)])],2))}}),AB=P({__name:`LifecycleFields`,props:za({showHttp:{type:Boolean,default:!0}},{restart:{required:!0},restartModifiers:{},health:{required:!0},healthModifiers:{},stop:{required:!0},stopModifiers:{}}),emits:[`update:restart`,`update:health`,`update:stop`],setup(e){let t=so(e,`restart`),n=so(e,`health`),r=so(e,`stop`);function i(e,t,n=0){return W({get:e,set:e=>t(e??n)})}let a=i(()=>t.value.maxRetries,e=>t.value.maxRetries=e),o=i(()=>t.value.baseDelayMs,e=>t.value.baseDelayMs=e),s=i(()=>t.value.factor,e=>t.value.factor=e,1),c=i(()=>t.value.maxDelayMs,e=>t.value.maxDelayMs=e),l=i(()=>t.value.resetAfterMs,e=>t.value.resetAfterMs=e),u=i(()=>n.value.intervalMs,e=>n.value.intervalMs=e,500),d=i(()=>n.value.timeoutMs,e=>n.value.timeoutMs=e,100),f=i(()=>n.value.unhealthyThreshold,e=>n.value.unhealthyThreshold=e,1),p=i(()=>n.value.forceRestartAfterMs,e=>n.value.forceRestartAfterMs=e),m=i(()=>n.value.startTimeoutMs,e=>n.value.startTimeoutMs=e),h=W({get:()=>n.value.http.expectStatus??null,set:e=>{e===null||Number.isNaN(e)?delete n.value.http.expectStatus:n.value.http.expectStatus=e}}),g=i(()=>n.value.http.expectStatusBelow,e=>n.value.http.expectStatusBelow=e,400),_=i(()=>r.value.graceMs,e=>r.value.graceMs=e),v=[{value:`SIGTERM`,label:`SIGTERM — ask it to stop`},{value:`SIGINT`,label:`SIGINT — interrupt (Ctrl-C)`},{value:`SIGKILL`,label:`SIGKILL — kill immediately`}];return(i,y)=>(L(),R(I,null,[V(uR,{title:`Restart policy`,description:`Backoff between attempts after a crash.`,columns:3},{default:N(()=>[V(kB,{modelValue:t.value.enabled,"onUpdate:modelValue":y[0]||=e=>t.value.enabled=e,label:`Restart on crash`,wide:``},null,8,[`modelValue`]),V(gR,{modelValue:M(a),"onUpdate:modelValue":y[1]||=e=>A(a)?a.value=e:null,label:`Max retries`,min:0,hint:`Attempts before the server is left crashed.`},null,8,[`modelValue`]),V(gR,{modelValue:M(o),"onUpdate:modelValue":y[2]||=e=>A(o)?o.value=e:null,label:`Base delay (ms)`,min:0},null,8,[`modelValue`]),V(gR,{modelValue:M(s),"onUpdate:modelValue":y[3]||=e=>A(s)?s.value=e:null,label:`Backoff factor`,min:1,step:.1},null,8,[`modelValue`]),V(gR,{modelValue:M(c),"onUpdate:modelValue":y[4]||=e=>A(c)?c.value=e:null,label:`Max delay (ms)`,min:0},null,8,[`modelValue`]),V(gR,{modelValue:M(l),"onUpdate:modelValue":y[5]||=e=>A(l)?l.value=e:null,label:`Reset after (ms)`,min:0,hint:`A run this long clears the retry counter.`},null,8,[`modelValue`])]),_:1}),V(uR,{title:`Health check`,description:`How readiness is probed once the process is up.`,columns:3},{default:N(()=>[V(kB,{modelValue:n.value.enabled,"onUpdate:modelValue":y[6]||=e=>n.value.enabled=e,label:`Probe this server`,wide:``},null,8,[`modelValue`]),V(lL,{modelValue:n.value.mode,"onUpdate:modelValue":y[7]||=e=>n.value.mode=e,label:`Probe type`,options:[{value:`port`,label:`TCP port — connection only`},{value:`http`,label:`HTTP request — assert a response`}]},null,8,[`modelValue`]),V(gR,{modelValue:M(u),"onUpdate:modelValue":y[8]||=e=>A(u)?u.value=e:null,label:`Interval (ms)`,min:500,step:100},null,8,[`modelValue`]),V(gR,{modelValue:M(d),"onUpdate:modelValue":y[9]||=e=>A(d)?d.value=e:null,label:`Timeout (ms)`,min:100,step:100},null,8,[`modelValue`]),V(gR,{modelValue:M(f),"onUpdate:modelValue":y[10]||=e=>A(f)?f.value=e:null,label:`Unhealthy after`,min:1,hint:`Consecutive failed probes.`},null,8,[`modelValue`]),V(gR,{modelValue:M(p),"onUpdate:modelValue":y[11]||=e=>A(p)?p.value=e:null,label:`Force restart after (ms)`,min:0,hint:`0 disables it.`},null,8,[`modelValue`]),V(gR,{modelValue:M(m),"onUpdate:modelValue":y[12]||=e=>A(m)?m.value=e:null,label:`Start timeout (ms)`,min:0},null,8,[`modelValue`]),e.showHttp&&n.value.mode===`http`?(L(),R(I,{key:0},[V(TR,{modelValue:n.value.http.path,"onUpdate:modelValue":y[13]||=e=>n.value.http.path=e,label:`HTTP path`,placeholder:`/healthz`},null,8,[`modelValue`]),V(lL,{modelValue:n.value.http.method,"onUpdate:modelValue":y[14]||=e=>n.value.http.method=e,label:`HTTP method`,options:[{value:`GET`,label:`GET`},{value:`HEAD`,label:`HEAD`}]},null,8,[`modelValue`]),V(gR,{modelValue:h.value,"onUpdate:modelValue":y[15]||=e=>h.value=e,label:`Expect status`,nullable:``,hint:`Blank accepts anything below.`},null,8,[`modelValue`]),V(gR,{modelValue:M(g),"onUpdate:modelValue":y[16]||=e=>A(g)?g.value=e:null,label:`Healthy below status`,min:100},null,8,[`modelValue`]),V(TR,{modelValue:n.value.http.expectBody,"onUpdate:modelValue":y[17]||=e=>n.value.http.expectBody=e,label:`Body must contain`,placeholder:`optional substring`,wide:``},null,8,[`modelValue`])],64)):U(``,!0)]),_:1}),V(uR,{title:`Stop behaviour`,description:`How the process tree is asked to go away.`,columns:3},{default:N(()=>[V(lL,{modelValue:r.value.signal,"onUpdate:modelValue":y[18]||=e=>r.value.signal=e,label:`Signal`,options:v},null,8,[`modelValue`]),V(gR,{modelValue:M(_),"onUpdate:modelValue":y[19]||=e=>A(_)?_.value=e:null,label:`Grace period (ms)`,min:0},null,8,[`modelValue`]),V(kB,{modelValue:r.value.killGroup,"onUpdate:modelValue":y[20]||=e=>r.value.killGroup=e,label:`Kill the whole process group`},null,8,[`modelValue`]),V(kB,{modelValue:r.value.killPortHolders,"onUpdate:modelValue":y[21]||=e=>r.value.killPortHolders=e,label:`Also kill whatever holds the port`,wide:``},null,8,[`modelValue`])]),_:1})],64))}}),jB={class:`mb-4 flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1`},MB={class:`flex items-center gap-2`},NB={key:0,class:`text-2xs text-warn`},PB={key:1,class:`text-2xs text-faint`},FB={class:`flex flex-col gap-3`},IB={key:0,class:`mt-3 rounded-control border border-danger/40 bg-danger-soft px-2.5 py-1.5 font-mono text-2xs leading-4 text-danger`},LB={class:`mt-4 flex items-center justify-end gap-2 border-t border-line pt-3.5`},RB=[`disabled`],zB=P({__name:`ServerConfigEditor`,props:{serverId:{},config:{}},emits:[`saved`,`cancel`],setup(e,{emit:t}){let n=e,r=t,i=[`restart`,`health`,`stop`],a=wM(),o=j(!1),s=j(null);function c(e){return e.split(`
42
42
  `).map(e=>e.trim()).filter(e=>e.length>0)}function l(e){return Object.entries(e).map(([e,t])=>`${e}=${t}`).join(`
43
43
  `)}function u(e){let t={};for(let n of c(e)){let e=n.indexOf(`=`);e<=0||(t[n.slice(0,e).trim()]=n.slice(e+1).trim())}return t}function d(e){return e>0?Math.round(e/1024/1024):null}function f(e){return{label:e.label??``,command:e.command,cwd:e.cwd,args:e.args.join(`
44
44
  `),env:l(e.env),dataEnvs:l(e.dataEnvs),backupPaths:e.backupPaths.join(`
45
45
  `),dependsOn:e.dependsOn.join(`, `),envFile:e.envFile,maxRssMb:d(e.resources.maxRssBytes),port:e.port,bind:e.bind,onPortConflict:e.onPortConflict,logBufferLines:e.logBufferLines,enabled:e.enabled,autostart:e.autostart,bootstrapEnabled:e.bootstrap!==null&&e.bootstrap!==void 0,bootstrapCommand:e.bootstrap?.command??``,bootstrapArgs:(e.bootstrap?.args??[]).join(`
46
- `),bootstrapEnv:l(e.bootstrap?.env??{}),bootstrapTimeoutMs:e.bootstrap?.timeoutMs??12e4,bootstrapRunOnce:e.bootstrap?.runOnce??!0}}let p=en(f(n.config)),m=j({...n.config.restart}),h=j({...n.config.health}),g=j({...n.config.stop}),_={...n.config},v=W(()=>{let e=[{value:`local`,label:`local — 127.0.0.1`},{value:`lan`,label:`lan — 0.0.0.0`}];return/^\d{1,3}(?:\.\d{1,3}){3}$/.test(n.config.bind)&&e.push({value:n.config.bind,label:`${n.config.bind} — explicit`}),e});function y(){let e=Number.isFinite(p.maxRssMb)?p.maxRssMb:0,t=Number.isFinite(p.logBufferLines)?p.logBufferLines:0,n=Number.isFinite(p.bootstrapTimeoutMs)?p.bootstrapTimeoutMs:0;return{label:p.label.trim(),command:p.command.trim(),cwd:p.cwd.trim()===``?`.`:p.cwd.trim(),args:c(p.args),env:u(p.env),dataEnvs:u(p.dataEnvs),backupPaths:c(p.backupPaths),dependsOn:p.dependsOn.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),envFile:p.envFile.trim(),resources:{maxRssBytes:e>0?Math.round(e*1024*1024):0},port:p.port===null||Number.isNaN(p.port)?null:p.port,bind:p.bind,onPortConflict:p.onPortConflict,logBufferLines:t,enabled:p.enabled,autostart:p.autostart,restart:{...m.value},health:{...h.value},stop:{...g.value},bootstrap:p.bootstrapEnabled?{command:p.bootstrapCommand.trim(),args:c(p.bootstrapArgs),env:u(p.bootstrapEnv),timeoutMs:n,runOnce:p.bootstrapRunOnce}:null}}function b(e,t){let r=n.config[t]??{},i=e[t]??{},a={};for(let[e,t]of Object.entries(i))r[e]!==t&&(a[e]=t);return Object.keys(a).length>0?a:null}function x(e){for(let t of[`restart`,`health`,`stop`])b(e,t)===null&&delete e[t];return CB(n.config,e)}function S(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}let C=W(()=>{let e=y(),t=0;for(let[n,r]of Object.entries(e))i.includes(n)?t+=b(e,n)===null?0:1:S(_[n],r)||(t+=1);return t}),w=W(()=>C.value>0),T={...n.config};function ee(e){Object.assign(p,f(e)),m.value={...e.restart},h.value={...e.health},g.value={...e.stop},_={...e},T={...e},s.value=null}Ar(()=>n.config,e=>{S(e,T)||ee(e)});async function E(){s.value=null,o.value=!0;try{let e=y(),t=vA(e);if(t instanceof Y.errors){s.value=t.summary;return}let i=x(e);if(Object.keys(i).length===0){r(`saved`);return}if(await a.saveConfig(n.serverId,i),a.lastError.value!==null){s.value=a.lastError.value;return}_={...e},r(`saved`)}finally{o.value=!1}}return(e,t)=>(L(),R(`form`,{class:`border-t border-line bg-page/40 px-4 py-4`,onSubmit:lu(E,[`prevent`])},[B(`header`,kB,[t[26]||=B(`div`,{class:`min-w-0`},[B(`h2`,{class:`text-sm font-semibold text-ink`},` Edit configuration `),B(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},[H(` Writes overrides to `),B(`span`,{class:`font-mono`},`servers.config.json`),H(`; anything left alone keeps inheriting the defaults. `)])],-1),B(`div`,AB,[C.value>0?(L(),R(`span`,jB,k(C.value)+` unsaved `+k(C.value===1?`change`:`changes`),1)):(L(),R(`span`,MB,`in sync`))])]),B(`div`,NB,[V(uR,{title:`Process`,description:`What gets spawned, where, and with which environment.`,columns:2},{default:N(()=>[V(CR,{modelValue:p.label,"onUpdate:modelValue":t[0]||=e=>p.label=e,label:`Label`,placeholder:`falls back to the id`},null,8,[`modelValue`]),V(CR,{modelValue:p.command,"onUpdate:modelValue":t[1]||=e=>p.command=e,label:`Command`,placeholder:`node`,required:``,class:`font-mono text-xs`},null,8,[`modelValue`]),V(CR,{modelValue:p.cwd,"onUpdate:modelValue":t[2]||=e=>p.cwd=e,label:`Working directory`,placeholder:`.`,hint:`Relative paths resolve under projectDir.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(CR,{modelValue:p.envFile,"onUpdate:modelValue":t[3]||=e=>p.envFile=e,label:`Env file`,placeholder:`optional KEY=value file`,hint:`Loaded at spawn; its values override env.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(vR,{modelValue:p.args,"onUpdate:modelValue":t[4]||=e=>p.args=e,label:`Arguments`,rows:3,hint:`One per line; {port} {host} {home} {projectDir} {dataRoot} {id} {label} {cwd} {bind} {lanIp} are substituted.`,placeholder:`-p
47
- {port}`},null,8,[`modelValue`]),V(vR,{modelValue:p.env,"onUpdate:modelValue":t[5]||=e=>p.env=e,label:`Environment`,rows:3,hint:`KEY=value per line, exported to the process.`,placeholder:`NODE_ENV=production`},null,8,[`modelValue`]),V(vR,{modelValue:p.dataEnvs,"onUpdate:modelValue":t[6]||=e=>p.dataEnvs=e,label:`Data envs`,rows:3,hint:`ENV=path per line — exported to the process and backed up automatically.`,placeholder:`DATA_DIR={home}/.app`},null,8,[`modelValue`]),V(vR,{modelValue:p.backupPaths,"onUpdate:modelValue":t[7]||=e=>p.backupPaths=e,label:`Extra backup paths`,rows:2,hint:`One per line, placeholders allowed.`,placeholder:`{home}/.app/uploads`},null,8,[`modelValue`]),V(CR,{modelValue:p.dependsOn,"onUpdate:modelValue":t[8]||=e=>p.dependsOn=e,label:`Depends on`,placeholder:`postgres, redis`,hint:`Comma separated; started first, stopped last.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(mR,{modelValue:p.maxRssMb,"onUpdate:modelValue":t[9]||=e=>p.maxRssMb=e,label:`Max RSS (MB)`,min:0,hint:`Restart above this; blank or 0 disables it.`},null,8,[`modelValue`])]),_:1}),V(uR,{title:`Port & binding`,description:`How the port is preflighted and where the process is reachable.`,columns:2},{default:N(()=>[V(mR,{modelValue:p.port,"onUpdate:modelValue":t[10]||=e=>p.port=e,label:`Port`,nullable:``,min:1,max:65535,hint:`Blank means no port: no probe, no preflight.`},null,8,[`modelValue`]),V(lL,{modelValue:p.bind,"onUpdate:modelValue":t[11]||=e=>p.bind=e,label:`Bind address`,options:v.value,hint:`A custom IPv4 the config already sets stays selectable.`},null,8,[`modelValue`,`options`]),V(lL,{modelValue:p.onPortConflict,"onUpdate:modelValue":t[12]||=e=>p.onPortConflict=e,label:`On port conflict`,options:[{value:`block`,label:`block — refuse to start`},{value:`warn`,label:`warn — start anyway`},{value:`follow`,label:`follow — adopt a detached restart of itself`},{value:`reclaim`,label:`reclaim — replace it with a supervised copy`}]},null,8,[`modelValue`]),V(mR,{modelValue:p.logBufferLines,"onUpdate:modelValue":t[13]||=e=>p.logBufferLines=e,label:`Log buffer lines`,min:50,max:1e5,step:50},null,8,[`modelValue`])]),_:1}),V(uR,{title:`Lifecycle`,description:`Whether the supervisor owns this entry at all.`,columns:2},{default:N(()=>[V(ER,{modelValue:p.enabled,"onUpdate:modelValue":t[14]||=e=>p.enabled=e,label:`Enabled`,hint:`Shows up and can be started at all.`},null,8,[`modelValue`]),V(ER,{modelValue:p.autostart,"onUpdate:modelValue":t[15]||=e=>p.autostart=e,label:`Autostart with up`,hint:`Started when the control plane comes up.`},null,8,[`modelValue`])]),_:1}),V(OB,{restart:m.value,"onUpdate:restart":t[16]||=e=>m.value=e,health:h.value,"onUpdate:health":t[17]||=e=>h.value=e,stop:g.value,"onUpdate:stop":t[18]||=e=>g.value=e},null,8,[`restart`,`health`,`stop`]),V(uR,{title:`Bootstrap`,description:`A one-off command run before the first start — installs, migrations, downloads.`,columns:2},{default:N(()=>[V(ER,{modelValue:p.bootstrapEnabled,"onUpdate:modelValue":t[19]||=e=>p.bootstrapEnabled=e,label:`Run a bootstrap`,hint:`Off means the entry has none and the key is sent as null.`,wide:``},null,8,[`modelValue`]),p.bootstrapEnabled?(L(),R(I,{key:0},[V(CR,{modelValue:p.bootstrapCommand,"onUpdate:modelValue":t[20]||=e=>p.bootstrapCommand=e,label:`Command`,placeholder:`./scripts/install.sh`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(mR,{modelValue:p.bootstrapTimeoutMs,"onUpdate:modelValue":t[21]||=e=>p.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),V(ER,{modelValue:p.bootstrapRunOnce,"onUpdate:modelValue":t[22]||=e=>p.bootstrapRunOnce=e,label:`Only once per session`,hint:`Off means every start re-runs it.`},null,8,[`modelValue`])],64)):U(``,!0),p.bootstrapEnabled?(L(),z(vR,{key:1,modelValue:p.bootstrapArgs,"onUpdate:modelValue":t[23]||=e=>p.bootstrapArgs=e,label:`Bootstrap arguments`,rows:2,hint:`One per line; same placeholders as the main arguments.`},null,8,[`modelValue`])):U(``,!0),p.bootstrapEnabled?(L(),z(vR,{key:2,modelValue:p.bootstrapEnv,"onUpdate:modelValue":t[24]||=e=>p.bootstrapEnv=e,label:`Bootstrap environment`,rows:2,hint:`KEY=value per line, exported to the bootstrap process only.`},null,8,[`modelValue`])):U(``,!0)]),_:1})]),s.value?(L(),R(`p`,PB,k(s.value),1)):U(``,!0),B(`div`,FB,[B(`button`,{type:`button`,class:`inline-flex h-8 select-none items-center rounded-control border border-transparent bg-transparent px-2.5 text-xs font-medium whitespace-nowrap text-muted transition-colors duration-150 hover:bg-hover hover:text-ink`,onClick:t[25]||=e=>r(`cancel`)},` Cancel `),B(`button`,{type:`submit`,disabled:o.value||!w.value,class:`inline-flex h-8 select-none items-center gap-1.5 rounded-control border border-transparent bg-accent px-2.5 text-xs font-medium whitespace-nowrap text-accent-ink transition-[filter,opacity] duration-150 hover:brightness-110 disabled:pointer-events-none disabled:opacity-45`},k(o.value?`Saving…`:`Save to servers.config.json`),9,IB)])],32))}}),RB=[`aria-label`],zB=P({__name:`CopyButton`,props:{value:{},label:{default:`Copy`},class:{default:void 0}},setup(e){let t=e,n=j(!1),r=null;async function i(){try{await navigator.clipboard.writeText(t.value),n.value=!0,r&&clearTimeout(r),r=setTimeout(()=>{n.value=!1},1400)}catch{}}return ze(()=>{r&&clearTimeout(r)}),(e,r)=>(L(),R(`button`,{type:`button`,class:O(M(Q)(`grid size-6 shrink-0 place-items-center rounded-control text-faint transition-colors duration-150 hover:bg-hover hover:text-ink`,M(fF),t.class)),"aria-label":n.value?`Copied`:t.label,onClick:i},[n.value?(L(),z(M(Pv),{key:0,class:`size-3.5 text-ok`})):(L(),z(M(Gv),{key:1,class:`size-3.5`}))],10,RB))}}),BB={key:0,class:`mx-auto max-w-3xl p-4 sm:p-5`},VB={key:1,class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},HB={class:`font-mono text-xs text-faint`},UB=[`href`],WB={class:`px-2 py-1.5`},GB={class:`flex flex-col gap-0.5`},KB=[`onClick`],qB={class:`space-y-2`},JB={key:0,class:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-control border border-danger/25 bg-danger-soft px-3 py-2`},YB={class:`min-w-0 flex-1 text-2xs leading-4 text-danger`},XB={key:1,class:`rounded-control border border-warn/25 bg-warn-soft px-3 py-2 text-2xs leading-4 text-warn`},ZB={class:`grid grid-cols-2 gap-x-4 gap-y-3 p-4 sm:grid-cols-4 lg:grid-cols-6`},QB={class:`truncate text-2xs text-faint`},$B={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},eV={class:`grid gap-4 sm:grid-cols-3`},tV={class:`flex items-center justify-between gap-3`},nV=[`title`],rV={key:1,class:`space-y-4`},iV={key:0,class:`max-h-96 overflow-auto rounded-control border border-line bg-page/60 p-3 font-mono text-2xs leading-5 text-muted`},aV={key:1,class:`grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-2`},oV={class:`text-2xs text-faint`},sV=[`title`],cV={key:2,class:`grid gap-4 lg:grid-cols-3`},lV={key:0,class:`flex flex-wrap gap-1.5`},uV={key:1,class:`text-xs text-muted`},dV=P({__name:`ServerDetailView`,setup(e){let t=zg(),{serverById:n,now:r,seriesOf:i,start:a,stop:o,restart:s,setEnabled:c,setAutostart:l,setBind:u,clearLogs:d,freePort:f,remove:p}=wM(),m=W(()=>String(t.params.id??``)),h=W(()=>n(m.value)),g=W(()=>h.value?.config),_=W(()=>{let e=g.value;return e?.label&&e.label.length>0?e.label:m.value}),v=j(`output`),y=j(!1),b=j(!1),x=j(!1),S=j(!1),C=CM(()=>h.value?m.value:null),w=C.version,T=W(()=>(w.value,C.lines())),ee=W(()=>i(m.value)),E=W(()=>ee.value.cpu),te=W(()=>ee.value.rss),ne=W(()=>ee.value.probe),re=W(()=>{let e=h.value;return!e||e.startedAt===null||e.status!==`running`?`—`:_I(r.value-e.startedAt)}),ie=W(()=>h.value?.status===`running`),ae=W(()=>{let e=h.value;if(!e)return[];let t=[{key:`pid`,label:`PID`,value:e.pid===null?`—`:String(e.pid)},{key:`uptime`,label:`Uptime`,value:re.value},{key:`status`,label:`Status`,value:e.status},{key:`health`,label:`Health`,value:e.health},{key:`port`,label:`Port state`,value:e.portState},{key:`probe`,label:`Last probe`,value:e.responseMs===null?`—`:`${e.responseMs} ms`},{key:`rss`,label:`RSS`,value:SI(e.resources?.rssBytes??null)},{key:`procs`,label:`Processes`,value:e.resources?String(e.resources.processes):`—`},{key:`restarts`,label:`Restarts`,value:`${e.restarts}/${e.maxRetries}`},{key:`up24`,label:`24h uptime`,value:yI(e.history.uptimeRatio)},{key:`crashes`,label:`24h crashes`,value:String(e.history.crashes)},{key:`lastcrash`,label:`Last crash`,value:bI(e.history.lastCrashAt,r.value)}];return e.nextRetryAt!==null&&t.push({key:`retry`,label:`Next attempt`,value:vI(e.nextRetryAt,r.value)}),e.unhealthySince!==null&&t.push({key:`unhealthy`,label:`Unhealthy for`,value:_I(r.value-e.unhealthySince)}),t}),oe=W(()=>JSON.stringify(g.value??{},null,2)),se=W(()=>g.value?`${g.value.command} ${g.value.args.join(` `)}`.trim():``),ce=W(()=>{let e=g.value?.bind??`local`,t=[{value:`local`,label:`127.0.0.1 — this machine only`},{value:`lan`,label:`0.0.0.0 — every interface`}];return e!==`local`&&e!==`lan`&&t.push({value:e,label:`${e} — custom`}),t});async function D(e){S.value=!0;try{await{start:a,stop:o,restart:s}[e](m.value)}finally{S.value=!1}}async function le(){x.value=!1,await p(m.value)}async function ue(){let e=h.value;if(e){S.value=!0;try{await f(e.id)}finally{S.value=!1}}}let de=W(()=>gj(m.value,`${m.value}.log`)),fe=[{value:`output`,label:`Live output`},{value:`config`,label:`Configuration`},{value:`history`,label:`History`}];return(e,t)=>{let n=fa(`RouterLink`);return h.value?(L(),R(`div`,VB,[V(Fz,{title:_.value,"back-to":`/servers`,"back-label":`All servers`},{badges:N(()=>[V(tz,{status:h.value.status,health:h.value.health},null,8,[`status`,`health`]),h.value.adopted?(L(),z(vF,{key:0,label:`This process replaced itself: the panel adopted the successor instead of starting a second copy. Stop still works, its output stays where the successor sent it.`},{default:N(()=>[...t[16]||=[B(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):U(``,!0),B(`span`,HB,k(h.value.id),1),h.value.url?(L(),R(`a`,{key:1,href:h.value.url,target:`_blank`,rel:`noreferrer`,class:`inline-flex items-center gap-1 font-mono text-xs text-accent hover:underline`},[H(k(h.value.url)+` `,1),V(M(Yv),{class:`size-3`})],8,UB)):U(``,!0)]),actions:N(()=>[V($,{variant:`primary`,disabled:S.value||!g.value?.enabled||[`running`,`starting`].includes(h.value.status),onClick:t[0]||=e=>D(`start`)},{default:N(()=>[V(M(fy),{class:`size-3.5`}),t[17]||=H(`Start `,-1)]),_:1},8,[`disabled`]),V($,{disabled:S.value||h.value.status===`stopped`,onClick:t[1]||=e=>D(`stop`)},{default:N(()=>[V(M(Ty),{class:`size-3.5`}),t[18]||=H(`Stop `,-1)]),_:1},8,[`disabled`]),V($,{disabled:S.value||!g.value?.enabled,onClick:t[2]||=e=>D(`restart`)},{default:N(()=>[V(M(_y),{class:`size-3.5`}),t[19]||=H(`Restart `,-1)]),_:1},8,[`disabled`]),V(vF,{label:`Edit every field of this entry`},{default:N(()=>[V($,{variant:y.value?`secondary`:`ghost`,onClick:t[3]||=e=>{y.value=!y.value,v.value=`config`}},{default:N(()=>[V(M(dy),{class:`size-3.5`}),H(k(y.value?`Close editor`:`Edit`),1)]),_:1},8,[`variant`])]),_:1}),V(M(eg),null,{default:N(()=>[V(M(ag),{"as-child":``},{default:N(()=>[V($,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions for ${_.value}`},{default:N(()=>[V(M(Jv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),V(M(rg),null,{default:N(()=>[V(M(tg),{"side-offset":4,align:`end`,class:`z-50 min-w-56 rounded-panel border border-line bg-raise p-1 shadow-float data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:t[4]||=e=>M(c)(h.value.id,!h.value.config.enabled)},{default:N(()=>[H(k(g.value?.enabled?`Disable server`:`Enable server`),1)]),_:1}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:t[5]||=e=>M(l)(h.value.id,!h.value.config.autostart)},{default:N(()=>[H(k(g.value?.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),V(M(ig),{class:`my-1 h-px bg-line`}),B(`div`,WB,[t[20]||=B(`p`,{class:`mb-1 text-2xs text-faint`},` Bind `,-1),B(`div`,GB,[(L(!0),R(I,null,va(ce.value,e=>(L(),R(`button`,{key:e.value,type:`button`,class:O([`rounded-control px-2 py-1 text-left font-mono text-2xs transition-colors duration-150 hover:bg-hover`,e.value===g.value?.bind?`text-accent`:`text-muted`]),onClick:t=>M(u)(h.value.id,e.value)},k(e.label),11,KB))),128))])]),V(M(ig),{class:`my-1 h-px bg-line`}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-danger outline-none data-[highlighted]:bg-danger-soft`,onSelect:t[6]||=e=>x.value=!0},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),t[21]||=H(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,[`title`]),B(`div`,qB,[h.value.lastError?(L(),R(`div`,JB,[B(`p`,YB,k(h.value.lastError),1),h.value.status===`conflict`&&h.value.config.port!==null?(L(),z(PR,{key:0,port:h.value.config.port,busy:S.value,onConfirm:ue},null,8,[`port`,`busy`])):U(``,!0)])):U(``,!0),h.value.health===`unhealthy`?(L(),R(`p`,XB,[t[22]||=H(` The health probe has not passed `,-1),h.value.unhealthySince===null?U(``,!0):(L(),R(I,{key:0},[H(` for `+k(M(_I)(M(r)-h.value.unhealthySince)),1)],64)),t[23]||=H(`. `,-1)])):U(``,!0)]),V(zz,{class:`p-0`},{default:N(()=>[B(`dl`,ZB,[(L(!0),R(I,null,va(ae.value,e=>(L(),R(`div`,{key:e.key,class:`min-w-0`},[B(`dt`,QB,k(e.label),1),B(`dd`,$B,k(e.value),1)]))),128))])]),_:1}),V(zz,null,{header:N(()=>[...t[24]||=[B(`h2`,{class:`text-sm font-semibold text-ink`},` Telemetry `,-1),B(`p`,{class:`text-2xs text-muted`},` Sampled every 5 s while this page is open. `,-1)]]),default:N(()=>[B(`div`,eV,[V(ZR,{label:`CPU`,values:E.value,format:M(CI),max:100,"color-class":`text-cpu`,height:40},null,8,[`values`,`format`]),V(ZR,{label:`Memory (RSS)`,values:te.value,format:M(SI),"color-class":`text-mem`,height:40},null,8,[`values`,`format`]),V(ZR,{label:`Health probe`,values:ne.value,format:e=>e===null?`—`:`${e} ms`,"color-class":`text-probe`,height:40},null,8,[`values`,`format`])])]),_:1}),B(`div`,tV,[V(AI,{modelValue:v.value,"onUpdate:modelValue":t[7]||=e=>v.value=e,options:fe,size:`md`},null,8,[`modelValue`]),B(`p`,{class:`hidden font-mono text-2xs text-faint sm:block`,title:se.value},k(se.value),9,nV)]),v.value===`output`?(L(),z(KI,{key:0,lines:T.value,version:M(w),live:``,clearable:``,"download-url":h.value.config.logBufferLines>0?de.value:void 0,"download-name":`${h.value.id}.log`,"empty-hint":ie.value?`Waiting for the first line…`:`This server has not written anything yet.`,"min-height":`22rem`,onClear:t[8]||=e=>M(d)(h.value.id)},null,8,[`lines`,`version`,`download-url`,`download-name`,`empty-hint`])):v.value===`config`?(L(),R(`div`,rV,[y.value?(L(),z(LB,{key:0,"server-id":h.value.id,config:h.value.config,onSaved:t[9]||=e=>y.value=!1,onCancel:t[10]||=e=>y.value=!1},null,8,[`server-id`,`config`])):(L(),z(zz,{key:1},{header:N(()=>[...t[25]||=[B(`h2`,{class:`text-sm font-semibold text-ink`},` Effective configuration `,-1),B(`p`,{class:`text-2xs text-muted`},` Defaults from Settings are already merged into these values. `,-1)]]),actions:N(()=>[V($,{size:`xs`,variant:`ghost`,onClick:t[11]||=e=>b.value=!b.value},{default:N(()=>[V(M(Uv),{class:`size-3`}),H(k(b.value?`Fields`:`Raw JSON`),1)]),_:1}),V(zB,{value:oe.value,label:`Copy the JSON config`},null,8,[`value`]),V($,{size:`xs`,variant:`primary`,onClick:t[12]||=e=>y.value=!0},{default:N(()=>[V(M(dy),{class:`size-3`}),t[26]||=H(`Edit `,-1)]),_:1})]),default:N(()=>[b.value?(L(),R(`pre`,iV,k(oe.value),1)):(L(),R(`dl`,aV,[(L(!0),R(I,null,va([{label:`command`,value:g.value?.command},{label:`args`,value:g.value?.args.join(` `)||`—`},{label:`cwd`,value:g.value?.cwd},{label:`env`,value:Object.keys(g.value?.env??{}).join(`, `)||`—`},{label:`data envs`,value:Object.entries(g.value?.dataEnvs??{}).map(([e,t])=>`${e}=${t}`).join(`, `)||`—`},{label:`env file`,value:g.value?.envFile||`—`},{label:`port · bind`,value:`${g.value?.port??`none`} · ${g.value?.bind}`},{label:`on port conflict`,value:g.value?.onPortConflict},{label:`log buffer`,value:`${g.value?.logBufferLines} lines`},{label:`rtss limit`,value:g.value?.resources.maxRssBytes?M(SI)(g.value.resources.maxRssBytes):`none`},{label:`health`,value:g.value?.health.enabled?`${g.value.health.mode} every ${g.value.health.intervalMs} ms`:`off`},{label:`restart`,value:g.value?.restart.enabled?`${g.value.restart.maxRetries} retries, ×${g.value.restart.factor}`:`off`},{label:`stop`,value:g.value?`${g.value.stop.signal} after ${g.value.stop.graceMs} ms`:`—`},{label:`bootstrap`,value:g.value?.bootstrap?`${g.value.bootstrap.command} ${g.value.bootstrap.args.join(` `)}`:`none`},{label:`backup paths`,value:g.value?.backupPaths.join(`, `)||`—`},{label:`depends on`,value:g.value?.dependsOn.join(`, `)||`—`}],e=>(L(),R(`div`,{key:e.label,class:`min-w-0 border-b border-line-soft pb-1.5 last:border-0`},[B(`dt`,oV,k(e.label),1),B(`dd`,{class:`truncate font-mono text-xs text-ink`,title:String(e.value)},k(e.value),9,sV)]))),128))]))]),_:1}))])):(L(),R(`div`,cV,[V(zz,{class:`lg:col-span-2`},{header:N(()=>[...t[27]||=[B(`h2`,{class:`text-sm font-semibold text-ink`},` Event history `,-1),B(`p`,{class:`text-2xs text-muted`},` Kept by the panel for 24 hours. `,-1)]]),default:N(()=>[V(iR,{servers:[h.value],now:M(r),limit:30},null,8,[`servers`,`now`])]),_:1}),V(zz,null,{header:N(()=>[...t[28]||=[B(`h2`,{class:`text-sm font-semibold text-ink`},` Dependencies `,-1)]]),default:N(()=>[g.value&&g.value.dependsOn.length>0?(L(),R(`div`,lV,[(L(!0),R(I,null,va(g.value.dependsOn,e=>(L(),z(n,{key:e,to:`/servers/${e}`,class:`rounded-full border border-line px-2 py-0.5 font-mono text-2xs text-muted transition-colors duration-150 hover:border-accent/40 hover:text-accent`},{default:N(()=>[H(k(e),1)]),_:2},1032,[`to`]))),128))])):(L(),R(`p`,uV,[...t[29]||=[H(` Starts on its own. Add ids under `,-1),B(`code`,null,`dependsOn`,-1),H(` to order it after other servers. `,-1)]]))]),_:1})])),V(rL,{open:x.value,"onUpdate:open":t[14]||=e=>x.value=e,title:`Remove this server?`,description:`${_.value} is removed from servers.config.json. Its process is stopped and its persisted logs stay on disk.`,width:`w-[min(92vw,26rem)]`},{footer:N(()=>[V($,{variant:`ghost`,onClick:t[13]||=e=>x.value=!1},{default:N(()=>[...t[30]||=[H(` Keep it `,-1)]]),_:1}),V($,{variant:`danger`,onClick:le},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),t[31]||=H(`Remove `,-1)]),_:1})]),default:N(()=>[t[32]||=B(`p`,{class:`text-xs text-muted`},` This cannot be undone from the panel — the entry has to be added back by hand or from a backup. `,-1)]),_:1},8,[`open`,`description`])])):(L(),R(`div`,BB,[V(QI,{title:`That server is gone`,description:`${m.value} is not in servers.config.json any more. It may have been removed from another tab.`},{action:N(()=>[V(n,{to:`/servers`},{default:N(()=>[V($,{variant:`primary`},{default:N(()=>[...t[15]||=[H(` Back to servers `,-1)]]),_:1})]),_:1})]),_:1},8,[`description`])]))}}}),fV={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},pV={class:`flex flex-wrap items-center gap-2`},mV={class:`relative ml-auto w-full sm:w-64`},hV={key:0,class:`grid gap-4 lg:grid-cols-2`},gV={key:3,class:`grid gap-4 lg:grid-cols-2`},_V=P({__name:`ServersView`,setup(e){let{servers:t,appState:n,now:r,seriesOf:i,startAll:a,stopAll:o}=wM(),s=j(!1),c=j(``),l=j(`all`),u=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`stopped`,label:`Stopped`},{value:`attention`,label:`Attention`},{value:`disabled`,label:`Disabled`}],d=W(()=>n.value===null),f=W(()=>{let e=c.value.trim().toLowerCase();return t.value.filter(t=>l.value===`running`&&t.status!==`running`||l.value===`stopped`&&![`stopped`,`stopping`].includes(t.status)||l.value===`disabled`&&t.config.enabled||l.value===`attention`&&t.status!==`crashed`&&t.status!==`conflict`&&t.health!==`unhealthy`?!1:e.length===0||`${t.id} ${t.config.label??``} ${t.config.command} ${t.config.port??``}`.toLowerCase().includes(e))}),p=W(()=>({all:t.value.length,running:t.value.filter(e=>e.status===`running`).length,attention:t.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`).length}));return(e,n)=>(L(),R(`div`,fV,[V(Fz,{title:`Servers`,description:`Every entry in servers.config.json, with live resources, health and history.`},{actions:N(()=>[V($,{variant:`ghost`,onClick:n[0]||=e=>M(a)()},{default:N(()=>[V(M(fy),{class:`size-3.5`}),n[9]||=H(`Start all `,-1)]),_:1}),V($,{variant:`ghost`,onClick:n[1]||=e=>M(o)()},{default:N(()=>[V(M(Ty),{class:`size-3.5`}),n[10]||=H(`Stop all `,-1)]),_:1}),V($,{variant:`primary`,onClick:n[2]||=e=>s.value=!0},{default:N(()=>[V(M(py),{class:`size-3.5`}),n[11]||=H(`Add server `,-1)]),_:1})]),_:1}),B(`div`,pV,[V(AI,{modelValue:l.value,"onUpdate:modelValue":n[3]||=e=>l.value=e,options:u.map(e=>({...e,label:`${e.label}${e.value===`all`?` ${p.value.all}`:e.value===`running`?` ${p.value.running}`:e.value===`attention`&&p.value.attention>0?` ${p.value.attention}`:``}`}))},null,8,[`modelValue`,`options`]),B(`div`,mV,[V(M(yy),{class:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),br(B(`input`,{"onUpdate:modelValue":n[4]||=e=>c.value=e,type:`search`,placeholder:`Filter by id, label, command or port`,class:O([`pl-8`,[M(hF)]]),"aria-label":`Filter servers`},null,2),[[Jl,c.value]]),c.value.length>0?(L(),R(`button`,{key:0,type:`button`,class:`absolute right-1.5 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded-control text-faint hover:text-ink`,"aria-label":`Clear the filter`,onClick:n[5]||=e=>c.value=``},[V(M(My),{class:`size-3.5`})])):U(``,!0)])]),d.value?(L(),R(`div`,hV,[(L(),R(I,null,va(4,e=>V(uL,{key:e,class:`h-72 w-full`,rounded:`rounded-panel`})),64))])):M(t).length===0?(L(),z(QI,{key:1,title:`No servers configured`,description:`Add the first process this panel should supervise. Its command, args, env and working directory all live in the config file.`},{icon:N(()=>[V(M(by),{class:`size-4`})]),action:N(()=>[V($,{variant:`primary`,onClick:n[6]||=e=>s.value=!0},{default:N(()=>[V(M(py),{class:`size-3.5`}),n[12]||=H(`Add a server `,-1)]),_:1})]),_:1})):f.value.length===0?(L(),z(QI,{key:2,compact:``,title:`Nothing matches that filter`,description:`Try a different status or clear the search.`},{action:N(()=>[V($,{onClick:n[7]||=e=>{c.value=``,l.value=`all`}},{default:N(()=>[...n[13]||=[H(` Clear filters `,-1)]]),_:1})]),_:1})):(L(),R(`div`,gV,[(L(!0),R(I,null,va(f.value,e=>(L(),z(Oz,{key:e.id,server:e,series:M(i)(e.id),now:M(r)},null,8,[`server`,`series`,`now`]))),128))])),V(jR,{open:s.value,"onUpdate:open":n[8]||=e=>s.value=e},null,8,[`open`])]))}}),vV=P({__name:`ConfirmButton`,props:{label:{},confirmLabel:{default:`Confirm`},variant:{default:`danger-ghost`},confirmVariant:{default:`danger`},size:{default:`sm`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:[`confirm`],setup(e,{emit:t}){let n=e,r=t,i=j(!1),a=null;function o(){a&&clearTimeout(a),a=null,i.value=!1}function s(){if(!i.value){i.value=!0,a=setTimeout(o,5e3);return}o(),r(`confirm`)}return ze(o),(e,t)=>(L(),z($,{variant:i.value?n.confirmVariant:n.variant,size:n.size,disabled:n.disabled,loading:n.loading,onClick:s},{default:N(()=>[H(k(i.value?n.confirmLabel:n.label),1)]),_:1},8,[`variant`,`size`,`disabled`,`loading`]))}}),yV={class:`min-w-0 flex-1`},bV={key:0,class:`text-xs font-semibold`},xV=P({__name:`Notice`,props:{tone:{default:`info`},title:{default:void 0},class:{default:void 0}},setup(e){let t=e,n={ok:Bv,warn:jy,danger:ly,info:ey,neutral:ey,accent:xy},r=W(()=>n[t.tone]);return(e,n)=>(L(),R(`div`,{class:O(M(Q)(`flex items-start gap-2 rounded-panel border px-3 py-2`,M(dP)[t.tone],t.class))},[(L(),z(ma(r.value),{class:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`})),B(`div`,yV,[t.title?(L(),R(`p`,bV,k(t.title),1)):U(``,!0),B(`div`,{class:O(M(Q)(`text-xs leading-relaxed text-ink/85`,t.title&&`mt-0.5`))},[F(e.$slots,`default`)],2)])],2))}});async function SV(e,t=8e3){let n=Date.now()+t;for(;;){try{if((await fetch(`${e}/api/auth/session`,{cache:`no-store`})).ok)return!0}catch{}if(Date.now()>n)return!1;await new Promise(e=>setTimeout(e,250))}}var CV={enabled:!0,maxRetries:3,baseDelayMs:1e3,factor:2,maxDelayMs:3e4,resetAfterMs:6e4},wV={enabled:!0,mode:`port`,http:{path:`/`,method:`GET`,expectStatusBelow:400,expectBody:``},intervalMs:5e3,timeoutMs:1500,unhealthyThreshold:3,forceRestartAfterMs:0,startTimeoutMs:2e4},TV={signal:`SIGTERM`,killGroup:!0,graceMs:5e3,killPortHolders:!1};function EV(e){return{...e,http:{...e.http}}}function DV(){return{control:{label:`home-hosted`,port:3999,host:`local`,openBrowser:!1,tlsEnabled:!1},auth:{enabled:!1,sessionTtlMs:6048e5,cookieSecure:`auto`,trustProxy:!1,maxLoginAttempts:5,lockoutMs:6e4},defaults:{enabled:!0,autostart:!1,bind:`local`,onPortConflict:`block`,logBufferLines:500,restart:{...CV},health:EV(wV),stop:{...TV}},logs:{persist:!0,maxBytes:2e6,keep:3},host:{enabled:!0,intervalMs:15e3,diskPaths:`.`,diskUsedPercent:90,memoryUsedPercent:90,swapUsedPercent:50,loadPerCpu:2,tempCelsius:85},backups:{enabled:!0,keep:5,includePaths:``},telegram:{enabled:!1,chatId:``,cooldownMs:12e4,onCrash:!0,onUnhealthy:!0,onForcedRestart:!0,onRecovered:!1,onHost:!0}}}function OV(e){return{enabled:e.enabled,sessionTtlMs:e.sessionTtlMs,cookieSecure:e.cookieSecure,trustProxy:e.trustProxy,maxLoginAttempts:e.maxLoginAttempts,lockoutMs:e.lockoutMs}}function kV(e){return{label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,tlsEnabled:e.tls.enabled}}function AV(e){return{enabled:e.enabled,chatId:e.chatId,cooldownMs:e.cooldownMs,onCrash:e.onCrash,onUnhealthy:e.onUnhealthy,onForcedRestart:e.onForcedRestart,onRecovered:e.onRecovered,onHost:e.onHost}}function jV(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function MV(e){return{enabled:e.enabled,intervalMs:e.intervalMs,diskPaths:e.diskPaths.join(`, `),diskUsedPercent:e.diskUsedPercent,memoryUsedPercent:e.memoryUsedPercent,swapUsedPercent:e.swapUsedPercent,loadPerCpu:e.loadPerCpu,tempCelsius:e.tempCelsius}}function NV(e){return{enabled:e.enabled,keep:e.keep,includePaths:e.includePaths.join(`, `)}}function PV(e,t){return SB(e,{...t,diskPaths:jV(t.diskPaths)})}function FV(e,t){return SB(e,{...t,includePaths:jV(t.includePaths)})}function IV(e,t){return SB({label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,auth:OV(e.auth),tls:{enabled:e.tls.enabled}},{label:t.control.label,port:t.control.port,host:t.control.host,openBrowser:t.control.openBrowser,auth:{...t.auth},tls:{enabled:t.control.tlsEnabled}},[`auth`,`tls`])}function LV(e,t){let n=SB(e,t,[`restart`,`health`,`stop`]),r=n.health;return r!==void 0&&`http`in r&&JSON.stringify(e.health.http)===JSON.stringify(t.health.http)&&(delete r.http,Object.keys(r).length===0&&delete n.health),n}function RV(e,t){return SB(e,t)}function zV(e,t){return SB({telegram:AV(e)},{telegram:{...t}},[`telegram`])}function BV(e){return e.liveAvailable?!e.hydrated||e.changedCount===0:!1}function VV(e,t=``){return typeof e!=`object`||!e||Array.isArray(e)?[{path:t,value:e}]:Object.entries(e).flatMap(([e,n])=>VV(n,t.length===0?e:`${t}.${e}`))}function HV(e,t){let n=new Map(VV(t).map(e=>[e.path,e.value]));return VV(e).map(e=>({path:e.path,from:n.get(e.path),to:e.value}))}function UV(e){let t=0;for(let n of Object.values(e))t+=typeof n==`object`&&n&&!Array.isArray(n)?UV(n):1;return t}function WV(e,t){return e.label!==t.control.label||e.port!==t.control.port||e.host!==t.control.host||e.openBrowser!==t.control.openBrowser}function GV(e,t){return e.tls.enabled!==t.control.tlsEnabled}function KV(e,t){return UV(SB({...OV(e.auth)},{...t.auth}))>0}function qV(e,t,n){return W({get:e,set:e=>{t(e===null||Number.isNaN(e)?n:e)}})}async function JV(e){if(!e.rebinding)return null;let t=e.targetUrl??e.control.url;return t.length===0||t===window.location.origin?null:await SV(t)?(window.location.replace(t),null):`The control panel did not answer on ${t}. Check the console for the new listener.`}var YV={class:`space-y-2`},XV={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},ZV=P({__name:`AuthenticationSection`,props:za({view:{},dirty:{type:Boolean}},{auth:{required:!0},authModifiers:{}}),emits:za([`reset`],[`update:auth`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`auth`),a=qV(()=>i.value.sessionTtlMs,e=>i.value.sessionTtlMs=e,6048e5),o=qV(()=>i.value.maxLoginAttempts,e=>i.value.maxLoginAttempts=e,5),s=qV(()=>i.value.lockoutMs,e=>i.value.lockoutMs=e,6e4),c=W(()=>n.view?.auth.passwordSet===!0),l=W(()=>n.view?.auth.apiTokenSet===!0),u=W(()=>n.view?.auth.blockedReason??null),d=W(()=>n.view?.auth.exposed===!0),f=W(()=>n.view?.auth.usingDefaultPassword===!0),p=W(()=>i.value.enabled&&!c.value),{setPassword:m,clearPassword:h}=Vj(),g=j(``),_=j(``),v=j(``),y=j(null),b=j(null),x=j(!1),S=W(()=>v.value.length>0&&v.value!==_.value),C=W(()=>_.value.length>0&&_.value.length<8),w=W(()=>_.value.length>0&&!S.value&&(!c.value||g.value.length>0));async function T(){if(w.value&&!x.value){x.value=!0,b.value=null,y.value=null;try{let e=await m(c.value?g.value:void 0,_.value);if(e!==null){b.value=e;return}g.value=``,_.value=``,v.value=``,y.value=`Password updated. Other sessions were signed out.`}finally{x.value=!1}}}async function ee(){b.value=null,y.value=null;let e=await h();e===null?y.value=`Password cleared and authentication disabled.`:b.value=e}return(e,t)=>(L(),R(I,null,[V(uR,{title:`Access policy`,description:`Authentication applies whether the panel is on loopback or exposed to the network.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[10]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(ER,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Require a password`,hint:`Every request needs a signed-in session.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(mR,{modelValue:M(a),"onUpdate:modelValue":t[2]||=e=>A(a)?a.value=e:null,label:`Session lifetime (ms)`,min:6e4,hint:`604800000 is one week.`},null,8,[`modelValue`]),V(lL,{modelValue:i.value.cookieSecure,"onUpdate:modelValue":t[3]||=e=>i.value.cookieSecure=e,label:`Cookie Secure`,options:[{value:`auto`,label:`Auto — only over HTTPS`},{value:`always`,label:`Always`},{value:`never`,label:`Never — plain HTTP`}]},null,8,[`modelValue`]),V(ER,{modelValue:i.value.trustProxy,"onUpdate:modelValue":t[4]||=e=>i.value.trustProxy=e,label:`Behind a trusted reverse proxy`,hint:`Trust x-forwarded-* headers for the client address and protocol.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(mR,{modelValue:M(o),"onUpdate:modelValue":t[5]||=e=>A(o)?o.value=e:null,label:`Max login attempts`,min:1,hint:`Failures before a temporary lockout.`},null,8,[`modelValue`]),V(mR,{modelValue:M(s),"onUpdate:modelValue":t[6]||=e=>A(s)?s.value=e:null,label:`Lockout (ms)`,min:1e3},null,8,[`modelValue`])]),_:1}),B(`div`,YV,[V(xV,{tone:l.value?`info`:`neutral`,title:l.value?`An API token is set`:`No API token`},{default:N(()=>[l.value?(L(),R(I,{key:0},[t[11]||=H(` Scripts can call the API with `,-1),t[12]||=B(`code`,null,`Authorization: Bearer …`,-1),t[13]||=H(` instead of signing in. `,-1)],64)):(L(),R(I,{key:1},[t[14]||=H(` For shell scripts and agents, generate one with `,-1),t[15]||=B(`code`,null,`home-hosted set-token --generate`,-1),t[16]||=H(`. `,-1)],64))]),_:1},8,[`tone`,`title`]),f.value?(L(),z(xV,{key:0,tone:`warn`,title:`The default password is still in use`},{default:N(()=>[...t[17]||=[H(` Set your own password below. Binding beyond `,-1),B(`code`,null,`127.0.0.1`,-1),H(` stays refused until you do. `,-1)]]),_:1})):U(``,!0),u.value?(L(),z(xV,{key:1,tone:`danger`,title:`This listener is being refused`},{default:N(()=>[H(k(u.value),1)]),_:1})):p.value?(L(),z(xV,{key:2,tone:`warn`,title:`Authentication is on but no password is set`},{default:N(()=>[...t[18]||=[H(` Nothing is actually required yet, and binding beyond `,-1),B(`code`,null,`127.0.0.1`,-1),H(` stays refused until a password exists. `,-1)]]),_:1})):d.value?(L(),z(xV,{key:3,tone:`warn`,title:`Reachable beyond 127.0.0.1`},{default:N(()=>[...t[19]||=[H(` Keep the password strong, or put a TLS-terminating proxy in front of the panel. `,-1)]]),_:1})):U(``,!0)]),B(`form`,{class:`mt-3`,onSubmit:lu(T,[`prevent`])},[V(uR,{title:c.value?`Change password`:`Set a password`,description:`Stored as a scrypt hash in the secrets file, never in the config.`},{default:N(()=>[c.value?(L(),z(CR,{key:0,modelValue:g.value,"onUpdate:modelValue":t[7]||=e=>g.value=e,type:`password`,autocomplete:`current-password`,label:`Current password`},null,8,[`modelValue`])):U(``,!0),V(CR,{modelValue:_.value,"onUpdate:modelValue":t[8]||=e=>_.value=e,type:`password`,autocomplete:`new-password`,label:`New password`},null,8,[`modelValue`]),V(CR,{modelValue:v.value,"onUpdate:modelValue":t[9]||=e=>v.value=e,type:`password`,autocomplete:`new-password`,label:`Repeat new password`,error:S.value?`The two passwords do not match.`:null},null,8,[`modelValue`,`error`]),B(`div`,XV,[V($,{type:`submit`,variant:`primary`,disabled:!w.value,loading:x.value},{default:N(()=>[H(k(c.value?`Update password`:`Set password and enable auth`),1)]),_:1},8,[`disabled`,`loading`]),c.value?(L(),z(vV,{key:0,label:`Clear password`,"confirm-label":`Confirm clear`,"confirm-variant":`danger`,disabled:x.value,onConfirm:ee},null,8,[`disabled`])):U(``,!0)]),C.value||b.value||y.value?(L(),R(I,{key:1},[C.value?(L(),z(xV,{key:0,tone:`warn`,title:`That is a short password`,class:`sm:col-span-2`},{default:N(()=>[...t[20]||=[H(` It is allowed, but longer is the only thing standing between the network and this panel. `,-1)]]),_:1})):U(``,!0),b.value?(L(),z(xV,{key:1,tone:`danger`,class:`sm:col-span-2`},{default:N(()=>[H(k(b.value),1)]),_:1})):U(``,!0),y.value?(L(),z(xV,{key:2,tone:`ok`,class:`sm:col-span-2`},{default:N(()=>[H(k(y.value),1)]),_:1})):U(``,!0)],64)):U(``,!0)]),_:1},8,[`title`])],32)],64))}}),QV={class:`space-y-3`},$V={key:0,class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},eH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},tH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},nH={class:`text-2xs leading-4 text-faint`},rH={key:0,class:`space-y-2 sm:col-span-2`},iH={key:1,class:`text-xs text-muted sm:col-span-2`},aH={key:2,class:`divide-y divide-line-soft sm:col-span-2`},oH={class:`min-w-0`},sH={class:`truncate font-mono text-xs text-ink`},cH={class:`mt-0.5 text-2xs leading-4 text-muted`},lH={class:`sm:col-span-2`},uH={key:0,class:`space-y-2 sm:col-span-2`},dH={key:1,class:`sm:col-span-2`},fH={key:2,class:`divide-y divide-line-soft sm:col-span-2`},pH={class:`min-w-0 flex-1`},mH={class:`flex items-center gap-2`},hH={class:`truncate font-mono text-xs text-ink`},gH={class:`mt-0.5 font-mono text-2xs tabular-nums text-muted`},_H={class:`flex items-center gap-1.5`},vH=[`href`],yH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},bH={key:0,class:`font-mono text-2xs text-muted`},xH={class:`sm:col-span-2`},SH={key:0,class:`sm:col-span-2`},CH={class:`mt-2`},wH={class:`mt-2 max-w-sm`},TH={class:`mt-2`},EH={class:`mt-2`},DH={class:`mt-1 max-h-64 space-y-0.5 overflow-auto`},OH={class:`mt-2 flex flex-wrap items-center gap-2`},kH={class:`mt-2`},AH={class:`mt-2`},jH={key:1,class:`space-y-2 sm:col-span-2`},MH=P({__name:`BackupsSection`,props:za({state:{},policy:{},configPath:{},dirty:{type:Boolean}},{form:{required:!0},formModifiers:{}}),emits:za([`reset`],[`update:form`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`form`),a=wM(),o=qV(()=>i.value.keep,e=>i.value.keep=e,5),s=j(!1),c=j(null),l=j(null),u=j(``),d=j(null),f=j(null),p=j(``),m=j(null),h=W(()=>n.state?.files??[]),g=W(()=>n.state?.paths??[]),_=W(()=>d.value?.items.filter(e=>e.selected).length??0),v=W(()=>d.value?.items.some(e=>e.id===`config`&&e.selected)??!1),y=Q(hF,`cursor-pointer text-xs`,`file:mr-2 file:cursor-pointer file:rounded-control file:border-0 file:bg-panel-2 file:px-2 file:py-1 file:text-xs file:text-ink`),b=Q(`inline-flex h-6 shrink-0 items-center gap-1 rounded-control border border-line bg-raise px-2 text-2xs font-medium text-ink`,`transition-colors duration-150 hover:bg-hover`,fF);function x(e){for(let t of d.value?.items??[])t.restorable&&(t.selected=e)}async function S(){s.value=!0,l.value=null,c.value=null;try{await _j(u.value),u.value=``,c.value=`Backup created.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}async function C(e){s.value=!0,l.value=null,c.value=null;try{await vj(e),c.value=`Deleted ${e}.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}function w(e){f.value=e.target.files?.[0]??null,d.value=null,m.value=null,l.value=null,c.value=null}function T(){return p.value.length>0?{password:p.value}:{}}async function ee(e){s.value=!0,l.value=null,c.value=null,d.value=null;try{e===void 0?f.value===null?m.value=null:(m.value={kind:`upload`},d.value=await Sj(f.value,!1,T())):(m.value={kind:`stored`,name:e},d.value=await xj(e,!1,T())),d.value===null&&(l.value=`Choose a stored backup or upload one first.`)}catch(e){m.value=null,l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}async function E(){let e=m.value;e!==null&&await ee(e.kind===`stored`?e.name:void 0)}async function te(){let e=m.value,t=d.value;if(e===null||t===null){l.value=`Check an archive first.`;return}s.value=!0,l.value=null;let n={...T(),include:t.items.filter(e=>e.restorable&&e.selected).map(e=>e.id)};try{let t=e.kind===`stored`?await xj(e.name,!0,n):f.value===null?null:await Sj(f.value,!0,n);d.value=null,m.value=null,f.value=null,p.value=``;let r=[];t?.reloaded&&r.push(`the restored servers are live, autostart entries starting`),t?.restartRequired&&r.push(`restart the panel to apply its own settings`),c.value=t===null?`The restore failed.`:`Restored ${t.applied.length} item(s)${r.length===0?``:` — ${r.join(`; `)}`}.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}return(e,t)=>(L(),R(`div`,QV,[V(uR,{title:`Policy`,description:`What a backup captures, and how many archives are kept.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[9]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(ER,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Allow backups`,hint:`Turning this off hides nothing: the archives already on disk stay downloadable.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(mR,{modelValue:M(o),"onUpdate:modelValue":t[2]||=e=>A(o)?o.value=e:null,label:`Keep`,min:1,hint:`Older archives are pruned after each backup.`},null,8,[`modelValue`]),V(CR,{modelValue:i.value.includePaths,"onUpdate:modelValue":t[3]||=e=>i.value.includePaths=e,label:`Extra paths`,hint:`Comma separated, in addition to every entry's data directories.`,placeholder:`{home}/myapp-data`},null,8,[`modelValue`]),n.policy===null?U(``,!0):(L(),R(`div`,$V,[t[12]||=B(`span`,{class:`text-xs font-medium text-muted`},`Archive directory`,-1),B(`div`,eH,[B(`span`,tH,k(n.policy.dir),1),V(zB,{value:n.policy.dir,label:`Copy the archive directory`},null,8,[`value`])]),B(`p`,nH,[t[10]||=H(` Changing it is a file-level decision: edit `,-1),B(`code`,null,k(n.configPath??`the config file`),1),t[11]||=H(`. `,-1)])]))]),_:1}),V(uR,{title:`Declared paths`,description:`Config, secrets and TLS are always captured. A path already covered by a declared parent is skipped.`},{default:N(()=>[n.state===null?(L(),R(`div`,rH,[V(uL,{class:`h-4 w-full`})])):g.value.length===0?(L(),R(`p`,iH,[...t[13]||=[H(` No data paths are declared yet. Add `,-1),B(`code`,null,`dataEnvs`,-1),H(` or `,-1),B(`code`,null,`backupPaths`,-1),H(` to a server to capture its data. `,-1)]])):(L(),R(`ul`,aH,[(L(!0),R(I,null,va(g.value,e=>(L(),R(`li`,{key:`${e.origin}:${e.path}`,class:`flex items-start justify-between gap-3 py-1.5`},[B(`div`,oH,[B(`p`,sH,k(e.path),1),B(`p`,cH,k(e.included?`from ${e.origin}`:e.note??`not captured`),1)]),V(NF,{tone:e.included?`ok`:`neutral`,plain:``},{default:N(()=>[H(k(e.included?`included`:`skipped`),1)]),_:2},1032,[`tone`])]))),128))]))]),_:1}),V(uR,{title:`Create a backup now`,description:`Optional password encrypts the archive; restoring it will ask for the same password.`},{default:N(()=>[V(CR,{modelValue:u.value,"onUpdate:modelValue":t[4]||=e=>u.value=e,type:`password`,autocomplete:`new-password`,label:`Password (optional)`,wide:``},null,8,[`modelValue`]),B(`div`,lH,[V($,{variant:`primary`,disabled:s.value,loading:s.value,onClick:S},{default:N(()=>[...t[14]||=[H(` Create backup now `,-1)]]),_:1},8,[`disabled`,`loading`])])]),_:1}),V(uR,{title:`Archives`,description:`Stored in the backup directory and downloadable at any time.`},{default:N(()=>[n.state===null?(L(),R(`div`,uH,[V(uL,{class:`h-4 w-full`}),V(uL,{class:`h-4 w-2/3`})])):h.value.length===0?(L(),R(`div`,dH,[V(QI,{compact:``,title:`No archives yet`,description:`Create one now to capture the config, secrets and every declared data path.`},{icon:N(()=>[V(M(Mv),{class:`size-4`})]),action:N(()=>[V($,{size:`sm`,variant:`primary`,disabled:s.value,onClick:S},{default:N(()=>[...t[15]||=[H(` Create backup now `,-1)]]),_:1},8,[`disabled`])]),_:1})])):(L(),R(`ul`,fH,[(L(!0),R(I,null,va(h.value,e=>(L(),R(`li`,{key:e.name,class:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 first:pt-0 last:pb-0`},[B(`div`,pH,[B(`div`,mH,[B(`span`,hH,k(e.name),1),e.encrypted?(L(),z(NF,{key:0,tone:`warn`,plain:``},{default:N(()=>[...t[16]||=[H(` encrypted `,-1)]]),_:1})):U(``,!0)]),B(`p`,gH,k(M(xI)(e.sizeBytes))+` · `+k(M(gI)(e.createdAt)),1)]),B(`div`,_H,[B(`a`,{href:yj(e.name),class:O(M(b))},[V(M(qv),{class:`size-3`,"aria-hidden":`true`}),t[17]||=H(` Download `,-1)],10,vH),V($,{size:`xs`,variant:`secondary`,disabled:s.value,onClick:t=>ee(e.name)},{default:N(()=>[V(M(gy),{class:`size-3`,"aria-hidden":`true`}),t[18]||=H(` Restore `,-1)]),_:1},8,[`disabled`,`onClick`]),V(vV,{label:`Delete`,"confirm-label":`Confirm delete`,size:`xs`,variant:`ghost`,"confirm-variant":`danger`,disabled:s.value,onConfirm:t=>C(e.name)},null,8,[`disabled`,`onConfirm`])])]))),128))]))]),_:1}),V(uR,{title:`Restore`,description:`Nothing is written until the plan is applied.`},{default:N(()=>[B(`div`,yH,[B(`label`,{class:O(M(pF)),for:`restore-upload`},`Restore from an uploaded .zip`,2),B(`input`,{id:`restore-upload`,type:`file`,accept:`.zip,application/zip`,class:O(M(y)),onChange:w},null,34),f.value?(L(),R(`p`,bH,k(f.value.name),1)):U(``,!0)]),B(`div`,xH,[V($,{variant:`secondary`,disabled:s.value||f.value===null,onClick:t[5]||=e=>ee()},{default:N(()=>[...t[19]||=[H(` Check the upload `,-1)]]),_:1},8,[`disabled`])]),d.value?(L(),R(`div`,SH,[V(xV,{tone:`warn`,title:d.value.dryRun?`Nothing has changed yet`:`Applied`},{default:N(()=>[B(`p`,null,[m.value?.kind===`stored`?(L(),R(I,{key:0},[t[20]||=H(` Archive `,-1),B(`code`,null,k(m.value.name),1),t[21]||=H(`. `,-1)],64)):(L(),R(I,{key:1},[H(` The uploaded archive. `)],64))]),d.value.needsPassword?(L(),R(I,{key:0},[B(`p`,CH,k(d.value.error??`This backup is password-protected.`),1),B(`div`,wH,[V(CR,{modelValue:p.value,"onUpdate:modelValue":t[6]||=e=>p.value=e,type:`password`,autocomplete:`off`,label:`Password`},null,8,[`modelValue`])]),B(`div`,TH,[V($,{size:`sm`,variant:`secondary`,disabled:s.value,onClick:E},{default:N(()=>[...t[22]||=[H(` Check again with the password `,-1)]]),_:1},8,[`disabled`])])],64)):(L(),R(I,{key:1},[B(`p`,EH,` Choose what to restore — `+k(_.value)+` of `+k(d.value.items.length)+` selected. `,1),B(`ul`,DH,[(L(!0),R(I,null,va(d.value.items,e=>(L(),R(`li`,{key:e.id},[V(DB,{modelValue:e.selected,"onUpdate:modelValue":t=>e.selected=t,label:e.label,hint:[e.kind,e.note].filter(Boolean).join(` · `),disabled:!e.restorable},null,8,[`modelValue`,`onUpdate:modelValue`,`label`,`hint`,`disabled`])]))),128))]),B(`div`,OH,[V($,{size:`xs`,variant:`ghost`,disabled:s.value,onClick:t[7]||=e=>x(!0)},{default:N(()=>[...t[23]||=[H(` Select all `,-1)]]),_:1},8,[`disabled`]),V($,{size:`xs`,variant:`ghost`,disabled:s.value,onClick:t[8]||=e=>x(!1)},{default:N(()=>[...t[24]||=[H(` Select none `,-1)]]),_:1},8,[`disabled`])]),B(`p`,kH,[H(` Will restore: `+k(d.value.applied.join(`, `)||`nothing`)+`. `,1),d.value.skipped.length?(L(),R(I,{key:0},[H(` Skipped: `+k(d.value.skipped.join(`, `))+`. `,1)],64)):U(``,!0),d.value.restartRequired?(L(),R(I,{key:1},[H(` The panel's own settings differ, so restart the panel afterwards. `)],64)):v.value?(L(),R(I,{key:2},[H(` Restored servers are reloaded immediately; entries marked autostart start on their own. `)],64)):U(``,!0)]),B(`div`,AH,[V($,{size:`sm`,variant:`danger`,disabled:s.value||_.value===0,loading:s.value,onClick:te},{default:N(()=>[H(k(m.value?.kind===`stored`?`Apply this restore`:`Restore the upload`),1)]),_:1},8,[`disabled`,`loading`])])],64))]),_:1},8,[`title`])])):U(``,!0),l.value||c.value?(L(),R(`div`,jH,[l.value?(L(),z(xV,{key:0,tone:`danger`},{default:N(()=>[H(k(l.value),1)]),_:1})):U(``,!0),c.value?(L(),z(xV,{key:1,tone:`ok`},{default:N(()=>[H(k(c.value),1)]),_:1})):U(``,!0)])):U(``,!0)]),_:1})]))}}),NH={class:`mt-3 space-y-3`},PH=P({__name:`DefaultsSection`,props:za({dirty:{type:Boolean}},{defaults:{required:!0},defaultsModifiers:{}}),emits:za([`reset`],[`update:defaults`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`defaults`),a=qV(()=>i.value.logBufferLines,e=>i.value.logBufferLines=e,500);return(e,t)=>(L(),R(I,null,[V(uR,{title:`Server defaults`,description:`Applied to every entry that does not set its own value.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[9]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(DB,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Enabled`,hint:`New entries start enabled.`},null,8,[`modelValue`]),V(DB,{modelValue:i.value.autostart,"onUpdate:modelValue":t[2]||=e=>i.value.autostart=e,label:`Autostart with the panel`},null,8,[`modelValue`]),V(lL,{modelValue:i.value.bind,"onUpdate:modelValue":t[3]||=e=>i.value.bind=e,label:`Bind`,options:[{value:`local`,label:`Local — 127.0.0.1`},{value:`lan`,label:`LAN — 0.0.0.0`}]},null,8,[`modelValue`]),V(lL,{modelValue:i.value.onPortConflict,"onUpdate:modelValue":t[4]||=e=>i.value.onPortConflict=e,label:`On port conflict`,options:[{value:`block`,label:`Block the start`},{value:`warn`,label:`Warn and start anyway`},{value:`follow`,label:`Follow a detached restart of itself`},{value:`reclaim`,label:`Replace a detached restart with a supervised copy`}]},null,8,[`modelValue`]),V(mR,{modelValue:M(a),"onUpdate:modelValue":t[5]||=e=>A(a)?a.value=e:null,label:`Log buffer lines`,min:50,max:1e5,hint:`Kept in memory per server.`},null,8,[`modelValue`])]),_:1}),B(`div`,NH,[V(OB,{restart:i.value.restart,"onUpdate:restart":t[6]||=e=>i.value.restart=e,health:i.value.health,"onUpdate:health":t[7]||=e=>i.value.health=e,stop:i.value.stop,"onUpdate:stop":t[8]||=e=>i.value.stop=e},null,8,[`restart`,`health`,`stop`])])],64))}}),FH={key:0,class:`mt-3 flex flex-wrap items-center gap-1.5`},IH={key:1,class:`mt-3 text-xs text-muted`},LH=P({__name:`HostSection`,props:za({config:{},alerts:{},dirty:{type:Boolean}},{host:{required:!0},hostModifiers:{}}),emits:za([`reset`],[`update:host`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`host`),a=qV(()=>i.value.intervalMs,e=>i.value.intervalMs=e,15e3),o=qV(()=>i.value.diskUsedPercent,e=>i.value.diskUsedPercent=e,90),s=qV(()=>i.value.memoryUsedPercent,e=>i.value.memoryUsedPercent=e,90),c=qV(()=>i.value.swapUsedPercent,e=>i.value.swapUsedPercent=e,50),l=qV(()=>i.value.loadPerCpu,e=>i.value.loadPerCpu=e,2),u=qV(()=>i.value.tempCelsius,e=>i.value.tempCelsius=e,85);return(e,t)=>(L(),R(I,null,[V(uR,{title:`Thresholds`,description:`A threshold of 0 disables that alert. Breaches notify once, and once more on recovery.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[9]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(ER,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Sample this machine`,hint:`Load, memory, swap, disk and CPU temperature, on the interval below.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(mR,{modelValue:M(a),"onUpdate:modelValue":t[2]||=e=>A(a)?a.value=e:null,label:`Interval (ms)`,min:5e3,hint:`How often the host is sampled and alerts are checked.`},null,8,[`modelValue`]),V(CR,{modelValue:i.value.diskPaths,"onUpdate:modelValue":t[3]||=e=>i.value.diskPaths=e,label:`Disk paths`,hint:`Comma separated; templates like {home} are expanded.`},null,8,[`modelValue`]),V(mR,{modelValue:M(o),"onUpdate:modelValue":t[4]||=e=>A(o)?o.value=e:null,label:`Disk used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),V(mR,{modelValue:M(s),"onUpdate:modelValue":t[5]||=e=>A(s)?s.value=e:null,label:`Memory used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),V(mR,{modelValue:M(c),"onUpdate:modelValue":t[6]||=e=>A(c)?c.value=e:null,label:`Swap used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),V(mR,{modelValue:M(l),"onUpdate:modelValue":t[7]||=e=>A(l)?l.value=e:null,label:`Load per CPU`,min:0,hint:`1-minute load average divided by the core count.`},null,8,[`modelValue`]),V(mR,{modelValue:M(u),"onUpdate:modelValue":t[8]||=e=>A(u)?u.value=e:null,label:`CPU temperature (°C)`,min:0,hint:`Linux only; ignored where the OS does not expose it.`},null,8,[`modelValue`])]),_:1}),n.alerts.length>0?(L(),R(`div`,FH,[t[10]||=B(`span`,{class:`text-xs text-muted`},`Breaching now:`,-1),(L(!0),R(I,null,va(n.alerts,e=>(L(),z(NF,{key:e,tone:`danger`,dot:``},{default:N(()=>[H(k(e),1)]),_:2},1024))),128))])):i.value.enabled?(L(),R(`p`,IH,` Nothing is breaching right now. `)):U(``,!0)],64))}}),RH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},zH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},BH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},VH={class:`text-2xs leading-4 text-faint`},HH={key:0},UH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},WH=[`disabled`],GH=P({__name:`InterfaceSection`,props:za({ui:{},labelDirty:{type:Boolean}},{label:{required:!0},labelModifiers:{}}),emits:za([`changed`,`resetLabel`],[`update:label`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`label`),a=j(null),o=j(!1),s=j(null),c=j(null),l=j(!1),u=W(()=>{let e=n.ui;if(e===null)return`unknown`;if(!e.custom)return`stock`;let t=e.meta;return t===null?`custom`:`custom · ${t.name}${t.version===null?``:` ${t.version}`}`}),d=W(()=>{let e=n.ui?.meta;return e==null?null:`${e.files} files · ${new Date(e.uploadedAt).toLocaleString()}`});function f(e){a.value=e.target.files?.[0]??null,s.value=null,c.value=null}async function p(){if(a.value!==null){o.value=!0,c.value=null,s.value=null;try{let e=await Dj(a.value);s.value=`UI replaced with ${e.meta?.name??`your build`} — refresh the page`,a.value=null,r(`changed`)}catch(e){c.value=e instanceof Error?e.message:String(e)}finally{o.value=!1}}}async function m(){if(!l.value){l.value=!0,setTimeout(()=>{l.value=!1},5e3);return}l.value=!1,o.value=!0,c.value=null;try{let e=await Oj();s.value=e.removed?`stock UI restored — refresh the page`:`no custom UI was installed`,r(`changed`)}catch(e){c.value=e instanceof Error?e.message:String(e)}finally{o.value=!1}}return(t,h)=>(L(),z(uR,{title:`Interface`,description:`The panel is a static site: keep the stock one, or serve your own build from the state directory.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.labelDirty,onClick:h[1]||=e=>r(`resetLabel`)},{default:N(()=>[...h[4]||=[H(` Reset name `,-1)]]),_:1},8,[`disabled`]),e.ui?.custom?(L(),z($,{key:0,size:`xs`,variant:`ghost`,disabled:o.value,onClick:m},{default:N(()=>[H(k(l.value?`Confirm revert`:`Revert to stock`),1)]),_:1},8,[`disabled`])):U(``,!0),V($,{size:`xs`,variant:`primary`,disabled:o.value||a.value===null,onClick:p},{default:N(()=>[...h[5]||=[H(` Install UI `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[B(`div`,RH,[h[2]||=B(`span`,{class:`text-xs font-medium text-muted`},`Currently serving`,-1),B(`div`,zH,[B(`span`,BH,k(u.value),1),V(zB,{value:e.ui?.dir??``,label:`Copy the UI directory`},null,8,[`value`])]),B(`p`,VH,[d.value?(L(),R(`span`,HH,k(d.value)+` · `,1)):U(``,!0),B(`code`,null,k(e.ui?.dir??`—`),1)])]),V(CR,{modelValue:i.value,"onUpdate:modelValue":h[0]||=e=>i.value=e,label:`Panel name`,hint:`Shown in the sidebar by the stock UI. A custom UI may show its own name instead.`,wide:``},null,8,[`modelValue`]),B(`label`,UH,[h[3]||=B(`span`,{class:`text-xs font-medium text-muted`},`Upload a UI build (.zip with an index.html)`,-1),B(`input`,{type:`file`,accept:`.zip,application/zip`,class:`rounded-control border border-line bg-page/60 px-2.5 py-1.5 text-xs text-ink file:mr-2 file:rounded file:border-0 file:bg-line file:px-2 file:py-1 file:text-xs`,disabled:o.value,onChange:f},null,40,WH)]),c.value?(L(),z(xV,{key:0,tone:`warn`,title:c.value},null,8,[`title`])):s.value?(L(),z(xV,{key:1,tone:`ok`,title:s.value},null,8,[`title`])):U(``,!0),h[6]||=B(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},[H(` See `),B(`code`,null,`UI_CREATION.md`),H(` for the API contract. If a custom UI breaks the panel, `),B(`code`,null,`home-hosted ui-revert`),H(` puts the stock one back from the terminal. `)],-1)]),_:1}))}}),KH={class:`flex min-w-0 flex-col gap-1`},qH={class:`text-2xs leading-4 text-faint`},JH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},YH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},XH={class:`min-w-0 flex-1 truncate font-mono text-xs tabular-nums text-ink`},ZH=P({__name:`ListenerSection`,props:za({view:{},dirty:{type:Boolean}},{control:{required:!0},controlModifiers:{}}),emits:za([`reset`],[`update:control`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`control`),a=qV(()=>i.value.port,e=>i.value.port=e,3999),o=[`local`,`lan`],s=W({get:()=>o.includes(i.value.host)?i.value.host:`custom`,set:e=>{if(e!==`custom`){i.value.host=e;return}if(!o.includes(i.value.host))return;let t=n.view?.bindHost??``,r=t!==``&&t!==`0.0.0.0`&&t!==`127.0.0.1`&&Wk(t)!==null;i.value.host=r?t:`127.0.0.1`}}),c=W(()=>{if(s.value===`custom`&&Wk(i.value.host)===null)return`Enter an IPv4 address, for example 192.168.1.20.`}),l=W(()=>n.view?.url??`—`);return(e,t)=>(L(),z(uR,{title:`Listener`,description:`Where the panel answers. Moving this restarts the panel and sends this page to the new address.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[5]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(mR,{modelValue:M(a),"onUpdate:modelValue":t[1]||=e=>A(a)?a.value=e:null,label:`Control port`,min:1,max:65535,hint:`Default 3999.`},null,8,[`modelValue`]),B(`div`,KH,[t[6]||=B(`span`,{class:`text-xs font-medium text-muted`},`Bind`,-1),V(AI,{modelValue:s.value,"onUpdate:modelValue":t[2]||=e=>s.value=e,options:[{value:`local`,label:`Local`},{value:`lan`,label:`LAN`},{value:`custom`,label:`Custom`}]},null,8,[`modelValue`]),B(`p`,qH,k(s.value===`lan`?`0.0.0.0 — reachable from the whole network.`:s.value===`local`?`127.0.0.1 — this machine only.`:`A specific interface address you type in below.`),1)]),s.value===`custom`?(L(),z(CR,{key:0,modelValue:i.value.host,"onUpdate:modelValue":t[3]||=e=>i.value.host=e,label:`IPv4 address`,placeholder:`192.168.1.20`,error:c.value,hint:`Binding beyond 127.0.0.1 needs a real password.`},null,8,[`modelValue`,`error`])):U(``,!0),V(DB,{modelValue:i.value.openBrowser,"onUpdate:modelValue":t[4]||=e=>i.value.openBrowser=e,label:`Open a browser when the panel comes up`,wide:``},null,8,[`modelValue`]),B(`div`,JH,[t[8]||=B(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),B(`div`,YH,[B(`span`,XH,k(l.value),1),n.view?.restartRequired?(L(),z(NF,{key:0,tone:`warn`,dot:``},{default:N(()=>[...t[7]||=[H(` restart required `,-1)]]),_:1})):U(``,!0),V(zB,{value:l.value,label:`Copy the live address`},null,8,[`value`])]),t[9]||=B(`p`,{class:`text-2xs leading-4 text-faint`},` What the listener is bound to right now; saved changes take effect after the panel rebinds. `,-1)])]),_:1}))}}),QH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},$H={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},eU={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},tU={class:`text-2xs leading-4 text-faint`},nU=P({__name:`LogsSection`,props:za({logsDir:{},dirty:{type:Boolean}},{logs:{required:!0},logsModifiers:{}}),emits:za([`reset`],[`update:logs`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`logs`),a=qV(()=>i.value.maxBytes,e=>i.value.maxBytes=e,2e6),o=qV(()=>i.value.keep,e=>i.value.keep=e,3),s=W(()=>n.logsDir??`—`);return(e,t)=>{let c=fa(`RouterLink`);return L(),z(uR,{title:`Retention`,description:`The live view always comes from memory; these files survive a restart and feed the Logs page.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[4]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(ER,{modelValue:i.value.persist,"onUpdate:modelValue":t[1]||=e=>i.value.persist=e,label:`Keep logs on disk`,hint:`Turn off to hold everything in memory only.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(mR,{modelValue:M(a),"onUpdate:modelValue":t[2]||=e=>A(a)?a.value=e:null,label:`Rotate at (bytes)`,min:1e4,max:1e8,hint:`Per server, before rolling to .1, .2, …`},null,8,[`modelValue`]),V(mR,{modelValue:M(o),"onUpdate:modelValue":t[3]||=e=>A(o)?o.value=e:null,label:`Keep rotated files`,min:1,max:10},null,8,[`modelValue`]),B(`div`,QH,[t[8]||=B(`span`,{class:`text-xs font-medium text-muted`},`Logs directory`,-1),B(`div`,$H,[B(`span`,eU,k(s.value),1),V(zB,{value:s.value,label:`Copy the logs directory`},null,8,[`value`])]),B(`p`,tU,[t[6]||=H(` Browse and download these files on the `,-1),V(c,{to:`/logs`,class:`text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent`},{default:N(()=>[...t[5]||=[H(` Logs `,-1)]]),_:1}),t[7]||=H(` page. `,-1)])])]),_:1})}}}),rU={class:`flex items-center gap-2 border-t border-line-soft pt-3 sm:col-span-2`},iU={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},aU={key:0,class:`sm:col-span-2`},oU={class:`flex flex-wrap gap-1.5`},sU={key:1,class:`sm:col-span-2`},cU={class:`text-2xs leading-4 text-faint`},lU={key:2,class:`space-y-2 sm:col-span-2`},uU=P({__name:`NotificationsSection`,props:za({status:{},dirty:{type:Boolean}},{telegram:{required:!0},telegramModifiers:{}}),emits:za([`reset`],[`update:telegram`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`telegram`),a=wM(),o=qV(()=>i.value.cooldownMs,e=>i.value.cooldownMs=e,12e4),s=j(``),c=j(null),l=j(null),u=j([]),d=j(!1),f=W(()=>n.status?.tokenSet===!0),p=W(()=>n.status?.lastResult??null),m=W(()=>n.status?.lastResultAt??null),h=W(()=>f.value?`Saved — type a new token to replace it`:`123456789:AA…`);async function g(){d.value=!0,l.value=null,c.value=null;try{let e=await Cj(s.value.trim());s.value=``,c.value=`Token saved${e.username?` for @${e.username}`:``}.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{d.value=!1}}async function _(){d.value=!0,l.value=null,c.value=null;try{await wj(),c.value=`Token removed.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{d.value=!1}}async function v(){d.value=!0,l.value=null,c.value=null;try{let e=s.value.trim(),t=await Ej(e.length>0?{botToken:e}:{});u.value=t.chats,t.chats.length===0&&(l.value=`No chats found. Send /start to the bot first, then detect again.`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{d.value=!1}}async function y(){d.value=!0,l.value=null,c.value=null;try{let e=s.value.trim(),t=await Tj({chatId:i.value.chatId.length>0?i.value.chatId:void 0,...e.length>0?{botToken:e}:{}});t.ok?c.value=`Test message sent.`:l.value=t.error??`The test message failed.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{d.value=!1}}return(e,t)=>(L(),z(uR,{title:`Telegram`,description:`Policy lives in the config; the bot token is a secret and never comes back from the server.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[10]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(ER,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Send notifications`,hint:`One message per event, throttled by the cooldown below.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(CR,{modelValue:i.value.chatId,"onUpdate:modelValue":t[2]||=e=>i.value.chatId=e,label:`Chat id`,placeholder:`123456789 or @channel`,hint:`Use Detect chats to fill this from the bot's updates.`},null,8,[`modelValue`]),V(mR,{modelValue:M(o),"onUpdate:modelValue":t[3]||=e=>A(o)?o.value=e:null,label:`Cooldown per event (ms)`,min:0,hint:`Per server and reason, so a flapping server cannot spam.`},null,8,[`modelValue`]),V(DB,{modelValue:i.value.onCrash,"onUpdate:modelValue":t[4]||=e=>i.value.onCrash=e,label:`Retries exhausted`},null,8,[`modelValue`]),V(DB,{modelValue:i.value.onUnhealthy,"onUpdate:modelValue":t[5]||=e=>i.value.onUnhealthy=e,label:`Port unhealthy`},null,8,[`modelValue`]),V(DB,{modelValue:i.value.onForcedRestart,"onUpdate:modelValue":t[6]||=e=>i.value.onForcedRestart=e,label:`Forced restart`},null,8,[`modelValue`]),V(DB,{modelValue:i.value.onRecovered,"onUpdate:modelValue":t[7]||=e=>i.value.onRecovered=e,label:`Recovered`},null,8,[`modelValue`]),V(DB,{modelValue:i.value.onHost,"onUpdate:modelValue":t[8]||=e=>i.value.onHost=e,label:`Host vitals breached`,hint:`Disk, memory, swap, load and CPU temperature, per the thresholds under Host vitals.`,wide:``},null,8,[`modelValue`]),B(`div`,rU,[t[11]||=B(`span`,{class:`text-xs font-medium text-muted`},`Bot token`,-1),V(NF,{tone:f.value?`ok`:`warn`,dot:``},{default:N(()=>[H(k(f.value?`token set`:`no token`),1)]),_:1},8,[`tone`]),t[12]||=B(`span`,{class:`text-2xs text-faint`},`From @BotFather — a secret, never in servers.config.json.`,-1)]),V(CR,{modelValue:s.value,"onUpdate:modelValue":t[9]||=e=>s.value=e,type:`password`,autocomplete:`off`,label:`Bot token`,placeholder:h.value,wide:``},null,8,[`modelValue`,`placeholder`]),B(`div`,iU,[V($,{variant:`primary`,disabled:d.value||s.value.trim().length===0,loading:d.value&&s.value.trim().length>0,onClick:g},{default:N(()=>[...t[13]||=[H(` Save token `,-1)]]),_:1},8,[`disabled`,`loading`]),V($,{variant:`secondary`,disabled:d.value,onClick:v},{default:N(()=>[...t[14]||=[H(` Detect chats `,-1)]]),_:1},8,[`disabled`]),V($,{variant:`secondary`,disabled:d.value,onClick:y},{default:N(()=>[...t[15]||=[H(` Send test `,-1)]]),_:1},8,[`disabled`]),f.value?(L(),z(vV,{key:0,label:`Remove token`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:d.value,onConfirm:_},null,8,[`disabled`])):U(``,!0)]),u.value.length>0?(L(),R(`div`,aU,[t[16]||=B(`p`,{class:`mb-1.5 text-xs text-muted`},` Chats the bot has seen: `,-1),B(`div`,oU,[(L(!0),R(I,null,va(u.value,e=>(L(),z($,{key:String(e.id),size:`xs`,variant:`secondary`,onClick:t=>i.value.chatId=String(e.id)},{default:N(()=>[H(k(e.title)+` (`+k(e.id)+`) `,1)]),_:2},1032,[`onClick`]))),128))])])):U(``,!0),p.value?(L(),R(`div`,sU,[B(`p`,cU,` Last send: `+k(p.value)+k(m.value?` · ${M(bI)(m.value,M(a).now.value)}`:``),1)])):U(``,!0),l.value||c.value?(L(),R(`div`,lU,[l.value?(L(),z(xV,{key:0,tone:`danger`},{default:N(()=>[H(k(l.value),1)]),_:1})):U(``,!0),c.value?(L(),z(xV,{key:1,tone:`ok`},{default:N(()=>[H(k(c.value),1)]),_:1})):U(``,!0)])):U(``,!0)]),_:1}))}}),dU={class:`divide-y divide-line-soft sm:col-span-2`},fU={class:`min-w-0`},pU={class:`text-xs font-medium text-ink`},mU={class:`mt-0.5 text-2xs leading-4 text-faint`},hU={class:`flex min-w-0 flex-1 items-center justify-end gap-1.5`},gU={class:`min-w-0 truncate font-mono text-xs text-ink`},_U=P({__name:`PathsSection`,props:{configPath:{},dataRoot:{},logsDir:{},projectDir:{},panelUrl:{}},setup(e){let t=e,n=W(()=>[{key:`data`,label:`Data root`,hint:`HHOSTED_HOME — config, secrets, TLS, logs and backups.`,value:t.dataRoot??`—`},{key:`config`,label:`Config file`,hint:`servers.config.json — every policy on this page.`,value:t.configPath??`—`},{key:`logs`,label:`Logs directory`,hint:`Persisted output for every server.`,value:t.logsDir??`—`},{key:`project`,label:`Project directory`,hint:`Base for relative entry paths.`,value:t.projectDir??`—`},{key:`panel`,label:`Panel address`,hint:`Where this control panel is live right now.`,value:t.panelUrl??`—`}]);return(e,t)=>(L(),z(uR,{title:`Where things live`,description:`Read-only. Copy a path straight into a shell or an editor.`},{default:N(()=>[B(`ul`,dU,[(L(!0),R(I,null,va(n.value,e=>(L(),R(`li`,{key:e.key,class:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`},[B(`div`,fU,[B(`p`,pU,k(e.label),1),B(`p`,mU,k(e.hint),1)]),B(`div`,hU,[B(`span`,gU,k(e.value),1),V(zB,{value:e.value,label:`Copy ${e.label.toLowerCase()}`},null,8,[`value`,`label`])])]))),128))])]),_:1}))}}),vU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},yU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},bU={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},xU={key:0,class:`sm:col-span-2`},SU={key:1,class:`space-y-3 sm:col-span-2`},CU={class:`divide-y divide-line-soft text-xs`},wU={class:`flex items-start justify-between gap-4 py-1.5`},TU={class:`min-w-0 text-right font-mono text-xs text-ink`},EU={class:`flex items-start justify-between gap-4 py-1.5`},DU={class:`min-w-0 text-right font-mono text-xs text-ink`},OU={class:`flex items-start justify-between gap-4 py-1.5`},kU={class:`font-mono text-xs tabular-nums text-ink`},AU={class:`flex items-center justify-between gap-4 py-1.5`},jU={class:`flex items-start justify-between gap-4 py-1.5`},MU={class:`flex min-w-0 items-center gap-1.5`},NU={class:`min-w-0 truncate font-mono text-2xs text-ink`},PU={key:2,class:`sm:col-span-2`},FU={class:`flex min-w-0 flex-col gap-1`},IU={class:`flex min-w-0 flex-col gap-1`},LU={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},RU={key:3,class:`space-y-2 sm:col-span-2`},zU=P({__name:`TlsSection`,props:za({view:{},dirty:{type:Boolean}},{tlsEnabled:{type:Boolean,required:!0},tlsEnabledModifiers:{}}),emits:za([`reset`],[`update:tlsEnabled`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`tlsEnabled`),a=wM(),o=j(``),s=j(``),c=j(null),l=j(null),u=j(!1),d=W(()=>n.view?.tls??null),f=W(()=>n.view?`${n.view.protocol}://${n.view.bindHost}:${n.view.port}`:`—`),p=W(()=>o.value.trim().length>0&&s.value.trim().length>0&&!u.value),m=Q(hF,`cursor-pointer text-xs`,`file:mr-2 file:cursor-pointer file:rounded-control file:border-0 file:bg-panel-2 file:px-2 file:py-1 file:text-xs file:text-ink`);async function h(e,t){let n=e.target.files?.[0];if(!n)return;let r=await n.text();t===`cert`?o.value=r:s.value=r}async function g(){u.value=!0,l.value=null,c.value=null;try{let e=await kj(o.value,s.value);o.value=``,s.value=``,c.value=`Certificate stored.`,await a.refresh();let t=await JV(e);t!==null&&(l.value=t)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}async function _(){u.value=!0,l.value=null,c.value=null;try{let e=await Aj();c.value=`Certificate removed.`,await a.refresh();let t=await JV(e);t!==null&&(l.value=t)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}return(e,t)=>(L(),R(I,null,[V(uR,{title:`HTTPS`,description:`Upload a PEM pair and the panel serves TLS on its own listener. A self-signed certificate is fine on a home network.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[6]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(ER,{modelValue:i.value,"onUpdate:modelValue":t[1]||=e=>i.value=e,label:`Serve the panel over HTTPS`,hint:`Saved with Save settings; the panel rebinds and this page follows it.`,class:`sm:col-span-2`},null,8,[`modelValue`]),B(`div`,vU,[t[7]||=B(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),B(`div`,yU,[B(`span`,bU,k(f.value),1),V(zB,{value:f.value,label:`Copy the live address`},null,8,[`value`])])])]),_:1}),V(uR,{class:`mt-3`,title:`Certificate`,description:`PEM-encoded certificate and its private key. Both stay in the secrets file.`},{default:N(()=>[d.value?.error?(L(),R(`div`,xU,[V(xV,{tone:`danger`,title:`The stored certificate cannot be used`},{default:N(()=>[H(k(d.value.error),1)]),_:1})])):d.value?.certPresent?(L(),R(`div`,SU,[B(`dl`,CU,[B(`div`,wU,[t[8]||=B(`dt`,{class:`text-muted`},` Subject `,-1),B(`dd`,TU,k(d.value.subject??`—`),1)]),B(`div`,EU,[t[9]||=B(`dt`,{class:`text-muted`},` Issuer `,-1),B(`dd`,DU,k(d.value.issuer??`—`),1)]),B(`div`,OU,[t[10]||=B(`dt`,{class:`text-muted`},` Valid until `,-1),B(`dd`,kU,[H(k(d.value.validTo?d.value.validTo.slice(0,10):`—`)+` `,1),d.value.daysRemaining===null?U(``,!0):(L(),R(`span`,{key:0,class:O(M(Q)(`ml-1.5`,d.value.daysRemaining<14?`text-warn`:`text-faint`))},` (`+k(d.value.daysRemaining)+` days) `,3))])]),B(`div`,AU,[t[11]||=B(`dt`,{class:`text-muted`},` Private key `,-1),B(`dd`,null,[V(NF,{tone:d.value.keyMatches?`ok`:`danger`,dot:``},{default:N(()=>[H(k(d.value.keyMatches?`matches the certificate`:`does not match`),1)]),_:1},8,[`tone`])])]),B(`div`,jU,[t[12]||=B(`dt`,{class:`text-muted`},` Fingerprint `,-1),B(`dd`,MU,[B(`span`,NU,k(d.value.fingerprint??`—`),1),d.value.fingerprint?(L(),z(zB,{key:0,value:d.value.fingerprint,label:`Copy the fingerprint`},null,8,[`value`])):U(``,!0)])])])])):(L(),R(`div`,PU,[V(xV,{tone:`info`,title:`No certificate uploaded`},{default:N(()=>[...t[13]||=[H(` Upload a PEM certificate and key below, then save. HTTPS is not served until a certificate is present. `,-1)]]),_:1})])),B(`div`,FU,[B(`label`,{class:O(M(pF)),for:`tls-cert-file`},`Certificate file (.pem, .crt)`,2),B(`input`,{id:`tls-cert-file`,type:`file`,accept:`.pem,.crt,.cer,text/plain`,class:O(M(m)),onChange:t[2]||=e=>h(e,`cert`)},null,34)]),B(`div`,IU,[B(`label`,{class:O(M(pF)),for:`tls-key-file`},`Private key file (.pem, .key)`,2),B(`input`,{id:`tls-key-file`,type:`file`,accept:`.pem,.key,text/plain`,class:O(M(m)),onChange:t[3]||=e=>h(e,`key`)},null,34)]),V(vR,{modelValue:o.value,"onUpdate:modelValue":t[4]||=e=>o.value=e,label:`Or paste the certificate`,rows:4,placeholder:`-----BEGIN CERTIFICATE-----`},null,8,[`modelValue`]),V(vR,{modelValue:s.value,"onUpdate:modelValue":t[5]||=e=>s.value=e,label:`Or paste the private key`,rows:4,placeholder:`-----BEGIN PRIVATE KEY-----`},null,8,[`modelValue`]),B(`div`,LU,[V($,{variant:`primary`,disabled:!p.value,loading:u.value,onClick:g},{default:N(()=>[...t[14]||=[H(` Save certificate `,-1)]]),_:1},8,[`disabled`,`loading`]),d.value?.certPresent?(L(),z(vV,{key:0,label:`Remove certificate`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:u.value,onConfirm:_},null,8,[`disabled`])):U(``,!0)]),l.value||c.value?(L(),R(`div`,RU,[l.value?(L(),z(xV,{key:0,tone:`danger`},{default:N(()=>[H(k(l.value),1)]),_:1})):U(``,!0),c.value?(L(),z(xV,{key:1,tone:`ok`},{default:N(()=>[H(k(c.value),1)]),_:1})):U(``,!0)])):U(``,!0)]),_:1})],64))}}),BU={class:`min-h-full`},VU={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},HU={class:`lg:grid lg:grid-cols-[11rem_minmax(0,1fr)] lg:gap-8`},UU={"aria-label":`Settings sections`,class:`hidden lg:block`},WU={class:`sticky top-6 space-y-0.5 border-l border-line`},GU=[`aria-current`,`onClick`],KU={class:`space-y-6`},qU={id:`listener`,class:`scroll-mt-5`},JU={id:`authentication`,class:`scroll-mt-5`},YU={id:`password`,class:`scroll-mt-5`},XU={id:`defaults`,class:`scroll-mt-5`},ZU={id:`logs`,class:`scroll-mt-5`},QU={id:`notifications`,class:`scroll-mt-5`},$U={id:`host`,class:`scroll-mt-5`},eW={id:`backups`,class:`scroll-mt-5`},tW={id:`tls`,class:`scroll-mt-5`},nW={id:`interface`,class:`scroll-mt-5`},rW={id:`paths`,class:`scroll-mt-5`},iW={class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},aW={class:`mx-auto flex w-full max-w-5xl flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3 sm:px-6`},oW={class:`min-w-0 flex-1`},sW={class:`text-xs text-muted`},cW={class:`font-mono tabular-nums text-ink`},lW={key:0,class:`mt-0.5 text-xs text-danger`},uW={key:1,class:`mt-0.5 text-xs text-ok`},dW={class:`flex shrink-0 items-center gap-2`},fW={class:`max-h-[60dvh] overflow-auto px-4 py-3`},pW={key:0,class:`divide-y divide-line-soft`},mW={class:`font-mono text-xs text-ink`},hW={class:`ml-auto font-mono text-xs text-muted line-through`},gW={class:`font-mono text-xs text-accent`},_W={key:1,class:`text-xs text-muted`},vW={class:`flex items-center justify-end gap-2 border-t border-line px-4 py-3`},yW=P({__name:`SettingsView`,setup(e){let t=[{id:`listener`,title:`Listener`},{id:`authentication`,title:`Authentication`},{id:`defaults`,title:`Server defaults`},{id:`logs`,title:`Logs`},{id:`notifications`,title:`Notifications`},{id:`host`,title:`Host vitals`},{id:`backups`,title:`Backups`},{id:`tls`,title:`TLS`},{id:`interface`,title:`Interface`},{id:`paths`,title:`Paths`}],n=zg(),r=Rg(),i=wM(),a=Kj(),o=en(DV()),s=j(`listener`),c=j(!1),l=j(null),u=j(null),d=j(null),f=j(null),p=W(()=>i.control.value),m=W(()=>i.defaults.value),h=W(()=>i.logsConfig.value),g=W(()=>i.notifications.value?.telegram??null),_=W(()=>i.host.value?.alerts??[]),v=W(()=>f.value?.host??null),y=W(()=>f.value?.backups??null),b=W(()=>f.value?.ui??null),x=W(()=>i.backups.value),S=W(()=>i.appState.value?.configPath??null),C=W(()=>{let e={},t=p.value,n=m.value,r=h.value,i=g.value;if(t!==null){let n=IV(t,o);Object.keys(n).length>0&&(e.control=n)}if(n!==null){let t=LV(n,o.defaults);Object.keys(t).length>0&&(e.defaults=t)}if(r!==null){let t=RV(r,o.logs);Object.keys(t).length>0&&(e.logs=t)}if(i!==null){let t=zV(i,o.telegram);Object.keys(t).length>0&&(e.notifications=t)}let a=v.value;if(a!==null){let t=PV(a,o.host);Object.keys(t).length>0&&(e.host=t)}let s=y.value;if(s!==null){let t=FV(s,o.backups);Object.keys(t).length>0&&(e.backups=t)}return e}),w=W(()=>UV(C.value)),T=W(()=>{let e=p.value,t=g.value,n=v.value,r=y.value;return{control:e===null?{}:{...kV(e),auth:OV(e.auth)},defaults:m.value??{},logs:h.value??{},notifications:t===null?{}:{telegram:AV(t)},host:n??{},backups:r===null?{}:{enabled:r.enabled,keep:r.keep,includePaths:r.includePaths}}}),ee=W(()=>HV(C.value,T.value)),E=j(!1);function te(e){return e===void 0?`unset`:typeof e==`string`?e:JSON.stringify(e)}let ne=W(()=>p.value!==null&&WV(p.value,o)),re=W(()=>p.value!==null&&GV(p.value,o)),ie=W(()=>p.value!==null&&KV(p.value,o)),ae=W(()=>m.value!==null&&Object.keys(LV(m.value,o.defaults)).length>0),oe=W(()=>h.value!==null&&Object.keys(RV(h.value,o.logs)).length>0),se=W(()=>g.value!==null&&Object.keys(zV(g.value,o.telegram)).length>0),ce=W(()=>v.value!==null&&Object.keys(PV(v.value,o.host)).length>0),D=W(()=>y.value!==null&&Object.keys(FV(y.value,o.backups)).length>0),le=j(!1);function ue(){let e=p.value;e!==null&&(Object.assign(o.control,kV(e)),Object.assign(o.auth,OV(e.auth)));let t=h.value;t!==null&&Object.assign(o.logs,t);let n=g.value;n!==null&&Object.assign(o.telegram,AV(n));let r=v.value;r!==null&&Object.assign(o.host,MV(r));let i=y.value;i!==null&&Object.assign(o.backups,NV(i));let a=m.value;a!==null&&(o.defaults.enabled=a.enabled,o.defaults.autostart=a.autostart,o.defaults.bind=a.bind,o.defaults.onPortConflict=a.onPortConflict,o.defaults.logBufferLines=a.logBufferLines,o.defaults.restart={...a.restart},o.defaults.health=EV(a.health),o.defaults.stop={...a.stop}),le.value=!0}Ar([p,m,h,g,f],()=>{BV({hydrated:le.value,liveAvailable:p.value!==null,changedCount:w.value})&&ue()},{immediate:!0});async function de(){d.value=null;try{f.value=await dj()}catch(e){d.value=e instanceof Error?e.message:String(e)}}ta(()=>{de()});async function fe(){let e=C.value;if(!(Object.keys(e).length===0||c.value)){c.value=!0,l.value=null,u.value=null;try{let t=await i.saveSettings(e);if(!t){l.value=i.lastError.value??`The settings could not be saved.`;return}u.value=`Settings saved.`,a.success(`Settings saved`),await de();let n=await JV(t);n===null?t.rebinding&&(u.value=`Settings saved — the panel is moving to a new address.`):(u.value=null,l.value=n)}finally{c.value=!1}}}function pe(){l.value=null,u.value=null,ue()}function me(){v.value!==null&&Object.assign(o.host,MV(v.value))}function he(){y.value!==null&&Object.assign(o.backups,NV(y.value))}function ge(){if(p.value!==null){let e=kV(p.value);o.control.label=e.label,o.control.port=e.port,o.control.host=e.host,o.control.openBrowser=e.openBrowser}}function _e(){p.value!==null&&Object.assign(o.auth,OV(p.value.auth))}function ve(){let e=m.value;e!==null&&(o.defaults.enabled=e.enabled,o.defaults.autostart=e.autostart,o.defaults.bind=e.bind,o.defaults.onPortConflict=e.onPortConflict,o.defaults.logBufferLines=e.logBufferLines,o.defaults.restart={...e.restart},o.defaults.health=EV(e.health),o.defaults.stop={...e.stop})}function ye(){h.value!==null&&Object.assign(o.logs,h.value)}function be(){g.value!==null&&Object.assign(o.telegram,AV(g.value))}function xe(){p.value!==null&&(o.control.tlsEnabled=p.value.tls.enabled)}function Se(e){nr(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function Ce(e){s.value=e,n.query.section!==e&&r.replace({query:{...n.query,section:e}}),Se(e)}Ar(()=>n.query.section,e=>{let n=typeof e==`string`?e:``;t.some(e=>e.id===n)&&(s.value=n,Se(n))},{immediate:!0});let we=null;return ta(()=>{we=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];t!==void 0&&t.target.id.length>0&&(s.value=t.target.id)},{rootMargin:`-72px 0px -62% 0px`,threshold:0});for(let e of t){let t=document.getElementById(e.id);t&&we.observe(t)}}),ia(()=>we?.disconnect()),(e,n)=>{let r=fa(`PasswordSection`);return L(),R(I,null,[B(`div`,BU,[B(`div`,VU,[n[24]||=B(`header`,{class:`mb-5`},[B(`h1`,{class:`text-xl font-semibold tracking-tight text-ink`},` Settings `),B(`p`,{class:`mt-1 text-xs text-muted`},` Listener, access, defaults, retention, alerts, backups and paths for this panel. `)],-1),M(i).configError.value?(L(),z(xV,{key:0,tone:`danger`,title:`The config file could not be read`,class:`mb-4`},{default:N(()=>[H(k(M(i).configError.value),1)]),_:1})):d.value?(L(),z(xV,{key:1,tone:`warn`,title:`Some file-only values could not be loaded`,class:`mb-4`},{default:N(()=>[H(k(d.value),1)]),_:1})):U(``,!0),B(`div`,HU,[B(`nav`,UU,[B(`ul`,WU,[(L(),R(I,null,va(t,e=>B(`li`,{key:e.id},[B(`button`,{type:`button`,"aria-current":s.value===e.id?`true`:void 0,class:O(M(Q)(`-ml-px block w-full border-l-2 py-1.5 pl-3 text-left text-xs transition-colors duration-150`,s.value===e.id?`border-accent font-medium text-accent`:`border-transparent text-muted hover:border-line hover:text-ink`)),onClick:t=>Ce(e.id)},k(e.title),11,GU)])),64))])]),B(`div`,KU,[B(`section`,qU,[n[13]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Listener `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Where the control panel listens and how it announces itself. `)],-1),V(ZH,{control:o.control,"onUpdate:control":n[0]||=e=>o.control=e,view:p.value,dirty:ne.value,onReset:ge},null,8,[`control`,`view`,`dirty`])]),B(`section`,JU,[n[14]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Authentication `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Who may sign in, and how a session is trusted. `)],-1),V(ZV,{auth:o.auth,"onUpdate:auth":n[1]||=e=>o.auth=e,view:p.value,dirty:ie.value,onReset:_e},null,8,[`auth`,`view`,`dirty`])]),B(`section`,YU,[n[15]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Password `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` The one credential that guards this panel. `)],-1),V(r,{view:p.value},null,8,[`view`])]),B(`section`,XU,[n[16]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Server defaults `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Applied to every entry that does not set its own value. `)],-1),V(PH,{defaults:o.defaults,"onUpdate:defaults":n[2]||=e=>o.defaults=e,dirty:ae.value,onReset:ve},null,8,[`defaults`,`dirty`])]),B(`section`,ZU,[n[17]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Logs `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` How much output is kept on disk and for how long. `)],-1),V(nU,{logs:o.logs,"onUpdate:logs":n[3]||=e=>o.logs=e,"logs-dir":M(i).appState.value?.logsDir??null,dirty:oe.value,onReset:ye},null,8,[`logs`,`logs-dir`,`dirty`])]),B(`section`,QU,[n[18]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Notifications `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Crash and health alerts sent to a Telegram chat. `)],-1),V(uU,{telegram:o.telegram,"onUpdate:telegram":n[4]||=e=>o.telegram=e,status:g.value,dirty:se.value,onReset:be},null,8,[`telegram`,`status`,`dirty`])]),B(`section`,$U,[n[19]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Host vitals `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Alert thresholds for this machine's own resources. `)],-1),V(LH,{host:o.host,"onUpdate:host":n[5]||=e=>o.host=e,config:v.value,alerts:_.value,dirty:ce.value,onReset:me},null,8,[`host`,`config`,`alerts`,`dirty`])]),B(`section`,eW,[n[20]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Backups `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Archives of config, secrets and declared data paths. `)],-1),V(MH,{form:o.backups,"onUpdate:form":n[6]||=e=>o.backups=e,state:x.value,policy:y.value,"config-path":S.value,dirty:D.value,onReset:he},null,8,[`form`,`state`,`policy`,`config-path`,`dirty`])]),B(`section`,tW,[n[21]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` TLS `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve the panel over HTTPS with your own certificate. `)],-1),V(zU,{"tls-enabled":o.control.tlsEnabled,"onUpdate:tlsEnabled":n[7]||=e=>o.control.tlsEnabled=e,view:p.value,dirty:re.value,onReset:xe},null,8,[`tls-enabled`,`view`,`dirty`])]),B(`section`,nW,[n[22]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Interface `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve your own panel UI instead of the stock one. `)],-1),V(GH,{label:o.control.label,"onUpdate:label":n[8]||=e=>o.control.label=e,ui:b.value,"label-dirty":ne.value,onChanged:de,onResetLabel:ge},null,8,[`label`,`ui`,`label-dirty`])]),B(`section`,rW,[n[23]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Paths `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Where home-hosted keeps its files. `)],-1),V(_U,{"config-path":S.value,"data-root":M(i).appState.value?.dataRoot??null,"logs-dir":M(i).appState.value?.logsDir??null,"project-dir":M(i).appState.value?.projectDir??null,"panel-url":p.value?.url??null},null,8,[`config-path`,`data-root`,`logs-dir`,`project-dir`,`panel-url`])])])])]),B(`div`,iW,[B(`div`,aW,[B(`div`,oW,[B(`p`,sW,[w.value>0?(L(),R(`button`,{key:0,type:`button`,class:`rounded-control px-1 py-0.5 text-xs text-muted underline decoration-line underline-offset-2 hover:text-ink`,onClick:n[9]||=e=>E.value=!0},[B(`span`,cW,k(w.value),1),H(` field`+k(w.value===1?``:`s`)+` changed `,1)])):(L(),R(I,{key:1},[H(` No unsaved changes `)],64))]),l.value?(L(),R(`p`,lW,k(l.value),1)):u.value?(L(),R(`p`,uW,k(u.value),1)):U(``,!0)]),B(`div`,dW,[V($,{variant:`ghost`,disabled:w.value===0||c.value,onClick:pe},{default:N(()=>[...n[25]||=[H(` Discard changes `,-1)]]),_:1},8,[`disabled`]),V($,{variant:`primary`,disabled:w.value===0,loading:c.value,onClick:fe},{default:N(()=>[...n[26]||=[H(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])]),V(rL,{open:E.value,"onUpdate:open":n[12]||=e=>E.value=e,title:`Unsaved changes`,description:`What Save would write to servers.config.json.`,width:`w-[min(92vw,42rem)]`},{default:N(()=>[B(`div`,fW,[ee.value.length>0?(L(),R(`ul`,pW,[(L(!0),R(I,null,va(ee.value,e=>(L(),R(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[B(`code`,mW,k(e.path),1),B(`span`,hW,k(te(e.from)),1),n[27]||=B(`span`,{class:`text-2xs text-faint`},`→`,-1),B(`span`,gW,k(te(e.to)),1)]))),128))])):(L(),R(`p`,_W,` Nothing to save. `))]),B(`footer`,vW,[V($,{size:`sm`,variant:`ghost`,onClick:n[10]||=e=>E.value=!1},{default:N(()=>[...n[28]||=[H(` Close `,-1)]]),_:1}),V($,{size:`sm`,variant:`primary`,disabled:ee.value.length===0||c.value,loading:c.value,onClick:n[11]||=e=>{fe(),E.value=!1}},{default:N(()=>[H(` Save `+k(ee.value.length)+` change`+k(ee.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])])]),_:1},8,[`open`])],64)}}}),bW=Sv({history:W_(),routes:[{path:`/`,name:`overview`,component:yB,meta:{title:`Overview`}},{path:`/servers`,name:`servers`,component:_V,meta:{title:`Servers`}},{path:`/servers/:id`,name:`server-detail`,component:dV,meta:{title:`Server`}},{path:`/logs`,name:`logs`,component:ML,meta:{title:`Logs`}},{path:`/settings`,name:`settings`,component:yW,meta:{title:`Settings`}},{path:`/login`,name:`login`,component:nI,meta:{title:`Sign in`}},{path:`/:pathMatch(.*)*`,redirect:`/`}]});bW.beforeEach(async e=>{let{session:t,refresh:n}=Vj();t.value===null&&await n();let r=t.value?.authRequired===!0,i=t.value?.authenticated===!0;return r&&!i&&e.name!==`login`?{name:`login`,query:e.fullPath===`/`?void 0:{next:e.fullPath}}:e.name===`login`&&(!r||i)?{name:`overview`}:!0}),yu(jF).use(bW).mount(`#app`);
46
+ `),bootstrapEnv:l(e.bootstrap?.env??{}),bootstrapTimeoutMs:e.bootstrap?.timeoutMs??12e4,bootstrapRunOnce:e.bootstrap?.runOnce??!0}}let p=en(f(n.config)),m=j({...n.config.restart}),h=j({...n.config.health}),g=j({...n.config.stop}),_={...n.config},v=W(()=>{let e=[{value:`local`,label:`local — 127.0.0.1`},{value:`lan`,label:`lan — 0.0.0.0`}];return/^\d{1,3}(?:\.\d{1,3}){3}$/.test(n.config.bind)&&e.push({value:n.config.bind,label:`${n.config.bind} — explicit`}),e});function y(){let e=Number.isFinite(p.maxRssMb)?p.maxRssMb:0,t=Number.isFinite(p.logBufferLines)?p.logBufferLines:0,n=Number.isFinite(p.bootstrapTimeoutMs)?p.bootstrapTimeoutMs:0;return{label:p.label.trim(),command:p.command.trim(),cwd:p.cwd.trim()===``?`.`:p.cwd.trim(),args:c(p.args),env:u(p.env),dataEnvs:u(p.dataEnvs),backupPaths:c(p.backupPaths),dependsOn:p.dependsOn.split(`,`).map(e=>e.trim()).filter(e=>e.length>0),envFile:p.envFile.trim(),resources:{maxRssBytes:e>0?Math.round(e*1024*1024):0},port:p.port===null||Number.isNaN(p.port)?null:p.port,bind:p.bind,onPortConflict:p.onPortConflict,logBufferLines:t,enabled:p.enabled,autostart:p.autostart,restart:{...m.value},health:{...h.value},stop:{...g.value},bootstrap:p.bootstrapEnabled?{command:p.bootstrapCommand.trim(),args:c(p.bootstrapArgs),env:u(p.bootstrapEnv),timeoutMs:n,runOnce:p.bootstrapRunOnce}:null}}function b(e,t){let r=n.config[t]??{},i=e[t]??{},a={};for(let[e,t]of Object.entries(i))r[e]!==t&&(a[e]=t);return Object.keys(a).length>0?a:null}function x(e){for(let t of[`restart`,`health`,`stop`])b(e,t)===null&&delete e[t];return TB(n.config,e)}function S(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}let C=W(()=>{let e=y(),t=0;for(let[n,r]of Object.entries(e))i.includes(n)?t+=b(e,n)===null?0:1:S(_[n],r)||(t+=1);return t}),w=W(()=>C.value>0),T={...n.config};function ee(e){Object.assign(p,f(e)),m.value={...e.restart},h.value={...e.health},g.value={...e.stop},_={...e},T={...e},s.value=null}Ar(()=>n.config,e=>{S(e,T)||ee(e)});async function E(){s.value=null,o.value=!0;try{let e=y(),t=vA(e);if(t instanceof Y.errors){s.value=t.summary;return}let i=x(e);if(Object.keys(i).length===0){r(`saved`);return}if(await a.saveConfig(n.serverId,i),a.lastError.value!==null){s.value=a.lastError.value;return}_={...e},r(`saved`)}finally{o.value=!1}}return(e,t)=>(L(),R(`form`,{class:`border-t border-line bg-page/40 px-4 py-4`,onSubmit:lu(E,[`prevent`])},[B(`header`,jB,[t[26]||=B(`div`,{class:`min-w-0`},[B(`h2`,{class:`text-sm font-semibold text-ink`},` Edit configuration `),B(`p`,{class:`mt-0.5 text-2xs leading-4 text-muted`},[H(` Writes overrides to `),B(`span`,{class:`font-mono`},`servers.config.json`),H(`; anything left alone keeps inheriting the defaults. `)])],-1),B(`div`,MB,[C.value>0?(L(),R(`span`,NB,k(C.value)+` unsaved `+k(C.value===1?`change`:`changes`),1)):(L(),R(`span`,PB,`in sync`))])]),B(`div`,FB,[V(uR,{title:`Process`,description:`What gets spawned, where, and with which environment.`,columns:2},{default:N(()=>[V(TR,{modelValue:p.label,"onUpdate:modelValue":t[0]||=e=>p.label=e,label:`Label`,placeholder:`falls back to the id`},null,8,[`modelValue`]),V(TR,{modelValue:p.command,"onUpdate:modelValue":t[1]||=e=>p.command=e,label:`Command`,placeholder:`node`,required:``,class:`font-mono text-xs`},null,8,[`modelValue`]),V(TR,{modelValue:p.cwd,"onUpdate:modelValue":t[2]||=e=>p.cwd=e,label:`Working directory`,placeholder:`.`,hint:`Relative paths resolve under projectDir.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(TR,{modelValue:p.envFile,"onUpdate:modelValue":t[3]||=e=>p.envFile=e,label:`Env file`,placeholder:`optional KEY=value file`,hint:`Loaded at spawn; its values override env.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(bR,{modelValue:p.args,"onUpdate:modelValue":t[4]||=e=>p.args=e,label:`Arguments`,rows:3,hint:`One per line; {port} {host} {home} {projectDir} {dataRoot} {id} {label} {cwd} {bind} {lanIp} are substituted.`,placeholder:`-p
47
+ {port}`},null,8,[`modelValue`]),V(bR,{modelValue:p.env,"onUpdate:modelValue":t[5]||=e=>p.env=e,label:`Environment`,rows:3,hint:`KEY=value per line, exported to the process.`,placeholder:`NODE_ENV=production`},null,8,[`modelValue`]),V(bR,{modelValue:p.dataEnvs,"onUpdate:modelValue":t[6]||=e=>p.dataEnvs=e,label:`Data envs`,rows:3,hint:`ENV=path per line — exported to the process and backed up automatically.`,placeholder:`DATA_DIR={home}/.app`},null,8,[`modelValue`]),V(bR,{modelValue:p.backupPaths,"onUpdate:modelValue":t[7]||=e=>p.backupPaths=e,label:`Extra backup paths`,rows:2,hint:`One per line, placeholders allowed.`,placeholder:`{home}/.app/uploads`},null,8,[`modelValue`]),V(TR,{modelValue:p.dependsOn,"onUpdate:modelValue":t[8]||=e=>p.dependsOn=e,label:`Depends on`,placeholder:`postgres, redis`,hint:`Comma separated; started first, stopped last.`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(gR,{modelValue:p.maxRssMb,"onUpdate:modelValue":t[9]||=e=>p.maxRssMb=e,label:`Max RSS (MB)`,min:0,hint:`Restart above this; blank or 0 disables it.`},null,8,[`modelValue`])]),_:1}),V(uR,{title:`Port & binding`,description:`How the port is preflighted and where the process is reachable.`,columns:2},{default:N(()=>[V(gR,{modelValue:p.port,"onUpdate:modelValue":t[10]||=e=>p.port=e,label:`Port`,nullable:``,min:1,max:65535,hint:`Blank means no port: no probe, no preflight.`},null,8,[`modelValue`]),V(lL,{modelValue:p.bind,"onUpdate:modelValue":t[11]||=e=>p.bind=e,label:`Bind address`,options:v.value,hint:`A custom IPv4 the config already sets stays selectable.`},null,8,[`modelValue`,`options`]),V(lL,{modelValue:p.onPortConflict,"onUpdate:modelValue":t[12]||=e=>p.onPortConflict=e,label:`On port conflict`,options:[{value:`block`,label:`block — refuse to start`},{value:`warn`,label:`warn — start anyway`},{value:`follow`,label:`follow — adopt a detached restart of itself`},{value:`reclaim`,label:`reclaim — replace it with a supervised copy`}]},null,8,[`modelValue`]),V(gR,{modelValue:p.logBufferLines,"onUpdate:modelValue":t[13]||=e=>p.logBufferLines=e,label:`Log buffer lines`,min:50,max:1e5,step:50},null,8,[`modelValue`])]),_:1}),V(uR,{title:`Lifecycle`,description:`Whether the supervisor owns this entry at all.`,columns:2},{default:N(()=>[V(OR,{modelValue:p.enabled,"onUpdate:modelValue":t[14]||=e=>p.enabled=e,label:`Enabled`,hint:`Shows up and can be started at all.`},null,8,[`modelValue`]),V(OR,{modelValue:p.autostart,"onUpdate:modelValue":t[15]||=e=>p.autostart=e,label:`Autostart with up`,hint:`Started when the control plane comes up.`},null,8,[`modelValue`])]),_:1}),V(AB,{restart:m.value,"onUpdate:restart":t[16]||=e=>m.value=e,health:h.value,"onUpdate:health":t[17]||=e=>h.value=e,stop:g.value,"onUpdate:stop":t[18]||=e=>g.value=e},null,8,[`restart`,`health`,`stop`]),V(uR,{title:`Bootstrap`,description:`A one-off command run before the first start — installs, migrations, downloads.`,columns:2},{default:N(()=>[V(OR,{modelValue:p.bootstrapEnabled,"onUpdate:modelValue":t[19]||=e=>p.bootstrapEnabled=e,label:`Run a bootstrap`,hint:`Off means the entry has none and the key is sent as null.`,wide:``},null,8,[`modelValue`]),p.bootstrapEnabled?(L(),R(I,{key:0},[V(TR,{modelValue:p.bootstrapCommand,"onUpdate:modelValue":t[20]||=e=>p.bootstrapCommand=e,label:`Command`,placeholder:`./scripts/install.sh`,class:`font-mono text-xs`},null,8,[`modelValue`]),V(gR,{modelValue:p.bootstrapTimeoutMs,"onUpdate:modelValue":t[21]||=e=>p.bootstrapTimeoutMs=e,label:`Timeout (ms)`,min:1e3,step:1e3},null,8,[`modelValue`]),V(OR,{modelValue:p.bootstrapRunOnce,"onUpdate:modelValue":t[22]||=e=>p.bootstrapRunOnce=e,label:`Only once per session`,hint:`Off means every start re-runs it.`},null,8,[`modelValue`])],64)):U(``,!0),p.bootstrapEnabled?(L(),z(bR,{key:1,modelValue:p.bootstrapArgs,"onUpdate:modelValue":t[23]||=e=>p.bootstrapArgs=e,label:`Bootstrap arguments`,rows:2,hint:`One per line; same placeholders as the main arguments.`},null,8,[`modelValue`])):U(``,!0),p.bootstrapEnabled?(L(),z(bR,{key:2,modelValue:p.bootstrapEnv,"onUpdate:modelValue":t[24]||=e=>p.bootstrapEnv=e,label:`Bootstrap environment`,rows:2,hint:`KEY=value per line, exported to the bootstrap process only.`},null,8,[`modelValue`])):U(``,!0)]),_:1})]),s.value?(L(),R(`p`,IB,k(s.value),1)):U(``,!0),B(`div`,LB,[B(`button`,{type:`button`,class:`inline-flex h-8 select-none items-center rounded-control border border-transparent bg-transparent px-2.5 text-xs font-medium whitespace-nowrap text-muted transition-colors duration-150 hover:bg-hover hover:text-ink`,onClick:t[25]||=e=>r(`cancel`)},` Cancel `),B(`button`,{type:`submit`,disabled:o.value||!w.value,class:`inline-flex h-8 select-none items-center gap-1.5 rounded-control border border-transparent bg-accent px-2.5 text-xs font-medium whitespace-nowrap text-accent-ink transition-[filter,opacity] duration-150 hover:brightness-110 disabled:pointer-events-none disabled:opacity-45`},k(o.value?`Saving…`:`Save to servers.config.json`),9,RB)])],32))}}),BB=[`aria-label`],VB=P({__name:`CopyButton`,props:{value:{},label:{default:`Copy`},class:{default:void 0}},setup(e){let t=e,n=j(!1),r=null;async function i(){try{await navigator.clipboard.writeText(t.value),n.value=!0,r&&clearTimeout(r),r=setTimeout(()=>{n.value=!1},1400)}catch{}}return ze(()=>{r&&clearTimeout(r)}),(e,r)=>(L(),R(`button`,{type:`button`,class:O(M(Q)(`grid size-6 shrink-0 place-items-center rounded-control text-faint transition-colors duration-150 hover:bg-hover hover:text-ink`,M(fF),t.class)),"aria-label":n.value?`Copied`:t.label,onClick:i},[n.value?(L(),z(M(Pv),{key:0,class:`size-3.5 text-ok`})):(L(),z(M(Gv),{key:1,class:`size-3.5`}))],10,BB))}}),HB={key:0,class:`mx-auto max-w-3xl p-4 sm:p-5`},UB={key:1,class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},WB={class:`font-mono text-xs text-faint`},GB=[`href`],KB={class:`px-2 py-1.5`},qB={class:`flex flex-col gap-0.5`},JB=[`onClick`],YB={class:`space-y-2`},XB={key:0,class:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-control border border-danger/25 bg-danger-soft px-3 py-2`},ZB={class:`min-w-0 flex-1 text-2xs leading-4 text-danger`},QB={key:1,class:`rounded-control border border-warn/25 bg-warn-soft px-3 py-2 text-2xs leading-4 text-warn`},$B={class:`grid grid-cols-2 gap-x-4 gap-y-3 p-4 sm:grid-cols-4 lg:grid-cols-6`},eV={class:`truncate text-2xs text-faint`},tV={class:`truncate font-mono text-xs tabular-nums text-ink capitalize`},nV={class:`grid gap-4 sm:grid-cols-3`},rV={class:`flex items-center justify-between gap-3`},iV=[`title`],aV={key:1,class:`space-y-4`},oV={key:0,class:`max-h-96 overflow-auto rounded-control border border-line bg-page/60 p-3 font-mono text-2xs leading-5 text-muted`},sV={key:1,class:`grid grid-cols-1 gap-x-6 gap-y-2 sm:grid-cols-2`},cV={class:`text-2xs text-faint`},lV=[`title`],uV={key:2,class:`grid gap-4 lg:grid-cols-3`},dV={key:0,class:`flex flex-wrap gap-1.5`},fV={key:1,class:`text-xs text-muted`},pV=P({__name:`ServerDetailView`,setup(e){let t=zg(),{serverById:n,now:r,seriesOf:i,start:a,stop:o,restart:s,setEnabled:c,setAutostart:l,setBind:u,clearLogs:d,freePort:f,remove:p}=wM(),m=W(()=>String(t.params.id??``)),h=W(()=>n(m.value)),g=W(()=>h.value?.config),_=W(()=>{let e=g.value;return e?.label&&e.label.length>0?e.label:m.value}),v=j(`output`),y=j(!1),b=j(!1),x=j(!1),S=j(!1),C=CM(()=>h.value?m.value:null),w=C.version,T=W(()=>(w.value,C.lines())),ee=W(()=>i(m.value)),E=W(()=>ee.value.cpu),te=W(()=>ee.value.rss),ne=W(()=>ee.value.probe),re=W(()=>{let e=h.value;return!e||e.startedAt===null||e.status!==`running`?`—`:_I(r.value-e.startedAt)}),ie=W(()=>h.value?.status===`running`),ae=W(()=>{let e=h.value;if(!e)return[];let t=[{key:`pid`,label:`PID`,value:e.pid===null?`—`:String(e.pid)},{key:`uptime`,label:`Uptime`,value:re.value},{key:`status`,label:`Status`,value:e.status},{key:`health`,label:`Health`,value:e.health},{key:`port`,label:`Port state`,value:e.portState},{key:`probe`,label:`Last probe`,value:e.responseMs===null?`—`:`${e.responseMs} ms`},{key:`rss`,label:`RSS`,value:SI(e.resources?.rssBytes??null)},{key:`procs`,label:`Processes`,value:e.resources?String(e.resources.processes):`—`},{key:`restarts`,label:`Restarts`,value:`${e.restarts}/${e.maxRetries}`},{key:`up24`,label:`24h uptime`,value:yI(e.history.uptimeRatio)},{key:`crashes`,label:`24h crashes`,value:String(e.history.crashes)},{key:`lastcrash`,label:`Last crash`,value:bI(e.history.lastCrashAt,r.value)}];return e.nextRetryAt!==null&&t.push({key:`retry`,label:`Next attempt`,value:vI(e.nextRetryAt,r.value)}),e.unhealthySince!==null&&t.push({key:`unhealthy`,label:`Unhealthy for`,value:_I(r.value-e.unhealthySince)}),t}),oe=W(()=>JSON.stringify(g.value??{},null,2)),se=W(()=>g.value?`${g.value.command} ${g.value.args.join(` `)}`.trim():``),ce=W(()=>{let e=g.value?.bind??`local`,t=[{value:`local`,label:`127.0.0.1 — this machine only`},{value:`lan`,label:`0.0.0.0 — every interface`}];return e!==`local`&&e!==`lan`&&t.push({value:e,label:`${e} — custom`}),t});async function D(e){S.value=!0;try{await{start:a,stop:o,restart:s}[e](m.value)}finally{S.value=!1}}async function le(){x.value=!1,await p(m.value)}async function ue(){let e=h.value;if(e){S.value=!0;try{await f(e.id)}finally{S.value=!1}}}let de=W(()=>gj(m.value,`${m.value}.log`)),fe=[{value:`output`,label:`Live output`},{value:`config`,label:`Configuration`},{value:`history`,label:`History`}];return(e,t)=>{let n=fa(`RouterLink`);return h.value?(L(),R(`div`,UB,[V(Lz,{title:_.value,"back-to":`/servers`,"back-label":`All servers`},{badges:N(()=>[V(rz,{status:h.value.status,health:h.value.health},null,8,[`status`,`health`]),h.value.adopted?(L(),z(vF,{key:0,label:`This process replaced itself: the panel adopted the successor instead of starting a second copy. Stop still works, its output stays where the successor sent it.`},{default:N(()=>[...t[16]||=[B(`span`,{class:`rounded-full border border-line px-2 py-0.5 text-2xs text-muted`},`detached`,-1)]]),_:1})):U(``,!0),B(`span`,WB,k(h.value.id),1),h.value.url?(L(),R(`a`,{key:1,href:h.value.url,target:`_blank`,rel:`noreferrer`,class:`inline-flex items-center gap-1 font-mono text-xs text-accent hover:underline`},[H(k(h.value.url)+` `,1),V(M(Yv),{class:`size-3`})],8,GB)):U(``,!0)]),actions:N(()=>[V($,{variant:`primary`,disabled:S.value||!g.value?.enabled||[`running`,`starting`].includes(h.value.status),onClick:t[0]||=e=>D(`start`)},{default:N(()=>[V(M(fy),{class:`size-3.5`}),t[17]||=H(`Start `,-1)]),_:1},8,[`disabled`]),V($,{disabled:S.value||h.value.status===`stopped`,onClick:t[1]||=e=>D(`stop`)},{default:N(()=>[V(M(Ty),{class:`size-3.5`}),t[18]||=H(`Stop `,-1)]),_:1},8,[`disabled`]),V($,{disabled:S.value||!g.value?.enabled,onClick:t[2]||=e=>D(`restart`)},{default:N(()=>[V(M(_y),{class:`size-3.5`}),t[19]||=H(`Restart `,-1)]),_:1},8,[`disabled`]),V(vF,{label:`Edit every field of this entry`},{default:N(()=>[V($,{variant:y.value?`secondary`:`ghost`,onClick:t[3]||=e=>{y.value=!y.value,v.value=`config`}},{default:N(()=>[V(M(dy),{class:`size-3.5`}),H(k(y.value?`Close editor`:`Edit`),1)]),_:1},8,[`variant`])]),_:1}),V(M(eg),null,{default:N(()=>[V(M(ag),{"as-child":``},{default:N(()=>[V($,{variant:`ghost`,size:`icon-sm`,"aria-label":`More actions for ${_.value}`},{default:N(()=>[V(M(Jv),{class:`size-4`})]),_:1},8,[`aria-label`])]),_:1}),V(M(rg),null,{default:N(()=>[V(M(tg),{"side-offset":4,align:`end`,class:`z-50 min-w-56 rounded-panel border border-line bg-raise p-1 shadow-float data-[state=open]:animate-[hh-fade-in_120ms_ease-out]`},{default:N(()=>[V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:t[4]||=e=>M(c)(h.value.id,!h.value.config.enabled)},{default:N(()=>[H(k(g.value?.enabled?`Disable server`:`Enable server`),1)]),_:1}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-muted outline-none data-[highlighted]:bg-hover data-[highlighted]:text-ink`,onSelect:t[5]||=e=>M(l)(h.value.id,!h.value.config.autostart)},{default:N(()=>[H(k(g.value?.autostart?`Remove from autostart`:`Autostart with the panel`),1)]),_:1}),V(M(ig),{class:`my-1 h-px bg-line`}),B(`div`,KB,[t[20]||=B(`p`,{class:`mb-1 text-2xs text-faint`},` Bind `,-1),B(`div`,qB,[(L(!0),R(I,null,va(ce.value,e=>(L(),R(`button`,{key:e.value,type:`button`,class:O([`rounded-control px-2 py-1 text-left font-mono text-2xs transition-colors duration-150 hover:bg-hover`,e.value===g.value?.bind?`text-accent`:`text-muted`]),onClick:t=>M(u)(h.value.id,e.value)},k(e.label),11,JB))),128))])]),V(M(ig),{class:`my-1 h-px bg-line`}),V(M(ng),{class:`flex cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-xs text-danger outline-none data-[highlighted]:bg-danger-soft`,onSelect:t[6]||=e=>x.value=!0},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),t[21]||=H(` Remove server `,-1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,[`title`]),B(`div`,YB,[h.value.lastError?(L(),R(`div`,XB,[B(`p`,ZB,k(h.value.lastError),1),h.value.status===`conflict`&&h.value.config.port!==null?(L(),z(IR,{key:0,port:h.value.config.port,busy:S.value,onConfirm:ue},null,8,[`port`,`busy`])):U(``,!0)])):U(``,!0),h.value.health===`unhealthy`?(L(),R(`p`,QB,[t[22]||=H(` The health probe has not passed `,-1),h.value.unhealthySince===null?U(``,!0):(L(),R(I,{key:0},[H(` for `+k(M(_I)(M(r)-h.value.unhealthySince)),1)],64)),t[23]||=H(`. `,-1)])):U(``,!0)]),V(Vz,{class:`p-0`},{default:N(()=>[B(`dl`,$B,[(L(!0),R(I,null,va(ae.value,e=>(L(),R(`div`,{key:e.key,class:`min-w-0`},[B(`dt`,eV,k(e.label),1),B(`dd`,tV,k(e.value),1)]))),128))])]),_:1}),V(Vz,null,{header:N(()=>[...t[24]||=[B(`h2`,{class:`text-sm font-semibold text-ink`},` Telemetry `,-1),B(`p`,{class:`text-2xs text-muted`},` Sampled every 5 s while this page is open. `,-1)]]),default:N(()=>[B(`div`,nV,[V($R,{label:`CPU`,values:E.value,format:M(CI),max:100,"color-class":`text-cpu`,height:40},null,8,[`values`,`format`]),V($R,{label:`Memory (RSS)`,values:te.value,format:M(SI),"color-class":`text-mem`,height:40},null,8,[`values`,`format`]),V($R,{label:`Health probe`,values:ne.value,format:e=>e===null?`—`:`${e} ms`,"color-class":`text-probe`,height:40},null,8,[`values`,`format`])])]),_:1}),B(`div`,rV,[V(AI,{modelValue:v.value,"onUpdate:modelValue":t[7]||=e=>v.value=e,options:fe,size:`md`},null,8,[`modelValue`]),B(`p`,{class:`hidden font-mono text-2xs text-faint sm:block`,title:se.value},k(se.value),9,iV)]),v.value===`output`?(L(),z(KI,{key:0,lines:T.value,version:M(w),live:``,clearable:``,"download-url":h.value.config.logBufferLines>0?de.value:void 0,"download-name":`${h.value.id}.log`,"empty-hint":ie.value?`Waiting for the first line…`:`This server has not written anything yet.`,"min-height":`22rem`,onClear:t[8]||=e=>M(d)(h.value.id)},null,8,[`lines`,`version`,`download-url`,`download-name`,`empty-hint`])):v.value===`config`?(L(),R(`div`,aV,[y.value?(L(),z(zB,{key:0,"server-id":h.value.id,config:h.value.config,onSaved:t[9]||=e=>y.value=!1,onCancel:t[10]||=e=>y.value=!1},null,8,[`server-id`,`config`])):(L(),z(Vz,{key:1},{header:N(()=>[...t[25]||=[B(`h2`,{class:`text-sm font-semibold text-ink`},` Effective configuration `,-1),B(`p`,{class:`text-2xs text-muted`},` Defaults from Settings are already merged into these values. `,-1)]]),actions:N(()=>[V($,{size:`xs`,variant:`ghost`,onClick:t[11]||=e=>b.value=!b.value},{default:N(()=>[V(M(Uv),{class:`size-3`}),H(k(b.value?`Fields`:`Raw JSON`),1)]),_:1}),V(VB,{value:oe.value,label:`Copy the JSON config`},null,8,[`value`]),V($,{size:`xs`,variant:`primary`,onClick:t[12]||=e=>y.value=!0},{default:N(()=>[V(M(dy),{class:`size-3`}),t[26]||=H(`Edit `,-1)]),_:1})]),default:N(()=>[b.value?(L(),R(`pre`,oV,k(oe.value),1)):(L(),R(`dl`,sV,[(L(!0),R(I,null,va([{label:`command`,value:g.value?.command},{label:`args`,value:g.value?.args.join(` `)||`—`},{label:`cwd`,value:g.value?.cwd},{label:`env`,value:Object.keys(g.value?.env??{}).join(`, `)||`—`},{label:`data envs`,value:Object.entries(g.value?.dataEnvs??{}).map(([e,t])=>`${e}=${t}`).join(`, `)||`—`},{label:`env file`,value:g.value?.envFile||`—`},{label:`port · bind`,value:`${g.value?.port??`none`} · ${g.value?.bind}`},{label:`on port conflict`,value:g.value?.onPortConflict},{label:`log buffer`,value:`${g.value?.logBufferLines} lines`},{label:`rtss limit`,value:g.value?.resources.maxRssBytes?M(SI)(g.value.resources.maxRssBytes):`none`},{label:`health`,value:g.value?.health.enabled?`${g.value.health.mode} every ${g.value.health.intervalMs} ms`:`off`},{label:`restart`,value:g.value?.restart.enabled?`${g.value.restart.maxRetries} retries, ×${g.value.restart.factor}`:`off`},{label:`stop`,value:g.value?`${g.value.stop.signal} after ${g.value.stop.graceMs} ms`:`—`},{label:`bootstrap`,value:g.value?.bootstrap?`${g.value.bootstrap.command} ${g.value.bootstrap.args.join(` `)}`:`none`},{label:`backup paths`,value:g.value?.backupPaths.join(`, `)||`—`},{label:`depends on`,value:g.value?.dependsOn.join(`, `)||`—`}],e=>(L(),R(`div`,{key:e.label,class:`min-w-0 border-b border-line-soft pb-1.5 last:border-0`},[B(`dt`,cV,k(e.label),1),B(`dd`,{class:`truncate font-mono text-xs text-ink`,title:String(e.value)},k(e.value),9,lV)]))),128))]))]),_:1}))])):(L(),R(`div`,uV,[V(Vz,{class:`lg:col-span-2`},{header:N(()=>[...t[27]||=[B(`h2`,{class:`text-sm font-semibold text-ink`},` Event history `,-1),B(`p`,{class:`text-2xs text-muted`},` Kept by the panel for 24 hours. `,-1)]]),default:N(()=>[V(iR,{servers:[h.value],now:M(r),limit:30},null,8,[`servers`,`now`])]),_:1}),V(Vz,null,{header:N(()=>[...t[28]||=[B(`h2`,{class:`text-sm font-semibold text-ink`},` Dependencies `,-1)]]),default:N(()=>[g.value&&g.value.dependsOn.length>0?(L(),R(`div`,dV,[(L(!0),R(I,null,va(g.value.dependsOn,e=>(L(),z(n,{key:e,to:`/servers/${e}`,class:`rounded-full border border-line px-2 py-0.5 font-mono text-2xs text-muted transition-colors duration-150 hover:border-accent/40 hover:text-accent`},{default:N(()=>[H(k(e),1)]),_:2},1032,[`to`]))),128))])):(L(),R(`p`,fV,[...t[29]||=[H(` Starts on its own. Add ids under `,-1),B(`code`,null,`dependsOn`,-1),H(` to order it after other servers. `,-1)]]))]),_:1})])),V(rL,{open:x.value,"onUpdate:open":t[14]||=e=>x.value=e,title:`Remove this server?`,description:`${_.value} is removed from servers.config.json. Its process is stopped and its persisted logs stay on disk.`,width:`w-[min(92vw,26rem)]`},{footer:N(()=>[V($,{variant:`ghost`,onClick:t[13]||=e=>x.value=!1},{default:N(()=>[...t[30]||=[H(` Keep it `,-1)]]),_:1}),V($,{variant:`danger`,onClick:le},{default:N(()=>[V(M(Ay),{class:`size-3.5`}),t[31]||=H(`Remove `,-1)]),_:1})]),default:N(()=>[t[32]||=B(`p`,{class:`text-xs text-muted`},` This cannot be undone from the panel — the entry has to be added back by hand or from a backup. `,-1)]),_:1},8,[`open`,`description`])])):(L(),R(`div`,HB,[V(QI,{title:`That server is gone`,description:`${m.value} is not in servers.config.json any more. It may have been removed from another tab.`},{action:N(()=>[V(n,{to:`/servers`},{default:N(()=>[V($,{variant:`primary`},{default:N(()=>[...t[15]||=[H(` Back to servers `,-1)]]),_:1})]),_:1})]),_:1},8,[`description`])]))}}}),mV={class:`mx-auto max-w-7xl space-y-5 p-4 sm:p-5`},hV={class:`flex flex-wrap items-center gap-2`},gV={class:`relative ml-auto w-full sm:w-64`},_V={key:0,class:`grid gap-4 lg:grid-cols-2`},vV={key:3,class:`grid gap-4 lg:grid-cols-2`},yV=P({__name:`ServersView`,setup(e){let{servers:t,appState:n,now:r,seriesOf:i,startAll:a,stopAll:o}=wM(),s=j(!1),c=j(``),l=j(`all`),u=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`stopped`,label:`Stopped`},{value:`attention`,label:`Attention`},{value:`disabled`,label:`Disabled`}],d=W(()=>n.value===null),f=W(()=>{let e=c.value.trim().toLowerCase();return t.value.filter(t=>l.value===`running`&&t.status!==`running`||l.value===`stopped`&&![`stopped`,`stopping`].includes(t.status)||l.value===`disabled`&&t.config.enabled||l.value===`attention`&&t.status!==`crashed`&&t.status!==`conflict`&&t.health!==`unhealthy`?!1:e.length===0||`${t.id} ${t.config.label??``} ${t.config.command} ${t.config.port??``}`.toLowerCase().includes(e))}),p=W(()=>({all:t.value.length,running:t.value.filter(e=>e.status===`running`).length,attention:t.value.filter(e=>e.status===`crashed`||e.status===`conflict`||e.health===`unhealthy`).length}));return(e,n)=>(L(),R(`div`,mV,[V(Lz,{title:`Servers`,description:`Every entry in servers.config.json, with live resources, health and history.`},{actions:N(()=>[V($,{variant:`ghost`,onClick:n[0]||=e=>M(a)()},{default:N(()=>[V(M(fy),{class:`size-3.5`}),n[9]||=H(`Start all `,-1)]),_:1}),V($,{variant:`ghost`,onClick:n[1]||=e=>M(o)()},{default:N(()=>[V(M(Ty),{class:`size-3.5`}),n[10]||=H(`Stop all `,-1)]),_:1}),V($,{variant:`primary`,onClick:n[2]||=e=>s.value=!0},{default:N(()=>[V(M(py),{class:`size-3.5`}),n[11]||=H(`Add server `,-1)]),_:1})]),_:1}),B(`div`,hV,[V(AI,{modelValue:l.value,"onUpdate:modelValue":n[3]||=e=>l.value=e,options:u.map(e=>({...e,label:`${e.label}${e.value===`all`?` ${p.value.all}`:e.value===`running`?` ${p.value.running}`:e.value===`attention`&&p.value.attention>0?` ${p.value.attention}`:``}`}))},null,8,[`modelValue`,`options`]),B(`div`,gV,[V(M(yy),{class:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-faint`}),br(B(`input`,{"onUpdate:modelValue":n[4]||=e=>c.value=e,type:`search`,placeholder:`Filter by id, label, command or port`,class:O([`pl-8`,[M(hF)]]),"aria-label":`Filter servers`},null,2),[[Jl,c.value]]),c.value.length>0?(L(),R(`button`,{key:0,type:`button`,class:`absolute right-1.5 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded-control text-faint hover:text-ink`,"aria-label":`Clear the filter`,onClick:n[5]||=e=>c.value=``},[V(M(My),{class:`size-3.5`})])):U(``,!0)])]),d.value?(L(),R(`div`,_V,[(L(),R(I,null,va(4,e=>V(uL,{key:e,class:`h-72 w-full`,rounded:`rounded-panel`})),64))])):M(t).length===0?(L(),z(QI,{key:1,title:`No servers configured`,description:`Add the first process this panel should supervise. Its command, args, env and working directory all live in the config file.`},{icon:N(()=>[V(M(by),{class:`size-4`})]),action:N(()=>[V($,{variant:`primary`,onClick:n[6]||=e=>s.value=!0},{default:N(()=>[V(M(py),{class:`size-3.5`}),n[12]||=H(`Add a server `,-1)]),_:1})]),_:1})):f.value.length===0?(L(),z(QI,{key:2,compact:``,title:`Nothing matches that filter`,description:`Try a different status or clear the search.`},{action:N(()=>[V($,{onClick:n[7]||=e=>{c.value=``,l.value=`all`}},{default:N(()=>[...n[13]||=[H(` Clear filters `,-1)]]),_:1})]),_:1})):(L(),R(`div`,vV,[(L(!0),R(I,null,va(f.value,e=>(L(),z(Az,{key:e.id,server:e,series:M(i)(e.id),now:M(r)},null,8,[`server`,`series`,`now`]))),128))])),V(NR,{open:s.value,"onUpdate:open":n[8]||=e=>s.value=e},null,8,[`open`])]))}}),bV=P({__name:`ConfirmButton`,props:{label:{},confirmLabel:{default:`Confirm`},variant:{default:`danger-ghost`},confirmVariant:{default:`danger`},size:{default:`sm`},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:[`confirm`],setup(e,{emit:t}){let n=e,r=t,i=j(!1),a=null;function o(){a&&clearTimeout(a),a=null,i.value=!1}function s(){if(!i.value){i.value=!0,a=setTimeout(o,5e3);return}o(),r(`confirm`)}return ze(o),(e,t)=>(L(),z($,{variant:i.value?n.confirmVariant:n.variant,size:n.size,disabled:n.disabled,loading:n.loading,onClick:s},{default:N(()=>[H(k(i.value?n.confirmLabel:n.label),1)]),_:1},8,[`variant`,`size`,`disabled`,`loading`]))}}),xV={class:`min-w-0 flex-1`},SV={key:0,class:`text-xs font-semibold`},CV=P({__name:`Notice`,props:{tone:{default:`info`},title:{default:void 0},class:{default:void 0}},setup(e){let t=e,n={ok:Bv,warn:jy,danger:ly,info:ey,neutral:ey,accent:xy},r=W(()=>n[t.tone]);return(e,n)=>(L(),R(`div`,{class:O(M(Q)(`flex items-start gap-2 rounded-panel border px-3 py-2`,M(dP)[t.tone],t.class))},[(L(),z(ma(r.value),{class:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`})),B(`div`,xV,[t.title?(L(),R(`p`,SV,k(t.title),1)):U(``,!0),B(`div`,{class:O(M(Q)(`text-xs leading-relaxed text-ink/85`,t.title&&`mt-0.5`))},[F(e.$slots,`default`)],2)])],2))}});async function wV(e,t=8e3){let n=Date.now()+t;for(;;){try{if((await fetch(`${e}/api/auth/session`,{cache:`no-store`})).ok)return!0}catch{}if(Date.now()>n)return!1;await new Promise(e=>setTimeout(e,250))}}var TV={enabled:!0,maxRetries:3,baseDelayMs:1e3,factor:2,maxDelayMs:3e4,resetAfterMs:6e4},EV={enabled:!0,mode:`port`,http:{path:`/`,method:`GET`,expectStatusBelow:400,expectBody:``},intervalMs:5e3,timeoutMs:1500,unhealthyThreshold:3,forceRestartAfterMs:0,startTimeoutMs:2e4},DV={signal:`SIGTERM`,killGroup:!0,graceMs:5e3,killPortHolders:!1};function OV(e){return{...e,http:{...e.http}}}function kV(){return{control:{label:`home-hosted`,port:3999,host:`local`,openBrowser:!1,tlsEnabled:!1},auth:{enabled:!1,sessionTtlMs:6048e5,cookieSecure:`auto`,trustProxy:!1,maxLoginAttempts:5,lockoutMs:6e4},defaults:{enabled:!0,autostart:!1,bind:`local`,onPortConflict:`block`,logBufferLines:500,restart:{...TV},health:OV(EV),stop:{...DV}},logs:{persist:!0,maxBytes:2e6,keep:3},host:{enabled:!0,intervalMs:15e3,diskPaths:`.`,diskUsedPercent:90,memoryUsedPercent:90,swapUsedPercent:50,loadPerCpu:2,tempCelsius:85},backups:{enabled:!0,keep:5,includePaths:``},telegram:{enabled:!1,chatId:``,cooldownMs:12e4,onCrash:!0,onUnhealthy:!0,onForcedRestart:!0,onRecovered:!1,onHost:!0}}}function AV(e){return{enabled:e.enabled,sessionTtlMs:e.sessionTtlMs,cookieSecure:e.cookieSecure,trustProxy:e.trustProxy,maxLoginAttempts:e.maxLoginAttempts,lockoutMs:e.lockoutMs}}function jV(e){return{label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,tlsEnabled:e.tls.enabled}}function MV(e){return{enabled:e.enabled,chatId:e.chatId,cooldownMs:e.cooldownMs,onCrash:e.onCrash,onUnhealthy:e.onUnhealthy,onForcedRestart:e.onForcedRestart,onRecovered:e.onRecovered,onHost:e.onHost}}function NV(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function PV(e){return{enabled:e.enabled,intervalMs:e.intervalMs,diskPaths:e.diskPaths.join(`, `),diskUsedPercent:e.diskUsedPercent,memoryUsedPercent:e.memoryUsedPercent,swapUsedPercent:e.swapUsedPercent,loadPerCpu:e.loadPerCpu,tempCelsius:e.tempCelsius}}function FV(e){return{enabled:e.enabled,keep:e.keep,includePaths:e.includePaths.join(`, `)}}function IV(e,t){return wB(e,{...t,diskPaths:NV(t.diskPaths)})}function LV(e,t){return wB(e,{...t,includePaths:NV(t.includePaths)})}function RV(e,t){return wB({label:e.label,port:e.port,host:e.host,openBrowser:e.openBrowser,auth:AV(e.auth),tls:{enabled:e.tls.enabled}},{label:t.control.label,port:t.control.port,host:t.control.host,openBrowser:t.control.openBrowser,auth:{...t.auth},tls:{enabled:t.control.tlsEnabled}},[`auth`,`tls`])}function zV(e,t){let n=wB(e,t,[`restart`,`health`,`stop`]),r=n.health;return r!==void 0&&`http`in r&&JSON.stringify(e.health.http)===JSON.stringify(t.health.http)&&(delete r.http,Object.keys(r).length===0&&delete n.health),n}function BV(e,t){return wB(e,t)}function VV(e,t){return wB({telegram:MV(e)},{telegram:{...t}},[`telegram`])}function HV(e){return e.liveAvailable?!e.hydrated||e.changedCount===0:!1}function UV(e,t=``){return typeof e!=`object`||!e||Array.isArray(e)?[{path:t,value:e}]:Object.entries(e).flatMap(([e,n])=>UV(n,t.length===0?e:`${t}.${e}`))}function WV(e,t){let n=new Map(UV(t).map(e=>[e.path,e.value]));return UV(e).map(e=>({path:e.path,from:n.get(e.path),to:e.value}))}function GV(e){let t=0;for(let n of Object.values(e))t+=typeof n==`object`&&n&&!Array.isArray(n)?GV(n):1;return t}function KV(e,t){return e.label!==t.control.label||e.port!==t.control.port||e.host!==t.control.host||e.openBrowser!==t.control.openBrowser}function qV(e,t){return e.tls.enabled!==t.control.tlsEnabled}function JV(e,t){return GV(wB({...AV(e.auth)},{...t.auth}))>0}function YV(e,t,n){return W({get:e,set:e=>{t(e===null||Number.isNaN(e)?n:e)}})}async function XV(e){if(!e.rebinding)return null;let t=e.targetUrl??e.control.url;return t.length===0||t===window.location.origin?null:await wV(t)?(window.location.replace(t),null):`The control panel did not answer on ${t}. Check the console for the new listener.`}var ZV={class:`space-y-2`},QV={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},$V=P({__name:`AuthenticationSection`,props:za({view:{},dirty:{type:Boolean}},{auth:{required:!0},authModifiers:{}}),emits:za([`reset`],[`update:auth`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`auth`),a=YV(()=>i.value.sessionTtlMs,e=>i.value.sessionTtlMs=e,6048e5),o=YV(()=>i.value.maxLoginAttempts,e=>i.value.maxLoginAttempts=e,5),s=YV(()=>i.value.lockoutMs,e=>i.value.lockoutMs=e,6e4),c=W(()=>n.view?.auth.passwordSet===!0),l=W(()=>n.view?.auth.apiTokenSet===!0),u=W(()=>n.view?.auth.blockedReason??null),d=W(()=>n.view?.auth.exposed===!0),f=W(()=>n.view?.auth.usingDefaultPassword===!0),p=W(()=>i.value.enabled&&!c.value),{setPassword:m,clearPassword:h}=Vj(),g=j(``),_=j(``),v=j(``),y=j(null),b=j(null),x=j(!1),S=W(()=>v.value.length>0&&v.value!==_.value),C=W(()=>_.value.length>0&&_.value.length<8),w=W(()=>_.value.length>0&&!S.value&&(!c.value||g.value.length>0));async function T(){if(w.value&&!x.value){x.value=!0,b.value=null,y.value=null;try{let e=await m(c.value?g.value:void 0,_.value);if(e!==null){b.value=e;return}g.value=``,_.value=``,v.value=``,y.value=`Password updated. Other sessions were signed out.`}finally{x.value=!1}}}async function ee(){b.value=null,y.value=null;let e=await h();e===null?y.value=`Password cleared and authentication disabled.`:b.value=e}return(e,t)=>(L(),R(I,null,[V(uR,{title:`Access policy`,description:`Authentication applies whether the panel is on loopback or exposed to the network.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[10]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(OR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Require a password`,hint:`Every request needs a signed-in session.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(gR,{modelValue:M(a),"onUpdate:modelValue":t[2]||=e=>A(a)?a.value=e:null,label:`Session lifetime (ms)`,min:6e4,hint:`604800000 is one week.`},null,8,[`modelValue`]),V(lL,{modelValue:i.value.cookieSecure,"onUpdate:modelValue":t[3]||=e=>i.value.cookieSecure=e,label:`Cookie Secure`,options:[{value:`auto`,label:`Auto — only over HTTPS`},{value:`always`,label:`Always`},{value:`never`,label:`Never — plain HTTP`}]},null,8,[`modelValue`]),V(OR,{modelValue:i.value.trustProxy,"onUpdate:modelValue":t[4]||=e=>i.value.trustProxy=e,label:`Behind a trusted reverse proxy`,hint:`Trust x-forwarded-* headers for the client address and protocol.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(gR,{modelValue:M(o),"onUpdate:modelValue":t[5]||=e=>A(o)?o.value=e:null,label:`Max login attempts`,min:1,hint:`Failures before a temporary lockout.`},null,8,[`modelValue`]),V(gR,{modelValue:M(s),"onUpdate:modelValue":t[6]||=e=>A(s)?s.value=e:null,label:`Lockout (ms)`,min:1e3},null,8,[`modelValue`])]),_:1}),B(`div`,ZV,[V(CV,{tone:l.value?`info`:`neutral`,title:l.value?`An API token is set`:`No API token`},{default:N(()=>[l.value?(L(),R(I,{key:0},[t[11]||=H(` Scripts can call the API with `,-1),t[12]||=B(`code`,null,`Authorization: Bearer …`,-1),t[13]||=H(` instead of signing in. `,-1)],64)):(L(),R(I,{key:1},[t[14]||=H(` For shell scripts and agents, generate one with `,-1),t[15]||=B(`code`,null,`home-hosted set-token --generate`,-1),t[16]||=H(`. `,-1)],64))]),_:1},8,[`tone`,`title`]),f.value?(L(),z(CV,{key:0,tone:`warn`,title:`The default password is still in use`},{default:N(()=>[...t[17]||=[H(` Set your own password below. Binding beyond `,-1),B(`code`,null,`127.0.0.1`,-1),H(` stays refused until you do. `,-1)]]),_:1})):U(``,!0),u.value?(L(),z(CV,{key:1,tone:`danger`,title:`This listener is being refused`},{default:N(()=>[H(k(u.value),1)]),_:1})):p.value?(L(),z(CV,{key:2,tone:`warn`,title:`Authentication is on but no password is set`},{default:N(()=>[...t[18]||=[H(` Nothing is actually required yet, and binding beyond `,-1),B(`code`,null,`127.0.0.1`,-1),H(` stays refused until a password exists. `,-1)]]),_:1})):d.value?(L(),z(CV,{key:3,tone:`warn`,title:`Reachable beyond 127.0.0.1`},{default:N(()=>[...t[19]||=[H(` Keep the password strong, or put a TLS-terminating proxy in front of the panel. `,-1)]]),_:1})):U(``,!0)]),B(`form`,{class:`mt-3`,onSubmit:lu(T,[`prevent`])},[V(uR,{title:c.value?`Change password`:`Set a password`,description:`Stored as a scrypt hash in the secrets file, never in the config.`},{default:N(()=>[c.value?(L(),z(TR,{key:0,modelValue:g.value,"onUpdate:modelValue":t[7]||=e=>g.value=e,type:`password`,autocomplete:`current-password`,label:`Current password`},null,8,[`modelValue`])):U(``,!0),V(TR,{modelValue:_.value,"onUpdate:modelValue":t[8]||=e=>_.value=e,type:`password`,autocomplete:`new-password`,label:`New password`},null,8,[`modelValue`]),V(TR,{modelValue:v.value,"onUpdate:modelValue":t[9]||=e=>v.value=e,type:`password`,autocomplete:`new-password`,label:`Repeat new password`,error:S.value?`The two passwords do not match.`:null},null,8,[`modelValue`,`error`]),B(`div`,QV,[V($,{type:`submit`,variant:`primary`,disabled:!w.value,loading:x.value},{default:N(()=>[H(k(c.value?`Update password`:`Set password and enable auth`),1)]),_:1},8,[`disabled`,`loading`]),c.value?(L(),z(bV,{key:0,label:`Clear password`,"confirm-label":`Confirm clear`,"confirm-variant":`danger`,disabled:x.value,onConfirm:ee},null,8,[`disabled`])):U(``,!0)]),C.value||b.value||y.value?(L(),R(I,{key:1},[C.value?(L(),z(CV,{key:0,tone:`warn`,title:`That is a short password`,class:`sm:col-span-2`},{default:N(()=>[...t[20]||=[H(` It is allowed, but longer is the only thing standing between the network and this panel. `,-1)]]),_:1})):U(``,!0),b.value?(L(),z(CV,{key:1,tone:`danger`,class:`sm:col-span-2`},{default:N(()=>[H(k(b.value),1)]),_:1})):U(``,!0),y.value?(L(),z(CV,{key:2,tone:`ok`,class:`sm:col-span-2`},{default:N(()=>[H(k(y.value),1)]),_:1})):U(``,!0)],64)):U(``,!0)]),_:1},8,[`title`])],32)],64))}}),eH={class:`space-y-3`},tH={key:0,class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},nH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},rH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},iH={class:`text-2xs leading-4 text-faint`},aH={key:0,class:`space-y-2 sm:col-span-2`},oH={key:1,class:`text-xs text-muted sm:col-span-2`},sH={key:2,class:`divide-y divide-line-soft sm:col-span-2`},cH={class:`min-w-0`},lH={class:`truncate font-mono text-xs text-ink`},uH={class:`mt-0.5 text-2xs leading-4 text-muted`},dH={class:`sm:col-span-2`},fH={key:0,class:`space-y-2 sm:col-span-2`},pH={key:1,class:`sm:col-span-2`},mH={key:2,class:`divide-y divide-line-soft sm:col-span-2`},hH={class:`min-w-0 flex-1`},gH={class:`flex items-center gap-2`},_H={class:`truncate font-mono text-xs text-ink`},vH={class:`mt-0.5 font-mono text-2xs tabular-nums text-muted`},yH={class:`flex items-center gap-1.5`},bH=[`href`],xH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},SH={key:0,class:`font-mono text-2xs text-muted`},CH={class:`sm:col-span-2`},wH={key:0,class:`sm:col-span-2`},TH={class:`mt-2`},EH={class:`mt-2 max-w-sm`},DH={class:`mt-2`},OH={class:`mt-2`},kH={class:`mt-1 max-h-64 space-y-0.5 overflow-auto`},AH={class:`mt-2 flex flex-wrap items-center gap-2`},jH={class:`mt-2`},MH={class:`mt-2`},NH={key:1,class:`space-y-2 sm:col-span-2`},PH=P({__name:`BackupsSection`,props:za({state:{},policy:{},configPath:{},dirty:{type:Boolean}},{form:{required:!0},formModifiers:{}}),emits:za([`reset`],[`update:form`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`form`),a=wM(),o=YV(()=>i.value.keep,e=>i.value.keep=e,5),s=j(!1),c=j(null),l=j(null),u=j(``),d=j(null),f=j(null),p=j(``),m=j(null),h=W(()=>n.state?.files??[]),g=W(()=>n.state?.paths??[]),_=W(()=>d.value?.items.filter(e=>e.selected).length??0),v=W(()=>d.value?.items.some(e=>e.id===`config`&&e.selected)??!1),y=Q(hF,`cursor-pointer text-xs`,`file:mr-2 file:cursor-pointer file:rounded-control file:border-0 file:bg-panel-2 file:px-2 file:py-1 file:text-xs file:text-ink`),b=Q(`inline-flex h-6 shrink-0 items-center gap-1 rounded-control border border-line bg-raise px-2 text-2xs font-medium text-ink`,`transition-colors duration-150 hover:bg-hover`,fF);function x(e){for(let t of d.value?.items??[])t.restorable&&(t.selected=e)}async function S(){s.value=!0,l.value=null,c.value=null;try{await _j(u.value),u.value=``,c.value=`Backup created.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}async function C(e){s.value=!0,l.value=null,c.value=null;try{await vj(e),c.value=`Deleted ${e}.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}function w(e){f.value=e.target.files?.[0]??null,d.value=null,m.value=null,l.value=null,c.value=null}function T(){return p.value.length>0?{password:p.value}:{}}async function ee(e){s.value=!0,l.value=null,c.value=null,d.value=null;try{e===void 0?f.value===null?m.value=null:(m.value={kind:`upload`},d.value=await Sj(f.value,!1,T())):(m.value={kind:`stored`,name:e},d.value=await xj(e,!1,T())),d.value===null&&(l.value=`Choose a stored backup or upload one first.`)}catch(e){m.value=null,l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}async function E(){let e=m.value;e!==null&&await ee(e.kind===`stored`?e.name:void 0)}async function te(){let e=m.value,t=d.value;if(e===null||t===null){l.value=`Check an archive first.`;return}s.value=!0,l.value=null;let n={...T(),include:t.items.filter(e=>e.restorable&&e.selected).map(e=>e.id)};try{let t=e.kind===`stored`?await xj(e.name,!0,n):f.value===null?null:await Sj(f.value,!0,n);d.value=null,m.value=null,f.value=null,p.value=``;let r=[];t?.reloaded&&r.push(`the restored servers are live, autostart entries starting`),t?.restartRequired&&r.push(`restart the panel to apply its own settings`),c.value=t===null?`The restore failed.`:`Restored ${t.applied.length} item(s)${r.length===0?``:` — ${r.join(`; `)}`}.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{s.value=!1}}return(e,t)=>(L(),R(`div`,eH,[V(uR,{title:`Policy`,description:`What a backup captures, and how many archives are kept.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[9]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(OR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Allow backups`,hint:`Turning this off hides nothing: the archives already on disk stay downloadable.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(gR,{modelValue:M(o),"onUpdate:modelValue":t[2]||=e=>A(o)?o.value=e:null,label:`Keep`,min:1,hint:`Older archives are pruned after each backup.`},null,8,[`modelValue`]),V(TR,{modelValue:i.value.includePaths,"onUpdate:modelValue":t[3]||=e=>i.value.includePaths=e,label:`Extra paths`,hint:`Comma separated, in addition to every entry's data directories.`,placeholder:`{home}/myapp-data`},null,8,[`modelValue`]),n.policy===null?U(``,!0):(L(),R(`div`,tH,[t[12]||=B(`span`,{class:`text-xs font-medium text-muted`},`Archive directory`,-1),B(`div`,nH,[B(`span`,rH,k(n.policy.dir),1),V(VB,{value:n.policy.dir,label:`Copy the archive directory`},null,8,[`value`])]),B(`p`,iH,[t[10]||=H(` Changing it is a file-level decision: edit `,-1),B(`code`,null,k(n.configPath??`the config file`),1),t[11]||=H(`. `,-1)])]))]),_:1}),V(uR,{title:`Declared paths`,description:`Config, secrets and TLS are always captured. A path already covered by a declared parent is skipped.`},{default:N(()=>[n.state===null?(L(),R(`div`,aH,[V(uL,{class:`h-4 w-full`})])):g.value.length===0?(L(),R(`p`,oH,[...t[13]||=[H(` No data paths are declared yet. Add `,-1),B(`code`,null,`dataEnvs`,-1),H(` or `,-1),B(`code`,null,`backupPaths`,-1),H(` to a server to capture its data. `,-1)]])):(L(),R(`ul`,sH,[(L(!0),R(I,null,va(g.value,e=>(L(),R(`li`,{key:`${e.origin}:${e.path}`,class:`flex items-start justify-between gap-3 py-1.5`},[B(`div`,cH,[B(`p`,lH,k(e.path),1),B(`p`,uH,k(e.included?`from ${e.origin}`:e.note??`not captured`),1)]),V(NF,{tone:e.included?`ok`:`neutral`,plain:``},{default:N(()=>[H(k(e.included?`included`:`skipped`),1)]),_:2},1032,[`tone`])]))),128))]))]),_:1}),V(uR,{title:`Create a backup now`,description:`Optional password encrypts the archive; restoring it will ask for the same password.`},{default:N(()=>[V(TR,{modelValue:u.value,"onUpdate:modelValue":t[4]||=e=>u.value=e,type:`password`,autocomplete:`new-password`,label:`Password (optional)`,wide:``},null,8,[`modelValue`]),B(`div`,dH,[V($,{variant:`primary`,disabled:s.value,loading:s.value,onClick:S},{default:N(()=>[...t[14]||=[H(` Create backup now `,-1)]]),_:1},8,[`disabled`,`loading`])])]),_:1}),V(uR,{title:`Archives`,description:`Stored in the backup directory and downloadable at any time.`},{default:N(()=>[n.state===null?(L(),R(`div`,fH,[V(uL,{class:`h-4 w-full`}),V(uL,{class:`h-4 w-2/3`})])):h.value.length===0?(L(),R(`div`,pH,[V(QI,{compact:``,title:`No archives yet`,description:`Create one now to capture the config, secrets and every declared data path.`},{icon:N(()=>[V(M(Mv),{class:`size-4`})]),action:N(()=>[V($,{size:`sm`,variant:`primary`,disabled:s.value,onClick:S},{default:N(()=>[...t[15]||=[H(` Create backup now `,-1)]]),_:1},8,[`disabled`])]),_:1})])):(L(),R(`ul`,mH,[(L(!0),R(I,null,va(h.value,e=>(L(),R(`li`,{key:e.name,class:`flex flex-wrap items-center gap-x-3 gap-y-2 py-2 first:pt-0 last:pb-0`},[B(`div`,hH,[B(`div`,gH,[B(`span`,_H,k(e.name),1),e.encrypted?(L(),z(NF,{key:0,tone:`warn`,plain:``},{default:N(()=>[...t[16]||=[H(` encrypted `,-1)]]),_:1})):U(``,!0)]),B(`p`,vH,k(M(xI)(e.sizeBytes))+` · `+k(M(gI)(e.createdAt)),1)]),B(`div`,yH,[B(`a`,{href:yj(e.name),class:O(M(b))},[V(M(qv),{class:`size-3`,"aria-hidden":`true`}),t[17]||=H(` Download `,-1)],10,bH),V($,{size:`xs`,variant:`secondary`,disabled:s.value,onClick:t=>ee(e.name)},{default:N(()=>[V(M(gy),{class:`size-3`,"aria-hidden":`true`}),t[18]||=H(` Restore `,-1)]),_:1},8,[`disabled`,`onClick`]),V(bV,{label:`Delete`,"confirm-label":`Confirm delete`,size:`xs`,variant:`ghost`,"confirm-variant":`danger`,disabled:s.value,onConfirm:t=>C(e.name)},null,8,[`disabled`,`onConfirm`])])]))),128))]))]),_:1}),V(uR,{title:`Restore`,description:`Nothing is written until the plan is applied.`},{default:N(()=>[B(`div`,xH,[B(`label`,{class:O(M(pF)),for:`restore-upload`},`Restore from an uploaded .zip`,2),B(`input`,{id:`restore-upload`,type:`file`,accept:`.zip,application/zip`,class:O(M(y)),onChange:w},null,34),f.value?(L(),R(`p`,SH,k(f.value.name),1)):U(``,!0)]),B(`div`,CH,[V($,{variant:`secondary`,disabled:s.value||f.value===null,onClick:t[5]||=e=>ee()},{default:N(()=>[...t[19]||=[H(` Check the upload `,-1)]]),_:1},8,[`disabled`])]),d.value?(L(),R(`div`,wH,[V(CV,{tone:`warn`,title:d.value.dryRun?`Nothing has changed yet`:`Applied`},{default:N(()=>[B(`p`,null,[m.value?.kind===`stored`?(L(),R(I,{key:0},[t[20]||=H(` Archive `,-1),B(`code`,null,k(m.value.name),1),t[21]||=H(`. `,-1)],64)):(L(),R(I,{key:1},[H(` The uploaded archive. `)],64))]),d.value.needsPassword?(L(),R(I,{key:0},[B(`p`,TH,k(d.value.error??`This backup is password-protected.`),1),B(`div`,EH,[V(TR,{modelValue:p.value,"onUpdate:modelValue":t[6]||=e=>p.value=e,type:`password`,autocomplete:`off`,label:`Password`},null,8,[`modelValue`])]),B(`div`,DH,[V($,{size:`sm`,variant:`secondary`,disabled:s.value,onClick:E},{default:N(()=>[...t[22]||=[H(` Check again with the password `,-1)]]),_:1},8,[`disabled`])])],64)):(L(),R(I,{key:1},[B(`p`,OH,` Choose what to restore — `+k(_.value)+` of `+k(d.value.items.length)+` selected. `,1),B(`ul`,kH,[(L(!0),R(I,null,va(d.value.items,e=>(L(),R(`li`,{key:e.id},[V(kB,{modelValue:e.selected,"onUpdate:modelValue":t=>e.selected=t,label:e.label,hint:[e.kind,e.note].filter(Boolean).join(` · `),disabled:!e.restorable},null,8,[`modelValue`,`onUpdate:modelValue`,`label`,`hint`,`disabled`])]))),128))]),B(`div`,AH,[V($,{size:`xs`,variant:`ghost`,disabled:s.value,onClick:t[7]||=e=>x(!0)},{default:N(()=>[...t[23]||=[H(` Select all `,-1)]]),_:1},8,[`disabled`]),V($,{size:`xs`,variant:`ghost`,disabled:s.value,onClick:t[8]||=e=>x(!1)},{default:N(()=>[...t[24]||=[H(` Select none `,-1)]]),_:1},8,[`disabled`])]),B(`p`,jH,[H(` Will restore: `+k(d.value.applied.join(`, `)||`nothing`)+`. `,1),d.value.skipped.length?(L(),R(I,{key:0},[H(` Skipped: `+k(d.value.skipped.join(`, `))+`. `,1)],64)):U(``,!0),d.value.restartRequired?(L(),R(I,{key:1},[H(` The panel's own settings differ, so restart the panel afterwards. `)],64)):v.value?(L(),R(I,{key:2},[H(` Restored servers are reloaded immediately; entries marked autostart start on their own. `)],64)):U(``,!0)]),B(`div`,MH,[V($,{size:`sm`,variant:`danger`,disabled:s.value||_.value===0,loading:s.value,onClick:te},{default:N(()=>[H(k(m.value?.kind===`stored`?`Apply this restore`:`Restore the upload`),1)]),_:1},8,[`disabled`,`loading`])])],64))]),_:1},8,[`title`])])):U(``,!0),l.value||c.value?(L(),R(`div`,NH,[l.value?(L(),z(CV,{key:0,tone:`danger`},{default:N(()=>[H(k(l.value),1)]),_:1})):U(``,!0),c.value?(L(),z(CV,{key:1,tone:`ok`},{default:N(()=>[H(k(c.value),1)]),_:1})):U(``,!0)])):U(``,!0)]),_:1})]))}}),FH={class:`mt-3 space-y-3`},IH=P({__name:`DefaultsSection`,props:za({dirty:{type:Boolean}},{defaults:{required:!0},defaultsModifiers:{}}),emits:za([`reset`],[`update:defaults`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`defaults`),a=YV(()=>i.value.logBufferLines,e=>i.value.logBufferLines=e,500);return(e,t)=>(L(),R(I,null,[V(uR,{title:`Server defaults`,description:`Applied to every entry that does not set its own value.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[9]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(kB,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Enabled`,hint:`New entries start enabled.`},null,8,[`modelValue`]),V(kB,{modelValue:i.value.autostart,"onUpdate:modelValue":t[2]||=e=>i.value.autostart=e,label:`Autostart with the panel`},null,8,[`modelValue`]),V(lL,{modelValue:i.value.bind,"onUpdate:modelValue":t[3]||=e=>i.value.bind=e,label:`Bind`,options:[{value:`local`,label:`Local — 127.0.0.1`},{value:`lan`,label:`LAN — 0.0.0.0`}]},null,8,[`modelValue`]),V(lL,{modelValue:i.value.onPortConflict,"onUpdate:modelValue":t[4]||=e=>i.value.onPortConflict=e,label:`On port conflict`,options:[{value:`block`,label:`Block the start`},{value:`warn`,label:`Warn and start anyway`},{value:`follow`,label:`Follow a detached restart of itself`},{value:`reclaim`,label:`Replace a detached restart with a supervised copy`}]},null,8,[`modelValue`]),V(gR,{modelValue:M(a),"onUpdate:modelValue":t[5]||=e=>A(a)?a.value=e:null,label:`Log buffer lines`,min:50,max:1e5,hint:`Kept in memory per server.`},null,8,[`modelValue`])]),_:1}),B(`div`,FH,[V(AB,{restart:i.value.restart,"onUpdate:restart":t[6]||=e=>i.value.restart=e,health:i.value.health,"onUpdate:health":t[7]||=e=>i.value.health=e,stop:i.value.stop,"onUpdate:stop":t[8]||=e=>i.value.stop=e},null,8,[`restart`,`health`,`stop`])])],64))}}),LH={key:0,class:`mt-3 flex flex-wrap items-center gap-1.5`},RH={key:1,class:`mt-3 text-xs text-muted`},zH=P({__name:`HostSection`,props:za({config:{},alerts:{},dirty:{type:Boolean}},{host:{required:!0},hostModifiers:{}}),emits:za([`reset`],[`update:host`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`host`),a=YV(()=>i.value.intervalMs,e=>i.value.intervalMs=e,15e3),o=YV(()=>i.value.diskUsedPercent,e=>i.value.diskUsedPercent=e,90),s=YV(()=>i.value.memoryUsedPercent,e=>i.value.memoryUsedPercent=e,90),c=YV(()=>i.value.swapUsedPercent,e=>i.value.swapUsedPercent=e,50),l=YV(()=>i.value.loadPerCpu,e=>i.value.loadPerCpu=e,2),u=YV(()=>i.value.tempCelsius,e=>i.value.tempCelsius=e,85);return(e,t)=>(L(),R(I,null,[V(uR,{title:`Thresholds`,description:`A threshold of 0 disables that alert. Breaches notify once, and once more on recovery.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[9]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(OR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Sample this machine`,hint:`Load, memory, swap, disk and CPU temperature, on the interval below.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(gR,{modelValue:M(a),"onUpdate:modelValue":t[2]||=e=>A(a)?a.value=e:null,label:`Interval (ms)`,min:5e3,hint:`How often the host is sampled and alerts are checked.`},null,8,[`modelValue`]),V(TR,{modelValue:i.value.diskPaths,"onUpdate:modelValue":t[3]||=e=>i.value.diskPaths=e,label:`Disk paths`,hint:`Comma separated; templates like {home} are expanded.`},null,8,[`modelValue`]),V(gR,{modelValue:M(o),"onUpdate:modelValue":t[4]||=e=>A(o)?o.value=e:null,label:`Disk used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),V(gR,{modelValue:M(s),"onUpdate:modelValue":t[5]||=e=>A(s)?s.value=e:null,label:`Memory used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),V(gR,{modelValue:M(c),"onUpdate:modelValue":t[6]||=e=>A(c)?c.value=e:null,label:`Swap used (%)`,min:0,max:100,hint:`0 disables the alert.`},null,8,[`modelValue`]),V(gR,{modelValue:M(l),"onUpdate:modelValue":t[7]||=e=>A(l)?l.value=e:null,label:`Load per CPU`,min:0,hint:`1-minute load average divided by the core count.`},null,8,[`modelValue`]),V(gR,{modelValue:M(u),"onUpdate:modelValue":t[8]||=e=>A(u)?u.value=e:null,label:`CPU temperature (°C)`,min:0,hint:`Linux only; ignored where the OS does not expose it.`},null,8,[`modelValue`])]),_:1}),n.alerts.length>0?(L(),R(`div`,LH,[t[10]||=B(`span`,{class:`text-xs text-muted`},`Breaching now:`,-1),(L(!0),R(I,null,va(n.alerts,e=>(L(),z(NF,{key:e,tone:`danger`,dot:``},{default:N(()=>[H(k(e),1)]),_:2},1024))),128))])):i.value.enabled?(L(),R(`p`,RH,` Nothing is breaching right now. `)):U(``,!0)],64))}}),BH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},VH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},HH={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},UH={class:`text-2xs leading-4 text-faint`},WH={key:0},GH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},KH=[`disabled`],qH=P({__name:`InterfaceSection`,props:za({ui:{},labelDirty:{type:Boolean}},{label:{required:!0},labelModifiers:{}}),emits:za([`changed`,`resetLabel`],[`update:label`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`label`),a=j(null),o=j(!1),s=j(null),c=j(null),l=j(!1),u=W(()=>{let e=n.ui;if(e===null)return`unknown`;if(!e.custom)return`stock`;let t=e.meta;return t===null?`custom`:`custom · ${t.name}${t.version===null?``:` ${t.version}`}`}),d=W(()=>{let e=n.ui?.meta;return e==null?null:`${e.files} files · ${new Date(e.uploadedAt).toLocaleString()}`});function f(e){a.value=e.target.files?.[0]??null,s.value=null,c.value=null}async function p(){if(a.value!==null){o.value=!0,c.value=null,s.value=null;try{let e=await Dj(a.value);s.value=`UI replaced with ${e.meta?.name??`your build`} — refresh the page`,a.value=null,r(`changed`)}catch(e){c.value=e instanceof Error?e.message:String(e)}finally{o.value=!1}}}async function m(){if(!l.value){l.value=!0,setTimeout(()=>{l.value=!1},5e3);return}l.value=!1,o.value=!0,c.value=null;try{let e=await Oj();s.value=e.removed?`stock UI restored — refresh the page`:`no custom UI was installed`,r(`changed`)}catch(e){c.value=e instanceof Error?e.message:String(e)}finally{o.value=!1}}return(t,h)=>(L(),z(uR,{title:`Interface`,description:`The panel is a static site: keep the stock one, or serve your own build from the state directory.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.labelDirty,onClick:h[1]||=e=>r(`resetLabel`)},{default:N(()=>[...h[4]||=[H(` Reset name `,-1)]]),_:1},8,[`disabled`]),e.ui?.custom?(L(),z($,{key:0,size:`xs`,variant:`ghost`,disabled:o.value,onClick:m},{default:N(()=>[H(k(l.value?`Confirm revert`:`Revert to stock`),1)]),_:1},8,[`disabled`])):U(``,!0),V($,{size:`xs`,variant:`primary`,disabled:o.value||a.value===null,onClick:p},{default:N(()=>[...h[5]||=[H(` Install UI `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[B(`div`,BH,[h[2]||=B(`span`,{class:`text-xs font-medium text-muted`},`Currently serving`,-1),B(`div`,VH,[B(`span`,HH,k(u.value),1),V(VB,{value:e.ui?.dir??``,label:`Copy the UI directory`},null,8,[`value`])]),B(`p`,UH,[d.value?(L(),R(`span`,WH,k(d.value)+` · `,1)):U(``,!0),B(`code`,null,k(e.ui?.dir??`—`),1)])]),V(TR,{modelValue:i.value,"onUpdate:modelValue":h[0]||=e=>i.value=e,label:`Panel name`,hint:`Shown in the sidebar by the stock UI. A custom UI may show its own name instead.`,wide:``},null,8,[`modelValue`]),B(`label`,GH,[h[3]||=B(`span`,{class:`text-xs font-medium text-muted`},`Upload a UI build (.zip with an index.html)`,-1),B(`input`,{type:`file`,accept:`.zip,application/zip`,class:`rounded-control border border-line bg-page/60 px-2.5 py-1.5 text-xs text-ink file:mr-2 file:rounded file:border-0 file:bg-line file:px-2 file:py-1 file:text-xs`,disabled:o.value,onChange:f},null,40,KH)]),c.value?(L(),z(CV,{key:0,tone:`warn`,title:c.value},null,8,[`title`])):s.value?(L(),z(CV,{key:1,tone:`ok`,title:s.value},null,8,[`title`])):U(``,!0),h[6]||=B(`p`,{class:`text-2xs leading-4 text-faint sm:col-span-2`},[H(` See `),B(`code`,null,`UI_CREATION.md`),H(` for the API contract. If a custom UI breaks the panel, `),B(`code`,null,`home-hosted ui-revert`),H(` puts the stock one back from the terminal. `)],-1)]),_:1}))}}),JH={class:`flex min-w-0 flex-col gap-1`},YH={class:`text-2xs leading-4 text-faint`},XH={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},ZH={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},QH={class:`min-w-0 flex-1 truncate font-mono text-xs tabular-nums text-ink`},$H=P({__name:`ListenerSection`,props:za({view:{},dirty:{type:Boolean}},{control:{required:!0},controlModifiers:{}}),emits:za([`reset`],[`update:control`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`control`),a=YV(()=>i.value.port,e=>i.value.port=e,3999),o=[`local`,`lan`],s=W({get:()=>o.includes(i.value.host)?i.value.host:`custom`,set:e=>{if(e!==`custom`){i.value.host=e;return}if(!o.includes(i.value.host))return;let t=n.view?.bindHost??``,r=t!==``&&t!==`0.0.0.0`&&t!==`127.0.0.1`&&Wk(t)!==null;i.value.host=r?t:`127.0.0.1`}}),c=W(()=>{if(s.value===`custom`&&Wk(i.value.host)===null)return`Enter an IPv4 address, for example 192.168.1.20.`}),l=W(()=>n.view?.url??`—`);return(e,t)=>(L(),z(uR,{title:`Listener`,description:`Where the panel answers. Moving this restarts the panel and sends this page to the new address.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[5]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(gR,{modelValue:M(a),"onUpdate:modelValue":t[1]||=e=>A(a)?a.value=e:null,label:`Control port`,min:1,max:65535,hint:`Default 3999.`},null,8,[`modelValue`]),B(`div`,JH,[t[6]||=B(`span`,{class:`text-xs font-medium text-muted`},`Bind`,-1),V(AI,{modelValue:s.value,"onUpdate:modelValue":t[2]||=e=>s.value=e,options:[{value:`local`,label:`Local`},{value:`lan`,label:`LAN`},{value:`custom`,label:`Custom`}]},null,8,[`modelValue`]),B(`p`,YH,k(s.value===`lan`?`0.0.0.0 — reachable from the whole network.`:s.value===`local`?`127.0.0.1 — this machine only.`:`A specific interface address you type in below.`),1)]),s.value===`custom`?(L(),z(TR,{key:0,modelValue:i.value.host,"onUpdate:modelValue":t[3]||=e=>i.value.host=e,label:`IPv4 address`,placeholder:`192.168.1.20`,error:c.value,hint:`Binding beyond 127.0.0.1 needs a real password.`},null,8,[`modelValue`,`error`])):U(``,!0),V(kB,{modelValue:i.value.openBrowser,"onUpdate:modelValue":t[4]||=e=>i.value.openBrowser=e,label:`Open a browser when the panel comes up`,wide:``},null,8,[`modelValue`]),B(`div`,XH,[t[8]||=B(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),B(`div`,ZH,[B(`span`,QH,k(l.value),1),n.view?.restartRequired?(L(),z(NF,{key:0,tone:`warn`,dot:``},{default:N(()=>[...t[7]||=[H(` restart required `,-1)]]),_:1})):U(``,!0),V(VB,{value:l.value,label:`Copy the live address`},null,8,[`value`])]),t[9]||=B(`p`,{class:`text-2xs leading-4 text-faint`},` What the listener is bound to right now; saved changes take effect after the panel rebinds. `,-1)])]),_:1}))}}),eU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},tU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},nU={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},rU={class:`text-2xs leading-4 text-faint`},iU=P({__name:`LogsSection`,props:za({logsDir:{},dirty:{type:Boolean}},{logs:{required:!0},logsModifiers:{}}),emits:za([`reset`],[`update:logs`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`logs`),a=YV(()=>i.value.maxBytes,e=>i.value.maxBytes=e,2e6),o=YV(()=>i.value.keep,e=>i.value.keep=e,3),s=W(()=>n.logsDir??`—`);return(e,t)=>{let c=fa(`RouterLink`);return L(),z(uR,{title:`Retention`,description:`The live view always comes from memory; these files survive a restart and feed the Logs page.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[4]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(OR,{modelValue:i.value.persist,"onUpdate:modelValue":t[1]||=e=>i.value.persist=e,label:`Keep logs on disk`,hint:`Turn off to hold everything in memory only.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(gR,{modelValue:M(a),"onUpdate:modelValue":t[2]||=e=>A(a)?a.value=e:null,label:`Rotate at (bytes)`,min:1e4,max:1e8,hint:`Per server, before rolling to .1, .2, …`},null,8,[`modelValue`]),V(gR,{modelValue:M(o),"onUpdate:modelValue":t[3]||=e=>A(o)?o.value=e:null,label:`Keep rotated files`,min:1,max:10},null,8,[`modelValue`]),B(`div`,eU,[t[8]||=B(`span`,{class:`text-xs font-medium text-muted`},`Logs directory`,-1),B(`div`,tU,[B(`span`,nU,k(s.value),1),V(VB,{value:s.value,label:`Copy the logs directory`},null,8,[`value`])]),B(`p`,rU,[t[6]||=H(` Browse and download these files on the `,-1),V(c,{to:`/logs`,class:`text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent`},{default:N(()=>[...t[5]||=[H(` Logs `,-1)]]),_:1}),t[7]||=H(` page. `,-1)])])]),_:1})}}}),aU={class:`flex items-center gap-2 border-t border-line-soft pt-3 sm:col-span-2`},oU={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},sU={key:0,class:`sm:col-span-2`},cU={class:`flex flex-wrap gap-1.5`},lU={key:1,class:`sm:col-span-2`},uU={class:`text-2xs leading-4 text-faint`},dU={key:2,class:`space-y-2 sm:col-span-2`},fU=P({__name:`NotificationsSection`,props:za({status:{},dirty:{type:Boolean}},{telegram:{required:!0},telegramModifiers:{}}),emits:za([`reset`],[`update:telegram`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`telegram`),a=wM(),o=YV(()=>i.value.cooldownMs,e=>i.value.cooldownMs=e,12e4),s=j(``),c=j(null),l=j(null),u=j([]),d=j(!1),f=W(()=>n.status?.tokenSet===!0),p=W(()=>n.status?.lastResult??null),m=W(()=>n.status?.lastResultAt??null),h=W(()=>f.value?`Saved — type a new token to replace it`:`123456789:AA…`);async function g(){d.value=!0,l.value=null,c.value=null;try{let e=await Cj(s.value.trim());s.value=``,c.value=`Token saved${e.username?` for @${e.username}`:``}.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{d.value=!1}}async function _(){d.value=!0,l.value=null,c.value=null;try{await wj(),c.value=`Token removed.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{d.value=!1}}async function v(){d.value=!0,l.value=null,c.value=null;try{let e=s.value.trim(),t=await Ej(e.length>0?{botToken:e}:{});u.value=t.chats,t.chats.length===0&&(l.value=`No chats found. Send /start to the bot first, then detect again.`)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{d.value=!1}}async function y(){d.value=!0,l.value=null,c.value=null;try{let e=s.value.trim(),t=await Tj({chatId:i.value.chatId.length>0?i.value.chatId:void 0,...e.length>0?{botToken:e}:{}});t.ok?c.value=`Test message sent.`:l.value=t.error??`The test message failed.`,await a.refresh()}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{d.value=!1}}return(e,t)=>(L(),z(uR,{title:`Telegram`,description:`Policy lives in the config; the bot token is a secret and never comes back from the server.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[10]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(OR,{modelValue:i.value.enabled,"onUpdate:modelValue":t[1]||=e=>i.value.enabled=e,label:`Send notifications`,hint:`One message per event, throttled by the cooldown below.`,class:`sm:col-span-2`},null,8,[`modelValue`]),V(TR,{modelValue:i.value.chatId,"onUpdate:modelValue":t[2]||=e=>i.value.chatId=e,label:`Chat id`,placeholder:`123456789 or @channel`,hint:`Use Detect chats to fill this from the bot's updates.`},null,8,[`modelValue`]),V(gR,{modelValue:M(o),"onUpdate:modelValue":t[3]||=e=>A(o)?o.value=e:null,label:`Cooldown per event (ms)`,min:0,hint:`Per server and reason, so a flapping server cannot spam.`},null,8,[`modelValue`]),V(kB,{modelValue:i.value.onCrash,"onUpdate:modelValue":t[4]||=e=>i.value.onCrash=e,label:`Retries exhausted`},null,8,[`modelValue`]),V(kB,{modelValue:i.value.onUnhealthy,"onUpdate:modelValue":t[5]||=e=>i.value.onUnhealthy=e,label:`Port unhealthy`},null,8,[`modelValue`]),V(kB,{modelValue:i.value.onForcedRestart,"onUpdate:modelValue":t[6]||=e=>i.value.onForcedRestart=e,label:`Forced restart`},null,8,[`modelValue`]),V(kB,{modelValue:i.value.onRecovered,"onUpdate:modelValue":t[7]||=e=>i.value.onRecovered=e,label:`Recovered`},null,8,[`modelValue`]),V(kB,{modelValue:i.value.onHost,"onUpdate:modelValue":t[8]||=e=>i.value.onHost=e,label:`Host vitals breached`,hint:`Disk, memory, swap, load and CPU temperature, per the thresholds under Host vitals.`,wide:``},null,8,[`modelValue`]),B(`div`,aU,[t[11]||=B(`span`,{class:`text-xs font-medium text-muted`},`Bot token`,-1),V(NF,{tone:f.value?`ok`:`warn`,dot:``},{default:N(()=>[H(k(f.value?`token set`:`no token`),1)]),_:1},8,[`tone`]),t[12]||=B(`span`,{class:`text-2xs text-faint`},`From @BotFather — a secret, never in servers.config.json.`,-1)]),V(TR,{modelValue:s.value,"onUpdate:modelValue":t[9]||=e=>s.value=e,type:`password`,autocomplete:`off`,label:`Bot token`,placeholder:h.value,wide:``},null,8,[`modelValue`,`placeholder`]),B(`div`,oU,[V($,{variant:`primary`,disabled:d.value||s.value.trim().length===0,loading:d.value&&s.value.trim().length>0,onClick:g},{default:N(()=>[...t[13]||=[H(` Save token `,-1)]]),_:1},8,[`disabled`,`loading`]),V($,{variant:`secondary`,disabled:d.value,onClick:v},{default:N(()=>[...t[14]||=[H(` Detect chats `,-1)]]),_:1},8,[`disabled`]),V($,{variant:`secondary`,disabled:d.value,onClick:y},{default:N(()=>[...t[15]||=[H(` Send test `,-1)]]),_:1},8,[`disabled`]),f.value?(L(),z(bV,{key:0,label:`Remove token`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:d.value,onConfirm:_},null,8,[`disabled`])):U(``,!0)]),u.value.length>0?(L(),R(`div`,sU,[t[16]||=B(`p`,{class:`mb-1.5 text-xs text-muted`},` Chats the bot has seen: `,-1),B(`div`,cU,[(L(!0),R(I,null,va(u.value,e=>(L(),z($,{key:String(e.id),size:`xs`,variant:`secondary`,onClick:t=>i.value.chatId=String(e.id)},{default:N(()=>[H(k(e.title)+` (`+k(e.id)+`) `,1)]),_:2},1032,[`onClick`]))),128))])])):U(``,!0),p.value?(L(),R(`div`,lU,[B(`p`,uU,` Last send: `+k(p.value)+k(m.value?` · ${M(bI)(m.value,M(a).now.value)}`:``),1)])):U(``,!0),l.value||c.value?(L(),R(`div`,dU,[l.value?(L(),z(CV,{key:0,tone:`danger`},{default:N(()=>[H(k(l.value),1)]),_:1})):U(``,!0),c.value?(L(),z(CV,{key:1,tone:`ok`},{default:N(()=>[H(k(c.value),1)]),_:1})):U(``,!0)])):U(``,!0)]),_:1}))}}),pU={class:`divide-y divide-line-soft sm:col-span-2`},mU={class:`min-w-0`},hU={class:`text-xs font-medium text-ink`},gU={class:`mt-0.5 text-2xs leading-4 text-faint`},_U={class:`flex min-w-0 flex-1 items-center justify-end gap-1.5`},vU={class:`min-w-0 truncate font-mono text-xs text-ink`},yU=P({__name:`PathsSection`,props:{configPath:{},dataRoot:{},logsDir:{},projectDir:{},panelUrl:{}},setup(e){let t=e,n=W(()=>[{key:`data`,label:`Data root`,hint:`HHOSTED_HOME — config, secrets, TLS, logs and backups.`,value:t.dataRoot??`—`},{key:`config`,label:`Config file`,hint:`servers.config.json — every policy on this page.`,value:t.configPath??`—`},{key:`logs`,label:`Logs directory`,hint:`Persisted output for every server.`,value:t.logsDir??`—`},{key:`project`,label:`Project directory`,hint:`Base for relative entry paths.`,value:t.projectDir??`—`},{key:`panel`,label:`Panel address`,hint:`Where this control panel is live right now.`,value:t.panelUrl??`—`}]);return(e,t)=>(L(),z(uR,{title:`Where things live`,description:`Read-only. Copy a path straight into a shell or an editor.`},{default:N(()=>[B(`ul`,pU,[(L(!0),R(I,null,va(n.value,e=>(L(),R(`li`,{key:e.key,class:`flex items-start justify-between gap-3 py-2 first:pt-0 last:pb-0`},[B(`div`,mU,[B(`p`,hU,k(e.label),1),B(`p`,gU,k(e.hint),1)]),B(`div`,_U,[B(`span`,vU,k(e.value),1),V(VB,{value:e.value,label:`Copy ${e.label.toLowerCase()}`},null,8,[`value`,`label`])])]))),128))])]),_:1}))}}),bU={class:`flex min-w-0 flex-col gap-1 sm:col-span-2`},xU={class:`flex items-center gap-1.5 rounded-control border border-line bg-page/60 px-2.5 py-1.5`},SU={class:`min-w-0 flex-1 truncate font-mono text-xs text-ink`},CU={key:0,class:`sm:col-span-2`},wU={key:1,class:`space-y-3 sm:col-span-2`},TU={class:`divide-y divide-line-soft text-xs`},EU={class:`flex items-start justify-between gap-4 py-1.5`},DU={class:`min-w-0 text-right font-mono text-xs text-ink`},OU={class:`flex items-start justify-between gap-4 py-1.5`},kU={class:`min-w-0 text-right font-mono text-xs text-ink`},AU={class:`flex items-start justify-between gap-4 py-1.5`},jU={class:`font-mono text-xs tabular-nums text-ink`},MU={class:`flex items-center justify-between gap-4 py-1.5`},NU={class:`flex items-start justify-between gap-4 py-1.5`},PU={class:`flex min-w-0 items-center gap-1.5`},FU={class:`min-w-0 truncate font-mono text-2xs text-ink`},IU={key:2,class:`sm:col-span-2`},LU={class:`flex min-w-0 flex-col gap-1`},RU={class:`flex min-w-0 flex-col gap-1`},zU={class:`flex flex-wrap items-center gap-2 sm:col-span-2`},BU={key:3,class:`space-y-2 sm:col-span-2`},VU=P({__name:`TlsSection`,props:za({view:{},dirty:{type:Boolean}},{tlsEnabled:{type:Boolean,required:!0},tlsEnabledModifiers:{}}),emits:za([`reset`],[`update:tlsEnabled`]),setup(e,{emit:t}){let n=e,r=t,i=so(e,`tlsEnabled`),a=wM(),o=j(``),s=j(``),c=j(null),l=j(null),u=j(!1),d=W(()=>n.view?.tls??null),f=W(()=>n.view?`${n.view.protocol}://${n.view.bindHost}:${n.view.port}`:`—`),p=W(()=>o.value.trim().length>0&&s.value.trim().length>0&&!u.value),m=Q(hF,`cursor-pointer text-xs`,`file:mr-2 file:cursor-pointer file:rounded-control file:border-0 file:bg-panel-2 file:px-2 file:py-1 file:text-xs file:text-ink`);async function h(e,t){let n=e.target.files?.[0];if(!n)return;let r=await n.text();t===`cert`?o.value=r:s.value=r}async function g(){u.value=!0,l.value=null,c.value=null;try{let e=await kj(o.value,s.value);o.value=``,s.value=``,c.value=`Certificate stored.`,await a.refresh();let t=await XV(e);t!==null&&(l.value=t)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}async function _(){u.value=!0,l.value=null,c.value=null;try{let e=await Aj();c.value=`Certificate removed.`,await a.refresh();let t=await XV(e);t!==null&&(l.value=t)}catch(e){l.value=e instanceof Error?e.message:String(e)}finally{u.value=!1}}return(e,t)=>(L(),R(I,null,[V(uR,{title:`HTTPS`,description:`Upload a PEM pair and the panel serves TLS on its own listener. A self-signed certificate is fine on a home network.`},{actions:N(()=>[V($,{size:`xs`,variant:`ghost`,disabled:!n.dirty,onClick:t[0]||=e=>r(`reset`)},{default:N(()=>[...t[6]||=[H(` Reset `,-1)]]),_:1},8,[`disabled`])]),default:N(()=>[V(OR,{modelValue:i.value,"onUpdate:modelValue":t[1]||=e=>i.value=e,label:`Serve the panel over HTTPS`,hint:`Saved with Save settings; the panel rebinds and this page follows it.`,class:`sm:col-span-2`},null,8,[`modelValue`]),B(`div`,bU,[t[7]||=B(`span`,{class:`text-xs font-medium text-muted`},`Live address`,-1),B(`div`,xU,[B(`span`,SU,k(f.value),1),V(VB,{value:f.value,label:`Copy the live address`},null,8,[`value`])])])]),_:1}),V(uR,{class:`mt-3`,title:`Certificate`,description:`PEM-encoded certificate and its private key. Both stay in the secrets file.`},{default:N(()=>[d.value?.error?(L(),R(`div`,CU,[V(CV,{tone:`danger`,title:`The stored certificate cannot be used`},{default:N(()=>[H(k(d.value.error),1)]),_:1})])):d.value?.certPresent?(L(),R(`div`,wU,[B(`dl`,TU,[B(`div`,EU,[t[8]||=B(`dt`,{class:`text-muted`},` Subject `,-1),B(`dd`,DU,k(d.value.subject??`—`),1)]),B(`div`,OU,[t[9]||=B(`dt`,{class:`text-muted`},` Issuer `,-1),B(`dd`,kU,k(d.value.issuer??`—`),1)]),B(`div`,AU,[t[10]||=B(`dt`,{class:`text-muted`},` Valid until `,-1),B(`dd`,jU,[H(k(d.value.validTo?d.value.validTo.slice(0,10):`—`)+` `,1),d.value.daysRemaining===null?U(``,!0):(L(),R(`span`,{key:0,class:O(M(Q)(`ml-1.5`,d.value.daysRemaining<14?`text-warn`:`text-faint`))},` (`+k(d.value.daysRemaining)+` days) `,3))])]),B(`div`,MU,[t[11]||=B(`dt`,{class:`text-muted`},` Private key `,-1),B(`dd`,null,[V(NF,{tone:d.value.keyMatches?`ok`:`danger`,dot:``},{default:N(()=>[H(k(d.value.keyMatches?`matches the certificate`:`does not match`),1)]),_:1},8,[`tone`])])]),B(`div`,NU,[t[12]||=B(`dt`,{class:`text-muted`},` Fingerprint `,-1),B(`dd`,PU,[B(`span`,FU,k(d.value.fingerprint??`—`),1),d.value.fingerprint?(L(),z(VB,{key:0,value:d.value.fingerprint,label:`Copy the fingerprint`},null,8,[`value`])):U(``,!0)])])])])):(L(),R(`div`,IU,[V(CV,{tone:`info`,title:`No certificate uploaded`},{default:N(()=>[...t[13]||=[H(` Upload a PEM certificate and key below, then save. HTTPS is not served until a certificate is present. `,-1)]]),_:1})])),B(`div`,LU,[B(`label`,{class:O(M(pF)),for:`tls-cert-file`},`Certificate file (.pem, .crt)`,2),B(`input`,{id:`tls-cert-file`,type:`file`,accept:`.pem,.crt,.cer,text/plain`,class:O(M(m)),onChange:t[2]||=e=>h(e,`cert`)},null,34)]),B(`div`,RU,[B(`label`,{class:O(M(pF)),for:`tls-key-file`},`Private key file (.pem, .key)`,2),B(`input`,{id:`tls-key-file`,type:`file`,accept:`.pem,.key,text/plain`,class:O(M(m)),onChange:t[3]||=e=>h(e,`key`)},null,34)]),V(bR,{modelValue:o.value,"onUpdate:modelValue":t[4]||=e=>o.value=e,label:`Or paste the certificate`,rows:4,placeholder:`-----BEGIN CERTIFICATE-----`},null,8,[`modelValue`]),V(bR,{modelValue:s.value,"onUpdate:modelValue":t[5]||=e=>s.value=e,label:`Or paste the private key`,rows:4,placeholder:`-----BEGIN PRIVATE KEY-----`},null,8,[`modelValue`]),B(`div`,zU,[V($,{variant:`primary`,disabled:!p.value,loading:u.value,onClick:g},{default:N(()=>[...t[14]||=[H(` Save certificate `,-1)]]),_:1},8,[`disabled`,`loading`]),d.value?.certPresent?(L(),z(bV,{key:0,label:`Remove certificate`,"confirm-label":`Confirm remove`,"confirm-variant":`danger`,disabled:u.value,onConfirm:_},null,8,[`disabled`])):U(``,!0)]),l.value||c.value?(L(),R(`div`,BU,[l.value?(L(),z(CV,{key:0,tone:`danger`},{default:N(()=>[H(k(l.value),1)]),_:1})):U(``,!0),c.value?(L(),z(CV,{key:1,tone:`ok`},{default:N(()=>[H(k(c.value),1)]),_:1})):U(``,!0)])):U(``,!0)]),_:1})],64))}}),HU={class:`min-h-full`},UU={class:`mx-auto w-full max-w-5xl px-4 pb-6 pt-5 sm:px-6`},WU={class:`lg:grid lg:grid-cols-[11rem_minmax(0,1fr)] lg:gap-8`},GU={"aria-label":`Settings sections`,class:`hidden lg:block`},KU={class:`sticky top-6 space-y-0.5 border-l border-line`},qU=[`aria-current`,`onClick`],JU={class:`space-y-6`},YU={id:`listener`,class:`scroll-mt-5`},XU={id:`authentication`,class:`scroll-mt-5`},ZU={id:`password`,class:`scroll-mt-5`},QU={id:`defaults`,class:`scroll-mt-5`},$U={id:`logs`,class:`scroll-mt-5`},eW={id:`notifications`,class:`scroll-mt-5`},tW={id:`host`,class:`scroll-mt-5`},nW={id:`backups`,class:`scroll-mt-5`},rW={id:`tls`,class:`scroll-mt-5`},iW={id:`interface`,class:`scroll-mt-5`},aW={id:`paths`,class:`scroll-mt-5`},oW={class:`sticky bottom-0 z-30 border-t border-line bg-panel/95 backdrop-blur`},sW={class:`mx-auto flex w-full max-w-5xl flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3 sm:px-6`},cW={class:`min-w-0 flex-1`},lW={class:`text-xs text-muted`},uW={class:`font-mono tabular-nums text-ink`},dW={key:0,class:`mt-0.5 text-xs text-danger`},fW={key:1,class:`mt-0.5 text-xs text-ok`},pW={class:`flex shrink-0 items-center gap-2`},mW={class:`max-h-[60dvh] overflow-auto px-4 py-3`},hW={key:0,class:`divide-y divide-line-soft`},gW={class:`font-mono text-xs text-ink`},_W={class:`ml-auto font-mono text-xs text-muted line-through`},vW={class:`font-mono text-xs text-accent`},yW={key:1,class:`text-xs text-muted`},bW={class:`flex items-center justify-end gap-2 border-t border-line px-4 py-3`},xW=P({__name:`SettingsView`,setup(e){let t=[{id:`listener`,title:`Listener`},{id:`authentication`,title:`Authentication`},{id:`defaults`,title:`Server defaults`},{id:`logs`,title:`Logs`},{id:`notifications`,title:`Notifications`},{id:`host`,title:`Host vitals`},{id:`backups`,title:`Backups`},{id:`tls`,title:`TLS`},{id:`interface`,title:`Interface`},{id:`paths`,title:`Paths`}],n=zg(),r=Rg(),i=wM(),a=Kj(),o=en(kV()),s=j(`listener`),c=j(!1),l=j(null),u=j(null),d=j(null),f=j(null),p=W(()=>i.control.value),m=W(()=>i.defaults.value),h=W(()=>i.logsConfig.value),g=W(()=>i.notifications.value?.telegram??null),_=W(()=>i.host.value?.alerts??[]),v=W(()=>f.value?.host??null),y=W(()=>f.value?.backups??null),b=W(()=>f.value?.ui??null),x=W(()=>i.backups.value),S=W(()=>i.appState.value?.configPath??null),C=W(()=>{let e={},t=p.value,n=m.value,r=h.value,i=g.value;if(t!==null){let n=RV(t,o);Object.keys(n).length>0&&(e.control=n)}if(n!==null){let t=zV(n,o.defaults);Object.keys(t).length>0&&(e.defaults=t)}if(r!==null){let t=BV(r,o.logs);Object.keys(t).length>0&&(e.logs=t)}if(i!==null){let t=VV(i,o.telegram);Object.keys(t).length>0&&(e.notifications=t)}let a=v.value;if(a!==null){let t=IV(a,o.host);Object.keys(t).length>0&&(e.host=t)}let s=y.value;if(s!==null){let t=LV(s,o.backups);Object.keys(t).length>0&&(e.backups=t)}return e}),w=W(()=>GV(C.value)),T=W(()=>{let e=p.value,t=g.value,n=v.value,r=y.value;return{control:e===null?{}:{...jV(e),auth:AV(e.auth)},defaults:m.value??{},logs:h.value??{},notifications:t===null?{}:{telegram:MV(t)},host:n??{},backups:r===null?{}:{enabled:r.enabled,keep:r.keep,includePaths:r.includePaths}}}),ee=W(()=>WV(C.value,T.value)),E=j(!1);function te(e){return e===void 0?`unset`:typeof e==`string`?e:JSON.stringify(e)}let ne=W(()=>p.value!==null&&KV(p.value,o)),re=W(()=>p.value!==null&&qV(p.value,o)),ie=W(()=>p.value!==null&&JV(p.value,o)),ae=W(()=>m.value!==null&&Object.keys(zV(m.value,o.defaults)).length>0),oe=W(()=>h.value!==null&&Object.keys(BV(h.value,o.logs)).length>0),se=W(()=>g.value!==null&&Object.keys(VV(g.value,o.telegram)).length>0),ce=W(()=>v.value!==null&&Object.keys(IV(v.value,o.host)).length>0),D=W(()=>y.value!==null&&Object.keys(LV(y.value,o.backups)).length>0),le=j(!1);function ue(){let e=p.value;e!==null&&(Object.assign(o.control,jV(e)),Object.assign(o.auth,AV(e.auth)));let t=h.value;t!==null&&Object.assign(o.logs,t);let n=g.value;n!==null&&Object.assign(o.telegram,MV(n));let r=v.value;r!==null&&Object.assign(o.host,PV(r));let i=y.value;i!==null&&Object.assign(o.backups,FV(i));let a=m.value;a!==null&&(o.defaults.enabled=a.enabled,o.defaults.autostart=a.autostart,o.defaults.bind=a.bind,o.defaults.onPortConflict=a.onPortConflict,o.defaults.logBufferLines=a.logBufferLines,o.defaults.restart={...a.restart},o.defaults.health=OV(a.health),o.defaults.stop={...a.stop}),le.value=!0}Ar([p,m,h,g,f],()=>{HV({hydrated:le.value,liveAvailable:p.value!==null,changedCount:w.value})&&ue()},{immediate:!0});async function de(){d.value=null;try{f.value=await dj()}catch(e){d.value=e instanceof Error?e.message:String(e)}}ta(()=>{de()});async function fe(){let e=C.value;if(!(Object.keys(e).length===0||c.value)){c.value=!0,l.value=null,u.value=null;try{let t=await i.saveSettings(e);if(!t){l.value=i.lastError.value??`The settings could not be saved.`;return}u.value=`Settings saved.`,a.success(`Settings saved`),await de();let n=await XV(t);n===null?t.rebinding&&(u.value=`Settings saved — the panel is moving to a new address.`):(u.value=null,l.value=n)}finally{c.value=!1}}}function pe(){l.value=null,u.value=null,ue()}function me(){v.value!==null&&Object.assign(o.host,PV(v.value))}function he(){y.value!==null&&Object.assign(o.backups,FV(y.value))}function ge(){if(p.value!==null){let e=jV(p.value);o.control.label=e.label,o.control.port=e.port,o.control.host=e.host,o.control.openBrowser=e.openBrowser}}function _e(){p.value!==null&&Object.assign(o.auth,AV(p.value.auth))}function ve(){let e=m.value;e!==null&&(o.defaults.enabled=e.enabled,o.defaults.autostart=e.autostart,o.defaults.bind=e.bind,o.defaults.onPortConflict=e.onPortConflict,o.defaults.logBufferLines=e.logBufferLines,o.defaults.restart={...e.restart},o.defaults.health=OV(e.health),o.defaults.stop={...e.stop})}function ye(){h.value!==null&&Object.assign(o.logs,h.value)}function be(){g.value!==null&&Object.assign(o.telegram,MV(g.value))}function xe(){p.value!==null&&(o.control.tlsEnabled=p.value.tls.enabled)}function Se(e){nr(()=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})})}function Ce(e){s.value=e,n.query.section!==e&&r.replace({query:{...n.query,section:e}}),Se(e)}Ar(()=>n.query.section,e=>{let n=typeof e==`string`?e:``;t.some(e=>e.id===n)&&(s.value=n,Se(n))},{immediate:!0});let we=null;return ta(()=>{we=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];t!==void 0&&t.target.id.length>0&&(s.value=t.target.id)},{rootMargin:`-72px 0px -62% 0px`,threshold:0});for(let e of t){let t=document.getElementById(e.id);t&&we.observe(t)}}),ia(()=>we?.disconnect()),(e,n)=>{let r=fa(`PasswordSection`);return L(),R(I,null,[B(`div`,HU,[B(`div`,UU,[n[24]||=B(`header`,{class:`mb-5`},[B(`h1`,{class:`text-xl font-semibold tracking-tight text-ink`},` Settings `),B(`p`,{class:`mt-1 text-xs text-muted`},` Listener, access, defaults, retention, alerts, backups and paths for this panel. `)],-1),M(i).configError.value?(L(),z(CV,{key:0,tone:`danger`,title:`The config file could not be read`,class:`mb-4`},{default:N(()=>[H(k(M(i).configError.value),1)]),_:1})):d.value?(L(),z(CV,{key:1,tone:`warn`,title:`Some file-only values could not be loaded`,class:`mb-4`},{default:N(()=>[H(k(d.value),1)]),_:1})):U(``,!0),B(`div`,WU,[B(`nav`,GU,[B(`ul`,KU,[(L(),R(I,null,va(t,e=>B(`li`,{key:e.id},[B(`button`,{type:`button`,"aria-current":s.value===e.id?`true`:void 0,class:O(M(Q)(`-ml-px block w-full border-l-2 py-1.5 pl-3 text-left text-xs transition-colors duration-150`,s.value===e.id?`border-accent font-medium text-accent`:`border-transparent text-muted hover:border-line hover:text-ink`)),onClick:t=>Ce(e.id)},k(e.title),11,qU)])),64))])]),B(`div`,JU,[B(`section`,YU,[n[13]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Listener `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Where the control panel listens and how it announces itself. `)],-1),V($H,{control:o.control,"onUpdate:control":n[0]||=e=>o.control=e,view:p.value,dirty:ne.value,onReset:ge},null,8,[`control`,`view`,`dirty`])]),B(`section`,XU,[n[14]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Authentication `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Who may sign in, and how a session is trusted. `)],-1),V($V,{auth:o.auth,"onUpdate:auth":n[1]||=e=>o.auth=e,view:p.value,dirty:ie.value,onReset:_e},null,8,[`auth`,`view`,`dirty`])]),B(`section`,ZU,[n[15]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Password `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` The one credential that guards this panel. `)],-1),V(r,{view:p.value},null,8,[`view`])]),B(`section`,QU,[n[16]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Server defaults `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Applied to every entry that does not set its own value. `)],-1),V(IH,{defaults:o.defaults,"onUpdate:defaults":n[2]||=e=>o.defaults=e,dirty:ae.value,onReset:ve},null,8,[`defaults`,`dirty`])]),B(`section`,$U,[n[17]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Logs `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` How much output is kept on disk and for how long. `)],-1),V(iU,{logs:o.logs,"onUpdate:logs":n[3]||=e=>o.logs=e,"logs-dir":M(i).appState.value?.logsDir??null,dirty:oe.value,onReset:ye},null,8,[`logs`,`logs-dir`,`dirty`])]),B(`section`,eW,[n[18]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Notifications `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Crash and health alerts sent to a Telegram chat. `)],-1),V(fU,{telegram:o.telegram,"onUpdate:telegram":n[4]||=e=>o.telegram=e,status:g.value,dirty:se.value,onReset:be},null,8,[`telegram`,`status`,`dirty`])]),B(`section`,tW,[n[19]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Host vitals `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Alert thresholds for this machine's own resources. `)],-1),V(zH,{host:o.host,"onUpdate:host":n[5]||=e=>o.host=e,config:v.value,alerts:_.value,dirty:ce.value,onReset:me},null,8,[`host`,`config`,`alerts`,`dirty`])]),B(`section`,nW,[n[20]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Backups `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Archives of config, secrets and declared data paths. `)],-1),V(PH,{form:o.backups,"onUpdate:form":n[6]||=e=>o.backups=e,state:x.value,policy:y.value,"config-path":S.value,dirty:D.value,onReset:he},null,8,[`form`,`state`,`policy`,`config-path`,`dirty`])]),B(`section`,rW,[n[21]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` TLS `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve the panel over HTTPS with your own certificate. `)],-1),V(VU,{"tls-enabled":o.control.tlsEnabled,"onUpdate:tlsEnabled":n[7]||=e=>o.control.tlsEnabled=e,view:p.value,dirty:re.value,onReset:xe},null,8,[`tls-enabled`,`view`,`dirty`])]),B(`section`,iW,[n[22]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Interface `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Serve your own panel UI instead of the stock one. `)],-1),V(qH,{label:o.control.label,"onUpdate:label":n[8]||=e=>o.control.label=e,ui:b.value,"label-dirty":ne.value,onChanged:de,onResetLabel:ge},null,8,[`label`,`ui`,`label-dirty`])]),B(`section`,aW,[n[23]||=B(`header`,{class:`mb-3`},[B(`h2`,{class:`text-lg font-semibold text-ink`},` Paths `),B(`p`,{class:`mt-0.5 text-xs text-muted`},` Where home-hosted keeps its files. `)],-1),V(yU,{"config-path":S.value,"data-root":M(i).appState.value?.dataRoot??null,"logs-dir":M(i).appState.value?.logsDir??null,"project-dir":M(i).appState.value?.projectDir??null,"panel-url":p.value?.url??null},null,8,[`config-path`,`data-root`,`logs-dir`,`project-dir`,`panel-url`])])])])]),B(`div`,oW,[B(`div`,sW,[B(`div`,cW,[B(`p`,lW,[w.value>0?(L(),R(`button`,{key:0,type:`button`,class:`rounded-control px-1 py-0.5 text-xs text-muted underline decoration-line underline-offset-2 hover:text-ink`,onClick:n[9]||=e=>E.value=!0},[B(`span`,uW,k(w.value),1),H(` field`+k(w.value===1?``:`s`)+` changed `,1)])):(L(),R(I,{key:1},[H(` No unsaved changes `)],64))]),l.value?(L(),R(`p`,dW,k(l.value),1)):u.value?(L(),R(`p`,fW,k(u.value),1)):U(``,!0)]),B(`div`,pW,[V($,{variant:`ghost`,disabled:w.value===0||c.value,onClick:pe},{default:N(()=>[...n[25]||=[H(` Discard changes `,-1)]]),_:1},8,[`disabled`]),V($,{variant:`primary`,disabled:w.value===0,loading:c.value,onClick:fe},{default:N(()=>[...n[26]||=[H(` Save settings `,-1)]]),_:1},8,[`disabled`,`loading`])])])])]),V(rL,{open:E.value,"onUpdate:open":n[12]||=e=>E.value=e,title:`Unsaved changes`,description:`What Save would write to servers.config.json.`,width:`w-[min(92vw,42rem)]`},{default:N(()=>[B(`div`,mW,[ee.value.length>0?(L(),R(`ul`,hW,[(L(!0),R(I,null,va(ee.value,e=>(L(),R(`li`,{key:e.path,class:`flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2 first:pt-0`},[B(`code`,gW,k(e.path),1),B(`span`,_W,k(te(e.from)),1),n[27]||=B(`span`,{class:`text-2xs text-faint`},`→`,-1),B(`span`,vW,k(te(e.to)),1)]))),128))])):(L(),R(`p`,yW,` Nothing to save. `))]),B(`footer`,bW,[V($,{size:`sm`,variant:`ghost`,onClick:n[10]||=e=>E.value=!1},{default:N(()=>[...n[28]||=[H(` Close `,-1)]]),_:1}),V($,{size:`sm`,variant:`primary`,disabled:ee.value.length===0||c.value,loading:c.value,onClick:n[11]||=e=>{fe(),E.value=!1}},{default:N(()=>[H(` Save `+k(ee.value.length)+` change`+k(ee.value.length===1?``:`s`),1)]),_:1},8,[`disabled`,`loading`])])]),_:1},8,[`open`])],64)}}}),SW=Sv({history:W_(),routes:[{path:`/`,name:`overview`,component:xB,meta:{title:`Overview`}},{path:`/servers`,name:`servers`,component:yV,meta:{title:`Servers`}},{path:`/servers/:id`,name:`server-detail`,component:pV,meta:{title:`Server`}},{path:`/logs`,name:`logs`,component:ML,meta:{title:`Logs`}},{path:`/settings`,name:`settings`,component:xW,meta:{title:`Settings`}},{path:`/login`,name:`login`,component:nI,meta:{title:`Sign in`}},{path:`/:pathMatch(.*)*`,redirect:`/`}]});SW.beforeEach(async e=>{let{session:t,refresh:n}=Vj();t.value===null&&await n();let r=t.value?.authRequired===!0,i=t.value?.authenticated===!0;return r&&!i&&e.name!==`login`?{name:`login`,query:e.fullPath===`/`?void 0:{next:e.fullPath}}:e.name===`login`&&(!r||i)?{name:`overview`}:!0}),yu(jF).use(SW).mount(`#app`);